cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject git commit: Fixed minor bugs with the browser
Date Wed, 10 Sep 2014 23:38:58 GMT
Repository: cordova-plugin-camera
Updated Branches:
  refs/heads/master d84b875c4 -> 986bf6fd3


Fixed minor bugs with the browser


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/986bf6fd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/986bf6fd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/986bf6fd

Branch: refs/heads/master
Commit: 986bf6fd3c4669d5839a4885560ff7caa84d919a
Parents: d84b875
Author: Suraj Pindoria <suraj.pindoria@yahoo.com>
Authored: Wed Sep 10 15:38:09 2014 -0700
Committer: Suraj Pindoria <suraj.pindoria@yahoo.com>
Committed: Wed Sep 10 15:38:09 2014 -0700

----------------------------------------------------------------------
 src/browser/CameraProxy.js | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/986bf6fd/src/browser/CameraProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/CameraProxy.js b/src/browser/CameraProxy.js
index 5756c48..0944e58 100644
--- a/src/browser/CameraProxy.js
+++ b/src/browser/CameraProxy.js
@@ -21,7 +21,7 @@
 
 function takePicture(success, error, opts) {
     if (opts && opts[2] === 1) {
-        capture(success);
+        capture(success, error);
     } else {
         var input = document.createElement('input');
         input.type = 'file';
@@ -34,7 +34,9 @@ function takePicture(success, error, opts) {
             reader.onload = function(readerEvent) {
                 input.parentNode.removeChild(input);
 
-                return success(readerEvent.target.result.replace('data:image/png;base64,',
''));
+                var imageData = readerEvent.target.result;
+
+                return success(imageData.substr(imageData.indexOf(',') + 1));
             }
 
             reader.readAsDataURL(inputEvent.target.files[0]);
@@ -44,7 +46,7 @@ function takePicture(success, error, opts) {
     }
 }
 
-function capture(success) {
+function capture(success, errorCallback) {
     var localMediaStream;
 
     var video = document.createElement('video');
@@ -71,9 +73,6 @@ function capture(success) {
         return success(imageData);
     }
 
-    document.body.appendChild(video);
-    document.body.appendChild(button);
-
     navigator.getUserMedia = navigator.getUserMedia ||
                              navigator.webkitGetUserMedia ||
                              navigator.mozGetUserMedia ||
@@ -83,10 +82,9 @@ function capture(success) {
         localMediaStream = stream;
         video.src = window.URL.createObjectURL(localMediaStream);
         video.play();
-    }
 
-    var errorCallback = function(e) {
-        console.log('Error: ' + e);
+        document.body.appendChild(video);
+        document.body.appendChild(button);
     }
 
     if (navigator.getUserMedia) {


Mime
View raw message