Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

PlayerEventCallback

abstract class PlayerEventCallback
kotlin.Any
   ↳ 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

A callback class to receive notifications for events on the media player.

Public methods
open Unit
onSeekCompleted(@NonNull mpb: MediaPlayerConnector, position: Long)

Called to indicate that seekTo(long) is completed.

open Unit
onMediaPrepared(@NonNull mpb: MediaPlayerConnector, @NonNull dsd: DataSourceDesc2)

Called when the player is prepared, i.

open Unit

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

open Unit

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

open Unit
onBufferingStateChanged(@NonNull mpb: MediaPlayerConnector, @NonNull dsd: DataSourceDesc2, state: Int)

Called to report buffering events for a data source.

open Unit

Called to indicate that the playback speed has changed.

Public constructors

<init>

PlayerEventCallback()

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

Public methods

onSeekCompleted

open fun onSeekCompleted(@NonNull mpb: MediaPlayerConnector, position: Long): Unit

Called to indicate that seekTo(long) is completed.

Parameters
mpb MediaPlayerConnector: the player that has completed seeking.
position MediaPlayerConnector: the previous seeking request.

See Also

onMediaPrepared

open fun onMediaPrepared(@NonNull mpb: MediaPlayerConnector, @NonNull dsd: DataSourceDesc2): Unit

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 MediaPlayerConnector: the data source that the player is prepared to play.

onCurrentDataSourceChanged

open fun onCurrentDataSourceChanged(@NonNull mpb: MediaPlayerConnector, @Nullable dsd: DataSourceDesc2?): Unit

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 MediaPlayerConnector: the new current data source. null, if no more data sources available.

onPlayerStateChanged

open fun onPlayerStateChanged(@NonNull mpb: MediaPlayerConnector, state: Int): Unit

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 MediaPlayerConnector: the new state of the player.

onBufferingStateChanged

open fun onBufferingStateChanged(@NonNull mpb: MediaPlayerConnector, @NonNull dsd: DataSourceDesc2, state: Int): Unit

Called to report buffering events for a data source.

Parameters
mpb MediaPlayerConnector: the player that is buffering
dsd MediaPlayerConnector: the data source for which buffering is happening.
state MediaPlayerConnector: the new buffering state.

onPlaybackSpeedChanged

open fun onPlaybackSpeedChanged(@NonNull mpb: MediaPlayerConnector, speed: Float): Unit

Called to indicate that the playback speed has changed.

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