[Android] Save and restore playback rate for individual media

Nicolas Pomepuy git at videolan.org
Fri Apr 12 14:57:03 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Apr 12 14:16:06 2019 +0200| [29f9d9fc10b266dc7abead2d81e66fcc985cfe5d] | committer: Geoffrey Métais

Save and restore playback rate for individual media

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

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

diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index d7730ffb1..97cc8a239 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -401,6 +401,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         val time = player.getCurrentTime()
         val length = player.getLength()
         val canSwitchToVideo = player.canSwitchToVideo()
+        val rate = player.getRate()
         launch {
             val media = withContext(Dispatchers.IO) { medialibrary.findMedia(currentMedia) }
             if (media === null || media.id == 0L) return at launch
@@ -415,6 +416,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
                 media.time = if (progress == 0f) 0L else time
                 launch(Dispatchers.IO) { media.setLongMeta(MediaWrapper.META_PROGRESS, media.time) }
             }
+            launch(Dispatchers.IO) { media.setStringMeta(MediaWrapper.META_SPEED, rate.toString()) }
         }
     }
 
@@ -445,6 +447,10 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
                 player.setAudioDelay(media.getMetaLong(MediaWrapper.META_AUDIODELAY))
             player.setSpuTrack(media.getMetaLong(MediaWrapper.META_SUBTITLE_TRACK).toInt())
             player.setSpuDelay(media.getMetaLong(MediaWrapper.META_SUBTITLE_DELAY))
+            val rateString = media.getMetaString(MediaWrapper.META_SPEED)
+            if (!rateString.isNullOrEmpty()) {
+                player.setRate(rateString.toFloat(), false)
+            }
         }
     }
 



More information about the Android mailing list