mirror of
https://gitee.com/shuto/cordova-plugin-camera.git
synced 2025-05-14 21:24:04 +08:00
Fixed minor bugs with the browser
This commit is contained in:
parent
d84b875c44
commit
986bf6fd3c
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
function takePicture(success, error, opts) {
|
function takePicture(success, error, opts) {
|
||||||
if (opts && opts[2] === 1) {
|
if (opts && opts[2] === 1) {
|
||||||
capture(success);
|
capture(success, error);
|
||||||
} else {
|
} else {
|
||||||
var input = document.createElement('input');
|
var input = document.createElement('input');
|
||||||
input.type = 'file';
|
input.type = 'file';
|
||||||
@ -34,7 +34,9 @@ function takePicture(success, error, opts) {
|
|||||||
reader.onload = function(readerEvent) {
|
reader.onload = function(readerEvent) {
|
||||||
input.parentNode.removeChild(input);
|
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]);
|
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 localMediaStream;
|
||||||
|
|
||||||
var video = document.createElement('video');
|
var video = document.createElement('video');
|
||||||
@ -71,9 +73,6 @@ function capture(success) {
|
|||||||
return success(imageData);
|
return success(imageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.appendChild(video);
|
|
||||||
document.body.appendChild(button);
|
|
||||||
|
|
||||||
navigator.getUserMedia = navigator.getUserMedia ||
|
navigator.getUserMedia = navigator.getUserMedia ||
|
||||||
navigator.webkitGetUserMedia ||
|
navigator.webkitGetUserMedia ||
|
||||||
navigator.mozGetUserMedia ||
|
navigator.mozGetUserMedia ||
|
||||||
@ -83,10 +82,9 @@ function capture(success) {
|
|||||||
localMediaStream = stream;
|
localMediaStream = stream;
|
||||||
video.src = window.URL.createObjectURL(localMediaStream);
|
video.src = window.URL.createObjectURL(localMediaStream);
|
||||||
video.play();
|
video.play();
|
||||||
}
|
|
||||||
|
|
||||||
var errorCallback = function(e) {
|
document.body.appendChild(video);
|
||||||
console.log('Error: ' + e);
|
document.body.appendChild(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (navigator.getUserMedia) {
|
if (navigator.getUserMedia) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user