Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

MediaLibraryService.MediaLibrarySession

public static final class MediaLibraryService.MediaLibrarySession
extends MediaSession

java.lang.Object
   ↳ androidx.media2.session.MediaSession
     ↳ androidx.media2.session.MediaLibraryService.MediaLibrarySession


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

Summary

Nested classes

class MediaLibraryService.MediaLibrarySession.Builder

Builder for MediaLibraryService.MediaLibrarySession

class MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback

Callback for the MediaLibraryService.MediaLibrarySession

Public methods

void notifyChildrenChanged(MediaSession.ControllerInfo controller, String parentId, int itemCount, MediaLibraryService.LibraryParams params)

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

void notifyChildrenChanged(String parentId, int itemCount, MediaLibraryService.LibraryParams params)

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).

void notifySearchResultChanged(MediaSession.ControllerInfo controller, String query, int itemCount, MediaLibraryService.LibraryParams params)

Notify controller about change in the search result.

Inherited methods

Public methods

notifyChildrenChanged

public void notifyChildrenChanged (MediaSession.ControllerInfo controller, 
                String parentId, 
                int itemCount, 
                MediaLibraryService.LibraryParams params)

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 String: non-empty parent id with changes in its children

itemCount int: number of children.

params MediaLibraryService.LibraryParams: library params

notifyChildrenChanged

public void notifyChildrenChanged (String parentId, 
                int itemCount, 
                MediaLibraryService.LibraryParams params)

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 int: number of children

params MediaLibraryService.LibraryParams: library params

notifySearchResultChanged

public void notifySearchResultChanged (MediaSession.ControllerInfo controller, 
                String query, 
                int itemCount, 
                MediaLibraryService.LibraryParams params)

Notify controller about change in the search result.

Parameters
controller MediaSession.ControllerInfo: controller to notify

query String: previously sent non-empty search query from the controller.

itemCount int: the number of items that have been found in the search.

params MediaLibraryService.LibraryParams: library params