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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations