The Android Developer Challenge is back! Submit your idea before December 2.

MediaLibrarySession

class MediaLibrarySession : MediaSession
kotlin.Any
   ↳ androidx.media2.session.MediaSession
   ↳ androidx.media2.session.MediaLibraryService.MediaLibrarySession

Session for the MediaLibraryService. Build this object with Builder and return in MediaSessionService#onGetSession(ControllerInfo).

Summary

Nested classes

Builder for MediaLibrarySession.

Callback for the MediaLibrarySession.

Public methods

Unit
notifyChildrenChanged(@NonNull controller: MediaSession.ControllerInfo, @NonNull parentId: String, itemCount: Int, @Nullable params: MediaLibraryService.LibraryParams?)

Notify the controller of the change in a parent's children.

Unit
notifyChildrenChanged(@NonNull parentId: String, itemCount: Int, @Nullable params: MediaLibraryService.LibraryParams?)

Notify all controllers that subscribed to the parent about change in the parent's children, regardless of the library params supplied by MediaBrowser#subscribe(String, LibraryParams).

Unit
notifySearchResultChanged(@NonNull controller: MediaSession.ControllerInfo, @NonNull query: String, itemCount: Int, @Nullable params: MediaLibraryService.LibraryParams?)

Notify controller about change in the search result.

Inherited functions

Public methods

notifyChildrenChanged

fun notifyChildrenChanged(@NonNull controller: MediaSession.ControllerInfo, @NonNull parentId: String, itemCount: Int, @Nullable params: MediaLibraryService.LibraryParams?): Unit

Notify the controller of the change in a parent's children.

If the controller hasn't subscribed to the parent, the API will do nothing.

Controllers will use MediaBrowser#getChildren(String, int, int, LibraryParams) to get the list of children.

Parameters
controller MediaSession.ControllerInfo: controller to notify
parentId MediaSession.ControllerInfo: non-empty parent id with changes in its children
itemCount MediaSession.ControllerInfo: number of children.
params MediaSession.ControllerInfo: library params

notifyChildrenChanged

fun notifyChildrenChanged(@NonNull parentId: String, itemCount: Int, @Nullable params: MediaLibraryService.LibraryParams?): Unit

Notify all controllers that subscribed to the parent about change in the parent's children, regardless of the library params supplied by MediaBrowser#subscribe(String, LibraryParams).

Parameters
parentId String: non-empty parent id
itemCount String: number of children
params String: library params

notifySearchResultChanged

fun notifySearchResultChanged(@NonNull controller: MediaSession.ControllerInfo, @NonNull query: String, itemCount: Int, @Nullable params: MediaLibraryService.LibraryParams?): Unit

Notify controller about change in the search result.

Parameters
controller MediaSession.ControllerInfo: controller to notify
query MediaSession.ControllerInfo: previously sent non-empty search query from the controller.
itemCount MediaSession.ControllerInfo: the number of items that have been found in the search.
params MediaSession.ControllerInfo: library params