Appends the specified media segment to the SourceBuffer.
Method of apis/media_source_extensions/MediaSourceapis/media_source_extensions/MediaSource
Syntax SourceBuffer.appendBuffer(data);
Parameters data
Type: ArrayBuffer. The media segment to append
Return ValueNo return value
ExamplesThis example uses XMLHttpRequest to get a segment of video (range) from a file (url) and appends it to the current sourceBuffer.
function initVideo(range, url) {
var xhr = new XMLHttpRequest();
if (range || url) {
xhr.open('GET', url);
xhr.setRequestHeader("Range", "bytes=" + range);
segCheck = (timeToDownload(range) * .8).toFixed(3);
xhr.send();
xhr.responseType = 'arraybuffer';
try { xhr.addEventListener("readystatechange", function () {
if (xhr.readyState == xhr.DONE) {
try { videoSource.appendBuffer(new Uint8Array(xhr.response));
} catch (e) {
log('Exception while appending initialization content', e);
}
}
}, false);
} catch (e) {
log(e);
}
} else {
return
}
}
function updateFunct() {
bufferUpdated = true;
getStarted(file);
videoSource.removeEventListener("update", updateFunct);
}
Related specifications
appendBuffer
Microsoft 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