let innerAudioContext = null;
onLoad: function (options) {
innerAudioContext = wx.createInnerAudioContext({
useWebAudioImplement: true
});
//以下监听事件只需要注册一次就行
innerAudioContext.onPlay(() => { //监听播放事件
})
innerAudioContext.onStop(() => { //监听停止事件
})
innerAudioContext.onPause(() => { //监听暂停事件
})
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
},
//播放录音 第一种方式 --------
playRecord: function (e) {
var idx = parseInt(e.currentTarget.dataset.index);
var src = that.data.wxchatLists[idx].content;
console.log(src)
innerAudioContext.src = res.tempFilePath;
innerAudioContext.play();
},
//播放录音 第二种方式 --------
playRecord2: function (e) {
var idx = parseInt(e.currentTarget.dataset.index);
var src = that.data.wxchatLists[idx].content;
console.log(src)
wx.downloadFile({
url: src,
success: (res) => {
if (res.statusCode === 200) {
console.log('下载成功');
innerAudioContext.src = res.tempFilePath;
innerAudioContext.play();
}
}
})
},
在模拟器上很流畅,可以正常播放, 在手机上真机测试的时候点击无反应,出现
{"errCode": 26, "errMsg": "data error"}
或者
set audio src "https://img.3craftsman.cn/storage/audios/20230717/*******.mp3" fail: data error
这个报错不清楚是哪一步报错的,request合法域名也有添加,https证书也没有问题,src路径固定写死或者本地路径都试了, 都是出现 "errCode": 26。
调试基础库:2.33.0
测试手机:华为P40
麻烦帮我看一下哈~ 比较着急 SOS!
其他手机会有这个问题吗
图二:华为P40 (鸿蒙)
请具体描述问题出现的流程,并按照链接提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。