Taro.createInnerAudioContext()

创建内部 audio 上下文 InnerAudioContext 对象。

参考文档

类型

  1. () => InnerAudioContext

参数

示例代码

  1. const innerAudioContext = Taro.createInnerAudioContext()
  2. innerAudioContext.autoplay = true
  3. innerAudioContext.src = 'https://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
  4. innerAudioContext.onPlay(() => {
  5. console.log('开始播放')
  6. })
  7. innerAudioContext.onError((res) => {
  8. console.log(res.errMsg)
  9. console.log(res.errCode)
  10. })

API 支持度

API微信小程序H5React Native
Taro.createInnerAudioContext✔️✔️✔️