public final class

MediaLibraryService.MediaLibrarySession

extends MediaSession

 java.lang.Object

androidx.media2.session.MediaSession

↳androidx.media2.session.MediaLibraryService.MediaLibrarySession

Overview

Session for the MediaLibraryService. Build this object with MediaLibraryService.MediaLibrarySession.Builder and return in MediaSessionService.

Backward compatibility with legacy media browser APIs

Media library session supports connection from both MediaBrowser and android.support.v4.media.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 Actual UID
21 ≥ SDK_VERSION < 28,
MediaLibrarySessionCallback#onConnect and
MediaLibrarySessionCallback#onGetLibraryRoot
Actual package name via Actual UID
21 ≥ SDK_VERSION < 28, for other callbacks MediaSessionManager.RemoteUserInfo.LEGACY_CONTROLLER Negative value
28 ≥ SDK_VERSION Actual package name via Actual UID

Summary

Methods
public voidnotifyChildrenChanged(MediaSession.ControllerInfo controller, java.lang.String parentId, int itemCount, MediaLibraryService.LibraryParams params)

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

public voidnotifyChildrenChanged(java.lang.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.

public voidnotifySearchResultChanged(MediaSession.ControllerInfo controller, java.lang.String query, int itemCount, MediaLibraryService.LibraryParams params)

Notifies controller about change in the search result.

from MediaSessionbroadcastCustomCommand, close, getConnectedControllers, getId, getPlayer, getSessionCompat, getSessionCompatToken, getToken, isClosed, sendCustomCommand, setAllowedCommands, setCustomLayout, setLegacyControllerConnectionTimeoutMs, updatePlayer
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

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

Notifies 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 to get the list of children.

Parameters:

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

public void notifyChildrenChanged(java.lang.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.

Parameters:

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

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

Notifies controller about change in the search result.

Parameters:

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