Interface Player.EventListener
--
-
-
-
-
-
- All Known Subinterfaces: -
Player.Listener
-
-
-
- All Known Implementing Classes: -
AnalyticsCollector
,DebugTextViewHelper
,ExoPlayerTestRunner
,ImaAdsLoader
,SubtitleView
-
-
-
- Enclosing interface: -
- Player -
-@Deprecated -public static interface Player.EventListener
-Deprecated. --Use-Player.Listener
.Listener of changes in player state. - --All methods have no-op default implementations to allow selective overrides. - -
Listeners can choose to implement individual events (e.g.
onIsPlayingChanged(boolean)
) oronEvents(Player, Events)
, which is called after one - or more events occurred together.
-
-
-
-
-
-
- --
-
-
-
-
-
Method Summary
--
-All Methods Instance Methods Default Methods Deprecated Methods -- -Modifier and Type -Method -Description -- - -default void
-onAvailableCommandsChanged(Player.Commands availableCommands)
- -Deprecated.-Called when the value returned from-Player.isCommandAvailable(int)
changes for at least one -Player.Command
.- - -default void
-onEvents(Player player, - Player.Events events)
- -Deprecated.-Called when one or more player states changed.-- - -default void
-onIsLoadingChanged(boolean isLoading)
- -Deprecated.-Called when the player starts or stops loading the source.-- - -default void
-onIsPlayingChanged(boolean isPlaying)
- -Deprecated.-Called when the value of-Player.isPlaying()
changes.- - -default void
-onLoadingChanged(boolean isLoading)
- -Deprecated. --Use-onIsLoadingChanged(boolean)
instead.- - -default void
-onMaxSeekToPreviousPositionChanged(long maxSeekToPreviousPositionMs)
- -Deprecated.-Called when the value of-Player.getMaxSeekToPreviousPosition()
changes.- - -default void
-onMediaItemTransition(MediaItem mediaItem, - @com.google.android.exoplayer2.Player.MediaItemTransitionReason int reason)
- -Deprecated.-Called when playback transitions to a media item or starts repeating a media item according - to the current-repeat mode
.- - -default void
-onMediaMetadataChanged(MediaMetadata mediaMetadata)
- -Deprecated.-Called when the combined-MediaMetadata
changes.- - -default void
-onPlaybackParametersChanged(PlaybackParameters playbackParameters)
- -Deprecated.-Called when the current playback parameters change.-- - -default void
-onPlaybackStateChanged(@com.google.android.exoplayer2.Player.State int playbackState)
- -Deprecated.-Called when the value returned from-Player.getPlaybackState()
changes.- - -default void
-onPlaybackSuppressionReasonChanged(@com.google.android.exoplayer2.Player.PlaybackSuppressionReason int playbackSuppressionReason)
- -Deprecated.-Called when the value returned from-Player.getPlaybackSuppressionReason()
changes.- - -default void
-onPlayerError(PlaybackException error)
- -Deprecated.-Called when an error occurs.-- - -default void
-onPlayerErrorChanged(PlaybackException error)
- -Deprecated.-Called when the-PlaybackException
returned byPlayer.getPlayerError()
changes.- - -default void
-onPlayerStateChanged(boolean playWhenReady, - @com.google.android.exoplayer2.Player.State int playbackState)
- -Deprecated. --Use-onPlaybackStateChanged(int)
andonPlayWhenReadyChanged(boolean, int)
instead.- - -default void
-onPlaylistMetadataChanged(MediaMetadata mediaMetadata)
- -Deprecated.-Called when the playlist-MediaMetadata
changes.- - -default void
-onPlayWhenReadyChanged(boolean playWhenReady, - @com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason int reason)
- -Deprecated.-Called when the value returned from-Player.getPlayWhenReady()
changes.- - -default void
-onPositionDiscontinuity(@com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
- -Deprecated. - --- - -default void
-onPositionDiscontinuity(Player.PositionInfo oldPosition, - Player.PositionInfo newPosition, - @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
- -Deprecated.-Called when a position discontinuity occurs.-- - -default void
-onRepeatModeChanged(@com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
- -Deprecated.-Called when the value of-Player.getRepeatMode()
changes.- - -default void
-onSeekBackIncrementChanged(long seekBackIncrementMs)
- -Deprecated.-Called when the value of-Player.getSeekBackIncrement()
changes.- - -default void
-onSeekForwardIncrementChanged(long seekForwardIncrementMs)
- -Deprecated.-Called when the value of-Player.getSeekForwardIncrement()
changes.- - -default void
-onSeekProcessed()
- -Deprecated. --Seeks are processed without delay.-- - -default void
-onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
- -Deprecated.-Called when the value of-Player.getShuffleModeEnabled()
changes.- - -default void
-onTimelineChanged(Timeline timeline, - @com.google.android.exoplayer2.Player.TimelineChangeReason int reason)
- -Deprecated.-Called when the timeline has been refreshed.-- - -default void
-onTracksChanged(TrackGroupArray trackGroups, - TrackSelectionArray trackSelections)
- -Deprecated. --Use-onTracksInfoChanged(TracksInfo)
instead.- - -default void
-onTrackSelectionParametersChanged(TrackSelectionParameters parameters)
- -Deprecated.-Called when the value returned from-Player.getTrackSelectionParameters()
changes.- - -default void
-onTracksInfoChanged(TracksInfo tracksInfo)
- -Deprecated.-Called when the available or selected tracks change.-
-
- -
-
-
-
-
-
-
-
-
- --
-
-
-
-
-
Method Detail
- - - --
-
-
-
onTimelineChanged
-default void onTimelineChanged(Timeline timeline, - @TimelineChangeReason - @com.google.android.exoplayer2.Player.TimelineChangeReason int reason)
-Deprecated.-Called when the timeline has been refreshed. - --Note that the current
MediaItem
or playback position may change as a result of a - timeline change. If playback can't continue smoothly because of this timeline change, a - separateonPositionDiscontinuity(PositionInfo, PositionInfo, int)
callback will be - triggered. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
timeline
- The latest timeline. Never null, but may be empty.
-reason
- ThePlayer.TimelineChangeReason
responsible for this timeline change.
-
-
-
-
-
-
onMediaItemTransition
-default void onMediaItemTransition(@Nullable - MediaItem mediaItem, - @MediaItemTransitionReason - @com.google.android.exoplayer2.Player.MediaItemTransitionReason int reason)
-Deprecated.-Called when playback transitions to a media item or starts repeating a media item according - to the current-repeat mode
. - -Note that this callback is also called when the playlist becomes non-empty or empty as a - consequence of a playlist change. - -
onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
mediaItem
- TheMediaItem
. May be null if the playlist becomes empty.
-reason
- The reason for the transition.
-
-
-
-
-
-
onTracksChanged
-@Deprecated -default void onTracksChanged(TrackGroupArray trackGroups, - TrackSelectionArray trackSelections)
-Deprecated. --Use-onTracksInfoChanged(TracksInfo)
instead.Called when the available or selected tracks change. - --onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
trackGroups
- The available tracks. Never null, but may be of length zero.
-trackSelections
- The selected tracks. Never null, but may contain null elements. A - concrete implementation may include null elements if it has a fixed number of renderer - components, wishes to report a TrackSelection for each of them, and has one or more - renderer components that is not assigned any selected tracks.
-
-
-
-
-
-
onTracksInfoChanged
-default void onTracksInfoChanged(TracksInfo tracksInfo)
-Deprecated.-Called when the available or selected tracks change. - --onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
tracksInfo
- The available tracks information. Never null, but may be of length zero.
-
-
-
-
-
-
onMediaMetadataChanged
-default void onMediaMetadataChanged(MediaMetadata mediaMetadata)
-Deprecated.-Called when the combined-MediaMetadata
changes. - -The provided
MediaMetadata
is a combination of theMediaItem.mediaMetadata
- and the static and dynamic metadata from thetrack - selections' formats
andPlayer.Listener.onMetadata(Metadata)
. If a field is populated in - theMediaItem.mediaMetadata
, it will be prioritised above the same field coming from - static or dynamic metadata. - -This method may be called multiple times in quick succession. - -
onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
mediaMetadata
- The combinedMediaMetadata
.
-
-
-
-
-
-
onPlaylistMetadataChanged
-default void onPlaylistMetadataChanged(MediaMetadata mediaMetadata)
-Deprecated.-Called when the playlist-MediaMetadata
changes.
-
-
-
-
-
onIsLoadingChanged
-default void onIsLoadingChanged(boolean isLoading)
-Deprecated.-Called when the player starts or stops loading the source. - --onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
isLoading
- Whether the source is currently being loaded.
-
-
-
-
-
-
onLoadingChanged
-@Deprecated -default void onLoadingChanged(boolean isLoading)
-Deprecated. --Use-onIsLoadingChanged(boolean)
instead.
-
-
-
-
-
onAvailableCommandsChanged
-default void onAvailableCommandsChanged(Player.Commands availableCommands)
-Deprecated.-Called when the value returned from-Player.isCommandAvailable(int)
changes for at least one -Player.Command
. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
availableCommands
- The availablePlayer.Commands
.
-
-
-
-
-
-
onTrackSelectionParametersChanged
-default void onTrackSelectionParametersChanged(TrackSelectionParameters parameters)
-Deprecated.-Called when the value returned from-Player.getTrackSelectionParameters()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
parameters
- The newTrackSelectionParameters
.
-
-
-
-
-
-
onPlayerStateChanged
-@Deprecated -default void onPlayerStateChanged(boolean playWhenReady, - @State - @com.google.android.exoplayer2.Player.State int playbackState)
-Deprecated. --Use-onPlaybackStateChanged(int)
andonPlayWhenReadyChanged(boolean, int)
instead.
-
-
-
-
-
onPlaybackStateChanged
-default void onPlaybackStateChanged(@State - @com.google.android.exoplayer2.Player.State int playbackState)
-Deprecated.-Called when the value returned from-Player.getPlaybackState()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
playbackState
- The new playbackstate
.
-
-
-
-
-
-
onPlayWhenReadyChanged
-default void onPlayWhenReadyChanged(boolean playWhenReady, - @PlayWhenReadyChangeReason - @com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason int reason)
-Deprecated.-Called when the value returned from-Player.getPlayWhenReady()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
playWhenReady
- Whether playback will proceed when ready.
-reason
- Thereason
for the change.
-
-
-
-
-
-
onPlaybackSuppressionReasonChanged
-default void onPlaybackSuppressionReasonChanged(@PlaybackSuppressionReason - @com.google.android.exoplayer2.Player.PlaybackSuppressionReason int playbackSuppressionReason)
-Deprecated.-Called when the value returned from-Player.getPlaybackSuppressionReason()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
playbackSuppressionReason
- The currentPlayer.PlaybackSuppressionReason
.
-
-
-
-
-
-
onIsPlayingChanged
-default void onIsPlayingChanged(boolean isPlaying)
-Deprecated.-Called when the value of-Player.isPlaying()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
isPlaying
- Whether the player is playing.
-
-
-
-
-
-
onRepeatModeChanged
-default void onRepeatModeChanged(@RepeatMode - @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
-Deprecated.-Called when the value of-Player.getRepeatMode()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
repeatMode
- ThePlayer.RepeatMode
used for playback.
-
-
-
-
-
-
onShuffleModeEnabledChanged
-default void onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
-Deprecated.-Called when the value of-Player.getShuffleModeEnabled()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
shuffleModeEnabled
- Whether shuffling ofmedia items
is enabled.
-
-
-
-
-
-
onPlayerError
-default void onPlayerError(PlaybackException error)
-Deprecated.-Called when an error occurs. The playback state will transition to-Player.STATE_IDLE
- immediately after this method is called. The player instance can still be used, andPlayer.release()
must still be called on the player should it no longer be required. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration. - -Implementations of Player may pass an instance of a subclass of
PlaybackException
- to this method in order to include more information about the error.-
-
- Parameters: -
error
- The error.
-
-
-
-
-
-
onPlayerErrorChanged
-default void onPlayerErrorChanged(@Nullable - PlaybackException error)
-Deprecated.-Called when the-PlaybackException
returned byPlayer.getPlayerError()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration. - -Implementations of Player may pass an instance of a subclass of
PlaybackException
- to this method in order to include more information about the error.-
-
- Parameters: -
error
- The new error, or null if the error is being cleared.
-
-
-
-
-
-
onPositionDiscontinuity
-@Deprecated -default void onPositionDiscontinuity(@DiscontinuityReason - @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
-Deprecated. - --
-
-
-
-
-
onPositionDiscontinuity
-default void onPositionDiscontinuity(Player.PositionInfo oldPosition, - Player.PositionInfo newPosition, - @DiscontinuityReason - @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
-Deprecated.-Called when a position discontinuity occurs. - --A position discontinuity occurs when the playing period changes, the playback position - jumps within the period currently being played, or when the playing period has been skipped - or removed. - -
onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
oldPosition
- The position before the discontinuity.
-newPosition
- The position after the discontinuity.
-reason
- ThePlayer.DiscontinuityReason
responsible for the discontinuity.
-
-
-
-
-
-
onPlaybackParametersChanged
-default void onPlaybackParametersChanged(PlaybackParameters playbackParameters)
-Deprecated.-Called when the current playback parameters change. The playback parameters may change due to - a call to-Player.setPlaybackParameters(PlaybackParameters)
, or the player itself may change - them (for example, if audio playback switches to passthrough or offload mode, where speed - adjustment is no longer possible). - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
playbackParameters
- The playback parameters.
-
-
-
-
-
-
onSeekBackIncrementChanged
-default void onSeekBackIncrementChanged(long seekBackIncrementMs)
-Deprecated.-Called when the value of-Player.getSeekBackIncrement()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
seekBackIncrementMs
- ThePlayer.seekBack()
increment, in milliseconds.
-
-
-
-
-
-
onSeekForwardIncrementChanged
-default void onSeekForwardIncrementChanged(long seekForwardIncrementMs)
-Deprecated.-Called when the value of-Player.getSeekForwardIncrement()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
seekForwardIncrementMs
- ThePlayer.seekForward()
increment, in milliseconds.
-
-
-
-
-
-
onMaxSeekToPreviousPositionChanged
-default void onMaxSeekToPreviousPositionChanged(long maxSeekToPreviousPositionMs)
-Deprecated.-Called when the value of-Player.getMaxSeekToPreviousPosition()
changes. - -onEvents(Player, Events)
will also be called to report this event along with - other events that happen in the sameLooper
message queue iteration.-
-
- Parameters: -
maxSeekToPreviousPositionMs
- The maximum position for whichPlayer.seekToPrevious()
- seeks to the previous position, in milliseconds.
-
-
-
-
-
-
onSeekProcessed
-@Deprecated -default void onSeekProcessed()
-Deprecated. --Seeks are processed without delay. Listen to-onPositionDiscontinuity(PositionInfo, PositionInfo, int)
with reasonPlayer.DISCONTINUITY_REASON_SEEK
instead.
-
-
-
-
-
onEvents
-default void onEvents(Player player, - Player.Events events)
-Deprecated.-Called when one or more player states changed. - --State changes and events that happen within one
Looper
message queue iteration are - reported together and only after all individual callbacks were triggered. - -Only state changes represented by
events
are reported through this method. - -Listeners should prefer this method over individual callbacks in the following cases: - -
-
-
- They intend to trigger the same logic for multiple events (e.g. when updating a UI for
- both
onPlaybackStateChanged(int)
andonPlayWhenReadyChanged(boolean, - int)
). - - They need access to the
Player
object to trigger further events (e.g. to call -Player.seekTo(long)
after aonMediaItemTransition(MediaItem, int)
). - - They intend to use multiple state values together or in combination with
Player
- getter methods. For example usingPlayer.getCurrentMediaItemIndex()
with the- timeline
provided inonTimelineChanged(Timeline, int)
is only safe from - within this method. - - They are interested in events that logically happened together (e.g
onPlaybackStateChanged(int)
toPlayer.STATE_BUFFERING
because ofonMediaItemTransition(MediaItem, int)
). -
-
-
- Parameters: -
player
- ThePlayer
whose state changed. Use the getters to obtain the latest - states.
-events
- ThePlayer.Events
that happened in this iteration, indicating which player - states changed.
-
- - They intend to trigger the same logic for multiple events (e.g. when updating a UI for
- both
- -
-
- -
-
-
-