[Android] Get DVD title and chapter sooner to avoid a race condition
Nicolas Pomepuy
git at videolan.org
Fri Jan 24 15:53:13 CET 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jan 24 14:33:02 2020 +0100| [ca91510d4f4946de1939abcad910d63f79375149] | committer: Nicolas Pomepuy
Get DVD title and chapter sooner to avoid a race condition
> https://code.videolan.org/videolan/vlc-android/commit/ca91510d4f4946de1939abcad910d63f79375149
---
application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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 855c4ed91..07b0d4460 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -412,6 +412,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
}
fun saveMediaMeta() = launch(start = CoroutineStart.UNDISPATCHED) {
+ val titleIdx = player.getTitleIdx()
+ val chapterIdx = player.getChapterIdx()
val currentMedia = getCurrentMedia() ?: return at launch
if (currentMedia.uri.scheme == "fd") return at launch
//Save progress
@@ -421,9 +423,7 @@ 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()
More information about the Android
mailing list