小程序视频下载安卓端,pc端,体验版都没问题。ios下载就报错,分享解决办法

代码

复制代码
videos.forEach((url, index) => {
						var filepath = wx.env.USER_DATA_PATH + '/' + new Date().valueOf() + '.mp4'
						uni.downloadFile({
							url: url, //视频的地址
							filePath: filepath,
							header: {
								'content-type': 'application/json'
							},
							success: function(res) {
								console.log(res, '111')
								uni.saveVideoToPhotosAlbum({
									// filePath: modifiedPath,
									filePath: res.filePath,
									success: (ers) => {
										uni.hideLoading();
										setTimeout(() => {
											uni.showToast({
												title: '保存成功'
											});
										}, 600)
									},
									fail: (err) => {
										console.log(err, '444')
										uni.showToast({
											title: '保存失败',
											icon: 'error'
										});
									}
								});
                                 },
							fail: (err) => {
								console.log(err, '1012')
							},
						})
					})

苹果端报错:

后来查了大量资料,找到

一试就成了,视频格式转换可以下载《格式工厂》

,在记录一个安卓苹果都能用的图片下载

复制代码
uni.showLoading({
					title: '素材下载中'
				});
				var image = images
				// 图片下载
				let filename = new Date().getTime() + ".jpg";
				if (images.length > 0) {
					image.forEach((url, index) => {
						let uniqueFilename = new Date().getTime() + "_" + index + ".jpg";
						let filePath = wx.env.USER_DATA_PATH + "/" + uniqueFilename; // 每次生成唯一的文件路径
						uni.downloadFile({
							url: url, //图片的地址
							filePath: filePath,
							success: function(res) {
								uni.saveImageToPhotosAlbum({
									filePath: res.filePath,
									success: (red) => {
										uni.hideLoading();
										setTimeout(() => {
											uni.showToast({
												title: '保存成功'
											});
										}, 600)
									},
									fail: (err) => {
										console.log(err, '000')
										uni.hideLoading();
										uni.showToast({
											title: '保存失败',
											icon: 'error'
										});
									}
								});
							},
							fail: (err) => {
								console.log(err)
							},
						})
					})
				}
相关推荐
hjlgs1 小时前
framework修改快速验证
android
游戏开发爱好者81 小时前
iOS 开发者的安全加固工具,从源码到成品 IPA 的多层防护体系实践
android·安全·ios·小程序·uni-app·cocoa·iphone
安卓理事人2 小时前
安卓内存泄露排查LeakCanary
android
玄微云2 小时前
如何选择可靠的产后修复营销小程序?市场分析与实用指南
小程序
秃了也弱了。3 小时前
MySQL空间函数详解,MySQL记录经纬度并进行计算
android·数据库·mysql
.豆鲨包4 小时前
【Android】Binder机制浅析
android·binder
游戏开发爱好者84 小时前
Charles 抓不到包怎么办?从 HTTPS 代理排错到底层数据流补抓的完整解决方案
网络协议·http·ios·小程序·https·uni-app·iphone
Nerve5 小时前
GooglePay: API 文档
android·google
Nerve6 小时前
GooglePay: 订阅商品购买流程
android·google
summerkissyou19876 小时前
Audio-触摸音-播放流程
android