Answers for "load a video as blob"

0

load a video as blob

// function snippet
async function loadImage(fname) {
  var response = await fetch(fname);
  var videoDemo = document.querySelector('video');
  videoDemo.src = URL.createObjectURL(await response.blob());
}
loadImage('video.mp4');

// full code
<html>
  <video id="videoDemo" width="320" height="240" controls>
    <source src="" type="video/mp4" />
    Your browser does not support the video tag.
  </video>
  <script>
    async function loadImage(fname) {
      var response = await fetch(fname);
      var videoDemo = document.querySelector('video');
      videoDemo.src = URL.createObjectURL(await response.blob());
    }
    loadImage('video.mp4');
  </script>
</html>
Posted by: Guest on August-18-2021

Browse Popular Code Answers by Language