Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

CameraControl.release()

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

Summary

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.

Syntax

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

Parameters

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.

Example

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) {
    myCamera.release(onReleasedCamera);
  }
}

navigator.mozCameras.getCamera(options, onAccessCamera);

window.addEventListener('unload', releaseCamera);

Specification

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

See also

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, teoli, ajaybhat, kscarfone, Sheppy, Jeremie
 Last updated by: chrisdavidmills,