Skip to content
Snippets Groups Projects
Commit 176a1505 authored by Robert Stone's avatar Robert Stone Committed by Nicolas Pomepuy
Browse files

Reload medialibrary when browsing last added tracks

Fixes #2270
parent 5e76ec34
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment