Class: shaka.media.MediaSourcePlayhead

Constructor

new MediaSourcePlayhead(mediaElementnon-null, manifest, config, startTimenullable, onSeek, onEvent)

Parameters:
Name Type Attributes Description
mediaElement HTMLMediaElement
manifest shaka.extern.Manifest
config shaka.extern.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 Called when an event is raised to be sent to the application.
Implements:
Source:

Members

(private, nullable) lastCorrectiveSeek_ :number

Type:
  • number
Source:

(private) mediaElement_ :HTMLMediaElement

Type:
Source:

(private) minBufferTime_ :number

Type:
  • number
Source:

(private) minSeekRange_ :number

The seek range must be at least this number of seconds long. 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 is 3s long, to account for the weaker hardware on platforms like Chromecast.
Type:
  • number
Source:

(private) 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.
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

(private) createStallDetector_(mediaElementnon-null, config) → {shaka.media.StallDetector}

Create and configure a stall detector using the player's streaming configuration settings. If the player is configured to have no stall detector, this will return |null|.
Parameters:
Name Type Description
mediaElement HTMLMediaElement
config shaka.extern.StreamingConfiguration
Source:
Returns:
Type
shaka.media.StallDetector

(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}

Get the current playhead position. The position will be restricted to valid time ranges.
Implements:
Source:
Returns:
Type
number

notifyOfBufferingChange()

Notify the playhead that the buffered ranges have changed.
Implements:
Source:

(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:

(export) release()

Request that this object release all internal references.
Inherited From:
Implements:
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

setStartTime(startTime)

Set the start time. If the content has already started playback, this will be ignored.
Parameters:
Name Type Description
startTime number
Implements:
Source: