PhoneGap的/科尔多瓦 - 是否有可能创建设备媒体库新专辑? [英] PhoneGap/Cordova - Is it possible to create a new album in the device media library?

查看:104
本文介绍了PhoneGap的/科尔多瓦 - 是否有可能创建设备媒体库新专辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,可以捕捉新的视频或选择一个从相机胶卷或专辑
然而,是有可能创造通过API新专辑?

using PhoneGap (3.0.0) Camera plugin, one can capture new video or select one from the camera roll or album however is it possible to create a new album via API ?

在我们的移动应用项目,在初始阶段,我们要检查,如果swingAlbum存在,如果不能直接创建它。然后,用户将能够使用与我们的应用程序以后使用标准设备摄像头采集功能将剪辑保存到这个'swingAlbum。

In our mobile app project, during the init phase, we want to check if 'swingAlbum' exist and if not create it directly. Then the user will be able to store clips into this 'swingAlbum' using the standard device camera capture feature for later use with our app.

推荐答案

试试这个:

   <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);

        };
    }

这篇关于PhoneGap的/科尔多瓦 - 是否有可能创建设备媒体库新专辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