mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
fix(pip): handle two autoPip views
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user