Table of contents
- 1. Method overview
- 2. Constants
- 3. Methods
- 3.1. beep()
- 3.2. init()
- 3.3. play()
- 3.4. playEventSound()
- 3.5. playSystemSound()
nsISupports
Last changed in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)
Note that nsISound instances may play the sounds using another thread; however, this is not controlled by the caller.
Implemented by: @mozilla.org/sound;1. To use this interface, use:
var sound = Components.classes["@mozilla.org/sound;1"]
.createInstance(Components.interfaces.nsISound);
Method overview
void beep(); |
void init(); |
void play(in nsIURL aURL); |
void playEventSound(in unsigned long aEventId); Requires Gecko 1.9.2
|
void playSystemSound(in AString soundAlias); |
Constants
Sound event constants
| Constant | Value | Description |
EVENT_NEW_MAIL_RECEIVED | 0 | The system receives email. Requires Gecko 1.9.2 |
EVENT_ALERT_DIALOG_OPEN | 1 | An alert dialog is opened. Requires Gecko 1.9.2 |
EVENT_CONFIRM_DIALOG_OPEN | 2 | A confirm dialog is opened. Requires Gecko 1.9.2 |
EVENT_PROMPT_DIALOG_OPEN | 3 | A prompt dialog (one that allows the user to enter data, such as an authentication dialog) is opened. Requires Gecko 1.9.2 |
EVENT_SELECT_DIALOG_OPEN | 4 | A select dialog (one that contains a list box) is opened. Requires Gecko 1.9.2 |
EVENT_MENU_EXECUTE | 5 | A menu item is executed. Requires Gecko 1.9.2 |
EVENT_MENU_POPUP | 6 | A popup menu is shown. Requires Gecko 1.9.2 |
EVENT_EDITOR_MAX_LEN | 7 | More characters than the maximum allowed are typed into a text field. Requires Gecko 9.0 |
Methods
beep()
Plays a beep sound.
void beep();
Parameters
None.
init()
Not strictly necessary, but avoids a delay before the first sound. Other methods will call Init if they need to.
void init();
Parameters
None.
play()
Plays a sound specified by URL.
void play( in nsIURL aURL );
Parameters
aURL- The URL of the sound file to play.
playEventSound()
Plays the system sound for the specified event. If the user's system is configured to not play system sound effects for the event, this will do nothing.
void playEventSound( in unsigned long aEventId );
Parameters
aEventId- An event ID which is defined in the constants.
playSystemSound()
Plays the system sound whose name is specified. If the user's system is configured to not play system sound effects, this will do nothing.
void playSystemSound( in AString soundAlias );
Parameters
soundAlias-
Two different types of names are supported:
You can specify the name of a system sound provided by the host operating system; for example, if you specify "
SystemExclamation", you can play the Windows alert sound, but it's played only on Windows. Similarly, if you specify "Blow", you can play the Mac OS X "Blow" system sound, but, similarly, it's played only on the Macintosh. If you wish to use this method for playing sounds, you should check the platform before you callplaySystemSound().Note: This second usage is obsolete starting in Gecko 1.9.2. You should instead useplayEventSound()instead.Typically, it will be more useful to request that appropriate sounds be played based on which event you wish to represent by the sound effect. Various event names are provided, which will result in playing the corresponding sound effect on the platform the user is running on:
_moz_mailbeep- The system sound when the system receives email.
_moz_alertdialogRequires Gecko 1.9.1- The system sound when an alert dialog is opened.
_moz_confirmdialogRequires Gecko 1.9.1- The system sound when a confirm dialog is opened.
_moz_promptdialogRequires Gecko 1.9.1- The system sound when a prompt dialog (one that allows the user to enter data, such as an authentication dialog) is opened.
_moz_selectdialogRequires Gecko 1.9.1- The system sound when a select dialog (one that contains a list box) is opened.
_moz_menucommandRequires Gecko 1.9.1- The system sound when a menu item is executed.
_moz_menupopupRequires Gecko 1.9.1- The system sound when a popup menu is shown.


Mozilla Developer Network