Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" content="width=device-width, height=device-height" />
<title>Context Menu Test Blob Buffered</title>
</head>
<body>
<video id="video" controls preload></video>
</body>
<script>
window.addEventListener("DOMContentLoaded", function () {
const video = document.getElementById("video");
const mediaSource = new MediaSource();
video.src = URL.createObjectURL(mediaSource);
mediaSource.addEventListener("sourceopen", createBuffer);
function createBuffer(event) {
const mediaSource = event.target;
const assetURL = "/assets/www/videos/gizmo.webm";
const codec = 'video/webm; codecs="opus"';
const sourceBuffer = mediaSource.addSourceBuffer(codec);
function addBuffer(response) {
sourceBuffer.addEventListener("updateend", function () {
mediaSource.endOfStream();
});
sourceBuffer.appendBuffer(response);
}
fetchVideoData(assetURL, addBuffer);
}
function fetchVideoData(assetURL, videoArrayBuffer) {
const request = new XMLHttpRequest();
request.open("get", assetURL);
request.responseType = "arraybuffer";
request.onload = function () {
videoArrayBuffer(request.response);
};
request.send();
}
});
</script>
</html>