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

Backward compatibility with legacy media browser APIs

Media library session supports connection from both MediaBrowser and MediaBrowserCompat, but MediaSession.ControllerInfo may not be precise. Here are current limitations with details.
SDK version MediaSession.ControllerInfo.getPackageName()
for legacy browser
MediaSession.ControllerInfo.getUid()
for legacy browser
SDK_VERSION < 21 Actual package name via Context.getPackageName() Actual UID
21 ≥ SDK_VERSION < 28,
MediaLibrarySessionCallback#onConnect and
MediaLibrarySessionCallback#onGetLibraryRoot
Actual package name via Context.getPackageName() Actual UID
21 ≥ SDK_VERSION < 28, for other callbacks MediaSessionManager.RemoteUserInfo.LEGACY_CONTROLLER Negative value
28 ≥ SDK_VERSION Actual package name via Context.getPackageName() Actual UID

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)

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

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

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

Notifies controller about change in the search result.

Inherited methods