[Android] Ensure current media is not null for popup switch

Geoffrey Métais git at videolan.org
Wed Oct 11 16:48:00 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Oct 11 16:47:35 2017 +0200| [514f62df147aa50fd34f0a4719f2ff8bcf6ed303] | committer: Geoffrey Métais

Ensure current media is not null for popup switch

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

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 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 49c150565..5c46f828e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -591,11 +591,14 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
     @TargetApi(Build.VERSION_CODES.N)
     public void switchToPopup() {
+        final MediaWrapper mw = mService.getCurrentMediaWrapper();
+        if (mw == null)
+            return;
         if (AndroidDevices.hasPiP) {
             if (AndroidUtil.isOOrLater)
                 try {
-                    final int height = mVideoHeight != 0 ? mVideoHeight : mService.getCurrentMediaWrapper().getHeight();
-                    final int width = Math.min(mVideoWidth != 0 ? mVideoWidth : mService.getCurrentMediaWrapper().getWidth(), (int) (height*2.39f));
+                    final int height = mVideoHeight != 0 ? mVideoHeight : mw.getHeight();
+                    final int width = Math.min(mVideoWidth != 0 ? mVideoWidth : mw.getWidth(), (int) (height*2.39f));
                     enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(new Rational(width, height)).build());
                 } catch (IllegalArgumentException e) { // Fallback with default parameters
                     enterPictureInPictureMode();
@@ -607,9 +610,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             if (Permissions.canDrawOverlays(this)) {
                 mSwitchingView = true;
                 mSwitchToPopup = true;
-                final MediaWrapper mw = mService.getCurrentMediaWrapper();
-                if (mw == null)
-                    return;
                 if (mService != null && !mService.isPlaying())
                     mw.addFlags(MediaWrapper.MEDIA_PAUSED);
                 cleanUI();



More information about the Android mailing list