]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/sound.js
kill off soundmanager (flash is dead)
[irc/quakenet/qwebirc.git] / js / sound.js
index ba8c1a37b6cd4a68869594e41e857a52408d0ddb..1019e74413cb2809e2e88882ac1d6a6320f1c12a 100644 (file)
@@ -1,65 +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;
-  },
-  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;
-    }
-    
-    qwebirc.util.importJS(qwebirc.global.staticBaseURL + "js/" + (QWEBIRC_DEBUG?"soundmanager2":"soundmanager2-nodebug-jsmin") + ".js", "soundManager", function() {
-      soundManager.url = qwebirc.global.staticBaseURL + "sound/";
+    var sb = qwebirc.global.staticBaseURL;
+    if(qwebirc.global.baseURL.substr(qwebirc.global.baseURL.length - 1, 1) == "/" && sb.substr(0, 1) == "/")
+      sb = sb.substr(1);
 
-      var debugMode = false;
-      soundManager.debugMode = debugMode;
-      soundManager.useConsole = debugMode;
-      soundManager.onload = function() {
-        this.loadedSWF = true;
-        this.fireEvent("ready");
-      }.bind(this);
-      soundManager.beginDelayedInit();
-    }.bind(this));
+    this.sounds = {};
+    this.soundURL = qwebirc.global.baseURL + sb + "sound/";
   },
-  createSound: function(name, src) {
+  play: function(url) {
     try {
-      soundManager.createSound(name, src);
+      var s = this.sounds[url];
+      if (!s)
+        s = this.sounds[url] = new Audio(this.soundURL + url);
+      s.play();
     } catch(e) {
-      /* ignore... flashblock triggers this */
-    }
-  },
-  playSound: function(name) {
-    try {
-      soundManager.play(name);
-    } catch(e) {
-      /* ignore... */
-    }
-  },
-  beep: function() {
-    if(!this.beepLoaded) {
-      this.createSound("beep", qwebirc.global.staticBaseURL + "sound/beep3.mp3");
-      this.beepLoaded = true;
+      /* we tried */
     }
-    this.playSound("beep");
   }
 });