Activity Camera FirefoxOS

I am developing an app for Firefox OS which is supposed to load the camera when an element is touched.

I had a search on the internet but I could not find a way to do such thing unless I was to start a "web activity" and let the user choose an application to pick.

I would like to force the camera application to start and not let the user choose the app to launch. Is there a way? (I really hope so!)

Thank you for the answer in advance!

Lorenzo


Launching the camera (app) and getting access to the camera (hardware) are two different things - depending on your needs, you may need the Camera API (as suggested by Jack) to pull images/video off the device camera hardware, or you might just want to launch the built-in camera app, so the user can interact with it (without requiring to retrieve any result, like a photo, from this interaction).

Unfortunately, both use cases are currently restricted by the permission system of Firefox OS.

Direct hardware access to the camera requires a "Certified" level permission, which prevents it to be used in third party applications. If you need this feature, your best chance is to wait until WebRTC (the getUserMedia() API) lands on Firefox OS devices, which will give you direct access to camera and microphone hardware in third-party applications (there are already some experiments on early Nightly builds of FxOS that use the WebRTC getUserMedia API on actual devices, so you it shouldn't take long before it is available to end users, too). Keep an eye on bug 750011 to follow implementation progress.

The other use case is launching the built-in camera application itself from your app. To launch an installed App on the device you need a reference to its App object, invoking the App object's .launch() method launches the selected app. Unfortunately though, currently the only way to acquiring said app object seems to be via the Apps.mgmt.getAll() function call, which lists all the installed apps on your device - scanning the list you would be able to pick the Camera app, and use its launch() method to launch it. You could see this in action in Kevin Grandon's "Matchscreen" homescreen-experiment. Unfortunately the permission system has the last word in this use case too, as the Apps.mgmt object calls, too require a "Certified" level permission (the webapps-manage permission). That is one of the main reasons why third party homescreens (like the one by Matteo D'Ignazio) can't function and actually launch apps currently. There is an ongoing discussion on relaxing the requirements on this, though, and there is work ongoing regarding third party home screens, so (in time) this should also be resolved.


As seen on the mdn page explaining App permissions, camera API is not available to third-party developers yet, but there are plans for it happening in the future.

Note: The reason that camera is limited to certified apps is that the sandbox that apps run in prevents access to the camera hardware. Our goal is to make it available to third party apps as soon as possible, but we don't have time to do that in the initial release.


You can use webRTC(getUserMedia API) in FxOS to access camera as in modern desktop browser after half a year. It will be a preffered way rather than the obsolete mozCamera API (which is not able to use for 3rd party developer).

链接地址: http://www.djcxy.com/p/79744.html

上一篇: 如何为Firefox OS配置APP图标?

下一篇: 活动相机FirefoxOS