在网页中播放多首歌曲
我正在开发 HTML 和 Javascript 项目,我想为网站添加音乐。
有什么方法可以在要播放的代码中添加多首歌曲吗?无论如何,打开下一页时这首歌还会继续吗?
I'm working on my HTML and Javascript project and I wanted to add music for the website..
Is there any way I can put more than one song in the code to be played? And is there anyway that the song will continue when openning the next page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个类似问题,其中有一些很好的答案。该问题中的评论也列出了许多重复的问题。其中许多答案都需要 HTML5。还有各种基于 Flash 的答案。
如果您希望在打开下一页时继续播放歌曲,则需要使用 frames (简单)或让您的网站完全由 AJAX 驱动(更乏味)。
Here is a similar question with some good answers. The comments in that question list many duplicate questions as well. Many of those answers require HTML5. There are also various Flash-based answers as well.
If you want the song to continue when opening the next page you will need to use frames (easy) or make your website entirely AJAX-driven (more tedious).
如果不使用 Flash,您就必须使用新的 HTML5 技术
,Firefox 3.5+、Safari 4+、Chrome 3+ 和 Opera 10+ 均支持该技术。这是一个例子:
我不确定打开下一页时是否可以继续播放歌曲,也许您可以将播放器数据存储在 cookie 中。
Without using Flash, you are bound to a new HTML5 technique
<audio/>
, which is supported in Firefox 3.5+, Safari 4+, Chrome 3+, and Opera 10+. Here is an example:I'm not sure if it is possible to continue the song when opening the next page, maybe you could store player data in a cookie.