[Android] Limit aspect ratio in PiP mode

Geoffrey Métais git at videolan.org
Wed Oct 11 10:31:40 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Oct 11 10:03:29 2017 +0200| [eb40d586e64bdf18a438ddeabcd0242340ed0fb3] | committer: Geoffrey Métais

Limit aspect ratio in PiP mode

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

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

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 ff31c4ab7..3e896b6ff 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -594,7 +594,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         if (AndroidDevices.hasPiP) {
             if (AndroidUtil.isOOrLater)
                 try {
-                    enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(new Rational(mVideoWidth, mVideoHeight)).build());
+                    final int height = mVideoHeight != 0 ? mVideoHeight : mService.getCurrentMediaWrapper().getHeight();
+                    final int width = Math.min(mVideoWidth != 0 ? mVideoWidth : mService.getCurrentMediaWrapper().getWidth(), (int) (height*2.39f));
+                    enterPictureInPictureMode(new PictureInPictureParams.Builder().setAspectRatio(new Rational(width, height)).build());
                 } catch (IllegalArgumentException e) { // Fallback with default parameters
                     enterPictureInPictureMode();
                 }



More information about the Android mailing list