Skip to content

Getting WebRTC getUserMedia To Work

Skeel Lee edited this page Oct 26, 2013 · 3 revisions

Background Info

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.

Enabling WebRTC's getUserMedia()

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.

Test WebRTC's getUserMedia()

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.

Example Codes

I have created a WebRTC test file in this GitHub repository that shows the codes needed to get a basic WebRTC getUserMedia() page running.