Search in sources :

Example 1 with AnalyticsCollector

use of androidx.media3.exoplayer.analytics.AnalyticsCollector in project media by androidx.

the class MediaPeriodQueueTest method setUp.

@Before
public void setUp() {
    AnalyticsCollector analyticsCollector = new DefaultAnalyticsCollector(Clock.DEFAULT);
    analyticsCollector.setPlayer(new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build(), Looper.getMainLooper());
    mediaPeriodQueue = new MediaPeriodQueue(analyticsCollector, new Handler(Looper.getMainLooper()));
    mediaSourceList = new MediaSourceList(mock(MediaSourceList.MediaSourceListInfoRefreshListener.class), analyticsCollector, new Handler(Looper.getMainLooper()), PlayerId.UNSET);
    rendererCapabilities = new RendererCapabilities[0];
    trackSelector = mock(TrackSelector.class);
    allocator = mock(Allocator.class);
}
Also used : Allocator(androidx.media3.exoplayer.upstream.Allocator) DefaultAnalyticsCollector(androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector) AnalyticsCollector(androidx.media3.exoplayer.analytics.AnalyticsCollector) TrackSelector(androidx.media3.exoplayer.trackselection.TrackSelector) Handler(android.os.Handler) DefaultAnalyticsCollector(androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector) Before(org.junit.Before)

Example 2 with AnalyticsCollector

use of androidx.media3.exoplayer.analytics.AnalyticsCollector in project media by androidx.

the class MediaSourceListTest method setUp.

@Before
public void setUp() {
    AnalyticsCollector analyticsCollector = new DefaultAnalyticsCollector(Clock.DEFAULT);
    analyticsCollector.setPlayer(new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build(), Looper.getMainLooper());
    mediaSourceList = new MediaSourceList(mock(MediaSourceList.MediaSourceListInfoRefreshListener.class), analyticsCollector, Util.createHandlerForCurrentOrMainLooper(), PlayerId.UNSET);
}
Also used : DefaultAnalyticsCollector(androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector) AnalyticsCollector(androidx.media3.exoplayer.analytics.AnalyticsCollector) DefaultAnalyticsCollector(androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector) Before(org.junit.Before)

Example 3 with AnalyticsCollector

use of androidx.media3.exoplayer.analytics.AnalyticsCollector in project media by androidx.

the class DefaultAnalyticsCollectorTest method recursiveListenerInvocation_arrivesInCorrectOrder.

@Test
public void recursiveListenerInvocation_arrivesInCorrectOrder() {
    AnalyticsCollector analyticsCollector = new DefaultAnalyticsCollector(Clock.DEFAULT);
    analyticsCollector.setPlayer(new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build(), Looper.myLooper());
    AnalyticsListener listener1 = mock(AnalyticsListener.class);
    AnalyticsListener listener2 = spy(new AnalyticsListener() {

        @Override
        public void onPlayerError(EventTime eventTime, PlaybackException error) {
            analyticsCollector.onSurfaceSizeChanged(/* width= */
            0, /* height= */
            0);
        }
    });
    AnalyticsListener listener3 = mock(AnalyticsListener.class);
    analyticsCollector.addListener(listener1);
    analyticsCollector.addListener(listener2);
    analyticsCollector.addListener(listener3);
    analyticsCollector.onPlayerError(ExoPlaybackException.createForSource(new IOException(), PlaybackException.ERROR_CODE_IO_UNSPECIFIED));
    InOrder inOrder = inOrder(listener1, listener2, listener3);
    inOrder.verify(listener1).onPlayerError(any(), any());
    inOrder.verify(listener2).onPlayerError(any(), any());
    inOrder.verify(listener3).onPlayerError(any(), any());
    inOrder.verify(listener1).onSurfaceSizeChanged(any(), eq(0), eq(0));
    inOrder.verify(listener2).onSurfaceSizeChanged(any(), eq(0), eq(0));
    inOrder.verify(listener3).onSurfaceSizeChanged(any(), eq(0), eq(0));
}
Also used : ExoPlaybackException(androidx.media3.exoplayer.ExoPlaybackException) PlaybackException(androidx.media3.common.PlaybackException) InOrder(org.mockito.InOrder) TestExoPlayerBuilder(androidx.media3.test.utils.TestExoPlayerBuilder) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

AnalyticsCollector (androidx.media3.exoplayer.analytics.AnalyticsCollector)2 DefaultAnalyticsCollector (androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector)2 Before (org.junit.Before)2 Handler (android.os.Handler)1 PlaybackException (androidx.media3.common.PlaybackException)1 ExoPlaybackException (androidx.media3.exoplayer.ExoPlaybackException)1 TrackSelector (androidx.media3.exoplayer.trackselection.TrackSelector)1 Allocator (androidx.media3.exoplayer.upstream.Allocator)1 TestExoPlayerBuilder (androidx.media3.test.utils.TestExoPlayerBuilder)1 IOException (java.io.IOException)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1