nsISound

IID:B148EED1-236D-11d3-B35C-00A0CC3C1CDE
Inherits From:nsISupports

This interface is implemented by the following components:


Methods

void beep ( ) void init ( ) void play ( nsIURL URL ) void playSystemSound ( char* soundAlias )

void beep ( )


void init ( )

Not strictly necessary, but avoids delay before first sound. The various methods on nsISound call Init() if they need to.


void play ( nsIURL URL )

Arguments:
URL

void playSystemSound ( char* soundAlias )

For playing system sounds

Arguments:
soundAlias

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
March 4, 2005, 3:28 pm ihoss dot com at gmail dot com
To use nsISound to play a sound file use the code below:


soundURL = "chrome://extension/skin/file.wav";
//If you want to run it from a local file
//you have to change the soundURL to a file. If it is in
//the same directory simply use file.wav as SoundURL.
gSound = Components.classes["@mozilla.org/sound;1"].
createInstance(Components.interfaces.nsISound);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var url = ioService.newURI(soundURL, null, null);
gSound.play(url);

Copyright © 1999 - 2005 XULPlanet.com