如何保持音频播放,同时通过网页浏览? [英] How to keep audio playing while navigating through pages?

查看:175
本文介绍了如何保持音频播放,同时通过网页浏览?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个网站,我的朋友带。我想知道如果可能的(除了使用Ajax),以保持音频播放点击链接到另一个网页后?

I am making a website for my friends band. I would like to know if its possible (apart from using Ajax) to keep audio playing after clicking on a link to another page on the site?

目前,我有它设置使用Ajax重新加载的内容,但我有与它的几个问题,我宁愿不打扰处理,除非我真的不得不这样做。

I currently have it set up using Ajax to reload the content, but I am having a few issues with it, and I'd rather not deal with the bother unless I really have to.

如果不能,有没有办法,以尽量减少中断(暂停然后再播放),同时导航?这将有可能为新的页面继续播放从最后一页停在那里的轨道,但我想,以尽量减少暂停。或者说,在这个问题上,是有可能不断变化的URL后加载某些页面元素(不使用#的网址),像Fac​​ebook这样做(如,你点击它,但是加载过程中的旗帜永远不会消失)

If not possible, is there a way to minimise the disruption (pausing then playing again) while navigating? It would be possible for the new page to continue playing the track from where the last page stopped, but I would like to minimise the pause. Or, on this subject, is it possible to keep certain page elements loaded after changing the URL (without using # urls), like facebook does (as in, you click on it, but the banner never disappears during loading)

感谢任何帮助:)

推荐答案

使用Ajax加载内容和HTML5历史API(<一个href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#Adding_and_modifying_history_entries\"相对=nofollow> history.pushState() )改变URL,而不刷新页面。

Use Ajax to load content and HTML5 history API (history.pushState()) to alter URL without page reloading.

另一个可能的选择是使用cookies来保存当前的播放位置(<一href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video#Seeking_through_media\"相对=nofollow> Audio.currentTime ),当用户离开页面,然后从饼干提取位置,将其设置为音频。加载新页面时currentTime的值。请注意,这可能会导致一个明显的停顿,而新页面正在加载播放,所以,对于无缝播放,阿贾克斯/历史的做法是preferred。

Another possible option is to use cookies to save current playing position (Audio.currentTime) when user leaves a page and then extract position from cookie and set it to Audio.currentTime value when loading new page. Note that this may cause a noticeable pause in playing while new page is loading, so, for gapless playback, the Ajax/history approach is preferred.

这篇关于如何保持音频播放,同时通过网页浏览?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