use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultAnalyticsCollector method generateEventTime.
/**
* Returns a new {@link EventTime} for the specified timeline, window and media period id.
*/
@RequiresNonNull("player")
protected final EventTime generateEventTime(Timeline timeline, int windowIndex, @Nullable MediaPeriodId mediaPeriodId) {
if (timeline.isEmpty()) {
// Ensure media period id is only reported together with a valid timeline.
mediaPeriodId = null;
}
long realtimeMs = clock.elapsedRealtime();
long eventPositionMs;
boolean isInCurrentWindow = timeline.equals(player.getCurrentTimeline()) && windowIndex == player.getCurrentMediaItemIndex();
if (mediaPeriodId != null && mediaPeriodId.isAd()) {
boolean isCurrentAd = isInCurrentWindow && player.getCurrentAdGroupIndex() == mediaPeriodId.adGroupIndex && player.getCurrentAdIndexInAdGroup() == mediaPeriodId.adIndexInAdGroup;
// Assume start position of 0 for future ads.
eventPositionMs = isCurrentAd ? player.getCurrentPosition() : 0;
} else if (isInCurrentWindow) {
eventPositionMs = player.getContentPosition();
} else {
// Assume default start position for future content windows. If timeline is not available yet,
// assume start position of 0.
eventPositionMs = timeline.isEmpty() ? 0 : timeline.getWindow(windowIndex, window).getDefaultPositionMs();
}
@Nullable MediaPeriodId currentMediaPeriodId = mediaPeriodQueueTracker.getCurrentPlayerMediaPeriod();
return new EventTime(realtimeMs, timeline, windowIndex, mediaPeriodId, eventPositionMs, player.getCurrentTimeline(), player.getCurrentMediaItemIndex(), currentMediaPeriodId, player.getCurrentPosition(), player.getTotalBufferedDuration());
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onAudioCodecError.
@Override
public final void onAudioCodecError(Exception audioCodecError) {
EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent(eventTime, AnalyticsListener.EVENT_AUDIO_CODEC_ERROR, listener -> listener.onAudioCodecError(eventTime, audioCodecError));
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onVideoDisabled.
@Override
// Calling deprecated listener method.
@SuppressWarnings("deprecation")
public final void onVideoDisabled(DecoderCounters counters) {
EventTime eventTime = generatePlayingMediaPeriodEventTime();
sendEvent(eventTime, AnalyticsListener.EVENT_VIDEO_DISABLED, listener -> {
listener.onVideoDisabled(eventTime, counters);
listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_VIDEO, counters);
});
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onVideoEnabled.
// Video events.
@Override
// Calling deprecated listener method.
@SuppressWarnings("deprecation")
public final void onVideoEnabled(DecoderCounters counters) {
EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent(eventTime, AnalyticsListener.EVENT_VIDEO_ENABLED, listener -> {
listener.onVideoEnabled(eventTime, counters);
listener.onDecoderEnabled(eventTime, C.TRACK_TYPE_VIDEO, counters);
});
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onUpstreamDiscarded.
@Override
public final void onUpstreamDiscarded(int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
sendEvent(eventTime, AnalyticsListener.EVENT_UPSTREAM_DISCARDED, listener -> listener.onUpstreamDiscarded(eventTime, mediaLoadData));
}
Aggregations