Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play HTML audio in Internet Explorer?

I have this html and js which I'm using to play some audio:

HTML

<div id="audio-clips">
    <audio src="/audio/cha-ching.wav" type="audio/wav" id="audio-cha-ching">
</div>

JavaScript

var sfx = $("#audio-clips #audio-cha-ching")[0];
sfx.play();

This is failing in IE 8, due to it not recognising the "play" method. Is there a jQuery audio-playing method which works cross-browser, with the same code? I'd rather do that then try to fall back to some IE-specific solution (as browser-specific solutions are always brittle).

like image 602
Max Williams Avatar asked Dec 06 '25 05:12

Max Williams


1 Answers

I would strongly recommend using howler.js for playing audio files. It has great compatibility across browsers and devices. It uses HTML5 audio when available, and falls back to older technologies when necessary.

like image 72
Raphael Serota Avatar answered Dec 08 '25 19:12

Raphael Serota



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!