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

MediaPlayer2.EventCallback

public static abstract class MediaPlayer2.EventCallback
extends Object

java.lang.Object
   ↳ androidx.media2.MediaPlayer2.EventCallback


Interface definition for callbacks to be invoked when the player has the corresponding events.

Summary

Public constructors

MediaPlayer2.EventCallback()

Public methods

void onCallCompleted(MediaPlayer2 mp, DataSourceDesc2 dsd, int what, int status)

Called to acknowledge an API call.

void onCommandLabelReached(MediaPlayer2 mp, Object label)

Called to indicate MediaPlayer2.notifyWhenCommandLabelReached(Object) has been processed.

void onError(MediaPlayer2 mp, DataSourceDesc2 dsd, int what, int extra)

Called to indicate an error.

void onInfo(MediaPlayer2 mp, DataSourceDesc2 dsd, int what, int extra)

Called to indicate an info or a warning.

void onMediaTimeDiscontinuity(MediaPlayer2 mp, DataSourceDesc2 dsd, MediaTimestamp2 timestamp)

Called when a discontinuity in the normal progression of the media time is detected.

void onSubtitleData(MediaPlayer2 mp, DataSourceDesc2 dsd, SubtitleData2 data)

Called when when a player subtitle track has new subtitle data available.

void onTimedMetaDataAvailable(MediaPlayer2 mp, DataSourceDesc2 dsd, TimedMetaData2 data)

Called to indicate available timed metadata

This method will be called as timed metadata is extracted from the media, in the same order as it occurs in the media.

void onVideoSizeChanged(MediaPlayer2 mp, DataSourceDesc2 dsd, int width, int height)

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.

Inherited methods

Public constructors

MediaPlayer2.EventCallback

public MediaPlayer2.EventCallback ()

Public methods

onCallCompleted

public void onCallCompleted (MediaPlayer2 mp, 
                DataSourceDesc2 dsd, 
                int what, 
                int status)

Called to acknowledge an API call.

Parameters
mp MediaPlayer2: the MediaPlayer2 the call was made on.

dsd DataSourceDesc2: the DataSourceDesc2 of this data source

what int: the enum for the API call.

status int: the returned status code for the call.

onCommandLabelReached

public void onCommandLabelReached (MediaPlayer2 mp, 
                Object label)

Called to indicate MediaPlayer2.notifyWhenCommandLabelReached(Object) has been processed.

Parameters
mp MediaPlayer2: the MediaPlayer2 MediaPlayer2.notifyWhenCommandLabelReached(Object) was called on.

label Object: the application specific Object given by MediaPlayer2.notifyWhenCommandLabelReached(Object).

onError

public void onError (MediaPlayer2 mp, 
                DataSourceDesc2 dsd, 
                int what, 
                int extra)

Called to indicate an error.

Parameters
mp MediaPlayer2: the MediaPlayer2 the error pertains to

dsd DataSourceDesc2: the DataSourceDesc2 of this data source

what int: the type of error that has occurred.

extra int: an extra code, specific to the error. Typically implementation dependent.

onInfo

public void onInfo (MediaPlayer2 mp, 
                DataSourceDesc2 dsd, 
                int what, 
                int extra)

Called to indicate an info or a warning.

Parameters
mp MediaPlayer2: the MediaPlayer2 the info pertains to.

dsd DataSourceDesc2: the DataSourceDesc2 of this data source

what int: the type of info or warning.

extra int: an extra code, specific to the info. Typically implementation dependent.

onMediaTimeDiscontinuity

public void onMediaTimeDiscontinuity (MediaPlayer2 mp, 
                DataSourceDesc2 dsd, 
                MediaTimestamp2 timestamp)

Called when a discontinuity in the normal progression of the media time is detected. The "normal progression" of media time is defined as the expected increase of the playback position when playing media, relative to the playback speed (for instance every second, media time increases by two seconds when playing at 2x).
Discontinuities are encountered in the following cases:

  • when the player is starved for data and cannot play anymore
  • when the player encounters a playback error
  • when the a seek operation starts, and when it's completed
  • when the playback speed changes
  • when the playback state changes
  • when the player is reset

Parameters
mp MediaPlayer2: the MediaPlayer2 the media time pertains to.

dsd DataSourceDesc2: the DataSourceDesc2 of this data source

timestamp MediaTimestamp2: the timestamp that correlates media time, system time and clock rate, or MediaTimestamp2.TIMESTAMP_UNKNOWN in an error case.

onSubtitleData

public void onSubtitleData (MediaPlayer2 mp, 
                DataSourceDesc2 dsd, 
                SubtitleData2 data)

Called when when a player subtitle track has new subtitle data available.

Parameters
mp MediaPlayer2: the player that reports the new subtitle data

dsd DataSourceDesc2: the DataSourceDesc2 of this data source

data SubtitleData2: the subtitle data

onTimedMetaDataAvailable

public void onTimedMetaDataAvailable (MediaPlayer2 mp, 
                DataSourceDesc2 dsd, 
                TimedMetaData2 data)

Called to indicate available timed metadata

This method will be called as timed metadata is extracted from the media, in the same order as it occurs in the media. The timing of this event is not controlled by the associated timestamp.

Currently only HTTP live streaming data URI's embedded with timed ID3 tags generates TimedMetaData2.

Parameters
mp MediaPlayer2: the MediaPlayer2 associated with this callback

dsd DataSourceDesc2: the DataSourceDesc2 of this data source

data TimedMetaData2: the timed metadata sample associated with this event

onVideoSizeChanged

public void onVideoSizeChanged (MediaPlayer2 mp, 
                DataSourceDesc2 dsd, 
                int width, 
                int height)

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.

Parameters
mp MediaPlayer2: the MediaPlayer2 associated with this callback

dsd DataSourceDesc2: the DataSourceDesc2 of this data source

width int: the width of the video

height int: the height of the video