Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with Camera API in Firefox OS

Tags:

firefox-os

I want to work with camera api in firefox os simulator. Docs suggests that it is only available for certified apps. If i want to take picture using camera in my app, how can i proceed developing the app?? Thanks in advance

like image 347
user2590663 Avatar asked Jul 18 '13 10:07

user2590663


2 Answers

You have to use the Web Activities API to take pictures. Simply put, it's the equivalent of Android's Intents for the Open Web.

I'd write a lot about it, but there are good code examples out there, like this one, implementing just that. You have to a few stuff:

Create a Web Activity:

var recordActivity = new MozActivity({ name: "record" });

Set a onsuccess callback, and do whatever you want with the result on it:

recordActivity.onsuccess = function () { console.log(this); }

There are a few more details, and all of them are listed on this post on Hacks.

like image 62
Ricardo Panaggio Avatar answered Oct 17 '22 13:10

Ricardo Panaggio


So some stuff changed in the past year. Web Activities are still the way to go for most apps, but we have two APIs that were previously not exposed.

From Firefox OS 1.4 you have access to getUserMedia so you can get a direct camera stream. From Firefox OS 2.0 you now have access to the mozCameras API that allows for stuff like camera switching and control of the flash.

like image 24
Jan Jongboom Avatar answered Oct 17 '22 13:10

Jan Jongboom