use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class ImaAdsLoaderTest method resumePlaybackAfterMidroll_withoutPlayAdBeforeStartPosition_skipsMidroll.
@Test
public void resumePlaybackAfterMidroll_withoutPlayAdBeforeStartPosition_skipsMidroll() {
imaAdsLoader = new ImaAdsLoader.Builder(getApplicationContext()).setPlayAdBeforeStartPosition(false).setImaFactory(mockImaFactory).setImaSdkSettings(mockImaSdkSettings).build();
imaAdsLoader.setPlayer(fakePlayer);
adsMediaSource = new AdsMediaSource(new FakeMediaSource(CONTENT_TIMELINE), TEST_DATA_SPEC, TEST_ADS_ID, new DefaultMediaSourceFactory((Context) getApplicationContext()), imaAdsLoader, adViewProvider);
long midrollWindowTimeUs = 2 * C.MICROS_PER_SECOND;
long midrollPeriodTimeUs = midrollWindowTimeUs + TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US;
ImmutableList<Float> cuePoints = ImmutableList.of(0f, (float) midrollPeriodTimeUs / C.MICROS_PER_SECOND);
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
fakePlayer.setPlayingContentPosition(/* periodIndex= */
0, Util.usToMs(midrollWindowTimeUs) + 1_000);
imaAdsLoader.start(adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
verify(mockAdsManager).destroy();
assertThat(getAdPlaybackState(/* periodIndex= */
0)).isEqualTo(new AdPlaybackState(TEST_ADS_ID, getAdGroupTimesUsForCuePoints(cuePoints)).withContentDurationUs(CONTENT_PERIOD_DURATION_US).withSkippedAdGroup(/* adGroupIndex= */
0).withSkippedAdGroup(/* adGroupIndex= */
1));
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_relativeToDefaultPosition_isClippingMediaSource.
@Test
public void createMediaSource_relativeToDefaultPosition_isClippingMediaSource() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setClippingConfiguration(new MediaItem.ClippingConfiguration.Builder().setRelativeToDefaultPosition(true).build()).build();
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource).isInstanceOf(ClippingMediaSource.class);
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withoutMediaItemProperties_usesFactoryLiveProperties.
@Test
public void createMediaSource_withoutMediaItemProperties_usesFactoryLiveProperties() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()).setLiveTargetOffsetMs(20).setLiveMinOffsetMs(2222).setLiveMaxOffsetMs(4444).setLiveMinSpeed(.1f).setLiveMaxSpeed(2.0f);
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(20);
assertThat(mediaItemFromSource.liveConfiguration.minOffsetMs).isEqualTo(2222);
assertThat(mediaItemFromSource.liveConfiguration.maxOffsetMs).isEqualTo(4444);
assertThat(mediaItemFromSource.liveConfiguration.minPlaybackSpeed).isEqualTo(.1f);
assertThat(mediaItemFromSource.liveConfiguration.maxPlaybackSpeed).isEqualTo(2.0f);
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withEndPosition_isClippingMediaSource.
@Test
public void createMediaSource_withEndPosition_isClippingMediaSource() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setClippingConfiguration(new MediaItem.ClippingConfiguration.Builder().setEndPositionMs(1000L).build()).build();
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource).isInstanceOf(ClippingMediaSource.class);
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withAdsConfiguration_adProvidersNotSet_playsWithoutAdNoException.
@Test
public void createMediaSource_withAdsConfiguration_adProvidersNotSet_playsWithoutAdNoException() {
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setAdsConfiguration(new MediaItem.AdsConfiguration.Builder(Uri.parse(URI_MEDIA)).build()).build();
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource).isNotInstanceOf(AdsMediaSource.class);
}
Aggregations