Last active
June 26, 2020 15:32
-
-
Save mcmoe/d20ec256dd10d2345b5aa26bc9544763 to your computer and use it in GitHub Desktop.
Record a web mediaElement such as video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stream = $0.captureStream(); | |
const recorder = new MediaRecorder(stream); | |
const allChunks = []; | |
recorder.ondataavailable = (e) => allChunks.push(e.data); | |
recorder.start(); | |
// recorder.pause(); | |
// recorder.resume(); | |
recorder.stop(); | |
var fullBlob = new Blob(allChunks); | |
var link = document.createElement('a'); | |
link.style.display = 'none'; | |
var downloadUrl = window.URL.createObjectURL(fullBlob); | |
link.href = downloadUrl; | |
link.download = 'name-of-your-video.webm'; | |
document.body.appendChild(link); | |
link.click(); | |
link.remove(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment