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/04/24 21:03:03 UTC

[3/3] git commit: adding camera/preview support

adding camera/preview support


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/f28da938
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/f28da938
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/f28da938

Branch: refs/heads/master
Commit: f28da938d9b9c6e4c79aa83a808e2626ec776cc9
Parents: 2557edf
Author: Anis Kadri <an...@gmail.com>
Authored: Tue Apr 24 12:01:53 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Tue Apr 24 12:01:53 2012 -0700

----------------------------------------------------------------------
 lib/bada/plugin/bada/Camera.js |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f28da938/lib/bada/plugin/bada/Camera.js
----------------------------------------------------------------------
diff --git a/lib/bada/plugin/bada/Camera.js b/lib/bada/plugin/bada/Camera.js
new file mode 100644
index 0000000..10a5e4f
--- /dev/null
+++ b/lib/bada/plugin/bada/Camera.js
@@ -0,0 +1,31 @@
+module.exports = {
+      _mainCamera: null,
+      _cams: [],
+      getPicture: function(cameraSuccess, cameraFailure, cameraOptions) {
+       // TODO
+      },
+      getPreview: function() {
+       var self = this;
+       var onCreatePreviewNodeSuccess = function(previewObject) {
+           var previewDiv = document.getElementById("preview");
+           previewId = previewObject.id;
+           previewDiv.appendChild(previewObject);
+           previewObject.style.visibility = "visible";
+       };
+       var error = function(e) {
+           alert("An error occured: " + e.message);
+       };
+        
+       var success = function(cams) {
+           if (cams.length > 0) {
+            self._cams = cams;
+               self._mainCamera = cams[0];
+               self._mainCamera.createPreviewNode(onCreatePreviewNodeSuccess, error);
+               return;
+           }
+           alert("Sorry, no cameras available.");
+       };
+       deviceapis.camera.getCameras(success, error);
+      }
+};
+