BigDiggers
BigDiggers

Reputation: 105

How to play mp3 files via javascript without any html5 feature?

I need to encode an mp3 audio file with base64, then sent to client(web browser), decode it via javascript, then play it.

Is there a way to play an mp3 file via javascript?

Upvotes: 1

Views: 3715

Answers (3)

Lloyd
Lloyd

Reputation: 8406

jPlayer and SoundManager2 are the two main javascript media playback libraries

Upvotes: 1

Mark Coleman
Mark Coleman

Reputation: 23

You can use an object tag. Something like

    <object type="audio/mpeg" data="music.mp3">
      <param name="autoplay" value="true">
      No audio player. Please upgrade to a newer browser.
    </object>

You will have limited control over the playing of the mp3 and browser support can be spotty, but that should work.

Upvotes: 0

Dagg Nabbit
Dagg Nabbit

Reputation: 76776

You can use a flash plugin or java plugin. There is no other way to produce audio without HTML5 features, even if you wrote your own MP3 codec in "pure" JavaScript.

Upvotes: 3

Related Questions