[Android] Add a tip when changing the aspect ratio in the video player

Nicolas Pomepuy git at videolan.org
Thu Feb 24 11:14:28 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Feb 23 15:48:38 2022 +0100| [da27d742232cd4b52300bce3cae7b364f8dca845] | committer: Nicolas Pomepuy

Add a tip when changing the aspect ratio in the video player

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

 .../src/main/res/drawable/video_list_length_bg.xml |  2 +-
 .../resources/src/main/res/values/strings.xml      |  1 +
 .../vlc-android/res/layout/player_overlay_info.xml | 24 ++++++++++++++++++----
 .../vlc/gui/video/VideoPlayerOverlayDelegate.kt    | 12 ++++++++---
 .../vlc/gui/video/VideoPlayerResizeDelegate.kt     | 22 ++++++++++----------
 5 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/application/resources/src/main/res/drawable/video_list_length_bg.xml b/application/resources/src/main/res/drawable/video_list_length_bg.xml
index f48ce4905..1d8e2d67b 100644
--- a/application/resources/src/main/res/drawable/video_list_length_bg.xml
+++ b/application/resources/src/main/res/drawable/video_list_length_bg.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
     <solid android:color="@color/playerbackground" />
-    <corners android:radius="3dip" />
+    <corners android:radius="8dip" />
 </shape>
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index fa1212f95..409f97528 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -143,6 +143,7 @@
     <string name="surface_fit_screen">Fit screen</string>
     <string name="surface_fill">Fill</string>
     <string name="surface_original">Center</string>
+    <string name="resize_tip">Long tap for more options</string>
     <string name="unseekable_stream">Unseekable stream</string>
     <string name="refresh">Refresh</string>
     <string name="track_audio">Audio track</string>
diff --git a/application/vlc-android/res/layout/player_overlay_info.xml b/application/vlc-android/res/layout/player_overlay_info.xml
index 0edbba271..7f2da4511 100644
--- a/application/vlc-android/res/layout/player_overlay_info.xml
+++ b/application/vlc-android/res/layout/player_overlay_info.xml
@@ -4,18 +4,34 @@
         android:id="@+id/player_overlay_info"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:orientation="horizontal"
         android:background="@drawable/video_list_length_bg"
-        android:visibility="invisible">
+        android:gravity="center_horizontal"
+        android:orientation="vertical"
+        android:visibility="invisible"
+        tools:visibility="visible">
 
     <TextView
             android:id="@+id/player_overlay_textinfo"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:paddingLeft="10dp"
-            android:paddingRight="10dp"
             android:gravity="center"
+            android:paddingLeft="16dp"
+            android:paddingRight="16dp"
             android:textColor="@color/white"
             android:textSize="36sp"
             tools:text="Audio delay\n0ms" />
+
+    <TextView
+            android:id="@+id/player_overlay_subtextinfo"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_marginBottom="8dp"
+            android:gravity="center"
+            android:paddingLeft="16dp"
+            android:paddingRight="16dp"
+            android:textColor="@color/white"
+            android:textSize="12sp"
+            android:visibility="gone"
+            tools:text="Audio delay\n0ms"
+            tools:visibility="visible" />
 </LinearLayout>
\ No newline at end of file
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index d2184e1c7..65da4307e 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -94,6 +94,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
     private lateinit var volumeValueText: TextView
     private lateinit var playerVolumeProgress: PlayerProgress
     var info: TextView? = null
+    var subinfo: TextView? = null
     var overlayInfo: View? = null
     lateinit var playerUiContainer:RelativeLayout
 
@@ -173,8 +174,8 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
         })
     }
 
-    fun showInfo(@StringRes textId: Int, duration: Int) {
-        showInfo(player.getString(textId), duration)
+    fun showInfo(@StringRes textId: Int , duration: Int , at StringRes subtextId: Int = -1) {
+        showInfo(player.getString(textId), duration, if (subtextId == -1) "" else player.getString(subtextId))
     }
 
     /**
@@ -182,12 +183,16 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
      * @param text
      * @param duration
      */
-    fun showInfo(text: String, duration: Int) {
+    fun showInfo(text: String, duration: Int, subText:String = "") {
         if (player.isInPictureInPictureMode) return
         initInfoOverlay()
         overlayInfo.setVisible()
         info.setVisible()
         info?.text = text
+        if (subText.isNotBlank()) {
+            subinfo?.text = subText
+            subinfo.setVisible()
+        } else subinfo.setGone()
         player.handler.removeMessages(VideoPlayerActivity.FADE_OUT_INFO)
         player.handler.sendEmptyMessageDelayed(VideoPlayerActivity.FADE_OUT_INFO, duration.toLong())
     }
@@ -206,6 +211,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
             vsc.setVisible()
             // the info textView is not on the overlay
             info = player.findViewById(R.id.player_overlay_textinfo)
+            subinfo = player.findViewById(R.id.player_overlay_subtextinfo)
             overlayInfo = player.findViewById(R.id.player_overlay_info)
         }
     }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerResizeDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerResizeDelegate.kt
