Home  >  Article  >  Backend Development  >  javascript - WeChat audio interface, audio playback will not stop even if you leave the current page

javascript - WeChat audio interface, audio playback will not stop even if you leave the current page

WBOY
WBOYOriginal
2016-08-04 09:22:091260browse

<code>$(window).bind('beforeunload', function(){
    if(localId)
    {
        wx.stopVoice({
        localId:localId
        });
    }
});
</code>

Can’t call the wx.stopVoice interface when leaving the current page? What should I do to make the audio stop playing when I leave the page

Reply content:

<code>$(window).bind('beforeunload', function(){
    if(localId)
    {
        wx.stopVoice({
        localId:localId
        });
    }
});
</code>

Can’t call the wx.stopVoice interface when leaving the current page? What should I do to make the audio stop playing when I leave the page

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn