If you want to play music or sounds from a browser, your choice is to use either Flash or the new <audio>
tag in HTML5. Each method has issues, but depending on your requirements you might not care about all of them.
<audio>
tag in your HTML, or by instantiating a new Audio
object from Javascript. No additional libraries are required, although browser implementations are so bad you will probably want library support anyway (see below).<audio>
tag can take multiple <source>
children for this purpose.There are a number of libraries that can help you work around compatibility issues. All these solutions share some traits:
Some products I tested are:
jPlayer
Show archive.org snapshot
: Free. Provides a thin Javascript layer over the mess that is HTML5 audio and Flash playback. Requires jQuery. You need to provide your own <div>
containers and CSS for player controls, which is overhead if you don't care about looks but allows complete control over the visuals. Can play audio and video. Developers seem to know what they're doing.
JW Player
Show archive.org snapshot
: Non-free product, but very popular. Can play audio and video and has a good number of options. Offers some pretty skins for downloading, but is hard to customize beyond that.
SoundManager 2
Show archive.org snapshot
: Free. Only does audio. Awkward API. There seems to be no way to implement a seek bar.