use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class MergingMediaSourceTest method prepareMergingMediaSource.
/**
* Wraps the specified timelines in a {@link MergingMediaSource}, prepares it and returns the
* merged timeline.
*/
private static Timeline prepareMergingMediaSource(boolean clipDurations, Timeline... timelines) throws IOException {
FakeMediaSource[] mediaSources = new FakeMediaSource[timelines.length];
for (int i = 0; i < timelines.length; i++) {
mediaSources[i] = new FakeMediaSource(timelines[i]);
}
MergingMediaSource mergingMediaSource = new MergingMediaSource(/* adjustPeriodTimeOffsets= */
false, clipDurations, mediaSources);
MediaSourceTestRunner testRunner = new MediaSourceTestRunner(mergingMediaSource, /* allocator= */
null);
try {
Timeline timeline = testRunner.prepareSource();
testRunner.releaseSource();
for (FakeMediaSource mediaSource : mediaSources) {
mediaSource.assertReleased();
}
return timeline;
} finally {
testRunner.release();
}
}
use of com.google.android.exoplayer2.source.MediaSource 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).build();
MediaSource mediaSource = defaultMediaSourceFactory.setDrmSessionManagerProvider(null).setLoadErrorHandlingPolicy(null).createMediaSource(mediaItem);
assertThat(mediaSource).isNotNull();
}
use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withStartPosition_isClippingMediaSource.
@Test
public void createMediaSource_withStartPosition_isClippingMediaSource() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setClippingConfiguration(new MediaItem.ClippingConfiguration.Builder().setStartPositionMs(1000L).build()).build();
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource).isInstanceOf(ClippingMediaSource.class);
}
use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_fromMediaItem_returnsSameMediaItemInstance.
@Test
public void createMediaSource_fromMediaItem_returnsSameMediaItemInstance() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).build();
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource.getMediaItem()).isSameInstanceAs(mediaItem);
}
use of com.google.android.exoplayer2.source.MediaSource 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);
}
Aggregations