Uninterrupted mp3 play on a website?

2019-06-27 10:06发布

问题:

Client is requesting a single track to be heard across the website. Generally I advise against it, but they insist. So, what is the most straightforward way of having a flash player embedded in a site, and when a user goes to another page there isn't a gap/interruption?

I am thinking an iframe is required.. I am using a flash player that has autoresume, but that only solves picking up where you last left off on the song before going to another page. I tried searching SO for an answer..

回答1:

If you want it totally uninterrupted, you'll have to embed the whole site in an iframe, or load pages via Ajax.

If you can tolerate a pause in the music, what you could do is modify your Flash music player to keep a cookie with the current position in the song and when it loads checks for the cookie and resumes playing at that place.

Both are kind of ugly hacks, but so is forcing the user to listen to music.



回答2:

To do something like that you'd need to keep the browser on the same page and load the contents of the page using AJAX. The html you get back from your AJAX requests could be placed in an iFrame but there's no advantage to doing so. Really you'll need to know a bit of Javascript and AJAX. If you haven't done much AJAX I'd start with JQuery as it makes it quite a bit easier.
Of course doing a whole website like this could become very complicated especially if the pages are doing anything more complicated than showing text. Also take into consideration that the address bar will always show the same address so bookmarking pages wouldn't work. Again you could probably find a way around this, but my point is there's a lot of little things you'll have to think about if you decide to go this route.



回答3:

You can try a popunder. As horrid as that is, you can't really do much worse than playing music on a site anyway, so if the client would be ok with it, it's an option.



回答4:

Create a hidden iframe behind the current content. Play content there. Have page-to-page navigation happen in the top frame, so the background frame stays in place. As a minus, the URL will stay the same.

Seriously, though, the site's going to suck unless there's a way to turn the crap off.



标签: php drupal audio