欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > 微信小程序上传视频,解决ios上传完video组件无法播放

微信小程序上传视频,解决ios上传完video组件无法播放

2025/5/12 23:17:49 来源:https://blog.csdn.net/weixin_44705979/article/details/147796446  浏览:    关键词:微信小程序上传视频,解决ios上传完video组件无法播放

1.碰到问题
工单里面上传完视频video组件ios无法播放视频,安卓可以
2.原因
使用了后台接口返回的url拼域名 , 正确做法:使用wx.chooseMedia()里面的tempFilePath(本地临时文件路径 (本地路径)),上传好了详情可以使用后台返回的url拼域名
3.代码

		/*上传视频*/chooseVideo() {uni.chooseMedia({maxDuration: 30, //拍摄视频最长拍摄时间,单位秒。最长支持 60 秒count: 1,mediaType: ["video"],sourceType: ['album', 'camera'],sizeType:['compressed'],success: res => {if (res.size / 1024 / 1024 > 20) {return uni.showToast({icon: "none",title: "拍摄视频过大,请重新拍摄!",});}console.log('kkkk')console.log(res)console.log('kkkk')this.uploadFile(res.tempFiles[0]);}})},/*视频上传*/uploadFile(file) {let that = this;uni.showLoading({title: "努力加载中",mask: true});console.log(file)this.videoList.push(file.tempFilePath) // 重要代码!!!!!!!// 以文件流的方式上传文件uni.uploadFile({url: that.$A.uploadFiles,filePath: file.tempFilePath || "",name: "file",formData: {attachType: 'breakdown'},header: {Authorization: wx.getStorageSync("token")},success: async (res) => {uni.hideLoading()let resp = JSON.parse(res.data)console.log(resp)if (resp && resp.status == 200) {that.saveVideoList = []let urls = BASEURL + resp.data.attachPaththat.saveVideoList.push(resp.data)}},fail: (err) => {uni.hideLoading()console.log("图片上传接口调用失败", err);},});},

4.参考文档
在这里插入图片描述
微信小程序文档
5.效果
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词