Update media browsers when the list of local playlist changes
This commit is contained in:
parent
c916608c98
commit
0af4c34318
|
@ -70,6 +70,8 @@ public class MediaBrowserConnector implements MediaSessionConnector.PlaybackPrep
|
|||
sessionConnector.setMetadataDeduplicationEnabled(true);
|
||||
sessionConnector.setPlaybackPreparer(this);
|
||||
playerService.setSessionToken(mediaSession.getSessionToken());
|
||||
|
||||
setupBookmarksNotifications();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -79,6 +81,7 @@ public class MediaBrowserConnector implements MediaSessionConnector.PlaybackPrep
|
|||
|
||||
public void release() {
|
||||
disposePrepareOrPlayCommands();
|
||||
disposeBookmarksNotifications();
|
||||
mediaSession.release();
|
||||
}
|
||||
|
||||
|
@ -228,6 +231,20 @@ public class MediaBrowserConnector implements MediaSessionConnector.PlaybackPrep
|
|||
return localPlaylistManager;
|
||||
}
|
||||
|
||||
@Nullable Disposable bookmarksNotificationsDisposable;
|
||||
|
||||
private void setupBookmarksNotifications() {
|
||||
bookmarksNotificationsDisposable = getPlaylistManager().getPlaylists().subscribe(
|
||||
playlistMetadataEntries -> playerService.notifyChildrenChanged(ID_BOOKMARKS));
|
||||
}
|
||||
|
||||
private void disposeBookmarksNotifications() {
|
||||
if (bookmarksNotificationsDisposable != null) {
|
||||
bookmarksNotificationsDisposable.dispose();
|
||||
bookmarksNotificationsDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Suppress Sonar warning replace list collection by Stream.toList call, as this method is only
|
||||
// available in Android API 34 and not currently available with desugaring
|
||||
@SuppressWarnings("squid:S6204")
|
||||
|
|
Loading…
Reference in New Issue