[Android] Save and restore DVD title and chapter in playback
Nicolas Pomepuy
git at videolan.org
Mon Jan 20 17:46:54 CET 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jan 17 12:18:46 2020 +0100| [a295f5506fb9c827b73479d7408a289d579606cb] | committer: Geoffrey Métais
Save and restore DVD title and chapter in playback
> https://code.videolan.org/videolan/vlc-android/commit/a295f5506fb9c827b73479d7408a289d579606cb
---
vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 4dbaf0716..855c4ed91 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -300,11 +300,15 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
if (mw.type != MediaWrapper.TYPE_VIDEO || isVideoPlaying || player.hasRenderer
|| mw.hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO)) {
- val uri = withContext(Dispatchers.IO) { FileUtils.getUri(mw.uri) }
+ var uri = withContext(Dispatchers.IO) { FileUtils.getUri(mw.uri) }
if (uri == null) {
skipMedia()
return
}
+ val title = mw.getMetaLong(MediaWrapper.META_TITLE)
+ if (title > 0) uri = Uri.parse("$uri#$title")
+ val chapter = mw.getMetaLong(MediaWrapper.META_CHAPTER)
+ if (chapter > 0) uri = Uri.parse("$uri:$chapter")
val start = getStartTime(mw)
val media = mediaFactory.getFromUri(VLCInstance.get(service), uri)
media.addOption(":start-time=${start/1000L}")
@@ -417,6 +421,10 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
val rate = player.getRate()
val media = withContext(Dispatchers.IO) { medialibrary.findMedia(currentMedia) }
if (media === null || media.id == 0L) return at launch
+ val titleIdx = player.getTitleIdx()
+ if (titleIdx > 0) launch(Dispatchers.IO) { media.setLongMeta(MediaWrapper.META_TITLE, titleIdx.toLong()) }
+ val chapterIdx = player.getChapterIdx()
+ if (chapterIdx > 0) launch(Dispatchers.IO) { media.setLongMeta(MediaWrapper.META_CHAPTER, chapterIdx.toLong()) }
if (media.type == MediaWrapper.TYPE_VIDEO || canSwitchToVideo || media.isPodcast) {
var progress = time / length.toFloat()
if (progress > 0.95f || length - time < 10000) {
More information about the Android
mailing list