use of com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT in project ExoPlayer by google.
the class CastPlayerTest 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);
MediaItem mediaItem1 = createMediaItem(/* mediaQueueItemId= */
1);
MediaItem mediaItem2 = createMediaItem(/* mediaQueueItemId= */
2);
castPlayer.addMediaItems(ImmutableList.of(mediaItem1, mediaItem2));
updateTimeLine(ImmutableList.of(mediaItem1, mediaItem2), /* mediaQueueItemIds= */
new int[] { 1, 2 }, /* currentItemId= */
1);
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
castPlayer.removeMediaItem(/* index= */
0);
updateTimeLine(ImmutableList.of(mediaItem2), /* mediaQueueItemIds= */
new int[] { 2 }, /* currentItemId= */
2);
verify(mockListener).onAvailableCommandsChanged(defaultCommands);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
}
use of com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT in project ExoPlayer by google.
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 com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT in project ExoPlayer by google.
the class StyledPlayerControlView method updateNavigation.
private void updateNavigation() {
if (!isVisible() || !isAttachedToWindow) {
return;
}
@Nullable Player player = this.player;
boolean enableSeeking = false;
boolean enablePrevious = false;
boolean enableRewind = false;
boolean enableFastForward = false;
boolean enableNext = false;
if (player != null) {
enableSeeking = player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM);
enablePrevious = player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS);
enableRewind = player.isCommandAvailable(COMMAND_SEEK_BACK);
enableFastForward = player.isCommandAvailable(COMMAND_SEEK_FORWARD);
enableNext = player.isCommandAvailable(COMMAND_SEEK_TO_NEXT);
}
if (enableRewind) {
updateRewindButton();
}
if (enableFastForward) {
updateFastForwardButton();
}
updateButton(enablePrevious, previousButton);
updateButton(enableRewind, rewindButton);
updateButton(enableFastForward, fastForwardButton);
updateButton(enableNext, nextButton);
if (timeBar != null) {
timeBar.setEnabled(enableSeeking);
}
}
use of com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT in project ExoPlayer by google.
the class ExoPlayerTest method addMediaSource_atTheEnd_notifiesAvailableCommandsChanged.
@Test
public void addMediaSource_atTheEnd_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.addMediaSource(new FakeMediaSource());
verify(mockListener).onAvailableCommandsChanged(defaultCommands);
// Check that there were no other calls to onAvailableCommandsChanged.
verify(mockListener).onAvailableCommandsChanged(any());
player.addMediaSource(new FakeMediaSource());
verify(mockListener).onAvailableCommandsChanged(commandsWithSeekToNextWindow);
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
player.addMediaSource(new FakeMediaSource());
verify(mockListener, times(2)).onAvailableCommandsChanged(any());
}
use of com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT in project ExoPlayer by google.
the class ExoPlayerTest method isCommandAvailable_duringLiveItem_isTrueForSeekToNext.
@Test
public void isCommandAvailable_duringLiveItem_isTrueForSeekToNext() throws Exception {
Timeline timelineWithLiveWindow = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
0, /* isSeekable= */
true, /* isDynamic= */
true, /* isLive= */
true, /* isPlaceholder= */
false, /* durationUs= */
C.TIME_UNSET, /* defaultPositionUs= */
10_000_000, TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US, AdPlaybackState.NONE));
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addMediaSource(new FakeMediaSource(timelineWithLiveWindow));
player.prepare();
runUntilPlaybackState(player, Player.STATE_READY);
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT)).isTrue();
}
Aggregations