Google は、黒人コミュニティに対する人種平等の促進に取り組んでいます。取り組みを見る

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

Public constructors

<init>

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.

Public methods

onGetChildren

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

Called to get children of given parent id. Return the children here for the browser.

To allow getting the children, return the LibraryResult with the LibraryResult#RESULT_SUCCESS and the list of media item. Return an empty list for no children rather than using result code for error.

Parameters
session MediaLibraryService.MediaLibrarySession: the session for this event
controller MediaSession.ControllerInfo: controller
parentId String: non-empty parent id to get children
page Int: page number. Starts from 0.
pageSize Int: page size. Should be greater or equal to 1.
params MediaLibraryService.LibraryParams?: library params
Return
LibraryResult a library result with a list of media item with the id. A runtime exception will be thrown if an invalid result is returned.

onGetItem

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

Called to get an item.

To allow getting the item, return the LibraryResult with the LibraryResult#RESULT_SUCCESS and the media item.

Parameters
session MediaLibraryService.MediaLibrarySession: the session for this event
controller MediaSession.ControllerInfo: controller
mediaId String: non-empty media id of the requested item
Return
LibraryResult a library result with a media item with the id. A runtime exception will be thrown if an invalid result is returned.

onGetLibraryRoot

@NonNull open fun onGetLibraryRoot(
    @NonNull session: MediaLibraryService.MediaLibrarySession,
    @NonNull controller: MediaSession.ControllerInfo,
    @Nullable params: MediaLibraryService.LibraryParams?
): LibraryResult

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

To allow browsing media information, return the LibraryResult with the LibraryResult#RESULT_SUCCESS and the root media item with the valid media id. The media id must be included for the browser to get the children under it.

Interoperability: this callback may be called on the main thread, regardless of the callback executor.

Parameters
session MediaLibraryService.MediaLibrarySession: the session for this event
controller MediaSession.ControllerInfo: information of the controller requesting access to browse media.
params MediaLibraryService.LibraryParams?: An optional library params of service-specific arguments to send to the media library service when connecting and retrieving the root id for browsing, or null if none.
Return
LibraryResult a library result with the root media item with the id. A runtime exception will be thrown if an invalid result is returned.

onGetSearchResult

@NonNull open fun onGetSearchResult(
    @NonNull session: MediaLibraryService.MediaLibrarySession,
    @NonNull controller: MediaSession.ControllerInfo,
    @NonNull query: String,
    @IntRange(0)