timeBar = findViewById(R.id.exo_progress); if (timeBar != null) { timeBar.addListener(componentListener);
timeBar.setAdGroupTimesMs(adGroupTimesMs, playedAdGroups, totalAdGroupCount); timeBar.setPosition(position); timeBar.setBufferedPosition(bufferedPosition); timeBar.setDuration(duration);
private void updateNavigation() { if (!isVisible() || !isAttachedToWindow) { return; } Timeline timeline = player != null ? player.getCurrentTimeline() : null; boolean haveNonEmptyTimeline = timeline != null && !timeline.isEmpty(); boolean isSeekable = false; boolean enablePrevious = false; boolean enableNext = false; if (haveNonEmptyTimeline && !player.isPlayingAd()) { int windowIndex = player.getCurrentWindowIndex(); timeline.getWindow(windowIndex, window); isSeekable = window.isSeekable; enablePrevious = isSeekable || !window.isDynamic || player.hasPrevious(); enableNext = window.isDynamic || player.hasNext(); } setButtonEnabled(enablePrevious, previousButton); setButtonEnabled(enableNext, nextButton); setButtonEnabled(fastForwardMs > 0 && isSeekable, fastForwardButton); setButtonEnabled(rewindMs > 0 && isSeekable, rewindButton); if (timeBar != null) { timeBar.setEnabled(isSeekable); } }
/** * Set different seek time depending on the video length * @param player source of the video params */ public void initTimeBar(final SimpleExoPlayer player) { if (player == null) { return; } int incrementMS; final long durationMS = player.getDuration(); if (durationMS < 10*60*1000) { // 0 - 10 min incrementMS = SEEK_INCREMENT_10MIN_MS; } else if (durationMS < 60*60*1000) { // 10 - 60 min incrementMS = SEEK_INCREMENT_60MIN_MS; } else if (durationMS < 120*60*1000) { // 60 - 120 min incrementMS = SEEK_INCREMENT_120MIN_MS; } else if (durationMS < 180*60*1000) { // 120 - 180 min incrementMS = SEEK_INCREMENT_180MIN_MS; } else { // 180 - ... min incrementMS = SEEK_INCREMENT_MORE_180MIN_MS; } // time bar: rewind and fast forward to 15 secs final TimeBar timeBar = mExoPlayerView.findViewById(R.id.exo_progress); timeBar.setKeyTimeIncrement(incrementMS); // Playback control view. mExoPlayerView.setRewindIncrementMs(incrementMS); mExoPlayerView.setFastForwardIncrementMs(incrementMS); }
timeBar.setAdGroupTimesMs(adGroupTimesMs, playedAdGroups, totalAdGroupCount); timeBar.setPosition(position); timeBar.setBufferedPosition(bufferedPosition); timeBar.setDuration(duration); timeBarLandscape.setPosition(position); timeBarLandscape.setBufferedPosition(bufferedPosition); timeBarLandscape.setDuration(duration);
private void updateNavigation() { if (!isVisible() || !isAttachedToWindow) { return; } Timeline timeline = player != null ? player.getCurrentTimeline() : null; boolean haveNonEmptyTimeline = timeline != null && !timeline.isEmpty(); boolean isSeekable = false; boolean enablePrevious = false; boolean enableNext = false; if (haveNonEmptyTimeline && !player.isPlayingAd()) { int windowIndex = player.getCurrentWindowIndex(); timeline.getWindow(windowIndex, window); isSeekable = window.isSeekable; enablePrevious = isSeekable || !window.isDynamic || player.getPreviousWindowIndex() != C.INDEX_UNSET; enableNext = window.isDynamic || player.getNextWindowIndex() != C.INDEX_UNSET; } setButtonEnabled(enablePrevious, previousButton); setButtonEnabled(enableNext, nextButton); setButtonEnabled(fastForwardMs > 0 && isSeekable, fastForwardButton); setButtonEnabled(rewindMs > 0 && isSeekable, rewindButton); if (timeBar != null) { timeBar.setEnabled(isSeekable && !isHls); } if (timeBarLandscape != null) { timeBarLandscape.setEnabled(isSeekable && !isHls); } }
timeBar = findViewById(R.id.exo_player_progress); if (timeBar != null) { timeBar.addListener(componentListener); timeBarLandscape.addListener(componentListener);