Rez
Rez

Reputation:

How do you get a flash mp3 player to keep playing if a user changes page?

I really like the mp3 player on 8tracks.com and was wondering how they manage to keep the mp3 playing even when I change pages?

For example, listen to the track here http://8tracks.com/mixes?q=Aztec+Camera and click on one of the links to another page. The music cuts out for 1/4 of a second and then comes back in at exactly the right point!

I don't think it's using a streaming server, so was wondering if it's a feature of flash?

Upvotes: 3

Views: 2091

Answers (5)

skymt
skymt

Reputation: 3259

Keep it simple: have the player store the current track/time in a cookie when onunload fires, then start from there when the next page loads. You'll need to write a couple support functions in JavaScript, as AFAIK Flash doesn't have access to browser cookies or JS events.

Upvotes: 4

albertein
albertein

Reputation: 27130

Or avoid ajax and instead use a iframe

Upvotes: 0

devlord
devlord

Reputation: 4164

You could do it with Ajax by making it so that your internal "links" don't actually navigate to another page, but simply load content into your main content div. This would allow any streaming media to continue uninterrupted as long as it resides outside the div where the content is being replaced.

Upvotes: 0

Mike F
Mike F

Reputation:

Dunno if this is how they do it, but you could always put the music-player and the main page in two different frames (with only the main content-frame visible). Of course that wouldn't help with (eg) typing a new address into the address-bar.

EDIT: That's not how they're doing it. Presuambly they're saving the song & playback position in a cookie and using it to restart the player on each new page.

Upvotes: 0

albertein
albertein

Reputation: 27130

Yup, but you would get all the problemas that are involved with frames, you would end adding script code on all pages to take care when the user entered the site directly without the frame defining site

Upvotes: -1

Related Questions