X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/d84a29436096dd1db540c9d80ed18aac2d5653b4..9d0347c5fb69425f90d64215f1555643c5822a59:/js/sound.js diff --git a/js/sound.js b/js/sound.js index 66ebdd0..1019e74 100644 --- a/js/sound.js +++ b/js/sound.js @@ -1,70 +1,21 @@ -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; - var sb = qwebirc.global.staticBaseURL; if(qwebirc.global.baseURL.substr(qwebirc.global.baseURL.length - 1, 1) == "/" && sb.substr(0, 1) == "/") - sb = sb.substr(1) + sb = sb.substr(1); + this.sounds = {}; this.soundURL = qwebirc.global.baseURL + sb + "sound/"; }, - 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; - - var debugMode = false; - - window.soundManager = new SoundManager(); - - var sb = qwebirc.global.staticBaseURL; - if(qwebirc.global.baseURL.substr(-1) == "/" && sb.substr(0, 1) == "/") - sb = sb.substr(1) - - window.soundManager.url = this.soundURL; - window.soundManager.debugMode = debugMode; - window.soundManager.useConsole = debugMode; - window.soundManager.onload = function() { - this.loadedSWF = true; - this.fireEvent("ready"); - }.bind(this); - window.soundManager.beginDelayedInit(); - }, - createSound: function(name, src) { - try { - soundManager.createSound(name, src); - } catch(e) { - /* ignore... flashblock triggers this */ - } - }, - playSound: function(name) { + play: function(url) { try { - soundManager.play(name); + var s = this.sounds[url]; + if (!s) + s = this.sounds[url] = new Audio(this.soundURL + url); + s.play(); } catch(e) { - /* ignore... */ - } - }, - beep: function() { - if(!this.beepLoaded) { - this.createSound("beep", this.soundURL + "beep3.mp3"); - this.beepLoaded = true; + /* we tried */ } - this.playSound("beep"); } });