Class DefaultTimeBar

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, TimeBar

    @Deprecated
    public class DefaultTimeBar
    extends View
    implements TimeBar
    Deprecated.
    com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    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.
    • Field Detail

      • DEFAULT_BAR_HEIGHT_DP

        public static final int DEFAULT_BAR_HEIGHT_DP
        Deprecated.
        Default height for the time bar, in dp.
        See Also:
        Constant Field Values
      • DEFAULT_TOUCH_TARGET_HEIGHT_DP

        public static final int DEFAULT_TOUCH_TARGET_HEIGHT_DP
        Deprecated.
        Default height for the touch target, in dp.
        See Also:
        Constant Field Values
      • DEFAULT_AD_MARKER_WIDTH_DP

        public static final int DEFAULT_AD_MARKER_WIDTH_DP
        Deprecated.
        Default width for ad markers, in dp.
        See Also:
        Constant Field Values
      • DEFAULT_SCRUBBER_ENABLED_SIZE_DP

        public static final int DEFAULT_SCRUBBER_ENABLED_SIZE_DP
        Deprecated.
        Default diameter for the scrubber when enabled, in dp.
        See Also:
        Constant Field Values
      • DEFAULT_SCRUBBER_DISABLED_SIZE_DP

        public static final int DEFAULT_SCRUBBER_DISABLED_SIZE_DP
        Deprecated.
        Default diameter for the scrubber when disabled, in dp.
        See Also:
        Constant Field Values
      • DEFAULT_SCRUBBER_DRAGGED_SIZE_DP

        public static final int DEFAULT_SCRUBBER_DRAGGED_SIZE_DP
        Deprecated.
        Default diameter for the scrubber when dragged, in dp.
        See Also:
        Constant Field Values
      • DEFAULT_PLAYED_COLOR

        public static final int DEFAULT_PLAYED_COLOR
        Deprecated.
        Default color for the played portion of the time bar.
        See Also:
        Constant Field Values
      • DEFAULT_UNPLAYED_COLOR

        public static final int DEFAULT_UNPLAYED_COLOR
        Deprecated.
        Default color for the unplayed portion of the time bar.
        See Also:
        Constant Field Values
      • DEFAULT_BUFFERED_COLOR

        public static final int DEFAULT_BUFFERED_COLOR
        Deprecated.
        Default color for the buffered portion of the time bar.
        See Also:
        Constant Field Values
      • DEFAULT_SCRUBBER_COLOR

        public static final int DEFAULT_SCRUBBER_COLOR
        Deprecated.
        Default color for the scrubber handle.
        See Also:
        Constant Field Values
      • DEFAULT_AD_MARKER_COLOR

        public static final int DEFAULT_AD_MARKER_COLOR
        Deprecated.
        Default color for ad markers.
        See Also:
        Constant Field Values
      • DEFAULT_PLAYED_AD_MARKER_COLOR

        public static final int DEFAULT_PLAYED_AD_MARKER_COLOR
        Deprecated.
        Default color for played ad markers.
        See Also:
        Constant Field Values
      • BAR_GRAVITY_CENTER

        public static final int BAR_GRAVITY_CENTER
        Deprecated.
        Vertical gravity for progress bar to be located at the center in the view.
        See Also:
        Constant Field Values
      • BAR_GRAVITY_BOTTOM

        public static final int BAR_GRAVITY_BOTTOM
        Deprecated.
        Vertical gravity for progress bar to be located at the bottom in the view.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultTimeBar

        public DefaultTimeBar​(Context context)
        Deprecated.
      • DefaultTimeBar

        public DefaultTimeBar​(Context context,
                              @Nullable
                              AttributeSet attrs)
        Deprecated.
      • DefaultTimeBar

        public DefaultTimeBar​(Context context,
                              @Nullable
                              AttributeSet attrs,
                              int defStyleAttr)
        Deprecated.
      • DefaultTimeBar

        public DefaultTimeBar​(Context context,
                              @Nullable
                              AttributeSet attrs,
                              int defStyleAttr,
                              @Nullable
                              AttributeSet timebarAttrs)
        Deprecated.
      • DefaultTimeBar

        public DefaultTimeBar​(Context context,
                              @Nullable
                              AttributeSet attrs,
                              int defStyleAttr,
                              @Nullable
                              AttributeSet timebarAttrs,
                              int defStyleRes)
        Deprecated.
    • Method Detail

      • showScrubber

        public void showScrubber()
        Deprecated.
        Shows the scrubber handle.
      • showScrubber

        public void showScrubber​(long showAnimationDurationMs)
        Deprecated.
        Shows the scrubber handle with animation.
        Parameters:
        showAnimationDurationMs - The duration for scrubber showing animation.
      • hideScrubber

        public void hideScrubber​(boolean disableScrubberPadding)
        Deprecated.
        Hides the scrubber handle.
      • hideScrubber

        public void hideScrubber​(long hideAnimationDurationMs)
        Deprecated.
        Hides the scrubber handle with animation.
        Parameters:
        hideAnimationDurationMs - The duration for scrubber hiding animation.
      • setPlayedColor

        public void setPlayedColor​(@ColorInt
                                   int playedColor)
        Deprecated.
        Sets the color for the portion of the time bar representing media before the playback position.
        Parameters:
        playedColor - The color for the portion of the time bar representing media before the playback position.
      • setScrubberColor

        public void setScrubberColor​(@ColorInt
                                     int scrubberColor)
        Deprecated.
        Sets the color for the scrubber handle.
        Parameters:
        scrubberColor - The color for the scrubber handle.
      • setBufferedColor

        public void setBufferedColor​(@ColorInt
                                     int bufferedColor)
        Deprecated.
        Sets the color for the portion of the time bar after the current played position up to the current buffered position.
        Parameters:
        bufferedColor - The color for the portion of the time bar after the current played position up to the current buffered position.
      • setUnplayedColor

        public void setUnplayedColor​(@ColorInt
                                     int unplayedColor)
        Deprecated.
        Sets the color for the portion of the time bar after the current played position.
        Parameters:
        unplayedColor - The color for the portion of the time bar after the current played position.
      • setAdMarkerColor

        public void setAdMarkerColor​(@ColorInt
                                     int adMarkerColor)
        Deprecated.
        Sets the color for unplayed ad markers.
        Parameters:
        adMarkerColor - The color for unplayed ad markers.
      • setPlayedAdMarkerColor

        public void setPlayedAdMarkerColor​(@ColorInt
                                           int playedAdMarkerColor)
        Deprecated.
        Sets the color for played ad markers.
        Parameters:
        playedAdMarkerColor - The color for played ad markers.
      • addListener

        public void addListener​(TimeBar.OnScrubListener listener)
        Deprecated.
        Description copied from interface: TimeBar
        Adds a listener for scrubbing events.
        Specified by:
        addListener in interface TimeBar
        Parameters:
        listener - The listener to add.
      • removeListener

        public void removeListener​(TimeBar.OnScrubListener listener)
        Deprecated.
        Description copied from interface: TimeBar
        Removes a listener for scrubbing events.
        Specified by:
        removeListener in interface TimeBar
        Parameters:
        listener - The listener to remove.
      • setKeyTimeIncrement

        public void setKeyTimeIncrement​(long time)
        Deprecated.
        Description copied from interface: TimeBar
        Sets the position increment for key presses and accessibility actions, in milliseconds.

        Clears any increment specified in a preceding call to TimeBar.setKeyCountIncrement(int).

        Specified by:
        setKeyTimeIncrement in interface TimeBar
        Parameters:
        time - The time increment, in milliseconds.
      • setKeyCountIncrement

        public void setKeyCountIncrement​(int count)
        Deprecated.
        Description copied from interface: TimeBar
        Sets the position increment for key presses and accessibility actions, as a number of increments that divide the duration of the media. For example, passing 20 will cause key presses to increment/decrement the position by 1/20th of the duration (if known).

        Clears any increment specified in a preceding call to TimeBar.setKeyTimeIncrement(long).

        Specified by:
        setKeyCountIncrement in interface TimeBar
        Parameters:
        count - The number of increments that divide the duration of the media.
      • setPosition

        public void setPosition​(long position)
        Deprecated.
        Description copied from interface: TimeBar
        Sets the current position.
        Specified by:
        setPosition in interface TimeBar
        Parameters:
        position - The current position to show, in milliseconds.
      • setBufferedPosition

        public void setBufferedPosition​(long bufferedPosition)
        Deprecated.
        Description copied from interface: TimeBar
        Sets the buffered position.
        Specified by:
        setBufferedPosition in interface TimeBar
        Parameters:
        bufferedPosition - The current buffered position to show, in milliseconds.
      • setDuration

        public void setDuration​(long duration)
        Deprecated.
        Description copied from interface: TimeBar
        Sets the duration.
        Specified by:
        setDuration in interface TimeBar
        Parameters:
        duration - The duration to show, in milliseconds.
      • getPreferredUpdateDelay

        public long getPreferredUpdateDelay()
        Deprecated.
        Description copied from interface: TimeBar
        Returns the preferred delay in milliseconds of media time after which the time bar position should be updated.
        Specified by:
        getPreferredUpdateDelay in interface TimeBar
        Returns:
        Preferred delay, in milliseconds of media time.
      • setAdGroupTimesMs

        public void setAdGroupTimesMs​(@Nullable
                                      long[] adGroupTimesMs,
                                      @Nullable
                                      boolean[] playedAdGroups,
                                      int adGroupCount)
        Deprecated.
        Description copied from interface: TimeBar
        Sets the times of ad groups and whether each ad group has been played.
        Specified by:
        setAdGroupTimesMs in interface TimeBar
        Parameters:
        adGroupTimesMs - An array where the first adGroupCount elements are the times of ad groups in milliseconds. May be null if there are no ad groups.
        playedAdGroups - An array where the first adGroupCount elements indicate whether the corresponding ad groups have been played. May be null if there are no ad groups.
        adGroupCount - The number of ad groups.
      • onDraw

        public void onDraw​(Canvas canvas)
        Deprecated.
        Overrides:
        onDraw in class View
      • onFocusChanged

        protected void onFocusChanged​(boolean gainFocus,
                                      int direction,
                                      @Nullable
                                      Rect previouslyFocusedRect)
        Deprecated.
        Overrides:
        onFocusChanged in class View
      • drawableStateChanged

        protected void drawableStateChanged()
        Deprecated.
        Overrides:
        drawableStateChanged in class View
      • onMeasure

        protected void onMeasure​(int widthMeasureSpec,
                                 int heightMeasureSpec)
        Deprecated.
        Overrides:
        onMeasure in class View
      • onLayout

        protected void onLayout​(boolean changed,
                                int left,
                                int top,
                                int right,
                                int bottom)
        Deprecated.
        Overrides:
        onLayout in class View
      • onRtlPropertiesChanged

        public void onRtlPropertiesChanged​(int layoutDirection)
        Deprecated.
        Overrides:
        onRtlPropertiesChanged in class View