From: Chris Porter Date: Sat, 20 Jun 2009 15:40:34 +0000 (+0100) Subject: Update SoundManager2 to 2.95a.20090501 (fixes issue 48). X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/86f67adcab583f0260430d24fe28f71276e5f00a?hp=07f9257cf0cf71435fbd0bada121e0dd7c73094c Update SoundManager2 to 2.95a.20090501 (fixes issue 48). --- diff --git a/.hgignore b/.hgignore index 26ddb70..2751b4d 100644 --- a/.hgignore +++ b/.hgignore @@ -16,3 +16,5 @@ Thumbs.db static/{ugly,swm,mocha,q}ui{,debug}.html {bin/,}.checked {bin/,}.compiled +ssl +screenlog* diff --git a/static/js/soundmanager2-nodebug-jsmin.js b/static/js/soundmanager2-nodebug-jsmin.js index e1fd36e..7077a74 100644 --- a/static/js/soundmanager2-nodebug-jsmin.js +++ b/static/js/soundmanager2-nodebug-jsmin.js @@ -7,6 +7,6 @@ Code licensed under the BSD License: http://schillmania.com/projects/soundmanager2/license.txt - V2.93a.20090117 + V2.95a.20090501 */ -var 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;jWarning: 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=''+(e.useHighPerformance&&!e.useMovieStar?' ':"")+''}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;m8){e.defaultOptions=e._mergeObjects(e.defaultOptions,e.flash9Options);e.features.buffering=true}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>8)};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.strings={notReady:"Not loaded yet",appXHTML:"appendChild/innerHTML set failed."};this.supported=function(){return(e._didInit&&!e._disabled)};this.getMovie=function(h){return e.isIE?window[h]:(e.isSafari?g(h)||document[h]:g(h))};this.loadFromXML=function(h){try{e.o._loadFromXML(h)}catch(i){e._failSafely();return true}};this.createSound=function(i){if(arguments.length==2){i={id:arguments[0],url:arguments[1]}}var j=e._mergeObjects(i);var h=j;if(e._idCheck(h.id,true)){return e.sounds[h.id]}if(e.flashVersion>8&&e.useMovieStar){if(h.isMovieStar===null){h.isMovieStar=(h.url.match(e.netStreamPattern)?true:false)}if(h.isMovieStar){}if(h.isMovieStar&&(h.usePeakData||h.useWaveformData||h.useEQData)){h.usePeakData=false;h.useWaveformData=false;h.useEQData=false}}e.sounds[h.id]=new f(h);e.soundIDs[e.soundIDs.length]=h.id;if(e.flashVersion==8){e.o._createSound(h.id,h.onjustbeforefinishtime)}else{e.o._createSound(h.id,h.url,h.onjustbeforefinishtime,h.usePeakData,h.useWaveformData,h.useEQData,h.isMovieStar,(h.isMovieStar?h.useVideo:false),(h.isMovieStar?h.bufferTime:false))}if(h.autoLoad||h.autoPlay){if(e.sounds[h.id]){e.sounds[h.id].load(h)}}if(h.autoPlay){e.sounds[h.id].play()}return e.sounds[h.id]};this.createVideo=function(h){if(arguments.length==2){h={id:arguments[0],url:arguments[1]}}if(e.flashVersion>=9){h.isMovieStar=true;h.useVideo=true}else{return false}if(!e.useMovieStar){}return e.createSound(h)};this.destroySound=function(j,h){if(!e._idCheck(j)){return false}for(var k=0;k'+(e.wmode?' ':"")+''}else{o=document.createElement("embed");for(B in A){if(A.hasOwnProperty(B)){o.setAttribute(B,A[B])}}}var j=document.createElement("div");j.id=e.debugID+"-toggle";var k={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};j.appendChild(document.createTextNode("-"));j.onclick=e._toggleDebug;j.title="Toggle SM2 debug console";if(navigator.userAgent.match(/msie 6/i)){j.style.position="absolute";j.style.cursor="hand"}for(B in k){if(k.hasOwnProperty(B)){j.style[B]=k[B]}}var v=e._getDocument();if(v){e.oMC=g("sm2-container")?g("sm2-container"):document.createElement("div");if(!e.oMC.id){e.oMC.id="sm2-container";e.oMC.className="movieContainer";var p=null;var q=null;if(e.useHighPerformance){p={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px"}}else{p={position:"absolute",width:"1px",height:"1px",top:"-999px",left:"-999px"}}var l=null;for(l in p){if(p.hasOwnProperty(l)){e.oMC.style[l]=p[l]}}try{if(!e.isIE){e.oMC.appendChild(o)}v.appendChild(e.oMC);if(e.isIE){q=e.oMC.appendChild(document.createElement("div"));q.className="sm2-object-box";q.innerHTML=u}e._appendSuccess=true}catch(z){throw new Error(e.strings.appXHTML)}}else{e.oMC.appendChild(o);if(e.isIE){q=e.oMC.appendChild(document.createElement("div"));q.className="sm2-object-box";q.innerHTML=u}e._appendSuccess=true}if(!g(e.debugID)&&((!e._hasConsole||!e.useConsole)||(e.useConsole&&e._hasConsole&&!e.consoleOnly))){var m=document.createElement("div");m.id=e.debugID;m.style.display=(e.debugMode?"block":"none");if(e.debugMode&&!g(j.id)){try{v.appendChild(j)}catch(i){throw new Error(e.strings.appXHTML)}v.appendChild(m)}}v=null}if(t){}};this._writeDebug=function(i,p,k){if(!e.debugMode){return false}if(typeof k!="undefined"&&k){i=i+" | "+new Date().getTime()}if(e._hasConsole&&e.useConsole){var h=e._debugLevels[p];if(typeof console[h]!="undefined"){console[h](i)}else{console.log(i)}if(e.useConsoleOnly){return true}}var n="soundmanager-debug";try{var m=g(n);if(!m){return false}var l=document.createElement("div");if(++e._wdCount%2===0){l.className="sm2-alt"}if(typeof p=="undefined"){p=0}else{p=parseInt(p,10)}l.appendChild(document.createTextNode(i));if(p){if(p>=2){l.style.fontWeight="bold"}if(p==3){l.style.color="#ff3333"}}m.insertBefore(l,m.firstChild)}catch(j){}m=null};this._writeDebug._protected=true;this._wdCount=0;this._wdCount._protected=true;this._wD=this._writeDebug;this._wDAlert=function(h){alert(h)};if(window.location.href.indexOf("debug=alert")+1&&e.debugMode){e._wD=e._wDAlert}this._toggleDebug=function(){var i=g(e.debugID);var h=g(e.debugID+"-toggle");if(!i){return false}if(e._debugOpen){h.innerHTML="+";i.style.display="none"}else{h.innerHTML="-";i.style.display="block"}e._debugOpen=!e._debugOpen};this._toggleDebug._protected=true;this._debug=function(){for(var k=0,h=e.soundIDs.length;k0){}}};this.waitForExternalInterface=function(){if(e._waitingForEI){return false}e._waitingForEI=true;if(e._tryInitOnFocus&&!e._isFocused){return false}if(e.flashLoadTimeout>0){if(!e._didInit){}setTimeout(function(){if(!e._didInit){if(!e._overHTTP){}e._debugTS("flashtojs",false,": Timed out"+(e._overHTTP)?" (Check flash security)":" (No plugin/missing SWF?)")}if(!e._didInit&&e._okToDisable){e._failSafely(true)}},e.flashLoadTimeout)}else{if(!e.didInit){}}};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(h){if(e._didInit){return false}e._didInit=true;if(e._disabled||h){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{if(e.waitForWindowLoad&&e._windowLoaded){}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);if(!e.allowPolling){}e.setPolling(true);if(!e.debugMode){e.o._disableDebug()}e.enabled=true;e._debugTS("jstoflash",true)}catch(h){e._debugTS("jstoflash",false);e._failSafely(true);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(h){var i=e.sandbox;i.type=h;i.description=i.types[(typeof i.types[h]!="undefined"?h:"unknown")];if(i.type=="localWithFile"){i.noRemote=true;i.noLocal=false}else{if(i.type=="localWithNetwork"){i.noRemote=false;i.noLocal=true}else{if(i.type=="localTrusted"){i.noRemote=false;i.noLocal=false}}}};this.reboot=function(){if(e.soundIDs.length){}for(var h=e.soundIDs.length;h--;){e.sounds[e.soundIDs[h]].destruct()}try{if(e.isIE){e.oRemovedHTML=e.o.innerHTML}e.oRemoved=e.o.parentNode.removeChild(e.o)}catch(j){}e.enabled=false;e._didInit=false;e._waitingForEI=false;e._initPending=false;e._didInit=false;e._didAppend=false;e._appendSuccess=false;e._didInit=false;e._disabled=false;e._waitingforEI=true;e.swfLoaded=false;e.soundIDs={};e.sounds=[];e.o=null;window.setTimeout(function(){soundManager.beginDelayedInit()},20)};this.destruct=function(){e.disable(true)};f=function(h){var i=this;this.sID=h.id;this.url=h.url;this.options=e._mergeObjects(h);this.instanceOptions=this.options;this._iO=this.instanceOptions;this.pan=this.options.pan;this.volume=this.options.volume;this._lastURL=null;this._debug=function(){if(e.debugMode){var l=null;var n=[];var k=null;var m=null;var j=64;for(l in i.options){if(i.options[l]!==null){if(i.options[l] instanceof Function){k=i.options[l].toString();k=k.replace(/\s\s+/g," ");m=k.indexOf("{");n[n.length]=" "+l+": {"+k.substr(m+1,(Math.min(Math.max(k.indexOf("\n")-1,j),j))).replace(/\n/g,"")+"... }"}else{n[n.length]=" "+l+": "+i.options[l]}}}}};this._debug();this.id3={};this.resetProperties=function(j){i.bytesLoaded=null;i.bytesTotal=null;i.position=null;i.duration=null;i.durationEstimate=null;i.loaded=false;i.playState=0;i.paused=false;i.readyState=0;i.muted=false;i.didBeforeFinish=false;i.didJustBeforeFinish=false;i.isBuffering=false;i.instanceOptions={};i.instanceCount=0;i.peakData={left:0,right:0};i.waveformData={left:[],right:[]};i.eqData=[]};i.resetProperties();this.load=function(j){if(typeof j!="undefined"){i._iO=e._mergeObjects(j);i.instanceOptions=i._iO}else{j=i.options;i._iO=j;i.instanceOptions=i._iO;if(i._lastURL&&i._lastURL!=i.url){i._iO.url=i.url;i.url=null}}if(typeof i._iO.url=="undefined"){i._iO.url=i.url}if(i._iO.url==i.url&&i.readyState!==0&&i.readyState!=2){return false}i.url=i._iO.url;i._lastURL=i._iO.url;i.loaded=false;i.readyState=1;i.playState=0;try{if(e.flashVersion==8){e.o._load(i.sID,i._iO.url,i._iO.stream,i._iO.autoPlay,(i._iO.whileloading?1:0))}else{e.o._load(i.sID,i._iO.url,i._iO.stream?true:false,i._iO.autoPlay?true:false);if(i._iO.isMovieStar&&i._iO.autoLoad&&!i._iO.autoPlay){i.pause()}}}catch(k){e._debugTS("onload",false);e.onerror();e.disable()}};this.unload=function(){if(i.readyState!==0){if(i.readyState!=2){i.setPosition(0,true)}e.o._unload(i.sID,e.nullURL);i.resetProperties()}};this.destruct=function(){e.o._destroySound(i.sID);e.destroySound(i.sID,true)};this.play=function(k){if(!k){k={}}i._iO=e._mergeObjects(k,i._iO);i._iO=e._mergeObjects(i._iO,i.options);i.instanceOptions=i._iO;if(i.playState==1){var j=i._iO.multiShot;if(!j){return false}else{}}if(!i.loaded){if(i.readyState===0){i._iO.stream=true;i._iO.autoPlay=true;i.load(i._iO)}else{if(i.readyState==2){return false}else{}}}else{}if(i.paused){i.resume()}else{i.playState=1;if(!i.instanceCount||e.flashVersion>8){i.instanceCount++}i.position=(typeof i._iO.position!="undefined"&&!isNaN(i._iO.position)?i._iO.position:0);if(i._iO.onplay){i._iO.onplay.apply(i)}i.setVolume(i._iO.volume,true);i.setPan(i._iO.pan,true);e.o._start(i.sID,i._iO.loop||1,(e.flashVersion==9?i.position:i.position/1000))}};this.start=this.play;this.stop=function(j){if(i.playState==1){i.playState=0;i.paused=false;if(i._iO.onstop){i._iO.onstop.apply(i)}e.o._stop(i.sID,j);i.instanceCount=0;i._iO={}}};this.setPosition=function(k,j){if(typeof k=="undefined"){k=0}var l=Math.min(i.duration,Math.max(k,0));i._iO.position=l;if(!j){}e.o._setPosition(i.sID,(e.flashVersion==9?i._iO.position:i._iO.position/1000),(i.paused||!i.playState))};this.pause=function(){if(i.paused||i.playState===0){return false}i.paused=true;e.o._pause(i.sID);if(i._iO.onpause){i._iO.onpause.apply(i)}};this.resume=function(){if(!i.paused||i.playState===0){return false}i.paused=false;e.o._pause(i.sID);if(i._iO.onresume){i._iO.onresume.apply(i)}};this.togglePause=function(){if(i.playState===0){i.play({position:(e.flashVersion==9?i.position:i.position/1000)});return false}if(i.paused){i.resume()}else{i.pause()}};this.setPan=function(k,j){if(typeof k=="undefined"){k=0}if(typeof j=="undefined"){j=false}e.o._setPan(i.sID,k);i._iO.pan=k;if(!j){i.pan=k}};this.setVolume=function(j,k){if(typeof j=="undefined"){j=100}if(typeof k=="undefined"){k=false}e.o._setVolume(i.sID,(e.muted&&!i.muted)||i.muted?0:j);i._iO.volume=j;if(!k){i.volume=j}};this.mute=function(){i.muted=true;e.o._setVolume(i.sID,0)};this.unmute=function(){i.muted=false;var j=typeof i._iO.volume!="undefined";e.o._setVolume(i.sID,j?i._iO.volume:i.options.volume)};this._whileloading=function(j,k,l){if(!i._iO.isMovieStar){i.bytesLoaded=j;i.bytesTotal=k;i.duration=Math.floor(l);i.durationEstimate=parseInt((i.bytesTotal/i.bytesLoaded)*i.duration,10);if(i.readyState!=3&&i._iO.whileloading){i._iO.whileloading.apply(i)}}else{i.bytesLoaded=j;i.bytesTotal=k;i.duration=Math.floor(l);i.durationEstimate=i.duration;if(i.readyState!=3&&i._iO.whileloading){i._iO.whileloading.apply(i)}}};this._onid3=function(n,k){var o=[];for(var m=0,l=n.length;m0){k=0}i.position=k;if(i._iO.usePeakData&&typeof l!="undefined"&&l){i.peakData={left:l.leftPeak,right:l.rightPeak}}if(i._iO.useWaveformData&&typeof n!="undefined"&&n){i.waveformData={left:n.split(","),right:j.split(",")}}if(i._iO.useEQData&&typeof m!="undefined"&&m){i.eqData=m}if(i.playState==1){if(i.isBuffering){i._onbufferchange(0)}if(i._iO.whileplaying){i._iO.whileplaying.apply(i)}if(i.loaded&&i._iO.onbeforefinish&&i._iO.onbeforefinishtime&&!i.didBeforeFinish&&i.duration-i.position<=i._iO.onbeforefinishtime){i._onbeforefinish()}}};this._onload=function(j){j=(j==1?true:false);if(!j){if(e.sandbox.noRemote===true){}if(e.sandbox.noLocal===true){}}i.loaded=j;i.readyState=j?3:2;if(i._iO.onload){i._iO.onload.apply(i)}};this._onbeforefinish=function(){if(!i.didBeforeFinish){i.didBeforeFinish=true;if(i._iO.onbeforefinish){i._iO.onbeforefinish.apply(i)}}};this._onjustbeforefinish=function(j){if(!i.didJustBeforeFinish){i.didJustBeforeFinish=true;if(i._iO.onjustbeforefinish){i._iO.onjustbeforefinish.apply(i)}}};this._onfinish=function(){if(i._iO.onbeforefinishcomplete){i._iO.onbeforefinishcomplete.apply(i)}i.didBeforeFinish=false;i.didJustBeforeFinish=false;if(i.instanceCount){i.instanceCount--;if(!i.instanceCount){i.playState=0;i.paused=false;i.instanceCount=0;i.instanceOptions={};if(i._iO.onfinish){i._iO.onfinish.apply(i)}}}else{if(i.useVideo){}}};this._onmetadata=function(j){if(!j.width&&!j.height){j.width=320;j.height=240}i.metadata=j;i.width=j.width;i.height=j.height;if(i._iO.onmetadata){i._iO.onmetadata.apply(i)}};this._onbufferchange=function(j){if(i.playState===0){return false}if(j==i.isBuffering){return false}i.isBuffering=(j==1?true:false);if(i._iO.onbufferchange){i._iO.onbufferchange.apply(i)}};this._ondataerror=function(j){if(i.playState>0){if(i._iO.ondataerror){i._iO.ondataerror.apply(i)}}else{}}};this._onfullscreenchange=function(h){e.isFullScreen=(h==1?true:false);if(!e.isFullScreen){try{window.focus()}catch(i){}}};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)}}if(typeof SM2_DEFER=="undefined"||!SM2_DEFER){soundManager=new SoundManager()}; diff --git a/static/js/soundmanager2.js b/static/js/soundmanager2.js index 508d461..ea545b8 100644 --- a/static/js/soundmanager2.js +++ b/static/js/soundmanager2.js @@ -7,7 +7,7 @@ Code licensed under the BSD License: http://schillmania.com/projects/soundmanager2/license.txt - V2.93a.20090117 + V2.95a.20090501 */ var soundManager = null; @@ -22,8 +22,11 @@ function SoundManager(smURL,smID) { this.nullURL = 'null.mp3'; // path to "null" (empty) MP3 file, used to unload sounds (Flash 8 only) this.allowPolling = true; // allow flash to poll for status update (required for "while playing", peak, sound spectrum functions to work.) this.useMovieStar = false; // enable support for Flash 9.0r115+ (codename "MovieStar") MPEG4 audio + video formats (AAC, M4V, FLV, MOV etc.) - this.bgColor = '#ffffff'; // movie (.swf) background color, useful if showing on-screen for video etc. - 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) + this.bgColor = '#ffffff'; // movie (.swf) background color, '#000000' useful if showing on-screen/full-screen video etc. + this.useHighPerformance = false; // position:fixed flash movie gives increased js/flash speed + this.flashLoadTimeout = 750; // ms to wait for flash movie to load before failing (0 = infinity) + this.wmode = null; // mode to render the flash movie in - null, transparent, opaque (last two allow layering of HTML on top) + this.allowFullScreen = true; // enter full-screen (via double-click on movie) for flash 9+ video this.defaultOptions = { '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) @@ -50,25 +53,28 @@ function SoundManager(smURL,smID) { }; this.flash9Options = { // flash 9-only options, merged into defaultOptions if flash 9 is being used - 'isMovieStar': null, // "MovieStar" MPEG4 audio/video mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL + 'isMovieStar': null, // "MovieStar" MPEG4 audio/video mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL 'usePeakData': false, // enable left/right channel peak (level) data 'useWaveformData': false, // enable sound spectrum (raw waveform data) - WARNING: CPU-INTENSIVE: may set CPUs on fire. - 'useEQData': false // enable sound EQ (frequency spectrum data) - WARNING: Also CPU-intensive. + 'useEQData': false, // enable sound EQ (frequency spectrum data) - WARNING: Also CPU-intensive. + 'onbufferchange': null, // callback for "isBuffering" property change + 'ondataerror': null // callback for waveform/eq data access error (flash playing audio in other tabs/domains) }; this.movieStarOptions = { // flash 9.0r115+ MPEG4 audio/video options, merged into defaultOptions if flash 9 + movieStar mode is enabled - 'onmetadata': null, // callback for when video width/height etc. are received - 'useVideo': false // if loading movieStar content, whether to show video + 'onmetadata': null, // callback for when video width/height etc. are received + 'useVideo': false, // if loading movieStar content, whether to show video + 'bufferTime': null // seconds of data to buffer before playback begins (null = flash default of 0.1 seconds - if AAC playback is gappy, try up to 3 seconds) }; // jslint global declarations - /*global sm2Debugger, alert, console, document, navigator, setTimeout, window */ + /*global SM2_DEFER, sm2Debugger, alert, console, document, navigator, setTimeout, window */ var SMSound = null; // defined later var _s = this; this.version = null; - this.versionNumber = 'V2.93a.20090117'; + this.versionNumber = 'V2.95a.20090501'; this.movieURL = null; this.url = null; this.altURL = null; @@ -80,10 +86,12 @@ function SoundManager(smURL,smID) { this.sounds = {}; this.soundIDs = []; this.muted = false; + this.isFullScreen = false; // set later by flash 9+ 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.specialWmodeCase = false; this._debugOpen = true; this._didAppend = false; this._appendSuccess = false; @@ -93,6 +101,12 @@ function SoundManager(smURL,smID) { this._hasConsole = (typeof console != 'undefined' && typeof console.log != 'undefined'); this._debugLevels = ['log','info','warn','error']; this._defaultFlashVersion = 8; + this._oRemoved = null; + this._oRemovedHTML = null; + + var _$ = function(sID) { + return document.getElementById(sID); + }; this.filePatterns = { flash8: /\.mp3(\?.*)?$/i, @@ -104,6 +118,7 @@ function SoundManager(smURL,smID) { this.filePattern = null; this.features = { + buffering: false, peakData: false, waveformData: false, eqData: false, @@ -132,6 +147,7 @@ function SoundManager(smURL,smID) { // set up default options if (_s.flashVersion > 8) { _s.defaultOptions = _s._mergeObjects(_s.defaultOptions,_s.flash9Options); + _s.features.buffering = true; } if (_s.flashVersion > 8 && _s.useMovieStar) { // flash 9+ support for movieStar formats as well as MP3 @@ -144,7 +160,7 @@ function SoundManager(smURL,smID) { } _s.filePattern = _s.filePatterns[(_s.flashVersion!=8?'flash9':'flash8')]; _s.movieURL = (_s.flashVersion==8?'soundmanager2.swf':'soundmanager2_flash9.swf'); - _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_s.flashVersion==9); + _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_s.flashVersion>8); }; this._overHTTP = (document.location?document.location.protocol.match(/http/i):null); @@ -158,6 +174,11 @@ function SoundManager(smURL,smID) { var flashCPLink = 'http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html'; + this.strings = { + notReady: 'Not loaded yet - wait for soundManager.onload() before calling sound-related methods', + appXHTML: 'soundManager._createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.' + }; + // --- public methods --- this.supported = function() { @@ -165,7 +186,7 @@ function SoundManager(smURL,smID) { }; this.getMovie = function(smID) { - return _s.isIE?window[smID]:(_s.isSafari?document.getElementById(smID)||document[smID]:document.getElementById(smID)); + return _s.isIE?window[smID]:(_s.isSafari?_$(smID)||document[smID]:_$(smID)); }; this.loadFromXML = function(sXmlUrl) { @@ -179,7 +200,7 @@ function SoundManager(smURL,smID) { this.createSound = function(oOptions) { if (!_s._didInit) { - throw new Error('soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods'); + throw _s._complain('soundManager.createSound(): '+_s.strings.notReady,arguments.callee.caller); } if (arguments.length == 2) { // function overloading in JS! :) ..assume simple createSound(id,url) use case @@ -212,7 +233,7 @@ function SoundManager(smURL,smID) { if (_s.flashVersion == 8) { _s.o._createSound(_tO.id,_tO.onjustbeforefinishtime); } else { - _s.o._createSound(_tO.id,_tO.url,_tO.onjustbeforefinishtime,_tO.usePeakData,_tO.useWaveformData,_tO.useEQData,_tO.isMovieStar,(_tO.isMovieStar?_tO.useVideo:false)); + _s.o._createSound(_tO.id,_tO.url,_tO.onjustbeforefinishtime,_tO.usePeakData,_tO.useWaveformData,_tO.useEQData,_tO.isMovieStar,(_tO.isMovieStar?_tO.useVideo:false),(_tO.isMovieStar?_tO.bufferTime:false)); } if (_tO.autoLoad || _tO.autoPlay) { // TODO: does removing timeout here cause problems? @@ -283,6 +304,9 @@ function SoundManager(smURL,smID) { }; this.play = function(sID,oOptions) { + if (!_s._didInit) { + throw _s._complain('soundManager.play(): '+_s.strings.notReady,arguments.callee.caller); + } if (!_s._idCheck(sID)) { if (typeof oOptions != 'Object') { oOptions = {url:oOptions}; // overloading use case: play('mySound','/path/to/some.mp3'); @@ -432,22 +456,24 @@ function SoundManager(smURL,smID) { if (!_s.o || !_s.allowPolling) { return false; } - // _s._wD('soundManager.setPolling('+bPolling+')'); _s.o._setPolling(bPolling); }; - this.disable = function(bUnload) { + this.disable = function(bNoDisable) { // destroy all functions + if (typeof bNoDisable == 'undefined') { + bNoDisable = false; + } if (_s._disabled) { return false; - } + } _s._disabled = true; - _s._wD('soundManager.disable(): Disabling all functions - future calls will return false.',1); + _s._wD('soundManager.disable(): Shutting down',1); for (var i=_s.soundIDs.length; i--;) { _s._disableObject(_s.sounds[_s.soundIDs[i]]); } - _s.initComplete(); // fire "complete", despite fail - _s._disableObject(_s); + _s.initComplete(bNoDisable); // fire "complete", despite fail + // _s._disableObject(_s); // taken out to allow reboot() }; this.canPlayURL = function(sURL) { @@ -469,7 +495,7 @@ function SoundManager(smURL,smID) { this.onload = function() { // window.onload() equivalent for SM2, ready to create sounds etc. // this is a stub - you can override this in your own external script, eg. soundManager.onload = function() {} - soundManager._wD('Warning: soundManager.onload() is undefined.',2); + soundManager._wD('Warning: soundManager.onload() is undefined.',2); }; this.onerror = function() { @@ -480,9 +506,37 @@ function SoundManager(smURL,smID) { this._idCheck = this.getSoundById; + this._complain = function(sMsg,oCaller) { + // Try to create meaningful custom errors, w/stack trace to the "offending" line + var sPre = 'Error: '; + if (!oCaller) { + return new Error(sPre+sMsg); + } + var e = new Error(''); // make a mistake. + var stackMsg = null; + if (e.stack) { + // potentially dangerous: Try to return a meaningful stacktrace where provided (Mozilla) + try { + var splitChar = '@'; + var stackTmp = e.stack.split(splitChar); + stackMsg = stackTmp[4]; // try to return only the relevant bit, skipping internal SM2 shiz + } catch(ee) { + // oops. + stackMsg = e.stack; + } + } + if (typeof console != 'undefined' && typeof console.trace != 'undefined') { + console.trace(); + } + var errorDesc = sPre+sMsg+'. \nCaller: '+oCaller.toString()+(e.stack?' \nTop of stacktrace: '+stackMsg:(e.message?' \nMessage: '+e.message:'')); + // See JS error/debug/console output for real error source, stack trace / message detail where possible. + return new Error(errorDesc); + }; + var _doNothing = function() { return false; }; + _doNothing._protected = true; this._disableObject = function(o) { @@ -494,11 +548,14 @@ function SoundManager(smURL,smID) { oProp = null; }; - this._failSafely = function() { - // exception handler for "object doesn't support this property or method" or general failure - if (!_s._disabled) { + this._failSafely = function(bNoDisable) { + // general failure exception handler + if (typeof bNoDisable == 'undefined') { + bNoDisable = false; + } + if (!_s._disabled || bNoDisable) { _s._wD('soundManager: Failed to initialise.',2); - _s.disable(); + _s.disable(bNoDisable); } }; @@ -540,15 +597,25 @@ function SoundManager(smURL,smID) { smURL = _s.url; var specialCase = null; - if (_s.useHighPerformance && _s.useHighPerformance != 'always' && navigator.platform.match(/win32/i) && navigator.userAgent.match(/firefox/i)) { - specialCase = 'Note: disabling highPerformance, known issues with this browser/OS combo.'; + + if (_s.useHighPerformance && _s.useMovieStar && _s.defaultOptions.useVideo === true) { + specialCase = 'soundManager note: disabling highPerformance, not applicable with movieStar mode + useVideo'; _s.useHighPerformance = false; } - if (_s.useHighPerformance && _s.useMovieStar) { - specialCase = 'Note: disabling highPerformance, not applicable with movieStar mode on'; - _s.useHighPerformance = false; - } + _s.wmode = (!_s.wmode && _s.useHighPerformance && !_s.useMovieStar?'transparent':_s.wmode); + + if (_s.wmode !== null && _s.flashLoadTimeout !== 0 && !_s.useHighPerformance && !_s.isIE && navigator.platform.match(/win32/i)) { + _s.specialWmodeCase = true; + // extra-special case: movie doesn't load until scrolled into view when using wmode = anything but 'window' here + // does not apply when using high performance (position:fixed means on-screen), OR infinite flash load timeout + _s._wD('soundManager note: Removing wmode, preventing off-screen SWF loading issue'); + _s.wmode = null; + } + + if (_s.flashVersion == 8) { + _s.allowFullScreen = false; + } var oEmbed = { name: smID, @@ -560,42 +627,37 @@ function SoundManager(smURL,smID) { allowScriptAccess: 'always', bgcolor: _s.bgColor, pluginspage: 'http://www.macromedia.com/go/getflashplayer', - type: 'application/x-shockwave-flash' + type: 'application/x-shockwave-flash', + wmode: _s.wmode, + allowfullscreen: (_s.allowFullScreen?'true':'false') }; + if (!_s.wmode) { + delete oEmbed.wmode; // don't write empty attribute + } + var oObject = { id: smID, data: smURL, type: 'application/x-shockwave-flash', width: '100%', - height: '100%' - }; - - var oObjectParams = { - movie: smURL, - AllowScriptAccess: 'always', - quality: 'high', - bgcolor: _s.bgColor + height: '100%', + wmode: _s.wmode }; - if (_s.useHighPerformance && !_s.useMovieStar) { - oEmbed.wmode = 'transparent'; - oObjectParams.wmode = 'transparent'; - } - var oMovie = null; var tmp = null; if (_s.isIE) { // IE is "special". oMovie = document.createElement('div'); - var movieHTML = ''+(_s.useHighPerformance && !_s.useMovieStar?' ':'')+''; + var movieHTML = ''+(_s.wmode?' ':'')+''; } else { oMovie = document.createElement('embed'); for (tmp in oEmbed) { if (oEmbed.hasOwnProperty(tmp)) { oMovie.setAttribute(tmp,oEmbed[tmp]); - } + } } } @@ -627,18 +689,16 @@ function SoundManager(smURL,smID) { } for (tmp in oToggle) { - if (oToggle.hasOwnProperty(tmp)) { - oD.style[tmp] = oToggle[tmp]; - } + if (oToggle.hasOwnProperty(tmp)) { + oD.style[tmp] = oToggle[tmp]; + } } - var appXHTML = 'soundManager._createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.'; - var oTarget = _s._getDocument(); if (oTarget) { - _s.oMC = document.getElementById('sm2-container')?document.getElementById('sm2-container'):document.createElement('div'); + _s.oMC = _$('sm2-container')?_$('sm2-container'):document.createElement('div'); if (!_s.oMC.id) { _s.oMC.id = 'sm2-container'; @@ -652,16 +712,16 @@ function SoundManager(smURL,smID) { width: '8px', height: '8px', // must be at least 6px for flash to run fast. odd? yes. bottom: '0px', - left: '0px', - zIndex:-1 // sit behind everything else + left: '0px' + // zIndex:-1 // sit behind everything else - potentially dangerous/buggy? }; } else { s = { position: 'absolute', - width: '1px', + width: '1px', height: '1px', - bottom: '0px', - left: '0px' + top: '-999px', + left: '-999px' }; } var x = null; @@ -682,7 +742,7 @@ function SoundManager(smURL,smID) { } _s._appendSuccess = true; } catch(e) { - throw new Error(appXHTML); + throw new Error(_s.strings.appXHTML); } } else { // it's already in the document. @@ -695,18 +755,18 @@ function SoundManager(smURL,smID) { _s._appendSuccess = true; } - if (!document.getElementById(_s.debugID) && ((!_s._hasConsole||!_s.useConsole)||(_s.useConsole && _s._hasConsole && !_s.consoleOnly))) { + if (!_$(_s.debugID) && ((!_s._hasConsole||!_s.useConsole)||(_s.useConsole && _s._hasConsole && !_s.consoleOnly))) { var oDebug = document.createElement('div'); oDebug.id = _s.debugID; oDebug.style.display = (_s.debugMode?'block':'none'); - if (_s.debugMode) { + if (_s.debugMode && !_$(oD.id)) { try { oTarget.appendChild(oD); } catch(e2) { - throw new Error(appXHTML); + throw new Error(_s.strings.appXHTML); } + oTarget.appendChild(oDebug); } - oTarget.appendChild(oDebug); } oTarget = null; } @@ -715,8 +775,8 @@ function SoundManager(smURL,smID) { _s._wD(specialCase); } - _s._wD('-- SoundManager 2 '+_s.version+(_s.useMovieStar?', MovieStar mode':'')+(_s.useHighPerformance?', high performance mode':'')+' --',1); - _s._wD('soundManager._createMovie(): Trying to load '+smURL+(!_s._overHTTP && _s.altURL?'(alternate URL)':''),1); + _s._wD('-- SoundManager 2 '+_s.version+(_s.useMovieStar?', MovieStar mode':'')+(_s.useHighPerformance?', high performance mode':'')+(_s.wmode?', wmode: '+_s.wmode:'')+' --',1); + _s._wD('soundManager._createMovie(): Trying to load '+smURL+(!_s._overHTTP && _s.altURL?' (alternate URL)':''),1); }; // aliased to this._wD() @@ -730,21 +790,24 @@ function SoundManager(smURL,smID) { if (_s._hasConsole && _s.useConsole) { var sMethod = _s._debugLevels[sType]; if (typeof console[sMethod] != 'undefined') { - console[sMethod].apply(console,[sText]); // apply() fix for firebug 1.3, so "this" == console + console[sMethod](sText); } else { console.log(sText); } if (_s.useConsoleOnly) { - return true; - } + return true; + } } var sDID = 'soundmanager-debug'; try { - var o = document.getElementById(sDID); + var o = _$(sDID); if (!o) { return false; } var oItem = document.createElement('div'); + if (++_s._wdCount%2===0) { + oItem.className = 'sm2-alt'; + } // sText = sText.replace(/\n/g,'
'); if (typeof sType == 'undefined') { sType = 0; @@ -768,6 +831,8 @@ function SoundManager(smURL,smID) { o = null; }; this._writeDebug._protected = true; + this._wdCount = 0; + this._wdCount._protected = true; this._wD = this._writeDebug; this._wDAlert = function(sText) { alert(sText); }; @@ -777,8 +842,8 @@ function SoundManager(smURL,smID) { } this._toggleDebug = function() { - var o = document.getElementById(_s.debugID); - var oT = document.getElementById(_s.debugID+'-toggle'); + var o = _$(_s.debugID); + var oT = _$(_s.debugID+'-toggle'); if (!o) { return false; } @@ -844,17 +909,30 @@ function SoundManager(smURL,smID) { this._initMovie = function() { // attempt to get, or create, movie if (_s.o) { - return false; // pre-init may have fired this function before window.onload(), may already exist - } - _s.o = _s.getMovie(_s.id); // try to get flash movie (inline markup) + return false; // may already exist + } + _s.o = _s.getMovie(_s.id); // (inline markup) if (!_s.o) { - // try to create - _s._createMovie(_s.id,_s.url); + if (!_s.oRemoved) { + // try to create + _s._createMovie(_s.id,_s.url); + } else { + // try to re-append removed movie after reboot() + if (!_s.isIE) { + _s.oMC.appendChild(_s.oRemoved); + } else { + _s.oMC.innerHTML = _s.oRemovedHTML; + } + _s.oRemoved = null; + _s._didAppend = true; + } _s.o = _s.getMovie(_s.id); } if (_s.o) { _s._wD('soundManager._initMovie(): Got '+_s.o.nodeName+' element ('+(_s._didAppend?'created via JS':'static HTML')+')',1); - _s._wD('soundManager._initMovie(): Waiting for ExternalInterface call from Flash..'); + if (_s.flashLoadTimeout>0) { + _s._wD('soundManager._initMovie(): Waiting for ExternalInterface call from Flash..'); + } } }; @@ -864,25 +942,29 @@ function SoundManager(smURL,smID) { } _s._waitingForEI = true; if (_s._tryInitOnFocus && !_s._isFocused) { - _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..'); + _s._wD('soundManager: Special case: Waiting for focus-related event..'); return false; } - if (!_s._didInit) { - _s._wD('soundManager: Getting impatient, still waiting for Flash.. ;)'); - } - setTimeout(function() { + if (_s.flashLoadTimeout>0) { if (!_s._didInit) { - _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); - if (!_s._overHTTP) { + _s._wD('soundManager: Getting impatient, still waiting for Flash.. ;)'); + } + setTimeout(function() { + if (!_s._didInit) { + _s._wD('soundManager: No Flash response within reasonable time after document load.\nPossible causes: Loading '+_s.movieURL+' failed, Flash version under '+_s.flashVersion+', no support, flash blocked or JS-Flash security error.',2); + if (!_s._overHTTP) { _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); } _s._debugTS('flashtojs',false,': Timed out'+(_s._overHTTP)?' (Check flash security)':' (No plugin/missing SWF?)'); } // if still not initialized and no other options, give up if (!_s._didInit && _s._okToDisable) { - _s._failSafely(); - } - },750); + _s._failSafely(true); // don't disable, for reboot() + } + },_s.flashLoadTimeout); + } else if (!_s.didInit) { + _s._wD('soundManager: Waiting indefinitely for Flash...'); + } }; this.handleFocus = function() { @@ -907,13 +989,13 @@ function SoundManager(smURL,smID) { } }; - this.initComplete = function() { + this.initComplete = function(bNoDisable) { if (_s._didInit) { return false; } _s._didInit = true; _s._wD('-- SoundManager 2 '+(_s._disabled?'failed to load':'loaded')+' ('+(_s._disabled?'security/load error':'OK')+') --',1); - if (_s._disabled) { + if (_s._disabled || bNoDisable) { _s._wD('soundManager.initComplete(): calling soundManager.onerror()',1); _s._debugTS('onload',false); _s.onerror.apply(window); @@ -973,7 +1055,7 @@ function SoundManager(smURL,smID) { _s._debugTS('jstoflash',true); } catch(e) { _s._debugTS('jstoflash',false); - _s._failSafely(); + _s._failSafely(true); // don't disable, for reboot() _s.initComplete(); return false; } @@ -981,7 +1063,7 @@ function SoundManager(smURL,smID) { }; this.beginDelayedInit = function() { - _s._wD('soundManager.beginDelayedInit(): Document loaded'); + _s._wD('soundManager.beginDelayedInit()'); _s._windowLoaded = true; setTimeout(_s.waitForExternalInterface,500); setTimeout(_s.beginInit,20); @@ -1015,12 +1097,14 @@ function SoundManager(smURL,smID) { _s._debugTS('flashtojs',true); _s.swfLoaded = true; _s._tryInitOnFocus = false; + if (_s.isIE) { // IE needs a timeout OR delay until window.onload - may need TODO: investigating setTimeout(_s.init,100); } else { _s.init(); } + }; this._setSandboxType = function(sandboxType) { @@ -1041,6 +1125,46 @@ function SoundManager(smURL,smID) { } }; + this.reboot = function() { + // attempt to reset and init SM2 + _s._wD('soundManager.reboot()'); + if (_s.soundIDs.length) { + _s._wD('Destroying '+_s.soundIDs.length+' SMSound objects...'); + } + for (var i=_s.soundIDs.length; i--;) { + _s.sounds[_s.soundIDs[i]].destruct(); + } + // trash ze flash + try { + if (_s.isIE) { + _s.oRemovedHTML = _s.o.innerHTML; + } + _s.oRemoved = _s.o.parentNode.removeChild(_s.o); + _s._wD('Flash movie removed.'); + } catch(e) { + // uh-oh. + _s._wD('Warning: Failed to remove flash movie.',2); + } + _s.enabled = false; + _s._didInit = false; + _s._waitingForEI = false; + _s._initPending = false; + _s._didInit = false; + _s._didAppend = false; + _s._appendSuccess = false; + _s._didInit = false; + _s._disabled = false; + _s._waitingforEI = true; + _s.swfLoaded = false; + _s.soundIDs = {}; + _s.sounds = []; + _s.o = null; + _s._wD('soundManager: Rebooting...'); + window.setTimeout(function() { + soundManager.beginDelayedInit(); + },20); + }; + this.destruct = function() { _s._wD('soundManager.destruct()'); _s.disable(true); @@ -1060,6 +1184,8 @@ function SoundManager(smURL,smID) { this.pan = this.options.pan; this.volume = this.options.volume; + this._lastURL = null; + this._debug = function() { if (_s.debugMode) { var stuff = null; @@ -1107,13 +1233,17 @@ function SoundManager(smURL,smID) { _t.muted = false; _t.didBeforeFinish = false; _t.didJustBeforeFinish = false; + _t.isBuffering = false; _t.instanceOptions = {}; _t.instanceCount = 0; _t.peakData = { left: 0, right: 0 }; - _t.waveformData = []; + _t.waveformData = { + left: [], + right: [] + }; _t.eqData = []; }; @@ -1129,15 +1259,27 @@ function SoundManager(smURL,smID) { oOptions = _t.options; _t._iO = oOptions; _t.instanceOptions = _t._iO; + + // console.log('typeof oOptions: '+(typeof oOptions)+', lastURL: '+_t._lastURL+', _t.url: '+_t.url); + + if (_t._lastURL && _t._lastURL != _t.url) { + _s._wD('SMSound.load(): Using manually-assigned URL'); + _t._iO.url = _t.url; + _t.url = null; + } } + if (typeof _t._iO.url == 'undefined') { _t._iO.url = _t.url; } + _s._wD('soundManager.load(): '+_t._iO.url,1); if (_t._iO.url == _t.url && _t.readyState !== 0 && _t.readyState != 2) { _s._wD('soundManager.load(): current URL already assigned.',1); return false; } + _t.url = _t._iO.url; + _t._lastURL = _t._iO.url; _t.loaded = false; _t.readyState = 1; _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?) @@ -1219,7 +1361,7 @@ function SoundManager(smURL,smID) { _t.resume(); } else { _t.playState = 1; - if (!_t.instanceCount || _s.flashVersion == 9) { + if (!_t.instanceCount || _s.flashVersion > 8) { _t.instanceCount++; } _t.position = (typeof _t._iO.position != 'undefined' && !isNaN(_t._iO.position)?_t._iO.position:0); @@ -1256,7 +1398,7 @@ function SoundManager(smURL,smID) { var offset = Math.min(_t.duration,Math.max(nMsecOffset,0)); // position >= 0 and <= current available (loaded) duration _t._iO.position = offset; if (!bNoDebug) { - _s._wD('SMSound.setPosition('+nMsecOffset+')'+(nMsecOffset != offset?', corrected value: '+offset:'')); + // _s._wD('SMSound.setPosition('+nMsecOffset+')'+(nMsecOffset != offset?', corrected value: '+offset:'')); } _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) }; @@ -1287,7 +1429,7 @@ function SoundManager(smURL,smID) { this.togglePause = function() { _s._wD('SMSound.togglePause()'); - if (!_t.playState) { + if (_t.playState === 0) { _t.play({position:(_s.flashVersion==9?_t.position:_t.position/1000)}); return false; } @@ -1334,7 +1476,7 @@ function SoundManager(smURL,smID) { this.unmute = function() { _t.muted = false; var hasIO = typeof _t._iO.volume != 'undefined'; - _s.o._setVolume(_t.sID,hasIO?_t._iO.volume:_t.options.volume,hasIO?false:true); + _s.o._setVolume(_t.sID,hasIO?_t._iO.volume:_t.options.volume); }; // --- "private" methods called by Flash --- @@ -1344,7 +1486,7 @@ function SoundManager(smURL,smID) { _t.bytesLoaded = nBytesLoaded; _t.bytesTotal = nBytesTotal; _t.duration = Math.floor(nDuration); - _t.durationEstimate = parseInt((_t.bytesTotal/_t.bytesLoaded)*_t.duration,10); // estimate total time (will only be accurate with CBR MP3s.) + _t.durationEstimate = parseInt((_t.bytesTotal/_t.bytesLoaded)*_t.duration,10); if (_t.readyState != 3 && _t._iO.whileloading) { _t._iO.whileloading.apply(_t); } @@ -1374,10 +1516,17 @@ function SoundManager(smURL,smID) { } }; - this._whileplaying = function(nPosition,oPeakData,oWaveformData,oEQData) { + this._whileplaying = function(nPosition,oPeakData,oWaveformDataLeft,oWaveformDataRight,oEQData) { + if (isNaN(nPosition) || nPosition === null) { return false; // Flash may return NaN at times } + if (_t.playState === 0 && nPosition > 0) { + // can happen at the end of a video where nPosition == 33 for some reason, after finishing.??? + // can also happen with a normal stop operation. This resets the position to 0. + // _s._writeDebug('Note: Not playing, but position = '+nPosition); + nPosition = 0; + } _t.position = nPosition; if (_t._iO.usePeakData && typeof oPeakData != 'undefined' && oPeakData) { _t.peakData = { @@ -1385,21 +1534,22 @@ function SoundManager(smURL,smID) { right: oPeakData.rightPeak }; } - if (_t._iO.useWaveformData && typeof oWaveformData != 'undefined' && oWaveformData) { - _t.waveformData = oWaveformData; - /* - _t.spectrumData = { - left: oSpectrumData.left.split(','), - right: oSpectrumData.right.split(',') - } - */ + if (_t._iO.useWaveformData && typeof oWaveformDataLeft != 'undefined' && oWaveformDataLeft) { + _t.waveformData = { + left: oWaveformDataLeft.split(','), + right: oWaveformDataRight.split(',') + }; } if (_t._iO.useEQData && typeof oEQData != 'undefined' && oEQData) { _t.eqData = oEQData; } if (_t.playState == 1) { + // special case/hack: ensure buffering is false (instant load from cache, thus buffering stuck at 1?) + if (_t.isBuffering) { + _t._onbufferchange(0); + } if (_t._iO.whileplaying) { - _t._iO.whileplaying.apply(_t); // flash may call after actual finish + _t._iO.whileplaying.apply(_t); // flash may call after actual finish } if (_t.loaded && _t._iO.onbeforefinish && _t._iO.onbeforefinishtime && !_t.didBeforeFinish && _t.duration-_t.position <= _t._iO.onbeforefinishtime) { _s._wD('duration-position <= onbeforefinishtime: '+_t.duration+' - '+_t.position+' <= '+_t._iO.onbeforefinishtime+' ('+(_t.duration-_t.position)+')'); @@ -1410,7 +1560,7 @@ function SoundManager(smURL,smID) { this._onload = function(bSuccess) { bSuccess = (bSuccess==1?true:false); - _s._wD('SMSound._onload(): "'+_t.sID+'"'+(bSuccess?' loaded.':' failed to load? - '+_t.url)); + _s._wD('SMSound._onload(): "'+_t.sID+'"'+(bSuccess?' loaded.':' failed to load? - '+_t.url),(bSuccess?1:2)); if (!bSuccess) { if (_s.sandbox.noRemote === true) { _s._wD('SMSound._onload(): Reminder: Flash security is denying network/internet access',1); @@ -1452,7 +1602,6 @@ function SoundManager(smURL,smID) { // TODO: calling user-defined onfinish() should happen after setPosition(0) // OR: onfinish() and then setPosition(0) is bad. - if (_t._iO.onbeforefinishcomplete) { _t._iO.onbeforefinishcomplete.apply(_t); } @@ -1474,8 +1623,14 @@ function SoundManager(smURL,smID) { } } } else { + if (_t.useVideo) { + // video has finished + // may need to reset position for next play call, "rewind" + // _t.setPosition(0); + } // _t.setPosition(0); } + }; this._onmetadata = function(oMetaData) { @@ -1498,8 +1653,51 @@ function SoundManager(smURL,smID) { _s._wD('SMSound.onmetadata() complete'); }; + this._onbufferchange = function(bIsBuffering) { + if (_t.playState === 0) { + // ignore if not playing + return false; + } + if (bIsBuffering == _t.isBuffering) { + // ignore initial "false" default, if matching + _s._wD('_onbufferchange: ignoring false default / loaded sound'); + return false; + } + _t.isBuffering = (bIsBuffering==1?true:false); + if (_t._iO.onbufferchange) { + _s._wD('SMSound._onbufferchange(): '+bIsBuffering); + _t._iO.onbufferchange.apply(_t); + } + }; + + this._ondataerror = function(sError) { + // flash 9 wave/eq data handler + if (_t.playState > 0) { // hack: called at start, and end from flash at/after onfinish(). + _s._wD('SMSound._ondataerror(): '+sError); + if (_t._iO.ondataerror) { + _t._iO.ondataerror.apply(_t); + } + } else { + // _s._wD('SMSound._ondataerror(): ignoring'); + } + }; + }; // SMSound() + this._onfullscreenchange = function(bFullScreen) { + _s._wD('onfullscreenchange(): '+bFullScreen); + _s.isFullScreen = (bFullScreen==1?true:false); + if (!_s.isFullScreen) { + // attempt to restore window focus after leaving full-screen + try { + window.focus(); + _s._wD('window.focus()'); + } catch(e) { + // oh well + } + } + }; + // register a few event handlers if (window.addEventListener) { window.addEventListener('focus',_s.handleFocus,false); @@ -1525,5 +1723,7 @@ function SoundManager(smURL,smID) { } // SoundManager() -soundManager = new SoundManager(); - +// set var SM2_DEFER = true; in your own script to prevent auto start-up +if (typeof SM2_DEFER == 'undefined' || !SM2_DEFER) { + soundManager = new SoundManager(); +} \ No newline at end of file diff --git a/static/sound/soundmanager2.swf b/static/sound/soundmanager2.swf index 98ed98d..8a9711c 100644 Binary files a/static/sound/soundmanager2.swf and b/static/sound/soundmanager2.swf differ diff --git a/static/sound/soundmanager2_flash9.swf b/static/sound/soundmanager2_flash9.swf index 14e4578..86cefe5 100644 Binary files a/static/sound/soundmanager2_flash9.swf and b/static/sound/soundmanager2_flash9.swf differ