求助:wx.createInnerAudioContext()停止当前播放的音频
求助:wx.createInnerAudioContext() 如何停止停止当前播放的音频,官方文档没有示例代码
//语音控制
audioControl: {
/**
* 播放语音
* [@param](/user/param) audioUrl 语音路径
*/
playAudio(that, audioUrl) {
let innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.obeyMuteSwitch = true;
innerAudioContext.src = audioUrl;
innerAudioContext.onPlay(() => console.log('开始播放'));
innerAudioContext.onEnded(() => {
that.setData({
audioPlayState: false
})
});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
},
//暂停播放
stopVoice(that, audioUrl){
let innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.src = audioUrl;
innerAudioContext.onPause(() => {
console.log('暂停播放');
})
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
})
}
},