Camera

Using Camera API allows to invoke the native camera application to record video or take a picture and receive a path to the file stored.

The methods are static and don't required to create an instance of a camera.

Note that the application will require the user to grant it input simulation and file api permissions for this extension to work on the BlackBerry.


Supported Platform(s)

- BlackBerry OS 5.0+
- BlackBerry PlayBook 1.0+
View Supported Platform Table
APIBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
blackberry.media.camera.close Y Y Y       
blackberry.media.camera.takePicture Y Y Y Y Y   
blackberry.media.camera.takeVideo Y Y Y Y Y   

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

You must declare the feature element(s) below in your configuration document:

Feature IDBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
<feature id="blackberry.media.camera" /> Y Y Y Y Y   
Permission Elements (PlayBook and BlackBerry 10+)
You must declare the permission element(s) below in your configuration document:
- <rim:permit>use_camera</rim:permit>
Permits your app to use the camera.

Functions

static void blackberry.media.camera.close ()


Close the camera or video recorder if it's in the foreground.


Supported Platforms
 - BlackBerry OS 5.0+


Code Example:
function takeVideo() {
  try {
    blackberry.media.camera.takeVideo(successCB);
  } catch(e) {
    alert("Error in supported: " + e);
  }
}

function successCB(filePath) {
  blackberry.media.camera.close();
  // do something with filePath
}

static void blackberry.media.camera.takePicture (onCaptured: function([filePath: String]), [onCameraClosed: function()], [onError: function([e: String])])


Opens the camera and return a path to the onCaptured callback when a photo is taken.


Supported Platforms
 - BlackBerry OS 5.0+
 - BlackBerry PlayBook 1.0+


Parameters
onCaptured Method will be invoked when a picture is captured.
Expected signature: function onCaptured(filePath)

filePath: Path to a picture captured by the camera.
onCameraClosed Method will be invoked on camera closed event.
Expected signature: function onCameraClosed()
onError Method will be invoked when an error occurs.
Expected signature: function onError(e)

e: Error message

static void blackberry.media.camera.takeVideo (onCaptured: function([filePath: String]), [onCameraClosed: function()], [onError: function([e: String])])


Opens the camera and return a path to the onCaptured callback when a video is taken.


Supported Platforms
 - BlackBerry OS 5.0+
 - BlackBerry PlayBook 1.0+


Parameters
onCaptured Method will be invoked when a video is recorded.
Expected signature: function onCaptured(filePath)

filePath: Path to a video captured by the camera.
onCameraClosed Method will be invoked on camera closed event.
Expected signature: function onCameraClosed()
onError Method will be invoked when an error occurs.
Expected signature: function onError(e)

e: Error message

Code Example:
function takeVideo() {
  try {
    blackberry.media.camera.takeVideo(successCB, closedCB, errorCB);
  } catch(e) {
    alert("Error in supported: " + e);
  }
}

function successCB(filePath) {
  alert("Succeed: " + filePath);
}

function closedCB() {
  alert("Camera closed event");
}

function errorCB(e) {
  alert("Error occured: " + e);
}
Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 11 2013 14:51:03 GMT-0500 (EST)