我在页面里面用wx.createInnerAudioContext()创建了一个context播放英文单词的音频,然后添加了一个“下一个”按钮点击切换音频的src。当切换到40-50个的时候,会导致内存泄漏。(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit. 11,请问有什么方法可以解决这个问题吗?代码基本如下:
var innerAudioContext = wx.createInnerAudioContext() //播放音频 playVoice: function () { var that = this if (that.data.playStatus == 2){ return false } that.setData({ playStatus: 2 }) innerAudioContext.obeyMuteSwitch = false innerAudioContext.autoplay = true innerAudioContext.src = this .data.question.word_voice innerAudioContext.play() innerAudioContext.onEnded(() => { that.setData({ playStatus: 1 }) }) innerAudioContext.onError((res) => { wx.showModal({ title: '温馨提示' , content: res.errMsg, showCancel: false , success: function () { that.setData({ playStatus: 1 }) } }) }) } //下一个 chooseNext: function (e) { innerAudioContext.stop() var nindex = this .data.questionIndex + 1 var nquestion = this .data.questionArr[nindex] this .setData({ questionIndex: nindex, question: nquestion, playStatus: 1 }) this .playVoice() }, |
请问有没有英文单词转语音播放的接口
http://dict.youdao.com/dictvoice?audio=
找到这个,但是不知道怎么实现,你实现了通知一声
你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。