I want to use multiple single flash mp3 players (like Zanorg) on the same page. When using more than one single player, clicking on a track in a second player does not stop the track that’s playing on the first player (in other words, they both continue to play at the same time).
Is there a single player in existance that doesn’t do this? Failing that, is there a relatively simple way to modify an existing player’s code (ie, Zanorg) to stop this behaviour? I don’t know much about flash programming, but I think it has something to do with “player Ids”…
Basically, you’d have to use Javascript and Actionscript’s ExternalInterface to control this.
You would do something like:
Create an ExternalInterface-linked “stop” function for the player.
Create a Javascript function called “stopAll” which iterates through all the players and stops calls their stop function.
Modify the player’s “play” function to call the Javascript “stopAll” function (with ExternalInterface) in cause all the others to stop before the one that was just clicked plays.
Basically it allows you to call Javascript files from Actionscript, and allow Javascript to call Actionscript/Flash functions.
So, the only Javascript function you need to write is one which calls “stop” on all your players. If you put your players in a Javascript array, you can just loop through all of them.
You then need to make it so Javascript can call the stop() function of each of your functions (using ExternalInterface.addCallback() in Actionscript), then in your play() function in Actionscript, use ExternalInterface.call() to call your stopAll Javascript function.
If you mess around with the LocalConnection function, you can probably accomplish this with Actionscript-only, but I’ve not had a chance to play with this class yet, so I can’t help you directly with that.