Search in sources :

Example 41 with MediaItem

use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_withNull_usesNonNullDefaults.

@Test
public void createMediaSource_withNull_usesNonNullDefaults() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).build();
    MediaSource mediaSource = defaultMediaSourceFactory.setDrmSessionManagerProvider(null).setLoadErrorHandlingPolicy(null).createMediaSource(mediaItem);
    assertThat(mediaSource).isNotNull();
}
Also used : AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 42 with MediaItem

use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_withStartPosition_isClippingMediaSource.

@Test
public void createMediaSource_withStartPosition_isClippingMediaSource() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setClippingConfiguration(new MediaItem.ClippingConfiguration.Builder().setStartPositionMs(1000L).build()).build();
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    assertThat(mediaSource).isInstanceOf(ClippingMediaSource.class);
}
Also used : AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 43 with MediaItem

use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_fromMediaItem_returnsSameMediaItemInstance.

@Test
public void createMediaSource_fromMediaItem_returnsSameMediaItemInstance() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).build();
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    assertThat(mediaSource.getMediaItem()).isSameInstanceAs(mediaItem);
}
Also used : AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 44 with MediaItem

use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_withoutMimeType_progressiveSource.

@Test
public void createMediaSource_withoutMimeType_progressiveSource() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).build();
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    assertThat(mediaSource).isInstanceOf(ProgressiveMediaSource.class);
}
Also used : AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 45 with MediaItem

use of com.google.android.exoplayer2.MediaItem in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_withPath_progressiveSource.

@Test
public void createMediaSource_withPath_progressiveSource() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA + "/file.mp3").build();
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    assertThat(mediaSource).isInstanceOf(ProgressiveMediaSource.class);
}
Also used : AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Aggregations

MediaItem (com.google.android.exoplayer2.MediaItem)160 Test (org.junit.Test)151 MediaSource (com.google.android.exoplayer2.source.MediaSource)31 ArrayList (java.util.ArrayList)29 Timeline (com.google.android.exoplayer2.Timeline)25 InOrder (org.mockito.InOrder)20 Nullable (androidx.annotation.Nullable)19 AdsMediaSource (com.google.android.exoplayer2.source.ads.AdsMediaSource)19 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)19 Player (com.google.android.exoplayer2.Player)17 Uri (android.net.Uri)15 Listener (com.google.android.exoplayer2.Player.Listener)15 TestPlayerRunHelper.playUntilStartOfMediaItem (com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilStartOfMediaItem)15 DefaultMediaSourceFactory (com.google.android.exoplayer2.source.DefaultMediaSourceFactory)15 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)13 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)13 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 DrmSessionEventListener (com.google.android.exoplayer2.drm.DrmSessionEventListener)12 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)12