Constructor
new MediaSourceEngine(video, mediaSource, textTrack)
        MediaSourceEngine wraps all operations on MediaSource and SourceBuffers.
All asynchronous operations return a Promise, and all operations are
internally synchronized and serialized as needed.  Operations that can
be done in parallel will be done in parallel.
    
    
    
    
    
    
        Parameters:
| Name | Type | Description | 
|---|---|---|
| video | HTMLMediaElement | The video element, used to read error codes when MediaSource operations fail. | 
| mediaSource | MediaSource | The MediaSource, which must be in the 'open' state. | 
| textTrack | TextTrack | The TextTrack to use for subtitles/captions. | 
- Implements:
- Source:
Members
- 
    (private) destroyed_ :boolean
- 
    
    
        Type:- boolean
 - Source:
 
- 
    (private) eventManager_ :shaka.util.EventManager
- 
    
    
        Type:- Source:
 
- 
    (private) mediaSource_ :MediaSource
- 
    
    
        Type:- MediaSource
 - Source:
 
- 
    (private, non-null) queues_ :Object.<string, !Array.<shaka.media.MediaSourceEngine.Operation>>
- 
    
    
        Type:- Object.<string, !Array.<shaka.media.MediaSourceEngine.Operation>>
 - Source:
 
- 
    (private, non-null) sourceBuffers_ :Object.<string, SourceBuffer>
- 
    
    
        Type:- Object.<string, SourceBuffer>
 - Source:
 
- 
    (private) textEngine_ :shaka.media.TextEngine
- 
    
    
        Type:- Source:
 
- 
    (private) textTrack_ :TextTrack
- 
    
    
        Type:- TextTrack
 - Source:
 
- 
    (private) video_ :HTMLMediaElement
- 
    
    
        Type:- HTMLMediaElement
 - Source:
 
Methods
- 
    
        
            
            (static) isBrowserSupported() → {boolean}
- 
    
    Returns true if the browser has the basic APIs we need.- Source:
 Returns:- Type
- boolean
 
- 
    
        
            
            (static) isTypeSupported(mimeType) → {boolean}
- 
    
    Checks if a certain type is supported.Parameters:Name Type Description mimeTypestring - Source:
 Returns:- Type
- boolean
 
- 
    
        
            
            (static) probeSupport() → (non-null) {Object.<string, boolean>}
- 
    
    Returns a map of MediaSource support for well-known types.- Source:
 Returns:- Type
- Object.<string, boolean>
 
- 
    
        
            
            (private) abort_(contentType)
- 
    
    Call abort() on the SourceBuffer. This resets MSE's last_decode_timestamp on all track buffers, which should trigger the splicing logic for overlapping segments.Parameters:Name Type Description contentTypestring - Source:
 
- 
    
        
            
            (private) append_(contentType, datanon-null)
- 
    
    Append data to the SourceBuffer.Parameters:Name Type Description contentTypestring dataArrayBuffer - Source:
 Throws:QuotaExceededError if the browser's buffer is full
- 
    
        
            
            appendBuffer(contentType, datanon-null, startTimenullable, endTimenullable) → (non-null) {Promise}
- 
    
    Enqueue an operation to append data to the SourceBuffer. Start and end times are needed for TextEngine, but not for MediaSource. Start and end times may be null for initialization segments, if present they are relative to the presentation timeline.Parameters:Name Type Attributes Description contentTypestring dataArrayBuffer startTimenumber <nullable> 
 endTimenumber <nullable> 
 - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            bufferedAheadOf(contentType, time, opt_toleranceopt) → {number}
- 
    
    Computes how far ahead of the given timestamp is buffered for the given content type.Parameters:Name Type Attributes Description contentTypestring timenumber opt_tolerancenumber <optional> 
 An optional tolerance for range start times. Counts a range starting anywhere from time to time + opt_tolerance. - Source:
 Returns:The amount of time buffered ahead in seconds.- Type
- number
 
- 
    
        
            
            bufferEnd(contentType) → (nullable) {number}
- 
    
    Gets the last timestamp in buffer for the given content type.Parameters:Name Type Description contentTypestring - Source:
 Returns:The timestamp in seconds, or null if nothing is buffered.- Type
- number
 
- 
    
        
            
            bufferStart(contentType) → (nullable) {number}
- 
    
    Gets the first timestamp in buffer for the given content type.Parameters:Name Type Description contentTypestring - Source:
 Returns:The timestamp in seconds, or null if nothing is buffered.- Type
- number
 
- 
    
        
            
            clear(contentType) → (non-null) {Promise}
- 
    
    Enqueue an operation to clear the SourceBuffer.Parameters:Name Type Description contentTypestring - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            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
 
- 
    
        
            
            endOfStream(opt_reasonopt) → (non-null) {Promise}
- 
    
    
    
    
    
        Parameters:Name Type Attributes Description opt_reasonstring <optional> 
 Valid reasons are 'network' and 'decode'. - Source:
- See:
 Returns:- Type
- Promise
 
- 
    
        
            
            (private) enqueueBlockingOperation_(run) → (non-null) {Promise}
- 
    
    Enqueue an operation which must block all other operations on all SourceBuffers.Parameters:Name Type Description runfunction() - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            (private) enqueueOperation_(contentType, start) → (non-null) {Promise}
- 
    
    Enqueue an operation and start it if appropriate.Parameters:Name Type Description contentTypestring startfunction() - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            (private) getBuffered_(contentType) → {TimeRanges}
- 
    
    
    
    
    
        Parameters:Name Type Description contentTypestring - Source:
 Returns:The buffered ranges for the given content type, or null if the buffered ranges could not be obtained.- Type
- TimeRanges
 
- 
    
        
            
            getDuration() → {number}
- 
    
    Get the current MediaSource duration.- Source:
 Returns:- Type
- number
 
- 
    
        
            
            init(typeConfignon-null)
- 
    
    
    
    
    
        Parameters:Name Type Description typeConfigObject.<string, string> A map of content types to full MIME types. For example: { 'audio': 'audio/webm; codecs="vorbis"', 'video': 'video/webm; codecs="vp9"', 'text': 'text/vtt' }. All types given must be supported. - Source:
 Throws:- 
    InvalidAccessError if blank MIME types are given
- 
    NotSupportedError if unsupported MIME types are given
- 
    QuotaExceededError if the browser can't support that many buffers
 
- 
    
        
            
            (private) onError_(contentType, eventnon-null)
- 
    
    
    
    
    
        Parameters:Name Type Description contentTypestring eventEvent - Source:
 
- 
    
        
            
            (private) onUpdateEnd_(contentType)
- 
    
    
    
    
    
        Parameters:Name Type Description contentTypestring - Source:
 
- 
    
        
            
            (private) popFromQueue_(contentType)
- 
    
    Pop from the front of the queue and start a new operation.Parameters:Name Type Description contentTypestring - Source:
 
- 
    
        
            
            remove(contentType, startTime, endTime) → (non-null) {Promise}
- 
    
    Enqueue an operation to remove data from the SourceBuffer.Parameters:Name Type Description contentTypestring startTimenumber endTimenumber - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            (private) remove_(contentType, startTime, endTime)
- 
    
    Remove data from the SourceBuffer.Parameters:Name Type Description contentTypestring startTimenumber endTimenumber - Source:
 
- 
    
        
            
            setAppendWindowEnd(contentType, appendWindowEnd) → (non-null) {Promise}
- 
    
    Sets the append window end for the given content type.Parameters:Name Type Description contentTypestring appendWindowEndnumber The timestamp to set the append window end to. Media beyond this value will be truncated. - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            (private) setAppendWindowEnd_(contentType, appendWindowEnd)
- 
    
    Set the SourceBuffer's append window end.Parameters:Name Type Description contentTypestring appendWindowEndnumber - Source:
 
- 
    
        
            
            setDuration(duration) → (non-null) {Promise}
- 
    
    We only support increasing duration at this time. Decreasing duration causes the MSE removal algorithm to run, which results in an 'updateend' event. Supporting this scenario would be complicated, and is not currently needed.Parameters:Name Type Description durationnumber - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            setTimestampOffset(contentType, timestampOffset) → (non-null) {Promise}
- 
    
    Sets the timestamp offset for the given content type.Parameters:Name Type Description contentTypestring timestampOffsetnumber The timestamp offset. Segments which start at time t will be inserted at time t + timestampOffset instead. This value does not affect segments which have already been inserted. - Source:
 Returns:- Type
- Promise
 
- 
    
        
            
            (private) setTimestampOffset_(contentType, timestampOffset)
- 
    
    Set the SourceBuffer's timestamp offset.Parameters:Name Type Description contentTypestring timestampOffsetnumber - Source:
 
Type Definitions
- 
    OperationAn operation in queue. 
- 
    
    
        Type:- {start: function(), p: !shaka.util.PublicPromise}
 Properties:Name Type Description startfunction() The function which starts the operation. pshaka.util.PublicPromise The PublicPromise which is associated with this operation. - Source: