From a3e0c40a0f99f717bc96a22ea01ab0880e475bac Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 27 Jan 2023 16:29:59 +0100 Subject: [PATCH 1/2] Don't kill the app when closing through PiP --- .../com/github/libretube/ui/fragments/PlayerFragment.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 1e2e3b0d0..923885155 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 @@ -1439,10 +1439,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { updateCaptionsLanguage(null) } else if (lifecycle.currentState == Lifecycle.State.CREATED) { // close button got clicked in PiP mode - // destroying the fragment, player and notification - onDestroy() - // finish the activity - activity?.finishAndRemoveTask() + // pause the video and keep the app alive + exoPlayer.pause() } else { // enable exoPlayer controls again exoPlayerView.useController = true From 34c0d8d72e2dcb9a7b69b85bae32258fc1301363 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 27 Jan 2023 16:32:45 +0100 Subject: [PATCH 2/2] Fix unresponsive screen when closing through PiP --- .../com/github/libretube/ui/fragments/PlayerFragment.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 923885155..e62bc92d2 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 @@ -1437,11 +1437,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { viewModel.isFullscreen.value = false updateCaptionsLanguage(null) - } else if (lifecycle.currentState == Lifecycle.State.CREATED) { + } else { // close button got clicked in PiP mode // pause the video and keep the app alive - exoPlayer.pause() - } else { + if (lifecycle.currentState == Lifecycle.State.CREATED) exoPlayer.pause() + // enable exoPlayer controls again exoPlayerView.useController = true