public abstract class

MediaPlayer2.EventCallback

extends java.lang.Object

 java.lang.Object

↳androidx.media2.MediaPlayer2.EventCallback

Overview

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

Summary

Constructors
publicEventCallback()

Methods
public voidonCallCompleted(MediaPlayer2 mp, MediaItem item, int what, int status)

Called to acknowledge an API call.

public voidonCommandLabelReached(MediaPlayer2 mp, java.lang.Object label)

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

public voidonError(MediaPlayer2 mp, MediaItem item, int what, int extra)

Called to indicate an error.

public voidonInfo(MediaPlayer2 mp, MediaItem item, int what, int extra)

Called to indicate an info or a warning.

public voidonMediaTimeDiscontinuity(MediaPlayer2 mp, MediaItem item, MediaTimestamp timestamp)

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

public voidonSubtitleData(MediaPlayer2 mp, MediaItem item, SubtitleData data)

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

public voidonTimedMetaDataAvailable(MediaPlayer2 mp, MediaItem item, TimedMetaData data)

Called to indicate available timed metadata

public voidonVideoSizeChanged(MediaPlayer2 mp, MediaItem item, 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.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public EventCallback()

Methods

public void onVideoSizeChanged(MediaPlayer2 mp, MediaItem item, 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: the MediaPlayer2 associated with this callback
item: the MediaItem of this media item
width: the width of the video
height: the height of the video

public void onTimedMetaDataAvailable(MediaPlayer2 mp, MediaItem item, 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: the MediaPlayer2 associated with this callback
item: the MediaItem of this media item
data: the timed metadata sample associated with this event

See also: MediaPlayer2.selectTrack(int), TimedMetaData

public void onError(MediaPlayer2 mp, MediaItem item, int what, int extra)

Called to indicate an error.

Parameters:

mp: the MediaPlayer2 the error pertains to
item: the MediaItem of this media item
what: the type of error that has occurred.
extra: an extra code, specific to the error. Typically implementation dependent.

public void onInfo(MediaPlayer2 mp, MediaItem item, int what, int extra)

Called to indicate an info or a warning.

Parameters:

mp: the MediaPlayer2 the info pertains to.
item: the MediaItem of this media item
what: the type of info or warning.
extra: an extra code, specific to the info. Typically implementation dependent.

public void onCallCompleted(MediaPlayer2 mp, MediaItem item, int what, int status)

Called to acknowledge an API call.

Parameters:

mp: the MediaPlayer2 the call was made on.
item: the MediaItem of this media item
what: the enum for the API call.
status: the returned status code for the call.

public void onMediaTimeDiscontinuity(MediaPlayer2 mp, MediaItem item, 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: the MediaPlayer2 the media time pertains to.
item: the MediaItem of this media item
timestamp: the timestamp that correlates media time, system time and clock rate, or MediaTimestamp.TIMESTAMP_UNKNOWN in an error case.

public void onCommandLabelReached(MediaPlayer2 mp, java.lang.Object label)

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

Parameters:

mp: the MediaPlayer2 MediaPlayer2.notifyWhenCommandLabelReached(Object) was called on.
label: the application specific Object given by MediaPlayer2.notifyWhenCommandLabelReached(Object).

public void onSubtitleData(MediaPlayer2 mp, MediaItem item, SubtitleData data)

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

Parameters:

mp: the player that reports the new subtitle data
item: the MediaItem of this media item
data: the subtitle data