Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

MediaController2.ControllerCallback

public static abstract class MediaController2.ControllerCallback
extends Object

java.lang.Object
   ↳ android.media.MediaController2.ControllerCallback


Interface for listening to change in activeness of the MediaSession2.

This API is not generally intended for third party application developers.

Summary

Public constructors

MediaController2.ControllerCallback()

Public methods

void onCommandResult(MediaController2 controller, Object token, Session2Command command, Session2Command.Result result)

Called when the command sent to the connected session is finished.

void onConnected(MediaController2 controller, Session2CommandGroup allowedCommands)

Called when the controller is successfully connected to the session.

void onDisconnected(MediaController2 controller)

Called when the session refuses the controller or the controller is disconnected from the session.

void onPlaybackActiveChanged(MediaController2 controller, boolean playbackActive)

Called when the session's playback activeness is changed.

Session2Command.Result onSessionCommand(MediaController2 controller, Session2Command command, Bundle args)

Called when the connected session sent a session command.

Inherited methods

Public constructors

MediaController2.ControllerCallback

public MediaController2.ControllerCallback ()

Public methods

onCommandResult

public void onCommandResult (MediaController2 controller, 
                Object token, 
                Session2Command command, 
                Session2Command.Result result)

Called when the command sent to the connected session is finished.

Parameters
controller MediaController2: the controller for this event This value must never be null.

token Object: the token got from MediaController2#sendSessionCommand This value must never be null.

command Session2Command: the session command This value must never be null.

result Session2Command.Result: the result of the session command This value must never be null.

onConnected

public void onConnected (MediaController2 controller, 
                Session2CommandGroup allowedCommands)

Called when the controller is successfully connected to the session. The controller becomes available afterwards.

Parameters
controller MediaController2: the controller for this event This value must never be null.

allowedCommands Session2CommandGroup: commands that's allowed by the session. This value must never be null.

onDisconnected

public void onDisconnected (MediaController2 controller)

Called when the session refuses the controller or the controller is disconnected from the session. The controller becomes unavailable afterwards and the callback wouldn't be called.

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

Parameters
controller MediaController2: the controller for this event This value must never be null.

onPlaybackActiveChanged

public void onPlaybackActiveChanged (MediaController2 controller, 
                boolean playbackActive)

Called when the session's playback activeness is changed.

Parameters
controller MediaController2: the controller for this event This value must never be null.

playbackActive boolean: true if the session's playback is active. false otherwise.

onSessionCommand

public Session2Command.Result onSessionCommand (MediaController2 controller, 
                Session2Command command, 
                Bundle args)

Called when the connected session sent a session command.

Parameters
controller MediaController2: the controller for this event This value must never be null.

command Session2Command: the session command This value must never be null.

args Bundle: optional arguments This value may be null.

Returns
Session2Command.Result the result for the session command. If null, RESULT_INFO_SKIPPED will be sent to the session.