Search in sources :

Example 6 with PlaybackOutput

use of com.google.android.exoplayer2.robolectric.PlaybackOutput in project ExoPlayer by google.

the class PlaylistPlaybackTest method test_bypassOffThenOn.

@Test
public void test_bypassOffThenOn() 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.addMediaItem(MediaItem.fromUri("asset:///media/mka/bear-opus.mka"));
    player.addMediaItem(MediaItem.fromUri("asset:///media/wav/sample.wav"));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/playlists/bypass-off-then-on.dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) 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 7 with PlaybackOutput

use of com.google.android.exoplayer2.robolectric.PlaybackOutput in project ExoPlayer by google.

the class WavPlaybackTest method test.

@Test
public void test() 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.setMediaItem(MediaItem.fromUri("asset:///media/wav/" + inputFile));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(ApplicationProvider.getApplicationContext(), playbackOutput, "playbackdumps/wav/" + inputFile + ".dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) 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 8 with PlaybackOutput

use of com.google.android.exoplayer2.robolectric.PlaybackOutput in project ExoPlayer by google.

the class WebvttPlaybackTest method test.

@Test
public void test() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
    MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(applicationContext).experimentalUseProgressiveMediaSourceForSubtitles(true);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).setMediaSourceFactory(mediaSourceFactory).build();
    player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */
    1)));
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
    MediaItem mediaItem = new MediaItem.Builder().setUri("asset:///media/mp4/preroll-5s.mp4").setSubtitleConfigurations(ImmutableList.of(new MediaItem.SubtitleConfiguration.Builder(Uri.parse("asset:///media/webvtt/" + inputFile)).setMimeType(MimeTypes.TEXT_VTT).setLanguage("en").setSelectionFlags(C.SELECTION_FLAG_DEFAULT).build())).build();
    player.setMediaItem(mediaItem);
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/webvtt/" + inputFile + ".dump");
}
Also used : Context(android.content.Context) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Surface(android.view.Surface) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) SurfaceTexture(android.graphics.SurfaceTexture) 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 9 with PlaybackOutput

use of com.google.android.exoplayer2.robolectric.PlaybackOutput 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 10 with PlaybackOutput

use of com.google.android.exoplayer2.robolectric.PlaybackOutput in project ExoPlayer by google.

the class Vp9PlaybackTest method test.

@Test
public void test() throws Exception {
    Context applicationContext = ApplicationProvider.getApplicationContext();
    CapturingRenderersFactory capturingRenderersFactory = new CapturingRenderersFactory(applicationContext);
    ExoPlayer player = new ExoPlayer.Builder(applicationContext, capturingRenderersFactory).setClock(new FakeClock(/* isAutoAdvancing= */
    true)).build();
    player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */
    1)));
    PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
    player.setMediaItem(MediaItem.fromUri("asset:///media/vp9/" + inputFile));
    player.prepare();
    player.play();
    TestPlayerRunHelper.runUntilPlaybackState(player, Player.STATE_ENDED);
    player.release();
    DumpFileAsserts.assertOutput(applicationContext, playbackOutput, "playbackdumps/vp9/" + inputFile + ".dump");
}
Also used : Context(android.content.Context) PlaybackOutput(com.google.android.exoplayer2.robolectric.PlaybackOutput) SurfaceTexture(android.graphics.SurfaceTexture) CapturingRenderersFactory(com.google.android.exoplayer2.testutil.CapturingRenderersFactory) FakeClock(com.google.android.exoplayer2.testutil.FakeClock) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Surface(android.view.Surface) Test(org.junit.Test)

Aggregations

ExoPlayer (com.google.android.exoplayer2.ExoPlayer)21 PlaybackOutput (com.google.android.exoplayer2.robolectric.PlaybackOutput)21 Test (org.junit.Test)21 Context (android.content.Context)20 CapturingRenderersFactory (com.google.android.exoplayer2.testutil.CapturingRenderersFactory)20 FakeClock (com.google.android.exoplayer2.testutil.FakeClock)20 SurfaceTexture (android.graphics.SurfaceTexture)11 Surface (android.view.Surface)11 MediaItem (com.google.android.exoplayer2.MediaItem)4 DefaultMediaSourceFactory (com.google.android.exoplayer2.source.DefaultMediaSourceFactory)4 Pair (android.util.Pair)3 ApplicationProvider (androidx.test.core.app.ApplicationProvider)3 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)3 Player (com.google.android.exoplayer2.Player)3 Timeline (com.google.android.exoplayer2.Timeline)3 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)3 PlayerId (com.google.android.exoplayer2.analytics.PlayerId)3 RobolectricUtil.runMainLooperUntil (com.google.android.exoplayer2.robolectric.RobolectricUtil.runMainLooperUntil)3 ShadowMediaCodecConfig (com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig)3 TestPlayerRunHelper.playUntilPosition (com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilPosition)3