use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.
the class ExoPlayerTest method testReadAheadToEndDoesNotResetRenderer.
/**
* Tests that the player does not unnecessarily reset renderers when playing a multi-period
* source.
*/
public void testReadAheadToEndDoesNotResetRenderer() throws Exception {
final PlayerWrapper playerWrapper = new PlayerWrapper();
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(false, false, 10), new TimelineWindowDefinition(false, false, 10), new TimelineWindowDefinition(false, false, 10));
MediaSource mediaSource = new FakeMediaSource(timeline, null, TEST_VIDEO_FORMAT, TEST_AUDIO_FORMAT);
FakeRenderer videoRenderer = new FakeRenderer(TEST_VIDEO_FORMAT);
FakeMediaClockRenderer audioRenderer = new FakeMediaClockRenderer(TEST_AUDIO_FORMAT) {
@Override
public long getPositionUs() {
// TODO: Avoid hard-coding ExoPlayerImplInternal.RENDERER_TIMESTAMP_OFFSET_US.
return isCurrentStreamFinal() ? 60000030 : 60000000;
}
@Override
public boolean isEnded() {
// Allow playback to end once the final period is playing.
return playerWrapper.positionDiscontinuityCount == 2;
}
};
playerWrapper.setup(mediaSource, videoRenderer, audioRenderer);
playerWrapper.blockUntilEnded(TIMEOUT_MS);
assertEquals(2, playerWrapper.positionDiscontinuityCount);
assertEquals(1, audioRenderer.positionResetCount);
assertTrue(videoRenderer.isEnded);
assertTrue(audioRenderer.isEnded);
assertEquals(timeline, playerWrapper.timeline);
assertNull(playerWrapper.manifest);
}
use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.
the class DefaultMediaClockTest method rendererClockSetPlaybackSpeed_shouldNotTriggerCallback.
@Test
public void rendererClockSetPlaybackSpeed_shouldNotTriggerCallback() throws ExoPlaybackException {
FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(PlaybackParameters.DEFAULT, /* playbackParametersAreMutable= */
true);
mediaClock.onRendererEnabled(mediaClockRenderer);
mediaClock.syncAndGetPositionUs(/* isReadingAhead= */
false);
mediaClock.setPlaybackParameters(TEST_PLAYBACK_PARAMETERS);
verifyNoMoreInteractions(listener);
}
use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.
the class DefaultMediaClockTest method enableRendererMediaClockWithFixedPlaybackSpeed_shouldTriggerCallback.
@Test
public void enableRendererMediaClockWithFixedPlaybackSpeed_shouldTriggerCallback() throws ExoPlaybackException {
FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(TEST_PLAYBACK_PARAMETERS, /* playbackParametersAreMutable= */
false);
mediaClock.onRendererEnabled(mediaClockRenderer);
mediaClock.syncAndGetPositionUs(/* isReadingAhead= */
false);
verify(listener).onPlaybackParametersChanged(TEST_PLAYBACK_PARAMETERS);
}
use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.
the class DefaultMediaClockTest method enableRendererMediaClockWithFixedPlaybackSpeed_usesRendererPlaybackSpeed.
@Test
public void enableRendererMediaClockWithFixedPlaybackSpeed_usesRendererPlaybackSpeed() throws ExoPlaybackException {
FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(TEST_PLAYBACK_PARAMETERS, /* playbackParametersAreMutable= */
false);
mediaClock.onRendererEnabled(mediaClockRenderer);
assertThat(mediaClock.getPlaybackParameters()).isEqualTo(TEST_PLAYBACK_PARAMETERS);
}
use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.
the class DefaultMediaClockTest method enableRendererMediaClock_shouldOverwriteRendererPlaybackParametersIfPossible.
@Test
public void enableRendererMediaClock_shouldOverwriteRendererPlaybackParametersIfPossible() throws ExoPlaybackException {
FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(TEST_PLAYBACK_PARAMETERS, /* playbackParametersAreMutable= */
true);
mediaClock.onRendererEnabled(mediaClockRenderer);
assertThat(mediaClock.getPlaybackParameters()).isEqualTo(PlaybackParameters.DEFAULT);
verifyNoMoreInteractions(listener);
}
Aggregations