Possible Duplicate:
Playing a sound in a Firefox add-on
I am building a firefox extension, and I need to play a sound file (local) when a button is clicked.
I am new to extension development and have no idea how to do this.
Possible Duplicate:
Playing a sound in a Firefox add-on
I am building a firefox extension, and I need to play a sound file (local) when a button is clicked.
I am new to extension development and have no idea how to do this.
You use the HTML5 <audio>
tag. E.g. if you have a 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 do:
document.getElementById("clickSound").play();
In other words, it's exactly the same as in a web page. Only that you have to specify the XHTML namespace if you are in a XUL document.