录音接口wx.playVoice,首次播放暂停之后,再次播放无响应
/** * 监测录音播放点击事件 */bindPlayRecordTap() { this.data.playing ? this.pauseVoice1() : this.playVoice1();},/** * 播放录音 */playVoice1() { console.log('play voice'); const that = this; wx.playVoice({ filePath: this.data.recordData, success(res) { console.log(res); that.setData({ playing: true }); }, fail(err) { console.log(err); }, complete(res) { console.log(res); } });},/** * 暂停录音 */pauseVoice1() { console.log('pause voice'); this.setData({ playing: false }); wx.pauseVoice();}, |
运行结果如下
首次点击播放之后,可以正常播放。播放途中暂停,再次点击播放,wx.playVoice()方法既不正常调用,也不提示错误。
从运行的结果可以看到,首次点击播放之后,wx.playVoice()返回了两次success的结果,不知道是不是因为这个原因引起的问题。
请问这个要如何解决。谢谢。
