Saturday 5 September 2009

Javascript/Flash mp3 Player

I was recently asked if I could make a Flash mp3 player that was controlled with Javascript. Obviously my first question was why on earth would you want (or need) to do that? The answer I got was perfectly understandable. To have the ability to integrate the Flash element seamlessly into HTML content. In other words the links would be normal HTML links that when clicked played the song in the Flash player. Of course this also has the benefit of streamed content speeds, the user doesn't have to download anything. Flash's ExternalInterface class is the key to this solution, it makes linking from ActionScript to Javascript a piece of cake.
Here's an example. The white pixel in the top left corner of the grey panel is the the Flash content (it's white to show you can see it).

No comments: