wx.previewMedia ios真机不能播放本地视频
https://developers.weixin.qq.com/minigame/dev/api/media/image/wx.previewMedia.html
// 显示图片和视频
showImages: function (data) {
var type = data.currentTarget.dataset.type
var baseUrl = app.globalData.API_BASE_URL + "/file/getFile/"
var url = baseUrl + data.currentTarget.dataset.url
var ext = url.substring(url.lastIndexOf("."), url.length);
wx.showLoading({
title: '资源下载中...',
})
wx.downloadFile({
url: url,
filePath: `${wx.env.USER_DATA_PATH}/${+ new Date}_` + type + ext,
success: function (res) {
console.log(res)
const filePath = res.filePath
var fileType = 'image';
if (type == '3') {
fileType = 'video'
}
var source = {
url: filePath,
type: fileType
}
// 同时支持图片和视频预览
wx.previewMedia({
sources: [source],
success: function(e) {
console.log(e)
},
fail: function (e) {
console.log(e)
}
},true)
},
fail: function (res) {
console.log(res)
},
complete: function (res) {
wx.hideLoading()
},
})
},