[Android] Pip: add isInPiPMode LiveData to PlaybackService

Duncan McNamara git at videolan.org
Wed Jun 26 12:44:09 UTC 2024


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Jun 25 13:41:39 2024 +0200| [20ddc79c91e7bcf078a07ac0595cb29b4e0b8312] | committer: Nicolas Pomepuy

Pip: add isInPiPMode LiveData to PlaybackService

This is to be able to check when reopening the app if
pip is running

> https://code.videolan.org/videolan/vlc-android/commit/20ddc79c91e7bcf078a07ac0595cb29b4e0b8312
---

 application/vlc-android/src/org/videolan/vlc/PlaybackService.kt        | 2 ++
 .../vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index da08e7641d..df24f2b28d 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -224,6 +224,8 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
     var sleepTimerInterval = 0L
     private var mediaEndReached = false
 
+    var isInPiPMode: MutableLiveData<Boolean> = MutableLiveData(false)
+
     // Playback management
     internal lateinit var mediaSession: MediaSessionCompat
 
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 3fb3813f8e..debd4b2a81 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
@@ -1712,7 +1712,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
     }
 
     override fun isInPictureInPictureMode(): Boolean {
-        return AndroidUtil.isNougatOrLater && super.isInPictureInPictureMode()
+        return service?.isInPiPMode?.value ?: false
     }
 
     override fun setPictureInPictureParams(params: PictureInPictureParams) {
@@ -1725,6 +1725,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
 
     override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
         super.onPictureInPictureModeChanged(isInPictureInPictureMode)
+        service?.isInPiPMode?.value = isInPictureInPictureMode
         service?.mediaplayer?.updateVideoSurfaces()
     }
 



More information about the Android mailing list