[Android] Save and restore playback rate for individual media
Nicolas Pomepuy
git at videolan.org
Mon Apr 29 10:31:01 CEST 2019
vlc-android | branch: 3.1.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Apr 12 14:16:06 2019 +0200| [7d0f3d490cd453f333e7a6952e41142c9ff2d165] | committer: Geoffrey Métais
Save and restore playback rate for individual media
(cherry picked from commit 29f9d9fc10b266dc7abead2d81e66fcc985cfe5d)
> https://code.videolan.org/videolan/vlc-android/commit/7d0f3d490cd453f333e7a6952e41142c9ff2d165
---
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 e8aaab036..970e51792 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -414,6 +414,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
@@ -428,6 +429,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()) }
}
}
@@ -458,6 +460,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