音频api和背景音乐api在手机上播放不支持音频源
发布于 6 年前 作者 nhan 8199 次浏览 来自 官方Issues
  • 当前 Bug 的表现(可附上截图)

const innerAudioContext = wx.createInnerAudioContext()

innerAudioContext.autoplay = true

innerAudioContext.src = http://lhttp.qingting.fm/live/339/64k.mp3

innerAudioContext.onPlay(() => {

console.log(‘开始播放’)

})

innerAudioContext.onError((res) => {

console.log(res.errMsg)

console.log(res.errCode)

})

const backgroundAudioManager = wx.getBackgroundAudioManager()

backgroundAudioManager.title = ‘此时此刻’

backgroundAudioManager.epname = ‘此时此刻’

backgroundAudioManager.singer = ‘许巍’

backgroundAudioManager.coverImgUrl = http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000

// 设置了 src 之后会自动播放

backgroundAudioManager.src = http://lhttp.qingting.fm/live/339/64k.mp3

backgroundAudioManager.onError((res) => {

console.log(res.errMsg)

console.log(res.errCode)

})

  • 预期表现

在开发者工具中能正常播放,在手机上就不能行了,希望能够解决这个问题

  • 复现路径
  • 提供一个最简复现 Demo

音频播放api

const innerAudioContext = wx.createInnerAudioContext()

innerAudioContext.autoplay = true

innerAudioContext.src = http://lhttp.qingting.fm/live/339/64k.mp3

innerAudioContext.onPlay(() => {

console.log(‘开始播放’)

})

innerAudioContext.onError((res) => {

console.log(res.errMsg)

console.log(res.errCode)

})

背景音乐api

const backgroundAudioManager = wx.getBackgroundAudioManager()

backgroundAudioManager.title = ‘此时此刻’

backgroundAudioManager.epname = ‘此时此刻’

backgroundAudioManager.singer = ‘许巍’

backgroundAudioManager.coverImgUrl = http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000

// 设置了 src 之后会自动播放

backgroundAudioManager.src = http://lhttp.qingting.fm/live/339/64k.mp3

backgroundAudioManager.onError((res) => {

console.log(res.errMsg)

console.log(res.errCode)

})

1 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部