Display a seek scrub bar with the current playback position

TVSDK supports seeking to a specific position (time) where the stream is a sliding-window playlist, in video on demand (VOD) and live streams.


Seeking in a live stream is allowed only for DVR.

  1. Set up callbacks for seeking.

    Seeking is asynchronous, so TVSDK dispatches the following seek-related events:

    • MediaPlayerEvent.SEEK_BEGIN, where the seek starts.
    • MediaPlayerEvent.SEEK_END, where the seek is successful.
    • MediaPlayerEvent.OPERATION_FAILED, where the seek has failed.
  2. Wait for the player to be in a valid status for seeking.

    The valid statuses are PREPARED, COMPLETE, PAUSED, and PLAYING.

  3. Use the native SeekBar to set OnSeekBarChangeListener, which determines when the user is scrubbing.

  4. Pass the requested seek position (milliseconds) to the MediaPlayer.seek method.

    void seek(long position) throws MediaPlayerException;

    You can seek only in the asset’s seekable duration. For video on demand, that is from 0 through the asset’s duration.


    This step moves the play head to a new position in the stream, but the final computed position might differ from the specified seek position.

  5. Listen for MediaPlayerEvent.OPERATION_FAILED and take appropriate actions.

    This event passes the appropriate warning. Your application determines how to proceed, and the options include trying the seek again or continuing playback from the previous position.

  6. Wait for TVSDK to call the MediaPlayerEvent.SEEK_END callback.

  7. Retrieve the final adjusted play position using the callback’s position parameter.

    This is important because the actual start position after the seek can be different from the requested position. Rules, including playback behavior is affected if a seek or other repositioning ends in the middle of an ad break or skips ad breaks, might apply.

  8. Use the position information when displaying a seek scrub bar.

Seeking Example

In this example, the user scrubs the seek bar to seek to the desired position.

//Use the native SeekBar to set an OnSeekBarChangeListener to
// see when the user is scrubbing.
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
    public void onProgressChanged(SeekBar seekBar, int progress, boolean isFromUser) {
        if (isFromUser) {
            // Update the seek bar thumb with the position provided by the user.

    public void onStartTrackingTouch(SeekBar seekBar) {
        isSeeking = true;

    public void onStopTrackingTouch(SeekBar seekBar) {
        isSeeking = false;

        // Retrieve the playback range.
        TimeRange playbackRange = mediaPlayer.getPlaybackRange();

        // Make sure to seek inside the playback range.
        long seekPosition = Math.min(Math.round(seekBar.getProgress()),

        // Perform seek.
        seek(playbackRange.getBegin() + seekPosition);

On this page