Constructor
new StreamVideoSource(manifestInfo, estimatornon-null, abrManagernon-null)
        Creates a StreamVideoSource.
The new StreamVideoSource takes ownership of |manifestInfo|.
    
    
    
    
    
    
        Parameters:
| Name | Type | Description | 
|---|---|---|
| manifestInfo | shaka.media.ManifestInfo | |
| estimator | shaka.util.IBandwidthEstimator | |
| abrManager | shaka.media.IAbrManager | 
- Implements:
- Extends:
- Source:
Fires:
Listens to Events:
- shaka.media.Stream.event:EndedEvent
- shaka.media.Stream.event:StartedEvent
- shaka.util.IBandwidthEstimator.event:BandwidthEvent
Members
- 
    (private, static, constant) MIN_UPDATE_PERIOD_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private, static, constant) SEEK_OFFSET_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private, static, constant) SEEK_TOLERANCE_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private, non-null) abrManager_ :shaka.media.IAbrManager
- 
    
    
        Type:- Source:
 
- 
    (private, non-null) attachPromise_ :shaka.util.PublicPromise
- 
    
    
        Type:- Source:
 
- 
    (private) canSwitch_ :boolean
- 
    
    
        Type:- boolean
 - Source:
 
- 
    (private, non-null) deferredSwitches_ :Object.<string, {streamInfo: !shaka.media.StreamInfo, clearBuffer: boolean, clearBufferOffset: (number|undefined)}>
- 
    
    
        Type:- Object.<string, {streamInfo: !shaka.media.StreamInfo, clearBuffer: boolean, clearBufferOffset: (number|undefined)}>
 - Source:
 
- 
    (protected, non-null) estimator :shaka.util.IBandwidthEstimator
- 
    
    
        Type:- Source:
 
- 
    (protected, non-null) eventManager :shaka.util.EventManager
- 
    
    
        Type:- Source:
 
- 
    (private, nullable) ignoreSeek_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private) jumpToLive_ :boolean
- 
    
    
        Type:- boolean
 - Source:
 
- 
    (private) lang_ :string
- 
    
    
        Type:- string
 - Source:
 
- 
    (private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>
- 
    
    
        Type:- Inherited From:
- Source:
 
- 
    (private, nullable) liveEndedTimer_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private) liveEndTime_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private) liveStreamEndTimeout_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private) loaded_ :boolean
- 
    
    
        Type:- boolean
 - Source:
 
- 
    (protected) manifestInfo :shaka.media.ManifestInfo
- 
    
    
        Type:- Source:
 
- 
    (protected, non-null) mediaSource :MediaSource
- 
    
    
        Type:- MediaSource
 - Source:
 
- 
    (protected) mpdRequestTimeout :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private) originalPlaybackRate_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (protected) parent :shaka.util.FakeEventTarget
- 
    
    
        Type:- Inherited From:
- Source:
 
- 
    (private, nullable) playbackStartTime_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private, non-null) proceedPromise_ :shaka.util.PublicPromise
- 
    
    
        Type:- Source:
 
- 
    (private, non-null) restrictions_ :shaka.player.Restrictions
- 
    
    
        Type:- Source:
 
- 
    (private, nullable) seekRangeTimer_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (private) stats_ :shaka.player.Stats
- 
    
    
        Type:- Source:
 
- 
    (private, non-null) streamConfig_ :Object.<string, *>
- 
    
    
        Type:- Object.<string, *>
 - Source:
 
- 
    (private, non-null) streamsByType_ :Object.<string, !shaka.media.IStream>
- 
    
    
        Type:- Object.<string, !shaka.media.IStream>
 - Source:
 
- 
    (protected, non-null) streamSetsByType :shaka.util.MultiMap.<!shaka.media.StreamSetInfo>
- 
    
    All usable StreamSetInfos from the manifest. Each StreamInfo contained within is mutually compatible with all other StreamInfos of the same type. Populated in selectConfigurations().Type:- Source:
 
- 
    (private) subsNeeded_ :boolean
- 
    
    
        Type:- boolean
 - Source:
 
- 
    (private, nullable) updateTimer_ :number
- 
    
    
        Type:- number
 - Source:
 
- 
    (protected) video :HTMLVideoElement
- 
    
    
        Type:- HTMLVideoElement
 - 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:
 
- 
    
        
            
            (private) applyRestrictions_()
- 
    
    Applies the video track restrictions, if any.- Source:
 
- 
    
        
            
            attach(player, videonon-null) → (non-null) {Promise}
- 
    
    Attaches the video source to the specified video element. This allows the Player to avoid setting the video's |src| attribute until it is ready. Should not be called until load() has been resolved. Should only be called once.Parameters:Name Type Description playershaka.player.Player The associated Player, which may be used for event bubbling and stats. videoHTMLVideoElement The video element. - Implements:
- Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            (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. - Source:
 
- 
    
        
            
            (private) cancelSeekRangeTimer_()
- 
    
    Cancels the seek range timer, if any.- Source:
 
- 
    
        
            
            (private) cancelUpdateTimer_()
- 
    
    Cancels the update timer, if any.- 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. - 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. - 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> - 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. - Implements:
- Source:
 ExamplestreamVideoSouce.configure({'streamBufferSize': 20});
- 
  enableAdaptation: boolean 
- 
    
        
            
            (private) configureStreams_()
- 
    
    Configures each Stream with |streamConfig_|- 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.- 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 - 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> - Source:
 Returns:True on success; otherwise, return false.- Type
- boolean
 
- 
    
        
            
            (private) createTextStream_() → (non-null) {shaka.media.TextStream}
- 
    
    Creates a TextStream object.- Source:
 Returns:
- 
    
        
            
            destroy()
- 
    
    Destroys the video source.- Implements:
- 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(enabled)
- 
    
    Enable or disable the text track. Has no effect if called before load() resolves.Parameters:Name Type Description enabledboolean - Implements:
- Source:
 
- 
    
        
            
            (private) endOfStream_()
- 
    
    Signals the end of the video.- Source:
 
- 
    
        
            
            (private) fireSeekRangeChangedEvent_(start, end)
- 
    
    Fires a 'seekrangechanged' event.Parameters:Name Type Description startnumber endnumber - Source:
 
- 
    
        
            
            (private) fireTracksChangedEvent_()
- 
    
    Fires a 'trackschanged' event.- Source:
 
- 
    
        
            
            getAudioTracks() → (non-null) {Array.<!shaka.player.AudioTrack>}
- 
    
    Gets the available audio tracks.- Implements:
- Source:
 Returns:- Type
- Array.<!shaka.player.AudioTrack>
 
- 
    
        
            
            getBufferingGoal() → {number}
- 
    
    Gets the video source's buffering goal, which is the amount of content, in seconds, that the video source requires to be buffered for smooth playback.- Implements:
- Source:
 Returns:The buffering goal.- Type
- number
 
- 
    
        
            
            getConfigurations() → (non-null) {Array.<!shaka.media.StreamConfig>}
- 
    
    Get a list of configurations supported by the video source. Should not be called before load() resolves.- Implements:
- Source:
 Returns:A non-empty array.- Type
- Array.<!shaka.media.StreamConfig>
 
- 
    
        
            
            (private) getSegmentIndexes_() → (non-null) {Array.<!shaka.media.SegmentIndex>}
- 
    
    Gets the active Streams' SegmentIndexes.- Source:
 Returns:- Type
- Array.<!shaka.media.SegmentIndex>
 
- 
    
        
            
            getSessionIds() → (non-null) {Array.<string>}
- 
    
    Gets the available session IDs.- Implements:
- Source:
 Returns:- Type
- Array.<string>
 
- 
    
        
            
            getTextTracks() → (non-null) {Array.<!shaka.player.TextTrack>}
- 
    
    Gets the available text tracks.- Implements:
- Source:
 Returns:- Type
- Array.<!shaka.player.TextTrack>
 
- 
    
        
            
            getVideoTracks() → (non-null) {Array.<!shaka.player.VideoTrack>}
- 
    
    Gets the available video tracks.- Implements:
- Source:
 Returns:- Type
- Array.<!shaka.player.VideoTrack>
 
- 
    
        
            
            isLive() → {boolean}
- 
    
    Determines if the stream is live. Should not be called before load() resolves.- Implements:
- Source:
 Returns:True if the stream is live.- Type
- boolean
 
- 
    
        
            
            isOffline() → {boolean}
- 
    
    Determines if the stream is used for offline playback.- Implements:
- Source:
 Returns:True if the stream is stored or being stored.- Type
- boolean
 
- 
    
        
            
            load() → (non-null) {Promise}
- 
    
    Load any intermediate source material (manifest, etc.) Should only be called once.- Implements:
- Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            (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. - Source:
 
- 
    
        
            
            (private) onBandwidth_(eventnon-null)
- 
    
    Bandwidth statistics update callback.Parameters:Name Type Description eventEvent - Source:
 
- 
    
        
            
            (private) onBufferingEnd_(eventnon-null)
- 
    
    The buffering end event callback.Parameters:Name Type Description eventEvent - Source:
 
- 
    
        
            
            (private) onBufferingStart_(eventnon-null)
- 
    
    The buffering start event callback.Parameters:Name Type Description eventEvent - Source:
 
- 
    
        
            
            onKeyStatusesChange(keyStatusByKeyIdnon-null)
- 
    
    Notifies the video source that one or more content encryption keys have changed their status.Parameters:Name Type Description keyStatusByKeyIdObject.<string, string> A map from key ID, as a hex string, to key status. Each key status is a MediaKeyStatus value. - Implements:
- 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 - Source:
 
- 
    
        
            
            (private) onSeeking_(eventnon-null)
- 
    
    Video seeking callback.Parameters:Name Type Description eventEvent - Source:
 
- 
    
        
            
            (private) onStreamEnded_(eventnon-null)
- 
    
    Stream ended callback.Parameters:Name Type Description eventEvent - Source:
 
- 
    
        
            
            (protected) onUpdateLocalManifest() → (non-null) {Promise.<!shaka.media.ManifestInfo>}
- 
    
    Update local manifest hook. The caller takes ownership of the returned manifest. This CANNOT return this.manifestInfo.- Source:
 Returns:- Type
- Promise.<!shaka.media.ManifestInfo>
 
- 
    
        
            
            (protected) onUpdateManifest(urlnon-null) → (non-null) {Promise.<!shaka.media.ManifestInfo>}
- 
    
    Update manifest hook. The caller takes ownership of the returned manifest.Parameters:Name Type Description urlshaka.util.FailoverUri - Source:
 Returns:- Type
- Promise.<!shaka.media.ManifestInfo>
 
- 
    
        
            
            (private) onUpdateManifest_(useLocal)
- 
    
    Updates the manifest.Parameters:Name Type Description useLocalboolean Whether to update using the local manifest. - Source:
 
- 
    
        
            
            (private) onUpdateSeekRange_()
- 
    
    Computes a new seek range and fires a 'seekrangechanged' event. Also clamps the playhead to the seek start time during playback.- Source:
 
- 
    
        
            
            (private) processDeferredSwitches_()
- 
    
    Processes all deferred switches.- 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 - Source:
 
- 
    
        
            
            selectAudioTrack(id, clearBuffer, opt_clearBufferOffsetopt) → {boolean}
- 
    
    Select an audio track by ID.Parameters:Name Type Attributes Description idnumber The |id| field of the desired AudioTrack object. clearBufferboolean If true, removes the previous stream's content before switching to the new stream. opt_clearBufferOffsetnumber <optional> 
 if |clearBuffer| and |opt_clearBufferOffset| are truthy, clear the stream buffer from the given offset (relative to the audio's current time) to the end of the stream. - Implements:
- Source:
 Returns:True on success; otherwise, return false if the specified AudioTrack does not exist or if an audio stream does not exist.- Type
- boolean
 
- 
    
        
            
            selectConfigurations(configsnon-null)
- 
    
    Select the streams to use based on the given configurations. Should not be called before load() resolves. Should not be called after attach() has been resolved.Parameters:Name Type Description configsshaka.util.MultiMap.<!shaka.media.StreamConfig> The keys are content types, such as 'audio', 'video', or 'text'. The implementation may ignore the keys if they are not helpful. - Implements:
- 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> - Source:
 Returns:- Type
- Object.<string, !shaka.media.StreamInfo>
 
- 
    
        
            
            selectTextTrack(id, clearBuffer) → {boolean}
- 
    
    Select a text track by ID.Parameters:Name Type Description idnumber The |id| field of the desired TextTrack object. clearBufferboolean If true, removes the previous stream's content before switching to the new stream. - Implements:
- Source:
 Returns:True on success; otherwise, return false if the specified TextTrack does not exist or if a text stream does not exist.- Type
- boolean
 
- 
    
        
            
            (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. - Source:
 Returns:True on success.- Type
- boolean
 
- 
    
        
            
            selectVideoTrack(id, clearBuffer, opt_clearBufferOffsetopt) → {boolean}
- 
    
    Select a video track by ID.Parameters:Name Type Attributes Description idnumber The |id| field of the desired VideoTrack object. clearBufferboolean If true, removes the previous stream's content before switching to the new stream. opt_clearBufferOffsetnumber <optional> 
 if |clearBuffer| and |opt_clearBufferOffset| are truthy, clear the stream buffer from the given offset (relative to the video's current time) to the end of the stream. - Implements:
- Source:
 Returns:True on success; otherwise, return false if the specified VideoTrack does not exist or if a video stream does not exist.- Type
- boolean
 
- 
    
        
            
            setPlaybackStartTime(startTimenullable)
- 
    
    Sets the desired time (in seconds) to begin playback from.Parameters:Name Type Attributes Description startTimenumber <nullable> 
 - Implements:
- Source:
 
- 
    
        
            
            (private) setSeekRangeTimer_()
- 
    
    Sets the seek range timer.- Source:
 
- 
    
        
            
            (private) setUpdateLocalManifest_()
- 
    
    Sets the update timer to updated the manifest using the local copy.- 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. - 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. - Source:
 
- 
    
        
            
            (private) sortByLanguage_(streamSetsnon-null)
- 
    
    Move the best language match to the front of the array.Parameters:Name Type Description streamSetsArray.<!shaka.media.StreamSetInfo> - 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. - Source:
 
Events
- 
    
        
            
            SeekRangeChangedEvent
- 
    
    Fired when the seekable range changes.Properties:Name Type Description typestring 'seekrangechanged' bubblesboolean true startnumber The earliest time that can be seeked to, in seconds. endnumber The latest time that can be seeked to, in seconds. - Source:
 
- 
    
        
            
            TracksChangedEvent
- 
    
    Fired when one or more audio, video, or text tracks become available or unavailable.Properties:Name Type Description typestring 'trackschanged' bubblesboolean true - Source: