Java Code Examples for com.google.android.exoplayer2.Player#REPEAT_MODE_ALL

The following examples show how to use com.google.android.exoplayer2.Player#REPEAT_MODE_ALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomizeControlView.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
public void setRepeatToggleModes(@RepeatModeUtil.RepeatToggleModes int repeatToggleModes) {
    this.repeatToggleModes = repeatToggleModes;
    if (player != null) {
        @Player.RepeatMode int currentMode = player.getRepeatMode();
        if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE
                && currentMode != Player.REPEAT_MODE_OFF) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_OFF);
        } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ONE
                && currentMode == Player.REPEAT_MODE_ALL) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ONE);
        } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL
                && currentMode == Player.REPEAT_MODE_ONE) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ALL);
        }
    }
}
 
Example 2
Source File: ExoVideoPlaybackControlView.java    From ExoVideoView with Apache License 2.0 6 votes vote down vote up
/**
 * Sets which repeat toggle modes are enabled.
 *
 * @param repeatToggleModes A set of {@link RepeatModeUtil.RepeatToggleModes}.
 */
public void setRepeatToggleModes(@RepeatModeUtil.RepeatToggleModes int repeatToggleModes) {
    this.repeatToggleModes = repeatToggleModes;
    if (player != null) {
        @Player.RepeatMode int currentMode = player.getRepeatMode();
        if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE
                && currentMode != Player.REPEAT_MODE_OFF) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_OFF);
        } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ONE
                && currentMode == Player.REPEAT_MODE_ALL) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ONE);
        } else if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL
                && currentMode == Player.REPEAT_MODE_ONE) {
            controlDispatcher.dispatchSetRepeatMode(player, Player.REPEAT_MODE_ALL);
        }
    }
}
 
Example 3
Source File: AbstractConcatenatedTimeline.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find next window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int nextWindowIndexInChild = getTimelineByChildIndex(childIndex).getNextWindowIndex(
      windowIndex - firstWindowIndexInChild,
      repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
      shuffleModeEnabled);
  if (nextWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + nextWindowIndexInChild;
  }
  // If not found, find first window of next non-empty child.
  int nextChildIndex = getNextChildIndex(childIndex, shuffleModeEnabled);
  while (nextChildIndex != C.INDEX_UNSET && getTimelineByChildIndex(nextChildIndex).isEmpty()) {
    nextChildIndex = getNextChildIndex(nextChildIndex, shuffleModeEnabled);
  }
  if (nextChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(nextChildIndex)
        + getTimelineByChildIndex(nextChildIndex).getFirstWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the last window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getFirstWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 4
Source File: AbstractConcatenatedTimeline.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find previous window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int previousWindowIndexInChild = getTimelineByChildIndex(childIndex).getPreviousWindowIndex(
      windowIndex - firstWindowIndexInChild,
      repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
      shuffleModeEnabled);
  if (previousWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + previousWindowIndexInChild;
  }
  // If not found, find last window of previous non-empty child.
  int previousChildIndex = getPreviousChildIndex(childIndex, shuffleModeEnabled);
  while (previousChildIndex != C.INDEX_UNSET
      && getTimelineByChildIndex(previousChildIndex).isEmpty()) {
    previousChildIndex = getPreviousChildIndex(previousChildIndex, shuffleModeEnabled);
  }
  if (previousChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(previousChildIndex)
        + getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the first window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getLastWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 5
Source File: AbstractConcatenatedTimeline.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find next window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int nextWindowIndexInChild = getTimelineByChildIndex(childIndex).getNextWindowIndex(
      windowIndex - firstWindowIndexInChild,
      repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
      shuffleModeEnabled);
  if (nextWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + nextWindowIndexInChild;
  }
  // If not found, find first window of next non-empty child.
  int nextChildIndex = getNextChildIndex(childIndex, shuffleModeEnabled);
  while (nextChildIndex != C.INDEX_UNSET && getTimelineByChildIndex(nextChildIndex).isEmpty()) {
    nextChildIndex = getNextChildIndex(nextChildIndex, shuffleModeEnabled);
  }
  if (nextChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(nextChildIndex)
        + getTimelineByChildIndex(nextChildIndex).getFirstWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the last window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getFirstWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 6
Source File: EventLogger.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static String getRepeatModeString(@Player.RepeatMode int repeatMode) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return "OFF";
    case Player.REPEAT_MODE_ONE:
      return "ONE";
    case Player.REPEAT_MODE_ALL:
      return "ALL";
    default:
      return "?";
  }
}
 
Example 7
Source File: EventLogger.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
private static String getRepeatModeString(@Player.RepeatMode int repeatMode) {
    switch (repeatMode) {
        case Player.REPEAT_MODE_OFF:
            return "OFF";
        case Player.REPEAT_MODE_ONE:
            return "ONE";
        case Player.REPEAT_MODE_ALL:
            return "ALL";
        default:
            return "?";
    }
}
 
Example 8
Source File: ExoVideoPlaybackControlView.java    From ExoVideoView with Apache License 2.0 5 votes vote down vote up
private void updateRepeatModeButton() {
    if (!isVisible() || !isAttachedToWindow || repeatToggleButton == null) {
        return;
    }
    if (repeatToggleModes == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) {
        repeatToggleButton.setVisibility(View.GONE);
        return;
    }
    if (player == null) {
        setButtonEnabled(false, repeatToggleButton);
        return;
    }
    setButtonEnabled(true, repeatToggleButton);
    switch (player.getRepeatMode()) {
        case Player.REPEAT_MODE_OFF:
            repeatToggleButton.setImageDrawable(repeatOffButtonDrawable);
            repeatToggleButton.setContentDescription(repeatOffButtonContentDescription);
            break;
        case Player.REPEAT_MODE_ONE:
            repeatToggleButton.setImageDrawable(repeatOneButtonDrawable);
            repeatToggleButton.setContentDescription(repeatOneButtonContentDescription);
            break;
        case Player.REPEAT_MODE_ALL:
            repeatToggleButton.setImageDrawable(repeatAllButtonDrawable);
            repeatToggleButton.setContentDescription(repeatAllButtonContentDescription);
            break;
    }
    repeatToggleButton.setVisibility(View.VISIBLE);
}
 
Example 9
Source File: EventLogger.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static String getRepeatModeString(@Player.RepeatMode int repeatMode) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return "OFF";
    case Player.REPEAT_MODE_ONE:
      return "ONE";
    case Player.REPEAT_MODE_ALL:
      return "ALL";
    default:
      return "?";
  }
}
 
