[Android] Improve the fast play UI
Nicolas Pomepuy
git at videolan.org
Wed Jul 10 13:16:53 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jul 10 14:10:54 2024 +0200| [26fe518e30639f84db50cc5ed983e39260c8a4a7] | committer: Duncan McNamara
Improve the fast play UI
> https://code.videolan.org/videolan/vlc-android/commit/26fe518e30639f84db50cc5ed983e39260c8a4a7
---
.../vlc-android/res/layout/player_overlay_seek.xml | 44 ++++++++++++++++++++++
.../videolan/vlc/gui/video/VideoTouchDelegate.kt | 43 +++++++++++++++++++--
2 files changed, 84 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/res/layout/player_overlay_seek.xml b/application/vlc-android/res/layout/player_overlay_seek.xml
index 539b73938b..e763ca8a78 100644
--- a/application/vlc-android/res/layout/player_overlay_seek.xml
+++ b/application/vlc-android/res/layout/player_overlay_seek.xml
@@ -7,6 +7,50 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
+ <LinearLayout
+ android:id="@+id/fastPlayContainer"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/video_list_length_bg"
+ android:gravity="center"
+ android:orientation="horizontal"
+ android:padding="8dp"
+ android:alpha="0"
+ android:visibility="gone"
+ android:layout_marginTop="32dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:visibility="visible">
+
+ <TextView
+ android:id="@+id/fastPlayTitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="4dp"
+ android:layout_marginStart="4dp"
+ android:layout_weight="1"
+ android:textColor="@color/white"
+ android:textSize="16sp"
+ tools:text="@string/fastplay_title" />
+
+ <ImageView
+ android:id="@+id/fastPlayForwardFirst"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="4dp"
+ android:layout_weight="1"
+ app:srcCompat="@drawable/ic_half_seek_forward" />
+
+ <ImageView
+ android:id="@+id/fastPlayForwardSecond"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="4dp"
+ android:layout_weight="1"
+ app:srcCompat="@drawable/ic_half_seek_forward" />
+ </LinearLayout>
+
<androidx.constraintlayout.widget.Guideline
android:orientation="horizontal"
android:layout_width="wrap_content"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
index c603691ba5..e4d50c0e46 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
@@ -3,6 +3,7 @@ package org.videolan.vlc.gui.video
import android.animation.Animator
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
+import android.animation.ValueAnimator
import android.content.res.Configuration
import android.media.AudioManager
import android.os.Handler
@@ -19,6 +20,7 @@ import android.view.View
import android.view.ViewConfiguration
import android.widget.FrameLayout
import android.widget.ImageView
+import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.widget.ViewStubCompat
import androidx.constraintlayout.widget.ConstraintLayout
@@ -32,6 +34,7 @@ import org.videolan.resources.AndroidDevices
import org.videolan.resources.AndroidDevices.isTv
import org.videolan.tools.dp
import org.videolan.tools.readableString
+import org.videolan.tools.setGone
import org.videolan.tools.setVisible
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
@@ -95,6 +98,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
private var lastSeekWasForward = true
private var seekAnimRunning = false
private var animatorSet: AnimatorSet = AnimatorSet()
+ private var fastPlayAnimatorSet: AnimatorSet = AnimatorSet()
private val rightContainer: CircularRevealFrameLayout by lazy { player.findViewById(R.id.rightContainer) }
private val leftContainer: CircularRevealFrameLayout by lazy { player.findViewById(R.id.leftContainer) }
private val rightContainerBackground: HalfCircleView by lazy { player.findViewById(R.id.rightContainerBackground) }
@@ -191,9 +195,8 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
if (touchAction == TOUCH_NONE) {
savedRate = player.service!!.rate
player.service?.setRate(org.videolan.tools.Settings.fastplaySpeed, false)
- showSeek(true)
+ showFastPlay()
player.overlayDelegate.hideOverlay(fromUser = true)
- player.overlayDelegate.showInfo(player.getString(R.string.fastplay_title, org.videolan.tools.Settings.fastplaySpeed.readableString()), 2000, player.getString(R.string.fastplay_subtitle))
touchAction = TOUCH_FASTPLAY
}
}
@@ -242,7 +245,7 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
if (touchAction == TOUCH_FASTPLAY) {
player.overlayDelegate.hideOverlay(false)
player.service?.setRate(savedRate, false)
- player.overlayDelegate.hideInfo()
+ hideFastplay()
touchAction = TOUCH_NONE
return true
}
@@ -548,6 +551,40 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
}
}
+ /**
+ * Show the fast play overlay
+ */
+ private fun showFastPlay() {
+ initSeekOverlay()
+ val container:LinearLayout = player.findViewById(R.id.fastPlayContainer)
+ val title: TextView = player.findViewById(R.id.fastPlayTitle)
+ title.text = player.getString(R.string.fastplay_title, org.videolan.tools.Settings.fastplaySpeed.readableString())
+ container.setVisible()
+ container.animate().alpha(1F)
+ val firstImageAnim = ObjectAnimator.ofFloat(player.findViewById(R.id.fastPlayForwardFirst), "alpha", 1f, 0f, 0f)
+ firstImageAnim.duration = 750
+ firstImageAnim.repeatCount = ValueAnimator.INFINITE
+
+ val secondImageAnim = ObjectAnimator.ofFloat(player.findViewById(R.id.fastPlayForwardSecond), "alpha", 0F, 1f, 0f)
+ secondImageAnim.duration = 750
+ secondImageAnim.repeatCount = ValueAnimator.INFINITE
+
+
+ fastPlayAnimatorSet = AnimatorSet()
+ fastPlayAnimatorSet.playTogether(firstImageAnim, secondImageAnim)
+ fastPlayAnimatorSet.start()
+ }
+
+ /**
+ * Hide the fast play overlay
+ */
+ private fun hideFastplay() {
+ val container:LinearLayout = player.findViewById(R.id.fastPlayContainer)
+ container.animate().alpha(0F).withEndAction {
+ container.setGone()
+ }
+ fastPlayAnimatorSet.cancel()
+ }
private fun showSeek(seekForward: Boolean): TextView {
initSeekOverlay()
val container = if (seekForward) rightContainer else leftContainer
More information about the Android
mailing list