Google は、黒人コミュニティに対する人種平等の促進に取り組んでいます。取り組みを見る

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: SessionCommandGroup
): Unit

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

Parameters
controller MediaController: the controller for this event
allowedCommands SessionCommandGroup: commands that's allowed by the session

onCurrentMediaItemChanged

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

Called when the current item is changed. It's also called after setPlaylist or setMediaItem. Also called when MediaItem#setMetadata(MediaMetadata) is called on the current media item.

When it's called, you should invalidate previous playback information and wait for later callbacks. Also, current, previous, and next media item indices may need to be updated.

Parameters
controller MediaController: the controller for this event
item MediaItem?: new current media item

onCustomCommand

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

Called when the session sent a custom command. Returns a SessionResult for session to get notification back. If the null is returned, SessionResult#RESULT_ERROR_UNKNOWN will be returned.

Default implementation returns SessionResult#RESULT_ERROR_NOT_SUPPORTED.

Parameters
controller MediaController: the controller for this event
command SessionCommand:
args Bundle?:
Return
SessionResult result of handling custom command

onDisconnected

open fun onDisconnected(@NonNull controller: MediaController): 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 MediaController: the controller for this event

onPlaybackCompleted

open fun onPlaybackCompleted(@NonNull controller: MediaController): Unit

Called when the playback is completed.

Parameters
controller MediaController: the controller for this event

onPlaybackInfoChanged

open fun onPlaybackInfoChanged(
    @NonNull controller: MediaController,
    @NonNull info: MediaController.PlaybackInfo
): Unit

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

Interoperability: When connected to android.support.v4.media.session.MediaSessionCompat, this may be called when the session changes playback info by calling android.support.v4.media.session.MediaSessionCompat#setPlaybackToLocal(int) or android.support.v4.media.session.MediaSessionCompat#setPlaybackToRemote( * VolumeProviderCompat)}. Specifically:

  • Prior to API 21, this will always be called whenever any of those two methods is called.
  • From API 21 to 22, this is called only when the playback type is changed from local to remote (i.e. not from remote to local).
  • From API 23, this is called only when the playback type is changed.
Parameters
controller MediaController: the controller for this event
info MediaController.PlaybackInfo: new playback info

onPlaybackSpeedChanged

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

Called when playback speed is changed.

Parameters
controller MediaController: the controller for this event
speed Float: speed

onPlayerStateChanged

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

Called when the player state is changed.

Parameters
controller MediaController: the controller for this event
state Int: the new player state

onPlaylistChanged

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

Called when a playlist is changed. It's also called after setPlaylist or setMediaItem. Also called when MediaItem#setMetadata(MediaMetadata) is called on a media item that is contained in the current playlist.

When it's called, current, previous, and next media item indices may need to be updated.

Parameters
controller MediaController: the controller for this event
list MutableList<MediaItem!>?: new playlist
metadata MediaMetadata?: new metadata

onPlaylistMetadataChanged

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

Called when a playlist metadata is changed.

Parameters
controller MediaController: the controller for this event
metadata MediaMetadata?: new metadata

onRepeatModeChanged

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

Called when the repeat mode is changed.

Parameters
controller MediaController: the controller for this event
repeatMode Int: repeat mode

onSeekCompleted

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

Called to indicate that seeking is completed.

Parameters
controller MediaController: the controller for this event
position Long: the previous seeking request

onSetCustomLayout

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

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

Can be called before onConnected(MediaController, SessionCommandGroup) is called.

Default implementation returns SessionResult#RESULT_ERROR_NOT_SUPPORTED.

Parameters
controller MediaController: the controller for this event
layout MutableList<MediaSession.CommandButton!>:

onShuffleModeChanged

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

Called when the shuffle mode is changed.

Parameters
controller MediaController: the controller for this event
shuffleMode Int: repeat mode

onSubtitleData

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

Called when the subtitle track has new subtitle data available.

Parameters
controller MediaController: the controller for this event
item MediaItem: the MediaItem of this media item
track SessionPlayer.TrackInfo: the track that has the subtitle data
data SubtitleData: the subtitle data

onTrackDeselected

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

Called when a track is deselected.

The types of tracks supported may vary based on player implementation, but generally a track should already be selected in order to be deselected and audio and video tracks should not be deselected.

Parameters
controller MediaController: the controller for this event
trackInfo SessionPlayer.TrackInfo: the deselected track

onTrackSelected

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

Called when a track is selected.

The types of tracks supported may vary based on player implementation, but generally one track will be selected for each track type.

Parameters
controller MediaController: the controller for this event
trackInfo SessionPlayer.TrackInfo: the selected track

onTracksChanged

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

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.

When it's called, you should invalidate previous track information and use the new tracks to call selectTrack(TrackInfo) or deselectTrack(TrackInfo).

The types of tracks supported may vary based on player implementation.

Parameters
controller MediaController: the controller for this event
tracks MutableList<SessionPlayer.TrackInfo!>: the list of tracks. It can be empty.

onVideoSizeChanged

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

Called when video size is changed.

Parameters
controller MediaController: the controller for this event
videoSize VideoSize: the size of video