This API is available on Firefox OS for privileged or certified applications only.


Releases the camera so that other applications can use it. You should call this whenever the camera is not actively being used by your application.

Warning: If you fail to call this method, other applications will never be able to access the camera.

After calling this method, your CameraControl object is defunct; you will need to call CameraManager.getCamera() to get a new one if you want to use the camera again.


CameraControl.release([onsuccess[, onerror]]);


onsuccess Optional
A callback function which is called once the hardware has actually been released.
onerror Optional
A callback function that accepts an error string; this is called if an error occurs while releasing the camera.

Note: Both callbacks are optional; unless you really need to know when the hardware has actually been released for use by other applications, you probably won't need to use them.


This example sets up an unload event handler that will automatically release the camera when the document is unloaded (such as when the app exits).

var myCamera = null;
var options  = {
  camera: navigator.mozCameras.getListOfCameras()[0]

function onAccessCamera( camera ) {
  myCamera = camera;

  console.log("The camera is now used by this Apps")

function onReleasedCamera() {
  console.log("The camera is now free to be used by another Apps");

function releaseCamera() {
  if (myCamera) {

navigator.mozCameras.getCamera(options, onAccessCamera);

window.addEventListener('unload', releaseCamera);


Not part of any specification; however, this API should be removed when the WebRTC Capture and Stream API has been implemented.

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API B2G Camera camera DOM DOM Reference Firefox OS Graphics Method Reference Référence WebAPI