Search in sources :

Example 36 with MediaSource

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

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

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

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

Example 40 with MediaSource

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

the class DefaultMediaSourceFactoryTest method createMediaSource_defaultToEnd_isNotClippingMediaSource.

@Test
public void createMediaSource_defaultToEnd_isNotClippingMediaSource() {
    DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
    MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setClippingConfiguration(new MediaItem.ClippingConfiguration.Builder().setEndPositionMs(C.TIME_END_OF_SOURCE).build()).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

Test (org.junit.Test)182 MediaSource (com.google.android.exoplayer2.source.MediaSource)117 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)117 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)74 MediaItem (com.google.android.exoplayer2.MediaItem)70 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)70 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)69 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)60 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)51 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)51 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)51 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)50 FakeAdaptiveMediaSource (com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource)50 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)45 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)39 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)39 Timeline (com.google.android.exoplayer2.Timeline)35 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)34 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)28 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)25