use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withTag_tagInSource.
@Test
public void createMediaSource_withTag_tagInSource() {
Object tag = new Object();
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setMimeType(MimeTypes.APPLICATION_SS).setTag(tag).build();
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource.getMediaItem().localConfiguration.tag).isEqualTo(tag);
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withIsmPath_smoothstreamingSource.
@Test
public void createMediaSource_withIsmPath_smoothstreamingSource() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA + "/file.ism").build();
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource).isInstanceOf(SsMediaSource.class);
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withMimeType_smoothstreamingSource.
@Test
public void createMediaSource_withMimeType_smoothstreamingSource() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA).setMimeType(MimeTypes.APPLICATION_SS).build();
MediaSource mediaSource = defaultMediaSourceFactory.createMediaSource(mediaItem);
assertThat(mediaSource).isInstanceOf(SsMediaSource.class);
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class PlayerTestRule method before.
@Override
protected void before() {
context = ApplicationProvider.getApplicationContext();
executor = Executors.newFixedThreadPool(1);
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
// Initialize AudioManager on the main thread to workaround that
// audio focus listener is called on the thread where the AudioManager was
// originally initialized. [Internal: b/78617702]
// Without posting this, audio focus listeners wouldn't be called because the
// listeners would be posted to the test thread (here) where it waits until the
// tests are finished.
context.getSystemService(Context.AUDIO_SERVICE);
DataSource.Factory dataSourceFactory = new InstrumentingDataSourceFactory(context);
exoPlayer = new ExoPlayer.Builder(context).setLooper(Looper.myLooper()).setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory)).build();
sessionPlayerConnector = new SessionPlayerConnector(exoPlayer);
});
}
use of com.google.android.exoplayer2.source.DefaultMediaSourceFactory in project ExoPlayer by google.
the class PlayerActivity method createMediaSourceFactory.
private MediaSource.Factory createMediaSourceFactory() {
ImaServerSideAdInsertionMediaSource.AdsLoader.Builder serverSideAdLoaderBuilder = new ImaServerSideAdInsertionMediaSource.AdsLoader.Builder(/* context= */
this, playerView);
if (serverSideAdsLoaderState != null) {
serverSideAdLoaderBuilder.setAdsLoaderState(serverSideAdsLoaderState);
}
serverSideAdsLoader = serverSideAdLoaderBuilder.build();
ImaServerSideAdInsertionMediaSource.Factory imaServerSideAdInsertionMediaSourceFactory = new ImaServerSideAdInsertionMediaSource.Factory(serverSideAdsLoader, new DefaultMediaSourceFactory(dataSourceFactory));
return new DefaultMediaSourceFactory(dataSourceFactory).setAdsLoaderProvider(this::getClientSideAdsLoader).setAdViewProvider(playerView).setServerSideAdInsertionMediaSourceFactory(imaServerSideAdInsertionMediaSourceFactory);
}
Aggregations