Skip to content

Instantly share code, notes, and snippets.

@Gkiokan
Created May 26, 2021 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gkiokan/695b2e42d7b35526036092bd55122b77 to your computer and use it in GitHub Desktop.
Save Gkiokan/695b2e42d7b35526036092bd55122b77 to your computer and use it in GitHub Desktop.
record.js
// https://github.com/muaz-khan/RecordRTC
/*
<!-- recommended -->
<script src="https://www.WebRTC-Experiment.com/RecordRTC.js"></script>
<!-- use 5.6.2 or any other version on cdnjs -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/RecordRTC/5.6.2/RecordRTC.js"></script>
<!-- NPM i.e. "npm install recordrtc" -->
<script src="node_modules/recordrtc/RecordRTC.js"></script>
*/
navigator.mediaDevices.getUserMedia({
video: false,
audio: true
}).then(async function(stream) {
let recorder = RecordRTC(stream, {
type: 'video'
});
recorder.startRecording();
const sleep = m => new Promise(r => setTimeout(r, m));
await sleep(3000);
recorder.stopRecording(function() {
let blob = recorder.getBlob();
invokeSaveAsDialog(blob);
console.log(blob)
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment