diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index dad093817..9730a0244 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -512,11 +512,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { super.onDestroy() try { // disable the auto PiP mode for SDK >= 32 - if (SDK_INT >= Build.VERSION_CODES.S) { - activity?.setPictureInPictureParams( - PictureInPictureParams.Builder().setAutoEnterEnabled(false).build() - ) - } + disableAutoPiP() saveWatchPosition() @@ -535,6 +531,15 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { } } + private fun disableAutoPiP() { + if (SDK_INT < Build.VERSION_CODES.S) { + return + } + activity?.setPictureInPictureParams( + PictureInPictureParams.Builder().setAutoEnterEnabled(false).build() + ) + } + // save the watch position if video isn't finished and option enabled private fun saveWatchPosition() { if (!PlayerHelper.watchPositionsEnabled) return @@ -848,7 +853,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { ) { transitioning = true // check whether autoplay is enabled - if (binding.player.autoplayEnabled) playNextVideo() + playNextVideo() } when (playbackState) { @@ -873,6 +878,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { query { Database.watchPositionDao().insertAll(watchPosition) } + disableAutoPiP() } // listen for the stop button in the notification @@ -1463,8 +1469,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { val backgroundModeRunning = isServiceRunning(requireContext(), BackgroundMode::class.java) - return viewModel.isFullscreen.value == true && - (exoPlayer.isPlaying || !backgroundModeRunning) + return exoPlayer.isPlaying && !backgroundModeRunning } private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean {