这是我的代码。 我使用来自离子原始mediacapture插件的captureVideo()。
获取此文件路径
/private/var/mobile/Containers/Data/Application/95DB5A64-700B-4E3D-9C2C-562C46520BEC/tmp/52515367181__BBC39D42-69EC-4384-A36F-7A512E109329.MOV
我想将此文件复制到文档目录。
CreateVide(){
//SET CAPTUREVIDOE OPTION
let videooption:CaptureVideoOptions = {limit:1};
//CAPTURE VIDEO AND GET MEDIAFILE
this.mediaCapture.captureVideo().then((videoData:Array<MediaFile>)=>{
//SAVE AS FILE
let filedir = this.file.documentsDirectory ;
//Create directory
this.file.createDir(filedir,'recordvideo',false);
//SAVE FILE
// this.file.writeFile(filedir + 'recordvideo', 'sample.mov', videoData[0]. );
console.log('success:'+ videoData[0].fullPath);
var ind = (videoData[0].fullPath.lastIndexOf('/')+1);
var orgFilename = videoData[0].fullPath.substring(ind);
var orgFilePath = videoData[0].fullPath.substring(0,ind);
console.log(orgFilename, orgFilePath,filedir + 'recordvideo');
this.file.copyFile(orgFilePath, orgFilename, filedir + 'recordvideo','sample.mov');
});
}
有可能吗? 任何帮助将不胜感激。
答案 0 :(得分:0)
CreateVideo()
{
//SET CAPTUREVIDOE OPTION
let videooption:CaptureVideoOptions = {limit:1};
//CAPTURE VIDEO AND GET MEDIAFILE
this.mediaCapture.captureVideo().then((videoData:Array<MediaFile>)=>{
//SAVE AS FILE
let filedir = this.file.documentsDirectory ;
//Create directory
this.file.createDir(filedir,'recordvideo',false);
//CHANGE PATH
var path = videoData[0].fullPath.replace('/private','file://');
var ind = (path.lastIndexOf('/')+1);
var orgFilename = path.substring(ind);
var orgFilePath = path.substring(0,ind);
//SAVE FILE
this.file.copyFile(orgFilePath, orgFilename, filedir + 'recordvideo','sample.mov');
});
}
我通过替换文件路径解决了这个程序。 更好的答案将不胜感激。