问题
I want to build an app using jQuery-Mobile which every single page contains an image and autoplay audio. when the first page is swiped to the next page, the first page's audio stops playing and the second page's starts playing. Can anyone help me how to do it or inform me a plugin.
Thanks in advance!
回答1:
Use jQuery Mobile pagehide or pagebeforehide events to stop audio files.
$(document).on('pagebeforehide', function () {
$(this).find('audio').each(function () {
$(this)[0].pause();
});
});
来源:https://stackoverflow.com/questions/17543545/swipe-to-navigate-and-stop-audio