use of androidx.media3.common.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM in project media by androidx.
the class ExoPlayerTest method removeMediaItem_current_notifiesAvailableCommandsChanged.
@Test
public void removeMediaItem_current_notifiesAvailableCommandsChanged() {
Player.Commands defaultCommands = createWithDefaultCommands();
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);
player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()));
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
player.removeMediaItem(/* index= */
0);
verify(mockListener).onAvailableCommandsChanged(defaultCommands);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
}
use of androidx.media3.common.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM in project media by androidx.
the class ExoPlayerTest method seekTo_nextWindow_notifiesAvailableCommandsChanged.
@Test
public void seekTo_nextWindow_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.Commands commandsWithSeekToPreviousAndNextWindow = createWithDefaultCommands(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, 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);
player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource(), new FakeMediaSource(), new FakeMediaSource()));
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
player.seekTo(/* mediaItemIndex= */
1, /* positionMs= */
0);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousAndNextWindow);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
player.seekTo(/* mediaItemIndex= */
2, /* positionMs= */
0);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
player.seekTo(/* mediaItemIndex= */
3, /* positionMs= */
0);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousWindow);
verify(mockListener, times(3)).onAvailableCommandsChanged(any());
}
use of androidx.media3.common.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM in project media by androidx.
the class CastPlayerTest method addMediaItem_atTheEnd_notifiesAvailableCommandsChanged.
@Test
public void addMediaItem_atTheEnd_notifiesAvailableCommandsChanged() {
Player.Commands defaultCommands = createWithDefaultCommands();
Player.Commands commandsWithSeekToNextWindow = createWithDefaultCommands(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT);
MediaItem mediaItem1 = createMediaItem(/* mediaQueueItemId= */
1);
MediaItem mediaItem2 = createMediaItem(/* mediaQueueItemId= */
2);
MediaItem mediaItem3 = createMediaItem(/* mediaQueueItemId= */
3);
castPlayer.addMediaItem(mediaItem1);
updateTimeLine(ImmutableList.of(mediaItem1), /* mediaQueueItemIds= */
new int[] { 1 }, /* currentItemId= */
1);
verify(mockListener).onAvailableCommandsChanged(defaultCommands);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
castPlayer.addMediaItem(mediaItem2);
updateTimeLine(ImmutableList.of(mediaItem1, mediaItem2), /* mediaQueueItemIds= */
new int[] { 1, 2 }, /* currentItemId= */
1);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
castPlayer.addMediaItem(mediaItem3);
updateTimeLine(ImmutableList.of(mediaItem1, mediaItem2, mediaItem3), /* mediaQueueItemIds= */
new int[] { 1, 2, 3 }, /* currentItemId= */
1);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
}
use of androidx.media3.common.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM in project media by androidx.
the class ExoPlayerTest method seekTo_previousWindow_notifiesAvailableCommandsChanged.
@Test
public void seekTo_previousWindow_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.Commands commandsWithSeekToPreviousAndNextWindow = createWithDefaultCommands(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, 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);
player.seekTo(/* mediaItemIndex= */
3, /* positionMs= */
0);
player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource(), new FakeMediaSource(), new FakeMediaSource()));
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousWindow);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
player.seekTo(/* mediaItemIndex= */
2, /* positionMs= */
0);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToPreviousAndNextWindow);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
player.seekTo(/* mediaItemIndex= */
1, /* positionMs= */
0);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
player.seekTo(/* mediaItemIndex= */
0, /* positionMs= */
0);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
verify(mockListener, times(3)).onAvailableCommandsChanged(any());
}
use of androidx.media3.common.Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM 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());
}
Aggregations