MediaBrowser.Listener


interface MediaBrowser.Listener : MediaController.Listener


A listener for events from MediaLibraryService.

The methods will be called from the application thread associated with the application looper of the controller.

Summary

Public functions

Unit
onChildrenChanged(
    browser: MediaBrowser!,
    parentId: String!,
    itemCount: @IntRange(from = 0) Int,
    params: MediaLibraryService.LibraryParams?
)

Called when there's a change in the parent's children after you've subscribed to the parent with subscribe.

Unit
onSearchResultChanged(
    browser: MediaBrowser!,
    query: String!,
    itemCount: @IntRange(from = 0) Int,
    params: MediaLibraryService.LibraryParams?
)

Called when there's change in the search result requested by the previous search.

Inherited functions

From androidx.media3.session.MediaController.Listener
Unit
onAvailableSessionCommandsChanged(
    controller: MediaController!,
    commands: SessionCommands!
)

Called when the available session commands are changed by session.

ListenableFuture<SessionResult!>!
onCustomCommand(
    controller: MediaController!,
    command: SessionCommand!,
    args: Bundle!
)

Called when the session sends a custom command through sendCustomCommand.

Unit
@UnstableApi
onCustomLayoutChanged(
    controller: MediaController!,
    layout: (Mutable)List<CommandButton!>!
)

Called when the custom layout changed.

Unit

Called when the controller is disconnected from the session.

Unit
@UnstableApi
onError(controller: MediaController!, sessionError: SessionError!)

Called when an non-fatal error sent by the session is received.

Unit
onExtrasChanged(controller: MediaController!, extras: Bundle!)

Called when the session extras are set on the session side.

Unit
@UnstableApi
onMediaButtonPreferencesChanged(
    controller: MediaController!,
    mediaButtonPreferences: (Mutable)List<CommandButton!>!
)

Called when the media button preferences changed.

Unit
@UnstableApi
onSessionActivityChanged(
    controller: MediaController!,
    sessionActivity: PendingIntent!
)

Called when the PendingIntent to launch the session activity has been changed on the session side.

ListenableFuture<SessionResult!>!
onSetCustomLayout(
    controller: MediaController!,
    layout: (Mutable)List<CommandButton!>!
)

Called when the session sets the custom layout through setCustomLayout.

Public functions

onChildrenChanged

fun onChildrenChanged(
    browser: MediaBrowser!,
    parentId: String!,
    itemCount: @IntRange(from = 0) Int,
    params: MediaLibraryService.LibraryParams?
): Unit

Called when there's a change in the parent's children after you've subscribed to the parent with subscribe.

This method is called when the app calls notifyChildrenChanged for the parent, or it is called by the library immediately after calling subscribe.

Parameters
browser: MediaBrowser!

The browser for this event.

parentId: String!

The non-empty parent id that you've specified with subscribe.

itemCount: @IntRange(from = 0) Int

The number of children, or MAX_VALUE if the number of items is unknown.

params: MediaLibraryService.LibraryParams?

The optional parameters from the library service. Can be differ from the params that you've specified with subscribe.

onSearchResultChanged

fun onSearchResultChanged(
    browser: MediaBrowser!,
    query: String!,
    itemCount: @IntRange(from = 0) Int,
    params: MediaLibraryService.LibraryParams?
): Unit

Called when there's change in the search result requested by the previous search.

Parameters
browser: MediaBrowser!

The browser for this event.

query: String!

The non-empty search query that you've specified with search.

itemCount: @IntRange(from = 0) Int

The number of items for the search result.

params: MediaLibraryService.LibraryParams?

The optional parameters from the library service. Can be differ from the params that you've specified with search.