Compare commits

..
2 Commits
Author SHA1 Message Date
zoriya 9fea0949bd fix(pip): handle two autoPip views 2026-08-04 09:47:10 +02:00
zoriya 9945f2b339 fix(compil): oups, compil failed 2026-08-03 20:32:14 +02:00
3 changed files with 15 additions and 19 deletions
@@ -227,13 +227,15 @@ class OmniPlayer(
.build()
}
fun setVideoView(surfaceView: android.view.SurfaceView?) {
fun setVideoView(surfaceView: android.view.SurfaceView) {
runOnMainThread {
if (surfaceView == null) {
localPlayer.clearVideoSurface()
} else {
localPlayer.setVideoSurfaceView(surfaceView)
}
localPlayer.setVideoSurfaceView(surfaceView)
}
}
fun clearVideoView(surfaceView: android.view.SurfaceView) {
runOnMainThread {
localPlayer.clearVideoSurfaceView(surfaceView)
}
}
@@ -298,7 +300,7 @@ class OmniPlayer(
override val renditions by mainThreadProperty {
val group =
player.currentTracks.groups.firstOrNull { it.isSelected && it.type == C.TRACK_TYPE_VIDEO }
?: return emptyArray()
?: return@mainThreadProperty emptyArray<Rendition>()
val currentIndex = when {
isAutoQuality -> {
@@ -326,7 +328,7 @@ class OmniPlayer(
)
)
}
return result.toTypedArray()
return@mainThreadProperty result.toTypedArray()
}
override var isAutoQuality by mainThreadProperty {
@@ -478,9 +480,6 @@ class OmniPlayer(
return tracks.associateBy { it.id }
}
private fun getRenditions(): Array<Rendition> {
}
override fun selectRendition(rendition: Rendition?) {
runOnMainThreadSync {
if (rendition == null) {
@@ -154,15 +154,11 @@ class OmniView(val context: ThemedReactContext) :
val curPip = activeView.get()
when {
autoPip == true && curPip == this -> {}
autoPip == true && curPip == null -> {
autoPip == true -> {
activeView = WeakReference(this)
updatePictureInPictureParams()
}
autoPip == true -> {
throw Error("Only one OmniView can have `autoPip` set at a time.")
}
autoPip == false && curPip == this -> {
activeView = WeakReference(null)
clearPictureInPictureParams()
@@ -180,7 +176,7 @@ class OmniView(val context: ThemedReactContext) :
}
boundPlayer?.localPlayer?.removeListener(this)
boundPlayer?.setVideoView(null)
boundPlayer?.clearVideoView(surfaceView)
boundPlayer = omniPlayer
omniPlayer.localPlayer.addListener(this)
@@ -206,7 +202,7 @@ class OmniView(val context: ThemedReactContext) :
val omniPlayer = player as? OmniPlayer ?: return
boundPlayer?.localPlayer?.removeListener(this)
omniPlayer.setVideoView(null)
omniPlayer.clearVideoView(surfaceView)
boundPlayer = null
}
@@ -414,6 +410,6 @@ class OmniView(val context: ThemedReactContext) :
override fun surfaceDestroyed(holder: SurfaceHolder) {
surfaceReady = false
surfaceView.removeCallbacks(rebuildRunnable)
boundPlayer?.setVideoView(null)
boundPlayer?.clearVideoView(surfaceView)
}
}
@@ -894,6 +894,7 @@ class VlcPlayer(ctx: Context) :
}
override fun clearVideoSurfaceView(surfaceView: SurfaceView?) {
if (surfaceView != null && boundSurfaceView !== surfaceView) return
clearVideoSurface()
}