mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-05-23 07:06:29 +00:00
fix(android): disable controls when in PiP
This commit is contained in:
+6
-1
@@ -91,6 +91,7 @@ class FullscreenVideoFragment(private val videoView: VideoView) : Fragment() {
|
||||
requireActivity().isInPictureInPictureMode
|
||||
|
||||
if (isInPictureInPictureMode) {
|
||||
// Disable controls in PiP mode - media session creates its own controls for PiP
|
||||
videoView.playerView.useController = false
|
||||
} else {
|
||||
videoView.playerView.useController = videoView.useController
|
||||
@@ -197,7 +198,11 @@ class FullscreenVideoFragment(private val videoView: VideoView) : Fragment() {
|
||||
|
||||
restoreSystemUI()
|
||||
|
||||
if (videoView.useController == false) {
|
||||
// Keep controls disabled if in PiP mode - media session creates its own controls for PiP
|
||||
val isInPictureInPictureMode = requireActivity().isInPictureInPictureMode
|
||||
if (isInPictureInPictureMode) {
|
||||
videoView.playerView.useController = false
|
||||
} else if (videoView.useController == false) {
|
||||
videoView.playerView.useController = false
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -50,6 +50,9 @@ class PictureInPictureHelperFragment(private val videoView: VideoView) : Fragmen
|
||||
}
|
||||
|
||||
if (currentPipVideo == videoView) {
|
||||
// Disable controls immediately when entering PiP - media session creates its own controls for PiP
|
||||
videoView.playerView.useController = false
|
||||
|
||||
// If we're currently in fullscreen, exit it first to prevent parent conflicts
|
||||
if (videoView.isInFullscreen) {
|
||||
try {
|
||||
|
||||
@@ -320,10 +320,9 @@ class VideoView @JvmOverloads constructor(
|
||||
|
||||
Log.d("ReactNativeVideo", "Hiding root content views for PiP video nitroId: $nitroId")
|
||||
|
||||
// Remove playerView from parent
|
||||
// In PiP mode, we don't want to show the controller
|
||||
// Controls are handled by System if we have MediaSession
|
||||
// In PiP mode, disable controls immediately - media session creates its own controls for PiP
|
||||
playerView.useController = false
|
||||
|
||||
playerView.setBackgroundColor(Color.BLACK)
|
||||
playerView.setShutterBackgroundColor(Color.BLACK)
|
||||
|
||||
@@ -412,6 +411,11 @@ class VideoView @JvmOverloads constructor(
|
||||
return try {
|
||||
events.willEnterPictureInPicture?.let { it() }
|
||||
|
||||
// Disable controls before entering PiP - media session creates its own controls for PiP
|
||||
runOnMainThread {
|
||||
playerView.useController = false
|
||||
}
|
||||
|
||||
val success = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val params = createPictureInPictureParams(this)
|
||||
safeEnterPictureInPictureMode(params)
|
||||
@@ -447,6 +451,9 @@ class VideoView @JvmOverloads constructor(
|
||||
|
||||
events.willExitPictureInPicture?.let { it() }
|
||||
|
||||
// Restore controls when exiting PiP - they were disabled because media session handles PiP controls
|
||||
playerView.useController = useController
|
||||
|
||||
if (movedToRootForPiP) {
|
||||
restoreRootContentViews()
|
||||
} else {
|
||||
@@ -471,6 +478,10 @@ class VideoView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
events.willExitPictureInPicture?.let { it() }
|
||||
|
||||
// Restore controls when exiting PiP - they were disabled because media session handles PiP controls
|
||||
playerView.useController = useController
|
||||
|
||||
if (movedToRootForPiP) {
|
||||
restoreRootContentViews()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user