小程序音乐不能暂停好奇怪!

发布于 2022-09-11 14:49:29 字数 754 浏览 14 评论 0

console.log写在pasue()前面控制台有输出,如果把pause()写在log前面就不执行了,不知道是什么问题,。

audioPlay() {
console.log('autoplay')
InnerAudioContext.pause()
}

用的是官方案例案例能播放有声音


const innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.autoplay = true
innerAudioContext.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
innerAudioContext.onPlay(() => {
  console.log('开始播放')
})
innerAudioContext.onError((res) => {
  console.log(res.errMsg)
  console.log(res.errCode)
})

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牛↙奶布丁 2022-09-18 14:49:29

audioPlay() {
console.log('autoplay')
this.InnerAudioContext.pause()
}

白况 2022-09-18 14:49:29

大小写的问题?
InnerAudioContext
innerAudioContext

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文