Constructor
new DashVideoSource(mpdUrl, interpretContentProtectionnullable, estimator, abrManager)
Creates a DashVideoSource.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
mpdUrl |
string | The MPD URL. | |
interpretContentProtection |
shaka.player.DashVideoSource.ContentProtectionCallback |
<nullable> |
A callback to interpret the ContentProtection elements in the MPD. |
estimator |
shaka.util.IBandwidthEstimator | ||
abrManager |
shaka.media.IAbrManager |
- Extends:
- Source:
Members
-
(private, non-null) captionsLang_ :Array.<string>
-
Type:
- Array.<string>
- Source:
-
(private, non-null) captionsMime_ :Array.<string>
-
Type:
- Array.<string>
- Source:
-
(private, non-null) captionsUrl_ :Array.<string>
-
Type:
- Array.<string>
- Source:
-
(private, nullable) interpretContentProtection_ :shaka.player.DashVideoSource.ContentProtectionCallback
-
Type:
- Source:
-
(private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>
-
Type:
- Inherited From:
- Source:
-
(private) mpdUrl_ :string
-
Type:
- string
- Source:
-
(private) networkCallback_ :shaka.util.FailoverUri.NetworkCallback
-
Type:
- Source:
-
(private) oldMpd_ :shaka.dash.mpd.Mpd
-
Type:
- Source:
-
(protected) parent :shaka.util.FakeEventTarget
-
Type:
- Inherited From:
- Source:
-
(private, non-null) streamConfig_ :Object.<string, *>
-
Type:
- Object.<string, *>
- Inherited From:
- Source:
Methods
-
addEventListener(type, listener, opt_capturingopt)
-
Add an event listener to this object.
Parameters:
Name Type Attributes Description typestring The event type to listen for. listenershaka.util.FakeEventTarget.ListenerType The callback or listener object to invoke. opt_capturingboolean <optional>
True to listen during the capturing phase, false to listen during the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model. - Inherited From:
- Source:
-
addExternalCaptions(url, opt_langopt, opt_mimeopt)
-
Adds the given URL as a source for text tracks in addition to those specified in the MPD. This has no effect after load().
Parameters:
Name Type Attributes Description urlstring The |url| of the file to load from. opt_langstring <optional>
Optional language of the text track, defaults to 'en'. opt_mimestring <optional>
Optional MIME type of the file, defaults to 'text/vtt'. - Source:
-
(private) applyRestrictions_()
-
Applies the video track restrictions, if any.
- Inherited From:
- Source:
-
attach()
-
- Inherited From:
- Source:
-
(private) beginPlayback_(segmentIndexesnon-null, timestampCorrection)
-
Corrects the MediaSource's duration and append windows, moves the playhead to the start of the first buffered range, and then starts playback by signalling each Stream to proceed.
Parameters:
Name Type Description segmentIndexesArray.<!shaka.media.SegmentIndex> The initial set of SegmentIndexes. timestampCorrectionnumber The global timestamp correction. - Inherited From:
- Source:
-
(private) cancelSeekRangeTimer_()
-
Cancels the seek range timer, if any.
- Inherited From:
- Source:
-
(private) cancelUpdateTimer_()
-
Cancels the update timer, if any.
- Inherited From:
- Source:
-
(private) clampPlayheadToLeft_(currentTime, end) → {boolean}
-
Clamps the video's current time to the left of the given end time (inclusive).
Parameters:
Name Type Description currentTimenumber The video's current time. endnumber The end time in seconds. - Inherited From:
- Source:
Returns:
True if the video's current was clamped, in which case a 'seeking' event will be fired by the video.- Type
- boolean
-
(private) clampPlayheadToRight_(currentTime, start, end) → {boolean}
-
Clamps the video's current time to the right of the given start time (inclusive).
Parameters:
Name Type Description currentTimenumber The video's current time. startnumber The start time in seconds. endnumber The end time in seconds, which must be provided to ensure that the playhead is not adjusted too far right. - Inherited From:
- Source:
Returns:
True if the video's current was clamped, in which case a 'seeking' event will be fired by the video.- Type
- boolean
-
(private) computeStreamLimits_(segmentIndexesnon-null) → (nullable) {?{start: number, end: number, last: number}}
-
Computes the stream limits, i.e., a stream start time and stream end time, of the given SegmentIndexes. The stream limits define the video's seekable range, so the video's current time should always be within the stream limits. The stream limits are a subset of each individual SegmentIndex's seek range; however, the converse is not true.
Parameters:
Name Type Description segmentIndexesArray.<!shaka.media.SegmentIndex> - Inherited From:
- Source:
Returns:
The stream limits on success; otherwise, return null if a stream end time could not be computed or the streams' media timelines do not intersect.- Type
- ?{start: number, end: number, last: number}
-
configure(confignon-null)
-
Configures the StreamVideoSource options.
The following configuration options are supported:-
enableAdaptation: boolean
Enables or disables automatic bitrate adaptation. -
streamBufferSize: number
Sets the maximum amount of content, in seconds, that audio and video streams will buffer ahead of the playhead. For DASH streams, this will be overridden if 'minBufferTime' is larger. -
mpdRequestTimeout: number
Sets the MPD request timeout in seconds. A value of zero indicates no timeout. -
segmentRequestTimeout: number
Sets the segment request timeout in seconds. A value of zero indicates no timeout. -
preferredLanguage: string
Sets the preferred language (the default is 'en'). -
restrictions: shaka.player.Restrictions
Sets the video track restrictions.
Parameters:
Name Type Description configObject.<string, *> A configuration object, which contains the configuration options as key-value pairs. All fields should have already been validated. - Inherited From:
- Source:
Example
streamVideoSouce.configure({'streamBufferSize': 20}); -
enableAdaptation: boolean
-
(private) configureStreams_()
-
Configures each Stream with |streamConfig_|
- Inherited From:
- Source:
-
(private) createAndStartStreams_() → (non-null) {Promise}
-
Instantiates the Streams and begins stream startup. Stream startup consists of starting a Stream for each available content type, waiting for each of these Streams to complete their initialization sequence (see shaka.media.IStream), applying the global timestamp correction, and then beginning playback. This function resolves the returned Promise when it instantiates and starts the initial set of Streams; at this time, each Stream (i.e., each Stream in this.streamsByType_) will be in the 'startup' state; however, actual playback will not have begun, and the video's playback rate should be zero. When each Stream completes startup we call shaka.player.StreamVideoSource#onAllStreamsStarted_; at this time, each Stream will be in the 'waiting' state.
- Inherited From:
- Source:
Returns:
A Promise that resolves when this function creates the initial set of Streams and begins stream startup. If the manifest specifies live content then this function will always resolve the returned Promise; otherwise, this function may reject the returned Promise.- Type
- Promise
-
(private) createStream_(streamInfonon-null) → (non-null) {shaka.media.Stream}
-
Creates a Stream object.
Parameters:
Name Type Description streamInfoshaka.media.StreamInfo - Inherited From:
- Source:
Returns:
- Type
- shaka.media.Stream
-
(private) createStreams_(streamInfosByTypenon-null) → {boolean}
-
Creates the initial set of Stream objects. Populates |streamsByType_| on success.
Parameters:
Name Type Description streamInfosByTypeObject.<string, !shaka.media.StreamInfo> - Inherited From:
- Source:
Returns:
True on success; otherwise, return false.- Type
- boolean
-
(private) createTextStream_() → (non-null) {shaka.media.TextStream}
-
Creates a TextStream object.
- Inherited From:
- Source:
Returns:
-
destroy()
-
- Overrides:
- Source:
-
dispatchEvent(eventnon-null) → {boolean}
-
Dispatch an event from this object.
Parameters:
Name Type Description eventEvent The event to be dispatched from this object. - Inherited From:
- Source:
Returns:
True if the default action was prevented.- Type
- boolean
-
enableTextTrack()
-
- Inherited From:
- Source:
-
(private) endOfStream_()
-
Signals the end of the video.
- Inherited From:
- Source:
-
(private) fireSeekRangeChangedEvent_(start, end)
-
Fires a 'seekrangechanged' event.
Parameters:
Name Type Description startnumber endnumber - Inherited From:
- Source:
-
(private) fireTracksChangedEvent_()
-
Fires a 'trackschanged' event.
- Inherited From:
- Source:
-
getAudioTracks()
-
- Inherited From:
- Source:
-
getBufferingGoal()
-
- Inherited From:
- Source:
-
getConfigurations()
-
- Inherited From:
- Source:
-
(private) getSegmentIndexes_() → (non-null) {Array.<!shaka.media.SegmentIndex>}
-
Gets the active Streams' SegmentIndexes.
- Inherited From:
- Source:
Returns:
- Type
- Array.<!shaka.media.SegmentIndex>
-
getSessionIds()
-
- Inherited From:
- Source:
-
getTextTracks()
-
- Inherited From:
- Source:
-
getVideoTracks()
-
- Inherited From:
- Source:
-
isLive()
-
- Inherited From:
- Source:
-
isOffline()
-
- Inherited From:
- Source:
-
load()
-
- Overrides:
- Source:
-
(private) onAllStreamsStarted_(timestampCorrectionsnon-null)
-
Called when each Stream has completed startup. Computes a global timestamp correction and immediately applies it to the initial set of SegmentIndexes and then begins playback. In parallel, creates/fetches all SegmentIndexes and fetches all initialization segments.
Parameters:
Name Type Description timestampCorrectionsArray.<number> The initial set of streams' timestamp corrections. - Inherited From:
- Source:
-
(private) onBandwidth_(eventnon-null)
-
Bandwidth statistics update callback.
Parameters:
Name Type Description eventEvent - Inherited From:
- Source:
-
(private) onBufferingEnd_(eventnon-null)
-
The buffering end event callback.
Parameters:
Name Type Description eventEvent - Inherited From:
- Source:
-
(private) onBufferingStart_(eventnon-null)
-
The buffering start event callback.
Parameters:
Name Type Description eventEvent - Inherited From:
- Source:
-
onKeyStatusesChange()
-
- Inherited From:
- Source:
-
(private) onMediaSourceOpen_(eventnon-null)
-
Called when the MediaSource transitions into the 'open' state. Only called after load() has been called.
Parameters:
Name Type Description eventEvent - Inherited From:
- Source:
-
(private) onSeeking_(eventnon-null)
-
Video seeking callback.
Parameters:
Name Type Description eventEvent - Inherited From:
- Source:
-
(private) onStreamEnded_(eventnon-null)
-
Stream ended callback.
Parameters:
Name Type Description eventEvent - Inherited From:
- Source:
-
onUpdateLocalManifest()
-
- Overrides:
- Source:
-
onUpdateManifest()
-
- Overrides:
- Source:
-
(private) onUpdateManifest_(useLocal)
-
Updates the manifest.
Parameters:
Name Type Description useLocalboolean Whether to update using the local manifest. - Inherited From:
- Source:
-
(private) onUpdateSeekRange_()
-
Computes a new seek range and fires a 'seekrangechanged' event. Also clamps the playhead to the seek start time during playback.
- Inherited From:
- Source:
-
(private) processDeferredSwitches_()
-
Processes all deferred switches.
- Inherited From:
- Source:
-
(private) recursiveDispatch_(eventnon-null) → {boolean}
-
Dispatches an event recursively without changing its original target.
Parameters:
Name Type Description eventEvent - Inherited From:
- Source:
Returns:
True if the default action was prevented.- Type
- boolean
-
removeEventListener(type, listener, opt_capturingopt)
-
Remove an event listener from this object.
Parameters:
Name Type Attributes Description typestring The event type for which you wish to remove a listener. listenershaka.util.FakeEventTarget.ListenerType The callback or listener object to remove. opt_capturingboolean <optional>
True to remove a listener for the capturing phase, false to remove a listener for the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model. - Inherited From:
- Source:
-
(private) removeStream_(streamInfonon-null)
-
Removes the given StreamInfo. Handles removing an active stream.
Parameters:
Name Type Description streamInfoshaka.media.StreamInfo - Inherited From:
- Source:
-
selectAudioTrack()
-
- Inherited From:
- Source:
-
selectConfigurations()
-
- Inherited From:
- Source:
-
(private) selectStreamInfos_(streamSetInfosnon-null) → (non-null) {Object.<string, !shaka.media.StreamInfo>}
-
Selects the initial StreamInfos from the given StreamSetsInfos.
Parameters:
Name Type Description streamSetInfosArray.<!shaka.media.StreamSetInfo> - Inherited From:
- Source:
Returns:
- Type
- Object.<string, !shaka.media.StreamInfo>
-
selectTextTrack()
-
- Inherited From:
- Source:
-
(private) selectTrack_(type, id, clearBuffer, opt_clearBufferOffsetopt) → {boolean}
-
Select a track by ID.
Parameters:
Name Type Attributes Description typestring The type of track to change, such as 'video', 'audio', or 'text'. idnumber The |uniqueId| field of the desired StreamInfo. clearBufferboolean opt_clearBufferOffsetnumber <optional>
if |clearBuffer| and |opt_clearBufferOffset| are truthy, clear the stream buffer from the offset (in front of video currentTime) to the end of the stream. - Inherited From:
- Source:
Returns:
True on success.- Type
- boolean
-
selectVideoTrack()
-
- Inherited From:
- Source:
-
setNetworkCallback(callbacknon-null)
-
Sets the callback used to modify each segment request's URL and headers.
Parameters:
Name Type Description callbackshaka.util.FailoverUri.NetworkCallback - Source:
-
setPlaybackStartTime()
-
- Inherited From:
- Source:
-
(private) setSeekRangeTimer_()
-
Sets the seek range timer.
- Inherited From:
- Source:
-
(private) setUpdateLocalManifest_()
-
Sets the update timer to updated the manifest using the local copy.
- Inherited From:
- Source:
-
(private) setUpdateTimer_(offset)
-
Sets the update timer. Does nothing if the manifest does not specify an update period.
Parameters:
Name Type Description offsetnumber An offset, in seconds, to apply to the manifest's update period. - Inherited From:
- Source:
-
(private) setUpMediaSource_(streamLimits)
-
Sets the MediaSource's duration and the SourceBuffers' append windows. Before calling this function, the MediaSource must be in the 'open' state. This function may be called any number of times.
Parameters:
Name Type Description streamLimits{start: number, end: number, last: number} The current stream limits. - Inherited From:
- Source:
-
(private) sortByLanguage_(streamSetsnon-null)
-
Move the best language match to the front of the array.
Parameters:
Name Type Description streamSetsArray.<!shaka.media.StreamSetInfo> - Inherited From:
- Source:
-
(private) startStreams_(streamInfosByTypenon-null, streamLimits)
-
Starts each Stream.
Parameters:
Name Type Description streamInfosByTypeObject.<string, !shaka.media.StreamInfo> streamLimits{start: number, end: number, last: number} The initial stream limits. - Inherited From:
- Source:
Type Definitions
-
ContentProtectionCallback
-
A callback to the application to interpret DASH ContentProtection elements. The first parameter is the scheme ID URI. The second parameter is the ContentProtection XML element. The callback should return an array of shaka.player.DrmInfo.Config objects. A return value of null or an empty array indicates that the ContentProtection XML element could not be understood by the application. An empty shaka.player.DrmInfo.Config object or one with an empty key system indicates that the content is unencrypted. Note: the 'cenc:pssh' element is automatically parsed by the library. So, if the MPD specifies an explicit PSSH then the application does not have to manually convert it into an initData value (see shaka.player.DrmInfo.Config).
Type:
- function(string, !Node): Array.<shaka.player.DrmInfo.Config>
- Source: