mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Implement onSubscribe in session demo service
Immediately notify a subscribing client about the availability of child items of a parent ID to make the client load the children. PiperOrigin-RevId: 450396690
This commit is contained in:
parent
07039a45b0
commit
08fc89a585
@ -116,6 +116,21 @@ class PlaybackService : MediaLibraryService() {
|
||||
return SessionResult.RESULT_ERROR_NOT_SUPPORTED
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSubscribe(
|
||||
session: MediaLibrarySession,
|
||||
browser: MediaSession.ControllerInfo,
|
||||
parentId: String,
|
||||
params: LibraryParams?
|
||||
): ListenableFuture<LibraryResult<Void>> {
|
||||
val children =
|
||||
MediaItemTree.getChildren(parentId)
|
||||
?: return Futures.immediateFuture(
|
||||
LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE)
|
||||
)
|
||||
session.notifyChildrenChanged(browser, parentId, children.size, params)
|
||||
return Futures.immediateFuture(LibraryResult.ofVoid())
|
||||
}
|
||||
}
|
||||
|
||||
private class CustomMediaItemFiller : MediaSession.MediaItemFiller {
|
||||
|
Loading…
x
Reference in New Issue
Block a user