PDA

View Full Version : MP3 Player


douglas123
08-07-2008, 04:55 PM
Hello.

I am working on a Flash header that plays 1 song and only has a "play" and "stop" button. The music plays fine and starts and stops when the buttons are pushed, but is there a way/cookie for Flash to remember if the user pushed "stop" on the home page and goes to another page so the Flash does not reload the song from the beginning again? The song remains "stopped" until the "Play" button is clicked again to hear the song?

Basically, Flash would "remember" what the user clicked on on the home page and carry that through the other pages.

The song loads externally. Here is the example: http://www.broadwayseriessouth.com/index.php

Thanks for any help!

atomic
08-07-2008, 06:59 PM
You could possibly do it with a query string, having to write the object & embed tags on the new page with the passed variable or with a sharedObject...

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14253&sliceId=2

http://www.actionscript.org/resources/articles/118/1/SharedObjects/Page1.html

douglasbetsy
08-07-2008, 08:17 PM
Thanks for the information. I am not well versed in AC. Would I add the new code to the HTML so the music does not play or to a secondary Flash header that is like the homepage Flash, but has code to not play the music?

This is the code I am using to load the external MP3 on the homepage (it has a pause function because the client isn't sure if they want to keep a pause function or not):

// play button function
function playit() {
ply = true;
stpd = false;
if (pus) {
_root.dd.start(position);
_root.information.info = "Playing";
pus = false;
} else {
_root.dd.stop();
stopAllSounds();
_root.dd.start();
_root.information.info = "";
_root.information.play();
_root.information.info = "Playing";
}
}
//pause button function
function pauseit() {
if (!_root.stpd) {
position = _root.dd.position/1000;
if (!pus) {
_root.dd.stop();
pus = true;
_root.information.info = "";
_root.information.play();
_root.information.info = "Paused";
} else {
_root.dd.start(position);
pus = false;
_root.information.info = "Playing";
}
}
}
//stop button function
function stopit() {
if (!stpd) {
_root.dd.stop();
stpd = true;
_root.information.info = "";
_root.information.info = "Stopped";
_root.information.play();
}
}

Thanks again for your help!

atomic
08-07-2008, 09:55 PM
Before we further discuss a stop button, are you aware that supposing the stop hasn't been pressed and that sound is playing on the home page, and you leave the home page for another .html, that the sound will re-start from the beginning on every other page?

douglasbetsy
08-07-2008, 10:07 PM
Yes, Is there a way that I can control that or what would you suggest as the best way to use the one song player on the site as people go from page to page?

Thanks!

atomic
08-07-2008, 10:17 PM
The only way to ensure that the sound (if playing and not muted...) isn't interrupted when switching pages is to use a frame set, or have the player itself in a popup window... Otherwise, the transition will never be seamless...

You can use a sharedObject to store the soundObject's current position and even it's status (on or off, muted or not...), when leaving the home page, and then read in the sharedObject's data on the new page, to re-start the sound from the the position it was at, when leaving the home page, but that will never be seamless...

douglasbetsy
08-08-2008, 01:44 PM
Thanks for all of the information. Sounds more complicated than I thought and if it is not seemless it may seem like a mistake or something to the user.

Thanks again!

atomic
08-08-2008, 03:08 PM
Grrrrrrrrreat! ;)