Log in

View Full Version : Keep music playing on all pages?



kairick
03-26-2010, 07:13 PM
Hi
I currently have an mp3 file playing on the home page of a restaurant website ( I know and agree with the anti-music-on-web-pages movement, but it was a client's call, so please spare me.) using the <embed> tag. How do I get the music to play continuously as visitors navigate through pages of the website?

Please and thanks

BLiZZaRD
03-26-2010, 07:17 PM
The only way is with frames. Set a left and right frame set, make the left frame set 1px wide by 100% height.

Embed the music in this left frame set (overflow hidden). Music will play while content in right frame changes.

bluewalrus
03-26-2010, 07:25 PM
If the clients only requirement for the site is for the music to play the whole way you could make the whole site in flash ... Limits audience and search-ability of page though.

djr33
03-26-2010, 09:24 PM
The way that this is done on most modern sites (for example facebook) is that the entire site is designed to load through Ajax and NOT through normal links. Of course this requires Ajax (Javascript) is enabled/working, but for most people this will be the case-- though not all. Others will just reload everything each time.
This means that everything is difficult to setup because you are constantly requesting and serving partial pages then dealing with them in Javascript and it will be difficult to program. But then on facebook you can keep chat windows open while loading other pages.

Of course the non-Javascript alternative to this is using frames which would make your job a lot easier. The downside to that is using frames, and the problems that come with frames. (Very few technical issues, really, just that they are annoying to work with/use.)



Be aware that this approach is basically the opposite of how the web is designed: mainly, whole pages are supposed to be loaded, and secondarily small portions of pages can be loaded dynamically. Instead, you (and others) are attempting to load dynamically almost ALL of the page, except one part while leaving that static. It's technically possible using the same methods but much more complex and not standardized so it won't be easy.

BLiZZaRD
03-26-2010, 09:27 PM
I don't recommend that. As a Flash user I love the idea, but talk about more problems than it's worth. Trying to sync the music with each menu button click, or link click.. Its a huge hassle.

<edit> Didn't see djr's post prior...



Be aware that this approach is basically the opposite of how the web is designed: mainly, whole pages are supposed to be loaded, and secondarily small portions of pages can be loaded dynamically. Instead, you (and others) are attempting to load dynamically almost ALL of the page, except one part while leaving that static. It's technically possible using the same methods but much more complex and not standardized so it won't be easy.

Ahh, if only I hadn't removed the one I had that way. It was very simple. It worked and validated, and there were no browser issues.

Perhaps I will make it again. It was so super simple. ALMOST made me like frames. Almost.

djr33
03-27-2010, 12:34 AM
It's not possible that there were no browser issues-- it may be compatible with all browsers, but if Javascript is disabled everything gets messy. But I'd like to see a framework that works well for that.


More importantly, here's an easy way to do this:
launch the music player in a popup window (or just new window if Javascript is disabled for 'popups' specifically), then the user can operate your site and music independently. (Of course you can offer the user a choice to keep it in the window or launch as a popup if you'd prefer that.)

BLiZZaRD
03-27-2010, 12:53 AM
There wasn't any javascript involved. That's my point :)

When I get a free moment from school and work I will redo it. I may even have a back up copy I can just re-upload. I will check.

djr33
03-27-2010, 02:52 AM
What's the main approach to it, if you aren't using frames and you aren't using Javascript?

BLiZZaRD
03-27-2010, 02:59 AM
We must have crossed somewhere. It is using frames, same method as my first post here. No JS though.

djr33
03-27-2010, 05:15 AM
Oh, "almost made me like frames", I read as "almost ... like frames". Anyway....

Ok, that would work then.

techno_race
03-31-2010, 05:09 AM
Remember that using frames will screw up bookmarks and search engines, since the URL for the parent doesn't change dynamically. Bookmarks will all point to the same page, no matter what page the user was on when they were bookmarked. Search engine results will point to the individual frames, so the music won't play.

Thinking about it, a possible solution for these problems would be to use anchors and Javascript together in a somewhat complicated manner. I'll work on that.

djr33
03-31-2010, 07:41 PM
Thinking about it, a possible solution for these problems would be to use anchors and Javascript together in a somewhat complicated manner. I'll work on that.I doubt this would work:
1. anchors are not used by search engines (as far as I know).
2. Javascript is arguably more messy than frames for SEO.

It would help with bookmarks, though.


One possible way around the problems would be to use PHP to dynamically change the link. (Actually, use different links, but have PHP respond differently).

In other words:
page.php?iframeurl=url.htm

So then all links would have target="parent" and the whole page would reload.

But of course that doesn't work for keeping the music playing. That just helps fix the inherent issues of frames.

I don't think there is any way around the issues of bookmarks and SEO that will work to keep the music playing.


The only option for this is what I suggested earlier: just pop out the music player in a separate window (or tab) and let the user keep them separate. It's not an "all in one" experience, but it would be effective.


Of course you could also attempt to have a complex media player that reloads on each page (it would stop playing while loading), and your position/song are saved so that when you do reload the player "remembers" where you were and continues from there. It would be a bit jumpy, but somewhat reliable.

techno_race
04-06-2010, 03:10 AM
Nice thought. For example, you could find a way to track the music's position using Javascript, then set a cookie at onunload. On onload, the script would check if the cookie exists, and, if so, jump to the position in the cookie. I have, of course, absolutely no idea how to accomplish this. :p

djr33
04-06-2010, 04:20 AM
It's relatively simple using flash. But of course that means then reprogramming the media player among other things. It's possible using other methods as well, such as Javascript making the player jump if it is possible to send a time-specific command. This is possible to program into a flash media player, so it might be able to find one, or you can even do this in some approaches to embedded media with quicktime, etc. It's not completely reliable always though, and of course still requires JS is on.
The main problem with any of that is that there is no way around the page reloading and causing a pause in the audio. If your users are going through pages quickly on a slower connection it may never load; if they are going slowly such as reading a lot of content, the momentary pause may not be too bad.