我正在制作一个必须在后台拍照的应用程序,即没有交互。我目前正在使用的是cordova-plugin-camera,但这会打开一个交互式选项,用户必须手动点击该照片。
navigator.camera.getPicture(successCallback, FailCallback, {
destinationType: Camera.DestinationType.DATA_URL,
cameraDirection: 1,
quality: 25,
targetWidth: 300,
targetHeight: 300
});
答案 0 :(得分:0)
示例代码:
function success(imgurl) {
console.log("Imgurl = " + imgurl);
}
function onFail(message) {
alert('Failed because: ' + message);
}
function CaptureBCK() {
var options = {
name: "Image", //image suffix
dirName: "CameraPictureBackground", //foldername
orientation: "portrait", //or landscape
type: "back" //or front
};
window.plugins.CameraPictureBackground.takePicture(success, onFail, options);
}
<button onclick="CaptureBCK();">Capture Photo</button>
您可以在设备的CameraPictureBackground目录下找到您的照片。