From 5f5ed9e0073933d6e1d758d4c4f64a80793ff645 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 12 Nov 2014 14:03:47 +0900 Subject: ionSound initialised --- index.html | 2 ++ js/main.js | 19 ++++++++++++++++++- js/vendor/jquery.ion.sound.min.js | 2 ++ sounds/klaxon.mp3 | Bin 0 -> 96965 bytes 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 js/vendor/jquery.ion.sound.min.js create mode 100644 sounds/klaxon.mp3 diff --git a/index.html b/index.html index f4a0011..835c8b3 100644 --- a/index.html +++ b/index.html @@ -91,6 +91,8 @@ + + diff --git a/js/main.js b/js/main.js index 2c45cfa..567e89b 100644 --- a/js/main.js +++ b/js/main.js @@ -8,7 +8,24 @@ * - rework use of global variables * - button to make a loud noise like bell */ - + +$.ionSound({ + sounds: [ + { + name: "klaxon" + }, + { + name: "button_tiny", + }, + { + name: "cheonjae", + } + ], + // volume: 0.5, + path: "sounds/", + preload: true +}); + var timeWastingClock = new FlipClock($('.time-wasting-clock'), { autoStart:false }); diff --git a/js/vendor/jquery.ion.sound.min.js b/js/vendor/jquery.ion.sound.min.js new file mode 100644 index 0000000..f71cd04 --- /dev/null +++ b/js/vendor/jquery.ion.sound.min.js @@ -0,0 +1,2 @@ +// jQuery.Ion.Sound | version 2.1.3 | https://github.com/IonDen/ion.sound +(function(e){var l=function(a){a&&console&&(console.warn&&"function"===typeof console.warn?console.warn(a):console.log&&"function"===typeof console.log&&console.log(a))};if(e.ionSound)l("$.ionSound already exists!");else if("function"!==typeof Audio&&"object"!==typeof Audio){var g=function(){l("HTML5 Audio is not supported in this browser")};e.ionSound=function(){};e.ionSound.play=g;e.ionSound.stop=g;e.ionSound.destroy=g;g()}else{var f,m=/iPad|iPhone/.test(navigator.appVersion),k,d={},b={},n,h,c;m?(f=function(a){this.name=a.name;this.paused=this.loop=!1;this.callback=this.sound=null},f.prototype={init:function(){this.sound=k},play:function(a){a||(a={});a.loop?this.paused?this._playLoop(this.loop+1):this._playLoop(a.loop):(this.loop=!1,this._play());a.onEnded&&"function"===typeof a.onEnded&&(this.callback=a.onEnded)},_play:function(){if(this.paused)this.paused=!1;else try{this.sound.currentTime=0}catch(a){}this.sound.removeEventListener("ended");this.sound.addEventListener("ended",this._ended.bind(this),!1);this.sound.src=d.path+this.name+h;this.sound.load();this.sound.play()}}):(f=function(a){this.name=a.name;this.volume=d.volume||.5;this.preload=d.preload?"auto":"none";this.paused=this.loop=!1;this.callback=this.sound=null;"volume"in a&&(this.volume=+a.volume);"preload"in a&&(this.preload=a.preload?"auto":"none")},f.prototype={init:function(){this.sound=new Audio;this.sound.src=d.path+this.name+h;this.sound.load();this.sound.preload=this.preload;this.sound.volume=this.volume;this.sound.addEventListener("ended",this._ended.bind(this),!1)},play:function(a){a||(a={});if(a.volume||0===a.volume)this.volume=+a.volume,this.sound.volume=this.volume;a.loop?this.paused?this._playLoop(this.loop+1):this._playLoop(a.loop):(this.loop=!1,this._play());a.onEnded&&"function"===typeof a.onEnded&&(this.callback=a.onEnded)},_play:function(){if(this.paused)this.paused=!1;else try{this.sound.currentTime=0}catch(a){}this.sound.play()}});f.prototype._playLoop=function(a){"boolean"===typeof a?(this.loop=9999999,this._play()):"number"===typeof a&&(this.loop=a-1,this._play())};f.prototype._ended=function(){0