mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
fix(pip): fix wrong player source
This commit is contained in:
@@ -540,6 +540,15 @@ class OmniPlayerService : MediaSessionService() {
|
||||
triggerNotificationUpdate()
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
val current = OmniPlayer.notificationPlayer
|
||||
if (current != null && ::mediaSession.isInitialized && mediaSession.player !== current) {
|
||||
player = current
|
||||
mediaSession.player = current
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
||||
private fun createImmediateNotification(): Notification {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(
|
||||
|
||||
@@ -185,8 +185,7 @@ class OmniView(val context: ThemedReactContext) :
|
||||
return
|
||||
}
|
||||
|
||||
val omniPlayer = boundPlayer ?: return
|
||||
if (!omniPlayer.isPlaying) {
|
||||
if (boundPlayer == null || boundPlayer?.localPlayer?.isPlaying != true) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -220,7 +219,7 @@ class OmniView(val context: ThemedReactContext) :
|
||||
val autoEnterEnabled =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||
autoPip == true &&
|
||||
boundPlayer?.isPlaying == true
|
||||
boundPlayer?.localPlayer?.isPlaying == true
|
||||
activity.setPictureInPictureParams(buildPipParams(autoEnterEnabled))
|
||||
}
|
||||
|
||||
@@ -270,7 +269,7 @@ class OmniView(val context: ThemedReactContext) :
|
||||
if (context.currentActivity !== activity || autoPip != true || boundPlayer == null) {
|
||||
return
|
||||
}
|
||||
if (!afterEnteredPip && boundPlayer?.isPlaying != true) return
|
||||
if (!afterEnteredPip && boundPlayer?.localPlayer?.isPlaying != true) return
|
||||
isolateUiForPip(activity)
|
||||
}
|
||||
|
||||
@@ -337,7 +336,7 @@ class OmniView(val context: ThemedReactContext) :
|
||||
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||
surfaceReady = true
|
||||
boundPlayer?.setVideoView(surfaceView)
|
||||
if (boundPlayer?.isPlaying == true) pendingVideoRebuild = true
|
||||
if (boundPlayer?.localPlayer?.isPlaying == true) pendingVideoRebuild = true
|
||||
updatePictureInPictureParams()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user