Skip to content

Instantly share code, notes, and snippets.

@natp0ng
Created July 9, 2018 12:53
Show Gist options
  • Save natp0ng/bb2f9cab145b6105031241de352fc9eb to your computer and use it in GitHub Desktop.
Save natp0ng/bb2f9cab145b6105031241de352fc9eb to your computer and use it in GitHub Desktop.
Video test on RPI3 b+
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<video class="media-video" height="270" width="480" autoplay loop muted="" controls></video>
<script>
var videoElem = document.querySelector('.media-video')
var blob = null;
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://content.bitsontherun.com/videos/bkaovAYt-52qL9xLP.mp4");
xhr.responseType = "blob";//force the HTTP response, response-type header to be blob
xhr.onload = function()
{
blob = xhr.response;//xhr.response is now a blob object
var reader = new FileReader;
reader.onload = function() {
var blobAsDataUrl = reader.result;
// console.log(blobAsDataUrl)
videoElem.setAttribute('src', blobAsDataUrl)
};
reader.readAsDataURL(blob);
}
xhr.send();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment