transformLanguage(message) {
return new Promise(resolve => {
let text = encodeURIComponent(encodeURIComponent(message))
wx.downloadFile({
url: baiduUrl + '?tex=' + text + '&lan=zh&cuid=B9-48&ctp=1&spd=15&aue=3&tok=' + this.data.voiceToken,
success: res => {
if (res.statusCode === 200) {
const innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.src = encodeURI(res.tempFilePath)
wx.setInnerAudioOption({
obeyMuteSwitch: false,
mixWithOther: false
})
innerAudioContext.play()
innerAudioContext.onPlay(() => {
})
innerAudioContext.onEnded(() => {
innerAudioContext.destroy()
resolve()
})
innerAudioContext.onStop(() => {
})
innerAudioContext.onWaiting(() => {
})
innerAudioContext.onTimeUpdate(() => {
})
innerAudioContext.onError((res) => {})
}
}
})
})
}
创建音频代码片段如上,在本地真机测试都正常,放到体验版和线上,安卓手机正常,IOS只有第一次播放,后面音频就不播放了。
机型 iPhone11 pro max,IOS 14.3。
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。