Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Getting WebRTC getUserMedia To Work
WebRTC, being a relatively new web technology, has some differences between web browsers. Most notably, the
getUserMedia() function used in this project has different prefixes for different web browsers, such as
mozGetUserMedia() for Mozilla Firefox and
webkitGetUserMedia() for Google Chrome and other webkit-based browsers. There is an official Google WebRTC page that talks about these differences. I am using a polyfill from Google which handles the differences between Google Chrome and Mozilla Firefox, as provided in that page.
If you are using Google Chrome, you will need to enable these in chrome://flags:
- Enable screen capture support in
getUserMedia()There could be other flags that needs to be enabled in your version of Google Chrome.
If you are using other browsers, you can check whether
getUserMedia() is supported.
As a sanity check, you can test WebRTC on the official WebRTC demo app webpage. A prompt should appear, asking you to allow access or share your webcam device. Accept the request and you should see the webcam stream in your browser.
I have created a WebRTC test file in this GitHub repository that shows the codes needed to get a basic WebRTC
getUserMedia() page running.