Search in sources :

Example 41 with DefaultMediaSourceFactory

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);
}
Also used : MediaSource(com.google.android.exoplayer2.source.MediaSource) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 42 with DefaultMediaSourceFactory

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);
}
Also used : MediaSource(com.google.android.exoplayer2.source.MediaSource) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 43 with DefaultMediaSourceFactory

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);
}
Also used : MediaSource(com.google.android.exoplayer2.source.MediaSource) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 44 with DefaultMediaSourceFactory

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);
    });
}
Also used : DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) DataSource(com.google.android.exoplayer2.upstream.DataSource) DefaultDataSource(com.google.android.exoplayer2.upstream.DefaultDataSource)

Example 45 with DefaultMediaSourceFactory

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);
}
Also used : DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) ImaServerSideAdInsertionMediaSource(com.google.android.exoplayer2.ext.ima.ImaServerSideAdInsertionMediaSource) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) RenderersFactory(com.google.android.exoplayer2.RenderersFactory) ImaAdsLoader(com.google.android.exoplayer2.ext.ima.ImaAdsLoader) AdsLoader(com.google.android.exoplayer2.source.ads.AdsLoader)

Aggregations

Test (org.junit.Test)47 DefaultMediaSourceFactory (com.google.android.exoplayer2.source.DefaultMediaSourceFactory)36 MediaItem (com.google.android.exoplayer2.MediaItem)33 AdsMediaSource (com.google.android.exoplayer2.source.ads.AdsMediaSource)27 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)16 Context (android.content.Context)15 MediaSource (com.google.android.exoplayer2.source.MediaSource)15 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)7 SurfaceTexture (android.graphics.SurfaceTexture)5 Surface (android.view.Surface)5 ApplicationProvider (androidx.test.core.app.ApplicationProvider)5 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)5 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)5 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)5 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)5 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)5 RunWith (org.junit.runner.RunWith)5 Pair (android.util.Pair)4 Player (com.google.android.exoplayer2.Player)4