lightbulb_outline Please take our October 2018 developer survey. Start survey

MediaPlayerConnector.PlayerEventCallback

public static abstract class MediaPlayerConnector.PlayerEventCallback
extends Object

java.lang.Object
   ↳ androidx.media2.MediaPlayerConnector.PlayerEventCallback


A callback class to receive notifications for events on the media player. See MediaPlayerConnector.registerPlayerEventCallback(Executor, PlayerEventCallback) to register this callback.

Summary

Public constructors

MediaPlayerConnector.PlayerEventCallback()

Public methods

void onBufferingStateChanged(MediaPlayerConnector mpb, DataSourceDesc2 dsd, int state)

Called to report buffering events for a data source.

void onCurrentDataSourceChanged(MediaPlayerConnector mpb, DataSourceDesc2 dsd)

Called when the player's current data source has changed.

void onMediaPrepared(MediaPlayerConnector mpb, DataSourceDesc2 dsd)

Called when the player is prepared, i.e.

void onPlaybackSpeedChanged(MediaPlayerConnector mpb, float speed)

Called to indicate that the playback speed has changed.

void onPlayerStateChanged(MediaPlayerConnector mpb, int state)

Called to indicate that the state of the player has changed.

void onSeekCompleted(MediaPlayerConnector mpb, long position)

Called to indicate that MediaPlayerConnector.seekTo(long) is completed.

Inherited methods

Public constructors

MediaPlayerConnector.PlayerEventCallback

public MediaPlayerConnector.PlayerEventCallback ()

Public methods

onBufferingStateChanged

public void onBufferingStateChanged (MediaPlayerConnector mpb, 
                DataSourceDesc2 dsd, 
                int state)

Called to report buffering events for a data source.

Parameters
mpb MediaPlayerConnector: the player that is buffering

dsd DataSourceDesc2: the data source for which buffering is happening.

state int: the new buffering state.

onCurrentDataSourceChanged

public void onCurrentDataSourceChanged (MediaPlayerConnector mpb, 
                DataSourceDesc2 dsd)

Called when the player's current data source has changed.

When the playback completes, and no other source is about to be played next (i.e. playback reached the end of the list of sources to play), this callback will be invoked with a null dsd.

Parameters
mpb MediaPlayerConnector: the player whose data source changed.

dsd DataSourceDesc2: the new current data source. null, if no more data sources available.

onMediaPrepared

public void onMediaPrepared (MediaPlayerConnector mpb, 
                DataSourceDesc2 dsd)

Called when the player is prepared, i.e. it is ready to play the content referenced by the given data source.

Parameters
mpb MediaPlayerConnector: the player that is prepared.

dsd DataSourceDesc2: the data source that the player is prepared to play.

onPlaybackSpeedChanged

public void onPlaybackSpeedChanged (MediaPlayerConnector mpb, 
                float speed)

Called to indicate that the playback speed has changed.

Parameters
mpb MediaPlayerConnector: the player that has changed the playback speed.

speed float: the new playback speed.

onPlayerStateChanged

public void onPlayerStateChanged (MediaPlayerConnector mpb, 
                int state)

Called to indicate that the state of the player has changed. See MediaPlayerConnector.getPlayerState() for polling the player state.

Parameters
mpb MediaPlayerConnector: the player whose state has changed.

state int: the new state of the player.

onSeekCompleted

public void onSeekCompleted (MediaPlayerConnector mpb, 
                long position)

Called to indicate that MediaPlayerConnector.seekTo(long) is completed.

Parameters
mpb MediaPlayerConnector: the player that has completed seeking.

position long: the previous seeking request.