Class: shaka.media.Playhead

Constructor

new Playhead(video, timelinenon-null, rebufferingGoal, startTimenullable, onBuffering, onSeek)

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
timeline shaka.media.PresentationTimeline
rebufferingGoal number
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.
onBuffering function(boolean) Called and passed true when stopped for buffering; called and passed false when proceeding after buffering. If passed true, the callback should not set the video's playback rate.
onSeek function() Called when the user agent seeks to a time within the presentation timeline.
Implements:
Source:

Members

(private) buffering_ :boolean

Type:
  • boolean
Source:

(private) eventManager_ :shaka.util.EventManager

Type:
Source:

(private) lastPlaybackRate_ :number

Type:
  • number
Source:

(private, nullable) onBuffering_ :?function(boolean)

Type:
  • ?function(boolean)
Source:

(private, nullable) onSeek_ :?function()

Type:
  • ?function()
Source:

(private) rebufferingGoal_ :number

Type:
  • number
Source:

(private, constant) startTime_ :number

The playhead's initial position in seconds.
Type:
  • number
Source:

(private) timeline_ :shaka.media.PresentationTimeline

Type:
Source:

(private) video_ :HTMLMediaElement

Type:
  • HTMLMediaElement
Source:

Methods

(private) clampTime_(time) → {number}

Clamps the given time to the segment availability window.
Parameters:
Name Type Description
time number The time in seconds.
Source:
Returns:
The clamped time in seconds.
Type
number

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

getTime() → {number}

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

(private) onLoadedMetadata_()

Handles a 'loadedmetadata' event.
Source:

(private) onSeeking_()

Handles a 'seeking' event.
Source:

(private) reposition_(currentTime) → {number}

Computes a time to reposition the playhead to after a seek.
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:

setRebufferingGoal(rebufferingGoal)

Parameters:
Name Type Description
rebufferingGoal number
Source: