Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit ca5e072ea5fe3a948b4bd5f50f417d81e041f649

  • avatar
  • Chris Porter <slug @quak…et.org>
  • Sun Feb 01 21:55:23 EST 2009
Update SoundManager, also use the minified version.
.hgignore
(1 / 1)
  
11syntax: glob
2static/js/{ugly,swm,mocha,q}ui.js
2static/js/{ugly,swm,mocha,q}ui{,-*}.js
33static/js/qwebirc.js
44static/{js,css}/debug
55static/css
  
228228 if(eval("typeof " + watchFor) != "undefined") {
229229 onload();
230230 } else {
231 checkFn.delay(10);
231 checkFn.delay(100);
232232 }
233233 }
234234 checkFn();
  
2828 return;
2929 }
3030
31 qwebirc.util.importJS("/js/soundmanager2.js", "soundManager", function() {
31 var debugMode = false;
32 qwebirc.util.importJS("/js/" + (debugMode?"soundmanager2":"soundmanager2-nodebug-jsmin") + ".js", "soundManager", function() {
3233 soundManager.url = "/sound/";
3334
34 /* Fixes Firefox z-index Flash bug */
35 if(Browser.Engine.gecko)
36 soundManager.useHighPerformance = false;
37
38 soundManager.debugMode = false;
39 soundManager.useConsole = false;
35 soundManager.debugMode = debugMode;
36 soundManager.useConsole = debugMode;
4037 soundManager.onload = function() {
4138 this.loadedSWF = true;
4239 this.fireEvent("ready");
  
77 Code licensed under the BSD License:
88 http://schillmania.com/projects/soundmanager2/license.txt
99
10 V2.90a.20081028
10 V2.93a.20090117
1111*/
12function SoundManager(B,A){this.flashVersion=8;this.debugMode=true;this.useConsole=true;this.consoleOnly=false;this.waitForWindowLoad=false;this.nullURL="null.mp3";this.allowPolling=true;this.useMovieStar=false;this.useHighPerformance=true;this.bgColor="#ffffff";this.defaultOptions={autoLoad:false,stream:true,autoPlay:false,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfinish:null,onbeforefinish:null,onbeforefinishtime:5000,onbeforefinishcomplete:null,onjustbeforefinish:null,onjustbeforefinishtime:200,multiShot:true,position:null,pan:0,volume:100};this.flash9Options={isMovieStar:null,usePeakData:false,useWaveformData:false,useEQData:false};this.movieStarOptions={onmetadata:null,useVideo:false};this.flashBlockHelper={enabled:false,message:[]};var E=this;this.version=null;this.versionNumber="V2.90a.20081028";this.movieURL=null;this.url=null;this.altURL=null;this.swfLoaded=false;this.enabled=false;this.o=null;this.id=(A||"sm2movie");this.oMC=null;this.sounds=[];this.soundIDs=[];this.muted=false;this.isIE=(navigator.userAgent.match(/MSIE/i));this.isSafari=(navigator.userAgent.match(/safari/i));this.isGecko=(navigator.userAgent.match(/gecko/i));this.debugID="soundmanager-debug";this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._windowLoaded=false;this._hasConsole=(typeof console!="undefined"&&typeof console.log!="undefined");this._debugLevels=["log","info","warn","error"];this._defaultFlashVersion=8;this.filePatterns={flash8:/\.(mp3)/i,flash9:/\.(mp3)/i};this.netStreamTypes=["aac","flv","mov","mp4","m4v","f4v","m4a","mp4v","3gp","3g2"];this.netStreamPattern=new RegExp(".("+this.netStreamTypes.join("|")+")","i");this.filePattern=null;this.features={peakData:false,waveformData:false,eqData:false};this.sandbox={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local + internet access)"},description:null,noRemote:null,noLocal:null};this._setVersionInfo=function(){if(E.flashVersion!=8&&E.flashVersion!=9){alert('soundManager.flashVersion must be 8 or 9. "'+E.flashVersion+'" is invalid. Reverting to '+E._defaultFlashVersion+".");E.flashVersion=E._defaultFlashVersion}E.version=E.versionNumber+(E.flashVersion==9?" (AS3/Flash 9)":" (AS2/Flash 8)");if(E.flashVersion>8){E.defaultOptions=E._mergeObjects(E.defaultOptions,E.flash9Options)}if(E.flashVersion>8&&E.useMovieStar){E.defaultOptions=E._mergeObjects(E.defaultOptions,E.movieStarOptions);E.filePatterns.flash9=new RegExp(".(mp3|"+E.netStreamTypes.join("|")+")","i")}else{E.useMovieStar=false}E.filePattern=E.filePatterns[(E.flashVersion!=8?"flash9":"flash8")];E.movieURL=(E.flashVersion==8?"soundmanager2.swf":"soundmanager2_flash9.swf");E.features.peakData=E.features.waveformData=E.features.eqData=(E.flashVersion==9)};this._overHTTP=(document.location?document.location.protocol.match(/http/i):null);this._waitingforEI=false;this._initPending=false;this._tryInitOnFocus=(this.isSafari&&typeof document.hasFocus=="undefined");this._isFocused=(typeof document.hasFocus!="undefined"?document.hasFocus():null);this._okToDisable=!this._tryInitOnFocus;this.useAltURL=!this._overHTTP;var C="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html";this.supported=function(){return(E._didInit&&!E._disabled)};this.getMovie=function(F){return E.isIE?window[F]:(E.isSafari?document.getElementById(F)||document[F]:document.getElementById(F))};this.loadFromXML=function(F){try{E.o._loadFromXML(F)}catch(G){E._failSafely();return true}};this.createSound=function(G){if(!E._didInit){throw new Error("soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods")}if(arguments.length==2){var G={id:arguments[0],url:arguments[1]}}var H=E._mergeObjects(G);var F=H;if(E._idCheck(F.id,true)){return E.sounds[F.id]}if(E.flashVersion>8&&E.useMovieStar){if(F.isMovieStar==null){F.isMovieStar=(F.url.match(E.netStreamPattern)?true:false)}if(F.isMovieStar){}if(F.isMovieStar&&(F.usePeakData||F.useWaveformData||F.useEQData)){F.usePeakData=false;F.useWaveformData=false;F.useEQData=false}}E.sounds[F.id]=new D(F);E.soundIDs[E.soundIDs.length]=F.id;if(E.flashVersion==8){E.o._createSound(F.id,F.onjustbeforefinishtime)}else{E.o._createSound(F.id,F.url,F.onjustbeforefinishtime,F.usePeakData,F.useWaveformData,F.useEQData,F.isMovieStar,(F.isMovieStar?F.useVideo:false))}if(F.autoLoad||F.autoPlay){window.setTimeout(function(){if(E.sounds[F.id]){E.sounds[F.id].load(F)}},20)}if(F.autoPlay){if(E.flashVersion==8){E.sounds[F.id].playState=1}else{E.sounds[F.id].play()}}return E.sounds[F.id]};this.createVideo=function(F){if(arguments.length==2){var F={id:arguments[0],url:arguments[1]}}if(E.flashVersion>=9){F.isMovieStar=true;F.useVideo=true}else{return false}if(E.useMovieStar){}return E.createSound(F)};this.destroySound=function(G,F){if(!E._idCheck(G)){return false}for(var H=0;H<E.soundIDs.length;H++){if(E.soundIDs[H]==G){E.soundIDs.splice(H,1);continue}}E.sounds[G].unload();if(!F){E.sounds[G].destruct()}delete E.sounds[G]};this.destroyVideo=this.destroySound;this.load=function(F,G){if(!E._idCheck(F)){return false}E.sounds[F].load(G)};this.unload=function(F){if(!E._idCheck(F)){return false}E.sounds[F].unload()};this.play=function(F,G){if(!E._idCheck(F)){if(typeof G!="Object"){G={url:G}}if(G&&G.url){G.id=F;E.createSound(G)}else{return false}}E.sounds[F].play(G)};this.start=this.play;this.setPosition=function(F,G){if(!E._idCheck(F)){return false}G=Math.min((G||0),E.duration);E.sounds[F].setPosition(G)};this.stop=function(F){if(!E._idCheck(F)){return false}E.sounds[F].stop()};this.stopAll=function(){for(var F in E.sounds){if(E.sounds[F] instanceof D){E.sounds[F].stop()}}};this.pause=function(F){if(!E._idCheck(F)){return false}E.sounds[F].pause()};this.pauseAll=function(){for(var F=E.soundIDs.length;F--;){E.sounds[E.soundIDs[F]].pause()}};this.resume=function(F){if(!E._idCheck(F)){return false}E.sounds[F].resume()};this.resumeAll=function(){for(var F=E.soundIDs.length;F--;){E.sounds[E.soundIDs[F]].resume()}};this.togglePause=function(F){if(!E._idCheck(F)){return false}E.sounds[F].togglePause()};this.setPan=function(F,G){if(!E._idCheck(F)){return false}E.sounds[F].setPan(G)};this.setVolume=function(G,F){if(!E._idCheck(G)){return false}E.sounds[G].setVolume(F)};this.mute=function(F){if(typeof F!="string"){F=null}if(!F){var H=null;for(var G=E.soundIDs.length;G--;){E.sounds[E.soundIDs[G]].mute()}E.muted=true}else{if(!E._idCheck(F)){return false}E.sounds[F].mute()}};this.muteAll=function(){E.mute()};this.unmute=function(F){if(typeof F!="string"){F=null}if(!F){var H=null;for(var G=E.soundIDs.length;G--;){E.sounds[E.soundIDs[G]].unmute()}E.muted=false}else{if(!E._idCheck(F)){return false}E.sounds[F].unmute()}};this.unmuteAll=function(){E.unmute()};this.setPolling=function(F){if(!E.o||!E.allowPolling){return false}E.o._setPolling(F)};this.disable=function(F){if(E._disabled){return false}E._disabled=true;for(var G=E.soundIDs.length;G--;){E._disableObject(E.sounds[E.soundIDs[G]])}E.initComplete();E._disableObject(E)};this.handleFlashBlock=function(F){return false};this.canPlayURL=function(F){return(F?(F.match(E.filePattern)?true:false):null)};this.getSoundById=function(G,H){if(!G){throw new Error("SoundManager.getSoundById(): sID is null/undefined")}var F=E.sounds[G];if(!F&&!H){}return F};this.onload=function(){soundManager._wD("<em>Warning</em>: soundManager.onload() is undefined.",2)};this.onerror=function(){};this._idCheck=this.getSoundById;this._disableObject=function(G){for(var F in G){if(typeof G[F]=="function"&&typeof G[F]._protected=="undefined"){G[F]=function(){return false}}}F=null};this._failSafely=function(){var H="You may need to whitelist this location/domain eg. file:///C:/ or C:/ or mysite.com, or set ALWAYS ALLOW under the Flash Player Global Security Settings page. The latter is probably less-secure.";var G='<a href="'+C+'" title="'+H+'">view/edit</a>';var F='<a href="'+C+'" title="Flash Player Global Security Settings">FPGSS</a>';if(!E._disabled){E.disable()}};this._normalizeMovieURL=function(F){if(F){if(F.match(/\.swf/)){F=F.substr(0,F.lastIndexOf(".swf"))}if(F.lastIndexOf("/")!=F.length-1){F=F+"/"}}return(F&&F.lastIndexOf("/")!=-1?F.substr(0,F.lastIndexOf("/")+1):"./")+E.movieURL};this._getDocument=function(){return(document.body?document.body:(document.documentElement?document.documentElement:document.getElementsByTagName("div")[0]))};this._getDocument._protected=true;this._createMovie=function(I,H){if(E._didAppend&&E._appendSuccess){return false}E._didAppend=true;E._setVersionInfo();var M=(H?H:E.url);var G=(E.altURL?E.altURL:M);E.url=E._normalizeMovieURL(E._overHTTP?M:G);H=E.url;var P='<embed name="'+I+'" id="'+I+'" src="'+H+'" width="100%" height="100%" quality="high" allowScriptAccess="always" quality="high" '+(E.useHighPerformance&&!E.useMovieStar?'wmode="transparent" ':"")+'bgcolor="'+E.bgColor+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';var L='<object id="'+I+'" data="'+H+'" type="application/x-shockwave-flash" width="100%" height="100%"><param name="movie" value="'+H+'" /><param name="AllowScriptAccess" value="always" /><param name="quality" value="high" />'+(E.useHighPerformance&&!E.useMovieStar?'<param name="wmode" value="transparent" /> ':"")+'<param name="bgcolor" value="'+E.bgColor+'" /><!-- --></object>';var K=(!E.isIE?P:L);var J="soundManager._createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.";var F=E._getDocument();if(F){E.oMC=document.getElementById("sm2-container")?document.getElementById("sm2-container"):document.createElement("div");if(!E.oMC.id){E.oMC.id="sm2-container";E.oMC.className="movieContainer";var Q=null;if(E.useHighPerformance){Q={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",zIndex:-1}}else{Q={position:"absolute",width:"1px",height:"1px",bottom:"0px",left:"0px"}}var O=null;for(O in Q){E.oMC.style[O]=Q[O]}try{F.appendChild(E.oMC);E.oMC.innerHTML=K;E._appendSuccess=true}catch(N){throw new Error(J)}}else{E.oMC.innerHTML=K;E._appendSuccess=true}}};this._writeDebug=function(F,H,G){};this._writeDebug._protected=true;this._wD=this._writeDebug;this._wDAlert=function(F){alert(F)};if(window.location.href.indexOf("debug=alert")+1&&E.debugMode){}this._toggleDebug=function(){};this._toggleDebug._protected=true;this._debug=function(){for(var G=0,F=E.soundIDs.length;G<F;G++){E.sounds[E.soundIDs[G]]._debug()}};this._mergeObjects=function(G,F){var J={};for(var H in G){J[H]=G[H]}var I=(typeof F=="undefined"?E.defaultOptions:F);for(var K in I){if(typeof J[K]=="undefined"){J[K]=I[K]}}return J};this.createMovie=function(F){if(F){E.url=F}E._initMovie()};this.go=this.createMovie;this._initMovie=function(){if(E.o){return false}E.o=E.getMovie(E.id);if(!E.o){E._createMovie(E.id,E.url);E.o=E.getMovie(E.id)}if(E.o){}};this.waitForExternalInterface=function(){if(E._waitingForEI){return false}E._waitingForEI=true;if(E._tryInitOnFocus&&!E._isFocused){return false}if(!E._didInit){}setTimeout(function(){if(!E._didInit){if(!E._overHTTP){}}if(!E._didInit&&E._okToDisable){E._failSafely()}},750)};this.handleFocus=function(){if(E._isFocused||!E._tryInitOnFocus){return true}E._okToDisable=true;E._isFocused=true;if(E._tryInitOnFocus){window.removeEventListener("mousemove",E.handleFocus,false)}E._waitingForEI=false;setTimeout(E.waitForExternalInterface,500);if(window.removeEventListener){window.removeEventListener("focus",E.handleFocus,false)}else{if(window.detachEvent){window.detachEvent("onfocus",E.handleFocus)}}};this.initComplete=function(){if(E._didInit){return false}E._didInit=true;if(E._disabled){E.onerror.apply(window);return false}if(E.waitForWindowLoad&&!E._windowLoaded){if(window.addEventListener){window.addEventListener("load",E.initUserOnload,false)}else{if(window.attachEvent){window.attachEvent("onload",E.initUserOnload)}}return false}else{if(E.waitForWindowLoad&&E._windowLoaded){}E.initUserOnload()}};this.initUserOnload=function(){try{E.onload.apply(window)}catch(F){setTimeout(function(){throw new Error(F)},20);return false}};this.init=function(){E._initMovie();if(E._didInit){return false}if(window.removeEventListener){window.removeEventListener("load",E.beginDelayedInit,false)}else{if(window.detachEvent){window.detachEvent("onload",E.beginDelayedInit)}}try{E.o._externalInterfaceTest(false);if(!E.allowPolling){}E.setPolling(true);if(!E.debugMode){E.o._disableDebug()}E.enabled=true}catch(F){E._failSafely();E.initComplete();return false}E.initComplete()};this.beginDelayedInit=function(){E._windowLoaded=true;setTimeout(E.waitForExternalInterface,500);setTimeout(E.beginInit,20)};this.beginInit=function(){if(E._initPending){return false}E.createMovie();E._initMovie();E._initPending=true;return true};this.domContentLoaded=function(){if(document.removeEventListener){document.removeEventListener("DOMContentLoaded",E.domContentLoaded,false)}E.go()};this._externalInterfaceOK=function(){if(E.swfLoaded){return false}E.swfLoaded=true;E._tryInitOnFocus=false;if(E.isIE){setTimeout(E.init,100)}else{E.init()}};this._setSandboxType=function(F){var G=E.sandbox;G.type=F;G.description=G.types[(typeof G.types[F]!="undefined"?F:"unknown")];if(G.type=="localWithFile"){G.noRemote=true;G.noLocal=false}else{if(G.type=="localWithNetwork"){G.noRemote=false;G.noLocal=true}else{if(G.type=="localTrusted"){G.noRemote=false;G.noLocal=false}}}};this.destruct=function(){E.disable(true)};function D(F){var G=this;this.sID=F.id;this.url=F.url;this.options=E._mergeObjects(F);this.instanceOptions=this.options;this._iO=this.instanceOptions;this._debug=function(){};this._debug();this.id3={};this.resetProperties=function(H){G.bytesLoaded=null;G.bytesTotal=null;G.position=null;G.duration=null;G.durationEstimate=null;G.loaded=false;G.playState=0;G.paused=false;G.readyState=0;G.muted=false;G.didBeforeFinish=false;G.didJustBeforeFinish=false;G.instanceOptions={};G.instanceCount=0;G.peakData={left:0,right:0};G.waveformData=[];G.eqData=[]};G.resetProperties();this.load=function(H){if(typeof H!="undefined"){G._iO=E._mergeObjects(H);G.instanceOptions=G._iO}else{var H=G.options;G._iO=H;G.instanceOptions=G._iO}if(typeof G._iO.url=="undefined"){G._iO.url=G.url}if(G._iO.url==G.url&&G.readyState!=0&&G.readyState!=2){return false}G.loaded=false;G.readyState=1;G.playState=(H.autoPlay?1:0);try{if(E.flashVersion==8){E.o._load(G.sID,G._iO.url,G._iO.stream,G._iO.autoPlay,(G._iO.whileloading?1:0))}else{E.o._load(G.sID,G._iO.url,G._iO.stream?true:false,G._iO.autoPlay?true:false);if(G._iO.isMovieStar&&G._iO.autoLoad&&!G._iO.autoPlay){G.pause()}}}catch(I){E.onerror();E.disable()}};this.unload=function(){if(G.readyState!=0){if(G.readyState!=2){G.setPosition(0)}E.o._unload(G.sID,E.nullURL);G.resetProperties()}};this.destruct=function(){E.o._destroySound(G.sID);E.destroySound(G.sID,true)};this.play=function(I){if(!I){I={}}G._iO=E._mergeObjects(I,G._iO);G._iO=E._mergeObjects(G._iO,G.options);G.instanceOptions=G._iO;if(G.playState==1){var H=G._iO.multiShot;if(!H){return false}else{}}if(!G.loaded){if(G.readyState==0){G._iO.stream=true;G._iO.autoPlay=true;G.load(G._iO)}else{if(G.readyState==2){return false}else{}}}else{}if(G.paused){G.resume()}else{G.playState=1;if(!G.instanceCount||E.flashVersion==9){G.instanceCount++}G.position=(typeof G._iO.position!="undefined"&&!isNaN(G._iO.position)?G._iO.position:0);if(G._iO.onplay){G._iO.onplay.apply(G)}G.setVolume(G._iO.volume);G.setPan(G._iO.pan);E.o._start(G.sID,G._iO.loop||1,(E.flashVersion==9?G.position:G.position/1000))}};this.start=this.play;this.stop=function(H){if(G.playState==1){G.playState=0;G.paused=false;if(G._iO.onstop){G._iO.onstop.apply(G)}E.o._stop(G.sID,H);G.instanceCount=0;G._iO={}}};this.setPosition=function(H){G._iO.position=H;E.o._setPosition(G.sID,(E.flashVersion==9?G._iO.position:G._iO.position/1000),(G.paused||!G.playState))};this.pause=function(){if(G.paused||G.playState==0){return false}G.paused=true;E.o._pause(G.sID);if(G._iO.onpause){G._iO.onpause.apply(G)}};this.resume=function(){if(!G.paused||G.playState==0){return false}G.paused=false;E.o._pause(G.sID);if(G._iO.onresume){G._iO.onresume.apply(G)}};this.togglePause=function(){if(!G.playState){G.play({position:(E.flashVersion==9?G.position:G.position/1000)});return false}if(G.paused){G.resume()}else{G.pause()}};this.setPan=function(H){if(typeof H=="undefined"){H=0}E.o._setPan(G.sID,H);G._iO.pan=H};this.setVolume=function(H){if(typeof H=="undefined"){H=100}E.o._setVolume(G.sID,(E.muted&&!G.muted)||G.muted?0:H);G._iO.volume=H};this.mute=function(){G.muted=true;E.o._setVolume(G.sID,0)};this.unmute=function(){G.muted=false;E.o._setVolume(G.sID,typeof G._iO.volume!="undefined"?G._iO.volume:G.options.volume)};this._whileloading=function(H,I,J){if(!G._iO.isMovieStar){G.bytesLoaded=H;G.bytesTotal=I;G.duration=Math.floor(J);G.durationEstimate=parseInt((G.bytesTotal/G.bytesLoaded)*G.duration);if(G.readyState!=3&&G._iO.whileloading){G._iO.whileloading.apply(G)}}else{G.bytesLoaded=H;G.bytesTotal=I;G.duration=Math.floor(J);G.durationEstimate=G.duration;if(G.readyState!=3&&G._iO.whileloading){G._iO.whileloading.apply(G)}}};this._onid3=function(K,H){var L=[];for(var J=0,I=K.length;J<I;J++){L[K[J]]=H[J]}G.id3=E._mergeObjects(G.id3,L);if(G._iO.onid3){G._iO.onid3.apply(G)}};this._whileplaying=function(I,J,H,K){if(isNaN(I)||I==null){return false}G.position=I;if(G._iO.usePeakData&&typeof J!="undefined"&&J){G.peakData={left:J.leftPeak,right:J.rightPeak}}if(G._iO.useWaveformData&&typeof H!="undefined"&&H){G.waveformData=H}if(G._iO.useEQData&&typeof K!="undefined"&&K){G.eqData=K}if(G.playState==1){if(G._iO.whileplaying){G._iO.whileplaying.apply(G)}if(G.loaded&&G._iO.onbeforefinish&&G._iO.onbeforefinishtime&&!G.didBeforeFinish&&G.duration-G.position<=G._iO.onbeforefinishtime){G._onbeforefinish()}}};this._onload=function(H){H=(H==1?true:false);if(!H){if(E.sandbox.noRemote==true){}if(E.sandbox.noLocal==true){}}G.loaded=H;G.readyState=H?3:2;if(G._iO.onload){G._iO.onload.apply(G)}};this._onbeforefinish=function(){if(!G.didBeforeFinish){G.didBeforeFinish=true;if(G._iO.onbeforefinish){G._iO.onbeforefinish.apply(G)}}};this._onjustbeforefinish=function(H){if(!G.didJustBeforeFinish){G.didJustBeforeFinish=true;if(G._iO.onjustbeforefinish){G._iO.onjustbeforefinish.apply(G)}}};this._onfinish=function(){G.playState=0;G.paused=false;if(G._iO.onfinish){G._iO.onfinish.apply(G)}if(G._iO.onbeforefinishcomplete){G._iO.onbeforefinishcomplete.apply(G)}G.setPosition(0);G.didBeforeFinish=false;G.didJustBeforeFinish=false;if(G.instanceCount){G.instanceCount--;if(!G.instanceCount){G.instanceCount=0;G.instanceOptions={}}}};this._onmetadata=function(H){if(!H.width&&!H.height){H.width=320;H.height=240}G.metadata=H;G.width=H.width;G.height=H.height;if(G._iO.onmetadata){G._iO.onmetadata.apply(G)}E.wD("SMSound.onmetadata() complete")}}if(window.addEventListener){window.addEventListener("focus",E.handleFocus,false);window.addEventListener("load",E.beginDelayedInit,false);window.addEventListener("unload",E.destruct,false);if(E._tryInitOnFocus){window.addEventListener("mousemove",E.handleFocus,false)}}else{if(window.attachEvent){window.attachEvent("onfocus",E.handleFocus);window.attachEvent("onload",E.beginDelayedInit);window.attachEvent("unload",E.destruct)}else{soundManager.onerror();soundManager.disable()}}if(document.addEventListener){document.addEventListener("DOMContentLoaded",E.domContentLoaded,false)}}var soundManager=new SoundManager();
12var soundManager=null;function SoundManager(b,a){this.flashVersion=8;this.debugMode=true;this.useConsole=true;this.consoleOnly=false;this.waitForWindowLoad=false;this.nullURL="null.mp3";this.allowPolling=true;this.useMovieStar=false;this.bgColor="#ffffff";this.useHighPerformance=true;this.defaultOptions={autoLoad:false,stream:true,autoPlay:false,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfinish:null,onbeforefinish:null,onbeforefinishtime:5000,onbeforefinishcomplete:null,onjustbeforefinish:null,onjustbeforefinishtime:200,multiShot:true,position:null,pan:0,volume:100};this.flash9Options={isMovieStar:null,usePeakData:false,useWaveformData:false,useEQData:false};this.movieStarOptions={onmetadata:null,useVideo:false};var f=null;var e=this;this.version=null;this.versionNumber="V2.93a.20090117";this.movieURL=null;this.url=null;this.altURL=null;this.swfLoaded=false;this.enabled=false;this.o=null;this.id=(a||"sm2movie");this.oMC=null;this.sounds={};this.soundIDs=[];this.muted=false;this.isIE=(navigator.userAgent.match(/MSIE/i));this.isSafari=(navigator.userAgent.match(/safari/i));this.isGecko=(navigator.userAgent.match(/gecko/i));this.debugID="soundmanager-debug";this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._windowLoaded=false;this._hasConsole=(typeof console!="undefined"&&typeof console.log!="undefined");this._debugLevels=["log","info","warn","error"];this._defaultFlashVersion=8;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.netStreamTypes=["aac","flv","mov","mp4","m4v","f4v","m4a","mp4v","3gp","3g2"];this.netStreamPattern=new RegExp("\\.("+this.netStreamTypes.join("|")+")(\\?.*)?$","i");this.filePattern=null;this.features={peakData:false,waveformData:false,eqData:false,movieStar:false};this.sandbox={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local + internet access)"},description:null,noRemote:null,noLocal:null};this._setVersionInfo=function(){if(e.flashVersion!=8&&e.flashVersion!=9){alert('soundManager.flashVersion must be 8 or 9. "'+e.flashVersion+'" is invalid. Reverting to '+e._defaultFlashVersion+".");e.flashVersion=e._defaultFlashVersion}e.version=e.versionNumber+(e.flashVersion==9?" (AS3/Flash 9)":" (AS2/Flash 8)");if(e.flashVersion>8){e.defaultOptions=e._mergeObjects(e.defaultOptions,e.flash9Options)}if(e.flashVersion>8&&e.useMovieStar){e.defaultOptions=e._mergeObjects(e.defaultOptions,e.movieStarOptions);e.filePatterns.flash9=new RegExp("\\.(mp3|"+e.netStreamTypes.join("|")+")(\\?.*)?$","i");e.features.movieStar=true}else{e.useMovieStar=false;e.features.movieStar=false}e.filePattern=e.filePatterns[(e.flashVersion!=8?"flash9":"flash8")];e.movieURL=(e.flashVersion==8?"soundmanager2.swf":"soundmanager2_flash9.swf");e.features.peakData=e.features.waveformData=e.features.eqData=(e.flashVersion==9)};this._overHTTP=(document.location?document.location.protocol.match(/http/i):null);this._waitingforEI=false;this._initPending=false;this._tryInitOnFocus=(this.isSafari&&typeof document.hasFocus=="undefined");this._isFocused=(typeof document.hasFocus!="undefined"?document.hasFocus():null);this._okToDisable=!this._tryInitOnFocus;this.useAltURL=!this._overHTTP;var d="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html";this.supported=function(){return(e._didInit&&!e._disabled)};this.getMovie=function(g){return e.isIE?window[g]:(e.isSafari?document.getElementById(g)||document[g]:document.getElementById(g))};this.loadFromXML=function(g){try{e.o._loadFromXML(g)}catch(h){e._failSafely();return true}};this.createSound=function(h){if(!e._didInit){throw new Error("soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods")}if(arguments.length==2){h={id:arguments[0],url:arguments[1]}}var i=e._mergeObjects(h);var g=i;if(e._idCheck(g.id,true)){return e.sounds[g.id]}if(e.flashVersion>8&&e.useMovieStar){if(g.isMovieStar===null){g.isMovieStar=(g.url.match(e.netStreamPattern)?true:false)}if(g.isMovieStar&&(g.usePeakData||g.useWaveformData||g.useEQData)){g.usePeakData=false;g.useWaveformData=false;g.useEQData=false}}e.sounds[g.id]=new f(g);e.soundIDs[e.soundIDs.length]=g.id;if(e.flashVersion==8){e.o._createSound(g.id,g.onjustbeforefinishtime)}else{e.o._createSound(g.id,g.url,g.onjustbeforefinishtime,g.usePeakData,g.useWaveformData,g.useEQData,g.isMovieStar,(g.isMovieStar?g.useVideo:false))}if(g.autoLoad||g.autoPlay){if(e.sounds[g.id]){e.sounds[g.id].load(g)}}if(g.autoPlay){e.sounds[g.id].play()}return e.sounds[g.id]};this.createVideo=function(g){if(arguments.length==2){g={id:arguments[0],url:arguments[1]}}if(e.flashVersion>=9){g.isMovieStar=true;g.useVideo=true}else{return false}return e.createSound(g)};this.destroySound=function(h,g){if(!e._idCheck(h)){return false}for(var j=0;j<e.soundIDs.length;j++){if(e.soundIDs[j]==h){e.soundIDs.splice(j,1);continue}}e.sounds[h].unload();if(!g){e.sounds[h].destruct()}delete e.sounds[h]};this.destroyVideo=this.destroySound;this.load=function(g,h){if(!e._idCheck(g)){return false}e.sounds[g].load(h)};this.unload=function(g){if(!e._idCheck(g)){return false}e.sounds[g].unload()};this.play=function(g,h){if(!e._idCheck(g)){if(typeof h!="Object"){h={url:h}}if(h&&h.url){h.id=g;e.createSound(h)}else{return false}}e.sounds[g].play(h)};this.start=this.play;this.setPosition=function(g,h){if(!e._idCheck(g)){return false}e.sounds[g].setPosition(h)};this.stop=function(g){if(!e._idCheck(g)){return false}e.sounds[g].stop()};this.stopAll=function(){for(var g in e.sounds){if(e.sounds[g] instanceof f){e.sounds[g].stop()}}};this.pause=function(g){if(!e._idCheck(g)){return false}e.sounds[g].pause()};this.pauseAll=function(){for(var g=e.soundIDs.length;g--;){e.sounds[e.soundIDs[g]].pause()}};this.resume=function(g){if(!e._idCheck(g)){return false}e.sounds[g].resume()};this.resumeAll=function(){for(var g=e.soundIDs.length;g--;){e.sounds[e.soundIDs[g]].resume()}};this.togglePause=function(g){if(!e._idCheck(g)){return false}e.sounds[g].togglePause()};this.setPan=function(g,h){if(!e._idCheck(g)){return false}e.sounds[g].setPan(h)};this.setVolume=function(h,g){if(!e._idCheck(h)){return false}e.sounds[h].setVolume(g)};this.mute=function(g){if(typeof g!="string"){g=null}if(!g){for(var h=e.soundIDs.length;h--;){e.sounds[e.soundIDs[h]].mute()}e.muted=true}else{if(!e._idCheck(g)){return false}e.sounds[g].mute()}};this.muteAll=function(){e.mute()};this.unmute=function(g){if(typeof g!="string"){g=null}if(!g){for(var h=e.soundIDs.length;h--;){e.sounds[e.soundIDs[h]].unmute()}e.muted=false}else{if(!e._idCheck(g)){return false}e.sounds[g].unmute()}};this.unmuteAll=function(){e.unmute()};this.getMemoryUse=function(){if(e.flashVersion==8){return 0}if(e.o){return parseInt(e.o._getMemoryUse(),10)}};this.setPolling=function(g){if(!e.o||!e.allowPolling){return false}e.o._setPolling(g)};this.disable=function(g){if(e._disabled){return false}e._disabled=true;for(var h=e.soundIDs.length;h--;){e._disableObject(e.sounds[e.soundIDs[h]])}e.initComplete();e._disableObject(e)};this.canPlayURL=function(g){return(g?(g.match(e.filePattern)?true:false):null)};this.getSoundById=function(h,i){if(!h){throw new Error("SoundManager.getSoundById(): sID is null/undefined")}var g=e.sounds[h];if(!g&&!i){}return g};this.onload=function(){soundManager._wD("<em>Warning</em>: soundManager.onload() is undefined.",2)};this.onerror=function(){};this._idCheck=this.getSoundById;var c=function(){return false};c._protected=true;this._disableObject=function(h){for(var g in h){if(typeof h[g]=="function"&&typeof h[g]._protected=="undefined"){h[g]=c}}g=null};this._failSafely=function(){if(!e._disabled){e.disable()}};this._normalizeMovieURL=function(g){var h=null;if(g){if(g.match(/\.swf(\?.*)?$/i)){h=g.substr(g.toLowerCase().lastIndexOf(".swf?")+4);if(h){return g}}else{if(g.lastIndexOf("/")!=g.length-1){g=g+"/"}}}return(g&&g.lastIndexOf("/")!=-1?g.substr(0,g.lastIndexOf("/")+1):"./")+e.movieURL};this._getDocument=function(){return(document.body?document.body:(document.documentElement?document.documentElement:document.getElementsByTagName("div")[0]))};this._getDocument._protected=true;this._createMovie=function(z,o){if(e._didAppend&&e._appendSuccess){return false}if(window.location.href.indexOf("debug=1")+1){e.debugMode=true}e._didAppend=true;e._setVersionInfo();var y=(o?o:e.url);var t=(e.altURL?e.altURL:y);e.url=e._normalizeMovieURL(e._overHTTP?y:t);o=e.url;var u=null;if(e.useHighPerformance&&e.useHighPerformance!="always"&&navigator.platform.match(/win32/i)&&navigator.userAgent.match(/firefox/i)){u="Note: disabling highPerformance, known issues with this browser/OS combo.";e.useHighPerformance=false}if(e.useHighPerformance&&e.useMovieStar){u="Note: disabling highPerformance, not applicable with movieStar mode on";e.useHighPerformance=false}var B={name:z,id:z,src:o,width:"100%",height:"100%",quality:"high",allowScriptAccess:"always",bgcolor:e.bgColor,pluginspage:"http://www.macromedia.com/go/getflashplayer",type:"application/x-shockwave-flash"};var i={id:z,data:o,type:"application/x-shockwave-flash",width:"100%",height:"100%"};var g={movie:o,AllowScriptAccess:"always",quality:"high",bgcolor:e.bgColor};if(e.useHighPerformance&&!e.useMovieStar){B.wmode="transparent";g.wmode="transparent"}var p=null;var C=null;if(e.isIE){p=document.createElement("div");var v='<object id="'+z+'" data="'+o+'" type="application/x-shockwave-flash" width="100%" height="100%"><param name="movie" value="'+o+'" /><param name="AllowScriptAccess" value="always" /><param name="quality" value="high" />'+(e.useHighPerformance&&!e.useMovieStar?'<param name="wmode" value="transparent" /> ':"")+'<param name="bgcolor" value="'+e.bgColor+'" /><!-- --></object>'}else{p=document.createElement("embed");for(C in B){if(B.hasOwnProperty(C)){p.setAttribute(C,B[C])}}}var k=document.createElement("div");k.id=e.debugID+"-toggle";var l={position:"fixed",bottom:"0px",right:"0px",width:"1.2em",height:"1.2em",lineHeight:"1.2em",margin:"2px",textAlign:"center",border:"1px solid #999",cursor:"pointer",background:"#fff",color:"#333",zIndex:10001};k.appendChild(document.createTextNode("-"));k.onclick=e._toggleDebug;k.title="Toggle SM2 debug console";if(navigator.userAgent.match(/msie 6/i)){k.style.position="absolute";k.style.cursor="hand"}for(C in l){if(l.hasOwnProperty(C)){k.style[C]=l[C]}}var h="soundManager._createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.";var w=e._getDocument();if(w){e.oMC=document.getElementById("sm2-container")?document.getElementById("sm2-container"):document.createElement("div");if(!e.oMC.id){e.oMC.id="sm2-container";e.oMC.className="movieContainer";var q=null;var r=null;if(e.useHighPerformance){q={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",zIndex:-1}}else{q={position:"absolute",width:"1px",height:"1px",bottom:"0px",left:"0px"}}var m=null;for(m in q){if(q.hasOwnProperty(m)){e.oMC.style[m]=q[m]}}try{if(!e.isIE){e.oMC.appendChild(p)}w.appendChild(e.oMC);if(e.isIE){r=e.oMC.appendChild(document.createElement("div"));r.className="sm2-object-box";r.innerHTML=v}e._appendSuccess=true}catch(A){throw new Error(h)}}else{e.oMC.appendChild(p);if(e.isIE){r=e.oMC.appendChild(document.createElement("div"));r.className="sm2-object-box";r.innerHTML=v}e._appendSuccess=true}if(!document.getElementById(e.debugID)&&((!e._hasConsole||!e.useConsole)||(e.useConsole&&e._hasConsole&&!e.consoleOnly))){var n=document.createElement("div");n.id=e.debugID;n.style.display=(e.debugMode?"block":"none");if(e.debugMode){try{w.appendChild(k)}catch(j){throw new Error(h)}}w.appendChild(n)}w=null}};this._writeDebug=function(g,i,h){};this._writeDebug._protected=true;this._wD=this._writeDebug;this._wDAlert=function(g){alert(g)};this._toggleDebug=function(){};this._toggleDebug._protected=true;this._debug=function(){};this._debugTS=function(j,g,h){if(typeof sm2Debugger!="undefined"){try{sm2Debugger.handleEvent(j,g,h)}catch(i){}}};this._debugTS._protected=true;this._mergeObjects=function(h,g){var l={};for(var j in h){if(h.hasOwnProperty(j)){l[j]=h[j]}}var k=(typeof g=="undefined"?e.defaultOptions:g);for(var m in k){if(k.hasOwnProperty(m)&&typeof l[m]=="undefined"){l[m]=k[m]}}return l};this.createMovie=function(g){if(g){e.url=g}e._initMovie()};this.go=this.createMovie;this._initMovie=function(){if(e.o){return false}e.o=e.getMovie(e.id);if(!e.o){e._createMovie(e.id,e.url);e.o=e.getMovie(e.id)}};this.waitForExternalInterface=function(){if(e._waitingForEI){return false}e._waitingForEI=true;if(e._tryInitOnFocus&&!e._isFocused){return false}setTimeout(function(){if(!e._didInit){e._debugTS("flashtojs",false,": Timed out"+(e._overHTTP)?" (Check flash security)":" (No plugin/missing SWF?)")}if(!e._didInit&&e._okToDisable){e._failSafely()}},750)};this.handleFocus=function(){if(e._isFocused||!e._tryInitOnFocus){return true}e._okToDisable=true;e._isFocused=true;if(e._tryInitOnFocus){window.removeEventListener("mousemove",e.handleFocus,false)}e._waitingForEI=false;setTimeout(e.waitForExternalInterface,500);if(window.removeEventListener){window.removeEventListener("focus",e.handleFocus,false)}else{if(window.detachEvent){window.detachEvent("onfocus",e.handleFocus)}}};this.initComplete=function(){if(e._didInit){return false}e._didInit=true;if(e._disabled){e._debugTS("onload",false);e.onerror.apply(window);return false}else{e._debugTS("onload",true)}if(e.waitForWindowLoad&&!e._windowLoaded){if(window.addEventListener){window.addEventListener("load",e.initUserOnload,false)}else{if(window.attachEvent){window.attachEvent("onload",e.initUserOnload)}}return false}else{e.initUserOnload()}};this.initUserOnload=function(){e.onload.apply(window)};this.init=function(){e._initMovie();if(e._didInit){return false}if(window.removeEventListener){window.removeEventListener("load",e.beginDelayedInit,false)}else{if(window.detachEvent){window.detachEvent("onload",e.beginDelayedInit)}}try{e.o._externalInterfaceTest(false);e.setPolling(true);if(!e.debugMode){e.o._disableDebug()}e.enabled=true;e._debugTS("jstoflash",true)}catch(g){e._debugTS("jstoflash",false);e._failSafely();e.initComplete();return false}e.initComplete()};this.beginDelayedInit=function(){e._windowLoaded=true;setTimeout(e.waitForExternalInterface,500);setTimeout(e.beginInit,20)};this.beginInit=function(){if(e._initPending){return false}e.createMovie();e._initMovie();e._initPending=true;return true};this.domContentLoaded=function(){if(document.removeEventListener){document.removeEventListener("DOMContentLoaded",e.domContentLoaded,false)}e.go()};this._externalInterfaceOK=function(){if(e.swfLoaded){return false}e._debugTS("swf",true);e._debugTS("flashtojs",true);e.swfLoaded=true;e._tryInitOnFocus=false;if(e.isIE){setTimeout(e.init,100)}else{e.init()}};this._setSandboxType=function(g){var h=e.sandbox;h.type=g;h.description=h.types[(typeof h.types[g]!="undefined"?g:"unknown")];if(h.type=="localWithFile"){h.noRemote=true;h.noLocal=false}else{if(h.type=="localWithNetwork"){h.noRemote=false;h.noLocal=true}else{if(h.type=="localTrusted"){h.noRemote=false;h.noLocal=false}}}};this.destruct=function(){e.disable(true)};f=function(g){var h=this;this.sID=g.id;this.url=g.url;this.options=e._mergeObjects(g);this.instanceOptions=this.options;this._iO=this.instanceOptions;this.pan=this.options.pan;this.volume=this.options.volume;this._debug=function(){if(e.debugMode){var k=null;var m=[];var j=null;var l=null;var i=64;for(k in h.options){if(h.options[k]!==null){if(h.options[k] instanceof Function){j=h.options[k].toString();j=j.replace(/\s\s+/g," ");l=j.indexOf("{");m[m.length]=" "+k+": {"+j.substr(l+1,(Math.min(Math.max(j.indexOf("\n")-1,i),i))).replace(/\n/g,"")+"... }"}else{m[m.length]=" "+k+": "+h.options[k]}}}}};this._debug();this.id3={};this.resetProperties=function(i){h.bytesLoaded=null;h.bytesTotal=null;h.position=null;h.duration=null;h.durationEstimate=null;h.loaded=false;h.playState=0;h.paused=false;h.readyState=0;h.muted=false;h.didBeforeFinish=false;h.didJustBeforeFinish=false;h.instanceOptions={};h.instanceCount=0;h.peakData={left:0,right:0};h.waveformData=[];h.eqData=[]};h.resetProperties();this.load=function(i){if(typeof i!="undefined"){h._iO=e._mergeObjects(i);h.instanceOptions=h._iO}else{i=h.options;h._iO=i;h.instanceOptions=h._iO}if(typeof h._iO.url=="undefined"){h._iO.url=h.url}if(h._iO.url==h.url&&h.readyState!==0&&h.readyState!=2){return false}h.loaded=false;h.readyState=1;h.playState=0;try{if(e.flashVersion==8){e.o._load(h.sID,h._iO.url,h._iO.stream,h._iO.autoPlay,(h._iO.whileloading?1:0))}else{e.o._load(h.sID,h._iO.url,h._iO.stream?true:false,h._iO.autoPlay?true:false);if(h._iO.isMovieStar&&h._iO.autoLoad&&!h._iO.autoPlay){h.pause()}}}catch(j){e._debugTS("onload",false);e.onerror();e.disable()}};this.unload=function(){if(h.readyState!==0){if(h.readyState!=2){h.setPosition(0,true)}e.o._unload(h.sID,e.nullURL);h.resetProperties()}};this.destruct=function(){e.o._destroySound(h.sID);e.destroySound(h.sID,true)};this.play=function(j){if(!j){j={}}h._iO=e._mergeObjects(j,h._iO);h._iO=e._mergeObjects(h._iO,h.options);h.instanceOptions=h._iO;if(h.playState==1){var i=h._iO.multiShot;if(!i){return false}}if(!h.loaded){if(h.readyState===0){h._iO.stream=true;h._iO.autoPlay=true;h.load(h._iO)}else{if(h.readyState==2){return false}}}if(h.paused){h.resume()}else{h.playState=1;if(!h.instanceCount||e.flashVersion==9){h.instanceCount++}h.position=(typeof h._iO.position!="undefined"&&!isNaN(h._iO.position)?h._iO.position:0);if(h._iO.onplay){h._iO.onplay.apply(h)}h.setVolume(h._iO.volume,true);h.setPan(h._iO.pan,true);e.o._start(h.sID,h._iO.loop||1,(e.flashVersion==9?h.position:h.position/1000))}};this.start=this.play;this.stop=function(i){if(h.playState==1){h.playState=0;h.paused=false;if(h._iO.onstop){h._iO.onstop.apply(h)}e.o._stop(h.sID,i);h.instanceCount=0;h._iO={}}};this.setPosition=function(j,i){if(typeof j=="undefined"){j=0}var k=Math.min(h.duration,Math.max(j,0));h._iO.position=k;e.o._setPosition(h.sID,(e.flashVersion==9?h._iO.position:h._iO.position/1000),(h.paused||!h.playState))};this.pause=function(){if(h.paused||h.playState===0){return false}h.paused=true;e.o._pause(h.sID);if(h._iO.onpause){h._iO.onpause.apply(h)}};this.resume=function(){if(!h.paused||h.playState===0){return false}h.paused=false;e.o._pause(h.sID);if(h._iO.onresume){h._iO.onresume.apply(h)}};this.togglePause=function(){if(!h.playState){h.play({position:(e.flashVersion==9?h.position:h.position/1000)});return false}if(h.paused){h.resume()}else{h.pause()}};this.setPan=function(j,i){if(typeof j=="undefined"){j=0}if(typeof i=="undefined"){i=false}e.o._setPan(h.sID,j);h._iO.pan=j;if(!i){h.pan=j}};this.setVolume=function(i,j){if(typeof i=="undefined"){i=100}if(typeof j=="undefined"){j=false}e.o._setVolume(h.sID,(e.muted&&!h.muted)||h.muted?0:i);h._iO.volume=i;if(!j){h.volume=i}};this.mute=function(){h.muted=true;e.o._setVolume(h.sID,0)};this.unmute=function(){h.muted=false;var i=typeof h._iO.volume!="undefined";e.o._setVolume(h.sID,i?h._iO.volume:h.options.volume,i?false:true)};this._whileloading=function(i,j,k){if(!h._iO.isMovieStar){h.bytesLoaded=i;h.bytesTotal=j;h.duration=Math.floor(k);h.durationEstimate=parseInt((h.bytesTotal/h.bytesLoaded)*h.duration,10);if(h.readyState!=3&&h._iO.whileloading){h._iO.whileloading.apply(h)}}else{h.bytesLoaded=i;h.bytesTotal=j;h.duration=Math.floor(k);h.durationEstimate=h.duration;if(h.readyState!=3&&h._iO.whileloading){h._iO.whileloading.apply(h)}}};this._onid3=function(n,k){var o=[];for(var m=0,l=n.length;m<l;m++){o[n[m]]=k[m]}h.id3=e._mergeObjects(h.id3,o);if(h._iO.onid3){h._iO.onid3.apply(h)}};this._whileplaying=function(j,k,i,l){if(isNaN(j)||j===null){return false}h.position=j;if(h._iO.usePeakData&&typeof k!="undefined"&&k){h.peakData={left:k.leftPeak,right:k.rightPeak}}if(h._iO.useWaveformData&&typeof i!="undefined"&&i){h.waveformData=i}if(h._iO.useEQData&&typeof l!="undefined"&&l){h.eqData=l}if(h.playState==1){if(h._iO.whileplaying){h._iO.whileplaying.apply(h)}if(h.loaded&&h._iO.onbeforefinish&&h._iO.onbeforefinishtime&&!h.didBeforeFinish&&h.duration-h.position<=h._iO.onbeforefinishtime){h._onbeforefinish()}}};this._onload=function(i){i=(i==1?true:false);h.loaded=i;h.readyState=i?3:2;if(h._iO.onload){h._iO.onload.apply(h)}};this._onbeforefinish=function(){if(!h.didBeforeFinish){h.didBeforeFinish=true;if(h._iO.onbeforefinish){h._iO.onbeforefinish.apply(h)}}};this._onjustbeforefinish=function(i){if(!h.didJustBeforeFinish){h.didJustBeforeFinish=true;if(h._iO.onjustbeforefinish){h._iO.onjustbeforefinish.apply(h)}}};this._onfinish=function(){if(h._iO.onbeforefinishcomplete){h._iO.onbeforefinishcomplete.apply(h)}h.didBeforeFinish=false;h.didJustBeforeFinish=false;if(h.instanceCount){h.instanceCount--;if(!h.instanceCount){h.playState=0;h.paused=false;h.instanceCount=0;h.instanceOptions={};if(h._iO.onfinish){h._iO.onfinish.apply(h)}}}else{}};this._onmetadata=function(i){if(!i.width&&!i.height){i.width=320;i.height=240}h.metadata=i;h.width=i.width;h.height=i.height;if(h._iO.onmetadata){h._iO.onmetadata.apply(h)}}};if(window.addEventListener){window.addEventListener("focus",e.handleFocus,false);window.addEventListener("load",e.beginDelayedInit,false);window.addEventListener("unload",e.destruct,false);if(e._tryInitOnFocus){window.addEventListener("mousemove",e.handleFocus,false)}}else{if(window.attachEvent){window.attachEvent("onfocus",e.handleFocus);window.attachEvent("onload",e.beginDelayedInit);window.attachEvent("unload",e.destruct)}else{e._debugTS("onload",false);soundManager.onerror();soundManager.disable()}}if(document.addEventListener){document.addEventListener("DOMContentLoaded",e.domContentLoaded,false)}}soundManager=new SoundManager();
  
77 Code licensed under the BSD License:
88 http://schillmania.com/projects/soundmanager2/license.txt
99
10 V2.90a.20081028
10 V2.93a.20090117
1111*/
1212
13var soundManager = null;
14
1315function SoundManager(smURL,smID) {
1416
1517 this.flashVersion = 8; // version of flash to require, either 8 or 9. Some API features require Flash 9.
2222 this.nullURL = 'null.mp3'; // path to "null" (empty) MP3 file, used to unload sounds (Flash 8 only)
2323 this.allowPolling = true; // allow flash to poll for status update (required for "while playing", peak, sound spectrum functions to work.)
2424 this.useMovieStar = false; // enable support for Flash 9.0r115+ (codename "MovieStar") MPEG4 audio + video formats (AAC, M4V, FLV, MOV etc.)
25 this.useHighPerformance = true; // flash positioning trick, improves JS/flash callback speed, minimizes delay
2625 this.bgColor = '#ffffff'; // movie (.swf) background color, useful if showing on-screen for video etc.
26 this.useHighPerformance = true; // position:fixed flash movie gives increased js/flash speed, but buggy and disabled for firefox/win32 by default (set value to 'always' to override)
2727
2828 this.defaultOptions = {
2929 '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)
5959 this.movieStarOptions = { // flash 9.0r115+ MPEG4 audio/video options, merged into defaultOptions if flash 9 + movieStar mode is enabled
6060 'onmetadata': null, // callback for when video width/height etc. are received
6161 'useVideo': false // if loading movieStar content, whether to show video
62 }
63
64 this.flashBlockHelper = {
65 'enabled': false, // experimental, removed with >v2.80
66 'message': [] // "nag bar" to show when messaging the user, if SM2 fails on firefox etc.
6762 };
6863
69 var _s = this;
64 // jslint global declarations
65 /*global sm2Debugger, alert, console, document, navigator, setTimeout, window */
66
67 var SMSound = null; // defined later
68
69 var _s = this;
7070 this.version = null;
71 this.versionNumber = 'V2.90a.20081028';
71 this.versionNumber = 'V2.93a.20090117';
7272 this.movieURL = null;
7373 this.url = null;
7474 this.altURL = null;
7777 this.o = null;
7878 this.id = (smID||'sm2movie');
7979 this.oMC = null;
80 this.sounds = [];
80 this.sounds = {};
8181 this.soundIDs = [];
8282 this.muted = false;
8383 this.isIE = (navigator.userAgent.match(/MSIE/i));
9393 this._hasConsole = (typeof console != 'undefined' && typeof console.log != 'undefined');
9494 this._debugLevels = ['log','info','warn','error'];
9595 this._defaultFlashVersion = 8;
96
9697 this.filePatterns = {
97 flash8: /\.(mp3)/i,
98 flash9: /\.(mp3)/i
98 flash8: /\.mp3(\?.*)?$/i,
99 flash9: /\.mp3(\?.*)?$/i
99100 };
101
100102 this.netStreamTypes = ['aac','flv','mov','mp4','m4v','f4v','m4a','mp4v','3gp','3g2']; // Flash v9.0r115+ "moviestar" formats
101 this.netStreamPattern = new RegExp('.('+this.netStreamTypes.join('|')+')','i');
103 this.netStreamPattern = new RegExp('\\.('+this.netStreamTypes.join('|')+')(\\?.*)?$','i');
104
102105 this.filePattern = null;
103106 this.features = {
104107 peakData: false,
105108 waveformData: false,
106 eqData: false
109 eqData: false,
110 movieStar: false
107111 };
108112
109113 this.sandbox = {
134134 _s.defaultOptions = _s._mergeObjects(_s.defaultOptions,_s.flash9Options);
135135 }
136136 if (_s.flashVersion > 8 && _s.useMovieStar) {
137 // flash 9+ support for movieStar formats as well as MP3
137138 _s.defaultOptions = _s._mergeObjects(_s.defaultOptions,_s.movieStarOptions);
138 _s.filePatterns.flash9 = new RegExp('.(mp3|'+_s.netStreamTypes.join('|')+')','i');
139 _s.filePatterns.flash9 = new RegExp('\\.(mp3|'+_s.netStreamTypes.join('|')+')(\\?.*)?$','i');
140 _s.features.movieStar = true;
139141 } else {
140 _s.useMovieStar = false;
142 _s.useMovieStar = false;
143 _s.features.movieStar = false;
141144 }
142145 _s.filePattern = _s.filePatterns[(_s.flashVersion!=8?'flash9':'flash8')];
143146 _s.movieURL = (_s.flashVersion==8?'soundmanager2.swf':'soundmanager2_flash9.swf');
144147 _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_s.flashVersion==9);
145 }
148 };
146149
147150 this._overHTTP = (document.location?document.location.protocol.match(/http/i):null);
148151 this._waitingforEI = false;
174174 } catch(e) {
175175 _s._failSafely();
176176 return true;
177 };
177 }
178178 };
179179
180180 this.createSound = function(oOptions) {
181 if (!_s._didInit) throw new Error('soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods');
182 if (arguments.length==2) {
181 if (!_s._didInit) {
182 throw new Error('soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods');
183 }
184 if (arguments.length == 2) {
183185 // function overloading in JS! :) ..assume simple createSound(id,url) use case
184 var oOptions = {'id':arguments[0],'url':arguments[1]};
185 };
186 oOptions = {'id':arguments[0],'url':arguments[1]};
187 }
186188 var thisOptions = _s._mergeObjects(oOptions); // inherit SM2 defaults
187189 var _tO = thisOptions; // alias
188190 _s._wD('soundManager.createSound(): '+_tO.id+' ('+_tO.url+')',1);
189191 if (_s._idCheck(_tO.id,true)) {
190192 _s._wD('soundManager.createSound(): '+_tO.id+' exists',1);
191193 return _s.sounds[_tO.id];
192 };
194 }
193195 if (_s.flashVersion > 8 && _s.useMovieStar) {
194 if (_tO.isMovieStar == null) {
196 if (_tO.isMovieStar === null) {
195197 _tO.isMovieStar = (_tO.url.match(_s.netStreamPattern)?true:false);
196198 }
197199 if (_tO.isMovieStar) {
205205 _tO.useWaveformData = false;
206206 _tO.useEQData = false;
207207 }
208 };
208 }
209209 _s.sounds[_tO.id] = new SMSound(_tO);
210210 _s.soundIDs[_s.soundIDs.length] = _tO.id;
211211 // AS2:
213213 _s.o._createSound(_tO.id,_tO.onjustbeforefinishtime);
214214 } else {
215215 _s.o._createSound(_tO.id,_tO.url,_tO.onjustbeforefinishtime,_tO.usePeakData,_tO.useWaveformData,_tO.useEQData,_tO.isMovieStar,(_tO.isMovieStar?_tO.useVideo:false));
216 };
216 }
217217 if (_tO.autoLoad || _tO.autoPlay) {
218 window.setTimeout(function() {
218 // TODO: does removing timeout here cause problems?
219219 if (_s.sounds[_tO.id]) {
220220 _s.sounds[_tO.id].load(_tO);
221221 }
222 },20);
223222 }
224223 if (_tO.autoPlay) {
225 if (_s.flashVersion == 8) {
226 _s.sounds[_tO.id].playState = 1; // we can only assume this sound will be playing soon.
227 } else {
228 _s.sounds[_tO.id].play();
229 }
224 _s.sounds[_tO.id].play();
230225 }
231226 return _s.sounds[_tO.id];
232227 };
233228
234229 this.createVideo = function(oOptions) {
235230 if (arguments.length==2) {
236 var oOptions = {'id':arguments[0],'url':arguments[1]};
237 };
231 oOptions = {'id':arguments[0],'url':arguments[1]};
232 }
238233 if (_s.flashVersion >= 9) {
239234 oOptions.isMovieStar = true;
240235 oOptions.useVideo = true;
241241 _s._wD('soundManager.createVideo(): MovieStar mode not enabled. Exiting.',2);
242242 }
243243 return _s.createSound(oOptions);
244 }
244 };
245245
246246 this.destroySound = function(sID,bFromSound) {
247247 // explicitly destroy a sound before normal page unload, etc.
248 if (!_s._idCheck(sID)) return false;
248 if (!_s._idCheck(sID)) {
249 return false;
250 }
249251 for (var i=0; i<_s.soundIDs.length; i++) {
250252 if (_s.soundIDs[i] == sID) {
251253 _s.soundIDs.splice(i,1);
252254 continue;
253 };
254 };
255 }
256 }
255257 // conservative option: avoid crash with ze flash 8
256258 // calling destroySound() within a sound onload() might crash firefox, certain flavours of winXP + flash 8??
257259 // if (_s.flashVersion != 8) {
262262 if (!bFromSound) {
263263 // ignore if being called from SMSound instance
264264 _s.sounds[sID].destruct();
265 };
265 }
266266 delete _s.sounds[sID];
267267 };
268268
269269 this.destroyVideo = this.destroySound;
270270
271271 this.load = function(sID,oOptions) {
272 if (!_s._idCheck(sID)) return false;
272 if (!_s._idCheck(sID)) {
273 return false;
274 }
273275 _s.sounds[sID].load(oOptions);
274276 };
275277
276278 this.unload = function(sID) {
277 if (!_s._idCheck(sID)) return false;
279 if (!_s._idCheck(sID)) {
280 return false;
281 }
278282 _s.sounds[sID].unload();
279283 };
280284
281285 this.play = function(sID,oOptions) {
282286 if (!_s._idCheck(sID)) {
283 if (typeof oOptions != 'Object') oOptions = {url:oOptions}; // overloading use case: play('mySound','/path/to/some.mp3');
287 if (typeof oOptions != 'Object') {
288 oOptions = {url:oOptions}; // overloading use case: play('mySound','/path/to/some.mp3');
289 }
284290 if (oOptions && oOptions.url) {
285291 // overloading use case, creation + playing of sound: .play('someID',{url:'/path/to.mp3'});
286292 _s._wD('soundController.play(): attempting to create "'+sID+'"',1);
294294 _s.createSound(oOptions);
295295 } else {
296296 return false;
297 };
298 };
297 }
298 }
299299 _s.sounds[sID].play(oOptions);
300300 };
301301
302302 this.start = this.play; // just for convenience
303303
304304 this.setPosition = function(sID,nMsecOffset) {
305 if (!_s._idCheck(sID)) return false;
306 nMsecOffset = Math.min((nMsecOffset||0),_s.duration); // don't allow seek past loaded duration
305 if (!_s._idCheck(sID)) {
306 return false;
307 }
307308 _s.sounds[sID].setPosition(nMsecOffset);
308309 };
309310
310311 this.stop = function(sID) {
311 if (!_s._idCheck(sID)) return false;
312 if (!_s._idCheck(sID)) {
313 return false;
314 }
312315 _s._wD('soundManager.stop('+sID+')',1);
313316 _s.sounds[sID].stop();
314317 };
319319 this.stopAll = function() {
320320 _s._wD('soundManager.stopAll()',1);
321321 for (var oSound in _s.sounds) {
322 if (_s.sounds[oSound] instanceof SMSound) _s.sounds[oSound].stop(); // apply only to sound objects
323 };
322 if (_s.sounds[oSound] instanceof SMSound) {
323 _s.sounds[oSound].stop(); // apply only to sound objects
324 }
325 }
324326 };
325327
326328 this.pause = function(sID) {
327 if (!_s._idCheck(sID)) return false;
329 if (!_s._idCheck(sID)) {
330 return false;
331 }
328332 _s.sounds[sID].pause();
329333 };
330334
339339 };
340340
341341 this.resume = function(sID) {
342 if (!_s._idCheck(sID)) return false;
342 if (!_s._idCheck(sID)) {
343 return false;
344 }
343345 _s.sounds[sID].resume();
344346 };
345347
352352 };
353353
354354 this.togglePause = function(sID) {
355 if (!_s._idCheck(sID)) return false;
355 if (!_s._idCheck(sID)) {
356 return false;
357 }
356358 _s.sounds[sID].togglePause();
357359 };
358360
359361 this.setPan = function(sID,nPan) {
360 if (!_s._idCheck(sID)) return false;
362 if (!_s._idCheck(sID)) {
363 return false;
364 }
361365 _s.sounds[sID].setPan(nPan);
362366 };
363367
364368 this.setVolume = function(sID,nVol) {
365 if (!_s._idCheck(sID)) return false;
369 if (!_s._idCheck(sID)) {
370 return false;
371 }
366372 _s.sounds[sID].setVolume(nVol);
367373 };
368374
369375 this.mute = function(sID) {
370 if (typeof sID != 'string') sID = null;
376 if (typeof sID != 'string') {
377 sID = null;
378 }
371379 if (!sID) {
372 var o = null;
373380 _s._wD('soundManager.mute(): Muting all sounds');
374381 for (var i=_s.soundIDs.length; i--;) {
375382 _s.sounds[_s.soundIDs[i]].mute();
376383 }
377384 _s.muted = true;
378385 } else {
379 if (!_s._idCheck(sID)) return false;
386 if (!_s._idCheck(sID)) {
387 return false;
388 }
380389 _s._wD('soundManager.mute(): Muting "'+sID+'"');
381390 _s.sounds[sID].mute();
382391 }
396396 };
397397
398398 this.unmute = function(sID) {
399 if (typeof sID != 'string') sID = null;
399 if (typeof sID != 'string') {
400 sID = null;
401 }
400402 if (!sID) {
401 var o = null;
402403 _s._wD('soundManager.unmute(): Unmuting all sounds');
403404 for (var i=_s.soundIDs.length; i--;) {
404405 _s.sounds[_s.soundIDs[i]].unmute();
405406 }
406407 _s.muted = false;
407408 } else {
408 if (!_s._idCheck(sID)) return false;
409 if (!_s._idCheck(sID)) {
410 return false;
411 }
409412 _s._wD('soundManager.unmute(): Unmuting "'+sID+'"');
410413 _s.sounds[sID].unmute();
411414 }
418418 _s.unmute();
419419 };
420420
421 this.getMemoryUse = function() {
422 if (_s.flashVersion == 8) {
423 // not supported in Flash 8
424 return 0;
425 }
426 if (_s.o) {
427 return parseInt(_s.o._getMemoryUse(),10);
428 }
429 };
430
421431 this.setPolling = function(bPolling) {
422 if (!_s.o || !_s.allowPolling) return false;
432 if (!_s.o || !_s.allowPolling) {
433 return false;
434 }
423435 // _s._wD('soundManager.setPolling('+bPolling+')');
424436 _s.o._setPolling(bPolling);
425437 };
426438
427439 this.disable = function(bUnload) {
428440 // destroy all functions
429 if (_s._disabled) return false;
441 if (_s._disabled) {
442 return false;
443 }
430444 _s._disabled = true;
431445 _s._wD('soundManager.disable(): Disabling all functions - future calls will return false.',1);
432446 for (var i=_s.soundIDs.length; i--;) {
433447 _s._disableObject(_s.sounds[_s.soundIDs[i]]);
434 };
448 }
435449 _s.initComplete(); // fire "complete", despite fail
436450 _s._disableObject(_s);
437451 };
438452
439 this.handleFlashBlock = function(bForce) {
440 // experimental, removed with >v2.80.
441 return false;
442 };
443
444453 this.canPlayURL = function(sURL) {
445454 return (sURL?(sURL.match(_s.filePattern)?true:false):null);
446455 };
447456
448457 this.getSoundById = function(sID,suppressDebug) {
449 if (!sID) throw new Error('SoundManager.getSoundById(): sID is null/undefined');
458 if (!sID) {
459 throw new Error('SoundManager.getSoundById(): sID is null/undefined');
460 }
450461 var result = _s.sounds[sID];
451462 if (!result && !suppressDebug) {
452463 _s._wD('"'+sID+'" is an invalid sound ID.',2);
453464 // soundManager._wD('trace: '+arguments.callee.caller);
454 };
465 }
455466 return result;
456467 };
457468
480480
481481 this._idCheck = this.getSoundById;
482482
483 var _doNothing = function() {
484 return false;
485 };
486 _doNothing._protected = true;
487
483488 this._disableObject = function(o) {
484489 for (var oProp in o) {
485 if (typeof o[oProp] == 'function' && typeof o[oProp]._protected == 'undefined') o[oProp] = function(){return false;};
486 };
490 if (typeof o[oProp] == 'function' && typeof o[oProp]._protected == 'undefined') {
491 o[oProp] = _doNothing;
492 }
493 }
487494 oProp = null;
488495 };
489496
490497 this._failSafely = function() {
491498 // exception handler for "object doesn't support this property or method" or general failure
492 var fpgssTitle = 'You may need to whitelist this location/domain eg. file:///C:/ or C:/ or mysite.com, or set ALWAYS ALLOW under the Flash Player Global Security Settings page. The latter is probably less-secure.';
493 var flashCPL = '<a href="'+flashCPLink+'" title="'+fpgssTitle+'">view/edit</a>';
494 var FPGSS = '<a href="'+flashCPLink+'" title="Flash Player Global Security Settings">FPGSS</a>';
495499 if (!_s._disabled) {
496500 _s._wD('soundManager: Failed to initialise.',2);
497501 _s.disable();
498 };
502 }
499503 };
500504
501505 this._normalizeMovieURL = function(smURL) {
506 var urlParams = null;
502507 if (smURL) {
503 if (smURL.match(/\.swf/)) {
504 smURL = smURL.substr(0,smURL.lastIndexOf('.swf'));
505 }
506 if (smURL.lastIndexOf('/') != smURL.length-1) {
508 if (smURL.match(/\.swf(\?.*)?$/i)) {
509 urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?')+4);
510 if (urlParams) {
511 return smURL; // assume user knows what they're doing
512 }
513 } else if (smURL.lastIndexOf('/') != smURL.length-1) {
507514 smURL = smURL+'/';
508515 }
509516 }
524524 this._getDocument._protected = true;
525525
526526 this._createMovie = function(smID,smURL) {
527 if (_s._didAppend && _s._appendSuccess) return false; // ignore if already succeeded
528 if (window.location.href.indexOf('debug=1')+1) _s.debugMode = true; // allow force of debug mode via URL
527 if (_s._didAppend && _s._appendSuccess) {
528 return false; // ignore if already succeeded
529 }
530 if (window.location.href.indexOf('debug=1')+1) {
531 _s.debugMode = true; // allow force of debug mode via URL
532 }
529533 _s._didAppend = true;
530534
531535 // safety check for legacy (change to Flash 9 URL)
539539 _s.url = _s._normalizeMovieURL(_s._overHTTP?remoteURL:localURL);
540540 smURL = _s.url;
541541
542 var htmlEmbed = '<embed name="'+smID+'" id="'+smID+'" src="'+smURL+'" width="100%" height="100%" quality="high" allowScriptAccess="always" quality="high" '+(_s.useHighPerformance && !_s.useMovieStar?'wmode="transparent" ':'')+'bgcolor="'+_s.bgColor+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';
543 var htmlObject = '<object id="'+smID+'" data="'+smURL+'" type="application/x-shockwave-flash" width="100%" height="100%"><param name="movie" value="'+smURL+'" /><param name="AllowScriptAccess" value="always" /><param name="quality" value="high" />'+(_s.useHighPerformance && !_s.useMovieStar?'<param name="wmode" value="transparent" /> ':'')+'<param name="bgcolor" value="'+_s.bgColor+'" /><!-- --></object>';
544 var html = (!_s.isIE?htmlEmbed:htmlObject);
542 var specialCase = null;
543 if (_s.useHighPerformance && _s.useHighPerformance != 'always' && navigator.platform.match(/win32/i) && navigator.userAgent.match(/firefox/i)) {
544 specialCase = 'Note: disabling highPerformance, known issues with this browser/OS combo.';
545 _s.useHighPerformance = false;
546 }
545547
546 var toggleElement = '<div id="'+_s.debugID+'-toggle" style="position:fixed;_position:absolute;right:0px;bottom:0px;_top:0px;width:1.2em;height:1.2em;line-height:1.2em;margin:2px;padding:0px;text-align:center;border:1px solid #999;cursor:pointer;background:#fff;color:#333;z-index:10001" title="Toggle SM2 debug console" onclick="soundManager._toggleDebug()">-</div>';
547 var debugHTML = '<div id="'+_s.debugID+'" style="display:'+(_s.debugMode && ((!_s._hasConsole||!_s.useConsole)||(_s.useConsole && _s._hasConsole && !_s.consoleOnly))?'block':'none')+';opacity:0.85"></div>';
548 if (_s.useHighPerformance && _s.useMovieStar) {
549 specialCase = 'Note: disabling highPerformance, not applicable with movieStar mode on';
550 _s.useHighPerformance = false;
551 }
552
553 var oEmbed = {
554 name: smID,
555 id: smID,
556 src: smURL,
557 width: '100%',
558 height: '100%',
559 quality: 'high',
560 allowScriptAccess: 'always',
561 bgcolor: _s.bgColor,
562 pluginspage: 'http://www.macromedia.com/go/getflashplayer',
563 type: 'application/x-shockwave-flash'
564 };
565
566 var oObject = {
567 id: smID,
568 data: smURL,
569 type: 'application/x-shockwave-flash',
570 width: '100%',
571 height: '100%'
572 };
573
574 var oObjectParams = {
575 movie: smURL,
576 AllowScriptAccess: 'always',
577 quality: 'high',
578 bgcolor: _s.bgColor
579 };
580
581 if (_s.useHighPerformance && !_s.useMovieStar) {
582 oEmbed.wmode = 'transparent';
583 oObjectParams.wmode = 'transparent';
584 }
585
586 var oMovie = null;
587 var tmp = null;
588
589 if (_s.isIE) {
590 // IE is "special".
591 oMovie = document.createElement('div');
592 var movieHTML = '<object id="'+smID+'" data="'+smURL+'" type="application/x-shockwave-flash" width="100%" height="100%"><param name="movie" value="'+smURL+'" /><param name="AllowScriptAccess" value="always" /><param name="quality" value="high" />'+(_s.useHighPerformance && !_s.useMovieStar?'<param name="wmode" value="transparent" /> ':'')+'<param name="bgcolor" value="'+_s.bgColor+'" /><!-- --></object>';
593 } else {
594 oMovie = document.createElement('embed');
595 for (tmp in oEmbed) {
596 if (oEmbed.hasOwnProperty(tmp)) {
597 oMovie.setAttribute(tmp,oEmbed[tmp]);
598 }
599 }
600 }
601
602 var oD = document.createElement('div');
603 oD.id = _s.debugID+'-toggle';
604 var oToggle = {
605 position: 'fixed',
606 bottom: '0px',
607 right: '0px',
608 width: '1.2em',
609 height: '1.2em',
610 lineHeight: '1.2em',
611 margin: '2px',
612 textAlign: 'center',
613 border: '1px solid #999',
614 cursor: 'pointer',
615 background: '#fff',
616 color: '#333',
617 zIndex: 10001
618 };
619
620 oD.appendChild(document.createTextNode('-'));
621 oD.onclick = _s._toggleDebug;
622 oD.title = 'Toggle SM2 debug console';
623
624 if (navigator.userAgent.match(/msie 6/i)) {
625 oD.style.position = 'absolute';
626 oD.style.cursor = 'hand';
627 }
628
629 for (tmp in oToggle) {
630 if (oToggle.hasOwnProperty(tmp)) {
631 oD.style[tmp] = oToggle[tmp];
632 }
633 }
634
548635 var appXHTML = 'soundManager._createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.';
549636
550637 var oTarget = _s._getDocument();
638
551639 if (oTarget) {
552640
553641 _s.oMC = document.getElementById('sm2-container')?document.getElementById('sm2-container'):document.createElement('div');
642
554643 if (!_s.oMC.id) {
555644 _s.oMC.id = 'sm2-container';
556645 _s.oMC.className = 'movieContainer';
557646 // "hide" flash movie
558647 var s = null;
648 var oEl = null;
559649 if (_s.useHighPerformance) {
560650 s = {
561 position: 'fixed',
562 width: '8px',
651 position: 'fixed',
652 width: '8px',
563653 height: '8px', // must be at least 6px for flash to run fast. odd? yes.
564654 bottom: '0px',
565655 left: '0px',
566 zIndex:-1 // sit behind everything else
567 }
656 zIndex:-1 // sit behind everything else
657 };
568658 } else {
569659 s = {
570660 position: 'absolute',
571 width: '1px',
661 width: '1px',
572662 height: '1px',
573663 bottom: '0px',
574664 left: '0px'
575 }
665 };
576666 }
577667 var x = null;
578668 for (x in s) {
579 _s.oMC.style[x] = s[x];
669 if (s.hasOwnProperty(x)) {
670 _s.oMC.style[x] = s[x];
671 }
580672 }
581673 try {
674 if (!_s.isIE) {
675 _s.oMC.appendChild(oMovie);
676 }
582677 oTarget.appendChild(_s.oMC);
583 _s.oMC.innerHTML = html;
678 if (_s.isIE) {
679 oEl = _s.oMC.appendChild(document.createElement('div'));
680 oEl.className = 'sm2-object-box';
681 oEl.innerHTML = movieHTML;
682 }
584683 _s._appendSuccess = true;
585684 } catch(e) {
586685 throw new Error(appXHTML);
587686 }
588687 } else {
589688 // it's already in the document.
590 _s.oMC.innerHTML = html;
689 _s.oMC.appendChild(oMovie);
690 if (_s.isIE) {
691 oEl = _s.oMC.appendChild(document.createElement('div'));
692 oEl.className = 'sm2-object-box';
693 oEl.innerHTML = movieHTML;
694 }
591695 _s._appendSuccess = true;
592696 }
697
593698 if (!document.getElementById(_s.debugID) && ((!_s._hasConsole||!_s.useConsole)||(_s.useConsole && _s._hasConsole && !_s.consoleOnly))) {
594699 var oDebug = document.createElement('div');
595700 oDebug.id = _s.debugID;
596701 oDebug.style.display = (_s.debugMode?'block':'none');
597702 if (_s.debugMode) {
598703 try {
599 var oD = document.createElement('div');
600704 oTarget.appendChild(oD);
601 oD.innerHTML = toggleElement;
602 } catch(e) {
705 } catch(e2) {
603706 throw new Error(appXHTML);
604 };
605 };
707 }
708 }
606709 oTarget.appendChild(oDebug);
607 };
710 }
608711 oTarget = null;
609 };
610 _s._wD('-- SoundManager 2 '+_s.version+(_s.useMovieStar?', MovieStar mode':'')+(_s._wD?', high performance mode':'')+' --',1);
712 }
713
714 if (specialCase) {
715 _s._wD(specialCase);
716 }
717
718 _s._wD('-- SoundManager 2 '+_s.version+(_s.useMovieStar?', MovieStar mode':'')+(_s.useHighPerformance?', high performance mode':'')+' --',1);
611719 _s._wD('soundManager._createMovie(): Trying to load '+smURL+(!_s._overHTTP && _s.altURL?'(alternate URL)':''),1);
612720 };
613721
614722 // aliased to this._wD()
615723 this._writeDebug = function(sText,sType,bTimestamp) {
616 if (!_s.debugMode) return false;
724 if (!_s.debugMode) {
725 return false;
726 }
617727 if (typeof bTimestamp != 'undefined' && bTimestamp) {
618728 sText = sText + ' | '+new Date().getTime();
619 };
729 }
620730 if (_s._hasConsole && _s.useConsole) {
621731 var sMethod = _s._debugLevels[sType];
622732 if (typeof console[sMethod] != 'undefined') {
623 console[sMethod](sText);
733 console[sMethod].apply(console,[sText]); // apply() fix for firebug 1.3, so "this" == console
624734 } else {
625735 console.log(sText);
626 };
627 if (_s.useConsoleOnly) return true;
628 };
736 }
737 if (_s.useConsoleOnly) {
738 return true;
739 }
740 }
629741 var sDID = 'soundmanager-debug';
630742 try {
631743 var o = document.getElementById(sDID);
632 if (!o) return false;
744 if (!o) {
745 return false;
746 }
633747 var oItem = document.createElement('div');
634 sText = sText.replace(/\n/g,'<br />');
748 // sText = sText.replace(/\n/g,'<br />');
635749 if (typeof sType == 'undefined') {
636 var sType = 0;
750 sType = 0;
637751 } else {
638 sType = parseInt(sType);
639 };
640 oItem.innerHTML = sText;
752 sType = parseInt(sType,10);
753 }
754 oItem.appendChild(document.createTextNode(sText));
641755 if (sType) {
642 if (sType >= 2) oItem.style.fontWeight = 'bold';
643 if (sType == 3) oItem.style.color = '#ff3333';
644 };
756 if (sType >= 2) {
757 oItem.style.fontWeight = 'bold';
758 }
759 if (sType == 3) {
760 oItem.style.color = '#ff3333';
761 }
762 }
645763 // o.appendChild(oItem); // top-to-bottom
646764 o.insertBefore(oItem,o.firstChild); // bottom-to-top
647765 } catch(e) {
648766 // oh well
649 };
767 }
650768 o = null;
651769 };
652770 this._writeDebug._protected = true;
774774
775775 if (window.location.href.indexOf('debug=alert')+1 && _s.debugMode) {
776776 _s._wD = _s._wDAlert;
777 };
777 }
778778
779779 this._toggleDebug = function() {
780780 var o = document.getElementById(_s.debugID);
781781 var oT = document.getElementById(_s.debugID+'-toggle');
782 if (!o) return false;
782 if (!o) {
783 return false;
784 }
783785 if (_s._debugOpen) {
784786 // minimize
785787 oT.innerHTML = '+';
789789 } else {
790790 oT.innerHTML = '-';
791791 o.style.display = 'block';
792 };
792 }
793793 _s._debugOpen = !_s._debugOpen;
794794 };
795795
799799 _s._wD('--- soundManager._debug(): Current sound objects ---',1);
800800 for (var i=0,j=_s.soundIDs.length; i<j; i++) {
801801 _s.sounds[_s.soundIDs[i]]._debug();
802 };
802 }
803803 };
804804
805 this._debugTS = function(sEventType,bSuccess,sMessage) {
806 // troubleshooter debug hooks
807 if (typeof sm2Debugger != 'undefined') {
808 try {
809 sm2Debugger.handleEvent(sEventType,bSuccess,sMessage);
810 } catch(e) {
811 // oh well
812 }
813 }
814 };
815
816 this._debugTS._protected = true;
817
805818 this._mergeObjects = function(oMain,oAdd) {
806819 // non-destructive merge
807820 var o1 = {}; // clone o1
808821 for (var i in oMain) {
809 o1[i] = oMain[i];
822 if (oMain.hasOwnProperty(i)) {
823 o1[i] = oMain[i];
824 }
810825 }
811826 var o2 = (typeof oAdd == 'undefined'?_s.defaultOptions:oAdd);
812827 for (var o in o2) {
813 if (typeof o1[o] == 'undefined') o1[o] = o2[o];
814 };
828 if (o2.hasOwnProperty(o) && typeof o1[o] == 'undefined') {
829 o1[o] = o2[o];
830 }
831 }
815832 return o1;
816833 };
817834
818835 this.createMovie = function(sURL) {
819 if (sURL) _s.url = sURL;
836 if (sURL) {
837 _s.url = sURL;
838 }
820839 _s._initMovie();
821840 };
822841
843843
844844 this._initMovie = function() {
845845 // attempt to get, or create, movie
846 if (_s.o) return false; // pre-init may have fired this function before window.onload(), may already exist
846 if (_s.o) {
847 return false; // pre-init may have fired this function before window.onload(), may already exist
848 }
847849 _s.o = _s.getMovie(_s.id); // try to get flash movie (inline markup)
848850 if (!_s.o) {
849851 // try to create
850852 _s._createMovie(_s.id,_s.url);
851853 _s.o = _s.getMovie(_s.id);
852 };
854 }
853855 if (_s.o) {
854856 _s._wD('soundManager._initMovie(): Got '+_s.o.nodeName+' element ('+(_s._didAppend?'created via JS':'static HTML')+')',1);
855857 _s._wD('soundManager._initMovie(): Waiting for ExternalInterface call from Flash..');
856 };
858 }
857859 };
858860
859861 this.waitForExternalInterface = function() {
860 if (_s._waitingForEI) return false;
862 if (_s._waitingForEI) {
863 return false;
864 }
861865 _s._waitingForEI = true;
862866 if (_s._tryInitOnFocus && !_s._isFocused) {
863867 _s._wD('soundManager: Special case: Flash may not have started due to non-focused tab (Safari is lame), and/or focus cannot be detected. Waiting for focus-related event..');
864868 return false;
865 };
869 }
866870 if (!_s._didInit) {
867871 _s._wD('soundManager: Getting impatient, still waiting for Flash.. ;)');
868 };
872 }
869873 setTimeout(function() {
870874 if (!_s._didInit) {
871875 _s._wD('soundManager: No Flash response within reasonable time after document load.\nPossible causes: Flash version under 8, no support, or Flash security denying JS-Flash communication.',2);
872876 if (!_s._overHTTP) {
873877 _s._wD('soundManager: Loading this page from local/network file system (not over HTTP?) Flash security likely restricting JS-Flash access. Consider adding current URL to "trusted locations" in the Flash player security settings manager at '+flashCPLink+', or simply serve this content over HTTP.',2);
874 };
875 };
878 }
879 _s._debugTS('flashtojs',false,': Timed out'+(_s._overHTTP)?' (Check flash security)':' (No plugin/missing SWF?)');
880 }
876881 // if still not initialized and no other options, give up
877 if (!_s._didInit && _s._okToDisable) _s._failSafely();
882 if (!_s._didInit && _s._okToDisable) {
883 _s._failSafely();
884 }
878885 },750);
879886 };
880887
881888 this.handleFocus = function() {
882 if (_s._isFocused || !_s._tryInitOnFocus) return true;
889 if (_s._isFocused || !_s._tryInitOnFocus) {
890 return true;
891 }
883892 _s._okToDisable = true;
884893 _s._isFocused = true;
885894 _s._wD('soundManager.handleFocus()');
886895 if (_s._tryInitOnFocus) {
887896 // giant Safari 3.1 hack - assume window in focus if mouse is moving, since document.hasFocus() not currently implemented.
888897 window.removeEventListener('mousemove',_s.handleFocus,false);
889 };
898 }
890899 // allow init to restart
891900 _s._waitingForEI = false;
892901 setTimeout(_s.waitForExternalInterface,500);
904904 window.removeEventListener('focus',_s.handleFocus,false);
905905 } else if (window.detachEvent) {
906906 window.detachEvent('onfocus',_s.handleFocus);
907 };
907 }
908908 };
909909
910910 this.initComplete = function() {
911 if (_s._didInit) return false;
911 if (_s._didInit) {
912 return false;
913 }
912914 _s._didInit = true;
913915 _s._wD('-- SoundManager 2 '+(_s._disabled?'failed to load':'loaded')+' ('+(_s._disabled?'security/load error':'OK')+') --',1);
914916 if (_s._disabled) {
915917 _s._wD('soundManager.initComplete(): calling soundManager.onerror()',1);
918 _s._debugTS('onload',false);
916919 _s.onerror.apply(window);
917920 return false;
918 };
921 } else {
922 _s._debugTS('onload',true);
923 }
919924 if (_s.waitForWindowLoad && !_s._windowLoaded) {
920925 _s._wD('soundManager: Waiting for window.onload()');
921926 if (window.addEventListener) {
922927 window.addEventListener('load',_s.initUserOnload,false);
923928 } else if (window.attachEvent) {
924929 window.attachEvent('onload',_s.initUserOnload);
925 };
930 }
926931 return false;
927932 } else {
928933 if (_s.waitForWindowLoad && _s._windowLoaded) {
929934 _s._wD('soundManager: Document already loaded');
930 };
935 }
931936 _s.initUserOnload();
932 };
937 }
933938 };
934939
935940 this.initUserOnload = function() {
936941 _s._wD('soundManager.initComplete(): calling soundManager.onload()',1);
937942 // call user-defined "onload", scoped to window
938 try {
939 _s.onload.apply(window);
940 } catch(e) {
941 // something broke (likely JS error in user function)
942 _s._wD('soundManager.onload() threw an exception: '+e.message,2);
943 setTimeout(function(){throw new Error(e)},20);
944 return false;
945 };
943 _s.onload.apply(window);
946944 _s._wD('soundManager.onload() complete',1);
947945 };
948946
951951 if (_s._didInit) {
952952 _s._wD('soundManager.init(): Already called?');
953953 return false;
954 };
954 }
955955 // event cleanup
956956 if (window.removeEventListener) {
957957 window.removeEventListener('load',_s.beginDelayedInit,false);
958958 } else if (window.detachEvent) {
959959 window.detachEvent('onload',_s.beginDelayedInit);
960 };
960 }
961961 try {
962 _s._wD('Attempting to call JS -&gt; Flash..');
962 _s._wD('Attempting to call Flash from JS..');
963963 _s.o._externalInterfaceTest(false); // attempt to talk to Flash
964964 // _s._wD('Flash ExternalInterface call (JS-Flash) OK',1);
965965 if (!_s.allowPolling) {
966966 _s._wD('Polling (whileloading/whileplaying support) is disabled.',1);
967967 }
968968 _s.setPolling(true);
969 if (!_s.debugMode) _s.o._disableDebug();
969 if (!_s.debugMode) {
970 _s.o._disableDebug();
971 }
970972 _s.enabled = true;
973 _s._debugTS('jstoflash',true);
971974 } catch(e) {
975 _s._debugTS('jstoflash',false);
972976 _s._failSafely();
973977 _s.initComplete();
974978 return false;
975 };
979 }
976980 _s.initComplete();
977981 };
978982
988988 };
989989
990990 this.beginInit = function() {
991 if (_s._initPending) return false;
991 if (_s._initPending) {
992 return false;
993 }
992994 _s.createMovie(); // ensure creation if not already done
993995 _s._initMovie();
994996 _s._initPending = true;
999999
10001000 this.domContentLoaded = function() {
10011001 _s._wD('soundManager.domContentLoaded()');
1002 if (document.removeEventListener) document.removeEventListener('DOMContentLoaded',_s.domContentLoaded,false);
1002 if (document.removeEventListener) {
1003 document.removeEventListener('DOMContentLoaded',_s.domContentLoaded,false);
1004 }
10031005 _s.go();
10041006 };
10051007
10061008 this._externalInterfaceOK = function() {
10071009 // callback from flash for confirming that movie loaded, EI is working etc.
1008 if (_s.swfLoaded) return false;
1010 if (_s.swfLoaded) {
1011 return false;
1012 }
10091013 _s._wD('soundManager._externalInterfaceOK()');
1014 _s._debugTS('swf',true);
1015 _s._debugTS('flashtojs',true);
10101016 _s.swfLoaded = true;
10111017 _s._tryInitOnFocus = false;
10121018 if (_s.isIE) {
10201020 setTimeout(_s.init,100);
10211021 } else {
10221022 _s.init();
1023 };
1023 }
10241024 };
10251025
10261026 this._setSandboxType = function(sandboxType) {
10381038 } else if (sb.type == 'localTrusted') {
10391039 sb.noRemote = false;
10401040 sb.noLocal = false;
1041 };
1041 }
10421042 };
10431043
10441044 this.destruct = function() {
10481048
10491049 // SMSound (sound object)
10501050
1051 function SMSound(oOptions) {
1051 SMSound = function(oOptions) {
10521052 var _t = this;
10531053 this.sID = oOptions.id;
10541054 this.url = oOptions.url;
10561056 this.instanceOptions = this.options; // per-play-instance-specific options
10571057 this._iO = this.instanceOptions; // short alias
10581058
1059 // assign property defaults (volume, pan etc.)
1060 this.pan = this.options.pan;
1061 this.volume = this.options.volume;
1062
10591063 this._debug = function() {
10601064 if (_s.debugMode) {
10611065 var stuff = null;
10681068 var sfBracket = null;
10691069 var maxLength = 64; // # of characters of function code to show before truncating
10701070 for (stuff in _t.options) {
1071 if (_t.options[stuff] != null) {
1071 if (_t.options[stuff] !== null) {
10721072 if (_t.options[stuff] instanceof Function) {
10731073 // handle functions specially
10741074 sF = _t.options[stuff].toString();
10771077 msg[msg.length] = ' '+stuff+': {'+sF.substr(sfBracket+1,(Math.min(Math.max(sF.indexOf('\n')-1,maxLength),maxLength))).replace(/\n/g,'')+'... }';
10781078 } else {
10791079 msg[msg.length] = ' '+stuff+': '+_t.options[stuff];
1080 };
1081 };
1082 };
1080 }
1081 }
1082 }
10831083 _s._wD('SMSound() merged options: {\n'+msg.join(', \n')+'\n}');
1084 };
1084 }
10851085 };
10861086
10871087 this._debug();
11261126 _t._iO = _s._mergeObjects(oOptions);
11271127 _t.instanceOptions = _t._iO;
11281128 } else {
1129 var oOptions = _t.options;
1129 oOptions = _t.options;
11301130 _t._iO = oOptions;
11311131 _t.instanceOptions = _t._iO;
11321132 }
1133 if (typeof _t._iO.url == 'undefined') _t._iO.url = _t.url;
1133 if (typeof _t._iO.url == 'undefined') {
1134 _t._iO.url = _t.url;
1135 }
11341136 _s._wD('soundManager.load(): '+_t._iO.url,1);
1135 if (_t._iO.url == _t.url && _t.readyState != 0 && _t.readyState != 2) {
1137 if (_t._iO.url == _t.url && _t.readyState !== 0 && _t.readyState != 2) {
11361138 _s._wD('soundManager.load(): current URL already assigned.',1);
11371139 return false;
11381140 }
11391141 _t.loaded = false;
11401142 _t.readyState = 1;
1141 _t.playState = (oOptions.autoPlay?1:0); // if autoPlay, assume "playing" is true (no way to detect when it actually starts in Flash unless onPlay is watched?)
1143 _t.playState = 0; // (oOptions.autoPlay?1:0); // if autoPlay, assume "playing" is true (no way to detect when it actually starts in Flash unless onPlay is watched?)
11421144 try {
11431145 if (_s.flashVersion==8) {
11441146 _s.o._load(_t.sID,_t._iO.url,_t._iO.stream,_t._iO.autoPlay,(_t._iO.whileloading?1:0));
11501150 // special case: MPEG4 content must start playing to load, then pause to prevent playing.
11511151 _t.pause();
11521152 }
1153 };
1153 }
11541154 } catch(e) {
11551155 _s._wD('SMSound.load(): Exception: JS-Flash communication failed, or JS error.',2);
1156 _s._debugTS('onload',false);
11561157 _s.onerror();
11571158 _s.disable();
1158 };
1159 }
1160
11591161 };
11601162
11611163 this.unload = function() {
11621164 // Flash 8/AS2 can't "close" a stream - fake it by loading an empty MP3
11631165 // Flash 9/AS3: Close stream, preventing further load
1164 if (_t.readyState != 0) {
1166 if (_t.readyState !== 0) {
11651167 _s._wD('SMSound.unload(): "'+_t.sID+'"');
11661168 if (_t.readyState != 2) { // reset if not error
1167 _t.setPosition(0); // reset current sound positioning
1169 _t.setPosition(0,true); // reset current sound positioning
11681170 }
11691171 _s.o._unload(_t.sID,_s.nullURL);
11701172 // reset load/status flags
11791179 _s._wD('SMSound.destruct(): "'+_t.sID+'"');
11801180 _s.o._destroySound(_t.sID);
11811181 _s.destroySound(_t.sID,true); // ensure deletion from controller
1182 }
1182 };
11831183
11841184 this.play = function(oOptions) {
1185 if (!oOptions) oOptions = {};
1185 if (!oOptions) {
1186 oOptions = {};
1187 }
11861188 _t._iO = _s._mergeObjects(oOptions,_t._iO);
11871189 _t._iO = _s._mergeObjects(_t._iO,_t.options);
11881190 _t.instanceOptions = _t._iO;
11951195 return false;
11961196 } else {
11971197 _s._wD('SMSound.play(): "'+_t.sID+'" already playing (multi-shot)',1);
1198 };
1199 };
1198 }
1199 }
12001200 if (!_t.loaded) {
1201 if (_t.readyState == 0) {
1201 if (_t.readyState === 0) {
12021202 _s._wD('SMSound.play(): Attempting to load "'+_t.sID+'"',1);
12031203 // try to get this sound playing ASAP
12041204 _t._iO.stream = true;
12111211 return false;
12121212 } else {
12131213 _s._wD('SMSound.play(): "'+_t.sID+'" is loading - attempting to play..',1);
1214 };
1214 }
12151215 } else {
12161216 _s._wD('SMSound.play(): "'+_t.sID+'"');
1217 };
1217 }
12181218 if (_t.paused) {
12191219 _t.resume();
12201220 } else {
12211221 _t.playState = 1;
1222 if (!_t.instanceCount || _s.flashVersion == 9) _t.instanceCount++;
1222 if (!_t.instanceCount || _s.flashVersion == 9) {
1223 _t.instanceCount++;
1224 }
12231225 _t.position = (typeof _t._iO.position != 'undefined' && !isNaN(_t._iO.position)?_t._iO.position:0);
1224 if (_t._iO.onplay) _t._iO.onplay.apply(_t);
1225 _t.setVolume(_t._iO.volume);
1226 _t.setPan(_t._iO.pan);
1226 if (_t._iO.onplay) {
1227 _t._iO.onplay.apply(_t);
1228 }
1229 _t.setVolume(_t._iO.volume,true); // restrict volume to instance options only
1230 _t.setPan(_t._iO.pan,true);
12271231 _s.o._start(_t.sID,_t._iO.loop||1,(_s.flashVersion==9?_t.position:_t.position/1000));
1228 };
1232 }
12291233 };
12301234
12311235 this.start = this.play; // just for convenience
12391239 _t.playState = 0;
12401240 _t.paused = false;
12411241 // if (_s.defaultOptions.onstop) _s.defaultOptions.onstop.apply(_s);
1242 if (_t._iO.onstop) _t._iO.onstop.apply(_t);
1242 if (_t._iO.onstop) {
1243 _t._iO.onstop.apply(_t);
1244 }
12431245 _s.o._stop(_t.sID,bAll);
12441246 _t.instanceCount = 0;
12451247 _t._iO = {};
12461248 // _t.instanceOptions = _t._iO;
1247 };
1249 }
12481250 };
12491251
1250 this.setPosition = function(nMsecOffset) {
1251 _t._iO.position = nMsecOffset;
1252 _s._wD('SMSound.setPosition('+nMsecOffset+')');
1252 this.setPosition = function(nMsecOffset,bNoDebug) {
1253 if (typeof nMsecOffset == 'undefined') {
1254 nMsecOffset = 0;
1255 }
1256 var offset = Math.min(_t.duration,Math.max(nMsecOffset,0)); // position >= 0 and <= current available (loaded) duration
1257 _t._iO.position = offset;
1258 if (!bNoDebug) {
1259 _s._wD('SMSound.setPosition('+nMsecOffset+')'+(nMsecOffset != offset?', corrected value: '+offset:''));
1260 }
12531261 _s.o._setPosition(_t.sID,(_s.flashVersion==9?_t._iO.position:_t._iO.position/1000),(_t.paused||!_t.playState)); // if paused or not playing, will not resume (by playing)
12541262 };
12551263
12561264 this.pause = function() {
1257 if (_t.paused || _t.playState == 0) return false;
1265 if (_t.paused || _t.playState === 0) {
1266 return false;
1267 }
12581268 _s._wD('SMSound.pause()');
12591269 _t.paused = true;
12601270 _s.o._pause(_t.sID);
1261 if (_t._iO.onpause) _t._iO.onpause.apply(_t);
1271 if (_t._iO.onpause) {
1272 _t._iO.onpause.apply(_t);
1273 }
12621274 };
12631275
12641276 this.resume = function() {
1265 if (!_t.paused || _t.playState == 0) return false;
1277 if (!_t.paused || _t.playState === 0) {
1278 return false;
1279 }
12661280 _s._wD('SMSound.resume()');
12671281 _t.paused = false;
12681282 _s.o._pause(_t.sID); // flash method is toggle-based (pause/resume)
1269 if (_t._iO.onresume) _t._iO.onresume.apply(_t);
1283 if (_t._iO.onresume) {
1284 _t._iO.onresume.apply(_t);
1285 }
12701286 };
12711287
12721288 this.togglePause = function() {
12901290 if (!_t.playState) {
12911291 _t.play({position:(_s.flashVersion==9?_t.position:_t.position/1000)});
12921292 return false;
1293 };
1293 }
12941294 if (_t.paused) {
12951295 _t.resume();
12961296 } else {
12971297 _t.pause();
1298 };
1298 }
12991299 };
13001300
1301 this.setPan = function(nPan) {
1302 if (typeof nPan == 'undefined') nPan = 0;
1301 this.setPan = function(nPan,bInstanceOnly) {
1302 if (typeof nPan == 'undefined') {
1303 nPan = 0;
1304 }
1305 if (typeof bInstanceOnly == 'undefined') {
1306 bInstanceOnly = false;
1307 }
13031308 _s.o._setPan(_t.sID,nPan);
13041309 _t._iO.pan = nPan;
1310 if (!bInstanceOnly) {
1311 _t.pan = nPan;
1312 }
13051313 };
13061314
1307 this.setVolume = function(nVol) {
1308 if (typeof nVol == 'undefined') nVol = 100;
1315 this.setVolume = function(nVol,bInstanceOnly) {
1316 if (typeof nVol == 'undefined') {
1317 nVol = 100;
1318 }
1319 if (typeof bInstanceOnly == 'undefined') {
1320 bInstanceOnly = false;
1321 }
13091322 _s.o._setVolume(_t.sID,(_s.muted&&!_t.muted)||_t.muted?0:nVol);
13101323 _t._iO.volume = nVol;
1324 if (!bInstanceOnly) {
1325 _t.volume = nVol;
1326 }
13111327 };
13121328
13131329 this.mute = function() {
1314 _t.muted = true;
1330 _t.muted = true;
13151331 _s.o._setVolume(_t.sID,0);
13161332 };
13171333
13181334 this.unmute = function() {
1319 _t.muted = false;
1320 _s.o._setVolume(_t.sID,typeof _t._iO.volume != 'undefined'?_t._iO.volume:_t.options.volume);
1335 _t.muted = false;
1336 var hasIO = typeof _t._iO.volume != 'undefined';
1337 _s.o._setVolume(_t.sID,hasIO?_t._iO.volume:_t.options.volume,hasIO?false:true);
13211338 };
13221339
13231340 // --- "private" methods called by Flash ---
13441344 _t.bytesLoaded = nBytesLoaded;
13451345 _t.bytesTotal = nBytesTotal;
13461346 _t.duration = Math.floor(nDuration);
1347 _t.durationEstimate = parseInt((_t.bytesTotal/_t.bytesLoaded)*_t.duration); // estimate total time (will only be accurate with CBR MP3s.)
1348 if (_t.readyState != 3 && _t._iO.whileloading) _t._iO.whileloading.apply(_t);
1347 _t.durationEstimate = parseInt((_t.bytesTotal/_t.bytesLoaded)*_t.duration,10); // estimate total time (will only be accurate with CBR MP3s.)
1348 if (_t.readyState != 3 && _t._iO.whileloading) {
1349 _t._iO.whileloading.apply(_t);
1350 }
13491351 } else {
13501352 _t.bytesLoaded = nBytesLoaded;
13511353 _t.bytesTotal = nBytesTotal;
13521354 _t.duration = Math.floor(nDuration);
13531355 _t.durationEstimate = _t.duration;
1354 if (_t.readyState != 3 && _t._iO.whileloading) _t._iO.whileloading.apply(_t);
1356 if (_t.readyState != 3 && _t._iO.whileloading) {
1357 _t._iO.whileloading.apply(_t);
1358 }
13551359 }
13561360 };
13571361
13671367 for (var i=0,j=oID3PropNames.length; i<j; i++) {
13681368 oData[oID3PropNames[i]] = oID3Data[i];
13691369 // _s._wD(oID3PropNames[i]+': '+oID3Data[i]);
1370 };
1370 }
13711371 _t.id3 = _s._mergeObjects(_t.id3,oData);
1372 if (_t._iO.onid3) _t._iO.onid3.apply(_t);
1372 if (_t._iO.onid3) {
1373 _t._iO.onid3.apply(_t);
1374 }
13731375 };
13741376
13751377 this._whileplaying = function(nPosition,oPeakData,oWaveformData,oEQData) {
1376 if (isNaN(nPosition) || nPosition == null) return false; // Flash may return NaN at times
1378 if (isNaN(nPosition) || nPosition === null) {
1379 return false; // Flash may return NaN at times
1380 }
13771381 _t.position = nPosition;
13781382 if (_t._iO.usePeakData && typeof oPeakData != 'undefined' && oPeakData) {
13791383 _t.peakData = {
13801384 left: oPeakData.leftPeak,
13811385 right: oPeakData.rightPeak
13821386 };
1383 };
1387 }
13841388 if (_t._iO.useWaveformData && typeof oWaveformData != 'undefined' && oWaveformData) {
13851389 _t.waveformData = oWaveformData;
13861390 /*
13931393 right: oSpectrumData.right.split(',')
13941394 }
13951395 */
1396 };
1396 }
13971397 if (_t._iO.useEQData && typeof oEQData != 'undefined' && oEQData) {
13981398 _t.eqData = oEQData;
1399 };
1399 }
14001400 if (_t.playState == 1) {
14011401 if (_t._iO.whileplaying) {
1402 _t._iO.whileplaying.apply(_t); // flash may call after actual finish
1403 };
1402 _t._iO.whileplaying.apply(_t); // flash may call after actual finish
1403 }
14041404 if (_t.loaded && _t._iO.onbeforefinish && _t._iO.onbeforefinishtime && !_t.didBeforeFinish && _t.duration-_t.position <= _t._iO.onbeforefinishtime) {
14051405 _s._wD('duration-position &lt;= onbeforefinishtime: '+_t.duration+' - '+_t.position+' &lt= '+_t._iO.onbeforefinishtime+' ('+(_t.duration-_t.position)+')');
14061406 _t._onbeforefinish();
1407 };
1408 };
1407 }
1408 }
14091409 };
14101410
14111411 this._onload = function(bSuccess) {
14121412 bSuccess = (bSuccess==1?true:false);
14131413 _s._wD('SMSound._onload(): "'+_t.sID+'"'+(bSuccess?' loaded.':' failed to load? - '+_t.url));
14141414 if (!bSuccess) {
1415 if (_s.sandbox.noRemote == true) {
1415 if (_s.sandbox.noRemote === true) {
14161416 _s._wD('SMSound._onload(): Reminder: Flash security is denying network/internet access',1);
1417 };
1418 if (_s.sandbox.noLocal == true) {
1417 }
1418 if (_s.sandbox.noLocal === true) {
14191419 _s._wD('SMSound._onload(): Reminder: Flash security is denying local access',1);
1420 };
1421 };
1420 }
1421 }
14221422 _t.loaded = bSuccess;
14231423 _t.readyState = bSuccess?3:2;
14241424 if (_t._iO.onload) {
14251425 _t._iO.onload.apply(_t);
1426 };
1426 }
14271427 };
14281428
14291429 this._onbeforefinish = function() {
14331433 _s._wD('SMSound._onbeforefinish(): "'+_t.sID+'"');
14341434 _t._iO.onbeforefinish.apply(_t);
14351435 }
1436 };
1436 }
14371437 };
14381438
14391439 this._onjustbeforefinish = function(msOffset) {
14441444 _s._wD('SMSound._onjustbeforefinish(): "'+_t.sID+'"');
14451445 _t._iO.onjustbeforefinish.apply(_t);
14461446 }
1447 };
1447 }
14481448 };
14491449
14501450 this._onfinish = function() {
14511451 // sound has finished playing
1452 _t.playState = 0;
1453 _t.paused = false;
1454 if (_t._iO.onfinish) {
1455 _s._wD('SMSound._onfinish(): "'+_t.sID+'"');
1456 _t._iO.onfinish.apply(_t);
1452
1453 // TODO: calling user-defined onfinish() should happen after setPosition(0)
1454 // OR: onfinish() and then setPosition(0) is bad.
1455
1456 if (_t._iO.onbeforefinishcomplete) {
1457 _t._iO.onbeforefinishcomplete.apply(_t);
14571458 }
1458 if (_t._iO.onbeforefinishcomplete) _t._iO.onbeforefinishcomplete.apply(_t);
14591459 // reset some state items
1460 _t.setPosition(0);
14611460 _t.didBeforeFinish = false;
14621461 _t.didJustBeforeFinish = false;
14631462 if (_t.instanceCount) {
14641463 _t.instanceCount--;
14651464 if (!_t.instanceCount) {
14661465 // reset instance options
1466 // _t.setPosition(0);
1467 _t.playState = 0;
1468 _t.paused = false;
14671469 _t.instanceCount = 0;
14681470 _t.instanceOptions = {};
1471 if (_t._iO.onfinish) {
1472 _s._wD('SMSound._onfinish(): "'+_t.sID+'"');
1473 _t._iO.onfinish.apply(_t);
1474 }
14691475 }
1476 } else {
1477 // _t.setPosition(0);
14701478 }
14711479 };
14721480
14871487 _s._wD('No width/height given, assuming defaults');
14881488 oMetaData.width = 320;
14891489 oMetaData.height = 240;
1490 };
1490 }
14911491 _t.metadata = oMetaData; // potentially-large object from flash
14921492 _t.width = oMetaData.width;
14931493 _t.height = oMetaData.height;
14951495 _s._wD('SMSound._onmetadata(): "'+_t.sID+'"');
14961496 _t._iO.onmetadata.apply(_t);
14971497 }
1498 _s.wD('SMSound.onmetadata() complete');
1498 _s._wD('SMSound.onmetadata() complete');
14991499 };
15001500
15011501 }; // SMSound()
15051505 window.addEventListener('focus',_s.handleFocus,false);
15061506 window.addEventListener('load',_s.beginDelayedInit,false);
15071507 window.addEventListener('unload',_s.destruct,false);
1508 if (_s._tryInitOnFocus) window.addEventListener('mousemove',_s.handleFocus,false); // massive Safari focus hack
1508 if (_s._tryInitOnFocus) {
1509 window.addEventListener('mousemove',_s.handleFocus,false); // massive Safari focus hack
1510 }
15091511 } else if (window.attachEvent) {
15101512 window.attachEvent('onfocus',_s.handleFocus);
15111513 window.attachEvent('onload',_s.beginDelayedInit);
15121514 window.attachEvent('unload',_s.destruct);
15131515 } else {
15141516 // no add/attachevent support - safe to assume no JS -> Flash either.
1517 _s._debugTS('onload',false);
15151518 soundManager.onerror();
15161519 soundManager.disable();
1517 };
1520 }
15181521
1519 if (document.addEventListener) document.addEventListener('DOMContentLoaded',_s.domContentLoaded,false);
1522 if (document.addEventListener) {
1523 document.addEventListener('DOMContentLoaded',_s.domContentLoaded,false);
1524 }
15201525
1521}; // SoundManager()
1526} // SoundManager()
15221527
1523var soundManager = new SoundManager();
1528soundManager = new SoundManager();
1529