createInnerAudioContext 多次播放相同地址文件无效?

发布于 7 年前作者 minggong1563 次浏览最后编辑 7 年前来自 issues

wxml:

<view>

  <view>

    <text>

      1.第一次点击有效,间隔3秒以上再点击无效,之后两次点击之间间隔三秒内有效,超过三秒无效。\n

      2.真机调试正常,“编译并预览”有上述问题。\n

      3.机型:SM-N9200\n

    </text>

  </view>

  <button bindtap=“di”>Button</button>

</view>

js:

  di(){

    const innerAudioContext = wx.createInnerAudioContext()

    innerAudioContext.src = ‘/*******/di.mp3’  // 1秒钟音频地址

    innerAudioContext.play()

  }

2 回复
yanghan
yanghan1 楼5 年前

麻烦提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

taodeng
taodeng2 楼5 年前

可以这样试试,创建一次innerAudioContext,复用实例即可

const innerAudioContext = wx.createInnerAudioContext()
Page({
  ...
  di(url) {
     innerAudioContext.src = url
     innerAudioContext.stop()
     innerAudioContext.play()
  }
  ...
})