WeChat applet API audio playback control
wx.playVoice(OBJECT)
Start playing voice, and only one voice file is allowed to be played at the same time. If the previous voice file has not finished playing, the previous voice playback will be interrupted.
OBJECT parameter description:
##Sample code:
wx.startRecord({ success:function(res){ var tempFilePath = res.tempFilePath; wx.playVoice({ filePath:tempFilePath, complete:function(){ } }) } })wx.pauseVoice()
Pause the currently playing voice. When wx.playVoice is called again to play the same file, it will start playing from the pause point. If you want to start playing from the beginning, you need to call wx.stopVoice
Sample code:
wx.startRecord({ success:function(res){ var tempFilePath = res.tempFilePath; wx.playVoice({ filePath: tempFilePath }); setTimeout(function(){ //暂停播放 wx.pauseVoice() },5000) } });wx.stopVoice()
End playback Voice
Sample code:
wx.startRecord({ success:function(res){ var tempFilePath = res.tempFilePath; wx.playVoice({ filePath:tempFilePath }) setTimeout(function(){ wx.stopVoice(); },5000) } });