]> 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 66ebdd05a04ff5d9a0ae3f1e3f6ef43cd0bca8d3..1019e74413cb2809e2e88882ac1d6a6320f1c12a 100644 (file)
@@ -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");
   }
 });