wx.downloadFile是报错,视频地址是http://www.iesdouyin.com/aweme/v1/play/?video_id=v0200fg10000col413jc77u6dot73i8g&ratio=1080p&line=0,
放到浏览器可以正常播放,使用这个组件时开发工具却下载了一个json文件,手机调试是直接报错的,报的就是downloadFile:fail file data is empty?
downloadVideo: function() {
let that = this;
let url_video = that.data.url_video;
console.log(url_video)
if (!url_video.includes("https")){
url_video = url_video.replace("http","https")
}
let httpHost = app.globalData.httpHost;
console.log("执行了")
let task = wx.downloadFile({
url: url_video,
success(res) {
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success(res) {
console.log(res.errMsg)
wx.showToast({
title: '保存成功',
})
},
fail(res){
wx.showModal({
title: '提示',
content: '视频未保存成功',
showCancel: true,
confirmText: '确定',
})
}
})
}
},
fail(res){
console.log("错误信息:"+res.errMsg)
wx.showModal({
title: '提示',
content: res,
showCancel: true,
confirmText: '确定',
})
}
})
你这个不是视频文件地址吧