com.google.android.exoplayer2.Timeline.getLastWindowIndex()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中com.google.android.exoplayer2.Timeline.getLastWindowIndex()方法的一些代码示例,展示了Timeline.getLastWindowIndex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timeline.getLastWindowIndex()方法的具体详情如下:
包路径:com.google.android.exoplayer2.Timeline
类名称:Timeline
方法名:getLastWindowIndex

Timeline.getLastWindowIndex介绍

[英]Returns the index of the last window in the playback order depending on whether shuffling is enabled.
[中]根据是否启用随机播放,返回播放顺序中最后一个窗口的索引。

代码示例

代码示例来源:origin: google/ExoPlayer

@Override
public int getLastWindowIndex(boolean shuffleModeEnabled) {
 return timeline.getLastWindowIndex(shuffleModeEnabled);
}

代码示例来源:origin: google/ExoPlayer

/**
 * Returns the index of the window after the window at index {@code windowIndex} depending on the
 * {@code repeatMode} and whether shuffling is enabled.
 *
 * @param windowIndex Index of a window in the timeline.
 * @param repeatMode A repeat mode.
 * @param shuffleModeEnabled Whether shuffling is enabled.
 * @return The index of the next window, or {@link C#INDEX_UNSET} if this is the last window.
 */
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
  boolean shuffleModeEnabled) {
 switch (repeatMode) {
  case Player.REPEAT_MODE_OFF:
   return windowIndex == getLastWindowIndex(shuffleModeEnabled) ? C.INDEX_UNSET
     : windowIndex + 1;
  case Player.REPEAT_MODE_ONE:
   return windowIndex;
  case Player.REPEAT_MODE_ALL:
   return windowIndex == getLastWindowIndex(shuffleModeEnabled)
     ? getFirstWindowIndex(shuffleModeEnabled) : windowIndex + 1;
  default:
   throw new IllegalStateException();
 }
}

代码示例来源:origin: google/ExoPlayer

/**
 * Returns the index of the window before the window at index {@code windowIndex} depending on the
 * {@code repeatMode} and whether shuffling is enabled.
 *
 * @param windowIndex Index of a window in the timeline.
 * @param repeatMode A repeat mode.
 * @param shuffleModeEnabled Whether shuffling is enabled.
 * @return The index of the previous window, or {@link C#INDEX_UNSET} if this is the first window.
 */
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
  boolean shuffleModeEnabled) {
 switch (repeatMode) {
  case Player.REPEAT_MODE_OFF:
   return windowIndex == getFirstWindowIndex(shuffleModeEnabled) ? C.INDEX_UNSET
     : windowIndex - 1;
  case Player.REPEAT_MODE_ONE:
   return windowIndex;
  case Player.REPEAT_MODE_ALL:
   return windowIndex == getFirstWindowIndex(shuffleModeEnabled)
     ? getLastWindowIndex(shuffleModeEnabled) : windowIndex - 1;
  default:
   throw new IllegalStateException();
 }
}

代码示例来源:origin: google/ExoPlayer

/** Assert that timeline is empty (i.e. has no windows or periods). */
public static void assertEmpty(Timeline timeline) {
 assertWindowTags(timeline);
 assertPeriodCounts(timeline);
 for (boolean shuffled : new boolean[] {false, true}) {
  assertThat(timeline.getFirstWindowIndex(shuffled)).isEqualTo(C.INDEX_UNSET);
  assertThat(timeline.getLastWindowIndex(shuffled)).isEqualTo(C.INDEX_UNSET);
 }
}

代码示例来源:origin: google/ExoPlayer

/** Assert that timeline is empty (i.e. has no windows or periods). */
public static void assertEmpty(Timeline timeline) {
 assertWindowTags(timeline);
 assertPeriodCounts(timeline);
 for (boolean shuffled : new boolean[] {false, true}) {
  assertThat(timeline.getFirstWindowIndex(shuffled)).isEqualTo(C.INDEX_UNSET);
  assertThat(timeline.getLastWindowIndex(shuffled)).isEqualTo(C.INDEX_UNSET);
 }
}

代码示例来源:origin: google/ExoPlayer

@Override
public int getLastWindowIndex(boolean shuffleModeEnabled) {
 if (childCount == 0) {
  return C.INDEX_UNSET;
 }
 if (isAtomic) {
  shuffleModeEnabled = false;
 }
 // Find last non-empty child.
 int lastChildIndex = shuffleModeEnabled ? shuffleOrder.getLastIndex() : childCount - 1;
 while (getTimelineByChildIndex(lastChildIndex).isEmpty()) {
  lastChildIndex = getPreviousChildIndex(lastChildIndex, shuffleModeEnabled);
  if (lastChildIndex == C.INDEX_UNSET) {
   // All children are empty.
   return C.INDEX_UNSET;
  }
 }
 return getFirstWindowIndexByChildIndex(lastChildIndex)
   + getTimelineByChildIndex(lastChildIndex).getLastWindowIndex(shuffleModeEnabled);
}

代码示例来源:origin: google/ExoPlayer

+ getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(shuffleModeEnabled);

代码示例来源:origin: google/ExoPlayer

assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */ false)).isEqualTo(0);
assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */ true)).isEqualTo(0);
assertThat(timeline.getLastWindowIndex(/* shuffleModeEnabled= */ false)).isEqualTo(2);
assertThat(timeline.getLastWindowIndex(/* shuffleModeEnabled= */ true)).isEqualTo(2);

代码示例来源:origin: google/ExoPlayer

TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, true, 2, 0, 1);
assertThat(timeline.getFirstWindowIndex(false)).isEqualTo(0);
assertThat(timeline.getLastWindowIndex(false)).isEqualTo(2);
assertThat(timeline.getFirstWindowIndex(true)).isEqualTo(2);
assertThat(timeline.getLastWindowIndex(true)).isEqualTo(0);
testRunner.assertPrepareAndReleaseAllPeriods();
testRunner.assertCompletedManifestLoads(0, 1, 2);

代码示例来源:origin: google/ExoPlayer

TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, false, 2, 0, 1);
assertThat(timeline.getFirstWindowIndex(false)).isEqualTo(0);
assertThat(timeline.getLastWindowIndex(false)).isEqualTo(timeline.getWindowCount() - 1);
TimelineAsserts.assertNextWindowIndices(
  timeline, Player.REPEAT_MODE_OFF, true, C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, true, 1, 2, 0);
assertThat(timeline.getFirstWindowIndex(true)).isEqualTo(timeline.getWindowCount() - 1);
assertThat(timeline.getLastWindowIndex(true)).isEqualTo(0);

相关文章