Example 10
Source File: EventLogger.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static String getRepeatModeString(@Player.RepeatMode int repeatMode) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return "OFF";
    case Player.REPEAT_MODE_ONE:
      return "ONE";
    case Player.REPEAT_MODE_ALL:
      return "ALL";
    default:
      return "?";
  }
}
 
Example 11
Source File: AbstractConcatenatedTimeline.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find previous window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int previousWindowIndexInChild = getTimelineByChildIndex(childIndex).getPreviousWindowIndex(
      windowIndex - firstWindowIndexInChild,
      repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
      shuffleModeEnabled);
  if (previousWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + previousWindowIndexInChild;
  }
  // If not found, find last window of previous non-empty child.
  int previousChildIndex = getPreviousChildIndex(childIndex, shuffleModeEnabled);
  while (previousChildIndex != C.INDEX_UNSET
      && getTimelineByChildIndex(previousChildIndex).isEmpty()) {
    previousChildIndex = getPreviousChildIndex(previousChildIndex, shuffleModeEnabled);
  }
  if (previousChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(previousChildIndex)
        + getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the first window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getLastWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 12
Source File: AbstractConcatenatedTimeline.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public int getNextWindowIndex(
    int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find next window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int nextWindowIndexInChild =
      getTimelineByChildIndex(childIndex)
          .getNextWindowIndex(
              windowIndex - firstWindowIndexInChild,
              repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
              shuffleModeEnabled);
  if (nextWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + nextWindowIndexInChild;
  }
  // If not found, find first window of next non-empty child.
  int nextChildIndex = getNextChildIndex(childIndex, shuffleModeEnabled);
  while (nextChildIndex != C.INDEX_UNSET && getTimelineByChildIndex(nextChildIndex).isEmpty()) {
    nextChildIndex = getNextChildIndex(nextChildIndex, shuffleModeEnabled);
  }
  if (nextChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(nextChildIndex)
        + getTimelineByChildIndex(nextChildIndex).getFirstWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the last window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getFirstWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 13
Source File: RepeatModeUtil.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies whether a given {@code repeatMode} is enabled in the bitmask {@code enabledModes}.
 *
 * @param repeatMode The mode to check.
 * @param enabledModes The bitmask representing the enabled modes.
 * @return {@code true} if enabled.
 */
public static boolean isRepeatModeEnabled(@Player.RepeatMode int repeatMode, int enabledModes) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return true;
    case Player.REPEAT_MODE_ONE:
      return (enabledModes & REPEAT_TOGGLE_MODE_ONE) != 0;
    case Player.REPEAT_MODE_ALL:
      return (enabledModes & REPEAT_TOGGLE_MODE_ALL) != 0;
    default:
      return false;
  }
}
 
Example 14
Source File: RepeatModeUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies whether a given {@code repeatMode} is enabled in the bitmask {@code enabledModes}.
 *
 * @param repeatMode The mode to check.
 * @param enabledModes The bitmask representing the enabled modes.
 * @return {@code true} if enabled.
 */
public static boolean isRepeatModeEnabled(@Player.RepeatMode int repeatMode, int enabledModes) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return true;
    case Player.REPEAT_MODE_ONE:
      return (enabledModes & REPEAT_TOGGLE_MODE_ONE) != 0;
    case Player.REPEAT_MODE_ALL:
      return (enabledModes & REPEAT_TOGGLE_MODE_ALL) != 0;
    default:
      return false;
  }
}
 
