mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00: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
1 changed files with 15 additions and 0 deletions
|
|
@ -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…
Reference in a new issue