]> jfr.im git - irc/quakenet/qwebirc.git/blob - js/sound.js
iframes should not have borders -- breaks page layout
[irc/quakenet/qwebirc.git] / js / sound.js
1 qwebirc.sound.domReady = false;
2 window.addEvent("domready", function() {
3 qwebirc.sound.domReady = true;
4 });
5
6 qwebirc.sound.SoundPlayer = new Class({
7 Implements: [Events],
8 initialize: function() {
9 this.loadingSWF = false;
10 this.loadedSWF = false;
11
12 var sb = qwebirc.global.staticBaseURL;
13 if(qwebirc.global.baseURL.substr(qwebirc.global.baseURL.length - 1, 1) == "/" && sb.substr(0, 1) == "/")
14 sb = sb.substr(1)
15
16 this.soundURL = qwebirc.global.baseURL + sb + "sound/";
17 },
18 go: function() {
19 if(qwebirc.sound.domReady) {
20 this.loadSoundManager();
21 } else {
22 window.addEvent("domready", function() {
23 this.loadSoundManager();
24 }.bind(this));
25 }
26 },
27 loadSoundManager: function() {
28 if(this.loadingSWF)
29 return;
30 this.loadingSWF = true;
31
32 var debugMode = false;
33
34 window.soundManager = new SoundManager();
35
36 var sb = qwebirc.global.staticBaseURL;
37 if(qwebirc.global.baseURL.substr(-1) == "/" && sb.substr(0, 1) == "/")
38 sb = sb.substr(1)
39
40 window.soundManager.url = this.soundURL;
41 window.soundManager.debugMode = debugMode;
42 window.soundManager.useConsole = debugMode;
43 window.soundManager.onload = function() {
44 this.loadedSWF = true;
45 this.fireEvent("ready");
46 }.bind(this);
47 window.soundManager.beginDelayedInit();
48 },
49 createSound: function(name, src) {
50 try {
51 soundManager.createSound(name, src);
52 } catch(e) {
53 /* ignore... flashblock triggers this */
54 }
55 },
56 playSound: function(name) {
57 try {
58 soundManager.play(name);
59 } catch(e) {
60 /* ignore... */
61 }
62 },
63 beep: function() {
64 if(!this.beepLoaded) {
65 this.createSound("beep", this.soundURL + "beep3.mp3");
66 this.beepLoaded = true;
67 }
68 this.playSound("beep");
69 }
70 });