PlayerControlView


@UnstableApi
public class PlayerControlView extends FrameLayout


A view for controlling Player instances.

A PlayerControlView can be customized by setting attributes (or calling corresponding methods), or overriding drawables.

Attributes

The following attributes can be set on a PlayerControlView when used in a layout XML file:
  • show_timeout - The time between the last user interaction and the controls being automatically hidden, in milliseconds. Use zero if the controls should not automatically timeout.
  • show_rewind_button - Whether the rewind button is shown.
  • show_fastforward_button - Whether the fast forward button is shown.
  • show_previous_button - Whether the previous button is shown.
  • show_next_button - Whether the next button is shown.
  • repeat_toggle_modes - A flagged enumeration value specifying which repeat mode toggle options are enabled. Valid values are: none, one, all, or one|all.
  • show_shuffle_button - Whether the shuffle button is shown.
  • show_subtitle_button - Whether the subtitle button is shown.
  • animation_enabled - Whether an animation is used to show and hide the playback controls.
  • time_bar_min_update_interval - Specifies the minimum interval between time bar position updates.
  • All attributes that can be set on DefaultTimeBar can also be set on a PlayerControlView, and will be propagated to the inflated DefaultTimeBar.

Overriding drawables globally

The drawables used by PlayerControlView can be overridden by drawables with the same names defined in your application. Note that these icons will be the same across all usages of PlayerView/PlayerControlView in your app. The drawables that can be overridden are:
  • exo_styled_controls_play - The play icon.
  • exo_styled_controls_pause - The pause icon.
  • exo_styled_controls_rewind - The background of rewind icon.
  • exo_styled_controls_fastforward - The background of fast forward icon.
  • exo_styled_controls_previous - The previous icon.
  • exo_styled_controls_next - The next icon.
  • exo_styled_controls_repeat_off - The repeat icon for REPEAT_MODE_OFF.
  • exo_styled_controls_repeat_one - The repeat icon for REPEAT_MODE_ONE.
  • exo_styled_controls_repeat_all - The repeat icon for REPEAT_MODE_ALL.
  • exo_styled_controls_shuffle_off - The shuffle icon when shuffling is disabled.
  • exo_styled_controls_shuffle_on - The shuffle icon when shuffling is enabled.
  • exo_styled_controls_vr - The VR icon.
  • exo_styled_controls_fullscreen_enter - The fullscreen icon for when the player is minimized.
  • exo_styled_controls_fullscreen_exit - The fullscreen icon for when the player is in fullscreen mode.

Overriding drawables locally

If you want to customize drawable per PlayerView instance, you can use the following attributes: PlayerView/PlayerControlView in your app. The drawables that can be overridden are:
  • play_icon - The drawable resource ID for the play/pause button when play is shown.
    • Default: @drawable/exo_styled_controls_play
  • pause_icon - The drawable resource ID for the play/pause button when pause is shown.
    • Default: @drawable/exo_styled_controls_pause
  • fastforward_icon - The drawable resource ID for the simple fast forward button without the seek-forward amount. The ID of the image button in such case should be exo_ffwd, specified in the exo_player_control_ffwd_button layout.
    • Default: @drawable/exo_styled_controls_simple_fastforward
  • rewind_icon - The drawable resource ID for the simple rewind button without the seek-back amount. The ID of the image button in such case should be exo_rew, specified in the exo_player_control_rewind_button layout.
    • Default: @drawable/exo_styled_controls_simple_rewind
  • previous_icon - The drawable resource ID for the previous button.
    • Default: @drawable/exo_styled_controls_previous
  • next_icon - The drawable resource ID for the next button.
    • Default: @drawable/exo_styled_controls_next
  • repeat_off_icon - The drawable resource ID for the repeat button when the mode is none.
    • Default: @drawable/exo_styled_controls_repeat_off
  • repeat_one_icon - The drawable resource ID for the repeat button when the mode is one.
    • Default: @drawable/exo_styled_controls_repeat_one
  • repeat_all_icon - The drawable resource ID for the repeat button when the mode is all.
    • Default: @drawable/exo_styled_controls_repeat_all
  • shuffle_on_icon - The drawable resource ID for the repeat button when the mode is one.
    • Default: @drawable/exo_styled_controls_shuffle_on
  • shuffle_off_icon - The drawable resource ID for the repeat button when the mode is all.
    • Default: @drawable/exo_styled_controls_shuffle_off
  • subtitle_on_icon - The drawable resource ID for the subtitle button when the text track is on.
    • Default: @drawable/exo_styled_controls_subtitle_on
  • subtitle_off_icon - The drawable resource ID for the subtitle button when the text track is off.
    • Default: @drawable/exo_styled_controls_subtitle_off
  • vr_icon - The drawable resource ID for the VR button.
    • Default: @drawable/exo_styled_controls_vr
  • fullscreen_enter_icon - The drawable resource ID for the fullscreen button when the player is minimized.
    • Default: @drawable/exo_styled_controls_fullscreen_enter
  • fullscreen_exit_icon - The drawable resource ID for the fullscreen button when the player is in fullscreen mode.
    • Default: @drawable/exo_styled_controls_fullscreen_exit

Summary

Nested types

This interface is deprecated.

Register a PlayerView.FullscreenButtonClickListener via setFullscreenButtonClickListener instead.

Listener to be notified when progress has been updated.

This interface is deprecated.

Register a PlayerView.ControllerVisibilityListener via setControllerVisibilityListener instead.

Constants

static final int

The default repeat toggle modes.

static final int

The default show timeout, in milliseconds.

static final int

The default minimum interval between time bar position updates.

static final int

The maximum number of windows that can be shown in a multi-window time bar.

Public constructors

PlayerControlView(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)
PlayerControlView(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr,
    @Nullable AttributeSet playbackAttrs
)

Public methods

void

This method is deprecated.

Register a PlayerView.ControllerVisibilityListener via setControllerVisibilityListener instead.

boolean
boolean

Called to process media key events.

@Nullable Player

Returns the Player currently being controlled by this view, or null if no player is set.

int

Returns which repeat toggle modes are enabled.

boolean

Returns whether the shuffle button is shown.

boolean

Returns whether the subtitle button is shown.

int

Returns the playback controls timeout.

boolean

Returns whether the VR button is shown.

void

Hides the controller.

void

Hides the controller without any animation.

boolean

Returns whether an animation is used to show and hide the playback controls.

boolean

Returns whether the controller is fully visible, which means all UI controls are visible.

boolean

Returns whether the controller is currently visible.

void
void
void

This method is deprecated.

Register a PlayerView.ControllerVisibilityListener via setControllerVisibilityListener instead.

void
setAnimationEnabled(boolean animationEnabled)

Sets whether an animation is used to show and hide the playback controls.

void
setExtraAdGroupMarkers(
    @Nullable long[] extraAdGroupTimesMs,
    @Nullable boolean[] extraPlayedAdGroups
)

Sets the millisecond positions of extra ad markers relative to the start of the window (or timeline, if in multi-window mode) and whether each extra ad has been played or not.

void

This method is deprecated.

Register a PlayerView.FullscreenButtonClickListener via setFullscreenButtonClickListener instead.

void

Sets the Player to control.

void

Sets the ProgressUpdateListener.

void

Sets which repeat toggle modes are enabled.

void
setShowFastForwardButton(boolean showFastForwardButton)

Sets whether the fast forward button is shown.

void
setShowMultiWindowTimeBar(boolean showMultiWindowTimeBar)

This method is deprecated.

Replace multi-window time bar display by merging source windows together instead, for example using ExoPlayer's ConcatenatingMediaSource2.

void
setShowNextButton(boolean showNextButton)

Sets whether the next button is shown.

void
setShowPlayButtonIfPlaybackIsSuppressed(
    boolean showPlayButtonIfSuppressed
)

Sets whether a play button is shown if playback is suppressed.

void
setShowPreviousButton(boolean showPreviousButton)

Sets whether the previous button is shown.

void
setShowRewindButton(boolean showRewindButton)

Sets whether the rewind button is shown.

void
setShowShuffleButton(boolean showShuffleButton)

Sets whether the shuffle button is shown.

void
setShowSubtitleButton(boolean showSubtitleButton)

Sets whether the subtitle button is shown.

void
setShowTimeoutMs(int showTimeoutMs)

Sets the playback controls timeout.

void
setShowVrButton(boolean showVrButton)

Sets whether the VR button is shown.

void
setTimeBarMinUpdateInterval(int minUpdateIntervalMs)

Sets the minimum interval between time bar position updates.

void

Sets listener for the VR button.

void

Shows the playback controls.

Protected methods

void
onLayout(boolean changed, int left, int top, int right, int bottom)

Inherited Constants

From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
From android.view.ViewGroup
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

Inherited methods

From android.widget.FrameLayout
From android.view.View
void
void
void
ViewPropertyAnimator
void
void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void
boolean
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
int
void
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    Bundle arguments
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow
)
boolean
void
draw(Canvas canvas)
void
drawableHotspotChanged(float x, float y)
final OnBackInvokedDispatcher
final T
<T extends View> findViewById(int id)
final T
<T extends View> findViewWithTag(Object tag)
boolean

This method is deprecated.

void
forceHasOverlappingRendering(boolean hasOverlappingRendering)
void
void
generateDisplayHash(
    String hashAlgorithm,
    Rect bounds,
    Executor executor,
    DisplayHashResultCallback callback
)
static int
View.AccessibilityDelegate
int
AccessibilityNodeProvider
CharSequence
int
int
String
String
float
Animation
Matrix
IBinder
int[]
Map<IntegerInteger>
String[]
final AutofillId
int
AutofillValue
Drawable
BlendMode
ColorStateList
PorterDuff.Mode
int
final int
float
int
float
Rect
boolean
final boolean
final ContentCaptureSession
CharSequence
final Context
ContextMenu.ContextMenuInfo
final boolean
static int
getDefaultSize(int size, int measureSpec)
Display
final int[]
Bitmap

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
long
float
int
boolean
boolean
int
ArrayList<View>
getFocusables(int direction)
void
Drawable
int
BlendMode
ColorStateList
PorterDuff.Mode
boolean
getGlobalVisibleRect(Rect r, Point globalOffset)
Handler
float
float
float
float
Runnable
final boolean
final int
void
getHitRect(Rect outRect)
int
int
Drawable
Drawable
int
int
int
int
boolean
KeyEvent.DispatcherState
int
int
int
ViewGroup.LayoutParams
final int
float
int
final boolean
void
getLocationInSurface(int[] location)
void
getLocationInWindow(int[] outLocation)
void
getLocationOnScreen(int[] outLocation)
Matrix
final int
final int
final int
final int
final int
int
int
int
int
int
int
int
int
View.OnFocusChangeListener
int
ViewOutlineProvider
int
int
ViewOverlay
int
int
int
int
int
int
final ViewParent
ViewParent
float
float
PointerIcon
final List<Rect>
String[]
Resources
final boolean
final int
float
int
AttachedSurfaceControl
View
WindowInsets
float
float
float
float
float
int
int
int
int
int
int
final int
final int
int
int
final CharSequence
StateListAnimator
int
int
List<Rect>
int

This method is deprecated.

Object
int
int
CharSequence
final int
float
int
TouchDelegate
ArrayList<View>
float
String
float
float
float
long
int
int
Drawable
Drawable
int
ViewTranslationResponse
ViewTreeObserver
int
final int
int
WindowId
WindowInsetsController
int

This method is deprecated.

IBinder
int
void
float
float
float
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
static View
inflate(Context context, int resource, ViewGroup root)
void

This method is deprecated.

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean

This method is deprecated.

boolean
boolean
final boolean
final boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
View
keyboardNavigationClusterSearch(View currentCluster, int direction)
final void
measure(int widthMeasureSpec, int heightMeasureSpec)
static int[]
mergeDrawableStates(int[] baseState, int[] additionalState)
void
offsetLeftAndRight(int offset)
void
offsetTopAndBottom(int offset)
void
void
WindowInsets
void
boolean
boolean
void
void
InputConnection
void
onCreateViewTranslationRequest(
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onCreateVirtualViewTranslationRequests(
    long[] virtualIds,
    int[] supportedFormats,
    Consumer<ViewTranslationRequest> requestsCollector
)
void
onDisplayHint(int hint)
boolean
void
onDraw(Canvas canvas)
void
final void
boolean
void
void
void
onFocusChanged(
    boolean gainFocus,
    int direction,
    Rect previouslyFocusedRect
)
boolean
void
onHoverChanged(boolean hovered)
boolean
void
void
boolean
onKeyDown(int keyCode, KeyEvent event)
boolean
onKeyLongPress(int keyCode, KeyEvent event)
boolean
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
boolean
onKeyPreIme(int keyCode, KeyEvent event)
boolean
onKeyShortcut(int keyCode, KeyEvent event)
boolean
onKeyUp(int keyCode, KeyEvent event)
void
onOverScrolled(
    int scrollX,
    int scrollY,
    boolean clampedX,
    boolean clampedY
)
void
onPointerCaptureChange(boolean hasCapture)
void
void
onProvideAutofillStructure(ViewStructure structure, int flags)
void
void
void
void
ContentInfo
void
void
onRtlPropertiesChanged(int layoutDirection)
Parcelable
void
onScreenStateChanged(int screenState)
void
onScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
onScrollChanged(int l, int t, int oldl, int oldt)
boolean
onSetAlpha(int alpha)
void
onSizeChanged(int w, int h, int oldw, int oldh)
void
boolean
boolean
void
void
void
onVisibilityAggregated(boolean isVisible)
void
onVisibilityChanged(View changedView, int visibility)
void
onWindowFocusChanged(boolean hasWindowFocus)
void

This method is deprecated.

void
onWindowVisibilityChanged(int visibility)
boolean
overScrollBy(
    int deltaX,
    int deltaY,
    int scrollX,
    int scrollY,
    int scrollRangeX,
    int scrollRangeY,
    int maxOverScrollX,
    int maxOverScrollY,
    boolean isTouchEvent
)
boolean
performAccessibilityAction(int action, Bundle arguments)
boolean
boolean
performContextClick(float x, float y)
boolean
performHapticFeedback(int feedbackConstant)
boolean
ContentInfo
void
playSoundEffect(int soundConstant)
boolean
post(Runnable action)
boolean
postDelayed(Runnable action, long delayMillis)
void
void
postInvalidateDelayed(long delayMilliseconds)
void
void
void
postOnAnimationDelayed(Runnable action, long delayMillis)
void
void
boolean
void
void
void
void
void

This method is deprecated.

final boolean
void
void
boolean
final void
final T
<T extends View> requireViewById(int id)
void
static int
resolveSize(int size, int measureSpec)
static int
resolveSizeAndState(int size, int measureSpec, int childMeasuredState)
void
final void
saveAttributeDataForStyleable(
    Context context,
    int[] styleable,
    AttributeSet attrs,
    TypedArray t,
    int defStyleAttr,
    int defStyleRes
)
void
void
scheduleDrawable(Drawable who, Runnable what, long when)
void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
void
sendAccessibilityEvent(int eventType)
void
void
setAccessibilityDataSensitive(int accessibilityDataSensitive)
void
void
setAccessibilityHeading(boolean isHeading)
void
void
setAccessibilityPaneTitle(CharSequence accessibilityPaneTitle)
void
void
void
setActivated(boolean activated)
void
setAllowClickWhenDisabled(boolean clickableWhenDisabled)
void
void
void
setAlpha(float alpha)
void
void
void
setAutoHandwritingEnabled(boolean enabled)
void
setAutofillHints(String[] autofillHints)
void
void
setBackground(Drawable background)
void
setBackgroundColor(int color)
void

This method is deprecated.

void
void
void
void
final void
setBottom(int bottom)
void
setCameraDistance(float distance)
void
setClickable(boolean clickable)
void
setClipBounds(Rect clipBounds)
void
setClipToOutline(boolean clipToOutline)
void
void
setContentDescription(CharSequence contentDescription)
void
setContextClickable(boolean contextClickable)
void
setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled)
void

This method is deprecated.

void
setDrawingCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void
setElevation(float elevation)
void
setEnabled(boolean enabled)
void
setFadingEdgeLength(int length)
void
void
setFitsSystemWindows(boolean fitSystemWindows)
void
setFocusable(boolean focusable)
void
setFocusableInTouchMode(boolean focusableInTouchMode)
void
setFocusedByDefault(boolean isFocusedByDefault)
void
setForceDarkAllowed(boolean allow)
void
setForeground(Drawable foreground)
void
void
void
void
setHandwritingBoundsOffsets(
    float offsetLeft,
    float offsetTop,
    float offsetRight,
    float offsetBottom
)
void
void
setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
void
setHasTransientState(boolean hasTransientState)
void
setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
void
setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
void
void
void
setHovered(boolean hovered)
void
setId(int id)
void
void
void
void
setIsCredential(boolean isCredential)
void
setIsHandwritingDelegate(boolean isHandwritingDelegate)
void
setKeepScreenOn(boolean keepScreenOn)
void
setKeyboardNavigationCluster(boolean isCluster)
void
setLabelFor(int id)
void
void
setLayerType(int layerType, Paint paint)
void
setLayoutDirection(int layoutDirection)
void
final void
setLeft(int left)
final void
setLeftTopRightBottom(int left, int top, int right, int bottom)
void
setLongClickable(boolean longClickable)
final void
setMeasuredDimension(int measuredWidth, int measuredHeight)
void
setMinimumHeight(int minHeight)
void
setMinimumWidth(int minWidth)
void
setNestedScrollingEnabled(boolean enabled)
void
setNextClusterForwardId(int nextClusterForwardId)
void
setNextFocusDownId(int nextFocusDownId)
void
setNextFocusForwardId(int nextFocusForwardId)
void
setNextFocusLeftId(int nextFocusLeftId)
void
setNextFocusRightId(int nextFocusRightId)
void
setNextFocusUpId(int nextFocusUpId)
void
void
void
void
void
void
void
void
void
void
void
void
setOnReceiveContentListener(
    String[] mimeTypes,
    OnReceiveContentListener listener
)
void
void

This method is deprecated.

void
void
void
void
void
setOverScrollMode(int overScrollMode)
void
setPadding(int left, int top, int right, int bottom)
void
setPaddingRelative(int start, int top, int end, int bottom)
void
setPivotX(float pivotX)
void
setPivotY(float pivotY)
void
final void
setPreferKeepClear(boolean preferKeepClear)
final void
void
setPressed(boolean pressed)
void
final void
setRevealOnFocusHint(boolean revealOnFocus)
final void
setRight(int right)
void
setRotation(float rotation)
void
setRotationX(float rotationX)
void
setRotationY(float rotationY)
void
setSaveEnabled(boolean enabled)
void
setSaveFromParentEnabled(boolean enabled)
void
setScaleX(float scaleX)
void
setScaleY(float scaleY)
void
setScreenReaderFocusable(boolean screenReaderFocusable)
void
setScrollBarDefaultDelayBeforeFade(
    int scrollBarDefaultDelayBeforeFade
)
void
setScrollBarFadeDuration(int scrollBarFadeDuration)
void
setScrollBarSize(int scrollBarSize)
void
setScrollBarStyle(int style)
final void
void
void
setScrollContainer(boolean isScrollContainer)
void
setScrollIndicators(int indicators)
void
setScrollX(int value)
void
setScrollY(int value)
void
setScrollbarFadingEnabled(boolean fadeScrollbars)
void
setSelected(boolean selected)
void
setSoundEffectsEnabled(boolean soundEffectsEnabled)
void
void
void
void
setSystemUiVisibility(int visibility)

This method is deprecated.

void
void
setTextAlignment(int textAlignment)
void
setTextDirection(int textDirection)
void
final void
setTop(int top)
void
void
setTransitionAlpha(float alpha)
final void
setTransitionName(String transitionName)
void
setTransitionVisibility(int visibility)
void
setTranslationX(float translationX)
void
setTranslationY(float translationY)
void
setTranslationZ(float translationZ)
void
setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)
void
setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
void
void
void
void
void
setVisibility(int visibility)
void
setWillNotCacheDrawing(boolean willNotCacheDrawing)

This method is deprecated.

void
setWillNotDraw(boolean willNotDraw)
void
setX(float x)
void
setY(float y)
void
setZ(float z)
boolean
ActionMode
void
final boolean
startDrag(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)

This method is deprecated.

final boolean
startDragAndDrop(
    ClipData data,
    View.DragShadowBuilder shadowBuilder,
    Object myLocalState,
    int flags
)
boolean
void
String
void
void
void
final void
boolean
boolean

This method is deprecated.

boolean
From android.view.ViewGroup
void
void
addExtraDataToAccessibilityNodeInfo(
    AccessibilityNodeInfo info,
    String extraDataKey,
    Bundle arguments
)
void
addFocusables(ArrayList<View> views, int direction, int focusableMode)
void
boolean
void
void
addView(View child)
boolean
addViewInLayout(View child, int index, ViewGroup.LayoutParams params)
void
attachLayoutAnimationParameters(
    View child,
    ViewGroup.LayoutParams params,
    int index,
    int count
)
void
attachViewToParent(View child, int index, ViewGroup.LayoutParams params)
void
boolean
void
void
childHasTransientStateChanged(
    View child,
    boolean childHasTransientState
)
void
void
void
void
void
debug(int depth)
void
void
void
detachViewsFromParent(int start, int count)
WindowInsets
boolean
void
void
dispatchCreateViewTranslationRequest(
    Map<AutofillId, long[]> viewIds,
    int[] supportedFormats,
    TranslationCapability capability,
    List<ViewTranslationRequest> requests
)
void
boolean
void
void
dispatchDrawableHotspotChanged(float x, float y)
void
void
boolean
boolean
boolean
boolean
boolean
void
dispatchPointerCaptureChanged(boolean hasCapture)
void
void
void
void
void
dispatchScrollCaptureSearch(
    Rect localVisibleRect,
    Point windowOffset,
    Consumer<ScrollCaptureTarget> targets
)
void
dispatchSetActivated(boolean activated)
void
dispatchSetPressed(boolean pressed)
void
dispatchSetSelected(boolean selected)
void
void

This method is deprecated.

void
boolean
boolean
boolean
dispatchUnhandledMove(View focused, int direction)
void
dispatchVisibilityChanged(View changedView, int visibility)
void
dispatchWindowFocusChanged(boolean hasFocus)
void
void
WindowInsets
WindowInsetsAnimation.Bounds
void

This method is deprecated.

void
boolean
drawChild(Canvas canvas, View child, long drawingTime)
void
void
View
OnBackInvokedDispatcher
void
findViewsWithText(
    ArrayList<View> outViews,
    CharSequence text,
    int flags
)
View
focusSearch(View focused, int direction)
void
boolean
View
getChildAt(int index)
int
int
getChildDrawingOrder(int childCount, int drawingPosition)
static int
getChildMeasureSpec(int spec, int padding, int childDimension)
boolean
boolean
getChildVisibleRect(View child, Rect r, Point offset)
boolean
boolean
int
View
LayoutAnimationController
Animation.AnimationListener
int
LayoutTransition
int
ViewGroupOverlay
int

This method is deprecated.

boolean
boolean
boolean
int
final void
invalidateChild(View child, Rect dirty)

This method is deprecated.

ViewParent
invalidateChildInParent(int[] location, Rect dirty)

This method is deprecated.

boolean

This method is deprecated.

boolean

This method is deprecated.

boolean
boolean

This method is deprecated.

boolean
boolean
boolean
void
final void
layout(int l, int t, int r, int b)
void
measureChild(
    View child,
    int parentWidthMeasureSpec,
    int parentHeightMeasureSpec
)
void
measureChildWithMargins(
    View child,
    int parentWidthMeasureSpec,
    int widthUsed,
    int parentHeightMeasureSpec,
    int heightUsed
)
void
measureChildren(int widthMeasureSpec, int heightMeasureSpec)
void
notifySubtreeAccessibilityStateChanged(
    View child,
    View source,
    int changeType
)
final void
final void
int[]
onCreateDrawableState(int extraSpace)
void
boolean
boolean
boolean
onNestedFling(
    View target,
    float velocityX,
    float velocityY,
    boolean consumed
)
boolean
onNestedPreFling(View target, float velocityX, float velocityY)
boolean
onNestedPrePerformAccessibilityAction(
    View target,
    int action,
    Bundle args
)
void
onNestedPreScroll(View target, int dx, int dy, int[] consumed)
void
onNestedScroll(
    View target,
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed
)
void
onNestedScrollAccepted(View child, View target, int axes)
boolean
onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
boolean
PointerIcon
onResolvePointerIcon(MotionEvent event, int pointerIndex)
boolean
onStartNestedScroll(View child, View target, int nestedScrollAxes)
void
void
void
void
void
void
void
removeDetachedView(View child, boolean animate)
void
void
removeViewAt(int index)
void
void
removeViews(int start, int count)
void
removeViewsInLayout(int start, int count)
void
requestChildFocus(View child, View focused)
boolean
requestChildRectangleOnScreen(
    View child,
    Rect rectangle,
    boolean immediate
)
void
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
boolean
requestFocus(int direction, Rect previouslyFocusedRect)
boolean
void
boolean
void
void
setAddStatesFromChildren(boolean addsStates)
void

This method is deprecated.

void
setAnimationCacheEnabled(boolean enabled)

This method is deprecated.

void

This method is deprecated.

void
void

This method is deprecated.

void
setClipChildren(boolean clipChildren)
void
setClipToPadding(boolean clipToPadding)
void
setDescendantFocusability(int focusability)
void
void
void
setLayoutMode(int layoutMode)
void
void
void
void
setPersistentDrawingCache(int drawingCacheToKeep)

This method is deprecated.

void
void
setTouchscreenBlocksFocus(boolean touchscreenBlocksFocus)
void
setTransitionGroup(boolean isTransitionGroup)
void
boolean
ActionMode
startActionModeForChild(
    View originalView,
    ActionMode.Callback callback
)
void
void
void
suppressLayout(boolean suppress)
void

Constants

DEFAULT_REPEAT_TOGGLE_MODES

@RepeatModeUtil.RepeatToggleModes
public static final int DEFAULT_REPEAT_TOGGLE_MODES = 0

The default repeat toggle modes.

DEFAULT_SHOW_TIMEOUT_MS

public static final int DEFAULT_SHOW_TIMEOUT_MS = 5000

The default show timeout, in milliseconds.

DEFAULT_TIME_BAR_MIN_UPDATE_INTERVAL_MS

public static final int DEFAULT_TIME_BAR_MIN_UPDATE_INTERVAL_MS = 200

The default minimum interval between time bar position updates.

MAX_WINDOWS_FOR_MULTI_WINDOW_TIME_BAR

public static final int MAX_WINDOWS_FOR_MULTI_WINDOW_TIME_BAR = 100

The maximum number of windows that can be shown in a multi-window time bar.

Public fields

player

public @Nullable Player player

repeatToggleModes

@RepeatModeUtil.RepeatToggleModes
public int repeatToggleModes

showTimeoutMs

public int showTimeoutMs

Public constructors

PlayerControlView

public PlayerControlView(Context context)

PlayerControlView

public PlayerControlView(Context context, @Nullable AttributeSet attrs)

PlayerControlView

public PlayerControlView(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)

PlayerControlView

public PlayerControlView(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr,
    @Nullable AttributeSet playbackAttrs
)

Public methods

addVisibilityListener

public void addVisibilityListener(PlayerControlView.VisibilityListener listener)

dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent event)

dispatchMediaKeyEvent

public boolean dispatchMediaKeyEvent(KeyEvent event)

Called to process media key events. Any KeyEvent can be passed but only media key events will be handled.

Parameters
KeyEvent event

A key event.

Returns
boolean

Whether the key event was handled.

getPlayer

public @Nullable Player getPlayer()

Returns the Player currently being controlled by this view, or null if no player is set.

getRepeatToggleModes

@RepeatModeUtil.RepeatToggleModes
public int getRepeatToggleModes()

Returns which repeat toggle modes are enabled.

Returns
int

The currently enabled RepeatModeUtil.RepeatToggleModes.

getShowShuffleButton

public boolean getShowShuffleButton()

Returns whether the shuffle button is shown.

getShowSubtitleButton

public boolean getShowSubtitleButton()

Returns whether the subtitle button is shown.

getShowTimeoutMs

public int getShowTimeoutMs()

Returns the playback controls timeout. The playback controls are automatically hidden after this duration of time has elapsed without user input.

Returns
int

The duration in milliseconds. A non-positive value indicates that the controls will remain visible indefinitely.

getShowVrButton

public boolean getShowVrButton()

Returns whether the VR button is shown.

hide

public void hide()

Hides the controller.

hideImmediately

public void hideImmediately()

Hides the controller without any animation.

isAnimationEnabled

public boolean isAnimationEnabled()

Returns whether an animation is used to show and hide the playback controls.

isFullyVisible

public boolean isFullyVisible()

Returns whether the controller is fully visible, which means all UI controls are visible.

isVisible

public boolean isVisible()

Returns whether the controller is currently visible.

onAttachedToWindow

public void onAttachedToWindow()

onDetachedFromWindow

public void onDetachedFromWindow()

removeVisibilityListener

public void removeVisibilityListener(
    PlayerControlView.VisibilityListener listener
)

setAnimationEnabled

public void setAnimationEnabled(boolean animationEnabled)

Sets whether an animation is used to show and hide the playback controls.

Parameters
boolean animationEnabled

Whether an animation is applied to show and hide playback controls.

setExtraAdGroupMarkers

public void setExtraAdGroupMarkers(
    @Nullable long[] extraAdGroupTimesMs,
    @Nullable boolean[] extraPlayedAdGroups
)

Sets the millisecond positions of extra ad markers relative to the start of the window (or timeline, if in multi-window mode) and whether each extra ad has been played or not. The markers are shown in addition to any ad markers for ads in the player's timeline.

Parameters
@Nullable long[] extraAdGroupTimesMs

