Created
May 26, 2021 23:26
-
-
Save Gkiokan/695b2e42d7b35526036092bd55122b77 to your computer and use it in GitHub Desktop.
record.js
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
// 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