Skip to content

Instantly share code, notes, and snippets.

@bryanjenningz
Created October 7, 2017 20:19
Show Gist options
  • Save bryanjenningz/65680c8ce3b85d00824c7c726b830e2d to your computer and use it in GitHub Desktop.
Save bryanjenningz/65680c8ce3b85d00824c7c726b830e2d to your computer and use it in GitHub Desktop.
navigator.mediaDevices.getUserMedia({ audio: true })
.then(stream => {
const mediaRecorder = new MediaRecorder(stream);
mediaRecorder.start();
const audioChunks = [];
mediaRecorder.addEventListener("dataavailable", event => {
audioChunks.push(event.data);
});
mediaRecorder.addEventListener("stop", () => {
const audioBlob = new Blob(audioChunks);
const audioUrl = URL.createObjectURL(audioBlob);
});
setTimeout(() => {
mediaRecorder.stop();
}, 3000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment