[Android] CustomPip: app reopen -> force VideoPlayerActivity
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 15:12:28 2024 +0200| [220898786d88522af2f4199b77b0bf1116b83093] | committer: Nicolas Pomepuy
CustomPip: app reopen -> force VideoPlayerActivity
To match the new behavior of forcing VideoPlayerActivity back to the
foreground when reopening the app with PiP running, pip is disabled,
leading to the removal of the popup, before reopening the activity
> https://code.videolan.org/videolan/vlc-android/commit/220898786d88522af2f4199b77b0bf1116b83093
---
application/vlc-android/src/org/videolan/vlc/StartActivity.kt | 1 +
.../vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 2fc3412c61..d655d4eed7 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -218,6 +218,7 @@ class StartActivity : FragmentActivity() {
if (target == R.id.ml_menu_last_playlist)
PlaybackService.loadLastAudio(this)
else if (service != null && service.isInPiPMode.value == true) {
+ service.isInPiPMode.value = false
val startIntent = Intent(this, VideoPlayerActivity::class.java)
startIntent.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
startActivity(startIntent)
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 44be8dd6b6..486e86c44b 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
@@ -38,6 +38,7 @@ import android.view.View
import android.widget.ImageView
import androidx.core.app.NotificationCompat
import androidx.core.view.GestureDetectorCompat
+import androidx.lifecycle.Observer
import org.videolan.libvlc.MediaPlayer
import org.videolan.libvlc.interfaces.IMedia
import org.videolan.libvlc.interfaces.IVLCVout
@@ -67,6 +68,10 @@ class PopupManager constructor(private val service: PlaybackService) : PlaybackS
private lateinit var closeButton: ImageView
private lateinit var playPauseButton: ImageView
private val alwaysOn: Boolean = Settings.getInstance(service).getBoolean(POPUP_KEEPSCREEN, false)
+ var observer: Observer<Boolean> = Observer {
+ if (!it) {
+ removePopup()
+ }}
private val handler = object : Handler(Looper.getMainLooper()) {
override fun handleMessage(msg: Message) {
@@ -78,6 +83,7 @@ class PopupManager constructor(private val service: PlaybackService) : PlaybackS
}
fun removePopup() {
+ service.isInPiPMode.removeObserver(observer)
hideNotification()
val view = rootView ?: return
service.removeCallback(this)
@@ -89,6 +95,8 @@ class PopupManager constructor(private val service: PlaybackService) : PlaybackS
fun showPopup() {
service.addCallback(this)
+ service.isInPiPMode.value = true
+ service.isInPiPMode.observeForever(observer)
val li = LayoutInflater.from(service.applicationContext)
rootView = li.inflate(R.layout.video_popup, null) as PopupLayout
val view = rootView ?: return
@@ -231,6 +239,7 @@ class PopupManager constructor(private val service: PlaybackService) : PlaybackS
removePopup()
if (service.hasMedia() && !service.isPlaying)
service.currentMediaWrapper?.let { mw -> mw.flags = MediaWrapper.MEDIA_PAUSED }
+ service.isInPiPMode.value = false
service.switchToVideo()
}
More information about the Android
mailing list