Search in sources :

Example 11 with EventTime

use of androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime in project media by androidx.

the class DefaultAnalyticsCollector method onDrmSessionAcquired.

// DrmSessionEventListener implementation.
@Override
// Calls deprecated listener method.
@SuppressWarnings("deprecation")
public final void onDrmSessionAcquired(int windowIndex, @Nullable MediaPeriodId mediaPeriodId, @DrmSession.State int state) {
    EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
    sendEvent(eventTime, AnalyticsListener.EVENT_DRM_SESSION_ACQUIRED, listener -> {
        listener.onDrmSessionAcquired(eventTime);
        listener.onDrmSessionAcquired(eventTime, state);
    });
}
Also used : EventTime(androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime)

Example 12 with EventTime

use of androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime in project media by androidx.

the class DefaultAnalyticsCollector method onAudioEnabled.

// Audio events.
// Calling deprecated listener method.
@SuppressWarnings("deprecation")
@Override
public final void onAudioEnabled(DecoderCounters counters) {
    EventTime eventTime = generateReadingMediaPeriodEventTime();
    sendEvent(eventTime, AnalyticsListener.EVENT_AUDIO_ENABLED, listener -> {
        listener.onAudioEnabled(eventTime, counters);
        listener.onDecoderEnabled(eventTime, C.TRACK_TYPE_AUDIO, counters);
    });
}
Also used : EventTime(androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime)

Example 13 with EventTime

use of androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime in project media by androidx.

the class DefaultPlaybackSessionManager method updateCurrentSession.

@RequiresNonNull("listener")
private void updateCurrentSession(EventTime eventTime) {
    if (eventTime.timeline.isEmpty()) {
        // Clear current session if the Timeline is empty.
        currentSessionId = null;
        return;
    }
    @Nullable SessionDescriptor previousSessionDescriptor = sessions.get(currentSessionId);
    SessionDescriptor currentSessionDescriptor = getOrAddSession(eventTime.windowIndex, eventTime.mediaPeriodId);
    currentSessionId = currentSessionDescriptor.sessionId;
    updateSessions(eventTime);
    if (eventTime.mediaPeriodId != null && eventTime.mediaPeriodId.isAd() && (previousSessionDescriptor == null || previousSessionDescriptor.windowSequenceNumber != eventTime.mediaPeriodId.windowSequenceNumber || previousSessionDescriptor.adMediaPeriodId == null || previousSessionDescriptor.adMediaPeriodId.adGroupIndex != eventTime.mediaPeriodId.adGroupIndex || previousSessionDescriptor.adMediaPeriodId.adIndexInAdGroup != eventTime.mediaPeriodId.adIndexInAdGroup)) {
        // New ad playback started. Find corresponding content session and notify ad playback started.
        MediaPeriodId contentMediaPeriodId = new MediaPeriodId(eventTime.mediaPeriodId.periodUid, eventTime.mediaPeriodId.windowSequenceNumber);
        SessionDescriptor contentSession = getOrAddSession(eventTime.windowIndex, contentMediaPeriodId);
        listener.onAdPlaybackStarted(eventTime, contentSession.sessionId, currentSessionDescriptor.sessionId);
    }
}
Also used : MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) Nullable(androidx.annotation.Nullable) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 14 with EventTime

use of androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime in project media by androidx.

the class DefaultPlaybackSessionManager method updateSessionsWithTimelineChange.

@Override
public synchronized void updateSessionsWithTimelineChange(EventTime eventTime) {
    Assertions.checkNotNull(listener);
    Timeline previousTimeline = currentTimeline;
    currentTimeline = eventTime.timeline;
    Iterator<SessionDescriptor> iterator = sessions.values().iterator();
    while (iterator.hasNext()) {
        SessionDescriptor session = iterator.next();
        if (!session.tryResolvingToNewTimeline(previousTimeline, currentTimeline) || session.isFinishedAtEventTime(eventTime)) {
            iterator.remove();
            if (session.isCreated) {
                if (session.sessionId.equals(currentSessionId)) {
                    currentSessionId = null;
                }
                listener.onSessionFinished(eventTime, session.sessionId, /* automaticTransitionToNextPlayback= */
                false);
            }
        }
    }
    updateCurrentSession(eventTime);
}
Also used : Timeline(androidx.media3.common.Timeline)

Example 15 with EventTime

use of androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime in project media by androidx.

the class MediaMetricsListener method onVideoSizeChanged.

@Override
public void onVideoSizeChanged(EventTime eventTime, VideoSize videoSize) {
    @Nullable PendingFormatUpdate pendingVideoFormat = this.pendingVideoFormat;
    if (pendingVideoFormat != null && pendingVideoFormat.format.height == Format.NO_VALUE) {
        Format formatWithHeightAndWidth = pendingVideoFormat.format.buildUpon().setWidth(videoSize.width).setHeight(videoSize.height).build();
        this.pendingVideoFormat = new PendingFormatUpdate(formatWithHeightAndWidth, pendingVideoFormat.selectionReason, pendingVideoFormat.sessionId);
    }
}
Also used : Format(androidx.media3.common.Format) Nullable(androidx.annotation.Nullable)

Aggregations

EventTime (androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime)103 Test (org.junit.Test)41 Timeline (androidx.media3.common.Timeline)39 FakeTimeline (androidx.media3.test.utils.FakeTimeline)38 MediaPeriodId (androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)34 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)26 TimelineWindowDefinition (androidx.media3.test.utils.FakeTimeline.TimelineWindowDefinition)14 Nullable (androidx.annotation.Nullable)9 AdPlaybackState (androidx.media3.common.AdPlaybackState)6 TestExoPlayerBuilder (androidx.media3.test.utils.TestExoPlayerBuilder)6 FakeMediaSource (androidx.media3.test.utils.FakeMediaSource)5 PlaybackException (androidx.media3.common.PlaybackException)4 InOrder (org.mockito.InOrder)4 MediaItem (androidx.media3.common.MediaItem)3 PlaybackParameters (androidx.media3.common.PlaybackParameters)3 Player (androidx.media3.common.Player)3 ActionSchedule (androidx.media3.test.utils.ActionSchedule)3 ExoPlayerTestRunner (androidx.media3.test.utils.ExoPlayerTestRunner)3 IOException (java.io.IOException)3 Format (androidx.media3.common.Format)2