Search in sources :

Example 1 with DefaultAnalyticsCollector

use of com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector in project ExoPlayer by google.

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(com.google.android.exoplayer2.upstream.Allocator) DefaultAnalyticsCollector(com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector) AnalyticsCollector(com.google.android.exoplayer2.analytics.AnalyticsCollector) TrackSelector(com.google.android.exoplayer2.trackselection.TrackSelector) Handler(android.os.Handler) DefaultAnalyticsCollector(com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector) Before(org.junit.Before)

Example 2 with DefaultAnalyticsCollector

use of com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector in project ExoPlayer by google.

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(com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector) AnalyticsCollector(com.google.android.exoplayer2.analytics.AnalyticsCollector) DefaultAnalyticsCollector(com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector) Before(org.junit.Before)

Example 3 with DefaultAnalyticsCollector

use of com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector in project ExoPlayer by google.

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(com.google.android.exoplayer2.ExoPlaybackException) PlaybackException(com.google.android.exoplayer2.PlaybackException) InOrder(org.mockito.InOrder) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with DefaultAnalyticsCollector

use of com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector in project ExoPlayer by google.

the class TestExoPlayerBuilder method build.

/**
 * Builds an {@link ExoPlayer} using the provided values or their defaults.
 */
public ExoPlayer build() {
    Assertions.checkNotNull(looper, "TestExoPlayer builder run on a thread without Looper and no Looper specified.");
    // Do not update renderersFactory and renderers here, otherwise their getters may
    // return different values before and after build() is called, making them confusing.
    RenderersFactory playerRenderersFactory = renderersFactory;
    if (playerRenderersFactory == null) {
        playerRenderersFactory = (eventHandler, videoRendererEventListener, audioRendererEventListener, textRendererOutput, metadataRendererOutput) -> renderers != null ? renderers : new Renderer[] { new FakeVideoRenderer(eventHandler, videoRendererEventListener), new FakeAudioRenderer(eventHandler, audioRendererEventListener) };
    }
    ExoPlayer.Builder builder = new ExoPlayer.Builder(context, playerRenderersFactory).setTrackSelector(trackSelector).setLoadControl(loadControl).setBandwidthMeter(bandwidthMeter).setAnalyticsCollector(new DefaultAnalyticsCollector(clock)).setClock(clock).setUseLazyPreparation(useLazyPreparation).setLooper(looper).setSeekBackIncrementMs(seekBackIncrementMs).setSeekForwardIncrementMs(seekForwardIncrementMs);
    if (mediaSourceFactory != null) {
        builder.setMediaSourceFactory(mediaSourceFactory);
    }
    return builder.build();
}
Also used : Renderer(com.google.android.exoplayer2.Renderer) RenderersFactory(com.google.android.exoplayer2.RenderersFactory) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) DefaultAnalyticsCollector(com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector)

Aggregations

DefaultAnalyticsCollector (com.google.android.exoplayer2.analytics.DefaultAnalyticsCollector)3 AnalyticsCollector (com.google.android.exoplayer2.analytics.AnalyticsCollector)2 Before (org.junit.Before)2 Handler (android.os.Handler)1 ExoPlaybackException (com.google.android.exoplayer2.ExoPlaybackException)1 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)1 PlaybackException (com.google.android.exoplayer2.PlaybackException)1 Renderer (com.google.android.exoplayer2.Renderer)1 RenderersFactory (com.google.android.exoplayer2.RenderersFactory)1 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)1 TrackSelector (com.google.android.exoplayer2.trackselection.TrackSelector)1 Allocator (com.google.android.exoplayer2.upstream.Allocator)1 IOException (java.io.IOException)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1