For most sites, having background music that starts playing without the user’s consent is an annoyance. There are cases where using music on a website can enhance the overall experience.
Unfortunately, if you want to create ambiance with continuously playing background music (and avoid creating a flash-based website), there is no easy way to accomplish this. I spent some time yesterday and today digging up a workable solution, and found a flash mp3 player that “remembers” the position of the audio when you leave each page and starts the track back up again at that spot on the next page. The end result is when you navigate the site, the music starts up where it left off on the previous page. If you hit stop, the music remains off on subsequent page loads. The player is a very simple, open-source flash audio player called XSPF and was enhanced with a feature the author calls “autoresume.”
To have the music truly be continuous, with no breaks while clicking between pages, I’ll explain two potential solutions and the challenges with both. The easiest way to understand all of this may be to think about watching a movie on YouTube or listening to a song on MySpace. Basically, there is just no way to keep playing the audio or video if you click through to another page.. it has to stop, unless you keep that player loaded at all all times in its own window or “frame” on the page.
One way people get around this is to have the audio player open in a popup window. This window would contain just the audio player, and would remain open while you browse the site in a different window. I shutter at the thought of popups, but alas, this is a potential solution.
Most browsers have popup blockers, so it would be difficult to get this audio player to popup automatically. However, if people clicked a link on our site somewhere to play the audio, then we could trigger the popup window to open.
So, the downside to this is a) popups are annoying, and b) the music would most likely not play automatically, since popups that open automatically are typically blocked.
Another option is to use frames. Basically this means that we put the audio player into a horizontal “frame” along the bottom of the site, and load the rest of the site content above in a separate frame. When you browse the site, we only load the new pages into the top frame, but we don’t reload the bottom frame where the audio player is.
The major drawback to this is that when you browse the website, the URL in your browser will never change to reflect the current page. So, you lose the ability to bookmark pages, people can’t tell where they are on the site by looking at the address bar, and if you try to share a link to a page, like a menu page for example, it will always just be “scottconant.com” and not the actual menu page. Search engines also have a tough time with frames.
Generally, if you want background music on your website, I recommend you turn off auto-play and allow your visitors to decide themselves if they’d like to hear your audio. If you’d like the audio to be continuous across different pages, most flash-based audio players include a feature to “pop-out” the player into its own window. If you want to avoid popups, the “autoresume” feature is a good compromise.