ControllerCallback
abstract class ControllerCallback
kotlin.Any | |
↳ | android.media.MediaController2.ControllerCallback |
This API is not generally intended for third party application developers. Use the AndroidX Media2 session Library for consistent behavior across all devices.
Interface for listening to change in activeness of the MediaSession2
.
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
open Unit |
onCommandResult(controller: MediaController2, token: Any, command: Session2Command, result: Session2Command.Result) Called when the command sent to the connected session is finished. |
open Unit |
onConnected(controller: MediaController2, allowedCommands: Session2CommandGroup) Called when the controller is successfully connected to the session. |
open Unit |
onDisconnected(controller: MediaController2) Called when the session refuses the controller or the controller is disconnected from the session. |
open Unit |
onPlaybackActiveChanged(controller: MediaController2, playbackActive: Boolean) Called when the session's playback activeness is changed. |
open Session2Command.Result? |
onSessionCommand(controller: MediaController2, command: Session2Command, args: Bundle?) Called when the connected session sent a session command. |
Public constructors
Public methods
onCommandResult
open fun onCommandResult(
controller: MediaController2,
token: Any,
command: Session2Command,
result: Session2Command.Result
): Unit
Called when the command sent to the connected session is finished.
Parameters | |
---|---|
controller |
MediaController2: the controller for this event This value cannot be null . |
token |
Any: the token got from MediaController2#sendSessionCommand This value cannot be null . |
command |
Session2Command: the session command This value cannot be null . |
result |
Session2Command.Result: the result of the session command This value cannot be null . |
onConnected
open fun onConnected(
controller: MediaController2,
allowedCommands: Session2CommandGroup
): Unit
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 cannot be null . |
allowedCommands |
Session2CommandGroup: commands that's allowed by the session. This value cannot be null . |
onDisconnected
open fun onDisconnected(controller: MediaController2): Unit
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 close()
, so you can put clean up code here. You don't need to call close()
after this.
Parameters | |
---|---|
controller |
MediaController2: the controller for this event This value cannot be null . |
onPlaybackActiveChanged
open fun onPlaybackActiveChanged(
controller: MediaController2,
playbackActive: Boolean
): Unit
Called when the session's playback activeness is changed.
Parameters | |
---|---|
controller |
MediaController2: the controller for this event This value cannot be null . |
playbackActive |
Boolean: true if the session's playback is active. false otherwise. |
onSessionCommand
open fun onSessionCommand(
controller: MediaController2,
command: Session2Command,
args: Bundle?
): Session2Command.Result?
Called when the connected session sent a session command.
Parameters | |
---|---|
controller |
MediaController2: the controller for this event This value cannot be null . |
command |
Session2Command: the session command This value cannot be null . |
args |
Bundle?: optional arguments This value may be null . |
Return | |
---|---|
Session2Command.Result? |
the result for the session command. If null , RESULT_INFO_SKIPPED will be sent to the session. |