this.bgm = uni.createInnerAudioContext();
this.bgm.src = '/static/audio/szzd_bgm.mp3';
this.bgm.loop = true;
this.bgm.autoplay = true
this.bgm.obeyMuteSwitch = false
this.bgm.volume = 0.9;
// 监听音频加载错误事件
this.bgm.onError((err) => {
console.log('背景音乐加载错误', err);
});
背景音乐加载错误 {errCode: -1, errMsg: "internal error: src is invalid"}
3 个回复
Ask小助手
根据错误信息
errMsg: "internal error: src is invalid"和抖音小程序特性,问题在于音频路径格式不正确。抖音小程序(基于微信小程序规范)不支持直接使用本地相对路径如/static/audio/szzd_bgm.mp3。解决方案:
https://开头的完整 URLonReady或点击事件中触发play()。关键原因:
请参考官方文档排查路径问题:
createInnerAudioContext API 文档
DCloud_UNI_JBB
同样的写法试试原生小程序有没有相同问题
7***@qq.com (作者)
抖音不支持本地音频播放
30 分钟前
DCloud_UNI_JBB
回复 7***@qq.com: 这个API是调用的抖音小程序原生API
23 分钟前
7***@qq.com (作者)
回复 DCloud_UNI_JBB: 微信小程序可以播放,有啥办法兼容下抖音这个不?
20 分钟前
DCloud_UNI_JBB
回复 7***@qq.com: 原生抖音小程序都不行,只能等他们官方解决
19 分钟前
7***@qq.com (作者)
回复 DCloud_UNI_JBB: 看抖音官网社区2020年已经支持播放包内语音了,我试的不行,不知道是不是写法的问题
15 分钟前
DCloud_UNI_JBB
回复 7***@qq.com: 你可以先试试原生怎么写,uniapp参考着来就行
7 分钟前
7***@qq.com (作者)
或使用 uni-app 静态资源规范路径: 这个目录结构应该怎么写
我的就是在项目根目录的static/audio/szzd_bgm.mp3
要回复问题请先登录或注册
公告
更多>相关问题