From: olivier <> Date: Fri, 12 Dec 2008 18:45:01 +0000 (+0000) Subject: revert to soundmanager v2.90a.20081028, soundManager.url is broken in v2.91 X-Git-Tag: 1.1~774 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f062b9fc3b25215b94cc5e2a3c6217a8f8fa2534;p=telemeta.git revert to soundmanager v2.90a.20081028, soundManager.url is broken in v2.91 --- diff --git a/telemeta/htdocs/js/soundmanager2.js b/telemeta/htdocs/js/soundmanager2.js index 631814fd..216115ce 100644 --- a/telemeta/htdocs/js/soundmanager2.js +++ b/telemeta/htdocs/js/soundmanager2.js @@ -7,11 +7,9 @@ Code licensed under the BSD License: http://schillmania.com/projects/soundmanager2/license.txt - V2.91a.20081205 + V2.90a.20081028 */ -var soundManager = null; - function SoundManager(smURL,smID) { this.flashVersion = 8; // version of flash to require, either 8 or 9. Some API features require Flash 9. @@ -23,7 +21,7 @@ function SoundManager(smURL,smID) { 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.useHighPerformance = true; // flash positioning trick, improves JS/flash callback speed, minimizes delay - this.bgColor = '#ffffff'; // movie (.swf) background color, useful if showing on-screen for video etc. + this.bgColor = '#ffffff'; // movie (.swf) background color, useful if showing on-screen for video etc. 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 +48,25 @@ 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. }; 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 - }; - - // jslint global declarations - /*global alert, console, document, navigator, setTimeout, window */ + 'onmetadata': null, // callback for when video width/height etc. are received + 'useVideo': false // if loading movieStar content, whether to show video + } - var SMSound = null; // defined later + this.flashBlockHelper = { + 'enabled': false, // experimental, removed with >v2.80 + 'message': [] // "nag bar" to show when messaging the user, if SM2 fails on firefox etc. + }; - var _s = this; + var _s = this; this.version = null; - this.versionNumber = 'V2.91a.20081205'; + this.versionNumber = 'V2.90a.20081028'; this.movieURL = null; this.url = null; this.altURL = null; @@ -77,7 +75,7 @@ function SoundManager(smURL,smID) { this.o = null; this.id = (smID||'sm2movie'); this.oMC = null; - this.sounds = {}; + this.sounds = []; this.soundIDs = []; this.muted = false; this.isIE = (navigator.userAgent.match(/MSIE/i)); @@ -93,12 +91,10 @@ function SoundManager(smURL,smID) { 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 + flash8: /\.(mp3)/i, + flash9: /\.(mp3)/i }; - this.netStreamTypes = ['aac','flv','mov','mp4','m4v','f4v','m4a','mp4v','3gp','3g2']; // Flash v9.0r115+ "moviestar" formats this.netStreamPattern = new RegExp('.('+this.netStreamTypes.join('|')+')','i'); this.filePattern = null; @@ -140,7 +136,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); - }; + } this._overHTTP = (document.location?document.location.protocol.match(/http/i):null); this._waitingforEI = false; @@ -169,26 +165,24 @@ function SoundManager(smURL,smID) { } catch(e) { _s._failSafely(); return true; - } + }; }; this.createSound = function(oOptions) { - if (!_s._didInit) { - throw new Error('soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods'); - } - if (arguments.length == 2) { + if (!_s._didInit) throw new Error('soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods'); + if (arguments.length==2) { // function overloading in JS! :) ..assume simple createSound(id,url) use case - oOptions = {'id':arguments[0],'url':arguments[1]}; - } + var oOptions = {'id':arguments[0],'url':arguments[1]}; + }; var thisOptions = _s._mergeObjects(oOptions); // inherit SM2 defaults var _tO = thisOptions; // alias _s._wD('soundManager.createSound(): '+_tO.id+' ('+_tO.url+')',1); if (_s._idCheck(_tO.id,true)) { _s._wD('soundManager.createSound(): '+_tO.id+' exists',1); return _s.sounds[_tO.id]; - } + }; if (_s.flashVersion > 8 && _s.useMovieStar) { - if (_tO.isMovieStar === null) { + if (_tO.isMovieStar == null) { _tO.isMovieStar = (_tO.url.match(_s.netStreamPattern)?true:false); } if (_tO.isMovieStar) { @@ -200,7 +194,7 @@ function SoundManager(smURL,smID) { _tO.useWaveformData = false; _tO.useEQData = false; } - } + }; _s.sounds[_tO.id] = new SMSound(_tO); _s.soundIDs[_s.soundIDs.length] = _tO.id; // AS2: @@ -208,7 +202,7 @@ function SoundManager(smURL,smID) { _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)); - } + }; if (_tO.autoLoad || _tO.autoPlay) { window.setTimeout(function() { if (_s.sounds[_tO.id]) { @@ -228,8 +222,8 @@ function SoundManager(smURL,smID) { this.createVideo = function(oOptions) { if (arguments.length==2) { - oOptions = {'id':arguments[0],'url':arguments[1]}; - } + var oOptions = {'id':arguments[0],'url':arguments[1]}; + }; if (_s.flashVersion >= 9) { oOptions.isMovieStar = true; oOptions.useVideo = true; @@ -241,19 +235,17 @@ function SoundManager(smURL,smID) { _s._wD('soundManager.createVideo(): MovieStar mode not enabled. Exiting.',2); } return _s.createSound(oOptions); - }; + } this.destroySound = function(sID,bFromSound) { // explicitly destroy a sound before normal page unload, etc. - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; for (var i=0; i<_s.soundIDs.length; i++) { if (_s.soundIDs[i] == sID) { _s.soundIDs.splice(i,1); continue; - } - } + }; + }; // conservative option: avoid crash with ze flash 8 // calling destroySound() within a sound onload() might crash firefox, certain flavours of winXP + flash 8?? // if (_s.flashVersion != 8) { @@ -262,31 +254,25 @@ function SoundManager(smURL,smID) { if (!bFromSound) { // ignore if being called from SMSound instance _s.sounds[sID].destruct(); - } + }; delete _s.sounds[sID]; }; this.destroyVideo = this.destroySound; this.load = function(sID,oOptions) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s.sounds[sID].load(oOptions); }; this.unload = function(sID) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s.sounds[sID].unload(); }; this.play = function(sID,oOptions) { if (!_s._idCheck(sID)) { - if (typeof oOptions != 'Object') { - oOptions = {url:oOptions}; // overloading use case: play('mySound','/path/to/some.mp3'); - } + if (typeof oOptions != 'Object') oOptions = {url:oOptions}; // overloading use case: play('mySound','/path/to/some.mp3'); if (oOptions && oOptions.url) { // overloading use case, creation + playing of sound: .play('someID',{url:'/path/to.mp3'}); _s._wD('soundController.play(): attempting to create "'+sID+'"',1); @@ -294,24 +280,21 @@ function SoundManager(smURL,smID) { _s.createSound(oOptions); } else { return false; - } - } + }; + }; _s.sounds[sID].play(oOptions); }; this.start = this.play; // just for convenience this.setPosition = function(sID,nMsecOffset) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; + nMsecOffset = Math.min((nMsecOffset||0),_s.duration); // don't allow seek past loaded duration _s.sounds[sID].setPosition(nMsecOffset); }; this.stop = function(sID) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s._wD('soundManager.stop('+sID+')',1); _s.sounds[sID].stop(); }; @@ -319,16 +302,12 @@ function SoundManager(smURL,smID) { this.stopAll = function() { _s._wD('soundManager.stopAll()',1); for (var oSound in _s.sounds) { - if (_s.sounds[oSound] instanceof SMSound) { - _s.sounds[oSound].stop(); // apply only to sound objects - } - } + if (_s.sounds[oSound] instanceof SMSound) _s.sounds[oSound].stop(); // apply only to sound objects + }; }; this.pause = function(sID) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s.sounds[sID].pause(); }; @@ -339,9 +318,7 @@ function SoundManager(smURL,smID) { }; this.resume = function(sID) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s.sounds[sID].resume(); }; @@ -352,40 +329,31 @@ function SoundManager(smURL,smID) { }; this.togglePause = function(sID) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s.sounds[sID].togglePause(); }; this.setPan = function(sID,nPan) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s.sounds[sID].setPan(nPan); }; this.setVolume = function(sID,nVol) { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s.sounds[sID].setVolume(nVol); }; this.mute = function(sID) { - if (typeof sID != 'string') { - sID = null; - } + if (typeof sID != 'string') sID = null; if (!sID) { + var o = null; _s._wD('soundManager.mute(): Muting all sounds'); for (var i=_s.soundIDs.length; i--;) { _s.sounds[_s.soundIDs[i]].mute(); } _s.muted = true; } else { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s._wD('soundManager.mute(): Muting "'+sID+'"'); _s.sounds[sID].mute(); } @@ -396,19 +364,16 @@ function SoundManager(smURL,smID) { }; this.unmute = function(sID) { - if (typeof sID != 'string') { - sID = null; - } + if (typeof sID != 'string') sID = null; if (!sID) { + var o = null; _s._wD('soundManager.unmute(): Unmuting all sounds'); for (var i=_s.soundIDs.length; i--;) { _s.sounds[_s.soundIDs[i]].unmute(); } _s.muted = false; } else { - if (!_s._idCheck(sID)) { - return false; - } + if (!_s._idCheck(sID)) return false; _s._wD('soundManager.unmute(): Unmuting "'+sID+'"'); _s.sounds[sID].unmute(); } @@ -419,40 +384,39 @@ function SoundManager(smURL,smID) { }; this.setPolling = function(bPolling) { - if (!_s.o || !_s.allowPolling) { - return false; - } + if (!_s.o || !_s.allowPolling) return false; // _s._wD('soundManager.setPolling('+bPolling+')'); _s.o._setPolling(bPolling); }; this.disable = function(bUnload) { // destroy all functions - if (_s._disabled) { - return false; - } + if (_s._disabled) return false; _s._disabled = true; _s._wD('soundManager.disable(): Disabling all functions - future calls will return false.',1); for (var i=_s.soundIDs.length; i--;) { _s._disableObject(_s.sounds[_s.soundIDs[i]]); - } + }; _s.initComplete(); // fire "complete", despite fail _s._disableObject(_s); }; + this.handleFlashBlock = function(bForce) { + // experimental, removed with >v2.80. + return false; + }; + this.canPlayURL = function(sURL) { return (sURL?(sURL.match(_s.filePattern)?true:false):null); }; this.getSoundById = function(sID,suppressDebug) { - if (!sID) { - throw new Error('SoundManager.getSoundById(): sID is null/undefined'); - } + if (!sID) throw new Error('SoundManager.getSoundById(): sID is null/undefined'); var result = _s.sounds[sID]; if (!result && !suppressDebug) { _s._wD('"'+sID+'" is an invalid sound ID.',2); // soundManager._wD('trace: '+arguments.callee.caller); - } + }; return result; }; @@ -470,31 +434,27 @@ function SoundManager(smURL,smID) { this._idCheck = this.getSoundById; - var _doNothing = function() { - return false; - }; - _doNothing._protected = true; - this._disableObject = function(o) { for (var oProp in o) { - if (typeof o[oProp] == 'function' && typeof o[oProp]._protected == 'undefined') { - o[oProp] = _doNothing; - } - } + if (typeof o[oProp] == 'function' && typeof o[oProp]._protected == 'undefined') o[oProp] = function(){return false;}; + }; oProp = null; }; this._failSafely = function() { // exception handler for "object doesn't support this property or method" or general failure + 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.'; + var flashCPL = 'view/edit'; + var FPGSS = 'FPGSS'; if (!_s._disabled) { _s._wD('soundManager: Failed to initialise.',2); _s.disable(); - } + }; }; this._normalizeMovieURL = function(smURL) { if (smURL) { - if (smURL.match(/.swf/)) { + if (smURL.match(/\.swf/)) { smURL = smURL.substr(0,smURL.lastIndexOf('.swf')); } if (smURL.lastIndexOf('/') != smURL.length-1) { @@ -511,12 +471,8 @@ function SoundManager(smURL,smID) { this._getDocument._protected = true; this._createMovie = function(smID,smURL) { - if (_s._didAppend && _s._appendSuccess) { - return false; // ignore if already succeeded - } - if (window.location.href.indexOf('debug=1')+1) { - _s.debugMode = true; // allow force of debug mode via URL - } + if (_s._didAppend && _s._appendSuccess) return false; // ignore if already succeeded + if (window.location.href.indexOf('debug=1')+1) _s.debugMode = true; // allow force of debug mode via URL _s._didAppend = true; // safety check for legacy (change to Flash 9 URL) @@ -526,111 +482,18 @@ function SoundManager(smURL,smID) { _s.url = _s._normalizeMovieURL(_s._overHTTP?remoteURL:localURL); smURL = _s.url; - var specialCase = null; - if (_s.useHighPerformance && navigator.userAgent.match(/firefox\/2/i)) { - // no highPerformance for firefox 2. Causes failure on some pages, exact cause unknown at this point. - specialCase = 'Warning: disabling highPerformance, incompatible with Firefox 2.x'; - _s.useHighPerformance = false; - } - - if (_s.useHighPerformance && _s.useMovieStar) { - specialCase = 'Warning: disabling highPerformance, not applicable with movieStar mode on'; - _s.useHighPerformance = false; - } - - var oEmbed = { - name: smID, - id: smID, - src: smURL, - width: '100%', - height: '100%', - quality: 'high', - allowScriptAccess: 'always', - bgcolor: _s.bgColor, - pluginspage: 'http://www.macromedia.com/go/getflashplayer', - type: 'application/x-shockwave-flash' - }; - - 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 - }; - - 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 = ''; - - } else { - - oMovie = document.createElement('embed'); - for (tmp in oEmbed) { - if (oEmbed.hasOwnProperty(tmp)) { - oMovie.setAttribute(tmp,oEmbed[tmp]); - } - } - } - - var oD = document.createElement('div'); - oD.id = _s.debugID+'-toggle'; - var oToggle = { - 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 - }; - - oD.appendChild(document.createTextNode('-')); - oD.onclick = _s._toggleDebug; - oD.title = 'Toggle SM2 debug console'; - - if (navigator.userAgent.match(/msie 6/i)) { - oD.style.position = 'absolute'; - oD.style.cursor = 'hand'; - } - - for (tmp in oToggle) { - if (oToggle.hasOwnProperty(tmp)) { - oD.style[tmp] = oToggle[tmp]; - } - } + var htmlEmbed = ''; + var htmlObject = ''; + var html = (!_s.isIE?htmlEmbed:htmlObject); + var toggleElement = '