public abstract class

SessionPlayer.PlayerCallback

extends java.lang.Object

 java.lang.Object

↳androidx.media2.SessionPlayer.PlayerCallback

Subclasses:

RemoteSessionPlayer.Callback, MediaPlayer.PlayerCallback

Overview

A callback class to receive notifications for events on the session player. See SessionPlayer.registerPlayerCallback(Executor, SessionPlayer.PlayerCallback) to register this callback.

Summary

Constructors
publicPlayerCallback()

Methods
public voidonAudioAttributesChanged(SessionPlayer player, AudioAttributesCompat attributes)

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

public voidonBufferingStateChanged(SessionPlayer player, MediaItem item, int buffState)

Called when a buffering events for a media item happened.

public voidonCurrentMediaItemChanged(SessionPlayer player, MediaItem item)

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

public voidonPlaybackCompleted(SessionPlayer player)

Called when the player finished playing.

public voidonPlaybackSpeedChanged(SessionPlayer player, float playbackSpeed)

Called when the playback speed has changed.

public voidonPlayerStateChanged(SessionPlayer player, int playerState)

Called when the state of the player has changed.

public voidonPlaylistChanged(SessionPlayer player, java.util.List<MediaItem> list, MediaMetadata metadata)

Called when a playlist is changed.

public voidonPlaylistMetadataChanged(SessionPlayer player, MediaMetadata metadata)

Called when a playlist metadata is changed.

public voidonRepeatModeChanged(SessionPlayer player, int repeatMode)

Called when the repeat mode is changed.

public voidonSeekCompleted(SessionPlayer player, long position)

Called when SessionPlayer.seekTo(long) is completed.

public voidonShuffleModeChanged(SessionPlayer player, int shuffleMode)

Called when the shuffle mode is changed.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public PlayerCallback()

Methods

public void onPlayerStateChanged(SessionPlayer player, int playerState)

Called when the state of the player has changed.

Parameters:

player: the player whose state has changed.
playerState: the new state of the player.

See also: ()

public void onBufferingStateChanged(SessionPlayer player, MediaItem item, int buffState)

Called when a buffering events for a media item happened.

Parameters:

player: the player that is buffering
item: the media item for which buffering is happening.
buffState: the new buffering state.

See also: SessionPlayer.getBufferingState()

public void onPlaybackSpeedChanged(SessionPlayer player, float playbackSpeed)

Called when the playback speed has changed.

Parameters:

player: the player that has changed the playback speed.
playbackSpeed: the new playback speed.

See also: SessionPlayer.getPlaybackSpeed()

public void onSeekCompleted(SessionPlayer player, long position)

Called when SessionPlayer.seekTo(long) is completed.

Parameters:

player: the player that has completed seeking.
position: the previous seeking request.

See also: SessionPlayer.getCurrentPosition()

public void onPlaylistChanged(SessionPlayer player, java.util.List<MediaItem> list, MediaMetadata metadata)

Called when a playlist is changed.

Parameters:

player: the player that has changed the playlist and playlist metadata.
list: new playlist
metadata: new metadata

See also: SessionPlayer.getPlaylist(), SessionPlayer.getPlaylistMetadata()

public void onPlaylistMetadataChanged(SessionPlayer player, MediaMetadata metadata)

Called when a playlist metadata is changed.

Parameters:

player: the player that has changed the playlist metadata.
metadata: new metadata

See also: SessionPlayer.getPlaylistMetadata()

public void onShuffleModeChanged(SessionPlayer player, int shuffleMode)

Called when the shuffle mode is changed.

Parameters:

player: playlist agent for this event
shuffleMode: shuffle mode

See also: SessionPlayer.SHUFFLE_MODE_NONE, SessionPlayer.SHUFFLE_MODE_ALL, SessionPlayer.SHUFFLE_MODE_GROUP, SessionPlayer.getShuffleMode()

public void onRepeatModeChanged(SessionPlayer player, int repeatMode)

Called when the repeat mode is changed.

Parameters:

player: player for this event
repeatMode: repeat mode

See also: SessionPlayer.REPEAT_MODE_NONE, SessionPlayer.REPEAT_MODE_ONE, SessionPlayer.REPEAT_MODE_ALL, SessionPlayer.REPEAT_MODE_GROUP, SessionPlayer.getRepeatMode()

public void onCurrentMediaItemChanged(SessionPlayer player, MediaItem item)

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

Parameters:

player: the player whose media item changed.
item: the new current media item.

See also: SessionPlayer.getCurrentMediaItem()

public void onPlaybackCompleted(SessionPlayer player)

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

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

Parameters:

player: the player whose playback is completed.

See also: SessionPlayer.REPEAT_MODE_NONE

public void onAudioAttributesChanged(SessionPlayer player, AudioAttributesCompat attributes)

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

Parameters:

player: the player whose audio attributes are changed.
attributes: the new current audio attributes

See also: SessionPlayer.getAudioAttributes()