[Android] Video player: Fix PiP aspect ratio
Geoffrey Métais
git at videolan.org
Wed Dec 4 13:42:03 CET 2019
vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey at videolan.org> | Wed Dec 4 13:36:59 2019 +0100| [8236871b51f34a52b5fbd9a3d946daa016c0e599] | committer: Nicolas Pomepuy
Video player: Fix PiP aspect ratio
Fix #1105
(cherry picked from commit 2d1c3754c4bda49e1c0c9740c896ba2d24765ca5)
> https://code.videolan.org/videolan/vlc-android/commit/8236871b51f34a52b5fbd9a3d946daa016c0e599
---
.../org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index ba08d61e9..adf873ab3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -625,19 +625,14 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
if (AndroidDevices.hasPiP && !forceLegacy) {
if (AndroidUtil.isOOrLater)
try {
- videoLayout?.findViewById<View>(R.id.surface_video)?.run {
- val height = if (height != 0) height else mw.height
- val width = Math.min(if (width != 0) width else mw.width, (height * 2.39f).toInt())
- enterPictureInPictureMode(PictureInPictureParams.Builder().setAspectRatio(Rational(width, height)).build())
- }
+ val track = service?.playlistManager?.player?.mediaplayer?.currentVideoTrack
+ ?: return
+ val ar = Rational(track.width.coerceAtMost((track.height * 2.39f).toInt()), track.height)
+ enterPictureInPictureMode(PictureInPictureParams.Builder().setAspectRatio(ar).build())
} catch (e: IllegalArgumentException) { // Fallback with default parameters
-
enterPictureInPictureMode()
}
- else {
-
- enterPictureInPictureMode()
- }
+ else enterPictureInPictureMode()
} else {
if (Permissions.canDrawOverlays(this)) {
switchingView = true
@@ -645,8 +640,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
if (service?.isPlaying != true) mw.addFlags(AbstractMediaWrapper.MEDIA_PAUSED)
cleanUI()
exitOK()
- } else
- Permissions.checkDrawOverlaysPermission(this)
+ } else Permissions.checkDrawOverlaysPermission(this)
}
}
More information about the Android
mailing list