MediaPlayer.PlayerCallback
public
static
abstract
class
MediaPlayer.PlayerCallback
extends SessionPlayer.PlayerCallback
java.lang.Object | ||
↳ | androidx.media2.common.SessionPlayer.PlayerCallback | |
↳ | androidx.media2.player.MediaPlayer.PlayerCallback |
Interface definition for callbacks to be invoked when the player has the corresponding events.
Summary
Public constructors | |
---|---|
PlayerCallback()
|
Public methods | |
---|---|
void
|
onError(MediaPlayer mp, MediaItem item, int what, int extra)
Called to indicate an error. |
void
|
onInfo(MediaPlayer mp, MediaItem item, int what, int extra)
Called to indicate an info or a warning. |
void
|
onMediaTimeDiscontinuity(MediaPlayer mp, MediaItem item, MediaTimestamp timestamp)
Called when a discontinuity in the normal progression of the media time is detected. |
void
|
onTimedMetaDataAvailable(MediaPlayer 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. |
void
|
onVideoSizeChanged(SessionPlayer player, VideoSize size)
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. |
void
|
onVideoSizeChanged(MediaPlayer mp, MediaItem item, VideoSize size)
This method is deprecated.
Use
|
Inherited methods | |
---|---|
Public constructors
PlayerCallback
public PlayerCallback ()
Public methods
onError
public void onError (MediaPlayer mp, MediaItem item, int what, int extra)
Called to indicate an error.
Parameters | |
---|---|
mp |
MediaPlayer : the MediaPlayer2 the error pertains to |
item |
MediaItem : the MediaItem of this media item |
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 (MediaPlayer mp, MediaItem item, int what, int extra)
Called to indicate an info or a warning.
Parameters | |
---|---|
mp |
MediaPlayer : the player the info pertains to. |
item |
MediaItem : the MediaItem of this media item |
what |
int : the type of info or warning. |
extra |
int : an extra code, specific to the info. Typically implementation dependent.
|
onMediaTimeDiscontinuity
public void onMediaTimeDiscontinuity (MediaPlayer 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 |
MediaPlayer : the player the media time pertains to. |
item |
MediaItem : the MediaItem of this media item |
timestamp |
MediaTimestamp : the timestamp that correlates media time, system time and clock rate,
or MediaTimestamp.TIMESTAMP_UNKNOWN in an error case.
|
onTimedMetaDataAvailable
public void onTimedMetaDataAvailable (MediaPlayer 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 |
MediaPlayer : the player associated with this callback |
item |
MediaItem : the MediaItem of this media item |
data |
TimedMetaData : the timed metadata sample associated with this event
|
See also:
onVideoSizeChanged
public void onVideoSizeChanged (SessionPlayer player, VideoSize size)
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 | |
---|---|
player |
SessionPlayer : the player associated with this callback |
size |
VideoSize : the size of the video
|
onVideoSizeChanged
public void onVideoSizeChanged (MediaPlayer mp, MediaItem item, VideoSize size)
This method is deprecated.
Use
onVideoSizeChanged(SessionPlayer, androidx.media2.common.VideoSize)
instead.
Parameters | |
---|---|
mp |
MediaPlayer |
item |
MediaItem |
size |
VideoSize |