navigator.mozGetUserMedia() has just landed in Firefox desktop nightly builds!

I know a lot of Mozillians have been waiting for this: Firefox nightly (http://nightly.mozilla.org/) for Desktop now supports navigator.mozGetUserMedia().

mozGetUserMedia is a new DOM API that allows a JavaScript application to easily access a user’s camera and/or microphone.  It’s part of the greater WebRTC project which will enable real-time video/audio/data connections from within the browser.  The spec is still under development in the W3C, and so this API is currently a prefixed API in Firefox.  We’d love help from the community to try it out over the next few months and let us know how it’s working and what improvements you’d like to see.

mozGetUserMedia is still preffed off by default, so you will have to browse to about:config and set media.navigator.enabled to true (it’s a boolean).  We don’t yet have the UI for the feature (to query permission for camera and microphone access and to communicate camera/microphone status), and we won’t be enabling mozGetUserMedia by default until we have UI.  Also, because this feature is brand new, we’re still working out a lot of the kinks.  There are some known issues that we’re in the process of resolving:

  • We don’t yet support mixing both audio and video into a single stream yet (you can obtain them individually though as two different streams). (Bug 773649)
  • We’re seeing clock drift, so the video or audio streams may appear to start lagging after a while (Bug 771834)
  • On some systems, capturing audio doesn’t work a second time without restarting the browser (Bug 773646)

Note: we don’t currently support “stream_url=URL.createObjURL(stream); video.src=stream_url;”.  Instead we support “video.src=stream;”.   It’s under discussion in the W3C as to which one (or both) will be required.

To look at some sample code and try out a simple demo, browse to https://people.mozilla.com/~anarayanan/gum_test.html and look at the page source.

Please help us test and let us know what you think.  If you find bugs while using mozGetUserMedia, please report them at bugzilla.mozilla.org (Product: Core, Component:WebRTC).  If you want to give feedback on this feature or our implementation of it, please post to Mozilla’s dev.media newsgroup.
Thanks in advance for any help you can give us on this!

I’m so excited that WebRTC is finally happening!  getUserMedia is the first major piece of a project that has the power to revolutionize the web and impact how we live our daily lives. And I’m thrilled that Mozilla is helping to make that possible.

3 thoughts on “navigator.mozGetUserMedia() has just landed in Firefox desktop nightly builds!

  1. owennewo

    Thanks for your work, I’ve tried the demo and it works fine.

    I’ve got a question though. I plan to write some pitch detection code in js and need access to the raw audio stream. Is this possible? Is there some File or Blob API that I can use to get this data?

    BTW: I got a bit stuck at setting “media.navigator.enabled” – there setting isn’t in about:config and it took me a while before I realised I had to add it. Doh!

  2. Craig

    Hi great article.

    I’ve been trying to get mozGetUserMedia() working with little success. It fails at the point I am assigning the stream to the video src.

    If I try “video.src=stream;” i get the following error “HTTP load failed with status 404. Load of media resource http://localhost/5notflash/%5Bobject%20MediaStream%5D failed.”

    And if i try “stream_url=URL.createObjURL(stream); video.src=stream_url;” I get this error “NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMMozURLProperty.createObjectURL]”.

    I’ve tried it both ways on a Mac and a PC. In both cases the camera light comes on indicating mozGetUserMedia is finding the camera. I’m only using the video option on its own without audio and I have set “media.navigator.enabled” to true.

    I’m running Firefox 17.0.1 on both Mac and PC. My example works on both Chrome and Opera.

    I’ve tried looking at the example you posted but the link has since expired.

    Any thoughts or ideas would be gratefully received.

  3. Craig

    Ok solved this problem – it now works in Firefox 18 with “video.mozSrcObject = stream;” You have to call “play()” on the video as well – “video.autoplay = true;” doesn’t seem to work with Mozilla.

    Hope this helps somebody.

    Thanks Craig

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s