docs/doc/reference/com/google/android/exoplayer2/analytics/MediaMetricsListener.html
Package com.google.android.exoplayer2.analytics
All Implemented Interfaces:AnalyticsListener, PlaybackSessionManager.Listener
@RequiresApi(31)[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classMediaMetricsListenerextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[AnalyticsListener](AnalyticsListener.html "interface in com.google.android.exoplayer2.analytics"),[PlaybackSessionManager.Listener](PlaybackSessionManager.Listener.html "interface in com.google.android.exoplayer2.analytics")
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.
An AnalyticsListener that interacts with the Android MediaMetricsManager.
It listens to playback events and forwards them to a PlaybackSession. The LogSessionId of the playback session can be obtained with getLogSessionId().
-
AnalyticsListener.EventFlags, AnalyticsListener.Events, AnalyticsListener.EventTime
-
EVENT_AUDIO_ATTRIBUTES_CHANGED, EVENT_AUDIO_CODEC_ERROR, EVENT_AUDIO_DECODER_INITIALIZED, EVENT_AUDIO_DECODER_RELEASED, EVENT_AUDIO_DISABLED, EVENT_AUDIO_ENABLED, EVENT_AUDIO_INPUT_FORMAT_CHANGED, EVENT_AUDIO_POSITION_ADVANCING, EVENT_AUDIO_SESSION_ID, EVENT_AUDIO_SINK_ERROR, EVENT_AUDIO_UNDERRUN, EVENT_AVAILABLE_COMMANDS_CHANGED, EVENT_BANDWIDTH_ESTIMATE, EVENT_CUES, EVENT_DEVICE_INFO_CHANGED, EVENT_DEVICE_VOLUME_CHANGED, EVENT_DOWNSTREAM_FORMAT_CHANGED, EVENT_DRM_KEYS_LOADED, EVENT_DRM_KEYS_REMOVED, EVENT_DRM_KEYS_RESTORED, EVENT_DRM_SESSION_ACQUIRED, EVENT_DRM_SESSION_MANAGER_ERROR, EVENT_DRM_SESSION_RELEASED, EVENT_DROPPED_VIDEO_FRAMES, EVENT_IS_LOADING_CHANGED, EVENT_IS_PLAYING_CHANGED, EVENT_LOAD_CANCELED, EVENT_LOAD_COMPLETED, EVENT_LOAD_ERROR, EVENT_LOAD_STARTED, EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED, EVENT_MEDIA_ITEM_TRANSITION, EVENT_MEDIA_METADATA_CHANGED, EVENT_METADATA, EVENT_PLAY_WHEN_READY_CHANGED, EVENT_PLAYBACK_PARAMETERS_CHANGED, EVENT_PLAYBACK_STATE_CHANGED, EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED, EVENT_PLAYER_ERROR, EVENT_PLAYER_RELEASED, EVENT_PLAYLIST_METADATA_CHANGED, EVENT_POSITION_DISCONTINUITY, EVENT_RENDERED_FIRST_FRAME, EVENT_REPEAT_MODE_CHANGED, EVENT_SEEK_BACK_INCREMENT_CHANGED, EVENT_SEEK_FORWARD_INCREMENT_CHANGED, EVENT_SHUFFLE_MODE_ENABLED_CHANGED, EVENT_SKIP_SILENCE_ENABLED_CHANGED, EVENT_SURFACE_SIZE_CHANGED, EVENT_TIMELINE_CHANGED, EVENT_TRACK_SELECTION_PARAMETERS_CHANGED, EVENT_TRACKS_CHANGED, EVENT_UPSTREAM_DISCARDED, EVENT_VIDEO_CODEC_ERROR, EVENT_VIDEO_DECODER_INITIALIZED, EVENT_VIDEO_DECODER_RELEASED, EVENT_VIDEO_DISABLED, EVENT_VIDEO_ENABLED, EVENT_VIDEO_FRAME_PROCESSING_OFFSET, EVENT_VIDEO_INPUT_FORMAT_CHANGED, EVENT_VIDEO_SIZE_CHANGED, EVENT_VOLUME_CHANGED
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| static MediaMetricsListener | create(Context context) |
Deprecated.
Creates a media metrics listener.
|
| LogSessionId | getLogSessionId() |
Deprecated.
Returns the LogSessionId used by this listener.
|
| void | onAdPlaybackStarted(AnalyticsListener.EventTime eventTime, String contentSessionId, String adSessionId) |
Deprecated.
Called when a session is interrupted by ad playback.
|
| void | onBandwidthEstimate(AnalyticsListener.EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate) |
Deprecated.
Called when the bandwidth estimate for the current data source has been updated.
|
| void | onDownstreamFormatChanged(AnalyticsListener.EventTime eventTime, MediaLoadData mediaLoadData) |
Deprecated.
Called when the downstream format sent to the renderers changed.
|
| void | onEvents(Player player, AnalyticsListener.Events events) |
Deprecated.
Called after one or more events occurred.
|
| void | onLoadError(AnalyticsListener.EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData, IOException error, boolean wasCanceled) |
Deprecated.
Called when a media source loading error occurred.
|
| void | onPlayerError(AnalyticsListener.EventTime eventTime, PlaybackException error) |
Deprecated.
Called when a fatal player error occurred.
|
| void | onPositionDiscontinuity(AnalyticsListener.EventTime eventTime, Player.PositionInfo oldPosition, Player.PositionInfo newPosition, @com.google.android.exoplayer2.Player.DiscontinuityReason int reason) |
Deprecated.
Called when a position discontinuity occurred.
|
| void | onSessionActive(AnalyticsListener.EventTime eventTime, String sessionId) |
Deprecated.
Called when a session becomes active, i.e.
|
| void | onSessionCreated(AnalyticsListener.EventTime eventTime, String sessionId) |
Deprecated.
Called when a new session is created as a result of PlaybackSessionManager.updateSessions(EventTime).
|
| void | onSessionFinished(AnalyticsListener.EventTime eventTime, String sessionId, boolean automaticTransitionToNextPlayback) |
Deprecated.
Called when a session is permanently finished.
|
| void | onVideoDisabled(AnalyticsListener.EventTime eventTime, DecoderCounters decoderCounters) |
Deprecated.
Called when a video renderer is disabled.
|
| void | onVideoSizeChanged(AnalyticsListener.EventTime eventTime, VideoSize videoSize) |
Deprecated.
Called before a frame is rendered for the first time since setting the surface, and each time there's a change in the size or pixel aspect ratio of the video being rendered. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
onAudioAttributesChanged, onAudioCodecError, onAudioDecoderInitialized, onAudioDecoderInitialized, onAudioDecoderReleased, onAudioDisabled, onAudioEnabled, onAudioInputFormatChanged, onAudioInputFormatChanged, onAudioPositionAdvancing, onAudioSessionIdChanged, onAudioSinkError, onAudioUnderrun, onAvailableCommandsChanged, onCues, onCues, onDeviceInfoChanged, onDeviceVolumeChanged, onDrmKeysLoaded, onDrmKeysRemoved, onDrmKeysRestored, onDrmSessionAcquired, onDrmSessionAcquired, onDrmSessionManagerError, onDrmSessionReleased, onDroppedVideoFrames, onIsLoadingChanged, onIsPlayingChanged, onLoadCanceled, onLoadCompleted, onLoadingChanged, onLoadStarted, onMaxSeekToPreviousPositionChanged, onMediaItemTransition, onMediaMetadataChanged, onMetadata, onPlaybackParametersChanged, onPlaybackStateChanged, onPlaybackSuppressionReasonChanged, onPlayerErrorChanged, onPlayerReleased, onPlayerStateChanged, onPlaylistMetadataChanged, onPlayWhenReadyChanged, onPositionDiscontinuity, onRenderedFirstFrame, onRepeatModeChanged, onSeekBackIncrementChanged, onSeekForwardIncrementChanged, onSeekStarted, onShuffleModeChanged, onSkipSilenceEnabledChanged, onSurfaceSizeChanged, onTimelineChanged, onTracksChanged, onTrackSelectionParametersChanged, onUpstreamDiscarded, onVideoCodecError, onVideoDecoderInitialized, onVideoDecoderInitialized, onVideoDecoderReleased, onVideoEnabled, onVideoFrameProcessingOffset, onVideoInputFormatChanged, onVideoInputFormatChanged, onVideoSizeChanged, onVolumeChanged
-
@Nullable
public static[MediaMetricsListener](MediaMetricsListener.html "class in com.google.android.exoplayer2.analytics")create([Context](https://developer.android.com/reference/android/content/Context.html "class or interface in android.content")context)
Deprecated.
Creates a media metrics listener.
Parameters:context - A context.Returns:The MediaMetricsListener, or null if the media metrics service isn't available.
-
public[LogSessionId](https://developer.android.com/reference/android/media/metrics/LogSessionId.html "class or interface in android.media.metrics")getLogSessionId()
Deprecated.
Returns the LogSessionId used by this listener.
-
public void onSessionCreated([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")sessionId)
Deprecated.
Description copied from interface: PlaybackSessionManager.Listener
Called when a new session is created as a result of PlaybackSessionManager.updateSessions(EventTime).
Specified by:onSessionCreated in interface PlaybackSessionManager.ListenerParameters:eventTime - The AnalyticsListener.EventTime at which the session is created.sessionId - The identifier of the new session.
-
public void onSessionActive([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")sessionId)
Deprecated.
Description copied from interface: PlaybackSessionManager.Listener
Called when a session becomes active, i.e. playing in the foreground.
Specified by:onSessionActive in interface PlaybackSessionManager.ListenerParameters:eventTime - The AnalyticsListener.EventTime at which the session becomes active.sessionId - The identifier of the session.
-
public void onAdPlaybackStarted([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")contentSessionId,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")adSessionId)
Deprecated.
Description copied from interface: PlaybackSessionManager.Listener
Called when a session is interrupted by ad playback.
Specified by:onAdPlaybackStarted in interface PlaybackSessionManager.ListenerParameters:eventTime - The AnalyticsListener.EventTime at which the ad playback starts.contentSessionId - The session identifier of the content session.adSessionId - The identifier of the ad session.
-
public void onSessionFinished([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")sessionId,
boolean automaticTransitionToNextPlayback)
Deprecated.
Description copied from interface: PlaybackSessionManager.Listener
Called when a session is permanently finished.
Specified by:onSessionFinished in interface PlaybackSessionManager.ListenerParameters:eventTime - The AnalyticsListener.EventTime at which the session finished.sessionId - The identifier of the finished session.automaticTransitionToNextPlayback - Whether the session finished because of an automatic transition to the next playback item.
-
public void onPositionDiscontinuity([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[Player.PositionInfo](../Player.PositionInfo.html "class in com.google.android.exoplayer2")oldPosition,[Player.PositionInfo](../Player.PositionInfo.html "class in com.google.android.exoplayer2")newPosition,[@DiscontinuityReason](../Player.DiscontinuityReason.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
Deprecated.
Description copied from interface: AnalyticsListener
Called when a position discontinuity occurred.
Specified by:onPositionDiscontinuity in interface AnalyticsListenerParameters:eventTime - The event time.oldPosition - The position before the discontinuity.newPosition - The position after the discontinuity.reason - The reason for the position discontinuity.
-
public void onVideoDisabled([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[DecoderCounters](../decoder/DecoderCounters.html "class in com.google.android.exoplayer2.decoder")decoderCounters)
Deprecated.
Description copied from interface: AnalyticsListener
Called when a video renderer is disabled.
Specified by:onVideoDisabled in interface AnalyticsListenerParameters:eventTime - The event time.decoderCounters - DecoderCounters that were updated by the renderer.
-
public void onBandwidthEstimate([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,
int totalLoadTimeMs,
long totalBytesLoaded,
long bitrateEstimate)
Deprecated.
Description copied from interface: AnalyticsListener
Called when the bandwidth estimate for the current data source has been updated.
Specified by:onBandwidthEstimate in interface AnalyticsListenerParameters:eventTime - The event time.totalLoadTimeMs - The total time spend loading this update is based on, in milliseconds.totalBytesLoaded - The total bytes loaded this update is based on.bitrateEstimate - The bandwidth estimate, in bits per second.
-
public void onDownstreamFormatChanged([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[MediaLoadData](../source/MediaLoadData.html "class in com.google.android.exoplayer2.source")mediaLoadData)
Deprecated.
Description copied from interface: AnalyticsListener
Called when the downstream format sent to the renderers changed.
Specified by:onDownstreamFormatChanged in interface AnalyticsListenerParameters:eventTime - The event time.mediaLoadData - The MediaLoadData defining the newly selected media data.
-
public void onVideoSizeChanged([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[VideoSize](../video/VideoSize.html "class in com.google.android.exoplayer2.video")videoSize)
Deprecated.
Description copied from interface: AnalyticsListener
Called before a frame is rendered for the first time since setting the surface, and each time there's a change in the size or pixel aspect ratio of the video being rendered.
Specified by:onVideoSizeChanged in interface AnalyticsListenerParameters:eventTime - The event time.videoSize - The new size of the video.
-
public void onLoadError([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[LoadEventInfo](../source/LoadEventInfo.html "class in com.google.android.exoplayer2.source")loadEventInfo,[MediaLoadData](../source/MediaLoadData.html "class in com.google.android.exoplayer2.source")mediaLoadData,[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")error,
boolean wasCanceled)
Deprecated.
Description copied from interface: AnalyticsListener
Called when a media source loading error occurred.
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 interface AnalyticsListenerParameters:eventTime - The event time.loadEventInfo - The LoadEventInfo defining the load event.mediaLoadData - The MediaLoadData defining the data being loaded.error - The load error.wasCanceled - Whether the load was canceled as a result of the error.
-
public void onPlayerError([AnalyticsListener.EventTime](AnalyticsListener.EventTime.html "class in com.google.android.exoplayer2.analytics")eventTime,[PlaybackException](../PlaybackException.html "class in com.google.android.exoplayer2")error)
Deprecated.
Description copied from interface: AnalyticsListener
Called when a fatal player error occurred.
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 interface AnalyticsListenerParameters:eventTime - The event time.error - The error.
-
public void onEvents([Player](../Player.html "interface in com.google.android.exoplayer2")player,[AnalyticsListener.Events](AnalyticsListener.Events.html "class in com.google.android.exoplayer2.analytics")events)
Deprecated.
Description copied from interface: AnalyticsListener
Called after one or more events occurred.
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 [`AnalyticsListener.onPlaybackStateChanged(EventTime, int)`](AnalyticsListener.html#onPlaybackStateChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,@com.google.android.exoplayer2.Player.Stateint)) and [`AnalyticsListener.onPlayWhenReadyChanged(EventTime, boolean, int)`](AnalyticsListener.html#onPlayWhenReadyChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,boolean,@com.google.android.exoplayer2.Player.PlayWhenReadyChangeReasonint))).
- They need access to the [`Player`](../Player.html "interface in com.google.android.exoplayer2") object to trigger further events (e.g. to call [`Player.seekTo(long)`](../Player.html#seekTo(long)) after a [`AnalyticsListener.onMediaItemTransition(EventTime, MediaItem, int)`](AnalyticsListener.html#onMediaItemTransition(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,com.google.android.exoplayer2.MediaItem,@com.google.android.exoplayer2.Player.MediaItemTransitionReasonint))).
- They intend to use multiple state values together or in combination with [`Player`](../Player.html "interface in com.google.android.exoplayer2") getter methods. For example using [`Player.getCurrentMediaItemIndex()`](../Player.html#getCurrentMediaItemIndex()) with the `timeline` provided in [`AnalyticsListener.onTimelineChanged(EventTime, int)`](AnalyticsListener.html#onTimelineChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,@com.google.android.exoplayer2.Player.TimelineChangeReasonint)) is only safe from within this method.
- They are interested in events that logically happened together (e.g [`AnalyticsListener.onPlaybackStateChanged(EventTime, int)`](AnalyticsListener.html#onPlaybackStateChanged(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,@com.google.android.exoplayer2.Player.Stateint)) to [`Player.STATE_BUFFERING`](../Player.html#STATE_BUFFERING) because of [`AnalyticsListener.onMediaItemTransition(EventTime, MediaItem, int)`](AnalyticsListener.html#onMediaItemTransition(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime,com.google.android.exoplayer2.MediaItem,@com.google.android.exoplayer2.Player.MediaItemTransitionReasonint))).
Specified by:onEvents in interface AnalyticsListenerParameters:player - The Player.events - The AnalyticsListener.Events that occurred in this iteration.