Camera
An application can initiate capture of a still image or a video by doing a cross-app launch of the Camera application. You can specify a file name for the captured image or video, or let the Camera application assign a default name. After the capture is completed or cancelled, the original application resumes control.
Method
This section describes the following method:
- capture
capture
Initiates capture of a still image or video.
Required parameters:
- appId
- name
- sublaunch
Parameters
Parameter | Type | Description |
---|---|---|
appId | string | Set to "com.palm.app.camera". |
filename | string | Optional. A full path to the location where the image or video file should be saved (should be beneath /media/internal). |
name | string | Set to "capture". |
sublaunch | boolean | Indicates that control must be returned to the calling application after taking the picture or cacelling the application. |
mode | "still" | "video" | Optional. Specifies whether a still image (the default) or a video should be captured |
Return Handling
onSuccess
Attribute | Type | Description |
---|---|---|
filename | string | The full path to the location where the image or video file was saved. |
returnValue | boolean | true |
onFailure
Attribute | Type | Description |
---|---|---|
returnValue | boolean | false |
Example
This example initiates a still image capture, using a default filename:
this.controller.stageController.pushScene( { appId: "com.palm.app.camera", name: "capture" }, { sublaunch: true } );
This example initiates a video capture, using a specific filename (note the "mode" and "filename" parameters):
this.controller.stageController.pushScene( { appId: "com.palm.app.camera", name: "capture" }, { sublaunch: true, mode: "video", filename: "/media/internal/myApp/capturedVideo.mp4" } );
Sample Code
This section shows sample code.
MySceneAssistant = Class.create({ initialize : function(params) { ... }, setup : function() { this.cameraButtonElement = this.controller.get('camera_button'); this.cameraButtonElement.observe( Mojo.Event.tap, this.handleNewPicture.bindAsEventListener(this) ); ... }, activate : function(params) { if (!params){ return; } if (params.filename) { Mojo.Log.info("new pic with path:", params.filename); // Now go use the new image in params.filename ... } }, handleNewPicture : function(event) { var d = new Date().getTime(); var filestring = "/media/internal/app_images/"+d+".jpg"; this.controller.stageController.pushScene( { appId :'com.palm.app.camera', name: 'capture' }, { sublaunch : true, filename: filestring } ); }, ... });