belongs to Maven artifact androidx.media:media:1.0.0-alpha1

MediaPlayer2.MediaPlayer2EventCallback

public static abstract class MediaPlayer2.MediaPlayer2EventCallback
extends Object

java.lang.Object
   ↳ androidx.media.MediaPlayer2.MediaPlayer2EventCallback


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

Summary

Public constructors

MediaPlayer2.MediaPlayer2EventCallback()

Public methods

void onCallCompleted(MediaPlayer2 mp, DataSourceDesc 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, DataSourceDesc dsd, int what, int extra)

Called to indicate an error.

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

Called to indicate an info or a warning.

void onMediaTimeDiscontinuity(MediaPlayer2 mp, DataSourceDesc dsd, MediaTimestamp timestamp)

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

void onSubtitleData(MediaPlayer2 mp, DataSourceDesc dsd, SubtitleData data)

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

void onTimedMetaDataAvailable(MediaPlayer2 mp, DataSourceDesc dsd, TimedMetaData 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, DataSourceDesc 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.MediaPlayer2EventCallback

MediaPlayer2.MediaPlayer2EventCallback ()

Public methods

onCallCompleted

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

Called to acknowledge an API call.

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

dsd DataSourceDesc: the DataSourceDesc of this data source

what int: the enum for the API call.

status int: the returned status code for the call.

onCommandLabelReached

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

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

Called to indicate an error.

Parameters
mp MediaPlayer2: the MediaPlayer2 the error pertains to

dsd DataSourceDesc: the DataSourceDesc 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

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

Called to indicate an info or a warning.

Parameters
mp MediaPlayer2: the MediaPlayer2 the info pertains to.

dsd DataSourceDesc: the DataSourceDesc 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

void onMediaTimeDiscontinuity (MediaPlayer2 mp, 
                DataSourceDesc dsd, 
                MediaTimestamp 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 DataSourceDesc: the DataSourceDesc of this data source

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

onSubtitleData

void onSubtitleData (MediaPlayer2 mp, 
                DataSourceDesc dsd, 
                SubtitleData 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 DataSourceDesc: the DataSourceDesc of this data source

data SubtitleData: the subtitle data

onTimedMetaDataAvailable

void onTimedMetaDataAvailable (MediaPlayer2 mp, 
                DataSourceDesc dsd, 
                TimedMetaData 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 TimedMetaData.

Parameters
mp MediaPlayer2: the MediaPlayer2 associated with this callback

dsd DataSourceDesc: the DataSourceDesc of this data source

data TimedMetaData: the timed metadata sample associated with this event

onVideoSizeChanged

void onVideoSizeChanged (MediaPlayer2 mp, 
                DataSourceDesc 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 DataSourceDesc: the DataSourceDesc of this data source

width int: the width of the video

height int: the height of the video