Google is committed to advancing racial equity for Black communities. See how.

ControllerCallback

abstract class ControllerCallback
kotlin.Any
   ↳ androidx.media2.session.MediaController.ControllerCallback

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

Summary

Public constructors

Interface for listening to change in activeness of the MediaSession.

Public methods
open Unit
onAllowedCommandsChanged(@NonNull controller: MediaController, @NonNull commands: SessionCommandGroup)

Called when the allowed commands are changed by session.

open Unit
onBufferingStateChanged(@NonNull controller: MediaController, @NonNull item: MediaItem, state: Int)

Called to report buffering events for a media item.

open Unit
onConnected(@NonNull controller: MediaController, @NonNull allowedCommands: SessionCommandGroup)

Called when the controller is successfully connected to the session.

open Unit
onCurrentMediaItemChanged(@NonNull controller: MediaController, @Nullable item: MediaItem?)

Called when the current item is changed.

open SessionResult
onCustomCommand(@NonNull controller: MediaController, @NonNull command: SessionCommand, @Nullable args: Bundle?)

Called when the session sent a custom command.

open Unit
onDisconnected(@NonNull controller: MediaController)

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

open Unit
onPlaybackCompleted(@NonNull controller: MediaController)

Called when the playback is completed.

open Unit

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

open Unit
onPlaybackSpeedChanged(@NonNull controller: MediaController, speed: Float)

Called when playback speed is changed.

open Unit
onPlayerStateChanged(@NonNull controller: MediaController, state: Int)

Called when the player state is changed.

open Unit
onPlaylistChanged(@NonNull controller: MediaController, @Nullable list: MutableList<MediaItem!>?, @Nullable metadata: MediaMetadata?)

Called when a playlist is changed.

open Unit
onPlaylistMetadataChanged(@NonNull controller: MediaController, @Nullable metadata: MediaMetadata?)

Called when a playlist metadata is changed.

open Unit
onRepeatModeChanged(@NonNull controller: MediaController, repeatMode: Int)

Called when the repeat mode is changed.

open Unit
onSeekCompleted(@NonNull controller: MediaController, position: Long)

Called to indicate that seeking is completed.

open Int
onSetCustomLayout(@NonNull controller: MediaController, @NonNull layout: MutableList<MediaSession.CommandButton!>)

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

open Unit
onShuffleModeChanged(@NonNull controller: MediaController, shuffleMode: Int)

Called when the shuffle mode is changed.

open Unit
onSubtitleData(@NonNull controller: MediaController, @NonNull item: MediaItem, @NonNull track: SessionPlayer.TrackInfo, @NonNull data: SubtitleData)

Called when the subtitle track has new subtitle data available.

open Unit
onTrackDeselected(@NonNull controller: MediaController, @NonNull trackInfo: SessionPlayer.TrackInfo)

Called when a track is deselected.

open Unit
onTrackSelected(@NonNull controller: MediaController, @NonNull trackInfo: SessionPlayer.TrackInfo)

Called when a track is selected.

open Unit
onTracksChanged(@NonNull controller: MediaController, @NonNull tracks: MutableList<SessionPlayer.TrackInfo!>)

Called when the tracks of the current media item is changed such as 1) when tracks of a media item become available, 2) when new tracks are found during playback, or 3) when the current media item is changed.

open Unit
onVideoSizeChanged(@NonNull controller: MediaController, @NonNull videoSize: VideoSize)

Called when video size is changed.

Public constructors

<init>

ControllerCallback()

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

Public methods

onAllowedCommandsChanged

open fun onAllowedCommandsChanged(
    @NonNull controller: MediaController,
    @NonNull commands: SessionCommandGroup
): Unit

Called when the allowed commands are changed by session.

Parameters
controller MediaController: the controller for this event
commands SessionCommandGroup: newly allowed commands

onBufferingStateChanged

open fun onBufferingStateChanged(
    @NonNull controller: MediaController,
    @NonNull item: MediaItem,
    state: Int
): Unit

Called to report buffering events for a media item.

Use getBufferedPosition() for current buffering position.

Parameters
controller MediaController: the controller for this event
item MediaItem: the media item for which buffering is happening
state Int: the new buffering state

onConnected

open fun onConnected(
    @NonNull controller: MediaController,
    @NonNull allowedCommands: