Search code examples
firefox-os

How to work with Camera API in 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


Solution

  • 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.