5

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.

Community
  • 1
  • 1
user1016313
  • 1,274
  • 2
  • 15
  • 26

1 Answers1

-1

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.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126