Class: shaka.media.Playhead

Constructor

new Playhead(videonon-null, manifest, config, startTimenullable, onSeek, onEvent)

Creates a Playhead, which manages the video's current time. The Playhead provides mechanisms for setting the presentation's start time, restricting seeking to valid time ranges, and stopping playback for startup and re- buffering.
Parameters:
Name Type Attributes Description
video HTMLMediaElement
manifest shakaExtern.Manifest
config shakaExtern.StreamingConfiguration
startTime number <nullable>
The playhead's initial position in seconds. If null, defaults to the start of the presentation for VOD and the live-edge for live.
onSeek function() Called when the user agent seeks to a time within the presentation timeline.
onEvent function(!Event) Called when an event is raised to be sent to the application.
Implements:
Source:

Members

(private, static, constant) MIN_SEEK_RANGE_ :number

This is the minimum size (in seconds) that the seek range can be. If it is smaller than this, change it to be this big so we don't repeatedly seek to keep within a zero-width window. This has been increased to 3s long, to account for the weaker hardware on Chromecasts.
Type:
  • number
Source:

(private, nullable) checkWindowTimer_ :shaka.util.Timer

Type:
Source:

(private, nullable) lastCorrectiveSeek_ :number

Type:
  • number
Source:

(private, nullable) manifest_ :shakaExtern.Manifest

Type:
Source:

(private, nullable) onSeek_ :?function()

Type:
  • ?function()
Source:

Methods

(private) clampSeekToDuration_(time) → {number}

Clamp seek times and playback start times so that we never seek to the presentation duration. Seeking to or starting at duration does not work consistently across browsers. TODO: Clean up and simplify Playhead. There are too many layers of, methods for, and conditions on timestamp adjustment.
Parameters:
Name Type Description
time number
Source:
See:
Returns:
The adjusted seek time.
Type
number

(private) clampTime_(time) → {number}

Clamps the given time to the seek range.
Parameters:
Name Type Description
time number The time in seconds.
Source:
Returns:
The clamped time in seconds.
Type
number

(export) destroy() → (non-null) {Promise}

Destroys the object, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected.
Implements:
Source:
Returns:
Type
Promise

getPlaybackRate() → {number}

Gets the current effective playback rate. This may be negative even if the browser does not directly support rewinding.
Source:
Returns:
Type
number

(private) getStartTime_(startTimenullable) → {number}

Gets the playhead's initial position in seconds.
Parameters:
Name Type Attributes Description
startTime number <nullable>
Source:
Returns:
Type
number

getTime() → {number}

Gets the playhead's current (logical) position.
Source:
Returns:
Type
number

(private) onPollWindow_()

Called on a recurring timer to keep the playhead from falling outside the availability window.
Source:

(private) onSeeking_()

Handles when a seek happens on the video.
Source:

onSegmentAppended()

Called when a segment is appended by StreamingEngine, but not when a clear is pending. This means StreamingEngine will continue buffering forward from what is buffered. So we know about any gaps before the start.
Source:

(private) reposition_(currentTime) → {number}

Computes a new playhead position that's within the presentation timeline.
Parameters:
Name Type Description
currentTime number
Source:
Returns:
The time to reposition the playhead to.
Type
number

setBuffering(buffering)

Stops the playhead for buffering, or resumes the playhead after buffering.
Parameters:
Name Type Description
buffering boolean True to stop the playhead; false to allow it to continue.
Source:

setPlaybackRate(rate)

Sets the playback rate.
Parameters:
Name Type Description
rate number
Source:

setStartTime(startTime)

Adjust the start time. Used by Player to implement the streaming.startAtSegmentBoundary configuration.
Parameters:
Name Type Description
startTime number
Source: