const downloadTask = uni.downloadFile({
url: url, // 视频的下载地址
success: (data) => {
if (data.statusCode === 200) {
uni.saveImageToPhotosAlbum({ // 需要保存到相册 如果是下载文件 用uni.saveFile()
filePath: data.tempFilePath, // 视频的本地临时地址
success: function (res) {
console.log('下载成功')
uni.showToast({
title: '下载完成,请到相册查看',
position: 'center',
icon: 'none',
duration: 2000
});
},
fail: () => {
uni.showToast({
title: '下载视频失败请重试',
position: 'center',
icon: 'none',
duration: 2000
});
}
});
}
},
fail: (err)=>{
this.downText = '下载视频'
uni.hideLoading()
uni.showToast({
title: err,
position: 'center',
icon: 'none',
duration: 2000
});
},
complete: ()=>{
this.downText ='下载视频'
}
});
downloadTask.onProgressUpdate((res) => { // 下载进度
this.downText = `已下载${res.progress}%`
if(res.progress == 100){
this.downText = '下载视频'
}
});

雷霆嘎巴
- 发布:2020-12-25 15:18
- 更新:2020-12-26 11:55
- 阅读:1418
App 下载视频到本地相册
分类:uni-app
2 个评论
要回复文章请先登录或注册
[已删除]
MonikaChen