[Android] Reload medialibrary when browsing last added tracks
Robert Stone
git at videolan.org
Mon Dec 20 07:38:11 UTC 2021
vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Sun Dec 12 22:32:41 2021 -0800| [176a1505f113fb44514047b44c8867ae35857937] | committer: Nicolas Pomepuy
Reload medialibrary when browsing last added tracks
Fixes #2270
> https://code.videolan.org/videolan/vlc-android/commit/176a1505f113fb44514047b44c8867ae35857937
---
application/vlc-android/src/org/videolan/vlc/PlaybackService.kt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 0dc5f8ed6..9ccb7d527 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1622,12 +1622,14 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
override fun onLoadChildren(parentId: String, result: Result<List<MediaBrowserCompat.MediaItem>>) {
result.detach()
+ val reload = parentId == MediaSessionBrowser.ID_LAST_ADDED && parentId != lastParentId
lastParentId = parentId
lifecycleScope.launch(start = CoroutineStart.UNDISPATCHED) {
awaitMedialibraryStarted()
lifecycleScope.launch(Dispatchers.IO) {
try {
result.sendResult(MediaSessionBrowser.browse(applicationContext, parentId, isShuffling))
+ if (reload && !medialibrary.isWorking) applicationContext.reloadLibrary()
} catch (e: RuntimeException) {
Log.e(TAG, "Failed to load children for $parentId", e)
}
More information about the Android
mailing list