所以在休息了几个星期之后,回到这个问题上,我发现了这个问题。
事实证明,我一直在使用的插件正在剥离字符串中非常重要file://
的部分的fileURI(我以前没有使用过) 。所以我只剩下/var/mobile/Containers/Data/Application/69BCC8B8-D539-4BA3-AD6B-B3ECBD8DEDE9/Library/Caches/myvideo_17.mp4
.
所以在修复字符串之后(就像你在使用 base64Url 时所做的那样)。我最终得到以下结果:
'file://' + fileURI
;
总之,我的代码现在看起来像这样:
resolveFileSystemUrl(media){
let fixed = 'file://' + media;
this.file.resolveLocalFilesystemUrl(fixed)
.then(result => {
this.resolveFileEntry(result);
}).catch(err => {console.error('Error resolving the file system url'); });
}
resolveFileEntry(res) {
res.file((resFile) => {
let reader = new FileReader();
reader.readAsDataURL(resFile);
reader.onloadend = (evt: any) => {
// the base64 of the video is: evt.target.result
}
});
}