由于 remote 地址中有特殊字符,导致播放报错,可以把地址使用 encodeURI 转换后即可正常播放。
示例代码 let innerAudioContext = uni.createInnerAudioContext(); innerAudioContext.autoplay = true;
let path = res.message.remote; let encodePath = encodeURI(path) innerAudioContext.src = encodePath;
innerAudioContext.onPlay(() => { console.log('开始播放'); }); innerAudioContext.onError((res) => { console.log(res.errMsg); console.log(res.errCode); });
详情查看:https://www.rongcloud.cn/?utm_source=SEO&utm_term=helloworld