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);
}
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");
}
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");
}
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);
}
Aggregations