Google is committed to advancing racial equity for Black communities. See how.

MediaLibrarySessionCallback

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

Callback for the MediaLibrarySession.

When you return LibraryResult with media items, items must have valid MediaMetadata#METADATA_KEY_MEDIA_ID and specify MediaMetadata#METADATA_KEY_BROWSABLE and MediaMetadata#METADATA_KEY_PLAYABLE.

Summary

Public constructors

Callback for the MediaLibrarySession.

Public methods
open LibraryResult
onGetChildren(@NonNull session: MediaLibraryService.MediaLibrarySession, @NonNull controller: MediaSession.ControllerInfo, @NonNull parentId: String, @IntRange(0) page: Int, @IntRange(1) pageSize: Int, @Nullable params: MediaLibraryService.LibraryParams?)

Called to get children of given parent id.

open LibraryResult
onGetItem(@NonNull session: MediaLibraryService.MediaLibrarySession, @NonNull controller: MediaSession.ControllerInfo, @NonNull mediaId: String)

Called to get an item.

open LibraryResult

Called to get the root information for browsing by a MediaBrowser.

open LibraryResult
onGetSearchResult(@NonNull session: MediaLibraryService.MediaLibrarySession, @NonNull controller: MediaSession.ControllerInfo, @NonNull query: String, @IntRange(0) page: Int, @IntRange(1) pageSize: Int, @Nullable params: MediaLibraryService.LibraryParams?)

Called to get the search result.

open Int
onSearch(@NonNull session: MediaLibraryService.MediaLibrarySession, @NonNull controller: MediaSession.ControllerInfo, @NonNull query: String, @Nullable params: MediaLibraryService.LibraryParams?)

Called when a controller requests search.

open Int
onSubscribe(@NonNull session: MediaLibraryService.MediaLibrarySession, @NonNull controller: MediaSession.ControllerInfo, @NonNull parentId: String, @Nullable params: MediaLibraryService.LibraryParams?)

Called when a controller subscribes to the parent.

open Int
onUnsubscribe(@NonNull session: MediaLibraryService.MediaLibrarySession, @NonNull controller: MediaSession.ControllerInfo, @NonNull parentId: String)

Called when a controller unsubscribes to the parent.

Inherited functions