Last active
February 28, 2020 17:24
-
-
Save TheSalarKhan/d3b35adf48891a034426b8854902487b to your computer and use it in GitHub Desktop.
Get permission only WEBRTC
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
function getUserMediaPermission() { | |
return new Promise((resolve,reject) => { | |
navigator.mediaDevices.getUserMedia({ video: true, audio: true }) | |
.then(stream => { stream.getTracks().forEach(t => t.stop()); resolve(true) }) | |
.catch(() => { resolve(false) }); | |
}); | |
} | |
// usage | |
getUserMediaPermission().then((granted) => { console.log(granted) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment