You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/05/09 17:27:02 UTC

[4/4] js commit: added captureImage to support the native camera app control

added captureImage to support the native camera app control


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/516c1376
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/516c1376
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/516c1376

Branch: refs/heads/master
Commit: 516c1376760c152f52899271a36722713d355118
Parents: 6cb6e6c
Author: Anis Kadri <an...@gmail.com>
Authored: Wed May 9 02:50:53 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Wed May 9 02:50:53 2012 -0700

----------------------------------------------------------------------
 lib/bada/plugin/bada/Capture.js |   41 ++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/516c1376/lib/bada/plugin/bada/Capture.js
----------------------------------------------------------------------
diff --git a/lib/bada/plugin/bada/Capture.js b/lib/bada/plugin/bada/Capture.js
index 9a506d0..fb2dfc6 100644
--- a/lib/bada/plugin/bada/Capture.js
+++ b/lib/bada/plugin/bada/Capture.js
@@ -1,22 +1,45 @@
 module.exports = {
-    captureAudio: function() {
-        console.log("navigator.capture.captureAudio unsupported!");
-    },
-    captureVideo: function(success, fail, options) {
+    startVideoCapture: function(success, fail, options) {
         var camera = navigator.camera._mainCamera;
         camera.startVideoCapture(success, fail, options);
-        if(options.duration) {
-            Osp.Core.Function.delay(camera.stopVideoCapture, options.duration, camera);
-        }
     },
     stopVideoCapture: function() {
         navigator.camera._mainCamera.stopVideoCapture();
     },
-    captureImage: function(success, fail, options) {
+    captureImage2: function(success, fail, options) {
         try {
             navigator.camera._mainCamera.captureImage(success, fail, options);
         } catch(exp) {
             alert("Exception :[" + exp.code + "] " + exp.message);
         }
-    }
+    },
+    captureAudio: function() {
+        console.log("navigator.capture.captureAudio unsupported!");
+    },
+    captureImage: function(success, fail, options) {
+        var dataList = [];
+        dataList[0] = "type:camera";
+
+        var appcontrolobject = Osp.App.AppManager.findAppControl("osp.appcontrol.provider.camera", "osp.appcontrol.operation.capture");
+
+        if(appcontrolobject) {
+            appcontrolobject.start(dataList, function(cbtype, appControlId, operationId, resultList) {
+                var i;
+                var mediaFiles = [];
+                if(cbtype === "onAppControlCompleted") {
+                    for(i = 1 ; i < resultList.length ; i += 1) {
+                       if(resultList[i]) {
+                           //console.log("resultList[" + i + "] = " + resultList[i]);
+                           mediaFiles.push( {path: resultList[i]} );
+                       }
+                    }
+                    success(mediaFiles);
+                } else {
+                    var error = {message: "An error occured while capturing image", code: 0};
+                    fail(error);
+                }
+            });
+        }
+
+    },
 };