Treehouse: Grow your CSS skills. Land your dream job.

Audio Keeps Playing Between Page Loads

  • # June 19, 2014 at 10:43 am

    I honestly don’t know if this is possible within WordPress. Can I have a song begin playing on page load and then as you navigate the site by visiting other pages, the song continues to play without stopping and then doesn’t loop after the first play? I don’t want the song to re-start on every page load because having a song playing in the background of a website is already an iffy topic. I just want to set the mood for the website. And the song, “I Wanna Be Your Dog” by Émilie Simon, is rather unobtrusive.

    # June 19, 2014 at 11:07 am

    You can’t. Web is stateless, so as you navigate to new page new ‘state’ is created. To do this properly, your linked content needs to load via AJAX so that the current state can be preserved and music keeps playing. To stop looping all depends what sort of player you’re using.

    # June 19, 2014 at 11:21 am

    Do you know of any WordPress plugins that would allow this? I wouldn’t even know what to search for, other than AJAX music player.

    # June 19, 2014 at 11:46 am

    I would personally never start any sound on a website for any reason without the user telling me to start it. Also, I’m fairly certain every mobile browser will not load any auto-play video or audio. I know you probably know this since you mentioned it, but I just wanted to reiterate.

    As for WordPress and AJAX, you’re not looking for an AJAX music player, but a way to make all of WordPress “AJAXified”. I’m sure it’s possible, but it won’t be easy. You might want to find themes that do it for you if they exist.

    Once that’s done, JS is actually calling the PHP functions without a full page postback and you could technically have your music continue to play while PHP is building your new page.

    Sounds like a lot of work for a bad idea :P

    # June 19, 2014 at 12:34 pm

    Sounds like a lot of work for a bad idea :P

    Yeah, you’re probably right, @shaneisme. Probably not worth the trouble. Whenever I think of music blaring from my speakers unexpectedly, it’s not a good feeling.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.