如何在浏览页面时保持音频播放? [英] How to keep audio playing while navigating through pages?

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

问题描述

我正在为我的朋友乐队制作一个网站.我想知道是否有可能(除了使用 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 后保持加载某些页面元素(不使用 # url),就像 facebook 所做的那样(例如,你点击它,但横幅在加载过程中永远不会消失)

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 加载内容和历史 API 的 pushState() 无需重新加载页面即可更改 URL.

Use Ajax to load content and History API’s pushState() to alter URL without page reload.

为了跨浏览器保持一致的行为,请考虑使用像 History.js 这样的包装库.

For consistent behavior across browsers, consider using a wrapper library like History.js.

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

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