Commit 08fc89a5 by bachinger Committed by Ian Baker

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
parent 07039a45
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment