收藏
回答

手机上播放云端音乐,第一次点击不播或播上次请求的,点一遍,再点播放就没问题,是什么情况?

<view capture-bind:longpress="startRecord" mut-bind:touchend="stopRecord" bindtap="playVoice" data-id="{{item._id}}" data-voice="{{item.voice}}">


回答关注问题邀请回答
收藏

2 个回答

  • hongi
    hongi
    发表于小程序端
    2021-12-30

    qqq

    2021-12-30
    有用
    回复
  • 黄明
    黄明
    2021-12-30

    playVoice: function (e) {

    const voice = e.currentTarget.dataset.voice

    voicePlayer.src = voice

    voicePlayer.play()

    },


    2021-12-30
    有用
    回复 5
    • chenmoumou
      chenmoumou
      2021-12-30
      你用的是wx.createInnerAudioContext创造出来的audio对象吗
      2021-12-30
      1
      回复
    • 黄明
      黄明
      2021-12-30回复chenmoumou
      const voiceReciver = wx.getRecorderManager()
      const voicePlayer = wx.createInnerAudioContext()
      是的
      2021-12-30
      回复
    • chenmoumou
      chenmoumou
      2021-12-30回复黄明
      切换src的时候 先pause/stop,然后销毁实例,在重新创建实例对象 这时候更改src, 把播放放在onCanplay里,然后再试试看
      2021-12-30
      回复
    • 黄明
      黄明
      2021-12-30回复chenmoumou
      playVoice: function (e) {
          voicePlayer.stop()
          const i = e.currentTarget.dataset.i
          const voice = this.data.word[i].voice
          if (voice) {
            voicePlayer.src = voice
            voicePlayer.play()
          }
        },
      2021-12-30
      回复
    • 黄明
      黄明
      2021-12-30
      打开页面,点到一个播放,可以。后面的再点就需要点二次播放,第一次感觉滋啦一下
      2021-12-30
      回复
登录 后发表内容