--- /dev/null
+/** @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(m,g){function ba(ba,qa){function ca(a){return c.preferFlash&&A&&!c.ignoreFlash&&c.flash[a]!==g&&c.flash[a]}function s(a){return function(d){var e=this._s;!e||!e._a?(e&&e.id?c._wD(e.id+": Ignoring "+d.type):c._wD(ob+"Ignoring "+d.type),d=null):d=a.call(this,d);return d}}this.setupOptions={url:ba||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=qa||"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={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local+internet access)"},description:null,noRemote:null,noLocal:null};this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=!1;var Qa,c=this,Ra=null,l=null,ob="HTML5::",
+B,u=navigator.userAgent,S=m.location.href.toString(),h=document,ra,Sa,sa,p,D=[],ta=!0,y,T=!1,U=!1,q=!1,t=!1,da=!1,n,pb=0,V,x,ua,L,va,J,M,N,Ta,wa,ea,G,fa,xa,O,ya,W,ga,ha,P,Ua,za,Va=["log","info","warn","error"],Wa,Aa,Xa,X=null,Ba=null,r,Ca,Q,Ya,ia,ja,R,v,Y=!1,Da=!1,Za,$a,ab,ka=0,Z=null,la,K=[],C=null,bb,ma,$,H,Ea,Fa,cb,w,db=Array.prototype.slice,E=!1,Ga,A,Ha,eb,F,fb,Ia,na,oa=u.match(/(ipad|iphone|ipod)/i),gb=u.match(/android/i),I=u.match(/msie/i),qb=u.match(/webkit/i),Ja=u.match(/safari/i)&&!u.match(/chrome/i),
+Ka=u.match(/opera/i),La=u.match(/(mobile|pre\/|xoom)/i)||oa||gb,Ma=!S.match(/usehtml5audio/i)&&!S.match(/sm2\-ignorebadua/i)&&Ja&&!u.match(/silk/i)&&u.match(/OS X 10_6_([3-7])/i),hb=m.console!==g&&console.log!==g,Na=h.hasFocus!==g?h.hasFocus():null,pa=Ja&&(h.hasFocus===g||!h.hasFocus()),ib=!pa,jb=/(mp3|mp4|mpa|m4a|m4b)/i,aa=h.location?h.location.protocol.match(/http/i):null,kb=!aa?"http://":"",lb=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,mb="mpeg4 aac flv mov mp4 m4v f4v m4a m4b mp4v 3gp 3g2".split(" "),
+rb=RegExp("\\.("+mb.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!aa;var Oa;try{Oa=Audio!==g&&(Ka&&opera!==g&&10>opera.version()?new Audio(null):new Audio).canPlayType!==g}catch(sb){Oa=!1}this.hasHTML5=Oa;this.setup=function(a){var d=!c.url;a!==g&&(q&&C&&c.ok()&&(a.flashVersion!==g||a.url!==g||a.html5Test!==g))&&R(r("setupLate"));ua(a);d&&(W&&a.url!==g)&&c.beginDelayedInit();!W&&(a.url!==g&&"complete"===h.readyState)&&setTimeout(O,1);return c};
+this.supported=this.ok=function(){return C?q&&!t:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return B(c)||h[c]||m[c]};this.createSound=function(a,d){function e(){f=ia(f);c.sounds[f.id]=new Qa(f);c.soundIDs.push(f.id);return c.sounds[f.id]}var b,f;b=null;b="soundManager.createSound(): "+r(!q?"notReady":"notOK");if(!q||!c.ok())return R(b),!1;d!==g&&(a={id:a,url:d});f=x(a);f.url=la(f.url);f.id.toString().charAt(0).match(/^[0-9]$/)&&c._wD("soundManager.createSound(): "+r("badID",f.id),2);c._wD("soundManager.createSound(): "+
+f.id+" ("+f.url+")",1);if(v(f.id,!0))return c._wD("soundManager.createSound(): "+f.id+" exists",1),c.sounds[f.id];ma(f)?(b=e(),c._wD(f.id+": Using HTML5"),b._setup_html5(f)):(8<p&&(null===f.isMovieStar&&(f.isMovieStar=!(!f.serverURL&&!(f.type&&f.type.match(lb)||f.url.match(rb)))),f.isMovieStar&&(c._wD("soundManager.createSound(): using MovieStar handling"),1<f.loops&&n("noNSLoop"))),f=ja(f,"soundManager.createSound(): "),b=e(),8===p?l._createSound(f.id,f.loops||1,f.usePolicyFile):(l._createSound(f.id,
+f.url,f.usePeakData,f.useWaveformData,f.useEQData,f.isMovieStar,f.isMovieStar?f.bufferTime:!1,f.loops||1,f.serverURL,f.duration||null,f.autoPlay,!0,f.autoLoad,f.usePolicyFile),f.serverURL||(b.connected=!0,f.onconnect&&f.onconnect.apply(b))),!f.serverURL&&(f.autoLoad||f.autoPlay)&&b.load(f));!f.serverURL&&f.autoPlay&&b.play();return b};this.destroySound=function(a,d){if(!v(a))return!1;var e=c.sounds[a],b;e._iO={};e.stop();e.unload();for(b=0;b<c.soundIDs.length;b++)if(c.soundIDs[b]===a){c.soundIDs.splice(b,
+1);break}d||e.destruct(!0);delete c.sounds[a];return!0};this.load=function(a,d){return!v(a)?!1:c.sounds[a].load(d)};this.unload=function(a){return!v(a)?!1:c.sounds[a].unload()};this.onposition=this.onPosition=function(a,d,e,b){return!v(a)?!1:c.sounds[a].onposition(d,e,b)};this.clearOnPosition=function(a,d,e){return!v(a)?!1:c.sounds[a].clearOnPosition(d,e)};this.start=this.play=function(a,d){var e=!1;return!q||!c.ok()?(R("soundManager.play(): "+r(!q?"notReady":"notOK")),e):!v(a)?(d instanceof Object||
+(d={url:d}),d&&d.url&&(c._wD('soundManager.play(): attempting to create "'+a+'"',1),d.id=a,e=c.createSound(d).play()),e):c.sounds[a].play(d)};this.setPosition=function(a,d){return!v(a)?!1:c.sounds[a].setPosition(d)};this.stop=function(a){if(!v(a))return!1;c._wD("soundManager.stop("+a+")",1);return c.sounds[a].stop()};this.stopAll=function(){var a;c._wD("soundManager.stopAll()",1);for(a in c.sounds)c.sounds.hasOwnProperty(a)&&c.sounds[a].stop()};this.pause=function(a){return!v(a)?!1:c.sounds[a].pause()};
+this.pauseAll=function(){var a;for(a=c.soundIDs.length-1;0<=a;a--)c.sounds[c.soundIDs[a]].pause()};this.resume=function(a){return!v(a)?!1:c.sounds[a].resume()};this.resumeAll=function(){var a;for(a=c.soundIDs.length-1;0<=a;a--)c.sounds[c.soundIDs[a]].resume()};this.togglePause=function(a){return!v(a)?!1:c.sounds[a].togglePause()};this.setPan=function(a,d){return!v(a)?!1:c.sounds[a].setPan(d)};this.setVolume=function(a,d){return!v(a)?!1:c.sounds[a].setVolume(d)};this.mute=function(a){var d=0;a instanceof
+String&&(a=null);if(a){if(!v(a))return!1;c._wD('soundManager.mute(): Muting "'+a+'"');return c.sounds[a].mute()}c._wD("soundManager.mute(): Muting all sounds");for(d=c.soundIDs.length-1;0<=d;d--)c.sounds[c.soundIDs[d]].mute();return c.muted=!0};this.muteAll=function(){c.mute()};this.unmute=function(a){a instanceof String&&(a=null);if(a){if(!v(a))return!1;c._wD('soundManager.unmute(): Unmuting "'+a+'"');return c.sounds[a].unmute()}c._wD("soundManager.unmute(): Unmuting all sounds");for(a=c.soundIDs.length-
+1;0<=a;a--)c.sounds[c.soundIDs[a]].unmute();c.muted=!1;return!0};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(a){return!v(a)?!1:c.sounds[a].toggleMute()};this.getMemoryUse=function(){var c=0;l&&8!==p&&(c=parseInt(l._getMemoryUse(),10));return c};this.disable=function(a){var d;a===g&&(a=!1);if(t)return!1;t=!0;n("shutdown",1);for(d=c.soundIDs.length-1;0<=d;d--)Wa(c.sounds[c.soundIDs[d]]);V(a);w.remove(m,"load",M);return!0};this.canPlayMIME=function(a){var d;c.hasHTML5&&(d=$({type:a}));
+!d&&C&&(d=a&&c.ok()?!!(8<p&&a.match(lb)||a.match(c.mimePattern)):null);return d};this.canPlayURL=function(a){var d;c.hasHTML5&&(d=$({url:a}));!d&&C&&(d=a&&c.ok()?!!a.match(c.filePattern):null);return d};this.canPlayLink=function(a){return a.type!==g&&a.type&&c.canPlayMIME(a.type)?!0:c.canPlayURL(a.href)};this.getSoundById=function(a,d){if(!a)throw Error("soundManager.getSoundById(): sID is null/_undefined");var e=c.sounds[a];!e&&!d&&c._wD('"'+a+'" is an invalid sound ID.',2);return e};this.onready=
+function(a,d){if("function"===typeof a)q&&c._wD(r("queue","onready")),d||(d=m),va("onready",a,d),J();else throw r("needFunction","onready");return!0};this.ontimeout=function(a,d){if("function"===typeof a)q&&c._wD(r("queue","ontimeout")),d||(d=m),va("ontimeout",a,d),J({type:"ontimeout"});else throw r("needFunction","ontimeout");return!0};this._writeDebug=function(a,d){var e,b;if(!c.debugMode)return!1;if(hb&&c.useConsole){if(d&&"object"===typeof d)console.log(a,d);else if(Va[d]!==g)console[Va[d]](a);
+else console.log(a);if(c.consoleOnly)return!0}e=B("soundmanager-debug");if(!e)return!1;b=h.createElement("div");0===++pb%2&&(b.className="sm2-alt");d=d===g?0:parseInt(d,10);b.appendChild(h.createTextNode(a));d&&(2<=d&&(b.style.fontWeight="bold"),3===d&&(b.style.color="#ff3333"));e.insertBefore(b,e.firstChild);return!0};-1!==S.indexOf("sm2-debug\x3dalert")&&(this._writeDebug=function(c){m.alert(c)});this._wD=this._writeDebug;this._debug=function(){var a,d;n("currentObj",1);a=0;for(d=c.soundIDs.length;a<
+d;a++)c.sounds[c.soundIDs[a]]._debug()};this.reboot=function(a,d){c.soundIDs.length&&c._wD("Destroying "+c.soundIDs.length+" SMSound objects...");var e,b,f;for(e=c.soundIDs.length-1;0<=e;e--)c.sounds[c.soundIDs[e]].destruct();if(l)try{I&&(Ba=l.innerHTML),X=l.parentNode.removeChild(l),n("flRemoved")}catch(g){n("badRemove",2)}Ba=X=C=l=null;c.enabled=W=q=Y=Da=T=U=t=E=c.swfLoaded=!1;c.soundIDs=[];c.sounds={};if(a)D=[];else for(e in D)if(D.hasOwnProperty(e)){b=0;for(f=D[e].length;b<f;b++)D[e][b].fired=
+!1}d||c._wD("soundManager: Rebooting...");c.html5={usingFlash:null};c.flash={};c.html5Only=!1;c.ignoreFlash=!1;m.setTimeout(function(){xa();d||c.beginDelayedInit()},20);return c};this.reset=function(){n("reset");return c.reboot(!0,!0)};this.getMoviePercent=function(){return l&&"PercentLoaded"in l?l.PercentLoaded():null};this.beginDelayedInit=function(){da=!0;O();setTimeout(function(){if(Da)return!1;ha();fa();return Da=!0},20);N()};this.destruct=function(){c._wD("soundManager.destruct()");c.disable(!0)};
+Qa=function(a){var d,e,b=this,f,m,nb,k,h,q,s=!1,z=[],u=0,Pa,w,t=null;e=d=null;this.sID=this.id=a.id;this.url=a.url;this._iO=this.instanceOptions=this.options=x(a);this.pan=this.options.pan;this.volume=this.options.volume;this.isHTML5=!1;this._a=null;this.id3={};this._debug=function(){c._wD(b.id+": Merged options:",b.options)};this.load=function(a){var d=null,e;a!==g?b._iO=x(a,b.options):(a=b.options,b._iO=a,t&&t!==b.url&&(n("manURL"),b._iO.url=b.url,b.url=null));b._iO.url||(b._iO.url=b.url);b._iO.url=
+la(b._iO.url);e=b.instanceOptions=b._iO;c._wD(b.id+": load ("+e.url+")");if(e.url===b.url&&0!==b.readyState&&2!==b.readyState)return n("onURL",1),3===b.readyState&&e.onload&&na(b,function(){e.onload.apply(b,[!!b.duration])}),b;b.loaded=!1;b.readyState=1;b.playState=0;b.id3={};if(ma(e))d=b._setup_html5(e),d._called_load?c._wD(b.id+": Ignoring request to load again"):(b._html5_canplay=!1,b.url!==e.url&&(c._wD(n("manURL")+": "+e.url),b._a.src=e.url,b.setPosition(0)),b._a.autobuffer="auto",b._a.preload=
+"auto",b._a._called_load=!0,e.autoPlay&&b.play());else try{b.isHTML5=!1,b._iO=ja(ia(e)),e=b._iO,8===p?l._load(b.id,e.url,e.stream,e.autoPlay,e.usePolicyFile):l._load(b.id,e.url,!!e.stream,!!e.autoPlay,e.loops||1,!!e.autoLoad,e.usePolicyFile)}catch(f){n("smError",2),y("onload",!1),P({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:!0})}b.url=e.url;return b};this.unload=function(){0!==b.readyState&&(c._wD(b.id+": unload()"),b.isHTML5?(k(),b._a&&(b._a.pause(),Ea(b._a,"about:blank"),t="about:blank")):8===p?l._unload(b.id,
+"about:blank"):l._unload(b.id),f());return b};this.destruct=function(a){c._wD(b.id+": Destruct");b.isHTML5?(k(),b._a&&(b._a.pause(),Ea(b._a),E||nb(),b._a._s=null,b._a=null)):(b._iO.onfailure=null,l._destroySound(b.id));a||c.destroySound(b.id,!0)};this.start=this.play=function(a,d){var e,f,k=!0,k=null;e=b.id+": play(): ";d=d===g?!0:d;a||(a={});b.url&&(b._iO.url=b.url);b._iO=x(b._iO,b.options);b._iO=x(a,b._iO);b._iO.url=la(b._iO.url);b.instanceOptions=b._iO;if(b._iO.serverURL&&!b.connected)return b.getAutoPlay()||
+(c._wD(e+" Netstream not connected yet - setting autoPlay"),b.setAutoPlay(!0)),b;ma(b._iO)&&(b._setup_html5(b._iO),h());1===b.playState&&!b.paused&&((f=b._iO.multiShot)?c._wD(e+"Already playing (multi-shot)",1):(c._wD(e+"Already playing (one-shot)",1),k=b));if(null!==k)return k;a.url&&a.url!==b.url&&b.load(b._iO);b.loaded?c._wD(e.substr(0,e.lastIndexOf(":"))):0===b.readyState?(c._wD(e+"Attempting to load"),b.isHTML5||(b._iO.autoPlay=!0),b.load(b._iO),b.instanceOptions=b._iO):2===b.readyState?(c._wD(e+
+"Could not load - exiting",2),k=b):c._wD(e+"Loading - attempting to play...");if(null!==k)return k;!b.isHTML5&&(9===p&&0<b.position&&b.position===b.duration)&&(c._wD(e+"Sound at end, resetting to position:0"),a.position=0);if(b.paused&&0<=b.position&&(!b._iO.serverURL||0<b.position))c._wD(e+"Resuming from paused state",1),b.resume();else{b._iO=x(a,b._iO);if(null!==b._iO.from&&null!==b._iO.to&&0===b.instanceCount&&0===b.playState&&!b._iO.serverURL){f=function(){b._iO=x(a,b._iO);b.play(b._iO)};if(b.isHTML5&&
+!b._html5_canplay)c._wD(e+"Beginning load for from/to case"),b.load({oncanplay:f}),k=!1;else if(!b.isHTML5&&!b.loaded&&(!b.readyState||2!==b.readyState))c._wD(e+"Preloading for from/to case"),b.load({onload:f}),k=!1;if(null!==k)return k;b._iO=w()}c._wD(e+"Starting to play");(!b.instanceCount||b._iO.multiShotEvents||!b.isHTML5&&8<p&&!b.getAutoPlay())&&b.instanceCount++;b._iO.onposition&&0===b.playState&&q(b);b.playState=1;b.paused=!1;b.position=b._iO.position!==g&&!isNaN(b._iO.position)?b._iO.position:
+0;b.isHTML5||(b._iO=ja(ia(b._iO)));b._iO.onplay&&d&&(b._iO.onplay.apply(b),s=!0);b.setVolume(b._iO.volume,!0);b.setPan(b._iO.pan,!0);b.isHTML5?(h(),e=b._setup_html5(),b.setPosition(b._iO.position),e.play()):(k=l._start(b.id,b._iO.loops||1,9===p?b.position:b.position/1E3,b._iO.multiShot||!1),9===p&&!k&&(c._wD(e+"No sound hardware, or 32-sound ceiling hit"),b._iO.onplayerror&&b._iO.onplayerror.apply(b)))}return b};this.stop=function(a){var d=b._iO;1===b.playState&&(c._wD(b.id+": stop()"),b._onbufferchange(0),
+b._resetOnPosition(0),b.paused=!1,b.isHTML5||(b.playState=0),Pa(),d.to&&b.clearOnPosition(d.to),b.isHTML5?b._a&&(a=b.position,b.setPosition(0),b.position=a,b._a.pause(),b.playState=0,b._onTimer(),k()):(l._stop(b.id,a),d.serverURL&&b.unload()),b.instanceCount=0,b._iO={},d.onstop&&d.onstop.apply(b));return b};this.setAutoPlay=function(a){c._wD(b.id+": Autoplay turned "+(a?"on":"off"));b._iO.autoPlay=a;b.isHTML5||(l._setAutoPlay(b.id,a),a&&(!b.instanceCount&&1===b.readyState)&&(b.instanceCount++,c._wD(b.id+
+": Incremented instance count to "+b.instanceCount)))};this.getAutoPlay=function(){return b._iO.autoPlay};this.setPosition=function(a){a===g&&(a=0);var d=b.isHTML5?Math.max(a,0):Math.min(b.duration||b._iO.duration,Math.max(a,0));b.position=d;a=b.position/1E3;b._resetOnPosition(b.position);b._iO.position=d;if(b.isHTML5){if(b._a)if(b._html5_canplay){if(b._a.currentTime!==a){c._wD(b.id+": setPosition("+a+")");try{b._a.currentTime=a,(0===b.playState||b.paused)&&b._a.pause()}catch(e){c._wD(b.id+": setPosition("+
+a+") failed: "+e.message,2)}}}else c._wD(b.id+": setPosition("+a+"): Cannot seek yet, sound not ready")}else a=9===p?b.position:a,b.readyState&&2!==b.readyState&&l._setPosition(b.id,a,b.paused||!b.playState,b._iO.multiShot);b.isHTML5&&b.paused&&b._onTimer(!0);return b};this.pause=function(a){if(b.paused||0===b.playState&&1!==b.readyState)return b;c._wD(b.id+": pause()");b.paused=!0;b.isHTML5?(b._setup_html5().pause(),k()):(a||a===g)&&l._pause(b.id,b._iO.multiShot);b._iO.onpause&&b._iO.onpause.apply(b);
+return b};this.resume=function(){var a=b._iO;if(!b.paused)return b;c._wD(b.id+": resume()");b.paused=!1;b.playState=1;b.isHTML5?(b._setup_html5().play(),h()):(a.isMovieStar&&!a.serverURL&&b.setPosition(b.position),l._pause(b.id,a.multiShot));!s&&a.onplay?(a.onplay.apply(b),s=!0):a.onresume&&a.onresume.apply(b);return b};this.togglePause=function(){c._wD(b.id+": togglePause()");if(0===b.playState)return b.play({position:9===p&&!b.isHTML5?b.position:b.position/1E3}),b;b.paused?b.resume():b.pause();
+return b};this.setPan=function(a,c){a===g&&(a=0);c===g&&(c=!1);b.isHTML5||l._setPan(b.id,a);b._iO.pan=a;c||(b.pan=a,b.options.pan=a);return b};this.setVolume=function(a,d){a===g&&(a=100);d===g&&(d=!1);b.isHTML5?b._a&&(b._a.volume=Math.max(0,Math.min(1,a/100))):l._setVolume(b.id,c.muted&&!b.muted||b.muted?0:a);b._iO.volume=a;d||(b.volume=a,b.options.volume=a);return b};this.mute=function(){b.muted=!0;b.isHTML5?b._a&&(b._a.muted=!0):l._setVolume(b.id,0);return b};this.unmute=function(){b.muted=!1;var a=
+b._iO.volume!==g;b.isHTML5?b._a&&(b._a.muted=!1):l._setVolume(b.id,a?b._iO.volume:b.options.volume);return b};this.toggleMute=function(){return b.muted?b.unmute():b.mute()};this.onposition=this.onPosition=function(a,c,d){z.push({position:parseInt(a,10),method:c,scope:d!==g?d:b,fired:!1});return b};this.clearOnPosition=function(b,a){var c;b=parseInt(b,10);if(isNaN(b))return!1;for(c=0;c<z.length;c++)if(b===z[c].position&&(!a||a===z[c].method))z[c].fired&&u--,z.splice(c,1)};this._processOnPosition=function(){var a,
+c;a=z.length;if(!a||!b.playState||u>=a)return!1;for(a-=1;0<=a;a--)c=z[a],!c.fired&&b.position>=c.position&&(c.fired=!0,u++,c.method.apply(c.scope,[c.position]));return!0};this._resetOnPosition=function(b){var a,c;a=z.length;if(!a)return!1;for(a-=1;0<=a;a--)c=z[a],c.fired&&b<=c.position&&(c.fired=!1,u--);return!0};w=function(){var a=b._iO,d=a.from,e=a.to,f,g;g=function(){c._wD(b.id+': "To" time of '+e+" reached.");b.clearOnPosition(e,g);b.stop()};f=function(){c._wD(b.id+': Playing "from" '+d);if(null!==
+e&&!isNaN(e))b.onPosition(e,g)};null!==d&&!isNaN(d)&&(a.position=d,a.multiShot=!1,f());return a};q=function(){var a,c=b._iO.onposition;if(c)for(a in c)if(c.hasOwnProperty(a))b.onPosition(parseInt(a,10),c[a])};Pa=function(){var a,c=b._iO.onposition;if(c)for(a in c)c.hasOwnProperty(a)&&b.clearOnPosition(parseInt(a,10))};h=function(){b.isHTML5&&Za(b)};k=function(){b.isHTML5&&$a(b)};f=function(a){a||(z=[],u=0);s=!1;b._hasTimer=null;b._a=null;b._html5_canplay=!1;b.bytesLoaded=null;b.bytesTotal=null;b.duration=
+b._iO&&b._iO.duration?b._iO.duration:null;b.durationEstimate=null;b.buffered=[];b.eqData=[];b.eqData.left=[];b.eqData.right=[];b.failures=0;b.isBuffering=!1;b.instanceOptions={};b.instanceCount=0;b.loaded=!1;b.metadata={};b.readyState=0;b.muted=!1;b.paused=!1;b.peakData={left:0,right:0};b.waveformData={left:[],right:[]};b.playState=0;b.position=null;b.id3={}};f();this._onTimer=function(a){var c,f=!1,g={};if(b._hasTimer||a){if(b._a&&(a||(0<b.playState||1===b.readyState)&&!b.paused))c=b._get_html5_duration(),
+c!==d&&(d=c,b.duration=c,f=!0),b.durationEstimate=b.duration,c=1E3*b._a.currentTime||0,c!==e&&(e=c,f=!0),(f||a)&&b._whileplaying(c,g,g,g,g);return f}};this._get_html5_duration=function(){var a=b._iO;return(a=b._a&&b._a.duration?1E3*b._a.duration:a&&a.duration?a.duration:null)&&!isNaN(a)&&Infinity!==a?a:null};this._apply_loop=function(b,a){!b.loop&&1<a&&c._wD("Note: Native HTML5 looping is infinite.",1);b.loop=1<a?"loop":""};this._setup_html5=function(a){a=x(b._iO,a);var c=E?Ra:b._a,d=decodeURI(a.url),
+e;E?d===decodeURI(Ga)&&(e=!0):d===decodeURI(t)&&(e=!0);if(c){if(c._s)if(E)c._s&&(c._s.playState&&!e)&&c._s.stop();else if(!E&&d===decodeURI(t))return b._apply_loop(c,a.loops),c;e||(f(!1),c.src=a.url,Ga=t=b.url=a.url,c._called_load=!1)}else b._a=a.autoLoad||a.autoPlay?new Audio(a.url):Ka&&10>opera.version()?new Audio(null):new Audio,c=b._a,c._called_load=!1,E&&(Ra=c);b.isHTML5=!0;b._a=c;c._s=b;m();b._apply_loop(c,a.loops);a.autoLoad||a.autoPlay?b.load():(c.autobuffer=!1,c.preload="auto");return c};
+m=function(){if(b._a._added_events)return!1;var a;b._a._added_events=!0;for(a in F)F.hasOwnProperty(a)&&b._a&&b._a.addEventListener(a,F[a],!1);return!0};nb=function(){var a;c._wD(b.id+": Removing event listeners");b._a._added_events=!1;for(a in F)F.hasOwnProperty(a)&&b._a&&b._a.removeEventListener(a,F[a],!1)};this._onload=function(a){var d=!!a||!b.isHTML5&&8===p&&b.duration;a=b.id+": ";c._wD(a+(d?"onload()":"Failed to load? - "+b.url),d?1:2);!d&&!b.isHTML5&&(!0===c.sandbox.noRemote&&c._wD(a+r("noNet"),
+1),!0===c.sandbox.noLocal&&c._wD(a+r("noLocal"),1));b.loaded=d;b.readyState=d?3:2;b._onbufferchange(0);b._iO.onload&&na(b,function(){b._iO.onload.apply(b,[d])});return!0};this._onbufferchange=function(a){if(0===b.playState||a&&b.isBuffering||!a&&!b.isBuffering)return!1;b.isBuffering=1===a;b._iO.onbufferchange&&(c._wD(b.id+": Buffer state change: "+a),b._iO.onbufferchange.apply(b));return!0};this._onsuspend=function(){b._iO.onsuspend&&(c._wD(b.id+": Playback suspended"),b._iO.onsuspend.apply(b));return!0};
+this._onfailure=function(a,d,e){b.failures++;c._wD(b.id+": Failures \x3d "+b.failures);if(b._iO.onfailure&&1===b.failures)b._iO.onfailure(b,a,d,e);else c._wD(b.id+": Ignoring failure")};this._onfinish=function(){var a=b._iO.onfinish;b._onbufferchange(0);b._resetOnPosition(0);if(b.instanceCount&&(b.instanceCount--,b.instanceCount||(Pa(),b.playState=0,b.paused=!1,b.instanceCount=0,b.instanceOptions={},b._iO={},k(),b.isHTML5&&(b.position=0)),(!b.instanceCount||b._iO.multiShotEvents)&&a))c._wD(b.id+": onfinish()"),
+na(b,function(){a.apply(b)})};this._whileloading=function(a,c,d,e){var f=b._iO;b.bytesLoaded=a;b.bytesTotal=c;b.duration=Math.floor(d);b.bufferLength=e;b.durationEstimate=!b.isHTML5&&!f.isMovieStar?f.duration?b.duration>f.duration?b.duration:f.duration:parseInt(b.bytesTotal/b.bytesLoaded*b.duration,10):b.duration;b.isHTML5||(b.buffered=[{start:0,end:b.duration}]);(3!==b.readyState||b.isHTML5)&&f.whileloading&&f.whileloading.apply(b)};this._whileplaying=function(a,c,d,e,f){var k=b._iO;if(isNaN(a)||
+null===a)return!1;b.position=Math.max(0,a);b._processOnPosition();!b.isHTML5&&8<p&&(k.usePeakData&&(c!==g&&c)&&(b.peakData={left:c.leftPeak,right:c.rightPeak}),k.useWaveformData&&(d!==g&&d)&&(b.waveformData={left:d.split(","),right:e.split(",")}),k.useEQData&&(f!==g&&f&&f.leftEQ)&&(a=f.leftEQ.split(","),b.eqData=a,b.eqData.left=a,f.rightEQ!==g&&f.rightEQ&&(b.eqData.right=f.rightEQ.split(","))));1===b.playState&&(!b.isHTML5&&(8===p&&!b.position&&b.isBuffering)&&b._onbufferchange(0),k.whileplaying&&
+k.whileplaying.apply(b));return!0};this._oncaptiondata=function(a){c._wD(b.id+": Caption data received.");b.captiondata=a;b._iO.oncaptiondata&&b._iO.oncaptiondata.apply(b,[a])};this._onmetadata=function(a,d){c._wD(b.id+": Metadata received.");var e={},f,g;f=0;for(g=a.length;f<g;f++)e[a[f]]=d[f];b.metadata=e;b._iO.onmetadata&&b._iO.onmetadata.apply(b)};this._onid3=function(a,d){c._wD(b.id+": ID3 data received.");var e=[],f,g;f=0;for(g=a.length;f<g;f++)e[a[f]]=d[f];b.id3=x(b.id3,e);b._iO.onid3&&b._iO.onid3.apply(b)};
+this._onconnect=function(a){a=1===a;c._wD(b.id+": "+(a?"Connected.":"Failed to connect? - "+b.url),a?1:2);if(b.connected=a)b.failures=0,v(b.id)&&(b.getAutoPlay()?b.play(g,b.getAutoPlay()):b._iO.autoLoad&&b.load()),b._iO.onconnect&&b._iO.onconnect.apply(b,[a])};this._ondataerror=function(a){0<b.playState&&(c._wD(b.id+": Data error: "+a),b._iO.ondataerror&&b._iO.ondataerror.apply(b))};this._debug()};ga=function(){return h.body||h._docElement||h.getElementsByTagName("div")[0]};B=function(a){return h.getElementById(a)};
+x=function(a,d){var e=a||{},b,f;b=d===g?c.defaultOptions:d;for(f in b)b.hasOwnProperty(f)&&e[f]===g&&(e[f]="object"!==typeof b[f]||null===b[f]?b[f]:x(e[f],b[f]));return e};na=function(a,c){!a.isHTML5&&8===p?m.setTimeout(c,0):c()};L={onready:1,ontimeout:1,defaultOptions:1,flash9Options:1,movieStarOptions:1};ua=function(a,d){var e,b=!0,f=d!==g,h=c.setupOptions;if(a===g){b=[];for(e in h)h.hasOwnProperty(e)&&b.push(e);for(e in L)L.hasOwnProperty(e)&&("object"===typeof c[e]?b.push(e+": {...}"):c[e]instanceof
+Function?b.push(e+": function() {...}"):b.push(e));c._wD(r("setup",b.join(", ")));return!1}for(e in a)if(a.hasOwnProperty(e))if("object"!==typeof a[e]||null===a[e]||a[e]instanceof Array||a[e]instanceof RegExp)f&&L[d]!==g?c[d][e]=a[e]:h[e]!==g?(c.setupOptions[e]=a[e],c[e]=a[e]):L[e]===g?(R(r(c[e]===g?"setupUndef":"setupError",e),2),b=!1):c[e]instanceof Function?c[e].apply(c,a[e]instanceof Array?a[e]:[a[e]]):c[e]=a[e];else if(L[e]===g)R(r(c[e]===g?"setupUndef":"setupError",e),2),b=!1;else return ua(a[e],
+e);return b};w=function(){function a(a){a=db.call(a);var b=a.length;e?(a[1]="on"+a[1],3<b&&a.pop()):3===b&&a.push(!1);return a}function c(a,d){var g=a.shift(),k=[b[d]];if(e)g[k](a[0],a[1]);else g[k].apply(g,a)}var e=m.attachEvent,b={add:e?"attachEvent":"addEventListener",remove:e?"detachEvent":"removeEventListener"};return{add:function(){c(a(arguments),"add")},remove:function(){c(a(arguments),"remove")}}}();F={abort:s(function(){c._wD(this._s.id+": abort")}),canplay:s(function(){var a=this._s,d;if(a._html5_canplay)return!0;
+a._html5_canplay=!0;c._wD(a.id+": canplay");a._onbufferchange(0);d=a._iO.position!==g&&!isNaN(a._iO.position)?a._iO.position/1E3:null;if(a.position&&this.currentTime!==d){c._wD(a.id+": canplay: Setting position to "+d);try{this.currentTime=d}catch(e){c._wD(a.id+": canplay: Setting position of "+d+" failed: "+e.message,2)}}a._iO._oncanplay&&a._iO._oncanplay()}),canplaythrough:s(function(){var a=this._s;a.loaded||(a._onbufferchange(0),a._whileloading(a.bytesLoaded,a.bytesTotal,a._get_html5_duration()),
+a._onload(!0))}),ended:s(function(){var a=this._s;c._wD(a.id+": ended");a._onfinish()}),error:s(function(){c._wD(this._s.id+": HTML5 error, code "+this.error.code);this._s._onload(!1)}),loadeddata:s(function(){var a=this._s;c._wD(a.id+": loadeddata");!a._loaded&&!Ja&&(a.duration=a._get_html5_duration())}),loadedmetadata:s(function(){c._wD(this._s.id+": loadedmetadata")}),loadstart:s(function(){c._wD(this._s.id+": loadstart");this._s._onbufferchange(1)}),play:s(function(){c._wD(this._s.id+": play()");
+this._s._onbufferchange(0)}),playing:s(function(){c._wD(this._s.id+": playing");this._s._onbufferchange(0)}),progress:s(function(a){var d=this._s,e,b,f;e=0;var g="progress"===a.type,h=a.target.buffered,k=a.loaded||0,m=a.total||1;d.buffered=[];if(h&&h.length){e=0;for(b=h.length;e<b;e++)d.buffered.push({start:1E3*h.start(e),end:1E3*h.end(e)});e=1E3*(h.end(0)-h.start(0));k=e/(1E3*a.target.duration);if(g&&1<h.length){f=[];b=h.length;for(e=0;e<b;e++)f.push(1E3*a.target.buffered.start(e)+"-"+1E3*a.target.buffered.end(e));
+c._wD(this._s.id+": progress, timeRanges: "+f.join(", "))}g&&!isNaN(k)&&c._wD(this._s.id+": progress, "+Math.floor(100*k)+"% loaded")}isNaN(k)||(d._onbufferchange(0),d._whileloading(k,m,d._get_html5_duration()),k&&(m&&k===m)&&F.canplaythrough.call(this,a))}),ratechange:s(function(){c._wD(this._s.id+": ratechange")}),suspend:s(function(a){var d=this._s;c._wD(this._s.id+": suspend");F.progress.call(this,a);d._onsuspend()}),stalled:s(function(){c._wD(this._s.id+": stalled")}),timeupdate:s(function(){this._s._onTimer()}),
+waiting:s(function(){var a=this._s;c._wD(this._s.id+": waiting");a._onbufferchange(1)})};ma=function(a){return a.serverURL||a.type&&ca(a.type)?!1:a.type?$({type:a.type}):$({url:a.url})||c.html5Only};Ea=function(a,c){a&&(a.src=c,a._called_load=!1);E&&(Ga=null)};$=function(a){if(!c.useHTML5Audio||!c.hasHTML5)return!1;var d=a.url||null;a=a.type||null;var e=c.audioFormats,b;if(a&&c.html5[a]!==g)return c.html5[a]&&!ca(a);if(!H){H=[];for(b in e)e.hasOwnProperty(b)&&(H.push(b),e[b].related&&(H=H.concat(e[b].related)));
+H=RegExp("\\.("+H.join("|")+")(\\?.*)?$","i")}b=d?d.toLowerCase().match(H):null;!b||!b.length?a&&(d=a.indexOf(";"),b=(-1!==d?a.substr(0,d):a).substr(6)):b=b[1];b&&c.html5[b]!==g?d=c.html5[b]&&!ca(b):(a="audio/"+b,d=c.html5.canPlayType({type:a}),d=(c.html5[b]=d)&&c.html5[a]&&!ca(a));return d};cb=function(){function a(a){var b,e,f=b=!1;if(!d||"function"!==typeof d.canPlayType)return b;if(a instanceof Array){b=0;for(e=a.length;b<e;b++)if(c.html5[a[b]]||d.canPlayType(a[b]).match(c.html5Test))f=!0,c.html5[a[b]]=
+!0,c.flash[a[b]]=!!a[b].match(jb);b=f}else a=d&&"function"===typeof d.canPlayType?d.canPlayType(a):!1,b=!(!a||!a.match(c.html5Test));return b}if(!c.useHTML5Audio||!c.hasHTML5)return!1;var d=Audio!==g?Ka&&10>opera.version()?new Audio(null):new Audio:null,e,b,f={},h;h=c.audioFormats;for(e in h)if(h.hasOwnProperty(e)&&(b="audio/"+e,f[e]=a(h[e].type),f[b]=f[e],e.match(jb)?(c.flash[e]=!0,c.flash[b]=!0):(c.flash[e]=!1,c.flash[b]=!1),h[e]&&h[e].related))for(b=h[e].related.length-1;0<=b;b--)f["audio/"+h[e].related[b]]=
+f[e],c.html5[h[e].related[b]]=f[e],c.flash[h[e].related[b]]=f[e];f.canPlayType=d?a:null;c.html5=x(c.html5,f);return!0};G={notReady:"Unavailable - wait until onready() has fired.",notOK:"Audio support is not available.",domError:"soundManagerexception caught while appending SWF to DOM.",spcWmode:"Removing wmode, preventing known SWF loading issue(s)",swf404:"soundManager: Verify that %s is a valid path.",tryDebug:"Try soundManager.debugFlash \x3d true for more security details (output goes to SWF.)",
+checkSWF:"See SWF output for more debug info.",localFail:"soundManager: Non-HTTP page ("+h.location.protocol+" URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/",waitFocus:"soundManager: Special case: Waiting for SWF to load with window focus...",waitForever:"soundManager: Waiting indefinitely for Flash (will recover if unblocked)...",
+waitSWF:"soundManager: Waiting for 100% SWF load...",needFunction:"soundManager: Function object expected for %s",badID:'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',currentObj:"soundManager: _debug(): Current sound objects",waitOnload:"soundManager: Waiting for window.onload()",docLoaded:"soundManager: Document already loaded",onload:"soundManager: initComplete(): calling soundManager.onload()",onloadOK:"soundManager.onload() complete",didInit:"soundManager: init(): Already called?",
+secNote:"Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html",badRemove:"soundManager: Failed to remove Flash node.",shutdown:"soundManager.disable(): Shutting down",queue:"soundManager: Queueing %s handler",smError:"SMSound.load(): Exception: JS-Flash communication failed, or JS error.",fbTimeout:"No flash response, applying .swf_timedout CSS...",
+fbLoaded:"Flash loaded",flRemoved:"soundManager: Flash movie removed.",fbHandler:"soundManager: flashBlockHandler()",manURL:"SMSound.load(): Using manually-assigned URL",onURL:"soundManager.load(): current URL already assigned.",badFV:'soundManager.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',as2loop:"Note: Setting stream:false so looping can work (flash 8 limitation)",noNSLoop:"Note: Looping not implemented for MovieStar formats",needfl9:"Note: Switching to flash 9, required for MP4 formats.",
+mfTimeout:"Setting flashLoadTimeout \x3d 0 (infinite) for off-screen, mobile flash case",needFlash:"soundManager: Fatal error: Flash is needed to play some required formats, but is not available.",gotFocus:"soundManager: Got window focus.",policy:"Enabling usePolicyFile for data access",setup:"soundManager.setup(): allowed parameters: %s",setupError:'soundManager.setup(): "%s" cannot be assigned with this method.',setupUndef:'soundManager.setup(): Could not find option "%s"',setupLate:"soundManager.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().",
+noURL:"soundManager: Flash URL required. Call soundManager.setup({url:...}) to get started.",sm2Loaded:"SoundManager 2: Ready.",reset:"soundManager.reset(): Removing event callbacks",mobileUA:"Mobile UA detected, preferring HTML5 by default.",globalHTML5:"Using singleton HTML5 Audio() pattern for this device."};r=function(){var a=db.call(arguments),c=a.shift(),c=G&&G[c]?G[c]:"",e,b;if(c&&a&&a.length){e=0;for(b=a.length;e<b;e++)c=c.replace("%s",a[e])}return c};ia=function(a){8===p&&(1<a.loops&&a.stream)&&
+(n("as2loop"),a.stream=!1);return a};ja=function(a,d){if(a&&!a.usePolicyFile&&(a.onid3||a.usePeakData||a.useWaveformData||a.useEQData))c._wD((d||"")+r("policy")),a.usePolicyFile=!0;return a};R=function(a){console!==g&&console.warn!==g?console.warn(a):c._wD(a)};ra=function(){return!1};Wa=function(a){for(var c in a)a.hasOwnProperty(c)&&"function"===typeof a[c]&&(a[c]=ra)};Aa=function(a){a===g&&(a=!1);(t||a)&&c.disable(a)};Xa=function(a){var d=null;if(a)if(a.match(/\.swf(\?.*)?$/i)){if(d=a.substr(a.toLowerCase().lastIndexOf(".swf?")+
+4))return a}else a.lastIndexOf("/")!==a.length-1&&(a+="/");a=(a&&-1!==a.lastIndexOf("/")?a.substr(0,a.lastIndexOf("/")+1):"./")+c.movieURL;c.noSWFCache&&(a+="?ts\x3d"+(new Date).getTime());return a};wa=function(){p=parseInt(c.flashVersion,10);8!==p&&9!==p&&(c._wD(r("badFV",p,8)),c.flashVersion=p=8);var a=c.debugMode||c.debugFlash?"_debug.swf":".swf";c.useHTML5Audio&&(!c.html5Only&&c.audioFormats.mp4.required&&9>p)&&(c._wD(r("needfl9")),c.flashVersion=p=9);c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":
+9===p?" (AS3/Flash 9)":" (AS2/Flash 8)");8<p?(c.defaultOptions=x(c.defaultOptions,c.flash9Options),c.features.buffering=!0,c.defaultOptions=x(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+mb.join("|")+")(\\?.*)?$","i"),c.features.movieStar=!0):c.features.movieStar=!1;c.filePattern=c.filePatterns[8!==p?"flash9":"flash8"];c.movieURL=(8===p?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",a);c.features.peakData=c.features.waveformData=c.features.eqData=8<
+p};Ua=function(a,c){if(!l)return!1;l._setPolling(a,c)};za=function(){c.debugURLParam.test(S)&&(c.debugMode=!0);if(B(c.debugID))return!1;var a,d,e,b;if(c.debugMode&&!B(c.debugID)&&(!hb||!c.useConsole||!c.consoleOnly)){a=h.createElement("div");a.id=c.debugID+"-toggle";d={position:"fixed",bottom:"0px",right:"0px",width:"1.2em",height:"1.2em",lineHeight:"1.2em",margin:"2px",textAlign:"center",border:"1px solid #999",cursor:"pointer",background:"#fff",color:"#333",zIndex:10001};a.appendChild(h.createTextNode("-"));
+a.onclick=Ya;a.title="Toggle SM2 debug console";u.match(/msie 6/i)&&(a.style.position="absolute",a.style.cursor="hand");for(b in d)d.hasOwnProperty(b)&&(a.style[b]=d[b]);d=h.createElement("div");d.id=c.debugID;d.style.display=c.debugMode?"block":"none";if(c.debugMode&&!B(a.id)){try{e=ga(),e.appendChild(a)}catch(f){throw Error(r("domError")+" \n"+f.toString());}e.appendChild(d)}}};v=this.getSoundById;n=function(a,d){return!a?"":c._wD(r(a),d)};Ya=function(){var a=B(c.debugID),d=B(c.debugID+"-toggle");
+if(!a)return!1;ta?(d.innerHTML="+",a.style.display="none"):(d.innerHTML="-",a.style.display="block");ta=!ta};y=function(a,c,e){if(m.sm2Debugger!==g)try{sm2Debugger.handleEvent(a,c,e)}catch(b){}return!0};Q=function(){var a=[];c.debugMode&&a.push("sm2_debug");c.debugFlash&&a.push("flash_debug");c.useHighPerformance&&a.push("high_performance");return a.join(" ")};Ca=function(){var a=r("fbHandler"),d=c.getMoviePercent(),e={type:"FLASHBLOCK"};if(c.html5Only)return!1;c.ok()?(c.didFlashBlock&&c._wD(a+": Unblocked"),
+c.oMC&&(c.oMC.className=[Q(),"movieContainer","swf_loaded"+(c.didFlashBlock?" swf_unblocked":"")].join(" "))):(C&&(c.oMC.className=Q()+" movieContainer "+(null===d?"swf_timedout":"swf_error"),c._wD(a+": "+r("fbTimeout")+(d?" ("+r("fbLoaded")+")":""))),c.didFlashBlock=!0,J({type:"ontimeout",ignoreInit:!0,error:e}),P(e))};va=function(a,c,e){D[a]===g&&(D[a]=[]);D[a].push({method:c,scope:e||null,fired:!1})};J=function(a){a||(a={type:c.ok()?"onready":"ontimeout"});if(!q&&a&&!a.ignoreInit||"ontimeout"===
+a.type&&(c.ok()||t&&!a.ignoreInit))return!1;var d={success:a&&a.ignoreInit?c.ok():!t},e=a&&a.type?D[a.type]||[]:[],b=[],f,d=[d],g=C&&!c.ok();a.error&&(d[0].error=a.error);a=0;for(f=e.length;a<f;a++)!0!==e[a].fired&&b.push(e[a]);if(b.length){a=0;for(f=b.length;a<f;a++)b[a].scope?b[a].method.apply(b[a].scope,d):b[a].method.apply(this,d),g||(b[a].fired=!0)}return!0};M=function(){m.setTimeout(function(){c.useFlashBlock&&Ca();J();"function"===typeof c.onload&&(n("onload",1),c.onload.apply(m),n("onloadOK",
+1));c.waitForWindowLoad&&w.add(m,"load",M)},1)};Ha=function(){if(A!==g)return A;var a=!1,c=navigator,e=c.plugins,b,f=m.ActiveXObject;if(e&&e.length)(c=c.mimeTypes)&&(c["application/x-shockwave-flash"]&&c["application/x-shockwave-flash"].enabledPlugin&&c["application/x-shockwave-flash"].enabledPlugin.description)&&(a=!0);else if(f!==g&&!u.match(/MSAppHost/i)){try{b=new f("ShockwaveFlash.ShockwaveFlash")}catch(h){}a=!!b}return A=a};bb=function(){var a,d,e=c.audioFormats;if(oa&&u.match(/os (1|2|3_0|3_1)/i))c.hasHTML5=
+!1,c.html5Only=!0,c.oMC&&(c.oMC.style.display="none");else if(c.useHTML5Audio){if(!c.html5||!c.html5.canPlayType)c._wD("SoundManager: No HTML5 Audio() support detected."),c.hasHTML5=!1;Ma&&c._wD("soundManager: Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id\x3d32159 - "+(!A?" would use flash fallback for MP3/MP4, but none detected.":"will use flash fallback for MP3/MP4, if available"),1)}if(c.useHTML5Audio&&c.hasHTML5)for(d in e)if(e.hasOwnProperty(d)&&
+(e[d].required&&!c.html5.canPlayType(e[d].type)||c.preferFlash&&(c.flash[d]||c.flash[e[d].type])))a=!0;c.ignoreFlash&&(a=!1);c.html5Only=c.hasHTML5&&c.useHTML5Audio&&!a;return!c.html5Only};la=function(a){var d,e,b=0;if(a instanceof Array){d=0;for(e=a.length;d<e;d++)if(a[d]instanceof Object){if(c.canPlayMIME(a[d].type)){b=d;break}}else if(c.canPlayURL(a[d])){b=d;break}a[b].url&&(a[b]=a[b].url);a=a[b]}return a};Za=function(a){a._hasTimer||(a._hasTimer=!0,!La&&c.html5PollingInterval&&(null===Z&&0===
+ka&&(Z=setInterval(ab,c.html5PollingInterval)),ka++))};$a=function(a){a._hasTimer&&(a._hasTimer=!1,!La&&c.html5PollingInterval&&ka--)};ab=function(){var a;if(null!==Z&&!ka)return clearInterval(Z),Z=null,!1;for(a=c.soundIDs.length-1;0<=a;a--)c.sounds[c.soundIDs[a]].isHTML5&&c.sounds[c.soundIDs[a]]._hasTimer&&c.sounds[c.soundIDs[a]]._onTimer()};P=function(a){a=a!==g?a:{};"function"===typeof c.onerror&&c.onerror.apply(m,[{type:a.type!==g?a.type:null}]);a.fatal!==g&&a.fatal&&c.disable()};eb=function(){if(!Ma||
+!Ha())return!1;var a=c.audioFormats,d,e;for(e in a)if(a.hasOwnProperty(e)&&("mp3"===e||"mp4"===e))if(c._wD("soundManager: Using flash fallback for "+e+" format"),c.html5[e]=!1,a[e]&&a[e].related)for(d=a[e].related.length-1;0<=d;d--)c.html5[a[e].related[d]]=!1};this._setSandboxType=function(a){var d=c.sandbox;d.type=a;d.description=d.types[d.types[a]!==g?a:"unknown"];"localWithFile"===d.type?(d.noRemote=!0,d.noLocal=!1,n("secNote",2)):"localWithNetwork"===d.type?(d.noRemote=!1,d.noLocal=!0):"localTrusted"===
+d.type&&(d.noRemote=!1,d.noLocal=!1)};this._externalInterfaceOK=function(a,d){if(c.swfLoaded)return!1;var e;y("swf",!0);y("flashtojs",!0);c.swfLoaded=!0;pa=!1;Ma&&eb();if(!d||d.replace(/\+dev/i,"")!==c.versionNumber.replace(/\+dev/i,""))return e='soundManager: Fatal: JavaScript file build "'+c.versionNumber+'" does not match Flash SWF build "'+d+'" at '+c.url+". Ensure both are up-to-date.",setTimeout(function(){throw Error(e);},0),!1;setTimeout(sa,I?100:1)};ha=function(a,d){function e(){var a=[],
+b,d=[];b="SoundManager "+c.version+(!c.html5Only&&c.useHTML5Audio?c.hasHTML5?" + HTML5 audio":", no HTML5 audio support":"");c.html5Only?c.html5PollingInterval&&a.push("html5PollingInterval ("+c.html5PollingInterval+"ms)"):(c.preferFlash&&a.push("preferFlash"),c.useHighPerformance&&a.push("useHighPerformance"),c.flashPollingInterval&&a.push("flashPollingInterval ("+c.flashPollingInterval+"ms)"),c.html5PollingInterval&&a.push("html5PollingInterval ("+c.html5PollingInterval+"ms)"),c.wmode&&a.push("wmode ("+
+c.wmode+")"),c.debugFlash&&a.push("debugFlash"),c.useFlashBlock&&a.push("flashBlock"));a.length&&(d=d.concat([a.join(" + ")]));c._wD(b+(d.length?" + "+d.join(", "):""),1);fb()}function b(a,b){return'\x3cparam name\x3d"'+a+'" value\x3d"'+b+'" /\x3e'}if(T&&U)return!1;if(c.html5Only)return wa(),e(),c.oMC=B(c.movieID),sa(),U=T=!0,!1;var f=d||c.url,m=c.altURL||f,l=ga(),k=Q(),p=null,p=h.getElementsByTagName("html")[0],n,s,q,p=p&&p.dir&&p.dir.match(/rtl/i);a=a===g?c.id:a;wa();c.url=Xa(aa?f:m);d=c.url;c.wmode=
+!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(null!==c.wmode&&(u.match(/msie 8/i)||!I&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))K.push(G.spcWmode),c.wmode=null;l={name:a,id:a,src:d,quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:kb+"www.macromedia.com/go/getflashplayer",title:"JS/Flash audio component (SoundManager 2)",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};c.debugFlash&&(l.FlashVars="debug\x3d1");
+c.wmode||delete l.wmode;if(I)f=h.createElement("div"),s=['\x3cobject id\x3d"'+a+'" data\x3d"'+d+'" type\x3d"'+l.type+'" title\x3d"'+l.title+'" classid\x3d"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase\x3d"'+kb+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version\x3d6,0,40,0"\x3e',b("movie",d),b("AllowScriptAccess",c.allowScriptAccess),b("quality",l.quality),c.wmode?b("wmode",c.wmode):"",b("bgcolor",c.bgColor),b("hasPriority","true"),c.debugFlash?b("FlashVars",l.FlashVars):
+"","\x3c/object\x3e"].join("");else for(n in f=h.createElement("embed"),l)l.hasOwnProperty(n)&&f.setAttribute(n,l[n]);za();k=Q();if(l=ga())if(c.oMC=B(c.movieID)||h.createElement("div"),c.oMC.id)q=c.oMC.className,c.oMC.className=(q?q+" ":"movieContainer")+(k?" "+k:""),c.oMC.appendChild(f),I&&(n=c.oMC.appendChild(h.createElement("div")),n.className="sm2-object-box",n.innerHTML=s),U=!0;else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+k;n=k=null;c.useFlashBlock||(c.useHighPerformance?k={position:"fixed",
+width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"}:(k={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},p&&(k.left=Math.abs(parseInt(k.left,10))+"px")));qb&&(c.oMC.style.zIndex=1E4);if(!c.debugFlash)for(q in k)k.hasOwnProperty(q)&&(c.oMC.style[q]=k[q]);try{I||c.oMC.appendChild(f),l.appendChild(c.oMC),I&&(n=c.oMC.appendChild(h.createElement("div")),n.className="sm2-object-box",n.innerHTML=s),U=!0}catch(t){throw Error(r("domError")+" \n"+t.toString());}}T=
+!0;e();return!0};fa=function(){if(c.html5Only)return ha(),!1;if(l)return!1;if(!c.url)return n("noURL"),!1;l=c.getMovie(c.id);l||(X?(I?c.oMC.innerHTML=Ba:c.oMC.appendChild(X),X=null,T=!0):ha(c.id,c.url),l=c.getMovie(c.id));"function"===typeof c.oninitmovie&&setTimeout(c.oninitmovie,1);Ia();return!0};N=function(){setTimeout(Ta,1E3)};Ta=function(){var a,d=!1;if(!c.url||Y)return!1;Y=!0;w.remove(m,"load",N);if(pa&&!Na)return n("waitFocus"),!1;q||(a=c.getMoviePercent(),0<a&&100>a&&(d=!0));setTimeout(function(){a=
+c.getMoviePercent();if(d)return Y=!1,c._wD(r("waitSWF")),m.setTimeout(N,1),!1;q||(c._wD("soundManager: No Flash response within expected time. Likely causes: "+(0===a?"SWF load failed, ":"")+"Flash blocked or JS-Flash security error."+(c.debugFlash?" "+r("checkSWF"):""),2),!aa&&a&&(n("localFail",2),c.debugFlash||n("tryDebug",2)),0===a&&c._wD(r("swf404",c.url),1),y("flashtojs",!1,": Timed out"+aa?" (Check flash security or flash blockers)":" (No plugin/missing SWF?)"));!q&&ib&&(null===a?c.useFlashBlock||
+0===c.flashLoadTimeout?(c.useFlashBlock&&Ca(),n("waitForever")):(n("waitForever"),J({type:"ontimeout",ignoreInit:!0})):0===c.flashLoadTimeout?n("waitForever"):Aa(!0))},c.flashLoadTimeout)};ea=function(){if(Na||!pa)return w.remove(m,"focus",ea),!0;Na=ib=!0;n("gotFocus");Y=!1;N();w.remove(m,"focus",ea);return!0};Ia=function(){K.length&&(c._wD("SoundManager 2: "+K.join(" "),1),K=[])};fb=function(){Ia();var a,d=[];if(c.useHTML5Audio&&c.hasHTML5){for(a in c.audioFormats)c.audioFormats.hasOwnProperty(a)&&
+d.push(a+" \x3d "+c.html5[a]+(!c.html5[a]&&A&&c.flash[a]?" (using flash)":c.preferFlash&&c.flash[a]&&A?" (preferring flash)":!c.html5[a]?" ("+(c.audioFormats[a].required?"required, ":"")+"and no flash support)":""));c._wD("SoundManager 2 HTML5 support: "+d.join(", "),1)}};V=function(a){if(q)return!1;if(c.html5Only)return n("sm2Loaded"),q=!0,M(),y("onload",!0),!0;var d=!0,e;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())q=!0,t&&(e={type:!A&&C?"NO_FLASH":"INIT_TIMEOUT"});c._wD("SoundManager 2 "+
+(t?"failed to load":"loaded")+" ("+(t?"Flash security/load error":"OK")+")",t?2:1);t||a?(c.useFlashBlock&&c.oMC&&(c.oMC.className=Q()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error")),J({type:"ontimeout",error:e,ignoreInit:!0}),y("onload",!1),P(e),d=!1):y("onload",!0);t||(c.waitForWindowLoad&&!da?(n("waitOnload"),w.add(m,"load",M)):(c.waitForWindowLoad&&da&&n("docLoaded"),M()));return d};Sa=function(){var a,d=c.setupOptions;for(a in d)d.hasOwnProperty(a)&&(c[a]===g?c[a]=d[a]:c[a]!==d[a]&&
+(c.setupOptions[a]=c[a]))};sa=function(){if(q)return n("didInit"),!1;if(c.html5Only)return q||(w.remove(m,"load",c.beginDelayedInit),c.enabled=!0,V()),!0;fa();try{l._externalInterfaceTest(!1),Ua(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||l._disableDebug(),c.enabled=!0,y("jstoflash",!0),c.html5Only||w.add(m,"unload",ra)}catch(a){return c._wD("js/flash exception: "+a.toString()),y("jstoflash",!1),P({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),Aa(!0),V(),!1}V();w.remove(m,"load",
+c.beginDelayedInit);return!0};O=function(){if(W)return!1;W=!0;Sa();za();var a=null,a=null,d=m.console!==g&&"function"===typeof console.log,e=S.toLowerCase();-1!==e.indexOf("sm2-usehtml5audio\x3d")&&(a="1"===e.charAt(e.indexOf("sm2-usehtml5audio\x3d")+18),d&&console.log((a?"Enabling ":"Disabling ")+"useHTML5Audio via URL parameter"),c.setup({useHTML5Audio:a}));-1!==e.indexOf("sm2-preferflash\x3d")&&(a="1"===e.charAt(e.indexOf("sm2-preferflash\x3d")+16),d&&console.log((a?"Enabling ":"Disabling ")+"preferFlash via URL parameter"),
+c.setup({preferFlash:a}));!A&&c.hasHTML5&&(c._wD("SoundManager: No Flash detected"+(!c.useHTML5Audio?", enabling HTML5.":". Trying HTML5-only mode."),1),c.setup({useHTML5Audio:!0,preferFlash:!1}));cb();c.html5.usingFlash=bb();C=c.html5.usingFlash;!A&&C&&(K.push(G.needFlash),c.setup({flashLoadTimeout:1}));h.removeEventListener&&h.removeEventListener("DOMContentLoaded",O,!1);fa();return!0};Fa=function(){"complete"===h.readyState&&(O(),h.detachEvent("onreadystatechange",Fa));return!0};ya=function(){da=
+!0;w.remove(m,"load",ya)};xa=function(){if(La&&((!c.setupOptions.useHTML5Audio||c.setupOptions.preferFlash)&&K.push(G.mobileUA),c.setupOptions.useHTML5Audio=!0,c.setupOptions.preferFlash=!1,oa||gb&&!u.match(/android\s2\.3/i)))K.push(G.globalHTML5),oa&&(c.ignoreFlash=!0),E=!0};xa();Ha();w.add(m,"focus",ea);w.add(m,"load",N);w.add(m,"load",ya);h.addEventListener?h.addEventListener("DOMContentLoaded",O,!1):h.attachEvent?h.attachEvent("onreadystatechange",Fa):(y("onload",!1),P({type:"NO_DOM2_EVENTS",
+fatal:!0}))}var qa=null;if(void 0===m.SM2_DEFER||!SM2_DEFER)qa=new ba;m.SoundManager=ba;m.soundManager=qa})(window);
\ No newline at end of file
--- /dev/null
+/** @license\r
+ *\r
+ * SoundManager 2: JavaScript Sound for the Web\r
+ * ----------------------------------------------\r
+ * http://schillmania.com/projects/soundmanager2/\r
+ *\r
+ * Copyright (c) 2007, Scott Schiller. All rights reserved.\r
+ * Code provided under the BSD License:\r
+ * http://schillmania.com/projects/soundmanager2/license.txt\r
+ *\r
+ * V2.97a.20130324 ("Mahalo" Edition)\r
+ */\r
+\r
+/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */\r
+/*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */\r
+\r
+(function(window, _undefined) {\r
+"use strict";\r
+var soundManager = null;\r
+function SoundManager(smURL, smID) {\r
+ this.setupOptions = {\r
+ 'url': (smURL || null),\r
+ 'flashVersion': 8,\r
+ 'debugMode': true,\r
+ 'debugFlash': false,\r
+ 'useConsole': true,\r
+ 'consoleOnly': true,\r
+ 'waitForWindowLoad': false,\r
+ 'bgColor': '#ffffff',\r
+ 'useHighPerformance': false,\r
+ 'flashPollingInterval': null,\r
+ 'html5PollingInterval': null,\r
+ 'flashLoadTimeout': 1000,\r
+ 'wmode': null,\r
+ 'allowScriptAccess': 'always',\r
+ 'useFlashBlock': false,\r
+ 'useHTML5Audio': true,\r
+ 'html5Test': /^(probably|maybe)$/i,\r
+ 'preferFlash': true,\r
+ 'noSWFCache': false\r
+ };\r
+ this.defaultOptions = {\r
+ 'autoLoad': false,\r
+ 'autoPlay': false,\r
+ 'from': null,\r
+ 'loops': 1,\r
+ 'onid3': null,\r
+ 'onload': null,\r
+ 'whileloading': null,\r
+ 'onplay': null,\r
+ 'onpause': null,\r
+ 'onresume': null,\r
+ 'whileplaying': null,\r
+ 'onposition': null,\r
+ 'onstop': null,\r
+ 'onfailure': null,\r
+ 'onfinish': null,\r
+ 'multiShot': true,\r
+ 'multiShotEvents': false,\r
+ 'position': null,\r
+ 'pan': 0,\r
+ 'stream': true,\r
+ 'to': null,\r
+ 'type': null,\r
+ 'usePolicyFile': false,\r
+ 'volume': 100\r
+ };\r
+ this.flash9Options = {\r
+ 'isMovieStar': null,\r
+ 'usePeakData': false,\r
+ 'useWaveformData': false,\r
+ 'useEQData': false,\r
+ 'onbufferchange': null,\r
+ 'ondataerror': null\r
+ };\r
+ this.movieStarOptions = {\r
+ 'bufferTime': 3,\r
+ 'serverURL': null,\r
+ 'onconnect': null,\r
+ 'duration': null\r
+ };\r
+ this.audioFormats = {\r
+ 'mp3': {\r
+ 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'],\r
+ 'required': true\r
+ },\r
+ 'mp4': {\r
+ 'related': ['aac','m4a','m4b'],\r
+ 'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'],\r
+ 'required': false\r
+ },\r
+ 'ogg': {\r
+ 'type': ['audio/ogg; codecs=vorbis'],\r
+ 'required': false\r
+ },\r
+ 'opus': {\r
+ 'type': ['audio/ogg; codecs=opus', 'audio/opus'],\r
+ 'required': false\r
+ },\r
+ 'wav': {\r
+ 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],\r
+ 'required': false\r
+ }\r
+ };\r
+ this.movieID = 'sm2-container';\r
+ this.id = (smID || 'sm2movie');\r
+ this.debugID = 'soundmanager-debug';\r
+ this.debugURLParam = /([#?&])debug=1/i;\r
+ this.versionNumber = 'V2.97a.20130324';\r
+ this.version = null;\r
+ this.movieURL = null;\r
+ this.altURL = null;\r
+ this.swfLoaded = false;\r
+ this.enabled = false;\r
+ this.oMC = null;\r
+ this.sounds = {};\r
+ this.soundIDs = [];\r
+ this.muted = false;\r
+ this.didFlashBlock = false;\r
+ this.filePattern = null;\r
+ this.filePatterns = {\r
+ 'flash8': /\.mp3(\?.*)?$/i,\r
+ 'flash9': /\.mp3(\?.*)?$/i\r
+ };\r
+ this.features = {\r
+ 'buffering': false,\r
+ 'peakData': false,\r
+ 'waveformData': false,\r
+ 'eqData': false,\r
+ 'movieStar': false\r
+ };\r
+ this.sandbox = {\r
+ };\r
+ this.html5 = {\r
+ 'usingFlash': null\r
+ };\r
+ this.flash = {};\r
+ this.html5Only = false;\r
+ this.ignoreFlash = false;\r
+ var SMSound,\r
+ sm2 = this, globalHTML5Audio = null, flash = null, sm = 'soundManager', smc = sm + ': ', h5 = 'HTML5::', id, ua = navigator.userAgent, wl = window.location.href.toString(), doc = document, doNothing, setProperties, init, fV, on_queue = [], debugOpen = true, debugTS, didAppend = false, appendSuccess = false, didInit = false, disabled = false, windowLoaded = false, _wDS, wdCount = 0, initComplete, mixin, assign, extraOptions, addOnEvent, processOnEvents, initUserOnload, delayWaitForEI, waitForEI, setVersionInfo, handleFocus, strings, initMovie, preInit, domContentLoaded, winOnLoad, didDCLoaded, getDocument, createMovie, catchError, setPolling, initDebug, debugLevels = ['log', 'info', 'warn', 'error'], defaultFlashVersion = 8, disableObject, failSafely, normalizeMovieURL, oRemoved = null, oRemovedHTML = null, str, flashBlockHandler, getSWFCSS, swfCSS, toggleDebug, loopFix, policyFix, complain, idCheck, waitingForEI = false, initPending = false, startTimer, stopTimer, timerExecute, h5TimerCount = 0, h5IntervalTimer = null, parseURL, messages = [],\r
+ needsFlash = null, featureCheck, html5OK, html5CanPlay, html5Ext, html5Unload, domContentLoadedIE, testHTML5, event, slice = Array.prototype.slice, useGlobalHTML5Audio = false, lastGlobalHTML5URL, hasFlash, detectFlash, badSafariFix, html5_events, showSupport, flushMessages, wrapCallback,\r
+ is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie/i), isWebkit = ua.match(/webkit/i), isSafari = (ua.match(/safari/i) && !ua.match(/chrome/i)), isOpera = (ua.match(/opera/i)),\r
+ mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid),\r
+ isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2\-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS X 10_6_([3-7])/i)),\r
+ hasConsole = (window.console !== _undefined && console.log !== _undefined), isFocused = (doc.hasFocus !== _undefined?doc.hasFocus():null), tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())), okToDisable = !tryInitOnFocus, flashMIME = /(mp3|mp4|mpa|m4a|m4b)/i,\r
+ emptyURL = 'about:blank',\r
+ overHTTP = (doc.location?doc.location.protocol.match(/http/i):null),\r
+ http = (!overHTTP ? 'http:/'+'/' : ''),\r
+ netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,\r
+ netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'],\r
+ netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
+ this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;\r
+ this.useAltURL = !overHTTP;\r
+ swfCSS = {\r
+ 'swfBox': 'sm2-object-box',\r
+ 'swfDefault': 'movieContainer',\r
+ 'swfError': 'swf_error',\r
+ 'swfTimedout': 'swf_timedout',\r
+ 'swfLoaded': 'swf_loaded',\r
+ 'swfUnblocked': 'swf_unblocked',\r
+ 'sm2Debug': 'sm2_debug',\r
+ 'highPerf': 'high_performance',\r
+ 'flashDebug': 'flash_debug'\r
+ };\r
+ this.hasHTML5 = (function() {\r
+ try {\r
+ return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined);\r
+ } catch(e) {\r
+ return false;\r
+ }\r
+ }());\r
+ this.setup = function(options) {\r
+ var noURL = (!sm2.url);\r
+ if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) {\r
+ complain(str('setupLate'));\r
+ }\r
+ assign(options);\r
+ if (noURL && didDCLoaded && options.url !== _undefined) {\r
+ sm2.beginDelayedInit();\r
+ }\r
+ if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') {\r
+ setTimeout(domContentLoaded, 1);\r
+ }\r
+ return sm2;\r
+ };\r
+ this.ok = function() {\r
+ return (needsFlash?(didInit && !disabled):(sm2.useHTML5Audio && sm2.hasHTML5));\r
+ };\r
+ this.supported = this.ok;\r
+ this.getMovie = function(smID) {\r
+ return id(smID) || doc[smID] || window[smID];\r
+ };\r
+ this.createSound = function(oOptions, _url) {\r
+ var cs, cs_string, options, oSound = null;\r
+ if (!didInit || !sm2.ok()) {\r
+ complain(cs_string);\r
+ return false;\r
+ }\r
+ if (_url !== _undefined) {\r
+ oOptions = {\r
+ 'id': oOptions,\r
+ 'url': _url\r
+ };\r
+ }\r
+ options = mixin(oOptions);\r
+ options.url = parseURL(options.url);\r
+ if (idCheck(options.id, true)) {\r
+ return sm2.sounds[options.id];\r
+ }\r
+ function make() {\r
+ options = loopFix(options);\r
+ sm2.sounds[options.id] = new SMSound(options);\r
+ sm2.soundIDs.push(options.id);\r
+ return sm2.sounds[options.id];\r
+ }\r
+ if (html5OK(options)) {\r
+ oSound = make();\r
+ oSound._setup_html5(options);\r
+ } else {\r
+ if (fV > 8) {\r
+ if (options.isMovieStar === null) {\r
+ options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || options.url.match(netStreamPattern));\r
+ }\r
+ }\r
+ options = policyFix(options, cs);\r
+ oSound = make();\r
+ if (fV === 8) {\r
+ flash._createSound(options.id, options.loops||1, options.usePolicyFile);\r
+ } else {\r
+ flash._createSound(options.id, options.url, options.usePeakData, options.useWaveformData, options.useEQData, options.isMovieStar, (options.isMovieStar?options.bufferTime:false), options.loops||1, options.serverURL, options.duration||null, options.autoPlay, true, options.autoLoad, options.usePolicyFile);\r
+ if (!options.serverURL) {\r
+ oSound.connected = true;\r
+ if (options.onconnect) {\r
+ options.onconnect.apply(oSound);\r
+ }\r
+ }\r
+ }\r
+ if (!options.serverURL && (options.autoLoad || options.autoPlay)) {\r
+ oSound.load(options);\r
+ }\r
+ }\r
+ if (!options.serverURL && options.autoPlay) {\r
+ oSound.play();\r
+ }\r
+ return oSound;\r
+ };\r
+ this.destroySound = function(sID, _bFromSound) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ var oS = sm2.sounds[sID], i;\r
+ oS._iO = {};\r
+ oS.stop();\r
+ oS.unload();\r
+ for (i = 0; i < sm2.soundIDs.length; i++) {\r
+ if (sm2.soundIDs[i] === sID) {\r
+ sm2.soundIDs.splice(i, 1);\r
+ break;\r
+ }\r
+ }\r
+ if (!_bFromSound) {\r
+ oS.destruct(true);\r
+ }\r
+ oS = null;\r
+ delete sm2.sounds[sID];\r
+ return true;\r
+ };\r
+ this.load = function(sID, oOptions) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].load(oOptions);\r
+ };\r
+ this.unload = function(sID) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].unload();\r
+ };\r
+ this.onPosition = function(sID, nPosition, oMethod, oScope) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].onposition(nPosition, oMethod, oScope);\r
+ };\r
+ this.onposition = this.onPosition;\r
+ this.clearOnPosition = function(sID, nPosition, oMethod) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].clearOnPosition(nPosition, oMethod);\r
+ };\r
+ this.play = function(sID, oOptions) {\r
+ var result = false;\r
+ if (!didInit || !sm2.ok()) {\r
+ complain(sm + '.play(): ' + str(!didInit?'notReady':'notOK'));\r
+ return result;\r
+ }\r
+ if (!idCheck(sID)) {\r
+ if (!(oOptions instanceof Object)) {\r
+ oOptions = {\r
+ url: oOptions\r
+ };\r
+ }\r
+ if (oOptions && oOptions.url) {\r
+ oOptions.id = sID;\r
+ result = sm2.createSound(oOptions).play();\r
+ }\r
+ return result;\r
+ }\r
+ return sm2.sounds[sID].play(oOptions);\r
+ };\r
+ this.start = this.play;\r
+ this.setPosition = function(sID, nMsecOffset) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].setPosition(nMsecOffset);\r
+ };\r
+ this.stop = function(sID) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].stop();\r
+ };\r
+ this.stopAll = function() {\r
+ var oSound;\r
+ for (oSound in sm2.sounds) {\r
+ if (sm2.sounds.hasOwnProperty(oSound)) {\r
+ sm2.sounds[oSound].stop();\r
+ }\r
+ }\r
+ };\r
+ this.pause = function(sID) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].pause();\r
+ };\r
+ this.pauseAll = function() {\r
+ var i;\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].pause();\r
+ }\r
+ };\r
+ this.resume = function(sID) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].resume();\r
+ };\r
+ this.resumeAll = function() {\r
+ var i;\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].resume();\r
+ }\r
+ };\r
+ this.togglePause = function(sID) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].togglePause();\r
+ };\r
+ this.setPan = function(sID, nPan) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].setPan(nPan);\r
+ };\r
+ this.setVolume = function(sID, nVol) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].setVolume(nVol);\r
+ };\r
+ this.mute = function(sID) {\r
+ var i = 0;\r
+ if (sID instanceof String) {\r
+ sID = null;\r
+ }\r
+ if (!sID) {\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].mute();\r
+ }\r
+ sm2.muted = true;\r
+ } else {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].mute();\r
+ }\r
+ return true;\r
+ };\r
+ this.muteAll = function() {\r
+ sm2.mute();\r
+ };\r
+ this.unmute = function(sID) {\r
+ var i;\r
+ if (sID instanceof String) {\r
+ sID = null;\r
+ }\r
+ if (!sID) {\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].unmute();\r
+ }\r
+ sm2.muted = false;\r
+ } else {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].unmute();\r
+ }\r
+ return true;\r
+ };\r
+ this.unmuteAll = function() {\r
+ sm2.unmute();\r
+ };\r
+ this.toggleMute = function(sID) {\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].toggleMute();\r
+ };\r
+ this.getMemoryUse = function() {\r
+ var ram = 0;\r
+ if (flash && fV !== 8) {\r
+ ram = parseInt(flash._getMemoryUse(), 10);\r
+ }\r
+ return ram;\r
+ };\r
+ this.disable = function(bNoDisable) {\r
+ var i;\r
+ if (bNoDisable === _undefined) {\r
+ bNoDisable = false;\r
+ }\r
+ if (disabled) {\r
+ return false;\r
+ }\r
+ disabled = true;\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ disableObject(sm2.sounds[sm2.soundIDs[i]]);\r
+ }\r
+ initComplete(bNoDisable);\r
+ event.remove(window, 'load', initUserOnload);\r
+ return true;\r
+ };\r
+ this.canPlayMIME = function(sMIME) {\r
+ var result;\r
+ if (sm2.hasHTML5) {\r
+ result = html5CanPlay({type:sMIME});\r
+ }\r
+ if (!result && needsFlash) {\r
+ result = (sMIME && sm2.ok() ? !!((fV > 8 ? sMIME.match(netStreamMimeTypes) : null) || sMIME.match(sm2.mimePattern)) : null);\r
+ }\r
+ return result;\r
+ };\r
+ this.canPlayURL = function(sURL) {\r
+ var result;\r
+ if (sm2.hasHTML5) {\r
+ result = html5CanPlay({url: sURL});\r
+ }\r
+ if (!result && needsFlash) {\r
+ result = (sURL && sm2.ok() ? !!(sURL.match(sm2.filePattern)) : null);\r
+ }\r
+ return result;\r
+ };\r
+ this.canPlayLink = function(oLink) {\r
+ if (oLink.type !== _undefined && oLink.type) {\r
+ if (sm2.canPlayMIME(oLink.type)) {\r
+ return true;\r
+ }\r
+ }\r
+ return sm2.canPlayURL(oLink.href);\r
+ };\r
+ this.getSoundById = function(sID, _suppressDebug) {\r
+ if (!sID) {\r
+ throw new Error(sm + '.getSoundById(): sID is null/_undefined');\r
+ }\r
+ var result = sm2.sounds[sID];\r
+ return result;\r
+ };\r
+ this.onready = function(oMethod, oScope) {\r
+ var sType = 'onready',\r
+ result = false;\r
+ if (typeof oMethod === 'function') {\r
+ if (!oScope) {\r
+ oScope = window;\r
+ }\r
+ addOnEvent(sType, oMethod, oScope);\r
+ processOnEvents();\r
+ result = true;\r
+ } else {\r
+ throw str('needFunction', sType);\r
+ }\r
+ return result;\r
+ };\r
+ this.ontimeout = function(oMethod, oScope) {\r
+ var sType = 'ontimeout',\r
+ result = false;\r
+ if (typeof oMethod === 'function') {\r
+ if (!oScope) {\r
+ oScope = window;\r
+ }\r
+ addOnEvent(sType, oMethod, oScope);\r
+ processOnEvents({type:sType});\r
+ result = true;\r
+ } else {\r
+ throw str('needFunction', sType);\r
+ }\r
+ return result;\r
+ };\r
+ this._writeDebug = function(sText, sTypeOrObject) {\r
+ return true;\r
+ };\r
+ this._wD = this._writeDebug;\r
+ this._debug = function() {\r
+ };\r
+ this.reboot = function(resetEvents, excludeInit) {\r
+ var i, j, k;\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].destruct();\r
+ }\r
+ if (flash) {\r
+ try {\r
+ if (isIE) {\r
+ oRemovedHTML = flash.innerHTML;\r
+ }\r
+ oRemoved = flash.parentNode.removeChild(flash);\r
+ } catch(e) {\r
+ }\r
+ }\r
+ oRemovedHTML = oRemoved = needsFlash = flash = null;\r
+ sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false;\r
+ sm2.soundIDs = [];\r
+ sm2.sounds = {};\r
+ if (!resetEvents) {\r
+ for (i in on_queue) {\r
+ if (on_queue.hasOwnProperty(i)) {\r
+ for (j = 0, k = on_queue[i].length; j < k; j++) {\r
+ on_queue[i][j].fired = false;\r
+ }\r
+ }\r
+ }\r
+ } else {\r
+ on_queue = [];\r
+ }\r
+ sm2.html5 = {\r
+ 'usingFlash': null\r
+ };\r
+ sm2.flash = {};\r
+ sm2.html5Only = false;\r
+ sm2.ignoreFlash = false;\r
+ window.setTimeout(function() {\r
+ preInit();\r
+ if (!excludeInit) {\r
+ sm2.beginDelayedInit();\r
+ }\r
+ }, 20);\r
+ return sm2;\r
+ };\r
+ this.reset = function() {\r
+ return sm2.reboot(true, true);\r
+ };\r
+ this.getMoviePercent = function() {\r
+ return (flash && 'PercentLoaded' in flash ? flash.PercentLoaded() : null);\r
+ };\r
+ this.beginDelayedInit = function() {\r
+ windowLoaded = true;\r
+ domContentLoaded();\r
+ setTimeout(function() {\r
+ if (initPending) {\r
+ return false;\r
+ }\r
+ createMovie();\r
+ initMovie();\r
+ initPending = true;\r
+ return true;\r
+ }, 20);\r
+ delayWaitForEI();\r
+ };\r
+ this.destruct = function() {\r
+ sm2.disable(true);\r
+ };\r
+ SMSound = function(oOptions) {\r
+ var s = this, resetProperties, add_html5_events, remove_html5_events, stop_html5_timer, start_html5_timer, attachOnPosition, onplay_called = false, onPositionItems = [], onPositionFired = 0, detachOnPosition, applyFromTo, lastURL = null, lastHTML5State;\r
+ lastHTML5State = {\r
+ duration: null,\r
+ time: null\r
+ };\r
+ this.id = oOptions.id;\r
+ this.sID = this.id;\r
+ this.url = oOptions.url;\r
+ this.options = mixin(oOptions);\r
+ this.instanceOptions = this.options;\r
+ this._iO = this.instanceOptions;\r
+ this.pan = this.options.pan;\r
+ this.volume = this.options.volume;\r
+ this.isHTML5 = false;\r
+ this._a = null;\r
+ this.id3 = {};\r
+ this._debug = function() {\r
+ };\r
+ this.load = function(oOptions) {\r
+ var oSound = null, instanceOptions;\r
+ if (oOptions !== _undefined) {\r
+ s._iO = mixin(oOptions, s.options);\r
+ } else {\r
+ oOptions = s.options;\r
+ s._iO = oOptions;\r
+ if (lastURL && lastURL !== s.url) {\r
+ s._iO.url = s.url;\r
+ s.url = null;\r
+ }\r
+ }\r
+ if (!s._iO.url) {\r
+ s._iO.url = s.url;\r
+ }\r
+ s._iO.url = parseURL(s._iO.url);\r
+ s.instanceOptions = s._iO;\r
+ instanceOptions = s._iO;\r
+ if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) {\r
+ if (s.readyState === 3 && instanceOptions.onload) {\r
+ wrapCallback(s, function() {\r
+ instanceOptions.onload.apply(s, [(!!s.duration)]);\r
+ });\r
+ }\r
+ return s;\r
+ }\r
+ s.loaded = false;\r
+ s.readyState = 1;\r
+ s.playState = 0;\r
+ s.id3 = {};\r
+ if (html5OK(instanceOptions)) {\r
+ oSound = s._setup_html5(instanceOptions);\r
+ if (!oSound._called_load) {\r
+ s._html5_canplay = false;\r
+ if (s.url !== instanceOptions.url) {\r
+ s._a.src = instanceOptions.url;\r
+ s.setPosition(0);\r
+ }\r
+ s._a.autobuffer = 'auto';\r
+ s._a.preload = 'auto';\r
+ s._a._called_load = true;\r
+ if (instanceOptions.autoPlay) {\r
+ s.play();\r
+ }\r
+ } else {\r
+ }\r
+ } else {\r
+ try {\r
+ s.isHTML5 = false;\r
+ s._iO = policyFix(loopFix(instanceOptions));\r
+ instanceOptions = s._iO;\r
+ if (fV === 8) {\r
+ flash._load(s.id, instanceOptions.url, instanceOptions.stream, instanceOptions.autoPlay, instanceOptions.usePolicyFile);\r
+ } else {\r
+ flash._load(s.id, instanceOptions.url, !!(instanceOptions.stream), !!(instanceOptions.autoPlay), instanceOptions.loops||1, !!(instanceOptions.autoLoad), instanceOptions.usePolicyFile);\r
+ }\r
+ } catch(e) {\r
+ catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true});\r
+ }\r
+ }\r
+ s.url = instanceOptions.url;\r
+ return s;\r
+ };\r
+ this.unload = function() {\r
+ if (s.readyState !== 0) {\r
+ if (!s.isHTML5) {\r
+ if (fV === 8) {\r
+ flash._unload(s.id, emptyURL);\r
+ } else {\r
+ flash._unload(s.id);\r
+ }\r
+ } else {\r
+ stop_html5_timer();\r
+ if (s._a) {\r
+ s._a.pause();\r
+ html5Unload(s._a, emptyURL);\r
+ lastURL = emptyURL;\r
+ }\r
+ }\r
+ resetProperties();\r
+ }\r
+ return s;\r
+ };\r
+ this.destruct = function(_bFromSM) {\r
+ if (!s.isHTML5) {\r
+ s._iO.onfailure = null;\r
+ flash._destroySound(s.id);\r
+ } else {\r
+ stop_html5_timer();\r
+ if (s._a) {\r
+ s._a.pause();\r
+ html5Unload(s._a);\r
+ if (!useGlobalHTML5Audio) {\r
+ remove_html5_events();\r
+ }\r
+ s._a._s = null;\r
+ s._a = null;\r
+ }\r
+ }\r
+ if (!_bFromSM) {\r
+ sm2.destroySound(s.id, true);\r
+ }\r
+ };\r
+ this.play = function(oOptions, _updatePlayState) {\r
+ var fN, allowMulti, a, onready, startOK = true,\r
+ exit = null;\r
+ _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState);\r
+ if (!oOptions) {\r
+ oOptions = {};\r
+ }\r
+ if (s.url) {\r
+ s._iO.url = s.url;\r
+ }\r
+ s._iO = mixin(s._iO, s.options);\r
+ s._iO = mixin(oOptions, s._iO);\r
+ s._iO.url = parseURL(s._iO.url);\r
+ s.instanceOptions = s._iO;\r
+ if (s._iO.serverURL && !s.connected) {\r
+ if (!s.getAutoPlay()) {\r
+ s.setAutoPlay(true);\r
+ }\r
+ return s;\r
+ }\r
+ if (html5OK(s._iO)) {\r
+ s._setup_html5(s._iO);\r
+ start_html5_timer();\r
+ }\r
+ if (s.playState === 1 && !s.paused) {\r
+ allowMulti = s._iO.multiShot;\r
+ if (!allowMulti) {\r
+ exit = s;\r
+ } else {\r
+ }\r
+ }\r
+ if (exit !== null) {\r
+ return exit;\r
+ }\r
+ if (oOptions.url && oOptions.url !== s.url) {\r
+ s.load(s._iO);\r
+ }\r
+ if (!s.loaded) {\r
+ if (s.readyState === 0) {\r
+ if (!s.isHTML5) {\r
+ s._iO.autoPlay = true;\r
+ s.load(s._iO);\r
+ } else {\r
+ s.load(s._iO);\r
+ }\r
+ s.instanceOptions = s._iO;\r
+ } else if (s.readyState === 2) {\r
+ exit = s;\r
+ } else {\r
+ }\r
+ } else {\r
+ }\r
+ if (exit !== null) {\r
+ return exit;\r
+ }\r
+ if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) {\r
+ oOptions.position = 0;\r
+ }\r
+ if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position > 0)) {\r
+ s.resume();\r
+ } else {\r
+ s._iO = mixin(oOptions, s._iO);\r
+ if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {\r
+ onready = function() {\r
+ s._iO = mixin(oOptions, s._iO);\r
+ s.play(s._iO);\r
+ };\r
+ if (s.isHTML5 && !s._html5_canplay) {\r
+ s.load({\r
+ oncanplay: onready\r
+ });\r
+ exit = false;\r
+ } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) {\r
+ s.load({\r
+ onload: onready\r
+ });\r
+ exit = false;\r
+ }\r
+ if (exit !== null) {\r
+ return exit;\r
+ }\r
+ s._iO = applyFromTo();\r
+ }\r
+ if (!s.instanceCount || s._iO.multiShotEvents || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) {\r
+ s.instanceCount++;\r
+ }\r
+ if (s._iO.onposition && s.playState === 0) {\r
+ attachOnPosition(s);\r
+ }\r
+ s.playState = 1;\r
+ s.paused = false;\r
+ s.position = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position : 0);\r
+ if (!s.isHTML5) {\r
+ s._iO = policyFix(loopFix(s._iO));\r
+ }\r
+ if (s._iO.onplay && _updatePlayState) {\r
+ s._iO.onplay.apply(s);\r
+ onplay_called = true;\r
+ }\r
+ s.setVolume(s._iO.volume, true);\r
+ s.setPan(s._iO.pan, true);\r
+ if (!s.isHTML5) {\r
+ startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / 1000), s._iO.multiShot || false);\r
+ if (fV === 9 && !startOK) {\r
+ if (s._iO.onplayerror) {\r
+ s._iO.onplayerror.apply(s);\r
+ }\r
+ }\r
+ } else {\r
+ start_html5_timer();\r
+ a = s._setup_html5();\r
+ s.setPosition(s._iO.position);\r
+ a.play();\r
+ }\r
+ }\r
+ return s;\r
+ };\r
+ this.start = this.play;\r
+ this.stop = function(bAll) {\r
+ var instanceOptions = s._iO,\r
+ originalPosition;\r
+ if (s.playState === 1) {\r
+ s._onbufferchange(0);\r
+ s._resetOnPosition(0);\r
+ s.paused = false;\r
+ if (!s.isHTML5) {\r
+ s.playState = 0;\r
+ }\r
+ detachOnPosition();\r
+ if (instanceOptions.to) {\r
+ s.clearOnPosition(instanceOptions.to);\r
+ }\r
+ if (!s.isHTML5) {\r
+ flash._stop(s.id, bAll);\r
+ if (instanceOptions.serverURL) {\r
+ s.unload();\r
+ }\r
+ } else {\r
+ if (s._a) {\r
+ originalPosition = s.position;\r
+ s.setPosition(0);\r
+ s.position = originalPosition;\r
+ s._a.pause();\r
+ s.playState = 0;\r
+ s._onTimer();\r
+ stop_html5_timer();\r
+ }\r
+ }\r
+ s.instanceCount = 0;\r
+ s._iO = {};\r
+ if (instanceOptions.onstop) {\r
+ instanceOptions.onstop.apply(s);\r
+ }\r
+ }\r
+ return s;\r
+ };\r
+ this.setAutoPlay = function(autoPlay) {\r
+ s._iO.autoPlay = autoPlay;\r
+ if (!s.isHTML5) {\r
+ flash._setAutoPlay(s.id, autoPlay);\r
+ if (autoPlay) {\r
+ if (!s.instanceCount && s.readyState === 1) {\r
+ s.instanceCount++;\r
+ }\r
+ }\r
+ }\r
+ };\r
+ this.getAutoPlay = function() {\r
+ return s._iO.autoPlay;\r
+ };\r
+ this.setPosition = function(nMsecOffset) {\r
+ if (nMsecOffset === _undefined) {\r
+ nMsecOffset = 0;\r
+ }\r
+ var original_pos,\r
+ position, position1K,\r
+ offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0)));\r
+ original_pos = s.position;\r
+ s.position = offset;\r
+ position1K = s.position/1000;\r
+ s._resetOnPosition(s.position);\r
+ s._iO.position = offset;\r
+ if (!s.isHTML5) {\r
+ position = (fV === 9 ? s.position : position1K);\r
+ if (s.readyState && s.readyState !== 2) {\r
+ flash._setPosition(s.id, position, (s.paused || !s.playState), s._iO.multiShot);\r
+ }\r
+ } else if (s._a) {\r
+ if (s._html5_canplay) {\r
+ if (s._a.currentTime !== position1K) {\r
+ try {\r
+ s._a.currentTime = position1K;\r
+ if (s.playState === 0 || s.paused) {\r
+ s._a.pause();\r
+ }\r
+ } catch(e) {\r
+ }\r
+ }\r
+ } else {\r
+ }\r
+ }\r
+ if (s.isHTML5) {\r
+ if (s.paused) {\r
+ s._onTimer(true);\r
+ }\r
+ }\r
+ return s;\r
+ };\r
+ this.pause = function(_bCallFlash) {\r
+ if (s.paused || (s.playState === 0 && s.readyState !== 1)) {\r
+ return s;\r
+ }\r
+ s.paused = true;\r
+ if (!s.isHTML5) {\r
+ if (_bCallFlash || _bCallFlash === _undefined) {\r
+ flash._pause(s.id, s._iO.multiShot);\r
+ }\r
+ } else {\r
+ s._setup_html5().pause();\r
+ stop_html5_timer();\r
+ }\r
+ if (s._iO.onpause) {\r
+ s._iO.onpause.apply(s);\r
+ }\r
+ return s;\r
+ };\r
+ this.resume = function() {\r
+ var instanceOptions = s._iO;\r
+ if (!s.paused) {\r
+ return s;\r
+ }\r
+ s.paused = false;\r
+ s.playState = 1;\r
+ if (!s.isHTML5) {\r
+ if (instanceOptions.isMovieStar && !instanceOptions.serverURL) {\r
+ s.setPosition(s.position);\r
+ }\r
+ flash._pause(s.id, instanceOptions.multiShot);\r
+ } else {\r
+ s._setup_html5().play();\r
+ start_html5_timer();\r
+ }\r
+ if (!onplay_called && instanceOptions.onplay) {\r
+ instanceOptions.onplay.apply(s);\r
+ onplay_called = true;\r
+ } else if (instanceOptions.onresume) {\r
+ instanceOptions.onresume.apply(s);\r
+ }\r
+ return s;\r
+ };\r
+ this.togglePause = function() {\r
+ if (s.playState === 0) {\r
+ s.play({\r
+ position: (fV === 9 && !s.isHTML5 ? s.position : s.position / 1000)\r
+ });\r
+ return s;\r
+ }\r
+ if (s.paused) {\r
+ s.resume();\r
+ } else {\r
+ s.pause();\r
+ }\r
+ return s;\r
+ };\r
+ this.setPan = function(nPan, bInstanceOnly) {\r
+ if (nPan === _undefined) {\r
+ nPan = 0;\r
+ }\r
+ if (bInstanceOnly === _undefined) {\r
+ bInstanceOnly = false;\r
+ }\r
+ if (!s.isHTML5) {\r
+ flash._setPan(s.id, nPan);\r
+ }\r
+ s._iO.pan = nPan;\r
+ if (!bInstanceOnly) {\r
+ s.pan = nPan;\r
+ s.options.pan = nPan;\r
+ }\r
+ return s;\r
+ };\r
+ this.setVolume = function(nVol, _bInstanceOnly) {\r
+ if (nVol === _undefined) {\r
+ nVol = 100;\r
+ }\r
+ if (_bInstanceOnly === _undefined) {\r
+ _bInstanceOnly = false;\r
+ }\r
+ if (!s.isHTML5) {\r
+ flash._setVolume(s.id, (sm2.muted && !s.muted) || s.muted?0:nVol);\r
+ } else if (s._a) {\r
+ s._a.volume = Math.max(0, Math.min(1, nVol/100));\r
+ }\r
+ s._iO.volume = nVol;\r
+ if (!_bInstanceOnly) {\r
+ s.volume = nVol;\r
+ s.options.volume = nVol;\r
+ }\r
+ return s;\r
+ };\r
+ this.mute = function() {\r
+ s.muted = true;\r
+ if (!s.isHTML5) {\r
+ flash._setVolume(s.id, 0);\r
+ } else if (s._a) {\r
+ s._a.muted = true;\r
+ }\r
+ return s;\r
+ };\r
+ this.unmute = function() {\r
+ s.muted = false;\r
+ var hasIO = (s._iO.volume !== _undefined);\r
+ if (!s.isHTML5) {\r
+ flash._setVolume(s.id, hasIO?s._iO.volume:s.options.volume);\r
+ } else if (s._a) {\r
+ s._a.muted = false;\r
+ }\r
+ return s;\r
+ };\r
+ this.toggleMute = function() {\r
+ return (s.muted?s.unmute():s.mute());\r
+ };\r
+ this.onPosition = function(nPosition, oMethod, oScope) {\r
+ onPositionItems.push({\r
+ position: parseInt(nPosition, 10),\r
+ method: oMethod,\r
+ scope: (oScope !== _undefined ? oScope : s),\r
+ fired: false\r
+ });\r
+ return s;\r
+ };\r
+ this.onposition = this.onPosition;\r
+ this.clearOnPosition = function(nPosition, oMethod) {\r
+ var i;\r
+ nPosition = parseInt(nPosition, 10);\r
+ if (isNaN(nPosition)) {\r
+ return false;\r
+ }\r
+ for (i=0; i < onPositionItems.length; i++) {\r
+ if (nPosition === onPositionItems[i].position) {\r
+ if (!oMethod || (oMethod === onPositionItems[i].method)) {\r
+ if (onPositionItems[i].fired) {\r
+ onPositionFired--;\r
+ }\r
+ onPositionItems.splice(i, 1);\r
+ }\r
+ }\r
+ }\r
+ };\r
+ this._processOnPosition = function() {\r
+ var i, item, j = onPositionItems.length;\r
+ if (!j || !s.playState || onPositionFired >= j) {\r
+ return false;\r
+ }\r
+ for (i=j-1; i >= 0; i--) {\r
+ item = onPositionItems[i];\r
+ if (!item.fired && s.position >= item.position) {\r
+ item.fired = true;\r
+ onPositionFired++;\r
+ item.method.apply(item.scope, [item.position]);\r
+ }\r
+ }\r
+ return true;\r
+ };\r
+ this._resetOnPosition = function(nPosition) {\r
+ var i, item, j = onPositionItems.length;\r
+ if (!j) {\r
+ return false;\r
+ }\r
+ for (i=j-1; i >= 0; i--) {\r
+ item = onPositionItems[i];\r
+ if (item.fired && nPosition <= item.position) {\r
+ item.fired = false;\r
+ onPositionFired--;\r
+ }\r
+ }\r
+ return true;\r
+ };\r
+ applyFromTo = function() {\r
+ var instanceOptions = s._iO,\r
+ f = instanceOptions.from,\r
+ t = instanceOptions.to,\r
+ start, end;\r
+ end = function() {\r
+ s.clearOnPosition(t, end);\r
+ s.stop();\r
+ };\r
+ start = function() {\r
+ if (t !== null && !isNaN(t)) {\r
+ s.onPosition(t, end);\r
+ }\r
+ };\r
+ if (f !== null && !isNaN(f)) {\r
+ instanceOptions.position = f;\r
+ instanceOptions.multiShot = false;\r
+ start();\r
+ }\r
+ return instanceOptions;\r
+ };\r
+ attachOnPosition = function() {\r
+ var item,\r
+ op = s._iO.onposition;\r
+ if (op) {\r
+ for (item in op) {\r
+ if (op.hasOwnProperty(item)) {\r
+ s.onPosition(parseInt(item, 10), op[item]);\r
+ }\r
+ }\r
+ }\r
+ };\r
+ detachOnPosition = function() {\r
+ var item,\r
+ op = s._iO.onposition;\r
+ if (op) {\r
+ for (item in op) {\r
+ if (op.hasOwnProperty(item)) {\r
+ s.clearOnPosition(parseInt(item, 10));\r
+ }\r
+ }\r
+ }\r
+ };\r
+ start_html5_timer = function() {\r
+ if (s.isHTML5) {\r
+ startTimer(s);\r
+ }\r
+ };\r
+ stop_html5_timer = function() {\r
+ if (s.isHTML5) {\r
+ stopTimer(s);\r
+ }\r
+ };\r
+ resetProperties = function(retainPosition) {\r
+ if (!retainPosition) {\r
+ onPositionItems = [];\r
+ onPositionFired = 0;\r
+ }\r
+ onplay_called = false;\r
+ s._hasTimer = null;\r
+ s._a = null;\r
+ s._html5_canplay = false;\r
+ s.bytesLoaded = null;\r
+ s.bytesTotal = null;\r
+ s.duration = (s._iO && s._iO.duration ? s._iO.duration : null);\r
+ s.durationEstimate = null;\r
+ s.buffered = [];\r
+ s.eqData = [];\r
+ s.eqData.left = [];\r
+ s.eqData.right = [];\r
+ s.failures = 0;\r
+ s.isBuffering = false;\r
+ s.instanceOptions = {};\r
+ s.instanceCount = 0;\r
+ s.loaded = false;\r
+ s.metadata = {};\r
+ s.readyState = 0;\r
+ s.muted = false;\r
+ s.paused = false;\r
+ s.peakData = {\r
+ left: 0,\r
+ right: 0\r
+ };\r
+ s.waveformData = {\r
+ left: [],\r
+ right: []\r
+ };\r
+ s.playState = 0;\r
+ s.position = null;\r
+ s.id3 = {};\r
+ };\r
+ resetProperties();\r
+ this._onTimer = function(bForce) {\r
+ var duration, isNew = false, time, x = {};\r
+ if (s._hasTimer || bForce) {\r
+ if (s._a && (bForce || ((s.playState > 0 || s.readyState === 1) && !s.paused))) {\r
+ duration = s._get_html5_duration();\r
+ if (duration !== lastHTML5State.duration) {\r
+ lastHTML5State.duration = duration;\r
+ s.duration = duration;\r
+ isNew = true;\r
+ }\r
+ s.durationEstimate = s.duration;\r
+ time = (s._a.currentTime * 1000 || 0);\r
+ if (time !== lastHTML5State.time) {\r
+ lastHTML5State.time = time;\r
+ isNew = true;\r
+ }\r
+ if (isNew || bForce) {\r
+ s._whileplaying(time,x,x,x,x);\r
+ }\r
+ }\r
+ return isNew;\r
+ }\r
+ };\r
+ this._get_html5_duration = function() {\r
+ var instanceOptions = s._iO,\r
+ d = (s._a && s._a.duration ? s._a.duration*1000 : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)),\r
+ result = (d && !isNaN(d) && d !== Infinity ? d : null);\r
+ return result;\r
+ };\r
+ this._apply_loop = function(a, nLoops) {\r
+ a.loop = (nLoops > 1 ? 'loop' : '');\r
+ };\r
+ this._setup_html5 = function(oOptions) {\r
+ var instanceOptions = mixin(s._iO, oOptions),\r
+ a = useGlobalHTML5Audio ? globalHTML5Audio : s._a,\r
+ dURL = decodeURI(instanceOptions.url),\r
+ sameURL;\r
+ if (useGlobalHTML5Audio) {\r
+ if (dURL === decodeURI(lastGlobalHTML5URL)) {\r
+ sameURL = true;\r
+ }\r
+ } else if (dURL === decodeURI(lastURL)) {\r
+ sameURL = true;\r
+ }\r
+ if (a) {\r
+ if (a._s) {\r
+ if (useGlobalHTML5Audio) {\r
+ if (a._s && a._s.playState && !sameURL) {\r
+ a._s.stop();\r
+ }\r
+ } else if (!useGlobalHTML5Audio && dURL === decodeURI(lastURL)) {\r
+ s._apply_loop(a, instanceOptions.loops);\r
+ return a;\r
+ }\r
+ }\r
+ if (!sameURL) {\r
+ resetProperties(false);\r
+ a.src = instanceOptions.url;\r
+ s.url = instanceOptions.url;\r
+ lastURL = instanceOptions.url;\r
+ lastGlobalHTML5URL = instanceOptions.url;\r
+ a._called_load = false;\r
+ }\r
+ } else {\r
+ if (instanceOptions.autoLoad || instanceOptions.autoPlay) {\r
+ s._a = new Audio(instanceOptions.url);\r
+ } else {\r
+ s._a = (isOpera && opera.version() < 10 ? new Audio(null) : new Audio());\r
+ }\r
+ a = s._a;\r
+ a._called_load = false;\r
+ if (useGlobalHTML5Audio) {\r
+ globalHTML5Audio = a;\r
+ }\r
+ }\r
+ s.isHTML5 = true;\r
+ s._a = a;\r
+ a._s = s;\r
+ add_html5_events();\r
+ s._apply_loop(a, instanceOptions.loops);\r
+ if (instanceOptions.autoLoad || instanceOptions.autoPlay) {\r
+ s.load();\r
+ } else {\r
+ a.autobuffer = false;\r
+ a.preload = 'auto';\r
+ }\r
+ return a;\r
+ };\r
+ add_html5_events = function() {\r
+ if (s._a._added_events) {\r
+ return false;\r
+ }\r
+ var f;\r
+ function add(oEvt, oFn, bCapture) {\r
+ return s._a ? s._a.addEventListener(oEvt, oFn, bCapture||false) : null;\r
+ }\r
+ s._a._added_events = true;\r
+ for (f in html5_events) {\r
+ if (html5_events.hasOwnProperty(f)) {\r
+ add(f, html5_events[f]);\r
+ }\r
+ }\r
+ return true;\r
+ };\r
+ remove_html5_events = function() {\r
+ var f;\r
+ function remove(oEvt, oFn, bCapture) {\r
+ return (s._a ? s._a.removeEventListener(oEvt, oFn, bCapture||false) : null);\r
+ }\r
+ s._a._added_events = false;\r
+ for (f in html5_events) {\r
+ if (html5_events.hasOwnProperty(f)) {\r
+ remove(f, html5_events[f]);\r
+ }\r
+ }\r
+ };\r
+ this._onload = function(nSuccess) {\r
+ var fN,\r
+ loadOK = !!nSuccess || (!s.isHTML5 && fV === 8 && s.duration);\r
+ s.loaded = loadOK;\r
+ s.readyState = loadOK?3:2;\r
+ s._onbufferchange(0);\r
+ if (s._iO.onload) {\r
+ wrapCallback(s, function() {\r
+ s._iO.onload.apply(s, [loadOK]);\r
+ });\r
+ }\r
+ return true;\r
+ };\r
+ this._onbufferchange = function(nIsBuffering) {\r
+ if (s.playState === 0) {\r
+ return false;\r
+ }\r
+ if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) {\r
+ return false;\r
+ }\r
+ s.isBuffering = (nIsBuffering === 1);\r
+ if (s._iO.onbufferchange) {\r
+ s._iO.onbufferchange.apply(s);\r
+ }\r
+ return true;\r
+ };\r
+ this._onsuspend = function() {\r
+ if (s._iO.onsuspend) {\r
+ s._iO.onsuspend.apply(s);\r
+ }\r
+ return true;\r
+ };\r
+ this._onfailure = function(msg, level, code) {\r
+ s.failures++;\r
+ if (s._iO.onfailure && s.failures === 1) {\r
+ s._iO.onfailure(s, msg, level, code);\r
+ } else {\r
+ }\r
+ };\r
+ this._onfinish = function() {\r
+ var io_onfinish = s._iO.onfinish;\r
+ s._onbufferchange(0);\r
+ s._resetOnPosition(0);\r
+ if (s.instanceCount) {\r
+ s.instanceCount--;\r
+ if (!s.instanceCount) {\r
+ detachOnPosition();\r
+ s.playState = 0;\r
+ s.paused = false;\r
+ s.instanceCount = 0;\r
+ s.instanceOptions = {};\r
+ s._iO = {};\r
+ stop_html5_timer();\r
+ if (s.isHTML5) {\r
+ s.position = 0;\r
+ }\r
+ }\r
+ if (!s.instanceCount || s._iO.multiShotEvents) {\r
+ if (io_onfinish) {\r
+ wrapCallback(s, function() {\r
+ io_onfinish.apply(s);\r
+ });\r
+ }\r
+ }\r
+ }\r
+ };\r
+ this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) {\r
+ var instanceOptions = s._iO;\r
+ s.bytesLoaded = nBytesLoaded;\r
+ s.bytesTotal = nBytesTotal;\r
+ s.duration = Math.floor(nDuration);\r
+ s.bufferLength = nBufferLength;\r
+ if (!s.isHTML5 && !instanceOptions.isMovieStar) {\r
+ if (instanceOptions.duration) {\r
+ s.durationEstimate = (s.duration > instanceOptions.duration) ? s.duration : instanceOptions.duration;\r
+ } else {\r
+ s.durationEstimate = parseInt((s.bytesTotal / s.bytesLoaded) * s.duration, 10);\r
+ }\r
+ } else {\r
+ s.durationEstimate = s.duration;\r
+ }\r
+ if (!s.isHTML5) {\r
+ s.buffered = [{\r
+ 'start': 0,\r
+ 'end': s.duration\r
+ }];\r
+ }\r
+ if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) {\r
+ instanceOptions.whileloading.apply(s);\r
+ }\r
+ };\r
+ this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {\r
+ var instanceOptions = s._iO,\r
+ eqLeft;\r
+ if (isNaN(nPosition) || nPosition === null) {\r
+ return false;\r
+ }\r
+ s.position = Math.max(0, nPosition);\r
+ s._processOnPosition();\r
+ if (!s.isHTML5 && fV > 8) {\r
+ if (instanceOptions.usePeakData && oPeakData !== _undefined && oPeakData) {\r
+ s.peakData = {\r
+ left: oPeakData.leftPeak,\r
+ right: oPeakData.rightPeak\r
+ };\r
+ }\r
+ if (instanceOptions.useWaveformData && oWaveformDataLeft !== _undefined && oWaveformDataLeft) {\r
+ s.waveformData = {\r
+ left: oWaveformDataLeft.split(','),\r
+ right: oWaveformDataRight.split(',')\r
+ };\r
+ }\r
+ if (instanceOptions.useEQData) {\r
+ if (oEQData !== _undefined && oEQData && oEQData.leftEQ) {\r
+ eqLeft = oEQData.leftEQ.split(',');\r
+ s.eqData = eqLeft;\r
+ s.eqData.left = eqLeft;\r
+ if (oEQData.rightEQ !== _undefined && oEQData.rightEQ) {\r
+ s.eqData.right = oEQData.rightEQ.split(',');\r
+ }\r
+ }\r
+ }\r
+ }\r
+ if (s.playState === 1) {\r
+ if (!s.isHTML5 && fV === 8 && !s.position && s.isBuffering) {\r
+ s._onbufferchange(0);\r
+ }\r
+ if (instanceOptions.whileplaying) {\r
+ instanceOptions.whileplaying.apply(s);\r
+ }\r
+ }\r
+ return true;\r
+ };\r
+ this._oncaptiondata = function(oData) {\r
+ s.captiondata = oData;\r
+ if (s._iO.oncaptiondata) {\r
+ s._iO.oncaptiondata.apply(s, [oData]);\r
+ }\r
+ };\r
+ this._onmetadata = function(oMDProps, oMDData) {\r
+ var oData = {}, i, j;\r
+ for (i = 0, j = oMDProps.length; i < j; i++) {\r
+ oData[oMDProps[i]] = oMDData[i];\r
+ }\r
+ s.metadata = oData;\r
+ if (s._iO.onmetadata) {\r
+ s._iO.onmetadata.apply(s);\r
+ }\r
+ };\r
+ this._onid3 = function(oID3Props, oID3Data) {\r
+ var oData = [], i, j;\r
+ for (i = 0, j = oID3Props.length; i < j; i++) {\r
+ oData[oID3Props[i]] = oID3Data[i];\r
+ }\r
+ s.id3 = mixin(s.id3, oData);\r
+ if (s._iO.onid3) {\r
+ s._iO.onid3.apply(s);\r
+ }\r
+ };\r
+ this._onconnect = function(bSuccess) {\r
+ bSuccess = (bSuccess === 1);\r
+ s.connected = bSuccess;\r
+ if (bSuccess) {\r
+ s.failures = 0;\r
+ if (idCheck(s.id)) {\r
+ if (s.getAutoPlay()) {\r
+ s.play(_undefined, s.getAutoPlay());\r
+ } else if (s._iO.autoLoad) {\r
+ s.load();\r
+ }\r
+ }\r
+ if (s._iO.onconnect) {\r
+ s._iO.onconnect.apply(s, [bSuccess]);\r
+ }\r
+ }\r
+ };\r
+ this._ondataerror = function(sError) {\r
+ if (s.playState > 0) {\r
+ if (s._iO.ondataerror) {\r
+ s._iO.ondataerror.apply(s);\r
+ }\r
+ }\r
+ };\r
+ };\r
+ getDocument = function() {\r
+ return (doc.body || doc._docElement || doc.getElementsByTagName('div')[0]);\r
+ };\r
+ id = function(sID) {\r
+ return doc.getElementById(sID);\r
+ };\r
+ mixin = function(oMain, oAdd) {\r
+ var o1 = (oMain || {}), o2, o;\r
+ o2 = (oAdd === _undefined ? sm2.defaultOptions : oAdd);\r
+ for (o in o2) {\r
+ if (o2.hasOwnProperty(o) && o1[o] === _undefined) {\r
+ if (typeof o2[o] !== 'object' || o2[o] === null) {\r
+ o1[o] = o2[o];\r
+ } else {\r
+ o1[o] = mixin(o1[o], o2[o]);\r
+ }\r
+ }\r
+ }\r
+ return o1;\r
+ };\r
+ wrapCallback = function(oSound, callback) {\r
+ if (!oSound.isHTML5 && fV === 8) {\r
+ window.setTimeout(callback, 0);\r
+ } else {\r
+ callback();\r
+ }\r
+ };\r
+ extraOptions = {\r
+ 'onready': 1,\r
+ 'ontimeout': 1,\r
+ 'defaultOptions': 1,\r
+ 'flash9Options': 1,\r
+ 'movieStarOptions': 1\r
+ };\r
+ assign = function(o, oParent) {\r
+ var i,\r
+ result = true,\r
+ hasParent = (oParent !== _undefined),\r
+ setupOptions = sm2.setupOptions,\r
+ bonusOptions = extraOptions;\r
+ for (i in o) {\r
+ if (o.hasOwnProperty(i)) {\r
+ if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array || o[i] instanceof RegExp) {\r
+ if (hasParent && bonusOptions[oParent] !== _undefined) {\r
+ sm2[oParent][i] = o[i];\r
+ } else if (setupOptions[i] !== _undefined) {\r
+ sm2.setupOptions[i] = o[i];\r
+ sm2[i] = o[i];\r
+ } else if (bonusOptions[i] === _undefined) {\r
+ complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);\r
+ result = false;\r
+ } else {\r
+ if (sm2[i] instanceof Function) {\r
+ sm2[i].apply(sm2, (o[i] instanceof Array? o[i] : [o[i]]));\r
+ } else {\r
+ sm2[i] = o[i];\r
+ }\r
+ }\r
+ } else {\r
+ if (bonusOptions[i] === _undefined) {\r
+ complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);\r
+ result = false;\r
+ } else {\r
+ return assign(o[i], i);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return result;\r
+ };\r
+ function preferFlashCheck(kind) {\r
+ return (sm2.preferFlash && hasFlash && !sm2.ignoreFlash && (sm2.flash[kind] !== _undefined && sm2.flash[kind]));\r
+ }\r
+ event = (function() {\r
+ var old = (window.attachEvent),\r
+ evt = {\r
+ add: (old?'attachEvent':'addEventListener'),\r
+ remove: (old?'detachEvent':'removeEventListener')\r
+ };\r
+ function getArgs(oArgs) {\r
+ var args = slice.call(oArgs),\r
+ len = args.length;\r
+ if (old) {\r
+ args[1] = 'on' + args[1];\r
+ if (len > 3) {\r
+ args.pop();\r
+ }\r
+ } else if (len === 3) {\r
+ args.push(false);\r
+ }\r
+ return args;\r
+ }\r
+ function apply(args, sType) {\r
+ var element = args.shift(),\r
+ method = [evt[sType]];\r
+ if (old) {\r
+ element[method](args[0], args[1]);\r
+ } else {\r
+ element[method].apply(element, args);\r
+ }\r
+ }\r
+ function add() {\r
+ apply(getArgs(arguments), 'add');\r
+ }\r
+ function remove() {\r
+ apply(getArgs(arguments), 'remove');\r
+ }\r
+ return {\r
+ 'add': add,\r
+ 'remove': remove\r
+ };\r
+ }());\r
+ function html5_event(oFn) {\r
+ return function(e) {\r
+ var s = this._s,\r
+ result;\r
+ if (!s || !s._a) {\r
+ result = null;\r
+ } else {\r
+ result = oFn.call(this, e);\r
+ }\r
+ return result;\r
+ };\r
+ }\r
+ html5_events = {\r
+ abort: html5_event(function() {\r
+ }),\r
+ canplay: html5_event(function() {\r
+ var s = this._s,\r
+ position1K;\r
+ if (s._html5_canplay) {\r
+ return true;\r
+ }\r
+ s._html5_canplay = true;\r
+ s._onbufferchange(0);\r
+ position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/1000:null);\r
+ if (s.position && this.currentTime !== position1K) {\r
+ try {\r
+ this.currentTime = position1K;\r
+ } catch(ee) {\r
+ }\r
+ }\r
+ if (s._iO._oncanplay) {\r
+ s._iO._oncanplay();\r
+ }\r
+ }),\r
+ canplaythrough: html5_event(function() {\r
+ var s = this._s;\r
+ if (!s.loaded) {\r
+ s._onbufferchange(0);\r
+ s._whileloading(s.bytesLoaded, s.bytesTotal, s._get_html5_duration());\r
+ s._onload(true);\r
+ }\r
+ }),\r
+ ended: html5_event(function() {\r
+ var s = this._s;\r
+ s._onfinish();\r
+ }),\r
+ error: html5_event(function() {\r
+ this._s._onload(false);\r
+ }),\r
+ loadeddata: html5_event(function() {\r
+ var s = this._s;\r
+ if (!s._loaded && !isSafari) {\r
+ s.duration = s._get_html5_duration();\r
+ }\r
+ }),\r
+ loadedmetadata: html5_event(function() {\r
+ }),\r
+ loadstart: html5_event(function() {\r
+ this._s._onbufferchange(1);\r
+ }),\r
+ play: html5_event(function() {\r
+ this._s._onbufferchange(0);\r
+ }),\r
+ playing: html5_event(function() {\r
+ this._s._onbufferchange(0);\r
+ }),\r
+ progress: html5_event(function(e) {\r
+ var s = this._s,\r
+ i, j, str, buffered = 0,\r
+ isProgress = (e.type === 'progress'),\r
+ ranges = e.target.buffered,\r
+ loaded = (e.loaded||0),\r
+ total = (e.total||1),\r
+ scale = 1000;\r
+ s.buffered = [];\r
+ if (ranges && ranges.length) {\r
+ for (i=0, j=ranges.length; i<j; i++) {\r
+ s.buffered.push({\r
+ 'start': ranges.start(i) * scale,\r
+ 'end': ranges.end(i) * scale\r
+ });\r
+ }\r
+ buffered = (ranges.end(0) - ranges.start(0)) * scale;\r
+ loaded = buffered/(e.target.duration*scale);\r
+ }\r
+ if (!isNaN(loaded)) {\r
+ s._onbufferchange(0);\r
+ s._whileloading(loaded, total, s._get_html5_duration());\r
+ if (loaded && total && loaded === total) {\r
+ html5_events.canplaythrough.call(this, e);\r
+ }\r
+ }\r
+ }),\r
+ ratechange: html5_event(function() {\r
+ }),\r
+ suspend: html5_event(function(e) {\r
+ var s = this._s;\r
+ html5_events.progress.call(this, e);\r
+ s._onsuspend();\r
+ }),\r
+ stalled: html5_event(function() {\r
+ }),\r
+ timeupdate: html5_event(function() {\r
+ this._s._onTimer();\r
+ }),\r
+ waiting: html5_event(function() {\r
+ var s = this._s;\r
+ s._onbufferchange(1);\r
+ })\r
+ };\r
+ html5OK = function(iO) {\r
+ var result;\r
+ if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {\r
+ result = false;\r
+ } else {\r
+ result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only));\r
+ }\r
+ return result;\r
+ };\r
+ html5Unload = function(oAudio, url) {\r
+ if (oAudio) {\r
+ oAudio.src = url;\r
+ oAudio._called_load = false;\r
+ }\r
+ if (useGlobalHTML5Audio) {\r
+ lastGlobalHTML5URL = null;\r
+ }\r
+ };\r
+ html5CanPlay = function(o) {\r
+ if (!sm2.useHTML5Audio || !sm2.hasHTML5) {\r
+ return false;\r
+ }\r
+ var url = (o.url || null),\r
+ mime = (o.type || null),\r
+ aF = sm2.audioFormats,\r
+ result,\r
+ offset,\r
+ fileExt,\r
+ item;\r
+ if (mime && sm2.html5[mime] !== _undefined) {\r
+ return (sm2.html5[mime] && !preferFlashCheck(mime));\r
+ }\r
+ if (!html5Ext) {\r
+ html5Ext = [];\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ html5Ext.push(item);\r
+ if (aF[item].related) {\r
+ html5Ext = html5Ext.concat(aF[item].related);\r
+ }\r
+ }\r
+ }\r
+ html5Ext = new RegExp('\\.('+html5Ext.join('|')+')(\\?.*)?$','i');\r
+ }\r
+ fileExt = (url ? url.toLowerCase().match(html5Ext) : null);\r
+ if (!fileExt || !fileExt.length) {\r
+ if (!mime) {\r
+ result = false;\r
+ } else {\r
+ offset = mime.indexOf(';');\r
+ fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6);\r
+ }\r
+ } else {\r
+ fileExt = fileExt[1];\r
+ }\r
+ if (fileExt && sm2.html5[fileExt] !== _undefined) {\r
+ result = (sm2.html5[fileExt] && !preferFlashCheck(fileExt));\r
+ } else {\r
+ mime = 'audio/'+fileExt;\r
+ result = sm2.html5.canPlayType({type:mime});\r
+ sm2.html5[fileExt] = result;\r
+ result = (result && sm2.html5[mime] && !preferFlashCheck(mime));\r
+ }\r
+ return result;\r
+ };\r
+ testHTML5 = function() {\r
+ if (!sm2.useHTML5Audio || !sm2.hasHTML5) {\r
+ return false;\r
+ }\r
+ var a = (Audio !== _undefined ? (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()) : null),\r
+ item, lookup, support = {}, aF, i;\r
+ function cp(m) {\r
+ var canPlay, i, j,\r
+ result = false,\r
+ isOK = false;\r
+ if (!a || typeof a.canPlayType !== 'function') {\r
+ return result;\r
+ }\r
+ if (m instanceof Array) {\r
+ for (i=0, j=m.length; i<j; i++) {\r
+ if (sm2.html5[m[i]] || a.canPlayType(m[i]).match(sm2.html5Test)) {\r
+ isOK = true;\r
+ sm2.html5[m[i]] = true;\r
+ sm2.flash[m[i]] = !!(m[i].match(flashMIME));\r
+ }\r
+ }\r
+ result = isOK;\r
+ } else {\r
+ canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);\r
+ result = !!(canPlay && (canPlay.match(sm2.html5Test)));\r
+ }\r
+ return result;\r
+ }\r
+ aF = sm2.audioFormats;\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ lookup = 'audio/' + item;\r
+ support[item] = cp(aF[item].type);\r
+ support[lookup] = support[item];\r
+ if (item.match(flashMIME)) {\r
+ sm2.flash[item] = true;\r
+ sm2.flash[lookup] = true;\r
+ } else {\r
+ sm2.flash[item] = false;\r
+ sm2.flash[lookup] = false;\r
+ }\r
+ if (aF[item] && aF[item].related) {\r
+ for (i=aF[item].related.length-1; i >= 0; i--) {\r
+ support['audio/'+aF[item].related[i]] = support[item];\r
+ sm2.html5[aF[item].related[i]] = support[item];\r
+ sm2.flash[aF[item].related[i]] = support[item];\r
+ }\r
+ }\r
+ }\r
+ }\r
+ support.canPlayType = (a?cp:null);\r
+ sm2.html5 = mixin(sm2.html5, support);\r
+ return true;\r
+ };\r
+ strings = {\r
+ };\r
+ str = function() {\r
+ };\r
+ loopFix = function(sOpt) {\r
+ if (fV === 8 && sOpt.loops > 1 && sOpt.stream) {\r
+ sOpt.stream = false;\r
+ }\r
+ return sOpt;\r
+ };\r
+ policyFix = function(sOpt, sPre) {\r
+ if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) {\r
+ sOpt.usePolicyFile = true;\r
+ }\r
+ return sOpt;\r
+ };\r
+ complain = function(sMsg) {\r
+ };\r
+ doNothing = function() {\r
+ return false;\r
+ };\r
+ disableObject = function(o) {\r
+ var oProp;\r
+ for (oProp in o) {\r
+ if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') {\r
+ o[oProp] = doNothing;\r
+ }\r
+ }\r
+ oProp = null;\r
+ };\r
+ failSafely = function(bNoDisable) {\r
+ if (bNoDisable === _undefined) {\r
+ bNoDisable = false;\r
+ }\r
+ if (disabled || bNoDisable) {\r
+ sm2.disable(bNoDisable);\r
+ }\r
+ };\r
+ normalizeMovieURL = function(smURL) {\r
+ var urlParams = null, url;\r
+ if (smURL) {\r
+ if (smURL.match(/\.swf(\?.*)?$/i)) {\r
+ urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4);\r
+ if (urlParams) {\r
+ return smURL;\r
+ }\r
+ } else if (smURL.lastIndexOf('/') !== smURL.length - 1) {\r
+ smURL += '/';\r
+ }\r
+ }\r
+ url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + sm2.movieURL;\r
+ if (sm2.noSWFCache) {\r
+ url += ('?ts=' + new Date().getTime());\r
+ }\r
+ return url;\r
+ };\r
+ setVersionInfo = function() {\r
+ fV = parseInt(sm2.flashVersion, 10);\r
+ if (fV !== 8 && fV !== 9) {\r
+ sm2.flashVersion = fV = defaultFlashVersion;\r
+ }\r
+ var isDebug = (sm2.debugMode || sm2.debugFlash?'_debug.swf':'.swf');\r
+ if (sm2.useHTML5Audio && !sm2.html5Only && sm2.audioFormats.mp4.required && fV < 9) {\r
+ sm2.flashVersion = fV = 9;\r
+ }\r
+ sm2.version = sm2.versionNumber + (sm2.html5Only?' (HTML5-only mode)':(fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)'));\r
+ if (fV > 8) {\r
+ sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.flash9Options);\r
+ sm2.features.buffering = true;\r
+ sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.movieStarOptions);\r
+ sm2.filePatterns.flash9 = new RegExp('\\.(mp3|' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
+ sm2.features.movieStar = true;\r
+ } else {\r
+ sm2.features.movieStar = false;\r
+ }\r
+ sm2.filePattern = sm2.filePatterns[(fV !== 8?'flash9':'flash8')];\r
+ sm2.movieURL = (fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug);\r
+ sm2.features.peakData = sm2.features.waveformData = sm2.features.eqData = (fV > 8);\r
+ };\r
+ setPolling = function(bPolling, bHighPerformance) {\r
+ if (!flash) {\r
+ return false;\r
+ }\r
+ flash._setPolling(bPolling, bHighPerformance);\r
+ };\r
+ initDebug = function() {\r
+ if (sm2.debugURLParam.test(wl)) {\r
+ sm2.debugMode = true;\r
+ }\r
+ };\r
+ idCheck = this.getSoundById;\r
+ getSWFCSS = function() {\r
+ var css = [];\r
+ if (sm2.debugMode) {\r
+ css.push(swfCSS.sm2Debug);\r
+ }\r
+ if (sm2.debugFlash) {\r
+ css.push(swfCSS.flashDebug);\r
+ }\r
+ if (sm2.useHighPerformance) {\r
+ css.push(swfCSS.highPerf);\r
+ }\r
+ return css.join(' ');\r
+ };\r
+ flashBlockHandler = function() {\r
+ var name = str('fbHandler'),\r
+ p = sm2.getMoviePercent(),\r
+ css = swfCSS,\r
+ error = {type:'FLASHBLOCK'};\r
+ if (sm2.html5Only) {\r
+ return false;\r
+ }\r
+ if (!sm2.ok()) {\r
+ if (needsFlash) {\r
+ sm2.oMC.className = getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);\r
+ }\r
+ sm2.didFlashBlock = true;\r
+ processOnEvents({type:'ontimeout', ignoreInit:true, error:error});\r
+ catchError(error);\r
+ } else {\r
+ if (sm2.oMC) {\r
+ sm2.oMC.className = [getSWFCSS(), css.swfDefault, css.swfLoaded + (sm2.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');\r
+ }\r
+ }\r
+ };\r
+ addOnEvent = function(sType, oMethod, oScope) {\r
+ if (on_queue[sType] === _undefined) {\r
+ on_queue[sType] = [];\r
+ }\r
+ on_queue[sType].push({\r
+ 'method': oMethod,\r
+ 'scope': (oScope || null),\r
+ 'fired': false\r
+ });\r
+ };\r
+ processOnEvents = function(oOptions) {\r
+ if (!oOptions) {\r
+ oOptions = {\r
+ type: (sm2.ok() ? 'onready' : 'ontimeout')\r
+ };\r
+ }\r
+ if (!didInit && oOptions && !oOptions.ignoreInit) {\r
+ return false;\r
+ }\r
+ if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) {\r
+ return false;\r
+ }\r
+ var status = {\r
+ success: (oOptions && oOptions.ignoreInit?sm2.ok():!disabled)\r
+ },\r
+ srcQueue = (oOptions && oOptions.type?on_queue[oOptions.type]||[]:[]),\r
+ queue = [], i, j,\r
+ args = [status],\r
+ canRetry = (needsFlash && !sm2.ok());\r
+ if (oOptions.error) {\r
+ args[0].error = oOptions.error;\r
+ }\r
+ for (i = 0, j = srcQueue.length; i < j; i++) {\r
+ if (srcQueue[i].fired !== true) {\r
+ queue.push(srcQueue[i]);\r
+ }\r
+ }\r
+ if (queue.length) {\r
+ for (i = 0, j = queue.length; i < j; i++) {\r
+ if (queue[i].scope) {\r
+ queue[i].method.apply(queue[i].scope, args);\r
+ } else {\r
+ queue[i].method.apply(this, args);\r
+ }\r
+ if (!canRetry) {\r
+ queue[i].fired = true;\r
+ }\r
+ }\r
+ }\r
+ return true;\r
+ };\r
+ initUserOnload = function() {\r
+ window.setTimeout(function() {\r
+ if (sm2.useFlashBlock) {\r
+ flashBlockHandler();\r
+ }\r
+ processOnEvents();\r
+ if (typeof sm2.onload === 'function') {\r
+ sm2.onload.apply(window);\r
+ }\r
+ if (sm2.waitForWindowLoad) {\r
+ event.add(window, 'load', initUserOnload);\r
+ }\r
+ },1);\r
+ };\r
+ detectFlash = function() {\r
+ if (hasFlash !== _undefined) {\r
+ return hasFlash;\r
+ }\r
+ var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject;\r
+ if (nP && nP.length) {\r
+ type = 'application/x-shockwave-flash';\r
+ types = n.mimeTypes;\r
+ if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) {\r
+ hasPlugin = true;\r
+ }\r
+ } else if (AX !== _undefined && !ua.match(/MSAppHost/i)) {\r
+ try {\r
+ obj = new AX('ShockwaveFlash.ShockwaveFlash');\r
+ } catch(e) {\r
+ }\r
+ hasPlugin = (!!obj);\r
+ obj = null;\r
+ }\r
+ hasFlash = hasPlugin;\r
+ return hasPlugin;\r
+ };\r
+ featureCheck = function() {\r
+ var needsFlash,\r
+ item,\r
+ result = true,\r
+ formats = sm2.audioFormats,\r
+ isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i)));\r
+ if (isSpecial) {\r
+ sm2.hasHTML5 = false;\r
+ sm2.html5Only = true;\r
+ if (sm2.oMC) {\r
+ sm2.oMC.style.display = 'none';\r
+ }\r
+ result = false;\r
+ } else {\r
+ if (sm2.useHTML5Audio) {\r
+ if (!sm2.html5 || !sm2.html5.canPlayType) {\r
+ sm2.hasHTML5 = false;\r
+ }\r
+ }\r
+ }\r
+ if (sm2.useHTML5Audio && sm2.hasHTML5) {\r
+ for (item in formats) {\r
+ if (formats.hasOwnProperty(item)) {\r
+ if ((formats[item].required && !sm2.html5.canPlayType(formats[item].type)) || (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type]))) {\r
+ needsFlash = true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ if (sm2.ignoreFlash) {\r
+ needsFlash = false;\r
+ }\r
+ sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !needsFlash);\r
+ return (!sm2.html5Only);\r
+ };\r
+ parseURL = function(url) {\r
+ var i, j, urlResult = 0, result;\r
+ if (url instanceof Array) {\r
+ for (i=0, j=url.length; i<j; i++) {\r
+ if (url[i] instanceof Object) {\r
+ if (sm2.canPlayMIME(url[i].type)) {\r
+ urlResult = i;\r
+ break;\r
+ }\r
+ } else if (sm2.canPlayURL(url[i])) {\r
+ urlResult = i;\r
+ break;\r
+ }\r
+ }\r
+ if (url[urlResult].url) {\r
+ url[urlResult] = url[urlResult].url;\r
+ }\r
+ result = url[urlResult];\r
+ } else {\r
+ result = url;\r
+ }\r
+ return result;\r
+ };\r
+ startTimer = function(oSound) {\r
+ if (!oSound._hasTimer) {\r
+ oSound._hasTimer = true;\r
+ if (!mobileHTML5 && sm2.html5PollingInterval) {\r
+ if (h5IntervalTimer === null && h5TimerCount === 0) {\r
+ h5IntervalTimer = setInterval(timerExecute, sm2.html5PollingInterval);\r
+ }\r
+ h5TimerCount++;\r
+ }\r
+ }\r
+ };\r
+ stopTimer = function(oSound) {\r
+ if (oSound._hasTimer) {\r
+ oSound._hasTimer = false;\r
+ if (!mobileHTML5 && sm2.html5PollingInterval) {\r
+ h5TimerCount--;\r
+ }\r
+ }\r
+ };\r
+ timerExecute = function() {\r
+ var i;\r
+ if (h5IntervalTimer !== null && !h5TimerCount) {\r
+ clearInterval(h5IntervalTimer);\r
+ h5IntervalTimer = null;\r
+ return false;\r
+ }\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) {\r
+ sm2.sounds[sm2.soundIDs[i]]._onTimer();\r
+ }\r
+ }\r
+ };\r
+ catchError = function(options) {\r
+ options = (options !== _undefined ? options : {});\r
+ if (typeof sm2.onerror === 'function') {\r
+ sm2.onerror.apply(window, [{type:(options.type !== _undefined ? options.type : null)}]);\r
+ }\r
+ if (options.fatal !== _undefined && options.fatal) {\r
+ sm2.disable();\r
+ }\r
+ };\r
+ badSafariFix = function() {\r
+ if (!isBadSafari || !detectFlash()) {\r
+ return false;\r
+ }\r
+ var aF = sm2.audioFormats, i, item;\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ if (item === 'mp3' || item === 'mp4') {\r
+ sm2.html5[item] = false;\r
+ if (aF[item] && aF[item].related) {\r
+ for (i = aF[item].related.length-1; i >= 0; i--) {\r
+ sm2.html5[aF[item].related[i]] = false;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ };\r
+ this._setSandboxType = function(sandboxType) {\r
+ };\r
+ this._externalInterfaceOK = function(flashDate, swfVersion) {\r
+ if (sm2.swfLoaded) {\r
+ return false;\r
+ }\r
+ var e;\r
+ sm2.swfLoaded = true;\r
+ tryInitOnFocus = false;\r
+ if (isBadSafari) {\r
+ badSafariFix();\r
+ }\r
+ setTimeout(init, isIE ? 100 : 1);\r
+ };\r
+ createMovie = function(smID, smURL) {\r
+ if (didAppend && appendSuccess) {\r
+ return false;\r
+ }\r
+ function initMsg() {\r
+ }\r
+ if (sm2.html5Only) {\r
+ setVersionInfo();\r
+ initMsg();\r
+ sm2.oMC = id(sm2.movieID);\r
+ init();\r
+ didAppend = true;\r
+ appendSuccess = true;\r
+ return false;\r
+ }\r
+ var remoteURL = (smURL || sm2.url),\r
+ localURL = (sm2.altURL || remoteURL),\r
+ swfTitle = 'JS/Flash audio component (SoundManager 2)',\r
+ oTarget = getDocument(),\r
+ extraClass = getSWFCSS(),\r
+ isRTL = null,\r
+ html = doc.getElementsByTagName('html')[0],\r
+ oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass;\r
+ isRTL = (html && html.dir && html.dir.match(/rtl/i));\r
+ smID = (smID === _undefined?sm2.id:smID);\r
+ function param(name, value) {\r
+ return '<param name="'+name+'" value="'+value+'" />';\r
+ }\r
+ setVersionInfo();\r
+ sm2.url = normalizeMovieURL(overHTTP?remoteURL:localURL);\r
+ smURL = sm2.url;\r
+ sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode);\r
+ if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) {\r
+ messages.push(strings.spcWmode);\r
+ sm2.wmode = null;\r
+ }\r
+ oEmbed = {\r
+ 'name': smID,\r
+ 'id': smID,\r
+ 'src': smURL,\r
+ 'quality': 'high',\r
+ 'allowScriptAccess': sm2.allowScriptAccess,\r
+ 'bgcolor': sm2.bgColor,\r
+ 'pluginspage': http+'www.macromedia.com/go/getflashplayer',\r
+ 'title': swfTitle,\r
+ 'type': 'application/x-shockwave-flash',\r
+ 'wmode': sm2.wmode,\r
+ 'hasPriority': 'true'\r
+ };\r
+ if (sm2.debugFlash) {\r
+ oEmbed.FlashVars = 'debug=1';\r
+ }\r
+ if (!sm2.wmode) {\r
+ delete oEmbed.wmode;\r
+ }\r
+ if (isIE) {\r
+ oMovie = doc.createElement('div');\r
+ movieHTML = [\r
+ '<object id="' + smID + '" data="' + smURL + '" type="' + oEmbed.type + '" title="' + oEmbed.title +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + http+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">',\r
+ param('movie', smURL),\r
+ param('AllowScriptAccess', sm2.allowScriptAccess),\r
+ param('quality', oEmbed.quality),\r
+ (sm2.wmode? param('wmode', sm2.wmode): ''),\r
+ param('bgcolor', sm2.bgColor),\r
+ param('hasPriority', 'true'),\r
+ (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''),\r
+ '</object>'\r
+ ].join('');\r
+ } else {\r
+ oMovie = doc.createElement('embed');\r
+ for (tmp in oEmbed) {\r
+ if (oEmbed.hasOwnProperty(tmp)) {\r
+ oMovie.setAttribute(tmp, oEmbed[tmp]);\r
+ }\r
+ }\r
+ }\r
+ initDebug();\r
+ extraClass = getSWFCSS();\r
+ oTarget = getDocument();\r
+ if (oTarget) {\r
+ sm2.oMC = (id(sm2.movieID) || doc.createElement('div'));\r
+ if (!sm2.oMC.id) {\r
+ sm2.oMC.id = sm2.movieID;\r
+ sm2.oMC.className = swfCSS.swfDefault + ' ' + extraClass;\r
+ s = null;\r
+ oEl = null;\r
+ if (!sm2.useFlashBlock) {\r
+ if (sm2.useHighPerformance) {\r
+ s = {\r
+ 'position': 'fixed',\r
+ 'width': '8px',\r
+ 'height': '8px',\r
+ 'bottom': '0px',\r
+ 'left': '0px',\r
+ 'overflow': 'hidden'\r
+ };\r
+ } else {\r
+ s = {\r
+ 'position': 'absolute',\r
+ 'width': '6px',\r
+ 'height': '6px',\r
+ 'top': '-9999px',\r
+ 'left': '-9999px'\r
+ };\r
+ if (isRTL) {\r
+ s.left = Math.abs(parseInt(s.left,10))+'px';\r
+ }\r
+ }\r
+ }\r
+ if (isWebkit) {\r
+ sm2.oMC.style.zIndex = 10000;\r
+ }\r
+ if (!sm2.debugFlash) {\r
+ for (x in s) {\r
+ if (s.hasOwnProperty(x)) {\r
+ sm2.oMC.style[x] = s[x];\r
+ }\r
+ }\r
+ }\r
+ try {\r
+ if (!isIE) {\r
+ sm2.oMC.appendChild(oMovie);\r
+ }\r
+ oTarget.appendChild(sm2.oMC);\r
+ if (isIE) {\r
+ oEl = sm2.oMC.appendChild(doc.createElement('div'));\r
+ oEl.className = swfCSS.swfBox;\r
+ oEl.innerHTML = movieHTML;\r
+ }\r
+ appendSuccess = true;\r
+ } catch(e) {\r
+ throw new Error(str('domError')+' \n'+e.toString());\r
+ }\r
+ } else {\r
+ sClass = sm2.oMC.className;\r
+ sm2.oMC.className = (sClass?sClass+' ':swfCSS.swfDefault) + (extraClass?' '+extraClass:'');\r
+ sm2.oMC.appendChild(oMovie);\r
+ if (isIE) {\r
+ oEl = sm2.oMC.appendChild(doc.createElement('div'));\r
+ oEl.className = swfCSS.swfBox;\r
+ oEl.innerHTML = movieHTML;\r
+ }\r
+ appendSuccess = true;\r
+ }\r
+ }\r
+ didAppend = true;\r
+ initMsg();\r
+ return true;\r
+ };\r
+ initMovie = function() {\r
+ if (sm2.html5Only) {\r
+ createMovie();\r
+ return false;\r
+ }\r
+ if (flash) {\r
+ return false;\r
+ }\r
+ if (!sm2.url) {\r
+ return false;\r
+ }\r
+ flash = sm2.getMovie(sm2.id);\r
+ if (!flash) {\r
+ if (!oRemoved) {\r
+ createMovie(sm2.id, sm2.url);\r
+ } else {\r
+ if (!isIE) {\r
+ sm2.oMC.appendChild(oRemoved);\r
+ } else {\r
+ sm2.oMC.innerHTML = oRemovedHTML;\r
+ }\r
+ oRemoved = null;\r
+ didAppend = true;\r
+ }\r
+ flash = sm2.getMovie(sm2.id);\r
+ }\r
+ if (typeof sm2.oninitmovie === 'function') {\r
+ setTimeout(sm2.oninitmovie, 1);\r
+ }\r
+ return true;\r
+ };\r
+ delayWaitForEI = function() {\r
+ setTimeout(waitForEI, 1000);\r
+ };\r
+ waitForEI = function() {\r
+ var p,\r
+ loadIncomplete = false;\r
+ if (!sm2.url) {\r
+ return false;\r
+ }\r
+ if (waitingForEI) {\r
+ return false;\r
+ }\r
+ waitingForEI = true;\r
+ event.remove(window, 'load', delayWaitForEI);\r
+ if (tryInitOnFocus && !isFocused) {\r
+ return false;\r
+ }\r
+ if (!didInit) {\r
+ p = sm2.getMoviePercent();\r
+ if (p > 0 && p < 100) {\r
+ loadIncomplete = true;\r
+ }\r
+ }\r
+ setTimeout(function() {\r
+ p = sm2.getMoviePercent();\r
+ if (loadIncomplete) {\r
+ waitingForEI = false;\r
+ window.setTimeout(delayWaitForEI, 1);\r
+ return false;\r
+ }\r
+ if (!didInit && okToDisable) {\r
+ if (p === null) {\r
+ if (sm2.useFlashBlock || sm2.flashLoadTimeout === 0) {\r
+ if (sm2.useFlashBlock) {\r
+ flashBlockHandler();\r
+ }\r
+ } else {\r
+ processOnEvents({type:'ontimeout', ignoreInit: true});\r
+ }\r
+ } else {\r
+ if (sm2.flashLoadTimeout === 0) {\r
+ } else {\r
+ failSafely(true);\r
+ }\r
+ }\r
+ }\r
+ }, sm2.flashLoadTimeout);\r
+ };\r
+ handleFocus = function() {\r
+ function cleanup() {\r
+ event.remove(window, 'focus', handleFocus);\r
+ }\r
+ if (isFocused || !tryInitOnFocus) {\r
+ cleanup();\r
+ return true;\r
+ }\r
+ okToDisable = true;\r
+ isFocused = true;\r
+ waitingForEI = false;\r
+ delayWaitForEI();\r
+ cleanup();\r
+ return true;\r
+ };\r
+ flushMessages = function() {\r
+ };\r
+ showSupport = function() {\r
+ };\r
+ initComplete = function(bNoDisable) {\r
+ if (didInit) {\r
+ return false;\r
+ }\r
+ if (sm2.html5Only) {\r
+ didInit = true;\r
+ initUserOnload();\r
+ return true;\r
+ }\r
+ var wasTimeout = (sm2.useFlashBlock && sm2.flashLoadTimeout && !sm2.getMoviePercent()),\r
+ result = true,\r
+ error;\r
+ if (!wasTimeout) {\r
+ didInit = true;\r
+ if (disabled) {\r
+ error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')};\r
+ }\r
+ }\r
+ if (disabled || bNoDisable) {\r
+ if (sm2.useFlashBlock && sm2.oMC) {\r
+ sm2.oMC.className = getSWFCSS() + ' ' + (sm2.getMoviePercent() === null?swfCSS.swfTimedout:swfCSS.swfError);\r
+ }\r
+ processOnEvents({type:'ontimeout', error:error, ignoreInit: true});\r
+ catchError(error);\r
+ result = false;\r
+ } else {\r
+ }\r
+ if (!disabled) {\r
+ if (sm2.waitForWindowLoad && !windowLoaded) {\r
+ event.add(window, 'load', initUserOnload);\r
+ } else {\r
+ initUserOnload();\r
+ }\r
+ }\r
+ return result;\r
+ };\r
+ setProperties = function() {\r
+ var i,\r
+ o = sm2.setupOptions;\r
+ for (i in o) {\r
+ if (o.hasOwnProperty(i)) {\r
+ if (sm2[i] === _undefined) {\r
+ sm2[i] = o[i];\r
+ } else if (sm2[i] !== o[i]) {\r
+ sm2.setupOptions[i] = sm2[i];\r
+ }\r
+ }\r
+ }\r
+ };\r
+ init = function() {\r
+ if (didInit) {\r
+ return false;\r
+ }\r
+ function cleanup() {\r
+ event.remove(window, 'load', sm2.beginDelayedInit);\r
+ }\r
+ if (sm2.html5Only) {\r
+ if (!didInit) {\r
+ cleanup();\r
+ sm2.enabled = true;\r
+ initComplete();\r
+ }\r
+ return true;\r
+ }\r
+ initMovie();\r
+ try {\r
+ flash._externalInterfaceTest(false);\r
+ setPolling(true, (sm2.flashPollingInterval || (sm2.useHighPerformance ? 10 : 50)));\r
+ if (!sm2.debugMode) {\r
+ flash._disableDebug();\r
+ }\r
+ sm2.enabled = true;\r
+ if (!sm2.html5Only) {\r
+ event.add(window, 'unload', doNothing);\r
+ }\r
+ } catch(e) {\r
+ catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true});\r
+ failSafely(true);\r
+ initComplete();\r
+ return false;\r
+ }\r
+ initComplete();\r
+ cleanup();\r
+ return true;\r
+ };\r
+ domContentLoaded = function() {\r
+ if (didDCLoaded) {\r
+ return false;\r
+ }\r
+ didDCLoaded = true;\r
+ setProperties();\r
+ initDebug();\r
+ if (!hasFlash && sm2.hasHTML5) {\r
+ sm2.setup({\r
+ 'useHTML5Audio': true,\r
+ 'preferFlash': false\r
+ });\r
+ }\r
+ testHTML5();\r
+ sm2.html5.usingFlash = featureCheck();\r
+ needsFlash = sm2.html5.usingFlash;\r
+ if (!hasFlash && needsFlash) {\r
+ messages.push(strings.needFlash);\r
+ sm2.setup({\r
+ 'flashLoadTimeout': 1\r
+ });\r
+ }\r
+ if (doc.removeEventListener) {\r
+ doc.removeEventListener('DOMContentLoaded', domContentLoaded, false);\r
+ }\r
+ initMovie();\r
+ return true;\r
+ };\r
+ domContentLoadedIE = function() {\r
+ if (doc.readyState === 'complete') {\r
+ domContentLoaded();\r
+ doc.detachEvent('onreadystatechange', domContentLoadedIE);\r
+ }\r
+ return true;\r
+ };\r
+ winOnLoad = function() {\r
+ windowLoaded = true;\r
+ event.remove(window, 'load', winOnLoad);\r
+ };\r
+ preInit = function() {\r
+ if (mobileHTML5) {\r
+ sm2.setupOptions.useHTML5Audio = true;\r
+ sm2.setupOptions.preferFlash = false;\r
+ if (is_iDevice || (isAndroid && !ua.match(/android\s2\.3/i))) {\r
+ if (is_iDevice) {\r
+ sm2.ignoreFlash = true;\r
+ }\r
+ useGlobalHTML5Audio = true;\r
+ }\r
+ }\r
+ };\r
+ preInit();\r
+ detectFlash();\r
+ event.add(window, 'focus', handleFocus);\r
+ event.add(window, 'load', delayWaitForEI);\r
+ event.add(window, 'load', winOnLoad);\r
+ if (doc.addEventListener) {\r
+ doc.addEventListener('DOMContentLoaded', domContentLoaded, false);\r
+ } else if (doc.attachEvent) {\r
+ doc.attachEvent('onreadystatechange', domContentLoadedIE);\r
+ } else {\r
+ catchError({type:'NO_DOM2_EVENTS', fatal:true});\r
+ }\r
+}\r
+// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading\r
+if (window.SM2_DEFER === undefined || !SM2_DEFER) {\r
+ soundManager = new SoundManager();\r
+}\r
+window.SoundManager = SoundManager;\r
+window.soundManager = soundManager;\r
+}(window));
\ No newline at end of file
--- /dev/null
+/** @license\r
+ *\r
+ * SoundManager 2: JavaScript Sound for the Web\r
+ * ----------------------------------------------\r
+ * http://schillmania.com/projects/soundmanager2/\r
+ *\r
+ * Copyright (c) 2007, Scott Schiller. All rights reserved.\r
+ * Code provided under the BSD License:\r
+ * http://schillmania.com/projects/soundmanager2/license.txt\r
+ *\r
+ * V2.97a.20130324 ("Mahalo" Edition)\r
+ */\r
+\r
+/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */\r
+/*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */\r
+\r
+/**\r
+ * About this file\r
+ * -------------------------------------------------------------------------------------\r
+ * This is the fully-commented source version of the SoundManager 2 API,\r
+ * recommended for use during development and testing.\r
+ *\r
+ * See soundmanager2-nodebug-jsmin.js for an optimized build (~11KB with gzip.)\r
+ * http://schillmania.com/projects/soundmanager2/doc/getstarted/#basic-inclusion\r
+ * Alternately, serve this file with gzip for 75% compression savings (~30KB over HTTP.)\r
+ *\r
+ * You may notice <d> and </d> comments in this source; these are delimiters for\r
+ * debug blocks which are removed in the -nodebug builds, further optimizing code size.\r
+ *\r
+ * Also, as you may note: Whoa, reliable cross-platform/device audio support is hard! ;)\r
+ */\r
+\r
+(function(window, _undefined) {\r
+\r
+"use strict";\r
+\r
+var soundManager = null;\r
+\r
+/**\r
+ * The SoundManager constructor.\r
+ *\r
+ * @constructor\r
+ * @param {string} smURL Optional: Path to SWF files\r
+ * @param {string} smID Optional: The ID to use for the SWF container element\r
+ * @this {SoundManager}\r
+ * @return {SoundManager} The new SoundManager instance\r
+ */\r
+\r
+function SoundManager(smURL, smID) {\r
+\r
+ /**\r
+ * soundManager configuration options list\r
+ * defines top-level configuration properties to be applied to the soundManager instance (eg. soundManager.flashVersion)\r
+ * to set these properties, use the setup() method - eg., soundManager.setup({url: '/swf/', flashVersion: 9})\r
+ */\r
+\r
+ this.setupOptions = {\r
+\r
+ 'url': (smURL || null), // path (directory) where SoundManager 2 SWFs exist, eg., /path/to/swfs/\r
+ 'flashVersion': 8, // flash build to use (8 or 9.) Some API features require 9.\r
+ 'debugMode': true, // enable debugging output (console.log() with HTML fallback)\r
+ 'debugFlash': false, // enable debugging output inside SWF, troubleshoot Flash/browser issues\r
+ 'useConsole': true, // use console.log() if available (otherwise, writes to #soundmanager-debug element)\r
+ 'consoleOnly': true, // if console is being used, do not create/write to #soundmanager-debug\r
+ 'waitForWindowLoad': false, // force SM2 to wait for window.onload() before trying to call soundManager.onload()\r
+ 'bgColor': '#ffffff', // SWF background color. N/A when wmode = 'transparent'\r
+ 'useHighPerformance': false, // position:fixed flash movie can help increase js/flash speed, minimize lag\r
+ 'flashPollingInterval': null, // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used.\r
+ 'html5PollingInterval': null, // msec affecting whileplaying() for HTML5 audio, excluding mobile devices. If null, native HTML5 update events are used.\r
+ 'flashLoadTimeout': 1000, // msec to wait for flash movie to load before failing (0 = infinity)\r
+ 'wmode': null, // flash rendering mode - null, 'transparent', or 'opaque' (last two allow z-index to work)\r
+ 'allowScriptAccess': 'always', // for scripting the SWF (object/embed property), 'always' or 'sameDomain'\r
+ 'useFlashBlock': false, // *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable.\r
+ 'useHTML5Audio': true, // use HTML5 Audio() where API is supported (most Safari, Chrome versions), Firefox (no MP3/MP4.) Ideally, transparent vs. Flash API where possible.\r
+ 'html5Test': /^(probably|maybe)$/i, // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative.\r
+ 'preferFlash': true, // overrides useHTML5audio. if true and flash support present, will try to use flash for MP3/MP4 as needed since HTML5 audio support is still quirky in browsers.\r
+ 'noSWFCache': false // if true, appends ?ts={date} to break aggressive SWF caching.\r
+\r
+ };\r
+\r
+ this.defaultOptions = {\r
+\r
+ /**\r
+ * the default configuration for sound objects made with createSound() and related methods\r
+ * eg., volume, auto-load behaviour and so forth\r
+ */\r
+\r
+ 'autoLoad': false, // enable automatic loading (otherwise .load() will be called on demand with .play(), the latter being nicer on bandwidth - if you want to .load yourself, you also can)\r
+ 'autoPlay': false, // enable playing of file as soon as possible (much faster if "stream" is true)\r
+ 'from': null, // position to start playback within a sound (msec), default = beginning\r
+ 'loops': 1, // how many times to repeat the sound (position will wrap around to 0, setPosition() will break out of loop when >0)\r
+ 'onid3': null, // callback function for "ID3 data is added/available"\r
+ 'onload': null, // callback function for "load finished"\r
+ 'whileloading': null, // callback function for "download progress update" (X of Y bytes received)\r
+ 'onplay': null, // callback for "play" start\r
+ 'onpause': null, // callback for "pause"\r
+ 'onresume': null, // callback for "resume" (pause toggle)\r
+ 'whileplaying': null, // callback during play (position update)\r
+ 'onposition': null, // object containing times and function callbacks for positions of interest\r
+ 'onstop': null, // callback for "user stop"\r
+ 'onfailure': null, // callback function for when playing fails\r
+ 'onfinish': null, // callback function for "sound finished playing"\r
+ 'multiShot': true, // let sounds "restart" or layer on top of each other when played multiple times, rather than one-shot/one at a time\r
+ 'multiShotEvents': false, // fire multiple sound events (currently onfinish() only) when multiShot is enabled\r
+ 'position': null, // offset (milliseconds) to seek to within loaded sound data.\r
+ 'pan': 0, // "pan" settings, left-to-right, -100 to 100\r
+ 'stream': true, // allows playing before entire file has loaded (recommended)\r
+ 'to': null, // position to end playback within a sound (msec), default = end\r
+ 'type': null, // MIME-like hint for file pattern / canPlay() tests, eg. audio/mp3\r
+ 'usePolicyFile': false, // enable crossdomain.xml request for audio on remote domains (for ID3/waveform access)\r
+ 'volume': 100 // self-explanatory. 0-100, the latter being the max.\r
+\r
+ };\r
+\r
+ this.flash9Options = {\r
+\r
+ /**\r
+ * flash 9-only options,\r
+ * merged into defaultOptions if flash 9 is being used\r
+ */\r
+\r
+ 'isMovieStar': null, // "MovieStar" MPEG4 audio mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL\r
+ 'usePeakData': false, // enable left/right channel peak (level) data\r
+ 'useWaveformData': false, // enable sound spectrum (raw waveform data) - NOTE: May increase CPU load.\r
+ 'useEQData': false, // enable sound EQ (frequency spectrum data) - NOTE: May increase CPU load.\r
+ 'onbufferchange': null, // callback for "isBuffering" property change\r
+ 'ondataerror': null // callback for waveform/eq data access error (flash playing audio in other tabs/domains)\r
+\r
+ };\r
+\r
+ this.movieStarOptions = {\r
+\r
+ /**\r
+ * flash 9.0r115+ MPEG4 audio options,\r
+ * merged into defaultOptions if flash 9+movieStar mode is enabled\r
+ */\r
+\r
+ 'bufferTime': 3, // seconds of data to buffer before playback begins (null = flash default of 0.1 seconds - if AAC playback is gappy, try increasing.)\r
+ 'serverURL': null, // rtmp: FMS or FMIS server to connect to, required when requesting media via RTMP or one of its variants\r
+ 'onconnect': null, // rtmp: callback for connection to flash media server\r
+ 'duration': null // rtmp: song duration (msec)\r
+\r
+ };\r
+\r
+ this.audioFormats = {\r
+\r
+ /**\r
+ * determines HTML5 support + flash requirements.\r
+ * if no support (via flash and/or HTML5) for a "required" format, SM2 will fail to start.\r
+ * flash fallback is used for MP3 or MP4 if HTML5 can't play it (or if preferFlash = true)\r
+ */\r
+\r
+ 'mp3': {\r
+ 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'],\r
+ 'required': true\r
+ },\r
+\r
+ 'mp4': {\r
+ 'related': ['aac','m4a','m4b'], // additional formats under the MP4 container\r
+ 'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'],\r
+ 'required': false\r
+ },\r
+\r
+ 'ogg': {\r
+ 'type': ['audio/ogg; codecs=vorbis'],\r
+ 'required': false\r
+ },\r
+\r
+ 'opus': {\r
+ 'type': ['audio/ogg; codecs=opus', 'audio/opus'],\r
+ 'required': false\r
+ },\r
+\r
+ 'wav': {\r
+ 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],\r
+ 'required': false\r
+ }\r
+\r
+ };\r
+\r
+ // HTML attributes (id + class names) for the SWF container\r
+\r
+ this.movieID = 'sm2-container';\r
+ this.id = (smID || 'sm2movie');\r
+\r
+ this.debugID = 'soundmanager-debug';\r
+ this.debugURLParam = /([#?&])debug=1/i;\r
+\r
+ // dynamic attributes\r
+\r
+ this.versionNumber = 'V2.97a.20130324';\r
+ this.version = null;\r
+ this.movieURL = null;\r
+ this.altURL = null;\r
+ this.swfLoaded = false;\r
+ this.enabled = false;\r
+ this.oMC = null;\r
+ this.sounds = {};\r
+ this.soundIDs = [];\r
+ this.muted = false;\r
+ this.didFlashBlock = false;\r
+ this.filePattern = null;\r
+\r
+ this.filePatterns = {\r
+\r
+ 'flash8': /\.mp3(\?.*)?$/i,\r
+ 'flash9': /\.mp3(\?.*)?$/i\r
+\r
+ };\r
+\r
+ // support indicators, set at init\r
+\r
+ this.features = {\r
+\r
+ 'buffering': false,\r
+ 'peakData': false,\r
+ 'waveformData': false,\r
+ 'eqData': false,\r
+ 'movieStar': false\r
+\r
+ };\r
+\r
+ // flash sandbox info, used primarily in troubleshooting\r
+\r
+ this.sandbox = {\r
+\r
+ // <d>\r
+ 'type': null,\r
+ 'types': {\r
+ 'remote': 'remote (domain-based) rules',\r
+ 'localWithFile': 'local with file access (no internet access)',\r
+ 'localWithNetwork': 'local with network (internet access only, no local access)',\r
+ 'localTrusted': 'local, trusted (local+internet access)'\r
+ },\r
+ 'description': null,\r
+ 'noRemote': null,\r
+ 'noLocal': null\r
+ // </d>\r
+\r
+ };\r
+\r
+ /**\r
+ * format support (html5/flash)\r
+ * stores canPlayType() results based on audioFormats.\r
+ * eg. { mp3: boolean, mp4: boolean }\r
+ * treat as read-only.\r
+ */\r
+\r
+ this.html5 = {\r
+ 'usingFlash': null // set if/when flash fallback is needed\r
+ };\r
+\r
+ // file type support hash\r
+ this.flash = {};\r
+\r
+ // determined at init time\r
+ this.html5Only = false;\r
+\r
+ // used for special cases (eg. iPad/iPhone/palm OS?)\r
+ this.ignoreFlash = false;\r
+\r
+ /**\r
+ * a few private internals (OK, a lot. :D)\r
+ */\r
+\r
+ var SMSound,\r
+ sm2 = this, globalHTML5Audio = null, flash = null, sm = 'soundManager', smc = sm + ': ', h5 = 'HTML5::', id, ua = navigator.userAgent, wl = window.location.href.toString(), doc = document, doNothing, setProperties, init, fV, on_queue = [], debugOpen = true, debugTS, didAppend = false, appendSuccess = false, didInit = false, disabled = false, windowLoaded = false, _wDS, wdCount = 0, initComplete, mixin, assign, extraOptions, addOnEvent, processOnEvents, initUserOnload, delayWaitForEI, waitForEI, setVersionInfo, handleFocus, strings, initMovie, preInit, domContentLoaded, winOnLoad, didDCLoaded, getDocument, createMovie, catchError, setPolling, initDebug, debugLevels = ['log', 'info', 'warn', 'error'], defaultFlashVersion = 8, disableObject, failSafely, normalizeMovieURL, oRemoved = null, oRemovedHTML = null, str, flashBlockHandler, getSWFCSS, swfCSS, toggleDebug, loopFix, policyFix, complain, idCheck, waitingForEI = false, initPending = false, startTimer, stopTimer, timerExecute, h5TimerCount = 0, h5IntervalTimer = null, parseURL, messages = [],\r
+ needsFlash = null, featureCheck, html5OK, html5CanPlay, html5Ext, html5Unload, domContentLoadedIE, testHTML5, event, slice = Array.prototype.slice, useGlobalHTML5Audio = false, lastGlobalHTML5URL, hasFlash, detectFlash, badSafariFix, html5_events, showSupport, flushMessages, wrapCallback,\r
+ is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie/i), isWebkit = ua.match(/webkit/i), isSafari = (ua.match(/safari/i) && !ua.match(/chrome/i)), isOpera = (ua.match(/opera/i)), \r
+ mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid),\r
+ isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2\-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS X 10_6_([3-7])/i)), // Safari 4 and 5 (excluding Kindle Fire, "Silk") occasionally fail to load/play HTML5 audio on Snow Leopard 10.6.3 through 10.6.7 due to bug(s) in QuickTime X and/or other underlying frameworks. :/ Confirmed bug. https://bugs.webkit.org/show_bug.cgi?id=32159\r
+ hasConsole = (window.console !== _undefined && console.log !== _undefined), isFocused = (doc.hasFocus !== _undefined?doc.hasFocus():null), tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())), okToDisable = !tryInitOnFocus, flashMIME = /(mp3|mp4|mpa|m4a|m4b)/i,\r
+ emptyURL = 'about:blank', // safe URL to unload, or load nothing from (flash 8 + most HTML5 UAs)\r
+ overHTTP = (doc.location?doc.location.protocol.match(/http/i):null),\r
+ http = (!overHTTP ? 'http:/'+'/' : ''),\r
+ // mp3, mp4, aac etc.\r
+ netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,\r
+ // Flash v9.0r115+ "moviestar" formats\r
+ netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'],\r
+ netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
+\r
+ this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; // default mp3 set\r
+\r
+ // use altURL if not "online"\r
+ this.useAltURL = !overHTTP;\r
+\r
+ swfCSS = {\r
+\r
+ 'swfBox': 'sm2-object-box',\r
+ 'swfDefault': 'movieContainer',\r
+ 'swfError': 'swf_error', // SWF loaded, but SM2 couldn't start (other error)\r
+ 'swfTimedout': 'swf_timedout',\r
+ 'swfLoaded': 'swf_loaded',\r
+ 'swfUnblocked': 'swf_unblocked', // or loaded OK\r
+ 'sm2Debug': 'sm2_debug',\r
+ 'highPerf': 'high_performance',\r
+ 'flashDebug': 'flash_debug'\r
+\r
+ };\r
+\r
+ /**\r
+ * basic HTML5 Audio() support test\r
+ * try...catch because of IE 9 "not implemented" nonsense\r
+ * https://github.com/Modernizr/Modernizr/issues/224\r
+ */\r
+\r
+ this.hasHTML5 = (function() {\r
+ try {\r
+ // new Audio(null) for stupid Opera 9.64 case, which throws not_enough_arguments exception otherwise.\r
+ return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined);\r
+ } catch(e) {\r
+ return false;\r
+ }\r
+ }());\r
+\r
+ /**\r
+ * Public SoundManager API\r
+ * -----------------------\r
+ */\r
+\r
+ /**\r
+ * Configures top-level soundManager properties.\r
+ *\r
+ * @param {object} options Option parameters, eg. { flashVersion: 9, url: '/path/to/swfs/' }\r
+ * onready and ontimeout are also accepted parameters. call soundManager.setup() to see the full list.\r
+ */\r
+\r
+ this.setup = function(options) {\r
+\r
+ var noURL = (!sm2.url);\r
+\r
+ // warn if flash options have already been applied\r
+\r
+ if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) {\r
+ complain(str('setupLate'));\r
+ }\r
+\r
+ // TODO: defer: true?\r
+\r
+ assign(options);\r
+\r
+ // special case 1: "Late setup". SM2 loaded normally, but user didn't assign flash URL eg., setup({url:...}) before SM2 init. Treat as delayed init.\r
+\r
+ if (noURL && didDCLoaded && options.url !== _undefined) {\r
+ sm2.beginDelayedInit();\r
+ }\r
+\r
+ // special case 2: If lazy-loading SM2 (DOMContentLoaded has already happened) and user calls setup() with url: parameter, try to init ASAP.\r
+\r
+ if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') {\r
+ setTimeout(domContentLoaded, 1);\r
+ }\r
+\r
+ return sm2;\r
+\r
+ };\r
+\r
+ this.ok = function() {\r
+\r
+ return (needsFlash?(didInit && !disabled):(sm2.useHTML5Audio && sm2.hasHTML5));\r
+\r
+ };\r
+\r
+ this.supported = this.ok; // legacy\r
+\r
+ this.getMovie = function(smID) {\r
+\r
+ // safety net: some old browsers differ on SWF references, possibly related to ExternalInterface / flash version\r
+ return id(smID) || doc[smID] || window[smID];\r
+\r
+ };\r
+\r
+ /**\r
+ * Creates a SMSound sound object instance.\r
+ *\r
+ * @param {object} oOptions Sound options (at minimum, id and url parameters are required.)\r
+ * @return {object} SMSound The new SMSound object.\r
+ */\r
+\r
+ this.createSound = function(oOptions, _url) {\r
+\r
+ var cs, cs_string, options, oSound = null;\r
+\r
+ // <d>\r
+ cs = sm + '.createSound(): ';\r
+ cs_string = cs + str(!didInit?'notReady':'notOK');\r
+ // </d>\r
+\r
+ if (!didInit || !sm2.ok()) {\r
+ complain(cs_string);\r
+ return false;\r
+ }\r
+\r
+ if (_url !== _undefined) {\r
+ // function overloading in JS! :) ..assume simple createSound(id,url) use case\r
+ oOptions = {\r
+ 'id': oOptions,\r
+ 'url': _url\r
+ };\r
+ }\r
+\r
+ // inherit from defaultOptions\r
+ options = mixin(oOptions);\r
+\r
+ options.url = parseURL(options.url);\r
+\r
+ // <d>\r
+ if (options.id.toString().charAt(0).match(/^[0-9]$/)) {\r
+ sm2._wD(cs + str('badID', options.id), 2);\r
+ }\r
+\r
+ sm2._wD(cs + options.id + ' (' + options.url + ')', 1);\r
+ // </d>\r
+\r
+ if (idCheck(options.id, true)) {\r
+ sm2._wD(cs + options.id + ' exists', 1);\r
+ return sm2.sounds[options.id];\r
+ }\r
+\r
+ function make() {\r
+\r
+ options = loopFix(options);\r
+ sm2.sounds[options.id] = new SMSound(options);\r
+ sm2.soundIDs.push(options.id);\r
+ return sm2.sounds[options.id];\r
+\r
+ }\r
+\r
+ if (html5OK(options)) {\r
+\r
+ oSound = make();\r
+ sm2._wD(options.id + ': Using HTML5');\r
+ oSound._setup_html5(options);\r
+\r
+ } else {\r
+\r
+ if (fV > 8) {\r
+ if (options.isMovieStar === null) {\r
+ // attempt to detect MPEG-4 formats\r
+ options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || options.url.match(netStreamPattern));\r
+ }\r
+ // <d>\r
+ if (options.isMovieStar) {\r
+ sm2._wD(cs + 'using MovieStar handling');\r
+ if (options.loops > 1) {\r
+ _wDS('noNSLoop');\r
+ }\r
+ }\r
+ // </d>\r
+ }\r
+\r
+ options = policyFix(options, cs);\r
+ oSound = make();\r
+\r
+ if (fV === 8) {\r
+ flash._createSound(options.id, options.loops||1, options.usePolicyFile);\r
+ } else {\r
+ flash._createSound(options.id, options.url, options.usePeakData, options.useWaveformData, options.useEQData, options.isMovieStar, (options.isMovieStar?options.bufferTime:false), options.loops||1, options.serverURL, options.duration||null, options.autoPlay, true, options.autoLoad, options.usePolicyFile);\r
+ if (!options.serverURL) {\r
+ // We are connected immediately\r
+ oSound.connected = true;\r
+ if (options.onconnect) {\r
+ options.onconnect.apply(oSound);\r
+ }\r
+ }\r
+ }\r
+\r
+ if (!options.serverURL && (options.autoLoad || options.autoPlay)) {\r
+ // call load for non-rtmp streams\r
+ oSound.load(options);\r
+ }\r
+\r
+ }\r
+\r
+ // rtmp will play in onconnect\r
+ if (!options.serverURL && options.autoPlay) {\r
+ oSound.play();\r
+ }\r
+\r
+ return oSound;\r
+\r
+ };\r
+\r
+ /**\r
+ * Destroys a SMSound sound object instance.\r
+ *\r
+ * @param {string} sID The ID of the sound to destroy\r
+ */\r
+\r
+ this.destroySound = function(sID, _bFromSound) {\r
+\r
+ // explicitly destroy a sound before normal page unload, etc.\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+\r
+ var oS = sm2.sounds[sID], i;\r
+\r
+ // Disable all callbacks while the sound is being destroyed\r
+ oS._iO = {};\r
+\r
+ oS.stop();\r
+ oS.unload();\r
+\r
+ for (i = 0; i < sm2.soundIDs.length; i++) {\r
+ if (sm2.soundIDs[i] === sID) {\r
+ sm2.soundIDs.splice(i, 1);\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (!_bFromSound) {\r
+ // ignore if being called from SMSound instance\r
+ oS.destruct(true);\r
+ }\r
+\r
+ oS = null;\r
+ delete sm2.sounds[sID];\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the load() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @param {object} oOptions Optional: Sound options\r
+ */\r
+\r
+ this.load = function(sID, oOptions) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].load(oOptions);\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the unload() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ */\r
+\r
+ this.unload = function(sID) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].unload();\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the onPosition() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @param {number} nPosition The position to watch for\r
+ * @param {function} oMethod The relevant callback to fire\r
+ * @param {object} oScope Optional: The scope to apply the callback to\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.onPosition = function(sID, nPosition, oMethod, oScope) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].onposition(nPosition, oMethod, oScope);\r
+\r
+ };\r
+\r
+ // legacy/backwards-compability: lower-case method name\r
+ this.onposition = this.onPosition;\r
+\r
+ /**\r
+ * Calls the clearOnPosition() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @param {number} nPosition The position to watch for\r
+ * @param {function} oMethod Optional: The relevant callback to fire\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.clearOnPosition = function(sID, nPosition, oMethod) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].clearOnPosition(nPosition, oMethod);\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the play() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @param {object} oOptions Optional: Sound options\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.play = function(sID, oOptions) {\r
+\r
+ var result = false;\r
+\r
+ if (!didInit || !sm2.ok()) {\r
+ complain(sm + '.play(): ' + str(!didInit?'notReady':'notOK'));\r
+ return result;\r
+ }\r
+\r
+ if (!idCheck(sID)) {\r
+ if (!(oOptions instanceof Object)) {\r
+ // overloading use case: play('mySound','/path/to/some.mp3');\r
+ oOptions = {\r
+ url: oOptions\r
+ };\r
+ }\r
+ if (oOptions && oOptions.url) {\r
+ // overloading use case, create+play: .play('someID',{url:'/path/to.mp3'});\r
+ sm2._wD(sm + '.play(): attempting to create "' + sID + '"', 1);\r
+ oOptions.id = sID;\r
+ result = sm2.createSound(oOptions).play();\r
+ }\r
+ return result;\r
+ }\r
+\r
+ return sm2.sounds[sID].play(oOptions);\r
+\r
+ };\r
+\r
+ this.start = this.play; // just for convenience\r
+\r
+ /**\r
+ * Calls the setPosition() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @param {number} nMsecOffset Position (milliseconds)\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.setPosition = function(sID, nMsecOffset) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].setPosition(nMsecOffset);\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the stop() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.stop = function(sID) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+\r
+ sm2._wD(sm + '.stop(' + sID + ')', 1);\r
+ return sm2.sounds[sID].stop();\r
+\r
+ };\r
+\r
+ /**\r
+ * Stops all currently-playing sounds.\r
+ */\r
+\r
+ this.stopAll = function() {\r
+\r
+ var oSound;\r
+ sm2._wD(sm + '.stopAll()', 1);\r
+\r
+ for (oSound in sm2.sounds) {\r
+ if (sm2.sounds.hasOwnProperty(oSound)) {\r
+ // apply only to sound objects\r
+ sm2.sounds[oSound].stop();\r
+ }\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the pause() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.pause = function(sID) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].pause();\r
+\r
+ };\r
+\r
+ /**\r
+ * Pauses all currently-playing sounds.\r
+ */\r
+\r
+ this.pauseAll = function() {\r
+\r
+ var i;\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].pause();\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the resume() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.resume = function(sID) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].resume();\r
+\r
+ };\r
+\r
+ /**\r
+ * Resumes all currently-paused sounds.\r
+ */\r
+\r
+ this.resumeAll = function() {\r
+\r
+ var i;\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].resume();\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the togglePause() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.togglePause = function(sID) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].togglePause();\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the setPan() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @param {number} nPan The pan value (-100 to 100)\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.setPan = function(sID, nPan) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].setPan(nPan);\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the setVolume() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @param {number} nVol The volume value (0 to 100)\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.setVolume = function(sID, nVol) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].setVolume(nVol);\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the mute() method of either a single SMSound object by ID, or all sound objects.\r
+ *\r
+ * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.)\r
+ */\r
+\r
+ this.mute = function(sID) {\r
+\r
+ var i = 0;\r
+\r
+ if (sID instanceof String) {\r
+ sID = null;\r
+ }\r
+\r
+ if (!sID) {\r
+\r
+ sm2._wD(sm + '.mute(): Muting all sounds');\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].mute();\r
+ }\r
+ sm2.muted = true;\r
+\r
+ } else {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ sm2._wD(sm + '.mute(): Muting "' + sID + '"');\r
+ return sm2.sounds[sID].mute();\r
+\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * Mutes all sounds.\r
+ */\r
+\r
+ this.muteAll = function() {\r
+\r
+ sm2.mute();\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the unmute() method of either a single SMSound object by ID, or all sound objects.\r
+ *\r
+ * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.)\r
+ */\r
+\r
+ this.unmute = function(sID) {\r
+\r
+ var i;\r
+\r
+ if (sID instanceof String) {\r
+ sID = null;\r
+ }\r
+\r
+ if (!sID) {\r
+\r
+ sm2._wD(sm + '.unmute(): Unmuting all sounds');\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].unmute();\r
+ }\r
+ sm2.muted = false;\r
+\r
+ } else {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ sm2._wD(sm + '.unmute(): Unmuting "' + sID + '"');\r
+ return sm2.sounds[sID].unmute();\r
+\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * Unmutes all sounds.\r
+ */\r
+\r
+ this.unmuteAll = function() {\r
+\r
+ sm2.unmute();\r
+\r
+ };\r
+\r
+ /**\r
+ * Calls the toggleMute() method of a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.toggleMute = function(sID) {\r
+\r
+ if (!idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return sm2.sounds[sID].toggleMute();\r
+\r
+ };\r
+\r
+ /**\r
+ * Retrieves the memory used by the flash plugin.\r
+ *\r
+ * @return {number} The amount of memory in use\r
+ */\r
+\r
+ this.getMemoryUse = function() {\r
+\r
+ // flash-only\r
+ var ram = 0;\r
+\r
+ if (flash && fV !== 8) {\r
+ ram = parseInt(flash._getMemoryUse(), 10);\r
+ }\r
+\r
+ return ram;\r
+\r
+ };\r
+\r
+ /**\r
+ * Undocumented: NOPs soundManager and all SMSound objects.\r
+ */\r
+\r
+ this.disable = function(bNoDisable) {\r
+\r
+ // destroy all functions\r
+ var i;\r
+\r
+ if (bNoDisable === _undefined) {\r
+ bNoDisable = false;\r
+ }\r
+\r
+ if (disabled) {\r
+ return false;\r
+ }\r
+\r
+ disabled = true;\r
+ _wDS('shutdown', 1);\r
+\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ disableObject(sm2.sounds[sm2.soundIDs[i]]);\r
+ }\r
+\r
+ // fire "complete", despite fail\r
+ initComplete(bNoDisable);\r
+ event.remove(window, 'load', initUserOnload);\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * Determines playability of a MIME type, eg. 'audio/mp3'.\r
+ */\r
+\r
+ this.canPlayMIME = function(sMIME) {\r
+\r
+ var result;\r
+\r
+ if (sm2.hasHTML5) {\r
+ result = html5CanPlay({type:sMIME});\r
+ }\r
+\r
+ if (!result && needsFlash) {\r
+ // if flash 9, test netStream (movieStar) types as well.\r
+ result = (sMIME && sm2.ok() ? !!((fV > 8 ? sMIME.match(netStreamMimeTypes) : null) || sMIME.match(sm2.mimePattern)) : null);\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ /**\r
+ * Determines playability of a URL based on audio support.\r
+ *\r
+ * @param {string} sURL The URL to test\r
+ * @return {boolean} URL playability\r
+ */\r
+\r
+ this.canPlayURL = function(sURL) {\r
+\r
+ var result;\r
+\r
+ if (sm2.hasHTML5) {\r
+ result = html5CanPlay({url: sURL});\r
+ }\r
+\r
+ if (!result && needsFlash) {\r
+ result = (sURL && sm2.ok() ? !!(sURL.match(sm2.filePattern)) : null);\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ /**\r
+ * Determines playability of an HTML DOM <a> object (or similar object literal) based on audio support.\r
+ *\r
+ * @param {object} oLink an HTML DOM <a> object or object literal including href and/or type attributes\r
+ * @return {boolean} URL playability\r
+ */\r
+\r
+ this.canPlayLink = function(oLink) {\r
+\r
+ if (oLink.type !== _undefined && oLink.type) {\r
+ if (sm2.canPlayMIME(oLink.type)) {\r
+ return true;\r
+ }\r
+ }\r
+\r
+ return sm2.canPlayURL(oLink.href);\r
+\r
+ };\r
+\r
+ /**\r
+ * Retrieves a SMSound object by ID.\r
+ *\r
+ * @param {string} sID The ID of the sound\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.getSoundById = function(sID, _suppressDebug) {\r
+\r
+ if (!sID) {\r
+ throw new Error(sm + '.getSoundById(): sID is null/_undefined');\r
+ }\r
+\r
+ var result = sm2.sounds[sID];\r
+\r
+ // <d>\r
+ if (!result && !_suppressDebug) {\r
+ sm2._wD('"' + sID + '" is an invalid sound ID.', 2);\r
+ }\r
+ // </d>\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ /**\r
+ * Queues a callback for execution when SoundManager has successfully initialized.\r
+ *\r
+ * @param {function} oMethod The callback method to fire\r
+ * @param {object} oScope Optional: The scope to apply to the callback\r
+ */\r
+\r
+ this.onready = function(oMethod, oScope) {\r
+\r
+ var sType = 'onready',\r
+ result = false;\r
+\r
+ if (typeof oMethod === 'function') {\r
+\r
+ // <d>\r
+ if (didInit) {\r
+ sm2._wD(str('queue', sType));\r
+ }\r
+ // </d>\r
+\r
+ if (!oScope) {\r
+ oScope = window;\r
+ }\r
+\r
+ addOnEvent(sType, oMethod, oScope);\r
+ processOnEvents();\r
+\r
+ result = true;\r
+\r
+ } else {\r
+\r
+ throw str('needFunction', sType);\r
+\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ /**\r
+ * Queues a callback for execution when SoundManager has failed to initialize.\r
+ *\r
+ * @param {function} oMethod The callback method to fire\r
+ * @param {object} oScope Optional: The scope to apply to the callback\r
+ */\r
+\r
+ this.ontimeout = function(oMethod, oScope) {\r
+\r
+ var sType = 'ontimeout',\r
+ result = false;\r
+\r
+ if (typeof oMethod === 'function') {\r
+\r
+ // <d>\r
+ if (didInit) {\r
+ sm2._wD(str('queue', sType));\r
+ }\r
+ // </d>\r
+\r
+ if (!oScope) {\r
+ oScope = window;\r
+ }\r
+\r
+ addOnEvent(sType, oMethod, oScope);\r
+ processOnEvents({type:sType});\r
+\r
+ result = true;\r
+\r
+ } else {\r
+\r
+ throw str('needFunction', sType);\r
+\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ /**\r
+ * Writes console.log()-style debug output to a console or in-browser element.\r
+ * Applies when debugMode = true\r
+ *\r
+ * @param {string} sText The console message\r
+ * @param {object} nType Optional log level (number), or object. Number case: Log type/style where 0 = 'info', 1 = 'warn', 2 = 'error'. Object case: Object to be dumped.\r
+ */\r
+\r
+ this._writeDebug = function(sText, sTypeOrObject) {\r
+\r
+ // pseudo-private console.log()-style output\r
+ // <d>\r
+\r
+ var sDID = 'soundmanager-debug', o, oItem;\r
+\r
+ if (!sm2.debugMode) {\r
+ return false;\r
+ }\r
+\r
+ if (hasConsole && sm2.useConsole) {\r
+ if (sTypeOrObject && typeof sTypeOrObject === 'object') {\r
+ // object passed; dump to console.\r
+ console.log(sText, sTypeOrObject);\r
+ } else if (debugLevels[sTypeOrObject] !== _undefined) {\r
+ console[debugLevels[sTypeOrObject]](sText);\r
+ } else {\r
+ console.log(sText);\r
+ }\r
+ if (sm2.consoleOnly) {\r
+ return true;\r
+ }\r
+ }\r
+\r
+ o = id(sDID);\r
+\r
+ if (!o) {\r
+ return false;\r
+ }\r
+\r
+ oItem = doc.createElement('div');\r
+\r
+ if (++wdCount % 2 === 0) {\r
+ oItem.className = 'sm2-alt';\r
+ }\r
+\r
+ if (sTypeOrObject === _undefined) {\r
+ sTypeOrObject = 0;\r
+ } else {\r
+ sTypeOrObject = parseInt(sTypeOrObject, 10);\r
+ }\r
+\r
+ oItem.appendChild(doc.createTextNode(sText));\r
+\r
+ if (sTypeOrObject) {\r
+ if (sTypeOrObject >= 2) {\r
+ oItem.style.fontWeight = 'bold';\r
+ }\r
+ if (sTypeOrObject === 3) {\r
+ oItem.style.color = '#ff3333';\r
+ }\r
+ }\r
+\r
+ // top-to-bottom\r
+ // o.appendChild(oItem);\r
+\r
+ // bottom-to-top\r
+ o.insertBefore(oItem, o.firstChild);\r
+\r
+ o = null;\r
+ // </d>\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ // <d>\r
+ // last-resort debugging option\r
+ if (wl.indexOf('sm2-debug=alert') !== -1) {\r
+ this._writeDebug = function(sText) {\r
+ window.alert(sText);\r
+ };\r
+ }\r
+ // </d>\r
+\r
+ // alias\r
+ this._wD = this._writeDebug;\r
+\r
+ /**\r
+ * Provides debug / state information on all SMSound objects.\r
+ */\r
+\r
+ this._debug = function() {\r
+\r
+ // <d>\r
+ var i, j;\r
+ _wDS('currentObj', 1);\r
+\r
+ for (i = 0, j = sm2.soundIDs.length; i < j; i++) {\r
+ sm2.sounds[sm2.soundIDs[i]]._debug();\r
+ }\r
+ // </d>\r
+\r
+ };\r
+\r
+ /**\r
+ * Restarts and re-initializes the SoundManager instance.\r
+ *\r
+ * @param {boolean} resetEvents Optional: When true, removes all registered onready and ontimeout event callbacks.\r
+ * @param {boolean} excludeInit Options: When true, does not call beginDelayedInit() (which would restart SM2).\r
+ * @return {object} soundManager The soundManager instance.\r
+ */\r
+\r
+ this.reboot = function(resetEvents, excludeInit) {\r
+\r
+ // reset some (or all) state, and re-init unless otherwise specified.\r
+\r
+ // <d>\r
+ if (sm2.soundIDs.length) {\r
+ sm2._wD('Destroying ' + sm2.soundIDs.length + ' SMSound objects...');\r
+ }\r
+ // </d>\r
+\r
+ var i, j, k;\r
+\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+ sm2.sounds[sm2.soundIDs[i]].destruct();\r
+ }\r
+\r
+ // trash ze flash\r
+\r
+ if (flash) {\r
+\r
+ try {\r
+\r
+ if (isIE) {\r
+ oRemovedHTML = flash.innerHTML;\r
+ }\r
+\r
+ oRemoved = flash.parentNode.removeChild(flash);\r
+\r
+ _wDS('flRemoved');\r
+\r
+ } catch(e) {\r
+\r
+ // Remove failed? May be due to flash blockers silently removing the SWF object/embed node from the DOM. Warn and continue.\r
+\r
+ _wDS('badRemove', 2);\r
+\r
+ }\r
+\r
+ }\r
+\r
+ // actually, force recreate of movie.\r
+\r
+ oRemovedHTML = oRemoved = needsFlash = flash = null;\r
+\r
+ sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false;\r
+\r
+ sm2.soundIDs = [];\r
+ sm2.sounds = {};\r
+\r
+ if (!resetEvents) {\r
+ // reset callbacks for onready, ontimeout etc. so that they will fire again on re-init\r
+ for (i in on_queue) {\r
+ if (on_queue.hasOwnProperty(i)) {\r
+ for (j = 0, k = on_queue[i].length; j < k; j++) {\r
+ on_queue[i][j].fired = false;\r
+ }\r
+ }\r
+ }\r
+ } else {\r
+ // remove all callbacks entirely\r
+ on_queue = [];\r
+ }\r
+\r
+ // <d>\r
+ if (!excludeInit) {\r
+ sm2._wD(sm + ': Rebooting...');\r
+ }\r
+ // </d>\r
+\r
+ // reset HTML5 and flash canPlay test results\r
+\r
+ sm2.html5 = {\r
+ 'usingFlash': null\r
+ };\r
+\r
+ sm2.flash = {};\r
+\r
+ // reset device-specific HTML/flash mode switches\r
+\r
+ sm2.html5Only = false;\r
+ sm2.ignoreFlash = false;\r
+\r
+ window.setTimeout(function() {\r
+\r
+ preInit();\r
+\r
+ // by default, re-init\r
+\r
+ if (!excludeInit) {\r
+ sm2.beginDelayedInit();\r
+ }\r
+\r
+ }, 20);\r
+\r
+ return sm2;\r
+\r
+ };\r
+\r
+ this.reset = function() {\r
+\r
+ /**\r
+ * Shuts down and restores the SoundManager instance to its original loaded state, without an explicit reboot. All onready/ontimeout handlers are removed.\r
+ * After this call, SM2 may be re-initialized via soundManager.beginDelayedInit().\r
+ * @return {object} soundManager The soundManager instance.\r
+ */\r
+\r
+ _wDS('reset');\r
+ return sm2.reboot(true, true);\r
+\r
+ };\r
+\r
+ /**\r
+ * Undocumented: Determines the SM2 flash movie's load progress.\r
+ *\r
+ * @return {number or null} Percent loaded, or if invalid/unsupported, null.\r
+ */\r
+\r
+ this.getMoviePercent = function() {\r
+\r
+ /**\r
+ * Interesting syntax notes...\r
+ * Flash/ExternalInterface (ActiveX/NPAPI) bridge methods are not typeof "function" nor instanceof Function, but are still valid.\r
+ * Additionally, JSLint dislikes ('PercentLoaded' in flash)-style syntax and recommends hasOwnProperty(), which does not work in this case.\r
+ * Furthermore, using (flash && flash.PercentLoaded) causes IE to throw "object doesn't support this property or method".\r
+ * Thus, 'in' syntax must be used.\r
+ */\r
+\r
+ return (flash && 'PercentLoaded' in flash ? flash.PercentLoaded() : null); // Yes, JSLint. See nearby comment in source for explanation.\r
+\r
+ };\r
+\r
+ /**\r
+ * Additional helper for manually invoking SM2's init process after DOM Ready / window.onload().\r
+ */\r
+\r
+ this.beginDelayedInit = function() {\r
+\r
+ windowLoaded = true;\r
+ domContentLoaded();\r
+\r
+ setTimeout(function() {\r
+\r
+ if (initPending) {\r
+ return false;\r
+ }\r
+\r
+ createMovie();\r
+ initMovie();\r
+ initPending = true;\r
+\r
+ return true;\r
+\r
+ }, 20);\r
+\r
+ delayWaitForEI();\r
+\r
+ };\r
+\r
+ /**\r
+ * Destroys the SoundManager instance and all SMSound instances.\r
+ */\r
+\r
+ this.destruct = function() {\r
+\r
+ sm2._wD(sm + '.destruct()');\r
+ sm2.disable(true);\r
+\r
+ };\r
+\r
+ /**\r
+ * SMSound() (sound object) constructor\r
+ * ------------------------------------\r
+ *\r
+ * @param {object} oOptions Sound options (id and url are required attributes)\r
+ * @return {SMSound} The new SMSound object\r
+ */\r
+\r
+ SMSound = function(oOptions) {\r
+\r
+ var s = this, resetProperties, add_html5_events, remove_html5_events, stop_html5_timer, start_html5_timer, attachOnPosition, onplay_called = false, onPositionItems = [], onPositionFired = 0, detachOnPosition, applyFromTo, lastURL = null, lastHTML5State;\r
+\r
+ lastHTML5State = {\r
+ // tracks duration + position (time)\r
+ duration: null,\r
+ time: null\r
+ };\r
+\r
+ this.id = oOptions.id;\r
+\r
+ // legacy\r
+ this.sID = this.id;\r
+\r
+ this.url = oOptions.url;\r
+ this.options = mixin(oOptions);\r
+\r
+ // per-play-instance-specific options\r
+ this.instanceOptions = this.options;\r
+\r
+ // short alias\r
+ this._iO = this.instanceOptions;\r
+\r
+ // assign property defaults\r
+ this.pan = this.options.pan;\r
+ this.volume = this.options.volume;\r
+\r
+ // whether or not this object is using HTML5\r
+ this.isHTML5 = false;\r
+\r
+ // internal HTML5 Audio() object reference\r
+ this._a = null;\r
+\r
+ /**\r
+ * SMSound() public methods\r
+ * ------------------------\r
+ */\r
+\r
+ this.id3 = {};\r
+\r
+ /**\r
+ * Writes SMSound object parameters to debug console\r
+ */\r
+\r
+ this._debug = function() {\r
+\r
+ // <d>\r
+ sm2._wD(s.id + ': Merged options:', s.options);\r
+ // </d>\r
+\r
+ };\r
+\r
+ /**\r
+ * Begins loading a sound per its *url*.\r
+ *\r
+ * @param {object} oOptions Optional: Sound options\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.load = function(oOptions) {\r
+\r
+ var oSound = null, instanceOptions;\r
+\r
+ if (oOptions !== _undefined) {\r
+ s._iO = mixin(oOptions, s.options);\r
+ } else {\r
+ oOptions = s.options;\r
+ s._iO = oOptions;\r
+ if (lastURL && lastURL !== s.url) {\r
+ _wDS('manURL');\r
+ s._iO.url = s.url;\r
+ s.url = null;\r
+ }\r
+ }\r
+\r
+ if (!s._iO.url) {\r
+ s._iO.url = s.url;\r
+ }\r
+\r
+ s._iO.url = parseURL(s._iO.url);\r
+\r
+ // ensure we're in sync\r
+ s.instanceOptions = s._iO;\r
+\r
+ // local shortcut\r
+ instanceOptions = s._iO;\r
+\r
+ sm2._wD(s.id + ': load (' + instanceOptions.url + ')');\r
+\r
+ if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) {\r
+ _wDS('onURL', 1);\r
+ // if loaded and an onload() exists, fire immediately.\r
+ if (s.readyState === 3 && instanceOptions.onload) {\r
+ // assume success based on truthy duration.\r
+ wrapCallback(s, function() {\r
+ instanceOptions.onload.apply(s, [(!!s.duration)]);\r
+ });\r
+ }\r
+ return s;\r
+ }\r
+\r
+ // reset a few state properties\r
+\r
+ s.loaded = false;\r
+ s.readyState = 1;\r
+ s.playState = 0;\r
+ s.id3 = {};\r
+\r
+ // TODO: If switching from HTML5 -> flash (or vice versa), stop currently-playing audio.\r
+\r
+ if (html5OK(instanceOptions)) {\r
+\r
+ oSound = s._setup_html5(instanceOptions);\r
+\r
+ if (!oSound._called_load) {\r
+\r
+ s._html5_canplay = false;\r
+\r
+ // TODO: review called_load / html5_canplay logic\r
+\r
+ // if url provided directly to load(), assign it here.\r
+\r
+ if (s.url !== instanceOptions.url) {\r
+\r
+ sm2._wD(_wDS('manURL') + ': ' + instanceOptions.url);\r
+\r
+ s._a.src = instanceOptions.url;\r
+\r
+ // TODO: review / re-apply all relevant options (volume, loop, onposition etc.)\r
+\r
+ // reset position for new URL\r
+ s.setPosition(0);\r
+\r
+ }\r
+\r
+ // given explicit load call, try to preload.\r
+\r
+ // early HTML5 implementation (non-standard)\r
+ s._a.autobuffer = 'auto';\r
+\r
+ // standard\r
+ s._a.preload = 'auto';\r
+\r
+ s._a._called_load = true;\r
+\r
+ if (instanceOptions.autoPlay) {\r
+ s.play();\r
+ }\r
+\r
+ } else {\r
+\r
+ sm2._wD(s.id + ': Ignoring request to load again');\r
+\r
+ }\r
+\r
+ } else {\r
+\r
+ try {\r
+ s.isHTML5 = false;\r
+ s._iO = policyFix(loopFix(instanceOptions));\r
+ // re-assign local shortcut\r
+ instanceOptions = s._iO;\r
+ if (fV === 8) {\r
+ flash._load(s.id, instanceOptions.url, instanceOptions.stream, instanceOptions.autoPlay, instanceOptions.usePolicyFile);\r
+ } else {\r
+ flash._load(s.id, instanceOptions.url, !!(instanceOptions.stream), !!(instanceOptions.autoPlay), instanceOptions.loops||1, !!(instanceOptions.autoLoad), instanceOptions.usePolicyFile);\r
+ }\r
+ } catch(e) {\r
+ _wDS('smError', 2);\r
+ debugTS('onload', false);\r
+ catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true});\r
+ }\r
+\r
+ }\r
+\r
+ // after all of this, ensure sound url is up to date.\r
+ s.url = instanceOptions.url;\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Unloads a sound, canceling any open HTTP requests.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.unload = function() {\r
+\r
+ // Flash 8/AS2 can't "close" a stream - fake it by loading an empty URL\r
+ // Flash 9/AS3: Close stream, preventing further load\r
+ // HTML5: Most UAs will use empty URL\r
+\r
+ if (s.readyState !== 0) {\r
+\r
+ sm2._wD(s.id + ': unload()');\r
+\r
+ if (!s.isHTML5) {\r
+\r
+ if (fV === 8) {\r
+ flash._unload(s.id, emptyURL);\r
+ } else {\r
+ flash._unload(s.id);\r
+ }\r
+\r
+ } else {\r
+\r
+ stop_html5_timer();\r
+\r
+ if (s._a) {\r
+\r
+ s._a.pause();\r
+ html5Unload(s._a, emptyURL);\r
+\r
+ // update empty URL, too\r
+ lastURL = emptyURL;\r
+\r
+ }\r
+\r
+ }\r
+\r
+ // reset load/status flags\r
+ resetProperties();\r
+\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Unloads and destroys a sound.\r
+ */\r
+\r
+ this.destruct = function(_bFromSM) {\r
+\r
+ sm2._wD(s.id + ': Destruct');\r
+\r
+ if (!s.isHTML5) {\r
+\r
+ // kill sound within Flash\r
+ // Disable the onfailure handler\r
+ s._iO.onfailure = null;\r
+ flash._destroySound(s.id);\r
+\r
+ } else {\r
+\r
+ stop_html5_timer();\r
+\r
+ if (s._a) {\r
+ s._a.pause();\r
+ html5Unload(s._a);\r
+ if (!useGlobalHTML5Audio) {\r
+ remove_html5_events();\r
+ }\r
+ // break obvious circular reference\r
+ s._a._s = null;\r
+ s._a = null;\r
+ }\r
+\r
+ }\r
+\r
+ if (!_bFromSM) {\r
+ // ensure deletion from controller\r
+ sm2.destroySound(s.id, true);\r
+\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Begins playing a sound.\r
+ *\r
+ * @param {object} oOptions Optional: Sound options\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.play = function(oOptions, _updatePlayState) {\r
+\r
+ var fN, allowMulti, a, onready, startOK = true,\r
+ exit = null;\r
+\r
+ // <d>\r
+ fN = s.id + ': play(): ';\r
+ // </d>\r
+\r
+ // default to true\r
+ _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState);\r
+\r
+ if (!oOptions) {\r
+ oOptions = {};\r
+ }\r
+\r
+ // first, use local URL (if specified)\r
+ if (s.url) {\r
+ s._iO.url = s.url;\r
+ }\r
+\r
+ // mix in any options defined at createSound()\r
+ s._iO = mixin(s._iO, s.options);\r
+\r
+ // mix in any options specific to this method\r
+ s._iO = mixin(oOptions, s._iO);\r
+\r
+ s._iO.url = parseURL(s._iO.url);\r
+\r
+ s.instanceOptions = s._iO;\r
+\r
+ // RTMP-only\r
+ if (s._iO.serverURL && !s.connected) {\r
+ if (!s.getAutoPlay()) {\r
+ sm2._wD(fN +' Netstream not connected yet - setting autoPlay');\r
+ s.setAutoPlay(true);\r
+ }\r
+ // play will be called in onconnect()\r
+ return s;\r
+ }\r
+\r
+ if (html5OK(s._iO)) {\r
+ s._setup_html5(s._iO);\r
+ start_html5_timer();\r
+ }\r
+\r
+ if (s.playState === 1 && !s.paused) {\r
+ allowMulti = s._iO.multiShot;\r
+ if (!allowMulti) {\r
+ sm2._wD(fN + 'Already playing (one-shot)', 1);\r
+ exit = s;\r
+ } else {\r
+ sm2._wD(fN + 'Already playing (multi-shot)', 1);\r
+ }\r
+ }\r
+\r
+ if (exit !== null) {\r
+ return exit;\r
+ }\r
+\r
+ // edge case: play() with explicit URL parameter\r
+ if (oOptions.url && oOptions.url !== s.url) {\r
+ // load using merged options\r
+ s.load(s._iO);\r
+ }\r
+\r
+ if (!s.loaded) {\r
+\r
+ if (s.readyState === 0) {\r
+\r
+ sm2._wD(fN + 'Attempting to load');\r
+\r
+ // try to get this sound playing ASAP\r
+ if (!s.isHTML5) {\r
+ // assign directly because setAutoPlay() increments the instanceCount\r
+ s._iO.autoPlay = true;\r
+ s.load(s._iO);\r
+ } else {\r
+ // iOS needs this when recycling sounds, loading a new URL on an existing object.\r
+ s.load(s._iO);\r
+ }\r
+\r
+ // HTML5 hack - re-set instanceOptions?\r
+ s.instanceOptions = s._iO;\r
+\r
+ } else if (s.readyState === 2) {\r
+\r
+ sm2._wD(fN + 'Could not load - exiting', 2);\r
+ exit = s;\r
+\r
+ } else {\r
+\r
+ sm2._wD(fN + 'Loading - attempting to play...');\r
+\r
+ }\r
+\r
+ } else {\r
+\r
+ // "play()"\r
+ sm2._wD(fN.substr(0, fN.lastIndexOf(':')));\r
+\r
+ }\r
+\r
+ if (exit !== null) {\r
+ return exit;\r
+ }\r
+\r
+ if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) {\r
+ // flash 9 needs a position reset if play() is called while at the end of a sound.\r
+ sm2._wD(fN + 'Sound at end, resetting to position:0');\r
+ oOptions.position = 0;\r
+ }\r
+\r
+ /**\r
+ * Streams will pause when their buffer is full if they are being loaded.\r
+ * In this case paused is true, but the song hasn't started playing yet.\r
+ * If we just call resume() the onplay() callback will never be called.\r
+ * So only call resume() if the position is > 0.\r
+ * Another reason is because options like volume won't have been applied yet.\r
+ * For normal sounds, just resume.\r
+ */\r
+\r
+ if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position > 0)) {\r
+\r
+ // https://gist.github.com/37b17df75cc4d7a90bf6\r
+ sm2._wD(fN + 'Resuming from paused state', 1);\r
+ s.resume();\r
+\r
+ } else {\r
+\r
+ s._iO = mixin(oOptions, s._iO);\r
+\r
+ // apply from/to parameters, if they exist (and not using RTMP)\r
+ if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {\r
+\r
+ onready = function() {\r
+ // sound "canplay" or onload()\r
+ // re-apply from/to to instance options, and start playback\r
+ s._iO = mixin(oOptions, s._iO);\r
+ s.play(s._iO);\r
+ };\r
+\r
+ // HTML5 needs to at least have "canplay" fired before seeking.\r
+ if (s.isHTML5 && !s._html5_canplay) {\r
+\r
+ // this hasn't been loaded yet. load it first, and then do this again.\r
+ sm2._wD(fN + 'Beginning load for from/to case');\r
+\r
+ s.load({\r
+ // TODO: was _oncanplay. Sounds wrong.\r
+ oncanplay: onready\r
+ });\r
+\r
+ exit = false;\r
+\r
+ } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) {\r
+\r
+ // to be safe, preload the whole thing in Flash.\r
+\r
+ sm2._wD(fN + 'Preloading for from/to case');\r
+\r
+ s.load({\r
+ onload: onready\r
+ });\r
+\r
+ exit = false;\r
+\r
+ }\r
+\r
+ if (exit !== null) {\r
+ return exit;\r
+ }\r
+\r
+ // otherwise, we're ready to go. re-apply local options, and continue\r
+\r
+ s._iO = applyFromTo();\r
+\r
+ }\r
+\r
+ sm2._wD(fN + 'Starting to play');\r
+\r
+ if (!s.instanceCount || s._iO.multiShotEvents || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) {\r
+ s.instanceCount++;\r
+ }\r
+\r
+ // if first play and onposition parameters exist, apply them now\r
+ if (s._iO.onposition && s.playState === 0) {\r
+ attachOnPosition(s);\r
+ }\r
+\r
+ s.playState = 1;\r
+ s.paused = false;\r
+\r
+ s.position = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position : 0);\r
+\r
+ if (!s.isHTML5) {\r
+ s._iO = policyFix(loopFix(s._iO));\r
+ }\r
+\r
+ if (s._iO.onplay && _updatePlayState) {\r
+ s._iO.onplay.apply(s);\r
+ onplay_called = true;\r
+ }\r
+\r
+ s.setVolume(s._iO.volume, true);\r
+ s.setPan(s._iO.pan, true);\r
+\r
+ if (!s.isHTML5) {\r
+\r
+ startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / 1000), s._iO.multiShot || false);\r
+\r
+ if (fV === 9 && !startOK) {\r
+ // edge case: no sound hardware, or 32-channel flash ceiling hit.\r
+ // applies only to Flash 9, non-NetStream/MovieStar sounds.\r
+ // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29\r
+ sm2._wD(fN + 'No sound hardware, or 32-sound ceiling hit');\r
+ if (s._iO.onplayerror) {\r
+ s._iO.onplayerror.apply(s);\r
+ }\r
+\r
+ }\r
+\r
+ } else {\r
+\r
+ start_html5_timer();\r
+\r
+ a = s._setup_html5();\r
+\r
+ s.setPosition(s._iO.position);\r
+\r
+ a.play();\r
+\r
+ }\r
+\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ // just for convenience\r
+ this.start = this.play;\r
+\r
+ /**\r
+ * Stops playing a sound (and optionally, all sounds)\r
+ *\r
+ * @param {boolean} bAll Optional: Whether to stop all sounds\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.stop = function(bAll) {\r
+\r
+ var instanceOptions = s._iO,\r
+ originalPosition;\r
+\r
+ if (s.playState === 1) {\r
+\r
+ sm2._wD(s.id + ': stop()');\r
+\r
+ s._onbufferchange(0);\r
+ s._resetOnPosition(0);\r
+ s.paused = false;\r
+\r
+ if (!s.isHTML5) {\r
+ s.playState = 0;\r
+ }\r
+\r
+ // remove onPosition listeners, if any\r
+ detachOnPosition();\r
+\r
+ // and "to" position, if set\r
+ if (instanceOptions.to) {\r
+ s.clearOnPosition(instanceOptions.to);\r
+ }\r
+\r
+ if (!s.isHTML5) {\r
+\r
+ flash._stop(s.id, bAll);\r
+\r
+ // hack for netStream: just unload\r
+ if (instanceOptions.serverURL) {\r
+ s.unload();\r
+ }\r
+\r
+ } else {\r
+\r
+ if (s._a) {\r
+\r
+ originalPosition = s.position;\r
+\r
+ // act like Flash, though\r
+ s.setPosition(0);\r
+\r
+ // hack: reflect old position for onstop() (also like Flash)\r
+ s.position = originalPosition;\r
+\r
+ // html5 has no stop()\r
+ // NOTE: pausing means iOS requires interaction to resume.\r
+ s._a.pause();\r
+\r
+ s.playState = 0;\r
+\r
+ // and update UI\r
+ s._onTimer();\r
+\r
+ stop_html5_timer();\r
+\r
+ }\r
+\r
+ }\r
+\r
+ s.instanceCount = 0;\r
+ s._iO = {};\r
+\r
+ if (instanceOptions.onstop) {\r
+ instanceOptions.onstop.apply(s);\r
+ }\r
+\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Undocumented/internal: Sets autoPlay for RTMP.\r
+ *\r
+ * @param {boolean} autoPlay state\r
+ */\r
+\r
+ this.setAutoPlay = function(autoPlay) {\r
+\r
+ sm2._wD(s.id + ': Autoplay turned ' + (autoPlay ? 'on' : 'off'));\r
+ s._iO.autoPlay = autoPlay;\r
+\r
+ if (!s.isHTML5) {\r
+ flash._setAutoPlay(s.id, autoPlay);\r
+ if (autoPlay) {\r
+ // only increment the instanceCount if the sound isn't loaded (TODO: verify RTMP)\r
+ if (!s.instanceCount && s.readyState === 1) {\r
+ s.instanceCount++;\r
+ sm2._wD(s.id + ': Incremented instance count to '+s.instanceCount);\r
+ }\r
+ }\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Undocumented/internal: Returns the autoPlay boolean.\r
+ *\r
+ * @return {boolean} The current autoPlay value\r
+ */\r
+\r
+ this.getAutoPlay = function() {\r
+\r
+ return s._iO.autoPlay;\r
+\r
+ };\r
+\r
+ /**\r
+ * Sets the position of a sound.\r
+ *\r
+ * @param {number} nMsecOffset Position (milliseconds)\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.setPosition = function(nMsecOffset) {\r
+\r
+ if (nMsecOffset === _undefined) {\r
+ nMsecOffset = 0;\r
+ }\r
+\r
+ var original_pos,\r
+ position, position1K,\r
+ // Use the duration from the instance options, if we don't have a track duration yet.\r
+ // position >= 0 and <= current available (loaded) duration\r
+ offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0)));\r
+\r
+ original_pos = s.position;\r
+ s.position = offset;\r
+ position1K = s.position/1000;\r
+ s._resetOnPosition(s.position);\r
+ s._iO.position = offset;\r
+\r
+ if (!s.isHTML5) {\r
+\r
+ position = (fV === 9 ? s.position : position1K);\r
+ if (s.readyState && s.readyState !== 2) {\r
+ // if paused or not playing, will not resume (by playing)\r
+ flash._setPosition(s.id, position, (s.paused || !s.playState), s._iO.multiShot);\r
+ }\r
+\r
+ } else if (s._a) {\r
+\r
+ // Set the position in the canplay handler if the sound is not ready yet\r
+ if (s._html5_canplay) {\r
+ if (s._a.currentTime !== position1K) {\r
+ /**\r
+ * DOM/JS errors/exceptions to watch out for:\r
+ * if seek is beyond (loaded?) position, "DOM exception 11"\r
+ * "INDEX_SIZE_ERR": DOM exception 1\r
+ */\r
+ sm2._wD(s.id + ': setPosition('+position1K+')');\r
+ try {\r
+ s._a.currentTime = position1K;\r
+ if (s.playState === 0 || s.paused) {\r
+ // allow seek without auto-play/resume\r
+ s._a.pause();\r
+ }\r
+ } catch(e) {\r
+ sm2._wD(s.id + ': setPosition(' + position1K + ') failed: ' + e.message, 2);\r
+ }\r
+ }\r
+ } else {\r
+ sm2._wD(s.id + ': setPosition(' + position1K + '): Cannot seek yet, sound not ready');\r
+ }\r
+\r
+ }\r
+\r
+ if (s.isHTML5) {\r
+ if (s.paused) {\r
+ // if paused, refresh UI right away\r
+ // force update\r
+ s._onTimer(true);\r
+ }\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Pauses sound playback.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.pause = function(_bCallFlash) {\r
+\r
+ if (s.paused || (s.playState === 0 && s.readyState !== 1)) {\r
+ return s;\r
+ }\r
+\r
+ sm2._wD(s.id + ': pause()');\r
+ s.paused = true;\r
+\r
+ if (!s.isHTML5) {\r
+ if (_bCallFlash || _bCallFlash === _undefined) {\r
+ flash._pause(s.id, s._iO.multiShot);\r
+ }\r
+ } else {\r
+ s._setup_html5().pause();\r
+ stop_html5_timer();\r
+ }\r
+\r
+ if (s._iO.onpause) {\r
+ s._iO.onpause.apply(s);\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Resumes sound playback.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ /**\r
+ * When auto-loaded streams pause on buffer full they have a playState of 0.\r
+ * We need to make sure that the playState is set to 1 when these streams "resume".\r
+ * When a paused stream is resumed, we need to trigger the onplay() callback if it\r
+ * hasn't been called already. In this case since the sound is being played for the\r
+ * first time, I think it's more appropriate to call onplay() rather than onresume().\r
+ */\r
+\r
+ this.resume = function() {\r
+\r
+ var instanceOptions = s._iO;\r
+\r
+ if (!s.paused) {\r
+ return s;\r
+ }\r
+\r
+ sm2._wD(s.id + ': resume()');\r
+ s.paused = false;\r
+ s.playState = 1;\r
+\r
+ if (!s.isHTML5) {\r
+ if (instanceOptions.isMovieStar && !instanceOptions.serverURL) {\r
+ // Bizarre Webkit bug (Chrome reported via 8tracks.com dudes): AAC content paused for 30+ seconds(?) will not resume without a reposition.\r
+ s.setPosition(s.position);\r
+ }\r
+ // flash method is toggle-based (pause/resume)\r
+ flash._pause(s.id, instanceOptions.multiShot);\r
+ } else {\r
+ s._setup_html5().play();\r
+ start_html5_timer();\r
+ }\r
+\r
+ if (!onplay_called && instanceOptions.onplay) {\r
+ instanceOptions.onplay.apply(s);\r
+ onplay_called = true;\r
+ } else if (instanceOptions.onresume) {\r
+ instanceOptions.onresume.apply(s);\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Toggles sound playback.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.togglePause = function() {\r
+\r
+ sm2._wD(s.id + ': togglePause()');\r
+\r
+ if (s.playState === 0) {\r
+ s.play({\r
+ position: (fV === 9 && !s.isHTML5 ? s.position : s.position / 1000)\r
+ });\r
+ return s;\r
+ }\r
+\r
+ if (s.paused) {\r
+ s.resume();\r
+ } else {\r
+ s.pause();\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Sets the panning (L-R) effect.\r
+ *\r
+ * @param {number} nPan The pan value (-100 to 100)\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.setPan = function(nPan, bInstanceOnly) {\r
+\r
+ if (nPan === _undefined) {\r
+ nPan = 0;\r
+ }\r
+\r
+ if (bInstanceOnly === _undefined) {\r
+ bInstanceOnly = false;\r
+ }\r
+\r
+ if (!s.isHTML5) {\r
+ flash._setPan(s.id, nPan);\r
+ } // else { no HTML5 pan? }\r
+\r
+ s._iO.pan = nPan;\r
+\r
+ if (!bInstanceOnly) {\r
+ s.pan = nPan;\r
+ s.options.pan = nPan;\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Sets the volume.\r
+ *\r
+ * @param {number} nVol The volume value (0 to 100)\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.setVolume = function(nVol, _bInstanceOnly) {\r
+\r
+ /**\r
+ * Note: Setting volume has no effect on iOS "special snowflake" devices.\r
+ * Hardware volume control overrides software, and volume\r
+ * will always return 1 per Apple docs. (iOS 4 + 5.)\r
+ * http://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/AddingSoundtoCanvasAnimations/AddingSoundtoCanvasAnimations.html\r
+ */\r
+\r
+ if (nVol === _undefined) {\r
+ nVol = 100;\r
+ }\r
+\r
+ if (_bInstanceOnly === _undefined) {\r
+ _bInstanceOnly = false;\r
+ }\r
+\r
+ if (!s.isHTML5) {\r
+ flash._setVolume(s.id, (sm2.muted && !s.muted) || s.muted?0:nVol);\r
+ } else if (s._a) {\r
+ // valid range: 0-1\r
+ s._a.volume = Math.max(0, Math.min(1, nVol/100));\r
+ }\r
+\r
+ s._iO.volume = nVol;\r
+\r
+ if (!_bInstanceOnly) {\r
+ s.volume = nVol;\r
+ s.options.volume = nVol;\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Mutes the sound.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.mute = function() {\r
+\r
+ s.muted = true;\r
+\r
+ if (!s.isHTML5) {\r
+ flash._setVolume(s.id, 0);\r
+ } else if (s._a) {\r
+ s._a.muted = true;\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Unmutes the sound.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.unmute = function() {\r
+\r
+ s.muted = false;\r
+ var hasIO = (s._iO.volume !== _undefined);\r
+\r
+ if (!s.isHTML5) {\r
+ flash._setVolume(s.id, hasIO?s._iO.volume:s.options.volume);\r
+ } else if (s._a) {\r
+ s._a.muted = false;\r
+ }\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ /**\r
+ * Toggles the muted state of a sound.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.toggleMute = function() {\r
+\r
+ return (s.muted?s.unmute():s.mute());\r
+\r
+ };\r
+\r
+ /**\r
+ * Registers a callback to be fired when a sound reaches a given position during playback.\r
+ *\r
+ * @param {number} nPosition The position to watch for\r
+ * @param {function} oMethod The relevant callback to fire\r
+ * @param {object} oScope Optional: The scope to apply the callback to\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.onPosition = function(nPosition, oMethod, oScope) {\r
+\r
+ // TODO: basic dupe checking?\r
+\r
+ onPositionItems.push({\r
+ position: parseInt(nPosition, 10),\r
+ method: oMethod,\r
+ scope: (oScope !== _undefined ? oScope : s),\r
+ fired: false\r
+ });\r
+\r
+ return s;\r
+\r
+ };\r
+\r
+ // legacy/backwards-compability: lower-case method name\r
+ this.onposition = this.onPosition;\r
+\r
+ /**\r
+ * Removes registered callback(s) from a sound, by position and/or callback.\r
+ *\r
+ * @param {number} nPosition The position to clear callback(s) for\r
+ * @param {function} oMethod Optional: Identify one callback to be removed when multiple listeners exist for one position\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.clearOnPosition = function(nPosition, oMethod) {\r
+\r
+ var i;\r
+\r
+ nPosition = parseInt(nPosition, 10);\r
+\r
+ if (isNaN(nPosition)) {\r
+ // safety check\r
+ return false;\r
+ }\r
+\r
+ for (i=0; i < onPositionItems.length; i++) {\r
+\r
+ if (nPosition === onPositionItems[i].position) {\r
+ // remove this item if no method was specified, or, if the method matches\r
+ if (!oMethod || (oMethod === onPositionItems[i].method)) {\r
+ if (onPositionItems[i].fired) {\r
+ // decrement "fired" counter, too\r
+ onPositionFired--;\r
+ }\r
+ onPositionItems.splice(i, 1);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ this._processOnPosition = function() {\r
+\r
+ var i, item, j = onPositionItems.length;\r
+\r
+ if (!j || !s.playState || onPositionFired >= j) {\r
+ return false;\r
+ }\r
+\r
+ for (i=j-1; i >= 0; i--) {\r
+ item = onPositionItems[i];\r
+ if (!item.fired && s.position >= item.position) {\r
+ item.fired = true;\r
+ onPositionFired++;\r
+ item.method.apply(item.scope, [item.position]);\r
+ }\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ this._resetOnPosition = function(nPosition) {\r
+\r
+ // reset "fired" for items interested in this position\r
+ var i, item, j = onPositionItems.length;\r
+\r
+ if (!j) {\r
+ return false;\r
+ }\r
+\r
+ for (i=j-1; i >= 0; i--) {\r
+ item = onPositionItems[i];\r
+ if (item.fired && nPosition <= item.position) {\r
+ item.fired = false;\r
+ onPositionFired--;\r
+ }\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * SMSound() private internals\r
+ * --------------------------------\r
+ */\r
+\r
+ applyFromTo = function() {\r
+\r
+ var instanceOptions = s._iO,\r
+ f = instanceOptions.from,\r
+ t = instanceOptions.to,\r
+ start, end;\r
+\r
+ end = function() {\r
+\r
+ // end has been reached.\r
+ sm2._wD(s.id + ': "To" time of ' + t + ' reached.');\r
+\r
+ // detach listener\r
+ s.clearOnPosition(t, end);\r
+\r
+ // stop should clear this, too\r
+ s.stop();\r
+\r
+ };\r
+\r
+ start = function() {\r
+\r
+ sm2._wD(s.id + ': Playing "from" ' + f);\r
+\r
+ // add listener for end\r
+ if (t !== null && !isNaN(t)) {\r
+ s.onPosition(t, end);\r
+ }\r
+\r
+ };\r
+\r
+ if (f !== null && !isNaN(f)) {\r
+\r
+ // apply to instance options, guaranteeing correct start position.\r
+ instanceOptions.position = f;\r
+\r
+ // multiShot timing can't be tracked, so prevent that.\r
+ instanceOptions.multiShot = false;\r
+\r
+ start();\r
+\r
+ }\r
+\r
+ // return updated instanceOptions including starting position\r
+ return instanceOptions;\r
+\r
+ };\r
+\r
+ attachOnPosition = function() {\r
+\r
+ var item,\r
+ op = s._iO.onposition;\r
+\r
+ // attach onposition things, if any, now.\r
+\r
+ if (op) {\r
+\r
+ for (item in op) {\r
+ if (op.hasOwnProperty(item)) {\r
+ s.onPosition(parseInt(item, 10), op[item]); \r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ detachOnPosition = function() {\r
+\r
+ var item,\r
+ op = s._iO.onposition;\r
+\r
+ // detach any onposition()-style listeners.\r
+\r
+ if (op) {\r
+\r
+ for (item in op) {\r
+ if (op.hasOwnProperty(item)) {\r
+ s.clearOnPosition(parseInt(item, 10));\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ start_html5_timer = function() {\r
+\r
+ if (s.isHTML5) {\r
+ startTimer(s);\r
+ }\r
+\r
+ };\r
+\r
+ stop_html5_timer = function() {\r
+\r
+ if (s.isHTML5) {\r
+ stopTimer(s);\r
+ }\r
+\r
+ };\r
+\r
+ resetProperties = function(retainPosition) {\r
+\r
+ if (!retainPosition) {\r
+ onPositionItems = [];\r
+ onPositionFired = 0;\r
+ }\r
+\r
+ onplay_called = false;\r
+\r
+ s._hasTimer = null;\r
+ s._a = null;\r
+ s._html5_canplay = false;\r
+ s.bytesLoaded = null;\r
+ s.bytesTotal = null;\r
+ s.duration = (s._iO && s._iO.duration ? s._iO.duration : null);\r
+ s.durationEstimate = null;\r
+ s.buffered = [];\r
+\r
+ // legacy: 1D array\r
+ s.eqData = [];\r
+\r
+ s.eqData.left = [];\r
+ s.eqData.right = [];\r
+\r
+ s.failures = 0;\r
+ s.isBuffering = false;\r
+ s.instanceOptions = {};\r
+ s.instanceCount = 0;\r
+ s.loaded = false;\r
+ s.metadata = {};\r
+\r
+ // 0 = uninitialised, 1 = loading, 2 = failed/error, 3 = loaded/success\r
+ s.readyState = 0;\r
+\r
+ s.muted = false;\r
+ s.paused = false;\r
+\r
+ s.peakData = {\r
+ left: 0,\r
+ right: 0\r
+ };\r
+\r
+ s.waveformData = {\r
+ left: [],\r
+ right: []\r
+ };\r
+\r
+ s.playState = 0;\r
+ s.position = null;\r
+\r
+ s.id3 = {};\r
+\r
+ };\r
+\r
+ resetProperties();\r
+\r
+ /**\r
+ * Pseudo-private SMSound internals\r
+ * --------------------------------\r
+ */\r
+\r
+ this._onTimer = function(bForce) {\r
+\r
+ /**\r
+ * HTML5-only _whileplaying() etc.\r
+ * called from both HTML5 native events, and polling/interval-based timers\r
+ * mimics flash and fires only when time/duration change, so as to be polling-friendly\r
+ */\r
+\r
+ var duration, isNew = false, time, x = {};\r
+\r
+ if (s._hasTimer || bForce) {\r
+\r
+ // TODO: May not need to track readyState (1 = loading)\r
+\r
+ if (s._a && (bForce || ((s.playState > 0 || s.readyState === 1) && !s.paused))) {\r
+\r
+ duration = s._get_html5_duration();\r
+\r
+ if (duration !== lastHTML5State.duration) {\r
+\r
+ lastHTML5State.duration = duration;\r
+ s.duration = duration;\r
+ isNew = true;\r
+\r
+ }\r
+\r
+ // TODO: investigate why this goes wack if not set/re-set each time.\r
+ s.durationEstimate = s.duration;\r
+\r
+ time = (s._a.currentTime * 1000 || 0);\r
+\r
+ if (time !== lastHTML5State.time) {\r
+\r
+ lastHTML5State.time = time;\r
+ isNew = true;\r
+\r
+ }\r
+\r
+ if (isNew || bForce) {\r
+\r
+ s._whileplaying(time,x,x,x,x);\r
+\r
+ }\r
+\r
+ }/* else {\r
+\r
+ // sm2._wD('_onTimer: Warn for "'+s.id+'": '+(!s._a?'Could not find element. ':'')+(s.playState === 0?'playState bad, 0?':'playState = '+s.playState+', OK'));\r
+\r
+ return false;\r
+\r
+ }*/\r
+\r
+ return isNew;\r
+\r
+ }\r
+\r
+ };\r
+\r
+ this._get_html5_duration = function() {\r
+\r
+ var instanceOptions = s._iO,\r
+ // if audio object exists, use its duration - else, instance option duration (if provided - it's a hack, really, and should be retired) OR null\r
+ d = (s._a && s._a.duration ? s._a.duration*1000 : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)),\r
+ result = (d && !isNaN(d) && d !== Infinity ? d : null);\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ this._apply_loop = function(a, nLoops) {\r
+\r
+ /**\r
+ * boolean instead of "loop", for webkit? - spec says string. http://www.w3.org/TR/html-markup/audio.html#audio.attrs.loop\r
+ * note that loop is either off or infinite under HTML5, unlike Flash which allows arbitrary loop counts to be specified.\r
+ */\r
+\r
+ // <d>\r
+ if (!a.loop && nLoops > 1) {\r
+ sm2._wD('Note: Native HTML5 looping is infinite.', 1);\r
+ }\r
+ // </d>\r
+\r
+ a.loop = (nLoops > 1 ? 'loop' : '');\r
+\r
+ };\r
+\r
+ this._setup_html5 = function(oOptions) {\r
+\r
+ var instanceOptions = mixin(s._iO, oOptions),\r
+ a = useGlobalHTML5Audio ? globalHTML5Audio : s._a,\r
+ dURL = decodeURI(instanceOptions.url),\r
+ sameURL;\r
+\r
+ /**\r
+ * "First things first, I, Poppa..." (reset the previous state of the old sound, if playing)\r
+ * Fixes case with devices that can only play one sound at a time\r
+ * Otherwise, other sounds in mid-play will be terminated without warning and in a stuck state\r
+ */\r
+\r
+ if (useGlobalHTML5Audio) {\r
+\r
+ if (dURL === decodeURI(lastGlobalHTML5URL)) {\r
+ // global HTML5 audio: re-use of URL\r
+ sameURL = true;\r
+ }\r
+\r
+ } else if (dURL === decodeURI(lastURL)) {\r
+\r
+ // options URL is the same as the "last" URL, and we used (loaded) it\r
+ sameURL = true;\r
+\r
+ }\r
+\r
+ if (a) {\r
+\r
+ if (a._s) {\r
+\r
+ if (useGlobalHTML5Audio) {\r
+\r
+ if (a._s && a._s.playState && !sameURL) {\r
+\r
+ // global HTML5 audio case, and loading a new URL. stop the currently-playing one.\r
+ a._s.stop();\r
+\r
+ }\r
+\r
+ } else if (!useGlobalHTML5Audio && dURL === decodeURI(lastURL)) {\r
+\r
+ // non-global HTML5 reuse case: same url, ignore request\r
+ s._apply_loop(a, instanceOptions.loops);\r
+\r
+ return a;\r
+\r
+ }\r
+\r
+ }\r
+\r
+ if (!sameURL) {\r
+\r
+ // don't retain onPosition() stuff with new URL.\r
+\r
+ resetProperties(false);\r
+\r
+ // assign new HTML5 URL\r
+\r
+ a.src = instanceOptions.url;\r
+\r
+ s.url = instanceOptions.url;\r
+\r
+ lastURL = instanceOptions.url;\r
+\r
+ lastGlobalHTML5URL = instanceOptions.url;\r
+\r
+ a._called_load = false;\r
+\r
+ }\r
+\r
+ } else {\r
+\r
+ if (instanceOptions.autoLoad || instanceOptions.autoPlay) {\r
+\r
+ s._a = new Audio(instanceOptions.url);\r
+\r
+ } else {\r
+\r
+ // null for stupid Opera 9.64 case\r
+ s._a = (isOpera && opera.version() < 10 ? new Audio(null) : new Audio());\r
+\r
+ }\r
+\r
+ // assign local reference\r
+ a = s._a;\r
+\r
+ a._called_load = false;\r
+\r
+ if (useGlobalHTML5Audio) {\r
+\r
+ globalHTML5Audio = a;\r
+\r
+ }\r
+\r
+ }\r
+\r
+ s.isHTML5 = true;\r
+\r
+ // store a ref on the track\r
+ s._a = a;\r
+\r
+ // store a ref on the audio\r
+ a._s = s;\r
+\r
+ add_html5_events();\r
+\r
+ s._apply_loop(a, instanceOptions.loops);\r
+\r
+ if (instanceOptions.autoLoad || instanceOptions.autoPlay) {\r
+\r
+ s.load();\r
+\r
+ } else {\r
+\r
+ // early HTML5 implementation (non-standard)\r
+ a.autobuffer = false;\r
+\r
+ // standard ('none' is also an option.)\r
+ a.preload = 'auto';\r
+\r
+ }\r
+\r
+ return a;\r
+\r
+ };\r
+\r
+ add_html5_events = function() {\r
+\r
+ if (s._a._added_events) {\r
+ return false;\r
+ }\r
+\r
+ var f;\r
+\r
+ function add(oEvt, oFn, bCapture) {\r
+ return s._a ? s._a.addEventListener(oEvt, oFn, bCapture||false) : null;\r
+ }\r
+\r
+ s._a._added_events = true;\r
+\r
+ for (f in html5_events) {\r
+ if (html5_events.hasOwnProperty(f)) {\r
+ add(f, html5_events[f]);\r
+ }\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ remove_html5_events = function() {\r
+\r
+ // Remove event listeners\r
+\r
+ var f;\r
+\r
+ function remove(oEvt, oFn, bCapture) {\r
+ return (s._a ? s._a.removeEventListener(oEvt, oFn, bCapture||false) : null);\r
+ }\r
+\r
+ sm2._wD(s.id + ': Removing event listeners');\r
+ s._a._added_events = false;\r
+\r
+ for (f in html5_events) {\r
+ if (html5_events.hasOwnProperty(f)) {\r
+ remove(f, html5_events[f]);\r
+ }\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Pseudo-private event internals\r
+ * ------------------------------\r
+ */\r
+\r
+ this._onload = function(nSuccess) {\r
+\r
+ var fN,\r
+ // check for duration to prevent false positives from flash 8 when loading from cache.\r
+ loadOK = !!nSuccess || (!s.isHTML5 && fV === 8 && s.duration);\r
+\r
+ // <d>\r
+ fN = s.id + ': ';\r
+ sm2._wD(fN + (loadOK ? 'onload()' : 'Failed to load? - ' + s.url), (loadOK ? 1 : 2));\r
+ if (!loadOK && !s.isHTML5) {\r
+ if (sm2.sandbox.noRemote === true) {\r
+ sm2._wD(fN + str('noNet'), 1);\r
+ }\r
+ if (sm2.sandbox.noLocal === true) {\r
+ sm2._wD(fN + str('noLocal'), 1);\r
+ }\r
+ }\r
+ // </d>\r
+\r
+ s.loaded = loadOK;\r
+ s.readyState = loadOK?3:2;\r
+ s._onbufferchange(0);\r
+\r
+ if (s._iO.onload) {\r
+ wrapCallback(s, function() {\r
+ s._iO.onload.apply(s, [loadOK]);\r
+ });\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ this._onbufferchange = function(nIsBuffering) {\r
+\r
+ if (s.playState === 0) {\r
+ // ignore if not playing\r
+ return false;\r
+ }\r
+\r
+ if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) {\r
+ return false;\r
+ }\r
+\r
+ s.isBuffering = (nIsBuffering === 1);\r
+ if (s._iO.onbufferchange) {\r
+ sm2._wD(s.id + ': Buffer state change: ' + nIsBuffering);\r
+ s._iO.onbufferchange.apply(s);\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * Playback may have stopped due to buffering, or related reason.\r
+ * This state can be encountered on iOS < 6 when auto-play is blocked.\r
+ */\r
+\r
+ this._onsuspend = function() {\r
+\r
+ if (s._iO.onsuspend) {\r
+ sm2._wD(s.id + ': Playback suspended');\r
+ s._iO.onsuspend.apply(s);\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * flash 9/movieStar + RTMP-only method, should fire only once at most\r
+ * at this point we just recreate failed sounds rather than trying to reconnect\r
+ */\r
+\r
+ this._onfailure = function(msg, level, code) {\r
+\r
+ s.failures++;\r
+ sm2._wD(s.id + ': Failures = ' + s.failures);\r
+\r
+ if (s._iO.onfailure && s.failures === 1) {\r
+ s._iO.onfailure(s, msg, level, code);\r
+ } else {\r
+ sm2._wD(s.id + ': Ignoring failure');\r
+ }\r
+\r
+ };\r
+\r
+ this._onfinish = function() {\r
+\r
+ // store local copy before it gets trashed...\r
+ var io_onfinish = s._iO.onfinish;\r
+\r
+ s._onbufferchange(0);\r
+ s._resetOnPosition(0);\r
+\r
+ // reset some state items\r
+ if (s.instanceCount) {\r
+\r
+ s.instanceCount--;\r
+\r
+ if (!s.instanceCount) {\r
+\r
+ // remove onPosition listeners, if any\r
+ detachOnPosition();\r
+\r
+ // reset instance options\r
+ s.playState = 0;\r
+ s.paused = false;\r
+ s.instanceCount = 0;\r
+ s.instanceOptions = {};\r
+ s._iO = {};\r
+ stop_html5_timer();\r
+\r
+ // reset position, too\r
+ if (s.isHTML5) {\r
+ s.position = 0;\r
+ }\r
+\r
+ }\r
+\r
+ if (!s.instanceCount || s._iO.multiShotEvents) {\r
+ // fire onfinish for last, or every instance\r
+ if (io_onfinish) {\r
+ sm2._wD(s.id + ': onfinish()');\r
+ wrapCallback(s, function() {\r
+ io_onfinish.apply(s);\r
+ });\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) {\r
+\r
+ var instanceOptions = s._iO;\r
+\r
+ s.bytesLoaded = nBytesLoaded;\r
+ s.bytesTotal = nBytesTotal;\r
+ s.duration = Math.floor(nDuration);\r
+ s.bufferLength = nBufferLength;\r
+\r
+ if (!s.isHTML5 && !instanceOptions.isMovieStar) {\r
+\r
+ if (instanceOptions.duration) {\r
+ // use duration from options, if specified and larger. nobody should be specifying duration in options, actually, and it should be retired.\r
+ s.durationEstimate = (s.duration > instanceOptions.duration) ? s.duration : instanceOptions.duration;\r
+ } else {\r
+ s.durationEstimate = parseInt((s.bytesTotal / s.bytesLoaded) * s.duration, 10);\r
+ }\r
+\r
+ } else {\r
+\r
+ s.durationEstimate = s.duration;\r
+\r
+ }\r
+\r
+ // for flash, reflect sequential-load-style buffering\r
+ if (!s.isHTML5) {\r
+ s.buffered = [{\r
+ 'start': 0,\r
+ 'end': s.duration\r
+ }];\r
+ }\r
+\r
+ // allow whileloading to fire even if "load" fired under HTML5, due to HTTP range/partials\r
+ if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) {\r
+ instanceOptions.whileloading.apply(s);\r
+ }\r
+\r
+ };\r
+\r
+ this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {\r
+\r
+ var instanceOptions = s._iO,\r
+ eqLeft;\r
+\r
+ if (isNaN(nPosition) || nPosition === null) {\r
+ // flash safety net\r
+ return false;\r
+ }\r
+\r
+ // Safari HTML5 play() may return small -ve values when starting from position: 0, eg. -50.120396875. Unexpected/invalid per W3, I think. Normalize to 0.\r
+ s.position = Math.max(0, nPosition);\r
+\r
+ s._processOnPosition();\r
+\r
+ if (!s.isHTML5 && fV > 8) {\r
+\r
+ if (instanceOptions.usePeakData && oPeakData !== _undefined && oPeakData) {\r
+ s.peakData = {\r
+ left: oPeakData.leftPeak,\r
+ right: oPeakData.rightPeak\r
+ };\r
+ }\r
+\r
+ if (instanceOptions.useWaveformData && oWaveformDataLeft !== _undefined && oWaveformDataLeft) {\r
+ s.waveformData = {\r
+ left: oWaveformDataLeft.split(','),\r
+ right: oWaveformDataRight.split(',')\r
+ };\r
+ }\r
+\r
+ if (instanceOptions.useEQData) {\r
+ if (oEQData !== _undefined && oEQData && oEQData.leftEQ) {\r
+ eqLeft = oEQData.leftEQ.split(',');\r
+ s.eqData = eqLeft;\r
+ s.eqData.left = eqLeft;\r
+ if (oEQData.rightEQ !== _undefined && oEQData.rightEQ) {\r
+ s.eqData.right = oEQData.rightEQ.split(',');\r
+ }\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ if (s.playState === 1) {\r
+\r
+ // special case/hack: ensure buffering is false if loading from cache (and not yet started)\r
+ if (!s.isHTML5 && fV === 8 && !s.position && s.isBuffering) {\r
+ s._onbufferchange(0);\r
+ }\r
+\r
+ if (instanceOptions.whileplaying) {\r
+ // flash may call after actual finish\r
+ instanceOptions.whileplaying.apply(s);\r
+ }\r
+\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ this._oncaptiondata = function(oData) {\r
+\r
+ /**\r
+ * internal: flash 9 + NetStream (MovieStar/RTMP-only) feature\r
+ * \r
+ * @param {object} oData\r
+ */\r
+\r
+ sm2._wD(s.id + ': Caption data received.');\r
+\r
+ s.captiondata = oData;\r
+\r
+ if (s._iO.oncaptiondata) {\r
+ s._iO.oncaptiondata.apply(s, [oData]);\r
+ }\r
+\r
+ };\r
+\r
+ this._onmetadata = function(oMDProps, oMDData) {\r
+\r
+ /**\r
+ * internal: flash 9 + NetStream (MovieStar/RTMP-only) feature\r
+ * RTMP may include song title, MovieStar content may include encoding info\r
+ * \r
+ * @param {array} oMDProps (names)\r
+ * @param {array} oMDData (values)\r
+ */\r
+\r
+ sm2._wD(s.id + ': Metadata received.');\r
+\r
+ var oData = {}, i, j;\r
+\r
+ for (i = 0, j = oMDProps.length; i < j; i++) {\r
+ oData[oMDProps[i]] = oMDData[i];\r
+ }\r
+ s.metadata = oData;\r
+\r
+ if (s._iO.onmetadata) {\r
+ s._iO.onmetadata.apply(s);\r
+ }\r
+\r
+ };\r
+\r
+ this._onid3 = function(oID3Props, oID3Data) {\r
+\r
+ /**\r
+ * internal: flash 8 + flash 9 ID3 feature\r
+ * may include artist, song title etc.\r
+ * \r
+ * @param {array} oID3Props (names)\r
+ * @param {array} oID3Data (values)\r
+ */\r
+\r
+ sm2._wD(s.id + ': ID3 data received.');\r
+\r
+ var oData = [], i, j;\r
+\r
+ for (i = 0, j = oID3Props.length; i < j; i++) {\r
+ oData[oID3Props[i]] = oID3Data[i];\r
+ }\r
+ s.id3 = mixin(s.id3, oData);\r
+\r
+ if (s._iO.onid3) {\r
+ s._iO.onid3.apply(s);\r
+ }\r
+\r
+ };\r
+\r
+ // flash/RTMP-only\r
+\r
+ this._onconnect = function(bSuccess) {\r
+\r
+ bSuccess = (bSuccess === 1);\r
+ sm2._wD(s.id + ': ' + (bSuccess ? 'Connected.' : 'Failed to connect? - ' + s.url), (bSuccess ? 1 : 2));\r
+ s.connected = bSuccess;\r
+\r
+ if (bSuccess) {\r
+\r
+ s.failures = 0;\r
+\r
+ if (idCheck(s.id)) {\r
+ if (s.getAutoPlay()) {\r
+ // only update the play state if auto playing\r
+ s.play(_undefined, s.getAutoPlay());\r
+ } else if (s._iO.autoLoad) {\r
+ s.load();\r
+ }\r
+ }\r
+\r
+ if (s._iO.onconnect) {\r
+ s._iO.onconnect.apply(s, [bSuccess]);\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ this._ondataerror = function(sError) {\r
+\r
+ // flash 9 wave/eq data handler\r
+ // hack: called at start, and end from flash at/after onfinish()\r
+ if (s.playState > 0) {\r
+ sm2._wD(s.id + ': Data error: ' + sError);\r
+ if (s._iO.ondataerror) {\r
+ s._iO.ondataerror.apply(s);\r
+ }\r
+ }\r
+\r
+ };\r
+\r
+ // <d>\r
+ this._debug();\r
+ // </d>\r
+\r
+ }; // SMSound()\r
+\r
+ /**\r
+ * Private SoundManager internals\r
+ * ------------------------------\r
+ */\r
+\r
+ getDocument = function() {\r
+\r
+ return (doc.body || doc._docElement || doc.getElementsByTagName('div')[0]);\r
+\r
+ };\r
+\r
+ id = function(sID) {\r
+\r
+ return doc.getElementById(sID);\r
+\r
+ };\r
+\r
+ mixin = function(oMain, oAdd) {\r
+\r
+ // non-destructive merge\r
+ var o1 = (oMain || {}), o2, o;\r
+\r
+ // if unspecified, o2 is the default options object\r
+ o2 = (oAdd === _undefined ? sm2.defaultOptions : oAdd);\r
+\r
+ for (o in o2) {\r
+\r
+ if (o2.hasOwnProperty(o) && o1[o] === _undefined) {\r
+\r
+ if (typeof o2[o] !== 'object' || o2[o] === null) {\r
+\r
+ // assign directly\r
+ o1[o] = o2[o];\r
+\r
+ } else {\r
+\r
+ // recurse through o2\r
+ o1[o] = mixin(o1[o], o2[o]);\r
+\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
+ return o1;\r
+\r
+ };\r
+\r
+ wrapCallback = function(oSound, callback) {\r
+\r
+ /**\r
+ * 03/03/2013: Fix for Flash Player 11.6.602.171 + Flash 8 (flashVersion = 8) SWF issue\r
+ * setTimeout() fix for certain SMSound callbacks like onload() and onfinish(), where subsequent calls like play() and load() fail when Flash Player 11.6.602.171 is installed, and using soundManager with flashVersion = 8 (which is the default).\r
+ * Not sure of exact cause. Suspect race condition and/or invalid (NaN-style) position argument trickling down to the next JS -> Flash _start() call, in the play() case.\r
+ * Fix: setTimeout() to yield, plus safer null / NaN checking on position argument provided to Flash.\r
+ * https://getsatisfaction.com/schillmania/topics/recent_chrome_update_seems_to_have_broken_my_sm2_audio_player\r
+ */\r
+ if (!oSound.isHTML5 && fV === 8) {\r
+ window.setTimeout(callback, 0);\r
+ } else {\r
+ callback();\r
+ }\r
+\r
+ };\r
+\r
+ // additional soundManager properties that soundManager.setup() will accept\r
+\r
+ extraOptions = {\r
+ 'onready': 1,\r
+ 'ontimeout': 1,\r
+ 'defaultOptions': 1,\r
+ 'flash9Options': 1,\r
+ 'movieStarOptions': 1\r
+ };\r
+\r
+ assign = function(o, oParent) {\r
+\r
+ /**\r
+ * recursive assignment of properties, soundManager.setup() helper\r
+ * allows property assignment based on whitelist\r
+ */\r
+\r
+ var i,\r
+ result = true,\r
+ hasParent = (oParent !== _undefined),\r
+ setupOptions = sm2.setupOptions,\r
+ bonusOptions = extraOptions;\r
+\r
+ // <d>\r
+\r
+ // if soundManager.setup() called, show accepted parameters.\r
+\r
+ if (o === _undefined) {\r
+\r
+ result = [];\r
+\r
+ for (i in setupOptions) {\r
+\r
+ if (setupOptions.hasOwnProperty(i)) {\r
+ result.push(i);\r
+ }\r
+\r
+ }\r
+\r
+ for (i in bonusOptions) {\r
+\r
+ if (bonusOptions.hasOwnProperty(i)) {\r
+\r
+ if (typeof sm2[i] === 'object') {\r
+\r
+ result.push(i+': {...}');\r
+\r
+ } else if (sm2[i] instanceof Function) {\r
+\r
+ result.push(i+': function() {...}');\r
+\r
+ } else {\r
+\r
+ result.push(i);\r
+\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
+ sm2._wD(str('setup', result.join(', ')));\r
+\r
+ return false;\r
+\r
+ }\r
+\r
+ // </d>\r
+\r
+ for (i in o) {\r
+\r
+ if (o.hasOwnProperty(i)) {\r
+\r
+ // if not an {object} we want to recurse through...\r
+\r
+ if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array || o[i] instanceof RegExp) {\r
+\r
+ // check "allowed" options\r
+\r
+ if (hasParent && bonusOptions[oParent] !== _undefined) {\r
+\r
+ // valid recursive / nested object option, eg., { defaultOptions: { volume: 50 } }\r
+ sm2[oParent][i] = o[i];\r
+\r
+ } else if (setupOptions[i] !== _undefined) {\r
+\r
+ // special case: assign to setupOptions object, which soundManager property references\r
+ sm2.setupOptions[i] = o[i];\r
+\r
+ // assign directly to soundManager, too\r
+ sm2[i] = o[i];\r
+\r
+ } else if (bonusOptions[i] === _undefined) {\r
+\r
+ // invalid or disallowed parameter. complain.\r
+ complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);\r
+\r
+ result = false;\r
+\r
+ } else {\r
+\r
+ /**\r
+ * valid extraOptions (bonusOptions) parameter.\r
+ * is it a method, like onready/ontimeout? call it.\r
+ * multiple parameters should be in an array, eg. soundManager.setup({onready: [myHandler, myScope]});\r
+ */\r
+\r
+ if (sm2[i] instanceof Function) {\r
+\r
+ sm2[i].apply(sm2, (o[i] instanceof Array? o[i] : [o[i]]));\r
+\r
+ } else {\r
+\r
+ // good old-fashioned direct assignment\r
+ sm2[i] = o[i];\r
+\r
+ }\r
+\r
+ }\r
+\r
+ } else {\r
+\r
+ // recursion case, eg., { defaultOptions: { ... } }\r
+\r
+ if (bonusOptions[i] === _undefined) {\r
+\r
+ // invalid or disallowed parameter. complain.\r
+ complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);\r
+\r
+ result = false;\r
+\r
+ } else {\r
+\r
+ // recurse through object\r
+ return assign(o[i], i);\r
+\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ function preferFlashCheck(kind) {\r
+\r
+ // whether flash should play a given type\r
+ return (sm2.preferFlash && hasFlash && !sm2.ignoreFlash && (sm2.flash[kind] !== _undefined && sm2.flash[kind]));\r
+\r
+ }\r
+\r
+ /**\r
+ * Internal DOM2-level event helpers\r
+ * ---------------------------------\r
+ */\r
+\r
+ event = (function() {\r
+\r
+ // normalize event methods\r
+ var old = (window.attachEvent),\r
+ evt = {\r
+ add: (old?'attachEvent':'addEventListener'),\r
+ remove: (old?'detachEvent':'removeEventListener')\r
+ };\r
+\r
+ // normalize "on" event prefix, optional capture argument\r
+ function getArgs(oArgs) {\r
+\r
+ var args = slice.call(oArgs),\r
+ len = args.length;\r
+\r
+ if (old) {\r
+ // prefix\r
+ args[1] = 'on' + args[1];\r
+ if (len > 3) {\r
+ // no capture\r
+ args.pop();\r
+ }\r
+ } else if (len === 3) {\r
+ args.push(false);\r
+ }\r
+\r
+ return args;\r
+\r
+ }\r
+\r
+ function apply(args, sType) {\r
+\r
+ // normalize and call the event method, with the proper arguments\r
+ var element = args.shift(),\r
+ method = [evt[sType]];\r
+\r
+ if (old) {\r
+ // old IE can't do apply().\r
+ element[method](args[0], args[1]);\r
+ } else {\r
+ element[method].apply(element, args);\r
+ }\r
+\r
+ }\r
+\r
+ function add() {\r
+\r
+ apply(getArgs(arguments), 'add');\r
+\r
+ }\r
+\r
+ function remove() {\r
+\r
+ apply(getArgs(arguments), 'remove');\r
+\r
+ }\r
+\r
+ return {\r
+ 'add': add,\r
+ 'remove': remove\r
+ };\r
+\r
+ }());\r
+\r
+ /**\r
+ * Internal HTML5 event handling\r
+ * -----------------------------\r
+ */\r
+\r
+ function html5_event(oFn) {\r
+\r
+ // wrap html5 event handlers so we don't call them on destroyed and/or unloaded sounds\r
+\r
+ return function(e) {\r
+\r
+ var s = this._s,\r
+ result;\r
+\r
+ if (!s || !s._a) {\r
+ // <d>\r
+ if (s && s.id) {\r
+ sm2._wD(s.id + ': Ignoring ' + e.type);\r
+ } else {\r
+ sm2._wD(h5 + 'Ignoring ' + e.type);\r
+ }\r
+ // </d>\r
+ result = null;\r
+ } else {\r
+ result = oFn.call(this, e);\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ }\r
+\r
+ html5_events = {\r
+\r
+ // HTML5 event-name-to-handler map\r
+\r
+ abort: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': abort');\r
+\r
+ }),\r
+\r
+ // enough has loaded to play\r
+\r
+ canplay: html5_event(function() {\r
+\r
+ var s = this._s,\r
+ position1K;\r
+\r
+ if (s._html5_canplay) {\r
+ // this event has already fired. ignore.\r
+ return true;\r
+ }\r
+\r
+ s._html5_canplay = true;\r
+ sm2._wD(s.id + ': canplay');\r
+ s._onbufferchange(0);\r
+\r
+ // position according to instance options\r
+ position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/1000:null);\r
+\r
+ // set the position if position was set before the sound loaded\r
+ if (s.position && this.currentTime !== position1K) {\r
+ sm2._wD(s.id + ': canplay: Setting position to ' + position1K);\r
+ try {\r
+ this.currentTime = position1K;\r
+ } catch(ee) {\r
+ sm2._wD(s.id + ': canplay: Setting position of ' + position1K + ' failed: ' + ee.message, 2);\r
+ }\r
+ }\r
+\r
+ // hack for HTML5 from/to case\r
+ if (s._iO._oncanplay) {\r
+ s._iO._oncanplay();\r
+ }\r
+\r
+ }),\r
+\r
+ canplaythrough: html5_event(function() {\r
+\r
+ var s = this._s;\r
+\r
+ if (!s.loaded) {\r
+ s._onbufferchange(0);\r
+ s._whileloading(s.bytesLoaded, s.bytesTotal, s._get_html5_duration());\r
+ s._onload(true);\r
+ }\r
+\r
+ }),\r
+\r
+ // TODO: Reserved for potential use\r
+ /*\r
+ emptied: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': emptied');\r
+\r
+ }),\r
+ */\r
+\r
+ ended: html5_event(function() {\r
+\r
+ var s = this._s;\r
+\r
+ sm2._wD(s.id + ': ended');\r
+\r
+ s._onfinish();\r
+\r
+ }),\r
+\r
+ error: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': HTML5 error, code ' + this.error.code);\r
+ // call load with error state?\r
+ this._s._onload(false);\r
+\r
+ }),\r
+\r
+ loadeddata: html5_event(function() {\r
+\r
+ var s = this._s;\r
+\r
+ sm2._wD(s.id + ': loadeddata');\r
+\r
+ // safari seems to nicely report progress events, eventually totalling 100%\r
+ if (!s._loaded && !isSafari) {\r
+ s.duration = s._get_html5_duration();\r
+ }\r
+\r
+ }),\r
+\r
+ loadedmetadata: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': loadedmetadata');\r
+\r
+ }),\r
+\r
+ loadstart: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': loadstart');\r
+ // assume buffering at first\r
+ this._s._onbufferchange(1);\r
+\r
+ }),\r
+\r
+ play: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': play()');\r
+ // once play starts, no buffering\r
+ this._s._onbufferchange(0);\r
+\r
+ }),\r
+\r
+ playing: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': playing');\r
+ // once play starts, no buffering\r
+ this._s._onbufferchange(0);\r
+\r
+ }),\r
+\r
+ progress: html5_event(function(e) {\r
+\r
+ // note: can fire repeatedly after "loaded" event, due to use of HTTP range/partials\r
+\r
+ var s = this._s,\r
+ i, j, str, buffered = 0,\r
+ isProgress = (e.type === 'progress'),\r
+ ranges = e.target.buffered,\r
+ // firefox 3.6 implements e.loaded/total (bytes)\r
+ loaded = (e.loaded||0),\r
+ total = (e.total||1),\r
+ // HTML5 returns msec. SM2 API uses seconds for setPosition() etc., whether Flash or HTML5.\r
+ scale = 1000;\r
+\r
+ // reset the "buffered" (loaded byte ranges) array\r
+ s.buffered = [];\r
+\r
+ if (ranges && ranges.length) {\r
+\r
+ // if loaded is 0, try TimeRanges implementation as % of load\r
+ // https://developer.mozilla.org/en/DOM/TimeRanges\r
+\r
+ // re-build "buffered" array\r
+ for (i=0, j=ranges.length; i<j; i++) {\r
+ s.buffered.push({\r
+ 'start': ranges.start(i) * scale,\r
+ 'end': ranges.end(i) * scale\r
+ });\r
+ }\r
+\r
+ // use the last value locally\r
+ buffered = (ranges.end(0) - ranges.start(0)) * scale;\r
+\r
+ // linear case, buffer sum; does not account for seeking and HTTP partials / byte ranges\r
+ loaded = buffered/(e.target.duration*scale);\r
+\r
+ // <d>\r
+ if (isProgress && ranges.length > 1) {\r
+ str = [];\r
+ j = ranges.length;\r
+ for (i=0; i<j; i++) {\r
+ str.push(e.target.buffered.start(i)*scale +'-'+ e.target.buffered.end(i)*scale);\r
+ }\r
+ sm2._wD(this._s.id + ': progress, timeRanges: ' + str.join(', '));\r
+ }\r
+\r
+ if (isProgress && !isNaN(loaded)) {\r
+ sm2._wD(this._s.id + ': progress, ' + Math.floor(loaded*100) + '% loaded');\r
+ }\r
+ // </d>\r
+\r
+ }\r
+\r
+ if (!isNaN(loaded)) {\r
+\r
+ // if progress, likely not buffering\r
+ s._onbufferchange(0);\r
+ // TODO: prevent calls with duplicate values.\r
+ s._whileloading(loaded, total, s._get_html5_duration());\r
+ if (loaded && total && loaded === total) {\r
+ // in case "onload" doesn't fire (eg. gecko 1.9.2)\r
+ html5_events.canplaythrough.call(this, e);\r
+ }\r
+\r
+ }\r
+\r
+ }),\r
+\r
+ ratechange: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': ratechange');\r
+\r
+ }),\r
+\r
+ suspend: html5_event(function(e) {\r
+\r
+ // download paused/stopped, may have finished (eg. onload)\r
+ var s = this._s;\r
+\r
+ sm2._wD(this._s.id + ': suspend');\r
+ html5_events.progress.call(this, e);\r
+ s._onsuspend();\r
+\r
+ }),\r
+\r
+ stalled: html5_event(function() {\r
+\r
+ sm2._wD(this._s.id + ': stalled');\r
+\r
+ }),\r
+\r
+ timeupdate: html5_event(function() {\r
+\r
+ this._s._onTimer();\r
+\r
+ }),\r
+\r
+ waiting: html5_event(function() {\r
+\r
+ var s = this._s;\r
+\r
+ // see also: seeking\r
+ sm2._wD(this._s.id + ': waiting');\r
+\r
+ // playback faster than download rate, etc.\r
+ s._onbufferchange(1);\r
+\r
+ })\r
+\r
+ };\r
+\r
+ html5OK = function(iO) {\r
+\r
+ // playability test based on URL or MIME type\r
+\r
+ var result;\r
+\r
+ if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {\r
+\r
+ // RTMP, or preferring flash\r
+ result = false;\r
+\r
+ } else {\r
+\r
+ // Use type, if specified. If HTML5-only mode, no other options, so just give 'er\r
+ result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only));\r
+\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ html5Unload = function(oAudio, url) {\r
+\r
+ /**\r
+ * Internal method: Unload media, and cancel any current/pending network requests.\r
+ * Firefox can load an empty URL, which allegedly destroys the decoder and stops the download.\r
+ * https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Stopping_the_download_of_media\r
+ * However, Firefox has been seen loading a relative URL from '' and thus requesting the hosting page on unload.\r
+ * Other UA behaviour is unclear, so everyone else gets an about:blank-style URL.\r
+ */\r
+\r
+ if (oAudio) {\r
+\r
+ // Firefox likes '' for unload (used to work?) - however, may request hosting page URL (bad.) Most other UAs dislike '' and fail to unload.\r
+ oAudio.src = url;\r
+\r
+ // reset some state, too\r
+ oAudio._called_load = false;\r
+\r
+ }\r
+\r
+ if (useGlobalHTML5Audio) {\r
+\r
+ // ensure URL state is trashed, also\r
+ lastGlobalHTML5URL = null;\r
+\r
+ }\r
+\r
+ };\r
+\r
+ html5CanPlay = function(o) {\r
+\r
+ /**\r
+ * Try to find MIME, test and return truthiness\r
+ * o = {\r
+ * url: '/path/to/an.mp3',\r
+ * type: 'audio/mp3'\r
+ * }\r
+ */\r
+\r
+ if (!sm2.useHTML5Audio || !sm2.hasHTML5) {\r
+ return false;\r
+ }\r
+\r
+ var url = (o.url || null),\r
+ mime = (o.type || null),\r
+ aF = sm2.audioFormats,\r
+ result,\r
+ offset,\r
+ fileExt,\r
+ item;\r
+\r
+ // account for known cases like audio/mp3\r
+\r
+ if (mime && sm2.html5[mime] !== _undefined) {\r
+ return (sm2.html5[mime] && !preferFlashCheck(mime));\r
+ }\r
+\r
+ if (!html5Ext) {\r
+ html5Ext = [];\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ html5Ext.push(item);\r
+ if (aF[item].related) {\r
+ html5Ext = html5Ext.concat(aF[item].related);\r
+ }\r
+ }\r
+ }\r
+ html5Ext = new RegExp('\\.('+html5Ext.join('|')+')(\\?.*)?$','i');\r
+ }\r
+\r
+ // TODO: Strip URL queries, etc.\r
+ fileExt = (url ? url.toLowerCase().match(html5Ext) : null);\r
+\r
+ if (!fileExt || !fileExt.length) {\r
+ if (!mime) {\r
+ result = false;\r
+ } else {\r
+ // audio/mp3 -> mp3, result should be known\r
+ offset = mime.indexOf(';');\r
+ // strip "audio/X; codecs..."\r
+ fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6);\r
+ }\r
+ } else {\r
+ // match the raw extension name - "mp3", for example\r
+ fileExt = fileExt[1];\r
+ }\r
+\r
+ if (fileExt && sm2.html5[fileExt] !== _undefined) {\r
+ // result known\r
+ result = (sm2.html5[fileExt] && !preferFlashCheck(fileExt));\r
+ } else {\r
+ mime = 'audio/'+fileExt;\r
+ result = sm2.html5.canPlayType({type:mime});\r
+ sm2.html5[fileExt] = result;\r
+ // sm2._wD('canPlayType, found result: ' + result);\r
+ result = (result && sm2.html5[mime] && !preferFlashCheck(mime));\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ testHTML5 = function() {\r
+\r
+ /**\r
+ * Internal: Iterates over audioFormats, determining support eg. audio/mp3, audio/mpeg and so on\r
+ * assigns results to html5[] and flash[].\r
+ */\r
+\r
+ if (!sm2.useHTML5Audio || !sm2.hasHTML5) {\r
+ return false;\r
+ }\r
+\r
+ // double-whammy: Opera 9.64 throws WRONG_ARGUMENTS_ERR if no parameter passed to Audio(), and Webkit + iOS happily tries to load "null" as a URL. :/\r
+ var a = (Audio !== _undefined ? (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()) : null),\r
+ item, lookup, support = {}, aF, i;\r
+\r
+ function cp(m) {\r
+\r
+ var canPlay, i, j,\r
+ result = false,\r
+ isOK = false;\r
+\r
+ if (!a || typeof a.canPlayType !== 'function') {\r
+ return result;\r
+ }\r
+\r
+ if (m instanceof Array) {\r
+ // iterate through all mime types, return any successes\r
+ for (i=0, j=m.length; i<j; i++) {\r
+ if (sm2.html5[m[i]] || a.canPlayType(m[i]).match(sm2.html5Test)) {\r
+ isOK = true;\r
+ sm2.html5[m[i]] = true;\r
+ // note flash support, too\r
+ sm2.flash[m[i]] = !!(m[i].match(flashMIME));\r
+ }\r
+ }\r
+ result = isOK;\r
+ } else {\r
+ canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);\r
+ result = !!(canPlay && (canPlay.match(sm2.html5Test)));\r
+ }\r
+\r
+ return result;\r
+\r
+ }\r
+\r
+ // test all registered formats + codecs\r
+\r
+ aF = sm2.audioFormats;\r
+\r
+ for (item in aF) {\r
+\r
+ if (aF.hasOwnProperty(item)) {\r
+\r
+ lookup = 'audio/' + item;\r
+\r
+ support[item] = cp(aF[item].type);\r
+\r
+ // write back generic type too, eg. audio/mp3\r
+ support[lookup] = support[item];\r
+\r
+ // assign flash\r
+ if (item.match(flashMIME)) {\r
+\r
+ sm2.flash[item] = true;\r
+ sm2.flash[lookup] = true;\r
+\r
+ } else {\r
+\r
+ sm2.flash[item] = false;\r
+ sm2.flash[lookup] = false;\r
+\r
+ }\r
+\r
+ // assign result to related formats, too\r
+\r
+ if (aF[item] && aF[item].related) {\r
+\r
+ for (i=aF[item].related.length-1; i >= 0; i--) {\r
+\r
+ // eg. audio/m4a\r
+ support['audio/'+aF[item].related[i]] = support[item];\r
+ sm2.html5[aF[item].related[i]] = support[item];\r
+ sm2.flash[aF[item].related[i]] = support[item];\r
+\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
+ support.canPlayType = (a?cp:null);\r
+ sm2.html5 = mixin(sm2.html5, support);\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ strings = {\r
+\r
+ // <d>\r
+ notReady: 'Unavailable - wait until onready() has fired.',\r
+ notOK: 'Audio support is not available.',\r
+ domError: sm + 'exception caught while appending SWF to DOM.',\r
+ spcWmode: 'Removing wmode, preventing known SWF loading issue(s)',\r
+ swf404: smc + 'Verify that %s is a valid path.',\r
+ tryDebug: 'Try ' + sm + '.debugFlash = true for more security details (output goes to SWF.)',\r
+ checkSWF: 'See SWF output for more debug info.',\r
+ localFail: smc + 'Non-HTTP page (' + doc.location.protocol + ' URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/',\r
+ waitFocus: smc + 'Special case: Waiting for SWF to load with window focus...',\r
+ waitForever: smc + 'Waiting indefinitely for Flash (will recover if unblocked)...',\r
+ waitSWF: smc + 'Waiting for 100% SWF load...',\r
+ needFunction: smc + 'Function object expected for %s',\r
+ badID: 'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',\r
+ currentObj: smc + '_debug(): Current sound objects',\r
+ waitOnload: smc + 'Waiting for window.onload()',\r
+ docLoaded: smc + 'Document already loaded',\r
+ onload: smc + 'initComplete(): calling soundManager.onload()',\r
+ onloadOK: sm + '.onload() complete',\r
+ didInit: smc + 'init(): Already called?',\r
+ secNote: 'Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html',\r
+ badRemove: smc + 'Failed to remove Flash node.',\r
+ shutdown: sm + '.disable(): Shutting down',\r
+ queue: smc + 'Queueing %s handler',\r
+ smError: 'SMSound.load(): Exception: JS-Flash communication failed, or JS error.',\r
+ fbTimeout: 'No flash response, applying .'+swfCSS.swfTimedout+' CSS...',\r
+ fbLoaded: 'Flash loaded',\r
+ flRemoved: smc + 'Flash movie removed.',\r
+ fbHandler: smc + 'flashBlockHandler()',\r
+ manURL: 'SMSound.load(): Using manually-assigned URL',\r
+ onURL: sm + '.load(): current URL already assigned.',\r
+ badFV: sm + '.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',\r
+ as2loop: 'Note: Setting stream:false so looping can work (flash 8 limitation)',\r
+ noNSLoop: 'Note: Looping not implemented for MovieStar formats',\r
+ needfl9: 'Note: Switching to flash 9, required for MP4 formats.',\r
+ mfTimeout: 'Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case',\r
+ needFlash: smc + 'Fatal error: Flash is needed to play some required formats, but is not available.',\r
+ gotFocus: smc + 'Got window focus.',\r
+ policy: 'Enabling usePolicyFile for data access',\r
+ setup: sm + '.setup(): allowed parameters: %s',\r
+ setupError: sm + '.setup(): "%s" cannot be assigned with this method.',\r
+ setupUndef: sm + '.setup(): Could not find option "%s"',\r
+ setupLate: sm + '.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().',\r
+ noURL: smc + 'Flash URL required. Call soundManager.setup({url:...}) to get started.',\r
+ sm2Loaded: 'SoundManager 2: Ready.',\r
+ reset: sm + '.reset(): Removing event callbacks',\r
+ mobileUA: 'Mobile UA detected, preferring HTML5 by default.',\r
+ globalHTML5: 'Using singleton HTML5 Audio() pattern for this device.'\r
+ // </d>\r
+\r
+ };\r
+\r
+ str = function() {\r
+\r
+ // internal string replace helper.\r
+ // arguments: o [,items to replace]\r
+ // <d>\r
+\r
+ // real array, please\r
+ var args = slice.call(arguments),\r
+\r
+ // first arg\r
+ o = args.shift(),\r
+\r
+ str = (strings && strings[o]?strings[o]:''), i, j;\r
+ if (str && args && args.length) {\r
+ for (i = 0, j = args.length; i < j; i++) {\r
+ str = str.replace('%s', args[i]);\r
+ }\r
+ }\r
+\r
+ return str;\r
+ // </d>\r
+\r
+ };\r
+\r
+ loopFix = function(sOpt) {\r
+\r
+ // flash 8 requires stream = false for looping to work\r
+ if (fV === 8 && sOpt.loops > 1 && sOpt.stream) {\r
+ _wDS('as2loop');\r
+ sOpt.stream = false;\r
+ }\r
+\r
+ return sOpt;\r
+\r
+ };\r
+\r
+ policyFix = function(sOpt, sPre) {\r
+\r
+ if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) {\r
+ sm2._wD((sPre || '') + str('policy'));\r
+ sOpt.usePolicyFile = true;\r
+ }\r
+\r
+ return sOpt;\r
+\r
+ };\r
+\r
+ complain = function(sMsg) {\r
+\r
+ // <d>\r
+ if (console !== _undefined && console.warn !== _undefined) {\r
+ console.warn(sMsg);\r
+ } else {\r
+ sm2._wD(sMsg);\r
+ }\r
+ // </d>\r
+\r
+ };\r
+\r
+ doNothing = function() {\r
+\r
+ return false;\r
+\r
+ };\r
+\r
+ disableObject = function(o) {\r
+\r
+ var oProp;\r
+\r
+ for (oProp in o) {\r
+ if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') {\r
+ o[oProp] = doNothing;\r
+ }\r
+ }\r
+\r
+ oProp = null;\r
+\r
+ };\r
+\r
+ failSafely = function(bNoDisable) {\r
+\r
+ // general failure exception handler\r
+\r
+ if (bNoDisable === _undefined) {\r
+ bNoDisable = false;\r
+ }\r
+\r
+ if (disabled || bNoDisable) {\r
+ sm2.disable(bNoDisable);\r
+ }\r
+\r
+ };\r
+\r
+ normalizeMovieURL = function(smURL) {\r
+\r
+ var urlParams = null, url;\r
+\r
+ if (smURL) {\r
+ if (smURL.match(/\.swf(\?.*)?$/i)) {\r
+ urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4);\r
+ if (urlParams) {\r
+ // assume user knows what they're doing\r
+ return smURL;\r
+ }\r
+ } else if (smURL.lastIndexOf('/') !== smURL.length - 1) {\r
+ // append trailing slash, if needed\r
+ smURL += '/';\r
+ }\r
+ }\r
+\r
+ url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + sm2.movieURL;\r
+\r
+ if (sm2.noSWFCache) {\r
+ url += ('?ts=' + new Date().getTime());\r
+ }\r
+\r
+ return url;\r
+\r
+ };\r
+\r
+ setVersionInfo = function() {\r
+\r
+ // short-hand for internal use\r
+\r
+ fV = parseInt(sm2.flashVersion, 10);\r
+\r
+ if (fV !== 8 && fV !== 9) {\r
+ sm2._wD(str('badFV', fV, defaultFlashVersion));\r
+ sm2.flashVersion = fV = defaultFlashVersion;\r
+ }\r
+\r
+ // debug flash movie, if applicable\r
+\r
+ var isDebug = (sm2.debugMode || sm2.debugFlash?'_debug.swf':'.swf');\r
+\r
+ if (sm2.useHTML5Audio && !sm2.html5Only && sm2.audioFormats.mp4.required && fV < 9) {\r
+ sm2._wD(str('needfl9'));\r
+ sm2.flashVersion = fV = 9;\r
+ }\r
+\r
+ sm2.version = sm2.versionNumber + (sm2.html5Only?' (HTML5-only mode)':(fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)'));\r
+\r
+ // set up default options\r
+ if (fV > 8) {\r
+ // +flash 9 base options\r
+ sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.flash9Options);\r
+ sm2.features.buffering = true;\r
+ // +moviestar support\r
+ sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.movieStarOptions);\r
+ sm2.filePatterns.flash9 = new RegExp('\\.(mp3|' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
+ sm2.features.movieStar = true;\r
+ } else {\r
+ sm2.features.movieStar = false;\r
+ }\r
+\r
+ // regExp for flash canPlay(), etc.\r
+ sm2.filePattern = sm2.filePatterns[(fV !== 8?'flash9':'flash8')];\r
+\r
+ // if applicable, use _debug versions of SWFs\r
+ sm2.movieURL = (fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug);\r
+\r
+ sm2.features.peakData = sm2.features.waveformData = sm2.features.eqData = (fV > 8);\r
+\r
+ };\r
+\r
+ setPolling = function(bPolling, bHighPerformance) {\r
+\r
+ if (!flash) {\r
+ return false;\r
+ }\r
+\r
+ flash._setPolling(bPolling, bHighPerformance);\r
+\r
+ };\r
+\r
+ initDebug = function() {\r
+\r
+ // starts debug mode, creating output <div> for UAs without console object\r
+\r
+ // allow force of debug mode via URL\r
+ if (sm2.debugURLParam.test(wl)) {\r
+ sm2.debugMode = true;\r
+ }\r
+\r
+ // <d>\r
+ if (id(sm2.debugID)) {\r
+ return false;\r
+ }\r
+\r
+ var oD, oDebug, oTarget, oToggle, tmp;\r
+\r
+ if (sm2.debugMode && !id(sm2.debugID) && (!hasConsole || !sm2.useConsole || !sm2.consoleOnly)) {\r
+\r
+ oD = doc.createElement('div');\r
+ oD.id = sm2.debugID + '-toggle';\r
+\r
+ oToggle = {\r
+ 'position': 'fixed',\r
+ 'bottom': '0px',\r
+ 'right': '0px',\r
+ 'width': '1.2em',\r
+ 'height': '1.2em',\r
+ 'lineHeight': '1.2em',\r
+ 'margin': '2px',\r
+ 'textAlign': 'center',\r
+ 'border': '1px solid #999',\r
+ 'cursor': 'pointer',\r
+ 'background': '#fff',\r
+ 'color': '#333',\r
+ 'zIndex': 10001\r
+ };\r
+\r
+ oD.appendChild(doc.createTextNode('-'));\r
+ oD.onclick = toggleDebug;\r
+ oD.title = 'Toggle SM2 debug console';\r
+\r
+ if (ua.match(/msie 6/i)) {\r
+ oD.style.position = 'absolute';\r
+ oD.style.cursor = 'hand';\r
+ }\r
+\r
+ for (tmp in oToggle) {\r
+ if (oToggle.hasOwnProperty(tmp)) {\r
+ oD.style[tmp] = oToggle[tmp];\r
+ }\r
+ }\r
+\r
+ oDebug = doc.createElement('div');\r
+ oDebug.id = sm2.debugID;\r
+ oDebug.style.display = (sm2.debugMode?'block':'none');\r
+\r
+ if (sm2.debugMode && !id(oD.id)) {\r
+ try {\r
+ oTarget = getDocument();\r
+ oTarget.appendChild(oD);\r
+ } catch(e2) {\r
+ throw new Error(str('domError')+' \n'+e2.toString());\r
+ }\r
+ oTarget.appendChild(oDebug);\r
+ }\r
+\r
+ }\r
+\r
+ oTarget = null;\r
+ // </d>\r
+\r
+ };\r
+\r
+ idCheck = this.getSoundById;\r
+\r
+ // <d>\r
+ _wDS = function(o, errorLevel) {\r
+\r
+ return (!o ? '' : sm2._wD(str(o), errorLevel));\r
+\r
+ };\r
+\r
+ toggleDebug = function() {\r
+\r
+ var o = id(sm2.debugID),\r
+ oT = id(sm2.debugID + '-toggle');\r
+\r
+ if (!o) {\r
+ return false;\r
+ }\r
+\r
+ if (debugOpen) {\r
+ // minimize\r
+ oT.innerHTML = '+';\r
+ o.style.display = 'none';\r
+ } else {\r
+ oT.innerHTML = '-';\r
+ o.style.display = 'block';\r
+ }\r
+\r
+ debugOpen = !debugOpen;\r
+\r
+ };\r
+\r
+ debugTS = function(sEventType, bSuccess, sMessage) {\r
+\r
+ // troubleshooter debug hooks\r
+\r
+ if (window.sm2Debugger !== _undefined) {\r
+ try {\r
+ sm2Debugger.handleEvent(sEventType, bSuccess, sMessage);\r
+ } catch(e) {\r
+ // oh well\r
+ }\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+ // </d>\r
+\r
+ getSWFCSS = function() {\r
+\r
+ var css = [];\r
+\r
+ if (sm2.debugMode) {\r
+ css.push(swfCSS.sm2Debug);\r
+ }\r
+\r
+ if (sm2.debugFlash) {\r
+ css.push(swfCSS.flashDebug);\r
+ }\r
+\r
+ if (sm2.useHighPerformance) {\r
+ css.push(swfCSS.highPerf);\r
+ }\r
+\r
+ return css.join(' ');\r
+\r
+ };\r
+\r
+ flashBlockHandler = function() {\r
+\r
+ // *possible* flash block situation.\r
+\r
+ var name = str('fbHandler'),\r
+ p = sm2.getMoviePercent(),\r
+ css = swfCSS,\r
+ error = {type:'FLASHBLOCK'};\r
+\r
+ if (sm2.html5Only) {\r
+ return false;\r
+ }\r
+\r
+ if (!sm2.ok()) {\r
+\r
+ if (needsFlash) {\r
+ // make the movie more visible, so user can fix\r
+ sm2.oMC.className = getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);\r
+ sm2._wD(name + ': ' + str('fbTimeout') + (p ? ' (' + str('fbLoaded') + ')' : ''));\r
+ }\r
+\r
+ sm2.didFlashBlock = true;\r
+\r
+ // fire onready(), complain lightly\r
+ processOnEvents({type:'ontimeout', ignoreInit:true, error:error});\r
+ catchError(error);\r
+\r
+ } else {\r
+\r
+ // SM2 loaded OK (or recovered)\r
+\r
+ // <d>\r
+ if (sm2.didFlashBlock) {\r
+ sm2._wD(name + ': Unblocked');\r
+ }\r
+ // </d>\r
+\r
+ if (sm2.oMC) {\r
+ sm2.oMC.className = [getSWFCSS(), css.swfDefault, css.swfLoaded + (sm2.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ addOnEvent = function(sType, oMethod, oScope) {\r
+\r
+ if (on_queue[sType] === _undefined) {\r
+ on_queue[sType] = [];\r
+ }\r
+\r
+ on_queue[sType].push({\r
+ 'method': oMethod,\r
+ 'scope': (oScope || null),\r
+ 'fired': false\r
+ });\r
+\r
+ };\r
+\r
+ processOnEvents = function(oOptions) {\r
+\r
+ // if unspecified, assume OK/error\r
+\r
+ if (!oOptions) {\r
+ oOptions = {\r
+ type: (sm2.ok() ? 'onready' : 'ontimeout')\r
+ };\r
+ }\r
+\r
+ if (!didInit && oOptions && !oOptions.ignoreInit) {\r
+ // not ready yet.\r
+ return false;\r
+ }\r
+\r
+ if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) {\r
+ // invalid case\r
+ return false;\r
+ }\r
+\r
+ var status = {\r
+ success: (oOptions && oOptions.ignoreInit?sm2.ok():!disabled)\r
+ },\r
+\r
+ // queue specified by type, or none\r
+ srcQueue = (oOptions && oOptions.type?on_queue[oOptions.type]||[]:[]),\r
+\r
+ queue = [], i, j,\r
+ args = [status],\r
+ canRetry = (needsFlash && !sm2.ok());\r
+\r
+ if (oOptions.error) {\r
+ args[0].error = oOptions.error;\r
+ }\r
+\r
+ for (i = 0, j = srcQueue.length; i < j; i++) {\r
+ if (srcQueue[i].fired !== true) {\r
+ queue.push(srcQueue[i]);\r
+ }\r
+ }\r
+\r
+ if (queue.length) {\r
+ // sm2._wD(sm + ': Firing ' + queue.length + ' ' + oOptions.type + '() item' + (queue.length === 1 ? '' : 's'));\r
+ for (i = 0, j = queue.length; i < j; i++) {\r
+ if (queue[i].scope) {\r
+ queue[i].method.apply(queue[i].scope, args);\r
+ } else {\r
+ queue[i].method.apply(this, args);\r
+ }\r
+ if (!canRetry) {\r
+ // useFlashBlock and SWF timeout case doesn't count here.\r
+ queue[i].fired = true;\r
+ }\r
+ }\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ initUserOnload = function() {\r
+\r
+ window.setTimeout(function() {\r
+\r
+ if (sm2.useFlashBlock) {\r
+ flashBlockHandler();\r
+ }\r
+\r
+ processOnEvents();\r
+\r
+ // call user-defined "onload", scoped to window\r
+\r
+ if (typeof sm2.onload === 'function') {\r
+ _wDS('onload', 1);\r
+ sm2.onload.apply(window);\r
+ _wDS('onloadOK', 1);\r
+ }\r
+\r
+ if (sm2.waitForWindowLoad) {\r
+ event.add(window, 'load', initUserOnload);\r
+ }\r
+\r
+ },1);\r
+\r
+ };\r
+\r
+ detectFlash = function() {\r
+\r
+ // hat tip: Flash Detect library (BSD, (C) 2007) by Carl "DocYes" S. Yestrau - http://featureblend.com/javascript-flash-detection-library.html / http://featureblend.com/license.txt\r
+\r
+ if (hasFlash !== _undefined) {\r
+ // this work has already been done.\r
+ return hasFlash;\r
+ }\r
+\r
+ var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject;\r
+\r
+ if (nP && nP.length) {\r
+ type = 'application/x-shockwave-flash';\r
+ types = n.mimeTypes;\r
+ if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) {\r
+ hasPlugin = true;\r
+ }\r
+ } else if (AX !== _undefined && !ua.match(/MSAppHost/i)) {\r
+ // Windows 8 Store Apps (MSAppHost) are weird (compatibility?) and won't complain here, but will barf if Flash/ActiveX object is appended to the DOM.\r
+ try {\r
+ obj = new AX('ShockwaveFlash.ShockwaveFlash');\r
+ } catch(e) {\r
+ // oh well\r
+ }\r
+ hasPlugin = (!!obj);\r
+ // cleanup, because it is ActiveX after all\r
+ obj = null;\r
+ }\r
+\r
+ hasFlash = hasPlugin;\r
+\r
+ return hasPlugin;\r
+\r
+ };\r
+\r
+ featureCheck = function() {\r
+\r
+ var needsFlash,\r
+ item,\r
+ result = true,\r
+ formats = sm2.audioFormats,\r
+ // iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (original iPad) + iOS4 works.\r
+ isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i)));\r
+\r
+ if (isSpecial) {\r
+\r
+ // has Audio(), but is broken; let it load links directly.\r
+ sm2.hasHTML5 = false;\r
+\r
+ // ignore flash case, however\r
+ sm2.html5Only = true;\r
+\r
+ if (sm2.oMC) {\r
+ sm2.oMC.style.display = 'none';\r
+ }\r
+\r
+ result = false;\r
+\r
+ } else {\r
+\r
+ if (sm2.useHTML5Audio) {\r
+\r
+ if (!sm2.html5 || !sm2.html5.canPlayType) {\r
+ sm2._wD('SoundManager: No HTML5 Audio() support detected.');\r
+ sm2.hasHTML5 = false;\r
+ }\r
+\r
+ // <d>\r
+ if (isBadSafari) {\r
+ sm2._wD(smc + 'Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - ' + (!hasFlash ?' would use flash fallback for MP3/MP4, but none detected.' : 'will use flash fallback for MP3/MP4, if available'), 1);\r
+ }\r
+ // </d>\r
+\r
+ }\r
+\r
+ }\r
+\r
+ if (sm2.useHTML5Audio && sm2.hasHTML5) {\r
+\r
+ for (item in formats) {\r
+ if (formats.hasOwnProperty(item)) {\r
+ if ((formats[item].required && !sm2.html5.canPlayType(formats[item].type)) || (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type]))) {\r
+ // flash may be required, or preferred for this format\r
+ needsFlash = true;\r
+ }\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ // sanity check...\r
+ if (sm2.ignoreFlash) {\r
+ needsFlash = false;\r
+ }\r
+\r
+ sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !needsFlash);\r
+\r
+ return (!sm2.html5Only);\r
+\r
+ };\r
+\r
+ parseURL = function(url) {\r
+\r
+ /**\r
+ * Internal: Finds and returns the first playable URL (or failing that, the first URL.)\r
+ * @param {string or array} url A single URL string, OR, an array of URL strings or {url:'/path/to/resource', type:'audio/mp3'} objects.\r
+ */\r
+\r
+ var i, j, urlResult = 0, result;\r
+\r
+ if (url instanceof Array) {\r
+\r
+ // find the first good one\r
+ for (i=0, j=url.length; i<j; i++) {\r
+\r
+ if (url[i] instanceof Object) {\r
+ // MIME check\r
+ if (sm2.canPlayMIME(url[i].type)) {\r
+ urlResult = i;\r
+ break;\r
+ }\r
+\r
+ } else if (sm2.canPlayURL(url[i])) {\r
+ // URL string check\r
+ urlResult = i;\r
+ break;\r
+ }\r
+\r
+ }\r
+\r
+ // normalize to string\r
+ if (url[urlResult].url) {\r
+ url[urlResult] = url[urlResult].url;\r
+ }\r
+\r
+ result = url[urlResult];\r
+\r
+ } else {\r
+\r
+ // single URL case\r
+ result = url;\r
+\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+\r
+ startTimer = function(oSound) {\r
+\r
+ /**\r
+ * attach a timer to this sound, and start an interval if needed\r
+ */\r
+\r
+ if (!oSound._hasTimer) {\r
+\r
+ oSound._hasTimer = true;\r
+\r
+ if (!mobileHTML5 && sm2.html5PollingInterval) {\r
+\r
+ if (h5IntervalTimer === null && h5TimerCount === 0) {\r
+\r
+ h5IntervalTimer = setInterval(timerExecute, sm2.html5PollingInterval);\r
+ \r
+ }\r
+\r
+ h5TimerCount++;\r
+\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ stopTimer = function(oSound) {\r
+\r
+ /**\r
+ * detach a timer\r
+ */\r
+\r
+ if (oSound._hasTimer) {\r
+\r
+ oSound._hasTimer = false;\r
+\r
+ if (!mobileHTML5 && sm2.html5PollingInterval) {\r
+\r
+ // interval will stop itself at next execution.\r
+\r
+ h5TimerCount--;\r
+\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ timerExecute = function() {\r
+\r
+ /**\r
+ * manual polling for HTML5 progress events, ie., whileplaying() (can achieve greater precision than conservative default HTML5 interval)\r
+ */\r
+\r
+ var i;\r
+\r
+ if (h5IntervalTimer !== null && !h5TimerCount) {\r
+\r
+ // no active timers, stop polling interval.\r
+\r
+ clearInterval(h5IntervalTimer);\r
+\r
+ h5IntervalTimer = null;\r
+\r
+ return false;\r
+\r
+ }\r
+\r
+ // check all HTML5 sounds with timers\r
+\r
+ for (i = sm2.soundIDs.length-1; i >= 0; i--) {\r
+\r
+ if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) {\r
+\r
+ sm2.sounds[sm2.soundIDs[i]]._onTimer();\r
+\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ catchError = function(options) {\r
+\r
+ options = (options !== _undefined ? options : {});\r
+\r
+ if (typeof sm2.onerror === 'function') {\r
+ sm2.onerror.apply(window, [{type:(options.type !== _undefined ? options.type : null)}]);\r
+ }\r
+\r
+ if (options.fatal !== _undefined && options.fatal) {\r
+ sm2.disable();\r
+ }\r
+\r
+ };\r
+\r
+ badSafariFix = function() {\r
+\r
+ // special case: "bad" Safari (OS X 10.3 - 10.7) must fall back to flash for MP3/MP4\r
+ if (!isBadSafari || !detectFlash()) {\r
+ // doesn't apply\r
+ return false;\r
+ }\r
+\r
+ var aF = sm2.audioFormats, i, item;\r
+\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ if (item === 'mp3' || item === 'mp4') {\r
+ sm2._wD(sm + ': Using flash fallback for ' + item + ' format');\r
+ sm2.html5[item] = false;\r
+ // assign result to related formats, too\r
+ if (aF[item] && aF[item].related) {\r
+ for (i = aF[item].related.length-1; i >= 0; i--) {\r
+ sm2.html5[aF[item].related[i]] = false;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Pseudo-private flash/ExternalInterface methods\r
+ * ----------------------------------------------\r
+ */\r
+\r
+ this._setSandboxType = function(sandboxType) {\r
+\r
+ // <d>\r
+ var sb = sm2.sandbox;\r
+\r
+ sb.type = sandboxType;\r
+ sb.description = sb.types[(sb.types[sandboxType] !== _undefined?sandboxType:'unknown')];\r
+\r
+ if (sb.type === 'localWithFile') {\r
+\r
+ sb.noRemote = true;\r
+ sb.noLocal = false;\r
+ _wDS('secNote', 2);\r
+\r
+ } else if (sb.type === 'localWithNetwork') {\r
+\r
+ sb.noRemote = false;\r
+ sb.noLocal = true;\r
+\r
+ } else if (sb.type === 'localTrusted') {\r
+\r
+ sb.noRemote = false;\r
+ sb.noLocal = false;\r
+\r
+ }\r
+ // </d>\r
+\r
+ };\r
+\r
+ this._externalInterfaceOK = function(flashDate, swfVersion) {\r
+\r
+ // flash callback confirming flash loaded, EI working etc.\r
+ // flashDate = approx. timing/delay info for JS/flash bridge\r
+ // swfVersion: SWF build string\r
+\r
+ if (sm2.swfLoaded) {\r
+ return false;\r
+ }\r
+\r
+ var e;\r
+\r
+ debugTS('swf', true);\r
+ debugTS('flashtojs', true);\r
+ sm2.swfLoaded = true;\r
+ tryInitOnFocus = false;\r
+\r
+ if (isBadSafari) {\r
+ badSafariFix();\r
+ }\r
+\r
+ // complain if JS + SWF build/version strings don't match, excluding +DEV builds\r
+ // <d>\r
+ if (!swfVersion || swfVersion.replace(/\+dev/i,'') !== sm2.versionNumber.replace(/\+dev/i, '')) {\r
+\r
+ e = sm + ': Fatal: JavaScript file build "' + sm2.versionNumber + '" does not match Flash SWF build "' + swfVersion + '" at ' + sm2.url + '. Ensure both are up-to-date.';\r
+\r
+ // escape flash -> JS stack so this error fires in window.\r
+ setTimeout(function versionMismatch() {\r
+ throw new Error(e);\r
+ }, 0);\r
+\r
+ // exit, init will fail with timeout\r
+ return false;\r
+\r
+ }\r
+ // </d>\r
+\r
+ // slight delay before init\r
+ setTimeout(init, isIE ? 100 : 1);\r
+\r
+ };\r
+\r
+ /**\r
+ * Private initialization helpers\r
+ * ------------------------------\r
+ */\r
+\r
+ createMovie = function(smID, smURL) {\r
+\r
+ if (didAppend && appendSuccess) {\r
+ // ignore if already succeeded\r
+ return false;\r
+ }\r
+\r
+ function initMsg() {\r
+\r
+ // <d>\r
+\r
+ var options = [], title, str = [], delimiter = ' + ';\r
+\r
+ title = 'SoundManager ' + sm2.version + (!sm2.html5Only && sm2.useHTML5Audio ? (sm2.hasHTML5 ? ' + HTML5 audio' : ', no HTML5 audio support') : '');\r
+\r
+ if (!sm2.html5Only) {\r
+\r
+ if (sm2.preferFlash) {\r
+ options.push('preferFlash');\r
+ }\r
+\r
+ if (sm2.useHighPerformance) {\r
+ options.push('useHighPerformance');\r
+ }\r
+\r
+ if (sm2.flashPollingInterval) {\r
+ options.push('flashPollingInterval (' + sm2.flashPollingInterval + 'ms)');\r
+ }\r
+\r
+ if (sm2.html5PollingInterval) {\r
+ options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)');\r
+ }\r
+\r
+ if (sm2.wmode) {\r
+ options.push('wmode (' + sm2.wmode + ')');\r
+ }\r
+\r
+ if (sm2.debugFlash) {\r
+ options.push('debugFlash');\r
+ }\r
+\r
+ if (sm2.useFlashBlock) {\r
+ options.push('flashBlock');\r
+ }\r
+\r
+ } else {\r
+\r
+ if (sm2.html5PollingInterval) {\r
+ options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)');\r
+ }\r
+\r
+ }\r
+\r
+ if (options.length) {\r
+ str = str.concat([options.join(delimiter)]);\r
+ }\r
+\r
+ sm2._wD(title + (str.length ? delimiter + str.join(', ') : ''), 1);\r
+\r
+ showSupport();\r
+\r
+ // </d>\r
+\r
+ }\r
+\r
+ if (sm2.html5Only) {\r
+\r
+ // 100% HTML5 mode\r
+ setVersionInfo();\r
+\r
+ initMsg();\r
+ sm2.oMC = id(sm2.movieID);\r
+ init();\r
+\r
+ // prevent multiple init attempts\r
+ didAppend = true;\r
+\r
+ appendSuccess = true;\r
+\r
+ return false;\r
+\r
+ }\r
+\r
+ // flash path\r
+ var remoteURL = (smURL || sm2.url),\r
+ localURL = (sm2.altURL || remoteURL),\r
+ swfTitle = 'JS/Flash audio component (SoundManager 2)',\r
+ oTarget = getDocument(),\r
+ extraClass = getSWFCSS(),\r
+ isRTL = null,\r
+ html = doc.getElementsByTagName('html')[0],\r
+ oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass;\r
+\r
+ isRTL = (html && html.dir && html.dir.match(/rtl/i));\r
+ smID = (smID === _undefined?sm2.id:smID);\r
+\r
+ function param(name, value) {\r
+ return '<param name="'+name+'" value="'+value+'" />';\r
+ }\r
+\r
+ // safety check for legacy (change to Flash 9 URL)\r
+ setVersionInfo();\r
+ sm2.url = normalizeMovieURL(overHTTP?remoteURL:localURL);\r
+ smURL = sm2.url;\r
+\r
+ sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode);\r
+\r
+ if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) {\r
+ /**\r
+ * extra-special case: movie doesn't load until scrolled into view when using wmode = anything but 'window' here\r
+ * does not apply when using high performance (position:fixed means on-screen), OR infinite flash load timeout\r
+ * wmode breaks IE 8 on Vista + Win7 too in some cases, as of January 2011 (?)\r
+ */\r
+ messages.push(strings.spcWmode);\r
+ sm2.wmode = null;\r
+ }\r
+\r
+ oEmbed = {\r
+ 'name': smID,\r
+ 'id': smID,\r
+ 'src': smURL,\r
+ 'quality': 'high',\r
+ 'allowScriptAccess': sm2.allowScriptAccess,\r
+ 'bgcolor': sm2.bgColor,\r
+ 'pluginspage': http+'www.macromedia.com/go/getflashplayer',\r
+ 'title': swfTitle,\r
+ 'type': 'application/x-shockwave-flash',\r
+ 'wmode': sm2.wmode,\r
+ // http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html\r
+ 'hasPriority': 'true'\r
+ };\r
+\r
+ if (sm2.debugFlash) {\r
+ oEmbed.FlashVars = 'debug=1';\r
+ }\r
+\r
+ if (!sm2.wmode) {\r
+ // don't write empty attribute\r
+ delete oEmbed.wmode;\r
+ }\r
+\r
+ if (isIE) {\r
+\r
+ // IE is "special".\r
+ oMovie = doc.createElement('div');\r
+ movieHTML = [\r
+ '<object id="' + smID + '" data="' + smURL + '" type="' + oEmbed.type + '" title="' + oEmbed.title +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + http+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">',\r
+ param('movie', smURL),\r
+ param('AllowScriptAccess', sm2.allowScriptAccess),\r
+ param('quality', oEmbed.quality),\r
+ (sm2.wmode? param('wmode', sm2.wmode): ''),\r
+ param('bgcolor', sm2.bgColor),\r
+ param('hasPriority', 'true'),\r
+ (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''),\r
+ '</object>'\r
+ ].join('');\r
+\r
+ } else {\r
+\r
+ oMovie = doc.createElement('embed');\r
+ for (tmp in oEmbed) {\r
+ if (oEmbed.hasOwnProperty(tmp)) {\r
+ oMovie.setAttribute(tmp, oEmbed[tmp]);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ initDebug();\r
+ extraClass = getSWFCSS();\r
+ oTarget = getDocument();\r
+\r
+ if (oTarget) {\r
+\r
+ sm2.oMC = (id(sm2.movieID) || doc.createElement('div'));\r
+\r
+ if (!sm2.oMC.id) {\r
+\r
+ sm2.oMC.id = sm2.movieID;\r
+ sm2.oMC.className = swfCSS.swfDefault + ' ' + extraClass;\r
+ s = null;\r
+ oEl = null;\r
+\r
+ if (!sm2.useFlashBlock) {\r
+ if (sm2.useHighPerformance) {\r
+ // on-screen at all times\r
+ s = {\r
+ 'position': 'fixed',\r
+ 'width': '8px',\r
+ 'height': '8px',\r
+ // >= 6px for flash to run fast, >= 8px to start up under Firefox/win32 in some cases. odd? yes.\r
+ 'bottom': '0px',\r
+ 'left': '0px',\r
+ 'overflow': 'hidden'\r
+ };\r
+ } else {\r
+ // hide off-screen, lower priority\r
+ s = {\r
+ 'position': 'absolute',\r
+ 'width': '6px',\r
+ 'height': '6px',\r
+ 'top': '-9999px',\r
+ 'left': '-9999px'\r
+ };\r
+ if (isRTL) {\r
+ s.left = Math.abs(parseInt(s.left,10))+'px';\r
+ }\r
+ }\r
+ }\r
+\r
+ if (isWebkit) {\r
+ // soundcloud-reported render/crash fix, safari 5\r
+ sm2.oMC.style.zIndex = 10000;\r
+ }\r
+\r
+ if (!sm2.debugFlash) {\r
+ for (x in s) {\r
+ if (s.hasOwnProperty(x)) {\r
+ sm2.oMC.style[x] = s[x];\r
+ }\r
+ }\r
+ }\r
+\r
+ try {\r
+ if (!isIE) {\r
+ sm2.oMC.appendChild(oMovie);\r
+ }\r
+ oTarget.appendChild(sm2.oMC);\r
+ if (isIE) {\r
+ oEl = sm2.oMC.appendChild(doc.createElement('div'));\r
+ oEl.className = swfCSS.swfBox;\r
+ oEl.innerHTML = movieHTML;\r
+ }\r
+ appendSuccess = true;\r
+ } catch(e) {\r
+ throw new Error(str('domError')+' \n'+e.toString());\r
+ }\r
+\r
+ } else {\r
+\r
+ // SM2 container is already in the document (eg. flashblock use case)\r
+ sClass = sm2.oMC.className;\r
+ sm2.oMC.className = (sClass?sClass+' ':swfCSS.swfDefault) + (extraClass?' '+extraClass:'');\r
+ sm2.oMC.appendChild(oMovie);\r
+ if (isIE) {\r
+ oEl = sm2.oMC.appendChild(doc.createElement('div'));\r
+ oEl.className = swfCSS.swfBox;\r
+ oEl.innerHTML = movieHTML;\r
+ }\r
+ appendSuccess = true;\r
+\r
+ }\r
+\r
+ }\r
+\r
+ didAppend = true;\r
+ initMsg();\r
+ // sm2._wD(sm + ': Trying to load ' + smURL + (!overHTTP && sm2.altURL ? ' (alternate URL)' : ''), 1);\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ initMovie = function() {\r
+\r
+ if (sm2.html5Only) {\r
+ createMovie();\r
+ return false;\r
+ }\r
+\r
+ // attempt to get, or create, movie (may already exist)\r
+ if (flash) {\r
+ return false;\r
+ }\r
+\r
+ if (!sm2.url) {\r
+\r
+ /**\r
+ * Something isn't right - we've reached init, but the soundManager url property has not been set.\r
+ * User has not called setup({url: ...}), or has not set soundManager.url (legacy use case) directly before init time.\r
+ * Notify and exit. If user calls setup() with a url: property, init will be restarted as in the deferred loading case.\r
+ */\r
+\r
+ _wDS('noURL');\r
+ return false;\r
+\r
+ }\r
+\r
+ // inline markup case\r
+ flash = sm2.getMovie(sm2.id);\r
+\r
+ if (!flash) {\r
+ if (!oRemoved) {\r
+ // try to create\r
+ createMovie(sm2.id, sm2.url);\r
+ } else {\r
+ // try to re-append removed movie after reboot()\r
+ if (!isIE) {\r
+ sm2.oMC.appendChild(oRemoved);\r
+ } else {\r
+ sm2.oMC.innerHTML = oRemovedHTML;\r
+ }\r
+ oRemoved = null;\r
+ didAppend = true;\r
+ }\r
+ flash = sm2.getMovie(sm2.id);\r
+ }\r
+\r
+ if (typeof sm2.oninitmovie === 'function') {\r
+ setTimeout(sm2.oninitmovie, 1);\r
+ }\r
+\r
+ // <d>\r
+ flushMessages();\r
+ // </d>\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ delayWaitForEI = function() {\r
+\r
+ setTimeout(waitForEI, 1000);\r
+\r
+ };\r
+\r
+ waitForEI = function() {\r
+\r
+ var p,\r
+ loadIncomplete = false;\r
+\r
+ if (!sm2.url) {\r
+ // No SWF url to load (noURL case) - exit for now. Will be retried when url is set.\r
+ return false;\r
+ }\r
+\r
+ if (waitingForEI) {\r
+ return false;\r
+ }\r
+\r
+ waitingForEI = true;\r
+ event.remove(window, 'load', delayWaitForEI);\r
+\r
+ if (tryInitOnFocus && !isFocused) {\r
+ // Safari won't load flash in background tabs, only when focused.\r
+ _wDS('waitFocus');\r
+ return false;\r
+ }\r
+\r
+ if (!didInit) {\r
+ p = sm2.getMoviePercent();\r
+ if (p > 0 && p < 100) {\r
+ loadIncomplete = true;\r
+ }\r
+ }\r
+\r
+ setTimeout(function() {\r
+\r
+ p = sm2.getMoviePercent();\r
+\r
+ if (loadIncomplete) {\r
+ // special case: if movie *partially* loaded, retry until it's 100% before assuming failure.\r
+ waitingForEI = false;\r
+ sm2._wD(str('waitSWF'));\r
+ window.setTimeout(delayWaitForEI, 1);\r
+ return false;\r
+ }\r
+\r
+ // <d>\r
+ if (!didInit) {\r
+ sm2._wD(sm + ': No Flash response within expected time. Likely causes: ' + (p === 0 ? 'SWF load failed, ':'') + 'Flash blocked or JS-Flash security error.' + (sm2.debugFlash?' ' + str('checkSWF'):''), 2);\r
+ if (!overHTTP && p) {\r
+ _wDS('localFail', 2);\r
+ if (!sm2.debugFlash) {\r
+ _wDS('tryDebug', 2);\r
+ }\r
+ }\r
+ if (p === 0) {\r
+ // if 0 (not null), probably a 404.\r
+ sm2._wD(str('swf404', sm2.url), 1);\r
+ }\r
+ debugTS('flashtojs', false, ': Timed out' + overHTTP?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)');\r
+ }\r
+ // </d>\r
+\r
+ // give up / time-out, depending\r
+\r
+ if (!didInit && okToDisable) {\r
+ if (p === null) {\r
+ // SWF failed. Maybe blocked.\r
+ if (sm2.useFlashBlock || sm2.flashLoadTimeout === 0) {\r
+ if (sm2.useFlashBlock) {\r
+ flashBlockHandler();\r
+ }\r
+ _wDS('waitForever');\r
+ } else {\r
+ // no custom flash block handling, but SWF has timed out. Will recover if user unblocks / allows SWF load.\r
+ _wDS('waitForever');\r
+ // fire any regular registered ontimeout() listeners.\r
+ processOnEvents({type:'ontimeout', ignoreInit: true});\r
+ }\r
+ } else {\r
+ // flash loaded? Shouldn't be a blocking issue, then.\r
+ if (sm2.flashLoadTimeout === 0) {\r
+ _wDS('waitForever');\r
+ } else {\r
+ failSafely(true);\r
+ }\r
+ }\r
+ }\r
+\r
+ }, sm2.flashLoadTimeout);\r
+\r
+ };\r
+\r
+ handleFocus = function() {\r
+\r
+ function cleanup() {\r
+ event.remove(window, 'focus', handleFocus);\r
+ }\r
+\r
+ if (isFocused || !tryInitOnFocus) {\r
+ // already focused, or not special Safari background tab case\r
+ cleanup();\r
+ return true;\r
+ }\r
+\r
+ okToDisable = true;\r
+ isFocused = true;\r
+ _wDS('gotFocus');\r
+\r
+ // allow init to restart\r
+ waitingForEI = false;\r
+\r
+ // kick off ExternalInterface timeout, now that the SWF has started\r
+ delayWaitForEI();\r
+\r
+ cleanup();\r
+ return true;\r
+\r
+ };\r
+\r
+ flushMessages = function() {\r
+\r
+ // <d>\r
+\r
+ // SM2 pre-init debug messages\r
+ if (messages.length) {\r
+ sm2._wD('SoundManager 2: ' + messages.join(' '), 1);\r
+ messages = [];\r
+ }\r
+\r
+ // </d>\r
+\r
+ };\r
+\r
+ showSupport = function() {\r
+\r
+ // <d>\r
+\r
+ flushMessages();\r
+\r
+ var item, tests = [];\r
+\r
+ if (sm2.useHTML5Audio && sm2.hasHTML5) {\r
+ for (item in sm2.audioFormats) {\r
+ if (sm2.audioFormats.hasOwnProperty(item)) {\r
+ tests.push(item + ' = ' + sm2.html5[item] + (!sm2.html5[item] && hasFlash && sm2.flash[item] ? ' (using flash)' : (sm2.preferFlash && sm2.flash[item] && hasFlash ? ' (preferring flash)': (!sm2.html5[item] ? ' (' + (sm2.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : ''))));\r
+ }\r
+ }\r
+ sm2._wD('SoundManager 2 HTML5 support: ' + tests.join(', '), 1);\r
+ }\r
+\r
+ // </d>\r
+\r
+ };\r
+\r
+ initComplete = function(bNoDisable) {\r
+\r
+ if (didInit) {\r
+ return false;\r
+ }\r
+\r
+ if (sm2.html5Only) {\r
+ // all good.\r
+ _wDS('sm2Loaded');\r
+ didInit = true;\r
+ initUserOnload();\r
+ debugTS('onload', true);\r
+ return true;\r
+ }\r
+\r
+ var wasTimeout = (sm2.useFlashBlock && sm2.flashLoadTimeout && !sm2.getMoviePercent()),\r
+ result = true,\r
+ error;\r
+\r
+ if (!wasTimeout) {\r
+ didInit = true;\r
+ if (disabled) {\r
+ error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')};\r
+ }\r
+ }\r
+\r
+ sm2._wD('SoundManager 2 ' + (disabled ? 'failed to load' : 'loaded') + ' (' + (disabled ? 'Flash security/load error' : 'OK') + ')', disabled ? 2: 1);\r
+\r
+ if (disabled || bNoDisable) {\r
+ if (sm2.useFlashBlock && sm2.oMC) {\r
+ sm2.oMC.className = getSWFCSS() + ' ' + (sm2.getMoviePercent() === null?swfCSS.swfTimedout:swfCSS.swfError);\r
+ }\r
+ processOnEvents({type:'ontimeout', error:error, ignoreInit: true});\r
+ debugTS('onload', false);\r
+ catchError(error);\r
+ result = false;\r
+ } else {\r
+ debugTS('onload', true);\r
+ }\r
+\r
+ if (!disabled) {\r
+ if (sm2.waitForWindowLoad && !windowLoaded) {\r
+ _wDS('waitOnload');\r
+ event.add(window, 'load', initUserOnload);\r
+ } else {\r
+ // <d>\r
+ if (sm2.waitForWindowLoad && windowLoaded) {\r
+ _wDS('docLoaded');\r
+ }\r
+ // </d>\r
+ initUserOnload();\r
+ }\r
+ }\r
+\r
+ return result;\r
+\r
+ };\r
+\r
+ /**\r
+ * apply top-level setupOptions object as local properties, eg., this.setupOptions.flashVersion -> this.flashVersion (soundManager.flashVersion)\r
+ * this maintains backward compatibility, and allows properties to be defined separately for use by soundManager.setup().\r
+ */\r
+\r
+ setProperties = function() {\r
+\r
+ var i,\r
+ o = sm2.setupOptions;\r
+\r
+ for (i in o) {\r
+\r
+ if (o.hasOwnProperty(i)) {\r
+\r
+ // assign local property if not already defined\r
+\r
+ if (sm2[i] === _undefined) {\r
+\r
+ sm2[i] = o[i];\r
+\r
+ } else if (sm2[i] !== o[i]) {\r
+\r
+ // legacy support: write manually-assigned property (eg., soundManager.url) back to setupOptions to keep things in sync\r
+ sm2.setupOptions[i] = sm2[i];\r
+\r
+ }\r
+\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+\r
+ init = function() {\r
+\r
+ // called after onload()\r
+\r
+ if (didInit) {\r
+ _wDS('didInit');\r
+ return false;\r
+ }\r
+\r
+ function cleanup() {\r
+ event.remove(window, 'load', sm2.beginDelayedInit);\r
+ }\r
+\r
+ if (sm2.html5Only) {\r
+ if (!didInit) {\r
+ // we don't need no steenking flash!\r
+ cleanup();\r
+ sm2.enabled = true;\r
+ initComplete();\r
+ }\r
+ return true;\r
+ }\r
+\r
+ // flash path\r
+ initMovie();\r
+\r
+ try {\r
+\r
+ // attempt to talk to Flash\r
+ flash._externalInterfaceTest(false);\r
+\r
+ // apply user-specified polling interval, OR, if "high performance" set, faster vs. default polling\r
+ // (determines frequency of whileloading/whileplaying callbacks, effectively driving UI framerates)\r
+ setPolling(true, (sm2.flashPollingInterval || (sm2.useHighPerformance ? 10 : 50)));\r
+\r
+ if (!sm2.debugMode) {\r
+ // stop the SWF from making debug output calls to JS\r
+ flash._disableDebug();\r
+ }\r
+\r
+ sm2.enabled = true;\r
+ debugTS('jstoflash', true);\r
+\r
+ if (!sm2.html5Only) {\r
+ // prevent browser from showing cached page state (or rather, restoring "suspended" page state) via back button, because flash may be dead\r
+ // http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/\r
+ event.add(window, 'unload', doNothing);\r
+ }\r
+\r
+ } catch(e) {\r
+\r
+ sm2._wD('js/flash exception: ' + e.toString());\r
+ debugTS('jstoflash', false);\r
+ catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true});\r
+ // don't disable, for reboot()\r
+ failSafely(true);\r
+ initComplete();\r
+\r
+ return false;\r
+\r
+ }\r
+\r
+ initComplete();\r
+\r
+ // disconnect events\r
+ cleanup();\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ domContentLoaded = function() {\r
+\r
+ if (didDCLoaded) {\r
+ return false;\r
+ }\r
+\r
+ didDCLoaded = true;\r
+\r
+ // assign top-level soundManager properties eg. soundManager.url\r
+ setProperties();\r
+\r
+ initDebug();\r
+\r
+ /**\r
+ * Temporary feature: allow force of HTML5 via URL params: sm2-usehtml5audio=0 or 1\r
+ * Ditto for sm2-preferFlash, too.\r
+ */\r
+ // <d>\r
+ (function(){\r
+\r
+ var a = 'sm2-usehtml5audio=',\r
+ a2 = 'sm2-preferflash=',\r
+ b = null, \r
+ b2 = null,\r
+ hasCon = (window.console !== _undefined && typeof console.log === 'function'),\r
+ l = wl.toLowerCase();\r
+\r
+ if (l.indexOf(a) !== -1) {\r
+ b = (l.charAt(l.indexOf(a)+a.length) === '1');\r
+ if (hasCon) {\r
+ console.log((b?'Enabling ':'Disabling ')+'useHTML5Audio via URL parameter');\r
+ }\r
+ sm2.setup({\r
+ 'useHTML5Audio': b\r
+ });\r
+ }\r
+\r
+ if (l.indexOf(a2) !== -1) {\r
+ b2 = (l.charAt(l.indexOf(a2)+a2.length) === '1');\r
+ if (hasCon) {\r
+ console.log((b2?'Enabling ':'Disabling ')+'preferFlash via URL parameter');\r
+ }\r
+ sm2.setup({\r
+ 'preferFlash': b2\r
+ });\r
+ }\r
+\r
+ }());\r
+ // </d>\r
+\r
+ if (!hasFlash && sm2.hasHTML5) {\r
+ sm2._wD('SoundManager: No Flash detected' + (!sm2.useHTML5Audio ? ', enabling HTML5.' : '. Trying HTML5-only mode.'), 1);\r
+ sm2.setup({\r
+ 'useHTML5Audio': true,\r
+ // make sure we aren't preferring flash, either\r
+ // TODO: preferFlash should not matter if flash is not installed. Currently, stuff breaks without the below tweak.\r
+ 'preferFlash': false\r
+ });\r
+ }\r
+\r
+ testHTML5();\r
+ sm2.html5.usingFlash = featureCheck();\r
+ needsFlash = sm2.html5.usingFlash;\r
+\r
+ if (!hasFlash && needsFlash) {\r
+ messages.push(strings.needFlash);\r
+ // TODO: Fatal here vs. timeout approach, etc.\r
+ // hack: fail sooner.\r
+ sm2.setup({\r
+ 'flashLoadTimeout': 1\r
+ });\r
+ }\r
+\r
+ if (doc.removeEventListener) {\r
+ doc.removeEventListener('DOMContentLoaded', domContentLoaded, false);\r
+ }\r
+\r
+ initMovie();\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ domContentLoadedIE = function() {\r
+\r
+ if (doc.readyState === 'complete') {\r
+ domContentLoaded();\r
+ doc.detachEvent('onreadystatechange', domContentLoadedIE);\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ winOnLoad = function() {\r
+\r
+ // catch edge case of initComplete() firing after window.load()\r
+ windowLoaded = true;\r
+ event.remove(window, 'load', winOnLoad);\r
+\r
+ };\r
+\r
+ /**\r
+ * miscellaneous run-time, pre-init stuff\r
+ */\r
+\r
+ preInit = function() {\r
+\r
+ if (mobileHTML5) {\r
+\r
+ // prefer HTML5 for mobile + tablet-like devices, probably more reliable vs. flash at this point.\r
+\r
+ // <d>\r
+ if (!sm2.setupOptions.useHTML5Audio || sm2.setupOptions.preferFlash) {\r
+ // notify that defaults are being changed.\r
+ messages.push(strings.mobileUA);\r
+ }\r
+ // </d>\r
+\r
+ sm2.setupOptions.useHTML5Audio = true;\r
+ sm2.setupOptions.preferFlash = false;\r
+\r
+ if (is_iDevice || (isAndroid && !ua.match(/android\s2\.3/i))) {\r
+ // iOS and Android devices tend to work better with a single audio instance, specifically for chained playback of sounds in sequence.\r
+ // common use case: exiting sound onfinish() -> createSound() -> play()\r
+ // <d>\r
+ messages.push(strings.globalHTML5);\r
+ // </d>\r
+ if (is_iDevice) {\r
+ sm2.ignoreFlash = true;\r
+ }\r
+ useGlobalHTML5Audio = true;\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ preInit();\r
+\r
+ // sniff up-front\r
+ detectFlash();\r
+\r
+ // focus and window load, init (primarily flash-driven)\r
+ event.add(window, 'focus', handleFocus);\r
+ event.add(window, 'load', delayWaitForEI);\r
+ event.add(window, 'load', winOnLoad);\r
+\r
+ if (doc.addEventListener) {\r
+\r
+ doc.addEventListener('DOMContentLoaded', domContentLoaded, false);\r
+\r
+ } else if (doc.attachEvent) {\r
+\r
+ doc.attachEvent('onreadystatechange', domContentLoadedIE);\r
+\r
+ } else {\r
+\r
+ // no add/attachevent support - safe to assume no JS -> Flash either\r
+ debugTS('onload', false);\r
+ catchError({type:'NO_DOM2_EVENTS', fatal:true});\r
+\r
+ }\r
+\r
+} // SoundManager()\r
+\r
+// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading\r
+\r
+if (window.SM2_DEFER === undefined || !SM2_DEFER) {\r
+ soundManager = new SoundManager();\r
+}\r
+\r
+/**\r
+ * SoundManager public interfaces\r
+ * ------------------------------\r
+ */\r
+\r
+window.SoundManager = SoundManager; // constructor\r
+window.soundManager = soundManager; // public API, flash callbacks etc.\r
+\r
+}(window));
\ No newline at end of file