This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / httemplate / elements / qlib / sound.js
1 /**\r
2  * QLIB 1.0 Preloaded Sound\r
3  * Copyright (C) 2002 2003, Quazzle.com Serge Dolgov\r
4  * This program is free software; you can redistribute it and/or\r
5  * modify it under the terms of the GNU General Public License\r
6  * as published by the Free Software Foundation; either version 2\r
7  * of the License, or (at your option) any later version.\r
8  * http://qlib.quazzle.com\r
9  */\r
10 \r
11 function QSound_play(loop) {\r
12     this._out.loop = loop || 0;\r
13     this._out.src = this._buf.src;\r
14 }\r
15 \r
16 function QSound_stop() {\r
17     this._out.loop = 0;\r
18     this._out.src = "";\r
19 }\r
20 \r
21 function QSound_setVolume(volume) {\r
22     this._out.volume = this.volume = volume;\r
23 }\r
24  \r
25 function QSound(parent, name, src, volume) {\r
26     this.init(parent, name);\r
27     this.volume = volume || 0;\r
28     this.play = this.stop = this.setVolume = QControl.nop;\r
29     with (this) {\r
30         document.write('<bgsound id="' + id + '" src="" volume="' + volume + '">');\r
31         if (document.all && document.all.item) {\r
32             this._out = document.all.item(id);\r
33             if (_out && (typeof _out.src != "undefined") && (_out.volume === volume)) {\r
34                 document.write('<bgsound id="b' + id + '" src="' + src + '" volume="-10000">');\r
35                 this._buf = document.all.item("b" + id);\r
36                 if (_buf) {\r
37                     this.play = QSound_play;\r
38                     this.stop = QSound_stop;\r
39                     this.setVolume = QSound_setVolume;\r
40 \r
41                     _out.onreadystatechange = new Function("alert(0)");\r
42                 }\r
43             }\r
44         }\r
45     }\r
46 }\r
47 QSound.prototype = new QControl();\r