From 5e643209bc2b233cdec2b5b830164edaf0b2b4f3 Mon Sep 17 00:00:00 2001 From: Duncan McNamara Date: Wed, 16 Oct 2024 15:39:52 +0200 Subject: [PATCH] CustomPiP: fix popup killed when leaving the app When leaving the app with custom pip the VideoPlayerActivity onStop() is called which sets isInPiPMode to false which kills the popup. onStop isn't called with the system's pip. To fix this, just check if service.isPlayingPopup is true, it's false for system's pip. --- .../vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt | 3 +++ .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt index 486e86c44..d2a19514b 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt @@ -84,6 +84,9 @@ class PopupManager constructor(private val service: PlaybackService) : PlaybackS fun removePopup() { service.isInPiPMode.removeObserver(observer) + // If the popup is killed from the x button, isInPiPMode will still be true + // and when reopening the app will restart the video player + service.isInPiPMode.value = false hideNotification() val view = rootView ?: return service.removeCallback(this) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt index 89746c4fe..ebe0d82cb 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt @@ -959,7 +959,8 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, cleanUI() stopPlayback() service?.playlistManager?.videoStatsOn?.postValue(false) - if (isInteractive) + val isPlayingPopup = service?.isPlayingPopup ?: false + if (isInteractive && !isPlayingPopup) service?.isInPiPMode?.value = false if (savedTime != -1L) settings.putSingle(VIDEO_RESUME_TIME, savedTime)