-qwebirc.sound.domReady = false;
-window.addEvent("domready", function() {
- qwebirc.sound.domReady = true;
-});
-
qwebirc.sound.SoundPlayer = new Class({
Implements: [Events],
initialize: function() {
- this.loadingSWF = false;
- this.loadedSWF = false;
- },
- go: function() {
- if(qwebirc.sound.domReady) {
- this.loadSoundManager();
- } else {
- window.addEvent("domready", function() {
- this.loadSoundManager();
- }.bind(this));
- }
- },
- loadSoundManager: function() {
- if(this.loadingSWF)
- return;
- this.loadingSWF = true;
- if(eval("typeof soundManager") != "undefined") {
- this.loadedSWF = true;
- this.fireEvent("ready");
- return;
- }
-
- var debugMode = false;
- qwebirc.util.importJS(qwebirc.global.staticBaseURL + "js/" + (debugMode?"soundmanager2":"soundmanager2-nodebug-jsmin") + ".js", "soundManager", function() {
- soundManager.url = qwebirc.global.staticBaseURL + "sound/";
-
- soundManager.debugMode = debugMode;
- soundManager.useConsole = debugMode;
- soundManager.onload = function() {
- this.loadedSWF = true;
- this.fireEvent("ready");
- }.bind(this);
- soundManager.beginDelayedInit();
- }.bind(this));
- },
- createSound: function(name, src) {
- soundManager.createSound(name, src);
- },
- playSound: function(name) {
- soundManager.play(name);
+ var sb = qwebirc.global.staticBaseURL;
+ if(qwebirc.global.baseURL.substr(qwebirc.global.baseURL.length - 1, 1) == "/" && sb.substr(0, 1) == "/")
+ sb = sb.substr(1);
+
+ this.sounds = {};
+ this.soundURL = qwebirc.global.baseURL + sb + "sound/";
},
- beep: function() {
- if(!this.beepLoaded) {
- this.createSound("beep", qwebirc.global.staticBaseURL + "sound/beep3.mp3");
- this.beepLoaded = true;
+ play: function(url) {
+ try {
+ var s = this.sounds[url];
+ if (!s)
+ s = this.sounds[url] = new Audio(this.soundURL + url);
+ s.play();
+ } catch(e) {
+ /* we tried */
}
- this.playSound("beep");
}
});