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+ |
| API | BB5.0 | BB6.0 | BB7.0 | PB1.0 | PB2.0 | BB10 | Ripple |
|---|---|---|---|---|---|---|---|
| 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 ID | BB5.0 | BB6.0 | BB7.0 | PB1.0 | PB2.0 | BB10 | Ripple |
|---|---|---|---|---|---|---|---|
| <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
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:
|
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:
|