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

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


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

Video player: set PiP when Activity is started

(cherry picked from commit dbfc9a4e284410656e9ac753659022aa9a7f9056)

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

 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