com.brightcove.player.mediacontroller.buttons

## Class SeekButtonController

- java.lang.Object
- - com.brightcove.player.event.AbstractComponent
  - - com.brightcove.player.mediacontroller.buttons.AbstractButtonController
    - - com.brightcove.player.mediacontroller.buttons.SeekButtonController

- All Implemented Interfaces:
    AccessibilityListener, Component, ButtonController, RemoteControlKeyState
  Direct Known Subclasses:
    FastForwardButtonController, RewindButtonController

      public abstract class SeekButtonController
      extends AbstractButtonController

  Provides an abstract class that allows a subclass to either seek back or seek forward. You are required to implemented both, the `computeTargetSeekPosition(long, long)` and the `getDidSeekHandler()`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `SeekButtonController.HideSeekControlsHandler` Provides a handler for hiding the rewind button.
    `protected class` | `SeekButtonController.OnHoldHandler` Android Handler used to send `EventType.SEEKBAR_DRAGGING_PROGRESS` event when any of the Seek button is kept held, and `EventType.SEEKBAR_DRAGGING_STOP` event when the Seek button was released.
    `protected class` | `SeekButtonController.SeekConfigurationHandler` Provides a handler for configuring the SeekButtonController with custom values, which listen for `EventType.SEEK_CONTROLLER_CONFIGURATION` event.
    `protected class` | `SeekButtonController.SeekHandler` Provides a handler for dealing with a rewind operation, before the fact.
    `protected class` | `SeekButtonController.SeekOffsetHandler` Provides a handler for calculating the seekDefault offset based on the length of the video and the seekPercentage
    `protected class` | `SeekButtonController.ShowSeekControlsHandler` Provides a handler for hiding the rewind button.

    - ### Nested classes/interfaces inherited from class com.brightcove.player.mediacontroller.buttons.AbstractButtonController

      `AbstractButtonController.Visibility`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `DEFAULT_ON_HOLD_START_TIME`
    `protected static int` | `DEFAULT_ON_HOLD_UPDATE_FREQUENCY`
    `protected static int` | `DEFAULT_SEEK_PERCENTAGE`
    `protected static int` | `LIVE_OFFSET`
    `protected SeekButtonController.OnHoldHandler` | `onHoldHandler` Instance handler that reacts to control key inputs.
    `protected int` | `onHoldUpdateFrequency` The time in milliseconds, used to send the `EventType.SEEKBAR_DRAGGING_PROGRESS` event to update the Media Controller seek bar.
    `protected int` | `onHoldWaitTime` The time in milliseconds to be waited, for the key event to be considered a long press instead of a regular press.
    `protected int` | `seekDefault` Deprecated.
    `protected long` | `seekDefaultLong` The default amount of time (milliseconds) the seek button will skip.
    `protected int` | `seekPercentage` The percentage number used to calculate the seekDefault based on the video duration.
    `protected boolean` | `seekRelativeEnabled` If enabled, the `seekDefaultLong` will be set relative to the video duration and the `seekPercentage`.
    `protected int` | `seekStartPosition` Deprecated.
    `protected long` | `seekStartPositionLong` The start playhead position for the last seek operation.
    `protected int` | `seekTargetPosition` Deprecated.
    `protected long` | `seekTargetPositionLong` The target playhead position for the last seek operation.

    - ### Fields inherited from class com.brightcove.player.mediacontroller.buttons.AbstractButtonController

      `DEFAULT_AUDIO_TRACKS_BUTTON_ID, DEFAULT_CAPTIONS_BUTTON_ID, DEFAULT_FAST_FORWARD_BUTTON_ID, DEFAULT_FULL_SCREEN_BUTTON_ID, DEFAULT_LIVE_BUTTON_ID, DEFAULT_PLAY_BUTTON_ID, DEFAULT_REWIND_BUTTON_ID, DEFAULT_SEEK_BUTTON_ID, properties, stateList, videoView`

    - ### Fields inherited from class com.brightcove.player.event.AbstractComponent

      `eventEmitter, listenerTokens`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SeekButtonController(android.content.Context context, BaseVideoView videoView, android.view.View controlBar, int id, android.graphics.Typeface font, java.lang.String eventType)` Builds a button controller to handle the rewind button.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract int` | `computeTargetSeekPosition(int seekStartPosition, int offset)` Deprecated.
    `protected abstract long` | `computeTargetSeekPosition(long seekStartPosition, long offset)` Compute the target seek position based on the seekStartPosition and an offset.
    `protected abstract EventListener` | `getDidSeekHandler()` Gets the EventListener callback to trigger when the DID_SEEK_TO event is received.
    `int` | `getManagedState()` Implements a getter for the managed state.
    `int` | `getOnHoldUpdateFrequency()` Gets the on hold update frequency time in milliseconds, used to send the `EventType.SEEKBAR_DRAGGING_PROGRESS` event to update the Media Controller seek bar.
    `int` | `getOnHoldWaitTime()` Gets the on hold button wait time, which is the time in milliseconds to be waited, so that the key event is considered a long press instead of a regular press.
    `java.util.Map<java.lang.String,java.lang.Object>` | `getProperties()` Implements a getter to add the current playhead position to the payload when emitting a rewind event.
    `int` | `getSeekDefault()` Deprecated.
    `long` | `getSeekDefaultLong()` Gets default seek time.
    `int` | `getSeekPercentage()` Gets the seek percentage relative to video duration, used to set the `seekDefaultLong` The values are greater than 0 and lower than 100
    `int` | `getVisibilityState()` Gets the current visibility state.
    `protected boolean` | `handleSeekEvent(android.view.KeyEvent event)`
    `boolean` | `isSeekRelativeEnabled()` If enabled, the `seekDefaultLong` will be set relative to the video duration and the `seekPercentage`.
    `boolean` | `onDpadCenter(android.view.KeyEvent event)` On dpad center key actioned
    `void` | `setOnHoldUpdateFrequency(int onHoldUpdateFrequency)` Sets the on hold update frequency time in milliseconds, used to send the `EventType.SEEKBAR_DRAGGING_PROGRESS` event to update the Media Controller seek bar.
    `void` | `setOnHoldWaitTime(int onHoldWaitTime)` Sets the on hold button wait time, which is the time in milliseconds to be waited, so that the key event is considered a long press instead of a regular press.
    `void` | `setSeekDefault(int value)` Deprecated.
    `void` | `setSeekDefault(long value)` Sets the default seek time.
    `void` | `setSeekPercentage(int seekPercentage)` Sets the seek percentage relative to video duration, used to set the `seekDefaultLong` The values are greater than 0 and lower than 100
    `void` | `setSeekRelativeEnabled(boolean seekRelativeEnabled)` Enable or disable relative seeking.

    - ### Methods inherited from class com.brightcove.player.mediacontroller.buttons.AbstractButtonController

      `getButton, getEventEmitter, getFont, getId, getStateList, onAccessibilityStateChanged, onBack, onDpadDown, onDpadLeft, onDpadRight, onDpadUp, onFastForward, onHome, onMenu, onPause, onPlay, onPlayPause, onRewind, onSkipBackward, onSkipForward, setVisibility, syncStates`

    - ### Methods inherited from class com.brightcove.player.event.AbstractComponent

      `addListener, addOnceListener, removeListener, removeListeners`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.brightcove.player.mediacontroller.buttons.ButtonController

      `removeListeners`

- - ### Field Detail

    - #### LIVE_OFFSET

          protected static final int LIVE_OFFSET

      See Also:
        Constant Field Values

    - #### DEFAULT_SEEK_PERCENTAGE

          protected static final int DEFAULT_SEEK_PERCENTAGE

      See Also:
        Constant Field Values

    - #### DEFAULT_ON_HOLD_START_TIME

          protected static final int DEFAULT_ON_HOLD_START_TIME

      See Also:
        Constant Field Values

    - #### DEFAULT_ON_HOLD_UPDATE_FREQUENCY

          protected static final int DEFAULT_ON_HOLD_UPDATE_FREQUENCY

      See Also:
        Constant Field Values

    - #### seekDefault

          @Deprecated
          protected int seekDefault

      Deprecated.
      The default amount of time (milliseconds) the seek button will skip.

    - #### seekDefaultLong

          protected long seekDefaultLong

      The default amount of time (milliseconds) the seek button will skip.

    - #### seekStartPosition

          @Deprecated
          protected int seekStartPosition

      Deprecated.
      The start playhead position for the last seek operation.

    - #### seekStartPositionLong

          protected long seekStartPositionLong

      The start playhead position for the last seek operation.

    - #### seekTargetPosition

          @Deprecated
          protected int seekTargetPosition

      Deprecated.
      The target playhead position for the last seek operation.

    - #### seekTargetPositionLong

          protected long seekTargetPositionLong

      The target playhead position for the last seek operation.

    - #### seekRelativeEnabled

          protected boolean seekRelativeEnabled

      If enabled, the `seekDefaultLong` will be set relative to the video duration and the `seekPercentage`. `seekDefaultLong` is calculated on `EventType.VIDEO_DURATION_CHANGED` event.

    - #### seekPercentage

          protected int seekPercentage

      The percentage number used to calculate the seekDefault based on the video duration. Default value is `DEFAULT_SEEK_PERCENTAGE`.

    - #### onHoldWaitTime

          protected int onHoldWaitTime

      The time in milliseconds to be waited, for the key event to be considered a long press instead of a regular press. Default value is `DEFAULT_ON_HOLD_START_TIME`.

    - #### onHoldUpdateFrequency

          protected int onHoldUpdateFrequency

      The time in milliseconds, used to send the `EventType.SEEKBAR_DRAGGING_PROGRESS` event to update the Media Controller seek bar. Default value is `DEFAULT_ON_HOLD_UPDATE_FREQUENCY`.

    - #### onHoldHandler

          protected final SeekButtonController.OnHoldHandler onHoldHandler

      Instance handler that reacts to control key inputs.

  - ### Constructor Detail

    - #### SeekButtonController

          public SeekButtonController(@NonNull
                                      android.content.Context context,
                                      @NonNull
                                      BaseVideoView videoView,
                                      @NonNull
                                      android.view.View controlBar,
                                      int id,
                                      @Nullable
                                      android.graphics.Typeface font,
                                      java.lang.String eventType)

      Builds a button controller to handle the rewind button.
      Parameters:
        `context` - The Android application context.
        `videoView` - The SDK video view object parenting the control bar.
        `controlBar` - The button widget parent view.
        `font` - The, possibly null, typeface for the button.

  - ### Method Detail

    - #### getManagedState

          public int getManagedState()

      Implements a getter for the managed state.
      See Also:
        `ButtonController.getManagedState()`

    - #### getProperties

          public java.util.Map<java.lang.String,java.lang.Object> getProperties()

      Implements a getter to add the current playhead position to the payload when emitting a rewind event.
      Specified by:
        `getProperties` in interface `ButtonController`
      Overrides:
        `getProperties` in class `AbstractButtonController`
      See Also:
        `ButtonController.getProperties()`

    - #### getVisibilityState

          public int getVisibilityState()

      Gets the current visibility state. For the Rewind button, it is visible in non-live videos and when a DVR capability is detected with live videos.
      Specified by:
        `getVisibilityState` in interface `ButtonController`
      Overrides:
        `getVisibilityState` in class `AbstractButtonController`
      Returns:
        The expected visibility state, one of View.GONE, View.INVISIBLE or View.VISIBLE.
      See Also:
        `ButtonController.getVisibilityState()`

    - #### getSeekDefault

          @Deprecated
          public int getSeekDefault()

      Deprecated.
      Deprecated. Instead use {`getSeekDefaultLong()`}

    - #### getSeekDefaultLong

          public long getSeekDefaultLong()

      Gets default seek time.
      Returns:
        the seek time in milliseconds

    - #### setSeekDefault

          @Deprecated
          public void setSeekDefault(int value)

      Deprecated.
      Deprecated. Instead use {`setSeekDefault(long)`}

    - #### setSeekDefault

          public void setSeekDefault(long value)

      Sets the default seek time.
      Parameters:
        `value` - The number of milliseconds to seek.

    - #### isSeekRelativeEnabled

          public boolean isSeekRelativeEnabled()

      If enabled, the `seekDefaultLong` will be set relative to the video duration and the `seekPercentage`. `seekDefaultLong` is calculated on `EventType.VIDEO_DURATION_CHANGED` event.
      Returns:
        true if enabled

    - #### setSeekRelativeEnabled

          public void setSeekRelativeEnabled(boolean seekRelativeEnabled)

      Enable or disable relative seeking. If enabled, the `seekDefaultLong` will be set relative to the video duration and the `seekPercentage`. `seekDefaultLong` is calculated on `EventType.VIDEO_DURATION_CHANGED` event.
      Parameters:
        `seekRelativeEnabled` -

    - #### getSeekPercentage

          public int getSeekPercentage()

      Gets the seek percentage relative to video duration, used to set the `seekDefaultLong` The values are greater than 0 and lower than 100
      Returns:
        the seek percentage

    - #### setSeekPercentage

          public void setSeekPercentage(int seekPercentage)

      Sets the seek percentage relative to video duration, used to set the `seekDefaultLong` The values are greater than 0 and lower than 100
      Parameters:
        `seekPercentage` - the seek percentage

    - #### getOnHoldWaitTime

          public int getOnHoldWaitTime()

      Gets the on hold button wait time, which is the time in milliseconds to be waited, so that the key event is considered a long press instead of a regular press.
      Returns:
        the on hold start time

    - #### setOnHoldWaitTime

          public void setOnHoldWaitTime(int onHoldWaitTime)

      Sets the on hold button wait time, which is the time in milliseconds to be waited, so that the key event is considered a long press instead of a regular press.
      Parameters:
        `onHoldWaitTime` - the on hold start time

    - #### getOnHoldUpdateFrequency

          public int getOnHoldUpdateFrequency()

      Gets the on hold update frequency time in milliseconds, used to send the `EventType.SEEKBAR_DRAGGING_PROGRESS` event to update the Media Controller seek bar.
      Returns:
        the time in milliseconds

    - #### setOnHoldUpdateFrequency

          public void setOnHoldUpdateFrequency(int onHoldUpdateFrequency)

      Sets the on hold update frequency time in milliseconds, used to send the `EventType.SEEKBAR_DRAGGING_PROGRESS` event to update the Media Controller seek bar.
      Parameters:
        `onHoldUpdateFrequency` - the time in milliseconds

    - #### onDpadCenter

          public boolean onDpadCenter(android.view.KeyEvent event)

      Description copied from interface: `RemoteControlKeyState`
      On dpad center key actioned
      Specified by:
        `onDpadCenter` in interface `RemoteControlKeyState`
      Overrides:
        `onDpadCenter` in class `AbstractButtonController`
      Parameters:
        `event` - the android.view.KeyEvent
      Returns:
        true if the key event was handled, false otherwies.

    - #### handleSeekEvent

          protected boolean handleSeekEvent(android.view.KeyEvent event)

    - #### computeTargetSeekPosition

          @Deprecated
          protected abstract int computeTargetSeekPosition(int seekStartPosition,
                                                                       int offset)

      Deprecated.
      Compute the target seek position based on the seekStartPosition and an offset. The offset can be overridden by calling the `setSeekDefault(long)` The default offset for a Live video is `LIVE_OFFSET`
      Parameters:
        `seekStartPosition` - the seek start position
        `offset` - the amount of time in milliseconds to seek.
      Returns:
        the int position in the video to seek to.
      See Also:
        `setSeekDefault(long)`

    - #### computeTargetSeekPosition

          protected abstract long computeTargetSeekPosition(long seekStartPosition,
                                                            long offset)

      Compute the target seek position based on the seekStartPosition and an offset. The offset can be overridden by calling the `setSeekDefault(long)` The default offset for a Live video is `LIVE_OFFSET`
      Parameters:
        `seekStartPosition` - the seek start position
        `offset` - the amount of time in milliseconds to seek.
      Returns:
        the int position in the video to seek to.
      See Also:
        `setSeekDefault(long)`

    - #### getDidSeekHandler

          protected abstract EventListener getDidSeekHandler()

      Gets the EventListener callback to trigger when the DID_SEEK_TO event is received.
      Returns:
        EventListener who listens for DID_SEEK_TO