如何使Cordova Media捕获不保存到图库

时间:2017-08-31 01:59:13

标签: cordova ionic-framework storage media

我正在尝试使用Cordova Media Capture在我的应用中拍摄短视频片段。由于这些视频很短,我不想将它们保存在用户手机上。 API似乎没有指定执行此操作的选项。我该如何实现这样的东西?

1 个答案:

答案 0 :(得分:0)

您可以使用 cordovaFileTransfer 插件将捕获的视频文件发送到您首选的位置。

$scope.captureVideo = function() {
    var options = { limit: 3, duration: 15 };

        $cordovaCapture.captureVideo(options).then(function(videoData) {
        // Success! Video data is here
        /** following is sample usage to upload the video to server.**/
                    path = videoData[0].localURL;
                    var options = new FileUploadOptions();
                    options.fileKey = "uploadfile";                
                    options.fileName = videoData[0].name;
                    options.mimeType = "video/mp4";
         $cordovaFileTransfer.upload("video-upload-url", path, options).then(function (result) {

                //Success! Video file uploaded to destination.

                    }, function (err) {
                        console.log(err);
                    },                 
                    function (progress) {
                        if (progress.lengthComputable) {
                        } else {}
                    });
        }, function(err) {
        // An error occurred. Show a message to the user
        });   }

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-media-capture/

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/index.html