Stay organized with collections Save and categorize content based on your preferences.

MediaController.Listener

interface MediaController.Listener

Known direct subclasses
MediaBrowser.Listener

A listener for events from MediaLibraryService.


A listener for events and incoming commands from MediaSession.

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

Summary

Public functions

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

Called when the controller is disconnected from the session.

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

Called when the session extras have changed.

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

Called when the session sets the custom layout through setCustomLayout.

Public functions

onAvailableSessionCommandsChanged

fun onAvailableSessionCommandsChanged(
    controller: MediaController!,
    commands: SessionCommands!
): Unit

Called when the available session commands are changed by session.

Parameters
controller: MediaController!

The controller.

commands: SessionCommands!

The new available session commands.

onCustomCommand

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

Called when the session sends a custom command through sendCustomCommand.

Return a ListenableFuture to reply with a SessionResult to the session asynchronously. You can also return a SessionResult directly by using Guava's immediateFuture.

The default implementation returns ListenableFuture of RESULT_ERROR_NOT_SUPPORTED.

Parameters
controller: MediaController!

The controller.

command: SessionCommand!

The custom command.

args: Bundle!

The additional arguments. May be empty.

Returns
ListenableFuture<SessionResult!>!

The result of handling the custom command.

onDisconnected

fun onDisconnected(controller: MediaController!): Unit

Called when the controller is disconnected from the session. The controller becomes unavailable afterwards and this listener won't be called anymore.

It will be also called after the release, so you can put clean up code here. You don't need to call release after this.

Parameters
controller: MediaController!

The controller.

onExtrasChanged

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

Called when the session extras have changed.

Parameters
controller: MediaController!

The controller.

extras: Bundle!

The session extras that have changed.

onSetCustomLayout

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

Called when the session sets the custom layout through setCustomLayout.

Return a ListenableFuture to reply with a SessionResult to the session asynchronously. You can also return a SessionResult directly by using Guava's immediateFuture.

The default implementation returns a ListenableFuture of RESULT_ERROR_NOT_SUPPORTED.

Parameters
controller: MediaController!

The controller.

layout: (Mutable)List<CommandButton!>!

The ordered list of CommandButton.

Returns
ListenableFuture<SessionResult!>!

The result of handling the custom layout.