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, nullable) onBuffering_ :?function(boolean)
-
Type:
- ?function(boolean)
- Source:
-
(private, nullable) onSeek_ :?function()
-
Type:
- ?function()
- Source:
-
(private) playbackRate_ :number
-
Type:
- number
- Source:
-
(private) rebufferingGoal_ :number
-
Type:
- number
- Source:
-
(private, constant, nullable) startTime_ :number
-
The playhead's initial position in seconds, or null if it should automatically be calculated later.
Type:
- number
- Source:
-
(private) timeline_ :shaka.media.PresentationTimeline
-
Type:
- Source:
-
(private, nullable) trickPlayIntervalId_ :number
-
Type:
- number
- 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
-
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_() → {number}
-
Gets the playhead's initial position in seconds.
- Source:
Returns:
- Type
- number
-
getTime() → {number}
-
Gets the playhead's current (logical) position.
- Source:
Returns:
- Type
- number
-
(private) movePlayhead_(currentTime, targetTime)
-
Moves the playhead to the target time, triggering a call to onSeeking_().
Parameters:
Name Type Description currentTime
number targetTime
number - Source:
-
(private) onLoadedMetadata_()
-
Handles a 'loadedmetadata' event.
- Source:
-
(private) onPlaying_()
-
Handles a 'playing' event.
- Source:
-
(private) onRateChange_()
-
Handles a 'ratechange' event.
- Source:
-
(private) onSeeking_()
-
Handles a 'seeking' event.
- Source:
-
(private) onSeekingToStartTime_()
-
Handles the 'seeking' event from the initial jump to the start time (if there is one).
- 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:
-
setRebufferingGoal(rebufferingGoal)
-
Parameters:
Name Type Description rebufferingGoal
number - Source: