SessionPlayer.PlayerCallback

Added in 1.0.0
Deprecated in 1.3.0

abstract class SessionPlayer.PlayerCallback

Known direct subclasses
MediaPlayer.PlayerCallback

This class is deprecated.

androidx.media2 is deprecated.

RemoteSessionPlayer.Callback

This class is deprecated.

androidx.media2 is deprecated.


A callback class to receive notifications for events on the session player. See registerPlayerCallback to register this callback.

Summary

Public constructors

Public functions

Unit
onAudioAttributesChanged(
    player: SessionPlayer,
    attributes: AudioAttributesCompat?
)

Called when the player's current audio attributes are changed.

Unit
onBufferingStateChanged(
    player: SessionPlayer,
    item: MediaItem?,
    buffState: Int
)

Called when a buffering events for a media item happened.

Unit

Called when the player's current media item has changed.

Unit

Called when the player finished playing.

Unit
onPlaybackSpeedChanged(player: SessionPlayer, playbackSpeed: Float)

Called when the playback speed has changed.

Unit
onPlayerStateChanged(player: SessionPlayer, playerState: Int)

Called when the state of the player has changed.

Unit
onPlaylistChanged(
    player: SessionPlayer,
    list: (Mutable)List<MediaItem!>?,
    metadata: MediaMetadata?
)

Called when a playlist is changed.

Unit

Called when a playlist metadata is changed.

Unit
onRepeatModeChanged(player: SessionPlayer, repeatMode: Int)

Called when the repeat mode is changed.

Unit
onSeekCompleted(player: SessionPlayer, position: Long)

Called when seekTo is completed.

Unit
onShuffleModeChanged(player: SessionPlayer, shuffleMode: Int)

Called when the shuffle mode is changed.

Unit
onSubtitleData(
    player: SessionPlayer,
    item: MediaItem,
    track: SessionPlayer.TrackInfo,
    data: SubtitleData
)

Called when the player's subtitle track has new subtitle data available.

Unit
onTrackDeselected(
    player: SessionPlayer,
    trackInfo: SessionPlayer.TrackInfo
)

Called when a track is deselected.

Unit
onTrackSelected(
    player: SessionPlayer,
    trackInfo: SessionPlayer.TrackInfo
)

Called when a track is selected.

Unit
onTracksChanged(
    player: SessionPlayer,
    tracks: (Mutable)List<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.

Unit

Called to indicate the video size

Public constructors

PlayerCallback

Added in 1.0.0
Deprecated in 1.3.0
PlayerCallback()

Public functions

onAudioAttributesChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onAudioAttributesChanged(
    player: SessionPlayer,
    attributes: AudioAttributesCompat?
): Unit

Called when the player's current audio attributes are changed.

Parameters
player: SessionPlayer

the player whose audio attributes are changed

attributes: AudioAttributesCompat?

the new current audio attributes

onBufferingStateChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onBufferingStateChanged(
    player: SessionPlayer,
    item: MediaItem?,
    buffState: Int
): Unit

Called when a buffering events for a media item happened.

Parameters
player: SessionPlayer

the player that is buffering

item: MediaItem?

the media item for which buffering is happening

buffState: Int

the new buffering state

onCurrentMediaItemChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onCurrentMediaItemChanged(player: SessionPlayer, item: MediaItem?): Unit

Called when the player's current media item has changed. Generally called after a new media item is set through setPlaylist or setMediaItem, or after skipping to a different item in a given playlist.

Parameters
player: SessionPlayer

the player whose media item changed

item: MediaItem?

the new current media item. This can be null when the state of the player becomes PLAYER_STATE_IDLE.

onPlaybackCompleted

Added in 1.0.0
Deprecated in 1.3.0
fun onPlaybackCompleted(player: SessionPlayer): Unit

Called when the player finished playing. Playback state would be also set PLAYER_STATE_PAUSED with it.

This will be called only when the repeat mode is set to REPEAT_MODE_NONE.

Parameters
player: SessionPlayer

the player whose playback is completed

See also
REPEAT_MODE_NONE

onPlaybackSpeedChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onPlaybackSpeedChanged(player: SessionPlayer, playbackSpeed: Float): Unit

Called when the playback speed has changed.

Parameters
player: SessionPlayer

the player that has changed the playback speed

playbackSpeed: Float

the new playback speed

See also
getPlaybackSpeed

onPlayerStateChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onPlayerStateChanged(player: SessionPlayer, playerState: Int): Unit

Called when the state of the player has changed.

Parameters
player: SessionPlayer

the player whose state has changed

playerState: Int

the new state of the player

See also
getPlayerState

onPlaylistChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onPlaylistChanged(
    player: SessionPlayer,
    list: (Mutable)List<MediaItem!>?,
    metadata: MediaMetadata?
): Unit

Called when a playlist is changed. It's also called after setPlaylist or setMediaItem.

Parameters
player: SessionPlayer

the player that has changed the playlist and playlist metadata

list: (Mutable)List<MediaItem!>?

new playlist

metadata: MediaMetadata?

new metadata

onPlaylistMetadataChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onPlaylistMetadataChanged(player: SessionPlayer, metadata: MediaMetadata?): Unit

Called when a playlist metadata is changed.

Parameters
player: SessionPlayer

the player that has changed the playlist metadata

metadata: MediaMetadata?

new metadata

onRepeatModeChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onRepeatModeChanged(player: SessionPlayer, repeatMode: Int): Unit

Called when the repeat mode is changed.

getPreviousMediaItemIndex and getNextMediaItemIndex values can be outdated when this callback is called if the current media item is the first or last item in the playlist.

Parameters
player: SessionPlayer

player for this event

repeatMode: Int

repeat mode

onSeekCompleted

Added in 1.0.0
Deprecated in 1.3.0
fun onSeekCompleted(player: SessionPlayer, position: Long): Unit

Called when seekTo is completed.

Parameters
player: SessionPlayer

the player that has completed seeking

position: Long

the previous seeking request

onShuffleModeChanged

Added in 1.0.0
Deprecated in 1.3.0
fun onShuffleModeChanged(player: SessionPlayer, shuffleMode: Int): Unit

Called when the shuffle mode is changed.

getPreviousMediaItemIndex and getNextMediaItemIndex values can be outdated when this callback is called if the current media item is the first or last item in the playlist.

Parameters
player: SessionPlayer

playlist agent for this event

shuffleMode: Int

shuffle mode

onSubtitleData

Added in 1.1.0
Deprecated in 1.3.0
fun onSubtitleData(
    player: SessionPlayer,
    item: MediaItem,
    track: SessionPlayer.TrackInfo,
    data: SubtitleData
): Unit

Called when the player's subtitle track has new subtitle data available.

Parameters
player: SessionPlayer

the player that reports the new subtitle data

item: MediaItem

the MediaItem of this media item

track: SessionPlayer.TrackInfo

the track that has the subtitle data

data: SubtitleData

the subtitle data

onTrackDeselected

Added in 1.1.0
Deprecated in 1.3.0
fun onTrackDeselected(
    player: SessionPlayer,
    trackInfo: SessionPlayer.TrackInfo
): Unit

Called when a track is deselected.

This callback will generally be called only after calling deselectTrack.

Parameters
player: SessionPlayer

the player associated with this callback

trackInfo: SessionPlayer.TrackInfo

the deselected track

See also
deselectTrack

onTrackSelected

Added in 1.1.0
Deprecated in 1.3.0
fun onTrackSelected(
    player: SessionPlayer,
    trackInfo: SessionPlayer.TrackInfo
): Unit

Called when a track is selected.

Parameters
player: SessionPlayer

the player associated with this callback

trackInfo: SessionPlayer.TrackInfo

the selected track

See also
selectTrack

onTracksChanged

Added in 1.1.0
Deprecated in 1.3.0
fun onTracksChanged(
    player: SessionPlayer,
    tracks: (Mutable)List<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 or deselectTrack.

Parameters
player: SessionPlayer

the player associated with this callback

tracks: (Mutable)List<SessionPlayer.TrackInfo!>

the list of tracks. It can be empty

See also
getTracks

onVideoSizeChanged

Added in 1.1.0
Deprecated in 1.3.0
fun onVideoSizeChanged(player: SessionPlayer, size: VideoSize): Unit

Called to indicate the video size

The video size (width and height) could be 0 if there was no video, no display surface was set, or the value was not determined yet.

This callback is generally called when player updates video size, but will also be called when onCurrentMediaItemChanged is called.

Parameters
player: SessionPlayer

the player associated with this callback

size: VideoSize

the size of the video

See also
getVideoSize