phone 上的视频捕获不会显示在我的图库中

Video capture to not show in my gallery on phone

我正在使用 ng-cordova 的插件捕获从移动设备捕获离子框架内的 (https://github.com/apache/cordova-plugin-media-capture) 个视频 phone。

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

    $cordovaCapture.captureVideo(options).then(function(videoData) {
        var i, path, len;
        for (i = 0, len = videoData.length; i < len; i += 1) {
            path = videoData[i].fullPath;
            console.log("Path of the video is = " + path.toString());
        }
    }, function(err) {
        // An error occurred. Show a message to the user
    });
}

问题是我拍摄的每个视频捕捉都保存到我不想要的 phone 画廊。如果我捕捉图像,它不会保存到我的 phone 的图库中,而这正是我想要的视频捕捉。有没有办法阻止视频被保存?

I tried deleting the file but apparently the video file is not saved in cordovafile directories.

function DeleteFile() {

var filename = "20161024_095758.mp4";
var relativeFilePath = "file:/storage/C8F0-1207/DCIM/Camera";
console.log('data directory: '+cordova.file.dataDirectory);
window.resolveLocalFileSystemURL(relativeFilePath, function(dir) {
dir.getFile(filename, {create:false}, function(fileEntry) {
              fileEntry.remove(function(){
                alert('file removed');
                  // The file has been removed succesfully
              },function(error){
                alert('error'+JSON.stringify(error));
                  // Error deleting the file
              },function(){
                alert('file doesnt exist');
                 // The file doesn't exist
              });
  });
});

上面删除文件的代码导致错误 Code:6。不允许修改

嗯,显然 自版本 4.4 起,我们无法从 MICRO SD 卡中删除和写入文件。现在只读。。而且,当用户从图库中删除文件时,该文件将无法用于项目。这是我想出的。

我将视频文件复制到 cordova 的外部目录,从那里我可以在需要时读取文件并根据需要删除。需要的插件是 cordova-file-plugincordova-plugin-file-transfer

.controller('yourCtrl', function($scope,$cordovaCapture,$sce,$cordovaFile, $cordovaFileTransfer, $timeout) {
       $cordovaCapture.captureVideo(options).then(function(videoData) {
            console.log(JSON.stringify(videoData[0]));
            console.log(cordova.file.externalDataDirectory);
             $cordovaFileTransfer.download(videoData[0].fullPath, cordova.file.externalDataDirectory + 'my-video.mp4', {}, true).then(
                                function(result)
                                {
                                    console.log('success: '+ result);
                                },
                                function (error)
                                {
                                    console.log('error: '+ JSON.stringify(error));
                                },function (progress) {
                                    $timeout(function () {
                                      $scope.downloadProgress = (progress.loaded / progress.total) * 100;
                                    });
                                  },false);
               $scope.clipSrc = $sce.trustAsResourceUrl(videoData[0].fullPath);
               //$scope.videoSrc = videoData[0].fullPath;
        }, function(err) {
          alert('Err: <br />'+ JSON.stringify(videoData));
        });

  //delete the file according to filename.

    $scope.deleteVideo= function(){
        $cordovaFile.removeFile(cordova.file.externalDataDirectory, "my-video.mp4")
          .then(function (result) {
            console.log('Success: deleting videoData file' + JSON.stringify(result));
          }, function (err) {
            console.log('Error: deleting videoData file' + JSON.stringify(err));
          });
      }

})