use of com.google.android.exoplayer2.PlaybackParameters in project ExoPlayer by google.
the class DefaultAudioSinkTest method handlesBufferAfterReset_withPlaybackSpeed.
@Test
public void handlesBufferAfterReset_withPlaybackSpeed() throws Exception {
defaultAudioSink.setPlaybackParameters(new PlaybackParameters(/* speed= */
1.5f));
configureDefaultAudioSink(CHANNEL_COUNT_STEREO);
defaultAudioSink.handleBuffer(createDefaultSilenceBuffer(), /* presentationTimeUs= */
0, /* encodedAccessUnitCount= */
1);
// After reset and re-configure we can successfully queue more input.
defaultAudioSink.reset();
configureDefaultAudioSink(CHANNEL_COUNT_STEREO);
defaultAudioSink.handleBuffer(createDefaultSilenceBuffer(), /* presentationTimeUs= */
0, /* encodedAccessUnitCount= */
1);
assertThat(defaultAudioSink.getPlaybackParameters()).isEqualTo(new PlaybackParameters(/* speed= */
1.5f));
}
use of com.google.android.exoplayer2.PlaybackParameters in project ExoPlayer by google.
the class ExoPlayerTest method setUnsupportedPlaybackSpeedConsecutivelyNotifiesListenerForEveryChangeOnceAndResetsOnceHandled.
@Test
public void setUnsupportedPlaybackSpeedConsecutivelyNotifiesListenerForEveryChangeOnceAndResetsOnceHandled() throws Exception {
Renderer renderer = new FakeMediaClockRenderer(C.TRACK_TYPE_AUDIO) {
@Override
public long getPositionUs() {
return 0;
}
@Override
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
}
@Override
public PlaybackParameters getPlaybackParameters() {
return PlaybackParameters.DEFAULT;
}
};
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).setPlaybackParameters(new PlaybackParameters(/* speed= */
1.1f)).setPlaybackParameters(new PlaybackParameters(/* speed= */
1.2f)).setPlaybackParameters(new PlaybackParameters(/* speed= */
1.3f)).play().build();
List<PlaybackParameters> reportedPlaybackParameters = new ArrayList<>();
Player.Listener listener = new Player.Listener() {
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
reportedPlaybackParameters.add(playbackParameters);
}
};
new ExoPlayerTestRunner.Builder(context).setSupportedFormats(ExoPlayerTestRunner.AUDIO_FORMAT).setRenderers(renderer).setActionSchedule(actionSchedule).setPlayerListener(listener).build().start().blockUntilEnded(TIMEOUT_MS);
assertThat(reportedPlaybackParameters).containsExactly(new PlaybackParameters(/* speed= */
1.1f), new PlaybackParameters(/* speed= */
1.2f), new PlaybackParameters(/* speed= */
1.3f), PlaybackParameters.DEFAULT).inOrder();
}
use of com.google.android.exoplayer2.PlaybackParameters in project ExoPlayer by google.
the class MediaPeriodQueueTest method setupTimeline.
private void setupTimeline(Timeline timeline) {
fakeMediaSource = new FakeMediaSource(timeline);
MediaSourceList.MediaSourceHolder mediaSourceHolder = new MediaSourceList.MediaSourceHolder(fakeMediaSource, /* useLazyPreparation= */
false);
mediaSourceList.setMediaSources(ImmutableList.of(mediaSourceHolder), new FakeShuffleOrder(/* length= */
1));
mediaSourceHolder.mediaSource.prepareSource(mock(MediaSourceCaller.class), /* mediaTransferListener */
null, PlayerId.UNSET);
Timeline playlistTimeline = mediaSourceList.createTimeline();
firstPeriodUid = playlistTimeline.getUidOfPeriod(/* periodIndex= */
0);
playbackInfo = new PlaybackInfo(playlistTimeline, mediaPeriodQueue.resolveMediaPeriodIdForAds(playlistTimeline, firstPeriodUid, /* positionUs= */
0), /* requestedContentPositionUs= */
C.TIME_UNSET, /* discontinuityStartPositionUs= */
0, Player.STATE_READY, /* playbackError= */
null, /* isLoading= */
false, /* trackGroups= */
null, /* trackSelectorResult= */
null, /* staticMetadata= */
ImmutableList.of(), /* loadingMediaPeriodId= */
null, /* playWhenReady= */
false, Player.PLAYBACK_SUPPRESSION_REASON_NONE, /* playbackParameters= */
PlaybackParameters.DEFAULT, /* bufferedPositionUs= */
0, /* totalBufferedDurationUs= */
0, /* positionUs= */
0, /* offloadSchedulingEnabled= */
false, /* sleepingForOffload= */
false);
}
use of com.google.android.exoplayer2.PlaybackParameters in project ExoPlayer by google.
the class ExoPlayerTest method setPlaybackSpeedConsecutivelyNotifiesListenerForEveryChangeOnceAndIsMasked.
@Test
public void setPlaybackSpeedConsecutivelyNotifiesListenerForEveryChangeOnceAndIsMasked() throws Exception {
List<Float> maskedPlaybackSpeeds = new ArrayList<>();
Action getPlaybackSpeedAction = new Action("getPlaybackSpeed", /* description= */
null) {
@Override
protected void doActionImpl(ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
maskedPlaybackSpeeds.add(player.getPlaybackParameters().speed);
}
};
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).setPlaybackParameters(new PlaybackParameters(/* speed= */
1.1f)).apply(getPlaybackSpeedAction).setPlaybackParameters(new PlaybackParameters(/* speed= */
1.2f)).apply(getPlaybackSpeedAction).setPlaybackParameters(new PlaybackParameters(/* speed= */
1.3f)).apply(getPlaybackSpeedAction).play().build();
List<Float> reportedPlaybackSpeeds = new ArrayList<>();
Player.Listener listener = new Player.Listener() {
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
reportedPlaybackSpeeds.add(playbackParameters.speed);
}
};
new ExoPlayerTestRunner.Builder(context).setActionSchedule(actionSchedule).setPlayerListener(listener).build().start().blockUntilEnded(TIMEOUT_MS);
assertThat(reportedPlaybackSpeeds).containsExactly(1.1f, 1.2f, 1.3f).inOrder();
assertThat(maskedPlaybackSpeeds).isEqualTo(reportedPlaybackSpeeds);
}
use of com.google.android.exoplayer2.PlaybackParameters in project ExoPlayer by google.
the class PlaybackStatsListenerTest method events_duringInitialIdleState_dontCreateNewPlaybackStats.
@Test
public void events_duringInitialIdleState_dontCreateNewPlaybackStats() throws Exception {
PlaybackStatsListener playbackStatsListener = new PlaybackStatsListener(/* keepHistory= */
true, /* callback= */
null);
player.addAnalyticsListener(playbackStatsListener);
player.seekTo(/* positionMs= */
1234);
runUntilPendingCommandsAreFullyHandled(player);
player.setPlaybackParameters(new PlaybackParameters(/* speed= */
2f));
runUntilPendingCommandsAreFullyHandled(player);
player.play();
runUntilPendingCommandsAreFullyHandled(player);
assertThat(playbackStatsListener.getPlaybackStats()).isNull();
}
Aggregations