@Override public void onFastForward(Player player) { if (fastForwardIncrementMs <= 0) { return; } onSeekTo(player, player.getCurrentPosition() + fastForwardIncrementMs); }
@Override public void onRewind(Player player) { if (rewindIncrementMs <= 0) { return; } onSeekTo(player, player.getCurrentPosition() - rewindIncrementMs); }
private void rewind() { if (rewindMs <= 0) { return; } seekTo(Math.max(player.getCurrentPosition() - rewindMs, 0)); }
@Override public long getCurrentPosition() { return player.getPlaybackState() == Player.STATE_IDLE ? -1 : player.getCurrentPosition(); }
private void fastForward() { if (fastForwardMs <= 0) { return; } long durationMs = player.getDuration(); long seekPositionMs = player.getCurrentPosition() + fastForwardMs; if (durationMs != C.TIME_UNSET) { seekPositionMs = Math.min(seekPositionMs, durationMs); } seekTo(seekPositionMs); }
@Override public VideoProgressUpdate getAdProgress() { if (player == null) { return lastAdProgress; } else if (imaAdState != IMA_AD_STATE_NONE && playingAd) { long adDuration = player.getDuration(); return adDuration == C.TIME_UNSET ? VideoProgressUpdate.VIDEO_TIME_NOT_READY : new VideoProgressUpdate(player.getCurrentPosition(), adDuration); } else { return VideoProgressUpdate.VIDEO_TIME_NOT_READY; } }
long increment = ACTION_FAST_FORWARD.equals(action) ? fastForwardMs : -rewindMs; controlDispatcher.dispatchSeekTo( player, player.getCurrentWindowIndex(), player.getCurrentPosition() + increment); } else if (ACTION_NEXT.equals(action)) { int nextWindowIndex = player.getNextWindowIndex(); int previousWindowIndex = player.getPreviousWindowIndex(); if (previousWindowIndex != C.INDEX_UNSET && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS || (window.isDynamic && !window.isSeekable))) { controlDispatcher.dispatchSeekTo(player, previousWindowIndex, C.TIME_UNSET);
@Override public void detachPlayer() { if (adsManager != null && imaPausedContent) { adPlaybackState = adPlaybackState.withAdResumePositionUs( playingAd ? C.msToUs(player.getCurrentPosition()) : 0); adsManager.pause(); } lastVolumePercentage = getVolume(); lastAdProgress = getAdProgress(); lastContentProgress = getContentProgress(); player.removeListener(this); player = null; eventListener = null; }
private void previous() { Timeline timeline = player.getCurrentTimeline(); if (timeline.isEmpty() || player.isPlayingAd()) { return; } int windowIndex = player.getCurrentWindowIndex(); timeline.getWindow(windowIndex, window); int previousWindowIndex = player.getPreviousWindowIndex(); if (previousWindowIndex != C.INDEX_UNSET && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS || (window.isDynamic && !window.isSeekable))) { seekTo(previousWindowIndex, C.TIME_UNSET); } else { seekTo(0); } }
&& player.getCurrentAdIndexInAdGroup() == mediaPeriodId.adIndexInAdGroup; eventPositionMs = isCurrentAd ? player.getCurrentPosition() : 0; } else if (isInCurrentWindow) { eventPositionMs = player.getContentPosition(); mediaPeriodId, eventPositionMs, player.getCurrentPosition(), player.getTotalBufferedDuration());
adPlaybackState.getAdGroupIndexForPositionUs(C.msToUs(contentPositionMs)); } else if (imaAdState == IMA_AD_STATE_NONE && !playingAd && hasContentDuration) { contentPositionMs = player.getCurrentPosition();
@Override public void onSkipToPrevious(Player player) { Timeline timeline = player.getCurrentTimeline(); if (timeline.isEmpty() || player.isPlayingAd()) { return; } int windowIndex = player.getCurrentWindowIndex(); timeline.getWindow(windowIndex, window); int previousWindowIndex = player.getPreviousWindowIndex(); if (previousWindowIndex != C.INDEX_UNSET && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS || (window.isDynamic && !window.isSeekable))) { player.seekTo(previousWindowIndex, C.TIME_UNSET); } else { player.seekTo(0); } }
@Override public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) { if (adsManager == null) { return; } if (!playingAd && !player.isPlayingAd()) { checkForContentComplete(); if (sentContentComplete) { for (int i = 0; i < adPlaybackState.adGroupCount; i++) { if (adPlaybackState.adGroupTimesUs[i] != C.TIME_END_OF_SOURCE) { adPlaybackState = adPlaybackState.withSkippedAdGroup(i); } } updateAdPlaybackState(); } else { long positionMs = player.getCurrentPosition(); timeline.getPeriod(0, period); int newAdGroupIndex = period.getAdGroupIndexForPositionUs(C.msToUs(positionMs)); if (newAdGroupIndex != C.INDEX_UNSET) { sentPendingContentPositionMs = false; pendingContentPositionMs = positionMs; if (newAdGroupIndex != adGroupIndex) { shouldNotifyAdPrepareError = false; } } } } else { updateImaStateForPlayerState(); } }
.setState( sessionPlaybackState, player.getCurrentPosition(), player.getPlaybackParameters().speed, SystemClock.elapsedRealtime())
int playbackState = this.currentPlayer.getPlaybackState(); if (playbackState != Player.STATE_ENDED) { playbackPositionMs = this.currentPlayer.getCurrentPosition(); playWhenReady = this.currentPlayer.getPlayWhenReady(); windowIndex = this.currentPlayer.getCurrentWindowIndex();
long contentPositionMs = player.getCurrentPosition(); int adGroupIndexForPosition = adPlaybackState.getAdGroupIndexForPositionUs(C.msToUs(contentPositionMs));
private void rewind() { if (rewindMs <= 0) { return; } seekTo(Math.max(player.getCurrentPosition() - rewindMs, 0)); }
private void fastForward() { if (fastForwardMs <= 0) { return; } long durationMs = player.getDuration(); long seekPositionMs = player.getCurrentPosition() + fastForwardMs; if (durationMs != C.TIME_UNSET) { seekPositionMs = Math.min(seekPositionMs, durationMs); } seekTo(seekPositionMs); }
private void updatePositionDurationViews() { if(getPlayer().getCurrentPosition() == 0) { setDurationViewOnTop(); } else { setPositionViewOnTop(); } }
private void previous() { Timeline timeline = player.getCurrentTimeline(); if (timeline.isEmpty()) { return; } int windowIndex = player.getCurrentWindowIndex(); timeline.getWindow(windowIndex, window); int previousWindowIndex = player.getPreviousWindowIndex(); if (previousWindowIndex != C.INDEX_UNSET && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS || (window.isDynamic && !window.isSeekable))) { seekTo(previousWindowIndex, C.TIME_UNSET); } else { seekTo(0); } }