@Override public void setBufferedPosition(long bufferedPosition) { this.bufferedPosition = bufferedPosition; update(); }
@Override public void setAdGroupTimesMs(@Nullable long[] adGroupTimesMs, @Nullable boolean[] playedAdGroups, int adGroupCount) { Assertions.checkArgument(adGroupCount == 0 || (adGroupTimesMs != null && playedAdGroups != null)); this.adGroupCount = adGroupCount; this.adGroupTimesMs = adGroupTimesMs; this.playedAdGroups = playedAdGroups; update(); }
@Override public void setDuration(long duration) { this.duration = duration; if (scrubbing && duration == C.TIME_UNSET) { stopScrubbing(true); } update(); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { int width = right - left; int height = bottom - top; int barY = (height - touchTargetHeight) / 2; int seekLeft = getPaddingLeft(); int seekRight = width - getPaddingRight(); int progressY = barY + (touchTargetHeight - barHeight) / 2; seekBounds.set(seekLeft, barY, seekRight, barY + touchTargetHeight); progressBar.set(seekBounds.left + scrubberPadding, progressY, seekBounds.right - scrubberPadding, progressY + barHeight); update(); }
@Override public void setPosition(long position) { this.position = position; setContentDescription(getProgressText()); update(); }
/** * Incrementally scrubs the position by {@code positionChange}. * * @param positionChange The change in the scrubber position, in milliseconds. May be negative. * @return Returns whether the scrubber position changed. */ private boolean scrubIncrementally(long positionChange) { if (duration <= 0) { return false; } long scrubberPosition = getScrubberPosition(); scrubPosition = Util.constrainValue(scrubberPosition + positionChange, 0, duration); if (scrubPosition == scrubberPosition) { return false; } if (!scrubbing) { startScrubbing(); } for (OnScrubListener listener : listeners) { listener.onScrubMove(this, scrubPosition); } update(); return true; }