MediaBrowser.Listener


public interface MediaBrowser.Listener extends 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 methods

default void
onChildrenChanged(
    MediaBrowser browser,
    String parentId,
    @IntRange(from = 0) int itemCount,
    @Nullable MediaLibraryService.LibraryParams params
)

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

default void
onSearchResultChanged(
    MediaBrowser browser,
    String query,
    @IntRange(from = 0) int itemCount,
    @Nullable MediaLibraryService.LibraryParams params
)

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

Inherited methods

From androidx.media3.session.MediaController.Listener
default void

Called when the available session commands are changed by session.

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

Called when the session sends a custom command through sendCustomCommand.

default void

Called when the custom layout changed.

default void

Called when the controller is disconnected from the session.

default void
@UnstableApi
onError(MediaController controller, SessionError sessionError)

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

default void
onExtrasChanged(MediaController controller, Bundle extras)

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

default void
@UnstableApi
onMediaButtonPreferencesChanged(
    MediaController controller,
    List<CommandButton> mediaButtonPreferences
)

Called when the media button preferences changed.

default void
@UnstableApi
onSessionActivityChanged(
    MediaController controller,
    PendingIntent sessionActivity
)

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

default ListenableFuture<SessionResult>
onSetCustomLayout(
    MediaController controller,
    List<CommandButton> layout
)

Called when the session sets the custom layout through setCustomLayout.

Public methods

onChildrenChanged

default void onChildrenChanged(
    MediaBrowser browser,
    String parentId,
    @IntRange(from = 0) int itemCount,
    @Nullable MediaLibraryService.LibraryParams params
)

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
MediaBrowser browser

The browser for this event.

String parentId

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

@IntRange(from = 0) int itemCount

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

@Nullable MediaLibraryService.LibraryParams params

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

onSearchResultChanged

default void onSearchResultChanged(
    MediaBrowser browser,
    String query,
    @IntRange(from = 0) int itemCount,
    @Nullable MediaLibraryService.LibraryParams params
)

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

Parameters
MediaBrowser browser

The browser for this event.

String query

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

@IntRange(from = 0) int itemCount

The number of items for the search result.

@Nullable MediaLibraryService.LibraryParams params

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