public class EventLogger extends java.lang.Object implements Player.EventListener, MetadataOutput, AudioRendererEventListener, VideoRendererEventListener, MediaSourceEventListener, AdsMediaSource.EventListener, DefaultDrmSessionManager.EventListener
Player and other core components using Log.AudioRendererEventListener.EventDispatcherVideoRendererEventListener.EventDispatcher| Constructor and Description |
|---|
EventLogger(MappingTrackSelector trackSelector) |
| Modifier and Type | Method and Description |
|---|---|
void |
onAdClicked()
Called when the user clicks through an ad (for example, following a 'learn more' link).
|
void |
onAdLoadError(java.io.IOException error)
Called if there was an error loading one or more ads.
|
void |
onAdTapped()
Called when the user taps a non-clickthrough part of an ad.
|
void |
onAudioDecoderInitialized(java.lang.String decoderName,
long elapsedRealtimeMs,
long initializationDurationMs)
Called when a decoder is created.
|
void |
onAudioDisabled(DecoderCounters counters)
Called when the renderer is disabled.
|
void |
onAudioEnabled(DecoderCounters counters)
Called when the renderer is enabled.
|
void |
onAudioInputFormatChanged(Format format)
Called when the format of the media being consumed by the renderer changes.
|
void |
onAudioSessionId(int audioSessionId)
Called when the audio session is set.
|
void |
onAudioSinkUnderrun(int bufferSize,
long bufferSizeMs,
long elapsedSinceLastFeedMs)
Called when an
AudioSink underrun occurs. |
void |
onDownstreamFormatChanged(int trackType,
Format trackFormat,
int trackSelectionReason,
java.lang.Object trackSelectionData,
long mediaTimeMs)
Called when a downstream format change occurs (i.e.
|
void |
onDrmKeysLoaded()
Called each time keys are loaded.
|
void |
onDrmKeysRemoved()
Called each time offline keys are removed.
|
void |
onDrmKeysRestored()
Called each time offline keys are restored.
|
void |
onDrmSessionManagerError(java.lang.Exception e)
Called when a drm error occurs.
|
void |
onDroppedFrames(int count,
long elapsed)
Called to report the number of frames dropped by the renderer.
|
void |
onInternalAdLoadError(java.lang.RuntimeException error)
Called when an unexpected internal error is encountered while loading ads.
|
void |
onLoadCanceled(DataSpec dataSpec,
int dataType,
int trackType,
Format trackFormat,
int trackSelectionReason,
java.lang.Object trackSelectionData,
long mediaStartTimeMs,
long mediaEndTimeMs,
long elapsedRealtimeMs,
long loadDurationMs,
long bytesLoaded)
Called when a load is canceled.
|
void |
onLoadCompleted(DataSpec dataSpec,
int dataType,
int trackType,
Format trackFormat,
int trackSelectionReason,
java.lang.Object trackSelectionData,
long mediaStartTimeMs,
long mediaEndTimeMs,
long elapsedRealtimeMs,
long loadDurationMs,
long bytesLoaded)
Called when a load ends.
|
void |
onLoadError(DataSpec dataSpec,
int dataType,
int trackType,
Format trackFormat,
int trackSelectionReason,
java.lang.Object trackSelectionData,
long mediaStartTimeMs,
long mediaEndTimeMs,
long elapsedRealtimeMs,
long loadDurationMs,
long bytesLoaded,
java.io.IOException error,
boolean wasCanceled)
Called when a load error occurs.
|
void |
onLoadingChanged(boolean isLoading)
Called when the player starts or stops loading the source.
|
void |
onLoadStarted(DataSpec dataSpec,
int dataType,
int trackType,
Format trackFormat,
int trackSelectionReason,
java.lang.Object trackSelectionData,
long mediaStartTimeMs,
long mediaEndTimeMs,
long elapsedRealtimeMs)
Called when a load begins.
|
void |
onMetadata(Metadata metadata)
Called when there is metadata associated with current playback time.
|
void |
onPlaybackParametersChanged(PlaybackParameters playbackParameters)
Called when the current playback parameters change.
|
void |
onPlayerError(ExoPlaybackException e)
Called when an error occurs.
|
void |
onPlayerStateChanged(boolean playWhenReady,
int state)
Called when the value returned from either
Player.getPlayWhenReady() or
Player.getPlaybackState() changes. |
void |
onPositionDiscontinuity(int reason)
Called when a position discontinuity occurs without a change to the timeline.
|
void |
onRenderedFirstFrame(android.view.Surface surface)
Called when a frame is rendered for the first time since setting the surface, and when a frame
is rendered for the first time since the renderer was reset.
|
void |
onRepeatModeChanged(int repeatMode)
Called when the value of
Player.getRepeatMode() changes. |
void |
onSeekProcessed()
Called when all pending seek requests have been processed by the player.
|
void |
onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
Called when the value of
Player.getShuffleModeEnabled() changes. |
void |
onTimelineChanged(Timeline timeline,
java.lang.Object manifest,
int reason)
Called when the timeline and/or manifest has been refreshed.
|
void |
onTracksChanged(TrackGroupArray ignored,
TrackSelectionArray trackSelections)
Called when the available or selected tracks change.
|
void |
onUpstreamDiscarded(int trackType,
long mediaStartTimeMs,
long mediaEndTimeMs)
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 |
onVideoDecoderInitialized(java.lang.String decoderName,
long elapsedRealtimeMs,
long initializationDurationMs)
Called when a decoder is created.
|
void |
onVideoDisabled(DecoderCounters counters)
Called when the renderer is disabled.
|
void |
onVideoEnabled(DecoderCounters counters)
Called when the renderer is enabled.
|
void |
onVideoInputFormatChanged(Format format)
Called when the format of the media being consumed by the renderer changes.
|
void |
onVideoSizeChanged(int width,
int height,
int unappliedRotationDegrees,
float pixelWidthHeightRatio)
Called before a frame is rendered for the first time since setting the surface, and each time
there's a change in the size, rotation or pixel aspect ratio of the video being rendered.
|
public EventLogger(MappingTrackSelector trackSelector)
public void onLoadingChanged(boolean isLoading)
Player.EventListeneronLoadingChanged in interface Player.EventListenerisLoading - Whether the source is currently being loaded.public void onPlayerStateChanged(boolean playWhenReady,
int state)
Player.EventListenerPlayer.getPlayWhenReady() or
Player.getPlaybackState() changes.onPlayerStateChanged in interface Player.EventListenerplayWhenReady - Whether playback will proceed when ready.state - One of the STATE constants.public void onRepeatModeChanged(int repeatMode)
Player.EventListenerPlayer.getRepeatMode() changes.onRepeatModeChanged in interface Player.EventListenerrepeatMode - The Player.RepeatMode used for playback.public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
Player.EventListenerPlayer.getShuffleModeEnabled() changes.onShuffleModeEnabledChanged in interface Player.EventListenershuffleModeEnabled - Whether shuffling of windows is enabled.public void onPositionDiscontinuity(int reason)
Player.EventListener
When a position discontinuity occurs as a result of a change to the timeline this method is
not called. Player.EventListener.onTimelineChanged(Timeline, Object, int) is called in this
case.
onPositionDiscontinuity in interface Player.EventListenerreason - The Player.DiscontinuityReason responsible for the discontinuity.public void onPlaybackParametersChanged(PlaybackParameters playbackParameters)
Player.EventListenerPlayer.setPlaybackParameters(PlaybackParameters), or the player itself may change
them (for example, if audio playback switches to passthrough mode, where speed adjustment is
no longer possible).onPlaybackParametersChanged in interface Player.EventListenerplaybackParameters - The playback parameters.public void onTimelineChanged(Timeline timeline, java.lang.Object manifest, int reason)
Player.EventListener
Note that if the timeline has changed then a position discontinuity may also have occurred.
For example, the current period index may have changed as a result of periods being added or
removed from the timeline. This will not be reported via a separate call to
Player.EventListener.onPositionDiscontinuity(int).
onTimelineChanged in interface Player.EventListenertimeline - The latest timeline. Never null, but may be empty.manifest - The latest manifest. May be null.reason - The Player.TimelineChangeReason responsible for this timeline change.public void onPlayerError(ExoPlaybackException e)
Player.EventListenerPlayer.STATE_IDLE
immediately after this method is called. The player instance can still be used, and
Player.release() must still be called on the player should it no longer be required.onPlayerError in interface Player.EventListenere - The error.public void onTracksChanged(TrackGroupArray ignored, TrackSelectionArray trackSelections)
Player.EventListeneronTracksChanged in interface Player.EventListenerignored - The available tracks. Never null, but may be of length zero.trackSelections - The track selections for each renderer. Never null and always of
length Player.getRendererCount(), but may contain null elements.public void onSeekProcessed()
Player.EventListenerPlayer.EventListener.onPlayerStateChanged(boolean, int).onSeekProcessed in interface Player.EventListenerpublic void onMetadata(Metadata metadata)
MetadataOutputonMetadata in interface MetadataOutputmetadata - The metadata.public void onAudioEnabled(DecoderCounters counters)
AudioRendererEventListeneronAudioEnabled in interface AudioRendererEventListenercounters - DecoderCounters that will be updated by the renderer for as long as it
remains enabled.public void onAudioSessionId(int audioSessionId)
AudioRendererEventListeneronAudioSessionId in interface AudioRendererEventListeneraudioSessionId - The audio session id.public void onAudioDecoderInitialized(java.lang.String decoderName,
long elapsedRealtimeMs,
long initializationDurationMs)
AudioRendererEventListeneronAudioDecoderInitialized in interface AudioRendererEventListenerdecoderName - The decoder that was created.elapsedRealtimeMs - SystemClock.elapsedRealtime() when initialization
finished.initializationDurationMs - The time taken to initialize the decoder in milliseconds.public void onAudioInputFormatChanged(Format format)
AudioRendererEventListeneronAudioInputFormatChanged in interface AudioRendererEventListenerformat - The new format.public void onAudioDisabled(DecoderCounters counters)
AudioRendererEventListeneronAudioDisabled in interface AudioRendererEventListenercounters - DecoderCounters that were updated by the renderer.public void onAudioSinkUnderrun(int bufferSize,
long bufferSizeMs,
long elapsedSinceLastFeedMs)
AudioRendererEventListenerAudioSink underrun occurs.onAudioSinkUnderrun in interface AudioRendererEventListenerbufferSize - The size of the AudioSink's buffer, in bytes.bufferSizeMs - The size of the AudioSink's buffer, in milliseconds, if it is
configured for PCM output. C.TIME_UNSET if it is configured for passthrough output,
as the buffered media can have a variable bitrate so the duration may be unknown.elapsedSinceLastFeedMs - The time since the AudioSink was last fed data.public void onVideoEnabled(DecoderCounters counters)
VideoRendererEventListeneronVideoEnabled in interface VideoRendererEventListenercounters - DecoderCounters that will be updated by the renderer for as long as it
remains enabled.public void onVideoDecoderInitialized(java.lang.String decoderName,
long elapsedRealtimeMs,
long initializationDurationMs)
VideoRendererEventListeneronVideoDecoderInitialized in interface VideoRendererEventListenerdecoderName - The decoder that was created.elapsedRealtimeMs - SystemClock.elapsedRealtime() when initialization
finished.initializationDurationMs - The time taken to initialize the decoder in milliseconds.public void onVideoInputFormatChanged(Format format)
VideoRendererEventListeneronVideoInputFormatChanged in interface VideoRendererEventListenerformat - The new format.public void onVideoDisabled(DecoderCounters counters)
VideoRendererEventListeneronVideoDisabled in interface VideoRendererEventListenercounters - DecoderCounters that were updated by the renderer.public void onDroppedFrames(int count,
long elapsed)
VideoRendererEventListeneronDroppedFrames in interface VideoRendererEventListenercount - The number of dropped frames.elapsed - 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.public void onVideoSizeChanged(int width,
int height,
int unappliedRotationDegrees,
float pixelWidthHeightRatio)
VideoRendererEventListeneronVideoSizeChanged in interface VideoRendererEventListenerwidth - The video width in pixels.height - The video height in pixels.unappliedRotationDegrees - For videos that require a rotation, this is the clockwise
rotation in degrees that the application should apply for the video for it to be rendered
in the correct orientation. This value will always be zero on API levels 21 and above,
since the renderer will apply all necessary rotations internally. On earlier API levels
this is not possible. Applications that use TextureView can apply the rotation by
calling TextureView.setTransform(android.graphics.Matrix). Applications that do not expect to encounter
rotated videos can safely ignore this parameter.pixelWidthHeightRatio - The width to height ratio of each pixel. For the normal case
of square pixels this will be equal to 1.0. Different values are indicative of anamorphic
content.public void onRenderedFirstFrame(android.view.Surface surface)
VideoRendererEventListeneronRenderedFirstFrame in interface VideoRendererEventListenersurface - The Surface to which a first frame has been rendered, or null if
the renderer renders to something that isn't a Surface.public void onDrmSessionManagerError(java.lang.Exception e)
DefaultDrmSessionManager.EventListener
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.EventListener#onPlayerError 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.
onDrmSessionManagerError in interface DefaultDrmSessionManager.EventListenere - The corresponding exception.public void onDrmKeysRestored()
DefaultDrmSessionManager.EventListeneronDrmKeysRestored in interface DefaultDrmSessionManager.EventListenerpublic void onDrmKeysRemoved()
DefaultDrmSessionManager.EventListeneronDrmKeysRemoved in interface DefaultDrmSessionManager.EventListenerpublic void onDrmKeysLoaded()
DefaultDrmSessionManager.EventListeneronDrmKeysLoaded in interface DefaultDrmSessionManager.EventListenerpublic void onLoadStarted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, java.lang.Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs)
MediaSourceEventListeneronLoadStarted in interface MediaSourceEventListenerdataSpec - Defines the data being loaded.dataType - One of the C DATA_TYPE_* constants defining the type of data
being loaded.trackType - One of the C TRACK_TYPE_* constants if the data corresponds to
media of a specific type. C.TRACK_TYPE_UNKNOWN otherwise.trackFormat - The format of the track to which the data belongs. Null if the data does not
belong to a track.trackSelectionReason - One of the C SELECTION_REASON_* constants if the
data belongs to a track. C.SELECTION_REASON_UNKNOWN otherwise.trackSelectionData - Optional data associated with the selection of the track to which the
data belongs. Null if the data does not belong to a track.mediaStartTimeMs - The start time of the media being loaded, or C.TIME_UNSET if
the load is not for media data.mediaEndTimeMs - The end time of the media being loaded, or C.TIME_UNSET if the
load is not for media data or the end time is unknown.elapsedRealtimeMs - The value of SystemClock.elapsedRealtime() when the load began.public void onLoadError(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, java.lang.Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded, java.io.IOException error, boolean wasCanceled)
MediaSourceEventListenerThe 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(com.google.android.exoplayer2.upstream.DataSpec, int, int, com.google.android.exoplayer2.Format, int, java.lang.Object, long, long, long, long, long) 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 and continue. Hence applications should
not implement this method to display a user visible error or initiate an application
level retry (Player.EventListener#onPlayerError 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.
onLoadError in interface MediaSourceEventListenerdataSpec - Defines the data being loaded.dataType - One of the C DATA_TYPE_* constants defining the type of data
being loaded.trackType - One of the C TRACK_TYPE_* constants if the data corresponds to
media of a specific type. C.TRACK_TYPE_UNKNOWN otherwise.trackFormat - The format of the track to which the data belongs. Null if the data does not
belong to a track.trackSelectionReason - One of the C SELECTION_REASON_* constants if the
data belongs to a track. C.SELECTION_REASON_UNKNOWN otherwise.trackSelectionData - Optional data associated with the selection of the track to which the
data belongs. Null if the data does not belong to a track.mediaStartTimeMs - The start time of the media being loaded, or C.TIME_UNSET if
the load is not for media data.mediaEndTimeMs - The end time of the media being loaded, or C.TIME_UNSET if the
load is not for media data.elapsedRealtimeMs - The value of SystemClock.elapsedRealtime() when the error
occurred.loadDurationMs - The duration of the load up to the point at which the error occurred.bytesLoaded - The number of bytes that were loaded prior to the error.error - The load error.wasCanceled - Whether the load was canceled as a result of the error.public void onLoadCanceled(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, java.lang.Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded)
MediaSourceEventListeneronLoadCanceled in interface MediaSourceEventListenerdataSpec - Defines the data being loaded.dataType - One of the C DATA_TYPE_* constants defining the type of data
being loaded.trackType - One of the C TRACK_TYPE_* constants if the data corresponds to
media of a specific type. C.TRACK_TYPE_UNKNOWN otherwise.trackFormat - The format of the track to which the data belongs. Null if the data does not
belong to a track.trackSelectionReason - One of the C SELECTION_REASON_* constants if the
data belongs to a track. C.SELECTION_REASON_UNKNOWN otherwise.trackSelectionData - Optional data associated with the selection of the track to which the
data belongs. Null if the data does not belong to a track.mediaStartTimeMs - The start time of the media being loaded, or C.TIME_UNSET if
the load is not for media data.mediaEndTimeMs - The end time of the media being loaded, or C.TIME_UNSET if the
load is not for media data.elapsedRealtimeMs - The value of SystemClock.elapsedRealtime() when the load was
canceled.loadDurationMs - The duration of the load up to the point at which it was canceled.bytesLoaded - The number of bytes that were loaded prior to cancelation.public void onLoadCompleted(DataSpec dataSpec, int dataType, int trackType, Format trackFormat, int trackSelectionReason, java.lang.Object trackSelectionData, long mediaStartTimeMs, long mediaEndTimeMs, long elapsedRealtimeMs, long loadDurationMs, long bytesLoaded)
MediaSourceEventListeneronLoadCompleted in interface MediaSourceEventListenerdataSpec - Defines the data being loaded.dataType - One of the C DATA_TYPE_* constants defining the type of data
being loaded.trackType - One of the C TRACK_TYPE_* constants if the data corresponds to
media of a specific type. C.TRACK_TYPE_UNKNOWN otherwise.trackFormat - The format of the track to which the data belongs. Null if the data does not
belong to a track.trackSelectionReason - One of the C SELECTION_REASON_* constants if the
data belongs to a track. C.SELECTION_REASON_UNKNOWN otherwise.trackSelectionData - Optional data associated with the selection of the track to which the
data belongs. Null if the data does not belong to a track.mediaStartTimeMs - The start time of the media being loaded, or C.TIME_UNSET if
the load is not for media data.mediaEndTimeMs - The end time of the media being loaded, or C.TIME_UNSET if the
load is not for media data.elapsedRealtimeMs - The value of SystemClock.elapsedRealtime() when the load ended.loadDurationMs - The duration of the load.bytesLoaded - The number of bytes that were loaded.public void onUpstreamDiscarded(int trackType,
long mediaStartTimeMs,
long mediaEndTimeMs)
MediaSourceEventListeneronUpstreamDiscarded in interface MediaSourceEventListenertrackType - The type of the media. One of the C TRACK_TYPE_* constants.mediaStartTimeMs - The start time of the media being discarded.mediaEndTimeMs - The end time of the media being discarded.public void onDownstreamFormatChanged(int trackType,
Format trackFormat,
int trackSelectionReason,
java.lang.Object trackSelectionData,
long mediaTimeMs)
MediaSourceEventListenerSampleStreams provided by the source changes).onDownstreamFormatChanged in interface MediaSourceEventListenertrackType - The type of the media. One of the C TRACK_TYPE_* constants.trackFormat - The format of the track to which the data belongs. Null if the data does not
belong to a track.trackSelectionReason - One of the C SELECTION_REASON_* constants if the
data belongs to a track. C.SELECTION_REASON_UNKNOWN otherwise.trackSelectionData - Optional data associated with the selection of the track to which the
data belongs. Null if the data does not belong to a track.mediaTimeMs - The media time at which the change occurred.public void onAdLoadError(java.io.IOException error)
AdsMediaSource.EventListeneronAdLoadError in interface AdsMediaSource.EventListenererror - The error.public void onInternalAdLoadError(java.lang.RuntimeException error)
AdsMediaSource.EventListeneronInternalAdLoadError in interface AdsMediaSource.EventListenererror - The error.public void onAdClicked()
AdsMediaSource.EventListeneronAdClicked in interface AdsMediaSource.EventListenerpublic void onAdTapped()
AdsMediaSource.EventListeneronAdTapped in interface AdsMediaSource.EventListener