[Android] Save time when navigating the play queue

Nicolas Pomepuy git at videolan.org
Thu Apr 15 07:51:14 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Apr 14 08:13:21 2021 +0200| [0ab7c9d3f46cf0198a2f6fd4f751dc7bea1fd436] | committer: Nicolas Pomepuy

Save time when navigating the play queue

Fixes #1982

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

 application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 7ee31b945..635dbfa8e 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -220,6 +220,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
 
     @MainThread
     fun next(force : Boolean = false) {
+        mediaList.getMedia(currentIndex)?.time = player.getCurrentTime()
         val size = mediaList.size()
         if (force || repeating != PlaybackStateCompat.REPEAT_MODE_ONE) {
             previous.push(currentIndex)
@@ -275,6 +276,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
 
     @MainThread
     fun previous(force : Boolean) {
+        mediaList.getMedia(currentIndex)?.time = player.getCurrentTime()
         if (hasPrevious() && currentIndex > 0 &&
                 ((force || !player.seekable || (player.getCurrentTime() < PREVIOUS_LIMIT_DELAY) || (lastPrevious != -1L && System.currentTimeMillis() - lastPrevious <  PREVIOUS_LIMIT_DELAY)))) {
             val size = mediaList.size()
@@ -315,6 +317,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
     }
 
     suspend fun playIndex(index: Int, flags: Int = 0) {
+        mediaList.getMedia(currentIndex)?.time = player.getCurrentTime()
         videoBackground = videoBackground || (!player.isVideoPlaying() && player.canSwitchToVideo())
         if (mediaList.size() == 0) {
             Log.w(TAG, "Warning: empty media list, nothing to play !")



More information about the Android mailing list