[Android] Update player progress when seeking from media controls

Robert Stone git at videolan.org
Tue May 30 09:37:05 UTC 2023


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Mon May 22 20:37:13 2023 -0700| [25687a12eefb7bf61e53cfb3fa0ce945c11a22ca] | committer: Robert Stone

Update player progress when seeking from media controls

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

 .../vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt b/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
index 5062094bd7..0e0ca50f46 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
@@ -299,6 +299,11 @@ internal class MediaSessionCallback(private val playbackService: PlaybackService
         }
     }
 
+    private fun seek(position: Long) {
+        playbackService.seek(position, fromUser = true)
+        playbackService.playlistManager.player.updateProgress(position)
+    }
+
     private fun checkForSeekFailure(forward: Boolean) {
         if (playbackService.playlistManager.player.lastPosition == 0.0f && (forward || playbackService.getTime() > 0))
             playbackService.displayPlaybackMessage(R.string.unseekable_stream)
@@ -373,15 +378,15 @@ internal class MediaSessionCallback(private val playbackService: PlaybackService
 
     override fun onSkipToPrevious() = playbackService.previous(false)
 
-    override fun onSeekTo(pos: Long) = playbackService.seek(if (pos < 0) playbackService.getTime() + pos else pos, fromUser = true)
+    override fun onSeekTo(pos: Long) = seek(if (pos < 0) playbackService.getTime() + pos else pos)
 
     override fun onFastForward() {
-        playbackService.seek((playbackService.getTime() + Settings.audioJumpDelay * ONE_SECOND).coerceAtMost(playbackService.length), fromUser = true)
+        seek((playbackService.getTime() + Settings.audioJumpDelay * ONE_SECOND).coerceAtMost(playbackService.length))
         checkForSeekFailure(forward = true)
     }
 
     override fun onRewind() {
-        playbackService.seek((playbackService.getTime() - Settings.audioJumpDelay * ONE_SECOND).coerceAtLeast(0), fromUser = true)
+        seek((playbackService.getTime() - Settings.audioJumpDelay * ONE_SECOND).coerceAtLeast(0))
         checkForSeekFailure(forward = false)
     }
 



More information about the Android mailing list