How to work with Camera API in Firefox OS
Asked Answered
H

2

7

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

Harveyharvie answered 18/7, 2013 at 10:28 Comment(0)
M
8

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.

Moncear answered 18/7, 2013 at 11:43 Comment(2)
yeah thank u..:) but the simulator is opening camera but not taking any picture(demp pic). Android emulator will return some picture right.. Isn't it possible in firefox os simulator?Harveyharvie
Any success using the camera in simulator?Courier
F
1

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.

Fixity answered 24/7, 2014 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.