Package com.castlabs.android.player

# Interface InitialPositionProvider

public interface InitialPositionProvider
Callback to define an initial playing position right after the `Timeline` is ready. This allows for runtime decision of the starting playback position, before the Player starts buffering the media. Note that setting an InitialPositionProvider will override any starting position set in the `PlayerConfig` passed to the `PlayerController.open(PlayerConfig)` method.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `DEFAULT_POSITION`
  The default initial position.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getInitialPositionUs(Timeline timeline)`
  Return the desired initial position in microseconds.
  `default boolean`
  `snapToSegmentStart()`
  Determines whether the player should snap to the previous sync point.

- ## Field Details

  - ### DEFAULT_POSITION

    static final long DEFAULT_POSITION
    The default initial position.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### getInitialPositionUs

    long getInitialPositionUs(Timeline timeline)
    Return the desired initial position in microseconds. If the default should be used, return `DEFAULT_POSITION`. For DASH live streams, it is `LiveConfiguration.liveEdgeLatencyMs` milliseconds away from the Live edge. For progressive streams (such as mp4 files), the timeline information will not be complete, but the returned position will still be taken into account. Note that this method will be invoked on the Player's media loader thread, and any delays introduced here will directly impact startup time. The returned position must be relative to the first `Timeline.Window` of the Timeline.
    Parameters:
      `timeline` - the computed `Timeline`.
    Returns:
      the desired initial position in microseconds or `DEFAULT_POSITION`.

  - ### snapToSegmentStart

    default boolean snapToSegmentStart()
    Determines whether the player should snap to the previous sync point. This is used to ensure proper segment alignment in streaming playback.
    Returns:
      `true` if the player should snap to the previous sync point