Saturday, July 14, 2012

Firefox 16 now supports HTML5 getUserMedia




Firefox 16 nightly build now supports HTML5 getUserMedia which enables you to access webcam without the use of plugins.

How to use it?

This is the tricky part here.  Mostly there will be an entry in about:config.  You need to set that to true.  But in this case you need to add a new entry.  Open "about:config" and right click any entry and select 'New' and then 'Boolean'. (Thanks to the friends at #irc for this tip.)


Add this entry

media.navigator.enabled

and set it to true.  You are now set to go.

Mozilla has a test page to test this feature.  You can use it to try this feature.  GetUserMedia feature is too basic and they don't have any authorization feature like in Chrome and Opera and more.




Make sure to define callback methods right within the getUserMedia() method like below.

navigator.getUserMedia(gumOptions,
        function successCallback(stream) {
            // Replace the source of the video element with the stream from the camera
        	if(navigator.getUserMedia==navigator.mozGetUserMedia) {
        		video.src = stream;
        	} else {
        		video.src = window.URL.createObjectURL(stream) || stream;
        	}
            
            video.play();
        },
        function errorCallback(error) {
            console.error('An error occurred: [CODE ' + error.code + ']');
            video.play();
        });


If you have defined the method elsewhere, it won't work.  This is the reason Opera's Explode camera demo did not work with Firefox.

Also you don't use CreateObjectURL to pass the stream the video element. Instead pass the stream directly.

video.src=stream 

Don't forget to check out the tutorial on How to access webcam using HTML5 getUserMedia

Paul Rouget of Mozilla, created an video to demonstrate HTML5 getUserMedia.  Don't forget to check it out.



Upgrade your nightly build now or download from Mozilla Nightly site to try  HTML5 getUserMedia.  Share your opinions through comments





  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP