MediaSession2.SessionCallback
public
static
abstract
class
MediaSession2.SessionCallback
extends Object
| java.lang.Object | |
| ↳ | android.media.MediaSession2.SessionCallback |
Callback to be called for all incoming commands from MediaController2s.
This API is not generally intended for third party application developers.
Summary
Public constructors | |
|---|---|
MediaSession2.SessionCallback()
|
|
Public methods | |
|---|---|
void
|
onCommandResult(MediaSession2 session, MediaSession2.ControllerInfo controller, Object token, Session2Command command, Session2Command.Result result)
Called when the command sent to the controller is finished. |
Session2CommandGroup
|
onConnect(MediaSession2 session, MediaSession2.ControllerInfo controller)
Called when a controller is created for this session. |
void
|
onDisconnected(MediaSession2 session, MediaSession2.ControllerInfo controller)
Called when a controller is disconnected |
void
|
onPostConnect(MediaSession2 session, MediaSession2.ControllerInfo controller)
Called immediately after a controller is connected. |
Session2Command.Result
|
onSessionCommand(MediaSession2 session, MediaSession2.ControllerInfo controller, Session2Command command, Bundle args)
Called when a controller sent a session command. |
Inherited methods | |
|---|---|
Public constructors
MediaSession2.SessionCallback
public MediaSession2.SessionCallback ()
Public methods
onCommandResult
public void onCommandResult (MediaSession2 session, MediaSession2.ControllerInfo controller, Object token, Session2Command command, Session2Command.Result result)
Called when the command sent to the controller is finished.
| Parameters | |
|---|---|
session |
MediaSession2: the session for this event
This value must never be null. |
controller |
MediaSession2.ControllerInfo: controller information
This value must never be null. |
token |
Object: the token got from MediaSession2#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. |
onConnect
public Session2CommandGroup onConnect (MediaSession2 session, MediaSession2.ControllerInfo controller)
Called when a controller is created for this session. Return allowed commands for
controller. By default it returns null.
You can reject the connection by returning null. In that case, controller
receives MediaController2.ControllerCallback#onDisconnected(MediaController2)
and cannot be used.
| Parameters | |
|---|---|
session |
MediaSession2: the session for this event
This value must never be null. |
controller |
MediaSession2.ControllerInfo: controller information.
This value must never be null. |
| Returns | |
|---|---|
Session2CommandGroup |
allowed commands. Can be null to reject connection. |
onDisconnected
public void onDisconnected (MediaSession2 session, MediaSession2.ControllerInfo controller)
Called when a controller is disconnected
| Parameters | |
|---|---|
session |
MediaSession2: the session for this event
This value must never be null. |
controller |
MediaSession2.ControllerInfo: controller information
This value must never be null. |
onPostConnect
public void onPostConnect (MediaSession2 session, MediaSession2.ControllerInfo controller)
Called immediately after a controller is connected. This is a convenient method to add custom initialization between the session and a controller.
| Parameters | |
|---|---|
session |
MediaSession2: the session for this event
This value must never be null. |
controller |
MediaSession2.ControllerInfo: controller information.
This value must never be null. |
onSessionCommand
public Session2Command.Result onSessionCommand (MediaSession2 session, MediaSession2.ControllerInfo controller, Session2Command command, Bundle args)
Called when a controller sent a session command.
| Parameters | |
|---|---|
session |
MediaSession2: the session for this event
This value must never be null. |
controller |
MediaSession2.ControllerInfo: controller information
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. |