use of com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM in project ExoPlayer by google.
the class ExoPlayerTest method isCommandAvailable_duringAd_isFalseForSeekCommands.
@Test
public void isCommandAvailable_duringAd_isFalseForSeekCommands() throws Exception {
AdPlaybackState adPlaybackState = new AdPlaybackState(/* adsId= */
new Object(), /* adGroupTimesUs...= */
0).withAdCount(/* adGroupIndex= */
0, /* adCount= */
1).withAdUri(/* adGroupIndex= */
0, /* adIndexInAdGroup= */
0, Uri.EMPTY).withAdDurationsUs(/* adDurationUs= */
new long[][] { { Util.msToUs(4_000) } });
Timeline adTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
0, /* isSeekable= */
true, /* isDynamic= */
false, /* durationUs= */
Util.msToUs(10_000), adPlaybackState));
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource(adTimeline), new FakeMediaSource()));
player.seekTo(/* mediaItemIndex= */
1, /* positionMs= */
0);
player.prepare();
runUntilPlaybackState(player, Player.STATE_READY);
assertThat(player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
}
use of com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM in project ExoPlayer by google.
the class CastPlayerTest method isCommandAvailable_duringUnseekableItem_isFalseForSeekInCurrentCommands.
@Test
public void isCommandAvailable_duringUnseekableItem_isFalseForSeekInCurrentCommands() {
MediaItem mediaItem = createMediaItem(/* mediaQueueItemId= */
1);
List<MediaItem> mediaItems = ImmutableList.of(mediaItem);
int[] mediaQueueItemIds = new int[] { 1 };
int[] streamTypes = new int[] { MediaInfo.STREAM_TYPE_LIVE };
long[] durationsMs = new long[] { C.TIME_UNSET };
castPlayer.addMediaItem(mediaItem);
updateTimeLine(mediaItems, mediaQueueItemIds, /* currentItemId= */
1, streamTypes, durationsMs, /* positionMs= */
C.TIME_UNSET);
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse();
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse();
assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
}
use of com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM 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_IN_CURRENT_MEDIA_ITEM in project ExoPlayer by google.
the class ExoPlayerTest method isCommandAvailable_isTrueForAvailableCommands.
@Test
public void isCommandAvailable_isTrueForAvailableCommands() {
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource()));
assertThat(player.isCommandAvailable(COMMAND_PLAY_PAUSE)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_PREPARE)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_STOP)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_DEFAULT_POSITION)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_PREVIOUS)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SEEK_BACK)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SEEK_FORWARD)).isFalse();
assertThat(player.isCommandAvailable(COMMAND_SET_SPEED_AND_PITCH)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_SHUFFLE_MODE)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_REPEAT_MODE)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_CURRENT_MEDIA_ITEM)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_TIMELINE)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_MEDIA_ITEMS_METADATA)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_MEDIA_ITEMS_METADATA)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_CHANGE_MEDIA_ITEMS)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_AUDIO_ATTRIBUTES)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_VOLUME)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_DEVICE_VOLUME)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_VOLUME)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_DEVICE_VOLUME)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_ADJUST_DEVICE_VOLUME)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_VIDEO_SURFACE)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_TEXT)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_SET_TRACK_SELECTION_PARAMETERS)).isTrue();
assertThat(player.isCommandAvailable(COMMAND_GET_TRACK_INFOS)).isTrue();
}
Aggregations