-/** @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.20110424
-*/
-(function(Y){function M(M,X){function i(c){return function(a){return!this._t||!this._t._a?null:c.call(this,a)}}function pa(){if(c.debugURLParam.test(N))c.debugMode=!0}this.flashVersion=8;this.debugFlash=this.debugMode=!1;this.useConsole=!0;this.waitForWindowLoad=this.consoleOnly=!1;this.nullURL="about:blank";this.allowPolling=!0;this.useFastPolling=!1;this.useMovieStar=!0;this.bgColor="#ffffff";this.useHighPerformance=!1;this.flashPollingInterval=null;this.flashLoadTimeout=1E3;this.wmode=null;this.allowScriptAccess=
-"always";this.useHTML5Audio=this.useFlashBlock=!1;this.html5Test=/^probably$/i;this.useGlobalHTML5Audio=!0;this.requireFlash=!1;this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!0},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave",
-"audio/x-wav"],required:!1}};this.defaultOptions={autoLoad:!1,stream:!0,autoPlay:!1,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfailure:null,onfinish:null,onbeforefinish:null,onbeforefinishtime:5E3,onbeforefinishcomplete:null,onjustbeforefinish:null,onjustbeforefinishtime:200,multiShot:!0,multiShotEvents:!1,position:null,pan:0,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.version=null;this.versionNumber="V2.97a.20110424";this.movieURL=null;this.url=M||null;this.altURL=null;this.enabled=this.swfLoaded=!1;this.o=null;this.movieID="sm2-container";this.id=X||"sm2movie";this.swfCSS={swfBox:"sm2-object-box",swfDefault:"movieContainer",swfError:"swf_error",swfTimedout:"swf_timedout",swfLoaded:"swf_loaded",swfUnblocked:"swf_unblocked",sm2Debug:"sm2_debug",
-highPerf:"high_performance",flashDebug:"flash_debug"};this.oMC=null;this.sounds={};this.soundIDs=[];this.muted=!1;this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.didFlashBlock=this.specialWmodeCase=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.baseMimeTypes=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.netStreamMimeTypes=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.netStreamTypes=["aac","flv","mov","mp4","m4v",
-"f4v","m4a","mp4v","3gp","3g2"];this.netStreamPattern=RegExp("\\.("+this.netStreamTypes.join("|")+")(\\?.*)?$","i");this.mimePattern=this.baseMimeTypes;this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1};this.sandbox={};this.hasHTML5=null;this.html5={usingFlash:null};this.ignoreFlash=!1;var Z,c=this,y,n=navigator.userAgent,h=Y,N=h.location.href.toString(),k=this.flashVersion,g=document,$,O,r=[],E=!1,F=!1,m=!1,t=!1,qa=!1,G,o,aa,u,z,ba,P,ra,ca,v,sa,H,A,da,ea,Q,fa,ta,ua,R,
-va,I=null,ga=null,w,ha,B,S,T,ia,j,U=!1,ja=!1,wa,xa,x=null,ya,V,p=!1,J,s,ka,za,l,Da=Array.prototype.slice,K=!1,la,C,Aa,Ba=n.match(/pre\//i),Ea=n.match(/(ipad|iphone|ipod)/i);n.match(/mobile/i);var q=n.match(/msie/i),Fa=n.match(/webkit/i),L=n.match(/safari/i)&&!n.match(/chrome/i),Ga=n.match(/opera/i),ma=!N.match(/usehtml5audio/i)&&!N.match(/sm2\-ignorebadua/i)&&L&&n.match(/OS X 10_6_([3-9])/i),na=typeof g.hasFocus!=="undefined"?g.hasFocus():null,D=typeof g.hasFocus==="undefined"&&L,Ca=!D;this._use_maybe=
-N.match(/sm2\-useHTML5Maybe\=1/i);this._overHTTP=g.location?g.location.protocol.match(/http/i):null;this._http=!this._overHTTP?"http:":"";this.useAltURL=!this._overHTTP;this._global_a=null;if(Ea||Ba)c.useHTML5Audio=!0,c.ignoreFlash=!0,c.useGlobalHTML5Audio&&(K=!0);if(Ba||this._use_maybe)c.html5Test=/^(probably|maybe)$/i;this.supported=this.ok=function(){return x?m&&!t:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return q?h[c]:L?y(c)||g[c]:y(c)};this.createSound=function(b){function a(){e=
-S(e);c.sounds[d.id]=new Z(d);c.soundIDs.push(d.id);return c.sounds[d.id]}var e=null,f=null,d=null;if(!m||!c.ok())return ia("soundManager.createSound(): "+w(!m?"notReady":"notOK")),!1;arguments.length===2&&(b={id:arguments[0],url:arguments[1]});d=e=o(b);if(j(d.id,!0))return c.sounds[d.id];if(V(d))f=a(),f._setup_html5(d);else{if(k>8&&c.useMovieStar){if(d.isMovieStar===null)d.isMovieStar=d.serverURL||d.type&&d.type.match(c.netStreamPattern)||d.url.match(c.netStreamPattern)?!0:!1;if(d.isMovieStar&&d.usePeakData)d.usePeakData=
-!1}d=T(d,"soundManager.createSound(): ");f=a();if(k===8)c.o._createSound(d.id,d.onjustbeforefinishtime,d.loops||1,d.usePolicyFile);else if(c.o._createSound(d.id,d.url,d.onjustbeforefinishtime,d.usePeakData,d.useWaveformData,d.useEQData,d.isMovieStar,d.isMovieStar?d.bufferTime:!1,d.loops||1,d.serverURL,d.duration||null,d.autoPlay,!0,d.autoLoad,d.usePolicyFile),!d.serverURL)f.connected=!0,d.onconnect&&d.onconnect.apply(f);(d.autoLoad||d.autoPlay)&&!d.serverURL&&f.load(d)}d.autoPlay&&!d.serverURL&&f.play();
-return f};this.destroySound=function(b,a){if(!j(b))return!1;var e=c.sounds[b],f;e._iO={};e.stop();e.unload();for(f=0;f<c.soundIDs.length;f++)if(c.soundIDs[f]===b){c.soundIDs.splice(f,1);break}a||e.destruct(!0);delete c.sounds[b];return!0};this.load=function(b,a){if(!j(b))return!1;return c.sounds[b].load(a)};this.unload=function(b){if(!j(b))return!1;return c.sounds[b].unload()};this.start=this.play=function(b,a){if(!m||!c.ok())return ia("soundManager.play(): "+w(!m?"notReady":"notOK")),!1;if(!j(b))return a instanceof
-Object||(a={url:a}),a&&a.url?(a.id=b,c.createSound(a).play()):!1;return c.sounds[b].play(a)};this.setPosition=function(b,a){if(!j(b))return!1;return c.sounds[b].setPosition(a)};this.stop=function(b){if(!j(b))return!1;return c.sounds[b].stop()};this.stopAll=function(){for(var b in c.sounds)c.sounds[b]instanceof Z&&c.sounds[b].stop()};this.pause=function(b){if(!j(b))return!1;return c.sounds[b].pause()};this.pauseAll=function(){for(var b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].pause()};this.resume=
-function(b){if(!j(b))return!1;return c.sounds[b].resume()};this.resumeAll=function(){for(var b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].resume()};this.togglePause=function(b){if(!j(b))return!1;return c.sounds[b].togglePause()};this.setPan=function(b,a){if(!j(b))return!1;return c.sounds[b].setPan(a)};this.setVolume=function(b,a){if(!j(b))return!1;return c.sounds[b].setVolume(a)};this.mute=function(b){var a=0;typeof b!=="string"&&(b=null);if(b){if(!j(b))return!1;return c.sounds[b].mute()}else{for(a=
-c.soundIDs.length;a--;)c.sounds[c.soundIDs[a]].mute();c.muted=!0}return!0};this.muteAll=function(){c.mute()};this.unmute=function(b){typeof b!=="string"&&(b=null);if(b){if(!j(b))return!1;return c.sounds[b].unmute()}else{for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].unmute();c.muted=!1}return!0};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(b){if(!j(b))return!1;return c.sounds[b].toggleMute()};this.getMemoryUse=function(){if(k===8)return 0;if(c.o)return parseInt(c.o._getMemoryUse(),
-10)};this.disable=function(b){typeof b==="undefined"&&(b=!1);if(t)return!1;t=!0;for(var a=c.soundIDs.length;a--;)ua(c.sounds[c.soundIDs[a]]);G(b);l.remove(h,"load",z);return!0};this.canPlayMIME=function(b){var a;c.hasHTML5&&(a=J({type:b}));return!x||a?a:b?b.match(c.mimePattern)?!0:!1:null};this.canPlayURL=function(b){var a;c.hasHTML5&&(a=J(b));return!x||a?a:b?b.match(c.filePattern)?!0:!1:null};this.canPlayLink=function(b){if(typeof b.type!=="undefined"&&b.type&&c.canPlayMIME(b.type))return!0;return c.canPlayURL(b.href)};
-this.getSoundById=function(b){if(!b)throw Error("soundManager.getSoundById(): sID is null/undefined");return c.sounds[b]};this.onready=function(c,a){if(c&&c instanceof Function)return a||(a=h),aa("onready",c,a),u(),!0;else throw w("needFunction","onready");};this.ontimeout=function(c,a){if(c&&c instanceof Function)return a||(a=h),aa("ontimeout",c,a),u({type:"ontimeout"}),!0;else throw w("needFunction","ontimeout");};this.getMoviePercent=function(){return c.o&&typeof c.o.PercentLoaded!=="undefined"?
-c.o.PercentLoaded():null};this._wD=this._writeDebug=function(){return!0};this._debug=function(){};this.reboot=function(){var b,a;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].destruct();try{if(q)ga=c.o.innerHTML;I=c.o.parentNode.removeChild(c.o)}catch(e){}ga=I=null;c.enabled=m=U=ja=E=F=t=c.swfLoaded=!1;c.soundIDs=c.sounds=[];c.o=null;for(b in r)if(r.hasOwnProperty(b))for(a=r[b].length;a--;)r[b][a].fired=!1;h.setTimeout(function(){c.beginDelayedInit()},20)};this.destruct=function(){c.disable(!0)};
-this.beginDelayedInit=function(){qa=!0;A();setTimeout(sa,20);P()};this._html5_events={abort:i(function(){}),canplay:i(function(){this._t._onbufferchange(0);var c=!isNaN(this._t.position)?this._t.position/1E3:null;this._t._html5_canplay=!0;if(this._t.position&&this.currentTime!==c)try{this.currentTime=c}catch(a){}}),load:i(function(){this._t.loaded||(this._t._onbufferchange(0),this._t._whileloading(this._t.bytesTotal,this._t.bytesTotal,this._t._get_html5_duration()),this._t._onload(!0))}),emptied:i(function(){}),
-ended:i(function(){this._t._onfinish()}),error:i(function(){this._t._onload(!1)}),loadeddata:i(function(){}),loadedmetadata:i(function(){}),loadstart:i(function(){this._t._onbufferchange(1)}),play:i(function(){this._t._onbufferchange(0)}),playing:i(function(){this._t._onbufferchange(0)}),progress:i(function(b){if(this._t.loaded)return!1;var a,e=0,f=b.type==="progress",d=b.target.buffered;a=b.loaded||0;var oa=b.total||1;if(d&&d.length){for(a=d.length;a--;)e=d.end(a)-d.start(a);a=e/b.target.duration;
-f&&isNaN(a)}isNaN(a)||(this._t._onbufferchange(0),this._t._whileloading(a,oa,this._t._get_html5_duration()),a&&oa&&a===oa&&c._html5_events.load.call(this,b))}),ratechange:i(function(){}),suspend:i(function(b){c._html5_events.progress.call(this,b)}),stalled:i(function(){}),timeupdate:i(function(){this._t._onTimer()}),waiting:i(function(){this._t._onbufferchange(1)})};Z=function(b){var a=this,e,f,d;this.sID=b.id;this.url=b.url;this._iO=this.instanceOptions=this.options=o(b);this.pan=this.options.pan;
-this.volume=this.options.volume;this._lastURL=null;this.isHTML5=!1;this._a=null;this.id3={};this._debug=function(){};this._debug();this.load=function(b){var d=null;if(typeof b!=="undefined")a._iO=o(b,a.options),a.instanceOptions=a._iO;else if(b=a.options,a._iO=b,a.instanceOptions=a._iO,a._lastURL&&a._lastURL!==a.url)a._iO.url=a.url,a.url=null;if(!a._iO.url)a._iO.url=a.url;if(a._iO.url===a.url&&a.readyState!==0&&a.readyState!==2)return a;a._lastURL=a.url;a.loaded=!1;a.readyState=1;a.playState=0;if(V(a._iO)){if(d=
-a._setup_html5(a._iO),!d._called_load)d.load(),d._called_load=!0,a._iO.autoPlay&&a.play()}else try{a.isHTML5=!1,a._iO=T(S(a._iO)),k===8?c.o._load(a.sID,a._iO.url,a._iO.stream,a._iO.autoPlay,a._iO.whileloading?1:0,a._iO.loops||1,a._iO.usePolicyFile):c.o._load(a.sID,a._iO.url,a._iO.stream?!0:!1,a._iO.autoPlay?!0:!1,a._iO.loops||1,a._iO.autoLoad?!0:!1,a._iO.usePolicyFile)}catch(e){fa()}return a};this.unload=function(){if(a.readyState!==0){if(a.isHTML5){if(f(),a._a)a._a.pause(),a._a.src=""}else k===8?
-c.o._unload(a.sID,c.nullURL):c.o._unload(a.sID);e()}return a};this.destruct=function(b){if(a.isHTML5){if(f(),a._a)a._a.pause(),a._a.src="",K||a._remove_html5_events()}else a._iO.onfailure=null,c.o._destroySound(a.sID);b||c.destroySound(a.sID,!0)};this.start=this.play=function(b,W){var e,W=W===void 0?!0:W;b||(b={});a._iO=o(b,a._iO);a._iO=o(a._iO,a.options);a.instanceOptions=a._iO;if(a._iO.serverURL&&!a.connected)return a.getAutoPlay()||a.setAutoPlay(!0),a;V(a._iO)&&(a._setup_html5(a._iO),d());if(a.playState===
-1&&!a.paused)if(e=a._iO.multiShot)a.isHTML5&&a.setPosition(a._iO.position);else return a;if(!a.loaded)if(a.readyState===0){if(!a.isHTML5)a._iO.autoPlay=!0;a.load(a._iO)}else if(a.readyState===2)return a;if(a.paused&&a.position&&a.position>0)a.resume();else{a.playState=1;a.paused=!1;(!a.instanceCount||a._iO.multiShotEvents||k>8&&!a.isHTML5&&!a.getAutoPlay())&&a.instanceCount++;a.position=typeof a._iO.position!=="undefined"&&!isNaN(a._iO.position)?a._iO.position:0;if(!a.isHTML5)a._iO=T(S(a._iO));if(a._iO.onplay&&
-W)a._iO.onplay.apply(a),a._onplay_called=!0;a.setVolume(a._iO.volume,!0);a.setPan(a._iO.pan,!0);a.isHTML5?(d(),a._setup_html5().play()):c.o._start(a.sID,a._iO.loops||1,k===9?a.position:a.position/1E3)}return a};this.stop=function(b){if(a.playState===1){a._onbufferchange(0);a.resetOnPosition(0);if(!a.isHTML5)a.playState=0;a.paused=!1;a._iO.onstop&&a._iO.onstop.apply(a);if(a.isHTML5){if(a._a)a.setPosition(0),a._a.pause(),a.playState=0,a._onTimer(),f(),a.unload()}else c.o._stop(a.sID,b),a._iO.serverURL&&
-a.unload();a.instanceCount=0;a._iO={}}return a};this.setAutoPlay=function(b){a._iO.autoPlay=b;a.isHTML5?a._a&&b&&a.play():c.o._setAutoPlay(a.sID,b);b&&!a.instanceCount&&a.readyState===1&&a.instanceCount++};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition=function(b){b===void 0&&(b=0);var d=a.isHTML5?Math.max(b,0):Math.min(a.duration||a._iO.duration,Math.max(b,0));a.position=d;b=a.position/1E3;a.resetOnPosition(a.position);a._iO.position=d;if(a.isHTML5){if(a._a&&a._html5_canplay&&
-a._a.currentTime!==b)try{a._a.currentTime=b}catch(e){}}else b=k===9?a.position:b,a.readyState&&a.readyState!==2&&c.o._setPosition(a.sID,b,a.paused||!a.playState);a.isHTML5&&a.paused&&a._onTimer(!0);return a};this.pause=function(b){if(a.paused||a.playState===0&&a.readyState!==1)return a;a.paused=!0;a.isHTML5?(a._setup_html5().pause(),f()):(b||b===void 0)&&c.o._pause(a.sID);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){if(!a.paused)return a;a.paused=!1;a.playState=1;a.isHTML5?
-(a._setup_html5().play(),d()):(a._iO.isMovieStar&&a.setPosition(a.position),c.o._pause(a.sID));!a._onplay_called&&a._iO.onplay?(a._iO.onplay.apply(a),a._onplay_called=!0):a._iO.onresume&&a._iO.onresume.apply(a);return a};this.togglePause=function(){if(a.playState===0)return a.play({position:k===9&&!a.isHTML5?a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,d){typeof b==="undefined"&&(b=0);typeof d==="undefined"&&(d=!1);a.isHTML5||c.o._setPan(a.sID,b);a._iO.pan=
-b;if(!d)a.pan=b,a.options.pan=b;return a};this.setVolume=function(b,d){typeof b==="undefined"&&(b=100);typeof d==="undefined"&&(d=!1);if(a.isHTML5){if(a._a)a._a.volume=Math.max(0,Math.min(1,b/100))}else c.o._setVolume(a.sID,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;if(!d)a.volume=b,a.options.volume=b;return a};this.mute=function(){a.muted=!0;if(a.isHTML5){if(a._a)a._a.muted=!0}else c.o._setVolume(a.sID,0);return a};this.unmute=function(){a.muted=!1;var b=typeof a._iO.volume!=="undefined";if(a.isHTML5){if(a._a)a._a.muted=
-!1}else c.o._setVolume(a.sID,b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=function(c,b,d){a._onPositionItems.push({position:c,method:b,scope:typeof d!=="undefined"?d:a,fired:!1});return a};this.processOnPosition=function(){var b,d;b=a._onPositionItems.length;if(!b||!a.playState||a._onPositionFired>=b)return!1;for(;b--;)if(d=a._onPositionItems[b],!d.fired&&a.position>=d.position)d.method.apply(d.scope,[d.position]),d.fired=
-!0,c._onPositionFired++;return!0};this.resetOnPosition=function(b){var d,e;d=a._onPositionItems.length;if(!d)return!1;for(;d--;)if(e=a._onPositionItems[d],e.fired&&b<=e.position)e.fired=!1,c._onPositionFired--;return!0};this._onTimer=function(c){var b={};if(a._hasTimer||c)return a._a&&(c||(a.playState>0||a.readyState===1)&&!a.paused)?(a.duration=a._get_html5_duration(),a.durationEstimate=a.duration,c=a._a.currentTime?a._a.currentTime*1E3:0,a._whileplaying(c,b,b,b,b),!0):!1};this._get_html5_duration=
-function(){var c=a._a?a._a.duration*1E3:a._iO?a._iO.duration:void 0;return c&&!isNaN(c)&&c!==Infinity?c:a._iO?a._iO.duration:null};d=function(){a.isHTML5&&wa(a)};f=function(){a.isHTML5&&xa(a)};e=function(){a._onPositionItems=[];a._onPositionFired=0;a._hasTimer=null;a._onplay_called=!1;a._a=null;a._html5_canplay=!1;a.bytesLoaded=null;a.bytesTotal=null;a.position=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.failures=0;a.loaded=!1;a.playState=0;a.paused=!1;a.readyState=
-0;a.muted=!1;a.didBeforeFinish=!1;a.didJustBeforeFinish=!1;a.isBuffering=!1;a.instanceOptions={};a.instanceCount=0;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.eqData=[];a.eqData.left=[];a.eqData.right=[]};e();this._setup_html5=function(b){var b=o(a._iO,b),d=K?c._global_a:a._a;decodeURI(b.url);var f=d&&d._t?d._t.instanceOptions:null;if(d){if(d._t&&f.url===b.url&&(!a._lastURL||a._lastURL===f.url))return d;K&&d._t&&d._t.playState&&b.url!==f.url&&d._t.stop();e();d.src=b.url;a.url=
-b.url;a._lastURL=b.url;d._called_load=!1}else if(d=new Audio(b.url),d._called_load=!1,K)c._global_a=d;a.isHTML5=!0;a._a=d;d._t=a;a._add_html5_events();d.loop=b.loops>1?"loop":"";b.autoLoad||b.autoPlay?(d.autobuffer="auto",d.preload="auto",a.load(),d._called_load=!0):(d.autobuffer=!1,d.preload="none");d.loop=b.loops>1?"loop":"";return d};this._add_html5_events=function(){if(a._a._added_events)return!1;var b;a._a._added_events=!0;for(b in c._html5_events)c._html5_events.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,
-c._html5_events[b],!1);return!0};this._remove_html5_events=function(){a._a._added_events=!1;for(var b in c._html5_events)c._html5_events.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,c._html5_events[b],!1)};this._whileloading=function(c,b,d,e){a.bytesLoaded=c;a.bytesTotal=b;a.duration=Math.floor(d);a.bufferLength=e;if(a._iO.isMovieStar)a.durationEstimate=a.duration;else if(a.durationEstimate=a._iO.duration?a.duration>a._iO.duration?a.duration:a._iO.duration:parseInt(a.bytesTotal/a.bytesLoaded*
-a.duration,10),a.durationEstimate===void 0)a.durationEstimate=a.duration;a.readyState!==3&&a._iO.whileloading&&a._iO.whileloading.apply(a)};this._onid3=function(c,b){var d=[],e,f;e=0;for(f=c.length;e<f;e++)d[c[e]]=b[e];a.id3=o(a.id3,d);a._iO.onid3&&a._iO.onid3.apply(a)};this._whileplaying=function(b,d,e,f,g){if(isNaN(b)||b===null)return!1;a.playState===0&&b>0&&(b=0);a.position=b;a.processOnPosition();if(k>8&&!a.isHTML5){if(a._iO.usePeakData&&typeof d!=="undefined"&&d)a.peakData={left:d.leftPeak,right:d.rightPeak};
-if(a._iO.useWaveformData&&typeof e!=="undefined"&&e)a.waveformData={left:e.split(","),right:f.split(",")};if(a._iO.useEQData&&typeof g!=="undefined"&&g&&g.leftEQ&&(b=g.leftEQ.split(","),a.eqData=b,a.eqData.left=b,typeof g.rightEQ!=="undefined"&&g.rightEQ))a.eqData.right=g.rightEQ.split(",")}a.playState===1&&(!a.isHTML5&&c.flashVersion===8&&!a.position&&a.isBuffering&&a._onbufferchange(0),a._iO.whileplaying&&a._iO.whileplaying.apply(a),(a.loaded||!a.loaded&&a._iO.isMovieStar)&&a._iO.onbeforefinish&&
-a._iO.onbeforefinishtime&&!a.didBeforeFinish&&a.duration-a.position<=a._iO.onbeforefinishtime&&a._onbeforefinish());return!0};this._onconnect=function(b){b=b===1;if(a.connected=b)a.failures=0,j(a.sID)&&(a.getAutoPlay()?a.play(void 0,a.getAutoPlay()):a._iO.autoLoad&&a.load()),a._iO.onconnect&&a._iO.onconnect.apply(a,[b])};this._onload=function(b){b=b?!0:!1;a.loaded=b;a.readyState=b?3:2;a._onbufferchange(0);a._iO.onload&&a._iO.onload.apply(a,[b]);return!0};this._onfailure=function(b,c,d){a.failures++;
-if(a._iO.onfailure&&a.failures===1)a._iO.onfailure(a,b,c,d)};this._onbeforefinish=function(){if(!a.didBeforeFinish)a.didBeforeFinish=!0,a._iO.onbeforefinish&&a._iO.onbeforefinish.apply(a)};this._onjustbeforefinish=function(){if(!a.didJustBeforeFinish)a.didJustBeforeFinish=!0,a._iO.onjustbeforefinish&&a._iO.onjustbeforefinish.apply(a)};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a.resetOnPosition(0);a._iO.onbeforefinishcomplete&&a._iO.onbeforefinishcomplete.apply(a);a.didBeforeFinish=
-!1;a.didJustBeforeFinish=!1;if(a.instanceCount){a.instanceCount--;if(!a.instanceCount)a.playState=0,a.paused=!1,a.instanceCount=0,a.instanceOptions={},a._iO={},f();(!a.instanceCount||a._iO.multiShotEvents)&&b&&b.apply(a)}};this._onbufferchange=function(b){if(a.playState===0)return!1;if(b&&a.isBuffering||!b&&!a.isBuffering)return!1;a.isBuffering=b===1;a._iO.onbufferchange&&a._iO.onbufferchange.apply(a);return!0};this._ondataerror=function(){a.playState>0&&a._iO.ondataerror&&a._iO.ondataerror.apply(a)}};
-ea=function(){return g.body?g.body:g._docElement?g.documentElement:g.getElementsByTagName("div")[0]};y=function(b){return g.getElementById(b)};o=function(b,a){var e={},f,d;for(f in b)b.hasOwnProperty(f)&&(e[f]=b[f]);f=typeof a==="undefined"?c.defaultOptions:a;for(d in f)f.hasOwnProperty(d)&&typeof e[d]==="undefined"&&(e[d]=f[d]);return e};l=function(){function b(a){var a=Da.call(a),b=a.length;c?(a[1]="on"+a[1],b>3&&a.pop()):b===3&&a.push(!1);return a}function a(a,b){var g=a.shift(),h=[f[b]];if(c)g[h](a[0],
-a[1]);else g[h].apply(g,a)}var c=h.attachEvent,f={add:c?"attachEvent":"addEventListener",remove:c?"detachEvent":"removeEventListener"};return{add:function(){a(b(arguments),"add")},remove:function(){a(b(arguments),"remove")}}}();V=function(b){return!b.serverURL&&(b.type?J({type:b.type}):J(b.url)||p)};J=function(b){if(!c.useHTML5Audio||!c.hasHTML5)return!1;var a,e=c.audioFormats;if(!s){s=[];for(a in e)e.hasOwnProperty(a)&&(s.push(a),e[a].related&&(s=s.concat(e[a].related)));s=RegExp("\\.("+s.join("|")+
-")","i")}a=typeof b.type!=="undefined"?b.type:null;b=typeof b==="string"?b.toLowerCase().match(s):null;if(!b||!b.length)if(a)b=a.indexOf(";"),b=(b!==-1?a.substr(0,b):a).substr(6);else return!1;else b=b[0].substr(1);if(b&&typeof c.html5[b]!=="undefined")return c.html5[b];else{if(!a)if(b&&c.html5[b])return c.html5[b];else a="audio/"+b;a=c.html5.canPlayType(a);return c.html5[b]=a}};za=function(){function b(b){var d,e,f=!1;if(!a||typeof a.canPlayType!=="function")return!1;if(b instanceof Array){d=0;for(e=
-b.length;d<e&&!f;d++)if(c.html5[b[d]]||a.canPlayType(b[d]).match(c.html5Test))f=!0,c.html5[b[d]]=!0;return f}else return(b=a&&typeof a.canPlayType==="function"?a.canPlayType(b):!1)&&(b.match(c.html5Test)?!0:!1)}if(!c.useHTML5Audio||typeof Audio==="undefined")return!1;var a=typeof Audio!=="undefined"?Ga?new Audio(null):new Audio:null,e,f={},d,g;C();d=c.audioFormats;for(e in d)if(d.hasOwnProperty(e)&&(f[e]=b(d[e].type),d[e]&&d[e].related))for(g=d[e].related.length;g--;)c.html5[d[e].related[g]]=f[e];
-f.canPlayType=a?b:null;c.html5=o(c.html5,f);return!0};w=function(){};S=function(b){if(k===8&&b.loops>1&&b.stream)b.stream=!1;return b};T=function(b){if(b&&!b.usePolicyFile&&(b.onid3||b.usePeakData||b.useWaveformData||b.useEQData))b.usePolicyFile=!0;return b};ia=function(b){typeof console!=="undefined"&&typeof console.warn!=="undefined"&&console.warn(b)};$=function(){return!1};ua=function(b){for(var a in b)b.hasOwnProperty(a)&&typeof b[a]==="function"&&(b[a]=$)};R=function(b){typeof b==="undefined"&&
-(b=!1);(t||b)&&c.disable(b)};va=function(b){var a=null;if(b)if(b.match(/\.swf(\?.*)?$/i)){if(a=b.substr(b.toLowerCase().lastIndexOf(".swf?")+4))return b}else b.lastIndexOf("/")!==b.length-1&&(b+="/");return(b&&b.lastIndexOf("/")!==-1?b.substr(0,b.lastIndexOf("/")+1):"./")+c.movieURL};ca=function(){if(k!==8&&k!==9)c.flashVersion=8;var b=c.debugMode||c.debugFlash?"_debug.swf":".swf";if(c.useHTML5Audio&&!p&&c.audioFormats.mp4.required&&c.flashVersion<9)c.flashVersion=9;k=c.flashVersion;c.version=c.versionNumber+
-(p?" (HTML5-only mode)":k===9?" (AS3/Flash 9)":" (AS2/Flash 8)");if(k>8)c.defaultOptions=o(c.defaultOptions,c.flash9Options),c.features.buffering=!0;k>8&&c.useMovieStar?(c.defaultOptions=o(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+c.netStreamTypes.join("|")+")(\\?.*)?$","i"),c.mimePattern=c.netStreamMimeTypes,c.features.movieStar=!0):(c.useMovieStar=!1,c.features.movieStar=!1);c.filePattern=c.filePatterns[k!==8?"flash9":"flash8"];c.movieURL=(k===8?"soundmanager2.swf":
-"soundmanager2_flash9.swf").replace(".swf",b);c.features.peakData=c.features.waveformData=c.features.eqData=k>8};ta=function(b,a){if(!c.o||!c.allowPolling)return!1;c.o._setPolling(b,a)};Q=function(b,a){var e=a?a:c.url,f=c.altURL?c.altURL:e,d;d=ea();var h,k,i=B(),j,l=null,l=(l=g.getElementsByTagName("html")[0])&&l.dir&&l.dir.match(/rtl/i),b=typeof b==="undefined"?c.id:b;if(E&&F)return!1;if(p)return ca(),c.oMC=y(c.movieID),O(),F=E=!0,!1;E=!0;ca();c.url=va(c._overHTTP?e:f);a=c.url;c.wmode=!c.wmode&&
-c.useHighPerformance&&!c.useMovieStar?"transparent":c.wmode;if(c.wmode!==null&&(n.match(/msie 8/i)||!q&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))c.specialWmodeCase=!0,c.wmode=null;d={name:b,id:b,src:a,width:"100%",height:"100%",quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:c._http+"//www.macromedia.com/go/getflashplayer",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};if(c.debugFlash)d.FlashVars="debug=1";c.wmode||
-delete d.wmode;if(q)e=g.createElement("div"),k='<object id="'+b+'" data="'+a+'" type="'+d.type+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+c._http+'//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+d.width+'" height="'+d.height+'"><param name="movie" value="'+a+'" /><param name="AllowScriptAccess" value="'+c.allowScriptAccess+'" /><param name="quality" value="'+d.quality+'" />'+(c.wmode?'<param name="wmode" value="'+c.wmode+'" /> ':"")+
-'<param name="bgcolor" value="'+c.bgColor+'" />'+(c.debugFlash?'<param name="FlashVars" value="'+d.FlashVars+'" />':"")+"</object>";else for(h in e=g.createElement("embed"),d)d.hasOwnProperty(h)&&e.setAttribute(h,d[h]);pa();i=B();if(d=ea())if(c.oMC=y(c.movieID)?y(c.movieID):g.createElement("div"),c.oMC.id){j=c.oMC.className;c.oMC.className=(j?j+" ":c.swfCSS.swfDefault)+(i?" "+i:"");c.oMC.appendChild(e);if(q)h=c.oMC.appendChild(g.createElement("div")),h.className=c.swfCSS.swfBox,h.innerHTML=k;F=!0}else{c.oMC.id=
-c.movieID;c.oMC.className=c.swfCSS.swfDefault+" "+i;h=i=null;if(!c.useFlashBlock)if(c.useHighPerformance)i={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"};else if(i={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},l)i.left=Math.abs(parseInt(i.left,10))+"px";if(Fa)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(j in i)i.hasOwnProperty(j)&&(c.oMC.style[j]=i[j]);try{q||c.oMC.appendChild(e);d.appendChild(c.oMC);if(q)h=c.oMC.appendChild(g.createElement("div")),
-h.className=c.swfCSS.swfBox,h.innerHTML=k;F=!0}catch(m){throw Error(w("appXHTML"));}}return!0};j=this.getSoundById;H=function(){if(p)return Q(),!1;if(c.o)return!1;c.o=c.getMovie(c.id);if(!c.o)I?(q?c.oMC.innerHTML=ga:c.oMC.appendChild(I),I=null,E=!0):Q(c.id,c.url),c.o=c.getMovie(c.id);c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return!0};ba=function(b){if(b)c.url=b;H()};P=function(){setTimeout(ra,500)};ra=function(){if(U)return!1;U=!0;l.remove(h,"load",P);if(D&&!na)return!1;var b;
-m||(b=c.getMoviePercent());setTimeout(function(){b=c.getMoviePercent();!m&&Ca&&(b===null?c.useFlashBlock||c.flashLoadTimeout===0?c.useFlashBlock&&ha():R(!0):c.flashLoadTimeout!==0&&R(!0))},c.flashLoadTimeout)};ba=function(b){if(b)c.url=b;H()};B=function(){var b=[];c.debugMode&&b.push(c.swfCSS.sm2Debug);c.debugFlash&&b.push(c.swfCSS.flashDebug);c.useHighPerformance&&b.push(c.swfCSS.highPerf);return b.join(" ")};ha=function(){w("fbHandler");var b=c.getMoviePercent(),a=c.swfCSS;if(c.ok()){if(c.oMC)c.oMC.className=
-[B(),a.swfDefault,a.swfLoaded+(c.didFlashBlock?" "+a.swfUnblocked:"")].join(" ")}else{if(x)c.oMC.className=B()+" "+a.swfDefault+" "+(b===null?a.swfTimedout:a.swfError);c.didFlashBlock=!0;u({type:"ontimeout",ignoreInit:!0});c.onerror instanceof Function&&c.onerror.apply(h)}};v=function(){function b(){l.remove(h,"focus",v);l.remove(h,"load",v)}if(na||!D)return b(),!0;na=Ca=!0;L&&D&&l.remove(h,"mousemove",v);U=!1;b();return!0};G=function(b){if(m)return!1;if(p)return m=!0,u(),z(),!0;c.useFlashBlock&&
-c.flashLoadTimeout&&!c.getMoviePercent()||(m=!0);if(t||b){if(c.useFlashBlock)c.oMC.className=B()+" "+(c.getMoviePercent()===null?c.swfCSS.swfTimedout:c.swfCSS.swfError);u({type:"ontimeout"});c.onerror instanceof Function&&c.onerror.apply(h);return!1}l.add(h,"unload",$);if(c.waitForWindowLoad&&!qa)return l.add(h,"load",z),!1;else z();return!0};aa=function(b,a,c){typeof r[b]==="undefined"&&(r[b]=[]);r[b].push({method:a,scope:c||null,fired:!1})};u=function(b){b||(b={type:"onready"});if(!m&&b&&!b.ignoreInit)return!1;
-var a={success:b&&b.ignoreInit?c.ok():!t},e=b&&b.type?r[b.type]||[]:[],b=[],f,d=x&&c.useFlashBlock&&!c.ok();for(f=0;f<e.length;f++)e[f].fired!==!0&&b.push(e[f]);if(b.length){f=0;for(e=b.length;f<e;f++)if(b[f].scope?b[f].method.apply(b[f].scope,[a]):b[f].method(a),!d)b[f].fired=!0}return!0};z=function(){h.setTimeout(function(){c.useFlashBlock&&ha();u();c.onload instanceof Function&&c.onload.apply(h);c.waitForWindowLoad&&l.add(h,"load",z)},1)};C=function(){if(la!==void 0)return la;var b=!1,a=navigator,
-c=a.plugins,f,d=h.ActiveXObject;if(c&&c.length)(a=a.mimeTypes)&&a["application/x-shockwave-flash"]&&a["application/x-shockwave-flash"].enabledPlugin&&a["application/x-shockwave-flash"].enabledPlugin.description&&(b=!0);else if(typeof d!=="undefined"){try{f=new d("ShockwaveFlash.ShockwaveFlash")}catch(g){}b=!!f}return la=b};ya=function(){var b,a;if(n.match(/iphone os (1|2|3_0|3_1)/i)){c.hasHTML5=!1;p=!0;if(c.oMC)c.oMC.style.display="none";return!1}if(c.useHTML5Audio){if(!c.html5||!c.html5.canPlayType)return c.hasHTML5=
-!1,!0;else c.hasHTML5=!0;if(ma&&C())return!0}else return!0;for(a in c.audioFormats)c.audioFormats.hasOwnProperty(a)&&c.audioFormats[a].required&&!c.html5.canPlayType(c.audioFormats[a].type)&&(b=!0);c.ignoreFlash&&(b=!1);p=c.useHTML5Audio&&c.hasHTML5&&!b&&!c.requireFlash;return C()&&b};O=function(){var b,a=[];if(m)return!1;if(c.hasHTML5)for(b in c.audioFormats)c.audioFormats.hasOwnProperty(b)&&a.push(b+": "+c.html5[b]);if(p){if(!m)l.remove(h,"load",c.beginDelayedInit),c.enabled=!0,G();return!0}H();
-try{c.o._externalInterfaceTest(!1),c.allowPolling&&ta(!0,c.flashPollingInterval?c.flashPollingInterval:c.useFastPolling?10:50),c.debugMode||c.o._disableDebug(),c.enabled=!0}catch(e){return R(!0),G(),!1}G();l.remove(h,"load",c.beginDelayedInit);return!0};sa=function(){if(ja)return!1;Q();H();return ja=!0};A=function(){if(da)return!1;da=!0;pa();if(!c.useHTML5Audio&&!C())c.useHTML5Audio=!0;za();c.html5.usingFlash=ya();x=c.html5.usingFlash;da=!0;g.removeEventListener&&g.removeEventListener("DOMContentLoaded",
-A,!1);ba();return!0};wa=function(b){if(!b._hasTimer)b._hasTimer=!0};xa=function(b){if(b._hasTimer)b._hasTimer=!1};fa=function(){if(c.onerror instanceof Function)c.onerror();c.disable()};Aa=function(){if(!ma||!C())return!1;var b=c.audioFormats,a,e;for(e in b)if(b.hasOwnProperty(e)&&(e==="mp3"||e==="mp4"))if(c.html5[e]=!1,b[e]&&b[e].related)for(a=b[e].related.length;a--;)c.html5[b[e].related[a]]=!1};this._setSandboxType=function(){};this._externalInterfaceOK=function(){if(c.swfLoaded)return!1;(new Date).getTime();
-c.swfLoaded=!0;D=!1;ma&&Aa();q?setTimeout(O,100):O()};ka=function(){g.readyState==="complete"&&(A(),g.detachEvent("onreadystatechange",ka));return!0};if(!c.hasHTML5||x)l.add(h,"focus",v),l.add(h,"load",v),l.add(h,"load",P),L&&D&&l.add(h,"mousemove",v);g.addEventListener?g.addEventListener("DOMContentLoaded",A,!1):g.attachEvent?g.attachEvent("onreadystatechange",ka):fa();g.readyState==="complete"&&setTimeout(A,100)}var X=null;if(typeof SM2_DEFER==="undefined"||!SM2_DEFER)X=new M;Y.SoundManager=M;Y.soundManager=
-X})(window);
\ No newline at end of file
+/** @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.20111030\r
+ */\r
+(function($){function N(N,Z){function j(c){return function(a){return!this._t||!this._t._a?null:c.call(this,a)}}this.flashVersion=8;this.debugFlash=this.debugMode=false;this.useConsole=true;this.waitForWindowLoad=this.consoleOnly=false;this.bgColor="#ffffff";this.useHighPerformance=false;this.flashPollingInterval=null;this.flashLoadTimeout=1E3;this.wmode=null;this.allowScriptAccess="always";this.useFlashBlock=false;this.useHTML5Audio=true;this.html5Test=/^(probably|maybe)$/i;this.preferFlash=true;
+this.noSWFCache=false;this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:true},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:false},ogg:{type:["audio/ogg; codecs=vorbis"],required:false},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:false}};this.defaultOptions={autoLoad:false,stream:true,autoPlay:false,
+loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfailure:null,onfinish:null,multiShot:true,multiShotEvents:false,position:null,pan:0,type:null,usePolicyFile:false,volume:100};this.flash9Options={isMovieStar:null,usePeakData:false,useWaveformData:false,useEQData:false,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.movieID="sm2-container";this.id=Z||"sm2movie";
+this.swfCSS={swfBox:"sm2-object-box",swfDefault:"movieContainer",swfError:"swf_error",swfTimedout:"swf_timedout",swfLoaded:"swf_loaded",swfUnblocked:"swf_unblocked",sm2Debug:"sm2_debug",highPerf:"high_performance",flashDebug:"flash_debug"};this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20111030";this.movieURL=this.version=null;this.url=N||null;this.altURL=null;this.enabled=this.swfLoaded=false;this.oMC=this.o=null;this.sounds={};this.soundIDs=[];
+this.didFlashBlock=this.specialWmodeCase=this.muted=false;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:false,peakData:false,waveformData:false,eqData:false,movieStar:false};this.sandbox={};var F;try{F=typeof Audio!=="undefined"&&typeof(new Audio).canPlayType!=="undefined"}catch(Oa){F=false}this.hasHTML5=F;this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=false;var ra,c=this,O,o=navigator.userAgent,i=$,aa=
+i.location.href.toString(),h=document,ba,P,g,s=[],G=false,H=false,m=false,t=false,sa=false,I,n,ca,z,A,Q,ta,da,x,R,B,ea,fa,S,C,ua,ga,va,T,wa,J=null,ha=null,y,ia,D,U,V,ja,l,W=false,ka=false,xa,ya,q=null,za,X,K,u,la,ma,Aa,k,Ia=Array.prototype.slice,L=false,p,Y,Ba,r,Ca,na=o.match(/(ipad|iphone|ipod)/i),Ja=o.match(/firefox/i),Ka=o.match(/droid/i),v=o.match(/msie/i),La=o.match(/webkit/i),M=o.match(/safari/i)&&!o.match(/chrome/i),Ma=o.match(/opera/i);F=o.match(/(mobile|pre\/|xoom)/i)||na;var oa=!aa.match(/usehtml5audio/i)&&
+!aa.match(/sm2\-ignorebadua/i)&&M&&o.match(/OS X 10_6_([3-7])/i),pa=typeof h.hasFocus!=="undefined"?h.hasFocus():null,E=M&&typeof h.hasFocus==="undefined",Da=!E,Ea=/(mp3|mp4|mpa)/i,qa=h.location?h.location.protocol.match(/http/i):null,Fa=!qa?"http://":"",Ga=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i,Ha="mpeg4,aac,flv,mov,mp4,m4v,f4v,m4a,mp4v,3gp,3g2".split(","),Na=RegExp("\\.("+Ha.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;
+this.useAltURL=!qa;this._global_a=null;if(F&&(c.useHTML5Audio=true,c.preferFlash=false,na))L=c.ignoreFlash=true;this.supported=this.ok=function(){return q?m&&!t:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return O(c)||h[c]||i[c]};this.createSound=function(b){function a(){e=U(e);c.sounds[d.id]=new ra(d);c.soundIDs.push(d.id);return c.sounds[d.id]}var e=null,f=null,d=null;if(!m||!c.ok())return ja("soundManager.createSound(): "+y(!m?"notReady":"notOK")),false;arguments.length===2&&(b={id:arguments[0],
+url:arguments[1]});d=e=n(b);if(l(d.id,true))return c.sounds[d.id];if(X(d))f=a(),f._setup_html5(d);else{if(g>8){if(d.isMovieStar===null)d.isMovieStar=d.serverURL||(d.type?d.type.match(Ga):false)||d.url.match(Na);if(d.isMovieStar&&d.usePeakData)d.usePeakData=false}d=V(d,"soundManager.createSound(): ");f=a();if(g===8)c.o._createSound(d.id,d.loops||1,d.usePolicyFile);else if(c.o._createSound(d.id,d.url,d.usePeakData,d.useWaveformData,d.useEQData,d.isMovieStar,d.isMovieStar?d.bufferTime:false,d.loops||
+1,d.serverURL,d.duration||null,d.autoPlay,true,d.autoLoad,d.usePolicyFile),!d.serverURL)f.connected=true,d.onconnect&&d.onconnect.apply(f);!d.serverURL&&(d.autoLoad||d.autoPlay)&&f.load(d)}!d.serverURL&&d.autoPlay&&f.play();return f};this.destroySound=function(b,a){if(!l(b))return false;var e=c.sounds[b],f;e._iO={};e.stop();e.unload();for(f=0;f<c.soundIDs.length;f++)if(c.soundIDs[f]===b){c.soundIDs.splice(f,1);break}a||e.destruct(true);delete c.sounds[b];return true};this.load=function(b,a){return!l(b)?
+false:c.sounds[b].load(a)};this.unload=function(b){return!l(b)?false:c.sounds[b].unload()};this.onposition=function(b,a,e,f){return!l(b)?false:c.sounds[b].onposition(a,e,f)};this.start=this.play=function(b,a){if(!m||!c.ok())return ja("soundManager.play(): "+y(!m?"notReady":"notOK")),false;return!l(b)?(a instanceof Object||(a={url:a}),a&&a.url?(a.id=b,c.createSound(a).play()):false):c.sounds[b].play(a)};this.setPosition=function(b,a){return!l(b)?false:c.sounds[b].setPosition(a)};this.stop=function(b){return!l(b)?
+false:c.sounds[b].stop()};this.stopAll=function(){for(var b in c.sounds)c.sounds.hasOwnProperty(b)&&c.sounds[b].stop()};this.pause=function(b){return!l(b)?false:c.sounds[b].pause()};this.pauseAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].pause()};this.resume=function(b){return!l(b)?false:c.sounds[b].resume()};this.resumeAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].resume()};this.togglePause=function(b){return!l(b)?false:c.sounds[b].togglePause()};
+this.setPan=function(b,a){return!l(b)?false:c.sounds[b].setPan(a)};this.setVolume=function(b,a){return!l(b)?false:c.sounds[b].setVolume(a)};this.mute=function(b){var a=0;typeof b!=="string"&&(b=null);if(b)return!l(b)?false:c.sounds[b].mute();else{for(a=c.soundIDs.length;a--;)c.sounds[c.soundIDs[a]].mute();c.muted=true}return true};this.muteAll=function(){c.mute()};this.unmute=function(b){typeof b!=="string"&&(b=null);if(b)return!l(b)?false:c.sounds[b].unmute();else{for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].unmute();
+c.muted=false}return true};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(b){return!l(b)?false:c.sounds[b].toggleMute()};this.getMemoryUse=function(){var b=0;c.o&&g!==8&&(b=parseInt(c.o._getMemoryUse(),10));return b};this.disable=function(b){var a;typeof b==="undefined"&&(b=false);if(t)return false;t=true;for(a=c.soundIDs.length;a--;)va(c.sounds[c.soundIDs[a]]);I(b);k.remove(i,"load",A);return true};this.canPlayMIME=function(b){var a;c.hasHTML5&&(a=K({type:b}));return!q||a?a:b?!!(g>
+8&&b.match(Ga)||b.match(c.mimePattern)):null};this.canPlayURL=function(b){var a;c.hasHTML5&&(a=K({url:b}));return!q||a?a:b?!!b.match(c.filePattern):null};this.canPlayLink=function(b){return typeof b.type!=="undefined"&&b.type&&c.canPlayMIME(b.type)?true:c.canPlayURL(b.href)};this.getSoundById=function(b){if(!b)throw Error("soundManager.getSoundById(): sID is null/undefined");return c.sounds[b]};this.onready=function(c,a){if(c&&c instanceof Function)return a||(a=i),ca("onready",c,a),z(),true;else throw y("needFunction",
+"onready");};this.ontimeout=function(c,a){if(c&&c instanceof Function)return a||(a=i),ca("ontimeout",c,a),z({type:"ontimeout"}),true;else throw y("needFunction","ontimeout");};this._wD=this._writeDebug=function(){return true};this._debug=function(){};this.reboot=function(){var b,a;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].destruct();try{if(v)ha=c.o.innerHTML;J=c.o.parentNode.removeChild(c.o)}catch(e){}ha=J=q=null;c.enabled=ea=m=W=ka=G=H=t=c.swfLoaded=false;c.soundIDs=c.sounds=[];c.o=null;
+for(b in s)if(s.hasOwnProperty(b))for(a=s[b].length;a--;)s[b][a].fired=false;i.setTimeout(c.beginDelayedInit,20)};this.getMoviePercent=function(){return c.o&&typeof c.o.PercentLoaded!=="undefined"?c.o.PercentLoaded():null};this.beginDelayedInit=function(){sa=true;B();setTimeout(function(){if(ka)return false;S();R();return ka=true},20);Q()};this.destruct=function(){c.disable(true)};ra=function(b){var a=this,e,f,d;this.sID=b.id;this.url=b.url;this._iO=this.instanceOptions=this.options=n(b);this.pan=
+this.options.pan;this.volume=this.options.volume;this._lastURL=null;this.isHTML5=false;this._a=null;this.id3={};this._debug=function(){};this.load=function(b){var d=null;if(typeof b!=="undefined")a._iO=n(b,a.options),a.instanceOptions=a._iO;else if(b=a.options,a._iO=b,a.instanceOptions=a._iO,a._lastURL&&a._lastURL!==a.url)a._iO.url=a.url,a.url=null;if(!a._iO.url)a._iO.url=a.url;if(a._iO.url===a.url&&a.readyState!==0&&a.readyState!==2)return a;a._lastURL=a.url;a.loaded=false;a.readyState=1;a.playState=
+0;if(X(a._iO)){if(d=a._setup_html5(a._iO),!d._called_load)a._html5_canplay=false,d.load(),d._called_load=true,a._iO.autoPlay&&a.play()}else try{a.isHTML5=false,a._iO=V(U(a._iO)),g===8?c.o._load(a.sID,a._iO.url,a._iO.stream,a._iO.autoPlay,a._iO.whileloading?1:0,a._iO.loops||1,a._iO.usePolicyFile):c.o._load(a.sID,a._iO.url,!!a._iO.stream,!!a._iO.autoPlay,a._iO.loops||1,!!a._iO.autoLoad,a._iO.usePolicyFile)}catch(e){C({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:true})}return a};this.unload=function(){a.readyState!==
+0&&(a.isHTML5?(f(),a._a&&(a._a.pause(),la(a._a))):g===8?c.o._unload(a.sID,"about:blank"):c.o._unload(a.sID),e());return a};this.destruct=function(b){if(a.isHTML5){if(f(),a._a)a._a.pause(),la(a._a),L||a._remove_html5_events(),a._a._t=null,a._a=null}else a._iO.onfailure=null,c.o._destroySound(a.sID);b||c.destroySound(a.sID,true)};this.start=this.play=function(b,w){var e,w=w===void 0?true:w;b||(b={});a._iO=n(b,a._iO);a._iO=n(a._iO,a.options);a.instanceOptions=a._iO;if(a._iO.serverURL&&!a.connected)return a.getAutoPlay()||
+a.setAutoPlay(true),a;X(a._iO)&&(a._setup_html5(a._iO),d());if(a.playState===1&&!a.paused&&(e=a._iO.multiShot,!e))return a;if(!a.loaded)if(a.readyState===0){if(!a.isHTML5)a._iO.autoPlay=true;a.load(a._iO)}else if(a.readyState===2)return a;if(!a.isHTML5&&g===9&&a.position>0&&a.position===a.duration)a._iO.position=0;if(a.paused&&a.position&&a.position>0)a.resume();else{a.playState=1;a.paused=false;(!a.instanceCount||a._iO.multiShotEvents||!a.isHTML5&&g>8&&!a.getAutoPlay())&&a.instanceCount++;a.position=
+typeof a._iO.position!=="undefined"&&!isNaN(a._iO.position)?a._iO.position:0;if(!a.isHTML5)a._iO=V(U(a._iO));if(a._iO.onplay&&w)a._iO.onplay.apply(a),a._onplay_called=true;a.setVolume(a._iO.volume,true);a.setPan(a._iO.pan,true);a.isHTML5?(d(),e=a._setup_html5(),a.setPosition(a._iO.position),e.play()):c.o._start(a.sID,a._iO.loops||1,g===9?a._iO.position:a._iO.position/1E3)}return a};this.stop=function(b){if(a.playState===1){a._onbufferchange(0);a.resetOnPosition(0);a.paused=false;if(!a.isHTML5)a.playState=
+0;a._iO.onstop&&a._iO.onstop.apply(a);if(a.isHTML5){if(a._a)a.setPosition(0),a._a.pause(),a.playState=0,a._onTimer(),f()}else c.o._stop(a.sID,b),a._iO.serverURL&&a.unload();a.instanceCount=0;a._iO={}}return a};this.setAutoPlay=function(b){a._iO.autoPlay=b;a.isHTML5||(c.o._setAutoPlay(a.sID,b),b&&!a.instanceCount&&a.readyState===1&&a.instanceCount++)};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition=function(b){b===void 0&&(b=0);var d=a.isHTML5?Math.max(b,0):Math.min(a.duration||
+a._iO.duration,Math.max(b,0));a.position=d;b=a.position/1E3;a.resetOnPosition(a.position);a._iO.position=d;if(a.isHTML5){if(a._a&&a._html5_canplay&&a._a.currentTime!==b)try{a._a.currentTime=b,(a.playState===0||a.paused)&&a._a.pause()}catch(e){}}else b=g===9?a.position:b,a.readyState&&a.readyState!==2&&c.o._setPosition(a.sID,b,a.paused||!a.playState);a.isHTML5&&a.paused&&a._onTimer(true);return a};this.pause=function(b){if(a.paused||a.playState===0&&a.readyState!==1)return a;a.paused=true;a.isHTML5?
+(a._setup_html5().pause(),f()):(b||b===void 0)&&c.o._pause(a.sID);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){if(!a.paused)return a;a.paused=false;a.playState=1;a.isHTML5?(a._setup_html5().play(),d()):(a._iO.isMovieStar&&a.setPosition(a.position),c.o._pause(a.sID));!a._onplay_called&&a._iO.onplay?(a._iO.onplay.apply(a),a._onplay_called=true):a._iO.onresume&&a._iO.onresume.apply(a);return a};this.togglePause=function(){if(a.playState===0)return a.play({position:g===9&&!a.isHTML5?
+a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,d){typeof b==="undefined"&&(b=0);typeof d==="undefined"&&(d=false);a.isHTML5||c.o._setPan(a.sID,b);a._iO.pan=b;if(!d)a.pan=b,a.options.pan=b;return a};this.setVolume=function(b,d){typeof b==="undefined"&&(b=100);typeof d==="undefined"&&(d=false);if(a.isHTML5){if(a._a)a._a.volume=Math.max(0,Math.min(1,b/100))}else c.o._setVolume(a.sID,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;if(!d)a.volume=b,a.options.volume=
+b;return a};this.mute=function(){a.muted=true;if(a.isHTML5){if(a._a)a._a.muted=true}else c.o._setVolume(a.sID,0);return a};this.unmute=function(){a.muted=false;var b=typeof a._iO.volume!=="undefined";if(a.isHTML5){if(a._a)a._a.muted=false}else c.o._setVolume(a.sID,b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=function(b,c,d){a._onPositionItems.push({position:b,method:c,scope:typeof d!=="undefined"?d:a,fired:false});return a};
+this.processOnPosition=function(){var b,d;b=a._onPositionItems.length;if(!b||!a.playState||a._onPositionFired>=b)return false;for(;b--;)if(d=a._onPositionItems[b],!d.fired&&a.position>=d.position)d.fired=true,c._onPositionFired++,d.method.apply(d.scope,[d.position]);return true};this.resetOnPosition=function(b){var d,e;d=a._onPositionItems.length;if(!d)return false;for(;d--;)if(e=a._onPositionItems[d],e.fired&&b<=e.position)e.fired=false,c._onPositionFired--;return true};d=function(){a.isHTML5&&xa(a)};
+f=function(){a.isHTML5&&ya(a)};e=function(){a._onPositionItems=[];a._onPositionFired=0;a._hasTimer=null;a._onplay_called=false;a._a=null;a._html5_canplay=false;a.bytesLoaded=null;a.bytesTotal=null;a.position=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.failures=0;a.loaded=false;a.playState=0;a.paused=false;a.readyState=0;a.muted=false;a.isBuffering=false;a.instanceOptions={};a.instanceCount=0;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.eqData=
+[];a.eqData.left=[];a.eqData.right=[]};e();this._onTimer=function(b){var c={};if(a._hasTimer||b)return a._a&&(b||(a.playState>0||a.readyState===1)&&!a.paused)?(a.duration=a._get_html5_duration(),a.durationEstimate=a.duration,b=a._a.currentTime?a._a.currentTime*1E3:0,a._whileplaying(b,c,c,c,c),true):false};this._get_html5_duration=function(){var b=a._a?a._a.duration*1E3:a._iO?a._iO.duration:void 0;return b&&!isNaN(b)&&b!==Infinity?b:a._iO?a._iO.duration:null};this._setup_html5=function(b){var b=n(a._iO,
+b),d=L?c._global_a:a._a;decodeURI(b.url);var f=d&&d._t?d._t.instanceOptions:null;if(d){if(d._t&&f.url===b.url&&(!a._lastURL||a._lastURL===f.url))return d;L&&d._t&&d._t.playState&&b.url!==f.url&&d._t.stop();e();d.src=b.url;a.url=b.url;a._lastURL=b.url;d._called_load=false}else{d=new Audio(b.url);d._called_load=false;if(Ka)d._called_load=true;if(L)c._global_a=d}a.isHTML5=true;a._a=d;d._t=a;a._add_html5_events();d.loop=b.loops>1?"loop":"";b.autoLoad||b.autoPlay?(d.autobuffer="auto",d.preload="auto",
+a.load(),d._called_load=true):(d.autobuffer=false,d.preload="none");d.loop=b.loops>1?"loop":"";return d};this._add_html5_events=function(){if(a._a._added_events)return false;var b;a._a._added_events=true;for(b in r)r.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,r[b],false);return true};this._remove_html5_events=function(){var b;a._a._added_events=false;for(b in r)r.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,r[b],false)};this._onload=function(b){b=!!b;a.loaded=b;a.readyState=b?3:2;a._onbufferchange(0);
+a._iO.onload&&a._iO.onload.apply(a,[b]);return true};this._onbufferchange=function(b){if(a.playState===0)return false;if(b&&a.isBuffering||!b&&!a.isBuffering)return false;a.isBuffering=b===1;a._iO.onbufferchange&&a._iO.onbufferchange.apply(a);return true};this._onsuspend=function(){a._iO.onsuspend&&a._iO.onsuspend.apply(a);return true};this._onfailure=function(b,c,d){a.failures++;if(a._iO.onfailure&&a.failures===1)a._iO.onfailure(a,b,c,d)};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);
+a.resetOnPosition(0);if(a.instanceCount){a.instanceCount--;if(!a.instanceCount)a.playState=0,a.paused=false,a.instanceCount=0,a.instanceOptions={},a._iO={},f();(!a.instanceCount||a._iO.multiShotEvents)&&b&&b.apply(a)}};this._whileloading=function(b,c,d,e){a.bytesLoaded=b;a.bytesTotal=c;a.duration=Math.floor(d);a.bufferLength=e;if(a._iO.isMovieStar)a.durationEstimate=a.duration;else if(a.durationEstimate=a._iO.duration?a.duration>a._iO.duration?a.duration:a._iO.duration:parseInt(a.bytesTotal/a.bytesLoaded*
+a.duration,10),a.durationEstimate===void 0)a.durationEstimate=a.duration;a.readyState!==3&&a._iO.whileloading&&a._iO.whileloading.apply(a)};this._whileplaying=function(b,c,d,e,f){if(isNaN(b)||b===null)return false;a.position=b;a.processOnPosition();if(!a.isHTML5&&g>8){if(a._iO.usePeakData&&typeof c!=="undefined"&&c)a.peakData={left:c.leftPeak,right:c.rightPeak};if(a._iO.useWaveformData&&typeof d!=="undefined"&&d)a.waveformData={left:d.split(","),right:e.split(",")};if(a._iO.useEQData&&typeof f!==
+"undefined"&&f&&f.leftEQ&&(b=f.leftEQ.split(","),a.eqData=b,a.eqData.left=b,typeof f.rightEQ!=="undefined"&&f.rightEQ))a.eqData.right=f.rightEQ.split(",")}a.playState===1&&(!a.isHTML5&&g===8&&!a.position&&a.isBuffering&&a._onbufferchange(0),a._iO.whileplaying&&a._iO.whileplaying.apply(a));return true};this._onid3=function(b,c){var d=[],e,f;for(e=0,f=b.length;e<f;e++)d[b[e]]=c[e];a.id3=n(a.id3,d);a._iO.onid3&&a._iO.onid3.apply(a)};this._onconnect=function(b){b=b===1;if(a.connected=b)a.failures=0,l(a.sID)&&
+(a.getAutoPlay()?a.play(void 0,a.getAutoPlay()):a._iO.autoLoad&&a.load()),a._iO.onconnect&&a._iO.onconnect.apply(a,[b])};this._ondataerror=function(){a.playState>0&&a._iO.ondataerror&&a._iO.ondataerror.apply(a)}};fa=function(){return h.body||h._docElement||h.getElementsByTagName("div")[0]};O=function(b){return h.getElementById(b)};n=function(b,a){var e={},f,d;for(f in b)b.hasOwnProperty(f)&&(e[f]=b[f]);f=typeof a==="undefined"?c.defaultOptions:a;for(d in f)f.hasOwnProperty(d)&&typeof e[d]==="undefined"&&
+(e[d]=f[d]);return e};k=function(){function b(a){var a=Ia.call(a),b=a.length;c?(a[1]="on"+a[1],b>3&&a.pop()):b===3&&a.push(false);return a}function a(a,b){var w=a.shift(),h=[f[b]];if(c)w[h](a[0],a[1]);else w[h].apply(w,a)}var c=i.attachEvent,f={add:c?"attachEvent":"addEventListener",remove:c?"detachEvent":"removeEventListener"};return{add:function(){a(b(arguments),"add")},remove:function(){a(b(arguments),"remove")}}}();r={abort:j(function(){}),canplay:j(function(){if(this._t._html5_canplay)return true;
+this._t._html5_canplay=true;this._t._onbufferchange(0);var b=!isNaN(this._t.position)?this._t.position/1E3:null;if(this._t.position&&this.currentTime!==b)try{this.currentTime=b}catch(a){}}),load:j(function(){this._t.loaded||(this._t._onbufferchange(0),this._t._whileloading(this._t.bytesTotal,this._t.bytesTotal,this._t._get_html5_duration()),this._t._onload(true))}),emptied:j(function(){}),ended:j(function(){this._t._onfinish()}),error:j(function(){this._t._onload(false)}),loadeddata:j(function(){var b=
+this._t,a=b.bytesTotal||1;if(!b._loaded&&!M)b.duration=b._get_html5_duration(),b._whileloading(a,a,b._get_html5_duration()),b._onload(true)}),loadedmetadata:j(function(){}),loadstart:j(function(){this._t._onbufferchange(1)}),play:j(function(){this._t._onbufferchange(0)}),playing:j(function(){this._t._onbufferchange(0)}),progress:j(function(b){if(this._t.loaded)return false;var a,c=0,f=b.target.buffered;a=b.loaded||0;var d=b.total||1;if(f&&f.length){for(a=f.length;a--;)c=f.end(a)-f.start(a);a=c/b.target.duration}isNaN(a)||
+(this._t._onbufferchange(0),this._t._whileloading(a,d,this._t._get_html5_duration()),a&&d&&a===d&&r.load.call(this,b))}),ratechange:j(function(){}),suspend:j(function(b){r.progress.call(this,b);this._t._onsuspend()}),stalled:j(function(){}),timeupdate:j(function(){this._t._onTimer()}),waiting:j(function(){this._t._onbufferchange(1)})};X=function(b){return!b.serverURL&&(b.type?K({type:b.type}):K({url:b.url})||c.html5Only)};la=function(b){if(b)b.src=Ja?"":"about:blank"};K=function(b){function a(a){return c.preferFlash&&
+p&&!c.ignoreFlash&&typeof c.flash[a]!=="undefined"&&c.flash[a]}if(!c.useHTML5Audio||!c.hasHTML5)return false;var e=b.url||null,b=b.type||null,f=c.audioFormats,d;if(b&&c.html5[b]!=="undefined")return c.html5[b]&&!a(b);if(!u){u=[];for(d in f)f.hasOwnProperty(d)&&(u.push(d),f[d].related&&(u=u.concat(f[d].related)));u=RegExp("\\.("+u.join("|")+")(\\?.*)?$","i")}d=e?e.toLowerCase().match(u):null;if(!d||!d.length)if(b)e=b.indexOf(";"),d=(e!==-1?b.substr(0,e):b).substr(6);else return false;else d=d[1];return d&&
+typeof c.html5[d]!=="undefined"?c.html5[d]&&!a(d):(b="audio/"+d,e=c.html5.canPlayType({type:b}),(c.html5[d]=e)&&c.html5[b]&&!a(b))};Aa=function(){function b(b){var d,e,f=false;if(!a||typeof a.canPlayType!=="function")return false;if(b instanceof Array){for(d=0,e=b.length;d<e&&!f;d++)if(c.html5[b[d]]||a.canPlayType(b[d]).match(c.html5Test))f=true,c.html5[b[d]]=true,c.flash[b[d]]=!(!c.preferFlash||!p||!b[d].match(Ea));return f}else return b=a&&typeof a.canPlayType==="function"?a.canPlayType(b):false,
+!(!b||!b.match(c.html5Test))}if(!c.useHTML5Audio||typeof Audio==="undefined")return false;var a=typeof Audio!=="undefined"?Ma?new Audio(null):new Audio:null,e,f={},d,h;d=c.audioFormats;for(e in d)if(d.hasOwnProperty(e)&&(f[e]=b(d[e].type),f["audio/"+e]=f[e],c.flash[e]=c.preferFlash&&!c.ignoreFlash&&e.match(Ea)?true:false,d[e]&&d[e].related))for(h=d[e].related.length;h--;)f["audio/"+d[e].related[h]]=f[e],c.html5[d[e].related[h]]=f[e],c.flash[d[e].related[h]]=f[e];f.canPlayType=a?b:null;c.html5=n(c.html5,
+f);return true};y=function(){};U=function(b){if(g===8&&b.loops>1&&b.stream)b.stream=false;return b};V=function(b){if(b&&!b.usePolicyFile&&(b.onid3||b.usePeakData||b.useWaveformData||b.useEQData))b.usePolicyFile=true;return b};ja=function(){};ba=function(){return false};va=function(b){for(var a in b)b.hasOwnProperty(a)&&typeof b[a]==="function"&&(b[a]=ba)};T=function(b){typeof b==="undefined"&&(b=false);(t||b)&&c.disable(b)};wa=function(b){var a=null;if(b)if(b.match(/\.swf(\?.*)?$/i)){if(a=b.substr(b.toLowerCase().lastIndexOf(".swf?")+
+4))return b}else b.lastIndexOf("/")!==b.length-1&&(b+="/");b=(b&&b.lastIndexOf("/")!==-1?b.substr(0,b.lastIndexOf("/")+1):"./")+c.movieURL;c.noSWFCache&&(b+="?ts="+(new Date).getTime());return b};da=function(){g=parseInt(c.flashVersion,10);if(g!==8&&g!==9)c.flashVersion=g=8;var b=c.debugMode||c.debugFlash?"_debug.swf":".swf";if(c.useHTML5Audio&&!c.html5Only&&c.audioFormats.mp4.required&&g<9)c.flashVersion=g=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":g===9?" (AS3/Flash 9)":" (AS2/Flash 8)");
+g>8?(c.defaultOptions=n(c.defaultOptions,c.flash9Options),c.features.buffering=true,c.defaultOptions=n(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+Ha.join("|")+")(\\?.*)?$","i"),c.features.movieStar=true):c.features.movieStar=false;c.filePattern=c.filePatterns[g!==8?"flash9":"flash8"];c.movieURL=(g===8?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",b);c.features.peakData=c.features.waveformData=c.features.eqData=g>8};ua=function(b,a){if(!c.o)return false;
+c.o._setPolling(b,a)};ga=function(){if(c.debugURLParam.test(aa))c.debugMode=true};l=this.getSoundById;D=function(){var b=[];c.debugMode&&b.push(c.swfCSS.sm2Debug);c.debugFlash&&b.push(c.swfCSS.flashDebug);c.useHighPerformance&&b.push(c.swfCSS.highPerf);return b.join(" ")};ia=function(){y("fbHandler");var b=c.getMoviePercent(),a=c.swfCSS,e={type:"FLASHBLOCK"};if(c.html5Only)return false;if(c.ok()){if(c.oMC)c.oMC.className=[D(),a.swfDefault,a.swfLoaded+(c.didFlashBlock?" "+a.swfUnblocked:"")].join(" ")}else{if(q)c.oMC.className=
+D()+" "+a.swfDefault+" "+(b===null?a.swfTimedout:a.swfError);c.didFlashBlock=true;z({type:"ontimeout",ignoreInit:true,error:e});C(e)}};ca=function(b,a,c){typeof s[b]==="undefined"&&(s[b]=[]);s[b].push({method:a,scope:c||null,fired:false})};z=function(b){b||(b={type:"onready"});if(!m&&b&&!b.ignoreInit)return false;if(b.type==="ontimeout"&&c.ok())return false;var a={success:b&&b.ignoreInit?c.ok():!t},e=b&&b.type?s[b.type]||[]:[],f=[],d,a=[a],h=q&&c.useFlashBlock&&!c.ok();if(b.error)a[0].error=b.error;
+for(b=0,d=e.length;b<d;b++)e[b].fired!==true&&f.push(e[b]);if(f.length)for(b=0,d=f.length;b<d;b++)if(f[b].scope?f[b].method.apply(f[b].scope,a):f[b].method.apply(this,a),!h)f[b].fired=true;return true};A=function(){i.setTimeout(function(){c.useFlashBlock&&ia();z();c.onload instanceof Function&&c.onload.apply(i);c.waitForWindowLoad&&k.add(i,"load",A)},1)};Y=function(){if(p!==void 0)return p;var b=false,a=navigator,c=a.plugins,f,d=i.ActiveXObject;if(c&&c.length)(a=a.mimeTypes)&&a["application/x-shockwave-flash"]&&
+a["application/x-shockwave-flash"].enabledPlugin&&a["application/x-shockwave-flash"].enabledPlugin.description&&(b=true);else if(typeof d!=="undefined"){try{f=new d("ShockwaveFlash.ShockwaveFlash")}catch(h){}b=!!f}return p=b};za=function(){var b,a;if(na&&o.match(/os (1|2|3_0|3_1)/i)){c.hasHTML5=false;c.html5Only=true;if(c.oMC)c.oMC.style.display="none";return false}if(c.useHTML5Audio){if(!c.html5||!c.html5.canPlayType)return c.hasHTML5=false,true;else c.hasHTML5=true;if(oa&&Y())return true}else return true;
+for(a in c.audioFormats)if(c.audioFormats.hasOwnProperty(a)&&(c.audioFormats[a].required&&!c.html5.canPlayType(c.audioFormats[a].type)||c.flash[a]||c.flash[c.audioFormats[a].type]))b=true;c.ignoreFlash&&(b=false);c.html5Only=c.hasHTML5&&c.useHTML5Audio&&!b;return!c.html5Only};xa=function(b){if(!b._hasTimer)b._hasTimer=true};ya=function(b){if(b._hasTimer)b._hasTimer=false};C=function(b){b=typeof b!=="undefined"?b:{};c.onerror instanceof Function&&c.onerror.apply(i,[{type:typeof b.type!=="undefined"?
+b.type:null}]);typeof b.fatal!=="undefined"&&b.fatal&&c.disable()};Ba=function(){if(!oa||!Y())return false;var b=c.audioFormats,a,e;for(e in b)if(b.hasOwnProperty(e)&&(e==="mp3"||e==="mp4"))if(c.html5[e]=false,b[e]&&b[e].related)for(a=b[e].related.length;a--;)c.html5[b[e].related[a]]=false};this._setSandboxType=function(){};this._externalInterfaceOK=function(){if(c.swfLoaded)return false;(new Date).getTime();c.swfLoaded=true;E=false;oa&&Ba();v?setTimeout(P,100):P()};S=function(b,a){function e(a,b){return'<param name="'+
+a+'" value="'+b+'" />'}if(G&&H)return false;if(c.html5Only)return da(),c.oMC=O(c.movieID),P(),H=G=true,false;var f=a||c.url,d=c.altURL||f,g;g=fa();var i,l,j=D(),k,m=null,m=(m=h.getElementsByTagName("html")[0])&&m.dir&&m.dir.match(/rtl/i),b=typeof b==="undefined"?c.id:b;da();c.url=wa(qa?f:d);a=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(c.wmode!==null&&(o.match(/msie 8/i)||!v&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))c.specialWmodeCase=true,c.wmode=
+null;g={name:b,id:b,src:a,width:"auto",height:"auto",quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Fa+"www.macromedia.com/go/getflashplayer",title:"JS/Flash audio component (SoundManager 2)",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};if(c.debugFlash)g.FlashVars="debug=1";c.wmode||delete g.wmode;if(v)f=h.createElement("div"),l=['<object id="'+b+'" data="'+a+'" type="'+g.type+'" title="'+g.title+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+
+Fa+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+g.width+'" height="'+g.height+'">',e("movie",a),e("AllowScriptAccess",c.allowScriptAccess),e("quality",g.quality),c.wmode?e("wmode",c.wmode):"",e("bgcolor",c.bgColor),e("hasPriority","true"),c.debugFlash?e("FlashVars",g.FlashVars):"","</object>"].join("");else for(i in f=h.createElement("embed"),g)g.hasOwnProperty(i)&&f.setAttribute(i,g[i]);ga();j=D();if(g=fa())if(c.oMC=O(c.movieID)||h.createElement("div"),
+c.oMC.id){k=c.oMC.className;c.oMC.className=(k?k+" ":c.swfCSS.swfDefault)+(j?" "+j:"");c.oMC.appendChild(f);if(v)i=c.oMC.appendChild(h.createElement("div")),i.className=c.swfCSS.swfBox,i.innerHTML=l;H=true}else{c.oMC.id=c.movieID;c.oMC.className=c.swfCSS.swfDefault+" "+j;i=j=null;if(!c.useFlashBlock)if(c.useHighPerformance)j={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"};else if(j={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},m)j.left=
+Math.abs(parseInt(j.left,10))+"px";if(La)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(k in j)j.hasOwnProperty(k)&&(c.oMC.style[k]=j[k]);try{v||c.oMC.appendChild(f);g.appendChild(c.oMC);if(v)i=c.oMC.appendChild(h.createElement("div")),i.className=c.swfCSS.swfBox,i.innerHTML=l;H=true}catch(n){throw Error(y("domError")+" \n"+n.toString());}}return G=true};R=function(){if(c.html5Only)return S(),false;if(c.o)return false;c.o=c.getMovie(c.id);if(!c.o)J?(v?c.oMC.innerHTML=ha:c.oMC.appendChild(J),J=null,G=
+true):S(c.id,c.url),c.o=c.getMovie(c.id);c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return true};Q=function(){setTimeout(ta,1E3)};ta=function(){if(W)return false;W=true;k.remove(i,"load",Q);if(E&&!pa)return false;var b;m||(b=c.getMoviePercent());setTimeout(function(){b=c.getMoviePercent();!m&&Da&&(b===null?c.useFlashBlock||c.flashLoadTimeout===0?c.useFlashBlock&&ia():T(true):c.flashLoadTimeout!==0&&T(true))},c.flashLoadTimeout)};x=function(){function b(){k.remove(i,"focus",x);
+k.remove(i,"load",x)}if(pa||!E)return b(),true;pa=Da=true;M&&E&&k.remove(i,"mousemove",x);W=false;b();return true};Ca=function(){var b,a=[];if(c.useHTML5Audio&&c.hasHTML5)for(b in c.audioFormats)c.audioFormats.hasOwnProperty(b)&&a.push(b+": "+c.html5[b]+(!c.html5[b]&&p&&c.flash[b]?" (using flash)":c.preferFlash&&c.flash[b]&&p?" (preferring flash)":!c.html5[b]?" ("+(c.audioFormats[b].required?"required, ":"")+"and no flash support)":""))};I=function(b){if(m)return false;if(c.html5Only)return m=true,
+A(),true;var a;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())m=true,t&&(a={type:!p&&q?"NO_FLASH":"INIT_TIMEOUT"});if(t||b){if(c.useFlashBlock&&c.oMC)c.oMC.className=D()+" "+(c.getMoviePercent()===null?c.swfCSS.swfTimedout:c.swfCSS.swfError);z({type:"ontimeout",error:a});C(a);return false}if(c.waitForWindowLoad&&!sa)return k.add(i,"load",A),false;else A();return true};P=function(){if(m)return false;if(c.html5Only){if(!m)k.remove(i,"load",c.beginDelayedInit),c.enabled=true,I();return true}R();
+try{c.o._externalInterfaceTest(false),ua(true,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||c.o._disableDebug(),c.enabled=true,c.html5Only||k.add(i,"unload",ba)}catch(b){return C({type:"JS_TO_FLASH_EXCEPTION",fatal:true}),T(true),I(),false}I();k.remove(i,"load",c.beginDelayedInit);return true};B=function(){if(ea)return false;ea=true;ga();if(!p&&c.hasHTML5)c.useHTML5Audio=true,c.preferFlash=false;Aa();c.html5.usingFlash=za();q=c.html5.usingFlash;Ca();if(!p&&q)c.flashLoadTimeout=
+1;h.removeEventListener&&h.removeEventListener("DOMContentLoaded",B,false);R();return true};ma=function(){h.readyState==="complete"&&(B(),h.detachEvent("onreadystatechange",ma));return true};Y();k.add(i,"focus",x);k.add(i,"load",x);k.add(i,"load",Q);M&&E&&k.add(i,"mousemove",x);h.addEventListener?h.addEventListener("DOMContentLoaded",B,false):h.attachEvent?h.attachEvent("onreadystatechange",ma):C({type:"NO_DOM2_EVENTS",fatal:true});h.readyState==="complete"&&setTimeout(B,100)}var Z=null;if(typeof SM2_DEFER===
+"undefined"||!SM2_DEFER)Z=new N;$.SoundManager=N;$.soundManager=Z})(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.20111030\r
+ */\r
+\r
+/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio */\r
+/* jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true */\r
+\r
+(function(window) {\r
+var soundManager = null;\r
+function SoundManager(smURL, smID) {\r
+ this.flashVersion = 8;\r
+ this.debugMode = false;\r
+ this.debugFlash = false;\r
+ this.useConsole = true;\r
+ this.consoleOnly = false;\r
+ this.waitForWindowLoad = false;\r
+ this.bgColor = '#ffffff';\r
+ this.useHighPerformance = false;\r
+ this.flashPollingInterval = null;\r
+ this.flashLoadTimeout = 1000;\r
+ this.wmode = null;\r
+ this.allowScriptAccess = 'always';\r
+ this.useFlashBlock = false;\r
+ this.useHTML5Audio = true;\r
+ this.html5Test = /^(probably|maybe)$/i;\r
+ this.preferFlash = true;\r
+ this.noSWFCache = false;\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'],\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
+ 'wav': {\r
+ 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],\r
+ 'required': false\r
+ }\r
+ };\r
+ this.defaultOptions = {\r
+ 'autoLoad': false,\r
+ 'stream': true,\r
+ 'autoPlay': false,\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
+ 'onstop': null,\r
+ 'onfailure': null,\r
+ 'onfinish': null,\r
+ 'multiShot': true,\r
+ 'multiShotEvents': false,\r
+ 'position': null,\r
+ 'pan': 0,\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.movieID = 'sm2-container';\r
+ this.id = (smID || 'sm2movie');\r
+ this.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.debugID = 'soundmanager-debug';\r
+ this.debugURLParam = /([#?&])debug=1/i;\r
+ this.versionNumber = 'V2.97a.20111030';\r
+ this.version = null;\r
+ this.movieURL = null;\r
+ this.url = (smURL || null);\r
+ this.altURL = null;\r
+ this.swfLoaded = false;\r
+ this.enabled = false;\r
+ this.o = null;\r
+ this.oMC = null;\r
+ this.sounds = {};\r
+ this.soundIDs = [];\r
+ this.muted = false;\r
+ this.specialWmodeCase = 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.hasHTML5 = (function() {\r
+ try {\r
+ return (typeof Audio !== 'undefined' && typeof new Audio().canPlayType !== 'undefined');\r
+ } catch(e) {\r
+ return false;\r
+ }\r
+ }());\r
+ this.html5 = {\r
+ 'usingFlash': null\r
+ };\r
+ this.flash = {};\r
+ this.html5Only = false;\r
+ this.ignoreFlash = false;\r
+ var SMSound,\r
+ _s = this, _sm = 'soundManager', _smc = _sm+'::', _h5 = 'HTML5::', _id, _ua = navigator.userAgent, _win = window, _wl = _win.location.href.toString(), _doc = document, _doNothing, _init, _fV, _on_queue = [], _debugOpen = true, _debugTS, _didAppend = false, _appendSuccess = false, _didInit = false, _disabled = false, _windowLoaded = false, _wDS, _wdCount = 0, _initComplete, _mixin, _addOnEvent, _processOnEvents, _initUserOnload, _delayWaitForEI, _waitForEI, _setVersionInfo, _handleFocus, _strings, _initMovie, _domContentLoaded, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _smTimer, _onTimer, _startTimer, _stopTimer, _needsFlash = null, _featureCheck, _html5OK, _html5CanPlay, _html5Ext, _html5Unload, _domContentLoadedIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix, _html5_events, _showSupport,\r
+ _is_iDevice = _ua.match(/(ipad|iphone|ipod)/i), _is_firefox = _ua.match(/firefox/i), _is_android = _ua.match(/droid/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
+ _likesHTML5 = (_ua.match(/(mobile|pre\/|xoom)/i) || _is_iDevice),\r
+ _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && _ua.match(/OS X 10_6_([3-7])/i)),\r
+ _hasConsole = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (_isSafari && typeof _doc.hasFocus === 'undefined'), _okToDisable = !_tryInitOnFocus, _flashMIME = /(mp3|mp4|mpa)/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|mp4v|3gp|3g2)\s*(?:$|;)/i,\r
+ _netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', '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
+ this._global_a = null;\r
+ if (_likesHTML5) {\r
+ _s.useHTML5Audio = true;\r
+ _s.preferFlash = false;\r
+ if (_is_iDevice) {\r
+ _s.ignoreFlash = true;\r
+ _useGlobalHTML5Audio = true;\r
+ }\r
+ }\r
+ this.ok = function() {\r
+ return (_needsFlash?(_didInit && !_disabled):(_s.useHTML5Audio && _s.hasHTML5));\r
+ };\r
+ this.supported = this.ok;\r
+ this.getMovie = function(smID) {\r
+ return _id(smID) || _doc[smID] || _win[smID];\r
+ };\r
+ this.createSound = function(oOptions) {\r
+ var _cs = _sm+'.createSound(): ',\r
+ thisOptions = null, oSound = null, _tO = null;\r
+ if (!_didInit || !_s.ok()) {\r
+ _complain(_cs + _str(!_didInit?'notReady':'notOK'));\r
+ return false;\r
+ }\r
+ if (arguments.length === 2) {\r
+ oOptions = {\r
+ 'id': arguments[0],\r
+ 'url': arguments[1]\r
+ };\r
+ }\r
+ thisOptions = _mixin(oOptions);\r
+ _tO = thisOptions;\r
+ if (_idCheck(_tO.id, true)) {\r
+ return _s.sounds[_tO.id];\r
+ }\r
+ function make() {\r
+ thisOptions = _loopFix(thisOptions);\r
+ _s.sounds[_tO.id] = new SMSound(_tO);\r
+ _s.soundIDs.push(_tO.id);\r
+ return _s.sounds[_tO.id];\r
+ }\r
+ if (_html5OK(_tO)) {\r
+ oSound = make();\r
+ oSound._setup_html5(_tO);\r
+ } else {\r
+ if (_fV > 8) {\r
+ if (_tO.isMovieStar === null) {\r
+ _tO.isMovieStar = (_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern));\r
+ }\r
+ if (_tO.isMovieStar) {\r
+ if (_tO.usePeakData) {\r
+ _tO.usePeakData = false;\r
+ }\r
+ }\r
+ }\r
+ _tO = _policyFix(_tO, _cs);\r
+ oSound = make();\r
+ if (_fV === 8) {\r
+ _s.o._createSound(_tO.id, _tO.loops||1, _tO.usePolicyFile);\r
+ } else {\r
+ _s.o._createSound(_tO.id, _tO.url, _tO.usePeakData, _tO.useWaveformData, _tO.useEQData, _tO.isMovieStar, (_tO.isMovieStar?_tO.bufferTime:false), _tO.loops||1, _tO.serverURL, _tO.duration||null, _tO.autoPlay, true, _tO.autoLoad, _tO.usePolicyFile);\r
+ if (!_tO.serverURL) {\r
+ oSound.connected = true;\r
+ if (_tO.onconnect) {\r
+ _tO.onconnect.apply(oSound);\r
+ }\r
+ }\r
+ }\r
+ if (!_tO.serverURL && (_tO.autoLoad || _tO.autoPlay)) {\r
+ oSound.load(_tO);\r
+ }\r
+ }\r
+ if (!_tO.serverURL && _tO.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 = _s.sounds[sID], i;\r
+ oS._iO = {};\r
+ oS.stop();\r
+ oS.unload();\r
+ for (i = 0; i < _s.soundIDs.length; i++) {\r
+ if (_s.soundIDs[i] === sID) {\r
+ _s.soundIDs.splice(i, 1);\r
+ break;\r
+ }\r
+ }\r
+ if (!_bFromSound) {\r
+ oS.destruct(true);\r
+ }\r
+ oS = null;\r
+ delete _s.sounds[sID];\r
+ return true;\r
+ };\r
+ this.load = function(sID, oOptions) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].load(oOptions);\r
+ };\r
+ this.unload = function(sID) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].unload();\r
+ };\r
+ this.onposition = function(sID, nPosition, oMethod, oScope) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].onposition(nPosition, oMethod, oScope);\r
+ };\r
+ this.play = function(sID, oOptions) {\r
+ var fN = _sm+'.play(): ';\r
+ if (!_didInit || !_s.ok()) {\r
+ _complain(fN + _str(!_didInit?'notReady':'notOK'));\r
+ return false;\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
+ return _s.createSound(oOptions).play();\r
+ } else {\r
+ return false;\r
+ }\r
+ }\r
+ return _s.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 _s.sounds[sID].setPosition(nMsecOffset);\r
+ };\r
+ this.stop = function(sID) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].stop();\r
+ };\r
+ this.stopAll = function() {\r
+ var oSound;\r
+ for (oSound in _s.sounds) {\r
+ if (_s.sounds.hasOwnProperty(oSound)) {\r
+ _s.sounds[oSound].stop();\r
+ }\r
+ }\r
+ };\r
+ this.pause = function(sID) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].pause();\r
+ };\r
+ this.pauseAll = function() {\r
+ var i;\r
+ for (i = _s.soundIDs.length; i--;) {\r
+ _s.sounds[_s.soundIDs[i]].pause();\r
+ }\r
+ };\r
+ this.resume = function(sID) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].resume();\r
+ };\r
+ this.resumeAll = function() {\r
+ var i;\r
+ for (i = _s.soundIDs.length; i--;) {\r
+ _s.sounds[_s.soundIDs[i]].resume();\r
+ }\r
+ };\r
+ this.togglePause = function(sID) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].togglePause();\r
+ };\r
+ this.setPan = function(sID, nPan) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].setPan(nPan);\r
+ };\r
+ this.setVolume = function(sID, nVol) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].setVolume(nVol);\r
+ };\r
+ this.mute = function(sID) {\r
+ var fN = _sm+'.mute(): ',\r
+ i = 0;\r
+ if (typeof sID !== 'string') {\r
+ sID = null;\r
+ }\r
+ if (!sID) {\r
+ for (i = _s.soundIDs.length; i--;) {\r
+ _s.sounds[_s.soundIDs[i]].mute();\r
+ }\r
+ _s.muted = true;\r
+ } else {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].mute();\r
+ }\r
+ return true;\r
+ };\r
+ this.muteAll = function() {\r
+ _s.mute();\r
+ };\r
+ this.unmute = function(sID) {\r
+ var fN = _sm+'.unmute(): ', i;\r
+ if (typeof sID !== 'string') {\r
+ sID = null;\r
+ }\r
+ if (!sID) {\r
+ for (i = _s.soundIDs.length; i--;) {\r
+ _s.sounds[_s.soundIDs[i]].unmute();\r
+ }\r
+ _s.muted = false;\r
+ } else {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].unmute();\r
+ }\r
+ return true;\r
+ };\r
+ this.unmuteAll = function() {\r
+ _s.unmute();\r
+ };\r
+ this.toggleMute = function(sID) {\r
+ if (!_idCheck(sID)) {\r
+ return false;\r
+ }\r
+ return _s.sounds[sID].toggleMute();\r
+ };\r
+ this.getMemoryUse = function() {\r
+ var ram = 0;\r
+ if (_s.o && _fV !== 8) {\r
+ ram = parseInt(_s.o._getMemoryUse(), 10);\r
+ }\r
+ return ram;\r
+ };\r
+ this.disable = function(bNoDisable) {\r
+ var i;\r
+ if (typeof bNoDisable === 'undefined') {\r
+ bNoDisable = false;\r
+ }\r
+ if (_disabled) {\r
+ return false;\r
+ }\r
+ _disabled = true;\r
+ for (i = _s.soundIDs.length; i--;) {\r
+ _disableObject(_s.sounds[_s.soundIDs[i]]);\r
+ }\r
+ _initComplete(bNoDisable);\r
+ _event.remove(_win, 'load', _initUserOnload);\r
+ return true;\r
+ };\r
+ this.canPlayMIME = function(sMIME) {\r
+ var result;\r
+ if (_s.hasHTML5) {\r
+ result = _html5CanPlay({type:sMIME});\r
+ }\r
+ if (!_needsFlash || result) {\r
+ return result;\r
+ } else {\r
+ return (sMIME ? !!((_fV > 8 ? sMIME.match(_netStreamMimeTypes) : null) || sMIME.match(_s.mimePattern)) : null);\r
+ }\r
+ };\r
+ this.canPlayURL = function(sURL) {\r
+ var result;\r
+ if (_s.hasHTML5) {\r
+ result = _html5CanPlay({url: sURL});\r
+ }\r
+ if (!_needsFlash || result) {\r
+ return result;\r
+ } else {\r
+ return (sURL ? !!(sURL.match(_s.filePattern)) : null);\r
+ }\r
+ };\r
+ this.canPlayLink = function(oLink) {\r
+ if (typeof oLink.type !== 'undefined' && oLink.type) {\r
+ if (_s.canPlayMIME(oLink.type)) {\r
+ return true;\r
+ }\r
+ }\r
+ return _s.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 = _s.sounds[sID];\r
+ return result;\r
+ };\r
+ this.onready = function(oMethod, oScope) {\r
+ var sType = 'onready';\r
+ if (oMethod && oMethod instanceof Function) {\r
+ if (!oScope) {\r
+ oScope = _win;\r
+ }\r
+ _addOnEvent(sType, oMethod, oScope);\r
+ _processOnEvents();\r
+ return true;\r
+ } else {\r
+ throw _str('needFunction', sType);\r
+ }\r
+ };\r
+ this.ontimeout = function(oMethod, oScope) {\r
+ var sType = 'ontimeout';\r
+ if (oMethod && oMethod instanceof Function) {\r
+ if (!oScope) {\r
+ oScope = _win;\r
+ }\r
+ _addOnEvent(sType, oMethod, oScope);\r
+ _processOnEvents({type:sType});\r
+ return true;\r
+ } else {\r
+ throw _str('needFunction', sType);\r
+ }\r
+ };\r
+ this._writeDebug = function(sText, sType, _bTimestamp) {\r
+ return true;\r
+ };\r
+ this._wD = this._writeDebug;\r
+ this._debug = function() {\r
+ };\r
+ this.reboot = function() {\r
+ var i, j;\r
+ for (i = _s.soundIDs.length; i--;) {\r
+ _s.sounds[_s.soundIDs[i]].destruct();\r
+ }\r
+ try {\r
+ if (_isIE) {\r
+ _oRemovedHTML = _s.o.innerHTML;\r
+ }\r
+ _oRemoved = _s.o.parentNode.removeChild(_s.o);\r
+ } catch(e) {\r
+ }\r
+ _oRemovedHTML = _oRemoved = _needsFlash = null;\r
+ _s.enabled = _didDCLoaded = _didInit = _waitingForEI = _initPending = _didAppend = _appendSuccess = _disabled = _s.swfLoaded = false;\r
+ _s.soundIDs = _s.sounds = [];\r
+ _s.o = null;\r
+ for (i in _on_queue) {\r
+ if (_on_queue.hasOwnProperty(i)) {\r
+ for (j = _on_queue[i].length; j--;) {\r
+ _on_queue[i][j].fired = false;\r
+ }\r
+ }\r
+ }\r
+ _win.setTimeout(_s.beginDelayedInit, 20);\r
+ };\r
+ this.getMoviePercent = function() {\r
+ return (_s.o && typeof _s.o.PercentLoaded !== 'undefined' ? _s.o.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
+ _s.disable(true);\r
+ };\r
+ SMSound = function(oOptions) {\r
+ var _t = this, _resetProperties, _stop_html5_timer, _start_html5_timer;\r
+ this.sID = oOptions.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._lastURL = null;\r
+ this.isHTML5 = false;\r
+ this._a = null;\r
+ this.id3 = {};\r
+ this._debug = function() {\r
+ };\r
+ this.load = function(oOptions) {\r
+ var oS = null;\r
+ if (typeof oOptions !== 'undefined') {\r
+ _t._iO = _mixin(oOptions, _t.options);\r
+ _t.instanceOptions = _t._iO;\r
+ } else {\r
+ oOptions = _t.options;\r
+ _t._iO = oOptions;\r
+ _t.instanceOptions = _t._iO;\r
+ if (_t._lastURL && _t._lastURL !== _t.url) {\r
+ _t._iO.url = _t.url;\r
+ _t.url = null;\r
+ }\r
+ }\r
+ if (!_t._iO.url) {\r
+ _t._iO.url = _t.url;\r
+ }\r
+ if (_t._iO.url === _t.url && _t.readyState !== 0 && _t.readyState !== 2) {\r
+ return _t;\r
+ }\r
+ _t._lastURL = _t.url;\r
+ _t.loaded = false;\r
+ _t.readyState = 1;\r
+ _t.playState = 0;\r
+ if (_html5OK(_t._iO)) {\r
+ oS = _t._setup_html5(_t._iO);\r
+ if (!oS._called_load) {\r
+ _t._html5_canplay = false;\r
+ oS.load();\r
+ oS._called_load = true;\r
+ if (_t._iO.autoPlay) {\r
+ _t.play();\r
+ }\r
+ } else {\r
+ }\r
+ } else {\r
+ try {\r
+ _t.isHTML5 = false;\r
+ _t._iO = _policyFix(_loopFix(_t._iO));\r
+ if (_fV === 8) {\r
+ _s.o._load(_t.sID, _t._iO.url, _t._iO.stream, _t._iO.autoPlay, (_t._iO.whileloading?1:0), _t._iO.loops||1, _t._iO.usePolicyFile);\r
+ } else {\r
+ _s.o._load(_t.sID, _t._iO.url, !!(_t._iO.stream), !!(_t._iO.autoPlay), _t._iO.loops||1, !!(_t._iO.autoLoad), _t._iO.usePolicyFile);\r
+ }\r
+ } catch(e) {\r
+ _catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true});\r
+ }\r
+ }\r
+ return _t;\r
+ };\r
+ this.unload = function() {\r
+ if (_t.readyState !== 0) {\r
+ if (!_t.isHTML5) {\r
+ if (_fV === 8) {\r
+ _s.o._unload(_t.sID, _emptyURL);\r
+ } else {\r
+ _s.o._unload(_t.sID);\r
+ }\r
+ } else {\r
+ _stop_html5_timer();\r
+ if (_t._a) {\r
+ _t._a.pause();\r
+ _html5Unload(_t._a);\r
+ }\r
+ }\r
+ _resetProperties();\r
+ }\r
+ return _t;\r
+ };\r
+ this.destruct = function(_bFromSM) {\r
+ if (!_t.isHTML5) {\r
+ _t._iO.onfailure = null;\r
+ _s.o._destroySound(_t.sID);\r
+ } else {\r
+ _stop_html5_timer();\r
+ if (_t._a) {\r
+ _t._a.pause();\r
+ _html5Unload(_t._a);\r
+ if (!_useGlobalHTML5Audio) {\r
+ _t._remove_html5_events();\r
+ }\r
+ _t._a._t = null;\r
+ _t._a = null;\r
+ }\r
+ }\r
+ if (!_bFromSM) {\r
+ _s.destroySound(_t.sID, true);\r
+ }\r
+ };\r
+ this.play = function(oOptions, _updatePlayState) {\r
+ var fN = 'SMSound.play(): ', allowMulti, a;\r
+ _updatePlayState = _updatePlayState === undefined ? true : _updatePlayState;\r
+ if (!oOptions) {\r
+ oOptions = {};\r
+ }\r
+ _t._iO = _mixin(oOptions, _t._iO);\r
+ _t._iO = _mixin(_t._iO, _t.options);\r
+ _t.instanceOptions = _t._iO;\r
+ if (_t._iO.serverURL && !_t.connected) {\r
+ if (!_t.getAutoPlay()) {\r
+ _t.setAutoPlay(true);\r
+ }\r
+ return _t;\r
+ }\r
+ if (_html5OK(_t._iO)) {\r
+ _t._setup_html5(_t._iO);\r
+ _start_html5_timer();\r
+ }\r
+ if (_t.playState === 1 && !_t.paused) {\r
+ allowMulti = _t._iO.multiShot;\r
+ if (!allowMulti) {\r
+ return _t;\r
+ } else {\r
+ }\r
+ }\r
+ if (!_t.loaded) {\r
+ if (_t.readyState === 0) {\r
+ if (!_t.isHTML5) {\r
+ _t._iO.autoPlay = true;\r
+ }\r
+ _t.load(_t._iO);\r
+ } else if (_t.readyState === 2) {\r
+ return _t;\r
+ } else {\r
+ }\r
+ } else {\r
+ }\r
+ if (!_t.isHTML5 && _fV === 9 && _t.position > 0 && _t.position === _t.duration) {\r
+ _t._iO.position = 0;\r
+ }\r
+ if (_t.paused && _t.position && _t.position > 0) {\r
+ _t.resume();\r
+ } else {\r
+ _t.playState = 1;\r
+ _t.paused = false;\r
+ if (!_t.instanceCount || _t._iO.multiShotEvents || (!_t.isHTML5 && _fV > 8 && !_t.getAutoPlay())) {\r
+ _t.instanceCount++;\r
+ }\r
+ _t.position = (typeof _t._iO.position !== 'undefined' && !isNaN(_t._iO.position)?_t._iO.position:0);\r
+ if (!_t.isHTML5) {\r
+ _t._iO = _policyFix(_loopFix(_t._iO));\r
+ }\r
+ if (_t._iO.onplay && _updatePlayState) {\r
+ _t._iO.onplay.apply(_t);\r
+ _t._onplay_called = true;\r
+ }\r
+ _t.setVolume(_t._iO.volume, true);\r
+ _t.setPan(_t._iO.pan, true);\r
+ if (!_t.isHTML5) {\r
+ _s.o._start(_t.sID, _t._iO.loops || 1, (_fV === 9?_t._iO.position:_t._iO.position / 1000));\r
+ } else {\r
+ _start_html5_timer();\r
+ a = _t._setup_html5();\r
+ _t.setPosition(_t._iO.position);\r
+ a.play();\r
+ }\r
+ }\r
+ return _t;\r
+ };\r
+ this.start = this.play;\r
+ this.stop = function(bAll) {\r
+ if (_t.playState === 1) {\r
+ _t._onbufferchange(0);\r
+ _t.resetOnPosition(0);\r
+ _t.paused = false;\r
+ if (!_t.isHTML5) {\r
+ _t.playState = 0;\r
+ }\r
+ if (_t._iO.onstop) {\r
+ _t._iO.onstop.apply(_t);\r
+ }\r
+ if (!_t.isHTML5) {\r
+ _s.o._stop(_t.sID, bAll);\r
+ if (_t._iO.serverURL) {\r
+ _t.unload();\r
+ }\r
+ } else {\r
+ if (_t._a) {\r
+ _t.setPosition(0);\r
+ _t._a.pause();\r
+ _t.playState = 0;\r
+ _t._onTimer();\r
+ _stop_html5_timer();\r
+ }\r
+ }\r
+ _t.instanceCount = 0;\r
+ _t._iO = {};\r
+ }\r
+ return _t;\r
+ };\r
+ this.setAutoPlay = function(autoPlay) {\r
+ _t._iO.autoPlay = autoPlay;\r
+ if (!_t.isHTML5) {\r
+ _s.o._setAutoPlay(_t.sID, autoPlay);\r
+ if (autoPlay) {\r
+ if (!_t.instanceCount && _t.readyState === 1) {\r
+ _t.instanceCount++;\r
+ }\r
+ }\r
+ }\r
+ };\r
+ this.getAutoPlay = function() {\r
+ return _t._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 = (_t.isHTML5 ? Math.max(nMsecOffset,0) : Math.min(_t.duration || _t._iO.duration, Math.max(nMsecOffset, 0)));\r
+ original_pos = _t.position;\r
+ _t.position = offset;\r
+ position1K = _t.position/1000;\r
+ _t.resetOnPosition(_t.position);\r
+ _t._iO.position = offset;\r
+ if (!_t.isHTML5) {\r
+ position = (_fV === 9 ? _t.position : position1K);\r
+ if (_t.readyState && _t.readyState !== 2) {\r
+ _s.o._setPosition(_t.sID, position, (_t.paused || !_t.playState));\r
+ }\r
+ } else if (_t._a) {\r
+ if (_t._html5_canplay) {\r
+ if (_t._a.currentTime !== position1K) {\r
+ try {\r
+ _t._a.currentTime = position1K;\r
+ if (_t.playState === 0 || _t.paused) {\r
+ _t._a.pause();\r
+ }\r
+ } catch(e) {\r
+ }\r
+ }\r
+ } else {\r
+ }\r
+ }\r
+ if (_t.isHTML5) {\r
+ if (_t.paused) {\r
+ _t._onTimer(true);\r
+ }\r
+ }\r
+ return _t;\r
+ };\r
+ this.pause = function(_bCallFlash) {\r
+ if (_t.paused || (_t.playState === 0 && _t.readyState !== 1)) {\r
+ return _t;\r
+ }\r
+ _t.paused = true;\r
+ if (!_t.isHTML5) {\r
+ if (_bCallFlash || _bCallFlash === undefined) {\r
+ _s.o._pause(_t.sID);\r
+ }\r
+ } else {\r
+ _t._setup_html5().pause();\r
+ _stop_html5_timer();\r
+ }\r
+ if (_t._iO.onpause) {\r
+ _t._iO.onpause.apply(_t);\r
+ }\r
+ return _t;\r
+ };\r
+ this.resume = function() {\r
+ if (!_t.paused) {\r
+ return _t;\r
+ }\r
+ _t.paused = false;\r
+ _t.playState = 1;\r
+ if (!_t.isHTML5) {\r
+ if (_t._iO.isMovieStar) {\r
+ _t.setPosition(_t.position);\r
+ }\r
+ _s.o._pause(_t.sID);\r
+ } else {\r
+ _t._setup_html5().play();\r
+ _start_html5_timer();\r
+ }\r
+ if (!_t._onplay_called && _t._iO.onplay) {\r
+ _t._iO.onplay.apply(_t);\r
+ _t._onplay_called = true;\r
+ } else if (_t._iO.onresume) {\r
+ _t._iO.onresume.apply(_t);\r
+ }\r
+ return _t;\r
+ };\r
+ this.togglePause = function() {\r
+ if (_t.playState === 0) {\r
+ _t.play({\r
+ position: (_fV === 9 && !_t.isHTML5 ? _t.position : _t.position / 1000)\r
+ });\r
+ return _t;\r
+ }\r
+ if (_t.paused) {\r
+ _t.resume();\r
+ } else {\r
+ _t.pause();\r
+ }\r
+ return _t;\r
+ };\r
+ this.setPan = function(nPan, bInstanceOnly) {\r
+ if (typeof nPan === 'undefined') {\r
+ nPan = 0;\r
+ }\r
+ if (typeof bInstanceOnly === 'undefined') {\r
+ bInstanceOnly = false;\r
+ }\r
+ if (!_t.isHTML5) {\r
+ _s.o._setPan(_t.sID, nPan);\r
+ }\r
+ _t._iO.pan = nPan;\r
+ if (!bInstanceOnly) {\r
+ _t.pan = nPan;\r
+ _t.options.pan = nPan;\r
+ }\r
+ return _t;\r
+ };\r
+ this.setVolume = function(nVol, _bInstanceOnly) {\r
+ if (typeof nVol === 'undefined') {\r
+ nVol = 100;\r
+ }\r
+ if (typeof _bInstanceOnly === 'undefined') {\r
+ _bInstanceOnly = false;\r
+ }\r
+ if (!_t.isHTML5) {\r
+ _s.o._setVolume(_t.sID, (_s.muted && !_t.muted) || _t.muted?0:nVol);\r
+ } else if (_t._a) {\r
+ _t._a.volume = Math.max(0, Math.min(1, nVol/100));\r
+ }\r
+ _t._iO.volume = nVol;\r
+ if (!_bInstanceOnly) {\r
+ _t.volume = nVol;\r
+ _t.options.volume = nVol;\r
+ }\r
+ return _t;\r
+ };\r
+ this.mute = function() {\r
+ _t.muted = true;\r
+ if (!_t.isHTML5) {\r
+ _s.o._setVolume(_t.sID, 0);\r
+ } else if (_t._a) {\r
+ _t._a.muted = true;\r
+ }\r
+ return _t;\r
+ };\r
+ this.unmute = function() {\r
+ _t.muted = false;\r
+ var hasIO = typeof _t._iO.volume !== 'undefined';\r
+ if (!_t.isHTML5) {\r
+ _s.o._setVolume(_t.sID, hasIO?_t._iO.volume:_t.options.volume);\r
+ } else if (_t._a) {\r
+ _t._a.muted = false;\r
+ }\r
+ return _t;\r
+ };\r
+ this.toggleMute = function() {\r
+ return (_t.muted?_t.unmute():_t.mute());\r
+ };\r
+ this.onposition = function(nPosition, oMethod, oScope) {\r
+ _t._onPositionItems.push({\r
+ position: nPosition,\r
+ method: oMethod,\r
+ scope: (typeof oScope !== 'undefined'?oScope:_t),\r
+ fired: false\r
+ });\r
+ return _t;\r
+ };\r
+ this.processOnPosition = function() {\r
+ var i, item, j = _t._onPositionItems.length;\r
+ if (!j || !_t.playState || _t._onPositionFired >= j) {\r
+ return false;\r
+ }\r
+ for (i=j; i--;) {\r
+ item = _t._onPositionItems[i];\r
+ if (!item.fired && _t.position >= item.position) {\r
+ item.fired = true;\r
+ _s._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 = _t._onPositionItems.length;\r
+ if (!j) {\r
+ return false;\r
+ }\r
+ for (i=j; i--;) {\r
+ item = _t._onPositionItems[i];\r
+ if (item.fired && nPosition <= item.position) {\r
+ item.fired = false;\r
+ _s._onPositionFired--;\r
+ }\r
+ }\r
+ return true;\r
+ };\r
+ _start_html5_timer = function() {\r
+ if (_t.isHTML5) {\r
+ _startTimer(_t);\r
+ }\r
+ };\r
+ _stop_html5_timer = function() {\r
+ if (_t.isHTML5) {\r
+ _stopTimer(_t);\r
+ }\r
+ };\r
+ _resetProperties = function() {\r
+ _t._onPositionItems = [];\r
+ _t._onPositionFired = 0;\r
+ _t._hasTimer = null;\r
+ _t._onplay_called = false;\r
+ _t._a = null;\r
+ _t._html5_canplay = false;\r
+ _t.bytesLoaded = null;\r
+ _t.bytesTotal = null;\r
+ _t.position = null;\r
+ _t.duration = (_t._iO && _t._iO.duration?_t._iO.duration:null);\r
+ _t.durationEstimate = null;\r
+ _t.failures = 0;\r
+ _t.loaded = false;\r
+ _t.playState = 0;\r
+ _t.paused = false;\r
+ _t.readyState = 0;\r
+ _t.muted = false;\r
+ _t.isBuffering = false;\r
+ _t.instanceOptions = {};\r
+ _t.instanceCount = 0;\r
+ _t.peakData = {\r
+ left: 0,\r
+ right: 0\r
+ };\r
+ _t.waveformData = {\r
+ left: [],\r
+ right: []\r
+ };\r
+ _t.eqData = [];\r
+ _t.eqData.left = [];\r
+ _t.eqData.right = [];\r
+ };\r
+ _resetProperties();\r
+ this._onTimer = function(bForce) {\r
+ var time, x = {};\r
+ if (_t._hasTimer || bForce) {\r
+ if (_t._a && (bForce || ((_t.playState > 0 || _t.readyState === 1) && !_t.paused))) {\r
+ _t.duration = _t._get_html5_duration();\r
+ _t.durationEstimate = _t.duration;\r
+ time = _t._a.currentTime?_t._a.currentTime*1000:0;\r
+ _t._whileplaying(time,x,x,x,x);\r
+ return true;\r
+ } else {\r
+ return false;\r
+ }\r
+ }\r
+ };\r
+ this._get_html5_duration = function() {\r
+ var d = (_t._a ? _t._a.duration*1000 : (_t._iO ? _t._iO.duration : undefined)),\r
+ result = (d && !isNaN(d) && d !== Infinity ? d : (_t._iO ? _t._iO.duration : null));\r
+ return result;\r
+ };\r
+ this._setup_html5 = function(oOptions) {\r
+ var _iO = _mixin(_t._iO, oOptions), d = decodeURI,\r
+ _a = _useGlobalHTML5Audio ? _s._global_a : _t._a,\r
+ _dURL = d(_iO.url),\r
+ _oldIO = (_a && _a._t ? _a._t.instanceOptions : null);\r
+ if (_a) {\r
+ if (_a._t && _oldIO.url === _iO.url && (!_t._lastURL || (_t._lastURL === _oldIO.url))) {\r
+ return _a;\r
+ }\r
+ if (_useGlobalHTML5Audio && _a._t && _a._t.playState && _iO.url !== _oldIO.url) {\r
+ _a._t.stop();\r
+ }\r
+ _resetProperties();\r
+ _a.src = _iO.url;\r
+ _t.url = _iO.url;\r
+ _t._lastURL = _iO.url;\r
+ _a._called_load = false;\r
+ } else {\r
+ _a = new Audio(_iO.url);\r
+ _a._called_load = false;\r
+ if (_is_android) {\r
+ _a._called_load = true;\r
+ }\r
+ if (_useGlobalHTML5Audio) {\r
+ _s._global_a = _a;\r
+ }\r
+ }\r
+ _t.isHTML5 = true;\r
+ _t._a = _a;\r
+ _a._t = _t;\r
+ _t._add_html5_events();\r
+ _a.loop = (_iO.loops>1?'loop':'');\r
+ if (_iO.autoLoad || _iO.autoPlay) {\r
+ _a.autobuffer = 'auto';\r
+ _a.preload = 'auto';\r
+ _t.load();\r
+ _a._called_load = true;\r
+ } else {\r
+ _a.autobuffer = false;\r
+ _a.preload = 'none';\r
+ }\r
+ _a.loop = (_iO.loops>1?'loop':'');\r
+ return _a;\r
+ };\r
+ this._add_html5_events = function() {\r
+ if (_t._a._added_events) {\r
+ return false;\r
+ }\r
+ var f;\r
+ function add(oEvt, oFn, bCapture) {\r
+ return _t._a ? _t._a.addEventListener(oEvt, oFn, bCapture||false) : null;\r
+ }\r
+ _t._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
+ this._remove_html5_events = function() {\r
+ var f;\r
+ function remove(oEvt, oFn, bCapture) {\r
+ return (_t._a ? _t._a.removeEventListener(oEvt, oFn, bCapture||false) : null);\r
+ }\r
+ _t._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 = 'SMSound._onload(): ', loadOK = !!(nSuccess);\r
+ _t.loaded = loadOK;\r
+ _t.readyState = loadOK?3:2;\r
+ _t._onbufferchange(0);\r
+ if (_t._iO.onload) {\r
+ _t._iO.onload.apply(_t, [loadOK]);\r
+ }\r
+ return true;\r
+ };\r
+ this._onbufferchange = function(nIsBuffering) {\r
+ var fN = 'SMSound._onbufferchange()';\r
+ if (_t.playState === 0) {\r
+ return false;\r
+ }\r
+ if ((nIsBuffering && _t.isBuffering) || (!nIsBuffering && !_t.isBuffering)) {\r
+ return false;\r
+ }\r
+ _t.isBuffering = (nIsBuffering === 1);\r
+ if (_t._iO.onbufferchange) {\r
+ _t._iO.onbufferchange.apply(_t);\r
+ }\r
+ return true;\r
+ };\r
+ this._onsuspend = function () {\r
+ if (_t._iO.onsuspend) {\r
+ _t._iO.onsuspend.apply(_t);\r
+ }\r
+ return true;\r
+ };\r
+ this._onfailure = function(msg, level, code) {\r
+ _t.failures++;\r
+ if (_t._iO.onfailure && _t.failures === 1) {\r
+ _t._iO.onfailure(_t, msg, level, code);\r
+ } else {\r
+ }\r
+ };\r
+ this._onfinish = function() {\r
+ var _io_onfinish = _t._iO.onfinish;\r
+ _t._onbufferchange(0);\r
+ _t.resetOnPosition(0);\r
+ if (_t.instanceCount) {\r
+ _t.instanceCount--;\r
+ if (!_t.instanceCount) {\r
+ _t.playState = 0;\r
+ _t.paused = false;\r
+ _t.instanceCount = 0;\r
+ _t.instanceOptions = {};\r
+ _t._iO = {};\r
+ _stop_html5_timer();\r
+ }\r
+ if (!_t.instanceCount || _t._iO.multiShotEvents) {\r
+ if (_io_onfinish) {\r
+ _io_onfinish.apply(_t);\r
+ }\r
+ }\r
+ }\r
+ };\r
+ this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) {\r
+ _t.bytesLoaded = nBytesLoaded;\r
+ _t.bytesTotal = nBytesTotal;\r
+ _t.duration = Math.floor(nDuration);\r
+ _t.bufferLength = nBufferLength;\r
+ if (!_t._iO.isMovieStar) {\r
+ if (_t._iO.duration) {\r
+ _t.durationEstimate = (_t.duration > _t._iO.duration) ? _t.duration : _t._iO.duration;\r
+ } else {\r
+ _t.durationEstimate = parseInt((_t.bytesTotal / _t.bytesLoaded) * _t.duration, 10);\r
+ }\r
+ if (_t.durationEstimate === undefined) {\r
+ _t.durationEstimate = _t.duration;\r
+ }\r
+ if (_t.readyState !== 3 && _t._iO.whileloading) {\r
+ _t._iO.whileloading.apply(_t);\r
+ }\r
+ } else {\r
+ _t.durationEstimate = _t.duration;\r
+ if (_t.readyState !== 3 && _t._iO.whileloading) {\r
+ _t._iO.whileloading.apply(_t);\r
+ }\r
+ }\r
+ };\r
+ this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {\r
+ if (isNaN(nPosition) || nPosition === null) {\r
+ return false;\r
+ }\r
+ _t.position = nPosition;\r
+ _t.processOnPosition();\r
+ if (!_t.isHTML5 && _fV > 8) {\r
+ if (_t._iO.usePeakData && typeof oPeakData !== 'undefined' && oPeakData) {\r
+ _t.peakData = {\r
+ left: oPeakData.leftPeak,\r
+ right: oPeakData.rightPeak\r
+ };\r
+ }\r
+ if (_t._iO.useWaveformData && typeof oWaveformDataLeft !== 'undefined' && oWaveformDataLeft) {\r
+ _t.waveformData = {\r
+ left: oWaveformDataLeft.split(','),\r
+ right: oWaveformDataRight.split(',')\r
+ };\r
+ }\r
+ if (_t._iO.useEQData) {\r
+ if (typeof oEQData !== 'undefined' && oEQData && oEQData.leftEQ) {\r
+ var eqLeft = oEQData.leftEQ.split(',');\r
+ _t.eqData = eqLeft;\r
+ _t.eqData.left = eqLeft;\r
+ if (typeof oEQData.rightEQ !== 'undefined' && oEQData.rightEQ) {\r
+ _t.eqData.right = oEQData.rightEQ.split(',');\r
+ }\r
+ }\r
+ }\r
+ }\r
+ if (_t.playState === 1) {\r
+ if (!_t.isHTML5 && _fV === 8 && !_t.position && _t.isBuffering) {\r
+ _t._onbufferchange(0);\r
+ }\r
+ if (_t._iO.whileplaying) {\r
+ _t._iO.whileplaying.apply(_t);\r
+ }\r
+ }\r
+ return true;\r
+ };\r
+ this._onid3 = function(oID3PropNames, oID3Data) {\r
+ var oData = [], i, j;\r
+ for (i = 0, j = oID3PropNames.length; i < j; i++) {\r
+ oData[oID3PropNames[i]] = oID3Data[i];\r
+ }\r
+ _t.id3 = _mixin(_t.id3, oData);\r
+ if (_t._iO.onid3) {\r
+ _t._iO.onid3.apply(_t);\r
+ }\r
+ };\r
+ this._onconnect = function(bSuccess) {\r
+ var fN = 'SMSound._onconnect(): ';\r
+ bSuccess = (bSuccess === 1);\r
+ _t.connected = bSuccess;\r
+ if (bSuccess) {\r
+ _t.failures = 0;\r
+ if (_idCheck(_t.sID)) {\r
+ if (_t.getAutoPlay()) {\r
+ _t.play(undefined, _t.getAutoPlay());\r
+ } else if (_t._iO.autoLoad) {\r
+ _t.load();\r
+ }\r
+ }\r
+ if (_t._iO.onconnect) {\r
+ _t._iO.onconnect.apply(_t,[bSuccess]);\r
+ }\r
+ }\r
+ };\r
+ this._ondataerror = function(sError) {\r
+ if (_t.playState > 0) {\r
+ if (_t._iO.ondataerror) {\r
+ _t._iO.ondataerror.apply(_t);\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 = {}, i, o2, o;\r
+ for (i in oMain) {\r
+ if (oMain.hasOwnProperty(i)) {\r
+ o1[i] = oMain[i];\r
+ }\r
+ }\r
+ o2 = (typeof oAdd === 'undefined'?_s.defaultOptions:oAdd);\r
+ for (o in o2) {\r
+ if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') {\r
+ o1[o] = o2[o];\r
+ }\r
+ }\r
+ return o1;\r
+ };\r
+ _event = (function() {\r
+ var old = (_win.attachEvent),\r
+ evt = {\r
+ add: (old?'attachEvent':'addEventListener'),\r
+ remove: (old?'detachEvent':'removeEventListener')\r
+ };\r
+ function getArgs(oArgs) {\r
+ var args = _slice.call(oArgs), 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
+ if (!this._t || !this._t._a) {\r
+ return null;\r
+ } else {\r
+ return oFn.call(this, e);\r
+ }\r
+ };\r
+ }\r
+ _html5_events = {\r
+ abort: _html5_event(function(e) {\r
+ }),\r
+ canplay: _html5_event(function(e) {\r
+ if (this._t._html5_canplay) {\r
+ return true;\r
+ }\r
+ this._t._html5_canplay = true;\r
+ this._t._onbufferchange(0);\r
+ var position1K = (!isNaN(this._t.position)?this._t.position/1000:null);\r
+ if (this._t.position && this.currentTime !== position1K) {\r
+ try {\r
+ this.currentTime = position1K;\r
+ } catch(ee) {\r
+ }\r
+ }\r
+ }),\r
+ load: _html5_event(function(e) {\r
+ if (!this._t.loaded) {\r
+ this._t._onbufferchange(0);\r
+ this._t._whileloading(this._t.bytesTotal, this._t.bytesTotal, this._t._get_html5_duration());\r
+ this._t._onload(true);\r
+ }\r
+ }),\r
+ emptied: _html5_event(function(e) {\r
+ }),\r
+ ended: _html5_event(function(e) {\r
+ this._t._onfinish();\r
+ }),\r
+ error: _html5_event(function(e) {\r
+ this._t._onload(false);\r
+ }),\r
+ loadeddata: _html5_event(function(e) {\r
+ var t = this._t,\r
+ bytesTotal = t.bytesTotal || 1;\r
+ if (!t._loaded && !_isSafari) {\r
+ t.duration = t._get_html5_duration();\r
+ t._whileloading(bytesTotal, bytesTotal, t._get_html5_duration());\r
+ t._onload(true);\r
+ }\r
+ }),\r
+ loadedmetadata: _html5_event(function(e) {\r
+ }),\r
+ loadstart: _html5_event(function(e) {\r
+ this._t._onbufferchange(1);\r
+ }),\r
+ play: _html5_event(function(e) {\r
+ this._t._onbufferchange(0);\r
+ }),\r
+ playing: _html5_event(function(e) {\r
+ this._t._onbufferchange(0);\r
+ }),\r
+ progress: _html5_event(function(e) {\r
+ if (this._t.loaded) {\r
+ return false;\r
+ }\r
+ var 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
+ if (ranges && ranges.length) {\r
+ for (i=ranges.length; i--;) {\r
+ buffered = (ranges.end(i) - ranges.start(i));\r
+ }\r
+ loaded = buffered/e.target.duration;\r
+ }\r
+ if (!isNaN(loaded)) {\r
+ this._t._onbufferchange(0);\r
+ this._t._whileloading(loaded, total, this._t._get_html5_duration());\r
+ if (loaded && total && loaded === total) {\r
+ _html5_events.load.call(this, e);\r
+ }\r
+ }\r
+ }),\r
+ ratechange: _html5_event(function(e) {\r
+ }),\r
+ suspend: _html5_event(function(e) {\r
+ _html5_events.progress.call(this, e);\r
+ this._t._onsuspend();\r
+ }),\r
+ stalled: _html5_event(function(e) {\r
+ }),\r
+ timeupdate: _html5_event(function(e) {\r
+ this._t._onTimer();\r
+ }),\r
+ waiting: _html5_event(function(e) {\r
+ this._t._onbufferchange(1);\r
+ })\r
+ };\r
+ _html5OK = function(iO) {\r
+ return (!iO.serverURL && (iO.type?_html5CanPlay({type:iO.type}):_html5CanPlay({url:iO.url})||_s.html5Only));\r
+ };\r
+ _html5Unload = function(oAudio) {\r
+ if (oAudio) {\r
+ oAudio.src = (_is_firefox ? '' : _emptyURL);\r
+ }\r
+ };\r
+ _html5CanPlay = function(o) {\r
+ if (!_s.useHTML5Audio || !_s.hasHTML5) {\r
+ return false;\r
+ }\r
+ var url = (o.url || null),\r
+ mime = (o.type || null),\r
+ aF = _s.audioFormats,\r
+ result,\r
+ offset,\r
+ fileExt,\r
+ item;\r
+ function preferFlashCheck(kind) {\r
+ return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind]));\r
+ }\r
+ if (mime && _s.html5[mime] !== 'undefined') {\r
+ return (_s.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
+ return 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 && typeof _s.html5[fileExt] !== 'undefined') {\r
+ return (_s.html5[fileExt] && !preferFlashCheck(fileExt));\r
+ } else {\r
+ mime = 'audio/'+fileExt;\r
+ result = _s.html5.canPlayType({type:mime});\r
+ _s.html5[fileExt] = result;\r
+ return (result && _s.html5[mime] && !preferFlashCheck(mime));\r
+ }\r
+ };\r
+ _testHTML5 = function() {\r
+ if (!_s.useHTML5Audio || typeof Audio === 'undefined') {\r
+ return false;\r
+ }\r
+ var a = (typeof Audio !== 'undefined' ? (_isOpera ? new Audio(null) : new Audio()) : null),\r
+ item, support = {}, aF, i;\r
+ function _cp(m) {\r
+ var canPlay, i, j, isOK = false;\r
+ if (!a || typeof a.canPlayType !== 'function') {\r
+ return false;\r
+ }\r
+ if (m instanceof Array) {\r
+ for (i=0, j=m.length; i<j && !isOK; i++) {\r
+ if (_s.html5[m[i]] || a.canPlayType(m[i]).match(_s.html5Test)) {\r
+ isOK = true;\r
+ _s.html5[m[i]] = true;\r
+ _s.flash[m[i]] = !!(_s.preferFlash && _hasFlash && m[i].match(_flashMIME));\r
+ }\r
+ }\r
+ return isOK;\r
+ } else {\r
+ canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);\r
+ return !!(canPlay && (canPlay.match(_s.html5Test)));\r
+ }\r
+ }\r
+ aF = _s.audioFormats;\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ support[item] = _cp(aF[item].type);\r
+ support['audio/'+item] = support[item];\r
+ if (_s.preferFlash && !_s.ignoreFlash && item.match(_flashMIME)) {\r
+ _s.flash[item] = true;\r
+ } else {\r
+ _s.flash[item] = false;\r
+ }\r
+ if (aF[item] && aF[item].related) {\r
+ for (i=aF[item].related.length; i--;) {\r
+ support['audio/'+aF[item].related[i]] = support[item];\r
+ _s.html5[aF[item].related[i]] = support[item];\r
+ _s.flash[aF[item].related[i]] = support[item];\r
+ }\r
+ }\r
+ }\r
+ }\r
+ support.canPlayType = (a?_cp:null);\r
+ _s.html5 = _mixin(_s.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 (typeof bNoDisable === 'undefined') {\r
+ bNoDisable = false;\r
+ }\r
+ if (_disabled || bNoDisable) {\r
+ _s.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) : './') + _s.movieURL;\r
+ if (_s.noSWFCache) {\r
+ url += ('?ts=' + new Date().getTime());\r
+ }\r
+ return url;\r
+ };\r
+ _setVersionInfo = function() {\r
+ _fV = parseInt(_s.flashVersion, 10);\r
+ if (_fV !== 8 && _fV !== 9) {\r
+ _s.flashVersion = _fV = _defaultFlashVersion;\r
+ }\r
+ var isDebug = (_s.debugMode || _s.debugFlash?'_debug.swf':'.swf');\r
+ if (_s.useHTML5Audio && !_s.html5Only && _s.audioFormats.mp4.required && _fV < 9) {\r
+ _s.flashVersion = _fV = 9;\r
+ }\r
+ _s.version = _s.versionNumber + (_s.html5Only?' (HTML5-only mode)':(_fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)'));\r
+ if (_fV > 8) {\r
+ _s.defaultOptions = _mixin(_s.defaultOptions, _s.flash9Options);\r
+ _s.features.buffering = true;\r
+ _s.defaultOptions = _mixin(_s.defaultOptions, _s.movieStarOptions);\r
+ _s.filePatterns.flash9 = new RegExp('\\.(mp3|' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
+ _s.features.movieStar = true;\r
+ } else {\r
+ _s.features.movieStar = false;\r
+ }\r
+ _s.filePattern = _s.filePatterns[(_fV !== 8?'flash9':'flash8')];\r
+ _s.movieURL = (_fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug);\r
+ _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_fV > 8);\r
+ };\r
+ _setPolling = function(bPolling, bHighPerformance) {\r
+ if (!_s.o) {\r
+ return false;\r
+ }\r
+ _s.o._setPolling(bPolling, bHighPerformance);\r
+ };\r
+ _initDebug = function() {\r
+ if (_s.debugURLParam.test(_wl)) {\r
+ _s.debugMode = true;\r
+ }\r
+ };\r
+ _idCheck = this.getSoundById;\r
+ _getSWFCSS = function() {\r
+ var css = [];\r
+ if (_s.debugMode) {\r
+ css.push(_s.swfCSS.sm2Debug);\r
+ }\r
+ if (_s.debugFlash) {\r
+ css.push(_s.swfCSS.flashDebug);\r
+ }\r
+ if (_s.useHighPerformance) {\r
+ css.push(_s.swfCSS.highPerf);\r
+ }\r
+ return css.join(' ');\r
+ };\r
+ _flashBlockHandler = function() {\r
+ var name = _str('fbHandler'),\r
+ p = _s.getMoviePercent(),\r
+ css = _s.swfCSS,\r
+ error = {type:'FLASHBLOCK'};\r
+ if (_s.html5Only) {\r
+ return false;\r
+ }\r
+ if (!_s.ok()) {\r
+ if (_needsFlash) {\r
+ _s.oMC.className = _getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);\r
+ }\r
+ _s.didFlashBlock = true;\r
+ _processOnEvents({type:'ontimeout', ignoreInit:true, error:error});\r
+ _catchError(error);\r
+ } else {\r
+ if (_s.didFlashBlock) {\r
+ }\r
+ if (_s.oMC) {\r
+ _s.oMC.className = [_getSWFCSS(), css.swfDefault, css.swfLoaded + (_s.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');\r
+ }\r
+ }\r
+ };\r
+ _addOnEvent = function(sType, oMethod, oScope) {\r
+ if (typeof _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: 'onready'\r
+ };\r
+ }\r
+ if (!_didInit && oOptions && !oOptions.ignoreInit) {\r
+ return false;\r
+ }\r
+ if (oOptions.type === 'ontimeout' && _s.ok()) {\r
+ return false;\r
+ }\r
+ var status = {\r
+ success: (oOptions && oOptions.ignoreInit?_s.ok():!_disabled)\r
+ },\r
+ srcQueue = (oOptions && oOptions.type?_on_queue[oOptions.type]||[]:[]),\r
+ queue = [], i, j,\r
+ args = [status],\r
+ canRetry = (_needsFlash && _s.useFlashBlock && !_s.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
+ _win.setTimeout(function() {\r
+ if (_s.useFlashBlock) {\r
+ _flashBlockHandler();\r
+ }\r
+ _processOnEvents();\r
+ if (_s.onload instanceof Function) {\r
+ _s.onload.apply(_win);\r
+ }\r
+ if (_s.waitForWindowLoad) {\r
+ _event.add(_win, '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 = _win.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 (typeof AX !== 'undefined') {\r
+ try {\r
+ obj = new AX('ShockwaveFlash.ShockwaveFlash');\r
+ } catch(e) {\r
+ }\r
+ hasPlugin = (!!obj);\r
+ }\r
+ _hasFlash = hasPlugin;\r
+ return hasPlugin;\r
+ };\r
+ _featureCheck = function() {\r
+ var needsFlash, item,\r
+ isSpecial = (_is_iDevice && !!(_ua.match(/os (1|2|3_0|3_1)/i)));\r
+ if (isSpecial) {\r
+ _s.hasHTML5 = false;\r
+ _s.html5Only = true;\r
+ if (_s.oMC) {\r
+ _s.oMC.style.display = 'none';\r
+ }\r
+ return false;\r
+ }\r
+ if (_s.useHTML5Audio) {\r
+ if (!_s.html5 || !_s.html5.canPlayType) {\r
+ _s.hasHTML5 = false;\r
+ return true;\r
+ } else {\r
+ _s.hasHTML5 = true;\r
+ }\r
+ if (_isBadSafari) {\r
+ if (_detectFlash()) {\r
+ return true;\r
+ }\r
+ }\r
+ } else {\r
+ return true;\r
+ }\r
+ for (item in _s.audioFormats) {\r
+ if (_s.audioFormats.hasOwnProperty(item)) {\r
+ if ((_s.audioFormats[item].required && !_s.html5.canPlayType(_s.audioFormats[item].type)) || _s.flash[item] || _s.flash[_s.audioFormats[item].type]) {\r
+ needsFlash = true;\r
+ }\r
+ }\r
+ }\r
+ if (_s.ignoreFlash) {\r
+ needsFlash = false;\r
+ }\r
+ _s.html5Only = (_s.hasHTML5 && _s.useHTML5Audio && !needsFlash);\r
+ return (!_s.html5Only);\r
+ };\r
+ _startTimer = function(oSound) {\r
+ if (!oSound._hasTimer) {\r
+ oSound._hasTimer = true;\r
+ }\r
+ };\r
+ _stopTimer = function(oSound) {\r
+ if (oSound._hasTimer) {\r
+ oSound._hasTimer = false;\r
+ }\r
+ };\r
+ _catchError = function(options) {\r
+ options = (typeof options !== 'undefined' ? options : {});\r
+ if (_s.onerror instanceof Function) {\r
+ _s.onerror.apply(_win, [{type:(typeof options.type !== 'undefined' ? options.type : null)}]);\r
+ }\r
+ if (typeof options.fatal !== 'undefined' && options.fatal) {\r
+ _s.disable();\r
+ }\r
+ };\r
+ _badSafariFix = function() {\r
+ if (!_isBadSafari || !_detectFlash()) {\r
+ return false;\r
+ }\r
+ var aF = _s.audioFormats, i, item;\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ if (item === 'mp3' || item === 'mp4') {\r
+ _s.html5[item] = false;\r
+ if (aF[item] && aF[item].related) {\r
+ for (i = aF[item].related.length; i--;) {\r
+ _s.html5[aF[item].related[i]] = false;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ };\r
+ this._setSandboxType = function(sandboxType) {\r
+ };\r
+ this._externalInterfaceOK = function(flashDate) {\r
+ if (_s.swfLoaded) {\r
+ return false;\r
+ }\r
+ var eiTime = new Date().getTime();\r
+ _s.swfLoaded = true;\r
+ _tryInitOnFocus = false;\r
+ if (_isBadSafari) {\r
+ _badSafariFix();\r
+ }\r
+ if (_isIE) {\r
+ setTimeout(_init, 100);\r
+ } else {\r
+ _init();\r
+ }\r
+ };\r
+ _createMovie = function(smID, smURL) {\r
+ if (_didAppend && _appendSuccess) {\r
+ return false;\r
+ }\r
+ function _initMsg() {\r
+ }\r
+ if (_s.html5Only) {\r
+ _setVersionInfo();\r
+ _initMsg();\r
+ _s.oMC = _id(_s.movieID);\r
+ _init();\r
+ _didAppend = true;\r
+ _appendSuccess = true;\r
+ return false;\r
+ }\r
+ var remoteURL = (smURL || _s.url),\r
+ localURL = (_s.altURL || remoteURL),\r
+ swfTitle = 'JS/Flash audio component (SoundManager 2)',\r
+ oEmbed, oMovie, oTarget = _getDocument(), tmp, movieHTML, oEl, extraClass = _getSWFCSS(),\r
+ s, x, sClass, side = 'auto', isRTL = null,\r
+ html = _doc.getElementsByTagName('html')[0];\r
+ isRTL = (html && html.dir && html.dir.match(/rtl/i));\r
+ smID = (typeof smID === 'undefined'?_s.id:smID);\r
+ function param(name, value) {\r
+ return '<param name="'+name+'" value="'+value+'" />';\r
+ }\r
+ _setVersionInfo();\r
+ _s.url = _normalizeMovieURL(_overHTTP?remoteURL:localURL);\r
+ smURL = _s.url;\r
+ _s.wmode = (!_s.wmode && _s.useHighPerformance ? 'transparent' : _s.wmode);\r
+ if (_s.wmode !== null && (_ua.match(/msie 8/i) || (!_isIE && !_s.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) {\r
+ _s.specialWmodeCase = true;\r
+ _s.wmode = null;\r
+ }\r
+ oEmbed = {\r
+ 'name': smID,\r
+ 'id': smID,\r
+ 'src': smURL,\r
+ 'width': side,\r
+ 'height': side,\r
+ 'quality': 'high',\r
+ 'allowScriptAccess': _s.allowScriptAccess,\r
+ 'bgcolor': _s.bgColor,\r
+ 'pluginspage': _http+'www.macromedia.com/go/getflashplayer',\r
+ 'title': swfTitle,\r
+ 'type': 'application/x-shockwave-flash',\r
+ 'wmode': _s.wmode,\r
+ 'hasPriority': 'true'\r
+ };\r
+ if (_s.debugFlash) {\r
+ oEmbed.FlashVars = 'debug=1';\r
+ }\r
+ if (!_s.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" width="' + oEmbed.width + '" height="' + oEmbed.height + '">',\r
+ param('movie', smURL),\r
+ param('AllowScriptAccess', _s.allowScriptAccess),\r
+ param('quality', oEmbed.quality),\r
+ (_s.wmode? param('wmode', _s.wmode): ''),\r
+ param('bgcolor', _s.bgColor),\r
+ param('hasPriority', 'true'),\r
+ (_s.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
+ _s.oMC = (_id(_s.movieID) || _doc.createElement('div'));\r
+ if (!_s.oMC.id) {\r
+ _s.oMC.id = _s.movieID;\r
+ _s.oMC.className = _s.swfCSS.swfDefault + ' ' + extraClass;\r
+ s = null;\r
+ oEl = null;\r
+ if (!_s.useFlashBlock) {\r
+ if (_s.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
+ _s.oMC.style.zIndex = 10000;\r
+ }\r
+ if (!_s.debugFlash) {\r
+ for (x in s) {\r
+ if (s.hasOwnProperty(x)) {\r
+ _s.oMC.style[x] = s[x];\r
+ }\r
+ }\r
+ }\r
+ try {\r
+ if (!_isIE) {\r
+ _s.oMC.appendChild(oMovie);\r
+ }\r
+ oTarget.appendChild(_s.oMC);\r
+ if (_isIE) {\r
+ oEl = _s.oMC.appendChild(_doc.createElement('div'));\r
+ oEl.className = _s.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 = _s.oMC.className;\r
+ _s.oMC.className = (sClass?sClass+' ':_s.swfCSS.swfDefault) + (extraClass?' '+extraClass:'');\r
+ _s.oMC.appendChild(oMovie);\r
+ if (_isIE) {\r
+ oEl = _s.oMC.appendChild(_doc.createElement('div'));\r
+ oEl.className = _s.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 (_s.html5Only) {\r
+ _createMovie();\r
+ return false;\r
+ }\r
+ if (_s.o) {\r
+ return false;\r
+ }\r
+ _s.o = _s.getMovie(_s.id);\r
+ if (!_s.o) {\r
+ if (!_oRemoved) {\r
+ _createMovie(_s.id, _s.url);\r
+ } else {\r
+ if (!_isIE) {\r
+ _s.oMC.appendChild(_oRemoved);\r
+ } else {\r
+ _s.oMC.innerHTML = _oRemovedHTML;\r
+ }\r
+ _oRemoved = null;\r
+ _didAppend = true;\r
+ }\r
+ _s.o = _s.getMovie(_s.id);\r
+ }\r
+ if (_s.oninitmovie instanceof Function) {\r
+ setTimeout(_s.oninitmovie, 1);\r
+ }\r
+ return true;\r
+ };\r
+ _delayWaitForEI = function() {\r
+ setTimeout(_waitForEI, 1000);\r
+ };\r
+ _waitForEI = function() {\r
+ if (_waitingForEI) {\r
+ return false;\r
+ }\r
+ _waitingForEI = true;\r
+ _event.remove(_win, 'load', _delayWaitForEI);\r
+ if (_tryInitOnFocus && !_isFocused) {\r
+ return false;\r
+ }\r
+ var p;\r
+ if (!_didInit) {\r
+ p = _s.getMoviePercent();\r
+ }\r
+ setTimeout(function() {\r
+ p = _s.getMoviePercent();\r
+ if (!_didInit && _okToDisable) {\r
+ if (p === null) {\r
+ if (_s.useFlashBlock || _s.flashLoadTimeout === 0) {\r
+ if (_s.useFlashBlock) {\r
+ _flashBlockHandler();\r
+ }\r
+ } else {\r
+ _failSafely(true);\r
+ }\r
+ } else {\r
+ if (_s.flashLoadTimeout === 0) {\r
+ } else {\r
+ _failSafely(true);\r
+ }\r
+ }\r
+ }\r
+ }, _s.flashLoadTimeout);\r
+ };\r
+ _handleFocus = function() {\r
+ function cleanup() {\r
+ _event.remove(_win, 'focus', _handleFocus);\r
+ _event.remove(_win, 'load', _handleFocus);\r
+ }\r
+ if (_isFocused || !_tryInitOnFocus) {\r
+ cleanup();\r
+ return true;\r
+ }\r
+ _okToDisable = true;\r
+ _isFocused = true;\r
+ if (_isSafari && _tryInitOnFocus) {\r
+ _event.remove(_win, 'mousemove', _handleFocus);\r
+ }\r
+ _waitingForEI = false;\r
+ cleanup();\r
+ return true;\r
+ };\r
+ _showSupport = function() {\r
+ var item, tests = [];\r
+ if (_s.useHTML5Audio && _s.hasHTML5) {\r
+ for (item in _s.audioFormats) {\r
+ if (_s.audioFormats.hasOwnProperty(item)) {\r
+ tests.push(item + ': ' + _s.html5[item] + (!_s.html5[item] && _hasFlash && _s.flash[item] ? ' (using flash)' : (_s.preferFlash && _s.flash[item] && _hasFlash ? ' (preferring flash)': (!_s.html5[item] ? ' (' + (_s.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : ''))));\r
+ }\r
+ }\r
+ }\r
+ };\r
+ _initComplete = function(bNoDisable) {\r
+ if (_didInit) {\r
+ return false;\r
+ }\r
+ if (_s.html5Only) {\r
+ _didInit = true;\r
+ _initUserOnload();\r
+ return true;\r
+ }\r
+ var wasTimeout = (_s.useFlashBlock && _s.flashLoadTimeout && !_s.getMoviePercent()),\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 (_s.useFlashBlock && _s.oMC) {\r
+ _s.oMC.className = _getSWFCSS() + ' ' + (_s.getMoviePercent() === null?_s.swfCSS.swfTimedout:_s.swfCSS.swfError);\r
+ }\r
+ _processOnEvents({type:'ontimeout', error:error});\r
+ _catchError(error);\r
+ return false;\r
+ } else {\r
+ }\r
+ if (_s.waitForWindowLoad && !_windowLoaded) {\r
+ _event.add(_win, 'load', _initUserOnload);\r
+ return false;\r
+ } else {\r
+ _initUserOnload();\r
+ }\r
+ return true;\r
+ };\r
+ _init = function() {\r
+ if (_didInit) {\r
+ return false;\r
+ }\r
+ function _cleanup() {\r
+ _event.remove(_win, 'load', _s.beginDelayedInit);\r
+ }\r
+ if (_s.html5Only) {\r
+ if (!_didInit) {\r
+ _cleanup();\r
+ _s.enabled = true;\r
+ _initComplete();\r
+ }\r
+ return true;\r
+ }\r
+ _initMovie();\r
+ try {\r
+ _s.o._externalInterfaceTest(false);\r
+ _setPolling(true, (_s.flashPollingInterval || (_s.useHighPerformance ? 10 : 50)));\r
+ if (!_s.debugMode) {\r
+ _s.o._disableDebug();\r
+ }\r
+ _s.enabled = true;\r
+ if (!_s.html5Only) {\r
+ _event.add(_win, '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
+ _initDebug();\r
+ if (!_hasFlash && _s.hasHTML5) {\r
+ _s.useHTML5Audio = true;\r
+ _s.preferFlash = false;\r
+ }\r
+ _testHTML5();\r
+ _s.html5.usingFlash = _featureCheck();\r
+ _needsFlash = _s.html5.usingFlash;\r
+ _showSupport();\r
+ if (!_hasFlash && _needsFlash) {\r
+ _s.flashLoadTimeout = 1;\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
+ _detectFlash();\r
+ _event.add(_win, 'focus', _handleFocus);\r
+ _event.add(_win, 'load', _handleFocus);\r
+ _event.add(_win, 'load', _delayWaitForEI);\r
+ if (_isSafari && _tryInitOnFocus) {\r
+ _event.add(_win, 'mousemove', _handleFocus);\r
+ }\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
+ if (_doc.readyState === 'complete') {\r
+ setTimeout(_domContentLoaded,100);\r
+ }\r
+}\r
+// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading\r
+if (typeof 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
/** @license\r
+ *\r
* SoundManager 2: JavaScript Sound for the Web\r
* ----------------------------------------------\r
* http://schillmania.com/projects/soundmanager2/\r
* Code provided under the BSD License:\r
* http://schillmania.com/projects/soundmanager2/license.txt\r
*\r
- * V2.97a.20110424\r
+ * V2.97a.20111030\r
*/\r
\r
-/*jslint white: false, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, regexp: false, newcap: true, immed: true */\r
/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio */\r
+/* jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: 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 (~10KB 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
\r
(function(window) {\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
+ // Top-level configuration options\r
+\r
this.flashVersion = 8; // version of flash to require, either 8 or 9. Some API features require Flash 9.\r
this.debugMode = true; // enable debugging output (div#soundmanager-debug, OR console if available+configured)\r
this.debugFlash = false; // enable debugging output inside SWF, troubleshoot Flash/browser issues\r
this.useConsole = true; // use firebug/safari console.log()-type debug console if available\r
this.consoleOnly = false; // if console is being used, do not create/write to #soundmanager-debug\r
this.waitForWindowLoad = false; // force SM2 to wait for window.onload() before trying to call soundManager.onload()\r
- this.nullURL = 'about:blank'; // path to "null" (empty) MP3 file, used to unload sounds (Flash 8 only)\r
- this.allowPolling = true; // allow flash to poll for status update (required for whileplaying() events, peak, sound spectrum functions to work.)\r
- this.useFastPolling = false; // uses lower flash timer interval for higher callback frequency, best combined with useHighPerformance\r
- this.useMovieStar = true; // enable support for Flash 9.0r115+ (codename "MovieStar") MPEG4 audio formats (AAC, M4V, FLV, MOV etc.)\r
this.bgColor = '#ffffff'; // movie (.swf) background color, eg. '#000000'\r
this.useHighPerformance = false; // position:fixed flash movie can help increase js/flash speed, minimize lag\r
- this.flashPollingInterval = null; // msec for polling interval. Defaults to 50 unless useFastPolling = true.\r
+ this.flashPollingInterval = null; // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used.\r
this.flashLoadTimeout = 1000; // msec to wait for flash movie to load before failing (0 = infinity)\r
this.wmode = null; // string: flash rendering mode - null, transparent, opaque (last two allow layering of HTML on top)\r
this.allowScriptAccess = 'always'; // for scripting the SWF (object/embed property), either 'always' or 'sameDomain'\r
this.useFlashBlock = false; // *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable.\r
- this.useHTML5Audio = false; // Beta feature: Use HTML5 Audio() where API is supported (most Safari, Chrome versions), Firefox (no MP3/MP4.) Ideally, transparent vs. Flash API where possible.\r
- this.html5Test = /^probably$/i; // HTML5 Audio().canPlayType() test. /^(probably|maybe)$/i if you want to be more liberal/risky.\r
- this.useGlobalHTML5Audio = true; // (experimental) if true, re-use single HTML5 audio object across all sounds. Enabled by default on mobile devices/iOS.\r
- this.requireFlash = false; // (experimental) if true, prevents "HTML5-only" mode when flash present. Allows flash to handle RTMP/serverURL, but HTML5 for other cases\r
+ this.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
+ this.html5Test = /^(probably|maybe)$/i; // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative.\r
+ this.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
+ this.noSWFCache = false; // if true, appends ?ts={date} to break aggressive SWF caching.\r
\r
this.audioFormats = {\r
- // determines HTML5 support, flash requirements\r
- // eg. if MP3 or MP4 required, Flash fallback is used if HTML5 can't play it\r
- // shotgun approach to MIME testing due to browser variance\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
+ * multiple MIME types may be tested while trying to get a positive canPlayType() response.\r
+ */\r
+\r
'mp3': {\r
- 'type': ['audio/mpeg; codecs="mp3"','audio/mpeg','audio/mp3','audio/MPA','audio/mpa-robust'],\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'], // 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': true\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
+\r
'ogg': {\r
'type': ['audio/ogg; codecs=vorbis'],\r
'required': false\r
},\r
+\r
'wav': {\r
- 'type': ['audio/wav; codecs="1"','audio/wav','audio/wave','audio/x-wav'],\r
+ 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],\r
'required': false\r
}\r
+\r
};\r
\r
this.defaultOptions = {\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
- 'stream': true, // allows playing before entire file has loaded (recommended)\r
- 'autoPlay': false, // enable playing of file as soon as possible (much faster if "stream" is true)\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
- '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
- 'onbeforefinish': null, // callback for "before sound finished playing (at [time])"\r
- 'onbeforefinishtime': 5000, // offset (milliseconds) before end of sound to trigger beforefinish (eg. 1000 msec = 1 second)\r
- 'onbeforefinishcomplete': null,// function to call when said sound finishes playing\r
- 'onjustbeforefinish': null, // callback for [n] msec before end of current sound\r
- 'onjustbeforefinishtime': 200, // [n] - if not using, set to 0 (or null handler) and event will not fire.\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
- '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
- this.flash9Options = { // flash 9-only options, merged into defaultOptions if flash 9 is being used\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
+ 'stream': true, // allows playing before entire file has loaded (recommended)\r
+ 'autoPlay': false, // enable playing of file as soon as possible (much faster if "stream" is true)\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
+ '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
+ '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) - WARNING: CPU-INTENSIVE: may set CPUs on fire.\r
- 'useEQData': false, // enable sound EQ (frequency spectrum data) - WARNING: Also CPU-intensive.\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 = { // flash 9.0r115+ MPEG4 audio options, merged into defaultOptions if flash 9+movieStar mode is enabled\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
+ 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.version = null;\r
- this.versionNumber = 'V2.97a.20110424';\r
- this.movieURL = null;\r
- this.url = (smURL || null);\r
- this.altURL = null;\r
- this.swfLoaded = false;\r
- this.enabled = false;\r
- this.o = null;\r
+ // HTML attributes (id + class names) for the SWF container\r
+\r
this.movieID = 'sm2-container';\r
this.id = (smID || 'sm2movie');\r
+\r
this.swfCSS = {\r
+\r
'swfBox': 'sm2-object-box',\r
'swfDefault': 'movieContainer',\r
'swfError': 'swf_error', // SWF loaded, but SM2 couldn't start (other error)\r
'sm2Debug': 'sm2_debug',\r
'highPerf': 'high_performance',\r
'flashDebug': 'flash_debug'\r
+\r
};\r
+\r
+ this.debugID = 'soundmanager-debug';\r
+ this.debugURLParam = /([#?&])debug=1/i;\r
+\r
+ // dynamic attributes\r
+\r
+ this.versionNumber = 'V2.97a.20111030';\r
+ this.version = null;\r
+ this.movieURL = null;\r
+ this.url = (smURL || null);\r
+ this.altURL = null;\r
+ this.swfLoaded = false;\r
+ this.enabled = false;\r
+ this.o = null;\r
this.oMC = null;\r
this.sounds = {};\r
this.soundIDs = [];\r
this.muted = false;\r
- this.debugID = 'soundmanager-debug';\r
- this.debugURLParam = /([#?&])debug=1/i;\r
this.specialWmodeCase = false;\r
this.didFlashBlock = false;\r
-\r
this.filePattern = null;\r
+\r
this.filePatterns = {\r
+\r
'flash8': /\.mp3(\?.*)?$/i,\r
'flash9': /\.mp3(\?.*)?$/i\r
+\r
};\r
\r
- this.baseMimeTypes = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; // mp3\r
- this.netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; // mp3, mp4, aac etc.\r
- this.netStreamTypes = ['aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'mp4v', '3gp', '3g2']; // Flash v9.0r115+ "moviestar" formats\r
- this.netStreamPattern = new RegExp('\\.(' + this.netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
- this.mimePattern = this.baseMimeTypes;\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
'noRemote': null,\r
'noLocal': null\r
// </d>\r
+\r
};\r
\r
- this.hasHTML5 = null; // switch for handling logic\r
- this.html5 = { // stores canPlayType() results, etc. treat as read-only.\r
- // mp3: boolean\r
- // mp4: boolean\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
+ return (typeof Audio !== 'undefined' && typeof new Audio().canPlayType !== 'undefined');\r
+ } catch(e) {\r
+ return false;\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
+ this.flash = {};\r
+\r
+ this.html5Only = false; // determined at init time\r
this.ignoreFlash = false; // used for special cases (eg. iPad/iPhone/palm OS?)\r
\r
- // --- private SM2 internals ---\r
+ /**\r
+ * a few private internals (OK, a lot. :D)\r
+ */\r
\r
var SMSound,\r
- _s = this, _sm = 'soundManager', _smc = _sm+'::', _h5 = 'HTML5::', _id, _ua = navigator.userAgent, _win = window, _wl = _win.location.href.toString(), _fV = this.flashVersion, _doc = document, _doNothing, _init, _on_queue = [], _debugOpen = true, _debugTS, _didAppend = false, _appendSuccess = false, _didInit = false, _disabled = false, _windowLoaded = false, _wDS, _wdCount = 0, _initComplete, _mixin, _addOnEvent, _processOnEvents, _initUserOnload, _go, _delayWaitForEI, _waitForEI, _setVersionInfo, _handleFocus, _beginInit, _strings, _initMovie, _dcLoaded, _didDCLoaded, _getDocument, _createMovie, _die, _setPolling, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _smTimer, _onTimer, _startTimer, _stopTimer, _needsFlash = null, _featureCheck, _html5OK, _html5Only = false, _html5CanPlay, _html5Ext, _dcIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix,\r
- _is_pre = _ua.match(/pre\//i), _is_iDevice = _ua.match(/(ipad|iphone|ipod)/i), _isMobile = (_ua.match(/mobile/i) || _is_pre || _is_iDevice), _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
- _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && _ua.match(/OS X 10_6_([3-9])/i)), // Safari 4 and 5 occasionally fail to load/play HTML5 audio on Snow Leopard due to bug(s) in QuickTime X and/or other underlying frameworks. :/ Known Apple "radar" bug. https://bugs.webkit.org/show_bug.cgi?id=32159\r
- _hasConsole = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (typeof _doc.hasFocus === 'undefined' && _isSafari), _okToDisable = !_tryInitOnFocus;\r
-\r
- this._use_maybe = (_wl.match(/sm2\-useHTML5Maybe\=1/i)); // temporary feature: #sm2-useHTML5Maybe=1 forces loose canPlay() check\r
- this._overHTTP = (_doc.location?_doc.location.protocol.match(/http/i):null);\r
- this._http = (!this._overHTTP ? 'http:' : '');\r
- this.useAltURL = !this._overHTTP; // use altURL if not "online"\r
+ _s = this, _sm = 'soundManager', _smc = _sm+'::', _h5 = 'HTML5::', _id, _ua = navigator.userAgent, _win = window, _wl = _win.location.href.toString(), _doc = document, _doNothing, _init, _fV, _on_queue = [], _debugOpen = true, _debugTS, _didAppend = false, _appendSuccess = false, _didInit = false, _disabled = false, _windowLoaded = false, _wDS, _wdCount = 0, _initComplete, _mixin, _addOnEvent, _processOnEvents, _initUserOnload, _delayWaitForEI, _waitForEI, _setVersionInfo, _handleFocus, _strings, _initMovie, _domContentLoaded, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _smTimer, _onTimer, _startTimer, _stopTimer, _needsFlash = null, _featureCheck, _html5OK, _html5CanPlay, _html5Ext, _html5Unload, _domContentLoadedIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix, _html5_events, _showSupport,\r
+ _is_iDevice = _ua.match(/(ipad|iphone|ipod)/i), _is_firefox = _ua.match(/firefox/i), _is_android = _ua.match(/droid/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
+ _likesHTML5 = (_ua.match(/(mobile|pre\/|xoom)/i) || _is_iDevice),\r
+ _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && _ua.match(/OS X 10_6_([3-7])/i)), // Safari 4 and 5 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 = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (_isSafari && typeof _doc.hasFocus === 'undefined'), _okToDisable = !_tryInitOnFocus, _flashMIME = /(mp3|mp4|mpa)/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|mp4v|3gp|3g2)\s*(?:$|;)/i,\r
+ // Flash v9.0r115+ "moviestar" formats\r
+ _netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'mp4v', '3gp', '3g2'],\r
+ _netStreamPattern = new RegExp('\\.(' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\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
this._global_a = null;\r
\r
- if (_is_iDevice || _is_pre) {\r
- // during HTML5 beta period (off by default), may as well force it on Apple + Palm, flash support unlikely\r
+ if (_likesHTML5) {\r
+\r
+ // prefer HTML5 for mobile + tablet-like devices, probably more reliable vs. flash at this point.\r
_s.useHTML5Audio = true;\r
- _s.ignoreFlash = true;\r
- if (_s.useGlobalHTML5Audio) {\r
+ _s.preferFlash = false;\r
+\r
+ if (_is_iDevice) {\r
+ // by default, use global feature. iOS onfinish() -> next may fail otherwise.\r
+ _s.ignoreFlash = true;\r
_useGlobalHTML5Audio = true;\r
}\r
- }\r
\r
- if (_is_pre || this._use_maybe) {\r
- // less-strict canPlayType() checking option\r
- _s.html5Test = /^(probably|maybe)$/i;\r
}\r
\r
- // Temporary feature: allow force of HTML5 via URL: #sm2-usehtml5audio=0 or 1\r
- // <d>\r
- (function(){\r
- var a = '#sm2-usehtml5audio=', l = _wl, b = null;\r
- if (l.indexOf(a) !== -1) {\r
- b = (l.charAt(l.indexOf(a)+a.length) === '1');\r
- if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {\r
- console.log((b?'Enabling ':'Disabling ')+'useHTML5Audio via URL parameter');\r
- }\r
- _s.useHTML5Audio = b;\r
- }\r
- }());\r
- // </d>\r
-\r
- // --- public API methods ---\r
+ /**\r
+ * Public SoundManager API\r
+ * -----------------------\r
+ */\r
\r
this.ok = function() {\r
+\r
return (_needsFlash?(_didInit && !_disabled):(_s.useHTML5Audio && _s.hasHTML5));\r
+\r
};\r
\r
this.supported = this.ok; // legacy\r
\r
this.getMovie = function(smID) {\r
- return _isIE?_win[smID]:(_isSafari?_id(smID) || _doc[smID]:_id(smID));\r
+\r
+ // safety net: some old browsers differ on SWF references, possibly related to ExternalInterface / flash version\r
+ return _id(smID) || _doc[smID] || _win[smID];\r
+\r
};\r
\r
+ /**\r
+ * Creates a SMSound sound object instance.\r
+ *\r
+ * @param {object} oOptions Sound options (at minimum, id and url are required.)\r
+ * @return {object} SMSound The new SMSound object.\r
+ */\r
+\r
this.createSound = function(oOptions) {\r
+\r
var _cs = _sm+'.createSound(): ',\r
thisOptions = null, oSound = null, _tO = null;\r
+\r
if (!_didInit || !_s.ok()) {\r
_complain(_cs + _str(!_didInit?'notReady':'notOK'));\r
return false;\r
}\r
+\r
if (arguments.length === 2) {\r
// function overloading in JS! :) ..assume simple createSound(id,url) use case\r
oOptions = {\r
'url': arguments[1]\r
};\r
}\r
- thisOptions = _mixin(oOptions); // inherit from defaultOptions\r
- _tO = thisOptions; // alias\r
+\r
+ // inherit from defaultOptions\r
+ thisOptions = _mixin(oOptions);\r
+\r
+ // alias\r
+ _tO = thisOptions;\r
+\r
// <d>\r
if (_tO.id.toString().charAt(0).match(/^[0-9]$/)) {\r
_s._wD(_cs + _str('badID', _tO.id), 2);\r
}\r
+\r
_s._wD(_cs + _tO.id + ' (' + _tO.url + ')', 1);\r
// </d>\r
+\r
if (_idCheck(_tO.id, true)) {\r
_s._wD(_cs + _tO.id + ' exists', 1);\r
return _s.sounds[_tO.id];\r
}\r
\r
function make() {\r
+\r
thisOptions = _loopFix(thisOptions);\r
_s.sounds[_tO.id] = new SMSound(_tO);\r
_s.soundIDs.push(_tO.id);\r
return _s.sounds[_tO.id];\r
+\r
}\r
\r
if (_html5OK(_tO)) {\r
+\r
oSound = make();\r
_s._wD('Loading sound '+_tO.id+' via HTML5');\r
oSound._setup_html5(_tO);\r
+\r
} else {\r
- if (_fV > 8 && _s.useMovieStar) {\r
+\r
+ if (_fV > 8) {\r
if (_tO.isMovieStar === null) {\r
- _tO.isMovieStar = ((_tO.serverURL || (_tO.type?_tO.type.match(_s.netStreamPattern):false)||_tO.url.match(_s.netStreamPattern))?true:false);\r
+ // attempt to detect MPEG-4 formats\r
+ _tO.isMovieStar = (_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern));\r
}\r
+ // <d>\r
if (_tO.isMovieStar) {\r
_s._wD(_cs + 'using MovieStar handling');\r
}\r
+ // </d>\r
if (_tO.isMovieStar) {\r
if (_tO.usePeakData) {\r
_wDS('noPeak');\r
_tO.usePeakData = false;\r
}\r
+ // <d>\r
if (_tO.loops > 1) {\r
_wDS('noNSLoop');\r
}\r
+ // </d>\r
}\r
}\r
+\r
_tO = _policyFix(_tO, _cs);\r
oSound = make();\r
+\r
if (_fV === 8) {\r
- _s.o._createSound(_tO.id, _tO.onjustbeforefinishtime, _tO.loops||1, _tO.usePolicyFile);\r
+ _s.o._createSound(_tO.id, _tO.loops||1, _tO.usePolicyFile);\r
} else {\r
- _s.o._createSound(_tO.id, _tO.url, _tO.onjustbeforefinishtime, _tO.usePeakData, _tO.useWaveformData, _tO.useEQData, _tO.isMovieStar, (_tO.isMovieStar?_tO.bufferTime:false), _tO.loops||1, _tO.serverURL, _tO.duration||null, _tO.autoPlay, true, _tO.autoLoad, _tO.usePolicyFile);\r
+ _s.o._createSound(_tO.id, _tO.url, _tO.usePeakData, _tO.useWaveformData, _tO.useEQData, _tO.isMovieStar, (_tO.isMovieStar?_tO.bufferTime:false), _tO.loops||1, _tO.serverURL, _tO.duration||null, _tO.autoPlay, true, _tO.autoLoad, _tO.usePolicyFile);\r
if (!_tO.serverURL) {\r
// We are connected immediately\r
oSound.connected = true;\r
}\r
}\r
\r
- if ((_tO.autoLoad || _tO.autoPlay) && !_tO.serverURL) {\r
- oSound.load(_tO); // call load for non-rtmp streams\r
+ if (!_tO.serverURL && (_tO.autoLoad || _tO.autoPlay)) {\r
+ // call load for non-rtmp streams\r
+ oSound.load(_tO);\r
}\r
+\r
}\r
\r
- if (_tO.autoPlay && !_tO.serverURL) { // rtmp will play in onconnect\r
+ // rtmp will play in onconnect\r
+ if (!_tO.serverURL && _tO.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 = _s.sounds[sID], i;\r
- oS._iO = {}; // Disable all callbacks while the sound is being destroyed\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 < _s.soundIDs.length; i++) {\r
if (_s.soundIDs[i] === sID) {\r
_s.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 _s.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 _s.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
+\r
return _s.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 _s.sounds[sID].onposition(nPosition, oMethod, oScope);\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 fN = _sm+'.play(): ';\r
+\r
if (!_didInit || !_s.ok()) {\r
_complain(fN + _str(!_didInit?'notReady':'notOK'));\r
return false;\r
}\r
+\r
if (!_idCheck(sID)) {\r
if (!(oOptions instanceof Object)) {\r
oOptions = {\r
return false;\r
}\r
}\r
+\r
return _s.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
}\r
return _s.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
_s._wD(_sm+'.stop(' + sID + ')', 1);\r
return _s.sounds[sID].stop();\r
+\r
};\r
\r
+ /**\r
+ * Stops all currently-playing sounds.\r
+ */\r
+\r
this.stopAll = function() {\r
+\r
+ var oSound;\r
_s._wD(_sm+'.stopAll()', 1);\r
- for (var oSound in _s.sounds) {\r
- if (_s.sounds[oSound] instanceof SMSound) {\r
- _s.sounds[oSound].stop(); // apply only to sound objects\r
+\r
+ for (oSound in _s.sounds) {\r
+ if (_s.sounds.hasOwnProperty(oSound)) {\r
+ // apply only to sound objects\r
+ _s.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 _s.sounds[sID].pause();\r
+\r
};\r
\r
+ /**\r
+ * Pauses all currently-playing sounds.\r
+ */\r
+\r
this.pauseAll = function() {\r
- for (var i = _s.soundIDs.length; i--;) {\r
+\r
+ var i;\r
+ for (i = _s.soundIDs.length; i--;) {\r
_s.sounds[_s.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 _s.sounds[sID].resume();\r
+\r
};\r
\r
+ /**\r
+ * Resumes all currently-paused sounds.\r
+ */\r
+\r
this.resumeAll = function() {\r
- for (var i = _s.soundIDs.length; i--;) {\r
+\r
+ var i;\r
+ for (i = _s.soundIDs.length; i--;) {\r
_s.sounds[_s.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 _s.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 _s.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 _s.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 fN = _sm+'.mute(): ',\r
i = 0;\r
+\r
if (typeof sID !== 'string') {\r
sID = null;\r
}\r
+\r
if (!sID) {\r
_s._wD(fN + 'Muting all sounds');\r
for (i = _s.soundIDs.length; i--;) {\r
_s._wD(fN + 'Muting "' + sID + '"');\r
return _s.sounds[sID].mute();\r
}\r
+\r
return true;\r
+\r
};\r
\r
+ /**\r
+ * Mutes all sounds.\r
+ */\r
+\r
this.muteAll = function() {\r
+\r
_s.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 fN = _sm+'.unmute(): ', i;\r
+\r
if (typeof sID !== 'string') {\r
sID = null;\r
}\r
+\r
if (!sID) {\r
+\r
_s._wD(fN + 'Unmuting all sounds');\r
for (i = _s.soundIDs.length; i--;) {\r
_s.sounds[_s.soundIDs[i]].unmute();\r
}\r
_s.muted = false;\r
+\r
} else {\r
+\r
if (!_idCheck(sID)) {\r
return false;\r
}\r
_s._wD(fN + 'Unmuting "' + sID + '"');\r
return _s.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
_s.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
+\r
return _s.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
- if (_fV === 8) {\r
- return 0;\r
- }\r
- if (_s.o) {\r
- return parseInt(_s.o._getMemoryUse(), 10);\r
+\r
+ // flash-only\r
+ var ram = 0;\r
+\r
+ if (_s.o && _fV !== 8) {\r
+ ram = parseInt(_s.o._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 (typeof bNoDisable === 'undefined') {\r
bNoDisable = false;\r
}\r
+\r
if (_disabled) {\r
return false;\r
}\r
+\r
_disabled = true;\r
_wDS('shutdown', 1);\r
- for (var i = _s.soundIDs.length; i--;) {\r
+\r
+ for (i = _s.soundIDs.length; i--;) {\r
_disableObject(_s.sounds[_s.soundIDs[i]]);\r
}\r
- _initComplete(bNoDisable); // fire "complete", despite fail\r
+\r
+ // fire "complete", despite fail\r
+ _initComplete(bNoDisable);\r
_event.remove(_win, '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 (_s.hasHTML5) {\r
result = _html5CanPlay({type:sMIME});\r
}\r
+\r
if (!_needsFlash || result) {\r
// no flash, or OK\r
return result;\r
} else {\r
- return (sMIME?(sMIME.match(_s.mimePattern)?true:false):null);\r
+ // if flash 9, test netStream (movieStar) types as well.\r
+ return (sMIME ? !!((_fV > 8 ? sMIME.match(_netStreamMimeTypes) : null) || sMIME.match(_s.mimePattern)) : null);\r
}\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 (_s.hasHTML5) {\r
- result = _html5CanPlay(sURL);\r
+ result = _html5CanPlay({url: sURL});\r
}\r
+\r
if (!_needsFlash || result) {\r
// no flash, or OK\r
return result;\r
} else {\r
- return (sURL?(sURL.match(_s.filePattern)?true:false):null);\r
+ return (sURL ? !!(sURL.match(_s.filePattern)) : null);\r
}\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 (typeof oLink.type !== 'undefined' && oLink.type) {\r
if (_s.canPlayMIME(oLink.type)) {\r
return true;\r
}\r
}\r
+\r
return _s.canPlayURL(oLink.href);\r
+\r
};\r
\r
- this.getSoundById = function(sID, suppressDebug) {\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 = _s.sounds[sID];\r
- if (!result && !suppressDebug) {\r
+\r
+ // <d>\r
+ if (!result && !_suppressDebug) {\r
_s._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
+\r
if (oMethod && oMethod instanceof Function) {\r
+\r
+ // <d>\r
if (_didInit) {\r
- _wDS('queue', sType);\r
+ _s._wD(_str('queue', sType));\r
}\r
+ // </d>\r
+\r
if (!oScope) {\r
oScope = _win;\r
}\r
+\r
_addOnEvent(sType, oMethod, oScope);\r
_processOnEvents();\r
+\r
return true;\r
+\r
} else {\r
+\r
throw _str('needFunction', sType);\r
+\r
}\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
+\r
if (oMethod && oMethod instanceof Function) {\r
+\r
+ // <d>\r
if (_didInit) {\r
- _wDS('queue');\r
+ _s._wD(_str('queue', sType));\r
}\r
- if (!oScope) {\r
+ // </d>\r
+\r
+ if (!oScope) {\r
oScope = _win;\r
}\r
+\r
_addOnEvent(sType, oMethod, oScope);\r
_processOnEvents({type:sType});\r
+\r
return true;\r
+\r
} else {\r
+\r
throw _str('needFunction', sType);\r
+\r
}\r
- };\r
\r
- this.getMoviePercent = function() {\r
- return (_s.o && typeof _s.o.PercentLoaded !== 'undefined'?_s.o.PercentLoaded():null);\r
};\r
\r
- this._writeDebug = function(sText, sType, bTimestamp) {\r
+ /**\r
+ * Writes console.log()-style debug output to a console or in-browser element.\r
+ * Applies when SoundManager.debugMode = true\r
+ *\r
+ * @param {string} sText The console message\r
+ * @param {string} sType Optional: Log type of 'info', 'warn' or 'error'\r
+ * @param {object} Optional: The scope to apply to the callback\r
+ */\r
+\r
+ this._writeDebug = function(sText, sType, _bTimestamp) {\r
+\r
// pseudo-private console.log()-style output\r
// <d>\r
+\r
var sDID = 'soundmanager-debug', o, oItem, sMethod;\r
+\r
if (!_s.debugMode) {\r
return false;\r
}\r
- if (typeof bTimestamp !== 'undefined' && bTimestamp) {\r
+\r
+ if (typeof _bTimestamp !== 'undefined' && _bTimestamp) {\r
sText = sText + ' | ' + new Date().getTime();\r
}\r
+\r
if (_hasConsole && _s.useConsole) {\r
sMethod = _debugLevels[sType];\r
if (typeof console[sMethod] !== 'undefined') {\r
return true;\r
}\r
}\r
+\r
try {\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 (typeof sType === 'undefined') {\r
sType = 0;\r
} else {\r
sType = parseInt(sType, 10);\r
}\r
+\r
oItem.appendChild(_doc.createTextNode(sText));\r
+\r
if (sType) {\r
if (sType >= 2) {\r
oItem.style.fontWeight = 'bold';\r
oItem.style.color = '#ff3333';\r
}\r
}\r
- // o.appendChild(oItem); // top-to-bottom\r
- o.insertBefore(oItem, o.firstChild); // bottom-to-top\r
+\r
+ // top-to-bottom\r
+ // o.appendChild(oItem);\r
+\r
+ // bottom-to-top\r
+ o.insertBefore(oItem, o.firstChild);\r
+\r
} catch(e) {\r
// oh well\r
}\r
+\r
o = null;\r
// </d>\r
+\r
return true;\r
+\r
};\r
- this._wD = this._writeDebug; // alias\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
- for (var i = 0, j = _s.soundIDs.length; i < j; i++) {\r
+\r
+ for (i = 0, j = _s.soundIDs.length; i < j; i++) {\r
_s.sounds[_s.soundIDs[i]]._debug();\r
}\r
// </d>\r
+\r
};\r
\r
+ /**\r
+ * Restarts and re-initializes the SoundManager instance.\r
+ */\r
+\r
this.reboot = function() {\r
+\r
// attempt to reset and init SM2\r
_s._wD(_sm+'.reboot()');\r
+\r
+ // <d>\r
if (_s.soundIDs.length) {\r
_s._wD('Destroying ' + _s.soundIDs.length + ' SMSound objects...');\r
}\r
+ // </d>\r
+\r
var i, j;\r
+\r
for (i = _s.soundIDs.length; i--;) {\r
_s.sounds[_s.soundIDs[i]].destruct();\r
}\r
+\r
// trash ze flash\r
+\r
try {\r
if (_isIE) {\r
_oRemovedHTML = _s.o.innerHTML;\r
// uh-oh.\r
_wDS('badRemove', 2);\r
}\r
+\r
// actually, force recreate of movie.\r
- _oRemovedHTML = _oRemoved = null;\r
- _s.enabled = _didInit = _waitingForEI = _initPending = _didAppend = _appendSuccess = _disabled = _s.swfLoaded = false;\r
+ _oRemovedHTML = _oRemoved = _needsFlash = null;\r
+\r
+ _s.enabled = _didDCLoaded = _didInit = _waitingForEI = _initPending = _didAppend = _appendSuccess = _disabled = _s.swfLoaded = false;\r
_s.soundIDs = _s.sounds = [];\r
_s.o = null;\r
+\r
for (i in _on_queue) {\r
if (_on_queue.hasOwnProperty(i)) {\r
for (j = _on_queue[i].length; j--;) {\r
}\r
}\r
}\r
- _s._wD(_sm + ': Rebooting...');\r
- _win.setTimeout(function() {\r
- _s.beginDelayedInit();\r
- }, 20);\r
- };\r
\r
- this.destruct = function() {\r
- _s._wD(_sm+'.destruct()');\r
- _s.disable(true);\r
- };\r
+ _s._wD(_sm + ': Rebooting...');\r
+ _win.setTimeout(_s.beginDelayedInit, 20);\r
\r
- this.beginDelayedInit = function() {\r
- // _s._wD(_sm+'.beginDelayedInit()');\r
- _windowLoaded = true;\r
- _dcLoaded();\r
- setTimeout(_beginInit, 20);\r
- _delayWaitForEI();\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
- // Wrap html5 event handlers so we don't call them on destroyed sounds\r
- function _html5_event(oFn) {\r
- return function(e) {\r
- if (!this._t || !this._t._a) {\r
- if (this._t && this._t.sID) {\r
- _s._wD(_h5+'ignoring '+e.type+': '+this._t.sID);\r
- } else {\r
- _s._wD(_h5+'ignoring '+e.type);\r
- }\r
- return null;\r
- } else {\r
- return oFn.call(this, e);\r
- }\r
- };\r
- }\r
-\r
- this._html5_events = {\r
-\r
- // HTML5 event-name-to-handler map\r
- abort: _html5_event(function(e) {\r
- _s._wD(_h5+'abort: '+this._t.sID);\r
- }),\r
-\r
- // enough has loaded to play\r
- canplay: _html5_event(function(e) {\r
- _s._wD(_h5+'canplay: '+this._t.sID+', '+this._t.url);\r
- this._t._onbufferchange(0);\r
- var position1K = (!isNaN(this._t.position)?this._t.position/1000:null);\r
- // set the position if position was set before the sound loaded\r
- this._t._html5_canplay = true;\r
- if (this._t.position && this.currentTime !== position1K) {\r
- _s._wD(_h5+'canplay: setting position to '+position1K+'');\r
- try {\r
- this.currentTime = position1K;\r
- } catch(ee) {\r
- _s._wD(_h5+'setting position failed: '+ee.message, 2);\r
- }\r
- }\r
- }),\r
-\r
- load: _html5_event(function(e) {\r
- if (!this._t.loaded) {\r
- this._t._onbufferchange(0);\r
- // should be 1, and the same\r
- this._t._whileloading(this._t.bytesTotal, this._t.bytesTotal, this._t._get_html5_duration());\r
- this._t._onload(true);\r
- }\r
- }),\r
-\r
- emptied: _html5_event(function(e) {\r
- _s._wD(_h5+'emptied: '+this._t.sID);\r
- }),\r
-\r
- ended: _html5_event(function(e) {\r
- _s._wD(_h5+'ended: '+this._t.sID);\r
- this._t._onfinish();\r
- }),\r
-\r
- error: _html5_event(function(e) {\r
- _s._wD(_h5+'error: '+this.error.code);\r
- // call load with error state?\r
- this._t._onload(false);\r
- }),\r
+ this.getMoviePercent = function() {\r
\r
- loadeddata: _html5_event(function(e) {\r
- _s._wD(_h5+'loadeddata: '+this._t.sID);\r
- }),\r
+ return (_s.o && typeof _s.o.PercentLoaded !== 'undefined' ? _s.o.PercentLoaded() : null);\r
\r
- loadedmetadata: _html5_event(function(e) {\r
- _s._wD(_h5+'loadedmetadata: '+this._t.sID);\r
- }),\r
+ };\r
\r
- loadstart: _html5_event(function(e) {\r
- _s._wD(_h5+'loadstart: '+this._t.sID);\r
- // assume buffering at first\r
- this._t._onbufferchange(1);\r
- }),\r
+ /**\r
+ * Additional helper for manually invoking SM2's init process after DOM Ready / window.onload().\r
+ */\r
\r
- play: _html5_event(function(e) {\r
- _s._wD(_h5+'play: '+this._t.sID+', '+this._t.url);\r
- // once play starts, no buffering\r
- this._t._onbufferchange(0);\r
- }),\r
+ this.beginDelayedInit = function() {\r
\r
- // TODO: verify if this is actually implemented anywhere yet.\r
- playing: _html5_event(function(e) {\r
- _s._wD(_h5+'playing: '+this._t.sID+', '+this._t.url);\r
- // once play starts, no buffering\r
- this._t._onbufferchange(0);\r
- }),\r
+ _windowLoaded = true;\r
+ _domContentLoaded();\r
\r
- progress: _html5_event(function(e) {\r
+ setTimeout(function() {\r
\r
- if (this._t.loaded) {\r
+ if (_initPending) {\r
return false;\r
}\r
\r
- var i, j, str, loadSum = 0, buffered = 0,\r
- isProgress = (e.type === 'progress'),\r
- ranges = e.target.buffered,\r
- loaded = (e.loaded||0), // firefox 3.6 implements e.loaded/total (bytes)\r
- total = (e.total||1);\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
- for (i=ranges.length; i--;) {\r
- buffered = (ranges.end(i) - ranges.start(i));\r
- }\r
-\r
- // linear case, buffer sum; does not account for seeking and HTTP partials / byte ranges\r
- loaded = buffered/e.target.duration;\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) +'-'+ e.target.buffered.end(i));\r
- }\r
- _s._wD(_h5+'progress: timeRanges: '+str.join(', '));\r
- }\r
- // </d>\r
-\r
- if (isProgress && !isNaN(loaded)) {\r
- _s._wD(_h5+'progress: '+this._t.sID+': ' + Math.floor(loaded*100)+'% loaded');\r
- }\r
-\r
- }\r
-\r
- if (!isNaN(loaded)) {\r
-\r
- this._t._onbufferchange(0); // if progress, likely not buffering\r
- this._t._whileloading(loaded, total, this._t._get_html5_duration());\r
-\r
- if (loaded && total && loaded === total) {\r
- // in case "onload" doesn't fire (eg. gecko 1.9.2)\r
- _s._html5_events.load.call(this, e);\r
- }\r
+ _createMovie();\r
+ _initMovie();\r
+ _initPending = true;\r
\r
- }\r
+ return true;\r
\r
- }),\r
+ }, 20);\r
\r
- ratechange: _html5_event(function(e) {\r
- _s._wD(_h5+'ratechange: '+this._t.sID);\r
- }),\r
+ _delayWaitForEI();\r
\r
- suspend: _html5_event(function(e) {\r
- // download paused/stopped, may have finished (eg. onload)\r
- _s._wD(_h5+'suspend: '+this._t.sID);\r
- _s._html5_events.progress.call(this, e);\r
- }),\r
+ };\r
\r
- stalled: _html5_event(function(e) {\r
- _s._wD(_h5+'stalled: '+this._t.sID);\r
- }),\r
+ /**\r
+ * Destroys the SoundManager instance and all SMSound instances.\r
+ */\r
\r
- timeupdate: _html5_event(function(e) {\r
- this._t._onTimer();\r
- }),\r
+ this.destruct = function() {\r
\r
- waiting: _html5_event(function(e) { // see also: seeking\r
- _s._wD(_h5+'waiting: '+this._t.sID);\r
- // playback faster than download rate, etc.\r
- this._t._onbufferchange(1);\r
- })\r
+ _s._wD(_sm+'.destruct()');\r
+ _s.disable(true);\r
\r
};\r
\r
- // --- SMSound (sound object) instance ---\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 _t = this, _resetProperties, _stop_html5_timer, _start_html5_timer;\r
this.sID = oOptions.id;\r
this.url = oOptions.url;\r
this.options = _mixin(oOptions);\r
- this.instanceOptions = this.options; // per-play-instance-specific options\r
- this._iO = this.instanceOptions; // short alias\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
this.isHTML5 = false;\r
this._a = null;\r
\r
- // --- public methods ---\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
// pseudo-private console.log()-style output\r
+\r
if (_s.debugMode) {\r
+\r
var stuff = null, msg = [], sF, sfBracket, maxLength = 64;\r
+\r
for (stuff in _t.options) {\r
if (_t.options[stuff] !== null) {\r
if (_t.options[stuff] instanceof Function) {\r
// handle functions specially\r
sF = _t.options[stuff].toString();\r
- sF = sF.replace(/\s\s+/g, ' '); // normalize spaces\r
+ // normalize spaces\r
+ sF = sF.replace(/\s\s+/g, ' ');\r
sfBracket = sF.indexOf('{');\r
msg.push(' ' + stuff + ': {' + sF.substr(sfBracket + 1, (Math.min(Math.max(sF.indexOf('\n') - 1, maxLength), maxLength))).replace(/\n/g, '') + '... }');\r
} else {\r
}\r
}\r
}\r
+\r
_s._wD('SMSound() merged options: {\n' + msg.join(', \n') + '\n}');\r
+\r
}\r
// </d>\r
+\r
};\r
\r
+ // <d>\r
this._debug();\r
+ // </d>\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 oS = null;\r
+\r
if (typeof oOptions !== 'undefined') {\r
_t._iO = _mixin(oOptions, _t.options);\r
_t.instanceOptions = _t._iO;\r
_t.url = null;\r
}\r
}\r
+\r
if (!_t._iO.url) {\r
_t._iO.url = _t.url;\r
}\r
+\r
_s._wD('SMSound.load(): ' + _t._iO.url, 1);\r
+\r
if (_t._iO.url === _t.url && _t.readyState !== 0 && _t.readyState !== 2) {\r
_wDS('onURL', 1);\r
return _t;\r
}\r
+\r
_t._lastURL = _t.url;\r
_t.loaded = false;\r
_t.readyState = 1;\r
_t.playState = 0;\r
+\r
+ // TODO: If switching from HTML5 -> flash (or vice versa), stop currently-playing audio.\r
+\r
if (_html5OK(_t._iO)) {\r
+\r
oS = _t._setup_html5(_t._iO);\r
if (!oS._called_load) {\r
_s._wD(_h5+'load: '+_t.sID);\r
+ _t._html5_canplay = false;\r
oS.load();\r
oS._called_load = true;\r
if (_t._iO.autoPlay) {\r
_t.play();\r
}\r
} else {\r
- _s._wD('HTML5 ignoring request to load again: '+_t.sID);\r
+ _s._wD(_h5+'ignoring request to load again: '+_t.sID);\r
}\r
+\r
} else {\r
+\r
try {\r
_t.isHTML5 = false;\r
_t._iO = _policyFix(_loopFix(_t._iO));\r
if (_fV === 8) {\r
_s.o._load(_t.sID, _t._iO.url, _t._iO.stream, _t._iO.autoPlay, (_t._iO.whileloading?1:0), _t._iO.loops||1, _t._iO.usePolicyFile);\r
} else {\r
- _s.o._load(_t.sID, _t._iO.url, _t._iO.stream?true:false, _t._iO.autoPlay?true:false, _t._iO.loops||1, _t._iO.autoLoad?true:false, _t._iO.usePolicyFile);\r
+ _s.o._load(_t.sID, _t._iO.url, !!(_t._iO.stream), !!(_t._iO.autoPlay), _t._iO.loops||1, !!(_t._iO.autoLoad), _t._iO.usePolicyFile);\r
}\r
} catch(e) {\r
_wDS('smError', 2);\r
_debugTS('onload', false);\r
- _die();\r
+ _catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true});\r
+\r
}\r
+\r
}\r
+\r
return _t;\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
- // Flash 8/AS2 can't "close" a stream - fake it by loading an empty MP3\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 (_t.readyState !== 0) {\r
+\r
_s._wD('SMSound.unload(): "' + _t.sID + '"');\r
+\r
if (!_t.isHTML5) {\r
if (_fV === 8) {\r
- _s.o._unload(_t.sID, _s.nullURL);\r
+ _s.o._unload(_t.sID, _emptyURL);\r
} else {\r
_s.o._unload(_t.sID);\r
}\r
} else {\r
_stop_html5_timer();\r
if (_t._a) {\r
- // abort()-style method here, stop loading? (doesn't exist?)\r
_t._a.pause();\r
-// if (!_useGlobalHTML5Audio || (_useGlobalHTML5Audio && _t.playState)) { // if global audio, only unload if actively playing\r
- _t._a.src = ''; // https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Stopping_the_download_of_media\r
-// }\r
+ _html5Unload(_t._a);\r
}\r
}\r
+\r
// reset load/status flags\r
_resetProperties();\r
+\r
}\r
+\r
return _t;\r
+\r
};\r
\r
+ /**\r
+ * Unloads and destroys a sound.\r
+ */\r
+\r
this.destruct = function(_bFromSM) {\r
+\r
_s._wD('SMSound.destruct(): "' + _t.sID + '"');\r
+\r
if (!_t.isHTML5) {\r
+\r
// kill sound within Flash\r
// Disable the onfailure handler\r
_t._iO.onfailure = null;\r
_s.o._destroySound(_t.sID);\r
+\r
} else {\r
+\r
_stop_html5_timer();\r
+\r
if (_t._a) {\r
- // abort()-style method here, stop loading? (doesn't exist?)\r
_t._a.pause();\r
- _t._a.src = ''; // https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Stopping_the_download_of_media\r
+ _html5Unload(_t._a);\r
if (!_useGlobalHTML5Audio) {\r
_t._remove_html5_events();\r
}\r
+ // break obvious circular reference\r
+ _t._a._t = null;\r
+ _t._a = null;\r
}\r
+\r
}\r
+\r
if (!_bFromSM) {\r
- _s.destroySound(_t.sID, true); // ensure deletion from controller\r
+ // ensure deletion from controller\r
+ _s.destroySound(_t.sID, 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
- var fN = 'SMSound.play(): ', allowMulti;\r
- _updatePlayState = _updatePlayState === undefined ? true : _updatePlayState; // default true\r
+\r
+ var fN = 'SMSound.play(): ', allowMulti, a;\r
+\r
+ _updatePlayState = _updatePlayState === undefined ? true : _updatePlayState; // default to true\r
+\r
if (!oOptions) {\r
oOptions = {};\r
}\r
+\r
_t._iO = _mixin(oOptions, _t._iO);\r
_t._iO = _mixin(_t._iO, _t.options);\r
_t.instanceOptions = _t._iO;\r
- if (_t._iO.serverURL) {\r
- if (!_t.connected) {\r
- if (!_t.getAutoPlay()) {\r
- _s._wD(fN+' Netstream not connected yet - setting autoPlay');\r
- _t.setAutoPlay(true);\r
- }\r
- return _t; // play will be called in _onconnect()\r
+\r
+ // RTMP-only\r
+ if (_t._iO.serverURL && !_t.connected) {\r
+ if (!_t.getAutoPlay()) {\r
+ _s._wD(fN+' Netstream not connected yet - setting autoPlay');\r
+ _t.setAutoPlay(true);\r
}\r
+ // play will be called in _onconnect()\r
+ return _t;\r
}\r
+\r
if (_html5OK(_t._iO)) {\r
_t._setup_html5(_t._iO);\r
_start_html5_timer();\r
}\r
+\r
if (_t.playState === 1 && !_t.paused) {\r
allowMulti = _t._iO.multiShot;\r
if (!allowMulti) {\r
return _t;\r
} else {\r
_s._wD(fN + '"' + _t.sID + '" already playing (multi-shot)', 1);\r
- if (_t.isHTML5) {\r
- // TODO: BUG?\r
- _t.setPosition(_t._iO.position);\r
- }\r
}\r
}\r
+\r
if (!_t.loaded) {\r
+\r
if (_t.readyState === 0) {\r
+\r
_s._wD(fN + 'Attempting to load "' + _t.sID + '"', 1);\r
// try to get this sound playing ASAP\r
if (!_t.isHTML5) {\r
- _t._iO.autoPlay = true; // assign directly because setAutoPlay() increments the instanceCount\r
- _t.load(_t._iO);\r
- } else {\r
- _t.load(_t._iO);\r
- // _t.readyState = 1; // redundant\r
+ // assign directly because setAutoPlay() increments the instanceCount\r
+ _t._iO.autoPlay = true;\r
}\r
+ _t.load(_t._iO);\r
+\r
} else if (_t.readyState === 2) {\r
+\r
_s._wD(fN + 'Could not load "' + _t.sID + '" - exiting', 2);\r
return _t;\r
+\r
} else {\r
+\r
_s._wD(fN + '"' + _t.sID + '" is loading - attempting to play..', 1);\r
+\r
}\r
+\r
} else {\r
+\r
_s._wD(fN + '"' + _t.sID + '"');\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. If\r
- // we just call resume() the onplay() callback will never be called. So\r
- // only call resume() if the position is > 0.\r
- // Another reason is because options like volume won't have been applied yet.\r
- if (_t.paused && _t.position && _t.position > 0) { // https://gist.github.com/37b17df75cc4d7a90bf6\r
+\r
+ if (!_t.isHTML5 && _fV === 9 && _t.position > 0 && _t.position === _t.duration) {\r
+ // flash 9 needs a position reset if play() is called while at the end of a sound.\r
+ _s._wD(fN + '"' + _t.sID + '": Sound at end, resetting to position:0');\r
+ _t._iO.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
+ */\r
+\r
+ if (_t.paused && _t.position && _t.position > 0) {\r
+\r
+ // https://gist.github.com/37b17df75cc4d7a90bf6\r
_s._wD(fN + '"' + _t.sID + '" is resuming from paused state',1);\r
_t.resume();\r
+\r
} else {\r
+\r
_s._wD(fN+'"'+ _t.sID+'" is starting to play');\r
_t.playState = 1;\r
_t.paused = false;\r
- if (!_t.instanceCount || _t._iO.multiShotEvents || (_fV > 8 && !_t.isHTML5 && !_t.getAutoPlay())) {\r
+\r
+ if (!_t.instanceCount || _t._iO.multiShotEvents || (!_t.isHTML5 && _fV > 8 && !_t.getAutoPlay())) {\r
_t.instanceCount++;\r
}\r
+\r
_t.position = (typeof _t._iO.position !== 'undefined' && !isNaN(_t._iO.position)?_t._iO.position:0);\r
+\r
if (!_t.isHTML5) {\r
_t._iO = _policyFix(_loopFix(_t._iO));\r
}\r
+\r
if (_t._iO.onplay && _updatePlayState) {\r
_t._iO.onplay.apply(_t);\r
_t._onplay_called = true;\r
}\r
+\r
_t.setVolume(_t._iO.volume, true);\r
_t.setPan(_t._iO.pan, true);\r
+\r
if (!_t.isHTML5) {\r
- _s.o._start(_t.sID, _t._iO.loops || 1, (_fV === 9?_t.position:_t.position / 1000));\r
+ _s.o._start(_t.sID, _t._iO.loops || 1, (_fV === 9?_t._iO.position:_t._iO.position / 1000));\r
} else {\r
_start_html5_timer();\r
- _t._setup_html5().play();\r
+ a = _t._setup_html5();\r
+ _t.setPosition(_t._iO.position);\r
+ a.play();\r
}\r
+\r
}\r
+\r
return _t;\r
+\r
};\r
\r
- this.start = this.play; // just for convenience\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
if (_t.playState === 1) {\r
+\r
_t._onbufferchange(0);\r
_t.resetOnPosition(0);\r
+ _t.paused = false;\r
+\r
if (!_t.isHTML5) {\r
_t.playState = 0;\r
}\r
- _t.paused = false;\r
+\r
if (_t._iO.onstop) {\r
_t._iO.onstop.apply(_t);\r
}\r
+\r
if (!_t.isHTML5) {\r
+\r
_s.o._stop(_t.sID, bAll);\r
// hack for netStream: just unload\r
if (_t._iO.serverURL) {\r
_t.unload();\r
}\r
+\r
} else {\r
+\r
if (_t._a) {\r
- _t.setPosition(0); // act like Flash, though\r
- _t._a.pause(); // html5 has no stop()\r
+\r
+ // act like Flash, though\r
+ _t.setPosition(0);\r
+\r
+ // html5 has no stop()\r
+ _t._a.pause();\r
+\r
_t.playState = 0;\r
- _t._onTimer(); // and update UI\r
+\r
+ // and update UI\r
+ _t._onTimer();\r
+\r
_stop_html5_timer();\r
- _t.unload();\r
+\r
}\r
+\r
}\r
+\r
_t.instanceCount = 0;\r
_t._iO = {};\r
+\r
}\r
+\r
return _t;\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
_s._wD('sound '+_t.sID+' turned autoplay ' + (autoPlay ? 'on' : 'off'));\r
_t._iO.autoPlay = autoPlay;\r
- if (_t.isHTML5) {\r
- if (_t._a && autoPlay) {\r
- _t.play(); // HTML5 onload isn't reliable\r
- }\r
- } else {\r
+\r
+ if (!_t.isHTML5) {\r
_s.o._setAutoPlay(_t.sID, autoPlay);\r
- }\r
- if (autoPlay) {\r
- // only increment the instanceCount if the sound isn't loaded (TODO: verify RTMP)\r
- if (!_t.instanceCount && _t.readyState === 1) {\r
- _t.instanceCount++;\r
- _s._wD('sound '+_t.sID+' incremented instance count to '+_t.instanceCount);\r
+ if (autoPlay) {\r
+ // only increment the instanceCount if the sound isn't loaded (TODO: verify RTMP)\r
+ if (!_t.instanceCount && _t.readyState === 1) {\r
+ _t.instanceCount++;\r
+ _s._wD('sound '+_t.sID+' incremented instance count to '+_t.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 _t._iO.autoPlay;\r
+\r
};\r
\r
- this.setPosition = function(nMsecOffset, bNoDebug) {\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
- // Use the duration from the instance options, if we don't have a track duration yet.\r
- var original_pos, position, position1K, offset = (_t.isHTML5 ? Math.max(nMsecOffset,0) : Math.min(_t.duration || _t._iO.duration, Math.max(nMsecOffset, 0))); // position >= 0 and <= current available (loaded) duration\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 = (_t.isHTML5 ? Math.max(nMsecOffset,0) : Math.min(_t.duration || _t._iO.duration, Math.max(nMsecOffset, 0)));\r
+\r
original_pos = _t.position;\r
_t.position = offset;\r
position1K = _t.position/1000;\r
_t.resetOnPosition(_t.position);\r
_t._iO.position = offset;\r
+\r
if (!_t.isHTML5) {\r
- position = _fV === 9 ? _t.position : position1K;\r
+\r
+ position = (_fV === 9 ? _t.position : position1K);\r
if (_t.readyState && _t.readyState !== 2) {\r
- _s.o._setPosition(_t.sID, position, (_t.paused || !_t.playState)); // if paused or not playing, will not resume (by playing)\r
+ // if paused or not playing, will not resume (by playing)\r
+ _s.o._setPosition(_t.sID, position, (_t.paused || !_t.playState));\r
}\r
+\r
} else if (_t._a) {\r
+\r
// Set the position in the canplay handler if the sound is not ready yet\r
if (_t._html5_canplay) {\r
if (_t._a.currentTime !== position1K) {\r
- // Only set the position if we need to.\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
+ * 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
_s._wD('setPosition('+position1K+'): setting position');\r
try {\r
_t._a.currentTime = position1K;\r
+ if (_t.playState === 0 || _t.paused) {\r
+ // allow seek without auto-play/resume\r
+ _t._a.pause();\r
+ }\r
} catch(e) {\r
_s._wD('setPosition('+position1K+'): setting position failed: '+e.message, 2);\r
}\r
} else {\r
_s._wD('setPosition('+position1K+'): delaying, sound not ready');\r
}\r
+\r
}\r
+\r
if (_t.isHTML5) {\r
- if (_t.paused) { // if paused, refresh UI right away\r
- _t._onTimer(true); // force update\r
+ if (_t.paused) {\r
+ // if paused, refresh UI right away\r
+ // force update\r
+ _t._onTimer(true);\r
}\r
}\r
+\r
return _t;\r
+\r
};\r
\r
- this.pause = function(bCallFlash) {\r
+ /**\r
+ * Pauses sound playback.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
+ this.pause = function(_bCallFlash) {\r
+\r
if (_t.paused || (_t.playState === 0 && _t.readyState !== 1)) {\r
return _t;\r
}\r
+\r
_s._wD('SMSound.pause()');\r
_t.paused = true;\r
+\r
if (!_t.isHTML5) {\r
- if (bCallFlash || bCallFlash === undefined) {\r
+ if (_bCallFlash || _bCallFlash === undefined) {\r
_s.o._pause(_t.sID);\r
}\r
} else {\r
_t._setup_html5().pause();\r
_stop_html5_timer();\r
}\r
+\r
if (_t._iO.onpause) {\r
_t._iO.onpause.apply(_t);\r
}\r
+\r
return _t;\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
- //\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
+ * 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
if (!_t.paused) {\r
return _t;\r
}\r
+\r
_s._wD('SMSound.resume()');\r
_t.paused = false;\r
_t.playState = 1;\r
+\r
if (!_t.isHTML5) {\r
if (_t._iO.isMovieStar) {\r
// Bizarre Webkit bug (Chrome reported via 8tracks.com dudes): AAC content paused for 30+ seconds(?) will not resume without a reposition.\r
_t.setPosition(_t.position);\r
}\r
- _s.o._pause(_t.sID); // flash method is toggle-based (pause/resume)\r
+ // flash method is toggle-based (pause/resume)\r
+ _s.o._pause(_t.sID);\r
} else {\r
_t._setup_html5().play();\r
_start_html5_timer();\r
}\r
+\r
if (!_t._onplay_called && _t._iO.onplay) {\r
_t._iO.onplay.apply(_t);\r
_t._onplay_called = true;\r
} else if (_t._iO.onresume) {\r
_t._iO.onresume.apply(_t);\r
}\r
+\r
return _t;\r
+\r
};\r
\r
+ /**\r
+ * Toggles sound playback.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
this.togglePause = function() {\r
+\r
_s._wD('SMSound.togglePause()');\r
+\r
if (_t.playState === 0) {\r
_t.play({\r
- position: (_fV === 9 && !_t.isHTML5 ? _t.position:_t.position / 1000)\r
+ position: (_fV === 9 && !_t.isHTML5 ? _t.position : _t.position / 1000)\r
});\r
return _t;\r
}\r
+\r
if (_t.paused) {\r
_t.resume();\r
} else {\r
_t.pause();\r
}\r
+\r
return _t;\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 (typeof nPan === 'undefined') {\r
nPan = 0;\r
}\r
+\r
if (typeof bInstanceOnly === 'undefined') {\r
bInstanceOnly = false;\r
}\r
+\r
if (!_t.isHTML5) {\r
_s.o._setPan(_t.sID, nPan);\r
} // else { no HTML5 pan? }\r
+\r
_t._iO.pan = nPan;\r
+\r
if (!bInstanceOnly) {\r
_t.pan = nPan;\r
_t.options.pan = nPan;\r
}\r
+\r
return _t;\r
+\r
};\r
\r
- this.setVolume = function(nVol, bInstanceOnly) {\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
if (typeof nVol === 'undefined') {\r
nVol = 100;\r
}\r
- if (typeof bInstanceOnly === 'undefined') {\r
- bInstanceOnly = false;\r
+\r
+ if (typeof _bInstanceOnly === 'undefined') {\r
+ _bInstanceOnly = false;\r
}\r
+\r
if (!_t.isHTML5) {\r
_s.o._setVolume(_t.sID, (_s.muted && !_t.muted) || _t.muted?0:nVol);\r
} else if (_t._a) {\r
_t._a.volume = Math.max(0, Math.min(1, nVol/100)); // valid range: 0-1\r
}\r
+\r
_t._iO.volume = nVol;\r
- if (!bInstanceOnly) {\r
+\r
+ if (!_bInstanceOnly) {\r
_t.volume = nVol;\r
_t.options.volume = nVol;\r
}\r
+\r
return _t;\r
+\r
};\r
\r
+ /**\r
+ * Mutes the sound.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
this.mute = function() {\r
+\r
_t.muted = true;\r
+\r
if (!_t.isHTML5) {\r
_s.o._setVolume(_t.sID, 0);\r
} else if (_t._a) {\r
_t._a.muted = true;\r
}\r
+\r
return _t;\r
+\r
};\r
\r
+ /**\r
+ * Unmutes the sound.\r
+ *\r
+ * @return {SMSound} The SMSound object\r
+ */\r
+\r
this.unmute = function() {\r
+\r
_t.muted = false;\r
var hasIO = typeof _t._iO.volume !== 'undefined';\r
+\r
if (!_t.isHTML5) {\r
_s.o._setVolume(_t.sID, hasIO?_t._iO.volume:_t.options.volume);\r
} else if (_t._a) {\r
_t._a.muted = false;\r
}\r
+\r
return _t;\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 (_t.muted?_t.unmute():_t.mute());\r
+\r
};\r
\r
+ /**\r
+ * Calls the onposition() method of a SMSound object.\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: allow for ranges, too? eg. (nPosition instanceof Array)\r
+\r
_t._onPositionItems.push({\r
position: nPosition,\r
method: oMethod,\r
scope: (typeof oScope !== 'undefined'?oScope:_t),\r
fired: false\r
});\r
+\r
return _t;\r
+\r
};\r
\r
+ /**\r
+ * TODO: This should be marked as pseudo-private.\r
+ */\r
+\r
this.processOnPosition = function() {\r
+\r
var i, item, j = _t._onPositionItems.length;\r
+\r
if (!j || !_t.playState || _t._onPositionFired >= j) {\r
return false;\r
}\r
+\r
for (i=j; i--;) {\r
item = _t._onPositionItems[i];\r
if (!item.fired && _t.position >= item.position) {\r
- item.method.apply(item.scope,[item.position]);\r
item.fired = true;\r
_s._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 = _t._onPositionItems.length;\r
+\r
if (!j) {\r
return false;\r
}\r
+\r
for (i=j; i--;) {\r
item = _t._onPositionItems[i];\r
if (item.fired && nPosition <= item.position) {\r
_s._onPositionFired--;\r
}\r
}\r
- return true;\r
- };\r
\r
- // pseudo-private soundManager reference\r
+ return true;\r
\r
- this._onTimer = function(bForce) {\r
- // HTML5-only _whileplaying() etc.\r
- var time, x = {};\r
- if (_t._hasTimer || bForce) {\r
- if (_t._a && (bForce || ((_t.playState > 0 || _t.readyState === 1) && !_t.paused))) { // TODO: May not need to track readyState (1 = loading)\r
- _t.duration = _t._get_html5_duration();\r
- _t.durationEstimate = _t.duration;\r
- time = _t._a.currentTime?_t._a.currentTime*1000:0;\r
- _t._whileplaying(time,x,x,x,x);\r
- return true;\r
- } else {\r
- _s._wD('_onTimer: Warn for "'+_t.sID+'": '+(!_t._a?'Could not find element. ':'')+(_t.playState === 0?'playState bad, 0?':'playState = '+_t.playState+', OK'));\r
- return false;\r
- }\r
- }\r
};\r
\r
- // --- private internals ---\r
-\r
- this._get_html5_duration = function() {\r
- var d = (_t._a ? _t._a.duration*1000 : (_t._iO ? _t._iO.duration : undefined));\r
- return (d && !isNaN(d) && d !== Infinity ? d : (_t._iO ? _t._iO.duration : null));\r
- };\r
+ /**\r
+ * SoundManager() private internals\r
+ * --------------------------------\r
+ */\r
\r
_start_html5_timer = function() {\r
+\r
if (_t.isHTML5) {\r
_startTimer(_t);\r
}\r
+\r
};\r
\r
_stop_html5_timer = function() {\r
+\r
if (_t.isHTML5) {\r
_stopTimer(_t);\r
}\r
+\r
};\r
\r
- _resetProperties = function(bLoaded) {\r
+ _resetProperties = function() {\r
+\r
_t._onPositionItems = [];\r
_t._onPositionFired = 0;\r
_t._hasTimer = null;\r
_t.loaded = false;\r
_t.playState = 0;\r
_t.paused = false;\r
- _t.readyState = 0; // 0 = uninitialised, 1 = loading, 2 = failed/error, 3 = loaded/success\r
+\r
+ // 0 = uninitialised, 1 = loading, 2 = failed/error, 3 = loaded/success\r
+ _t.readyState = 0;\r
+\r
_t.muted = false;\r
- _t.didBeforeFinish = false;\r
- _t.didJustBeforeFinish = false;\r
_t.isBuffering = false;\r
_t.instanceOptions = {};\r
_t.instanceCount = 0;\r
+\r
_t.peakData = {\r
left: 0,\r
right: 0\r
};\r
+\r
_t.waveformData = {\r
left: [],\r
right: []\r
};\r
- _t.eqData = []; // legacy: 1D array\r
+\r
+ // legacy: 1D array\r
+ _t.eqData = [];\r
+\r
_t.eqData.left = [];\r
_t.eqData.right = [];\r
+\r
};\r
\r
_resetProperties();\r
\r
- // pseudo-private methods used by soundManager\r
+ /**\r
+ * Pseudo-private SMSound internals\r
+ * --------------------------------\r
+ */\r
+\r
+ this._onTimer = function(bForce) {\r
+\r
+ // HTML5-only _whileplaying() etc.\r
+\r
+ var time, x = {};\r
+\r
+ if (_t._hasTimer || bForce) {\r
+\r
+ // TODO: May not need to track readyState (1 = loading)\r
+\r
+ if (_t._a && (bForce || ((_t.playState > 0 || _t.readyState === 1) && !_t.paused))) {\r
+\r
+ _t.duration = _t._get_html5_duration();\r
+ _t.durationEstimate = _t.duration;\r
+ time = _t._a.currentTime?_t._a.currentTime*1000:0;\r
+ _t._whileplaying(time,x,x,x,x);\r
+ return true;\r
+\r
+ } else {\r
+\r
+ _s._wD('_onTimer: Warn for "'+_t.sID+'": '+(!_t._a?'Could not find element. ':'')+(_t.playState === 0?'playState bad, 0?':'playState = '+_t.playState+', OK'));\r
+ return false;\r
+\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ this._get_html5_duration = function() {\r
+\r
+ var d = (_t._a ? _t._a.duration*1000 : (_t._iO ? _t._iO.duration : undefined)),\r
+ result = (d && !isNaN(d) && d !== Infinity ? d : (_t._iO ? _t._iO.duration : null));\r
+\r
+ return result;\r
+\r
+ };\r
\r
this._setup_html5 = function(oOptions) {\r
+\r
var _iO = _mixin(_t._iO, oOptions), d = decodeURI,\r
_a = _useGlobalHTML5Audio ? _s._global_a : _t._a,\r
_dURL = d(_iO.url),\r
_oldIO = (_a && _a._t ? _a._t.instanceOptions : null);\r
+\r
if (_a) {\r
+\r
if (_a._t && _oldIO.url === _iO.url && (!_t._lastURL || (_t._lastURL === _oldIO.url))) {\r
- return _a; // same url, ignore request\r
+ // same url, ignore request\r
+ return _a; \r
}\r
+\r
_s._wD('setting new URL on existing object: ' + _dURL + (_t._lastURL ? ', old URL: ' + _t._lastURL : ''));\r
- /*\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 && _a._t && _a._t.playState && _iO.url !== _oldIO.url) {\r
_a._t.stop();\r
}\r
- _resetProperties(); // new URL, so reset load/playstate and so on\r
+\r
+ // new URL, so reset load/playstate and so on\r
+ _resetProperties();\r
+\r
_a.src = _iO.url;\r
_t.url = _iO.url;\r
_t._lastURL = _iO.url;\r
_a._called_load = false;\r
+\r
} else {\r
+\r
_s._wD('creating HTML5 Audio() element with URL: '+_dURL);\r
_a = new Audio(_iO.url);\r
+\r
_a._called_load = false;\r
+\r
+ // android (seen in 2.3/Honeycomb) sometimes fails first .load() -> .play(), results in playback failure and ended() events?\r
+ if (_is_android) {\r
+ _a._called_load = true;\r
+ }\r
+\r
if (_useGlobalHTML5Audio) {\r
_s._global_a = _a;\r
}\r
+\r
}\r
_t.isHTML5 = true;\r
- _t._a = _a; // store a ref on the track\r
- _a._t = _t; // store a ref on the audio\r
+\r
+ // store a ref on the track\r
+ _t._a = _a;\r
+\r
+ // store a ref on the audio\r
+ _a._t = _t;\r
+\r
_t._add_html5_events();\r
_a.loop = (_iO.loops>1?'loop':'');\r
+\r
if (_iO.autoLoad || _iO.autoPlay) {\r
- _a.autobuffer = 'auto'; // early HTML5 implementation (non-standard)\r
- _a.preload = 'auto'; // standard\r
+\r
+ // early HTML5 implementation (non-standard)\r
+ _a.autobuffer = 'auto';\r
+\r
+ // standard\r
+ _a.preload = 'auto';\r
+\r
_t.load();\r
_a._called_load = true;\r
+\r
} else {\r
- _a.autobuffer = false; // early HTML5 implementation (non-standard)\r
- _a.preload = 'none'; // standard\r
+\r
+ // early HTML5 implementation (non-standard)\r
+ _a.autobuffer = false;\r
+\r
+ // standard\r
+ _a.preload = 'none';\r
+\r
}\r
- _a.loop = (_iO.loops>1?'loop':''); // boolean instead of "loop", for webkit? - spec says string. http://www.w3.org/TR/html-markup/audio.html#audio.attrs.loop\r
+\r
+ // boolean instead of "loop", for webkit? - spec says string. http://www.w3.org/TR/html-markup/audio.html#audio.attrs.loop\r
+ _a.loop = (_iO.loops>1?'loop':'');\r
+\r
return _a;\r
- };\r
\r
- // related private methods\r
+ };\r
\r
this._add_html5_events = function() {\r
+\r
if (_t._a._added_events) {\r
return false;\r
}\r
_s._wD(_h5+'adding event listeners: '+_t.sID);\r
_t._a._added_events = true;\r
\r
- for (f in _s._html5_events) {\r
- if (_s._html5_events.hasOwnProperty(f)) {\r
- add(f, _s._html5_events[f]);\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
- // Keep this externally accessible\r
this._remove_html5_events = function() {\r
+\r
// Remove event listeners\r
+\r
+ var f;\r
+\r
function remove(oEvt, oFn, bCapture) {\r
return (_t._a ? _t._a.removeEventListener(oEvt, oFn, bCapture||false) : null);\r
}\r
+\r
_s._wD(_h5+'removing event listeners: '+_t.sID);\r
_t._a._added_events = false;\r
\r
- for (var f in _s._html5_events) {\r
- if (_s._html5_events.hasOwnProperty(f)) {\r
- remove(f, _s._html5_events[f]);\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
+\r
+ var fN = 'SMSound._onload(): ', loadOK = !!(nSuccess);\r
+ _s._wD(fN + '"' + _t.sID + '"' + (loadOK?' loaded.':' failed to load? - ' + _t.url), (loadOK?1:2));\r
+ // <d>\r
+\r
+ if (!loadOK && !_t.isHTML5) {\r
+ if (_s.sandbox.noRemote === true) {\r
+ _s._wD(fN + _str('noNet'), 1);\r
+ }\r
+ if (_s.sandbox.noLocal === true) {\r
+ _s._wD(fN + _str('noLocal'), 1);\r
}\r
}\r
+ // </d>\r
+\r
+ _t.loaded = loadOK;\r
+ _t.readyState = loadOK?3:2;\r
+ _t._onbufferchange(0);\r
+\r
+ if (_t._iO.onload) {\r
+ _t._iO.onload.apply(_t, [loadOK]);\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ this._onbufferchange = function(nIsBuffering) {\r
+\r
+ var fN = 'SMSound._onbufferchange()';\r
+\r
+ if (_t.playState === 0) {\r
+ // ignore if not playing\r
+ return false;\r
+ }\r
+\r
+ if ((nIsBuffering && _t.isBuffering) || (!nIsBuffering && !_t.isBuffering)) {\r
+ return false;\r
+ }\r
+\r
+ _t.isBuffering = (nIsBuffering === 1);\r
+ if (_t._iO.onbufferchange) {\r
+ _s._wD(fN + ': ' + nIsBuffering);\r
+ _t._iO.onbufferchange.apply(_t);\r
+ }\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ /**\r
+ * Notify Mobile Safari that user action is required\r
+ * to continue playing / loading the audio file.\r
+ */\r
+\r
+ this._onsuspend = function () {\r
+\r
+ if (_t._iO.onsuspend) {\r
+ _s._wD('SMSound._onsuspend()');\r
+ _t._iO.onsuspend.apply(_t);\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
+ _t.failures++;\r
+ _s._wD('SMSound._onfailure(): "'+_t.sID+'" count '+_t.failures);\r
+\r
+ if (_t._iO.onfailure && _t.failures === 1) {\r
+ _t._iO.onfailure(_t, msg, level, code);\r
+ } else {\r
+ _s._wD('SMSound._onfailure(): ignoring');\r
+ }\r
+\r
};\r
\r
- // --- "private" methods called by Flash ---\r
+ this._onfinish = function() {\r
+\r
+ // store local copy before it gets trashed..\r
+ var _io_onfinish = _t._iO.onfinish;\r
+ _t._onbufferchange(0);\r
+ _t.resetOnPosition(0);\r
+\r
+ // reset some state items\r
+ if (_t.instanceCount) {\r
+\r
+ _t.instanceCount--;\r
+ if (!_t.instanceCount) {\r
+ // reset instance options\r
+ _t.playState = 0;\r
+ _t.paused = false;\r
+ _t.instanceCount = 0;\r
+ _t.instanceOptions = {};\r
+ _t._iO = {};\r
+ _stop_html5_timer();\r
+ }\r
+\r
+ if (!_t.instanceCount || _t._iO.multiShotEvents) {\r
+ // fire onfinish for last, or every instance\r
+ if (_io_onfinish) {\r
+ _s._wD('SMSound._onfinish(): "' + _t.sID + '"');\r
+ _io_onfinish.apply(_t);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ };\r
\r
this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) {\r
+\r
_t.bytesLoaded = nBytesLoaded;\r
_t.bytesTotal = nBytesTotal;\r
_t.duration = Math.floor(nDuration);\r
_t.bufferLength = nBufferLength;\r
+\r
if (!_t._iO.isMovieStar) {\r
+\r
if (_t._iO.duration) {\r
// use options, if specified and larger\r
_t.durationEstimate = (_t.duration > _t._iO.duration) ? _t.duration : _t._iO.duration;\r
} else {\r
_t.durationEstimate = parseInt((_t.bytesTotal / _t.bytesLoaded) * _t.duration, 10);\r
+\r
}\r
+\r
if (_t.durationEstimate === undefined) {\r
_t.durationEstimate = _t.duration;\r
}\r
+\r
if (_t.readyState !== 3 && _t._iO.whileloading) {\r
_t._iO.whileloading.apply(_t);\r
}\r
+\r
} else {\r
+\r
_t.durationEstimate = _t.duration;\r
if (_t.readyState !== 3 && _t._iO.whileloading) {\r
_t._iO.whileloading.apply(_t);\r
}\r
- }\r
- };\r
\r
- this._onid3 = function(oID3PropNames, oID3Data) {\r
- // oID3PropNames: string array (names)\r
- // ID3Data: string array (data)\r
- _s._wD('SMSound._onid3(): "' + this.sID + '" ID3 data received.');\r
- var oData = [], i, j;\r
- for (i = 0, j = oID3PropNames.length; i < j; i++) {\r
- oData[oID3PropNames[i]] = oID3Data[i];\r
- }\r
- _t.id3 = _mixin(_t.id3, oData);\r
- if (_t._iO.onid3) {\r
- _t._iO.onid3.apply(_t);\r
}\r
+\r
};\r
\r
this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {\r
+\r
if (isNaN(nPosition) || nPosition === null) {\r
- return false; // flash safety net\r
- }\r
- if (_t.playState === 0 && nPosition > 0) {\r
- // invalid position edge case for end/stop\r
- nPosition = 0;\r
+ // flash safety net\r
+ return false;\r
}\r
+\r
_t.position = nPosition;\r
_t.processOnPosition();\r
- if (_fV > 8 && !_t.isHTML5) {\r
+\r
+ if (!_t.isHTML5 && _fV > 8) {\r
+\r
if (_t._iO.usePeakData && typeof oPeakData !== 'undefined' && oPeakData) {\r
_t.peakData = {\r
left: oPeakData.leftPeak,\r
right: oPeakData.rightPeak\r
};\r
}\r
+\r
if (_t._iO.useWaveformData && typeof oWaveformDataLeft !== 'undefined' && oWaveformDataLeft) {\r
_t.waveformData = {\r
left: oWaveformDataLeft.split(','),\r
right: oWaveformDataRight.split(',')\r
};\r
}\r
+\r
if (_t._iO.useEQData) {\r
if (typeof oEQData !== 'undefined' && oEQData && oEQData.leftEQ) {\r
var eqLeft = oEQData.leftEQ.split(',');\r
}\r
}\r
}\r
+\r
}\r
+\r
if (_t.playState === 1) {\r
+\r
// special case/hack: ensure buffering is false if loading from cache (and not yet started)\r
- if (!_t.isHTML5 && _s.flashVersion === 8 && !_t.position && _t.isBuffering) {\r
+ if (!_t.isHTML5 && _fV === 8 && !_t.position && _t.isBuffering) {\r
_t._onbufferchange(0);\r
}\r
+\r
if (_t._iO.whileplaying) {\r
- _t._iO.whileplaying.apply(_t); // flash may call after actual finish\r
- }\r
- if ((_t.loaded || (!_t.loaded && _t._iO.isMovieStar)) && _t._iO.onbeforefinish && _t._iO.onbeforefinishtime && !_t.didBeforeFinish && _t.duration - _t.position <= _t._iO.onbeforefinishtime) {\r
- _t._onbeforefinish();\r
+ // flash may call after actual finish\r
+ _t._iO.whileplaying.apply(_t);\r
}\r
+\r
}\r
+\r
return true;\r
+\r
+ };\r
+\r
+ this._onid3 = function(oID3PropNames, oID3Data) {\r
+\r
+ // oID3PropNames: string array (names)\r
+ // ID3Data: string array (data)\r
+ _s._wD('SMSound._onid3(): "' + this.sID + '" ID3 data received.');\r
+\r
+ var oData = [], i, j;\r
+\r
+ for (i = 0, j = oID3PropNames.length; i < j; i++) {\r
+ oData[oID3PropNames[i]] = oID3Data[i];\r
+ }\r
+ _t.id3 = _mixin(_t.id3, oData);\r
+\r
+ if (_t._iO.onid3) {\r
+ _t._iO.onid3.apply(_t);\r
+ }\r
+\r
};\r
\r
- // Only applies to RTMP\r
+ // flash/RTMP-only\r
+\r
this._onconnect = function(bSuccess) {\r
+\r
var fN = 'SMSound._onconnect(): ';\r
bSuccess = (bSuccess === 1);\r
_s._wD(fN+'"'+_t.sID+'"'+(bSuccess?' connected.':' failed to connect? - '+_t.url), (bSuccess?1:2));\r
_t.connected = bSuccess;\r
+\r
if (bSuccess) {\r
+\r
_t.failures = 0;\r
+\r
if (_idCheck(_t.sID)) {\r
if (_t.getAutoPlay()) {\r
- _t.play(undefined, _t.getAutoPlay()); // only update the play state if auto playing\r
+ // only update the play state if auto playing\r
+ _t.play(undefined, _t.getAutoPlay());\r
} else if (_t._iO.autoLoad) {\r
_t.load();\r
}\r
}\r
+\r
if (_t._iO.onconnect) {\r
_t._iO.onconnect.apply(_t,[bSuccess]);\r
}\r
- }\r
- };\r
\r
- this._onload = function(nSuccess) {\r
- var fN = 'SMSound._onload(): ', loadOK = (nSuccess?true:false);\r
- _s._wD(fN + '"' + _t.sID + '"' + (loadOK?' loaded.':' failed to load? - ' + _t.url), (loadOK?1:2));\r
- // <d>\r
- if (!loadOK && !_t.isHTML5) {\r
- if (_s.sandbox.noRemote === true) {\r
- _s._wD(fN + _str('noNet'), 1);\r
- }\r
- if (_s.sandbox.noLocal === true) {\r
- _s._wD(fN + _str('noLocal'), 1);\r
- }\r
- }\r
- // </d>\r
- _t.loaded = loadOK;\r
- _t.readyState = loadOK?3:2;\r
- _t._onbufferchange(0);\r
- if (_t._iO.onload) {\r
- _t._iO.onload.apply(_t, [loadOK]);\r
}\r
- return true;\r
- };\r
\r
- // fire onfailure() only once at most\r
- // at this point we just recreate failed sounds rather than trying to reconnect.\r
- this._onfailure = function(msg, level, code) {\r
- _t.failures++;\r
- _s._wD('SMSound._onfailure(): "'+_t.sID+'" count '+_t.failures);\r
- if (_t._iO.onfailure && _t.failures === 1) {\r
- _t._iO.onfailure(_t, msg, level, code);\r
- } else {\r
- _s._wD('SMSound._onfailure(): ignoring');\r
- }\r
};\r
\r
- this._onbeforefinish = function() {\r
- if (!_t.didBeforeFinish) {\r
- _t.didBeforeFinish = true;\r
- if (_t._iO.onbeforefinish) {\r
- _s._wD('SMSound._onbeforefinish(): "' + _t.sID + '"');\r
- _t._iO.onbeforefinish.apply(_t);\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 (_t.playState > 0) {\r
+ _s._wD('SMSound._ondataerror(): ' + sError);\r
+ if (_t._iO.ondataerror) {\r
+ _t._iO.ondataerror.apply(_t);\r
}\r
}\r
+\r
};\r
\r
- this._onjustbeforefinish = function(msOffset) {\r
- if (!_t.didJustBeforeFinish) {\r
- _t.didJustBeforeFinish = true;\r
- if (_t._iO.onjustbeforefinish) {\r
- _s._wD('SMSound._onjustbeforefinish(): "' + _t.sID + '"');\r
- _t._iO.onjustbeforefinish.apply(_t);\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 = {}, i, o2, o;\r
+\r
+ // clone c1\r
+ for (i in oMain) {\r
+ if (oMain.hasOwnProperty(i)) {\r
+ o1[i] = oMain[i];\r
}\r
- };\r
+ }\r
\r
- this._onfinish = function() {\r
- // _s._wD('SMSound._onfinish(): "' + _t.sID + '" got instanceCount '+_t.instanceCount);\r
- var _io_onfinish = _t._iO.onfinish; // store local copy before it gets trashed..\r
- _t._onbufferchange(0);\r
- _t.resetOnPosition(0);\r
- if (_t._iO.onbeforefinishcomplete) {\r
- _t._iO.onbeforefinishcomplete.apply(_t);\r
- }\r
- // reset some state items\r
- _t.didBeforeFinish = false;\r
- _t.didJustBeforeFinish = false;\r
- if (_t.instanceCount) {\r
- _t.instanceCount--;\r
- if (!_t.instanceCount) {\r
- // reset instance options\r
- _t.playState = 0;\r
- _t.paused = false;\r
- _t.instanceCount = 0;\r
- _t.instanceOptions = {};\r
- _t._iO = {};\r
- _stop_html5_timer();\r
- }\r
- if (!_t.instanceCount || _t._iO.multiShotEvents) {\r
- // fire onfinish for last, or every instance\r
- if (_io_onfinish) {\r
- _s._wD('SMSound._onfinish(): "' + _t.sID + '"');\r
- _io_onfinish.apply(_t);\r
- }\r
- }\r
- }\r
- };\r
-\r
- this._onbufferchange = function(nIsBuffering) {\r
- var fN = 'SMSound._onbufferchange()';\r
- if (_t.playState === 0) {\r
- // ignore if not playing\r
- return false;\r
- }\r
- if ((nIsBuffering && _t.isBuffering) || (!nIsBuffering && !_t.isBuffering)) {\r
- return false;\r
- }\r
- _t.isBuffering = (nIsBuffering === 1);\r
- if (_t._iO.onbufferchange) {\r
- _s._wD(fN + ': ' + nIsBuffering);\r
- _t._iO.onbufferchange.apply(_t);\r
- }\r
- return true;\r
- };\r
-\r
- this._ondataerror = function(sError) {\r
- // flash 9 wave/eq data handler\r
- if (_t.playState > 0) { // hack: called at start, and end from flash at/after onfinish()\r
- _s._wD('SMSound._ondataerror(): ' + sError);\r
- if (_t._iO.ondataerror) {\r
- _t._iO.ondataerror.apply(_t);\r
- }\r
- }\r
- };\r
-\r
- }; // SMSound()\r
-\r
- // --- private SM2 internals ---\r
-\r
- _getDocument = function() {\r
- return (_doc.body?_doc.body:(_doc._docElement?_doc.documentElement:_doc.getElementsByTagName('div')[0]));\r
- };\r
-\r
- _id = function(sID) {\r
- return _doc.getElementById(sID);\r
- };\r
-\r
- _mixin = function(oMain, oAdd) {\r
- // non-destructive merge\r
- var o1 = {}, i, o2, o;\r
- for (i in oMain) { // clone c1\r
- if (oMain.hasOwnProperty(i)) {\r
- o1[i] = oMain[i];\r
- }\r
- }\r
- o2 = (typeof oAdd === 'undefined'?_s.defaultOptions:oAdd);\r
- for (o in o2) {\r
- if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') {\r
- o1[o] = o2[o];\r
+ o2 = (typeof oAdd === 'undefined'?_s.defaultOptions:oAdd);\r
+ for (o in o2) {\r
+ if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') {\r
+ o1[o] = o2[o];\r
}\r
}\r
return o1;\r
+\r
};\r
\r
_event = (function() {\r
};\r
\r
function getArgs(oArgs) {\r
+\r
var args = _slice.call(oArgs), len = args.length;\r
+\r
if (old) {\r
- args[1] = 'on' + args[1]; // prefix\r
+ // prefix\r
+ args[1] = 'on' + args[1];\r
if (len > 3) {\r
- args.pop(); // no capture\r
+ // no capture\r
+ args.pop();\r
}\r
} else if (len === 3) {\r
args.push(false);\r
}\r
return args;\r
+\r
}\r
\r
function apply(args, sType) {\r
+\r
var element = args.shift(),\r
method = [evt[sType]];\r
+\r
if (old) {\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
\r
}());\r
\r
- _html5OK = function(iO) {\r
- return (!iO.serverURL && (iO.type?_html5CanPlay({type:iO.type}):_html5CanPlay(iO.url)||_html5Only)); // Use type, if specified. If HTML5-only mode, no other options, so just give 'er\r
- };\r
+ /**\r
+ * Internal HTML5 event handling\r
+ * -----------------------------\r
+ */\r
\r
- _html5CanPlay = function(sURL) {\r
- // try to find MIME, test and return truthiness\r
- if (!_s.useHTML5Audio || !_s.hasHTML5) {\r
- return false;\r
- }\r
- var result, mime, offset, fileExt, item, aF = _s.audioFormats;\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
- mime = (typeof sURL.type !== 'undefined'?sURL.type:null);\r
- fileExt = (typeof sURL === 'string'?sURL.toLowerCase().match(_html5Ext):null); // TODO: Strip URL queries, etc.\r
- if (!fileExt || !fileExt.length) {\r
- if (!mime) {\r
- return false;\r
- } else {\r
- // audio/mp3 -> mp3, result should be known\r
- offset = mime.indexOf(';');\r
- fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6); // strip "audio/X; codecs.."\r
- }\r
- } else {\r
- fileExt = fileExt[0].substr(1); // "mp3", for example\r
- }\r
- if (fileExt && typeof _s.html5[fileExt] !== 'undefined') {\r
- // result known\r
- return _s.html5[fileExt];\r
- } else {\r
- if (!mime) {\r
- if (fileExt && _s.html5[fileExt]) {\r
- return _s.html5[fileExt];\r
- } else {\r
- // best-case guess, audio/whatever-dot-filename-format-you're-playing\r
- mime = 'audio/'+fileExt;\r
- }\r
- }\r
- result = _s.html5.canPlayType(mime);\r
- _s.html5[fileExt] = result;\r
- // _s._wD('canPlayType, found result: '+result);\r
- return result;\r
- }\r
- };\r
+ function _html5_event(oFn) {\r
\r
- _testHTML5 = function() {\r
- if (!_s.useHTML5Audio || typeof Audio === 'undefined') {\r
- return false;\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 = (typeof Audio !== 'undefined' ? (_isOpera ? new Audio(null) : new Audio()) : null), item, support = {}, aF, i, _hasFlash = _detectFlash();\r
- function _cp(m) {\r
- var canPlay, i, j, isOK = false;\r
- if (!a || typeof a.canPlayType !== 'function') {\r
- return false;\r
- }\r
- if (m instanceof Array) {\r
- // iterate through all mime types, return any successes\r
- for (i=0, j=m.length; i<j && !isOK; i++) {\r
- if (_s.html5[m[i]] || a.canPlayType(m[i]).match(_s.html5Test)) {\r
- isOK = true;\r
- _s.html5[m[i]] = true;\r
- }\r
+ // wrap html5 event handlers so we don't call them on destroyed sounds\r
+\r
+ return function(e) {\r
+\r
+ if (!this._t || !this._t._a) {\r
+ // <d>\r
+ if (this._t && this._t.sID) {\r
+ _s._wD(_h5+'ignoring '+e.type+': '+this._t.sID);\r
+ } else {\r
+ _s._wD(_h5+'ignoring '+e.type);\r
}\r
- return isOK;\r
+ // </d>\r
+ return null;\r
} else {\r
- canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);\r
- return (canPlay && (canPlay.match(_s.html5Test)?true:false));\r
- }\r
- }\r
- // test all registered formats + codecs\r
- aF = _s.audioFormats;\r
- for (item in aF) {\r
- if (aF.hasOwnProperty(item)) {\r
- support[item] = _cp(aF[item].type);\r
- // assign result to related formats, too\r
- if (aF[item] && aF[item].related) {\r
- for (i=aF[item].related.length; i--;) {\r
- _s.html5[aF[item].related[i]] = support[item];\r
- }\r
- }\r
+ return oFn.call(this, e);\r
}\r
- }\r
- support.canPlayType = (a?_cp:null);\r
- _s.html5 = _mixin(_s.html5, support);\r
- return true;\r
- };\r
\r
- _strings = {\r
- // <d>\r
- notReady: 'Not loaded yet - wait for soundManager.onload()/onready()',\r
- notOK: 'Audio support is not available.',\r
- appXHTML: _smc + 'createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.',\r
- spcWmode: _smc + 'createMovie(): Removing wmode, preventing known SWF loading issue(s)',\r
- swf404: _sm + ': 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: _sm + ': 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: _sm + ': Special case: Waiting for focus-related event..',\r
- waitImpatient: _sm + ': Getting impatient, still waiting for Flash%s...',\r
- waitForever: _sm + ': Waiting indefinitely for Flash (will recover if unblocked)...',\r
- needFunction: _sm + ': Function object expected for %s',\r
- badID: 'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',\r
- noMS: 'MovieStar mode not enabled. Exiting.',\r
- currentObj: '--- ' + _sm + '._debug(): Current sound objects ---',\r
- waitEI: _smc + 'initMovie(): Waiting for ExternalInterface call from Flash..',\r
- waitOnload: _sm + ': Waiting for window.onload()',\r
- docLoaded: _sm + ': Document already loaded',\r
- onload: _smc + 'initComplete(): calling soundManager.onload()',\r
- onloadOK: _sm + '.onload() complete',\r
- init: '-- ' + _smc + 'init() --',\r
- didInit: _smc + 'init(): Already called?',\r
- flashJS: _sm + ': Attempting to call Flash from JS..',\r
- noPolling: _sm + ': Polling (whileloading()/whileplaying() support) is disabled.',\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: 'Warning: Failed to remove flash movie.',\r
- noPeak: 'Warning: peakData features unsupported for movieStar formats',\r
- shutdown: _sm + '.disable(): Shutting down',\r
- queue: _sm + ': Queueing %s handler',\r
- smFail: _sm + ': Failed to initialise.',\r
- smError: 'SMSound.load(): Exception: JS-Flash communication failed, or JS error.',\r
- fbTimeout: 'No flash response, applying .'+_s.swfCSS.swfTimedout+' CSS..',\r
- fbLoaded: 'Flash loaded',\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
- mfOn: 'mobileFlash::enabling on-screen flash repositioning',\r
- policy: 'Enabling usePolicyFile for data access'\r
- // </d>\r
- };\r
+ };\r
\r
- _str = function() { // o [,items to replace]\r
- // <d>\r
- var args = _slice.call(arguments), // real array, please\r
- o = args.shift(), // first arg\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
- return str;\r
- // </d>\r
- };\r
+ }\r
\r
- _loopFix = function(sOpt) {\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
- return sOpt;\r
- };\r
+ _html5_events = {\r
\r
- _policyFix = function(sOpt, sPre) {\r
- if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) {\r
- _s._wD((sPre?sPre+':':'') + _str('policy'));\r
- sOpt.usePolicyFile = true;\r
- }\r
- return sOpt;\r
- };\r
+ // HTML5 event-name-to-handler map\r
\r
- _complain = function(sMsg) {\r
- if (typeof console !== 'undefined' && typeof console.warn !== 'undefined') {\r
- console.warn(sMsg);\r
- } else {\r
- _s._wD(sMsg);\r
- }\r
- };\r
+ abort: _html5_event(function(e) {\r
\r
- _doNothing = function() {\r
- return false;\r
- };\r
+ _s._wD(_h5+'abort: '+this._t.sID);\r
\r
- _disableObject = function(o) {\r
- for (var oProp in o) {\r
- if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') {\r
- o[oProp] = _doNothing;\r
- }\r
- }\r
- oProp = null;\r
- };\r
+ }),\r
\r
- _failSafely = function(bNoDisable) {\r
- // general failure exception handler\r
- if (typeof bNoDisable === 'undefined') {\r
+ // enough has loaded to play\r
+\r
+ canplay: _html5_event(function(e) {\r
+\r
+ if (this._t._html5_canplay) {\r
+ // this event has already fired. ignore.\r
+ return true;\r
+ }\r
+\r
+ this._t._html5_canplay = true;\r
+ _s._wD(_h5+'canplay: '+this._t.sID+', '+this._t.url);\r
+ this._t._onbufferchange(0);\r
+ var position1K = (!isNaN(this._t.position)?this._t.position/1000:null);\r
+\r
+ // set the position if position was set before the sound loaded\r
+ if (this._t.position && this.currentTime !== position1K) {\r
+ _s._wD(_h5+'canplay: setting position to '+position1K);\r
+ try {\r
+ this.currentTime = position1K;\r
+ } catch(ee) {\r
+ _s._wD(_h5+'setting position failed: '+ee.message, 2);\r
+ }\r
+ }\r
+\r
+ }),\r
+\r
+ load: _html5_event(function(e) {\r
+\r
+ if (!this._t.loaded) {\r
+ this._t._onbufferchange(0);\r
+ // should be 1, and the same\r
+ this._t._whileloading(this._t.bytesTotal, this._t.bytesTotal, this._t._get_html5_duration());\r
+ this._t._onload(true);\r
+ }\r
+\r
+ }),\r
+\r
+ emptied: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'emptied: '+this._t.sID);\r
+\r
+ }),\r
+\r
+ ended: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'ended: '+this._t.sID);\r
+ this._t._onfinish();\r
+\r
+ }),\r
+\r
+ error: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'error: '+this.error.code);\r
+ // call load with error state?\r
+ this._t._onload(false);\r
+\r
+ }),\r
+\r
+ loadeddata: _html5_event(function(e) {\r
+\r
+ var t = this._t,\r
+ // at least 1 byte, so math works\r
+ bytesTotal = t.bytesTotal || 1;\r
+\r
+ _s._wD(_h5+'loadeddata: '+this._t.sID);\r
+\r
+ // safari seems to nicely report progress events, eventually totalling 100%\r
+ if (!t._loaded && !_isSafari) {\r
+ t.duration = t._get_html5_duration();\r
+ // fire whileloading() with 100% values\r
+ t._whileloading(bytesTotal, bytesTotal, t._get_html5_duration());\r
+ t._onload(true);\r
+ }\r
+\r
+ }),\r
+\r
+ loadedmetadata: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'loadedmetadata: '+this._t.sID);\r
+\r
+ }),\r
+\r
+ loadstart: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'loadstart: '+this._t.sID);\r
+ // assume buffering at first\r
+ this._t._onbufferchange(1);\r
+\r
+ }),\r
+\r
+ play: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'play: '+this._t.sID+', '+this._t.url);\r
+ // once play starts, no buffering\r
+ this._t._onbufferchange(0);\r
+\r
+ }),\r
+\r
+ // TODO: verify if this is actually implemented anywhere yet.\r
+ playing: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'playing: '+this._t.sID+', '+this._t.url);\r
+\r
+ // once play starts, no buffering\r
+ this._t._onbufferchange(0);\r
+\r
+ }),\r
+\r
+ progress: _html5_event(function(e) {\r
+\r
+ if (this._t.loaded) {\r
+ return false;\r
+ }\r
+\r
+ var i, j, str, buffered = 0,\r
+ isProgress = (e.type === 'progress'),\r
+ ranges = e.target.buffered,\r
+\r
+ // firefox 3.6 implements e.loaded/total (bytes)\r
+ loaded = (e.loaded||0),\r
+\r
+ total = (e.total||1);\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
+ for (i=ranges.length; i--;) {\r
+ buffered = (ranges.end(i) - ranges.start(i));\r
+ }\r
+\r
+ // linear case, buffer sum; does not account for seeking and HTTP partials / byte ranges\r
+ loaded = buffered/e.target.duration;\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) +'-'+ e.target.buffered.end(i));\r
+ }\r
+ _s._wD(_h5+'progress: timeRanges: '+str.join(', '));\r
+ }\r
+\r
+ if (isProgress && !isNaN(loaded)) {\r
+ _s._wD(_h5+'progress: '+this._t.sID+': ' + Math.floor(loaded*100)+'% loaded');\r
+ }\r
+ // </d>\r
+\r
+ }\r
+\r
+ if (!isNaN(loaded)) {\r
+\r
+ // if progress, likely not buffering\r
+ this._t._onbufferchange(0);\r
+ this._t._whileloading(loaded, total, this._t._get_html5_duration());\r
+ if (loaded && total && loaded === total) {\r
+ // in case "onload" doesn't fire (eg. gecko 1.9.2)\r
+ _html5_events.load.call(this, e);\r
+ }\r
+\r
+ }\r
+\r
+ }),\r
+\r
+ ratechange: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'ratechange: '+this._t.sID);\r
+\r
+ }),\r
+\r
+ suspend: _html5_event(function(e) {\r
+\r
+ // download paused/stopped, may have finished (eg. onload)\r
+\r
+ _s._wD(_h5+'suspend: '+this._t.sID);\r
+ _html5_events.progress.call(this, e);\r
+ this._t._onsuspend();\r
+\r
+ }),\r
+\r
+ stalled: _html5_event(function(e) {\r
+\r
+ _s._wD(_h5+'stalled: '+this._t.sID);\r
+\r
+ }),\r
+\r
+ timeupdate: _html5_event(function(e) {\r
+\r
+ this._t._onTimer();\r
+\r
+ }),\r
+\r
+ waiting: _html5_event(function(e) {\r
+\r
+ // see also: seeking\r
+ _s._wD(_h5+'waiting: '+this._t.sID);\r
+\r
+ // playback faster than download rate, etc.\r
+ this._t._onbufferchange(1);\r
+\r
+ })\r
+\r
+ };\r
+\r
+ _html5OK = function(iO) {\r
+\r
+ // Use type, if specified. If HTML5-only mode, no other options, so just give 'er\r
+ return (!iO.serverURL && (iO.type?_html5CanPlay({type:iO.type}):_html5CanPlay({url:iO.url})||_s.html5Only));\r
+\r
+ };\r
+\r
+ _html5Unload = function(oAudio) {\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
+ * Other UA behaviour is unclear, so everyone else gets an about:blank-style URL.\r
+ */\r
+\r
+ if (oAudio) {\r
+ // Firefox likes '' for unload, most other UAs don't and fail to unload.\r
+ oAudio.src = (_is_firefox ? '' : _emptyURL);\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 (!_s.useHTML5Audio || !_s.hasHTML5) {\r
+ return false;\r
+ }\r
+\r
+ var url = (o.url || null),\r
+ mime = (o.type || null),\r
+ aF = _s.audioFormats,\r
+ result,\r
+ offset,\r
+ fileExt,\r
+ item;\r
+\r
+ function preferFlashCheck(kind) {\r
+\r
+ // whether flash should play a given type\r
+ return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind]));\r
+\r
+ }\r
+\r
+ // account for known cases like audio/mp3\r
+\r
+ if (mime && _s.html5[mime] !== 'undefined') {\r
+ return (_s.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
+ return 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 && typeof _s.html5[fileExt] !== 'undefined') {\r
+ // result known\r
+ return (_s.html5[fileExt] && !preferFlashCheck(fileExt));\r
+ } else {\r
+ mime = 'audio/'+fileExt;\r
+ result = _s.html5.canPlayType({type:mime});\r
+ _s.html5[fileExt] = result;\r
+ // _s._wD('canPlayType, found result: '+result);\r
+ return (result && _s.html5[mime] && !preferFlashCheck(mime));\r
+ }\r
+\r
+ };\r
+\r
+ _testHTML5 = function() {\r
+\r
+ if (!_s.useHTML5Audio || typeof Audio === 'undefined') {\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 = (typeof Audio !== 'undefined' ? (_isOpera ? new Audio(null) : new Audio()) : null),\r
+ item, support = {}, aF, i;\r
+\r
+ function _cp(m) {\r
+\r
+ var canPlay, i, j, isOK = false;\r
+\r
+ if (!a || typeof a.canPlayType !== 'function') {\r
+ return false;\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 && !isOK; i++) {\r
+ if (_s.html5[m[i]] || a.canPlayType(m[i]).match(_s.html5Test)) {\r
+ isOK = true;\r
+ _s.html5[m[i]] = true;\r
+\r
+ // if flash can play and preferred, also mark it for use.\r
+ _s.flash[m[i]] = !!(_s.preferFlash && _hasFlash && m[i].match(_flashMIME));\r
+\r
+ }\r
+ }\r
+ return isOK;\r
+ } else {\r
+ canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);\r
+ return !!(canPlay && (canPlay.match(_s.html5Test)));\r
+ }\r
+\r
+ }\r
+\r
+ // test all registered formats + codecs\r
+\r
+ aF = _s.audioFormats;\r
+\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ support[item] = _cp(aF[item].type);\r
+\r
+ // write back generic type too, eg. audio/mp3\r
+ support['audio/'+item] = support[item];\r
+\r
+ // assign flash\r
+ if (_s.preferFlash && !_s.ignoreFlash && item.match(_flashMIME)) {\r
+ _s.flash[item] = true;\r
+ } else {\r
+ _s.flash[item] = false;\r
+ }\r
+\r
+ // assign result to related formats, too\r
+ if (aF[item] && aF[item].related) {\r
+ for (i=aF[item].related.length; i--;) {\r
+ // eg. audio/m4a\r
+ support['audio/'+aF[item].related[i]] = support[item];\r
+ _s.html5[aF[item].related[i]] = support[item];\r
+ _s.flash[aF[item].related[i]] = support[item];\r
+\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ support.canPlayType = (a?_cp:null);\r
+ _s.html5 = _mixin(_s.html5, support);\r
+\r
+ return true;\r
+\r
+ };\r
+\r
+ _strings = {\r
+\r
+ // <d>\r
+ notReady: 'Not loaded yet - wait for soundManager.onload()/onready()',\r
+ notOK: 'Audio support is not available.',\r
+ domError: _smc + 'createMovie(): appendChild/innerHTML call failed. DOM not ready or other error.',\r
+ spcWmode: _smc + 'createMovie(): Removing wmode, preventing known SWF loading issue(s)',\r
+ swf404: _sm + ': 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: _sm + ': 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: _sm + ': Special case: Waiting for focus-related event..',\r
+ waitImpatient: _sm + ': Getting impatient, still waiting for Flash%s...',\r
+ waitForever: _sm + ': Waiting indefinitely for Flash (will recover if unblocked)...',\r
+ needFunction: _sm + ': Function object expected for %s',\r
+ badID: 'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',\r
+ currentObj: '--- ' + _sm + '._debug(): Current sound objects ---',\r
+ waitEI: _smc + 'initMovie(): Waiting for ExternalInterface call from Flash..',\r
+ waitOnload: _sm + ': Waiting for window.onload()',\r
+ docLoaded: _sm + ': Document already loaded',\r
+ onload: _smc + 'initComplete(): calling soundManager.onload()',\r
+ onloadOK: _sm + '.onload() complete',\r
+ init: _smc + 'init()',\r
+ didInit: _smc + 'init(): Already called?',\r
+ flashJS: _sm + ': Attempting to call Flash from JS..',\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: 'Warning: Failed to remove flash movie.',\r
+ noPeak: 'Warning: peakData features unsupported for movieStar formats',\r
+ shutdown: _sm + '.disable(): Shutting down',\r
+ queue: _sm + ': Queueing %s handler',\r
+ smFail: _sm + ': Failed to initialise.',\r
+ smError: 'SMSound.load(): Exception: JS-Flash communication failed, or JS error.',\r
+ fbTimeout: 'No flash response, applying .'+_s.swfCSS.swfTimedout+' CSS..',\r
+ fbLoaded: 'Flash loaded',\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
+ mfOn: 'mobileFlash::enabling on-screen flash repositioning',\r
+ policy: 'Enabling usePolicyFile for data access'\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
+ _s._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 (typeof console !== 'undefined' && typeof console.warn !== 'undefined') {\r
+ console.warn(sMsg);\r
+ } else {\r
+ _s._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 (typeof bNoDisable === 'undefined') {\r
bNoDisable = false;\r
}\r
- if (_disabled || bNoDisable) {\r
- _wDS('smFail', 2);\r
- _s.disable(bNoDisable);\r
+\r
+ if (_disabled || bNoDisable) {\r
+ _wDS('smFail', 2);\r
+ _s.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) : './') + _s.movieURL;\r
+\r
+ if (_s.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(_s.flashVersion, 10);\r
+\r
+ if (_fV !== 8 && _fV !== 9) {\r
+ _s._wD(_str('badFV', _fV, _defaultFlashVersion));\r
+ _s.flashVersion = _fV = _defaultFlashVersion;\r
+ }\r
+\r
+ // debug flash movie, if applicable\r
+\r
+ var isDebug = (_s.debugMode || _s.debugFlash?'_debug.swf':'.swf');\r
+\r
+ if (_s.useHTML5Audio && !_s.html5Only && _s.audioFormats.mp4.required && _fV < 9) {\r
+ _s._wD(_str('needfl9'));\r
+ _s.flashVersion = _fV = 9;\r
+ }\r
+\r
+ _s.version = _s.versionNumber + (_s.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
+ _s.defaultOptions = _mixin(_s.defaultOptions, _s.flash9Options);\r
+ _s.features.buffering = true;\r
+ // +moviestar support\r
+ _s.defaultOptions = _mixin(_s.defaultOptions, _s.movieStarOptions);\r
+ _s.filePatterns.flash9 = new RegExp('\\.(mp3|' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
+ _s.features.movieStar = true;\r
+ } else {\r
+ _s.features.movieStar = false;\r
+ }\r
+\r
+ // regExp for flash canPlay(), etc.\r
+ _s.filePattern = _s.filePatterns[(_fV !== 8?'flash9':'flash8')];\r
+\r
+ // if applicable, use _debug versions of SWFs\r
+ _s.movieURL = (_fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug);\r
+\r
+ _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_fV > 8);\r
+\r
+ };\r
+\r
+ _setPolling = function(bPolling, bHighPerformance) {\r
+\r
+ if (!_s.o) {\r
+ return false;\r
+ }\r
+\r
+ _s.o._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 (_s.debugURLParam.test(_wl)) {\r
+ _s.debugMode = true;\r
+ }\r
+\r
+ // <d>\r
+ if (_id(_s.debugID)) {\r
+ return false;\r
+ }\r
+\r
+ var oD, oDebug, oTarget, oToggle, tmp;\r
+\r
+ if (_s.debugMode && !_id(_s.debugID) && ((!_hasConsole || !_s.useConsole) || (_s.useConsole && _hasConsole && !_s.consoleOnly))) {\r
+\r
+ oD = _doc.createElement('div');\r
+ oD.id = _s.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 = _s.debugID;\r
+ oDebug.style.display = (_s.debugMode?'block':'none');\r
+\r
+ if (_s.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
+ if (!o) {\r
+ return '';\r
+ } else {\r
+ return _s._wD(_str(o), errorLevel);\r
+ }\r
+\r
+ };\r
+\r
+ // last-resort debugging option\r
+\r
+ if (_wl.indexOf('sm2-debug=alert') + 1 && _s.debugMode) {\r
+ _s._wD = function(sText) {window.alert(sText);};\r
+ }\r
+\r
+ _toggleDebug = function() {\r
+\r
+ var o = _id(_s.debugID),\r
+ oT = _id(_s.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 (typeof 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 (_s.debugMode) {\r
+ css.push(_s.swfCSS.sm2Debug);\r
+ }\r
+\r
+ if (_s.debugFlash) {\r
+ css.push(_s.swfCSS.flashDebug);\r
+ }\r
+\r
+ if (_s.useHighPerformance) {\r
+ css.push(_s.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 = _s.getMoviePercent(),\r
+ css = _s.swfCSS,\r
+ error = {type:'FLASHBLOCK'};\r
+\r
+ if (_s.html5Only) {\r
+ return false;\r
+ }\r
+\r
+ if (!_s.ok()) {\r
+\r
+ if (_needsFlash) {\r
+ // make the movie more visible, so user can fix\r
+ _s.oMC.className = _getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);\r
+ _s._wD(name+': '+_str('fbTimeout')+(p?' ('+_str('fbLoaded')+')':''));\r
+ }\r
+\r
+ _s.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
+ if (_s.didFlashBlock) {\r
+ _s._wD(name+': Unblocked');\r
+ }\r
+\r
+ if (_s.oMC) {\r
+ _s.oMC.className = [_getSWFCSS(), css.swfDefault, css.swfLoaded + (_s.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');\r
+ }\r
+\r
+ }\r
+\r
+ };\r
+\r
+ _addOnEvent = function(sType, oMethod, oScope) {\r
+\r
+ if (typeof _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
+ // assume onready, if unspecified\r
+\r
+ if (!oOptions) {\r
+ oOptions = {\r
+ type: 'onready'\r
+ };\r
+ }\r
+\r
+ if (!_didInit && oOptions && !oOptions.ignoreInit) {\r
+ // not ready yet.\r
+ return false;\r
+ }\r
+\r
+ if (oOptions.type === 'ontimeout' && _s.ok()) {\r
+ // invalid case\r
+ return false;\r
+ }\r
+\r
+ var status = {\r
+ success: (oOptions && oOptions.ignoreInit?_s.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 && _s.useFlashBlock && !_s.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
+ _s._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
+ // flashblock 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
+ _win.setTimeout(function() {\r
+\r
+ if (_s.useFlashBlock) {\r
+ _flashBlockHandler();\r
+ }\r
+\r
+ _processOnEvents();\r
+\r
+ // call user-defined "onload", scoped to window\r
+\r
+ if (_s.onload instanceof Function) {\r
+ _wDS('onload', 1);\r
+ _s.onload.apply(_win);\r
+ _wDS('onloadOK', 1);\r
+ }\r
+\r
+ if (_s.waitForWindowLoad) {\r
+ _event.add(_win, '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 = _win.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 (typeof AX !== 'undefined') {\r
+ try {\r
+ obj = new AX('ShockwaveFlash.ShockwaveFlash');\r
+ } catch(e) {\r
+ // oh well\r
+ }\r
+ hasPlugin = (!!obj);\r
}\r
+\r
+ _hasFlash = hasPlugin;\r
+\r
+ return hasPlugin;\r
+\r
};\r
\r
- _normalizeMovieURL = function(smURL) {\r
- var urlParams = null;\r
- if (smURL) {\r
- if (smURL.match(/\.swf(\?.*)?$/i)) {\r
- urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4);\r
- if (urlParams) {\r
- return smURL; // assume user knows what they're doing\r
- }\r
- } else if (smURL.lastIndexOf('/') !== smURL.length - 1) {\r
- smURL = smURL + '/';\r
+ _featureCheck = function() {\r
+\r
+ var needsFlash, item,\r
+\r
+ // iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (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
+ _s.hasHTML5 = false;\r
+\r
+ // ignore flash case, however\r
+ _s.html5Only = true;\r
+\r
+ if (_s.oMC) {\r
+ _s.oMC.style.display = 'none';\r
}\r
+\r
+ return false;\r
+\r
}\r
- return (smURL && smURL.lastIndexOf('/') !== - 1?smURL.substr(0, smURL.lastIndexOf('/') + 1):'./') + _s.movieURL;\r
- };\r
\r
- _setVersionInfo = function() {\r
- if (_fV !== 8 && _fV !== 9) {\r
- _s._wD(_str('badFV', _fV, _defaultFlashVersion));\r
- _s.flashVersion = _defaultFlashVersion;\r
+ if (_s.useHTML5Audio) {\r
+\r
+ if (!_s.html5 || !_s.html5.canPlayType) {\r
+ _s._wD('SoundManager: No HTML5 Audio() support detected.');\r
+ _s.hasHTML5 = false;\r
+ return true;\r
+ } else {\r
+ _s.hasHTML5 = true;\r
+ }\r
+ if (_isBadSafari) {\r
+ _s._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
+ if (_detectFlash()) {\r
+ return true;\r
+ }\r
+ }\r
+ } else {\r
+\r
+ // flash needed (or, HTML5 needs enabling.)\r
+ return true;\r
+\r
}\r
- var isDebug = (_s.debugMode || _s.debugFlash?'_debug.swf':'.swf'); // debug flash movie, if applicable\r
- if (_s.useHTML5Audio && !_html5Only && _s.audioFormats.mp4.required && _s.flashVersion < 9) {\r
- _s._wD(_str('needfl9'));\r
- _s.flashVersion = 9;\r
+\r
+ for (item in _s.audioFormats) {\r
+ if (_s.audioFormats.hasOwnProperty(item)) {\r
+ if ((_s.audioFormats[item].required && !_s.html5.canPlayType(_s.audioFormats[item].type)) || _s.flash[item] || _s.flash[_s.audioFormats[item].type]) {\r
+ // flash may be required, or preferred for this format\r
+ needsFlash = true;\r
+ }\r
+ }\r
}\r
- _fV = _s.flashVersion; // short-hand for internal use\r
- _s.version = _s.versionNumber + (_html5Only?' (HTML5-only mode)':(_fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)'));\r
- // set up default options\r
- if (_fV > 8) {\r
- _s.defaultOptions = _mixin(_s.defaultOptions, _s.flash9Options);\r
- _s.features.buffering = true;\r
+\r
+ // sanity check..\r
+ if (_s.ignoreFlash) {\r
+ needsFlash = false;\r
}\r
- if (_fV > 8 && _s.useMovieStar) {\r
- // flash 9+ support for movieStar formats as well as MP3\r
- _s.defaultOptions = _mixin(_s.defaultOptions, _s.movieStarOptions);\r
- _s.filePatterns.flash9 = new RegExp('\\.(mp3|' + _s.netStreamTypes.join('|') + ')(\\?.*)?$', 'i');\r
- _s.mimePattern = _s.netStreamMimeTypes;\r
- _s.features.movieStar = true;\r
- } else {\r
- _s.useMovieStar = false;\r
- _s.features.movieStar = false;\r
+\r
+ _s.html5Only = (_s.hasHTML5 && _s.useHTML5Audio && !needsFlash);\r
+\r
+ return (!_s.html5Only);\r
+\r
+ };\r
+\r
+ _startTimer = function(oSound) {\r
+\r
+ if (!oSound._hasTimer) {\r
+ oSound._hasTimer = true;\r
}\r
- _s.filePattern = _s.filePatterns[(_fV !== 8?'flash9':'flash8')];\r
- _s.movieURL = (_fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf',isDebug);\r
- _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_fV > 8);\r
+\r
};\r
\r
- _setPolling = function(bPolling, bHighPerformance) {\r
- if (!_s.o || !_s.allowPolling) {\r
- return false;\r
+ _stopTimer = function(oSound) {\r
+\r
+ if (oSound._hasTimer) {\r
+ oSound._hasTimer = false;\r
}\r
- _s.o._setPolling(bPolling, bHighPerformance);\r
+\r
};\r
\r
- function _initDebug() {\r
- if (_s.debugURLParam.test(_wl)) {\r
- _s.debugMode = true; // allow force of debug mode via URL\r
+ _catchError = function(options) {\r
+\r
+ options = (typeof options !== 'undefined' ? options : {});\r
+\r
+ if (_s.onerror instanceof Function) {\r
+ _s.onerror.apply(_win, [{type:(typeof options.type !== 'undefined' ? options.type : null)}]);\r
}\r
- // <d>\r
- if (_id(_s.debugID)) {\r
+\r
+ if (typeof options.fatal !== 'undefined' && options.fatal) {\r
+ _s.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
- var oD, oDebug, oTarget, oToggle, tmp;\r
- if (_s.debugMode && !_id(_s.debugID) && ((!_hasConsole || !_s.useConsole) || (_s.useConsole && _hasConsole && !_s.consoleOnly))) {\r
- oD = _doc.createElement('div');\r
- oD.id = _s.debugID + '-toggle';\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
- oD.appendChild(_doc.createTextNode('-'));\r
- oD.onclick = _toggleDebug;\r
- oD.title = 'Toggle SM2 debug console';\r
- if (_ua.match(/msie 6/i)) {\r
- oD.style.position = 'absolute';\r
- oD.style.cursor = 'hand';\r
- }\r
- for (tmp in oToggle) {\r
- if (oToggle.hasOwnProperty(tmp)) {\r
- oD.style[tmp] = oToggle[tmp];\r
- }\r
- }\r
- oDebug = _doc.createElement('div');\r
- oDebug.id = _s.debugID;\r
- oDebug.style.display = (_s.debugMode?'block':'none');\r
- if (_s.debugMode && !_id(oD.id)) {\r
- try {\r
- oTarget = _getDocument();\r
- oTarget.appendChild(oD);\r
- } catch(e2) {\r
- throw new Error(_str('appXHTML'));\r
+\r
+ var aF = _s.audioFormats, i, item;\r
+\r
+ for (item in aF) {\r
+ if (aF.hasOwnProperty(item)) {\r
+ if (item === 'mp3' || item === 'mp4') {\r
+ _s._wD(_sm+': Using flash fallback for '+item+' format');\r
+ _s.html5[item] = false;\r
+ // assign result to related formats, too\r
+ if (aF[item] && aF[item].related) {\r
+ for (i = aF[item].related.length; i--;) {\r
+ _s.html5[aF[item].related[i]] = false;\r
+ }\r
+ }\r
}\r
- oTarget.appendChild(oDebug);\r
}\r
}\r
- oTarget = null;\r
+\r
+ };\r
+\r
+ /**\r
+ * Pseudo-private flash/ExternalInterface methods\r
+ * ----------------------------------------------\r
+ */\r
+\r
+ this._setSandboxType = function(sandboxType) {\r
+\r
+ // <d>\r
+ var sb = _s.sandbox;\r
+\r
+ sb.type = sandboxType;\r
+ sb.description = sb.types[(typeof sb.types[sandboxType] !== 'undefined'?sandboxType:'unknown')];\r
+\r
+ _s._wD('Flash security sandbox type: ' + sb.type);\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
- _createMovie = function(smID, smURL) {\r
+ };\r
\r
- var specialCase = null,\r
- remoteURL = (smURL?smURL:_s.url),\r
- localURL = (_s.altURL?_s.altURL:remoteURL),\r
- oEmbed, oMovie, oTarget = _getDocument(), tmp, movieHTML, oEl, extraClass = _getSWFCSS(), s, x, sClass, side = '100%', isRTL = null, html = _doc.getElementsByTagName('html')[0];\r
- isRTL = (html && html.dir && html.dir.match(/rtl/i));\r
- smID = (typeof smID === 'undefined'?_s.id:smID);\r
+ this._externalInterfaceOK = function(flashDate) {\r
+\r
+ // flash callback confirming flash loaded, EI working etc.\r
+ // flashDate = approx. timing/delay info for JS/flash bridge\r
+\r
+ if (_s.swfLoaded) {\r
+ return false;\r
+ }\r
+\r
+ var eiTime = new Date().getTime();\r
+\r
+ _s._wD(_smc+'externalInterfaceOK()' + (flashDate?' (~' + (eiTime - flashDate) + ' ms)':''));\r
+ _debugTS('swf', true);\r
+ _debugTS('flashtojs', true);\r
+ _s.swfLoaded = true;\r
+ _tryInitOnFocus = false;\r
+\r
+ if (_isBadSafari) {\r
+ _badSafariFix();\r
+ }\r
+\r
+ if (_isIE) {\r
+ // IE needs a timeout OR delay until window.onload - may need TODO: investigating\r
+ setTimeout(_init, 100);\r
+ } else {\r
+ _init();\r
+ }\r
+\r
+ };\r
+\r
+ /**\r
+ * Private initialization helpers\r
+ * ------------------------------\r
+ */\r
+\r
+ _createMovie = function(smID, smURL) {\r
\r
if (_didAppend && _appendSuccess) {\r
- return false; // ignore if already succeeded\r
+ // ignore if already succeeded\r
+ return false;\r
}\r
\r
function _initMsg() {\r
- _s._wD('-- SoundManager 2 ' + _s.version + (!_html5Only && _s.useHTML5Audio?(_s.hasHTML5?' + HTML5 audio':', no HTML5 audio support'):'') + (!_html5Only ? (_s.useMovieStar?', MovieStar mode':'') + (_s.useHighPerformance?', high performance mode, ':', ') + (( _s.flashPollingInterval ? 'custom (' + _s.flashPollingInterval + 'ms)' : (_s.useFastPolling?'fast':'normal')) + ' polling') + (_s.wmode?', wmode: ' + _s.wmode:'') + (_s.debugFlash?', flash debug mode':'') + (_s.useFlashBlock?', flashBlock mode':'') : '') + ' --', 1);\r
+ _s._wD('-- SoundManager 2 ' + _s.version + (!_s.html5Only && _s.useHTML5Audio?(_s.hasHTML5?' + HTML5 audio':', no HTML5 audio support'):'') + (!_s.html5Only ? (_s.useHighPerformance?', high performance mode, ':', ') + (( _s.flashPollingInterval ? 'custom (' + _s.flashPollingInterval + 'ms)' : 'normal') + ' polling') + (_s.wmode?', wmode: ' + _s.wmode:'') + (_s.debugFlash?', flash debug mode':'') + (_s.useFlashBlock?', flashBlock mode':'') : '') + ' --', 1);\r
}\r
\r
- if (_html5Only) {\r
+ if (_s.html5Only) {\r
+\r
+ // 100% HTML5 mode\r
_setVersionInfo();\r
+\r
_initMsg();\r
_s.oMC = _id(_s.movieID);\r
_init();\r
+\r
// prevent multiple init attempts\r
_didAppend = true;\r
+\r
_appendSuccess = true;\r
+\r
return false;\r
+\r
}\r
\r
- _didAppend = true;\r
+ // flash path\r
+ var remoteURL = (smURL || _s.url),\r
+ localURL = (_s.altURL || remoteURL),\r
+ swfTitle = 'JS/Flash audio component (SoundManager 2)',\r
+ oEmbed, oMovie, oTarget = _getDocument(), tmp, movieHTML, oEl, extraClass = _getSWFCSS(),\r
+ s, x, sClass, side = 'auto', isRTL = null,\r
+ html = _doc.getElementsByTagName('html')[0];\r
+\r
+ isRTL = (html && html.dir && html.dir.match(/rtl/i));\r
+ smID = (typeof smID === 'undefined'?_s.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
- _s.url = _normalizeMovieURL(_s._overHTTP?remoteURL:localURL);\r
+ _s.url = _normalizeMovieURL(_overHTTP?remoteURL:localURL);\r
smURL = _s.url;\r
\r
- _s.wmode = (!_s.wmode && _s.useHighPerformance && !_s.useMovieStar?'transparent':_s.wmode);\r
+ _s.wmode = (!_s.wmode && _s.useHighPerformance ? 'transparent' : _s.wmode);\r
\r
if (_s.wmode !== null && (_ua.match(/msie 8/i) || (!_isIE && !_s.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
_s.specialWmodeCase = true;\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 Jan.2011 (?)\r
_wDS('spcWmode');\r
_s.wmode = null;\r
}\r
'quality': 'high',\r
'allowScriptAccess': _s.allowScriptAccess,\r
'bgcolor': _s.bgColor,\r
- 'pluginspage': _s._http+'//www.macromedia.com/go/getflashplayer',\r
+ 'pluginspage': _http+'www.macromedia.com/go/getflashplayer',\r
+ 'title': swfTitle,\r
'type': 'application/x-shockwave-flash',\r
'wmode': _s.wmode,\r
- 'hasPriority': 'true' // http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html\r
+ // http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html\r
+ 'hasPriority': 'true'\r
};\r
\r
if (_s.debugFlash) {\r
}\r
\r
if (!_s.wmode) {\r
- delete oEmbed.wmode; // don't write empty attribute\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 = '<object id="' + smID + '" data="' + smURL + '" type="' + oEmbed.type + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+_s._http+'//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + oEmbed.width + '" height="' + oEmbed.height + '"><param name="movie" value="' + smURL + '" /><param name="AllowScriptAccess" value="' + _s.allowScriptAccess + '" /><param name="quality" value="' + oEmbed.quality + '" />' + (_s.wmode?'<param name="wmode" value="' + _s.wmode + '" /> ':'') + '<param name="bgcolor" value="' + _s.bgColor + '" />' + (_s.debugFlash?'<param name="FlashVars" value="' + oEmbed.FlashVars + '" />':'') + '</object>';\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" width="' + oEmbed.width + '" height="' + oEmbed.height + '">',\r
+ param('movie', smURL),\r
+ param('AllowScriptAccess', _s.allowScriptAccess),\r
+ param('quality', oEmbed.quality),\r
+ (_s.wmode? param('wmode', _s.wmode): ''),\r
+ param('bgcolor', _s.bgColor),\r
+ param('hasPriority', 'true'),\r
+ (_s.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
oTarget = _getDocument();\r
\r
if (oTarget) {\r
- _s.oMC = _id(_s.movieID)?_id(_s.movieID):_doc.createElement('div');\r
+\r
+ _s.oMC = (_id(_s.movieID) || _doc.createElement('div'));\r
+\r
if (!_s.oMC.id) {\r
+\r
_s.oMC.id = _s.movieID;\r
_s.oMC.className = _s.swfCSS.swfDefault + ' ' + extraClass;\r
- // "hide" flash movie\r
s = null;\r
oEl = null;\r
+\r
if (!_s.useFlashBlock) {\r
if (_s.useHighPerformance) {\r
+ // on-screen at all times\r
s = {\r
'position': 'fixed',\r
'width': '8px',\r
'overflow': 'hidden'\r
};\r
} else {\r
+ // hide off-screen, lower priority\r
s = {\r
'position': 'absolute',\r
'width': '6px',\r
}\r
}\r
}\r
+\r
if (_isWebkit) {\r
- _s.oMC.style.zIndex = 10000; // soundcloud-reported render/crash fix, safari 5\r
+ // soundcloud-reported render/crash fix, safari 5\r
+ _s.oMC.style.zIndex = 10000;\r
}\r
+\r
if (!_s.debugFlash) {\r
for (x in s) {\r
if (s.hasOwnProperty(x)) {\r
}\r
}\r
}\r
+\r
try {\r
if (!_isIE) {\r
_s.oMC.appendChild(oMovie);\r
}\r
_appendSuccess = true;\r
} catch(e) {\r
- throw new Error(_str('appXHTML'));\r
+ throw new Error(_str('domError')+' \n'+e.toString());\r
}\r
+\r
} else {\r
- // it's already in the document.\r
+\r
+ // SM2 container is already in the document (eg. flashblock use case)\r
sClass = _s.oMC.className;\r
_s.oMC.className = (sClass?sClass+' ':_s.swfCSS.swfDefault) + (extraClass?' '+extraClass:'');\r
_s.oMC.appendChild(oMovie);\r
oEl.innerHTML = movieHTML;\r
}\r
_appendSuccess = true;\r
+\r
}\r
- }\r
\r
- if (specialCase) {\r
- _s._wD(specialCase);\r
}\r
\r
+ _didAppend = true;\r
_initMsg();\r
- _s._wD(_smc+'createMovie(): Trying to load ' + smURL + (!_s._overHTTP && _s.altURL?' (alternate URL)':''), 1);\r
+ _s._wD(_smc+'createMovie(): Trying to load ' + smURL + (!_overHTTP && _s.altURL?' (alternate URL)':''), 1);\r
\r
return true;\r
- };\r
\r
- _idCheck = this.getSoundById;\r
+ };\r
\r
_initMovie = function() {\r
- if (_html5Only) {\r
+\r
+ if (_s.html5Only) {\r
_createMovie();\r
return false;\r
}\r
+\r
// attempt to get, or create, movie\r
+ // may already exist\r
if (_s.o) {\r
- return false; // may already exist\r
+ return false;\r
}\r
- _s.o = _s.getMovie(_s.id); // inline markup\r
+\r
+ // inline markup case\r
+ _s.o = _s.getMovie(_s.id);\r
+\r
if (!_s.o) {\r
if (!_oRemoved) {\r
// try to create\r
}\r
_s.o = _s.getMovie(_s.id);\r
}\r
+\r
+ // <d>\r
if (_s.o) {\r
- _s._wD(_smc+'initMovie(): Got '+_s.o.nodeName+' element ('+(_didAppend?'created via JS':'static HTML')+')');\r
_wDS('waitEI');\r
}\r
+ // </d>\r
+\r
if (_s.oninitmovie instanceof Function) {\r
setTimeout(_s.oninitmovie, 1);\r
}\r
+\r
return true;\r
- };\r
\r
- _go = function(sURL) {\r
- // where it all begins.\r
- if (sURL) {\r
- _s.url = sURL;\r
- }\r
- _initMovie();\r
};\r
\r
_delayWaitForEI = function() {\r
- setTimeout(_waitForEI, 500);\r
+\r
+ setTimeout(_waitForEI, 1000);\r
+\r
};\r
\r
_waitForEI = function() {\r
+\r
if (_waitingForEI) {\r
return false;\r
}\r
+\r
_waitingForEI = true;\r
_event.remove(_win, 'load', _delayWaitForEI);\r
+\r
if (_tryInitOnFocus && !_isFocused) {\r
+ // giant Safari 3.1 hack - assume mousemove = focus given lack of focus event\r
_wDS('waitFocus');\r
return false;\r
}\r
+\r
var p;\r
if (!_didInit) {\r
p = _s.getMoviePercent();\r
_s._wD(_str('waitImpatient', (p === 100?' (SWF loaded)':(p > 0?' (SWF ' + p + '% loaded)':''))));\r
}\r
+\r
setTimeout(function() {\r
+\r
p = _s.getMoviePercent();\r
+\r
+ // <d>\r
if (!_didInit) {\r
_s._wD(_sm + ': No Flash response within expected time.\nLikely causes: ' + (p === 0?'Loading ' + _s.movieURL + ' may have failed (and/or Flash ' + _fV + '+ not present?), ':'') + 'Flash blocked or JS-Flash security error.' + (_s.debugFlash?' ' + _str('checkSWF'):''), 2);\r
- if (!_s._overHTTP && p) {\r
+ if (!_overHTTP && p) {\r
_wDS('localFail', 2);\r
if (!_s.debugFlash) {\r
_wDS('tryDebug', 2);\r
// if 0 (not null), probably a 404.\r
_s._wD(_str('swf404', _s.url));\r
}\r
- _debugTS('flashtojs', false, ': Timed out' + _s._overHTTP?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)');\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
}\r
}\r
}\r
- }, _s.flashLoadTimeout);\r
- };\r
-\r
- _go = function(sURL) {\r
- // where it all begins.\r
- if (sURL) {\r
- _s.url = sURL;\r
- }\r
- _initMovie();\r
- };\r
-\r
- // <d>\r
- _wDS = function(o, errorLevel) {\r
- if (!o) {\r
- return '';\r
- } else {\r
- return _s._wD(_str(o), errorLevel);\r
- }\r
- };\r
-\r
- if (_wl.indexOf('debug=alert') + 1 && _s.debugMode) {\r
- _s._wD = function(sText) {window.alert(sText);};\r
- }\r
-\r
- _toggleDebug = function() {\r
- var o = _id(_s.debugID),\r
- oT = _id(_s.debugID + '-toggle');\r
- if (!o) {\r
- return false;\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
- _debugOpen = !_debugOpen;\r
- };\r
-\r
- _debugTS = function(sEventType, bSuccess, sMessage) {\r
- // troubleshooter debug hooks\r
- if (typeof sm2Debugger !== 'undefined') {\r
- try {\r
- sm2Debugger.handleEvent(sEventType, bSuccess, sMessage);\r
- } catch(e) {\r
- // oh well\r
- }\r
- }\r
- return true;\r
- };\r
- // </d>\r
-\r
- _getSWFCSS = function() {\r
- var css = [];\r
- if (_s.debugMode) {\r
- css.push(_s.swfCSS.sm2Debug);\r
- }\r
- if (_s.debugFlash) {\r
- css.push(_s.swfCSS.flashDebug);\r
- }\r
- if (_s.useHighPerformance) {\r
- css.push(_s.swfCSS.highPerf);\r
- }\r
- return css.join(' ');\r
- };\r
-\r
- _flashBlockHandler = function() {\r
- // *possible* flash block situation.\r
- var name = _str('fbHandler'), p = _s.getMoviePercent(), css = _s.swfCSS;\r
- if (!_s.ok()) {\r
- if (_needsFlash) {\r
- // make the movie more visible, so user can fix\r
- _s.oMC.className = _getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);\r
- _s._wD(name+': '+_str('fbTimeout')+(p?' ('+_str('fbLoaded')+')':''));\r
- }\r
- _s.didFlashBlock = true;\r
- _processOnEvents({type:'ontimeout',ignoreInit:true}); // fire onready(), complain lightly\r
- if (_s.onerror instanceof Function) {\r
- _s.onerror.apply(_win);\r
- }\r
- } else {\r
- // SM2 loaded OK (or recovered)\r
- if (_s.didFlashBlock) {\r
- _s._wD(name+': Unblocked');\r
- }\r
- if (_s.oMC) {\r
- _s.oMC.className = [_getSWFCSS(), css.swfDefault, css.swfLoaded + (_s.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');\r
- }\r
- }\r
- };\r
-\r
- _handleFocus = function() {\r
- function cleanup() {\r
- _event.remove(_win, 'focus', _handleFocus);\r
- _event.remove(_win, 'load', _handleFocus);\r
- }\r
- if (_isFocused || !_tryInitOnFocus) {\r
- cleanup();\r
- return true;\r
- }\r
- _okToDisable = true;\r
- _isFocused = true;\r
- _s._wD(_smc+'handleFocus()');\r
- if (_isSafari && _tryInitOnFocus) {\r
- // giant Safari 3.1 hack - assume mousemove = focus given lack of focus event\r
- _event.remove(_win, 'mousemove', _handleFocus);\r
- }\r
- // allow init to restart\r
- _waitingForEI = false;\r
- cleanup();\r
- return true;\r
- };\r
-\r
- _initComplete = function(bNoDisable) {\r
- if (_didInit) {\r
- return false;\r
- }\r
- if (_html5Only) {\r
- // all good.\r
- _s._wD('-- SoundManager 2: loaded --');\r
- _didInit = true;\r
- _processOnEvents();\r
- _initUserOnload();\r
- return true;\r
- }\r
- var sClass = _s.oMC.className,\r
- wasTimeout = (_s.useFlashBlock && _s.flashLoadTimeout && !_s.getMoviePercent());\r
- if (!wasTimeout) {\r
- _didInit = true;\r
- }\r
- _s._wD('-- SoundManager 2 ' + (_disabled?'failed to load':'loaded') + ' (' + (_disabled?'security/load error':'OK') + ') --', 1);\r
- if (_disabled || bNoDisable) {\r
- if (_s.useFlashBlock) {\r
- _s.oMC.className = _getSWFCSS() + ' ' + (_s.getMoviePercent() === null?_s.swfCSS.swfTimedout:_s.swfCSS.swfError);\r
- }\r
- _processOnEvents({type:'ontimeout'});\r
- _debugTS('onload', false);\r
- if (_s.onerror instanceof Function) {\r
- _s.onerror.apply(_win);\r
- }\r
- return false;\r
- } else {\r
- _debugTS('onload', true);\r
- }\r
- _event.add(_win, 'unload', _doNothing); // prevent browser from showing cached state via back button, because flash will be dead\r
- if (_s.waitForWindowLoad && !_windowLoaded) {\r
- _wDS('waitOnload');\r
- _event.add(_win, 'load', _initUserOnload);\r
- return false;\r
- } else {\r
- if (_s.waitForWindowLoad && _windowLoaded) {\r
- _wDS('docLoaded');\r
- }\r
- _initUserOnload();\r
- }\r
- return true;\r
- };\r
-\r
- _addOnEvent = function(sType, oMethod, oScope) {\r
- if (typeof _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
-\r
- _processOnEvents = function(oOptions) {\r
- if (!oOptions) { // assume onready, if unspecified\r
- oOptions = {\r
- type: 'onready'\r
- };\r
- }\r
- if (!_didInit && oOptions && !oOptions.ignoreInit) {\r
- // not ready yet.\r
- return false;\r
- }\r
- var status = {\r
- success: (oOptions && oOptions.ignoreInit?_s.ok():!_disabled)\r
- },\r
- srcQueue = (oOptions && oOptions.type?_on_queue[oOptions.type]||[]:[]), // queue specified by type, or none\r
- queue = [], i, j,\r
- canRetry = (_needsFlash && _s.useFlashBlock && !_s.ok());\r
- for (i = 0; i < srcQueue.length; i++) {\r
- if (srcQueue[i].fired !== true) {\r
- queue.push(srcQueue[i]);\r
- }\r
- }\r
- if (queue.length) {\r
- _s._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, [status]);\r
- } else {\r
- queue[i].method(status);\r
- }\r
- if (!canRetry) { // flashblock case doesn't count here\r
- queue[i].fired = true;\r
- }\r
- }\r
- }\r
- return true;\r
- };\r
-\r
- _initUserOnload = function() {\r
- _win.setTimeout(function() {\r
- if (_s.useFlashBlock) {\r
- _flashBlockHandler();\r
- }\r
- _processOnEvents();\r
- // call user-defined "onload", scoped to window\r
- if (_s.onload instanceof Function) {\r
- _wDS('onload', 1);\r
- _s.onload.apply(_win);\r
- _wDS('onloadOK', 1);\r
- }\r
- if (_s.waitForWindowLoad) {\r
- _event.add(_win, 'load', _initUserOnload);\r
- }\r
- },1);\r
+\r
+ }, _s.flashLoadTimeout);\r
+\r
};\r
\r
- _detectFlash = function() {\r
+ _handleFocus = 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
+ function cleanup() {\r
+ _event.remove(_win, 'focus', _handleFocus);\r
+ _event.remove(_win, 'load', _handleFocus);\r
+ }\r
\r
- if (_hasFlash !== undefined) {\r
- // this work has already been done.\r
- return _hasFlash;\r
+ if (_isFocused || !_tryInitOnFocus) {\r
+ cleanup();\r
+ return true;\r
}\r
\r
- var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = _win.ActiveXObject;\r
+ _okToDisable = true;\r
+ _isFocused = true;\r
+ _s._wD(_smc+'handleFocus()');\r
\r
- if (nP && nP.length) {\r
+ if (_isSafari && _tryInitOnFocus) {\r
+ _event.remove(_win, 'mousemove', _handleFocus);\r
+ }\r
\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
+ // allow init to restart\r
+ _waitingForEI = false;\r
\r
- } else if (typeof AX !== 'undefined') {\r
+ cleanup();\r
+ return true;\r
\r
- try {\r
- obj = new AX('ShockwaveFlash.ShockwaveFlash');\r
- } catch(e) {\r
- // oh well\r
- }\r
- hasPlugin = (!!obj);\r
+ };\r
\r
- }\r
+ _showSupport = function() {\r
\r
- _hasFlash = hasPlugin;\r
+ var item, tests = [];\r
\r
- return hasPlugin;\r
+ if (_s.useHTML5Audio && _s.hasHTML5) {\r
+ for (item in _s.audioFormats) {\r
+ if (_s.audioFormats.hasOwnProperty(item)) {\r
+ tests.push(item + ': ' + _s.html5[item] + (!_s.html5[item] && _hasFlash && _s.flash[item] ? ' (using flash)' : (_s.preferFlash && _s.flash[item] && _hasFlash ? ' (preferring flash)': (!_s.html5[item] ? ' (' + (_s.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : ''))));\r
+ }\r
+ }\r
+ _s._wD('-- SoundManager 2: HTML5 support tests ('+_s.html5Test+'): '+tests.join(', ')+' --',1);\r
+ }\r
\r
};\r
\r
- _featureCheck = function() {\r
- var needsFlash, item,\r
- isSpecial = (_ua.match(/iphone os (1|2|3_0|3_1)/i)?true:false); // iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (iPad) + iOS4 works.\r
- if (isSpecial) {\r
- _s.hasHTML5 = false; // has Audio(), but is broken; let it load links directly.\r
- _html5Only = true; // ignore flash case, however\r
- if (_s.oMC) {\r
- _s.oMC.style.display = 'none';\r
- }\r
+ _initComplete = function(bNoDisable) {\r
+\r
+ if (_didInit) {\r
return false;\r
}\r
- if (_s.useHTML5Audio) {\r
- if (!_s.html5 || !_s.html5.canPlayType) {\r
- _s._wD('SoundManager: No HTML5 Audio() support detected.');\r
- _s.hasHTML5 = false;\r
- return true;\r
- } else {\r
- _s.hasHTML5 = true;\r
+\r
+ if (_s.html5Only) {\r
+ // all good.\r
+ _s._wD('-- SoundManager 2: loaded --');\r
+ _didInit = true;\r
+ _initUserOnload();\r
+ _debugTS('onload', true);\r
+ return true;\r
+ }\r
+\r
+ var wasTimeout = (_s.useFlashBlock && _s.flashLoadTimeout && !_s.getMoviePercent()),\r
+ error;\r
+\r
+ if (!wasTimeout) {\r
+ _didInit = true;\r
+ if (_disabled) {\r
+ error = {type: (!_hasFlash && _needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')};\r
}\r
- if (_isBadSafari) {\r
- _s._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
- if (_detectFlash()) {\r
- return true;\r
- }\r
+ }\r
+\r
+ _s._wD('-- SoundManager 2 ' + (_disabled?'failed to load':'loaded') + ' (' + (_disabled?'security/load error':'OK') + ') --', 1);\r
+\r
+ if (_disabled || bNoDisable) {\r
+ if (_s.useFlashBlock && _s.oMC) {\r
+ _s.oMC.className = _getSWFCSS() + ' ' + (_s.getMoviePercent() === null?_s.swfCSS.swfTimedout:_s.swfCSS.swfError);\r
}\r
+ _processOnEvents({type:'ontimeout', error:error});\r
+ _debugTS('onload', false);\r
+ _catchError(error);\r
+ return false;\r
} else {\r
- // flash required.\r
- return true;\r
+ _debugTS('onload', true);\r
}\r
- for (item in _s.audioFormats) {\r
- if (_s.audioFormats.hasOwnProperty(item) && _s.audioFormats[item].required && !_s.html5.canPlayType(_s.audioFormats[item].type)) {\r
- // may need flash for this format?\r
- needsFlash = true;\r
+\r
+ if (_s.waitForWindowLoad && !_windowLoaded) {\r
+ _wDS('waitOnload');\r
+ _event.add(_win, 'load', _initUserOnload);\r
+ return false;\r
+ } else {\r
+ // <d>\r
+ if (_s.waitForWindowLoad && _windowLoaded) {\r
+ _wDS('docLoaded');\r
}\r
+ // </d>\r
+ _initUserOnload();\r
}\r
- // sanity check..\r
- if (_s.ignoreFlash) {\r
- needsFlash = false;\r
- }\r
- _html5Only = (_s.useHTML5Audio && _s.hasHTML5 && !needsFlash && !_s.requireFlash);\r
- return (_detectFlash() && needsFlash);\r
+\r
+ return true;\r
+\r
};\r
\r
_init = function() {\r
- var item, tests = [];\r
+\r
_wDS('init');\r
\r
// called after onload()\r
+\r
if (_didInit) {\r
_wDS('didInit');\r
return false;\r
_event.remove(_win, 'load', _s.beginDelayedInit);\r
}\r
\r
- if (_s.hasHTML5) {\r
- for (item in _s.audioFormats) {\r
- if (_s.audioFormats.hasOwnProperty(item)) {\r
- tests.push(item+': '+_s.html5[item]);\r
- }\r
- }\r
- _s._wD('-- SoundManager 2: HTML5 support tests ('+_s.html5Test+'): '+tests.join(', ')+' --',1);\r
- }\r
-\r
- if (_html5Only) {\r
+ if (_s.html5Only) {\r
if (!_didInit) {\r
// we don't need no steenking flash!\r
_cleanup();\r
\r
// flash path\r
_initMovie();\r
+\r
try {\r
+\r
_wDS('flashJS');\r
- _s.o._externalInterfaceTest(false); // attempt to talk to Flash\r
- if (!_s.allowPolling) {\r
- _wDS('noPolling', 1);\r
- } else {\r
- _setPolling(true, _s.flashPollingInterval ? _s.flashPollingInterval : (_s.useFastPolling ? 10 : 50));\r
- }\r
+\r
+ // attempt to talk to Flash\r
+ _s.o._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, (_s.flashPollingInterval || (_s.useHighPerformance ? 10 : 50)));\r
+\r
if (!_s.debugMode) {\r
+ // stop the SWF from making debug output calls to JS\r
_s.o._disableDebug();\r
}\r
+\r
_s.enabled = true;\r
_debugTS('jstoflash', true);\r
+\r
+ if (!_s.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(_win, 'unload', _doNothing);\r
+ }\r
+\r
} catch(e) {\r
+\r
_s._wD('js/flash exception: ' + e.toString());\r
_debugTS('jstoflash', false);\r
- _failSafely(true); // don't disable, for reboot()\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
- // event cleanup\r
+\r
+ // disconnect events\r
_cleanup();\r
- return true;\r
- };\r
\r
- _beginInit = function() {\r
- if (_initPending) {\r
- return false;\r
- }\r
- _createMovie();\r
- _initMovie();\r
- _initPending = true;\r
return true;\r
+\r
};\r
\r
- _dcLoaded = function() {\r
+ _domContentLoaded = function() {\r
+\r
if (_didDCLoaded) {\r
return false;\r
}\r
+\r
_didDCLoaded = true;\r
_initDebug();\r
- if (!_s.useHTML5Audio) {\r
- if (!_detectFlash()) {\r
- _s._wD('SoundManager: No Flash detected, trying HTML5');\r
- _s.useHTML5Audio = true;\r
- }\r
- }\r
- _testHTML5();\r
- _s.html5.usingFlash = _featureCheck();\r
- _needsFlash = _s.html5.usingFlash;\r
- _didDCLoaded = true;\r
- if (_doc.removeEventListener) {\r
- _doc.removeEventListener('DOMContentLoaded', _dcLoaded, false);\r
- }\r
- _go();\r
- return true;\r
- };\r
-\r
- _startTimer = function(oSound) {\r
- if (!oSound._hasTimer) {\r
- oSound._hasTimer = true;\r
- }\r
- };\r
\r
- _stopTimer = function(oSound) {\r
- if (oSound._hasTimer) {\r
- oSound._hasTimer = false;\r
- }\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
- _die = function() {\r
- if (_s.onerror instanceof Function) {\r
- _s.onerror();\r
- }\r
- _s.disable();\r
- };\r
+ var a = 'sm2-usehtml5audio=', l = _wl.toLowerCase(), b = null,\r
+ a2 = 'sm2-preferflash=', b2 = null, hasCon = (typeof console !== 'undefined' && typeof console.log !== 'undefined');\r
\r
- _badSafariFix = function() {\r
- // special case: "bad" Safari can fall back to flash for MP3/MP4\r
- if (!_isBadSafari || !_detectFlash()) {\r
- return false; // doesn't apply\r
- }\r
- var aF = _s.audioFormats, i, item;\r
- for (item in aF) {\r
- if (aF.hasOwnProperty(item)) {\r
- // special case: "bad" Safari can fall back to flash for MP3/MP4\r
- if (item === 'mp3' || item === 'mp4') {\r
- _s._wD(_sm+': Using flash fallback for '+item+' format');\r
- _s.html5[item] = false;\r
- // assign result to related formats, too\r
- if (aF[item] && aF[item].related) {\r
- for (i = aF[item].related.length; i--;) {\r
- _s.html5[aF[item].related[i]] = false;\r
- }\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
+ _s.useHTML5Audio = b;\r
}\r
- }\r
- };\r
\r
- // pseudo-private methods called by Flash\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
+ _s.preferFlash = b2;\r
+ }\r
\r
- this._setSandboxType = function(sandboxType) {\r
- // <d>\r
- var sb = _s.sandbox;\r
- sb.type = sandboxType;\r
- sb.description = sb.types[(typeof sb.types[sandboxType] !== 'undefined'?sandboxType:'unknown')];\r
- _s._wD('Flash security sandbox type: ' + sb.type);\r
- if (sb.type === 'localWithFile') {\r
- sb.noRemote = true;\r
- sb.noLocal = false;\r
- _wDS('secNote', 2);\r
- } else if (sb.type === 'localWithNetwork') {\r
- sb.noRemote = false;\r
- sb.noLocal = true;\r
- } else if (sb.type === 'localTrusted') {\r
- sb.noRemote = false;\r
- sb.noLocal = false;\r
- }\r
+ }());\r
// </d>\r
- };\r
\r
- this._externalInterfaceOK = function(flashDate) {\r
- // flash callback confirming flash loaded, EI working etc.\r
- // flashDate = approx. timing/delay info for JS/flash bridge\r
- if (_s.swfLoaded) {\r
- return false;\r
+ if (!_hasFlash && _s.hasHTML5) {\r
+ _s._wD('SoundManager: No Flash detected'+(!_s.useHTML5Audio?', enabling HTML5.':'. Trying HTML5-only mode.'));\r
+ _s.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
+ _s.preferFlash = false;\r
}\r
- var eiTime = new Date().getTime();\r
- _s._wD(_smc+'externalInterfaceOK()' + (flashDate?' (~' + (eiTime - flashDate) + ' ms)':''));\r
- _debugTS('swf', true);\r
- _debugTS('flashtojs', true);\r
- _s.swfLoaded = true;\r
- _tryInitOnFocus = false;\r
- if (_isBadSafari) {\r
- _badSafariFix();\r
+\r
+ _testHTML5();\r
+ _s.html5.usingFlash = _featureCheck();\r
+ _needsFlash = _s.html5.usingFlash;\r
+ _showSupport();\r
+\r
+ if (!_hasFlash && _needsFlash) {\r
+ _s._wD('SoundManager: Fatal error: Flash is needed to play some required formats, but is not available.');\r
+ // TODO: Fatal here vs. timeout approach, etc.\r
+ // hack: fail sooner.\r
+ _s.flashLoadTimeout = 1;\r
}\r
- if (_isIE) {\r
- // IE needs a timeout OR delay until window.onload - may need TODO: investigating\r
- setTimeout(_init, 100);\r
- } else {\r
- _init();\r
+\r
+ if (_doc.removeEventListener) {\r
+ _doc.removeEventListener('DOMContentLoaded', _domContentLoaded, false);\r
}\r
+\r
+ _initMovie();\r
+ return true;\r
+\r
};\r
\r
- _dcIE = function() {\r
+ _domContentLoadedIE = function() {\r
+\r
if (_doc.readyState === 'complete') {\r
- _dcLoaded();\r
- _doc.detachEvent('onreadystatechange', _dcIE);\r
+ _domContentLoaded();\r
+ _doc.detachEvent('onreadystatechange', _domContentLoadedIE);\r
}\r
+\r
return true;\r
+\r
};\r
\r
- // focus and window load, init\r
- if (!_s.hasHTML5 || _needsFlash) {\r
- // only applies to Flash mode\r
- _event.add(_win, 'focus', _handleFocus);\r
- _event.add(_win, 'load', _handleFocus);\r
- _event.add(_win, 'load', _delayWaitForEI);\r
- if (_isSafari && _tryInitOnFocus) {\r
- _event.add(_win, 'mousemove', _handleFocus); // massive Safari focus hack\r
- }\r
+ // sniff up-front\r
+ _detectFlash();\r
+\r
+ // focus and window load, init (primarily flash-driven)\r
+ _event.add(_win, 'focus', _handleFocus);\r
+ _event.add(_win, 'load', _handleFocus);\r
+ _event.add(_win, 'load', _delayWaitForEI);\r
+\r
+ if (_isSafari && _tryInitOnFocus) {\r
+ // massive Safari 3.1 focus detection hack\r
+ _event.add(_win, 'mousemove', _handleFocus);\r
}\r
\r
if (_doc.addEventListener) {\r
- _doc.addEventListener('DOMContentLoaded', _dcLoaded, false);\r
+\r
+ _doc.addEventListener('DOMContentLoaded', _domContentLoaded, false);\r
+\r
} else if (_doc.attachEvent) {\r
- _doc.attachEvent('onreadystatechange', _dcIE);\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
- _die();\r
+ _catchError({type:'NO_DOM2_EVENTS', fatal:true});\r
+\r
}\r
\r
if (_doc.readyState === 'complete') {\r
- setTimeout(_dcLoaded,100);\r
+ // DOMReady has already happened.\r
+ setTimeout(_domContentLoaded,100);\r
}\r
\r
} // SoundManager()\r
\r
// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading\r
+\r
if (typeof SM2_DEFER === 'undefined' || !SM2_DEFER) {\r
soundManager = new SoundManager();\r
}\r
\r
-// public interfaces\r
+/**\r
+ * SoundManager public interfaces\r
+ * ------------------------------\r
+ */\r
+\r
window.SoundManager = SoundManager; // constructor\r
-window.soundManager = soundManager; // public API, flash callbacks etc\r
+window.soundManager = soundManager; // public API, flash callbacks etc.\r
\r
-}(window));\r
+}(window));
\ No newline at end of file