ControllerCallback

abstract class ControllerCallback
kotlin.Any
   ↳ androidx.media.MediaController2.ControllerCallback

Interface for listening to change in activeness of the MediaSession2. It's active if and only if it has set a player.

Summary

Public constructors

Public methods
open Unit

Called when the session has changed anything related with the PlaybackInfo.

open Unit
onRepeatModeChanged(controller: MediaController2, repeatMode: Int)

Called when the repeat mode is changed.

open Unit

Called when the allowed commands are changed by session.

open Unit
onCustomCommand(controller: MediaController2, command: SessionCommand2, args: Bundle?, receiver: ResultReceiver?)

Called when the session sent a custom command.

open Unit

Called when a playlist is changed.

open Unit

Called when a property of the indicated media route has changed.

open Unit

Called when the session set the custom layout through the MediaSession2#setCustomLayout(ControllerInfo, List).

open Unit
onSeekCompleted(controller: MediaController2, position: Long)

Called to indicate that seeking is completed.

open Unit

Called when the player state is changed.

open Unit

Called when the player's currently playing item is changed

open Unit

Called when a playlist metadata is changed.

open Unit

Called to report buffering events for a data source.

open Unit
onConnected(controller: MediaController2, allowedCommands: SessionCommandGroup2)

Called when the controller is successfully connected to the session.

open Unit
onShuffleModeChanged(controller: MediaController2, shuffleMode: Int)

Called when the shuffle mode is changed.

open Unit

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

open Unit

Called when playback speed is changed.

open Unit
onError(controller: MediaController2, errorCode: Int, extras: Bundle?)

Called when a error from

Public constructors

<init>

ControllerCallback()

Public methods

onPlaybackInfoChanged

open fun onPlaybackInfoChanged(controller: MediaController2, info: MediaController2.PlaybackInfo): Unit

Called when the session has changed anything related with the PlaybackInfo.

Parameters
controller MediaController2: the controller for this event
info MediaController2: new playback info

onRepeatModeChanged

open fun onRepeatModeChanged(controller: MediaController2, repeatMode: Int): Unit

Called when the repeat mode is changed.

Parameters
controller MediaController2: the controller for this event
repeatMode MediaController2: repeat mode

onAllowedCommandsChanged

open fun onAllowedCommandsChanged(controller: MediaController2, commands: SessionCommandGroup2): Unit

Called when the allowed commands are changed by session.

Parameters
controller MediaController2: the controller for this event
commands MediaController2: newly allowed commands

onCustomCommand

open fun onCustomCommand(controller: MediaController2, command: SessionCommand2, args: Bundle?, receiver: ResultReceiver?): Unit

Called when the session sent a custom command.

Parameters
controller MediaController2: the controller for this event
command MediaController2:
args MediaController2:
receiver MediaController2:

onPlaylistChanged

open fun onPlaylistChanged(controller: MediaController2, list: MutableList<MediaItem2!>, metadata: MediaMetadata2?): Unit

Called when a playlist is changed.

Parameters
controller MediaController2: the controller for this event
list MediaController2: new playlist
metadata MediaController2: new metadata

onRoutesInfoChanged

open fun onRoutesInfoChanged(controller: MediaController2, routes: MutableList<Bundle!>?): Unit

Called when a property of the indicated media route has changed.

Parameters
controller MediaController2: the controller for this event
routes MediaController2: The list of Bundle from MediaRouteDescriptor.asBundle(). See MediaRouteDescriptor.fromBundle(Bundle bundle) to get MediaRouteDescriptor object from the routes

onCustomLayoutChanged

open fun onCustomLayoutChanged(controller: MediaController2, layout: MutableList<MediaSession2.CommandButton!>): Unit

Called when the session set the custom layout through the MediaSession2#setCustomLayout(ControllerInfo, List).

Can be called before #onConnected(MediaController2, SessionCommandGroup2) is called.

Parameters
controller MediaController2: the controller for this event
layout MediaController2:

onSeekCompleted

open fun onSeekCompleted(controller: MediaController2, position: Long): Unit

Called to indicate that seeking is completed.

Parameters
controller MediaController2: the controller for this event.
position MediaController2: the previous seeking request.

onPlayerStateChanged

open fun onPlayerStateChanged(controller: MediaController2, state: Int): Unit

Called when the player state is changed.

Parameters
controller MediaController2: the controller for this event
state MediaController2:

onCurrentMediaItemChanged

open fun onCurrentMediaItemChanged(controller: MediaController2, item: MediaItem2?): Unit

Called when the player's currently playing item is changed

When it's called, you should invalidate previous playback information and wait for later callbacks.

Parameters
controller MediaController2: the controller for this event
item MediaController2: new item

onPlaylistMetadataChanged

open fun onPlaylistMetadataChanged(controller: MediaController2, metadata: MediaMetadata2?): Unit

Called when a playlist metadata is changed.

Parameters
controller MediaController2: the controller for this event
metadata MediaController2: new metadata

onBufferingStateChanged

open fun onBufferingStateChanged(controller: MediaController2, item: MediaItem2, state: Int): Unit

Called to report buffering events for a data source.

Use #getBufferedPosition() for current buffering position.

Parameters
controller MediaController2: the controller for this event
item MediaController2: the media item for which buffering is happening.
state MediaController2: the new buffering state.

onConnected

open fun onConnected(controller: MediaController2, allowedCommands: SessionCommandGroup2): Unit

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

Parameters
controller MediaController2: the controller for this event
allowedCommands MediaController2: commands that's allowed by the session.

onShuffleModeChanged

open fun onShuffleModeChanged(controller: MediaController2, shuffleMode: Int): Unit

Called when the shuffle mode is changed.

Parameters
controller MediaController2: the controller for this event
shuffleMode MediaController2: repeat mode

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

onPlaybackSpeedChanged

open fun onPlaybackSpeedChanged(controller: MediaController2, speed: Float): Unit

Called when playback speed is changed.

Parameters
controller MediaController2: the controller for this event
speed MediaController2: speed

onError

open fun onError(controller: MediaController2, errorCode: Int, extras: Bundle?): Unit

Called when a error from

Parameters
controller MediaController2: the controller for this event
errorCode MediaController2: error code
extras MediaController2: extra information