The millisecond timestamps of the extra ad markers to show, or null to show no extra ad markers.

@Nullable boolean[] extraPlayedAdGroups

Whether each ad has been played. Must be the same length as extraAdGroupTimesMs, or null if extraAdGroupTimesMs is null.

setOnFullScreenModeChangedListener

public void setOnFullScreenModeChangedListener(
    @Nullable PlayerControlView.OnFullScreenModeChangedListener listener
)

setPlayer

public void setPlayer(@Nullable Player player)

Sets the Player to control.

Parameters
@Nullable Player player

The Player to control, or null to detach the current player. Only players which are accessed on the main thread are supported ( player.getApplicationLooper() == Looper.getMainLooper()).

setProgressUpdateListener

public void setProgressUpdateListener(
    @Nullable PlayerControlView.ProgressUpdateListener listener
)

Sets the ProgressUpdateListener.

Parameters
@Nullable PlayerControlView.ProgressUpdateListener listener

The listener to be notified about when progress is updated.

setRepeatToggleModes

public void setRepeatToggleModes(
    @RepeatModeUtil.RepeatToggleModes int repeatToggleModes
)

Sets which repeat toggle modes are enabled.

Parameters
@RepeatModeUtil.RepeatToggleModes int repeatToggleModes

A set of RepeatModeUtil.RepeatToggleModes.

setShowFastForwardButton

public void setShowFastForwardButton(boolean showFastForwardButton)

Sets whether the fast forward button is shown.

Parameters
boolean showFastForwardButton

Whether the fast forward button is shown.

setShowMultiWindowTimeBar

public void setShowMultiWindowTimeBar(boolean showMultiWindowTimeBar)

setShowNextButton

public void setShowNextButton(boolean showNextButton)

Sets whether the next button is shown.

Parameters
boolean showNextButton

Whether the next button is shown.

setShowPlayButtonIfPlaybackIsSuppressed

public void setShowPlayButtonIfPlaybackIsSuppressed(
    boolean showPlayButtonIfSuppressed
)

Sets whether a play button is shown if playback is suppressed.

The default is true.

Parameters
boolean showPlayButtonIfSuppressed

Whether to show a play button if playback is suppressed.

setShowPreviousButton

public void setShowPreviousButton(boolean showPreviousButton)

Sets whether the previous button is shown.

Parameters
boolean showPreviousButton

Whether the previous button is shown.

setShowRewindButton

public void setShowRewindButton(boolean showRewindButton)

Sets whether the rewind button is shown.

Parameters
boolean showRewindButton

Whether the rewind button is shown.

setShowShuffleButton

public void setShowShuffleButton(boolean showShuffleButton)

Sets whether the shuffle button is shown.

Parameters
boolean showShuffleButton

Whether the shuffle button is shown.

setShowSubtitleButton

public void setShowSubtitleButton(boolean showSubtitleButton)

Sets whether the subtitle button is shown.

Parameters
boolean showSubtitleButton

Whether the subtitle button is shown.

setShowTimeoutMs

public void setShowTimeoutMs(int showTimeoutMs)

Sets the playback controls timeout. The playback controls are automatically hidden after this duration of time has elapsed without user input.

Parameters
int showTimeoutMs

The duration in milliseconds. A non-positive value will cause the controls to remain visible indefinitely.

setShowVrButton

public void setShowVrButton(boolean showVrButton)

Sets whether the VR button is shown.

Parameters
boolean showVrButton

Whether the VR button is shown.

setTimeBarMinUpdateInterval

public void setTimeBarMinUpdateInterval(int minUpdateIntervalMs)

Sets the minimum interval between time bar position updates.

Note that smaller intervals, e.g. 33ms, will result in a smooth movement but will use more CPU resources while the time bar is visible, whereas larger intervals, e.g. 200ms, will result in a step-wise update with less CPU usage.

Parameters
int minUpdateIntervalMs

The minimum interval between time bar position updates, in milliseconds.

setVrButtonListener

public void setVrButtonListener(@Nullable View.OnClickListener onClickListener)

Sets listener for the VR button.

Parameters
@Nullable View.OnClickListener onClickListener

Listener for the VR button, or null to clear the listener.

show

public void show()

Shows the playback controls. If getShowTimeoutMs is positive then the controls will be automatically hidden after this duration of time has elapsed without user input.

Protected methods

onLayout

protected void onLayout(boolean changed, int left, int top, int right, int bottom)