Search code examples
htmlsoundmanager2

How to handle URL changes and keep SoundManager2 playing on background?


I am developing a web application, where a mp3 player is present and user can play the music. Issue that i am facing is how to keep the music playing (and the player untouched) even when I change the URL - go to a different page? The same thing as Deezer or SoundCloud do. You can browse the web and listen to the music meanwhile. Please point me a direction how to implement it. Thank you all!


Solution

  • On soundcloud they don't actually change the page they just change some of the body content with javascript. You can simply do the same, by adding a hidden div for the music, and a div for the content, which calls an api (recommend jquery.ajax) to fetch the content relative to the url in the address bar.

    With rewriterules inside the .htaccess file, you can make it so it ignores all query strings etc. So it will always load the index.php file.

    In short, this is no rocket science, has nothing to do with html5 nor soundmanager2. For more info you should use the .htaccess and jquery tag.