index 7619fe4bb..e8e51e7ed 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerResizeDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerResizeDelegate.kt
@@ -142,17 +142,17 @@ class VideoPlayerResizeDelegate(private val player: VideoPlayerActivity) {
     fun setVideoScale(scale: MediaPlayer.ScaleType) = player.service?.run {
         mediaplayer.videoScale = scale
         when (scale) {
-            MediaPlayer.ScaleType.SURFACE_BEST_FIT -> overlayDelegate.showInfo(R.string.surface_best_fit, 1000)
-            MediaPlayer.ScaleType.SURFACE_FIT_SCREEN -> overlayDelegate.showInfo(R.string.surface_fit_screen, 1000)
-            MediaPlayer.ScaleType.SURFACE_FILL -> overlayDelegate.showInfo(R.string.surface_fill, 1000)
-            MediaPlayer.ScaleType.SURFACE_16_9 -> overlayDelegate.showInfo("16:9", 1000)
-            MediaPlayer.ScaleType.SURFACE_4_3 -> overlayDelegate.showInfo("4:3", 1000)
-            MediaPlayer.ScaleType.SURFACE_16_10 -> overlayDelegate.showInfo("16:10", 1000)
-            MediaPlayer.ScaleType.SURFACE_221_1 -> overlayDelegate.showInfo("2.21:1", 1000)
-            MediaPlayer.ScaleType.SURFACE_235_1 -> overlayDelegate.showInfo("2.35:1", 1000)
-            MediaPlayer.ScaleType.SURFACE_239_1 -> overlayDelegate.showInfo("2.39:1", 1000)
-            MediaPlayer.ScaleType.SURFACE_5_4 -> overlayDelegate.showInfo("5:4", 1000)
-            MediaPlayer.ScaleType.SURFACE_ORIGINAL -> overlayDelegate.showInfo(R.string.surface_original, 1000)
+            MediaPlayer.ScaleType.SURFACE_BEST_FIT -> overlayDelegate.showInfo(R.string.surface_best_fit, 1000, R.string.resize_tip)
+            MediaPlayer.ScaleType.SURFACE_FIT_SCREEN -> overlayDelegate.showInfo(R.string.surface_fit_screen, 1000, R.string.resize_tip)
+            MediaPlayer.ScaleType.SURFACE_FILL -> overlayDelegate.showInfo(R.string.surface_fill, 1000, R.string.resize_tip)
+            MediaPlayer.ScaleType.SURFACE_16_9 -> overlayDelegate.showInfo("16:9", 1000, player.getString(R.string.resize_tip))
+            MediaPlayer.ScaleType.SURFACE_4_3 -> overlayDelegate.showInfo("4:3", 1000, player.getString(R.string.resize_tip))
+            MediaPlayer.ScaleType.SURFACE_16_10 -> overlayDelegate.showInfo("16:10", 1000, player.getString(R.string.resize_tip))
+            MediaPlayer.ScaleType.SURFACE_221_1 -> overlayDelegate.showInfo("2.21:1", 1000, player.getString(R.string.resize_tip))
+            MediaPlayer.ScaleType.SURFACE_235_1 -> overlayDelegate.showInfo("2.35:1", 1000, player.getString(R.string.resize_tip))
+            MediaPlayer.ScaleType.SURFACE_239_1 -> overlayDelegate.showInfo("2.39:1", 1000, player.getString(R.string.resize_tip))
+            MediaPlayer.ScaleType.SURFACE_5_4 -> overlayDelegate.showInfo("5:4", 1000, player.getString(R.string.resize_tip))
+            MediaPlayer.ScaleType.SURFACE_ORIGINAL -> overlayDelegate.showInfo(R.string.surface_original, 1000, R.string.resize_tip)
         }
         settings.putSingle(VIDEO_RATIO, scale.ordinal)
     }



More information about the Android mailing list