use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class ExoPlayerTest method restartAfterEmptyTimelineWithShuffleModeEnabledUsesCorrectFirstPeriod.
@Test
public void restartAfterEmptyTimelineWithShuffleModeEnabledUsesCorrectFirstPeriod() throws Exception {
ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, new FakeShuffleOrder(0));
AtomicInteger mediaItemIndexAfterAddingSources = new AtomicInteger();
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).setShuffleModeEnabled(true).waitForPlaybackState(Player.STATE_ENDED).executeRunnable(() -> concatenatingMediaSource.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()))).waitForTimelineChanged().executeRunnable(new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
mediaItemIndexAfterAddingSources.set(player.getCurrentMediaItemIndex());
}
}).build();
new ExoPlayerTestRunner.Builder(context).setMediaSources(concatenatingMediaSource).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
assertThat(mediaItemIndexAfterAddingSources.get()).isEqualTo(1);
}
use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class ExoPlayerTest method resetMediaSourcesWithPositionResetAndShufflingUsesFirstPeriod.
@Test
public void resetMediaSourcesWithPositionResetAndShufflingUsesFirstPeriod() throws Exception {
Timeline fakeTimeline = new FakeTimeline(new TimelineWindowDefinition(/* isSeekable= */
true, /* isDynamic= */
false, /* durationUs= */
100000));
ConcatenatingMediaSource firstMediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, new FakeShuffleOrder(/* length= */
2), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT));
ConcatenatingMediaSource secondMediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, new FakeShuffleOrder(/* length= */
2), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT));
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).setShuffleModeEnabled(true).setMediaSources(/* resetPosition= */
true, secondMediaSource).play().waitForPositionDiscontinuity().build();
ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder(context).setMediaSources(firstMediaSource).setActionSchedule(actionSchedule).build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
testRunner.assertPlayedPeriodIndices(0, 1, 0);
}
use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class MediaSourceListTest method addMediaSources_expectTimelineUsesCustomShuffleOrder.
@Test
public void addMediaSources_expectTimelineUsesCustomShuffleOrder() {
Timeline timeline = mediaSourceList.addMediaSources(/* index= */
0, createFakeHolders(), new FakeShuffleOrder(MEDIA_SOURCE_LIST_SIZE));
assertTimelineUsesFakeShuffleOrder(timeline);
}
use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class MediaSourceListTest method moveMediaSources_expectTimelineUsesCustomShuffleOrder.
@Test
public void moveMediaSources_expectTimelineUsesCustomShuffleOrder() {
ShuffleOrder shuffleOrder = new ShuffleOrder.DefaultShuffleOrder(/* length= */
MEDIA_SOURCE_LIST_SIZE);
mediaSourceList.addMediaSources(/* index= */
0, createFakeHolders(), shuffleOrder);
Timeline timeline = mediaSourceList.moveMediaSource(/* currentIndex= */
0, /* newIndex= */
1, new FakeShuffleOrder(MEDIA_SOURCE_LIST_SIZE));
assertTimelineUsesFakeShuffleOrder(timeline);
}
use of com.google.android.exoplayer2.testutil.FakeShuffleOrder in project ExoPlayer by google.
the class MediaSourceListTest method moveMediaSourceRange_expectTimelineUsesCustomShuffleOrder.
@Test
public void moveMediaSourceRange_expectTimelineUsesCustomShuffleOrder() {
ShuffleOrder shuffleOrder = new ShuffleOrder.DefaultShuffleOrder(/* length= */
MEDIA_SOURCE_LIST_SIZE);
mediaSourceList.addMediaSources(/* index= */
0, createFakeHolders(), shuffleOrder);
Timeline timeline = mediaSourceList.moveMediaSourceRange(/* fromIndex= */
0, /* toIndex= */
2, /* newFromIndex= */
2, new FakeShuffleOrder(MEDIA_SOURCE_LIST_SIZE));
assertTimelineUsesFakeShuffleOrder(timeline);
}
Aggregations