Skip to content

Instantly share code, notes, and snippets.

@C-Rodg
Created July 19, 2017 19:16
Show Gist options
  • Save C-Rodg/1c64fe3c24e85a34d22a7eca6e0d9d68 to your computer and use it in GitHub Desktop.
Save C-Rodg/1c64fe3c24e85a34d22a7eca6e0d9d68 to your computer and use it in GitHub Desktop.
Using WebRTC to request camera and microphone access in the browser.
navigator.getUserMedia( { video: true, audio: true }, (stream) => {
localStream = stream;
const cameraBox = document.getElementById('camera-box');
cameraBox.setAttribute('src', URL.createObjectURL( stream ) );
init();
}, (error) => {
alert('error accessing usermedia ' + error.toString() );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment