Canvas视频

stream = canvas.captureStream();
recorder = new MediaRecorder(stream, {
mimeType: 'video/webm'
});
recorder.addEventListener('dataavailable', e => {
if (e.data && e.data.size) {
data.push(e.data);
}
});
recorder.addEventListener('stop', () => {
const url = URL.createObjectURL(new Blob(data, {
type: 'video/webm'
}));
canvas.style.display = 'none'
document.querySelector('#video-container').style.display = 'block'
document.querySelector('#video-container').src = url;
document.querySelector('#video-container').play();
});

  

posted @ 2020-10-10 14:13  雲天望垂墨傾池  阅读(149)  评论(0编辑  收藏  举报