Display a seek scrub bar with the current playback time position

The PSDK supports seeking to a specific position (time) in live streams where the stream is either a sliding-window playlist or an event type and in VOD.

You can seek to a particular location in the stream.

Note:

Seeking in a live stream is allowed only for DVR.

  1. Wait for the PSDK to be in a valid status for seeking.

    Valid statuses are PREPARED, COMPLETED, PAUSED, and PLAYING. Being in a valid state ensures that the media resource has successfully loaded. If the player is not in a valid seekable status, attempting to call the following methods throws an IllegalStateException.

    For example, wait for the PSDK to call your callback for the MediaPlayerStatusChangeEvent.STATUS_CHANGED event with PREPARED status.

  2. Pass the requested seek position to the MediaPlayer.seek method as a parameter expressed in milliseconds.

    This moves the play head to a different position in the stream. Note that the requested seek position might not coincide with the actual computed position.

    function seek(position:Number):void;
  3. Wait for the PSDK to dispatch a SeekEvent.SEEK_END event, then retrieve the adjusted position with event.actualPosition.

    This is important because the actual start position after the seek could be different than the requested position. Various rules might apply, including:

    • Playback behavior is affected if a seek or other repositioning ends in the middle of an ad break or skips ad breaks.
    • If you seek close to a segment boundary, the seek position is adjusted to the beginning of the segment.
    • You can seek only in the asset’s seekable duration. For video on demand, that is from 0 through the asset's duration.
  4. Use the position information when displaying a seek scrub bar.
  5. Set up event listener callbacks for changes in the user’s seek activity.

    The seek operation is asynchronous, so the PSDK dispatches these events related to seeking:

    • SeekEvent.SEEK_BEGIN - Dispatchedto indicate that seek is starting.
    • SeekEvent.SEEK_END - Dispatched to indicate that seeking was successful.

    The media player might readjust the seek position provided by the user. Therefore, check the callback for SeekEvent.SEEK_POSITION_ADJUSTED, which notifies the application that the position has been adjusted. The adjusted position is provided through event.actualPosition.