[Android] Video player: set PiP when Activity is started

Geoffrey Métais git at videolan.org
Thu Mar 14 11:12:51 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 14 10:27:46 2019 +0100| [dbfc9a4e284410656e9ac753659022aa9a7f9056] | committer: Geoffrey Métais

Video player: set PiP when Activity is started

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

 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 149d7863b..f3678b1bb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -485,7 +485,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
     @TargetApi(Build.VERSION_CODES.O)
     public void switchToPopup() {
         final MediaWrapper mw = mService != null ? mService.getCurrentMediaWrapper() : null;
-        if (mw == null || !AndroidDevices.pipAllowed) return;
+        if (mw == null || !AndroidDevices.pipAllowed
+                || !getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;
         if (AndroidDevices.hasPiP) {
             if (AndroidUtil.isOOrLater) try {
                 final SurfaceView videoSurface = (SurfaceView) (mVideoLayout != null ? mVideoLayout.findViewById(R.id.surface_video) : null);
@@ -495,8 +496,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
             } catch (IllegalArgumentException e) { // Fallback with default parameters
                 //noinspection deprecation
                 enterPictureInPictureMode();
-            }
-            else {
+            } else {
                 //noinspection deprecation
                 enterPictureInPictureMode();
             }



More information about the Android mailing list