Skip to content

Instantly share code, notes, and snippets.

@chicken-suop
Created October 17, 2019 16:29
Show Gist options
  • Save chicken-suop/47c8d98c9269a2587650a49b6cc1fa95 to your computer and use it in GitHub Desktop.
Save chicken-suop/47c8d98c9269a2587650a49b6cc1fa95 to your computer and use it in GitHub Desktop.
const timeout = 1000;
this.stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const recorder = new MediaRecorder(this.stream);
recorder.addEventListener('dataavailable', ({ data }) => this.upload(data));
recorder.addEventListener('stop', () => {
recorder.start();
setTimeout(() => recorder.stop(), timeout);
});
recorder.start();
setTimeout(() => recorder.stop(), timeout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment