视频格式mp4,大小未超200M,ios真机运行保存到手机失败,试过了网上说的“永久文件路径保存”,依然保存失败
解决方法: 文件下载后进行压缩再保存至本地
saveVideo() {
uni.showLoading({title:'保存中……'})
uni.downloadFile({
url: this.swiperVideo[0], // 此为视频下载地址
success: (res) => {
if (res.statusCode === 200) {
uni.compressVideo({ // 压缩下载返回的地址
src: res.tempFilePath, // 下载成功的临时路径
quality:'high',
success: (res1) => {
uni.saveVideoToPhotosAlbum({
filePath: res1.tempFilePath, // 压缩后的路径
success: (errMsg)=>{
console.log('成功', errMsg)
uni.hideLoading()
uni.showToast({
mask: true,
title: '保存成功'
});
},
fail: (errMsg) => {
console.log('失败', errMsg)
uni.hideLoading()
uni.showToast({
mask: true,
title: '保存失败'
});
},
});
}
})
}
}
})
},