Javascript mp3 player

2 min read >

Javascript mp3 player

Engineering Insights & Enterprise solutions

Seems impossible, right? Well, it is :-). The title is a bit misleading. You can’t play mp3 in javascript. Not yet at least. Not without a flash-object behind the scenes.

But when it comes to searching for a flash mp3 player that has also a customizable skin and javascript integration you won’t have so much luck. The players that allow flash – javascript communication are not skinnable, and the ones that are skinnable, don’t allow communication with javascript.

So after a bit of hacking here’s the final result: https://tremend.com/wp-content/uploads/2010/02/flash-javascript-mp3-player/test.html

The script is based on this excellent flash mp3 player which involves a hidden flash mp3 player. The main headache is actually not the UI which uses a simple Scriptaculous effect for scrolling (just drag and drop the cursor to see it working), but actually making sure the commands from javascript to the flash player work on all browsers.

Another bonus feature added is the ability to jump to different sections of the audio file. The sections are described in a javascript configuration object. A UI for this feature can be easily built using your favorite UI framework.