mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fea0949bd | ||
|
|
9945f2b339 |
@@ -227,13 +227,15 @@ class OmniPlayer(
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setVideoView(surfaceView: android.view.SurfaceView?) {
|
fun setVideoView(surfaceView: android.view.SurfaceView) {
|
||||||
runOnMainThread {
|
runOnMainThread {
|
||||||
if (surfaceView == null) {
|
localPlayer.setVideoSurfaceView(surfaceView)
|
||||||
localPlayer.clearVideoSurface()
|
}
|
||||||
} else {
|
}
|
||||||
localPlayer.setVideoSurfaceView(surfaceView)
|
|
||||||
}
|
fun clearVideoView(surfaceView: android.view.SurfaceView) {
|
||||||
|
runOnMainThread {
|
||||||
|
localPlayer.clearVideoSurfaceView(surfaceView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +300,7 @@ class OmniPlayer(
|
|||||||
override val renditions by mainThreadProperty {
|
override val renditions by mainThreadProperty {
|
||||||
val group =
|
val group =
|
||||||
player.currentTracks.groups.firstOrNull { it.isSelected && it.type == C.TRACK_TYPE_VIDEO }
|
player.currentTracks.groups.firstOrNull { it.isSelected && it.type == C.TRACK_TYPE_VIDEO }
|
||||||
?: return emptyArray()
|
?: return@mainThreadProperty emptyArray<Rendition>()
|
||||||
|
|
||||||
val currentIndex = when {
|
val currentIndex = when {
|
||||||
isAutoQuality -> {
|
isAutoQuality -> {
|
||||||
@@ -326,7 +328,7 @@ class OmniPlayer(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return result.toTypedArray()
|
return@mainThreadProperty result.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
override var isAutoQuality by mainThreadProperty {
|
override var isAutoQuality by mainThreadProperty {
|
||||||
@@ -478,9 +480,6 @@ class OmniPlayer(
|
|||||||
return tracks.associateBy { it.id }
|
return tracks.associateBy { it.id }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRenditions(): Array<Rendition> {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun selectRendition(rendition: Rendition?) {
|
override fun selectRendition(rendition: Rendition?) {
|
||||||
runOnMainThreadSync {
|
runOnMainThreadSync {
|
||||||
if (rendition == null) {
|
if (rendition == null) {
|
||||||
|
|||||||
@@ -154,15 +154,11 @@ class OmniView(val context: ThemedReactContext) :
|
|||||||
val curPip = activeView.get()
|
val curPip = activeView.get()
|
||||||
when {
|
when {
|
||||||
autoPip == true && curPip == this -> {}
|
autoPip == true && curPip == this -> {}
|
||||||
autoPip == true && curPip == null -> {
|
autoPip == true -> {
|
||||||
activeView = WeakReference(this)
|
activeView = WeakReference(this)
|
||||||
updatePictureInPictureParams()
|
updatePictureInPictureParams()
|
||||||
}
|
}
|
||||||
|
|
||||||
autoPip == true -> {
|
|
||||||
throw Error("Only one OmniView can have `autoPip` set at a time.")
|
|
||||||
}
|
|
||||||
|
|
||||||
autoPip == false && curPip == this -> {
|
autoPip == false && curPip == this -> {
|
||||||
activeView = WeakReference(null)
|
activeView = WeakReference(null)
|
||||||
clearPictureInPictureParams()
|
clearPictureInPictureParams()
|
||||||
@@ -180,7 +176,7 @@ class OmniView(val context: ThemedReactContext) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
boundPlayer?.localPlayer?.removeListener(this)
|
boundPlayer?.localPlayer?.removeListener(this)
|
||||||
boundPlayer?.setVideoView(null)
|
boundPlayer?.clearVideoView(surfaceView)
|
||||||
boundPlayer = omniPlayer
|
boundPlayer = omniPlayer
|
||||||
omniPlayer.localPlayer.addListener(this)
|
omniPlayer.localPlayer.addListener(this)
|
||||||
|
|
||||||
@@ -206,7 +202,7 @@ class OmniView(val context: ThemedReactContext) :
|
|||||||
|
|
||||||
val omniPlayer = player as? OmniPlayer ?: return
|
val omniPlayer = player as? OmniPlayer ?: return
|
||||||
boundPlayer?.localPlayer?.removeListener(this)
|
boundPlayer?.localPlayer?.removeListener(this)
|
||||||
omniPlayer.setVideoView(null)
|
omniPlayer.clearVideoView(surfaceView)
|
||||||
boundPlayer = null
|
boundPlayer = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,6 +410,6 @@ class OmniView(val context: ThemedReactContext) :
|
|||||||
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||||
surfaceReady = false
|
surfaceReady = false
|
||||||
surfaceView.removeCallbacks(rebuildRunnable)
|
surfaceView.removeCallbacks(rebuildRunnable)
|
||||||
boundPlayer?.setVideoView(null)
|
boundPlayer?.clearVideoView(surfaceView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -894,6 +894,7 @@ class VlcPlayer(ctx: Context) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun clearVideoSurfaceView(surfaceView: SurfaceView?) {
|
override fun clearVideoSurfaceView(surfaceView: SurfaceView?) {
|
||||||
|
if (surfaceView != null && boundSurfaceView !== surfaceView) return
|
||||||
clearVideoSurface()
|
clearVideoSurface()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user