Example 15
Source File: AbstractConcatenatedTimeline.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find previous window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int previousWindowIndexInChild = getTimelineByChildIndex(childIndex).getPreviousWindowIndex(
      windowIndex - firstWindowIndexInChild,
      repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
      shuffleModeEnabled);
  if (previousWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + previousWindowIndexInChild;
  }
  // If not found, find last window of previous non-empty child.
  int previousChildIndex = getPreviousChildIndex(childIndex, shuffleModeEnabled);
  while (previousChildIndex != C.INDEX_UNSET
      && getTimelineByChildIndex(previousChildIndex).isEmpty()) {
    previousChildIndex = getPreviousChildIndex(previousChildIndex, shuffleModeEnabled);
  }
  if (previousChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(previousChildIndex)
        + getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the first window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getLastWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 16
Source File: AbstractConcatenatedTimeline.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find next window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int nextWindowIndexInChild = getTimelineByChildIndex(childIndex).getNextWindowIndex(
      windowIndex - firstWindowIndexInChild,
      repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
      shuffleModeEnabled);
  if (nextWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + nextWindowIndexInChild;
  }
  // If not found, find first window of next non-empty child.
  int nextChildIndex = getNextChildIndex(childIndex, shuffleModeEnabled);
  while (nextChildIndex != C.INDEX_UNSET && getTimelineByChildIndex(nextChildIndex).isEmpty()) {
    nextChildIndex = getNextChildIndex(nextChildIndex, shuffleModeEnabled);
  }
  if (nextChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(nextChildIndex)
        + getTimelineByChildIndex(nextChildIndex).getFirstWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the last window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getFirstWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 17
Source File: RepeatModeUtil.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies whether a given {@code repeatMode} is enabled in the bitmask {@code enabledModes}.
 *
 * @param repeatMode The mode to check.
 * @param enabledModes The bitmask representing the enabled modes.
 * @return {@code true} if enabled.
 */
public static boolean isRepeatModeEnabled(@Player.RepeatMode int repeatMode, int enabledModes) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return true;
    case Player.REPEAT_MODE_ONE:
      return (enabledModes & REPEAT_TOGGLE_MODE_ONE) != 0;
    case Player.REPEAT_MODE_ALL:
      return (enabledModes & REPEAT_TOGGLE_MODE_ALL) != 0;
    default:
      return false;
  }
}
 
Example 18
Source File: EventLogger.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static String getRepeatModeString(@Player.RepeatMode int repeatMode) {
  switch (repeatMode) {
    case Player.REPEAT_MODE_OFF:
      return "OFF";
    case Player.REPEAT_MODE_ONE:
      return "ONE";
    case Player.REPEAT_MODE_ALL:
      return "ALL";
    default:
      return "?";
  }
}
 
Example 19
Source File: AbstractConcatenatedTimeline.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find previous window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int previousWindowIndexInChild = getTimelineByChildIndex(childIndex).getPreviousWindowIndex(
      windowIndex - firstWindowIndexInChild,
      repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
      shuffleModeEnabled);
  if (previousWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + previousWindowIndexInChild;
  }
  // If not found, find last window of previous non-empty child.
  int previousChildIndex = getPreviousChildIndex(childIndex, shuffleModeEnabled);
  while (previousChildIndex != C.INDEX_UNSET
      && getTimelineByChildIndex(previousChildIndex).isEmpty()) {
    previousChildIndex = getPreviousChildIndex(previousChildIndex, shuffleModeEnabled);
  }
  if (previousChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(previousChildIndex)
        + getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the first window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getLastWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}
 
Example 20
Source File: AbstractConcatenatedTimeline.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public int getPreviousWindowIndex(
    int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
  if (isAtomic) {
    // Adapt repeat and shuffle mode to atomic concatenation.
    repeatMode = repeatMode == Player.REPEAT_MODE_ONE ? Player.REPEAT_MODE_ALL : repeatMode;
    shuffleModeEnabled = false;
  }
  // Find previous window within current child.
  int childIndex = getChildIndexByWindowIndex(windowIndex);
  int firstWindowIndexInChild = getFirstWindowIndexByChildIndex(childIndex);
  int previousWindowIndexInChild =
      getTimelineByChildIndex(childIndex)
          .getPreviousWindowIndex(
              windowIndex - firstWindowIndexInChild,
              repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode,
              shuffleModeEnabled);
  if (previousWindowIndexInChild != C.INDEX_UNSET) {
    return firstWindowIndexInChild + previousWindowIndexInChild;
  }
  // If not found, find last window of previous non-empty child.
  int previousChildIndex = getPreviousChildIndex(childIndex, shuffleModeEnabled);
  while (previousChildIndex != C.INDEX_UNSET
      && getTimelineByChildIndex(previousChildIndex).isEmpty()) {
    previousChildIndex = getPreviousChildIndex(previousChildIndex, shuffleModeEnabled);
  }
  if (previousChildIndex != C.INDEX_UNSET) {
    return getFirstWindowIndexByChildIndex(previousChildIndex)
        + getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(shuffleModeEnabled);
  }
  // If not found, this is the first window.
  if (repeatMode == Player.REPEAT_MODE_ALL) {
    return getLastWindowIndex(shuffleModeEnabled);
  }
  return C.INDEX_UNSET;
}