Camera 如何使用phonegap framework7模板访问相机并拍照?
我需要摄像头才能拍照。我使用了framework7模板。Camera 如何使用phonegap framework7模板访问相机并拍照?,camera,phonegap,html-framework-7,camera-api,Camera,Phonegap,Html Framework 7,Camera Api,我需要摄像头才能拍照。我使用了framework7模板。 我尝试了一些不同的方法,但失败了。使用了插件 1. 二, 设计 <div id="Photos"> <a href="#" onclick="ImageSourceShareSheet()" style="text-decoration:none"> <p class="footermenutext">Photos</p>
我尝试了一些不同的方法,但失败了。使用了插件
1.
二, 设计
<div id="Photos">
<a href="#" onclick="ImageSourceShareSheet()" style="text-decoration:none">
<p class="footermenutext">Photos</p>
</a>
</div>
太多了,伙计
//Onclick Event for Photos Icon
function ImageSourceShareSheet() {
//Options for Customize Actionsheet
var options = {
'title': 'Select Image Source',
'buttonLabels': ['Camera', 'Photo Library'],
'addCancelButtonWithLabel': 'Cancel',
'position': [20, 40] // for iPad pass in the [x, y] position of the popover
};
window.plugins.actionsheet.show(options, callback);
}
//Actionsheet Callback function
function callback(buttonIndex) {
switch (buttonIndex) {
case 1:
capturePhoto();
break;
case 2:
SelectPhotosfromLibrary();
break;
}
}
//Take image source from Camera
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail,{
quality : 25,
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA,
allowEdit : true,
encodingType: Camera.EncodingType.JPEG,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true });
}
function SelectPhotosfromLibrary() {
window.imagePicker.getPictures(
function(results) {
alert(JSON.stringify(results));
if(results.length != 0)
{
// Photo Selected
}
else
{
// No photos Selected!
}
}, function (error) {
console.log('Error: ' + error);
}
);
}