belongs to Maven artifact androidx.media2:media2:1.0.0-alpha01

BaseMediaPlayer.PlayerEventCallback

public static abstract class BaseMediaPlayer.PlayerEventCallback
extends Object

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


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

Summary

Public constructors

BaseMediaPlayer.PlayerEventCallback()

Public methods

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

Called to report buffering events for a data source.

void onCurrentDataSourceChanged(BaseMediaPlayer mpb, DataSourceDesc2 dsd)

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

void onMediaPrepared(BaseMediaPlayer mpb, DataSourceDesc2 dsd)

Called when the player is prepared, i.e.

void onPlaybackSpeedChanged(BaseMediaPlayer mpb, float speed)

Called to indicate that the playback speed has changed.

void onPlayerStateChanged(BaseMediaPlayer mpb, int state)

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

void onSeekCompleted(BaseMediaPlayer mpb, long position)

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

Inherited methods

Public constructors

BaseMediaPlayer.PlayerEventCallback

public BaseMediaPlayer.PlayerEventCallback ()

Public methods

onBufferingStateChanged

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

Called to report buffering events for a data source.

Parameters
mpb BaseMediaPlayer: 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 (BaseMediaPlayer 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 BaseMediaPlayer: the player whose data source changed.

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

onMediaPrepared

public void onMediaPrepared (BaseMediaPlayer 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 BaseMediaPlayer: the player that is prepared.

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

onPlaybackSpeedChanged

public void onPlaybackSpeedChanged (BaseMediaPlayer mpb, 
                float speed)

Called to indicate that the playback speed has changed.

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

speed float: the new playback speed.

onPlayerStateChanged

public void onPlayerStateChanged (BaseMediaPlayer mpb, 
                int state)

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

Parameters
mpb BaseMediaPlayer: the player whose state has changed.

state int: the new state of the player.

onSeekCompleted

public void onSeekCompleted (BaseMediaPlayer mpb, 
                long position)

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

Parameters
mpb BaseMediaPlayer: the player that has completed seeking.

position long: the previous seeking request.