语音合成ios、华为无法播放
发布于 4 年前 作者 oyu 18420 次浏览 来自 问答
  1. 使用tts,合成的音频在开发工具可以正常播放,部分安卓机也可以正常播放,但是ios和华为无法播放

  2. 使用backgroundAudioManager.onEnded无法进入到方法内部

js代码:

playButton: function () {
  this.playAudio(0)
  this.setData({
    currentIndex: 0
  })
},
 
pauseButton: function () {
  wx.pauseBackgroundAudio()
},
 
playAudio: function (e) {
  var that = this
  this.createAudio('http://dev.hivoice.cn/TTSServlet?text=' + that.data.contentLists[e] + '&voiceName=xiaoli&voicePitch=50&voiceSpeed=50&voiceVolume=50')
},
 
createAudio: function (playUrl) {
  let that = this
  const backgroundAudioManager = wx.getBackgroundAudioManager()
  wx.playBackgroundAudio({
    dataUrl: playUrl,
    title: that.data.title
  })
  wx.onBackgroundAudioStop(function () {
    that.next()
  })
  // backgroundAudioManager.onEnded(()=> {
  //   that.next()
  // })
},
 
next: function () {
  let that = this
  if (that.data.currentIndex != that.data.maxIndex) {
    that.setData({
      currentIndex: that.data.currentIndex + 1
    })
    that.playAudio(that.data.currentIndex)
  }
}
1 回复

你好,我用华为手机播放正常,请提供无法正常播放的手机设备型号和微信版本号

回到顶部