use of androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.
the class ConcatenatingMediaSourceTest method setUp.
@Before
public void setUp() throws Exception {
mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, new FakeShuffleOrder(0));
testRunner = new MediaSourceTestRunner(mediaSource, null);
}
use of androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.
the class ExoPlayerTest method sendMessagesNonLinearPeriodOrder.
@Test
public void sendMessagesNonLinearPeriodOrder() throws Exception {
Timeline fakeTimeline = new FakeTimeline();
MediaSource[] fakeMediaSources = { new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(fakeTimeline, ExoPlayerTestRunner.VIDEO_FORMAT) };
ConcatenatingMediaSource mediaSource = new ConcatenatingMediaSource(false, new FakeShuffleOrder(3), fakeMediaSources);
PositionGrabbingMessageTarget target1 = new PositionGrabbingMessageTarget();
PositionGrabbingMessageTarget target2 = new PositionGrabbingMessageTarget();
PositionGrabbingMessageTarget target3 = new PositionGrabbingMessageTarget();
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).sendMessage(target1, /* mediaItemIndex = */
0, /* positionMs= */
50).sendMessage(target2, /* mediaItemIndex = */
1, /* positionMs= */
50).sendMessage(target3, /* mediaItemIndex = */
2, /* positionMs= */
50).setShuffleModeEnabled(true).seek(/* mediaItemIndex= */
2, /* positionMs= */
0).play().build();
new ExoPlayerTestRunner.Builder(context).setMediaSources(mediaSource).setActionSchedule(actionSchedule).build().start().blockUntilEnded(TIMEOUT_MS);
assertThat(target1.mediaItemIndex).isEqualTo(0);
assertThat(target2.mediaItemIndex).isEqualTo(1);
assertThat(target3.mediaItemIndex).isEqualTo(2);
}
use of androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.
the class ExoPlayerTest method setShuffleModeEnabled_notifiesAvailableCommandsChanged.
@Test
public void setShuffleModeEnabled_notifiesAvailableCommandsChanged() {
Player.Commands commandsWithSeekToPreviousWindow = createWithDefaultCommands(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
Player.Commands commandsWithSeekToNextWindow = createWithDefaultCommands(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT);
Player.Listener mockListener = mock(Player.Listener.class);
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addListener(mockListener);
MediaSource mediaSource = new ConcatenatingMediaSource(false, new FakeShuffleOrder(/* length= */
2), new FakeMediaSource(), new FakeMediaSource());
player.addMediaSource(mediaSource);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
player.setShuffleModeEnabled(true);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousWindow);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
}
use of androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.
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 androidx.media3.test.utils.FakeShuffleOrder in project media by androidx.
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);
}
Aggregations