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();
});