/** Hides the controller. */ public void hide() { if (isVisible()) { setVisibility(GONE); if (visibilityListener != null) { visibilityListener.onVisibilityChange(getVisibility()); } removeCallbacks(updateProgressAction); removeCallbacks(hideAction); hideAtMs = C.TIME_UNSET; } }
private boolean toggleControllerVisibility() { if (!useController || player == null) { return false; } if (!controller.isVisible()) { maybeShowController(true); } else if (controllerHideOnTouch) { controller.hide(); } return true; }
/** Shows the playback controls, but only if forced or shown indefinitely. */ private void maybeShowController(boolean isForced) { if (isPlayingAd() && controllerHideDuringAds) { return; } if (useController) { boolean wasShowingIndefinitely = controller.isVisible() && controller.getShowTimeoutMs() <= 0; boolean shouldShowIndefinitely = shouldShowControllerIndefinitely(); if (isForced || wasShowingIndefinitely || shouldShowIndefinitely) { showController(shouldShowIndefinitely); } } }
private void showController(boolean showIndefinitely) { if (!useController) { return; } controller.setShowTimeoutMs(showIndefinitely ? 0 : controllerShowTimeoutMs); controller.show(); }
/** * Sets the text size to one derived from {@link CaptioningManager#getFontScale()}, or to a * default size before API level 19. */ public void setUserDefaultTextSize() { float fontScale = Util.SDK_INT >= 19 && !isInEditMode() ? getUserCaptionFontScaleV19() : 1f; setFractionalTextSize(DEFAULT_TEXT_SIZE_FRACTION * fontScale); }
@Override public void setPosition(long position) { this.position = position; setContentDescription(getProgressText()); update(); }
/** * Dispatches a given {@link KeyEvent} to the corresponding view of the current player. * * @param event The {@link KeyEvent}. * @return Whether the event was handled by the target view. */ public boolean dispatchKeyEvent(KeyEvent event) { if (currentPlayer == exoPlayer) { return localPlayerView.dispatchKeyEvent(event); } else /* currentPlayer == castPlayer */ { return castControlView.dispatchKeyEvent(event); } }
/** * Sets the text size to be a fraction of the view's remaining height after its top and bottom * padding have been subtracted. * <p> * Equivalent to {@code #setFractionalTextSize(fractionOfHeight, false)}. * * @param fractionOfHeight A fraction between 0 and 1. */ public void setFractionalTextSize(float fractionOfHeight) { setFractionalTextSize(fractionOfHeight, false); }
/** * Called to process media key events. Any {@link KeyEvent} can be passed but only media key * events will be handled. Does nothing if playback controls are disabled. * * @param event A key event. * @return Whether the key event was handled. */ public boolean dispatchMediaKeyEvent(KeyEvent event) { return useController && controller.dispatchMediaKeyEvent(event); }
/** * Shows the playback controls. Does nothing if playback controls are disabled. * * <p>The playback controls are automatically hidden during playback after {{@link * #getControllerShowTimeoutMs()}}. They are shown indefinitely when playback has not started yet, * is paused, has ended or failed. */ public void showController() { showController(shouldShowControllerIndefinitely()); }
@Override public void setDuration(long duration) { this.duration = duration; if (scrubbing && duration == C.TIME_UNSET) { stopScrubbing(true); } update(); }
@Override public void onRtlPropertiesChanged(int layoutDirection) { if (scrubberDrawable != null && setDrawableLayoutDirection(scrubberDrawable, layoutDirection)) { invalidate(); } }
/** * Sets the aspect ratio that this view should satisfy. * * @param widthHeightRatio The width to height ratio. */ public void setAspectRatio(float widthHeightRatio) { if (this.videoAspectRatio != widthHeightRatio) { this.videoAspectRatio = widthHeightRatio; requestLayout(); } }
@Override public void run() { isScheduled = false; if (aspectRatioListener == null) { return; } aspectRatioListener.onAspectRatioUpdated( targetAspectRatio, naturalAspectRatio, aspectRatioMismatch); } }
/** * Sets whether the play and pause actions should be used. * * @param usePlayPauseActions Whether to use play and pause actions. */ public final void setUsePlayPauseActions(boolean usePlayPauseActions) { if (this.usePlayPauseActions != usePlayPauseActions) { this.usePlayPauseActions = usePlayPauseActions; invalidate(); } }
private void setTextSize(@Cue.TextSizeType int textSizeType, float textSize) { if (this.textSizeType == textSizeType && this.textSize == textSize) { return; } this.textSizeType = textSizeType; this.textSize = textSize; // Invalidate to trigger drawing. invalidate(); }
public void scheduleUpdate( float targetAspectRatio, float naturalAspectRatio, boolean aspectRatioMismatch) { this.targetAspectRatio = targetAspectRatio; this.naturalAspectRatio = naturalAspectRatio; this.aspectRatioMismatch = aspectRatioMismatch; if (!isScheduled) { isScheduled = true; post(this); } }
/** * Sets the fast forward increment in milliseconds. * * @param fastForwardMs The fast forward increment in milliseconds. A non-positive value will * cause the fast forward button to be disabled. */ public void setFastForwardIncrementMs(int fastForwardMs) { this.fastForwardMs = fastForwardMs; updateNavigation(); }
@Override public boolean onTrackballEvent(MotionEvent ev) { if (!useController || player == null) { return false; } maybeShowController(true); return true; }
@Override public void setBufferedPosition(long bufferedPosition) { this.bufferedPosition = bufferedPosition; update(); }