本文整理了Java中com.google.android.exoplayer2.Timeline.isEmpty()
方法的一些代码示例,展示了Timeline.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timeline.isEmpty()
方法的具体详情如下:
包路径:com.google.android.exoplayer2.Timeline
类名称:Timeline
方法名:isEmpty
[英]Returns whether the timeline is empty.
[中]返回时间线是否为空。
代码示例来源:origin: google/ExoPlayer
/**
* Returns the index of the first window in the playback order depending on whether shuffling is
* enabled.
*
* @param shuffleModeEnabled Whether shuffling is enabled.
* @return The index of the first window in the playback order, or {@link C#INDEX_UNSET} if the
* timeline is empty.
*/
public int getFirstWindowIndex(boolean shuffleModeEnabled) {
return isEmpty() ? C.INDEX_UNSET : 0;
}
代码示例来源:origin: google/ExoPlayer
private boolean shouldMaskPosition() {
return playbackInfo.timeline.isEmpty() || pendingOperationAcks > 0;
}
代码示例来源:origin: google/ExoPlayer
/**
* Returns the {@link MediaPeriodInfo} of the media period in the front of the queue. This is
* the playing media period unless the player hasn't started playing yet (in which case it is
* the loading media period or null). While the player is seeking or preparing, this method will
* always return null to reflect the uncertainty about the current playing period. May also be
* null, if the timeline is empty or no media period is active yet.
*/
public @Nullable MediaPeriodInfo getPlayingMediaPeriod() {
return mediaPeriodInfoQueue.isEmpty() || timeline.isEmpty() || isSeeking
? null
: mediaPeriodInfoQueue.get(0);
}
代码示例来源:origin: google/ExoPlayer
/**
* Returns the index of the last window in the playback order depending on whether shuffling is
* enabled.
*
* @param shuffleModeEnabled Whether shuffling is enabled.
* @return The index of the last window in the playback order, or {@link C#INDEX_UNSET} if the
* timeline is empty.
*/
public int getLastWindowIndex(boolean shuffleModeEnabled) {
return isEmpty() ? C.INDEX_UNSET : getWindowCount() - 1;
}
代码示例来源:origin: google/ExoPlayer
@Override
public void onTimelineChanged(
Timeline timeline, @Nullable Object manifest, @TimelineChangeReason int reason) {
updateCurrentItemIndex();
if (timeline.isEmpty()) {
castMediaQueueCreationPending = true;
}
}
代码示例来源:origin: google/ExoPlayer
@Override
@Nullable
public Object getTag() {
boolean hasTimeline = timeline != null && !timeline.isEmpty();
return hasTimeline ? timeline.getWindow(0, new Timeline.Window()).tag : null;
}
代码示例来源:origin: google/ExoPlayer
/** Updates the queue with a newly created media period. */
public void onMediaPeriodCreated(int windowIndex, MediaPeriodId mediaPeriodId) {
boolean isInTimeline = timeline.getIndexOfPeriod(mediaPeriodId.periodUid) != C.INDEX_UNSET;
MediaPeriodInfo mediaPeriodInfo =
new MediaPeriodInfo(mediaPeriodId, isInTimeline ? timeline : Timeline.EMPTY, windowIndex);
mediaPeriodInfoQueue.add(mediaPeriodInfo);
mediaPeriodIdToInfo.put(mediaPeriodId, mediaPeriodInfo);
if (mediaPeriodInfoQueue.size() == 1 && !timeline.isEmpty()) {
updateLastReportedPlayingMediaPeriod();
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public long getSupportedPlaybackActions(Player player) {
if (player == null || player.getCurrentTimeline().isEmpty()) {
return 0;
} else if (!player.isCurrentWindowSeekable()) {
return BASE_ACTIONS;
}
long actions = BASE_ACTIONS | PlaybackStateCompat.ACTION_SEEK_TO;
if (fastForwardIncrementMs > 0) {
actions |= PlaybackStateCompat.ACTION_FAST_FORWARD;
}
if (rewindIncrementMs > 0) {
actions |= PlaybackStateCompat.ACTION_REWIND;
}
return actions;
}
代码示例来源:origin: google/ExoPlayer
@Override
public final boolean isCurrentWindowDynamic() {
Timeline timeline = getCurrentTimeline();
return !timeline.isEmpty() && timeline.getWindow(getCurrentWindowIndex(), window).isDynamic;
}
代码示例来源:origin: google/ExoPlayer
@Override
public void onTimelineChanged(Timeline timeline, @Nullable Object manifest, int reason) {
if (timeline.isEmpty()) {
playerReference.get().setPlayWhenReady(/* playWhenReady= */ false);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public final boolean isCurrentWindowSeekable() {
Timeline timeline = getCurrentTimeline();
return !timeline.isEmpty() && timeline.getWindow(getCurrentWindowIndex(), window).isSeekable;
}
代码示例来源:origin: google/ExoPlayer
@Override
public void onSkipToQueueItem(Player player, long id) {
Timeline timeline = player.getCurrentTimeline();
if (timeline.isEmpty() || player.isPlayingAd()) {
return;
}
int windowIndex = (int) id;
if (0 <= windowIndex && windowIndex < timeline.getWindowCount()) {
player.seekTo(windowIndex, C.TIME_UNSET);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public final long getContentDuration() {
Timeline timeline = getCurrentTimeline();
return timeline.isEmpty()
? C.TIME_UNSET
: timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
}
代码示例来源:origin: google/ExoPlayer
@Override
@Nullable
public Object getTag() {
boolean hasTimeline = timeline != null && !timeline.isEmpty();
return hasTimeline ? timeline.getWindow(0, new Timeline.Window()).tag : null;
}
代码示例来源:origin: google/ExoPlayer
@Override
public final void onCurrentWindowIndexChanged(Player player) {
if (activeQueueItemId == MediaSessionCompat.QueueItem.UNKNOWN_ID
|| player.getCurrentTimeline().getWindowCount() > maxQueueSize) {
publishFloatingQueueWindow(player);
} else if (!player.getCurrentTimeline().isEmpty()) {
activeQueueItemId = player.getCurrentWindowIndex();
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public final int getNextWindowIndex() {
Timeline timeline = getCurrentTimeline();
return timeline.isEmpty()
? C.INDEX_UNSET
: timeline.getNextWindowIndex(
getCurrentWindowIndex(), getRepeatModeForNavigation(), getShuffleModeEnabled());
}
代码示例来源:origin: google/ExoPlayer
@Override
public final int getPreviousWindowIndex() {
Timeline timeline = getCurrentTimeline();
return timeline.isEmpty()
? C.INDEX_UNSET
: timeline.getPreviousWindowIndex(
getCurrentWindowIndex(), getRepeatModeForNavigation(), getShuffleModeEnabled());
}
代码示例来源:origin: google/ExoPlayer
private void next() {
Timeline timeline = player.getCurrentTimeline();
if (timeline.isEmpty() || player.isPlayingAd()) {
return;
}
int windowIndex = player.getCurrentWindowIndex();
int nextWindowIndex = player.getNextWindowIndex();
if (nextWindowIndex != C.INDEX_UNSET) {
seekTo(nextWindowIndex, C.TIME_UNSET);
} else if (timeline.getWindow(windowIndex, window).isDynamic) {
seekTo(windowIndex, C.TIME_UNSET);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public void onSkipToNext(Player player) {
Timeline timeline = player.getCurrentTimeline();
if (timeline.isEmpty() || player.isPlayingAd()) {
return;
}
int windowIndex = player.getCurrentWindowIndex();
int nextWindowIndex = player.getNextWindowIndex();
if (nextWindowIndex != C.INDEX_UNSET) {
player.seekTo(nextWindowIndex, C.TIME_UNSET);
} else if (timeline.getWindow(windowIndex, window).isDynamic) {
player.seekTo(windowIndex, C.TIME_UNSET);
}
}
代码示例来源:origin: google/ExoPlayer
@Override
public long getDuration() {
if (timeline.isEmpty()) {
return C.INDEX_UNSET;
}
if (isPlayingAd()) {
long adDurationUs =
timeline.getPeriod(0, period).getAdDurationUs(adGroupIndex, adIndexInAdGroup);
return C.usToMs(adDurationUs);
} else {
return timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
}
}
内容来源于网络,如有侵权,请联系作者删除!