equal
deleted
inserted
replaced
|
1 /** |
|
2 * This class provides access to the device camera. |
|
3 * @constructor |
|
4 */ |
|
5 function Camera() { |
|
6 this.success_callback = null; |
|
7 this.error_callback = null; |
|
8 } |
|
9 |
|
10 /** |
|
11 * We use the Platform Services 2.0 API here. So we must include a portion of the |
|
12 * PS 2.0 source code (camera API). |
|
13 * @param {Function} successCallback |
|
14 * @param {Function} errorCallback |
|
15 * @param {Object} options |
|
16 */ |
|
17 Camera.prototype.getPicture = function(successCallback, errorCallback, options){ |
|
18 try { |
|
19 if (!this.serviceObj) { |
|
20 this.serviceObj = com.nokia.device.load("", "com.nokia.device.camera", ""); |
|
21 } |
|
22 if (!this.serviceObj) { |
|
23 throw { |
|
24 name: "CameraError", |
|
25 message: "could not load camera service" |
|
26 }; |
|
27 } |
|
28 var obj = this; |
|
29 |
|
30 obj.success_callback = successCallback; |
|
31 obj.error_callback = errorCallback; |
|
32 this.serviceObj.startCamera( function(transactionID, errorCode, outPut) { |
|
33 //outPut should be an array of image urls (local), or an error code |
|
34 if (errorCode == 0) { |
|
35 obj.success_callback(outPut); |
|
36 } |
|
37 else { |
|
38 obj.error_callback({ |
|
39 name: "CameraError", |
|
40 message: errorCode |
|
41 }); |
|
42 } |
|
43 }); |
|
44 |
|
45 } catch (ex) { |
|
46 errorCallback.call(ex); |
|
47 } |
|
48 |
|
49 }; |
|
50 |
|
51 if (typeof navigator.camera == "undefined") navigator.camera = new Camera(); |