How to play a sound in a web browser (it ain’t easy)
mir.aculo.us
mir.aculo.us
Maybe because he's not trying to play music.
if(!!(a.canPlayType &&
a.canPlayType('audio/ogg; codecs="vorbis"')
.replace(/no/, '')))
a.src = "/sounds/ping.ogg";
else if ...
Does anyone know if this is more successful than the standard HTML5 way, which is to include in the <audio> element multiple <source> elements pointing to different formats?Personally I think lots of one letter variable names and liberal prefixing of everything with _ is a bigger annoyance, but to each their own I guess.
Has broad support and will play most stuff thrown at it. Also, no cross-platform differences.
Thank you Chrome.
mkdir static && wget http://www.soundjay.com/button/beep-1.mp3 -O static/beep.mp3 && python -c "import flask; flask.Flask(__name__).run()"
Then hit:
http://127.0.0.1:5000/static/beep.mp3The mp3 plays fine in Firefox (not natively of course), but doesn't play at all in Chrome. The same problem extends to the HTML5 audio tag (eg. <audio src="static/beep.mp3" />).