How to receive continuous chunk of video as a blob array and set to video tag dynamically in Websocket

浪尽此生 提交于 2019-12-08 08:24:27

In client side will get array buffer. So you need to convert array buffer into blob array.

 let video = document.querySelector('video'); 
  let blobArray = [];
 socket.on('message',data=>{
  blobArray.push(new Blob([new Uint8Array(data)],{'type':'video/mp4'}));
  let currentTime = video.currentTime;
  let blob = new Blob(blobArray,{'type':'video/mp4'});
  video.src = window.URL.createObjectURL(blob);
  video.currentTime = currentTime;
  video.play();
 });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!