微信咨询

微信咨询

13610*910*9

服务热线 7*24小时

电话咨询

微信小程序点击播放MP3音频文件

iamdu2022-05-30 18:24:04 浏览: 897300
onload({
this.innerAudioContext = wx.createInnerAudioContext(); //初始化音频播放文件
}) 

    /*选择发音员*/
    goSelectVoice: function(e) {
      let that = this
      var a = e.currentTarget.dataset.index //当前选择的选项ID
      this.setData({
          selectVoice: a
      })
//
      this.innerAudioContext && this.innerAudioContext.stop(), 
      this.innerAudioContext.src = 'https://btaotao-1255753702.cos.ap-guangzhou.myqcloud.com/qushuiyinxcx/ico/'+ a +'.mp3' 
      this.innerAudioContext.play();
//
    },
//页面退出时销毁音频播放
    onUnload:function(){
      this.innerAudioContext.destroy();
    },