DefaultTimeBar


@UnstableApi
public class DefaultTimeBar extends View implements TimeBar


A time bar that shows a current position, buffered position, duration and ad markers.

A DefaultTimeBar can be customized by setting attributes, as outlined below.

Attributes

The following attributes can be set on a DefaultTimeBar when used in a layout XML file:
  • bar_height - Dimension for the height of the time bar.
  • touch_target_height - Dimension for the height of the area in which touch interactions with the time bar are handled. If no height is specified, this also determines the height of the view.
  • ad_marker_width - Dimension for the width of any ad markers shown on the bar. Ad markers are superimposed on the time bar to show the times at which ads will play.
  • scrubber_enabled_size - Dimension for the diameter of the circular scrubber handle when scrubbing is enabled but not in progress. Set to zero if no scrubber handle should be shown.
  • scrubber_disabled_size - Dimension for the diameter of the circular scrubber handle when scrubbing isn't enabled. Set to zero if no scrubber handle should be shown.
  • scrubber_dragged_size - Dimension for the diameter of the circular scrubber handle when scrubbing is in progress. Set to zero if no scrubber handle should be shown.
  • scrubber_drawable - Optional reference to a drawable to draw for the scrubber handle. If set, this overrides the default behavior, which is to draw a circle for the scrubber handle.
  • played_color - Color for the portion of the time bar representing media before the current playback position.
  • scrubber_color - Color for the scrubber handle.
  • buffered_color - Color for the portion of the time bar after the current played position up to the current buffered position.
  • unplayed_color - Color for the portion of the time bar after the current buffered position.
  • ad_marker_color - Color for unplayed ad markers.
  • played_ad_marker_color - Color for played ad markers.

Summary

Constants

static final int

Vertical gravity for progress bar to be located at the bottom in the view.

static final int

Vertical gravity for progress bar to be located at the center in the view.

static final int

Default color for ad markers.

static final int

Default width for ad markers, in dp.

static final int

Default height for the time bar, in dp.

static final int

Default color for the buffered portion of the time bar.

static final int

Default color for played ad markers.

static final int

Default color for the played portion of the time bar.

static final int

Default color for the scrubber handle.

static final int

Default diameter for the scrubber when disabled, in dp.

static final int

Default diameter for the scrubber when dragged, in dp.

static final int

Default diameter for the scrubber when enabled, in dp.

static final int

Default height for the touch target, in dp.

static final int

Default color for the unplayed portion of the time bar.

Public constructors

DefaultTimeBar(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)
DefaultTimeBar(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr,
    @Nullable AttributeSet timebarAttrs
)
DefaultTimeBar(
    Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr,
    @Nullable AttributeSet timebarAttrs,
    int defStyleRes
)

Public methods

void

Adds a listener for scrubbing events.

long

Returns the preferred delay in milliseconds of media time after which the time bar position should be updated.

void
hideScrubber(boolean disableScrubberPadding)

Hides the scrubber handle.

void
hideScrubber(long hideAnimationDurationMs)

Hides the scrubber handle with animation.

void
void
onDraw(Canvas canvas)
void
void
boolean
onKeyDown(int keyCode, KeyEvent event)
void
onRtlPropertiesChanged(int layoutDirection)
boolean
boolean
void

Removes a listener for scrubbing events.

void
setAdGroupTimesMs(
    @Nullable long[] adGroupTimesMs,
    @Nullable boolean[] playedAdGroups,
    int adGroupCount
)

Sets the times of ad groups and whether each ad group has been played.

void
setAdMarkerColor(@ColorInt int adMarkerColor)

Sets the color for unplayed ad markers.

void
setBufferedColor(@ColorInt int bufferedColor)

Sets the color for the portion of the time bar after the current played position up to the current buffered position.

void
setBufferedPosition(long bufferedPosition)

Sets the buffered position.

void
setDuration(long duration)

Sets the duration.

void
setEnabled(boolean enabled)
void

Sets the position increment for key presses and accessibility actions, as a number of increments that divide the duration of the media.

void

Sets the position increment for key presses and accessibility actions, in milliseconds.

void
setPlayedAdMarkerColor(@ColorInt int playedAdMarkerColor)

Sets the color for played ad markers.

void
setPlayedColor(@ColorInt int playedColor)

Sets the color for the portion of the time bar representing media before the playback position.

void
setPosition(long position)

Sets the current position.

void
setScrubberColor(@ColorInt int scrubberColor)

Sets the color for the scrubber handle.

void
setUnplayedColor(@ColorInt int unplayedColor)

Sets the color for the portion of the time bar after the current played position.

void

Shows the scrubber handle.

void
showScrubber(long showAnimationDurationMs)

Shows the scrubber handle with animation.

Protected methods

void
void
onFocusChanged(
    boolean gainFocus,
    int direction,
    @Nullable Rect previouslyFocusedRect
)
void
onLayout(boolean changed, int left, int top, int right, int bottom)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)

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>

Inherited methods

From android.view.View
void
void
addExtraDataToAccessibilityNodeInfo(
    AccessibilityNodeInfo info,
    String extraDataKey,
    Bundle arguments
)
void
addFocusables(ArrayList<View> views, int direction)
void
void
void
void
void
ViewPropertyAnimator
void

This method is deprecated.

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
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
int
void
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

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