Search in sources :

Example 36 with DefaultMediaSourceFactory

use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_withSubtitle_isMergingMediaSource.

@Test
public void createMediaSource_withSubtitle_isMergingMediaSource() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    List<MediaItem.SubtitleConfiguration> subtitleConfigurations = Arrays.asList(new MediaItem.SubtitleConfiguration.Builder(Uri.parse(URI_TEXT)).setMimeType(MimeTypes.APPLICATION_TTML).setLanguage("en").build(), new MediaItem.SubtitleConfiguration.Builder(Uri.parse(URI_TEXT)).setMimeType(MimeTypes.APPLICATION_TTML).setLanguage("de").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setSubtitleConfigurations(subtitleConfigurations).build();
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    assertThat(mediaSource).isInstanceOf(MergingMediaSource.class);
}
Also used : AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 37 with DefaultMediaSourceFactory

use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_undefinedLiveProperties_livePropertiesUnset.

@Test
public void createMediaSource_undefinedLiveProperties_livePropertiesUnset() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA + "/file.mp4").build();
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    MediaItem mediaItemFromSource = mediaSource.getMediaItem();
    assertThat(mediaItemFromSource.liveConfiguration.targetOffsetMs).isEqualTo(C.TIME_UNSET);
    assertThat(mediaItemFromSource.liveConfiguration.minOffsetMs).isEqualTo(C.TIME_UNSET);
    assertThat(mediaItemFromSource.liveConfiguration.maxOffsetMs).isEqualTo(C.TIME_UNSET);
    assertThat(mediaItemFromSource.liveConfiguration.minPlaybackSpeed).isEqualTo(C.RATE_UNSET);
    assertThat(mediaItemFromSource.liveConfiguration.maxPlaybackSpeed).isEqualTo(C.RATE_UNSET);
}
Also used : AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 38 with DefaultMediaSourceFactory

use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory 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 + "/file.mpd").build();
    MediaSource mediaSource = defaultMediaSourceFactory.setDrmSessionManagerProvider(null).setLoadErrorHandlingPolicy(null).createMediaSource(mediaItem);
    assertThat(mediaSource).isNotNull();
}
Also used : MediaSource(com.google.android.exoplayer2.source.MediaSource) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 39 with DefaultMediaSourceFactory

use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_withMimeType_dashSource.

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

Example 40 with DefaultMediaSourceFactory

use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.

the class DefaultMediaSourceFactoryTest method createMediaSource_withPath_dashSource.

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

Aggregations

Test (org.junit.Test)47 DefaultMediaSourceFactory (com.google.android.exoplayer2.source.DefaultMediaSourceFactory)36 MediaItem (com.google.android.exoplayer2.MediaItem)33 AdsMediaSource (com.google.android.exoplayer2.source.ads.AdsMediaSource)27 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)16 Context (android.content.Context)15 MediaSource (com.google.android.exoplayer2.source.MediaSource)15 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)7 SurfaceTexture (android.graphics.SurfaceTexture)5 Surface (android.view.Surface)5 ApplicationProvider (androidx.test.core.app.ApplicationProvider)5 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)5 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)5 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)5 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)5 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)5 RunWith (org.junit.runner.RunWith)5 Pair (android.util.Pair)4 Player (com.google.android.exoplayer2.Player)4