Search in sources :

Example 1 with SilenceMediaSource

use of com.google.android.exoplayer2.source.SilenceMediaSource in project ExoPlayer by google.

the class SilenceMediaSourceTest method newInstance_setsMediaItem.

@Test
public void newInstance_setsMediaItem() {
    SilenceMediaSource mediaSource = new SilenceMediaSource(1_000_000);
    MediaItem mediaItem = mediaSource.getMediaItem();
    assertThat(mediaItem).isNotNull();
    assertThat(mediaItem.mediaId).isEqualTo(SilenceMediaSource.MEDIA_ID);
    assertThat(mediaSource.getMediaItem().localConfiguration.uri).isEqualTo(Uri.EMPTY);
    assertThat(mediaItem.localConfiguration.mimeType).isEqualTo(MimeTypes.AUDIO_RAW);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 2 with SilenceMediaSource

use of com.google.android.exoplayer2.source.SilenceMediaSource in project ExoPlayer by google.

the class SilencePlaybackTest method test_0ms.

@Test
public void test_0ms() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).build();
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
    player.setMediaSource(new SilenceMediaSource(/* durationUs= */
    0));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/silence/0ms.dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) SilenceMediaSource(com.google.android.exoplayer2.source.SilenceMediaSource) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Test(org.junit.Test)

Example 3 with SilenceMediaSource

use of com.google.android.exoplayer2.source.SilenceMediaSource in project ExoPlayer by google.

the class SilencePlaybackTest method test_500ms.

@Test
public void test_500ms() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).build();
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
    player.setMediaSource(new SilenceMediaSource(/* durationUs= */
    500_000));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/silence/500ms.dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) SilenceMediaSource(com.google.android.exoplayer2.source.SilenceMediaSource) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Test(org.junit.Test)

Example 4 with SilenceMediaSource

use of com.google.android.exoplayer2.source.SilenceMediaSource in project ExoPlayer by google.

the class SilenceMediaSourceTest method builder_setsMediaItem.

@Test
public void builder_setsMediaItem() {
    SilenceMediaSource mediaSource = new SilenceMediaSource.Factory().setDurationUs(1_000_000).createMediaSource();
    MediaItem mediaItem = mediaSource.getMediaItem();
    assertThat(mediaItem).isNotNull();
    assertThat(mediaItem.mediaId).isEqualTo(SilenceMediaSource.MEDIA_ID);
    assertThat(mediaItem.localConfiguration.uri).isEqualTo(Uri.EMPTY);
    assertThat(mediaItem.localConfiguration.mimeType).isEqualTo(MimeTypes.AUDIO_RAW);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 Context (android.content.Context)2 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)2 MediaItem (com.google.android.exoplayer2.MediaItem)2 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)2 SilenceMediaSource (com.google.android.exoplayer2.source.SilenceMediaSource)2 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)2 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)2