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

The following examples show how to use com.google.android.exoplayer2.Player#REPEAT_MODE_ONE . 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: 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 3
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 4
Source File: ReactExoplayerView.java    From react-native-video with MIT License 5 votes vote down vote up
@Override
public void onPositionDiscontinuity(int reason) {
    if (playerNeedsSource) {
        // This will only occur if the user has performed a seek whilst in the error state. Update the
        // resume position so that if the user then retries, playback will resume from the position to
        // which they seeked.
        updateResumePosition();
    }
    // When repeat is turned on, reaching the end of the video will not cause a state change
    // so we need to explicitly detect it.
    if (reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION
            && player.getRepeatMode() == Player.REPEAT_MODE_ONE) {
        eventEmitter.end();
    }
}
 
Example 5
Source File: QueuedExoPlayer.java    From Jockey with Apache License 2.0 5 votes vote down vote up
private int getExoPlayerRepeatMode() {
    if (mRepeatAll) {
        return Player.REPEAT_MODE_ALL;
    } else if (mRepeatOne) {
        return Player.REPEAT_MODE_ONE;
    } else {
        return Player.REPEAT_MODE_OFF;
    }
}
 
Example 6
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 7
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 8
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 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: 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 11
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 12
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 13
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 14
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 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: AbstractConcatenatedTimeline.java    From Telegram 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 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: RepeatModeUtil.java    From MediaSDK with Apache License 2.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 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;
}