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

The following examples show how to use com.google.android.exoplayer2.Player#RepeatMode . 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: LoopingMediaSource.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) {
  int childNextWindowIndex = timeline.getNextWindowIndex(windowIndex, repeatMode,
      shuffleModeEnabled);
  return childNextWindowIndex == C.INDEX_UNSET ? getFirstWindowIndex(shuffleModeEnabled)
      : childNextWindowIndex;
}
 
Example 2
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 3
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 4
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;
}
 
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: 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 7
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 8
Source File: EventLogger.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public void onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode) {
  logd(eventTime, "repeatMode", getRepeatModeString(repeatMode));
}
 
Example 9
Source File: NativeSurfaceVideoView.java    From ExoMedia with Apache License 2.0 4 votes vote down vote up
@Override
public void setRepeatMode(@Player.RepeatMode int repeatMode) {
    // Purposefully left blank
}
 
Example 10
Source File: ExoSurfaceVideoView.java    From ExoMedia with Apache License 2.0 4 votes vote down vote up
@Override
public void setRepeatMode(@Player.RepeatMode int repeatMode) {
    delegate.setRepeatMode(repeatMode);
}
 
Example 11
Source File: ForwardingTimeline.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  return timeline.getPreviousWindowIndex(windowIndex, repeatMode, shuffleModeEnabled);
}
 
Example 12
Source File: EventLogger.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode) {
  logd(eventTime, "repeatMode", getRepeatModeString(repeatMode));
}
 
Example 13
Source File: ForwardingTimeline.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  return timeline.getNextWindowIndex(windowIndex, repeatMode, shuffleModeEnabled);
}
 
Example 14
Source File: EventLogger.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode) {
  logd(eventTime, "repeatMode", getRepeatModeString(repeatMode));
}
 
Example 15
Source File: ExoMediaPlayer.java    From ExoMedia with Apache License 2.0 4 votes vote down vote up
public void setRepeatMode(@Player.RepeatMode int repeatMode) {
    player.setRepeatMode(repeatMode);
}
 
Example 16
Source File: ForwardingTimeline.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  return timeline.getPreviousWindowIndex(windowIndex, repeatMode, shuffleModeEnabled);
}
 
Example 17
Source File: ForwardingTimeline.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  return timeline.getNextWindowIndex(windowIndex, repeatMode, shuffleModeEnabled);
}
 
Example 18
Source File: ForwardingTimeline.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled) {
  return timeline.getNextWindowIndex(windowIndex, repeatMode, shuffleModeEnabled);
}
 
Example 19
Source File: AnalyticsListener.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Called when the repeat mode changed.
 *
 * @param eventTime The event time.
 * @param repeatMode The new repeat mode.
 */
default void onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode) {}
 
Example 20
Source File: AudioPlayerApi.java    From ExoMedia with Apache License 2.0 votes vote down vote up
void setRepeatMode(@Player.RepeatMode int repeatMode);