From 753f60c7d4769fa72d3b910e491f37db6f130898 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:19:21 -0500 Subject: dymaxion --- .../demo/flashblock/method1/flashblock.js | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 docs/dymaxion/soundmanagerv297a-20101010/demo/flashblock/method1/flashblock.js (limited to 'docs/dymaxion/soundmanagerv297a-20101010/demo/flashblock/method1/flashblock.js') diff --git a/docs/dymaxion/soundmanagerv297a-20101010/demo/flashblock/method1/flashblock.js b/docs/dymaxion/soundmanagerv297a-20101010/demo/flashblock/method1/flashblock.js new file mode 100755 index 0000000..f96cf46 --- /dev/null +++ b/docs/dymaxion/soundmanagerv297a-20101010/demo/flashblock/method1/flashblock.js @@ -0,0 +1,90 @@ +/* + + FlashBlock handler for SoundManager 2 + ------------------------------------------------------------------- + Attempt to handle and gracefully recover from flashblock conditions + Requires SoundManger v2.95a.20090717+ + + http://schillmania.com/projects/soundmanager2/ + +*/ +soundManager._flashBlock = new function() { + + var _s = this; + this.name = 'soundManager._flashblock'; + this.didTimeout = false; // did initial attempt fail? + this.timer = null; // for setTimeout call + + this.startTimer = function(nMsec) { + // soundManager._wD(_s.name+'_.starttimer()'); + _s.timer = window.setTimeout(_s.checkFlashStatus,nMsec); + }; + + this.stopTimer = function() { + // soundManager._wD(_s.name+'.stoptimer()'); + if (_s.timer) { + window.clearTimeout(_s.timer); + _s.timer = null; + } + }; + + this.checkFlashStatus = function() { + // soundManager._wD(_s.name+'.checkflashstatus()'); + var _sm = soundManager; + var oMC = _sm.oMC; // DIV (default: #sm2-container) for .SWF + var oStatus = document.getElementById('sm2-status'); // demo-only + + if (!_sm.supported()) { + // make the movie more visible, so user can fix + oMC.className = 'swf-timedout'; + _s.didTimeout = true; + var msg = 'No flash response, applying .swf-timedout CSS..'; + _sm._wD(_s.name+': '+msg); + if (oStatus) { + oStatus.innerHTML = ''+msg+''; + } + } else { + // SM2 loaded OK + // move the movie container to its proper place + oMC.className = 'swf-loaded'; + if (!_s.didTimeout) { + // SM2 didn't previously fail, no blocker active + var msg = 'SM2 loaded OK (before timeout), fast unblock or no blocker.'; + _sm._writeDebug(_s.name+'.checkFlashStatus: '+msg,1); + if (oStatus) { + oStatus.innerHTML = ''+msg+''; + } + } else { + var msg = 'SM2 recovered after block (or timeout), loaded OK.'; + _sm._wD(_s.name+': '+msg); + if (oStatus) { + oStatus.innerHTML = ''+msg+''; + } + } + // stop timer, if applicable + _s.stopTimer(); + return false; + } + }; + + soundManager.flashLoadTimeout = 0; // wait forever for flash to load - we'll set our own timeout via oninitmovie() + + soundManager.oninitmovie = function() { + // when SWF is written (or ready to start), wait and make SWF visible (time-out case) + soundManager._flashBlock.startTimer(750); + }; + + soundManager.onready(function(oStatus) { + // SM2 has now initialized, either no blocking OR blocked movie was allowed/whitelisted + var fb = soundManager._flashBlock; + if (oStatus.success) { + // Yay! recovered OK. + fb.checkFlashStatus(); + } else { + // Blocking was passed (or no blocking), but then something *else* went wrong. + } + // stop timer, if applicable + fb.stopTimer(); + }); + +}(); -- cgit v1.2.3-70-g09d2