使用 PhoneGap (3.0.0) 相机插件,可以捕捉新视频或从相机胶卷或相册中选择一个,但是是否可以通过 API 创建新相册?
在我们的移动应用程序项目中,在初始化阶段,我们要检查“swingAlbum”是否存在,如果不直接创建它。然后,用户将能够使用标准设备相机捕获功能将剪辑存储到此“swingAlbum”中,以供以后与我们的应用程序一起使用。
尝试这个:
<button onclick="capture()"></button>
function capture() {
navigator.camera.getPicture(getImageURI, function (message) {
alert('Image Capture Failed');
}, {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
correctOrientation: true
});
}
function getImageURI(imageURI) {
var gotFileEntry = function (fileEntry) {
// alert("got image file entry: " + fileEntry.fullPath);
var gotFileSystem = function (fileSystem) {
fileSystem.root.getDirectory('swingAlbum', {
create: true
}, function (dataDir) {
fileName = "myfile.jpg";
fileEntry.moveTo(dataDir, fileName, success, fsFail);
}, dirFail);
};
// get file system to copy or move image file to
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem, fsFail);
};
// resolve file system for image
window.resolveLocalFileSystemURI(imageURI, gotFileEntry, fsFail);
// file system fail
var fsFail = function (error) {
alert("failed with error code: " + error.code);
};
var dirFail = function (error) {
alert("Directory error code: " + error.code);
};
}