MediaSource interface of the
Media Source Extensions API represents a source of media data for an
HTMLMediaElement object. A MediaSource object can be attached to a
HTMLMediaElement to be played in the user agent.
Returns a SourceBufferList object containing the list of SourceBuffer objects associated with this MediaSource.
Returns a SourceBufferList object containing a subset of the SourceBuffer objects contained within MediaSource.sourceBuffers — the list of objects providing the selected video track, enabled audio tracks, and shown/hidden text tracks.
Returns an enum representing the state of the current MediaSource, whether it is not currently attached to a media element (closed), attached and ready to receive SourceBuffer objects (open), or attached but the stream has been ended via MediaSource.endOfStream() (ended.)
Gets and sets the duration of the current media being presented.
The event handler for the sourceclose event.
The event handler for the sourceended event.
The event handler for the sourceopen event.
Inherits methods from its parent interface, EventTarget.
Creates a new SourceBuffer of the given MIME type and adds it to the MediaSource.sourceBuffers list.
Removes the given SourceBuffer from the MediaSource.sourceBuffers list.
Signals the end of the stream.
Sets the range that the user can seek to in the media element.
Clears the live seekable range.
Returns a Boolean value indicating if the given MIME type is supported by the current user agent — this is, if it can successfully create SourceBuffer objects for that MIME type.
The following simple example loads a video with XMLHttpRequest, playing it as soon as it can. This example was written by Nick Desaulniers and can be viewed live here (you can also download the source for further investigation.)