--- books/www/chapters/ch05.html 2002/12/14 14:28:30 1.16 +++ books/www/chapters/ch05.html 2002/12/17 13:13:19 1.19 @@ -1273,23 +1273,28 @@ retval=OK; "77032"> Scripting components from HTML

<html> - <head> - <title>Sound Service Play Example</title> - <script> - function play() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - var sample = Components.classes["@mozilla.org/sound;1"].createInstance(); - sample = sample.QueryInterface(Components.interfaces.nsISound); - sample.playSystemSound('resource:/res/samples/test.wav'); - } - </script> - </head> - <body> - <form name="form"> - <input type="button" value="Play Sound" onclick="play();"> - </form> - </body> - </html> + <head> + <title>Sound Service Play Example</title> + <script> + function play() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var sample = Components.classes["@mozilla.org/sound;1"].createInstance(); + sample = sample.QueryInterface(Components.interfaces.nsISound); + const SND_NETWORK_STD_CID = "@mozilla.org/network/standard-url;1"; + const SND_I_URL = "nsIURL"; + const SND_URL = new C.Constructor(SND_NETWORK_STD_CID, SND_I_URL); + var url = new SND_URL(); + url.spec = 'http://jslib.mozdev.org/test.wav'; + sample.play(url); + } + </script> + </head> + <body> + <form name="form"> + <input type="button" value="Play Sound" onclick="play();"> + </form> + </body> +</html>

As in Example 5-10, the classes[ ] array on the special Mozilla Components object refers