Search in sources :

Example 41 with Listener

use of com.google.android.exoplayer2.Player.Listener in project ExoPlayer by google.

the class DefaultAnalyticsCollector method onLoadStarted.

// MediaSourceEventListener implementation.
@Override
public final void onLoadStarted(int windowIndex, @Nullable MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
    EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
    sendEvent(eventTime, AnalyticsListener.EVENT_LOAD_STARTED, listener -> listener.onLoadStarted(eventTime, loadEventInfo, mediaLoadData));
}
Also used : EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Example 42 with Listener

use of com.google.android.exoplayer2.Player.Listener in project ExoPlayer by google.

the class DefaultAnalyticsCollector method onSeekForwardIncrementChanged.

@Override
public void onSeekForwardIncrementChanged(long seekForwardIncrementMs) {
    EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
    sendEvent(eventTime, AnalyticsListener.EVENT_SEEK_FORWARD_INCREMENT_CHANGED, listener -> listener.onSeekForwardIncrementChanged(eventTime, seekForwardIncrementMs));
}
Also used : EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Example 43 with Listener

use of com.google.android.exoplayer2.Player.Listener in project ExoPlayer by google.

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(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Example 44 with Listener

use of com.google.android.exoplayer2.Player.Listener in project ExoPlayer by google.

the class DefaultAnalyticsCollector method onAudioPositionAdvancing.

@Override
public final void onAudioPositionAdvancing(long playoutStartSystemTimeMs) {
    EventTime eventTime = generateReadingMediaPeriodEventTime();
    sendEvent(eventTime, AnalyticsListener.EVENT_AUDIO_POSITION_ADVANCING, listener -> listener.onAudioPositionAdvancing(eventTime, playoutStartSystemTimeMs));
}
Also used : EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)

Example 45 with Listener

use of com.google.android.exoplayer2.Player.Listener in project ExoPlayer by google.

the class CastPlayerTest method updateTimeLine.

private void updateTimeLine(List<MediaItem> mediaItems, int[] mediaQueueItemIds, int currentItemId, int[] streamTypes, long[] durationsMs, long positionMs) {
    // Set up mocks to allow the player to update the timeline.
    List<MediaQueueItem> queueItems = new ArrayList<>();
    for (int i = 0; i < mediaQueueItemIds.length; i++) {
        MediaItem mediaItem = mediaItems.get(i);
        int mediaQueueItemId = mediaQueueItemIds[i];
        int streamType = streamTypes[i];
        long durationMs = durationsMs[i];
        MediaInfo.Builder mediaInfoBuilder = new MediaInfo.Builder(mediaItem.localConfiguration.uri.toString()).setStreamType(streamType).setContentType(mediaItem.localConfiguration.mimeType);
        if (durationMs != C.TIME_UNSET) {
            mediaInfoBuilder.setStreamDuration(durationMs);
        }
        MediaInfo mediaInfo = mediaInfoBuilder.build();
        MediaQueueItem mediaQueueItem = mock(MediaQueueItem.class);
        when(mediaQueueItem.getItemId()).thenReturn(mediaQueueItemId);
        when(mediaQueueItem.getMedia()).thenReturn(mediaInfo);
        queueItems.add(mediaQueueItem);
        if (mediaQueueItemId == currentItemId) {
            when(mockRemoteMediaClient.getCurrentItem()).thenReturn(mediaQueueItem);
            when(mockMediaStatus.getMediaInfo()).thenReturn(mediaInfo);
        }
    }
    if (positionMs != C.TIME_UNSET) {
        when(mockRemoteMediaClient.getApproximateStreamPosition()).thenReturn(positionMs);
    }
    when(mockMediaQueue.getItemIds()).thenReturn(mediaQueueItemIds);
    when(mockMediaStatus.getQueueItems()).thenReturn(queueItems);
    when(mockMediaStatus.getCurrentItemId()).thenReturn(currentItemId == C.INDEX_UNSET ? 0 : currentItemId);
    // Call listener to update the timeline of the player.
    remoteMediaClientCallback.onStatusUpdated();
}
Also used : MediaInfo(com.google.android.gms.cast.MediaInfo) MediaItem(com.google.android.exoplayer2.MediaItem) ArrayList(java.util.ArrayList) MediaQueueItem(com.google.android.gms.cast.MediaQueueItem)

Aggregations

Test (org.junit.Test)87 EventTime (com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)68 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)58 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)54 Listener (com.google.android.exoplayer2.Player.Listener)45 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)38 MediaSource (com.google.android.exoplayer2.source.MediaSource)38 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)34 ArrayList (java.util.ArrayList)33 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)31 Nullable (androidx.annotation.Nullable)27 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)27 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)26 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)26 PositionInfo (com.google.android.exoplayer2.Player.PositionInfo)25 DrmSessionEventListener (com.google.android.exoplayer2.drm.DrmSessionEventListener)25 MediaSourceEventListener (com.google.android.exoplayer2.source.MediaSourceEventListener)25 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)24 InOrder (org.mockito.InOrder)22 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)21