Multiple Flash MP3 Players On Same Page?

I’ve Googled this for hours but no joy…

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”…

TIA

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.

I think you can do something similar without Javascript using LocalConnection (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/LocalConnection.html), but I haven’t had a chance to experiment with that yet, so I’m not sure.

Thanks …so there’s no way to do this with Flash? I suppose that JavaScript might be better anyway, as I would like the MP3s to be Iphone Accessible.

My JavaScript programming skills are meager. Do you know of a tutorial - or better yet, an existing JavaScript player - that I could use for this?

Sorry if I was a bit unclear.

You’re still using Actionscript for almost everything. Check out the ExternalInterface class: flash.external.ExternalInterface (ActionScript 3.0)

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.