incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [13/17] bada-wac commit: adding camera preview
Date Sat, 28 Apr 2012 00:27:55 GMT
adding camera preview


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/commit/06e81ddd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/tree/06e81ddd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/diff/06e81ddd

Branch: refs/heads/master
Commit: 06e81ddd2fd81c00d64d6beff472abb0b3969fdc
Parents: fa18c75
Author: Anis Kadri <anis.kadri@gmail.com>
Authored: Fri Apr 6 17:21:53 2012 -0700
Committer: Anis Kadri <anis.kadri@gmail.com>
Committed: Fri Apr 6 17:21:53 2012 -0700

----------------------------------------------------------------------
 Res/index.html   |    8 ++++++++
 Res/js/camera.js |   26 ++++++++++++++++++++++++++
 Res/js/sample.js |    4 ++++
 3 files changed, 38 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/06e81ddd/Res/index.html
----------------------------------------------------------------------
diff --git a/Res/index.html b/Res/index.html
index 86cbf94..d75caae 100644
--- a/Res/index.html
+++ b/Res/index.html
@@ -98,7 +98,15 @@ button.btn {
 				<button type="button" class="btn" onclick="notificationLightOn();">Light ON</button>
 			</div>
 		</li>
+		<li>
+			<h3>Camera</h3>
+			<div>
+				<button type="button" class="btn" onclick="getCameraPreview();">Camera</button>
+			</div>
+			<div id="preview"></div>
+		</li>
 	</ul>
+<script type="text/javascript" src="./js/camera.js"></script>
 <script type="text/javascript" src="./js/notification.js"></script>
 <script type="text/javascript" src="./js/connection.js"></script>
 <script type="text/javascript" src="./js/accelerometer.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/06e81ddd/Res/js/camera.js
----------------------------------------------------------------------
diff --git a/Res/js/camera.js b/Res/js/camera.js
new file mode 100644
index 0000000..6d48436
--- /dev/null
+++ b/Res/js/camera.js
@@ -0,0 +1,26 @@
+navigator.camera = {
+		getPicture: function(cameraSuccess, cameraFailure, cameraOptions) {
+			// TODO
+		},
+		getPreview: function() {
+			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) {
+			        mainCamera = cams[0];
+			        mainCamera.createPreviewNode(onCreatePreviewNodeSuccess, error);
+			        return;
+			    }
+			    alert("Sorry, no cameras available.");
+			};
+			deviceapis.camera.getCameras(success, error);
+		}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/06e81ddd/Res/js/sample.js
----------------------------------------------------------------------
diff --git a/Res/js/sample.js b/Res/js/sample.js
index 1ffd6ab..a0e58f3 100644
--- a/Res/js/sample.js
+++ b/Res/js/sample.js
@@ -198,4 +198,8 @@ function notificationBeep() {
 
 function notificationLightOn() {
 	navigator.notification.lightOn(2000);
+}
+
+function getCameraPreview() {
+	navigator.camera.getPreview();
 }
\ No newline at end of file


Mime
View raw message