mozilla
Your Search Results

    CameraManager.getCamera()

    This article is in need of a technical review.

    Non-standard
    This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

    Summary

    This method is used to access to one of the cameras available on the device based on its identifier. You can get a list of the available cameras by calling the CameraManager.getListOfCameras() method.

    Syntax

    CameraManager.getCamera(camera, cameraConfiguration, onsuccess[, onerror]);

    Parameters

    camera
    Specify the camera you want to use (the device may have more than one camera).
    cameraConfiguration
    An object allowing you to set camera options for this camera: mode, previewSize and recorderProfile.
    onsuccess
    A callback function that take a CameraControl object as parameter.
    onerror
    An optional callback function that accepts an error string as a parameter.

    Example

    var options = {
      mode: 'picture',
      recorderProfile: 'jpg',
      previewSize: {
        width: 352,
        height: 288
      }
    };
    
    var camera = navigator.mozCameras.getListOfCameras()[0];
    
    function onSuccess(camera) {
      // Do stuff with the camera
    };
    
    function onError(error) {
      console.warn(error);
    };
    
    navigator.mozCameras.getCamera(camera, options, onSuccess, onError);
    

    Specification

    Not part of any specification as yet; this will probably be replaced by WebRTC when it gains more widespread support on mobile devices.

    Permissions

    Up until Firefox OS 1.4, The Camera API was a certified API, so not accessible to third party apps. From Firefox OS 2.0 onwards, the permission level has been downgraded to privileged, so it is now available for developers to use in their apps.

    "type": "privileged"
    "permissions": {
      "camera": {
        "description": "Required for accessing cameras on the device."
      }
    }

    See also

    Document Tags and Contributors

    Last updated by: fscholz,