我读过这个问题,据我所知,它的唯一可能用框架做(我真的不希望全现场AJAX): How在多个HTML页面播放背景声音。?
I've read this question and I understand that its only possible to do it with frames (I really don't want full-site AJAX): How to play a background audio across multiple HTML pages.?
我的问题是,有没有办法有一个小的,或者是不可见的框架,其播放音乐,并为它的地方在主框架中的一些设计精美的控制?其实我想使用SoundCloud来解决它,但如果它与不可能那么我愿意对一些自定义播放器,像FlowPlayer或SoundManager类2。
My question is that is there any way to have a small, or maybe invisible frame which plays the music and some nicely designed control for it somewhere in the main frame? Actually I would like to solve it with using SoundCloud, but if its impossible with that then I'm open for some custom player, like FlowPlayer or SoundManager 2.
我想要做的是有一个小乐队一个网站(我做的自愿),其中有几页,像photos.php,biography.php,music.php我想有一个选择的music.php页面上的音乐曲目,但我想,以保持音乐播放,即使访问者浏览出来的音乐页面。例如,它一定是最明显的任务时,有人开始音乐然后去photos.php并查看照片,而音乐仍在播放。
What I would like to do is to have a website for a small band (I'm doing it voluntarily), which has a couple of pages, like photos.php, biography.php, music.php and I would like to have a selection of music tracks on the music.php page, but I would like to keep the music playing even if the visitor navigates out of the music page. For example it must be the most obvious task when someone starts a music then goes to photos.php and views the photos, while the music is still playing.
什么是做到这一点的最好方法是什么?
What would be the best way to do it?
更新:当然,我不想要的音乐自动启动
Update: Of course, I don't want the music to start automatically.
推荐答案我强烈反对,但如果你的真正的想它也有一些选择:
I strongly recommend against it, but if you really wanted it there are some options:
帧/ AJAX网站
该框架可能是最好的情况下(它会显示为一个网站,你的观众)。完整的现场AJAX的原理基本相同。但是你说你是对这些选项(但不为什么)。
The frame is probably the "best" case (it would appear as one site to your viewers). The full-site AJAX is basically the same principle. However you said you are against these options (but not why).
AJAX播放器同步
在AJAX播放器同步将涉及存储的cookie来识别用户,并有一个AJAX播放器调用哪个存储当前播放时间,歌曲为当前用户后端。
The AJAX-player synchronisation would involve storing a cookie to identify the user and having an AJAX player call a back-end which stored the current playing time for the song for the current user.
然后,在页面加载,你可以查找这个时候,并开始播放歌曲在那里。
Then, on page load you could lookup this time, and start the song there.
不过,你仍然可以得到页之间的轻微跳跃(相当于当您在嵌入式框架播放YouTube,然后中途歌曲中跳跃到真正的YouTube,而不是嵌入的视频,并继续,除非他们这么做的URL参数传递)。
However, you'd still get slight skips between pages (comparable to when you play YouTube in an embedded frame, then half way through the song skip through to "real YouTube" rather than the embedded video, and it continues, except they do this with URL parameter passing).
URL参数+改写链接
另一种方式来实现同步的办法是有一个定义当前歌曲瞬间URL参数。然后在每一个滴答(比如第二/半秒),你可以使用JavaScript来重写网页上的所有链接,包括更新的URL参数。但是,如果有人打开你的网站在新标签/窗口/不点击网页上的链接玩家将重新启动,这将意味着。这会发生在大多数这些选项呢,但这样也许不是一个真正的缺点。
Another way to achieve the "synchronisation" option would be to have URL parameters that define the current song moment. Then on every "tick" (say a second/half second) you could use JavaScript to rewrite all the links on the page to include an updated URL parameter. However, this would mean if someone opens your site in a new tab/window/without clicking a link on your page the player would restart. This would happen in most of these options anyway though so is perhaps not a real downside.
要做到这一点的方法是:
The way to do this would be:
如果你可以设置从JavaScript饼干(我不认为你可以,但有可能是现在的解决方法),这可以通过让您的播放器检查cookie的负载,然后让你的蜱功能作了更容易更新的cookie,而不是重写所有URL。
If you can set cookies from javascript (which I didn't think you could, but there might be workarounds now), this could be made even easier by having your player check the cookie on load, and then having your tick function update the cookie rather than rewriting all URLs.
弹出
您可以载入播放器中弹出(当然检查,以确保你不开始在每一个页面加载一个新的弹出窗口)。这可能是实现你想要的最简单的选择。
You could load the player in a popup (of course checking to make sure you don't start a new popup on every page load). This is probably the easiest option to achieve what you want.
我的建议
我的建议是,未经允许不能播放音乐 - 有一个播放器(这可能是上一帧/在一个完整的AJAX网站/在弹出的一个不变的组成部分),它需要用户点击播放。此外,请确保音乐是不够好,他们都希望能够获得YouTube的/他们的媒体播放器播放它在后台呢。
My recommendation is to not play music without permission - have a player (which could be on a frame/in an unchanged component of a full AJAX-site/in a popup) which requires a user-click to play. Alternatively, make sure the music is good enough that they will want to have YouTube / their media player playing it in the background anyway.
更多推荐
如何在跨页后台播放音乐
发布评论