网站背景音乐不间断
我正在为一个乐队制作一个网站,我想知道在网站上播放背景音乐而不中断音乐流(即使是一瞬间)的最佳方式。
目前,我正在考虑使用框架,但这不应该是一个好的做法。 请有人告诉我如何做到这一点。 我更喜欢使用 HTML 来编码网站,因为我还没有掌握 Flash 编码。
I was making a website for a music band, and i was wondering the best way to play background music on the website without interrupting the flow of the music (even for a split second).
At the moment, i am considering using frames, but this is not supposed to be good practice. Please someone tell me how i can do this. I would prefer to use HTML to code the website as i have not yet mastered coding in flash.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这听起来可能有争议,但这里有一个想法:不要在您的网站上播放音乐。 说真的,不要。 我想每个人都知道这是多么令人讨厌,要求一群软件开发人员来帮助你解决这个问题就像问一群羊制作羔羊皮大衣的最佳方法一样。
如果你真的必须这样做,框架将是最简单的方法,所以我会这样做。 但无论如何你都不会这么做,对吧?
This might sound controversial, but here's an idea: Don't play music on your website. Seriously, don't. I think everyone knows how incredibly annoying that is, and asking a group of software developers to help you out with that is going to be like asking a group of sheep the best way to make a lambskin coat.
If you really have to do it, frames would be the simplest way, so I'd do that. But you're not going to do it anyway, right?
我可以想到四种方法:
I can think of four ways:
防止音乐停止的唯一方法是不要重新加载音乐组件所在的页面。 不幸的是,目前唯一的方法是使用框架。
唯一的选择是使用 Flash 或其他不依赖于更改页面作为导航的技术来开发整个网站。
The only way to prevent the music from stopping is to not let the page your music component is on reload. Currently the only way to do this is to use frames, unfortunately.
The only alternative is to develop the whole site in Flash or another technology that doesn't rely on changing pages as navigation.
虽然不太漂亮,但您可以使用 AJAX 来完成。 母版页的页眉/页脚/导航控件带有一个大的空内容 div,而不是常规链接,您可以调用返回要注入到内容 div 中的 HTML 的 AJAX 函数。
我倾向于同意其他人推荐框架的观点。 这可能被认为是“不好的做法”,但播放背景音乐也是如此。
It wouldn't be pretty but you could do it using AJAX. Have the master page with the header/footer/navigation controls with a big empty content div, and instead of regular links you have calls to AJAX functions that return HTML to be injected in the content div.
I tend to agree with the others who recommend frames. It may be considered "bad practice", but so is playing background music in the first place.
如前所述,要做到这一点,您必须防止您的网站重新加载。
实现此目的的一个选项可能是使用异步请求来修改网站内容,而无需重新加载整个页面,这基本上就是 Ajax 的用途。
话虽这么说,我有点同意亚历克斯的观点:不要播放音乐。
As was said, to do that you have to prevent your website from relaoding.
An option to achieve this might be to use asynchronous requests to modify your website content without reloading the whole page, that's basically what Ajax is about.
That being said, I sort of agree with Alex here : dont' play music.
这可能是另一篇文章的主题,但为什么您认为 IFrame 是一个好的实践呢? 您可以将要更改的内容放入 IFrame 中,并让您的代码在其外部运行音乐播放器。 当您加载页面时,它将加载到 IFrame 上。 只是一个想法...
This may be a topic for another post, but why would you cosnider IFrames to be good practice? you could out the content you want to change into an IFrame and have your code running your music player ouside it. When you load a page it woul load on the IFrame. Just a thought...
您很可能需要闪光灯或窗口外的新窗口(弹出窗口)。
不要使用框架。 曾经。
编辑:对于所有对此进行修改和评论的人,没有一个人给出了您应该使用框架的正当理由。
为了澄清我的立场,请阅读任何有关可用性、网络和框架的文章。
对于那些仍在学习的人(以及那些愚蠢地更新的老人)来说,
框架打破了网络的统一模型。
框架会给搜索引擎机器人带来问题。
框架使 URL 停止工作。
框架破坏了书签。
框架使打印变得更加困难。
框架会损害可访问性。
框架增加了技术复杂性。
以及不使用框架的第一大原因……
用户讨厌它们!
http://www.456bereastreet.com/archive/200411/who_framed_the_web_frames_and_usability/
2009 年,真的有这么多人认为框架是一个有效的解决方案吗? 多么令人失望啊。
You would most likely need flash or a new window (pop-up) outside of the window.
Don't use frames. Ever.
EDIT: To all the people downmodding and commenting on this, not a single person has given a valid reason why you SHOULD use frames.
Just to clarify my position, please read ANY article on usability, the web, and frames.
For those still learning (and to those old people to dumb to update)
Frames break the unified model of the web.
Frames cause problems for search engine robots.
Frames make URLs stop working.
Frames break bookmarking.
Frames make printing more difficult.
Frames hurt accessibility.
Frames increase technical complexity.
and the #1 reason to not use frames......
USERS HATE THEM!
http://www.456bereastreet.com/archive/200411/who_framed_the_web_frames_and_usability/
Are there seriously this many people out there suggesting frames are a valid solution in 2009? How disappointing.