PlayerCallback
abstract class PlayerCallback : SessionPlayer.PlayerCallback
kotlin.Any | ||
↳ | 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 |
|
---|---|
<init>() Interface definition for callbacks to be invoked when the player has the corresponding events. |
Public methods |
|
---|---|
open Unit |
onError(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, what: Int, extra: Int) Called to indicate an error. |
open Unit |
onInfo(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, what: Int, extra: Int) Called to indicate an info or a warning. |
open Unit |
onMediaTimeDiscontinuity(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, @NonNull timestamp: MediaTimestamp) Called when a discontinuity in the normal progression of the media time is detected. |
open Unit |
onTimedMetaDataAvailable(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, @NonNull data: TimedMetaData) Called to indicate available timed metadata |
open Unit |
onVideoSizeChanged(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, @NonNull size: VideoSize) Called to indicate the video size |
Inherited functions |
|
---|---|
Public constructors
<init>
PlayerCallback()
Interface definition for callbacks to be invoked when the player has the corresponding events.
Public methods
onError
open fun onError(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, what: Int, extra: Int): Unit
Called to indicate an error.
Parameters | |
---|---|
mp |
MediaPlayer: the MediaPlayer2 the error pertains to |
item |
MediaPlayer: the MediaItem of this media item |
what |
MediaPlayer: the type of error that has occurred. |
extra |
MediaPlayer: an extra code, specific to the error. Typically implementation dependent. |
onInfo
open fun onInfo(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, what: Int, extra: Int): Unit
Called to indicate an info or a warning.
Parameters | |
---|---|
mp |
MediaPlayer: the player the info pertains to. |
item |
MediaPlayer: the MediaItem of this media item |
what |
MediaPlayer: the type of info or warning. |
extra |
MediaPlayer: an extra code, specific to the info. Typically implementation dependent. |
onMediaTimeDiscontinuity
open fun onMediaTimeDiscontinuity(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, @NonNull timestamp: MediaTimestamp): Unit
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 |
MediaPlayer: the MediaItem of this media item |
timestamp |
MediaPlayer: the timestamp that correlates media time, system time and clock rate, or MediaTimestamp#TIMESTAMP_UNKNOWN in an error case. |
onTimedMetaDataAvailable
open fun onTimedMetaDataAvailable(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, @NonNull data: TimedMetaData): Unit
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 |
MediaPlayer: the MediaItem of this media item |
data |
MediaPlayer: the timed metadata sample associated with this event |
See Also
onVideoSizeChanged
open fun onVideoSizeChanged(@NonNull mp: MediaPlayer, @NonNull item: MediaItem, @NonNull size: VideoSize): Unit
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 |
MediaPlayer: the player associated with this callback |
item |
MediaPlayer: the MediaItem of this media item |
size |
MediaPlayer: the size of the video |