Search in sources :

Example 11 with DefaultMediaSourceFactory

use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory 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 12 with DefaultMediaSourceFactory

use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory 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)

Example 13 with DefaultMediaSourceFactory

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

the class DefaultMediaSourceFactoryTest method createMediaSource_withAdsConfigurationProvidersNull_playsWithoutAdNoException.

@Test
public void createMediaSource_withAdsConfigurationProvidersNull_playsWithoutAdNoException() {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setAdsConfiguration(new MediaItem.AdsConfiguration.Builder(Uri.parse(URI_MEDIA)).build()).build();
    MediaSource mediaSource = new DefaultMediaSourceFactory(applicationContext).createMediaSource(mediaItem);
    assertThat(mediaSource).isNotInstanceOf(AdsMediaSource.class);
}
Also used : Context(android.content.Context) AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 14 with DefaultMediaSourceFactory

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

the class DefaultMediaSourceFactoryTest method createMediaSource_withMediaItemLiveProperties_overridesFactoryLiveProperties.

@Test
public void createMediaSource_withMediaItemLiveProperties_overridesFactoryLiveProperties() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()).setLiveTargetOffsetMs(20).setLiveMinOffsetMs(2222).setLiveMinOffsetMs(4444).setLiveMinSpeed(.1f).setLiveMaxSpeed(2.0f);
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA + "/file.mp4").setLiveConfiguration(new MediaItem.LiveConfiguration.Builder().setTargetOffsetMs(10).setMinOffsetMs(1111).setMinOffsetMs(3333).setMinPlaybackSpeed(20.0f).setMaxPlaybackSpeed(20.0f).build()).build();
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    MediaItem mediaItemFromSource = mediaSource.getMediaItem();
    assertThat(mediaItemFromSource).isEqualTo(mediaItem);
}
Also used : Context(android.content.Context) AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 15 with DefaultMediaSourceFactory

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

the class DefaultMediaSourceFactoryTest method createMediaSource_withAdsConfiguration_callsAdsLoader.

@Test
public void createMediaSource_withAdsConfiguration_callsAdsLoader() {
    Uri adTagUri = Uri.parse(URI_MEDIA);
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setAdsConfiguration(new MediaItem.AdsConfiguration.Builder(adTagUri).build()).build();
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()).setAdsLoaderProvider(ignoredAdsConfiguration -> mock(AdsLoader.class)).setAdViewProvider(mock(AdViewProvider.class));
    MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
    assertThat(mediaSource).isInstanceOf(AdsMediaSource.class);
}
Also used : Context(android.content.Context) Arrays(java.util.Arrays) MediaItem(com.google.android.exoplayer2.MediaItem) Uri(android.net.Uri) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) AdsLoader(com.google.android.exoplayer2.source.ads.AdsLoader) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) AdViewProvider(com.google.android.exoplayer2.ui.AdViewProvider) ApplicationProvider(androidx.test.core.app.ApplicationProvider) List(java.util.List) MimeTypes(com.google.android.exoplayer2.util.MimeTypes) AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) Mockito.mock(org.mockito.Mockito.mock) C(com.google.android.exoplayer2.C) AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) MediaItem(com.google.android.exoplayer2.MediaItem) AdViewProvider(com.google.android.exoplayer2.ui.AdViewProvider) Uri(android.net.Uri) 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