views:

199

answers:

5

Is there a JavaScript library available that can playback an MP3 or related music file? The JavaScript would be fed the MP3 from the server and stream it back over the browser.

+4  A: 

On FF3 you can use the audio tag... but it does not support MP3 (only ogg). On Chrome it might work with mp3. Safari should work as Chrome. Opera should also work, but I am unsure which codecs/formats it can play. Guess what does IE support? :)

IMHO, you should resort to playing MP3 using flash.

elcuco
Flash would work but I don't want to use it for various reasons. I was hoping there was a javascript library available that could playback music and it didn't rely on WMP or QT or anything.
Nathan Z
Not cross browser yet, specially since the audio tag is non standard yet (HTML5 is not out) and then mp3 still has patent issues and thus it cannot be used freely by Firefox for example.
elcuco
HTML Audio playback on Chrome is completely unusable on all the machines I've tried (even with the latest beta). Safari works but it lags a lot. Firefox is good but as you've said it only plays back Ogg Vorbis files. I agree, the best option at the moment is still Flash (or Silverlight).
DrJokepu
@DrJokepu: you meant filvershminths of course ;-)
elcuco
+1  A: 

You'll probably end up using some flash-based media player, that you can can control via javascript using swfobject.

timdev
Don't want to use Flash. I know how with it but was wondering if there is anything out there that is standalone Javascript.
Nathan Z
As elcuco says in his comment on your question, you're out of luck. You'll end up relying on some kind of browser plugin, and Flash is your best bet to make it work for the broadest range of platforms.
timdev
A: 

Probably your best bet here would be to use the Flash Player. There are many other ways, involving various plugins (Quicktime, WMP, Real), but Flash probably will give you the greatest coverage.

EDIT:

A pure Javascript solution is simply not possible, probably due to licensing constraints of the mp3 format.

spender
Flash isn't an option, but thank you.
Nathan Z
+1  A: 

Here it is: soundmanager2

It works by exploiting flash, but it's a full javascript experience.

ZJR
A: 

No.
As others wrote, you cannot do that in a portable way, particularly on IE, which would need some plugin to play sounds.
JavaScript isn't really suited to manipulate binary data, anyway, and is quite limited to access computer's hardware, so it has to ask the browser, if possible, to do the job itself.

PhiLho