Represents a source of media data (audio or video) for a media element.
OverviewProvides a buffer based source for a media object. The app creates a MediaSource object and adds it to the media (audio or video) object as a source for the src object. SourceBuffers are then added to the MediaSource object and media content is then appended to the buffers to provide streaming or multi-source playback.
var mediaSource = new MediaSource();
No properties.
MethodsNo events.
ExamplesThis example creates a new MediaSource object and adds it to a video object. It then adds a sourceBuffer and calls to start loading content.
The live sample only runs on a browser that support the W3C syntax and MP4 files.
function setupVideo() {
if (window.MediaSource) {
mediaSource = new window.MediaSource();
} else {
log("mediasource or syntax not supported");
return;
}
var url = URL.createObjectURL(mediaSource);
videoElement.src = url;
mediaSource.addEventListener('sourceopen', function (e) {
try {
videoSource = mediaSource.addSourceBuffer('video/mp4');
} catch (e) {
return;
}
});
}
Related specifications
MediaSource
}
}
AttributionsMicrosoft Developer Network.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4