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. Note that PlayerControlView is not intended to be used a standalone component outside of PlayerView.

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.

void
updateIsFullscreen(boolean isFullscreen)

Updates whether the controller is in fullscreen, changing its fullscreen icon and reports it to to the listener.

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