You are using the HTML5 tag <audio>. For instance. if you have an XUL document, you add it like this:
<audio xmlns="http://www.w3.org/1999/xhtml" id="clickSound" src="click.ogg" />
When you need to play the sound you make:
document.getElementById("clickSound").play();
In other words, it is exactly the same as on the web page . Just that you must specify the XHTML namespace if you are in an XUL document.
source
share