[Android] Set dimensions according to surface size

Geoffrey Métais git at videolan.org
Fri Nov 15 16:53:22 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Nov 14 15:08:30 2019 +0100| [3a2b18bbbab3eb487df97dd52643d2eb7ed2ce1b] | committer: Geoffrey Métais

Set dimensions according to surface size

Do not get window size as reference, and do not change surface parent
size anymore

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

 libvlc/res/layout/vlc_video_layout.xml          |  6 ++++--
 libvlc/src/org/videolan/libvlc/VideoHelper.java | 10 ++--------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/libvlc/res/layout/vlc_video_layout.xml b/libvlc/res/layout/vlc_video_layout.xml
index 73cf5cd39..f2d04b6a1 100644
--- a/libvlc/res/layout/vlc_video_layout.xml
+++ b/libvlc/res/layout/vlc_video_layout.xml
@@ -13,7 +13,8 @@
         android:layout_height="match_parent"
         android:inflatedId="@+id/surface_video"
         android:layout="@layout/surface_view"
-        android:id="@+id/surface_stub" />
+        android:id="@+id/surface_stub"
+        android:layout_gravity="center"/>
 
     <ViewStub
         android:layout_width="1dp"
@@ -27,5 +28,6 @@
         android:layout_height="match_parent"
         android:layout="@layout/texture_view"
         android:inflatedId="@+id/texture_video"
-        android:id="@+id/texture_stub" />
+        android:id="@+id/texture_stub"
+        android:layout_gravity="center" />
 </FrameLayout>
diff --git a/libvlc/src/org/videolan/libvlc/VideoHelper.java b/libvlc/src/org/videolan/libvlc/VideoHelper.java
index 86b163a79..a33e8a414 100644
--- a/libvlc/src/org/videolan/libvlc/VideoHelper.java
+++ b/libvlc/src/org/videolan/libvlc/VideoHelper.java
@@ -195,8 +195,8 @@ class VideoHelper implements IVLCVout.OnNewVideoLayoutListener {
 
         // get screen size
         if (activity != null) {
-            sw = activity.getWindow().getDecorView().getWidth();
-            sh = activity.getWindow().getDecorView().getHeight();
+            sw = mVideoSurfaceFrame.getWidth();
+            sh = mVideoSurfaceFrame.getHeight();
         } else if (mDisplayManager != null && mDisplayManager.getPresentation() != null && mDisplayManager.getPresentation().getWindow() != null) {
             sw = mDisplayManager.getPresentation().getWindow().getDecorView().getWidth();
             sh = mDisplayManager.getPresentation().getWindow().getDecorView().getHeight();
@@ -296,12 +296,6 @@ class VideoHelper implements IVLCVout.OnNewVideoLayoutListener {
         mVideoSurface.setLayoutParams(lp);
         if (mSubtitlesSurface != null) mSubtitlesSurface.setLayoutParams(lp);
 
-        // set frame size (crop if necessary)
-        lp = mVideoSurfaceFrame.getLayoutParams();
-        lp.width = (int) Math.floor(dw);
-        lp.height = (int) Math.floor(dh);
-        mVideoSurfaceFrame.setLayoutParams(lp);
-
         mVideoSurface.invalidate();
         if (mSubtitlesSurface != null) mSubtitlesSurface.invalidate();
     }



More information about the Android mailing list