Class DefaultAnalyticsCollector
- java.lang.Object
-
- com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector
-
- All Implemented Interfaces:
AnalyticsCollector
,DrmSessionEventListener
,Player.Listener
,MediaSourceEventListener
,BandwidthMeter.EventListener
@Deprecated public class DefaultAnalyticsCollector extends Object implements AnalyticsCollector
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Data collector that forwards analytics events toAnalyticsListeners
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener
BandwidthMeter.EventListener.EventDispatcher
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.drm.DrmSessionEventListener
DrmSessionEventListener.EventDispatcher
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.MediaSourceEventListener
MediaSourceEventListener.EventDispatcher
-
-
Constructor Summary
Constructors Constructor Description DefaultAnalyticsCollector(Clock clock)
Deprecated.Creates an analytics collector.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addListener(AnalyticsListener listener)
Deprecated.Adds a listener for analytics events.protected AnalyticsListener.EventTime
generateCurrentPlayerMediaPeriodEventTime()
Deprecated.Generates anAnalyticsListener.EventTime
for the currently playing item in the player.protected AnalyticsListener.EventTime
generateEventTime(Timeline timeline, int windowIndex, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns a newAnalyticsListener.EventTime
for the specified timeline, window and media period id.void
notifySeekStarted()
Deprecated.Notify analytics collector that a seek operation will start.void
onAudioAttributesChanged(AudioAttributes audioAttributes)
Deprecated.Called when the value ofPlayer.getAudioAttributes()
changes.void
onAudioCodecError(Exception audioCodecError)
Deprecated.Called when an audio decoder encounters an error.void
onAudioDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs)
Deprecated.Called when a audio decoder is created.void
onAudioDecoderReleased(String decoderName)
Deprecated.Called when a audio decoder is released.void
onAudioDisabled(DecoderCounters counters)
Deprecated.Called when the audio renderer is disabled.void
onAudioEnabled(DecoderCounters counters)
Deprecated.Called when the audio renderer is enabled.void
onAudioInputFormatChanged(Format format, DecoderReuseEvaluation decoderReuseEvaluation)
Deprecated.Called when the format of the media being consumed by the audio renderer changes.void
onAudioPositionAdvancing(long playoutStartSystemTimeMs)
Deprecated.Called when the audio position has increased for the first time since the last pause or position reset.void
onAudioSessionIdChanged(int audioSessionId)
Deprecated.Called when the audio session ID changes.void
onAudioSinkError(Exception audioSinkError)
Deprecated.Called whenAudioSink
has encountered an error.void
onAudioUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs)
Deprecated.Called when an audio underrun occurs.void
onAvailableCommandsChanged(Player.Commands availableCommands)
Deprecated.Called when the value returned fromPlayer.isCommandAvailable(int)
changes for at least onePlayer.Command
.void
onBandwidthSample(int elapsedMs, long bytesTransferred, long bitrateEstimate)
Deprecated.Called periodically to indicate that bytes have been transferred or the estimated bitrate has changed.void
onCues(CueGroup cueGroup)
Deprecated.Called when the value ofPlayer.getCurrentCues()
changes.void
onCues(List<Cue> cues)
Deprecated.Called when the value ofPlayer.getCurrentCues()
changes.void
onDeviceInfoChanged(DeviceInfo deviceInfo)
Deprecated.Called when the device information changesvoid
onDeviceVolumeChanged(int volume, boolean muted)
Deprecated.Called when the value ofPlayer.getDeviceVolume()
orPlayer.isDeviceMuted()
changes.void
onDownstreamFormatChanged(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData)
Deprecated.Called when a downstream format change occurs (i.e.void
onDrmKeysLoaded(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Called each time keys are loaded.void
onDrmKeysRemoved(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Called each time offline keys are removed.void
onDrmKeysRestored(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Called each time offline keys are restored.void
onDrmSessionAcquired(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, @com.google.android.exoplayer2.drm.DrmSession.State int state)
Deprecated.Called each time a drm session is acquired.void
onDrmSessionManagerError(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, Exception error)
Deprecated.Called when a drm error occurs.void
onDrmSessionReleased(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Called each time a drm session is released.void
onDroppedFrames(int count, long elapsedMs)
Deprecated.Called to report the number of frames dropped by the video renderer.void
onEvents(Player player, Player.Events events)
Deprecated.Called when one or more player states changed.void
onIsLoadingChanged(boolean isLoading)
Deprecated.Called when the player starts or stops loading the source.void
onIsPlayingChanged(boolean isPlaying)
Deprecated.Called when the value ofPlayer.isPlaying()
changes.void
onLoadCanceled(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)
Deprecated.Called when a load is canceled.void
onLoadCompleted(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)
Deprecated.Called when a load ends.void
onLoadError(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData, IOException error, boolean wasCanceled)
Deprecated.Called when a load error occurs.void
onLoadingChanged(boolean isLoading)
Deprecated.void
onLoadStarted(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)
Deprecated.Called when a load begins.void
onMaxSeekToPreviousPositionChanged(long maxSeekToPreviousPositionMs)
Deprecated.Called when the value ofPlayer.getMaxSeekToPreviousPosition()
changes.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 currentrepeat mode
.void
onMediaMetadataChanged(MediaMetadata mediaMetadata)
Deprecated.Called when the value ofPlayer.getMediaMetadata()
changes.void
onMetadata(Metadata metadata)
Deprecated.Called when there is metadata associated with the current playback time.void
onPlaybackParametersChanged(PlaybackParameters playbackParameters)
Deprecated.Called when the value ofPlayer.getPlaybackParameters()
changes.void
onPlaybackStateChanged(@com.google.android.exoplayer2.Player.State int playbackState)
Deprecated.Called when the value returned fromPlayer.getPlaybackState()
changes.void
onPlaybackSuppressionReasonChanged(@com.google.android.exoplayer2.Player.PlaybackSuppressionReason int playbackSuppressionReason)
Deprecated.Called when the value returned fromPlayer.getPlaybackSuppressionReason()
changes.void
onPlayerError(PlaybackException error)
Deprecated.Called when an error occurs.void
onPlayerErrorChanged(PlaybackException error)
Deprecated.Called when thePlaybackException
returned byPlayer.getPlayerError()
changes.void
onPlayerStateChanged(boolean playWhenReady, @com.google.android.exoplayer2.Player.State int playbackState)
Deprecated.void
onPlaylistMetadataChanged(MediaMetadata playlistMetadata)
Deprecated.Called when the value ofPlayer.getPlaylistMetadata()
changes.void
onPlayWhenReadyChanged(boolean playWhenReady, @com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason int reason)
Deprecated.Called when the value returned fromPlayer.getPlayWhenReady()
changes.void
onPositionDiscontinuity(@com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
Deprecated.void
onPositionDiscontinuity(Player.PositionInfo oldPosition, Player.PositionInfo newPosition, @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
Deprecated.Called when a position discontinuity occurs.void
onRenderedFirstFrame()
Deprecated.Called when a frame is rendered for the first time since setting the surface, or since the renderer was reset, or since the stream being rendered was changed.void
onRenderedFirstFrame(Object output, long renderTimeMs)
Deprecated.Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed.void
onRepeatModeChanged(@com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Deprecated.Called when the value ofPlayer.getRepeatMode()
changes.void
onSeekBackIncrementChanged(long seekBackIncrementMs)
Deprecated.Called when the value ofPlayer.getSeekBackIncrement()
changes.void
onSeekForwardIncrementChanged(long seekForwardIncrementMs)
Deprecated.Called when the value ofPlayer.getSeekForwardIncrement()
changes.void
onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
Deprecated.Called when the value ofPlayer.getShuffleModeEnabled()
changes.void
onSkipSilenceEnabledChanged(boolean skipSilenceEnabled)
Deprecated.Called when skipping silences is enabled or disabled in the audio stream.void
onSurfaceSizeChanged(int width, int height)
Deprecated.Called each time there's a change in the size of the surface onto which the video is being rendered.void
onTimelineChanged(Timeline timeline, @com.google.android.exoplayer2.Player.TimelineChangeReason int reason)
Deprecated.Called when the value ofPlayer.getCurrentTimeline()
changes.void
onTracksChanged(Tracks tracks)
Deprecated.Called when the value ofPlayer.getCurrentTracks()
changes.void
onTrackSelectionParametersChanged(TrackSelectionParameters parameters)
Deprecated.Called when the value returned fromPlayer.getTrackSelectionParameters()
changes.void
onUpstreamDiscarded(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData)
Deprecated.Called when data is removed from the back of a media buffer, typically so that it can be re-buffered in a different format.void
onVideoCodecError(Exception videoCodecError)
Deprecated.Called when a video decoder encounters an error.void
onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs)
Deprecated.Called when a video decoder is created.void
onVideoDecoderReleased(String decoderName)
Deprecated.Called when a video decoder is released.void
onVideoDisabled(DecoderCounters counters)
Deprecated.Called when the video renderer is disabled.void
onVideoEnabled(DecoderCounters counters)
Deprecated.Called when the video renderer is enabled.void
onVideoFrameProcessingOffset(long totalProcessingOffsetUs, int frameCount)
Deprecated.Called to report the video processing offset of video frames processed by the video renderer.void
onVideoInputFormatChanged(Format format, DecoderReuseEvaluation decoderReuseEvaluation)
Deprecated.Called when the format of the media being consumed by the video renderer changes.void
onVideoSizeChanged(VideoSize videoSize)
Deprecated.Called each time whenPlayer.getVideoSize()
changes.void
onVolumeChanged(float volume)
Deprecated.Called when the value ofPlayer.getVolume()
changes.void
release()
Deprecated.Releases the collector.void
removeListener(AnalyticsListener listener)
Deprecated.Removes a previously added analytics event listener.protected void
sendEvent(AnalyticsListener.EventTime eventTime, int eventFlag, ListenerSet.Event<AnalyticsListener> eventInvocation)
Deprecated.Sends an event to registered listeners.void
setPlayer(Player player, Looper looper)
Deprecated.Sets the player for which data will be collected.void
setThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread)
Deprecated.Do not use this method and ensure all calls are made from the correct thread.void
updateMediaPeriodQueueInfo(List<MediaSource.MediaPeriodId> queue, MediaSource.MediaPeriodId readingPeriod)
Deprecated.Updates the playback queue information used for event association.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.drm.DrmSessionEventListener
onDrmSessionAcquired
-
-
-
-
Method Detail
-
setThrowsWhenUsingWrongThread
@Deprecated public void setThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread)
Deprecated.Do not use this method and ensure all calls are made from the correct thread.Sets whether methods throw when using the wrong thread.Do not use this method unless to support legacy use cases.
- Parameters:
throwsWhenUsingWrongThread
- Whether to throw when using the wrong thread.
-
addListener
@CallSuper public void addListener(AnalyticsListener listener)
Deprecated.Description copied from interface:AnalyticsCollector
Adds a listener for analytics events.- Specified by:
addListener
in interfaceAnalyticsCollector
- Parameters:
listener
- The listener to add.
-
removeListener
@CallSuper public void removeListener(AnalyticsListener listener)
Deprecated.Description copied from interface:AnalyticsCollector
Removes a previously added analytics event listener.- Specified by:
removeListener
in interfaceAnalyticsCollector
- Parameters:
listener
- The listener to remove.
-
setPlayer
@CallSuper public void setPlayer(Player player, Looper looper)
Deprecated.Description copied from interface:AnalyticsCollector
Sets the player for which data will be collected. Must only be called if no player has been set yet or the current player is idle.- Specified by:
setPlayer
in interfaceAnalyticsCollector
- Parameters:
player
- ThePlayer
for which data will be collected.looper
- TheLooper
used for listener callbacks.
-
release
@CallSuper public void release()
Deprecated.Description copied from interface:AnalyticsCollector
Releases the collector. Must be called after the player for which data is collected has been released.- Specified by:
release
in interfaceAnalyticsCollector
-
updateMediaPeriodQueueInfo
public final void updateMediaPeriodQueueInfo(List<MediaSource.MediaPeriodId> queue, @Nullable MediaSource.MediaPeriodId readingPeriod)
Deprecated.Description copied from interface:AnalyticsCollector
Updates the playback queue information used for event association.Should only be called by the player controlling the queue and not from app code.
- Specified by:
updateMediaPeriodQueueInfo
in interfaceAnalyticsCollector
- Parameters:
queue
- The playback queue of media periods identified by theirMediaSource.MediaPeriodId
.readingPeriod
- The media period in the queue that is currently being read by renderers, or null if the queue is empty.
-
notifySeekStarted
public final void notifySeekStarted()
Deprecated.Description copied from interface:AnalyticsCollector
Notify analytics collector that a seek operation will start. Should be called before the player adjusts its state and position to the seek.- Specified by:
notifySeekStarted
in interfaceAnalyticsCollector
-
onAudioEnabled
public final void onAudioEnabled(DecoderCounters counters)
Deprecated.Description copied from interface:AnalyticsCollector
Called when the audio renderer is enabled.- Specified by:
onAudioEnabled
in interfaceAnalyticsCollector
- Parameters:
counters
-DecoderCounters
that will be updated by the audio renderer for as long as it remains enabled.
-
onAudioDecoderInitialized
public final void onAudioDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs)
Deprecated.Description copied from interface:AnalyticsCollector
Called when a audio decoder is created.- Specified by:
onAudioDecoderInitialized
in interfaceAnalyticsCollector
- Parameters:
decoderName
- The audio decoder that was created.initializedTimestampMs
-SystemClock.elapsedRealtime()
when initialization finished.initializationDurationMs
- The time taken to initialize the decoder in milliseconds.
-
onAudioInputFormatChanged
public final void onAudioInputFormatChanged(Format format, @Nullable DecoderReuseEvaluation decoderReuseEvaluation)
Deprecated.Description copied from interface:AnalyticsCollector
Called when the format of the media being consumed by the audio renderer changes.- Specified by:
onAudioInputFormatChanged
in interfaceAnalyticsCollector
- Parameters:
format
- The new format.decoderReuseEvaluation
- The result of the evaluation to determine whether an existing decoder instance can be reused for the new format, ornull
if the renderer did not have a decoder.
-
onAudioPositionAdvancing
public final void onAudioPositionAdvancing(long playoutStartSystemTimeMs)
Deprecated.Description copied from interface:AnalyticsCollector
Called when the audio position has increased for the first time since the last pause or position reset.- Specified by:
onAudioPositionAdvancing
in interfaceAnalyticsCollector
- Parameters:
playoutStartSystemTimeMs
- The approximate derivedSystem.currentTimeMillis()
at which playout started.
-
onAudioUnderrun
public final void onAudioUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs)
Deprecated.Description copied from interface:AnalyticsCollector
Called when an audio underrun occurs.- Specified by:
onAudioUnderrun
in interfaceAnalyticsCollector
- Parameters:
bufferSize
- The size of the audio output buffer, in bytes.bufferSizeMs
- The size of the audio output buffer, in milliseconds, if it contains PCM encoded audio.C.TIME_UNSET
if the output buffer contains non-PCM encoded audio.elapsedSinceLastFeedMs
- The time since audio was last written to the output buffer.
-
onAudioDecoderReleased
public final void onAudioDecoderReleased(String decoderName)
Deprecated.Description copied from interface:AnalyticsCollector
Called when a audio decoder is released.- Specified by:
onAudioDecoderReleased
in interfaceAnalyticsCollector
- Parameters:
decoderName
- The audio decoder that was released.
-
onAudioDisabled
public final void onAudioDisabled(DecoderCounters counters)
Deprecated.Description copied from interface:AnalyticsCollector
Called when the audio renderer is disabled.- Specified by:
onAudioDisabled
in interfaceAnalyticsCollector
- Parameters:
counters
-DecoderCounters
that were updated by the audio renderer.
-
onAudioSinkError
public final void onAudioSinkError(Exception audioSinkError)
Deprecated.Description copied from interface:AnalyticsCollector
Called whenAudioSink
has encountered an error.If the sink writes to a platform
AudioTrack
, this will be called for allAudioTrack
errors.- Specified by:
onAudioSinkError
in interfaceAnalyticsCollector
- Parameters:
audioSinkError
- The error that occurred. Typically anAudioSink.InitializationException
, aAudioSink.WriteException
, or anAudioSink.UnexpectedDiscontinuityException
.
-
onAudioCodecError
public final void onAudioCodecError(Exception audioCodecError)
Deprecated.Description copied from interface:AnalyticsCollector
Called when an audio decoder encounters an error.- Specified by:
onAudioCodecError
in interfaceAnalyticsCollector
- Parameters:
audioCodecError
- The error. Typically aMediaCodec.CodecException
if the renderer usesMediaCodec
, or aDecoderException
if the renderer uses a software decoder.
-
onVolumeChanged
public final void onVolumeChanged(float volume)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getVolume()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onVolumeChanged
in interfacePlayer.Listener
- Parameters:
volume
- The new volume, with 0 being silence and 1 being unity gain.
-
onVideoEnabled
public final void onVideoEnabled(DecoderCounters counters)
Deprecated.Description copied from interface:AnalyticsCollector
Called when the video renderer is enabled.- Specified by:
onVideoEnabled
in interfaceAnalyticsCollector
- Parameters:
counters
-DecoderCounters
that will be updated by the video renderer for as long as it remains enabled.
-
onVideoDecoderInitialized
public final void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs)
Deprecated.Description copied from interface:AnalyticsCollector
Called when a video decoder is created.- Specified by:
onVideoDecoderInitialized
in interfaceAnalyticsCollector
- Parameters:
decoderName
- The decoder that was created.initializedTimestampMs
-SystemClock.elapsedRealtime()
when initialization finished.initializationDurationMs
- The time taken to initialize the decoder in milliseconds.
-
onVideoInputFormatChanged
public final void onVideoInputFormatChanged(Format format, @Nullable DecoderReuseEvaluation decoderReuseEvaluation)
Deprecated.Description copied from interface:AnalyticsCollector
Called when the format of the media being consumed by the video renderer changes.- Specified by:
onVideoInputFormatChanged
in interfaceAnalyticsCollector
- Parameters:
format
- The new format.decoderReuseEvaluation
- The result of the evaluation to determine whether an existing decoder instance can be reused for the new format, ornull
if the renderer did not have a decoder.
-
onDroppedFrames
public final void onDroppedFrames(int count, long elapsedMs)
Deprecated.Description copied from interface:AnalyticsCollector
Called to report the number of frames dropped by the video renderer. Dropped frames are reported whenever the renderer is stopped having dropped frames, and optionally, whenever the count reaches a specified threshold whilst the renderer is started.- Specified by:
onDroppedFrames
in interfaceAnalyticsCollector
- Parameters:
count
- The number of dropped frames.elapsedMs
- The duration in milliseconds over which the frames were dropped. This duration is timed from when the renderer was started or from when dropped frames were last reported (whichever was more recent), and not from when the first of the reported drops occurred.
-
onVideoDecoderReleased
public final void onVideoDecoderReleased(String decoderName)
Deprecated.Description copied from interface:AnalyticsCollector
Called when a video decoder is released.- Specified by:
onVideoDecoderReleased
in interfaceAnalyticsCollector
- Parameters:
decoderName
- The video decoder that was released.
-
onVideoDisabled
public final void onVideoDisabled(DecoderCounters counters)
Deprecated.Description copied from interface:AnalyticsCollector
Called when the video renderer is disabled.- Specified by:
onVideoDisabled
in interfaceAnalyticsCollector
- Parameters:
counters
-DecoderCounters
that were updated by the video renderer.
-
onRenderedFirstFrame
public final void onRenderedFirstFrame(Object output, long renderTimeMs)
Deprecated.Description copied from interface:AnalyticsCollector
Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed.- Specified by:
onRenderedFirstFrame
in interfaceAnalyticsCollector
- Parameters:
output
- The output of the video renderer. Normally aSurface
, however some video renderers may have other output types (e.g., aVideoDecoderOutputBufferRenderer
).renderTimeMs
- TheSystemClock.elapsedRealtime()
when the frame was rendered.
-
onVideoFrameProcessingOffset
public final void onVideoFrameProcessingOffset(long totalProcessingOffsetUs, int frameCount)
Deprecated.Description copied from interface:AnalyticsCollector
Called to report the video processing offset of video frames processed by the video renderer.Video processing offset represents how early a video frame is processed compared to the player's current position. For each video frame, the offset is calculated as Pvf - Ppl where Pvf is the presentation timestamp of the video frame and Ppl is the current position of the player. Positive values indicate the frame was processed early enough whereas negative values indicate that the player's position had progressed beyond the frame's timestamp when the frame was processed (and the frame was probably dropped).
The renderer reports the sum of video processing offset samples (one sample per processed video frame: dropped, skipped or rendered) and the total number of samples.
- Specified by:
onVideoFrameProcessingOffset
in interfaceAnalyticsCollector
- Parameters:
totalProcessingOffsetUs
- The sum of all video frame processing offset samples for the video frames processed by the renderer in microseconds.frameCount
- The number of samples included in thetotalProcessingOffsetUs
.
-
onVideoCodecError
public final void onVideoCodecError(Exception videoCodecError)
Deprecated.Description copied from interface:AnalyticsCollector
Called when a video decoder encounters an error.This method being called does not indicate that playback has failed, or that it will fail. The player may be able to recover from the error. Hence applications should not implement this method to display a user visible error or initiate an application level retry.
Player.Listener.onPlayerError(com.google.android.exoplayer2.PlaybackException)
is the appropriate place to implement such behavior. This method is called to provide the application with an opportunity to log the error if it wishes to do so.- Specified by:
onVideoCodecError
in interfaceAnalyticsCollector
- Parameters:
videoCodecError
- The error. Typically aMediaCodec.CodecException
if the renderer usesMediaCodec
, or aDecoderException
if the renderer uses a software decoder.
-
onSurfaceSizeChanged
public final void onSurfaceSizeChanged(int width, int height)
Deprecated.Description copied from interface:Player.Listener
Called each time there's a change in the size of the surface onto which the video is being rendered.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onSurfaceSizeChanged
in interfacePlayer.Listener
- Parameters:
width
- The surface width in pixels. May beC.LENGTH_UNSET
if unknown, or 0 if the video is not rendered onto a surface.height
- The surface height in pixels. May beC.LENGTH_UNSET
if unknown, or 0 if the video is not rendered onto a surface.
-
onLoadStarted
public final void onLoadStarted(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)
Deprecated.Description copied from interface:MediaSourceEventListener
Called when a load begins.- Specified by:
onLoadStarted
in interfaceMediaSourceEventListener
- Parameters:
windowIndex
- The window index in the timeline of the media source this load belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
this load belongs to. Null if the load does not belong to a specific media period.loadEventInfo
- TheLoadEventInfo
corresponding to the event. The value ofLoadEventInfo.uri
won't reflect potential redirection yet andLoadEventInfo.responseHeaders
will be empty.mediaLoadData
- TheMediaLoadData
defining the data being loaded.
-
onLoadCompleted
public final void onLoadCompleted(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)
Deprecated.Description copied from interface:MediaSourceEventListener
Called when a load ends.- Specified by:
onLoadCompleted
in interfaceMediaSourceEventListener
- Parameters:
windowIndex
- The window index in the timeline of the media source this load belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
this load belongs to. Null if the load does not belong to a specific media period.loadEventInfo
- TheLoadEventInfo
corresponding to the event. The values ofLoadEventInfo.elapsedRealtimeMs
andLoadEventInfo.bytesLoaded
are relative to the correspondingMediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)
event.mediaLoadData
- TheMediaLoadData
defining the data being loaded.
-
onLoadCanceled
public final void onLoadCanceled(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData)
Deprecated.Description copied from interface:MediaSourceEventListener
Called when a load is canceled.- Specified by:
onLoadCanceled
in interfaceMediaSourceEventListener
- Parameters:
windowIndex
- The window index in the timeline of the media source this load belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
this load belongs to. Null if the load does not belong to a specific media period.loadEventInfo
- TheLoadEventInfo
corresponding to the event. The values ofLoadEventInfo.elapsedRealtimeMs
andLoadEventInfo.bytesLoaded
are relative to the correspondingMediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)
event.mediaLoadData
- TheMediaLoadData
defining the data being loaded.
-
onLoadError
public final void onLoadError(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData, IOException error, boolean wasCanceled)
Deprecated.Description copied from interface:MediaSourceEventListener
Called when a load error occurs.The error may or may not have resulted in the load being canceled, as indicated by the
wasCanceled
parameter. If the load was canceled,MediaSourceEventListener.onLoadCanceled(int, com.google.android.exoplayer2.source.MediaSource.MediaPeriodId, com.google.android.exoplayer2.source.LoadEventInfo, com.google.android.exoplayer2.source.MediaLoadData)
will not be called in addition to this method.This method being called does not indicate that playback has failed, or that it will fail. The player may be able to recover from the error. Hence applications should not implement this method to display a user visible error or initiate an application level retry.
Player.Listener.onPlayerError(com.google.android.exoplayer2.PlaybackException)
is the appropriate place to implement such behavior. This method is called to provide the application with an opportunity to log the error if it wishes to do so.- Specified by:
onLoadError
in interfaceMediaSourceEventListener
- Parameters:
windowIndex
- The window index in the timeline of the media source this load belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
this load belongs to. Null if the load does not belong to a specific media period.loadEventInfo
- TheLoadEventInfo
corresponding to the event. The values ofLoadEventInfo.elapsedRealtimeMs
andLoadEventInfo.bytesLoaded
are relative to the correspondingMediaSourceEventListener.onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)
event.mediaLoadData
- TheMediaLoadData
defining the data being loaded.error
- The load error.wasCanceled
- Whether the load was canceled as a result of the error.
-
onUpstreamDiscarded
public final void onUpstreamDiscarded(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData)
Deprecated.Description copied from interface:MediaSourceEventListener
Called when data is removed from the back of a media buffer, typically so that it can be re-buffered in a different format.- Specified by:
onUpstreamDiscarded
in interfaceMediaSourceEventListener
- Parameters:
windowIndex
- The window index in the timeline of the media source this load belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
the media belongs to.mediaLoadData
- TheMediaLoadData
defining the media being discarded.
-
onDownstreamFormatChanged
public final void onDownstreamFormatChanged(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData)
Deprecated.Description copied from interface:MediaSourceEventListener
Called when a downstream format change occurs (i.e. when the format of the media being read from one or moreSampleStream
s provided by the source changes).- Specified by:
onDownstreamFormatChanged
in interfaceMediaSourceEventListener
- Parameters:
windowIndex
- The window index in the timeline of the media source this load belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
the media belongs to.mediaLoadData
- TheMediaLoadData
defining the newly selected downstream data.
-
onTimelineChanged
public final void onTimelineChanged(Timeline timeline, @TimelineChangeReason @com.google.android.exoplayer2.Player.TimelineChangeReason int reason)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getCurrentTimeline()
changes.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 separatePlayer.Listener.onPositionDiscontinuity(PositionInfo, PositionInfo, int)
callback will be triggered.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onTimelineChanged
in interfacePlayer.Listener
- Parameters:
timeline
- The latest timeline. Never null, but may be empty.reason
- ThePlayer.TimelineChangeReason
responsible for this timeline change.
-
onMediaItemTransition
public final void onMediaItemTransition(@Nullable MediaItem mediaItem, @MediaItemTransitionReason @com.google.android.exoplayer2.Player.MediaItemTransitionReason int reason)
Deprecated.Description copied from interface:Player.Listener
Called when playback transitions to a media item or starts repeating a media item according to the currentrepeat mode
.Note that this callback is also called when the value of
Player.getCurrentTimeline()
becomes non-empty or empty.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onMediaItemTransition
in interfacePlayer.Listener
- Parameters:
mediaItem
- TheMediaItem
. May be null if the playlist becomes empty.reason
- The reason for the transition.
-
onTracksChanged
public void onTracksChanged(Tracks tracks)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getCurrentTracks()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onTracksChanged
in interfacePlayer.Listener
- Parameters:
tracks
- The available tracks information. Never null, but may be of length zero.
-
onLoadingChanged
public void onLoadingChanged(boolean isLoading)
Deprecated.- Specified by:
onLoadingChanged
in interfacePlayer.Listener
-
onIsLoadingChanged
public final void onIsLoadingChanged(boolean isLoading)
Deprecated.Description copied from interface:Player.Listener
Called when the player starts or stops loading the source.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onIsLoadingChanged
in interfacePlayer.Listener
- Parameters:
isLoading
- Whether the source is currently being loaded.
-
onAvailableCommandsChanged
public void onAvailableCommandsChanged(Player.Commands availableCommands)
Deprecated.Description copied from interface:Player.Listener
Called when the value returned fromPlayer.isCommandAvailable(int)
changes for at least onePlayer.Command
.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onAvailableCommandsChanged
in interfacePlayer.Listener
- Parameters:
availableCommands
- The availablePlayer.Commands
.
-
onPlayerStateChanged
public final void onPlayerStateChanged(boolean playWhenReady, @State @com.google.android.exoplayer2.Player.State int playbackState)
Deprecated.- Specified by:
onPlayerStateChanged
in interfacePlayer.Listener
-
onPlaybackStateChanged
public final void onPlaybackStateChanged(@State @com.google.android.exoplayer2.Player.State int playbackState)
Deprecated.Description copied from interface:Player.Listener
Called when the value returned fromPlayer.getPlaybackState()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onPlaybackStateChanged
in interfacePlayer.Listener
- Parameters:
playbackState
- The new playbackPlayer.State
.
-
onPlayWhenReadyChanged
public final void onPlayWhenReadyChanged(boolean playWhenReady, @PlayWhenReadyChangeReason @com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason int reason)
Deprecated.Description copied from interface:Player.Listener
Called when the value returned fromPlayer.getPlayWhenReady()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onPlayWhenReadyChanged
in interfacePlayer.Listener
- Parameters:
playWhenReady
- Whether playback will proceed when ready.reason
- ThePlayer.PlayWhenReadyChangeReason
for the change.
-
onPlaybackSuppressionReasonChanged
public final void onPlaybackSuppressionReasonChanged(@PlaybackSuppressionReason @com.google.android.exoplayer2.Player.PlaybackSuppressionReason int playbackSuppressionReason)
Deprecated.Description copied from interface:Player.Listener
Called when the value returned fromPlayer.getPlaybackSuppressionReason()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onPlaybackSuppressionReasonChanged
in interfacePlayer.Listener
- Parameters:
playbackSuppressionReason
- The currentPlayer.PlaybackSuppressionReason
.
-
onIsPlayingChanged
public void onIsPlayingChanged(boolean isPlaying)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.isPlaying()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onIsPlayingChanged
in interfacePlayer.Listener
- Parameters:
isPlaying
- Whether the player is playing.
-
onRepeatModeChanged
public final void onRepeatModeChanged(@RepeatMode @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getRepeatMode()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onRepeatModeChanged
in interfacePlayer.Listener
- Parameters:
repeatMode
- ThePlayer.RepeatMode
used for playback.
-
onShuffleModeEnabledChanged
public final void onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getShuffleModeEnabled()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onShuffleModeEnabledChanged
in interfacePlayer.Listener
- Parameters:
shuffleModeEnabled
- Whether shuffling of media items is enabled.
-
onPlayerError
public final void onPlayerError(PlaybackException error)
Deprecated.Description copied from interface:Player.Listener
Called when an error occurs. The playback state will transition toPlayer.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.Player.Listener.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.- Specified by:
onPlayerError
in interfacePlayer.Listener
- Parameters:
error
- The error.
-
onPlayerErrorChanged
public void onPlayerErrorChanged(@Nullable PlaybackException error)
Deprecated.Description copied from interface:Player.Listener
Called when thePlaybackException
returned byPlayer.getPlayerError()
changes.Player.Listener.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.- Specified by:
onPlayerErrorChanged
in interfacePlayer.Listener
- Parameters:
error
- The new error, or null if the error is being cleared.
-
onPositionDiscontinuity
public void onPositionDiscontinuity(@DiscontinuityReason @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
Deprecated.- Specified by:
onPositionDiscontinuity
in interfacePlayer.Listener
-
onPositionDiscontinuity
public final void onPositionDiscontinuity(Player.PositionInfo oldPosition, Player.PositionInfo newPosition, @DiscontinuityReason @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
Deprecated.Description copied from interface:Player.Listener
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.
Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onPositionDiscontinuity
in interfacePlayer.Listener
- Parameters:
oldPosition
- The position before the discontinuity.newPosition
- The position after the discontinuity.reason
- ThePlayer.DiscontinuityReason
responsible for the discontinuity.
-
onPlaybackParametersChanged
public final void onPlaybackParametersChanged(PlaybackParameters playbackParameters)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getPlaybackParameters()
changes. The playback parameters may change due to a call toPlayer.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).Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onPlaybackParametersChanged
in interfacePlayer.Listener
- Parameters:
playbackParameters
- The playback parameters.
-
onSeekBackIncrementChanged
public void onSeekBackIncrementChanged(long seekBackIncrementMs)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getSeekBackIncrement()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onSeekBackIncrementChanged
in interfacePlayer.Listener
- Parameters:
seekBackIncrementMs
- ThePlayer.seekBack()
increment, in milliseconds.
-
onSeekForwardIncrementChanged
public void onSeekForwardIncrementChanged(long seekForwardIncrementMs)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getSeekForwardIncrement()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onSeekForwardIncrementChanged
in interfacePlayer.Listener
- Parameters:
seekForwardIncrementMs
- ThePlayer.seekForward()
increment, in milliseconds.
-
onMaxSeekToPreviousPositionChanged
public void onMaxSeekToPreviousPositionChanged(long maxSeekToPreviousPositionMs)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getMaxSeekToPreviousPosition()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onMaxSeekToPreviousPositionChanged
in interfacePlayer.Listener
- Parameters:
maxSeekToPreviousPositionMs
- The maximum position for whichPlayer.seekToPrevious()
seeks to the previous position, in milliseconds.
-
onMediaMetadataChanged
public void onMediaMetadataChanged(MediaMetadata mediaMetadata)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getMediaMetadata()
changes.This method may be called multiple times in quick succession.
Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onMediaMetadataChanged
in interfacePlayer.Listener
- Parameters:
mediaMetadata
- The combinedMediaMetadata
.
-
onPlaylistMetadataChanged
public void onPlaylistMetadataChanged(MediaMetadata playlistMetadata)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getPlaylistMetadata()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onPlaylistMetadataChanged
in interfacePlayer.Listener
-
onMetadata
public final void onMetadata(Metadata metadata)
Deprecated.Description copied from interface:Player.Listener
Called when there is metadata associated with the current playback time.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onMetadata
in interfacePlayer.Listener
- Parameters:
metadata
- The metadata.
-
onCues
public void onCues(List<Cue> cues)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getCurrentCues()
changes.Both this method and
Player.Listener.onCues(CueGroup)
are called when there is a change in the cues. You should only implement one or the other.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onCues
in interfacePlayer.Listener
-
onCues
public void onCues(CueGroup cueGroup)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getCurrentCues()
changes.Both this method and
Player.Listener.onCues(List)
are called when there is a change in the cues. You should only implement one or the other.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onCues
in interfacePlayer.Listener
-
onSkipSilenceEnabledChanged
public final void onSkipSilenceEnabledChanged(boolean skipSilenceEnabled)
Deprecated.Description copied from interface:Player.Listener
Called when skipping silences is enabled or disabled in the audio stream.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onSkipSilenceEnabledChanged
in interfacePlayer.Listener
- Parameters:
skipSilenceEnabled
- Whether skipping silences in the audio stream is enabled.
-
onAudioSessionIdChanged
public final void onAudioSessionIdChanged(int audioSessionId)
Deprecated.Description copied from interface:Player.Listener
Called when the audio session ID changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onAudioSessionIdChanged
in interfacePlayer.Listener
- Parameters:
audioSessionId
- The audio session ID.
-
onAudioAttributesChanged
public final void onAudioAttributesChanged(AudioAttributes audioAttributes)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getAudioAttributes()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onAudioAttributesChanged
in interfacePlayer.Listener
- Parameters:
audioAttributes
- The audio attributes.
-
onVideoSizeChanged
public final void onVideoSizeChanged(VideoSize videoSize)
Deprecated.Description copied from interface:Player.Listener
Called each time whenPlayer.getVideoSize()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onVideoSizeChanged
in interfacePlayer.Listener
- Parameters:
videoSize
- The new size of the video.
-
onTrackSelectionParametersChanged
public void onTrackSelectionParametersChanged(TrackSelectionParameters parameters)
Deprecated.Description copied from interface:Player.Listener
Called when the value returned fromPlayer.getTrackSelectionParameters()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onTrackSelectionParametersChanged
in interfacePlayer.Listener
- Parameters:
parameters
- The newTrackSelectionParameters
.
-
onDeviceInfoChanged
public void onDeviceInfoChanged(DeviceInfo deviceInfo)
Deprecated.Description copied from interface:Player.Listener
Called when the device information changesPlayer.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onDeviceInfoChanged
in interfacePlayer.Listener
- Parameters:
deviceInfo
- The newDeviceInfo
.
-
onDeviceVolumeChanged
public void onDeviceVolumeChanged(int volume, boolean muted)
Deprecated.Description copied from interface:Player.Listener
Called when the value ofPlayer.getDeviceVolume()
orPlayer.isDeviceMuted()
changes.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onDeviceVolumeChanged
in interfacePlayer.Listener
- Parameters:
volume
- The new device volume, with 0 being silence and 1 being unity gain.muted
- Whether the device is muted.
-
onRenderedFirstFrame
public void onRenderedFirstFrame()
Deprecated.Description copied from interface:Player.Listener
Called when a frame is rendered for the first time since setting the surface, or since the renderer was reset, or since the stream being rendered was changed.Player.Listener.onEvents(Player, Events)
will also be called to report this event along with other events that happen in the sameLooper
message queue iteration.- Specified by:
onRenderedFirstFrame
in interfacePlayer.Listener
-
onEvents
public void onEvents(Player player, Player.Events events)
Deprecated.Description copied from interface:Player.Listener
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.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
Player.Listener.onPlaybackStateChanged(int)
andPlayer.Listener.onPlayWhenReadyChanged(boolean, int)
). - They need access to the
Player
object to trigger further events (e.g. to callPlayer.seekTo(long)
after aPlayer.Listener.onMediaItemTransition(MediaItem, int)
). - They intend to use multiple state values together or in combination with
Player
getter methods. For example usingPlayer.getCurrentMediaItemIndex()
with thetimeline
provided inPlayer.Listener.onTimelineChanged(Timeline, int)
is only safe from within this method. - They are interested in events that logically happened together (e.g
Player.Listener.onPlaybackStateChanged(int)
toPlayer.STATE_BUFFERING
because ofPlayer.Listener.onMediaItemTransition(MediaItem, int)
).
- Specified by:
onEvents
in interfacePlayer.Listener
- 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
-
onBandwidthSample
public final void onBandwidthSample(int elapsedMs, long bytesTransferred, long bitrateEstimate)
Deprecated.Description copied from interface:BandwidthMeter.EventListener
Called periodically to indicate that bytes have been transferred or the estimated bitrate has changed.Note: The estimated bitrate is typically derived from more information than just
bytesTransferred
andelapsedMs
.- Specified by:
onBandwidthSample
in interfaceBandwidthMeter.EventListener
- Parameters:
elapsedMs
- The time taken to transferbytesTransferred
, in milliseconds. This is at most the elapsed time since the last callback, but may be less if there were periods during which data was not being transferred.bytesTransferred
- The number of bytes transferred since the last callback.bitrateEstimate
- The estimated bitrate in bits/sec.
-
onDrmSessionAcquired
public final void onDrmSessionAcquired(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, @State @com.google.android.exoplayer2.drm.DrmSession.State int state)
Deprecated.Description copied from interface:DrmSessionEventListener
Called each time a drm session is acquired.- Specified by:
onDrmSessionAcquired
in interfaceDrmSessionEventListener
- Parameters:
windowIndex
- The window index in the timeline this media period belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
associated with the drm session.state
- TheDrmSession.State
of the session when the acquisition completed.
-
onDrmKeysLoaded
public final void onDrmKeysLoaded(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Description copied from interface:DrmSessionEventListener
Called each time keys are loaded.- Specified by:
onDrmKeysLoaded
in interfaceDrmSessionEventListener
- Parameters:
windowIndex
- The window index in the timeline this media period belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
associated with the drm session.
-
onDrmSessionManagerError
public final void onDrmSessionManagerError(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, Exception error)
Deprecated.Description copied from interface:DrmSessionEventListener
Called when a drm error occurs.This method being called does not indicate that playback has failed, or that it will fail. The player may be able to recover from the error and continue. Hence applications should not implement this method to display a user visible error or initiate an application level retry (
Player.Listener.onPlayerError(com.google.android.exoplayer2.PlaybackException)
is the appropriate place to implement such behavior). This method is called to provide the application with an opportunity to log the error if it wishes to do so.- Specified by:
onDrmSessionManagerError
in interfaceDrmSessionEventListener
- Parameters:
windowIndex
- The window index in the timeline this media period belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
associated with the drm session.error
- The corresponding exception.
-
onDrmKeysRestored
public final void onDrmKeysRestored(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Description copied from interface:DrmSessionEventListener
Called each time offline keys are restored.- Specified by:
onDrmKeysRestored
in interfaceDrmSessionEventListener
- Parameters:
windowIndex
- The window index in the timeline this media period belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
associated with the drm session.
-
onDrmKeysRemoved
public final void onDrmKeysRemoved(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Description copied from interface:DrmSessionEventListener
Called each time offline keys are removed.- Specified by:
onDrmKeysRemoved
in interfaceDrmSessionEventListener
- Parameters:
windowIndex
- The window index in the timeline this media period belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
associated with the drm session.
-
onDrmSessionReleased
public final void onDrmSessionReleased(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Description copied from interface:DrmSessionEventListener
Called each time a drm session is released.- Specified by:
onDrmSessionReleased
in interfaceDrmSessionEventListener
- Parameters:
windowIndex
- The window index in the timeline this media period belongs to.mediaPeriodId
- TheMediaSource.MediaPeriodId
associated with the drm session.
-
sendEvent
protected final void sendEvent(AnalyticsListener.EventTime eventTime, int eventFlag, ListenerSet.Event<AnalyticsListener> eventInvocation)
Deprecated.Sends an event to registered listeners.- Parameters:
eventTime
- TheAnalyticsListener.EventTime
to report.eventFlag
- An integer flag indicating the type of the event, orC.INDEX_UNSET
to report this event without flag.eventInvocation
- The event.
-
generateCurrentPlayerMediaPeriodEventTime
protected final AnalyticsListener.EventTime generateCurrentPlayerMediaPeriodEventTime()
Deprecated.Generates anAnalyticsListener.EventTime
for the currently playing item in the player.
-
generateEventTime
@RequiresNonNull("player") protected final AnalyticsListener.EventTime generateEventTime(Timeline timeline, int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns a newAnalyticsListener.EventTime
for the specified timeline, window and media period id.
-
-