LegacyPlayerControlView


@UnstableApi
public class LegacyPlayerControlView extends FrameLayout


A view for controlling Player instances.

A LegacyPlayerControlView can be customized by setting attributes (or calling corresponding methods), overriding drawables, overriding the view's layout file, or by specifying a custom view layout file.

Attributes

The following attributes can be set on a LegacyPlayerControlView 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.
  • time_bar_min_update_interval - Specifies the minimum interval between time bar position updates.
  • controller_layout_id - Specifies the id of the layout to be inflated. See below for more details.
    • Corresponding method: None
    • Default: R.layout.exo_legacy_player_control_view
  • All attributes that can be set on DefaultTimeBar can also be set on a LegacyPlayerControlView, and will be propagated to the inflated DefaultTimeBar unless the layout is overridden to specify a custom exo_progress (see below).

Overriding drawables

The drawables used by LegacyPlayerControlView (with its default layout file) can be overridden by drawables with the same names defined in your application. The drawables that can be overridden are:
  • exo_legacy_controls_play - The play icon.
  • exo_legacy_controls_pause - The pause icon.
  • exo_legacy_controls_rewind - The rewind icon.
  • exo_legacy_controls_fastforward - The fast forward icon.
  • exo_legacy_controls_previous - The previous icon.
  • exo_legacy_controls_next - The next icon.
  • exo_legacy_controls_repeat_off - The repeat icon for REPEAT_MODE_OFF.
  • exo_legacy_controls_repeat_one - The repeat icon for REPEAT_MODE_ONE.
  • exo_legacy_controls_repeat_all - The repeat icon for REPEAT_MODE_ALL.
  • exo_legacy_controls_shuffle_off - The shuffle icon when shuffling is disabled.
  • exo_legacy_controls_shuffle_on - The shuffle icon when shuffling is enabled.
  • exo_legacy_controls_vr - The VR icon.

Overriding the layout file

To customize the layout of LegacyPlayerControlView throughout your app, or just for certain configurations, you can define exo_legacy_player_control_view.xml layout files in your application res/layout* directories. These layouts will override the one provided by the library, and will be inflated for use by LegacyPlayerControlView. The view identifies and binds its children by looking for the following ids:
  • exo_play - The play button.
  • exo_pause - The pause button.
  • exo_rew - The rewind button.
  • exo_ffwd - The fast forward button.
  • exo_prev - The previous button.
  • exo_next - The next button.
  • exo_repeat_toggle - The repeat toggle button.
    • Type: ImageView
    • Note: LegacyPlayerControlView will programmatically set the drawable on the repeat toggle button according to the player's current repeat mode. The drawables used are exo_legacy_controls_repeat_off, exo_legacy_controls_repeat_one and exo_legacy_controls_repeat_all. See the section above for information on overriding these drawables.
  • exo_shuffle - The shuffle button.
    • Type: ImageView
    • Note: LegacyPlayerControlView will programmatically set the drawable on the shuffle button according to the player's current repeat mode. The drawables used are exo_legacy_controls_shuffle_off and exo_legacy_controls_shuffle_on. See the section above for information on overriding these drawables.
  • exo_vr - The VR mode button.
  • exo_position - Text view displaying the current playback position.
  • exo_duration - Text view displaying the current media duration.
  • exo_progress_placeholder - A placeholder that's replaced with the inflated DefaultTimeBar. Ignored if an exo_progress view exists.
  • exo_progress - Time bar that's updated during playback and allows seeking. DefaultTimeBar attributes set on the LegacyPlayerControlView will not be automatically propagated through to this instance. If a view exists with this id, any exo_progress_placeholder view will be ignored.

All child views are optional and so can be omitted if not required, however where defined they must be of the expected type.

Specifying a custom layout file

Defining your own exo_legacy_player_control_view.xml is useful to customize the layout of LegacyPlayerControlView throughout your application. It's also possible to customize the layout for a single instance in a layout file. This is achieved by setting the controller_layout_id attribute on a LegacyPlayerControlView. This will cause the specified layout to be inflated instead of exo_legacy_player_control_view.xml for only the instance on which the attribute is set.

Summary

Nested types

Listener to be notified when progress has been updated.

Listener to be notified about changes of the visibility of the UI control.

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

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

Public methods

void

Adds a VisibilityListener.

boolean
boolean

Called to process media key events.

final boolean
@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.

int

Returns the playback controls timeout.

boolean

Returns whether the VR button is shown.

void

Hides the controller.

boolean

Returns whether the controller is currently visible.

void
void
void

Removes a VisibilityListener.

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

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
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.

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
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 float
static final float
static final float
static final float
static final float
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.