Skip to content

Node.js based forum software built for the modern web

adding buzz and sound assets

Julian Lam4cb9f3425379
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md
new file mode 100644
index 0000000000..b4b25e5073
--- /dev/null
+++ b/ATTRIBUTION.md
@@ -0,0 +1,4 @@
+## Sound Assets
+
+* "Waterdrop" by [Porphyr](freesound.org/people/Porphyr) / [CC BY 3.0](creativecommons.org/licenses/by/3.0)
+* "SweetAlertSound2.wav" by [KIZILSUNGUR](http://www.freesound.org/people/KIZILSUNGUR/) / [Public Domain / CC 0](http://creativecommons.org/publicdomain/zero/1.0/)
\ No newline at end of file
diff --git a/public/sound/chat-outgoing.wav b/public/sound/chat-outgoing.wav
new file mode 100644
index 0000000000..4ad54e4a67
Binary files /dev/null and b/public/sound/chat-outgoing.wav differ
diff --git a/public/sound/notification.wav b/public/sound/notification.wav
new file mode 100644
index 0000000000..c6ba307524
Binary files /dev/null and b/public/sound/notification.wav differ
diff --git a/public/vendor/buzz/buzz.js b/public/vendor/buzz/buzz.js
new file mode 100644
index 0000000000..0b289df5c8
--- /dev/null
+++ b/public/vendor/buzz/buzz.js
@@ -0,0 +1,698 @@
+ // ----------------------------------------------------------------------------
+ // Buzz, a Javascript HTML5 Audio library
+ // v1.1.0 - released 2013-08-15 13:18
+ // Licensed under the MIT license.
+ // http://buzz.jaysalvat.com/
+ // ----------------------------------------------------------------------------
+ // Copyright (C) 2010-2013 Jay Salvat
+ // http://jaysalvat.com/
+ // ----------------------------------------------------------------------------
+
+(function(name, context, factory) {
+ if (typeof module !== "undefined" && module.exports) {
+ module.exports = factory();
+ } else if (typeof context.define === "function" && context.define.amd) {
+ define(name, [], factory);
+ } else {
+ context[name] = factory();
+ }
+})("buzz", this, function() {
+ var buzz = {
+ defaults: {
+ autoplay: false,
+ duration: 5e3,
+ formats: [],
+ loop: false,
+ placeholder: "--",
+ preload: "metadata",
+ volume: 80,
+ document: document
+ },
+ types: {
+ mp3: "audio/mpeg",
+ ogg: "audio/ogg",
+ wav: "audio/wav",
+ aac: "audio/aac",
+ m4a: "audio/x-m4a"
+ },
+ sounds: [],
+ el: document.createElement("audio"),
+ sound: function(src, options) {
+ options = options || {};
+ var doc = options.document || buzz.defaults.document;
+ var pid = 0, events = [], eventsOnce = {}, supported = buzz.isSupported();
+ this.load = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.load();
+ return this;
+ };
+ this.play = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.play();
+ return this;
+ };
+ this.togglePlay = function() {
+ if (!supported) {
+ return this;
+ }
+ if (this.sound.paused) {
+ this.sound.play();
+ } else {
+ this.sound.pause();
+ }
+ return this;
+ };
+ this.pause = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.pause();
+ return this;
+ };
+ this.isPaused = function() {
+ if (!supported) {
+ return null;
+ }
+ return this.sound.paused;
+ };
+ this.stop = function() {
+ if (!supported) {
+ return this;
+ }
+ this.setTime(0);
+ this.sound.pause();
+ return this;
+ };
+ this.isEnded = function() {
+ if (!supported) {
+ return null;
+ }
+ return this.sound.ended;
+ };
+ this.loop = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.loop = "loop";
+ this.bind("ended.buzzloop", function() {
+ this.currentTime = 0;
+ this.play();
+ });
+ return this;
+ };
+ this.unloop = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.removeAttribute("loop");
+ this.unbind("ended.buzzloop");
+ return this;
+ };
+ this.mute = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.muted = true;
+ return this;
+ };
+ this.unmute = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.muted = false;
+ return this;
+ };
+ this.toggleMute = function() {
+ if (!supported) {
+ return this;
+ }
+ this.sound.muted = !this.sound.muted;
+ return this;
+ };
+ this.isMuted = function() {
+ if (!supported) {
+ return null;
+ }
+ return this.sound.muted;
+ };
+ this.setVolume = function(volume) {
+ if (!supported) {
+ return this;
+ }
+ if (volume < 0) {
+ volume = 0;
+ }
+ if (volume > 100) {
+ volume = 100;
+ }
+ this.volume = volume;
+ this.sound.volume = volume / 100;
+ return this;
+ };
+ this.getVolume = function() {
+ if (!supported) {
+ return this;
+ }
+ return this.volume;
+ };
+ this.increaseVolume = function(value) {
+ return this.setVolume(this.volume + (value || 1));
+ };
+ this.decreaseVolume = function(value) {
+ return this.setVolume(this.volume - (value || 1));
+ };
+ this.setTime = function(time) {
+ if (!supported) {
+ return this;
+ }
+ var set = true;
+ this.whenReady(function() {
+ if (set === true) {
+ set = false;
+ this.sound.currentTime = time;
+ }
+ });
+ return this;
+ };
+ this.getTime = function() {
+ if (!supported) {
+ return null;
+ }
+ var time = Math.round(this.sound.currentTime * 100) / 100;
+ return isNaN(time) ? buzz.defaults.placeholder : time;
+ };
+ this.setPercent = function(percent) {
+ if (!supported) {
+ return this;
+ }
+ return this.setTime(buzz.fromPercent(percent, this.sound.duration));
+ };
+ this.getPercent = function() {
+ if (!supported) {
+ return null;
+ }
+ var percent = Math.round(buzz.toPercent(this.sound.currentTime, this.sound.duration));
+ return isNaN(percent) ? buzz.defaults.placeholder : percent;
+ };
+ this.setSpeed = function(duration) {
+ if (!supported) {
+ return this;
+ }
+ this.sound.playbackRate = duration;
+ return this;
+ };
+ this.getSpeed = function() {
+ if (!supported) {
+ return null;
+ }
+ return this.sound.playbackRate;
+ };
+ this.getDuration = function() {
+ if (!supported) {
+ return null;
+ }
+ var duration = Math.round(this.sound.duration * 100) / 100;
+ return isNaN(duration) ? buzz.defaults.placeholder : duration;
+ };
+ this.getPlayed = function() {
+ if (!supported) {
+ return null;
+ }
+ return timerangeToArray(this.sound.played);
+ };
+ this.getBuffered = function() {
+ if (!supported) {
+ return null;
+ }
+ return timerangeToArray(this.sound.buffered);
+ };
+ this.getSeekable = function() {
+ if (!supported) {
+ return null;
+ }
+ return timerangeToArray(this.sound.seekable);
+ };
+ this.getErrorCode = function() {
+ if (supported && this.sound.error) {
+ return this.sound.error.code;
+ }
+ return 0;
+ };
+ this.getErrorMessage = function() {
+ if (!supported) {
+ return null;
+ }
+ switch (this.getErrorCode()) {
+ case 1:
+ return "MEDIA_ERR_ABORTED";
+
+ case 2:
+ return "MEDIA_ERR_NETWORK";
+
+ case 3:
+ return "MEDIA_ERR_DECODE";
+
+ case 4:
+ return "MEDIA_ERR_SRC_NOT_SUPPORTED";
+
+ default:
+ return null;
+ }
+ };
+ this.getStateCode = function() {
+ if (!supported) {
+ return null;
+ }
+ return this.sound.readyState;
+ };
+ this.getStateMessage = function() {
+ if (!supported) {
+ return null;
+ }
+ switch (this.getStateCode()) {
+ case 0:
+ return "HAVE_NOTHING";
+
+ case 1:
+ return "HAVE_METADATA";
+
+ case 2:
+ return "HAVE_CURRENT_DATA";
+
+ case 3:
+ return "HAVE_FUTURE_DATA";
+
+ case 4:
+ return "HAVE_ENOUGH_DATA";
+
+ default:
+ return null;
+ }
+ };
+ this.getNetworkStateCode = function() {
+ if (!supported) {
+ return null;
+ }
+ return this.sound.networkState;
+ };
+ this.getNetworkStateMessage = function() {
+ if (!supported) {
+ return null;
+ }
+ switch (this.getNetworkStateCode()) {
+ case 0:
+ return "NETWORK_EMPTY";
+
+ case 1:
+ return "NETWORK_IDLE";
+
+ case 2:
+ return "NETWORK_LOADING";
+
+ case 3:
+ return "NETWORK_NO_SOURCE";
+
+ default:
+ return null;
+ }
+ };
+ this.set = function(key, value) {
+ if (!supported) {
+ return this;
+ }
+ this.sound[key] = value;
+ return this;
+ };
+ this.get = function(key) {
+ if (!supported) {
+ return null;
+ }
+ return key ? this.sound[key] : this.sound;
+ };
+ this.bind = function(types, func) {
+ if (!supported) {
+ return this;
+ }
+ types = types.split(" ");
+ var self = this, efunc = function(e) {
+ func.call(self, e);
+ };
+ for (var t = 0; t < types.length; t++) {
+ var type = types[t], idx = type;
+ type = idx.split(".")[0];
+ events.push({
+ idx: idx,
+ func: efunc
+ });
+ this.sound.addEventListener(type, efunc, true);
+ }
+ return this;
+ };
+ this.unbind = function(types) {
+ if (!supported) {
+ return this;
+ }
+ types = types.split(" ");
+ for (var t = 0; t < types.length; t++) {
+ var idx = types[t], type = idx.split(".")[0];
+ for (var i = 0; i < events.length; i++) {
+ var namespace = events[i].idx.split(".");
+ if (events[i].idx == idx || namespace[1] && namespace[1] == idx.replace(".", "")) {
+ this.sound.removeEventListener(type, events[i].func, true);
+ events.splice(i, 1);
+ }
+ }
+ }
+ return this;
+ };
+ this.bindOnce = function(type, func) {
+ if (!supported) {
+ return this;
+ }
+ var self = this;
+ eventsOnce[pid++] = false;
+ this.bind(type + "." + pid, function() {
+ if (!eventsOnce[pid]) {
+ eventsOnce[pid] = true;
+ func.call(self);
+ }
+ self.unbind(type + "." + pid);
+ });
+ return this;
+ };
+ this.trigger = function(types) {
+ if (!supported) {
+ return this;
+ }
+ types = types.split(" ");
+ for (var t = 0; t < types.length; t++) {
+ var idx = types[t];
+ for (var i = 0; i < events.length; i++) {
+ var eventType = events[i].idx.split(".");
+ if (events[i].idx == idx || eventType[0] && eventType[0] == idx.replace(".", "")) {
+ var evt = doc.createEvent("HTMLEvents");
+ evt.initEvent(eventType[0], false, true);
+ this.sound.dispatchEvent(evt);
+ }
+ }
+ }
+ return this;
+ };
+ this.fadeTo = function(to, duration, callback) {
+ if (!supported) {
+ return this;
+ }
+ if (duration instanceof Function) {
+ callback = duration;
+ duration = buzz.defaults.duration;
+ } else {
+ duration = duration || buzz.defaults.duration;
+ }
+ var from = this.volume, delay = duration / Math.abs(from - to), self = this;
+ this.play();
+ function doFade() {
+ setTimeout(function() {
+ if (from < to && self.volume < to) {
+ self.setVolume(self.volume += 1);
+ doFade();
+ } else if (from > to && self.volume > to) {
+ self.setVolume(self.volume -= 1);
+ doFade();
+ } else if (callback instanceof Function) {
+ callback.apply(self);
+ }
+ }, delay);
+ }
+ this.whenReady(function() {
+ doFade();
+ });
+ return this;
+ };
+ this.fadeIn = function(duration, callback) {
+ if (!supported) {
+ return this;
+ }
+ return this.setVolume(0).fadeTo(100, duration, callback);
+ };
+ this.fadeOut = function(duration, callback) {
+ if (!supported) {
+ return this;
+ }
+ return this.fadeTo(0, duration, callback);
+ };
+ this.fadeWith = function(sound, duration) {
+ if (!supported) {
+ return this;
+ }
+ this.fadeOut(duration, function() {
+ this.stop();
+ });
+ sound.play().fadeIn(duration);
+ return this;
+ };
+ this.whenReady = function(func) {
+ if (!supported) {
+ return null;
+ }
+ var self = this;
+ if (this.sound.readyState === 0) {
+ this.bind("canplay.buzzwhenready", function() {
+ func.call(self);
+ });
+ } else {
+ func.call(self);
+ }
+ };
+ function timerangeToArray(timeRange) {
+ var array = [], length = timeRange.length - 1;
+ for (var i = 0; i <= length; i++) {
+ array.push({
+ start: timeRange.start(i),
+ end: timeRange.end(i)
+ });
+ }
+ return array;
+ }
+ function getExt(filename) {
+ return filename.split(".").pop();
+ }
+ function addSource(sound, src) {
+ var source = doc.createElement("source");
+ source.src = src;
+ if (buzz.types[getExt(src)]) {
+ source.type = buzz.types[getExt(src)];
+ }
+ sound.appendChild(source);
+ }
+ if (supported && src) {
+ for (var i in buzz.defaults) {
+ if (buzz.defaults.hasOwnProperty(i)) {
+ options[i] = options[i] || buzz.defaults[i];
+ }
+ }
+ this.sound = doc.createElement("audio");
+ if (src instanceof Array) {
+ for (var j in src) {
+ if (src.hasOwnProperty(j)) {
+ addSource(this.sound, src[j]);
+ }
+ }
+ } else if (options.formats.length) {
+ for (var k in options.formats) {
+ if (options.formats.hasOwnProperty(k)) {
+ addSource(this.sound, src + "." + options.formats[k]);
+ }
+ }
+ } else {
+ addSource(this.sound, src);
+ }
+ if (options.loop) {
+ this.loop();
+ }
+ if (options.autoplay) {
+ this.sound.autoplay = "autoplay";
+ }
+ if (options.preload === true) {
+ this.sound.preload = "auto";
+ } else if (options.preload === false) {
+ this.sound.preload = "none";
+ } else {
+ this.sound.preload = options.preload;
+ }
+ this.setVolume(options.volume);
+ buzz.sounds.push(this);
+ }
+ },
+ group: function(sounds) {
+ sounds = argsToArray(sounds, arguments);
+ this.getSounds = function() {
+ return sounds;
+ };
+ this.add = function(soundArray) {
+ soundArray = argsToArray(soundArray, arguments);
+ for (var a = 0; a < soundArray.length; a++) {
+ sounds.push(soundArray[a]);
+ }
+ };
+ this.remove = function(soundArray) {
+ soundArray = argsToArray(soundArray, arguments);
+ for (var a = 0; a < soundArray.length; a++) {
+ for (var i = 0; i < sounds.length; i++) {
+ if (sounds[i] == soundArray[a]) {
+ sounds.splice(i, 1);
+ break;
+ }
+ }
+ }
+ };
+ this.load = function() {
+ fn("load");
+ return this;
+ };
+ this.play = function() {
+ fn("play");
+ return this;
+ };
+ this.togglePlay = function() {
+ fn("togglePlay");
+ return this;
+ };
+ this.pause = function(time) {
+ fn("pause", time);
+ return this;
+ };
+ this.stop = function() {
+ fn("stop");
+ return this;
+ };
+ this.mute = function() {
+ fn("mute");
+ return this;
+ };
+ this.unmute = function() {
+ fn("unmute");
+ return this;
+ };
+ this.toggleMute = function() {
+ fn("toggleMute");
+ return this;
+ };
+ this.setVolume = function(volume) {
+ fn("setVolume", volume);
+ return this;
+ };
+ this.increaseVolume = function(value) {
+ fn("increaseVolume", value);
+ return this;
+ };
+ this.decreaseVolume = function(value) {
+ fn("decreaseVolume", value);
+ return this;
+ };
+ this.loop = function() {
+ fn("loop");
+ return this;
+ };
+ this.unloop = function() {
+ fn("unloop");
+ return this;
+ };
+ this.setTime = function(time) {
+ fn("setTime", time);
+ return this;
+ };
+ this.set = function(key, value) {
+ fn("set", key, value);
+ return this;
+ };
+ this.bind = function(type, func) {
+ fn("bind", type, func);
+ return this;
+ };
+ this.unbind = function(type) {
+ fn("unbind", type);
+ return this;
+ };
+ this.bindOnce = function(type, func) {
+ fn("bindOnce", type, func);
+ return this;
+ };
+ this.trigger = function(type) {
+ fn("trigger", type);
+ return this;
+ };
+ this.fade = function(from, to, duration, callback) {
+ fn("fade", from, to, duration, callback);
+ return this;
+ };
+ this.fadeIn = function(duration, callback) {
+ fn("fadeIn", duration, callback);
+ return this;
+ };
+ this.fadeOut = function(duration, callback) {
+ fn("fadeOut", duration, callback);
+ return this;
+ };
+ function fn() {
+ var args = argsToArray(null, arguments), func = args.shift();
+ for (var i = 0; i < sounds.length; i++) {
+ sounds[i][func].apply(sounds[i], args);
+ }
+ }
+ function argsToArray(array, args) {
+ return array instanceof Array ? array : Array.prototype.slice.call(args);
+ }
+ },
+ all: function() {
+ return new buzz.group(buzz.sounds);
+ },
+ isSupported: function() {
+ return !!buzz.el.canPlayType;
+ },
+ isOGGSupported: function() {
+ return !!buzz.el.canPlayType && buzz.el.canPlayType('audio/ogg; codecs="vorbis"');
+ },
+ isWAVSupported: function() {
+ return !!buzz.el.canPlayType && buzz.el.canPlayType('audio/wav; codecs="1"');
+ },
+ isMP3Supported: function() {
+ return !!buzz.el.canPlayType && buzz.el.canPlayType("audio/mpeg;");
+ },
+ isAACSupported: function() {
+ return !!buzz.el.canPlayType && (buzz.el.canPlayType("audio/x-m4a;") || buzz.el.canPlayType("audio/aac;"));
+ },
+ toTimer: function(time, withHours) {
+ var h, m, s;
+ h = Math.floor(time / 3600);
+ h = isNaN(h) ? "--" : h >= 10 ? h : "0" + h;
+ m = withHours ? Math.floor(time / 60 % 60) : Math.floor(time / 60);
+ m = isNaN(m) ? "--" : m >= 10 ? m : "0" + m;
+ s = Math.floor(time % 60);
+ s = isNaN(s) ? "--" : s >= 10 ? s : "0" + s;
+ return withHours ? h + ":" + m + ":" + s : m + ":" + s;
+ },
+ fromTimer: function(time) {
+ var splits = time.toString().split(":");
+ if (splits && splits.length == 3) {
+ time = parseInt(splits[0], 10) * 3600 + parseInt(splits[1], 10) * 60 + parseInt(splits[2], 10);
+ }
+ if (splits && splits.length == 2) {
+ time = parseInt(splits[0], 10) * 60 + parseInt(splits[1], 10);
+ }
+ return time;
+ },
+ toPercent: function(value, total, decimal) {
+ var r = Math.pow(10, decimal || 0);
+ return Math.round(value * 100 / total * r) / r;
+ },
+ fromPercent: function(percent, total, decimal) {
+ var r = Math.pow(10, decimal || 0);
+ return Math.round(total / 100 * percent * r) / r;
+ }
+ };
+ return buzz;
+});
\ No newline at end of file
diff --git a/public/vendor/buzz/buzz.min.js b/public/vendor/buzz/buzz.min.js
new file mode 100644
index 0000000000..556ce7663b
--- /dev/null
+++ b/public/vendor/buzz/buzz.min.js
@@ -0,0 +1,11 @@
+ // ----------------------------------------------------------------------------
+ // Buzz, a Javascript HTML5 Audio library
+ // v1.1.0 - released 2013-08-15 13:18
+ // Licensed under the MIT license.
+ // http://buzz.jaysalvat.com/
+ // ----------------------------------------------------------------------------
+ // Copyright (C) 2010-2013 Jay Salvat
+ // http://jaysalvat.com/
+ // ----------------------------------------------------------------------------
+
+(function(t,n,e){"undefined"!=typeof module&&module.exports?module.exports=e():"function"==typeof n.define&&n.define.amd?define(t,[],e):n[t]=e()})("buzz",this,function(){var t={defaults:{autoplay:!1,duration:5e3,formats:[],loop:!1,placeholder:"--",preload:"metadata",volume:80,document:document},types:{mp3:"audio/mpeg",ogg:"audio/ogg",wav:"audio/wav",aac:"audio/aac",m4a:"audio/x-m4a"},sounds:[],el:document.createElement("audio"),sound:function(n,e){function i(t){for(var n=[],e=t.length-1,i=0;e>=i;i++)n.push({start:t.start(i),end:t.end(i)});return n}function u(t){return t.split(".").pop()}function s(n,e){var i=r.createElement("source");i.src=e,t.types[u(e)]&&(i.type=t.types[u(e)]),n.appendChild(i)}e=e||{};var r=e.document||t.defaults.document,o=0,a=[],h={},l=t.isSupported();if(this.load=function(){return l?(this.sound.load(),this):this},this.play=function(){return l?(this.sound.play(),this):this},this.togglePlay=function(){return l?(this.sound.paused?this.sound.play():this.sound.pause(),this):this},this.pause=function(){return l?(this.sound.pause(),this):this},this.isPaused=function(){return l?this.sound.paused:null},this.stop=function(){return l?(this.setTime(0),this.sound.pause(),this):this},this.isEnded=function(){return l?this.sound.ended:null},this.loop=function(){return l?(this.sound.loop="loop",this.bind("ended.buzzloop",function(){this.currentTime=0,this.play()}),this):this},this.unloop=function(){return l?(this.sound.removeAttribute("loop"),this.unbind("ended.buzzloop"),this):this},this.mute=function(){return l?(this.sound.muted=!0,this):this},this.unmute=function(){return l?(this.sound.muted=!1,this):this},this.toggleMute=function(){return l?(this.sound.muted=!this.sound.muted,this):this},this.isMuted=function(){return l?this.sound.muted:null},this.setVolume=function(t){return l?(0>t&&(t=0),t>100&&(t=100),this.volume=t,this.sound.volume=t/100,this):this},this.getVolume=function(){return l?this.volume:this},this.increaseVolume=function(t){return this.setVolume(this.volume+(t||1))},this.decreaseVolume=function(t){return this.setVolume(this.volume-(t||1))},this.setTime=function(t){if(!l)return this;var n=!0;return this.whenReady(function(){n===!0&&(n=!1,this.sound.currentTime=t)}),this},this.getTime=function(){if(!l)return null;var n=Math.round(100*this.sound.currentTime)/100;return isNaN(n)?t.defaults.placeholder:n},this.setPercent=function(n){return l?this.setTime(t.fromPercent(n,this.sound.duration)):this},this.getPercent=function(){if(!l)return null;var n=Math.round(t.toPercent(this.sound.currentTime,this.sound.duration));return isNaN(n)?t.defaults.placeholder:n},this.setSpeed=function(t){return l?(this.sound.playbackRate=t,this):this},this.getSpeed=function(){return l?this.sound.playbackRate:null},this.getDuration=function(){if(!l)return null;var n=Math.round(100*this.sound.duration)/100;return isNaN(n)?t.defaults.placeholder:n},this.getPlayed=function(){return l?i(this.sound.played):null},this.getBuffered=function(){return l?i(this.sound.buffered):null},this.getSeekable=function(){return l?i(this.sound.seekable):null},this.getErrorCode=function(){return l&&this.sound.error?this.sound.error.code:0},this.getErrorMessage=function(){if(!l)return null;switch(this.getErrorCode()){case 1:return"MEDIA_ERR_ABORTED";case 2:return"MEDIA_ERR_NETWORK";case 3:return"MEDIA_ERR_DECODE";case 4:return"MEDIA_ERR_SRC_NOT_SUPPORTED";default:return null}},this.getStateCode=function(){return l?this.sound.readyState:null},this.getStateMessage=function(){if(!l)return null;switch(this.getStateCode()){case 0:return"HAVE_NOTHING";case 1:return"HAVE_METADATA";case 2:return"HAVE_CURRENT_DATA";case 3:return"HAVE_FUTURE_DATA";case 4:return"HAVE_ENOUGH_DATA";default:return null}},this.getNetworkStateCode=function(){return l?this.sound.networkState:null},this.getNetworkStateMessage=function(){if(!l)return null;switch(this.getNetworkStateCode()){case 0:return"NETWORK_EMPTY";case 1:return"NETWORK_IDLE";case 2:return"NETWORK_LOADING";case 3:return"NETWORK_NO_SOURCE";default:return null}},this.set=function(t,n){return l?(this.sound[t]=n,this):this},this.get=function(t){return l?t?this.sound[t]:this.sound:null},this.bind=function(t,n){if(!l)return this;t=t.split(" ");for(var e=this,i=function(t){n.call(e,t)},u=0;t.length>u;u++){var s=t[u],r=s;s=r.split(".")[0],a.push({idx:r,func:i}),this.sound.addEventListener(s,i,!0)}return this},this.unbind=function(t){if(!l)return this;t=t.split(" ");for(var n=0;t.length>n;n++)for(var e=t[n],i=e.split(".")[0],u=0;a.length>u;u++){var s=a[u].idx.split(".");(a[u].idx==e||s[1]&&s[1]==e.replace(".",""))&&(this.sound.removeEventListener(i,a[u].func,!0),a.splice(u,1))}return this},this.bindOnce=function(t,n){if(!l)return this;var e=this;return h[o++]=!1,this.bind(t+"."+o,function(){h[o]||(h[o]=!0,n.call(e)),e.unbind(t+"."+o)}),this},this.trigger=function(t){if(!l)return this;t=t.split(" ");for(var n=0;t.length>n;n++)for(var e=t[n],i=0;a.length>i;i++){var u=a[i].idx.split(".");if(a[i].idx==e||u[0]&&u[0]==e.replace(".","")){var s=r.createEvent("HTMLEvents");s.initEvent(u[0],!1,!0),this.sound.dispatchEvent(s)}}return this},this.fadeTo=function(n,e,i){function u(){setTimeout(function(){n>s&&n>o.volume?(o.setVolume(o.volume+=1),u()):s>n&&o.volume>n?(o.setVolume(o.volume-=1),u()):i instanceof Function&&i.apply(o)},r)}if(!l)return this;e instanceof Function?(i=e,e=t.defaults.duration):e=e||t.defaults.duration;var s=this.volume,r=e/Math.abs(s-n),o=this;return this.play(),this.whenReady(function(){u()}),this},this.fadeIn=function(t,n){return l?this.setVolume(0).fadeTo(100,t,n):this},this.fadeOut=function(t,n){return l?this.fadeTo(0,t,n):this},this.fadeWith=function(t,n){return l?(this.fadeOut(n,function(){this.stop()}),t.play().fadeIn(n),this):this},this.whenReady=function(t){if(!l)return null;var n=this;0===this.sound.readyState?this.bind("canplay.buzzwhenready",function(){t.call(n)}):t.call(n)},l&&n){for(var d in t.defaults)t.defaults.hasOwnProperty(d)&&(e[d]=e[d]||t.defaults[d]);if(this.sound=r.createElement("audio"),n instanceof Array)for(var c in n)n.hasOwnProperty(c)&&s(this.sound,n[c]);else if(e.formats.length)for(var f in e.formats)e.formats.hasOwnProperty(f)&&s(this.sound,n+"."+e.formats[f]);else s(this.sound,n);e.loop&&this.loop(),e.autoplay&&(this.sound.autoplay="autoplay"),this.sound.preload=e.preload===!0?"auto":e.preload===!1?"none":e.preload,this.setVolume(e.volume),t.sounds.push(this)}},group:function(t){function n(){for(var n=e(null,arguments),i=n.shift(),u=0;t.length>u;u++)t[u][i].apply(t[u],n)}function e(t,n){return t instanceof Array?t:Array.prototype.slice.call(n)}t=e(t,arguments),this.getSounds=function(){return t},this.add=function(n){n=e(n,arguments);for(var i=0;n.length>i;i++)t.push(n[i])},this.remove=function(n){n=e(n,arguments);for(var i=0;n.length>i;i++)for(var u=0;t.length>u;u++)if(t[u]==n[i]){t.splice(u,1);break}},this.load=function(){return n("load"),this},this.play=function(){return n("play"),this},this.togglePlay=function(){return n("togglePlay"),this},this.pause=function(t){return n("pause",t),this},this.stop=function(){return n("stop"),this},this.mute=function(){return n("mute"),this},this.unmute=function(){return n("unmute"),this},this.toggleMute=function(){return n("toggleMute"),this},this.setVolume=function(t){return n("setVolume",t),this},this.increaseVolume=function(t){return n("increaseVolume",t),this},this.decreaseVolume=function(t){return n("decreaseVolume",t),this},this.loop=function(){return n("loop"),this},this.unloop=function(){return n("unloop"),this},this.setTime=function(t){return n("setTime",t),this},this.set=function(t,e){return n("set",t,e),this},this.bind=function(t,e){return n("bind",t,e),this},this.unbind=function(t){return n("unbind",t),this},this.bindOnce=function(t,e){return n("bindOnce",t,e),this},this.trigger=function(t){return n("trigger",t),this},this.fade=function(t,e,i,u){return n("fade",t,e,i,u),this},this.fadeIn=function(t,e){return n("fadeIn",t,e),this},this.fadeOut=function(t,e){return n("fadeOut",t,e),this}},all:function(){return new t.group(t.sounds)},isSupported:function(){return!!t.el.canPlayType},isOGGSupported:function(){return!!t.el.canPlayType&&t.el.canPlayType('audio/ogg; codecs="vorbis"')},isWAVSupported:function(){return!!t.el.canPlayType&&t.el.canPlayType('audio/wav; codecs="1"')},isMP3Supported:function(){return!!t.el.canPlayType&&t.el.canPlayType("audio/mpeg;")},isAACSupported:function(){return!!t.el.canPlayType&&(t.el.canPlayType("audio/x-m4a;")||t.el.canPlayType("audio/aac;"))},toTimer:function(t,n){var e,i,u;return e=Math.floor(t/3600),e=isNaN(e)?"--":e>=10?e:"0"+e,i=n?Math.floor(t/60%60):Math.floor(t/60),i=isNaN(i)?"--":i>=10?i:"0"+i,u=Math.floor(t%60),u=isNaN(u)?"--":u>=10?u:"0"+u,n?e+":"+i+":"+u:i+":"+u},fromTimer:function(t){var n=(""+t).split(":");return n&&3==n.length&&(t=3600*parseInt(n[0],10)+60*parseInt(n[1],10)+parseInt(n[2],10)),n&&2==n.length&&(t=60*parseInt(n[0],10)+parseInt(n[1],10)),t},toPercent:function(t,n,e){var i=Math.pow(10,e||0);return Math.round(100*t/n*i)/i},fromPercent:function(t,n,e){var i=Math.pow(10,e||0);return Math.round(n/100*t*i)/i}};return t});
\ No newline at end of file