Skip to content

Instantly share code, notes, and snippets.

@TheSalarKhan
Last active February 28, 2020 17:24
Show Gist options
  • Save TheSalarKhan/d3b35adf48891a034426b8854902487b to your computer and use it in GitHub Desktop.
Save TheSalarKhan/d3b35adf48891a034426b8854902487b to your computer and use it in GitHub Desktop.
Get permission only WEBRTC
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