[Android] Refactor the seek jump in the VideoPlayerActivity

Nicolas Pomepuy git at videolan.org
Fri Feb 28 12:32:39 UTC 2025


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Feb 25 12:47:51 2025 +0100| [95084781cbe8db07a2e19977fcd61f72ca6bb47e] | committer: Duncan McNamara

Refactor the seek jump in the VideoPlayerActivity

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

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt  | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index fb06acd5f5..b4f88fc7d7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1949,12 +1949,18 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
         overlayDelegate.togglePlaylist()
     }
 
+    private fun jump (forward:Boolean, long: Boolean) {
+        val jumpDelay = if (long) Settings.videoLongJumpDelay else Settings.videoJumpDelay
+        val delay = if (forward) jumpDelay * 1000 else -(jumpDelay * 1000)
+        touchDelegate.seekDelta(if (LocaleUtil.isRtl()) -delay  else delay)
+    }
+
     override fun onClick(v: View) {
         when (v.id) {
             R.id.orientation_toggle -> toggleOrientationLock()
             R.id.playlist_toggle -> overlayDelegate.togglePlaylist()
-            R.id.player_overlay_forward -> touchDelegate.seekDelta(if (LocaleUtil.isRtl()) -Settings.videoJumpDelay * 1000  else Settings.videoJumpDelay * 1000)
-            R.id.player_overlay_rewind -> touchDelegate.seekDelta(if (LocaleUtil.isRtl()) Settings.videoJumpDelay * 1000  else -Settings.videoJumpDelay * 1000)
+            R.id.player_overlay_forward -> jump(forward = true, long = false)
+            R.id.player_overlay_rewind -> jump(forward = false, long = false)
             R.id.ab_repeat_add_marker -> service?.playlistManager?.setABRepeatValue(
                 service?.playlistManager?.getCurrentMedia(), overlayDelegate.hudBinding.playerOverlaySeekbar.progress.toLong())
             R.id.ab_repeat_reset -> service?.playlistManager?.resetABRepeatValues(service?.playlistManager?.getCurrentMedia())
@@ -2014,11 +2020,11 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
                 return true
             }
             R.id.player_overlay_forward -> {
-                touchDelegate.seekDelta(if (LocaleUtil.isRtl()) -Settings.videoLongJumpDelay * 1000  else Settings.videoLongJumpDelay * 1000)
+                jump(forward = true, long = true)
                 return true
             }
             R.id.player_overlay_rewind -> {
-                touchDelegate.seekDelta(if (LocaleUtil.isRtl()) Settings.videoLongJumpDelay * 1000  else -Settings.videoLongJumpDelay * 1000)
+                jump(forward = false, long = true)
                 return true
             }
         }



More information about the Android mailing list