html5怎么调用手机摄像头并且扫描二维码
发布网友
发布时间:2022-04-20 02:39
我来回答
共1个回答
热心网友
时间:2022-04-20 00:23
参考,需要加载cordova.js 方法:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
} //相册
function fromCamera() {
var source = pictureSource.PHOTOLIBRARY; navigator.camera.getPicture(function (imageData) {
setimg(imageData);
}, function (message) {
if (source == pictureSource.CAMERA) alert('加载照相机出错!' + message); else alert('加载相册出错!' + message);
}, { quality: 50, destinationType: destinationType.FILE_URI, sourceType: source }); } //拍照 function EditImgPz() { navigator.camera.getPicture(function (imageData) { setimg(imageData);
}, function (message) { alert(message);
}, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.CAMERA, allowEdit: true, encodingType: Camera.EncodingType.JPEG, popoverOptions: CameraPopoverOptions, saveToPhotoAlbum: true }); }