/** @license * * SoundManager 2: JavaScript Sound for the Web * ---------------------------------------------- * http://schillmania.com/projects/soundmanager2/ * * Copyright (c) 2007, Scott Schiller. All rights reserved. * Code provided under the BSD License: * http://schillmania.com/projects/soundmanager2/license.txt * * V2.97a.20130324 ("Mahalo" Edition) */ (function(k,g){function U(U,ia){function V(b){return c.preferFlash&&D&&!c.ignoreFlash&&c.flash[b]!==g&&c.flash[b]}function m(b){return function(c){var d=this._s;return!d||!d._a?null:b.call(this,c)}}this.setupOptions={url:U||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1E3,wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0, html5Test:/^(probably|maybe)$/i,preferFlash:!0,noSWFCache:!1};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null}; this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.audioFormats={mp3:{type:['audio/mpeg; codecs\x3d"mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs\x3d"mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs\x3dvorbis"],required:!1},opus:{type:["audio/ogg; codecs\x3dopus","audio/opus"],required:!1},wav:{type:['audio/wav; codecs\x3d"1"', "audio/wav","audio/wave","audio/x-wav"],required:!1}};this.movieID="sm2-container";this.id=ia||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20130324";this.altURL=this.movieURL=this.version=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:!1,peakData:!1,waveformData:!1, eqData:!1,movieStar:!1};this.sandbox={};this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=!1;var Ja,c=this,Ka=null,h=null,W,q=navigator.userAgent,ja=k.location.href.toString(),n=document,ka,La,la,l,x=[],M=!1,N=!1,r=!1,v=!1,ma=!1,O,u,na,X,oa,E,F,G,Ma,pa,Y,qa,Z,ra,H,sa,P,ta,$,I,Na,ua,Oa,va,Pa,Q=null,wa=null,y,xa,J,aa,ba,K,p,R=!1,ya=!1,Qa,Ra,Sa,ca=0,S=null,da,Ta=[],t=null,Ua,ea,T,B,za,Aa,Va,s,eb=Array.prototype.slice,z=!1,Ba,D,Ca,Wa,A,fa,ga=q.match(/(ipad|iphone|ipod)/i),Xa= q.match(/android/i),C=q.match(/msie/i),fb=q.match(/webkit/i),Da=q.match(/safari/i)&&!q.match(/chrome/i),Ea=q.match(/opera/i),Fa=q.match(/(mobile|pre\/|xoom)/i)||ga||Xa,Ya=!ja.match(/usehtml5audio/i)&&!ja.match(/sm2\-ignorebadua/i)&&Da&&!q.match(/silk/i)&&q.match(/OS X 10_6_([3-7])/i),Ga=n.hasFocus!==g?n.hasFocus():null,ha=Da&&(n.hasFocus===g||!n.hasFocus()),Za=!ha,$a=/(mp3|mp4|mpa|m4a|m4b)/i,Ha=n.location?n.location.protocol.match(/http/i):null,ab=!Ha?"http://":"",bb=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i, cb="mpeg4 aac flv mov mp4 m4v f4v m4a m4b mp4v 3gp 3g2".split(" "),gb=RegExp("\\.("+cb.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!Ha;var Ia;try{Ia=Audio!==g&&(Ea&&opera!==g&&10>opera.version()?new Audio(null):new Audio).canPlayType!==g}catch(hb){Ia=!1}this.hasHTML5=Ia;this.setup=function(b){var e=!c.url;b!==g&&(r&&t&&c.ok()&&(b.flashVersion!==g||b.url!==g||b.html5Test!==g))&&K(y("setupLate"));na(b);e&&(P&&b.url!==g)&&c.beginDelayedInit(); !P&&(b.url!==g&&"complete"===n.readyState)&&setTimeout(H,1);return c};this.supported=this.ok=function(){return t?r&&!v:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(b){return W(b)||n[b]||k[b]};this.createSound=function(b,e){function d(){a=aa(a);c.sounds[a.id]=new Ja(a);c.soundIDs.push(a.id);return c.sounds[a.id]}var a,f=null;if(!r||!c.ok())return K(void 0),!1;e!==g&&(b={id:b,url:e});a=u(b);a.url=da(a.url);if(p(a.id,!0))return c.sounds[a.id];ea(a)?(f=d(),f._setup_html5(a)):(8=b)return!1;for(b-=1;0<=b;b--)c=q[b],!c.fired&&a.position>=c.position&&(c.fired=!0,r++,c.method.apply(c.scope,[c.position]));return!0};this._resetOnPosition=function(a){var b,c;b=q.length;if(!b)return!1;for(b-=1;0<=b;b--)c=q[b],c.fired&&a<=c.position&&(c.fired=!1,r--);return!0};v=function(){var b=a._iO, c=b.from,e=b.to,d,f;f=function(){a.clearOnPosition(e,f);a.stop()};d=function(){if(null!==e&&!isNaN(e))a.onPosition(e,f)};null!==c&&!isNaN(c)&&(b.position=c,b.multiShot=!1,d());return b};n=function(){var b,c=a._iO.onposition;if(c)for(b in c)if(c.hasOwnProperty(b))a.onPosition(parseInt(b,10),c[b])};s=function(){var b,c=a._iO.onposition;if(c)for(b in c)c.hasOwnProperty(b)&&a.clearOnPosition(parseInt(b,10))};k=function(){a.isHTML5&&Qa(a)};L=function(){a.isHTML5&&Ra(a)};f=function(b){b||(q=[],r=0);m=!1; a._hasTimer=null;a._a=null;a._html5_canplay=!1;a.bytesLoaded=null;a.bytesTotal=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.buffered=[];a.eqData=[];a.eqData.left=[];a.eqData.right=[];a.failures=0;a.isBuffering=!1;a.instanceOptions={};a.instanceCount=0;a.loaded=!1;a.metadata={};a.readyState=0;a.muted=!1;a.paused=!1;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.playState=0;a.position=null;a.id3={}};f();this._onTimer=function(b){var c,f=!1,g={}; if(a._hasTimer||b){if(a._a&&(b||(0opera.version()?new Audio(null):new Audio,c=a._a,c._called_load=!1,z&&(Ka=c);a.isHTML5=!0;a._a=c;c._s=a;w();a._apply_loop(c,b.loops);b.autoLoad||b.autoPlay?a.load():(c.autobuffer= !1,c.preload="auto");return c};w=function(){if(a._a._added_events)return!1;var b;a._a._added_events=!0;for(b in A)A.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,A[b],!1);return!0};db=function(){var b;a._a._added_events=!1;for(b in A)A.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,A[b],!1)};this._onload=function(b){var c=!!b||!a.isHTML5&&8===l&&a.duration;a.loaded=c;a.readyState=c?3:2;a._onbufferchange(0);a._iO.onload&&fa(a,function(){a._iO.onload.apply(a,[c])});return!0};this._onbufferchange= function(b){if(0===a.playState||b&&a.isBuffering||!b&&!a.isBuffering)return!1;a.isBuffering=1===b;a._iO.onbufferchange&&a._iO.onbufferchange.apply(a);return!0};this._onsuspend=function(){a._iO.onsuspend&&a._iO.onsuspend.apply(a);return!0};this._onfailure=function(b,c,e){a.failures++;if(a._iO.onfailure&&1===a.failures)a._iO.onfailure(a,b,c,e)};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a._resetOnPosition(0);a.instanceCount&&(a.instanceCount--,a.instanceCount||(s(),a.playState= 0,a.paused=!1,a.instanceCount=0,a.instanceOptions={},a._iO={},L(),a.isHTML5&&(a.position=0)),(!a.instanceCount||a._iO.multiShotEvents)&&b&&fa(a,function(){b.apply(a)}))};this._whileloading=function(b,c,e,d){var f=a._iO;a.bytesLoaded=b;a.bytesTotal=c;a.duration=Math.floor(e);a.bufferLength=d;a.durationEstimate=!a.isHTML5&&!f.isMovieStar?f.duration?a.duration>f.duration?a.duration:f.duration:parseInt(a.bytesTotal/a.bytesLoaded*a.duration,10):a.duration;a.isHTML5||(a.buffered=[{start:0,end:a.duration}]); (3!==a.readyState||a.isHTML5)&&f.whileloading&&f.whileloading.apply(a)};this._whileplaying=function(b,c,e,d,f){var w=a._iO;if(isNaN(b)||null===b)return!1;a.position=Math.max(0,b);a._processOnPosition();!a.isHTML5&&8opera.version()?new Audio(null):new Audio:null,d,a,f={},h;h=c.audioFormats;for(d in h)if(h.hasOwnProperty(d)&&(a="audio/"+d,f[d]=b(h[d].type),f[a]=f[d],d.match($a)?(c.flash[d]=!0,c.flash[a]=!0):(c.flash[d]=!1,c.flash[a]=!1),h[d]&&h[d].related))for(a=h[d].related.length-1;0<=a;a--)f["audio/"+h[d].related[a]]=f[d],c.html5[h[d].related[a]]=f[d],c.flash[h[d].related[a]]=f[d];f.canPlayType= e?b:null;c.html5=u(c.html5,f);return!0};qa={};y=function(){};aa=function(b){8===l&&(1l)&&(c.flashVersion=l=9);c.version=c.versionNumber+(c.html5Only? " (HTML5-only mode)":9===l?" (AS3/Flash 9)":" (AS2/Flash 8)");8b&&(e=!0));setTimeout(function(){b=c.getMoviePercent();if(e)return R=!1,k.setTimeout(G,1),!1;!r&&Za&&(null===b?c.useFlashBlock||0===c.flashLoadTimeout?c.useFlashBlock&&xa():E({type:"ontimeout",ignoreInit:!0}):0!==c.flashLoadTimeout&&va(!0))},c.flashLoadTimeout)};Y=function(){if(Ga||!ha)return s.remove(k,"focus",Y),!0;Ga=Za=!0;R=!1;G();s.remove(k,"focus",Y);return!0};O=function(b){if(r)return!1;if(c.html5Only)return r=!0, F(),!0;var e=!0,d;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())r=!0,v&&(d={type:!D&&t?"NO_FLASH":"INIT_TIMEOUT"});if(v||b)c.useFlashBlock&&c.oMC&&(c.oMC.className=J()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error")),E({type:"ontimeout",error:d,ignoreInit:!0}),I(d),e=!1;v||(c.waitForWindowLoad&&!ma?s.add(k,"load",F):F());return e};La=function(){var b,e=c.setupOptions;for(b in e)e.hasOwnProperty(b)&&(c[b]===g?c[b]=e[b]:c[b]!==e[b]&&(c.setupOptions[b]=c[b]))};la=function(){if(r)return!1; if(c.html5Only)return r||(s.remove(k,"load",c.beginDelayedInit),c.enabled=!0,O()),!0;Z();try{h._externalInterfaceTest(!1),Na(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||h._disableDebug(),c.enabled=!0,c.html5Only||s.add(k,"unload",ka)}catch(b){return I({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),va(!0),O(),!1}O();s.remove(k,"load",c.beginDelayedInit);return!0};H=function(){if(P)return!1;P=!0;La();ua();!D&&c.hasHTML5&&c.setup({useHTML5Audio:!0,preferFlash:!1});Va();c.html5.usingFlash= Ua();t=c.html5.usingFlash;!D&&t&&(Ta.push(qa.needFlash),c.setup({flashLoadTimeout:1}));n.removeEventListener&&n.removeEventListener("DOMContentLoaded",H,!1);Z();return!0};Aa=function(){"complete"===n.readyState&&(H(),n.detachEvent("onreadystatechange",Aa));return!0};sa=function(){ma=!0;s.remove(k,"load",sa)};ra=function(){if(Fa&&(c.setupOptions.useHTML5Audio=!0,c.setupOptions.preferFlash=!1,ga||Xa&&!q.match(/android\s2\.3/i)))ga&&(c.ignoreFlash=!0),z=!0};ra();Ca();s.add(k,"focus",Y);s.add(k,"load", G);s.add(k,"load",sa);n.addEventListener?n.addEventListener("DOMContentLoaded",H,!1):n.attachEvent?n.attachEvent("onreadystatechange",Aa):I({type:"NO_DOM2_EVENTS",fatal:!0})}var ia=null;if(void 0===k.SM2_DEFER||!SM2_DEFER)ia=new U;k.SoundManager=U;k.soundManager=ia})(window);