Swipe to navigate and stop audio

白昼怎懂夜的黑 提交于 2019-12-13 04:23:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!