Index: trunk/extensions/SoundManager2Button/swf/soundmanager2_flash9_debug.swf |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SoundManager2Button/swf/soundmanager2_flash9_debug.swf |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 1 | + application/octet-stream |
Index: trunk/extensions/SoundManager2Button/swf/soundmanager2.swf |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SoundManager2Button/swf/soundmanager2.swf |
___________________________________________________________________ |
Added: svn:mime-type |
2 | 2 | + application/octet-stream |
Index: trunk/extensions/SoundManager2Button/swf/soundmanager2_debug.swf |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SoundManager2Button/swf/soundmanager2_debug.swf |
___________________________________________________________________ |
Added: svn:mime-type |
3 | 3 | + application/octet-stream |
Index: trunk/extensions/SoundManager2Button/swf/soundmanager2_flash9.swf |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/SoundManager2Button/swf/soundmanager2_flash9.swf |
___________________________________________________________________ |
Added: svn:mime-type |
4 | 4 | + application/octet-stream |
Index: trunk/extensions/SoundManager2Button/license.txt |
— | — | @@ -0,0 +1,29 @@ |
| 2 | +Software License Agreement (BSD License) |
| 3 | + |
| 4 | +Copyright (c) 2007, Scott Schiller (schillmania.com) |
| 5 | +All rights reserved. |
| 6 | + |
| 7 | +Redistribution and use in source and binary forms, with or without modification, |
| 8 | +are permitted provided that the following conditions are met: |
| 9 | + |
| 10 | +* Redistributions of source code must retain the above copyright notice, this |
| 11 | + list of conditions and the following disclaimer. |
| 12 | + |
| 13 | +* Redistributions in binary form must reproduce the above copyright notice, this |
| 14 | + list of conditions and the following disclaimer in the documentation and/or |
| 15 | + other materials provided with the distribution. |
| 16 | + |
| 17 | +* Neither the name of schillmania.com nor the names of its contributors may be |
| 18 | + used to endorse or promote products derived from this software without |
| 19 | + specific prior written permission from schillmania.com. |
| 20 | + |
| 21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 22 | +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 23 | +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 24 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 25 | +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 26 | +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 27 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 28 | +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 30 | +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
\ No newline at end of file |
Property changes on: trunk/extensions/SoundManager2Button/license.txt |
___________________________________________________________________ |
Added: svn:keywords |
1 | 31 | + Author Date Id Rev URL |
Added: svn:eol-style |
2 | 32 | + native |
Index: trunk/extensions/SoundManager2Button/image/arrow-right-black.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/extensions/SoundManager2Button/image/arrow-right-black.png |
___________________________________________________________________ |
Added: svn:mime-type |
3 | 33 | + image/png |
Index: trunk/extensions/SoundManager2Button/image/arrow-right-black.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = image/gif |
Property changes on: trunk/extensions/SoundManager2Button/image/arrow-right-black.gif |
___________________________________________________________________ |
Added: svn:mime-type |
4 | 34 | + image/gif |
Index: trunk/extensions/SoundManager2Button/image/arrow-right-white.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/extensions/SoundManager2Button/image/arrow-right-white.png |
___________________________________________________________________ |
Added: svn:mime-type |
5 | 35 | + image/png |
Index: trunk/extensions/SoundManager2Button/image/arrow-right-white.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = image/gif |
Property changes on: trunk/extensions/SoundManager2Button/image/arrow-right-white.gif |
___________________________________________________________________ |
Added: svn:mime-type |
6 | 36 | + image/gif |
Index: trunk/extensions/SoundManager2Button/script/soundmanager2-nodebug-jsmin.js |
— | — | @@ -0,0 +1,76 @@ |
| 2 | +/** @license |
| 3 | + * |
| 4 | + * SoundManager 2: JavaScript Sound for the Web |
| 5 | + * ---------------------------------------------- |
| 6 | + * http://schillmania.com/projects/soundmanager2/ |
| 7 | + * |
| 8 | + * Copyright (c) 2007, Scott Schiller. All rights reserved. |
| 9 | + * Code provided under the BSD License: |
| 10 | + * http://schillmania.com/projects/soundmanager2/license.txt |
| 11 | + * |
| 12 | + * V2.97a.20111030 |
| 13 | + */ |
| 14 | +(function($){function N(N,Z){function j(c){return function(a){return!this._t||!this._t._a?null:c.call(this,a)}}this.flashVersion=8;this.debugFlash=this.debugMode=false;this.useConsole=true;this.waitForWindowLoad=this.consoleOnly=false;this.bgColor="#ffffff";this.useHighPerformance=false;this.flashPollingInterval=null;this.flashLoadTimeout=1E3;this.wmode=null;this.allowScriptAccess="always";this.useFlashBlock=false;this.useHTML5Audio=true;this.html5Test=/^(probably|maybe)$/i;this.preferFlash=true; |
| 15 | +this.noSWFCache=false;this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:true},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:false},ogg:{type:["audio/ogg; codecs=vorbis"],required:false},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:false}};this.defaultOptions={autoLoad:false,stream:true,autoPlay:false, |
| 16 | +loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfailure:null,onfinish:null,multiShot:true,multiShotEvents:false,position:null,pan:0,type:null,usePolicyFile:false,volume:100};this.flash9Options={isMovieStar:null,usePeakData:false,useWaveformData:false,useEQData:false,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.movieID="sm2-container";this.id=Z||"sm2movie"; |
| 17 | +this.swfCSS={swfBox:"sm2-object-box",swfDefault:"movieContainer",swfError:"swf_error",swfTimedout:"swf_timedout",swfLoaded:"swf_loaded",swfUnblocked:"swf_unblocked",sm2Debug:"sm2_debug",highPerf:"high_performance",flashDebug:"flash_debug"};this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20111030";this.movieURL=this.version=null;this.url=N||null;this.altURL=null;this.enabled=this.swfLoaded=false;this.oMC=this.o=null;this.sounds={};this.soundIDs=[]; |
| 18 | +this.didFlashBlock=this.specialWmodeCase=this.muted=false;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:false,peakData:false,waveformData:false,eqData:false,movieStar:false};this.sandbox={};var F;try{F=typeof Audio!=="undefined"&&typeof(new Audio).canPlayType!=="undefined"}catch(Oa){F=false}this.hasHTML5=F;this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=false;var ra,c=this,O,o=navigator.userAgent,i=$,aa= |
| 19 | +i.location.href.toString(),h=document,ba,P,g,s=[],G=false,H=false,m=false,t=false,sa=false,I,n,ca,z,A,Q,ta,da,x,R,B,ea,fa,S,C,ua,ga,va,T,wa,J=null,ha=null,y,ia,D,U,V,ja,l,W=false,ka=false,xa,ya,q=null,za,X,K,u,la,ma,Aa,k,Ia=Array.prototype.slice,L=false,p,Y,Ba,r,Ca,na=o.match(/(ipad|iphone|ipod)/i),Ja=o.match(/firefox/i),Ka=o.match(/droid/i),v=o.match(/msie/i),La=o.match(/webkit/i),M=o.match(/safari/i)&&!o.match(/chrome/i),Ma=o.match(/opera/i);F=o.match(/(mobile|pre\/|xoom)/i)||na;var oa=!aa.match(/usehtml5audio/i)&& |
| 20 | +!aa.match(/sm2\-ignorebadua/i)&&M&&o.match(/OS X 10_6_([3-7])/i),pa=typeof h.hasFocus!=="undefined"?h.hasFocus():null,E=M&&typeof h.hasFocus==="undefined",Da=!E,Ea=/(mp3|mp4|mpa)/i,qa=h.location?h.location.protocol.match(/http/i):null,Fa=!qa?"http://":"",Ga=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i,Ha="mpeg4,aac,flv,mov,mp4,m4v,f4v,m4a,mp4v,3gp,3g2".split(","),Na=RegExp("\\.("+Ha.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; |
| 21 | +this.useAltURL=!qa;this._global_a=null;if(F&&(c.useHTML5Audio=true,c.preferFlash=false,na))L=c.ignoreFlash=true;this.supported=this.ok=function(){return q?m&&!t:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return O(c)||h[c]||i[c]};this.createSound=function(b){function a(){e=U(e);c.sounds[d.id]=new ra(d);c.soundIDs.push(d.id);return c.sounds[d.id]}var e=null,f=null,d=null;if(!m||!c.ok())return ja("soundManager.createSound(): "+y(!m?"notReady":"notOK")),false;arguments.length===2&&(b={id:arguments[0], |
| 22 | +url:arguments[1]});d=e=n(b);if(l(d.id,true))return c.sounds[d.id];if(X(d))f=a(),f._setup_html5(d);else{if(g>8){if(d.isMovieStar===null)d.isMovieStar=d.serverURL||(d.type?d.type.match(Ga):false)||d.url.match(Na);if(d.isMovieStar&&d.usePeakData)d.usePeakData=false}d=V(d,"soundManager.createSound(): ");f=a();if(g===8)c.o._createSound(d.id,d.loops||1,d.usePolicyFile);else if(c.o._createSound(d.id,d.url,d.usePeakData,d.useWaveformData,d.useEQData,d.isMovieStar,d.isMovieStar?d.bufferTime:false,d.loops|| |
| 23 | +1,d.serverURL,d.duration||null,d.autoPlay,true,d.autoLoad,d.usePolicyFile),!d.serverURL)f.connected=true,d.onconnect&&d.onconnect.apply(f);!d.serverURL&&(d.autoLoad||d.autoPlay)&&f.load(d)}!d.serverURL&&d.autoPlay&&f.play();return f};this.destroySound=function(b,a){if(!l(b))return false;var e=c.sounds[b],f;e._iO={};e.stop();e.unload();for(f=0;f<c.soundIDs.length;f++)if(c.soundIDs[f]===b){c.soundIDs.splice(f,1);break}a||e.destruct(true);delete c.sounds[b];return true};this.load=function(b,a){return!l(b)? |
| 24 | +false:c.sounds[b].load(a)};this.unload=function(b){return!l(b)?false:c.sounds[b].unload()};this.onposition=function(b,a,e,f){return!l(b)?false:c.sounds[b].onposition(a,e,f)};this.start=this.play=function(b,a){if(!m||!c.ok())return ja("soundManager.play(): "+y(!m?"notReady":"notOK")),false;return!l(b)?(a instanceof Object||(a={url:a}),a&&a.url?(a.id=b,c.createSound(a).play()):false):c.sounds[b].play(a)};this.setPosition=function(b,a){return!l(b)?false:c.sounds[b].setPosition(a)};this.stop=function(b){return!l(b)? |
| 25 | +false:c.sounds[b].stop()};this.stopAll=function(){for(var b in c.sounds)c.sounds.hasOwnProperty(b)&&c.sounds[b].stop()};this.pause=function(b){return!l(b)?false:c.sounds[b].pause()};this.pauseAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].pause()};this.resume=function(b){return!l(b)?false:c.sounds[b].resume()};this.resumeAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].resume()};this.togglePause=function(b){return!l(b)?false:c.sounds[b].togglePause()}; |
| 26 | +this.setPan=function(b,a){return!l(b)?false:c.sounds[b].setPan(a)};this.setVolume=function(b,a){return!l(b)?false:c.sounds[b].setVolume(a)};this.mute=function(b){var a=0;typeof b!=="string"&&(b=null);if(b)return!l(b)?false:c.sounds[b].mute();else{for(a=c.soundIDs.length;a--;)c.sounds[c.soundIDs[a]].mute();c.muted=true}return true};this.muteAll=function(){c.mute()};this.unmute=function(b){typeof b!=="string"&&(b=null);if(b)return!l(b)?false:c.sounds[b].unmute();else{for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].unmute(); |
| 27 | +c.muted=false}return true};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(b){return!l(b)?false:c.sounds[b].toggleMute()};this.getMemoryUse=function(){var b=0;c.o&&g!==8&&(b=parseInt(c.o._getMemoryUse(),10));return b};this.disable=function(b){var a;typeof b==="undefined"&&(b=false);if(t)return false;t=true;for(a=c.soundIDs.length;a--;)va(c.sounds[c.soundIDs[a]]);I(b);k.remove(i,"load",A);return true};this.canPlayMIME=function(b){var a;c.hasHTML5&&(a=K({type:b}));return!q||a?a:b?!!(g> |
| 28 | +8&&b.match(Ga)||b.match(c.mimePattern)):null};this.canPlayURL=function(b){var a;c.hasHTML5&&(a=K({url:b}));return!q||a?a:b?!!b.match(c.filePattern):null};this.canPlayLink=function(b){return typeof b.type!=="undefined"&&b.type&&c.canPlayMIME(b.type)?true:c.canPlayURL(b.href)};this.getSoundById=function(b){if(!b)throw Error("soundManager.getSoundById(): sID is null/undefined");return c.sounds[b]};this.onready=function(c,a){if(c&&c instanceof Function)return a||(a=i),ca("onready",c,a),z(),true;else throw y("needFunction", |
| 29 | +"onready");};this.ontimeout=function(c,a){if(c&&c instanceof Function)return a||(a=i),ca("ontimeout",c,a),z({type:"ontimeout"}),true;else throw y("needFunction","ontimeout");};this._wD=this._writeDebug=function(){return true};this._debug=function(){};this.reboot=function(){var b,a;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].destruct();try{if(v)ha=c.o.innerHTML;J=c.o.parentNode.removeChild(c.o)}catch(e){}ha=J=q=null;c.enabled=ea=m=W=ka=G=H=t=c.swfLoaded=false;c.soundIDs=c.sounds=[];c.o=null; |
| 30 | +for(b in s)if(s.hasOwnProperty(b))for(a=s[b].length;a--;)s[b][a].fired=false;i.setTimeout(c.beginDelayedInit,20)};this.getMoviePercent=function(){return c.o&&typeof c.o.PercentLoaded!=="undefined"?c.o.PercentLoaded():null};this.beginDelayedInit=function(){sa=true;B();setTimeout(function(){if(ka)return false;S();R();return ka=true},20);Q()};this.destruct=function(){c.disable(true)};ra=function(b){var a=this,e,f,d;this.sID=b.id;this.url=b.url;this._iO=this.instanceOptions=this.options=n(b);this.pan= |
| 31 | +this.options.pan;this.volume=this.options.volume;this._lastURL=null;this.isHTML5=false;this._a=null;this.id3={};this._debug=function(){};this.load=function(b){var d=null;if(typeof b!=="undefined")a._iO=n(b,a.options),a.instanceOptions=a._iO;else if(b=a.options,a._iO=b,a.instanceOptions=a._iO,a._lastURL&&a._lastURL!==a.url)a._iO.url=a.url,a.url=null;if(!a._iO.url)a._iO.url=a.url;if(a._iO.url===a.url&&a.readyState!==0&&a.readyState!==2)return a;a._lastURL=a.url;a.loaded=false;a.readyState=1;a.playState= |
| 32 | +0;if(X(a._iO)){if(d=a._setup_html5(a._iO),!d._called_load)a._html5_canplay=false,d.load(),d._called_load=true,a._iO.autoPlay&&a.play()}else try{a.isHTML5=false,a._iO=V(U(a._iO)),g===8?c.o._load(a.sID,a._iO.url,a._iO.stream,a._iO.autoPlay,a._iO.whileloading?1:0,a._iO.loops||1,a._iO.usePolicyFile):c.o._load(a.sID,a._iO.url,!!a._iO.stream,!!a._iO.autoPlay,a._iO.loops||1,!!a._iO.autoLoad,a._iO.usePolicyFile)}catch(e){C({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:true})}return a};this.unload=function(){a.readyState!== |
| 33 | +0&&(a.isHTML5?(f(),a._a&&(a._a.pause(),la(a._a))):g===8?c.o._unload(a.sID,"about:blank"):c.o._unload(a.sID),e());return a};this.destruct=function(b){if(a.isHTML5){if(f(),a._a)a._a.pause(),la(a._a),L||a._remove_html5_events(),a._a._t=null,a._a=null}else a._iO.onfailure=null,c.o._destroySound(a.sID);b||c.destroySound(a.sID,true)};this.start=this.play=function(b,w){var e,w=w===void 0?true:w;b||(b={});a._iO=n(b,a._iO);a._iO=n(a._iO,a.options);a.instanceOptions=a._iO;if(a._iO.serverURL&&!a.connected)return a.getAutoPlay()|| |
| 34 | +a.setAutoPlay(true),a;X(a._iO)&&(a._setup_html5(a._iO),d());if(a.playState===1&&!a.paused&&(e=a._iO.multiShot,!e))return a;if(!a.loaded)if(a.readyState===0){if(!a.isHTML5)a._iO.autoPlay=true;a.load(a._iO)}else if(a.readyState===2)return a;if(!a.isHTML5&&g===9&&a.position>0&&a.position===a.duration)a._iO.position=0;if(a.paused&&a.position&&a.position>0)a.resume();else{a.playState=1;a.paused=false;(!a.instanceCount||a._iO.multiShotEvents||!a.isHTML5&&g>8&&!a.getAutoPlay())&&a.instanceCount++;a.position= |
| 35 | +typeof a._iO.position!=="undefined"&&!isNaN(a._iO.position)?a._iO.position:0;if(!a.isHTML5)a._iO=V(U(a._iO));if(a._iO.onplay&&w)a._iO.onplay.apply(a),a._onplay_called=true;a.setVolume(a._iO.volume,true);a.setPan(a._iO.pan,true);a.isHTML5?(d(),e=a._setup_html5(),a.setPosition(a._iO.position),e.play()):c.o._start(a.sID,a._iO.loops||1,g===9?a._iO.position:a._iO.position/1E3)}return a};this.stop=function(b){if(a.playState===1){a._onbufferchange(0);a.resetOnPosition(0);a.paused=false;if(!a.isHTML5)a.playState= |
| 36 | +0;a._iO.onstop&&a._iO.onstop.apply(a);if(a.isHTML5){if(a._a)a.setPosition(0),a._a.pause(),a.playState=0,a._onTimer(),f()}else c.o._stop(a.sID,b),a._iO.serverURL&&a.unload();a.instanceCount=0;a._iO={}}return a};this.setAutoPlay=function(b){a._iO.autoPlay=b;a.isHTML5||(c.o._setAutoPlay(a.sID,b),b&&!a.instanceCount&&a.readyState===1&&a.instanceCount++)};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition=function(b){b===void 0&&(b=0);var d=a.isHTML5?Math.max(b,0):Math.min(a.duration|| |
| 37 | +a._iO.duration,Math.max(b,0));a.position=d;b=a.position/1E3;a.resetOnPosition(a.position);a._iO.position=d;if(a.isHTML5){if(a._a&&a._html5_canplay&&a._a.currentTime!==b)try{a._a.currentTime=b,(a.playState===0||a.paused)&&a._a.pause()}catch(e){}}else b=g===9?a.position:b,a.readyState&&a.readyState!==2&&c.o._setPosition(a.sID,b,a.paused||!a.playState);a.isHTML5&&a.paused&&a._onTimer(true);return a};this.pause=function(b){if(a.paused||a.playState===0&&a.readyState!==1)return a;a.paused=true;a.isHTML5? |
| 38 | +(a._setup_html5().pause(),f()):(b||b===void 0)&&c.o._pause(a.sID);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){if(!a.paused)return a;a.paused=false;a.playState=1;a.isHTML5?(a._setup_html5().play(),d()):(a._iO.isMovieStar&&a.setPosition(a.position),c.o._pause(a.sID));!a._onplay_called&&a._iO.onplay?(a._iO.onplay.apply(a),a._onplay_called=true):a._iO.onresume&&a._iO.onresume.apply(a);return a};this.togglePause=function(){if(a.playState===0)return a.play({position:g===9&&!a.isHTML5? |
| 39 | +a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,d){typeof b==="undefined"&&(b=0);typeof d==="undefined"&&(d=false);a.isHTML5||c.o._setPan(a.sID,b);a._iO.pan=b;if(!d)a.pan=b,a.options.pan=b;return a};this.setVolume=function(b,d){typeof b==="undefined"&&(b=100);typeof d==="undefined"&&(d=false);if(a.isHTML5){if(a._a)a._a.volume=Math.max(0,Math.min(1,b/100))}else c.o._setVolume(a.sID,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;if(!d)a.volume=b,a.options.volume= |
| 40 | +b;return a};this.mute=function(){a.muted=true;if(a.isHTML5){if(a._a)a._a.muted=true}else c.o._setVolume(a.sID,0);return a};this.unmute=function(){a.muted=false;var b=typeof a._iO.volume!=="undefined";if(a.isHTML5){if(a._a)a._a.muted=false}else c.o._setVolume(a.sID,b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=function(b,c,d){a._onPositionItems.push({position:b,method:c,scope:typeof d!=="undefined"?d:a,fired:false});return a}; |
| 41 | +this.processOnPosition=function(){var b,d;b=a._onPositionItems.length;if(!b||!a.playState||a._onPositionFired>=b)return false;for(;b--;)if(d=a._onPositionItems[b],!d.fired&&a.position>=d.position)d.fired=true,c._onPositionFired++,d.method.apply(d.scope,[d.position]);return true};this.resetOnPosition=function(b){var d,e;d=a._onPositionItems.length;if(!d)return false;for(;d--;)if(e=a._onPositionItems[d],e.fired&&b<=e.position)e.fired=false,c._onPositionFired--;return true};d=function(){a.isHTML5&&xa(a)}; |
| 42 | +f=function(){a.isHTML5&&ya(a)};e=function(){a._onPositionItems=[];a._onPositionFired=0;a._hasTimer=null;a._onplay_called=false;a._a=null;a._html5_canplay=false;a.bytesLoaded=null;a.bytesTotal=null;a.position=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.failures=0;a.loaded=false;a.playState=0;a.paused=false;a.readyState=0;a.muted=false;a.isBuffering=false;a.instanceOptions={};a.instanceCount=0;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.eqData= |
| 43 | +[];a.eqData.left=[];a.eqData.right=[]};e();this._onTimer=function(b){var c={};if(a._hasTimer||b)return a._a&&(b||(a.playState>0||a.readyState===1)&&!a.paused)?(a.duration=a._get_html5_duration(),a.durationEstimate=a.duration,b=a._a.currentTime?a._a.currentTime*1E3:0,a._whileplaying(b,c,c,c,c),true):false};this._get_html5_duration=function(){var b=a._a?a._a.duration*1E3:a._iO?a._iO.duration:void 0;return b&&!isNaN(b)&&b!==Infinity?b:a._iO?a._iO.duration:null};this._setup_html5=function(b){var b=n(a._iO, |
| 44 | +b),d=L?c._global_a:a._a;decodeURI(b.url);var f=d&&d._t?d._t.instanceOptions:null;if(d){if(d._t&&f.url===b.url&&(!a._lastURL||a._lastURL===f.url))return d;L&&d._t&&d._t.playState&&b.url!==f.url&&d._t.stop();e();d.src=b.url;a.url=b.url;a._lastURL=b.url;d._called_load=false}else{d=new Audio(b.url);d._called_load=false;if(Ka)d._called_load=true;if(L)c._global_a=d}a.isHTML5=true;a._a=d;d._t=a;a._add_html5_events();d.loop=b.loops>1?"loop":"";b.autoLoad||b.autoPlay?(d.autobuffer="auto",d.preload="auto", |
| 45 | +a.load(),d._called_load=true):(d.autobuffer=false,d.preload="none");d.loop=b.loops>1?"loop":"";return d};this._add_html5_events=function(){if(a._a._added_events)return false;var b;a._a._added_events=true;for(b in r)r.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,r[b],false);return true};this._remove_html5_events=function(){var b;a._a._added_events=false;for(b in r)r.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,r[b],false)};this._onload=function(b){b=!!b;a.loaded=b;a.readyState=b?3:2;a._onbufferchange(0); |
| 46 | +a._iO.onload&&a._iO.onload.apply(a,[b]);return true};this._onbufferchange=function(b){if(a.playState===0)return false;if(b&&a.isBuffering||!b&&!a.isBuffering)return false;a.isBuffering=b===1;a._iO.onbufferchange&&a._iO.onbufferchange.apply(a);return true};this._onsuspend=function(){a._iO.onsuspend&&a._iO.onsuspend.apply(a);return true};this._onfailure=function(b,c,d){a.failures++;if(a._iO.onfailure&&a.failures===1)a._iO.onfailure(a,b,c,d)};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0); |
| 47 | +a.resetOnPosition(0);if(a.instanceCount){a.instanceCount--;if(!a.instanceCount)a.playState=0,a.paused=false,a.instanceCount=0,a.instanceOptions={},a._iO={},f();(!a.instanceCount||a._iO.multiShotEvents)&&b&&b.apply(a)}};this._whileloading=function(b,c,d,e){a.bytesLoaded=b;a.bytesTotal=c;a.duration=Math.floor(d);a.bufferLength=e;if(a._iO.isMovieStar)a.durationEstimate=a.duration;else if(a.durationEstimate=a._iO.duration?a.duration>a._iO.duration?a.duration:a._iO.duration:parseInt(a.bytesTotal/a.bytesLoaded* |
| 48 | +a.duration,10),a.durationEstimate===void 0)a.durationEstimate=a.duration;a.readyState!==3&&a._iO.whileloading&&a._iO.whileloading.apply(a)};this._whileplaying=function(b,c,d,e,f){if(isNaN(b)||b===null)return false;a.position=b;a.processOnPosition();if(!a.isHTML5&&g>8){if(a._iO.usePeakData&&typeof c!=="undefined"&&c)a.peakData={left:c.leftPeak,right:c.rightPeak};if(a._iO.useWaveformData&&typeof d!=="undefined"&&d)a.waveformData={left:d.split(","),right:e.split(",")};if(a._iO.useEQData&&typeof f!== |
| 49 | +"undefined"&&f&&f.leftEQ&&(b=f.leftEQ.split(","),a.eqData=b,a.eqData.left=b,typeof f.rightEQ!=="undefined"&&f.rightEQ))a.eqData.right=f.rightEQ.split(",")}a.playState===1&&(!a.isHTML5&&g===8&&!a.position&&a.isBuffering&&a._onbufferchange(0),a._iO.whileplaying&&a._iO.whileplaying.apply(a));return true};this._onid3=function(b,c){var d=[],e,f;for(e=0,f=b.length;e<f;e++)d[b[e]]=c[e];a.id3=n(a.id3,d);a._iO.onid3&&a._iO.onid3.apply(a)};this._onconnect=function(b){b=b===1;if(a.connected=b)a.failures=0,l(a.sID)&& |
| 50 | +(a.getAutoPlay()?a.play(void 0,a.getAutoPlay()):a._iO.autoLoad&&a.load()),a._iO.onconnect&&a._iO.onconnect.apply(a,[b])};this._ondataerror=function(){a.playState>0&&a._iO.ondataerror&&a._iO.ondataerror.apply(a)}};fa=function(){return h.body||h._docElement||h.getElementsByTagName("div")[0]};O=function(b){return h.getElementById(b)};n=function(b,a){var e={},f,d;for(f in b)b.hasOwnProperty(f)&&(e[f]=b[f]);f=typeof a==="undefined"?c.defaultOptions:a;for(d in f)f.hasOwnProperty(d)&&typeof e[d]==="undefined"&& |
| 51 | +(e[d]=f[d]);return e};k=function(){function b(a){var a=Ia.call(a),b=a.length;c?(a[1]="on"+a[1],b>3&&a.pop()):b===3&&a.push(false);return a}function a(a,b){var w=a.shift(),h=[f[b]];if(c)w[h](a[0],a[1]);else w[h].apply(w,a)}var c=i.attachEvent,f={add:c?"attachEvent":"addEventListener",remove:c?"detachEvent":"removeEventListener"};return{add:function(){a(b(arguments),"add")},remove:function(){a(b(arguments),"remove")}}}();r={abort:j(function(){}),canplay:j(function(){if(this._t._html5_canplay)return true; |
| 52 | +this._t._html5_canplay=true;this._t._onbufferchange(0);var b=!isNaN(this._t.position)?this._t.position/1E3:null;if(this._t.position&&this.currentTime!==b)try{this.currentTime=b}catch(a){}}),load:j(function(){this._t.loaded||(this._t._onbufferchange(0),this._t._whileloading(this._t.bytesTotal,this._t.bytesTotal,this._t._get_html5_duration()),this._t._onload(true))}),emptied:j(function(){}),ended:j(function(){this._t._onfinish()}),error:j(function(){this._t._onload(false)}),loadeddata:j(function(){var b= |
| 53 | +this._t,a=b.bytesTotal||1;if(!b._loaded&&!M)b.duration=b._get_html5_duration(),b._whileloading(a,a,b._get_html5_duration()),b._onload(true)}),loadedmetadata:j(function(){}),loadstart:j(function(){this._t._onbufferchange(1)}),play:j(function(){this._t._onbufferchange(0)}),playing:j(function(){this._t._onbufferchange(0)}),progress:j(function(b){if(this._t.loaded)return false;var a,c=0,f=b.target.buffered;a=b.loaded||0;var d=b.total||1;if(f&&f.length){for(a=f.length;a--;)c=f.end(a)-f.start(a);a=c/b.target.duration}isNaN(a)|| |
| 54 | +(this._t._onbufferchange(0),this._t._whileloading(a,d,this._t._get_html5_duration()),a&&d&&a===d&&r.load.call(this,b))}),ratechange:j(function(){}),suspend:j(function(b){r.progress.call(this,b);this._t._onsuspend()}),stalled:j(function(){}),timeupdate:j(function(){this._t._onTimer()}),waiting:j(function(){this._t._onbufferchange(1)})};X=function(b){return!b.serverURL&&(b.type?K({type:b.type}):K({url:b.url})||c.html5Only)};la=function(b){if(b)b.src=Ja?"":"about:blank"};K=function(b){function a(a){return c.preferFlash&& |
| 55 | +p&&!c.ignoreFlash&&typeof c.flash[a]!=="undefined"&&c.flash[a]}if(!c.useHTML5Audio||!c.hasHTML5)return false;var e=b.url||null,b=b.type||null,f=c.audioFormats,d;if(b&&c.html5[b]!=="undefined")return c.html5[b]&&!a(b);if(!u){u=[];for(d in f)f.hasOwnProperty(d)&&(u.push(d),f[d].related&&(u=u.concat(f[d].related)));u=RegExp("\\.("+u.join("|")+")(\\?.*)?$","i")}d=e?e.toLowerCase().match(u):null;if(!d||!d.length)if(b)e=b.indexOf(";"),d=(e!==-1?b.substr(0,e):b).substr(6);else return false;else d=d[1];return d&& |
| 56 | +typeof c.html5[d]!=="undefined"?c.html5[d]&&!a(d):(b="audio/"+d,e=c.html5.canPlayType({type:b}),(c.html5[d]=e)&&c.html5[b]&&!a(b))};Aa=function(){function b(b){var d,e,f=false;if(!a||typeof a.canPlayType!=="function")return false;if(b instanceof Array){for(d=0,e=b.length;d<e&&!f;d++)if(c.html5[b[d]]||a.canPlayType(b[d]).match(c.html5Test))f=true,c.html5[b[d]]=true,c.flash[b[d]]=!(!c.preferFlash||!p||!b[d].match(Ea));return f}else return b=a&&typeof a.canPlayType==="function"?a.canPlayType(b):false, |
| 57 | +!(!b||!b.match(c.html5Test))}if(!c.useHTML5Audio||typeof Audio==="undefined")return false;var a=typeof Audio!=="undefined"?Ma?new Audio(null):new Audio:null,e,f={},d,h;d=c.audioFormats;for(e in d)if(d.hasOwnProperty(e)&&(f[e]=b(d[e].type),f["audio/"+e]=f[e],c.flash[e]=c.preferFlash&&!c.ignoreFlash&&e.match(Ea)?true:false,d[e]&&d[e].related))for(h=d[e].related.length;h--;)f["audio/"+d[e].related[h]]=f[e],c.html5[d[e].related[h]]=f[e],c.flash[d[e].related[h]]=f[e];f.canPlayType=a?b:null;c.html5=n(c.html5, |
| 58 | +f);return true};y=function(){};U=function(b){if(g===8&&b.loops>1&&b.stream)b.stream=false;return b};V=function(b){if(b&&!b.usePolicyFile&&(b.onid3||b.usePeakData||b.useWaveformData||b.useEQData))b.usePolicyFile=true;return b};ja=function(){};ba=function(){return false};va=function(b){for(var a in b)b.hasOwnProperty(a)&&typeof b[a]==="function"&&(b[a]=ba)};T=function(b){typeof b==="undefined"&&(b=false);(t||b)&&c.disable(b)};wa=function(b){var a=null;if(b)if(b.match(/\.swf(\?.*)?$/i)){if(a=b.substr(b.toLowerCase().lastIndexOf(".swf?")+ |
| 59 | +4))return b}else b.lastIndexOf("/")!==b.length-1&&(b+="/");b=(b&&b.lastIndexOf("/")!==-1?b.substr(0,b.lastIndexOf("/")+1):"./")+c.movieURL;c.noSWFCache&&(b+="?ts="+(new Date).getTime());return b};da=function(){g=parseInt(c.flashVersion,10);if(g!==8&&g!==9)c.flashVersion=g=8;var b=c.debugMode||c.debugFlash?"_debug.swf":".swf";if(c.useHTML5Audio&&!c.html5Only&&c.audioFormats.mp4.required&&g<9)c.flashVersion=g=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":g===9?" (AS3/Flash 9)":" (AS2/Flash 8)"); |
| 60 | +g>8?(c.defaultOptions=n(c.defaultOptions,c.flash9Options),c.features.buffering=true,c.defaultOptions=n(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+Ha.join("|")+")(\\?.*)?$","i"),c.features.movieStar=true):c.features.movieStar=false;c.filePattern=c.filePatterns[g!==8?"flash9":"flash8"];c.movieURL=(g===8?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",b);c.features.peakData=c.features.waveformData=c.features.eqData=g>8};ua=function(b,a){if(!c.o)return false; |
| 61 | +c.o._setPolling(b,a)};ga=function(){if(c.debugURLParam.test(aa))c.debugMode=true};l=this.getSoundById;D=function(){var b=[];c.debugMode&&b.push(c.swfCSS.sm2Debug);c.debugFlash&&b.push(c.swfCSS.flashDebug);c.useHighPerformance&&b.push(c.swfCSS.highPerf);return b.join(" ")};ia=function(){y("fbHandler");var b=c.getMoviePercent(),a=c.swfCSS,e={type:"FLASHBLOCK"};if(c.html5Only)return false;if(c.ok()){if(c.oMC)c.oMC.className=[D(),a.swfDefault,a.swfLoaded+(c.didFlashBlock?" "+a.swfUnblocked:"")].join(" ")}else{if(q)c.oMC.className= |
| 62 | +D()+" "+a.swfDefault+" "+(b===null?a.swfTimedout:a.swfError);c.didFlashBlock=true;z({type:"ontimeout",ignoreInit:true,error:e});C(e)}};ca=function(b,a,c){typeof s[b]==="undefined"&&(s[b]=[]);s[b].push({method:a,scope:c||null,fired:false})};z=function(b){b||(b={type:"onready"});if(!m&&b&&!b.ignoreInit)return false;if(b.type==="ontimeout"&&c.ok())return false;var a={success:b&&b.ignoreInit?c.ok():!t},e=b&&b.type?s[b.type]||[]:[],f=[],d,a=[a],h=q&&c.useFlashBlock&&!c.ok();if(b.error)a[0].error=b.error; |
| 63 | +for(b=0,d=e.length;b<d;b++)e[b].fired!==true&&f.push(e[b]);if(f.length)for(b=0,d=f.length;b<d;b++)if(f[b].scope?f[b].method.apply(f[b].scope,a):f[b].method.apply(this,a),!h)f[b].fired=true;return true};A=function(){i.setTimeout(function(){c.useFlashBlock&&ia();z();c.onload instanceof Function&&c.onload.apply(i);c.waitForWindowLoad&&k.add(i,"load",A)},1)};Y=function(){if(p!==void 0)return p;var b=false,a=navigator,c=a.plugins,f,d=i.ActiveXObject;if(c&&c.length)(a=a.mimeTypes)&&a["application/x-shockwave-flash"]&& |
| 64 | +a["application/x-shockwave-flash"].enabledPlugin&&a["application/x-shockwave-flash"].enabledPlugin.description&&(b=true);else if(typeof d!=="undefined"){try{f=new d("ShockwaveFlash.ShockwaveFlash")}catch(h){}b=!!f}return p=b};za=function(){var b,a;if(na&&o.match(/os (1|2|3_0|3_1)/i)){c.hasHTML5=false;c.html5Only=true;if(c.oMC)c.oMC.style.display="none";return false}if(c.useHTML5Audio){if(!c.html5||!c.html5.canPlayType)return c.hasHTML5=false,true;else c.hasHTML5=true;if(oa&&Y())return true}else return true; |
| 65 | +for(a in c.audioFormats)if(c.audioFormats.hasOwnProperty(a)&&(c.audioFormats[a].required&&!c.html5.canPlayType(c.audioFormats[a].type)||c.flash[a]||c.flash[c.audioFormats[a].type]))b=true;c.ignoreFlash&&(b=false);c.html5Only=c.hasHTML5&&c.useHTML5Audio&&!b;return!c.html5Only};xa=function(b){if(!b._hasTimer)b._hasTimer=true};ya=function(b){if(b._hasTimer)b._hasTimer=false};C=function(b){b=typeof b!=="undefined"?b:{};c.onerror instanceof Function&&c.onerror.apply(i,[{type:typeof b.type!=="undefined"? |
| 66 | +b.type:null}]);typeof b.fatal!=="undefined"&&b.fatal&&c.disable()};Ba=function(){if(!oa||!Y())return false;var b=c.audioFormats,a,e;for(e in b)if(b.hasOwnProperty(e)&&(e==="mp3"||e==="mp4"))if(c.html5[e]=false,b[e]&&b[e].related)for(a=b[e].related.length;a--;)c.html5[b[e].related[a]]=false};this._setSandboxType=function(){};this._externalInterfaceOK=function(){if(c.swfLoaded)return false;(new Date).getTime();c.swfLoaded=true;E=false;oa&&Ba();v?setTimeout(P,100):P()};S=function(b,a){function e(a,b){return'<param name="'+ |
| 67 | +a+'" value="'+b+'" />'}if(G&&H)return false;if(c.html5Only)return da(),c.oMC=O(c.movieID),P(),H=G=true,false;var f=a||c.url,d=c.altURL||f,g;g=fa();var i,l,j=D(),k,m=null,m=(m=h.getElementsByTagName("html")[0])&&m.dir&&m.dir.match(/rtl/i),b=typeof b==="undefined"?c.id:b;da();c.url=wa(qa?f:d);a=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(c.wmode!==null&&(o.match(/msie 8/i)||!v&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))c.specialWmodeCase=true,c.wmode= |
| 68 | +null;g={name:b,id:b,src:a,width:"auto",height:"auto",quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Fa+"www.macromedia.com/go/getflashplayer",title:"JS/Flash audio component (SoundManager 2)",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};if(c.debugFlash)g.FlashVars="debug=1";c.wmode||delete g.wmode;if(v)f=h.createElement("div"),l=['<object id="'+b+'" data="'+a+'" type="'+g.type+'" title="'+g.title+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+ |
| 69 | +Fa+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+g.width+'" height="'+g.height+'">',e("movie",a),e("AllowScriptAccess",c.allowScriptAccess),e("quality",g.quality),c.wmode?e("wmode",c.wmode):"",e("bgcolor",c.bgColor),e("hasPriority","true"),c.debugFlash?e("FlashVars",g.FlashVars):"","</object>"].join("");else for(i in f=h.createElement("embed"),g)g.hasOwnProperty(i)&&f.setAttribute(i,g[i]);ga();j=D();if(g=fa())if(c.oMC=O(c.movieID)||h.createElement("div"), |
| 70 | +c.oMC.id){k=c.oMC.className;c.oMC.className=(k?k+" ":c.swfCSS.swfDefault)+(j?" "+j:"");c.oMC.appendChild(f);if(v)i=c.oMC.appendChild(h.createElement("div")),i.className=c.swfCSS.swfBox,i.innerHTML=l;H=true}else{c.oMC.id=c.movieID;c.oMC.className=c.swfCSS.swfDefault+" "+j;i=j=null;if(!c.useFlashBlock)if(c.useHighPerformance)j={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"};else if(j={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},m)j.left= |
| 71 | +Math.abs(parseInt(j.left,10))+"px";if(La)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(k in j)j.hasOwnProperty(k)&&(c.oMC.style[k]=j[k]);try{v||c.oMC.appendChild(f);g.appendChild(c.oMC);if(v)i=c.oMC.appendChild(h.createElement("div")),i.className=c.swfCSS.swfBox,i.innerHTML=l;H=true}catch(n){throw Error(y("domError")+" \n"+n.toString());}}return G=true};R=function(){if(c.html5Only)return S(),false;if(c.o)return false;c.o=c.getMovie(c.id);if(!c.o)J?(v?c.oMC.innerHTML=ha:c.oMC.appendChild(J),J=null,G= |
| 72 | +true):S(c.id,c.url),c.o=c.getMovie(c.id);c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return true};Q=function(){setTimeout(ta,1E3)};ta=function(){if(W)return false;W=true;k.remove(i,"load",Q);if(E&&!pa)return false;var b;m||(b=c.getMoviePercent());setTimeout(function(){b=c.getMoviePercent();!m&&Da&&(b===null?c.useFlashBlock||c.flashLoadTimeout===0?c.useFlashBlock&&ia():T(true):c.flashLoadTimeout!==0&&T(true))},c.flashLoadTimeout)};x=function(){function b(){k.remove(i,"focus",x); |
| 73 | +k.remove(i,"load",x)}if(pa||!E)return b(),true;pa=Da=true;M&&E&&k.remove(i,"mousemove",x);W=false;b();return true};Ca=function(){var b,a=[];if(c.useHTML5Audio&&c.hasHTML5)for(b in c.audioFormats)c.audioFormats.hasOwnProperty(b)&&a.push(b+": "+c.html5[b]+(!c.html5[b]&&p&&c.flash[b]?" (using flash)":c.preferFlash&&c.flash[b]&&p?" (preferring flash)":!c.html5[b]?" ("+(c.audioFormats[b].required?"required, ":"")+"and no flash support)":""))};I=function(b){if(m)return false;if(c.html5Only)return m=true, |
| 74 | +A(),true;var a;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())m=true,t&&(a={type:!p&&q?"NO_FLASH":"INIT_TIMEOUT"});if(t||b){if(c.useFlashBlock&&c.oMC)c.oMC.className=D()+" "+(c.getMoviePercent()===null?c.swfCSS.swfTimedout:c.swfCSS.swfError);z({type:"ontimeout",error:a});C(a);return false}if(c.waitForWindowLoad&&!sa)return k.add(i,"load",A),false;else A();return true};P=function(){if(m)return false;if(c.html5Only){if(!m)k.remove(i,"load",c.beginDelayedInit),c.enabled=true,I();return true}R(); |
| 75 | +try{c.o._externalInterfaceTest(false),ua(true,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||c.o._disableDebug(),c.enabled=true,c.html5Only||k.add(i,"unload",ba)}catch(b){return C({type:"JS_TO_FLASH_EXCEPTION",fatal:true}),T(true),I(),false}I();k.remove(i,"load",c.beginDelayedInit);return true};B=function(){if(ea)return false;ea=true;ga();if(!p&&c.hasHTML5)c.useHTML5Audio=true,c.preferFlash=false;Aa();c.html5.usingFlash=za();q=c.html5.usingFlash;Ca();if(!p&&q)c.flashLoadTimeout= |
| 76 | +1;h.removeEventListener&&h.removeEventListener("DOMContentLoaded",B,false);R();return true};ma=function(){h.readyState==="complete"&&(B(),h.detachEvent("onreadystatechange",ma));return true};Y();k.add(i,"focus",x);k.add(i,"load",x);k.add(i,"load",Q);M&&E&&k.add(i,"mousemove",x);h.addEventListener?h.addEventListener("DOMContentLoaded",B,false):h.attachEvent?h.attachEvent("onreadystatechange",ma):C({type:"NO_DOM2_EVENTS",fatal:true});h.readyState==="complete"&&setTimeout(B,100)}var Z=null;if(typeof SM2_DEFER=== |
| 77 | +"undefined"||!SM2_DEFER)Z=new N;$.SoundManager=N;$.soundManager=Z})(window); |
\ No newline at end of file |
Property changes on: trunk/extensions/SoundManager2Button/script/soundmanager2-nodebug-jsmin.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 78 | + native |
Index: trunk/extensions/SoundManager2Button/script/soundmanager2.js |
— | — | @@ -0,0 +1,4520 @@ |
| 2 | +/** @license |
| 3 | + * |
| 4 | + * SoundManager 2: JavaScript Sound for the Web |
| 5 | + * ---------------------------------------------- |
| 6 | + * http://schillmania.com/projects/soundmanager2/ |
| 7 | + * |
| 8 | + * Copyright (c) 2007, Scott Schiller. All rights reserved. |
| 9 | + * Code provided under the BSD License: |
| 10 | + * http://schillmania.com/projects/soundmanager2/license.txt |
| 11 | + * |
| 12 | + * V2.97a.20111030 |
| 13 | + */ |
| 14 | + |
| 15 | +/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio */ |
| 16 | +/* jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true */ |
| 17 | + |
| 18 | +/** |
| 19 | + * About this file |
| 20 | + * --------------- |
| 21 | + * This is the fully-commented source version of the SoundManager 2 API, |
| 22 | + * recommended for use during development and testing. |
| 23 | + * |
| 24 | + * See soundmanager2-nodebug-jsmin.js for an optimized build (~10KB with gzip.) |
| 25 | + * http://schillmania.com/projects/soundmanager2/doc/getstarted/#basic-inclusion |
| 26 | + * Alternately, serve this file with gzip for 75% compression savings (~30KB over HTTP.) |
| 27 | + * |
| 28 | + * You may notice <d> and </d> comments in this source; these are delimiters for |
| 29 | + * debug blocks which are removed in the -nodebug builds, further optimizing code size. |
| 30 | + */ |
| 31 | + |
| 32 | +(function(window) { |
| 33 | + |
| 34 | +var soundManager = null; |
| 35 | + |
| 36 | +/** |
| 37 | + * The SoundManager constructor. |
| 38 | + * |
| 39 | + * @constructor |
| 40 | + * @param {string} smURL Optional: Path to SWF files |
| 41 | + * @param {string} smID Optional: The ID to use for the SWF container element |
| 42 | + * @this {SoundManager} |
| 43 | + * @return {SoundManager} The new SoundManager instance |
| 44 | + */ |
| 45 | + |
| 46 | +function SoundManager(smURL, smID) { |
| 47 | + |
| 48 | + // Top-level configuration options |
| 49 | + |
| 50 | + this.flashVersion = 8; // version of flash to require, either 8 or 9. Some API features require Flash 9. |
| 51 | + this.debugMode = true; // enable debugging output (div#soundmanager-debug, OR console if available+configured) |
| 52 | + this.debugFlash = false; // enable debugging output inside SWF, troubleshoot Flash/browser issues |
| 53 | + this.useConsole = true; // use firebug/safari console.log()-type debug console if available |
| 54 | + this.consoleOnly = false; // if console is being used, do not create/write to #soundmanager-debug |
| 55 | + this.waitForWindowLoad = false; // force SM2 to wait for window.onload() before trying to call soundManager.onload() |
| 56 | + this.bgColor = '#ffffff'; // movie (.swf) background color, eg. '#000000' |
| 57 | + this.useHighPerformance = false; // position:fixed flash movie can help increase js/flash speed, minimize lag |
| 58 | + this.flashPollingInterval = null; // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used. |
| 59 | + this.flashLoadTimeout = 1000; // msec to wait for flash movie to load before failing (0 = infinity) |
| 60 | + this.wmode = null; // string: flash rendering mode - null, transparent, opaque (last two allow layering of HTML on top) |
| 61 | + this.allowScriptAccess = 'always'; // for scripting the SWF (object/embed property), either 'always' or 'sameDomain' |
| 62 | + this.useFlashBlock = false; // *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable. |
| 63 | + this.useHTML5Audio = true; // use HTML5 Audio() where API is supported (most Safari, Chrome versions), Firefox (no MP3/MP4.) Ideally, transparent vs. Flash API where possible. |
| 64 | + this.html5Test = /^(probably|maybe)$/i; // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative. |
| 65 | + this.preferFlash = true; // overrides useHTML5audio. if true and flash support present, will try to use flash for MP3/MP4 as needed since HTML5 audio support is still quirky in browsers. |
| 66 | + this.noSWFCache = false; // if true, appends ?ts={date} to break aggressive SWF caching. |
| 67 | + |
| 68 | + this.audioFormats = { |
| 69 | + |
| 70 | + /** |
| 71 | + * determines HTML5 support + flash requirements. |
| 72 | + * if no support (via flash and/or HTML5) for a "required" format, SM2 will fail to start. |
| 73 | + * flash fallback is used for MP3 or MP4 if HTML5 can't play it (or if preferFlash = true) |
| 74 | + * multiple MIME types may be tested while trying to get a positive canPlayType() response. |
| 75 | + */ |
| 76 | + |
| 77 | + 'mp3': { |
| 78 | + 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'], |
| 79 | + 'required': true |
| 80 | + }, |
| 81 | + |
| 82 | + 'mp4': { |
| 83 | + 'related': ['aac','m4a'], // additional formats under the MP4 container |
| 84 | + 'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'], |
| 85 | + 'required': false |
| 86 | + |
| 87 | + }, |
| 88 | + |
| 89 | + 'ogg': { |
| 90 | + 'type': ['audio/ogg; codecs=vorbis'], |
| 91 | + 'required': false |
| 92 | + }, |
| 93 | + |
| 94 | + 'wav': { |
| 95 | + 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'], |
| 96 | + 'required': false |
| 97 | + } |
| 98 | + |
| 99 | + }; |
| 100 | + |
| 101 | + this.defaultOptions = { |
| 102 | + |
| 103 | + /** |
| 104 | + * the default configuration for sound objects made with createSound() and related methods |
| 105 | + * eg., volume, auto-load behaviour and so forth |
| 106 | + */ |
| 107 | + |
| 108 | + '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) |
| 109 | + 'stream': true, // allows playing before entire file has loaded (recommended) |
| 110 | + 'autoPlay': false, // enable playing of file as soon as possible (much faster if "stream" is true) |
| 111 | + 'loops': 1, // how many times to repeat the sound (position will wrap around to 0, setPosition() will break out of loop when >0) |
| 112 | + 'onid3': null, // callback function for "ID3 data is added/available" |
| 113 | + 'onload': null, // callback function for "load finished" |
| 114 | + 'whileloading': null, // callback function for "download progress update" (X of Y bytes received) |
| 115 | + 'onplay': null, // callback for "play" start |
| 116 | + 'onpause': null, // callback for "pause" |
| 117 | + 'onresume': null, // callback for "resume" (pause toggle) |
| 118 | + 'whileplaying': null, // callback during play (position update) |
| 119 | + 'onstop': null, // callback for "user stop" |
| 120 | + 'onfailure': null, // callback function for when playing fails |
| 121 | + 'onfinish': null, // callback function for "sound finished playing" |
| 122 | + 'multiShot': true, // let sounds "restart" or layer on top of each other when played multiple times, rather than one-shot/one at a time |
| 123 | + 'multiShotEvents': false, // fire multiple sound events (currently onfinish() only) when multiShot is enabled |
| 124 | + 'position': null, // offset (milliseconds) to seek to within loaded sound data. |
| 125 | + 'pan': 0, // "pan" settings, left-to-right, -100 to 100 |
| 126 | + 'type': null, // MIME-like hint for file pattern / canPlay() tests, eg. audio/mp3 |
| 127 | + 'usePolicyFile': false, // enable crossdomain.xml request for audio on remote domains (for ID3/waveform access) |
| 128 | + 'volume': 100 // self-explanatory. 0-100, the latter being the max. |
| 129 | + |
| 130 | + }; |
| 131 | + |
| 132 | + this.flash9Options = { |
| 133 | + |
| 134 | + /** |
| 135 | + * flash 9-only options, |
| 136 | + * merged into defaultOptions if flash 9 is being used |
| 137 | + */ |
| 138 | + |
| 139 | + 'isMovieStar': null, // "MovieStar" MPEG4 audio mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL |
| 140 | + 'usePeakData': false, // enable left/right channel peak (level) data |
| 141 | + 'useWaveformData': false, // enable sound spectrum (raw waveform data) - NOTE: May increase CPU load. |
| 142 | + 'useEQData': false, // enable sound EQ (frequency spectrum data) - NOTE: May increase CPU load. |
| 143 | + 'onbufferchange': null, // callback for "isBuffering" property change |
| 144 | + 'ondataerror': null // callback for waveform/eq data access error (flash playing audio in other tabs/domains) |
| 145 | + |
| 146 | + }; |
| 147 | + |
| 148 | + this.movieStarOptions = { |
| 149 | + |
| 150 | + /** |
| 151 | + * flash 9.0r115+ MPEG4 audio options, |
| 152 | + * merged into defaultOptions if flash 9+movieStar mode is enabled |
| 153 | + */ |
| 154 | + |
| 155 | + 'bufferTime': 3, // seconds of data to buffer before playback begins (null = flash default of 0.1 seconds - if AAC playback is gappy, try increasing.) |
| 156 | + 'serverURL': null, // rtmp: FMS or FMIS server to connect to, required when requesting media via RTMP or one of its variants |
| 157 | + 'onconnect': null, // rtmp: callback for connection to flash media server |
| 158 | + 'duration': null // rtmp: song duration (msec) |
| 159 | + |
| 160 | + }; |
| 161 | + |
| 162 | + // HTML attributes (id + class names) for the SWF container |
| 163 | + |
| 164 | + this.movieID = 'sm2-container'; |
| 165 | + this.id = (smID || 'sm2movie'); |
| 166 | + |
| 167 | + this.swfCSS = { |
| 168 | + |
| 169 | + 'swfBox': 'sm2-object-box', |
| 170 | + 'swfDefault': 'movieContainer', |
| 171 | + 'swfError': 'swf_error', // SWF loaded, but SM2 couldn't start (other error) |
| 172 | + 'swfTimedout': 'swf_timedout', |
| 173 | + 'swfLoaded': 'swf_loaded', |
| 174 | + 'swfUnblocked': 'swf_unblocked', // or loaded OK |
| 175 | + 'sm2Debug': 'sm2_debug', |
| 176 | + 'highPerf': 'high_performance', |
| 177 | + 'flashDebug': 'flash_debug' |
| 178 | + |
| 179 | + }; |
| 180 | + |
| 181 | + this.debugID = 'soundmanager-debug'; |
| 182 | + this.debugURLParam = /([#?&])debug=1/i; |
| 183 | + |
| 184 | + // dynamic attributes |
| 185 | + |
| 186 | + this.versionNumber = 'V2.97a.20111030'; |
| 187 | + this.version = null; |
| 188 | + this.movieURL = null; |
| 189 | + this.url = (smURL || null); |
| 190 | + this.altURL = null; |
| 191 | + this.swfLoaded = false; |
| 192 | + this.enabled = false; |
| 193 | + this.o = null; |
| 194 | + this.oMC = null; |
| 195 | + this.sounds = {}; |
| 196 | + this.soundIDs = []; |
| 197 | + this.muted = false; |
| 198 | + this.specialWmodeCase = false; |
| 199 | + this.didFlashBlock = false; |
| 200 | + this.filePattern = null; |
| 201 | + |
| 202 | + this.filePatterns = { |
| 203 | + |
| 204 | + 'flash8': /\.mp3(\?.*)?$/i, |
| 205 | + 'flash9': /\.mp3(\?.*)?$/i |
| 206 | + |
| 207 | + }; |
| 208 | + |
| 209 | + // support indicators, set at init |
| 210 | + |
| 211 | + this.features = { |
| 212 | + |
| 213 | + 'buffering': false, |
| 214 | + 'peakData': false, |
| 215 | + 'waveformData': false, |
| 216 | + 'eqData': false, |
| 217 | + 'movieStar': false |
| 218 | + |
| 219 | + }; |
| 220 | + |
| 221 | + // flash sandbox info, used primarily in troubleshooting |
| 222 | + |
| 223 | + this.sandbox = { |
| 224 | + |
| 225 | + // <d> |
| 226 | + 'type': null, |
| 227 | + 'types': { |
| 228 | + 'remote': 'remote (domain-based) rules', |
| 229 | + 'localWithFile': 'local with file access (no internet access)', |
| 230 | + 'localWithNetwork': 'local with network (internet access only, no local access)', |
| 231 | + 'localTrusted': 'local, trusted (local+internet access)' |
| 232 | + }, |
| 233 | + 'description': null, |
| 234 | + 'noRemote': null, |
| 235 | + 'noLocal': null |
| 236 | + // </d> |
| 237 | + |
| 238 | + }; |
| 239 | + |
| 240 | + /** |
| 241 | + * basic HTML5 Audio() support test |
| 242 | + * try...catch because of IE 9 "not implemented" nonsense |
| 243 | + * https://github.com/Modernizr/Modernizr/issues/224 |
| 244 | + */ |
| 245 | + |
| 246 | + this.hasHTML5 = (function() { |
| 247 | + try { |
| 248 | + return (typeof Audio !== 'undefined' && typeof new Audio().canPlayType !== 'undefined'); |
| 249 | + } catch(e) { |
| 250 | + return false; |
| 251 | + } |
| 252 | + }()); |
| 253 | + |
| 254 | + /** |
| 255 | + * format support (html5/flash) |
| 256 | + * stores canPlayType() results based on audioFormats. |
| 257 | + * eg. { mp3: boolean, mp4: boolean } |
| 258 | + * treat as read-only. |
| 259 | + */ |
| 260 | + |
| 261 | + this.html5 = { |
| 262 | + 'usingFlash': null // set if/when flash fallback is needed |
| 263 | + }; |
| 264 | + |
| 265 | + this.flash = {}; |
| 266 | + |
| 267 | + this.html5Only = false; // determined at init time |
| 268 | + this.ignoreFlash = false; // used for special cases (eg. iPad/iPhone/palm OS?) |
| 269 | + |
| 270 | + /** |
| 271 | + * a few private internals (OK, a lot. :D) |
| 272 | + */ |
| 273 | + |
| 274 | + var SMSound, |
| 275 | + _s = this, _sm = 'soundManager', _smc = _sm+'::', _h5 = 'HTML5::', _id, _ua = navigator.userAgent, _win = window, _wl = _win.location.href.toString(), _doc = document, _doNothing, _init, _fV, _on_queue = [], _debugOpen = true, _debugTS, _didAppend = false, _appendSuccess = false, _didInit = false, _disabled = false, _windowLoaded = false, _wDS, _wdCount = 0, _initComplete, _mixin, _addOnEvent, _processOnEvents, _initUserOnload, _delayWaitForEI, _waitForEI, _setVersionInfo, _handleFocus, _strings, _initMovie, _domContentLoaded, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _smTimer, _onTimer, _startTimer, _stopTimer, _needsFlash = null, _featureCheck, _html5OK, _html5CanPlay, _html5Ext, _html5Unload, _domContentLoadedIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix, _html5_events, _showSupport, |
| 276 | + _is_iDevice = _ua.match(/(ipad|iphone|ipod)/i), _is_firefox = _ua.match(/firefox/i), _is_android = _ua.match(/droid/i), _isIE = _ua.match(/msie/i), _isWebkit = _ua.match(/webkit/i), _isSafari = (_ua.match(/safari/i) && !_ua.match(/chrome/i)), _isOpera = (_ua.match(/opera/i)), |
| 277 | + _likesHTML5 = (_ua.match(/(mobile|pre\/|xoom)/i) || _is_iDevice), |
| 278 | + _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && _ua.match(/OS X 10_6_([3-7])/i)), // Safari 4 and 5 occasionally fail to load/play HTML5 audio on Snow Leopard 10.6.3 through 10.6.7 due to bug(s) in QuickTime X and/or other underlying frameworks. :/ Confirmed bug. https://bugs.webkit.org/show_bug.cgi?id=32159 |
| 279 | + _hasConsole = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (_isSafari && typeof _doc.hasFocus === 'undefined'), _okToDisable = !_tryInitOnFocus, _flashMIME = /(mp3|mp4|mpa)/i, |
| 280 | + _emptyURL = 'about:blank', // safe URL to unload, or load nothing from (flash 8 + most HTML5 UAs) |
| 281 | + _overHTTP = (_doc.location?_doc.location.protocol.match(/http/i):null), |
| 282 | + _http = (!_overHTTP ? 'http:/'+'/' : ''), |
| 283 | + // mp3, mp4, aac etc. |
| 284 | + _netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i, |
| 285 | + // Flash v9.0r115+ "moviestar" formats |
| 286 | + _netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'mp4v', '3gp', '3g2'], |
| 287 | + _netStreamPattern = new RegExp('\\.(' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); |
| 288 | + this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; // default mp3 set |
| 289 | + |
| 290 | + // use altURL if not "online" |
| 291 | + this.useAltURL = !_overHTTP; |
| 292 | + this._global_a = null; |
| 293 | + |
| 294 | + if (_likesHTML5) { |
| 295 | + |
| 296 | + // prefer HTML5 for mobile + tablet-like devices, probably more reliable vs. flash at this point. |
| 297 | + _s.useHTML5Audio = true; |
| 298 | + _s.preferFlash = false; |
| 299 | + |
| 300 | + if (_is_iDevice) { |
| 301 | + // by default, use global feature. iOS onfinish() -> next may fail otherwise. |
| 302 | + _s.ignoreFlash = true; |
| 303 | + _useGlobalHTML5Audio = true; |
| 304 | + } |
| 305 | + |
| 306 | + } |
| 307 | + |
| 308 | + /** |
| 309 | + * Public SoundManager API |
| 310 | + * ----------------------- |
| 311 | + */ |
| 312 | + |
| 313 | + this.ok = function() { |
| 314 | + |
| 315 | + return (_needsFlash?(_didInit && !_disabled):(_s.useHTML5Audio && _s.hasHTML5)); |
| 316 | + |
| 317 | + }; |
| 318 | + |
| 319 | + this.supported = this.ok; // legacy |
| 320 | + |
| 321 | + this.getMovie = function(smID) { |
| 322 | + |
| 323 | + // safety net: some old browsers differ on SWF references, possibly related to ExternalInterface / flash version |
| 324 | + return _id(smID) || _doc[smID] || _win[smID]; |
| 325 | + |
| 326 | + }; |
| 327 | + |
| 328 | + /** |
| 329 | + * Creates a SMSound sound object instance. |
| 330 | + * |
| 331 | + * @param {object} oOptions Sound options (at minimum, id and url are required.) |
| 332 | + * @return {object} SMSound The new SMSound object. |
| 333 | + */ |
| 334 | + |
| 335 | + this.createSound = function(oOptions) { |
| 336 | + |
| 337 | + var _cs = _sm+'.createSound(): ', |
| 338 | + thisOptions = null, oSound = null, _tO = null; |
| 339 | + |
| 340 | + if (!_didInit || !_s.ok()) { |
| 341 | + _complain(_cs + _str(!_didInit?'notReady':'notOK')); |
| 342 | + return false; |
| 343 | + } |
| 344 | + |
| 345 | + if (arguments.length === 2) { |
| 346 | + // function overloading in JS! :) ..assume simple createSound(id,url) use case |
| 347 | + oOptions = { |
| 348 | + 'id': arguments[0], |
| 349 | + 'url': arguments[1] |
| 350 | + }; |
| 351 | + } |
| 352 | + |
| 353 | + // inherit from defaultOptions |
| 354 | + thisOptions = _mixin(oOptions); |
| 355 | + |
| 356 | + // alias |
| 357 | + _tO = thisOptions; |
| 358 | + |
| 359 | + // <d> |
| 360 | + if (_tO.id.toString().charAt(0).match(/^[0-9]$/)) { |
| 361 | + _s._wD(_cs + _str('badID', _tO.id), 2); |
| 362 | + } |
| 363 | + |
| 364 | + _s._wD(_cs + _tO.id + ' (' + _tO.url + ')', 1); |
| 365 | + // </d> |
| 366 | + |
| 367 | + if (_idCheck(_tO.id, true)) { |
| 368 | + _s._wD(_cs + _tO.id + ' exists', 1); |
| 369 | + return _s.sounds[_tO.id]; |
| 370 | + } |
| 371 | + |
| 372 | + function make() { |
| 373 | + |
| 374 | + thisOptions = _loopFix(thisOptions); |
| 375 | + _s.sounds[_tO.id] = new SMSound(_tO); |
| 376 | + _s.soundIDs.push(_tO.id); |
| 377 | + return _s.sounds[_tO.id]; |
| 378 | + |
| 379 | + } |
| 380 | + |
| 381 | + if (_html5OK(_tO)) { |
| 382 | + |
| 383 | + oSound = make(); |
| 384 | + _s._wD('Loading sound '+_tO.id+' via HTML5'); |
| 385 | + oSound._setup_html5(_tO); |
| 386 | + |
| 387 | + } else { |
| 388 | + |
| 389 | + if (_fV > 8) { |
| 390 | + if (_tO.isMovieStar === null) { |
| 391 | + // attempt to detect MPEG-4 formats |
| 392 | + _tO.isMovieStar = (_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern)); |
| 393 | + } |
| 394 | + // <d> |
| 395 | + if (_tO.isMovieStar) { |
| 396 | + _s._wD(_cs + 'using MovieStar handling'); |
| 397 | + } |
| 398 | + // </d> |
| 399 | + if (_tO.isMovieStar) { |
| 400 | + if (_tO.usePeakData) { |
| 401 | + _wDS('noPeak'); |
| 402 | + _tO.usePeakData = false; |
| 403 | + } |
| 404 | + // <d> |
| 405 | + if (_tO.loops > 1) { |
| 406 | + _wDS('noNSLoop'); |
| 407 | + } |
| 408 | + // </d> |
| 409 | + } |
| 410 | + } |
| 411 | + |
| 412 | + _tO = _policyFix(_tO, _cs); |
| 413 | + oSound = make(); |
| 414 | + |
| 415 | + if (_fV === 8) { |
| 416 | + _s.o._createSound(_tO.id, _tO.loops||1, _tO.usePolicyFile); |
| 417 | + } else { |
| 418 | + _s.o._createSound(_tO.id, _tO.url, _tO.usePeakData, _tO.useWaveformData, _tO.useEQData, _tO.isMovieStar, (_tO.isMovieStar?_tO.bufferTime:false), _tO.loops||1, _tO.serverURL, _tO.duration||null, _tO.autoPlay, true, _tO.autoLoad, _tO.usePolicyFile); |
| 419 | + if (!_tO.serverURL) { |
| 420 | + // We are connected immediately |
| 421 | + oSound.connected = true; |
| 422 | + if (_tO.onconnect) { |
| 423 | + _tO.onconnect.apply(oSound); |
| 424 | + } |
| 425 | + } |
| 426 | + } |
| 427 | + |
| 428 | + if (!_tO.serverURL && (_tO.autoLoad || _tO.autoPlay)) { |
| 429 | + // call load for non-rtmp streams |
| 430 | + oSound.load(_tO); |
| 431 | + } |
| 432 | + |
| 433 | + } |
| 434 | + |
| 435 | + // rtmp will play in onconnect |
| 436 | + if (!_tO.serverURL && _tO.autoPlay) { |
| 437 | + oSound.play(); |
| 438 | + } |
| 439 | + |
| 440 | + return oSound; |
| 441 | + |
| 442 | + }; |
| 443 | + |
| 444 | + /** |
| 445 | + * Destroys a SMSound sound object instance. |
| 446 | + * |
| 447 | + * @param {string} sID The ID of the sound to destroy |
| 448 | + */ |
| 449 | + |
| 450 | + this.destroySound = function(sID, _bFromSound) { |
| 451 | + |
| 452 | + // explicitly destroy a sound before normal page unload, etc. |
| 453 | + |
| 454 | + if (!_idCheck(sID)) { |
| 455 | + return false; |
| 456 | + } |
| 457 | + |
| 458 | + var oS = _s.sounds[sID], i; |
| 459 | + |
| 460 | + // Disable all callbacks while the sound is being destroyed |
| 461 | + oS._iO = {}; |
| 462 | + |
| 463 | + oS.stop(); |
| 464 | + oS.unload(); |
| 465 | + |
| 466 | + for (i = 0; i < _s.soundIDs.length; i++) { |
| 467 | + if (_s.soundIDs[i] === sID) { |
| 468 | + _s.soundIDs.splice(i, 1); |
| 469 | + break; |
| 470 | + } |
| 471 | + } |
| 472 | + |
| 473 | + if (!_bFromSound) { |
| 474 | + // ignore if being called from SMSound instance |
| 475 | + oS.destruct(true); |
| 476 | + } |
| 477 | + |
| 478 | + oS = null; |
| 479 | + delete _s.sounds[sID]; |
| 480 | + |
| 481 | + return true; |
| 482 | + |
| 483 | + }; |
| 484 | + |
| 485 | + /** |
| 486 | + * Calls the load() method of a SMSound object by ID. |
| 487 | + * |
| 488 | + * @param {string} sID The ID of the sound |
| 489 | + * @param {object} oOptions Optional: Sound options |
| 490 | + */ |
| 491 | + |
| 492 | + this.load = function(sID, oOptions) { |
| 493 | + |
| 494 | + if (!_idCheck(sID)) { |
| 495 | + return false; |
| 496 | + } |
| 497 | + return _s.sounds[sID].load(oOptions); |
| 498 | + |
| 499 | + }; |
| 500 | + |
| 501 | + /** |
| 502 | + * Calls the unload() method of a SMSound object by ID. |
| 503 | + * |
| 504 | + * @param {string} sID The ID of the sound |
| 505 | + */ |
| 506 | + |
| 507 | + this.unload = function(sID) { |
| 508 | + |
| 509 | + if (!_idCheck(sID)) { |
| 510 | + return false; |
| 511 | + } |
| 512 | + |
| 513 | + return _s.sounds[sID].unload(); |
| 514 | + |
| 515 | + }; |
| 516 | + |
| 517 | + /** |
| 518 | + * Calls the onposition() method of a SMSound object by ID. |
| 519 | + * |
| 520 | + * @param {string} sID The ID of the sound |
| 521 | + * @param {number} nPosition The position to watch for |
| 522 | + * @param {function} oMethod The relevant callback to fire |
| 523 | + * @param {object} oScope Optional: The scope to apply the callback to |
| 524 | + * @return {SMSound} The SMSound object |
| 525 | + */ |
| 526 | + |
| 527 | + this.onposition = function(sID, nPosition, oMethod, oScope) { |
| 528 | + |
| 529 | + if (!_idCheck(sID)) { |
| 530 | + return false; |
| 531 | + } |
| 532 | + return _s.sounds[sID].onposition(nPosition, oMethod, oScope); |
| 533 | + |
| 534 | + }; |
| 535 | + |
| 536 | + /** |
| 537 | + * Calls the play() method of a SMSound object by ID. |
| 538 | + * |
| 539 | + * @param {string} sID The ID of the sound |
| 540 | + * @param {object} oOptions Optional: Sound options |
| 541 | + * @return {SMSound} The SMSound object |
| 542 | + */ |
| 543 | + |
| 544 | + this.play = function(sID, oOptions) { |
| 545 | + |
| 546 | + var fN = _sm+'.play(): '; |
| 547 | + |
| 548 | + if (!_didInit || !_s.ok()) { |
| 549 | + _complain(fN + _str(!_didInit?'notReady':'notOK')); |
| 550 | + return false; |
| 551 | + } |
| 552 | + |
| 553 | + if (!_idCheck(sID)) { |
| 554 | + if (!(oOptions instanceof Object)) { |
| 555 | + oOptions = { |
| 556 | + url: oOptions |
| 557 | + }; // overloading use case: play('mySound','/path/to/some.mp3'); |
| 558 | + } |
| 559 | + if (oOptions && oOptions.url) { |
| 560 | + // overloading use case, create+play: .play('someID',{url:'/path/to.mp3'}); |
| 561 | + _s._wD(fN + 'attempting to create "' + sID + '"', 1); |
| 562 | + oOptions.id = sID; |
| 563 | + return _s.createSound(oOptions).play(); |
| 564 | + } else { |
| 565 | + return false; |
| 566 | + } |
| 567 | + } |
| 568 | + |
| 569 | + return _s.sounds[sID].play(oOptions); |
| 570 | + |
| 571 | + }; |
| 572 | + |
| 573 | + this.start = this.play; // just for convenience |
| 574 | + |
| 575 | + /** |
| 576 | + * Calls the setPosition() method of a SMSound object by ID. |
| 577 | + * |
| 578 | + * @param {string} sID The ID of the sound |
| 579 | + * @param {number} nMsecOffset Position (milliseconds) |
| 580 | + * @return {SMSound} The SMSound object |
| 581 | + */ |
| 582 | + |
| 583 | + this.setPosition = function(sID, nMsecOffset) { |
| 584 | + |
| 585 | + if (!_idCheck(sID)) { |
| 586 | + return false; |
| 587 | + |
| 588 | + } |
| 589 | + return _s.sounds[sID].setPosition(nMsecOffset); |
| 590 | + |
| 591 | + }; |
| 592 | + |
| 593 | + /** |
| 594 | + * Calls the stop() method of a SMSound object by ID. |
| 595 | + * |
| 596 | + * @param {string} sID The ID of the sound |
| 597 | + * @return {SMSound} The SMSound object |
| 598 | + */ |
| 599 | + |
| 600 | + this.stop = function(sID) { |
| 601 | + |
| 602 | + if (!_idCheck(sID)) { |
| 603 | + return false; |
| 604 | + } |
| 605 | + _s._wD(_sm+'.stop(' + sID + ')', 1); |
| 606 | + return _s.sounds[sID].stop(); |
| 607 | + |
| 608 | + }; |
| 609 | + |
| 610 | + /** |
| 611 | + * Stops all currently-playing sounds. |
| 612 | + */ |
| 613 | + |
| 614 | + this.stopAll = function() { |
| 615 | + |
| 616 | + var oSound; |
| 617 | + _s._wD(_sm+'.stopAll()', 1); |
| 618 | + |
| 619 | + for (oSound in _s.sounds) { |
| 620 | + if (_s.sounds.hasOwnProperty(oSound)) { |
| 621 | + // apply only to sound objects |
| 622 | + _s.sounds[oSound].stop(); |
| 623 | + } |
| 624 | + } |
| 625 | + |
| 626 | + }; |
| 627 | + |
| 628 | + /** |
| 629 | + * Calls the pause() method of a SMSound object by ID. |
| 630 | + * |
| 631 | + * @param {string} sID The ID of the sound |
| 632 | + * @return {SMSound} The SMSound object |
| 633 | + */ |
| 634 | + |
| 635 | + this.pause = function(sID) { |
| 636 | + |
| 637 | + if (!_idCheck(sID)) { |
| 638 | + return false; |
| 639 | + } |
| 640 | + return _s.sounds[sID].pause(); |
| 641 | + |
| 642 | + }; |
| 643 | + |
| 644 | + /** |
| 645 | + * Pauses all currently-playing sounds. |
| 646 | + */ |
| 647 | + |
| 648 | + this.pauseAll = function() { |
| 649 | + |
| 650 | + var i; |
| 651 | + for (i = _s.soundIDs.length; i--;) { |
| 652 | + _s.sounds[_s.soundIDs[i]].pause(); |
| 653 | + } |
| 654 | + |
| 655 | + }; |
| 656 | + |
| 657 | + /** |
| 658 | + * Calls the resume() method of a SMSound object by ID. |
| 659 | + * |
| 660 | + * @param {string} sID The ID of the sound |
| 661 | + * @return {SMSound} The SMSound object |
| 662 | + */ |
| 663 | + |
| 664 | + this.resume = function(sID) { |
| 665 | + |
| 666 | + if (!_idCheck(sID)) { |
| 667 | + return false; |
| 668 | + } |
| 669 | + return _s.sounds[sID].resume(); |
| 670 | + |
| 671 | + }; |
| 672 | + |
| 673 | + /** |
| 674 | + * Resumes all currently-paused sounds. |
| 675 | + */ |
| 676 | + |
| 677 | + this.resumeAll = function() { |
| 678 | + |
| 679 | + var i; |
| 680 | + for (i = _s.soundIDs.length; i--;) { |
| 681 | + _s.sounds[_s.soundIDs[i]].resume(); |
| 682 | + } |
| 683 | + |
| 684 | + }; |
| 685 | + |
| 686 | + /** |
| 687 | + * Calls the togglePause() method of a SMSound object by ID. |
| 688 | + * |
| 689 | + * @param {string} sID The ID of the sound |
| 690 | + * @return {SMSound} The SMSound object |
| 691 | + */ |
| 692 | + |
| 693 | + this.togglePause = function(sID) { |
| 694 | + |
| 695 | + if (!_idCheck(sID)) { |
| 696 | + return false; |
| 697 | + } |
| 698 | + return _s.sounds[sID].togglePause(); |
| 699 | + |
| 700 | + }; |
| 701 | + |
| 702 | + /** |
| 703 | + * Calls the setPan() method of a SMSound object by ID. |
| 704 | + * |
| 705 | + * @param {string} sID The ID of the sound |
| 706 | + * @param {number} nPan The pan value (-100 to 100) |
| 707 | + * @return {SMSound} The SMSound object |
| 708 | + */ |
| 709 | + |
| 710 | + this.setPan = function(sID, nPan) { |
| 711 | + |
| 712 | + if (!_idCheck(sID)) { |
| 713 | + return false; |
| 714 | + } |
| 715 | + return _s.sounds[sID].setPan(nPan); |
| 716 | + |
| 717 | + }; |
| 718 | + |
| 719 | + /** |
| 720 | + * Calls the setVolume() method of a SMSound object by ID. |
| 721 | + * |
| 722 | + * @param {string} sID The ID of the sound |
| 723 | + * @param {number} nVol The volume value (0 to 100) |
| 724 | + * @return {SMSound} The SMSound object |
| 725 | + */ |
| 726 | + |
| 727 | + this.setVolume = function(sID, nVol) { |
| 728 | + |
| 729 | + if (!_idCheck(sID)) { |
| 730 | + return false; |
| 731 | + } |
| 732 | + return _s.sounds[sID].setVolume(nVol); |
| 733 | + |
| 734 | + }; |
| 735 | + |
| 736 | + /** |
| 737 | + * Calls the mute() method of either a single SMSound object by ID, or all sound objects. |
| 738 | + * |
| 739 | + * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.) |
| 740 | + */ |
| 741 | + |
| 742 | + this.mute = function(sID) { |
| 743 | + |
| 744 | + var fN = _sm+'.mute(): ', |
| 745 | + i = 0; |
| 746 | + |
| 747 | + if (typeof sID !== 'string') { |
| 748 | + sID = null; |
| 749 | + } |
| 750 | + |
| 751 | + if (!sID) { |
| 752 | + _s._wD(fN + 'Muting all sounds'); |
| 753 | + for (i = _s.soundIDs.length; i--;) { |
| 754 | + _s.sounds[_s.soundIDs[i]].mute(); |
| 755 | + } |
| 756 | + _s.muted = true; |
| 757 | + } else { |
| 758 | + if (!_idCheck(sID)) { |
| 759 | + return false; |
| 760 | + } |
| 761 | + _s._wD(fN + 'Muting "' + sID + '"'); |
| 762 | + return _s.sounds[sID].mute(); |
| 763 | + } |
| 764 | + |
| 765 | + return true; |
| 766 | + |
| 767 | + }; |
| 768 | + |
| 769 | + /** |
| 770 | + * Mutes all sounds. |
| 771 | + */ |
| 772 | + |
| 773 | + this.muteAll = function() { |
| 774 | + |
| 775 | + _s.mute(); |
| 776 | + |
| 777 | + }; |
| 778 | + |
| 779 | + /** |
| 780 | + * Calls the unmute() method of either a single SMSound object by ID, or all sound objects. |
| 781 | + * |
| 782 | + * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.) |
| 783 | + */ |
| 784 | + |
| 785 | + this.unmute = function(sID) { |
| 786 | + |
| 787 | + var fN = _sm+'.unmute(): ', i; |
| 788 | + |
| 789 | + if (typeof sID !== 'string') { |
| 790 | + sID = null; |
| 791 | + } |
| 792 | + |
| 793 | + if (!sID) { |
| 794 | + |
| 795 | + _s._wD(fN + 'Unmuting all sounds'); |
| 796 | + for (i = _s.soundIDs.length; i--;) { |
| 797 | + _s.sounds[_s.soundIDs[i]].unmute(); |
| 798 | + } |
| 799 | + _s.muted = false; |
| 800 | + |
| 801 | + } else { |
| 802 | + |
| 803 | + if (!_idCheck(sID)) { |
| 804 | + return false; |
| 805 | + } |
| 806 | + _s._wD(fN + 'Unmuting "' + sID + '"'); |
| 807 | + return _s.sounds[sID].unmute(); |
| 808 | + |
| 809 | + } |
| 810 | + |
| 811 | + return true; |
| 812 | + |
| 813 | + }; |
| 814 | + |
| 815 | + /** |
| 816 | + * Unmutes all sounds. |
| 817 | + */ |
| 818 | + |
| 819 | + this.unmuteAll = function() { |
| 820 | + |
| 821 | + _s.unmute(); |
| 822 | + |
| 823 | + }; |
| 824 | + |
| 825 | + /** |
| 826 | + * Calls the toggleMute() method of a SMSound object by ID. |
| 827 | + * |
| 828 | + * @param {string} sID The ID of the sound |
| 829 | + * @return {SMSound} The SMSound object |
| 830 | + */ |
| 831 | + |
| 832 | + this.toggleMute = function(sID) { |
| 833 | + |
| 834 | + if (!_idCheck(sID)) { |
| 835 | + return false; |
| 836 | + } |
| 837 | + |
| 838 | + return _s.sounds[sID].toggleMute(); |
| 839 | + |
| 840 | + }; |
| 841 | + |
| 842 | + /** |
| 843 | + * Retrieves the memory used by the flash plugin. |
| 844 | + * |
| 845 | + * @return {number} The amount of memory in use |
| 846 | + */ |
| 847 | + |
| 848 | + this.getMemoryUse = function() { |
| 849 | + |
| 850 | + // flash-only |
| 851 | + var ram = 0; |
| 852 | + |
| 853 | + if (_s.o && _fV !== 8) { |
| 854 | + ram = parseInt(_s.o._getMemoryUse(), 10); |
| 855 | + } |
| 856 | + |
| 857 | + return ram; |
| 858 | + |
| 859 | + }; |
| 860 | + |
| 861 | + /** |
| 862 | + * Undocumented: NOPs soundManager and all SMSound objects. |
| 863 | + */ |
| 864 | + |
| 865 | + this.disable = function(bNoDisable) { |
| 866 | + |
| 867 | + // destroy all functions |
| 868 | + var i; |
| 869 | + |
| 870 | + if (typeof bNoDisable === 'undefined') { |
| 871 | + bNoDisable = false; |
| 872 | + } |
| 873 | + |
| 874 | + if (_disabled) { |
| 875 | + return false; |
| 876 | + } |
| 877 | + |
| 878 | + _disabled = true; |
| 879 | + _wDS('shutdown', 1); |
| 880 | + |
| 881 | + for (i = _s.soundIDs.length; i--;) { |
| 882 | + _disableObject(_s.sounds[_s.soundIDs[i]]); |
| 883 | + } |
| 884 | + |
| 885 | + // fire "complete", despite fail |
| 886 | + _initComplete(bNoDisable); |
| 887 | + _event.remove(_win, 'load', _initUserOnload); |
| 888 | + |
| 889 | + return true; |
| 890 | + |
| 891 | + }; |
| 892 | + |
| 893 | + /** |
| 894 | + * Determines playability of a MIME type, eg. 'audio/mp3'. |
| 895 | + */ |
| 896 | + |
| 897 | + this.canPlayMIME = function(sMIME) { |
| 898 | + |
| 899 | + var result; |
| 900 | + |
| 901 | + if (_s.hasHTML5) { |
| 902 | + result = _html5CanPlay({type:sMIME}); |
| 903 | + } |
| 904 | + |
| 905 | + if (!_needsFlash || result) { |
| 906 | + // no flash, or OK |
| 907 | + return result; |
| 908 | + } else { |
| 909 | + // if flash 9, test netStream (movieStar) types as well. |
| 910 | + return (sMIME ? !!((_fV > 8 ? sMIME.match(_netStreamMimeTypes) : null) || sMIME.match(_s.mimePattern)) : null); |
| 911 | + } |
| 912 | + |
| 913 | + }; |
| 914 | + |
| 915 | + /** |
| 916 | + * Determines playability of a URL based on audio support. |
| 917 | + * |
| 918 | + * @param {string} sURL The URL to test |
| 919 | + * @return {boolean} URL playability |
| 920 | + */ |
| 921 | + |
| 922 | + this.canPlayURL = function(sURL) { |
| 923 | + |
| 924 | + var result; |
| 925 | + |
| 926 | + if (_s.hasHTML5) { |
| 927 | + result = _html5CanPlay({url: sURL}); |
| 928 | + } |
| 929 | + |
| 930 | + if (!_needsFlash || result) { |
| 931 | + // no flash, or OK |
| 932 | + return result; |
| 933 | + } else { |
| 934 | + return (sURL ? !!(sURL.match(_s.filePattern)) : null); |
| 935 | + } |
| 936 | + |
| 937 | + }; |
| 938 | + |
| 939 | + /** |
| 940 | + * Determines playability of an HTML DOM <a> object (or similar object literal) based on audio support. |
| 941 | + * |
| 942 | + * @param {object} oLink an HTML DOM <a> object or object literal including href and/or type attributes |
| 943 | + * @return {boolean} URL playability |
| 944 | + */ |
| 945 | + |
| 946 | + this.canPlayLink = function(oLink) { |
| 947 | + |
| 948 | + if (typeof oLink.type !== 'undefined' && oLink.type) { |
| 949 | + if (_s.canPlayMIME(oLink.type)) { |
| 950 | + return true; |
| 951 | + } |
| 952 | + } |
| 953 | + |
| 954 | + return _s.canPlayURL(oLink.href); |
| 955 | + |
| 956 | + }; |
| 957 | + |
| 958 | + /** |
| 959 | + * Retrieves a SMSound object by ID. |
| 960 | + * |
| 961 | + * @param {string} sID The ID of the sound |
| 962 | + * @return {SMSound} The SMSound object |
| 963 | + */ |
| 964 | + |
| 965 | + this.getSoundById = function(sID, _suppressDebug) { |
| 966 | + |
| 967 | + if (!sID) { |
| 968 | + throw new Error(_sm+'.getSoundById(): sID is null/undefined'); |
| 969 | + } |
| 970 | + |
| 971 | + var result = _s.sounds[sID]; |
| 972 | + |
| 973 | + // <d> |
| 974 | + if (!result && !_suppressDebug) { |
| 975 | + _s._wD('"' + sID + '" is an invalid sound ID.', 2); |
| 976 | + } |
| 977 | + // </d> |
| 978 | + |
| 979 | + return result; |
| 980 | + |
| 981 | + }; |
| 982 | + |
| 983 | + /** |
| 984 | + * Queues a callback for execution when SoundManager has successfully initialized. |
| 985 | + * |
| 986 | + * @param {function} oMethod The callback method to fire |
| 987 | + * @param {object} oScope Optional: The scope to apply to the callback |
| 988 | + */ |
| 989 | + |
| 990 | + this.onready = function(oMethod, oScope) { |
| 991 | + |
| 992 | + var sType = 'onready'; |
| 993 | + |
| 994 | + if (oMethod && oMethod instanceof Function) { |
| 995 | + |
| 996 | + // <d> |
| 997 | + if (_didInit) { |
| 998 | + _s._wD(_str('queue', sType)); |
| 999 | + } |
| 1000 | + // </d> |
| 1001 | + |
| 1002 | + if (!oScope) { |
| 1003 | + oScope = _win; |
| 1004 | + } |
| 1005 | + |
| 1006 | + _addOnEvent(sType, oMethod, oScope); |
| 1007 | + _processOnEvents(); |
| 1008 | + |
| 1009 | + return true; |
| 1010 | + |
| 1011 | + } else { |
| 1012 | + |
| 1013 | + throw _str('needFunction', sType); |
| 1014 | + |
| 1015 | + } |
| 1016 | + |
| 1017 | + }; |
| 1018 | + |
| 1019 | + /** |
| 1020 | + * Queues a callback for execution when SoundManager has failed to initialize. |
| 1021 | + * |
| 1022 | + * @param {function} oMethod The callback method to fire |
| 1023 | + * @param {object} oScope Optional: The scope to apply to the callback |
| 1024 | + */ |
| 1025 | + |
| 1026 | + this.ontimeout = function(oMethod, oScope) { |
| 1027 | + |
| 1028 | + var sType = 'ontimeout'; |
| 1029 | + |
| 1030 | + if (oMethod && oMethod instanceof Function) { |
| 1031 | + |
| 1032 | + // <d> |
| 1033 | + if (_didInit) { |
| 1034 | + _s._wD(_str('queue', sType)); |
| 1035 | + } |
| 1036 | + // </d> |
| 1037 | + |
| 1038 | + if (!oScope) { |
| 1039 | + oScope = _win; |
| 1040 | + } |
| 1041 | + |
| 1042 | + _addOnEvent(sType, oMethod, oScope); |
| 1043 | + _processOnEvents({type:sType}); |
| 1044 | + |
| 1045 | + return true; |
| 1046 | + |
| 1047 | + } else { |
| 1048 | + |
| 1049 | + throw _str('needFunction', sType); |
| 1050 | + |
| 1051 | + } |
| 1052 | + |
| 1053 | + }; |
| 1054 | + |
| 1055 | + /** |
| 1056 | + * Writes console.log()-style debug output to a console or in-browser element. |
| 1057 | + * Applies when SoundManager.debugMode = true |
| 1058 | + * |
| 1059 | + * @param {string} sText The console message |
| 1060 | + * @param {string} sType Optional: Log type of 'info', 'warn' or 'error' |
| 1061 | + * @param {object} Optional: The scope to apply to the callback |
| 1062 | + */ |
| 1063 | + |
| 1064 | + this._writeDebug = function(sText, sType, _bTimestamp) { |
| 1065 | + |
| 1066 | + // pseudo-private console.log()-style output |
| 1067 | + // <d> |
| 1068 | + |
| 1069 | + var sDID = 'soundmanager-debug', o, oItem, sMethod; |
| 1070 | + |
| 1071 | + if (!_s.debugMode) { |
| 1072 | + return false; |
| 1073 | + } |
| 1074 | + |
| 1075 | + if (typeof _bTimestamp !== 'undefined' && _bTimestamp) { |
| 1076 | + sText = sText + ' | ' + new Date().getTime(); |
| 1077 | + } |
| 1078 | + |
| 1079 | + if (_hasConsole && _s.useConsole) { |
| 1080 | + sMethod = _debugLevels[sType]; |
| 1081 | + if (typeof console[sMethod] !== 'undefined') { |
| 1082 | + console[sMethod](sText); |
| 1083 | + } else { |
| 1084 | + console.log(sText); |
| 1085 | + } |
| 1086 | + if (_s.useConsoleOnly) { |
| 1087 | + return true; |
| 1088 | + } |
| 1089 | + } |
| 1090 | + |
| 1091 | + try { |
| 1092 | + |
| 1093 | + o = _id(sDID); |
| 1094 | + |
| 1095 | + if (!o) { |
| 1096 | + return false; |
| 1097 | + } |
| 1098 | + |
| 1099 | + oItem = _doc.createElement('div'); |
| 1100 | + |
| 1101 | + if (++_wdCount % 2 === 0) { |
| 1102 | + oItem.className = 'sm2-alt'; |
| 1103 | + } |
| 1104 | + |
| 1105 | + if (typeof sType === 'undefined') { |
| 1106 | + sType = 0; |
| 1107 | + } else { |
| 1108 | + sType = parseInt(sType, 10); |
| 1109 | + } |
| 1110 | + |
| 1111 | + oItem.appendChild(_doc.createTextNode(sText)); |
| 1112 | + |
| 1113 | + if (sType) { |
| 1114 | + if (sType >= 2) { |
| 1115 | + oItem.style.fontWeight = 'bold'; |
| 1116 | + } |
| 1117 | + if (sType === 3) { |
| 1118 | + oItem.style.color = '#ff3333'; |
| 1119 | + } |
| 1120 | + } |
| 1121 | + |
| 1122 | + // top-to-bottom |
| 1123 | + // o.appendChild(oItem); |
| 1124 | + |
| 1125 | + // bottom-to-top |
| 1126 | + o.insertBefore(oItem, o.firstChild); |
| 1127 | + |
| 1128 | + } catch(e) { |
| 1129 | + // oh well |
| 1130 | + } |
| 1131 | + |
| 1132 | + o = null; |
| 1133 | + // </d> |
| 1134 | + |
| 1135 | + return true; |
| 1136 | + |
| 1137 | + }; |
| 1138 | + |
| 1139 | + // alias |
| 1140 | + this._wD = this._writeDebug; |
| 1141 | + |
| 1142 | + /** |
| 1143 | + * Provides debug / state information on all SMSound objects. |
| 1144 | + */ |
| 1145 | + |
| 1146 | + this._debug = function() { |
| 1147 | + |
| 1148 | + // <d> |
| 1149 | + var i, j; |
| 1150 | + _wDS('currentObj', 1); |
| 1151 | + |
| 1152 | + for (i = 0, j = _s.soundIDs.length; i < j; i++) { |
| 1153 | + _s.sounds[_s.soundIDs[i]]._debug(); |
| 1154 | + } |
| 1155 | + // </d> |
| 1156 | + |
| 1157 | + }; |
| 1158 | + |
| 1159 | + /** |
| 1160 | + * Restarts and re-initializes the SoundManager instance. |
| 1161 | + */ |
| 1162 | + |
| 1163 | + this.reboot = function() { |
| 1164 | + |
| 1165 | + // attempt to reset and init SM2 |
| 1166 | + _s._wD(_sm+'.reboot()'); |
| 1167 | + |
| 1168 | + // <d> |
| 1169 | + if (_s.soundIDs.length) { |
| 1170 | + _s._wD('Destroying ' + _s.soundIDs.length + ' SMSound objects...'); |
| 1171 | + } |
| 1172 | + // </d> |
| 1173 | + |
| 1174 | + var i, j; |
| 1175 | + |
| 1176 | + for (i = _s.soundIDs.length; i--;) { |
| 1177 | + _s.sounds[_s.soundIDs[i]].destruct(); |
| 1178 | + } |
| 1179 | + |
| 1180 | + // trash ze flash |
| 1181 | + |
| 1182 | + try { |
| 1183 | + if (_isIE) { |
| 1184 | + _oRemovedHTML = _s.o.innerHTML; |
| 1185 | + } |
| 1186 | + _oRemoved = _s.o.parentNode.removeChild(_s.o); |
| 1187 | + _s._wD('Flash movie removed.'); |
| 1188 | + } catch(e) { |
| 1189 | + // uh-oh. |
| 1190 | + _wDS('badRemove', 2); |
| 1191 | + } |
| 1192 | + |
| 1193 | + // actually, force recreate of movie. |
| 1194 | + _oRemovedHTML = _oRemoved = _needsFlash = null; |
| 1195 | + |
| 1196 | + _s.enabled = _didDCLoaded = _didInit = _waitingForEI = _initPending = _didAppend = _appendSuccess = _disabled = _s.swfLoaded = false; |
| 1197 | + _s.soundIDs = _s.sounds = []; |
| 1198 | + _s.o = null; |
| 1199 | + |
| 1200 | + for (i in _on_queue) { |
| 1201 | + if (_on_queue.hasOwnProperty(i)) { |
| 1202 | + for (j = _on_queue[i].length; j--;) { |
| 1203 | + _on_queue[i][j].fired = false; |
| 1204 | + } |
| 1205 | + } |
| 1206 | + } |
| 1207 | + |
| 1208 | + _s._wD(_sm + ': Rebooting...'); |
| 1209 | + _win.setTimeout(_s.beginDelayedInit, 20); |
| 1210 | + |
| 1211 | + }; |
| 1212 | + |
| 1213 | + /** |
| 1214 | + * Undocumented: Determines the SM2 flash movie's load progress. |
| 1215 | + * |
| 1216 | + * @return {number or null} Percent loaded, or if invalid/unsupported, null. |
| 1217 | + */ |
| 1218 | + |
| 1219 | + this.getMoviePercent = function() { |
| 1220 | + |
| 1221 | + return (_s.o && typeof _s.o.PercentLoaded !== 'undefined' ? _s.o.PercentLoaded() : null); |
| 1222 | + |
| 1223 | + }; |
| 1224 | + |
| 1225 | + /** |
| 1226 | + * Additional helper for manually invoking SM2's init process after DOM Ready / window.onload(). |
| 1227 | + */ |
| 1228 | + |
| 1229 | + this.beginDelayedInit = function() { |
| 1230 | + |
| 1231 | + _windowLoaded = true; |
| 1232 | + _domContentLoaded(); |
| 1233 | + |
| 1234 | + setTimeout(function() { |
| 1235 | + |
| 1236 | + if (_initPending) { |
| 1237 | + return false; |
| 1238 | + } |
| 1239 | + |
| 1240 | + _createMovie(); |
| 1241 | + _initMovie(); |
| 1242 | + _initPending = true; |
| 1243 | + |
| 1244 | + return true; |
| 1245 | + |
| 1246 | + }, 20); |
| 1247 | + |
| 1248 | + _delayWaitForEI(); |
| 1249 | + |
| 1250 | + }; |
| 1251 | + |
| 1252 | + /** |
| 1253 | + * Destroys the SoundManager instance and all SMSound instances. |
| 1254 | + */ |
| 1255 | + |
| 1256 | + this.destruct = function() { |
| 1257 | + |
| 1258 | + _s._wD(_sm+'.destruct()'); |
| 1259 | + _s.disable(true); |
| 1260 | + |
| 1261 | + }; |
| 1262 | + |
| 1263 | + /** |
| 1264 | + * SMSound() (sound object) constructor |
| 1265 | + * ------------------------------------ |
| 1266 | + * |
| 1267 | + * @param {object} oOptions Sound options (id and url are required attributes) |
| 1268 | + * @return {SMSound} The new SMSound object |
| 1269 | + */ |
| 1270 | + |
| 1271 | + SMSound = function(oOptions) { |
| 1272 | + |
| 1273 | + var _t = this, _resetProperties, _stop_html5_timer, _start_html5_timer; |
| 1274 | + this.sID = oOptions.id; |
| 1275 | + this.url = oOptions.url; |
| 1276 | + this.options = _mixin(oOptions); |
| 1277 | + |
| 1278 | + // per-play-instance-specific options |
| 1279 | + this.instanceOptions = this.options; |
| 1280 | + |
| 1281 | + // short alias |
| 1282 | + this._iO = this.instanceOptions; |
| 1283 | + |
| 1284 | + // assign property defaults |
| 1285 | + this.pan = this.options.pan; |
| 1286 | + this.volume = this.options.volume; |
| 1287 | + this._lastURL = null; |
| 1288 | + this.isHTML5 = false; |
| 1289 | + this._a = null; |
| 1290 | + |
| 1291 | + /** |
| 1292 | + * SMSound() public methods |
| 1293 | + * ------------------------ |
| 1294 | + */ |
| 1295 | + |
| 1296 | + this.id3 = {}; |
| 1297 | + |
| 1298 | + /** |
| 1299 | + * Writes SMSound object parameters to debug console |
| 1300 | + */ |
| 1301 | + |
| 1302 | + this._debug = function() { |
| 1303 | + |
| 1304 | + // <d> |
| 1305 | + // pseudo-private console.log()-style output |
| 1306 | + |
| 1307 | + if (_s.debugMode) { |
| 1308 | + |
| 1309 | + var stuff = null, msg = [], sF, sfBracket, maxLength = 64; |
| 1310 | + |
| 1311 | + for (stuff in _t.options) { |
| 1312 | + if (_t.options[stuff] !== null) { |
| 1313 | + if (_t.options[stuff] instanceof Function) { |
| 1314 | + // handle functions specially |
| 1315 | + sF = _t.options[stuff].toString(); |
| 1316 | + // normalize spaces |
| 1317 | + sF = sF.replace(/\s\s+/g, ' '); |
| 1318 | + sfBracket = sF.indexOf('{'); |
| 1319 | + msg.push(' ' + stuff + ': {' + sF.substr(sfBracket + 1, (Math.min(Math.max(sF.indexOf('\n') - 1, maxLength), maxLength))).replace(/\n/g, '') + '... }'); |
| 1320 | + } else { |
| 1321 | + msg.push(' ' + stuff + ': ' + _t.options[stuff]); |
| 1322 | + } |
| 1323 | + } |
| 1324 | + } |
| 1325 | + |
| 1326 | + _s._wD('SMSound() merged options: {\n' + msg.join(', \n') + '\n}'); |
| 1327 | + |
| 1328 | + } |
| 1329 | + // </d> |
| 1330 | + |
| 1331 | + }; |
| 1332 | + |
| 1333 | + // <d> |
| 1334 | + this._debug(); |
| 1335 | + // </d> |
| 1336 | + |
| 1337 | + /** |
| 1338 | + * Begins loading a sound per its *url*. |
| 1339 | + * |
| 1340 | + * @param {object} oOptions Optional: Sound options |
| 1341 | + * @return {SMSound} The SMSound object |
| 1342 | + */ |
| 1343 | + |
| 1344 | + this.load = function(oOptions) { |
| 1345 | + |
| 1346 | + var oS = null; |
| 1347 | + |
| 1348 | + if (typeof oOptions !== 'undefined') { |
| 1349 | + _t._iO = _mixin(oOptions, _t.options); |
| 1350 | + _t.instanceOptions = _t._iO; |
| 1351 | + } else { |
| 1352 | + oOptions = _t.options; |
| 1353 | + _t._iO = oOptions; |
| 1354 | + _t.instanceOptions = _t._iO; |
| 1355 | + if (_t._lastURL && _t._lastURL !== _t.url) { |
| 1356 | + _wDS('manURL'); |
| 1357 | + _t._iO.url = _t.url; |
| 1358 | + _t.url = null; |
| 1359 | + } |
| 1360 | + } |
| 1361 | + |
| 1362 | + if (!_t._iO.url) { |
| 1363 | + _t._iO.url = _t.url; |
| 1364 | + } |
| 1365 | + |
| 1366 | + _s._wD('SMSound.load(): ' + _t._iO.url, 1); |
| 1367 | + |
| 1368 | + if (_t._iO.url === _t.url && _t.readyState !== 0 && _t.readyState !== 2) { |
| 1369 | + _wDS('onURL', 1); |
| 1370 | + return _t; |
| 1371 | + } |
| 1372 | + |
| 1373 | + _t._lastURL = _t.url; |
| 1374 | + _t.loaded = false; |
| 1375 | + _t.readyState = 1; |
| 1376 | + _t.playState = 0; |
| 1377 | + |
| 1378 | + // TODO: If switching from HTML5 -> flash (or vice versa), stop currently-playing audio. |
| 1379 | + |
| 1380 | + if (_html5OK(_t._iO)) { |
| 1381 | + |
| 1382 | + oS = _t._setup_html5(_t._iO); |
| 1383 | + if (!oS._called_load) { |
| 1384 | + _s._wD(_h5+'load: '+_t.sID); |
| 1385 | + _t._html5_canplay = false; |
| 1386 | + oS.load(); |
| 1387 | + oS._called_load = true; |
| 1388 | + if (_t._iO.autoPlay) { |
| 1389 | + _t.play(); |
| 1390 | + } |
| 1391 | + } else { |
| 1392 | + _s._wD(_h5+'ignoring request to load again: '+_t.sID); |
| 1393 | + } |
| 1394 | + |
| 1395 | + } else { |
| 1396 | + |
| 1397 | + try { |
| 1398 | + _t.isHTML5 = false; |
| 1399 | + _t._iO = _policyFix(_loopFix(_t._iO)); |
| 1400 | + if (_fV === 8) { |
| 1401 | + _s.o._load(_t.sID, _t._iO.url, _t._iO.stream, _t._iO.autoPlay, (_t._iO.whileloading?1:0), _t._iO.loops||1, _t._iO.usePolicyFile); |
| 1402 | + } else { |
| 1403 | + _s.o._load(_t.sID, _t._iO.url, !!(_t._iO.stream), !!(_t._iO.autoPlay), _t._iO.loops||1, !!(_t._iO.autoLoad), _t._iO.usePolicyFile); |
| 1404 | + } |
| 1405 | + } catch(e) { |
| 1406 | + _wDS('smError', 2); |
| 1407 | + _debugTS('onload', false); |
| 1408 | + _catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true}); |
| 1409 | + |
| 1410 | + } |
| 1411 | + |
| 1412 | + } |
| 1413 | + |
| 1414 | + return _t; |
| 1415 | + |
| 1416 | + }; |
| 1417 | + |
| 1418 | + /** |
| 1419 | + * Unloads a sound, canceling any open HTTP requests. |
| 1420 | + * |
| 1421 | + * @return {SMSound} The SMSound object |
| 1422 | + */ |
| 1423 | + |
| 1424 | + this.unload = function() { |
| 1425 | + |
| 1426 | + // Flash 8/AS2 can't "close" a stream - fake it by loading an empty URL |
| 1427 | + // Flash 9/AS3: Close stream, preventing further load |
| 1428 | + // HTML5: Most UAs will use empty URL |
| 1429 | + |
| 1430 | + if (_t.readyState !== 0) { |
| 1431 | + |
| 1432 | + _s._wD('SMSound.unload(): "' + _t.sID + '"'); |
| 1433 | + |
| 1434 | + if (!_t.isHTML5) { |
| 1435 | + if (_fV === 8) { |
| 1436 | + _s.o._unload(_t.sID, _emptyURL); |
| 1437 | + } else { |
| 1438 | + _s.o._unload(_t.sID); |
| 1439 | + } |
| 1440 | + } else { |
| 1441 | + _stop_html5_timer(); |
| 1442 | + if (_t._a) { |
| 1443 | + _t._a.pause(); |
| 1444 | + _html5Unload(_t._a); |
| 1445 | + } |
| 1446 | + } |
| 1447 | + |
| 1448 | + // reset load/status flags |
| 1449 | + _resetProperties(); |
| 1450 | + |
| 1451 | + } |
| 1452 | + |
| 1453 | + return _t; |
| 1454 | + |
| 1455 | + }; |
| 1456 | + |
| 1457 | + /** |
| 1458 | + * Unloads and destroys a sound. |
| 1459 | + */ |
| 1460 | + |
| 1461 | + this.destruct = function(_bFromSM) { |
| 1462 | + |
| 1463 | + _s._wD('SMSound.destruct(): "' + _t.sID + '"'); |
| 1464 | + |
| 1465 | + if (!_t.isHTML5) { |
| 1466 | + |
| 1467 | + // kill sound within Flash |
| 1468 | + // Disable the onfailure handler |
| 1469 | + _t._iO.onfailure = null; |
| 1470 | + _s.o._destroySound(_t.sID); |
| 1471 | + |
| 1472 | + } else { |
| 1473 | + |
| 1474 | + _stop_html5_timer(); |
| 1475 | + |
| 1476 | + if (_t._a) { |
| 1477 | + _t._a.pause(); |
| 1478 | + _html5Unload(_t._a); |
| 1479 | + if (!_useGlobalHTML5Audio) { |
| 1480 | + _t._remove_html5_events(); |
| 1481 | + } |
| 1482 | + // break obvious circular reference |
| 1483 | + _t._a._t = null; |
| 1484 | + _t._a = null; |
| 1485 | + } |
| 1486 | + |
| 1487 | + } |
| 1488 | + |
| 1489 | + if (!_bFromSM) { |
| 1490 | + // ensure deletion from controller |
| 1491 | + _s.destroySound(_t.sID, true); |
| 1492 | + |
| 1493 | + } |
| 1494 | + |
| 1495 | + }; |
| 1496 | + |
| 1497 | + /** |
| 1498 | + * Begins playing a sound. |
| 1499 | + * |
| 1500 | + * @param {object} oOptions Optional: Sound options |
| 1501 | + * @return {SMSound} The SMSound object |
| 1502 | + */ |
| 1503 | + |
| 1504 | + this.play = function(oOptions, _updatePlayState) { |
| 1505 | + |
| 1506 | + var fN = 'SMSound.play(): ', allowMulti, a; |
| 1507 | + |
| 1508 | + _updatePlayState = _updatePlayState === undefined ? true : _updatePlayState; // default to true |
| 1509 | + |
| 1510 | + if (!oOptions) { |
| 1511 | + oOptions = {}; |
| 1512 | + } |
| 1513 | + |
| 1514 | + _t._iO = _mixin(oOptions, _t._iO); |
| 1515 | + _t._iO = _mixin(_t._iO, _t.options); |
| 1516 | + _t.instanceOptions = _t._iO; |
| 1517 | + |
| 1518 | + // RTMP-only |
| 1519 | + if (_t._iO.serverURL && !_t.connected) { |
| 1520 | + if (!_t.getAutoPlay()) { |
| 1521 | + _s._wD(fN+' Netstream not connected yet - setting autoPlay'); |
| 1522 | + _t.setAutoPlay(true); |
| 1523 | + } |
| 1524 | + // play will be called in _onconnect() |
| 1525 | + return _t; |
| 1526 | + } |
| 1527 | + |
| 1528 | + if (_html5OK(_t._iO)) { |
| 1529 | + _t._setup_html5(_t._iO); |
| 1530 | + _start_html5_timer(); |
| 1531 | + } |
| 1532 | + |
| 1533 | + if (_t.playState === 1 && !_t.paused) { |
| 1534 | + allowMulti = _t._iO.multiShot; |
| 1535 | + if (!allowMulti) { |
| 1536 | + _s._wD(fN + '"' + _t.sID + '" already playing (one-shot)', 1); |
| 1537 | + return _t; |
| 1538 | + } else { |
| 1539 | + _s._wD(fN + '"' + _t.sID + '" already playing (multi-shot)', 1); |
| 1540 | + } |
| 1541 | + } |
| 1542 | + |
| 1543 | + if (!_t.loaded) { |
| 1544 | + |
| 1545 | + if (_t.readyState === 0) { |
| 1546 | + |
| 1547 | + _s._wD(fN + 'Attempting to load "' + _t.sID + '"', 1); |
| 1548 | + // try to get this sound playing ASAP |
| 1549 | + if (!_t.isHTML5) { |
| 1550 | + // assign directly because setAutoPlay() increments the instanceCount |
| 1551 | + _t._iO.autoPlay = true; |
| 1552 | + } |
| 1553 | + _t.load(_t._iO); |
| 1554 | + |
| 1555 | + } else if (_t.readyState === 2) { |
| 1556 | + |
| 1557 | + _s._wD(fN + 'Could not load "' + _t.sID + '" - exiting', 2); |
| 1558 | + return _t; |
| 1559 | + |
| 1560 | + } else { |
| 1561 | + |
| 1562 | + _s._wD(fN + '"' + _t.sID + '" is loading - attempting to play..', 1); |
| 1563 | + |
| 1564 | + } |
| 1565 | + |
| 1566 | + } else { |
| 1567 | + |
| 1568 | + _s._wD(fN + '"' + _t.sID + '"'); |
| 1569 | + |
| 1570 | + } |
| 1571 | + |
| 1572 | + if (!_t.isHTML5 && _fV === 9 && _t.position > 0 && _t.position === _t.duration) { |
| 1573 | + // flash 9 needs a position reset if play() is called while at the end of a sound. |
| 1574 | + _s._wD(fN + '"' + _t.sID + '": Sound at end, resetting to position:0'); |
| 1575 | + _t._iO.position = 0; |
| 1576 | + } |
| 1577 | + |
| 1578 | + /** |
| 1579 | + * Streams will pause when their buffer is full if they are being loaded. |
| 1580 | + * In this case paused is true, but the song hasn't started playing yet. |
| 1581 | + * If we just call resume() the onplay() callback will never be called. |
| 1582 | + * So only call resume() if the position is > 0. |
| 1583 | + * Another reason is because options like volume won't have been applied yet. |
| 1584 | + */ |
| 1585 | + |
| 1586 | + if (_t.paused && _t.position && _t.position > 0) { |
| 1587 | + |
| 1588 | + // https://gist.github.com/37b17df75cc4d7a90bf6 |
| 1589 | + _s._wD(fN + '"' + _t.sID + '" is resuming from paused state',1); |
| 1590 | + _t.resume(); |
| 1591 | + |
| 1592 | + } else { |
| 1593 | + |
| 1594 | + _s._wD(fN+'"'+ _t.sID+'" is starting to play'); |
| 1595 | + _t.playState = 1; |
| 1596 | + _t.paused = false; |
| 1597 | + |
| 1598 | + if (!_t.instanceCount || _t._iO.multiShotEvents || (!_t.isHTML5 && _fV > 8 && !_t.getAutoPlay())) { |
| 1599 | + _t.instanceCount++; |
| 1600 | + } |
| 1601 | + |
| 1602 | + _t.position = (typeof _t._iO.position !== 'undefined' && !isNaN(_t._iO.position)?_t._iO.position:0); |
| 1603 | + |
| 1604 | + if (!_t.isHTML5) { |
| 1605 | + _t._iO = _policyFix(_loopFix(_t._iO)); |
| 1606 | + } |
| 1607 | + |
| 1608 | + if (_t._iO.onplay && _updatePlayState) { |
| 1609 | + _t._iO.onplay.apply(_t); |
| 1610 | + _t._onplay_called = true; |
| 1611 | + } |
| 1612 | + |
| 1613 | + _t.setVolume(_t._iO.volume, true); |
| 1614 | + _t.setPan(_t._iO.pan, true); |
| 1615 | + |
| 1616 | + if (!_t.isHTML5) { |
| 1617 | + _s.o._start(_t.sID, _t._iO.loops || 1, (_fV === 9?_t._iO.position:_t._iO.position / 1000)); |
| 1618 | + } else { |
| 1619 | + _start_html5_timer(); |
| 1620 | + a = _t._setup_html5(); |
| 1621 | + _t.setPosition(_t._iO.position); |
| 1622 | + a.play(); |
| 1623 | + } |
| 1624 | + |
| 1625 | + } |
| 1626 | + |
| 1627 | + return _t; |
| 1628 | + |
| 1629 | + }; |
| 1630 | + |
| 1631 | + // just for convenience |
| 1632 | + this.start = this.play; |
| 1633 | + |
| 1634 | + /** |
| 1635 | + * Stops playing a sound (and optionally, all sounds) |
| 1636 | + * |
| 1637 | + * @param {boolean} bAll Optional: Whether to stop all sounds |
| 1638 | + * @return {SMSound} The SMSound object |
| 1639 | + */ |
| 1640 | + |
| 1641 | + this.stop = function(bAll) { |
| 1642 | + |
| 1643 | + if (_t.playState === 1) { |
| 1644 | + |
| 1645 | + _t._onbufferchange(0); |
| 1646 | + _t.resetOnPosition(0); |
| 1647 | + _t.paused = false; |
| 1648 | + |
| 1649 | + if (!_t.isHTML5) { |
| 1650 | + _t.playState = 0; |
| 1651 | + } |
| 1652 | + |
| 1653 | + if (_t._iO.onstop) { |
| 1654 | + _t._iO.onstop.apply(_t); |
| 1655 | + } |
| 1656 | + |
| 1657 | + if (!_t.isHTML5) { |
| 1658 | + |
| 1659 | + _s.o._stop(_t.sID, bAll); |
| 1660 | + // hack for netStream: just unload |
| 1661 | + if (_t._iO.serverURL) { |
| 1662 | + _t.unload(); |
| 1663 | + } |
| 1664 | + |
| 1665 | + } else { |
| 1666 | + |
| 1667 | + if (_t._a) { |
| 1668 | + |
| 1669 | + // act like Flash, though |
| 1670 | + _t.setPosition(0); |
| 1671 | + |
| 1672 | + // html5 has no stop() |
| 1673 | + _t._a.pause(); |
| 1674 | + |
| 1675 | + _t.playState = 0; |
| 1676 | + |
| 1677 | + // and update UI |
| 1678 | + _t._onTimer(); |
| 1679 | + |
| 1680 | + _stop_html5_timer(); |
| 1681 | + |
| 1682 | + } |
| 1683 | + |
| 1684 | + } |
| 1685 | + |
| 1686 | + _t.instanceCount = 0; |
| 1687 | + _t._iO = {}; |
| 1688 | + |
| 1689 | + } |
| 1690 | + |
| 1691 | + return _t; |
| 1692 | + |
| 1693 | + }; |
| 1694 | + |
| 1695 | + /** |
| 1696 | + * Undocumented/internal: Sets autoPlay for RTMP. |
| 1697 | + * |
| 1698 | + * @param {boolean} autoPlay state |
| 1699 | + */ |
| 1700 | + |
| 1701 | + this.setAutoPlay = function(autoPlay) { |
| 1702 | + |
| 1703 | + _s._wD('sound '+_t.sID+' turned autoplay ' + (autoPlay ? 'on' : 'off')); |
| 1704 | + _t._iO.autoPlay = autoPlay; |
| 1705 | + |
| 1706 | + if (!_t.isHTML5) { |
| 1707 | + _s.o._setAutoPlay(_t.sID, autoPlay); |
| 1708 | + if (autoPlay) { |
| 1709 | + // only increment the instanceCount if the sound isn't loaded (TODO: verify RTMP) |
| 1710 | + if (!_t.instanceCount && _t.readyState === 1) { |
| 1711 | + _t.instanceCount++; |
| 1712 | + _s._wD('sound '+_t.sID+' incremented instance count to '+_t.instanceCount); |
| 1713 | + } |
| 1714 | + } |
| 1715 | + } |
| 1716 | + |
| 1717 | + }; |
| 1718 | + |
| 1719 | + /** |
| 1720 | + * Undocumented/internal: Returns the autoPlay boolean. |
| 1721 | + * |
| 1722 | + * @return {boolean} The current autoPlay value |
| 1723 | + */ |
| 1724 | + |
| 1725 | + this.getAutoPlay = function() { |
| 1726 | + |
| 1727 | + return _t._iO.autoPlay; |
| 1728 | + |
| 1729 | + }; |
| 1730 | + |
| 1731 | + /** |
| 1732 | + * Sets the position of a sound. |
| 1733 | + * |
| 1734 | + * @param {number} nMsecOffset Position (milliseconds) |
| 1735 | + * @return {SMSound} The SMSound object |
| 1736 | + */ |
| 1737 | + |
| 1738 | + this.setPosition = function(nMsecOffset) { |
| 1739 | + |
| 1740 | + if (nMsecOffset === undefined) { |
| 1741 | + nMsecOffset = 0; |
| 1742 | + } |
| 1743 | + |
| 1744 | + var original_pos, |
| 1745 | + position, position1K, |
| 1746 | + // Use the duration from the instance options, if we don't have a track duration yet. |
| 1747 | + // position >= 0 and <= current available (loaded) duration |
| 1748 | + offset = (_t.isHTML5 ? Math.max(nMsecOffset,0) : Math.min(_t.duration || _t._iO.duration, Math.max(nMsecOffset, 0))); |
| 1749 | + |
| 1750 | + original_pos = _t.position; |
| 1751 | + _t.position = offset; |
| 1752 | + position1K = _t.position/1000; |
| 1753 | + _t.resetOnPosition(_t.position); |
| 1754 | + _t._iO.position = offset; |
| 1755 | + |
| 1756 | + if (!_t.isHTML5) { |
| 1757 | + |
| 1758 | + position = (_fV === 9 ? _t.position : position1K); |
| 1759 | + if (_t.readyState && _t.readyState !== 2) { |
| 1760 | + // if paused or not playing, will not resume (by playing) |
| 1761 | + _s.o._setPosition(_t.sID, position, (_t.paused || !_t.playState)); |
| 1762 | + } |
| 1763 | + |
| 1764 | + } else if (_t._a) { |
| 1765 | + |
| 1766 | + // Set the position in the canplay handler if the sound is not ready yet |
| 1767 | + if (_t._html5_canplay) { |
| 1768 | + if (_t._a.currentTime !== position1K) { |
| 1769 | + /* |
| 1770 | + * DOM/JS errors/exceptions to watch out for: |
| 1771 | + * if seek is beyond (loaded?) position, "DOM exception 11" |
| 1772 | + * "INDEX_SIZE_ERR": DOM exception 1 |
| 1773 | + */ |
| 1774 | + _s._wD('setPosition('+position1K+'): setting position'); |
| 1775 | + try { |
| 1776 | + _t._a.currentTime = position1K; |
| 1777 | + if (_t.playState === 0 || _t.paused) { |
| 1778 | + // allow seek without auto-play/resume |
| 1779 | + _t._a.pause(); |
| 1780 | + } |
| 1781 | + } catch(e) { |
| 1782 | + _s._wD('setPosition('+position1K+'): setting position failed: '+e.message, 2); |
| 1783 | + } |
| 1784 | + } |
| 1785 | + } else { |
| 1786 | + _s._wD('setPosition('+position1K+'): delaying, sound not ready'); |
| 1787 | + } |
| 1788 | + |
| 1789 | + } |
| 1790 | + |
| 1791 | + if (_t.isHTML5) { |
| 1792 | + if (_t.paused) { |
| 1793 | + // if paused, refresh UI right away |
| 1794 | + // force update |
| 1795 | + _t._onTimer(true); |
| 1796 | + } |
| 1797 | + } |
| 1798 | + |
| 1799 | + return _t; |
| 1800 | + |
| 1801 | + }; |
| 1802 | + |
| 1803 | + /** |
| 1804 | + * Pauses sound playback. |
| 1805 | + * |
| 1806 | + * @return {SMSound} The SMSound object |
| 1807 | + */ |
| 1808 | + |
| 1809 | + this.pause = function(_bCallFlash) { |
| 1810 | + |
| 1811 | + if (_t.paused || (_t.playState === 0 && _t.readyState !== 1)) { |
| 1812 | + return _t; |
| 1813 | + } |
| 1814 | + |
| 1815 | + _s._wD('SMSound.pause()'); |
| 1816 | + _t.paused = true; |
| 1817 | + |
| 1818 | + if (!_t.isHTML5) { |
| 1819 | + if (_bCallFlash || _bCallFlash === undefined) { |
| 1820 | + _s.o._pause(_t.sID); |
| 1821 | + } |
| 1822 | + } else { |
| 1823 | + _t._setup_html5().pause(); |
| 1824 | + _stop_html5_timer(); |
| 1825 | + } |
| 1826 | + |
| 1827 | + if (_t._iO.onpause) { |
| 1828 | + _t._iO.onpause.apply(_t); |
| 1829 | + } |
| 1830 | + |
| 1831 | + return _t; |
| 1832 | + |
| 1833 | + }; |
| 1834 | + |
| 1835 | + /** |
| 1836 | + * Resumes sound playback. |
| 1837 | + * |
| 1838 | + * @return {SMSound} The SMSound object |
| 1839 | + */ |
| 1840 | + |
| 1841 | + /** |
| 1842 | + * When auto-loaded streams pause on buffer full they have a playState of 0. |
| 1843 | + * We need to make sure that the playState is set to 1 when these streams "resume". |
| 1844 | + * When a paused stream is resumed, we need to trigger the onplay() callback if it |
| 1845 | + * hasn't been called already. In this case since the sound is being played for the |
| 1846 | + * first time, I think it's more appropriate to call onplay() rather than onresume(). |
| 1847 | + */ |
| 1848 | + |
| 1849 | + this.resume = function() { |
| 1850 | + |
| 1851 | + if (!_t.paused) { |
| 1852 | + return _t; |
| 1853 | + } |
| 1854 | + |
| 1855 | + _s._wD('SMSound.resume()'); |
| 1856 | + _t.paused = false; |
| 1857 | + _t.playState = 1; |
| 1858 | + |
| 1859 | + if (!_t.isHTML5) { |
| 1860 | + if (_t._iO.isMovieStar) { |
| 1861 | + // Bizarre Webkit bug (Chrome reported via 8tracks.com dudes): AAC content paused for 30+ seconds(?) will not resume without a reposition. |
| 1862 | + _t.setPosition(_t.position); |
| 1863 | + } |
| 1864 | + // flash method is toggle-based (pause/resume) |
| 1865 | + _s.o._pause(_t.sID); |
| 1866 | + } else { |
| 1867 | + _t._setup_html5().play(); |
| 1868 | + _start_html5_timer(); |
| 1869 | + } |
| 1870 | + |
| 1871 | + if (!_t._onplay_called && _t._iO.onplay) { |
| 1872 | + _t._iO.onplay.apply(_t); |
| 1873 | + _t._onplay_called = true; |
| 1874 | + } else if (_t._iO.onresume) { |
| 1875 | + _t._iO.onresume.apply(_t); |
| 1876 | + } |
| 1877 | + |
| 1878 | + return _t; |
| 1879 | + |
| 1880 | + }; |
| 1881 | + |
| 1882 | + /** |
| 1883 | + * Toggles sound playback. |
| 1884 | + * |
| 1885 | + * @return {SMSound} The SMSound object |
| 1886 | + */ |
| 1887 | + |
| 1888 | + this.togglePause = function() { |
| 1889 | + |
| 1890 | + _s._wD('SMSound.togglePause()'); |
| 1891 | + |
| 1892 | + if (_t.playState === 0) { |
| 1893 | + _t.play({ |
| 1894 | + position: (_fV === 9 && !_t.isHTML5 ? _t.position : _t.position / 1000) |
| 1895 | + }); |
| 1896 | + return _t; |
| 1897 | + } |
| 1898 | + |
| 1899 | + if (_t.paused) { |
| 1900 | + _t.resume(); |
| 1901 | + } else { |
| 1902 | + _t.pause(); |
| 1903 | + } |
| 1904 | + |
| 1905 | + return _t; |
| 1906 | + |
| 1907 | + }; |
| 1908 | + |
| 1909 | + /** |
| 1910 | + * Sets the panning (L-R) effect. |
| 1911 | + * |
| 1912 | + * @param {number} nPan The pan value (-100 to 100) |
| 1913 | + * @return {SMSound} The SMSound object |
| 1914 | + */ |
| 1915 | + |
| 1916 | + this.setPan = function(nPan, bInstanceOnly) { |
| 1917 | + |
| 1918 | + if (typeof nPan === 'undefined') { |
| 1919 | + nPan = 0; |
| 1920 | + } |
| 1921 | + |
| 1922 | + if (typeof bInstanceOnly === 'undefined') { |
| 1923 | + bInstanceOnly = false; |
| 1924 | + } |
| 1925 | + |
| 1926 | + if (!_t.isHTML5) { |
| 1927 | + _s.o._setPan(_t.sID, nPan); |
| 1928 | + } // else { no HTML5 pan? } |
| 1929 | + |
| 1930 | + _t._iO.pan = nPan; |
| 1931 | + |
| 1932 | + if (!bInstanceOnly) { |
| 1933 | + _t.pan = nPan; |
| 1934 | + _t.options.pan = nPan; |
| 1935 | + } |
| 1936 | + |
| 1937 | + return _t; |
| 1938 | + |
| 1939 | + }; |
| 1940 | + |
| 1941 | + /** |
| 1942 | + * Sets the volume. |
| 1943 | + * |
| 1944 | + * @param {number} nVol The volume value (0 to 100) |
| 1945 | + * @return {SMSound} The SMSound object |
| 1946 | + */ |
| 1947 | + |
| 1948 | + this.setVolume = function(nVol, _bInstanceOnly) { |
| 1949 | + |
| 1950 | + if (typeof nVol === 'undefined') { |
| 1951 | + nVol = 100; |
| 1952 | + } |
| 1953 | + |
| 1954 | + if (typeof _bInstanceOnly === 'undefined') { |
| 1955 | + _bInstanceOnly = false; |
| 1956 | + } |
| 1957 | + |
| 1958 | + if (!_t.isHTML5) { |
| 1959 | + _s.o._setVolume(_t.sID, (_s.muted && !_t.muted) || _t.muted?0:nVol); |
| 1960 | + } else if (_t._a) { |
| 1961 | + _t._a.volume = Math.max(0, Math.min(1, nVol/100)); // valid range: 0-1 |
| 1962 | + } |
| 1963 | + |
| 1964 | + _t._iO.volume = nVol; |
| 1965 | + |
| 1966 | + if (!_bInstanceOnly) { |
| 1967 | + _t.volume = nVol; |
| 1968 | + _t.options.volume = nVol; |
| 1969 | + } |
| 1970 | + |
| 1971 | + return _t; |
| 1972 | + |
| 1973 | + }; |
| 1974 | + |
| 1975 | + /** |
| 1976 | + * Mutes the sound. |
| 1977 | + * |
| 1978 | + * @return {SMSound} The SMSound object |
| 1979 | + */ |
| 1980 | + |
| 1981 | + this.mute = function() { |
| 1982 | + |
| 1983 | + _t.muted = true; |
| 1984 | + |
| 1985 | + if (!_t.isHTML5) { |
| 1986 | + _s.o._setVolume(_t.sID, 0); |
| 1987 | + } else if (_t._a) { |
| 1988 | + _t._a.muted = true; |
| 1989 | + } |
| 1990 | + |
| 1991 | + return _t; |
| 1992 | + |
| 1993 | + }; |
| 1994 | + |
| 1995 | + /** |
| 1996 | + * Unmutes the sound. |
| 1997 | + * |
| 1998 | + * @return {SMSound} The SMSound object |
| 1999 | + */ |
| 2000 | + |
| 2001 | + this.unmute = function() { |
| 2002 | + |
| 2003 | + _t.muted = false; |
| 2004 | + var hasIO = typeof _t._iO.volume !== 'undefined'; |
| 2005 | + |
| 2006 | + if (!_t.isHTML5) { |
| 2007 | + _s.o._setVolume(_t.sID, hasIO?_t._iO.volume:_t.options.volume); |
| 2008 | + } else if (_t._a) { |
| 2009 | + _t._a.muted = false; |
| 2010 | + } |
| 2011 | + |
| 2012 | + return _t; |
| 2013 | + |
| 2014 | + }; |
| 2015 | + |
| 2016 | + /** |
| 2017 | + * Toggles the muted state of a sound. |
| 2018 | + * |
| 2019 | + * @return {SMSound} The SMSound object |
| 2020 | + */ |
| 2021 | + |
| 2022 | + this.toggleMute = function() { |
| 2023 | + |
| 2024 | + return (_t.muted?_t.unmute():_t.mute()); |
| 2025 | + |
| 2026 | + }; |
| 2027 | + |
| 2028 | + /** |
| 2029 | + * Calls the onposition() method of a SMSound object. |
| 2030 | + * |
| 2031 | + * @param {number} nPosition The position to watch for |
| 2032 | + * @param {function} oMethod The relevant callback to fire |
| 2033 | + * @param {object} oScope Optional: The scope to apply the callback to |
| 2034 | + * @return {SMSound} The SMSound object |
| 2035 | + */ |
| 2036 | + |
| 2037 | + this.onposition = function(nPosition, oMethod, oScope) { |
| 2038 | + |
| 2039 | + // TODO: allow for ranges, too? eg. (nPosition instanceof Array) |
| 2040 | + |
| 2041 | + _t._onPositionItems.push({ |
| 2042 | + position: nPosition, |
| 2043 | + method: oMethod, |
| 2044 | + scope: (typeof oScope !== 'undefined'?oScope:_t), |
| 2045 | + fired: false |
| 2046 | + }); |
| 2047 | + |
| 2048 | + return _t; |
| 2049 | + |
| 2050 | + }; |
| 2051 | + |
| 2052 | + /** |
| 2053 | + * TODO: This should be marked as pseudo-private. |
| 2054 | + */ |
| 2055 | + |
| 2056 | + this.processOnPosition = function() { |
| 2057 | + |
| 2058 | + var i, item, j = _t._onPositionItems.length; |
| 2059 | + |
| 2060 | + if (!j || !_t.playState || _t._onPositionFired >= j) { |
| 2061 | + return false; |
| 2062 | + } |
| 2063 | + |
| 2064 | + for (i=j; i--;) { |
| 2065 | + item = _t._onPositionItems[i]; |
| 2066 | + if (!item.fired && _t.position >= item.position) { |
| 2067 | + item.fired = true; |
| 2068 | + _s._onPositionFired++; |
| 2069 | + item.method.apply(item.scope,[item.position]); |
| 2070 | + } |
| 2071 | + } |
| 2072 | + |
| 2073 | + return true; |
| 2074 | + |
| 2075 | + }; |
| 2076 | + |
| 2077 | + this.resetOnPosition = function(nPosition) { |
| 2078 | + |
| 2079 | + // reset "fired" for items interested in this position |
| 2080 | + var i, item, j = _t._onPositionItems.length; |
| 2081 | + |
| 2082 | + if (!j) { |
| 2083 | + return false; |
| 2084 | + } |
| 2085 | + |
| 2086 | + for (i=j; i--;) { |
| 2087 | + item = _t._onPositionItems[i]; |
| 2088 | + if (item.fired && nPosition <= item.position) { |
| 2089 | + item.fired = false; |
| 2090 | + _s._onPositionFired--; |
| 2091 | + } |
| 2092 | + } |
| 2093 | + |
| 2094 | + return true; |
| 2095 | + |
| 2096 | + }; |
| 2097 | + |
| 2098 | + /** |
| 2099 | + * SoundManager() private internals |
| 2100 | + * -------------------------------- |
| 2101 | + */ |
| 2102 | + |
| 2103 | + _start_html5_timer = function() { |
| 2104 | + |
| 2105 | + if (_t.isHTML5) { |
| 2106 | + _startTimer(_t); |
| 2107 | + } |
| 2108 | + |
| 2109 | + }; |
| 2110 | + |
| 2111 | + _stop_html5_timer = function() { |
| 2112 | + |
| 2113 | + if (_t.isHTML5) { |
| 2114 | + _stopTimer(_t); |
| 2115 | + } |
| 2116 | + |
| 2117 | + }; |
| 2118 | + |
| 2119 | + _resetProperties = function() { |
| 2120 | + |
| 2121 | + _t._onPositionItems = []; |
| 2122 | + _t._onPositionFired = 0; |
| 2123 | + _t._hasTimer = null; |
| 2124 | + _t._onplay_called = false; |
| 2125 | + _t._a = null; |
| 2126 | + _t._html5_canplay = false; |
| 2127 | + _t.bytesLoaded = null; |
| 2128 | + _t.bytesTotal = null; |
| 2129 | + _t.position = null; |
| 2130 | + _t.duration = (_t._iO && _t._iO.duration?_t._iO.duration:null); |
| 2131 | + _t.durationEstimate = null; |
| 2132 | + _t.failures = 0; |
| 2133 | + _t.loaded = false; |
| 2134 | + _t.playState = 0; |
| 2135 | + _t.paused = false; |
| 2136 | + |
| 2137 | + // 0 = uninitialised, 1 = loading, 2 = failed/error, 3 = loaded/success |
| 2138 | + _t.readyState = 0; |
| 2139 | + |
| 2140 | + _t.muted = false; |
| 2141 | + _t.isBuffering = false; |
| 2142 | + _t.instanceOptions = {}; |
| 2143 | + _t.instanceCount = 0; |
| 2144 | + |
| 2145 | + _t.peakData = { |
| 2146 | + left: 0, |
| 2147 | + right: 0 |
| 2148 | + }; |
| 2149 | + |
| 2150 | + _t.waveformData = { |
| 2151 | + left: [], |
| 2152 | + right: [] |
| 2153 | + }; |
| 2154 | + |
| 2155 | + // legacy: 1D array |
| 2156 | + _t.eqData = []; |
| 2157 | + |
| 2158 | + _t.eqData.left = []; |
| 2159 | + _t.eqData.right = []; |
| 2160 | + |
| 2161 | + }; |
| 2162 | + |
| 2163 | + _resetProperties(); |
| 2164 | + |
| 2165 | + /** |
| 2166 | + * Pseudo-private SMSound internals |
| 2167 | + * -------------------------------- |
| 2168 | + */ |
| 2169 | + |
| 2170 | + this._onTimer = function(bForce) { |
| 2171 | + |
| 2172 | + // HTML5-only _whileplaying() etc. |
| 2173 | + |
| 2174 | + var time, x = {}; |
| 2175 | + |
| 2176 | + if (_t._hasTimer || bForce) { |
| 2177 | + |
| 2178 | + // TODO: May not need to track readyState (1 = loading) |
| 2179 | + |
| 2180 | + if (_t._a && (bForce || ((_t.playState > 0 || _t.readyState === 1) && !_t.paused))) { |
| 2181 | + |
| 2182 | + _t.duration = _t._get_html5_duration(); |
| 2183 | + _t.durationEstimate = _t.duration; |
| 2184 | + time = _t._a.currentTime?_t._a.currentTime*1000:0; |
| 2185 | + _t._whileplaying(time,x,x,x,x); |
| 2186 | + return true; |
| 2187 | + |
| 2188 | + } else { |
| 2189 | + |
| 2190 | + _s._wD('_onTimer: Warn for "'+_t.sID+'": '+(!_t._a?'Could not find element. ':'')+(_t.playState === 0?'playState bad, 0?':'playState = '+_t.playState+', OK')); |
| 2191 | + return false; |
| 2192 | + |
| 2193 | + } |
| 2194 | + |
| 2195 | + } |
| 2196 | + |
| 2197 | + }; |
| 2198 | + |
| 2199 | + this._get_html5_duration = function() { |
| 2200 | + |
| 2201 | + var d = (_t._a ? _t._a.duration*1000 : (_t._iO ? _t._iO.duration : undefined)), |
| 2202 | + result = (d && !isNaN(d) && d !== Infinity ? d : (_t._iO ? _t._iO.duration : null)); |
| 2203 | + |
| 2204 | + return result; |
| 2205 | + |
| 2206 | + }; |
| 2207 | + |
| 2208 | + this._setup_html5 = function(oOptions) { |
| 2209 | + |
| 2210 | + var _iO = _mixin(_t._iO, oOptions), d = decodeURI, |
| 2211 | + _a = _useGlobalHTML5Audio ? _s._global_a : _t._a, |
| 2212 | + _dURL = d(_iO.url), |
| 2213 | + _oldIO = (_a && _a._t ? _a._t.instanceOptions : null); |
| 2214 | + |
| 2215 | + if (_a) { |
| 2216 | + |
| 2217 | + if (_a._t && _oldIO.url === _iO.url && (!_t._lastURL || (_t._lastURL === _oldIO.url))) { |
| 2218 | + // same url, ignore request |
| 2219 | + return _a; |
| 2220 | + } |
| 2221 | + |
| 2222 | + _s._wD('setting new URL on existing object: ' + _dURL + (_t._lastURL ? ', old URL: ' + _t._lastURL : '')); |
| 2223 | + |
| 2224 | + /** |
| 2225 | + * "First things first, I, Poppa.." (reset the previous state of the old sound, if playing) |
| 2226 | + * Fixes case with devices that can only play one sound at a time |
| 2227 | + * Otherwise, other sounds in mid-play will be terminated without warning and in a stuck state |
| 2228 | + */ |
| 2229 | + |
| 2230 | + if (_useGlobalHTML5Audio && _a._t && _a._t.playState && _iO.url !== _oldIO.url) { |
| 2231 | + _a._t.stop(); |
| 2232 | + } |
| 2233 | + |
| 2234 | + // new URL, so reset load/playstate and so on |
| 2235 | + _resetProperties(); |
| 2236 | + |
| 2237 | + _a.src = _iO.url; |
| 2238 | + _t.url = _iO.url; |
| 2239 | + _t._lastURL = _iO.url; |
| 2240 | + _a._called_load = false; |
| 2241 | + |
| 2242 | + } else { |
| 2243 | + |
| 2244 | + _s._wD('creating HTML5 Audio() element with URL: '+_dURL); |
| 2245 | + _a = new Audio(_iO.url); |
| 2246 | + |
| 2247 | + _a._called_load = false; |
| 2248 | + |
| 2249 | + // android (seen in 2.3/Honeycomb) sometimes fails first .load() -> .play(), results in playback failure and ended() events? |
| 2250 | + if (_is_android) { |
| 2251 | + _a._called_load = true; |
| 2252 | + } |
| 2253 | + |
| 2254 | + if (_useGlobalHTML5Audio) { |
| 2255 | + _s._global_a = _a; |
| 2256 | + } |
| 2257 | + |
| 2258 | + } |
| 2259 | + _t.isHTML5 = true; |
| 2260 | + |
| 2261 | + // store a ref on the track |
| 2262 | + _t._a = _a; |
| 2263 | + |
| 2264 | + // store a ref on the audio |
| 2265 | + _a._t = _t; |
| 2266 | + |
| 2267 | + _t._add_html5_events(); |
| 2268 | + _a.loop = (_iO.loops>1?'loop':''); |
| 2269 | + |
| 2270 | + if (_iO.autoLoad || _iO.autoPlay) { |
| 2271 | + |
| 2272 | + // early HTML5 implementation (non-standard) |
| 2273 | + _a.autobuffer = 'auto'; |
| 2274 | + |
| 2275 | + // standard |
| 2276 | + _a.preload = 'auto'; |
| 2277 | + |
| 2278 | + _t.load(); |
| 2279 | + _a._called_load = true; |
| 2280 | + |
| 2281 | + } else { |
| 2282 | + |
| 2283 | + // early HTML5 implementation (non-standard) |
| 2284 | + _a.autobuffer = false; |
| 2285 | + |
| 2286 | + // standard |
| 2287 | + _a.preload = 'none'; |
| 2288 | + |
| 2289 | + } |
| 2290 | + |
| 2291 | + // boolean instead of "loop", for webkit? - spec says string. http://www.w3.org/TR/html-markup/audio.html#audio.attrs.loop |
| 2292 | + _a.loop = (_iO.loops>1?'loop':''); |
| 2293 | + |
| 2294 | + return _a; |
| 2295 | + |
| 2296 | + }; |
| 2297 | + |
| 2298 | + this._add_html5_events = function() { |
| 2299 | + |
| 2300 | + if (_t._a._added_events) { |
| 2301 | + return false; |
| 2302 | + } |
| 2303 | + |
| 2304 | + var f; |
| 2305 | + |
| 2306 | + function add(oEvt, oFn, bCapture) { |
| 2307 | + return _t._a ? _t._a.addEventListener(oEvt, oFn, bCapture||false) : null; |
| 2308 | + } |
| 2309 | + |
| 2310 | + _s._wD(_h5+'adding event listeners: '+_t.sID); |
| 2311 | + _t._a._added_events = true; |
| 2312 | + |
| 2313 | + for (f in _html5_events) { |
| 2314 | + if (_html5_events.hasOwnProperty(f)) { |
| 2315 | + add(f, _html5_events[f]); |
| 2316 | + } |
| 2317 | + } |
| 2318 | + |
| 2319 | + return true; |
| 2320 | + |
| 2321 | + }; |
| 2322 | + |
| 2323 | + this._remove_html5_events = function() { |
| 2324 | + |
| 2325 | + // Remove event listeners |
| 2326 | + |
| 2327 | + var f; |
| 2328 | + |
| 2329 | + function remove(oEvt, oFn, bCapture) { |
| 2330 | + return (_t._a ? _t._a.removeEventListener(oEvt, oFn, bCapture||false) : null); |
| 2331 | + } |
| 2332 | + |
| 2333 | + _s._wD(_h5+'removing event listeners: '+_t.sID); |
| 2334 | + _t._a._added_events = false; |
| 2335 | + |
| 2336 | + for (f in _html5_events) { |
| 2337 | + if (_html5_events.hasOwnProperty(f)) { |
| 2338 | + remove(f, _html5_events[f]); |
| 2339 | + } |
| 2340 | + } |
| 2341 | + |
| 2342 | + }; |
| 2343 | + |
| 2344 | + /** |
| 2345 | + * Pseudo-private event internals |
| 2346 | + * ------------------------------ |
| 2347 | + */ |
| 2348 | + |
| 2349 | + this._onload = function(nSuccess) { |
| 2350 | + |
| 2351 | + |
| 2352 | + var fN = 'SMSound._onload(): ', loadOK = !!(nSuccess); |
| 2353 | + _s._wD(fN + '"' + _t.sID + '"' + (loadOK?' loaded.':' failed to load? - ' + _t.url), (loadOK?1:2)); |
| 2354 | + // <d> |
| 2355 | + |
| 2356 | + if (!loadOK && !_t.isHTML5) { |
| 2357 | + if (_s.sandbox.noRemote === true) { |
| 2358 | + _s._wD(fN + _str('noNet'), 1); |
| 2359 | + } |
| 2360 | + if (_s.sandbox.noLocal === true) { |
| 2361 | + _s._wD(fN + _str('noLocal'), 1); |
| 2362 | + } |
| 2363 | + } |
| 2364 | + // </d> |
| 2365 | + |
| 2366 | + _t.loaded = loadOK; |
| 2367 | + _t.readyState = loadOK?3:2; |
| 2368 | + _t._onbufferchange(0); |
| 2369 | + |
| 2370 | + if (_t._iO.onload) { |
| 2371 | + _t._iO.onload.apply(_t, [loadOK]); |
| 2372 | + } |
| 2373 | + |
| 2374 | + return true; |
| 2375 | + |
| 2376 | + }; |
| 2377 | + |
| 2378 | + this._onbufferchange = function(nIsBuffering) { |
| 2379 | + |
| 2380 | + var fN = 'SMSound._onbufferchange()'; |
| 2381 | + |
| 2382 | + if (_t.playState === 0) { |
| 2383 | + // ignore if not playing |
| 2384 | + return false; |
| 2385 | + } |
| 2386 | + |
| 2387 | + if ((nIsBuffering && _t.isBuffering) || (!nIsBuffering && !_t.isBuffering)) { |
| 2388 | + return false; |
| 2389 | + } |
| 2390 | + |
| 2391 | + _t.isBuffering = (nIsBuffering === 1); |
| 2392 | + if (_t._iO.onbufferchange) { |
| 2393 | + _s._wD(fN + ': ' + nIsBuffering); |
| 2394 | + _t._iO.onbufferchange.apply(_t); |
| 2395 | + } |
| 2396 | + |
| 2397 | + return true; |
| 2398 | + |
| 2399 | + }; |
| 2400 | + |
| 2401 | + /** |
| 2402 | + * Notify Mobile Safari that user action is required |
| 2403 | + * to continue playing / loading the audio file. |
| 2404 | + */ |
| 2405 | + |
| 2406 | + this._onsuspend = function () { |
| 2407 | + |
| 2408 | + if (_t._iO.onsuspend) { |
| 2409 | + _s._wD('SMSound._onsuspend()'); |
| 2410 | + _t._iO.onsuspend.apply(_t); |
| 2411 | + } |
| 2412 | + |
| 2413 | + return true; |
| 2414 | + |
| 2415 | + }; |
| 2416 | + |
| 2417 | + /** |
| 2418 | + * flash 9/movieStar + RTMP-only method, should fire only once at most |
| 2419 | + * at this point we just recreate failed sounds rather than trying to reconnect |
| 2420 | + */ |
| 2421 | + |
| 2422 | + this._onfailure = function(msg, level, code) { |
| 2423 | + |
| 2424 | + _t.failures++; |
| 2425 | + _s._wD('SMSound._onfailure(): "'+_t.sID+'" count '+_t.failures); |
| 2426 | + |
| 2427 | + if (_t._iO.onfailure && _t.failures === 1) { |
| 2428 | + _t._iO.onfailure(_t, msg, level, code); |
| 2429 | + } else { |
| 2430 | + _s._wD('SMSound._onfailure(): ignoring'); |
| 2431 | + } |
| 2432 | + |
| 2433 | + }; |
| 2434 | + |
| 2435 | + this._onfinish = function() { |
| 2436 | + |
| 2437 | + // store local copy before it gets trashed.. |
| 2438 | + var _io_onfinish = _t._iO.onfinish; |
| 2439 | + _t._onbufferchange(0); |
| 2440 | + _t.resetOnPosition(0); |
| 2441 | + |
| 2442 | + // reset some state items |
| 2443 | + if (_t.instanceCount) { |
| 2444 | + |
| 2445 | + _t.instanceCount--; |
| 2446 | + if (!_t.instanceCount) { |
| 2447 | + // reset instance options |
| 2448 | + _t.playState = 0; |
| 2449 | + _t.paused = false; |
| 2450 | + _t.instanceCount = 0; |
| 2451 | + _t.instanceOptions = {}; |
| 2452 | + _t._iO = {}; |
| 2453 | + _stop_html5_timer(); |
| 2454 | + } |
| 2455 | + |
| 2456 | + if (!_t.instanceCount || _t._iO.multiShotEvents) { |
| 2457 | + // fire onfinish for last, or every instance |
| 2458 | + if (_io_onfinish) { |
| 2459 | + _s._wD('SMSound._onfinish(): "' + _t.sID + '"'); |
| 2460 | + _io_onfinish.apply(_t); |
| 2461 | + } |
| 2462 | + } |
| 2463 | + |
| 2464 | + } |
| 2465 | + |
| 2466 | + }; |
| 2467 | + |
| 2468 | + this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) { |
| 2469 | + |
| 2470 | + _t.bytesLoaded = nBytesLoaded; |
| 2471 | + _t.bytesTotal = nBytesTotal; |
| 2472 | + _t.duration = Math.floor(nDuration); |
| 2473 | + _t.bufferLength = nBufferLength; |
| 2474 | + |
| 2475 | + if (!_t._iO.isMovieStar) { |
| 2476 | + |
| 2477 | + if (_t._iO.duration) { |
| 2478 | + // use options, if specified and larger |
| 2479 | + _t.durationEstimate = (_t.duration > _t._iO.duration) ? _t.duration : _t._iO.duration; |
| 2480 | + } else { |
| 2481 | + _t.durationEstimate = parseInt((_t.bytesTotal / _t.bytesLoaded) * _t.duration, 10); |
| 2482 | + |
| 2483 | + } |
| 2484 | + |
| 2485 | + if (_t.durationEstimate === undefined) { |
| 2486 | + _t.durationEstimate = _t.duration; |
| 2487 | + } |
| 2488 | + |
| 2489 | + if (_t.readyState !== 3 && _t._iO.whileloading) { |
| 2490 | + _t._iO.whileloading.apply(_t); |
| 2491 | + } |
| 2492 | + |
| 2493 | + } else { |
| 2494 | + |
| 2495 | + _t.durationEstimate = _t.duration; |
| 2496 | + if (_t.readyState !== 3 && _t._iO.whileloading) { |
| 2497 | + _t._iO.whileloading.apply(_t); |
| 2498 | + } |
| 2499 | + |
| 2500 | + } |
| 2501 | + |
| 2502 | + }; |
| 2503 | + |
| 2504 | + this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) { |
| 2505 | + |
| 2506 | + if (isNaN(nPosition) || nPosition === null) { |
| 2507 | + // flash safety net |
| 2508 | + return false; |
| 2509 | + } |
| 2510 | + |
| 2511 | + _t.position = nPosition; |
| 2512 | + _t.processOnPosition(); |
| 2513 | + |
| 2514 | + if (!_t.isHTML5 && _fV > 8) { |
| 2515 | + |
| 2516 | + if (_t._iO.usePeakData && typeof oPeakData !== 'undefined' && oPeakData) { |
| 2517 | + _t.peakData = { |
| 2518 | + left: oPeakData.leftPeak, |
| 2519 | + right: oPeakData.rightPeak |
| 2520 | + }; |
| 2521 | + } |
| 2522 | + |
| 2523 | + if (_t._iO.useWaveformData && typeof oWaveformDataLeft !== 'undefined' && oWaveformDataLeft) { |
| 2524 | + _t.waveformData = { |
| 2525 | + left: oWaveformDataLeft.split(','), |
| 2526 | + right: oWaveformDataRight.split(',') |
| 2527 | + }; |
| 2528 | + } |
| 2529 | + |
| 2530 | + if (_t._iO.useEQData) { |
| 2531 | + if (typeof oEQData !== 'undefined' && oEQData && oEQData.leftEQ) { |
| 2532 | + var eqLeft = oEQData.leftEQ.split(','); |
| 2533 | + _t.eqData = eqLeft; |
| 2534 | + _t.eqData.left = eqLeft; |
| 2535 | + if (typeof oEQData.rightEQ !== 'undefined' && oEQData.rightEQ) { |
| 2536 | + _t.eqData.right = oEQData.rightEQ.split(','); |
| 2537 | + } |
| 2538 | + } |
| 2539 | + } |
| 2540 | + |
| 2541 | + } |
| 2542 | + |
| 2543 | + if (_t.playState === 1) { |
| 2544 | + |
| 2545 | + // special case/hack: ensure buffering is false if loading from cache (and not yet started) |
| 2546 | + if (!_t.isHTML5 && _fV === 8 && !_t.position && _t.isBuffering) { |
| 2547 | + _t._onbufferchange(0); |
| 2548 | + } |
| 2549 | + |
| 2550 | + if (_t._iO.whileplaying) { |
| 2551 | + // flash may call after actual finish |
| 2552 | + _t._iO.whileplaying.apply(_t); |
| 2553 | + } |
| 2554 | + |
| 2555 | + } |
| 2556 | + |
| 2557 | + return true; |
| 2558 | + |
| 2559 | + }; |
| 2560 | + |
| 2561 | + this._onid3 = function(oID3PropNames, oID3Data) { |
| 2562 | + |
| 2563 | + // oID3PropNames: string array (names) |
| 2564 | + // ID3Data: string array (data) |
| 2565 | + _s._wD('SMSound._onid3(): "' + this.sID + '" ID3 data received.'); |
| 2566 | + |
| 2567 | + var oData = [], i, j; |
| 2568 | + |
| 2569 | + for (i = 0, j = oID3PropNames.length; i < j; i++) { |
| 2570 | + oData[oID3PropNames[i]] = oID3Data[i]; |
| 2571 | + } |
| 2572 | + _t.id3 = _mixin(_t.id3, oData); |
| 2573 | + |
| 2574 | + if (_t._iO.onid3) { |
| 2575 | + _t._iO.onid3.apply(_t); |
| 2576 | + } |
| 2577 | + |
| 2578 | + }; |
| 2579 | + |
| 2580 | + // flash/RTMP-only |
| 2581 | + |
| 2582 | + this._onconnect = function(bSuccess) { |
| 2583 | + |
| 2584 | + var fN = 'SMSound._onconnect(): '; |
| 2585 | + bSuccess = (bSuccess === 1); |
| 2586 | + _s._wD(fN+'"'+_t.sID+'"'+(bSuccess?' connected.':' failed to connect? - '+_t.url), (bSuccess?1:2)); |
| 2587 | + _t.connected = bSuccess; |
| 2588 | + |
| 2589 | + if (bSuccess) { |
| 2590 | + |
| 2591 | + _t.failures = 0; |
| 2592 | + |
| 2593 | + if (_idCheck(_t.sID)) { |
| 2594 | + if (_t.getAutoPlay()) { |
| 2595 | + // only update the play state if auto playing |
| 2596 | + _t.play(undefined, _t.getAutoPlay()); |
| 2597 | + } else if (_t._iO.autoLoad) { |
| 2598 | + _t.load(); |
| 2599 | + } |
| 2600 | + } |
| 2601 | + |
| 2602 | + if (_t._iO.onconnect) { |
| 2603 | + _t._iO.onconnect.apply(_t,[bSuccess]); |
| 2604 | + } |
| 2605 | + |
| 2606 | + } |
| 2607 | + |
| 2608 | + }; |
| 2609 | + |
| 2610 | + this._ondataerror = function(sError) { |
| 2611 | + |
| 2612 | + // flash 9 wave/eq data handler |
| 2613 | + // hack: called at start, and end from flash at/after onfinish() |
| 2614 | + if (_t.playState > 0) { |
| 2615 | + _s._wD('SMSound._ondataerror(): ' + sError); |
| 2616 | + if (_t._iO.ondataerror) { |
| 2617 | + _t._iO.ondataerror.apply(_t); |
| 2618 | + } |
| 2619 | + } |
| 2620 | + |
| 2621 | + }; |
| 2622 | + |
| 2623 | + }; // SMSound() |
| 2624 | + |
| 2625 | + /** |
| 2626 | + * Private SoundManager internals |
| 2627 | + * ------------------------------ |
| 2628 | + */ |
| 2629 | + |
| 2630 | + _getDocument = function() { |
| 2631 | + |
| 2632 | + return (_doc.body || _doc._docElement || _doc.getElementsByTagName('div')[0]); |
| 2633 | + |
| 2634 | + }; |
| 2635 | + |
| 2636 | + _id = function(sID) { |
| 2637 | + |
| 2638 | + return _doc.getElementById(sID); |
| 2639 | + |
| 2640 | + }; |
| 2641 | + |
| 2642 | + _mixin = function(oMain, oAdd) { |
| 2643 | + |
| 2644 | + // non-destructive merge |
| 2645 | + var o1 = {}, i, o2, o; |
| 2646 | + |
| 2647 | + // clone c1 |
| 2648 | + for (i in oMain) { |
| 2649 | + if (oMain.hasOwnProperty(i)) { |
| 2650 | + o1[i] = oMain[i]; |
| 2651 | + } |
| 2652 | + } |
| 2653 | + |
| 2654 | + o2 = (typeof oAdd === 'undefined'?_s.defaultOptions:oAdd); |
| 2655 | + for (o in o2) { |
| 2656 | + if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') { |
| 2657 | + o1[o] = o2[o]; |
| 2658 | + } |
| 2659 | + } |
| 2660 | + return o1; |
| 2661 | + |
| 2662 | + }; |
| 2663 | + |
| 2664 | + _event = (function() { |
| 2665 | + |
| 2666 | + var old = (_win.attachEvent), |
| 2667 | + evt = { |
| 2668 | + add: (old?'attachEvent':'addEventListener'), |
| 2669 | + remove: (old?'detachEvent':'removeEventListener') |
| 2670 | + }; |
| 2671 | + |
| 2672 | + function getArgs(oArgs) { |
| 2673 | + |
| 2674 | + var args = _slice.call(oArgs), len = args.length; |
| 2675 | + |
| 2676 | + if (old) { |
| 2677 | + // prefix |
| 2678 | + args[1] = 'on' + args[1]; |
| 2679 | + if (len > 3) { |
| 2680 | + // no capture |
| 2681 | + args.pop(); |
| 2682 | + } |
| 2683 | + } else if (len === 3) { |
| 2684 | + args.push(false); |
| 2685 | + } |
| 2686 | + return args; |
| 2687 | + |
| 2688 | + } |
| 2689 | + |
| 2690 | + function apply(args, sType) { |
| 2691 | + |
| 2692 | + var element = args.shift(), |
| 2693 | + method = [evt[sType]]; |
| 2694 | + |
| 2695 | + if (old) { |
| 2696 | + element[method](args[0], args[1]); |
| 2697 | + } else { |
| 2698 | + element[method].apply(element, args); |
| 2699 | + } |
| 2700 | + |
| 2701 | + } |
| 2702 | + |
| 2703 | + function add() { |
| 2704 | + |
| 2705 | + apply(getArgs(arguments), 'add'); |
| 2706 | + |
| 2707 | + } |
| 2708 | + |
| 2709 | + function remove() { |
| 2710 | + |
| 2711 | + apply(getArgs(arguments), 'remove'); |
| 2712 | + |
| 2713 | + } |
| 2714 | + |
| 2715 | + return { |
| 2716 | + 'add': add, |
| 2717 | + 'remove': remove |
| 2718 | + }; |
| 2719 | + |
| 2720 | + }()); |
| 2721 | + |
| 2722 | + /** |
| 2723 | + * Internal HTML5 event handling |
| 2724 | + * ----------------------------- |
| 2725 | + */ |
| 2726 | + |
| 2727 | + function _html5_event(oFn) { |
| 2728 | + |
| 2729 | + // wrap html5 event handlers so we don't call them on destroyed sounds |
| 2730 | + |
| 2731 | + return function(e) { |
| 2732 | + |
| 2733 | + if (!this._t || !this._t._a) { |
| 2734 | + // <d> |
| 2735 | + if (this._t && this._t.sID) { |
| 2736 | + _s._wD(_h5+'ignoring '+e.type+': '+this._t.sID); |
| 2737 | + } else { |
| 2738 | + _s._wD(_h5+'ignoring '+e.type); |
| 2739 | + } |
| 2740 | + // </d> |
| 2741 | + return null; |
| 2742 | + } else { |
| 2743 | + return oFn.call(this, e); |
| 2744 | + } |
| 2745 | + |
| 2746 | + }; |
| 2747 | + |
| 2748 | + } |
| 2749 | + |
| 2750 | + _html5_events = { |
| 2751 | + |
| 2752 | + // HTML5 event-name-to-handler map |
| 2753 | + |
| 2754 | + abort: _html5_event(function(e) { |
| 2755 | + |
| 2756 | + _s._wD(_h5+'abort: '+this._t.sID); |
| 2757 | + |
| 2758 | + }), |
| 2759 | + |
| 2760 | + // enough has loaded to play |
| 2761 | + |
| 2762 | + canplay: _html5_event(function(e) { |
| 2763 | + |
| 2764 | + if (this._t._html5_canplay) { |
| 2765 | + // this event has already fired. ignore. |
| 2766 | + return true; |
| 2767 | + } |
| 2768 | + |
| 2769 | + this._t._html5_canplay = true; |
| 2770 | + _s._wD(_h5+'canplay: '+this._t.sID+', '+this._t.url); |
| 2771 | + this._t._onbufferchange(0); |
| 2772 | + var position1K = (!isNaN(this._t.position)?this._t.position/1000:null); |
| 2773 | + |
| 2774 | + // set the position if position was set before the sound loaded |
| 2775 | + if (this._t.position && this.currentTime !== position1K) { |
| 2776 | + _s._wD(_h5+'canplay: setting position to '+position1K); |
| 2777 | + try { |
| 2778 | + this.currentTime = position1K; |
| 2779 | + } catch(ee) { |
| 2780 | + _s._wD(_h5+'setting position failed: '+ee.message, 2); |
| 2781 | + } |
| 2782 | + } |
| 2783 | + |
| 2784 | + }), |
| 2785 | + |
| 2786 | + load: _html5_event(function(e) { |
| 2787 | + |
| 2788 | + if (!this._t.loaded) { |
| 2789 | + this._t._onbufferchange(0); |
| 2790 | + // should be 1, and the same |
| 2791 | + this._t._whileloading(this._t.bytesTotal, this._t.bytesTotal, this._t._get_html5_duration()); |
| 2792 | + this._t._onload(true); |
| 2793 | + } |
| 2794 | + |
| 2795 | + }), |
| 2796 | + |
| 2797 | + emptied: _html5_event(function(e) { |
| 2798 | + |
| 2799 | + _s._wD(_h5+'emptied: '+this._t.sID); |
| 2800 | + |
| 2801 | + }), |
| 2802 | + |
| 2803 | + ended: _html5_event(function(e) { |
| 2804 | + |
| 2805 | + _s._wD(_h5+'ended: '+this._t.sID); |
| 2806 | + this._t._onfinish(); |
| 2807 | + |
| 2808 | + }), |
| 2809 | + |
| 2810 | + error: _html5_event(function(e) { |
| 2811 | + |
| 2812 | + _s._wD(_h5+'error: '+this.error.code); |
| 2813 | + // call load with error state? |
| 2814 | + this._t._onload(false); |
| 2815 | + |
| 2816 | + }), |
| 2817 | + |
| 2818 | + loadeddata: _html5_event(function(e) { |
| 2819 | + |
| 2820 | + var t = this._t, |
| 2821 | + // at least 1 byte, so math works |
| 2822 | + bytesTotal = t.bytesTotal || 1; |
| 2823 | + |
| 2824 | + _s._wD(_h5+'loadeddata: '+this._t.sID); |
| 2825 | + |
| 2826 | + // safari seems to nicely report progress events, eventually totalling 100% |
| 2827 | + if (!t._loaded && !_isSafari) { |
| 2828 | + t.duration = t._get_html5_duration(); |
| 2829 | + // fire whileloading() with 100% values |
| 2830 | + t._whileloading(bytesTotal, bytesTotal, t._get_html5_duration()); |
| 2831 | + t._onload(true); |
| 2832 | + } |
| 2833 | + |
| 2834 | + }), |
| 2835 | + |
| 2836 | + loadedmetadata: _html5_event(function(e) { |
| 2837 | + |
| 2838 | + _s._wD(_h5+'loadedmetadata: '+this._t.sID); |
| 2839 | + |
| 2840 | + }), |
| 2841 | + |
| 2842 | + loadstart: _html5_event(function(e) { |
| 2843 | + |
| 2844 | + _s._wD(_h5+'loadstart: '+this._t.sID); |
| 2845 | + // assume buffering at first |
| 2846 | + this._t._onbufferchange(1); |
| 2847 | + |
| 2848 | + }), |
| 2849 | + |
| 2850 | + play: _html5_event(function(e) { |
| 2851 | + |
| 2852 | + _s._wD(_h5+'play: '+this._t.sID+', '+this._t.url); |
| 2853 | + // once play starts, no buffering |
| 2854 | + this._t._onbufferchange(0); |
| 2855 | + |
| 2856 | + }), |
| 2857 | + |
| 2858 | + // TODO: verify if this is actually implemented anywhere yet. |
| 2859 | + playing: _html5_event(function(e) { |
| 2860 | + |
| 2861 | + _s._wD(_h5+'playing: '+this._t.sID+', '+this._t.url); |
| 2862 | + |
| 2863 | + // once play starts, no buffering |
| 2864 | + this._t._onbufferchange(0); |
| 2865 | + |
| 2866 | + }), |
| 2867 | + |
| 2868 | + progress: _html5_event(function(e) { |
| 2869 | + |
| 2870 | + if (this._t.loaded) { |
| 2871 | + return false; |
| 2872 | + } |
| 2873 | + |
| 2874 | + var i, j, str, buffered = 0, |
| 2875 | + isProgress = (e.type === 'progress'), |
| 2876 | + ranges = e.target.buffered, |
| 2877 | + |
| 2878 | + // firefox 3.6 implements e.loaded/total (bytes) |
| 2879 | + loaded = (e.loaded||0), |
| 2880 | + |
| 2881 | + total = (e.total||1); |
| 2882 | + |
| 2883 | + if (ranges && ranges.length) { |
| 2884 | + |
| 2885 | + // if loaded is 0, try TimeRanges implementation as % of load |
| 2886 | + // https://developer.mozilla.org/en/DOM/TimeRanges |
| 2887 | + |
| 2888 | + for (i=ranges.length; i--;) { |
| 2889 | + buffered = (ranges.end(i) - ranges.start(i)); |
| 2890 | + } |
| 2891 | + |
| 2892 | + // linear case, buffer sum; does not account for seeking and HTTP partials / byte ranges |
| 2893 | + loaded = buffered/e.target.duration; |
| 2894 | + |
| 2895 | + // <d> |
| 2896 | + if (isProgress && ranges.length > 1) { |
| 2897 | + str = []; |
| 2898 | + j = ranges.length; |
| 2899 | + for (i=0; i<j; i++) { |
| 2900 | + str.push(e.target.buffered.start(i) +'-'+ e.target.buffered.end(i)); |
| 2901 | + } |
| 2902 | + _s._wD(_h5+'progress: timeRanges: '+str.join(', ')); |
| 2903 | + } |
| 2904 | + |
| 2905 | + if (isProgress && !isNaN(loaded)) { |
| 2906 | + _s._wD(_h5+'progress: '+this._t.sID+': ' + Math.floor(loaded*100)+'% loaded'); |
| 2907 | + } |
| 2908 | + // </d> |
| 2909 | + |
| 2910 | + } |
| 2911 | + |
| 2912 | + if (!isNaN(loaded)) { |
| 2913 | + |
| 2914 | + // if progress, likely not buffering |
| 2915 | + this._t._onbufferchange(0); |
| 2916 | + this._t._whileloading(loaded, total, this._t._get_html5_duration()); |
| 2917 | + if (loaded && total && loaded === total) { |
| 2918 | + // in case "onload" doesn't fire (eg. gecko 1.9.2) |
| 2919 | + _html5_events.load.call(this, e); |
| 2920 | + } |
| 2921 | + |
| 2922 | + } |
| 2923 | + |
| 2924 | + }), |
| 2925 | + |
| 2926 | + ratechange: _html5_event(function(e) { |
| 2927 | + |
| 2928 | + _s._wD(_h5+'ratechange: '+this._t.sID); |
| 2929 | + |
| 2930 | + }), |
| 2931 | + |
| 2932 | + suspend: _html5_event(function(e) { |
| 2933 | + |
| 2934 | + // download paused/stopped, may have finished (eg. onload) |
| 2935 | + |
| 2936 | + _s._wD(_h5+'suspend: '+this._t.sID); |
| 2937 | + _html5_events.progress.call(this, e); |
| 2938 | + this._t._onsuspend(); |
| 2939 | + |
| 2940 | + }), |
| 2941 | + |
| 2942 | + stalled: _html5_event(function(e) { |
| 2943 | + |
| 2944 | + _s._wD(_h5+'stalled: '+this._t.sID); |
| 2945 | + |
| 2946 | + }), |
| 2947 | + |
| 2948 | + timeupdate: _html5_event(function(e) { |
| 2949 | + |
| 2950 | + this._t._onTimer(); |
| 2951 | + |
| 2952 | + }), |
| 2953 | + |
| 2954 | + waiting: _html5_event(function(e) { |
| 2955 | + |
| 2956 | + // see also: seeking |
| 2957 | + _s._wD(_h5+'waiting: '+this._t.sID); |
| 2958 | + |
| 2959 | + // playback faster than download rate, etc. |
| 2960 | + this._t._onbufferchange(1); |
| 2961 | + |
| 2962 | + }) |
| 2963 | + |
| 2964 | + }; |
| 2965 | + |
| 2966 | + _html5OK = function(iO) { |
| 2967 | + |
| 2968 | + // Use type, if specified. If HTML5-only mode, no other options, so just give 'er |
| 2969 | + return (!iO.serverURL && (iO.type?_html5CanPlay({type:iO.type}):_html5CanPlay({url:iO.url})||_s.html5Only)); |
| 2970 | + |
| 2971 | + }; |
| 2972 | + |
| 2973 | + _html5Unload = function(oAudio) { |
| 2974 | + |
| 2975 | + /** |
| 2976 | + * Internal method: Unload media, and cancel any current/pending network requests. |
| 2977 | + * Firefox can load an empty URL, which allegedly destroys the decoder and stops the download. |
| 2978 | + * https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Stopping_the_download_of_media |
| 2979 | + * Other UA behaviour is unclear, so everyone else gets an about:blank-style URL. |
| 2980 | + */ |
| 2981 | + |
| 2982 | + if (oAudio) { |
| 2983 | + // Firefox likes '' for unload, most other UAs don't and fail to unload. |
| 2984 | + oAudio.src = (_is_firefox ? '' : _emptyURL); |
| 2985 | + } |
| 2986 | + |
| 2987 | + }; |
| 2988 | + |
| 2989 | + _html5CanPlay = function(o) { |
| 2990 | + |
| 2991 | + /** |
| 2992 | + * Try to find MIME, test and return truthiness |
| 2993 | + * o = { |
| 2994 | + * url: '/path/to/an.mp3', |
| 2995 | + * type: 'audio/mp3' |
| 2996 | + * } |
| 2997 | + */ |
| 2998 | + |
| 2999 | + if (!_s.useHTML5Audio || !_s.hasHTML5) { |
| 3000 | + return false; |
| 3001 | + } |
| 3002 | + |
| 3003 | + var url = (o.url || null), |
| 3004 | + mime = (o.type || null), |
| 3005 | + aF = _s.audioFormats, |
| 3006 | + result, |
| 3007 | + offset, |
| 3008 | + fileExt, |
| 3009 | + item; |
| 3010 | + |
| 3011 | + function preferFlashCheck(kind) { |
| 3012 | + |
| 3013 | + // whether flash should play a given type |
| 3014 | + return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind])); |
| 3015 | + |
| 3016 | + } |
| 3017 | + |
| 3018 | + // account for known cases like audio/mp3 |
| 3019 | + |
| 3020 | + if (mime && _s.html5[mime] !== 'undefined') { |
| 3021 | + return (_s.html5[mime] && !preferFlashCheck(mime)); |
| 3022 | + } |
| 3023 | + |
| 3024 | + if (!_html5Ext) { |
| 3025 | + _html5Ext = []; |
| 3026 | + for (item in aF) { |
| 3027 | + if (aF.hasOwnProperty(item)) { |
| 3028 | + _html5Ext.push(item); |
| 3029 | + if (aF[item].related) { |
| 3030 | + _html5Ext = _html5Ext.concat(aF[item].related); |
| 3031 | + } |
| 3032 | + } |
| 3033 | + } |
| 3034 | + _html5Ext = new RegExp('\\.('+_html5Ext.join('|')+')(\\?.*)?$','i'); |
| 3035 | + } |
| 3036 | + |
| 3037 | + // TODO: Strip URL queries, etc. |
| 3038 | + fileExt = (url ? url.toLowerCase().match(_html5Ext) : null); |
| 3039 | + |
| 3040 | + if (!fileExt || !fileExt.length) { |
| 3041 | + if (!mime) { |
| 3042 | + return false; |
| 3043 | + } else { |
| 3044 | + // audio/mp3 -> mp3, result should be known |
| 3045 | + offset = mime.indexOf(';'); |
| 3046 | + // strip "audio/X; codecs.." |
| 3047 | + fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6); |
| 3048 | + } |
| 3049 | + } else { |
| 3050 | + // match the raw extension name - "mp3", for example |
| 3051 | + fileExt = fileExt[1]; |
| 3052 | + } |
| 3053 | + |
| 3054 | + if (fileExt && typeof _s.html5[fileExt] !== 'undefined') { |
| 3055 | + // result known |
| 3056 | + return (_s.html5[fileExt] && !preferFlashCheck(fileExt)); |
| 3057 | + } else { |
| 3058 | + mime = 'audio/'+fileExt; |
| 3059 | + result = _s.html5.canPlayType({type:mime}); |
| 3060 | + _s.html5[fileExt] = result; |
| 3061 | + // _s._wD('canPlayType, found result: '+result); |
| 3062 | + return (result && _s.html5[mime] && !preferFlashCheck(mime)); |
| 3063 | + } |
| 3064 | + |
| 3065 | + }; |
| 3066 | + |
| 3067 | + _testHTML5 = function() { |
| 3068 | + |
| 3069 | + if (!_s.useHTML5Audio || typeof Audio === 'undefined') { |
| 3070 | + return false; |
| 3071 | + } |
| 3072 | + |
| 3073 | + // double-whammy: Opera 9.64 throws WRONG_ARGUMENTS_ERR if no parameter passed to Audio(), and Webkit + iOS happily tries to load "null" as a URL. :/ |
| 3074 | + var a = (typeof Audio !== 'undefined' ? (_isOpera ? new Audio(null) : new Audio()) : null), |
| 3075 | + item, support = {}, aF, i; |
| 3076 | + |
| 3077 | + function _cp(m) { |
| 3078 | + |
| 3079 | + var canPlay, i, j, isOK = false; |
| 3080 | + |
| 3081 | + if (!a || typeof a.canPlayType !== 'function') { |
| 3082 | + return false; |
| 3083 | + } |
| 3084 | + |
| 3085 | + if (m instanceof Array) { |
| 3086 | + // iterate through all mime types, return any successes |
| 3087 | + for (i=0, j=m.length; i<j && !isOK; i++) { |
| 3088 | + if (_s.html5[m[i]] || a.canPlayType(m[i]).match(_s.html5Test)) { |
| 3089 | + isOK = true; |
| 3090 | + _s.html5[m[i]] = true; |
| 3091 | + |
| 3092 | + // if flash can play and preferred, also mark it for use. |
| 3093 | + _s.flash[m[i]] = !!(_s.preferFlash && _hasFlash && m[i].match(_flashMIME)); |
| 3094 | + |
| 3095 | + } |
| 3096 | + } |
| 3097 | + return isOK; |
| 3098 | + } else { |
| 3099 | + canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false); |
| 3100 | + return !!(canPlay && (canPlay.match(_s.html5Test))); |
| 3101 | + } |
| 3102 | + |
| 3103 | + } |
| 3104 | + |
| 3105 | + // test all registered formats + codecs |
| 3106 | + |
| 3107 | + aF = _s.audioFormats; |
| 3108 | + |
| 3109 | + for (item in aF) { |
| 3110 | + if (aF.hasOwnProperty(item)) { |
| 3111 | + support[item] = _cp(aF[item].type); |
| 3112 | + |
| 3113 | + // write back generic type too, eg. audio/mp3 |
| 3114 | + support['audio/'+item] = support[item]; |
| 3115 | + |
| 3116 | + // assign flash |
| 3117 | + if (_s.preferFlash && !_s.ignoreFlash && item.match(_flashMIME)) { |
| 3118 | + _s.flash[item] = true; |
| 3119 | + } else { |
| 3120 | + _s.flash[item] = false; |
| 3121 | + } |
| 3122 | + |
| 3123 | + // assign result to related formats, too |
| 3124 | + if (aF[item] && aF[item].related) { |
| 3125 | + for (i=aF[item].related.length; i--;) { |
| 3126 | + // eg. audio/m4a |
| 3127 | + support['audio/'+aF[item].related[i]] = support[item]; |
| 3128 | + _s.html5[aF[item].related[i]] = support[item]; |
| 3129 | + _s.flash[aF[item].related[i]] = support[item]; |
| 3130 | + |
| 3131 | + } |
| 3132 | + } |
| 3133 | + } |
| 3134 | + } |
| 3135 | + |
| 3136 | + support.canPlayType = (a?_cp:null); |
| 3137 | + _s.html5 = _mixin(_s.html5, support); |
| 3138 | + |
| 3139 | + return true; |
| 3140 | + |
| 3141 | + }; |
| 3142 | + |
| 3143 | + _strings = { |
| 3144 | + |
| 3145 | + // <d> |
| 3146 | + notReady: 'Not loaded yet - wait for soundManager.onload()/onready()', |
| 3147 | + notOK: 'Audio support is not available.', |
| 3148 | + domError: _smc + 'createMovie(): appendChild/innerHTML call failed. DOM not ready or other error.', |
| 3149 | + spcWmode: _smc + 'createMovie(): Removing wmode, preventing known SWF loading issue(s)', |
| 3150 | + swf404: _sm + ': Verify that %s is a valid path.', |
| 3151 | + tryDebug: 'Try ' + _sm + '.debugFlash = true for more security details (output goes to SWF.)', |
| 3152 | + checkSWF: 'See SWF output for more debug info.', |
| 3153 | + localFail: _sm + ': Non-HTTP page (' + _doc.location.protocol + ' URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/', |
| 3154 | + waitFocus: _sm + ': Special case: Waiting for focus-related event..', |
| 3155 | + waitImpatient: _sm + ': Getting impatient, still waiting for Flash%s...', |
| 3156 | + waitForever: _sm + ': Waiting indefinitely for Flash (will recover if unblocked)...', |
| 3157 | + needFunction: _sm + ': Function object expected for %s', |
| 3158 | + badID: 'Warning: Sound ID "%s" should be a string, starting with a non-numeric character', |
| 3159 | + currentObj: '--- ' + _sm + '._debug(): Current sound objects ---', |
| 3160 | + waitEI: _smc + 'initMovie(): Waiting for ExternalInterface call from Flash..', |
| 3161 | + waitOnload: _sm + ': Waiting for window.onload()', |
| 3162 | + docLoaded: _sm + ': Document already loaded', |
| 3163 | + onload: _smc + 'initComplete(): calling soundManager.onload()', |
| 3164 | + onloadOK: _sm + '.onload() complete', |
| 3165 | + init: _smc + 'init()', |
| 3166 | + didInit: _smc + 'init(): Already called?', |
| 3167 | + flashJS: _sm + ': Attempting to call Flash from JS..', |
| 3168 | + secNote: 'Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html', |
| 3169 | + badRemove: 'Warning: Failed to remove flash movie.', |
| 3170 | + noPeak: 'Warning: peakData features unsupported for movieStar formats', |
| 3171 | + shutdown: _sm + '.disable(): Shutting down', |
| 3172 | + queue: _sm + ': Queueing %s handler', |
| 3173 | + smFail: _sm + ': Failed to initialise.', |
| 3174 | + smError: 'SMSound.load(): Exception: JS-Flash communication failed, or JS error.', |
| 3175 | + fbTimeout: 'No flash response, applying .'+_s.swfCSS.swfTimedout+' CSS..', |
| 3176 | + fbLoaded: 'Flash loaded', |
| 3177 | + fbHandler: _smc+'flashBlockHandler()', |
| 3178 | + manURL: 'SMSound.load(): Using manually-assigned URL', |
| 3179 | + onURL: _sm + '.load(): current URL already assigned.', |
| 3180 | + badFV: _sm + '.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.', |
| 3181 | + as2loop: 'Note: Setting stream:false so looping can work (flash 8 limitation)', |
| 3182 | + noNSLoop: 'Note: Looping not implemented for MovieStar formats', |
| 3183 | + needfl9: 'Note: Switching to flash 9, required for MP4 formats.', |
| 3184 | + mfTimeout: 'Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case', |
| 3185 | + mfOn: 'mobileFlash::enabling on-screen flash repositioning', |
| 3186 | + policy: 'Enabling usePolicyFile for data access' |
| 3187 | + // </d> |
| 3188 | + |
| 3189 | + }; |
| 3190 | + |
| 3191 | + _str = function() { |
| 3192 | + |
| 3193 | + // internal string replace helper. |
| 3194 | + // arguments: o [,items to replace] |
| 3195 | + // <d> |
| 3196 | + |
| 3197 | + // real array, please |
| 3198 | + var args = _slice.call(arguments), |
| 3199 | + |
| 3200 | + // first arg |
| 3201 | + o = args.shift(), |
| 3202 | + |
| 3203 | + str = (_strings && _strings[o]?_strings[o]:''), i, j; |
| 3204 | + if (str && args && args.length) { |
| 3205 | + for (i = 0, j = args.length; i < j; i++) { |
| 3206 | + str = str.replace('%s', args[i]); |
| 3207 | + } |
| 3208 | + } |
| 3209 | + |
| 3210 | + return str; |
| 3211 | + // </d> |
| 3212 | + |
| 3213 | + }; |
| 3214 | + |
| 3215 | + _loopFix = function(sOpt) { |
| 3216 | + |
| 3217 | + // flash 8 requires stream = false for looping to work |
| 3218 | + if (_fV === 8 && sOpt.loops > 1 && sOpt.stream) { |
| 3219 | + _wDS('as2loop'); |
| 3220 | + sOpt.stream = false; |
| 3221 | + } |
| 3222 | + |
| 3223 | + return sOpt; |
| 3224 | + |
| 3225 | + }; |
| 3226 | + |
| 3227 | + _policyFix = function(sOpt, sPre) { |
| 3228 | + |
| 3229 | + if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) { |
| 3230 | + _s._wD((sPre || '') + _str('policy')); |
| 3231 | + sOpt.usePolicyFile = true; |
| 3232 | + } |
| 3233 | + |
| 3234 | + return sOpt; |
| 3235 | + |
| 3236 | + }; |
| 3237 | + |
| 3238 | + _complain = function(sMsg) { |
| 3239 | + |
| 3240 | + // <d> |
| 3241 | + if (typeof console !== 'undefined' && typeof console.warn !== 'undefined') { |
| 3242 | + console.warn(sMsg); |
| 3243 | + } else { |
| 3244 | + _s._wD(sMsg); |
| 3245 | + } |
| 3246 | + // </d> |
| 3247 | + |
| 3248 | + }; |
| 3249 | + |
| 3250 | + _doNothing = function() { |
| 3251 | + |
| 3252 | + return false; |
| 3253 | + |
| 3254 | + }; |
| 3255 | + |
| 3256 | + _disableObject = function(o) { |
| 3257 | + |
| 3258 | + var oProp; |
| 3259 | + |
| 3260 | + for (oProp in o) { |
| 3261 | + if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') { |
| 3262 | + o[oProp] = _doNothing; |
| 3263 | + } |
| 3264 | + } |
| 3265 | + |
| 3266 | + oProp = null; |
| 3267 | + |
| 3268 | + }; |
| 3269 | + |
| 3270 | + _failSafely = function(bNoDisable) { |
| 3271 | + |
| 3272 | + // general failure exception handler |
| 3273 | + |
| 3274 | + if (typeof bNoDisable === 'undefined') { |
| 3275 | + bNoDisable = false; |
| 3276 | + } |
| 3277 | + |
| 3278 | + if (_disabled || bNoDisable) { |
| 3279 | + _wDS('smFail', 2); |
| 3280 | + _s.disable(bNoDisable); |
| 3281 | + } |
| 3282 | + |
| 3283 | + }; |
| 3284 | + |
| 3285 | + _normalizeMovieURL = function(smURL) { |
| 3286 | + |
| 3287 | + var urlParams = null, url; |
| 3288 | + |
| 3289 | + if (smURL) { |
| 3290 | + if (smURL.match(/\.swf(\?.*)?$/i)) { |
| 3291 | + urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4); |
| 3292 | + if (urlParams) { |
| 3293 | + // assume user knows what they're doing |
| 3294 | + return smURL; |
| 3295 | + } |
| 3296 | + } else if (smURL.lastIndexOf('/') !== smURL.length - 1) { |
| 3297 | + // append trailing slash, if needed |
| 3298 | + smURL += '/'; |
| 3299 | + } |
| 3300 | + } |
| 3301 | + |
| 3302 | + url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + _s.movieURL; |
| 3303 | + |
| 3304 | + if (_s.noSWFCache) { |
| 3305 | + url += ('?ts=' + new Date().getTime()); |
| 3306 | + } |
| 3307 | + |
| 3308 | + return url; |
| 3309 | + |
| 3310 | + }; |
| 3311 | + |
| 3312 | + _setVersionInfo = function() { |
| 3313 | + |
| 3314 | + // short-hand for internal use |
| 3315 | + |
| 3316 | + _fV = parseInt(_s.flashVersion, 10); |
| 3317 | + |
| 3318 | + if (_fV !== 8 && _fV !== 9) { |
| 3319 | + _s._wD(_str('badFV', _fV, _defaultFlashVersion)); |
| 3320 | + _s.flashVersion = _fV = _defaultFlashVersion; |
| 3321 | + } |
| 3322 | + |
| 3323 | + // debug flash movie, if applicable |
| 3324 | + |
| 3325 | + var isDebug = (_s.debugMode || _s.debugFlash?'_debug.swf':'.swf'); |
| 3326 | + |
| 3327 | + if (_s.useHTML5Audio && !_s.html5Only && _s.audioFormats.mp4.required && _fV < 9) { |
| 3328 | + _s._wD(_str('needfl9')); |
| 3329 | + _s.flashVersion = _fV = 9; |
| 3330 | + } |
| 3331 | + |
| 3332 | + _s.version = _s.versionNumber + (_s.html5Only?' (HTML5-only mode)':(_fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)')); |
| 3333 | + |
| 3334 | + // set up default options |
| 3335 | + if (_fV > 8) { |
| 3336 | + // +flash 9 base options |
| 3337 | + _s.defaultOptions = _mixin(_s.defaultOptions, _s.flash9Options); |
| 3338 | + _s.features.buffering = true; |
| 3339 | + // +moviestar support |
| 3340 | + _s.defaultOptions = _mixin(_s.defaultOptions, _s.movieStarOptions); |
| 3341 | + _s.filePatterns.flash9 = new RegExp('\\.(mp3|' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); |
| 3342 | + _s.features.movieStar = true; |
| 3343 | + } else { |
| 3344 | + _s.features.movieStar = false; |
| 3345 | + } |
| 3346 | + |
| 3347 | + // regExp for flash canPlay(), etc. |
| 3348 | + _s.filePattern = _s.filePatterns[(_fV !== 8?'flash9':'flash8')]; |
| 3349 | + |
| 3350 | + // if applicable, use _debug versions of SWFs |
| 3351 | + _s.movieURL = (_fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug); |
| 3352 | + |
| 3353 | + _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_fV > 8); |
| 3354 | + |
| 3355 | + }; |
| 3356 | + |
| 3357 | + _setPolling = function(bPolling, bHighPerformance) { |
| 3358 | + |
| 3359 | + if (!_s.o) { |
| 3360 | + return false; |
| 3361 | + } |
| 3362 | + |
| 3363 | + _s.o._setPolling(bPolling, bHighPerformance); |
| 3364 | + |
| 3365 | + }; |
| 3366 | + |
| 3367 | + _initDebug = function() { |
| 3368 | + |
| 3369 | + // starts debug mode, creating output <div> for UAs without console object |
| 3370 | + |
| 3371 | + // allow force of debug mode via URL |
| 3372 | + if (_s.debugURLParam.test(_wl)) { |
| 3373 | + _s.debugMode = true; |
| 3374 | + } |
| 3375 | + |
| 3376 | + // <d> |
| 3377 | + if (_id(_s.debugID)) { |
| 3378 | + return false; |
| 3379 | + } |
| 3380 | + |
| 3381 | + var oD, oDebug, oTarget, oToggle, tmp; |
| 3382 | + |
| 3383 | + if (_s.debugMode && !_id(_s.debugID) && ((!_hasConsole || !_s.useConsole) || (_s.useConsole && _hasConsole && !_s.consoleOnly))) { |
| 3384 | + |
| 3385 | + oD = _doc.createElement('div'); |
| 3386 | + oD.id = _s.debugID + '-toggle'; |
| 3387 | + |
| 3388 | + oToggle = { |
| 3389 | + 'position': 'fixed', |
| 3390 | + 'bottom': '0px', |
| 3391 | + 'right': '0px', |
| 3392 | + 'width': '1.2em', |
| 3393 | + 'height': '1.2em', |
| 3394 | + 'lineHeight': '1.2em', |
| 3395 | + 'margin': '2px', |
| 3396 | + 'textAlign': 'center', |
| 3397 | + 'border': '1px solid #999', |
| 3398 | + 'cursor': 'pointer', |
| 3399 | + 'background': '#fff', |
| 3400 | + 'color': '#333', |
| 3401 | + 'zIndex': 10001 |
| 3402 | + }; |
| 3403 | + |
| 3404 | + oD.appendChild(_doc.createTextNode('-')); |
| 3405 | + oD.onclick = _toggleDebug; |
| 3406 | + oD.title = 'Toggle SM2 debug console'; |
| 3407 | + |
| 3408 | + if (_ua.match(/msie 6/i)) { |
| 3409 | + oD.style.position = 'absolute'; |
| 3410 | + oD.style.cursor = 'hand'; |
| 3411 | + } |
| 3412 | + |
| 3413 | + for (tmp in oToggle) { |
| 3414 | + if (oToggle.hasOwnProperty(tmp)) { |
| 3415 | + oD.style[tmp] = oToggle[tmp]; |
| 3416 | + } |
| 3417 | + } |
| 3418 | + |
| 3419 | + oDebug = _doc.createElement('div'); |
| 3420 | + oDebug.id = _s.debugID; |
| 3421 | + oDebug.style.display = (_s.debugMode?'block':'none'); |
| 3422 | + |
| 3423 | + if (_s.debugMode && !_id(oD.id)) { |
| 3424 | + try { |
| 3425 | + oTarget = _getDocument(); |
| 3426 | + oTarget.appendChild(oD); |
| 3427 | + } catch(e2) { |
| 3428 | + throw new Error(_str('domError')+' \n'+e2.toString()); |
| 3429 | + } |
| 3430 | + oTarget.appendChild(oDebug); |
| 3431 | + } |
| 3432 | + |
| 3433 | + } |
| 3434 | + |
| 3435 | + oTarget = null; |
| 3436 | + // </d> |
| 3437 | + |
| 3438 | + }; |
| 3439 | + |
| 3440 | + _idCheck = this.getSoundById; |
| 3441 | + |
| 3442 | + // <d> |
| 3443 | + _wDS = function(o, errorLevel) { |
| 3444 | + |
| 3445 | + if (!o) { |
| 3446 | + return ''; |
| 3447 | + } else { |
| 3448 | + return _s._wD(_str(o), errorLevel); |
| 3449 | + } |
| 3450 | + |
| 3451 | + }; |
| 3452 | + |
| 3453 | + // last-resort debugging option |
| 3454 | + |
| 3455 | + if (_wl.indexOf('sm2-debug=alert') + 1 && _s.debugMode) { |
| 3456 | + _s._wD = function(sText) {window.alert(sText);}; |
| 3457 | + } |
| 3458 | + |
| 3459 | + _toggleDebug = function() { |
| 3460 | + |
| 3461 | + var o = _id(_s.debugID), |
| 3462 | + oT = _id(_s.debugID + '-toggle'); |
| 3463 | + |
| 3464 | + if (!o) { |
| 3465 | + return false; |
| 3466 | + } |
| 3467 | + |
| 3468 | + if (_debugOpen) { |
| 3469 | + // minimize |
| 3470 | + oT.innerHTML = '+'; |
| 3471 | + o.style.display = 'none'; |
| 3472 | + } else { |
| 3473 | + oT.innerHTML = '-'; |
| 3474 | + o.style.display = 'block'; |
| 3475 | + } |
| 3476 | + |
| 3477 | + _debugOpen = !_debugOpen; |
| 3478 | + |
| 3479 | + }; |
| 3480 | + |
| 3481 | + _debugTS = function(sEventType, bSuccess, sMessage) { |
| 3482 | + |
| 3483 | + // troubleshooter debug hooks |
| 3484 | + |
| 3485 | + if (typeof sm2Debugger !== 'undefined') { |
| 3486 | + try { |
| 3487 | + sm2Debugger.handleEvent(sEventType, bSuccess, sMessage); |
| 3488 | + } catch(e) { |
| 3489 | + // oh well |
| 3490 | + } |
| 3491 | + } |
| 3492 | + |
| 3493 | + return true; |
| 3494 | + |
| 3495 | + }; |
| 3496 | + // </d> |
| 3497 | + |
| 3498 | + _getSWFCSS = function() { |
| 3499 | + |
| 3500 | + var css = []; |
| 3501 | + |
| 3502 | + if (_s.debugMode) { |
| 3503 | + css.push(_s.swfCSS.sm2Debug); |
| 3504 | + } |
| 3505 | + |
| 3506 | + if (_s.debugFlash) { |
| 3507 | + css.push(_s.swfCSS.flashDebug); |
| 3508 | + } |
| 3509 | + |
| 3510 | + if (_s.useHighPerformance) { |
| 3511 | + css.push(_s.swfCSS.highPerf); |
| 3512 | + } |
| 3513 | + |
| 3514 | + return css.join(' '); |
| 3515 | + |
| 3516 | + }; |
| 3517 | + |
| 3518 | + _flashBlockHandler = function() { |
| 3519 | + |
| 3520 | + // *possible* flash block situation. |
| 3521 | + |
| 3522 | + var name = _str('fbHandler'), |
| 3523 | + p = _s.getMoviePercent(), |
| 3524 | + css = _s.swfCSS, |
| 3525 | + error = {type:'FLASHBLOCK'}; |
| 3526 | + |
| 3527 | + if (_s.html5Only) { |
| 3528 | + return false; |
| 3529 | + } |
| 3530 | + |
| 3531 | + if (!_s.ok()) { |
| 3532 | + |
| 3533 | + if (_needsFlash) { |
| 3534 | + // make the movie more visible, so user can fix |
| 3535 | + _s.oMC.className = _getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError); |
| 3536 | + _s._wD(name+': '+_str('fbTimeout')+(p?' ('+_str('fbLoaded')+')':'')); |
| 3537 | + } |
| 3538 | + |
| 3539 | + _s.didFlashBlock = true; |
| 3540 | + |
| 3541 | + // fire onready(), complain lightly |
| 3542 | + _processOnEvents({type:'ontimeout', ignoreInit:true, error:error}); |
| 3543 | + _catchError(error); |
| 3544 | + |
| 3545 | + } else { |
| 3546 | + |
| 3547 | + // SM2 loaded OK (or recovered) |
| 3548 | + |
| 3549 | + if (_s.didFlashBlock) { |
| 3550 | + _s._wD(name+': Unblocked'); |
| 3551 | + } |
| 3552 | + |
| 3553 | + if (_s.oMC) { |
| 3554 | + _s.oMC.className = [_getSWFCSS(), css.swfDefault, css.swfLoaded + (_s.didFlashBlock?' '+css.swfUnblocked:'')].join(' '); |
| 3555 | + } |
| 3556 | + |
| 3557 | + } |
| 3558 | + |
| 3559 | + }; |
| 3560 | + |
| 3561 | + _addOnEvent = function(sType, oMethod, oScope) { |
| 3562 | + |
| 3563 | + if (typeof _on_queue[sType] === 'undefined') { |
| 3564 | + _on_queue[sType] = []; |
| 3565 | + } |
| 3566 | + |
| 3567 | + _on_queue[sType].push({ |
| 3568 | + 'method': oMethod, |
| 3569 | + 'scope': (oScope || null), |
| 3570 | + 'fired': false |
| 3571 | + }); |
| 3572 | + |
| 3573 | + }; |
| 3574 | + |
| 3575 | + _processOnEvents = function(oOptions) { |
| 3576 | + |
| 3577 | + // assume onready, if unspecified |
| 3578 | + |
| 3579 | + if (!oOptions) { |
| 3580 | + oOptions = { |
| 3581 | + type: 'onready' |
| 3582 | + }; |
| 3583 | + } |
| 3584 | + |
| 3585 | + if (!_didInit && oOptions && !oOptions.ignoreInit) { |
| 3586 | + // not ready yet. |
| 3587 | + return false; |
| 3588 | + } |
| 3589 | + |
| 3590 | + if (oOptions.type === 'ontimeout' && _s.ok()) { |
| 3591 | + // invalid case |
| 3592 | + return false; |
| 3593 | + } |
| 3594 | + |
| 3595 | + var status = { |
| 3596 | + success: (oOptions && oOptions.ignoreInit?_s.ok():!_disabled) |
| 3597 | + }, |
| 3598 | + |
| 3599 | + // queue specified by type, or none |
| 3600 | + srcQueue = (oOptions && oOptions.type?_on_queue[oOptions.type]||[]:[]), |
| 3601 | + |
| 3602 | + queue = [], i, j, |
| 3603 | + args = [status], |
| 3604 | + canRetry = (_needsFlash && _s.useFlashBlock && !_s.ok()); |
| 3605 | + |
| 3606 | + if (oOptions.error) { |
| 3607 | + args[0].error = oOptions.error; |
| 3608 | + } |
| 3609 | + |
| 3610 | + for (i = 0, j = srcQueue.length; i < j; i++) { |
| 3611 | + if (srcQueue[i].fired !== true) { |
| 3612 | + queue.push(srcQueue[i]); |
| 3613 | + } |
| 3614 | + } |
| 3615 | + |
| 3616 | + if (queue.length) { |
| 3617 | + _s._wD(_sm + ': Firing ' + queue.length + ' '+oOptions.type+'() item' + (queue.length === 1?'':'s')); |
| 3618 | + for (i = 0, j = queue.length; i < j; i++) { |
| 3619 | + if (queue[i].scope) { |
| 3620 | + queue[i].method.apply(queue[i].scope, args); |
| 3621 | + } else { |
| 3622 | + queue[i].method.apply(this, args); |
| 3623 | + } |
| 3624 | + if (!canRetry) { |
| 3625 | + // flashblock case doesn't count here |
| 3626 | + queue[i].fired = true; |
| 3627 | + } |
| 3628 | + } |
| 3629 | + } |
| 3630 | + |
| 3631 | + return true; |
| 3632 | + |
| 3633 | + }; |
| 3634 | + |
| 3635 | + _initUserOnload = function() { |
| 3636 | + |
| 3637 | + _win.setTimeout(function() { |
| 3638 | + |
| 3639 | + if (_s.useFlashBlock) { |
| 3640 | + _flashBlockHandler(); |
| 3641 | + } |
| 3642 | + |
| 3643 | + _processOnEvents(); |
| 3644 | + |
| 3645 | + // call user-defined "onload", scoped to window |
| 3646 | + |
| 3647 | + if (_s.onload instanceof Function) { |
| 3648 | + _wDS('onload', 1); |
| 3649 | + _s.onload.apply(_win); |
| 3650 | + _wDS('onloadOK', 1); |
| 3651 | + } |
| 3652 | + |
| 3653 | + if (_s.waitForWindowLoad) { |
| 3654 | + _event.add(_win, 'load', _initUserOnload); |
| 3655 | + } |
| 3656 | + |
| 3657 | + },1); |
| 3658 | + |
| 3659 | + }; |
| 3660 | + |
| 3661 | + _detectFlash = function() { |
| 3662 | + |
| 3663 | + // hat tip: Flash Detect library (BSD, (C) 2007) by Carl "DocYes" S. Yestrau - http://featureblend.com/javascript-flash-detection-library.html / http://featureblend.com/license.txt |
| 3664 | + |
| 3665 | + if (_hasFlash !== undefined) { |
| 3666 | + // this work has already been done. |
| 3667 | + return _hasFlash; |
| 3668 | + } |
| 3669 | + |
| 3670 | + var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = _win.ActiveXObject; |
| 3671 | + |
| 3672 | + if (nP && nP.length) { |
| 3673 | + type = 'application/x-shockwave-flash'; |
| 3674 | + types = n.mimeTypes; |
| 3675 | + if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) { |
| 3676 | + hasPlugin = true; |
| 3677 | + } |
| 3678 | + } else if (typeof AX !== 'undefined') { |
| 3679 | + try { |
| 3680 | + obj = new AX('ShockwaveFlash.ShockwaveFlash'); |
| 3681 | + } catch(e) { |
| 3682 | + // oh well |
| 3683 | + } |
| 3684 | + hasPlugin = (!!obj); |
| 3685 | + } |
| 3686 | + |
| 3687 | + _hasFlash = hasPlugin; |
| 3688 | + |
| 3689 | + return hasPlugin; |
| 3690 | + |
| 3691 | + }; |
| 3692 | + |
| 3693 | + _featureCheck = function() { |
| 3694 | + |
| 3695 | + var needsFlash, item, |
| 3696 | + |
| 3697 | + // iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (iPad) + iOS4 works. |
| 3698 | + isSpecial = (_is_iDevice && !!(_ua.match(/os (1|2|3_0|3_1)/i))); |
| 3699 | + |
| 3700 | + if (isSpecial) { |
| 3701 | + |
| 3702 | + // has Audio(), but is broken; let it load links directly. |
| 3703 | + _s.hasHTML5 = false; |
| 3704 | + |
| 3705 | + // ignore flash case, however |
| 3706 | + _s.html5Only = true; |
| 3707 | + |
| 3708 | + if (_s.oMC) { |
| 3709 | + _s.oMC.style.display = 'none'; |
| 3710 | + } |
| 3711 | + |
| 3712 | + return false; |
| 3713 | + |
| 3714 | + } |
| 3715 | + |
| 3716 | + if (_s.useHTML5Audio) { |
| 3717 | + |
| 3718 | + if (!_s.html5 || !_s.html5.canPlayType) { |
| 3719 | + _s._wD('SoundManager: No HTML5 Audio() support detected.'); |
| 3720 | + _s.hasHTML5 = false; |
| 3721 | + return true; |
| 3722 | + } else { |
| 3723 | + _s.hasHTML5 = true; |
| 3724 | + } |
| 3725 | + if (_isBadSafari) { |
| 3726 | + _s._wD(_smc+'Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - '+(!_hasFlash?' would use flash fallback for MP3/MP4, but none detected.':'will use flash fallback for MP3/MP4, if available'),1); |
| 3727 | + if (_detectFlash()) { |
| 3728 | + return true; |
| 3729 | + } |
| 3730 | + } |
| 3731 | + } else { |
| 3732 | + |
| 3733 | + // flash needed (or, HTML5 needs enabling.) |
| 3734 | + return true; |
| 3735 | + |
| 3736 | + } |
| 3737 | + |
| 3738 | + for (item in _s.audioFormats) { |
| 3739 | + if (_s.audioFormats.hasOwnProperty(item)) { |
| 3740 | + if ((_s.audioFormats[item].required && !_s.html5.canPlayType(_s.audioFormats[item].type)) || _s.flash[item] || _s.flash[_s.audioFormats[item].type]) { |
| 3741 | + // flash may be required, or preferred for this format |
| 3742 | + needsFlash = true; |
| 3743 | + } |
| 3744 | + } |
| 3745 | + } |
| 3746 | + |
| 3747 | + // sanity check.. |
| 3748 | + if (_s.ignoreFlash) { |
| 3749 | + needsFlash = false; |
| 3750 | + } |
| 3751 | + |
| 3752 | + _s.html5Only = (_s.hasHTML5 && _s.useHTML5Audio && !needsFlash); |
| 3753 | + |
| 3754 | + return (!_s.html5Only); |
| 3755 | + |
| 3756 | + }; |
| 3757 | + |
| 3758 | + _startTimer = function(oSound) { |
| 3759 | + |
| 3760 | + if (!oSound._hasTimer) { |
| 3761 | + oSound._hasTimer = true; |
| 3762 | + } |
| 3763 | + |
| 3764 | + }; |
| 3765 | + |
| 3766 | + _stopTimer = function(oSound) { |
| 3767 | + |
| 3768 | + if (oSound._hasTimer) { |
| 3769 | + oSound._hasTimer = false; |
| 3770 | + } |
| 3771 | + |
| 3772 | + }; |
| 3773 | + |
| 3774 | + _catchError = function(options) { |
| 3775 | + |
| 3776 | + options = (typeof options !== 'undefined' ? options : {}); |
| 3777 | + |
| 3778 | + if (_s.onerror instanceof Function) { |
| 3779 | + _s.onerror.apply(_win, [{type:(typeof options.type !== 'undefined' ? options.type : null)}]); |
| 3780 | + } |
| 3781 | + |
| 3782 | + if (typeof options.fatal !== 'undefined' && options.fatal) { |
| 3783 | + _s.disable(); |
| 3784 | + } |
| 3785 | + |
| 3786 | + }; |
| 3787 | + |
| 3788 | + _badSafariFix = function() { |
| 3789 | + |
| 3790 | + // special case: "bad" Safari (OS X 10.3 - 10.7) must fall back to flash for MP3/MP4 |
| 3791 | + if (!_isBadSafari || !_detectFlash()) { |
| 3792 | + // doesn't apply |
| 3793 | + return false; |
| 3794 | + } |
| 3795 | + |
| 3796 | + var aF = _s.audioFormats, i, item; |
| 3797 | + |
| 3798 | + for (item in aF) { |
| 3799 | + if (aF.hasOwnProperty(item)) { |
| 3800 | + if (item === 'mp3' || item === 'mp4') { |
| 3801 | + _s._wD(_sm+': Using flash fallback for '+item+' format'); |
| 3802 | + _s.html5[item] = false; |
| 3803 | + // assign result to related formats, too |
| 3804 | + if (aF[item] && aF[item].related) { |
| 3805 | + for (i = aF[item].related.length; i--;) { |
| 3806 | + _s.html5[aF[item].related[i]] = false; |
| 3807 | + } |
| 3808 | + } |
| 3809 | + } |
| 3810 | + } |
| 3811 | + } |
| 3812 | + |
| 3813 | + }; |
| 3814 | + |
| 3815 | + /** |
| 3816 | + * Pseudo-private flash/ExternalInterface methods |
| 3817 | + * ---------------------------------------------- |
| 3818 | + */ |
| 3819 | + |
| 3820 | + this._setSandboxType = function(sandboxType) { |
| 3821 | + |
| 3822 | + // <d> |
| 3823 | + var sb = _s.sandbox; |
| 3824 | + |
| 3825 | + sb.type = sandboxType; |
| 3826 | + sb.description = sb.types[(typeof sb.types[sandboxType] !== 'undefined'?sandboxType:'unknown')]; |
| 3827 | + |
| 3828 | + _s._wD('Flash security sandbox type: ' + sb.type); |
| 3829 | + |
| 3830 | + if (sb.type === 'localWithFile') { |
| 3831 | + |
| 3832 | + sb.noRemote = true; |
| 3833 | + sb.noLocal = false; |
| 3834 | + _wDS('secNote', 2); |
| 3835 | + |
| 3836 | + } else if (sb.type === 'localWithNetwork') { |
| 3837 | + |
| 3838 | + sb.noRemote = false; |
| 3839 | + sb.noLocal = true; |
| 3840 | + |
| 3841 | + } else if (sb.type === 'localTrusted') { |
| 3842 | + |
| 3843 | + sb.noRemote = false; |
| 3844 | + sb.noLocal = false; |
| 3845 | + |
| 3846 | + } |
| 3847 | + // </d> |
| 3848 | + |
| 3849 | + }; |
| 3850 | + |
| 3851 | + this._externalInterfaceOK = function(flashDate) { |
| 3852 | + |
| 3853 | + // flash callback confirming flash loaded, EI working etc. |
| 3854 | + // flashDate = approx. timing/delay info for JS/flash bridge |
| 3855 | + |
| 3856 | + if (_s.swfLoaded) { |
| 3857 | + return false; |
| 3858 | + } |
| 3859 | + |
| 3860 | + var eiTime = new Date().getTime(); |
| 3861 | + |
| 3862 | + _s._wD(_smc+'externalInterfaceOK()' + (flashDate?' (~' + (eiTime - flashDate) + ' ms)':'')); |
| 3863 | + _debugTS('swf', true); |
| 3864 | + _debugTS('flashtojs', true); |
| 3865 | + _s.swfLoaded = true; |
| 3866 | + _tryInitOnFocus = false; |
| 3867 | + |
| 3868 | + if (_isBadSafari) { |
| 3869 | + _badSafariFix(); |
| 3870 | + } |
| 3871 | + |
| 3872 | + if (_isIE) { |
| 3873 | + // IE needs a timeout OR delay until window.onload - may need TODO: investigating |
| 3874 | + setTimeout(_init, 100); |
| 3875 | + } else { |
| 3876 | + _init(); |
| 3877 | + } |
| 3878 | + |
| 3879 | + }; |
| 3880 | + |
| 3881 | + /** |
| 3882 | + * Private initialization helpers |
| 3883 | + * ------------------------------ |
| 3884 | + */ |
| 3885 | + |
| 3886 | + _createMovie = function(smID, smURL) { |
| 3887 | + |
| 3888 | + if (_didAppend && _appendSuccess) { |
| 3889 | + // ignore if already succeeded |
| 3890 | + return false; |
| 3891 | + } |
| 3892 | + |
| 3893 | + function _initMsg() { |
| 3894 | + _s._wD('-- SoundManager 2 ' + _s.version + (!_s.html5Only && _s.useHTML5Audio?(_s.hasHTML5?' + HTML5 audio':', no HTML5 audio support'):'') + (!_s.html5Only ? (_s.useHighPerformance?', high performance mode, ':', ') + (( _s.flashPollingInterval ? 'custom (' + _s.flashPollingInterval + 'ms)' : 'normal') + ' polling') + (_s.wmode?', wmode: ' + _s.wmode:'') + (_s.debugFlash?', flash debug mode':'') + (_s.useFlashBlock?', flashBlock mode':'') : '') + ' --', 1); |
| 3895 | + } |
| 3896 | + |
| 3897 | + if (_s.html5Only) { |
| 3898 | + |
| 3899 | + // 100% HTML5 mode |
| 3900 | + _setVersionInfo(); |
| 3901 | + |
| 3902 | + _initMsg(); |
| 3903 | + _s.oMC = _id(_s.movieID); |
| 3904 | + _init(); |
| 3905 | + |
| 3906 | + // prevent multiple init attempts |
| 3907 | + _didAppend = true; |
| 3908 | + |
| 3909 | + _appendSuccess = true; |
| 3910 | + |
| 3911 | + return false; |
| 3912 | + |
| 3913 | + } |
| 3914 | + |
| 3915 | + // flash path |
| 3916 | + var remoteURL = (smURL || _s.url), |
| 3917 | + localURL = (_s.altURL || remoteURL), |
| 3918 | + swfTitle = 'JS/Flash audio component (SoundManager 2)', |
| 3919 | + oEmbed, oMovie, oTarget = _getDocument(), tmp, movieHTML, oEl, extraClass = _getSWFCSS(), |
| 3920 | + s, x, sClass, side = 'auto', isRTL = null, |
| 3921 | + html = _doc.getElementsByTagName('html')[0]; |
| 3922 | + |
| 3923 | + isRTL = (html && html.dir && html.dir.match(/rtl/i)); |
| 3924 | + smID = (typeof smID === 'undefined'?_s.id:smID); |
| 3925 | + |
| 3926 | + function param(name, value) { |
| 3927 | + return '<param name="'+name+'" value="'+value+'" />'; |
| 3928 | + } |
| 3929 | + |
| 3930 | + // safety check for legacy (change to Flash 9 URL) |
| 3931 | + _setVersionInfo(); |
| 3932 | + _s.url = _normalizeMovieURL(_overHTTP?remoteURL:localURL); |
| 3933 | + smURL = _s.url; |
| 3934 | + |
| 3935 | + _s.wmode = (!_s.wmode && _s.useHighPerformance ? 'transparent' : _s.wmode); |
| 3936 | + |
| 3937 | + if (_s.wmode !== null && (_ua.match(/msie 8/i) || (!_isIE && !_s.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) { |
| 3938 | + /** |
| 3939 | + * extra-special case: movie doesn't load until scrolled into view when using wmode = anything but 'window' here |
| 3940 | + * does not apply when using high performance (position:fixed means on-screen), OR infinite flash load timeout |
| 3941 | + * wmode breaks IE 8 on Vista + Win7 too in some cases, as of January 2011 (?) |
| 3942 | + */ |
| 3943 | + _s.specialWmodeCase = true; |
| 3944 | + _wDS('spcWmode'); |
| 3945 | + _s.wmode = null; |
| 3946 | + } |
| 3947 | + |
| 3948 | + oEmbed = { |
| 3949 | + 'name': smID, |
| 3950 | + 'id': smID, |
| 3951 | + 'src': smURL, |
| 3952 | + 'width': side, |
| 3953 | + 'height': side, |
| 3954 | + 'quality': 'high', |
| 3955 | + 'allowScriptAccess': _s.allowScriptAccess, |
| 3956 | + 'bgcolor': _s.bgColor, |
| 3957 | + 'pluginspage': _http+'www.macromedia.com/go/getflashplayer', |
| 3958 | + 'title': swfTitle, |
| 3959 | + 'type': 'application/x-shockwave-flash', |
| 3960 | + 'wmode': _s.wmode, |
| 3961 | + // http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html |
| 3962 | + 'hasPriority': 'true' |
| 3963 | + }; |
| 3964 | + |
| 3965 | + if (_s.debugFlash) { |
| 3966 | + oEmbed.FlashVars = 'debug=1'; |
| 3967 | + } |
| 3968 | + |
| 3969 | + if (!_s.wmode) { |
| 3970 | + // don't write empty attribute |
| 3971 | + delete oEmbed.wmode; |
| 3972 | + } |
| 3973 | + |
| 3974 | + if (_isIE) { |
| 3975 | + |
| 3976 | + // IE is "special". |
| 3977 | + oMovie = _doc.createElement('div'); |
| 3978 | + movieHTML = [ |
| 3979 | + '<object id="' + smID + '" data="' + smURL + '" type="' + oEmbed.type + '" title="' + oEmbed.title +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + _http+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + oEmbed.width + '" height="' + oEmbed.height + '">', |
| 3980 | + param('movie', smURL), |
| 3981 | + param('AllowScriptAccess', _s.allowScriptAccess), |
| 3982 | + param('quality', oEmbed.quality), |
| 3983 | + (_s.wmode? param('wmode', _s.wmode): ''), |
| 3984 | + param('bgcolor', _s.bgColor), |
| 3985 | + param('hasPriority', 'true'), |
| 3986 | + (_s.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''), |
| 3987 | + '</object>' |
| 3988 | + ].join(''); |
| 3989 | + |
| 3990 | + } else { |
| 3991 | + |
| 3992 | + oMovie = _doc.createElement('embed'); |
| 3993 | + for (tmp in oEmbed) { |
| 3994 | + if (oEmbed.hasOwnProperty(tmp)) { |
| 3995 | + oMovie.setAttribute(tmp, oEmbed[tmp]); |
| 3996 | + } |
| 3997 | + } |
| 3998 | + |
| 3999 | + } |
| 4000 | + |
| 4001 | + _initDebug(); |
| 4002 | + extraClass = _getSWFCSS(); |
| 4003 | + oTarget = _getDocument(); |
| 4004 | + |
| 4005 | + if (oTarget) { |
| 4006 | + |
| 4007 | + _s.oMC = (_id(_s.movieID) || _doc.createElement('div')); |
| 4008 | + |
| 4009 | + if (!_s.oMC.id) { |
| 4010 | + |
| 4011 | + _s.oMC.id = _s.movieID; |
| 4012 | + _s.oMC.className = _s.swfCSS.swfDefault + ' ' + extraClass; |
| 4013 | + s = null; |
| 4014 | + oEl = null; |
| 4015 | + |
| 4016 | + if (!_s.useFlashBlock) { |
| 4017 | + if (_s.useHighPerformance) { |
| 4018 | + // on-screen at all times |
| 4019 | + s = { |
| 4020 | + 'position': 'fixed', |
| 4021 | + 'width': '8px', |
| 4022 | + 'height': '8px', |
| 4023 | + // >= 6px for flash to run fast, >= 8px to start up under Firefox/win32 in some cases. odd? yes. |
| 4024 | + 'bottom': '0px', |
| 4025 | + 'left': '0px', |
| 4026 | + 'overflow': 'hidden' |
| 4027 | + }; |
| 4028 | + } else { |
| 4029 | + // hide off-screen, lower priority |
| 4030 | + s = { |
| 4031 | + 'position': 'absolute', |
| 4032 | + 'width': '6px', |
| 4033 | + 'height': '6px', |
| 4034 | + 'top': '-9999px', |
| 4035 | + 'left': '-9999px' |
| 4036 | + }; |
| 4037 | + if (isRTL) { |
| 4038 | + s.left = Math.abs(parseInt(s.left,10))+'px'; |
| 4039 | + } |
| 4040 | + } |
| 4041 | + } |
| 4042 | + |
| 4043 | + if (_isWebkit) { |
| 4044 | + // soundcloud-reported render/crash fix, safari 5 |
| 4045 | + _s.oMC.style.zIndex = 10000; |
| 4046 | + } |
| 4047 | + |
| 4048 | + if (!_s.debugFlash) { |
| 4049 | + for (x in s) { |
| 4050 | + if (s.hasOwnProperty(x)) { |
| 4051 | + _s.oMC.style[x] = s[x]; |
| 4052 | + } |
| 4053 | + } |
| 4054 | + } |
| 4055 | + |
| 4056 | + try { |
| 4057 | + if (!_isIE) { |
| 4058 | + _s.oMC.appendChild(oMovie); |
| 4059 | + } |
| 4060 | + oTarget.appendChild(_s.oMC); |
| 4061 | + if (_isIE) { |
| 4062 | + oEl = _s.oMC.appendChild(_doc.createElement('div')); |
| 4063 | + oEl.className = _s.swfCSS.swfBox; |
| 4064 | + oEl.innerHTML = movieHTML; |
| 4065 | + } |
| 4066 | + _appendSuccess = true; |
| 4067 | + } catch(e) { |
| 4068 | + throw new Error(_str('domError')+' \n'+e.toString()); |
| 4069 | + } |
| 4070 | + |
| 4071 | + } else { |
| 4072 | + |
| 4073 | + // SM2 container is already in the document (eg. flashblock use case) |
| 4074 | + sClass = _s.oMC.className; |
| 4075 | + _s.oMC.className = (sClass?sClass+' ':_s.swfCSS.swfDefault) + (extraClass?' '+extraClass:''); |
| 4076 | + _s.oMC.appendChild(oMovie); |
| 4077 | + if (_isIE) { |
| 4078 | + oEl = _s.oMC.appendChild(_doc.createElement('div')); |
| 4079 | + oEl.className = _s.swfCSS.swfBox; |
| 4080 | + oEl.innerHTML = movieHTML; |
| 4081 | + } |
| 4082 | + _appendSuccess = true; |
| 4083 | + |
| 4084 | + } |
| 4085 | + |
| 4086 | + } |
| 4087 | + |
| 4088 | + _didAppend = true; |
| 4089 | + _initMsg(); |
| 4090 | + _s._wD(_smc+'createMovie(): Trying to load ' + smURL + (!_overHTTP && _s.altURL?' (alternate URL)':''), 1); |
| 4091 | + |
| 4092 | + return true; |
| 4093 | + |
| 4094 | + }; |
| 4095 | + |
| 4096 | + _initMovie = function() { |
| 4097 | + |
| 4098 | + if (_s.html5Only) { |
| 4099 | + _createMovie(); |
| 4100 | + return false; |
| 4101 | + } |
| 4102 | + |
| 4103 | + // attempt to get, or create, movie |
| 4104 | + // may already exist |
| 4105 | + if (_s.o) { |
| 4106 | + return false; |
| 4107 | + } |
| 4108 | + |
| 4109 | + // inline markup case |
| 4110 | + _s.o = _s.getMovie(_s.id); |
| 4111 | + |
| 4112 | + if (!_s.o) { |
| 4113 | + if (!_oRemoved) { |
| 4114 | + // try to create |
| 4115 | + _createMovie(_s.id, _s.url); |
| 4116 | + } else { |
| 4117 | + // try to re-append removed movie after reboot() |
| 4118 | + if (!_isIE) { |
| 4119 | + _s.oMC.appendChild(_oRemoved); |
| 4120 | + } else { |
| 4121 | + _s.oMC.innerHTML = _oRemovedHTML; |
| 4122 | + } |
| 4123 | + _oRemoved = null; |
| 4124 | + _didAppend = true; |
| 4125 | + } |
| 4126 | + _s.o = _s.getMovie(_s.id); |
| 4127 | + } |
| 4128 | + |
| 4129 | + // <d> |
| 4130 | + if (_s.o) { |
| 4131 | + _wDS('waitEI'); |
| 4132 | + } |
| 4133 | + // </d> |
| 4134 | + |
| 4135 | + if (_s.oninitmovie instanceof Function) { |
| 4136 | + setTimeout(_s.oninitmovie, 1); |
| 4137 | + } |
| 4138 | + |
| 4139 | + return true; |
| 4140 | + |
| 4141 | + }; |
| 4142 | + |
| 4143 | + _delayWaitForEI = function() { |
| 4144 | + |
| 4145 | + setTimeout(_waitForEI, 1000); |
| 4146 | + |
| 4147 | + }; |
| 4148 | + |
| 4149 | + _waitForEI = function() { |
| 4150 | + |
| 4151 | + if (_waitingForEI) { |
| 4152 | + return false; |
| 4153 | + } |
| 4154 | + |
| 4155 | + _waitingForEI = true; |
| 4156 | + _event.remove(_win, 'load', _delayWaitForEI); |
| 4157 | + |
| 4158 | + if (_tryInitOnFocus && !_isFocused) { |
| 4159 | + // giant Safari 3.1 hack - assume mousemove = focus given lack of focus event |
| 4160 | + _wDS('waitFocus'); |
| 4161 | + return false; |
| 4162 | + } |
| 4163 | + |
| 4164 | + var p; |
| 4165 | + if (!_didInit) { |
| 4166 | + p = _s.getMoviePercent(); |
| 4167 | + _s._wD(_str('waitImpatient', (p === 100?' (SWF loaded)':(p > 0?' (SWF ' + p + '% loaded)':'')))); |
| 4168 | + } |
| 4169 | + |
| 4170 | + setTimeout(function() { |
| 4171 | + |
| 4172 | + p = _s.getMoviePercent(); |
| 4173 | + |
| 4174 | + // <d> |
| 4175 | + if (!_didInit) { |
| 4176 | + _s._wD(_sm + ': No Flash response within expected time.\nLikely causes: ' + (p === 0?'Loading ' + _s.movieURL + ' may have failed (and/or Flash ' + _fV + '+ not present?), ':'') + 'Flash blocked or JS-Flash security error.' + (_s.debugFlash?' ' + _str('checkSWF'):''), 2); |
| 4177 | + if (!_overHTTP && p) { |
| 4178 | + _wDS('localFail', 2); |
| 4179 | + if (!_s.debugFlash) { |
| 4180 | + _wDS('tryDebug', 2); |
| 4181 | + } |
| 4182 | + } |
| 4183 | + if (p === 0) { |
| 4184 | + // if 0 (not null), probably a 404. |
| 4185 | + _s._wD(_str('swf404', _s.url)); |
| 4186 | + } |
| 4187 | + _debugTS('flashtojs', false, ': Timed out' + _overHTTP?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)'); |
| 4188 | + } |
| 4189 | + // </d> |
| 4190 | + |
| 4191 | + // give up / time-out, depending |
| 4192 | + |
| 4193 | + if (!_didInit && _okToDisable) { |
| 4194 | + if (p === null) { |
| 4195 | + // SWF failed. Maybe blocked. |
| 4196 | + if (_s.useFlashBlock || _s.flashLoadTimeout === 0) { |
| 4197 | + if (_s.useFlashBlock) { |
| 4198 | + _flashBlockHandler(); |
| 4199 | + } |
| 4200 | + _wDS('waitForever'); |
| 4201 | + } else { |
| 4202 | + // old SM2 behaviour, simply fail |
| 4203 | + _failSafely(true); |
| 4204 | + } |
| 4205 | + } else { |
| 4206 | + // flash loaded? Shouldn't be a blocking issue, then. |
| 4207 | + if (_s.flashLoadTimeout === 0) { |
| 4208 | + _wDS('waitForever'); |
| 4209 | + } else { |
| 4210 | + _failSafely(true); |
| 4211 | + } |
| 4212 | + } |
| 4213 | + } |
| 4214 | + |
| 4215 | + }, _s.flashLoadTimeout); |
| 4216 | + |
| 4217 | + }; |
| 4218 | + |
| 4219 | + _handleFocus = function() { |
| 4220 | + |
| 4221 | + function cleanup() { |
| 4222 | + _event.remove(_win, 'focus', _handleFocus); |
| 4223 | + _event.remove(_win, 'load', _handleFocus); |
| 4224 | + } |
| 4225 | + |
| 4226 | + if (_isFocused || !_tryInitOnFocus) { |
| 4227 | + cleanup(); |
| 4228 | + return true; |
| 4229 | + } |
| 4230 | + |
| 4231 | + _okToDisable = true; |
| 4232 | + _isFocused = true; |
| 4233 | + _s._wD(_smc+'handleFocus()'); |
| 4234 | + |
| 4235 | + if (_isSafari && _tryInitOnFocus) { |
| 4236 | + _event.remove(_win, 'mousemove', _handleFocus); |
| 4237 | + } |
| 4238 | + |
| 4239 | + // allow init to restart |
| 4240 | + _waitingForEI = false; |
| 4241 | + |
| 4242 | + cleanup(); |
| 4243 | + return true; |
| 4244 | + |
| 4245 | + }; |
| 4246 | + |
| 4247 | + _showSupport = function() { |
| 4248 | + |
| 4249 | + var item, tests = []; |
| 4250 | + |
| 4251 | + if (_s.useHTML5Audio && _s.hasHTML5) { |
| 4252 | + for (item in _s.audioFormats) { |
| 4253 | + if (_s.audioFormats.hasOwnProperty(item)) { |
| 4254 | + tests.push(item + ': ' + _s.html5[item] + (!_s.html5[item] && _hasFlash && _s.flash[item] ? ' (using flash)' : (_s.preferFlash && _s.flash[item] && _hasFlash ? ' (preferring flash)': (!_s.html5[item] ? ' (' + (_s.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : '')))); |
| 4255 | + } |
| 4256 | + } |
| 4257 | + _s._wD('-- SoundManager 2: HTML5 support tests ('+_s.html5Test+'): '+tests.join(', ')+' --',1); |
| 4258 | + } |
| 4259 | + |
| 4260 | + }; |
| 4261 | + |
| 4262 | + _initComplete = function(bNoDisable) { |
| 4263 | + |
| 4264 | + if (_didInit) { |
| 4265 | + return false; |
| 4266 | + } |
| 4267 | + |
| 4268 | + if (_s.html5Only) { |
| 4269 | + // all good. |
| 4270 | + _s._wD('-- SoundManager 2: loaded --'); |
| 4271 | + _didInit = true; |
| 4272 | + _initUserOnload(); |
| 4273 | + _debugTS('onload', true); |
| 4274 | + return true; |
| 4275 | + } |
| 4276 | + |
| 4277 | + var wasTimeout = (_s.useFlashBlock && _s.flashLoadTimeout && !_s.getMoviePercent()), |
| 4278 | + error; |
| 4279 | + |
| 4280 | + if (!wasTimeout) { |
| 4281 | + _didInit = true; |
| 4282 | + if (_disabled) { |
| 4283 | + error = {type: (!_hasFlash && _needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')}; |
| 4284 | + } |
| 4285 | + } |
| 4286 | + |
| 4287 | + _s._wD('-- SoundManager 2 ' + (_disabled?'failed to load':'loaded') + ' (' + (_disabled?'security/load error':'OK') + ') --', 1); |
| 4288 | + |
| 4289 | + if (_disabled || bNoDisable) { |
| 4290 | + if (_s.useFlashBlock && _s.oMC) { |
| 4291 | + _s.oMC.className = _getSWFCSS() + ' ' + (_s.getMoviePercent() === null?_s.swfCSS.swfTimedout:_s.swfCSS.swfError); |
| 4292 | + } |
| 4293 | + _processOnEvents({type:'ontimeout', error:error}); |
| 4294 | + _debugTS('onload', false); |
| 4295 | + _catchError(error); |
| 4296 | + return false; |
| 4297 | + } else { |
| 4298 | + _debugTS('onload', true); |
| 4299 | + } |
| 4300 | + |
| 4301 | + if (_s.waitForWindowLoad && !_windowLoaded) { |
| 4302 | + _wDS('waitOnload'); |
| 4303 | + _event.add(_win, 'load', _initUserOnload); |
| 4304 | + return false; |
| 4305 | + } else { |
| 4306 | + // <d> |
| 4307 | + if (_s.waitForWindowLoad && _windowLoaded) { |
| 4308 | + _wDS('docLoaded'); |
| 4309 | + } |
| 4310 | + // </d> |
| 4311 | + _initUserOnload(); |
| 4312 | + } |
| 4313 | + |
| 4314 | + return true; |
| 4315 | + |
| 4316 | + }; |
| 4317 | + |
| 4318 | + _init = function() { |
| 4319 | + |
| 4320 | + _wDS('init'); |
| 4321 | + |
| 4322 | + // called after onload() |
| 4323 | + |
| 4324 | + if (_didInit) { |
| 4325 | + _wDS('didInit'); |
| 4326 | + return false; |
| 4327 | + } |
| 4328 | + |
| 4329 | + function _cleanup() { |
| 4330 | + _event.remove(_win, 'load', _s.beginDelayedInit); |
| 4331 | + } |
| 4332 | + |
| 4333 | + if (_s.html5Only) { |
| 4334 | + if (!_didInit) { |
| 4335 | + // we don't need no steenking flash! |
| 4336 | + _cleanup(); |
| 4337 | + _s.enabled = true; |
| 4338 | + _initComplete(); |
| 4339 | + } |
| 4340 | + return true; |
| 4341 | + } |
| 4342 | + |
| 4343 | + // flash path |
| 4344 | + _initMovie(); |
| 4345 | + |
| 4346 | + try { |
| 4347 | + |
| 4348 | + _wDS('flashJS'); |
| 4349 | + |
| 4350 | + // attempt to talk to Flash |
| 4351 | + _s.o._externalInterfaceTest(false); |
| 4352 | + |
| 4353 | + // apply user-specified polling interval, OR, if "high performance" set, faster vs. default polling |
| 4354 | + // (determines frequency of whileloading/whileplaying callbacks, effectively driving UI framerates) |
| 4355 | + _setPolling(true, (_s.flashPollingInterval || (_s.useHighPerformance ? 10 : 50))); |
| 4356 | + |
| 4357 | + if (!_s.debugMode) { |
| 4358 | + // stop the SWF from making debug output calls to JS |
| 4359 | + _s.o._disableDebug(); |
| 4360 | + } |
| 4361 | + |
| 4362 | + _s.enabled = true; |
| 4363 | + _debugTS('jstoflash', true); |
| 4364 | + |
| 4365 | + if (!_s.html5Only) { |
| 4366 | + // prevent browser from showing cached page state (or rather, restoring "suspended" page state) via back button, because flash may be dead |
| 4367 | + // http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/ |
| 4368 | + _event.add(_win, 'unload', _doNothing); |
| 4369 | + } |
| 4370 | + |
| 4371 | + } catch(e) { |
| 4372 | + |
| 4373 | + _s._wD('js/flash exception: ' + e.toString()); |
| 4374 | + _debugTS('jstoflash', false); |
| 4375 | + _catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true}); |
| 4376 | + // don't disable, for reboot() |
| 4377 | + _failSafely(true); |
| 4378 | + _initComplete(); |
| 4379 | + |
| 4380 | + return false; |
| 4381 | + |
| 4382 | + } |
| 4383 | + |
| 4384 | + _initComplete(); |
| 4385 | + |
| 4386 | + // disconnect events |
| 4387 | + _cleanup(); |
| 4388 | + |
| 4389 | + return true; |
| 4390 | + |
| 4391 | + }; |
| 4392 | + |
| 4393 | + _domContentLoaded = function() { |
| 4394 | + |
| 4395 | + if (_didDCLoaded) { |
| 4396 | + return false; |
| 4397 | + } |
| 4398 | + |
| 4399 | + _didDCLoaded = true; |
| 4400 | + _initDebug(); |
| 4401 | + |
| 4402 | + /** |
| 4403 | + * Temporary feature: allow force of HTML5 via URL params: sm2-usehtml5audio=0 or 1 |
| 4404 | + * Ditto for sm2-preferFlash, too. |
| 4405 | + */ |
| 4406 | + // <d> |
| 4407 | + (function(){ |
| 4408 | + |
| 4409 | + var a = 'sm2-usehtml5audio=', l = _wl.toLowerCase(), b = null, |
| 4410 | + a2 = 'sm2-preferflash=', b2 = null, hasCon = (typeof console !== 'undefined' && typeof console.log !== 'undefined'); |
| 4411 | + |
| 4412 | + if (l.indexOf(a) !== -1) { |
| 4413 | + b = (l.charAt(l.indexOf(a)+a.length) === '1'); |
| 4414 | + if (hasCon) { |
| 4415 | + console.log((b?'Enabling ':'Disabling ')+'useHTML5Audio via URL parameter'); |
| 4416 | + } |
| 4417 | + _s.useHTML5Audio = b; |
| 4418 | + } |
| 4419 | + |
| 4420 | + if (l.indexOf(a2) !== -1) { |
| 4421 | + b2 = (l.charAt(l.indexOf(a2)+a2.length) === '1'); |
| 4422 | + if (hasCon) { |
| 4423 | + console.log((b2?'Enabling ':'Disabling ')+'preferFlash via URL parameter'); |
| 4424 | + } |
| 4425 | + _s.preferFlash = b2; |
| 4426 | + } |
| 4427 | + |
| 4428 | + }()); |
| 4429 | + // </d> |
| 4430 | + |
| 4431 | + if (!_hasFlash && _s.hasHTML5) { |
| 4432 | + _s._wD('SoundManager: No Flash detected'+(!_s.useHTML5Audio?', enabling HTML5.':'. Trying HTML5-only mode.')); |
| 4433 | + _s.useHTML5Audio = true; |
| 4434 | + // make sure we aren't preferring flash, either |
| 4435 | + // TODO: preferFlash should not matter if flash is not installed. Currently, stuff breaks without the below tweak. |
| 4436 | + _s.preferFlash = false; |
| 4437 | + } |
| 4438 | + |
| 4439 | + _testHTML5(); |
| 4440 | + _s.html5.usingFlash = _featureCheck(); |
| 4441 | + _needsFlash = _s.html5.usingFlash; |
| 4442 | + _showSupport(); |
| 4443 | + |
| 4444 | + if (!_hasFlash && _needsFlash) { |
| 4445 | + _s._wD('SoundManager: Fatal error: Flash is needed to play some required formats, but is not available.'); |
| 4446 | + // TODO: Fatal here vs. timeout approach, etc. |
| 4447 | + // hack: fail sooner. |
| 4448 | + _s.flashLoadTimeout = 1; |
| 4449 | + } |
| 4450 | + |
| 4451 | + if (_doc.removeEventListener) { |
| 4452 | + _doc.removeEventListener('DOMContentLoaded', _domContentLoaded, false); |
| 4453 | + } |
| 4454 | + |
| 4455 | + _initMovie(); |
| 4456 | + return true; |
| 4457 | + |
| 4458 | + }; |
| 4459 | + |
| 4460 | + _domContentLoadedIE = function() { |
| 4461 | + |
| 4462 | + if (_doc.readyState === 'complete') { |
| 4463 | + _domContentLoaded(); |
| 4464 | + _doc.detachEvent('onreadystatechange', _domContentLoadedIE); |
| 4465 | + } |
| 4466 | + |
| 4467 | + return true; |
| 4468 | + |
| 4469 | + }; |
| 4470 | + |
| 4471 | + // sniff up-front |
| 4472 | + _detectFlash(); |
| 4473 | + |
| 4474 | + // focus and window load, init (primarily flash-driven) |
| 4475 | + _event.add(_win, 'focus', _handleFocus); |
| 4476 | + _event.add(_win, 'load', _handleFocus); |
| 4477 | + _event.add(_win, 'load', _delayWaitForEI); |
| 4478 | + |
| 4479 | + if (_isSafari && _tryInitOnFocus) { |
| 4480 | + // massive Safari 3.1 focus detection hack |
| 4481 | + _event.add(_win, 'mousemove', _handleFocus); |
| 4482 | + } |
| 4483 | + |
| 4484 | + if (_doc.addEventListener) { |
| 4485 | + |
| 4486 | + _doc.addEventListener('DOMContentLoaded', _domContentLoaded, false); |
| 4487 | + |
| 4488 | + } else if (_doc.attachEvent) { |
| 4489 | + |
| 4490 | + _doc.attachEvent('onreadystatechange', _domContentLoadedIE); |
| 4491 | + |
| 4492 | + } else { |
| 4493 | + |
| 4494 | + // no add/attachevent support - safe to assume no JS -> Flash either |
| 4495 | + _debugTS('onload', false); |
| 4496 | + _catchError({type:'NO_DOM2_EVENTS', fatal:true}); |
| 4497 | + |
| 4498 | + } |
| 4499 | + |
| 4500 | + if (_doc.readyState === 'complete') { |
| 4501 | + // DOMReady has already happened. |
| 4502 | + setTimeout(_domContentLoaded,100); |
| 4503 | + } |
| 4504 | + |
| 4505 | +} // SoundManager() |
| 4506 | + |
| 4507 | +// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading |
| 4508 | + |
| 4509 | +if (typeof SM2_DEFER === 'undefined' || !SM2_DEFER) { |
| 4510 | + soundManager = new SoundManager(); |
| 4511 | +} |
| 4512 | + |
| 4513 | +/** |
| 4514 | + * SoundManager public interfaces |
| 4515 | + * ------------------------------ |
| 4516 | + */ |
| 4517 | + |
| 4518 | +window.SoundManager = SoundManager; // constructor |
| 4519 | +window.soundManager = soundManager; // public API, flash callbacks etc. |
| 4520 | + |
| 4521 | +}(window)); |
\ No newline at end of file |
Property changes on: trunk/extensions/SoundManager2Button/script/soundmanager2.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 4522 | + native |
Index: trunk/extensions/SoundManager2Button/script/soundmanager2-nodebug.js |
— | — | @@ -0,0 +1,2184 @@ |
| 2 | +/** @license |
| 3 | + * |
| 4 | + * SoundManager 2: JavaScript Sound for the Web |
| 5 | + * ---------------------------------------------- |
| 6 | + * http://schillmania.com/projects/soundmanager2/ |
| 7 | + * |
| 8 | + * Copyright (c) 2007, Scott Schiller. All rights reserved. |
| 9 | + * Code provided under the BSD License: |
| 10 | + * http://schillmania.com/projects/soundmanager2/license.txt |
| 11 | + * |
| 12 | + * V2.97a.20111030 |
| 13 | + */ |
| 14 | + |
| 15 | +/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio */ |
| 16 | +/* jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true */ |
| 17 | + |
| 18 | +(function(window) { |
| 19 | +var soundManager = null; |
| 20 | +function SoundManager(smURL, smID) { |
| 21 | + this.flashVersion = 8; |
| 22 | + this.debugMode = false; |
| 23 | + this.debugFlash = false; |
| 24 | + this.useConsole = true; |
| 25 | + this.consoleOnly = false; |
| 26 | + this.waitForWindowLoad = false; |
| 27 | + this.bgColor = '#ffffff'; |
| 28 | + this.useHighPerformance = false; |
| 29 | + this.flashPollingInterval = null; |
| 30 | + this.flashLoadTimeout = 1000; |
| 31 | + this.wmode = null; |
| 32 | + this.allowScriptAccess = 'always'; |
| 33 | + this.useFlashBlock = false; |
| 34 | + this.useHTML5Audio = true; |
| 35 | + this.html5Test = /^(probably|maybe)$/i; |
| 36 | + this.preferFlash = true; |
| 37 | + this.noSWFCache = false; |
| 38 | + this.audioFormats = { |
| 39 | + 'mp3': { |
| 40 | + 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'], |
| 41 | + 'required': true |
| 42 | + }, |
| 43 | + 'mp4': { |
| 44 | + 'related': ['aac','m4a'], |
| 45 | + 'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'], |
| 46 | + 'required': false |
| 47 | + }, |
| 48 | + 'ogg': { |
| 49 | + 'type': ['audio/ogg; codecs=vorbis'], |
| 50 | + 'required': false |
| 51 | + }, |
| 52 | + 'wav': { |
| 53 | + 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'], |
| 54 | + 'required': false |
| 55 | + } |
| 56 | + }; |
| 57 | + this.defaultOptions = { |
| 58 | + 'autoLoad': false, |
| 59 | + 'stream': true, |
| 60 | + 'autoPlay': false, |
| 61 | + 'loops': 1, |
| 62 | + 'onid3': null, |
| 63 | + 'onload': null, |
| 64 | + 'whileloading': null, |
| 65 | + 'onplay': null, |
| 66 | + 'onpause': null, |
| 67 | + 'onresume': null, |
| 68 | + 'whileplaying': null, |
| 69 | + 'onstop': null, |
| 70 | + 'onfailure': null, |
| 71 | + 'onfinish': null, |
| 72 | + 'multiShot': true, |
| 73 | + 'multiShotEvents': false, |
| 74 | + 'position': null, |
| 75 | + 'pan': 0, |
| 76 | + 'type': null, |
| 77 | + 'usePolicyFile': false, |
| 78 | + 'volume': 100 |
| 79 | + }; |
| 80 | + this.flash9Options = { |
| 81 | + 'isMovieStar': null, |
| 82 | + 'usePeakData': false, |
| 83 | + 'useWaveformData': false, |
| 84 | + 'useEQData': false, |
| 85 | + 'onbufferchange': null, |
| 86 | + 'ondataerror': null |
| 87 | + }; |
| 88 | + this.movieStarOptions = { |
| 89 | + 'bufferTime': 3, |
| 90 | + 'serverURL': null, |
| 91 | + 'onconnect': null, |
| 92 | + 'duration': null |
| 93 | + }; |
| 94 | + this.movieID = 'sm2-container'; |
| 95 | + this.id = (smID || 'sm2movie'); |
| 96 | + this.swfCSS = { |
| 97 | + 'swfBox': 'sm2-object-box', |
| 98 | + 'swfDefault': 'movieContainer', |
| 99 | + 'swfError': 'swf_error', |
| 100 | + 'swfTimedout': 'swf_timedout', |
| 101 | + 'swfLoaded': 'swf_loaded', |
| 102 | + 'swfUnblocked': 'swf_unblocked', |
| 103 | + 'sm2Debug': 'sm2_debug', |
| 104 | + 'highPerf': 'high_performance', |
| 105 | + 'flashDebug': 'flash_debug' |
| 106 | + }; |
| 107 | + this.debugID = 'soundmanager-debug'; |
| 108 | + this.debugURLParam = /([#?&])debug=1/i; |
| 109 | + this.versionNumber = 'V2.97a.20111030'; |
| 110 | + this.version = null; |
| 111 | + this.movieURL = null; |
| 112 | + this.url = (smURL || null); |
| 113 | + this.altURL = null; |
| 114 | + this.swfLoaded = false; |
| 115 | + this.enabled = false; |
| 116 | + this.o = null; |
| 117 | + this.oMC = null; |
| 118 | + this.sounds = {}; |
| 119 | + this.soundIDs = []; |
| 120 | + this.muted = false; |
| 121 | + this.specialWmodeCase = false; |
| 122 | + this.didFlashBlock = false; |
| 123 | + this.filePattern = null; |
| 124 | + this.filePatterns = { |
| 125 | + 'flash8': /\.mp3(\?.*)?$/i, |
| 126 | + 'flash9': /\.mp3(\?.*)?$/i |
| 127 | + }; |
| 128 | + this.features = { |
| 129 | + 'buffering': false, |
| 130 | + 'peakData': false, |
| 131 | + 'waveformData': false, |
| 132 | + 'eqData': false, |
| 133 | + 'movieStar': false |
| 134 | + }; |
| 135 | + this.sandbox = { |
| 136 | + }; |
| 137 | + this.hasHTML5 = (function() { |
| 138 | + try { |
| 139 | + return (typeof Audio !== 'undefined' && typeof new Audio().canPlayType !== 'undefined'); |
| 140 | + } catch(e) { |
| 141 | + return false; |
| 142 | + } |
| 143 | + }()); |
| 144 | + this.html5 = { |
| 145 | + 'usingFlash': null |
| 146 | + }; |
| 147 | + this.flash = {}; |
| 148 | + this.html5Only = false; |
| 149 | + this.ignoreFlash = false; |
| 150 | + var SMSound, |
| 151 | + _s = this, _sm = 'soundManager', _smc = _sm+'::', _h5 = 'HTML5::', _id, _ua = navigator.userAgent, _win = window, _wl = _win.location.href.toString(), _doc = document, _doNothing, _init, _fV, _on_queue = [], _debugOpen = true, _debugTS, _didAppend = false, _appendSuccess = false, _didInit = false, _disabled = false, _windowLoaded = false, _wDS, _wdCount = 0, _initComplete, _mixin, _addOnEvent, _processOnEvents, _initUserOnload, _delayWaitForEI, _waitForEI, _setVersionInfo, _handleFocus, _strings, _initMovie, _domContentLoaded, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _smTimer, _onTimer, _startTimer, _stopTimer, _needsFlash = null, _featureCheck, _html5OK, _html5CanPlay, _html5Ext, _html5Unload, _domContentLoadedIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix, _html5_events, _showSupport, |
| 152 | + _is_iDevice = _ua.match(/(ipad|iphone|ipod)/i), _is_firefox = _ua.match(/firefox/i), _is_android = _ua.match(/droid/i), _isIE = _ua.match(/msie/i), _isWebkit = _ua.match(/webkit/i), _isSafari = (_ua.match(/safari/i) && !_ua.match(/chrome/i)), _isOpera = (_ua.match(/opera/i)), |
| 153 | + _likesHTML5 = (_ua.match(/(mobile|pre\/|xoom)/i) || _is_iDevice), |
| 154 | + _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && _ua.match(/OS X 10_6_([3-7])/i)), |
| 155 | + _hasConsole = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (_isSafari && typeof _doc.hasFocus === 'undefined'), _okToDisable = !_tryInitOnFocus, _flashMIME = /(mp3|mp4|mpa)/i, |
| 156 | + _emptyURL = 'about:blank', |
| 157 | + _overHTTP = (_doc.location?_doc.location.protocol.match(/http/i):null), |
| 158 | + _http = (!_overHTTP ? 'http:/'+'/' : ''), |
| 159 | + _netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i, |
| 160 | + _netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'mp4v', '3gp', '3g2'], |
| 161 | + _netStreamPattern = new RegExp('\\.(' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); |
| 162 | + this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; |
| 163 | + this.useAltURL = !_overHTTP; |
| 164 | + this._global_a = null; |
| 165 | + if (_likesHTML5) { |
| 166 | + _s.useHTML5Audio = true; |
| 167 | + _s.preferFlash = false; |
| 168 | + if (_is_iDevice) { |
| 169 | + _s.ignoreFlash = true; |
| 170 | + _useGlobalHTML5Audio = true; |
| 171 | + } |
| 172 | + } |
| 173 | + this.ok = function() { |
| 174 | + return (_needsFlash?(_didInit && !_disabled):(_s.useHTML5Audio && _s.hasHTML5)); |
| 175 | + }; |
| 176 | + this.supported = this.ok; |
| 177 | + this.getMovie = function(smID) { |
| 178 | + return _id(smID) || _doc[smID] || _win[smID]; |
| 179 | + }; |
| 180 | + this.createSound = function(oOptions) { |
| 181 | + var _cs = _sm+'.createSound(): ', |
| 182 | + thisOptions = null, oSound = null, _tO = null; |
| 183 | + if (!_didInit || !_s.ok()) { |
| 184 | + _complain(_cs + _str(!_didInit?'notReady':'notOK')); |
| 185 | + return false; |
| 186 | + } |
| 187 | + if (arguments.length === 2) { |
| 188 | + oOptions = { |
| 189 | + 'id': arguments[0], |
| 190 | + 'url': arguments[1] |
| 191 | + }; |
| 192 | + } |
| 193 | + thisOptions = _mixin(oOptions); |
| 194 | + _tO = thisOptions; |
| 195 | + if (_idCheck(_tO.id, true)) { |
| 196 | + return _s.sounds[_tO.id]; |
| 197 | + } |
| 198 | + function make() { |
| 199 | + thisOptions = _loopFix(thisOptions); |
| 200 | + _s.sounds[_tO.id] = new SMSound(_tO); |
| 201 | + _s.soundIDs.push(_tO.id); |
| 202 | + return _s.sounds[_tO.id]; |
| 203 | + } |
| 204 | + if (_html5OK(_tO)) { |
| 205 | + oSound = make(); |
| 206 | + oSound._setup_html5(_tO); |
| 207 | + } else { |
| 208 | + if (_fV > 8) { |
| 209 | + if (_tO.isMovieStar === null) { |
| 210 | + _tO.isMovieStar = (_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern)); |
| 211 | + } |
| 212 | + if (_tO.isMovieStar) { |
| 213 | + if (_tO.usePeakData) { |
| 214 | + _tO.usePeakData = false; |
| 215 | + } |
| 216 | + } |
| 217 | + } |
| 218 | + _tO = _policyFix(_tO, _cs); |
| 219 | + oSound = make(); |
| 220 | + if (_fV === 8) { |
| 221 | + _s.o._createSound(_tO.id, _tO.loops||1, _tO.usePolicyFile); |
| 222 | + } else { |
| 223 | + _s.o._createSound(_tO.id, _tO.url, _tO.usePeakData, _tO.useWaveformData, _tO.useEQData, _tO.isMovieStar, (_tO.isMovieStar?_tO.bufferTime:false), _tO.loops||1, _tO.serverURL, _tO.duration||null, _tO.autoPlay, true, _tO.autoLoad, _tO.usePolicyFile); |
| 224 | + if (!_tO.serverURL) { |
| 225 | + oSound.connected = true; |
| 226 | + if (_tO.onconnect) { |
| 227 | + _tO.onconnect.apply(oSound); |
| 228 | + } |
| 229 | + } |
| 230 | + } |
| 231 | + if (!_tO.serverURL && (_tO.autoLoad || _tO.autoPlay)) { |
| 232 | + oSound.load(_tO); |
| 233 | + } |
| 234 | + } |
| 235 | + if (!_tO.serverURL && _tO.autoPlay) { |
| 236 | + oSound.play(); |
| 237 | + } |
| 238 | + return oSound; |
| 239 | + }; |
| 240 | + this.destroySound = function(sID, _bFromSound) { |
| 241 | + if (!_idCheck(sID)) { |
| 242 | + return false; |
| 243 | + } |
| 244 | + var oS = _s.sounds[sID], i; |
| 245 | + oS._iO = {}; |
| 246 | + oS.stop(); |
| 247 | + oS.unload(); |
| 248 | + for (i = 0; i < _s.soundIDs.length; i++) { |
| 249 | + if (_s.soundIDs[i] === sID) { |
| 250 | + _s.soundIDs.splice(i, 1); |
| 251 | + break; |
| 252 | + } |
| 253 | + } |
| 254 | + if (!_bFromSound) { |
| 255 | + oS.destruct(true); |
| 256 | + } |
| 257 | + oS = null; |
| 258 | + delete _s.sounds[sID]; |
| 259 | + return true; |
| 260 | + }; |
| 261 | + this.load = function(sID, oOptions) { |
| 262 | + if (!_idCheck(sID)) { |
| 263 | + return false; |
| 264 | + } |
| 265 | + return _s.sounds[sID].load(oOptions); |
| 266 | + }; |
| 267 | + this.unload = function(sID) { |
| 268 | + if (!_idCheck(sID)) { |
| 269 | + return false; |
| 270 | + } |
| 271 | + return _s.sounds[sID].unload(); |
| 272 | + }; |
| 273 | + this.onposition = function(sID, nPosition, oMethod, oScope) { |
| 274 | + if (!_idCheck(sID)) { |
| 275 | + return false; |
| 276 | + } |
| 277 | + return _s.sounds[sID].onposition(nPosition, oMethod, oScope); |
| 278 | + }; |
| 279 | + this.play = function(sID, oOptions) { |
| 280 | + var fN = _sm+'.play(): '; |
| 281 | + if (!_didInit || !_s.ok()) { |
| 282 | + _complain(fN + _str(!_didInit?'notReady':'notOK')); |
| 283 | + return false; |
| 284 | + } |
| 285 | + if (!_idCheck(sID)) { |
| 286 | + if (!(oOptions instanceof Object)) { |
| 287 | + oOptions = { |
| 288 | + url: oOptions |
| 289 | + }; |
| 290 | + } |
| 291 | + if (oOptions && oOptions.url) { |
| 292 | + oOptions.id = sID; |
| 293 | + return _s.createSound(oOptions).play(); |
| 294 | + } else { |
| 295 | + return false; |
| 296 | + } |
| 297 | + } |
| 298 | + return _s.sounds[sID].play(oOptions); |
| 299 | + }; |
| 300 | + this.start = this.play; |
| 301 | + this.setPosition = function(sID, nMsecOffset) { |
| 302 | + if (!_idCheck(sID)) { |
| 303 | + return false; |
| 304 | + } |
| 305 | + return _s.sounds[sID].setPosition(nMsecOffset); |
| 306 | + }; |
| 307 | + this.stop = function(sID) { |
| 308 | + if (!_idCheck(sID)) { |
| 309 | + return false; |
| 310 | + } |
| 311 | + return _s.sounds[sID].stop(); |
| 312 | + }; |
| 313 | + this.stopAll = function() { |
| 314 | + var oSound; |
| 315 | + for (oSound in _s.sounds) { |
| 316 | + if (_s.sounds.hasOwnProperty(oSound)) { |
| 317 | + _s.sounds[oSound].stop(); |
| 318 | + } |
| 319 | + } |
| 320 | + }; |
| 321 | + this.pause = function(sID) { |
| 322 | + if (!_idCheck(sID)) { |
| 323 | + return false; |
| 324 | + } |
| 325 | + return _s.sounds[sID].pause(); |
| 326 | + }; |
| 327 | + this.pauseAll = function() { |
| 328 | + var i; |
| 329 | + for (i = _s.soundIDs.length; i--;) { |
| 330 | + _s.sounds[_s.soundIDs[i]].pause(); |
| 331 | + } |
| 332 | + }; |
| 333 | + this.resume = function(sID) { |
| 334 | + if (!_idCheck(sID)) { |
| 335 | + return false; |
| 336 | + } |
| 337 | + return _s.sounds[sID].resume(); |
| 338 | + }; |
| 339 | + this.resumeAll = function() { |
| 340 | + var i; |
| 341 | + for (i = _s.soundIDs.length; i--;) { |
| 342 | + _s.sounds[_s.soundIDs[i]].resume(); |
| 343 | + } |
| 344 | + }; |
| 345 | + this.togglePause = function(sID) { |
| 346 | + if (!_idCheck(sID)) { |
| 347 | + return false; |
| 348 | + } |
| 349 | + return _s.sounds[sID].togglePause(); |
| 350 | + }; |
| 351 | + this.setPan = function(sID, nPan) { |
| 352 | + if (!_idCheck(sID)) { |
| 353 | + return false; |
| 354 | + } |
| 355 | + return _s.sounds[sID].setPan(nPan); |
| 356 | + }; |
| 357 | + this.setVolume = function(sID, nVol) { |
| 358 | + if (!_idCheck(sID)) { |
| 359 | + return false; |
| 360 | + } |
| 361 | + return _s.sounds[sID].setVolume(nVol); |
| 362 | + }; |
| 363 | + this.mute = function(sID) { |
| 364 | + var fN = _sm+'.mute(): ', |
| 365 | + i = 0; |
| 366 | + if (typeof sID !== 'string') { |
| 367 | + sID = null; |
| 368 | + } |
| 369 | + if (!sID) { |
| 370 | + for (i = _s.soundIDs.length; i--;) { |
| 371 | + _s.sounds[_s.soundIDs[i]].mute(); |
| 372 | + } |
| 373 | + _s.muted = true; |
| 374 | + } else { |
| 375 | + if (!_idCheck(sID)) { |
| 376 | + return false; |
| 377 | + } |
| 378 | + return _s.sounds[sID].mute(); |
| 379 | + } |
| 380 | + return true; |
| 381 | + }; |
| 382 | + this.muteAll = function() { |
| 383 | + _s.mute(); |
| 384 | + }; |
| 385 | + this.unmute = function(sID) { |
| 386 | + var fN = _sm+'.unmute(): ', i; |
| 387 | + if (typeof sID !== 'string') { |
| 388 | + sID = null; |
| 389 | + } |
| 390 | + if (!sID) { |
| 391 | + for (i = _s.soundIDs.length; i--;) { |
| 392 | + _s.sounds[_s.soundIDs[i]].unmute(); |
| 393 | + } |
| 394 | + _s.muted = false; |
| 395 | + } else { |
| 396 | + if (!_idCheck(sID)) { |
| 397 | + return false; |
| 398 | + } |
| 399 | + return _s.sounds[sID].unmute(); |
| 400 | + } |
| 401 | + return true; |
| 402 | + }; |
| 403 | + this.unmuteAll = function() { |
| 404 | + _s.unmute(); |
| 405 | + }; |
| 406 | + this.toggleMute = function(sID) { |
| 407 | + if (!_idCheck(sID)) { |
| 408 | + return false; |
| 409 | + } |
| 410 | + return _s.sounds[sID].toggleMute(); |
| 411 | + }; |
| 412 | + this.getMemoryUse = function() { |
| 413 | + var ram = 0; |
| 414 | + if (_s.o && _fV !== 8) { |
| 415 | + ram = parseInt(_s.o._getMemoryUse(), 10); |
| 416 | + } |
| 417 | + return ram; |
| 418 | + }; |
| 419 | + this.disable = function(bNoDisable) { |
| 420 | + var i; |
| 421 | + if (typeof bNoDisable === 'undefined') { |
| 422 | + bNoDisable = false; |
| 423 | + } |
| 424 | + if (_disabled) { |
| 425 | + return false; |
| 426 | + } |
| 427 | + _disabled = true; |
| 428 | + for (i = _s.soundIDs.length; i--;) { |
| 429 | + _disableObject(_s.sounds[_s.soundIDs[i]]); |
| 430 | + } |
| 431 | + _initComplete(bNoDisable); |
| 432 | + _event.remove(_win, 'load', _initUserOnload); |
| 433 | + return true; |
| 434 | + }; |
| 435 | + this.canPlayMIME = function(sMIME) { |
| 436 | + var result; |
| 437 | + if (_s.hasHTML5) { |
| 438 | + result = _html5CanPlay({type:sMIME}); |
| 439 | + } |
| 440 | + if (!_needsFlash || result) { |
| 441 | + return result; |
| 442 | + } else { |
| 443 | + return (sMIME ? !!((_fV > 8 ? sMIME.match(_netStreamMimeTypes) : null) || sMIME.match(_s.mimePattern)) : null); |
| 444 | + } |
| 445 | + }; |
| 446 | + this.canPlayURL = function(sURL) { |
| 447 | + var result; |
| 448 | + if (_s.hasHTML5) { |
| 449 | + result = _html5CanPlay({url: sURL}); |
| 450 | + } |
| 451 | + if (!_needsFlash || result) { |
| 452 | + return result; |
| 453 | + } else { |
| 454 | + return (sURL ? !!(sURL.match(_s.filePattern)) : null); |
| 455 | + } |
| 456 | + }; |
| 457 | + this.canPlayLink = function(oLink) { |
| 458 | + if (typeof oLink.type !== 'undefined' && oLink.type) { |
| 459 | + if (_s.canPlayMIME(oLink.type)) { |
| 460 | + return true; |
| 461 | + } |
| 462 | + } |
| 463 | + return _s.canPlayURL(oLink.href); |
| 464 | + }; |
| 465 | + this.getSoundById = function(sID, _suppressDebug) { |
| 466 | + if (!sID) { |
| 467 | + throw new Error(_sm+'.getSoundById(): sID is null/undefined'); |
| 468 | + } |
| 469 | + var result = _s.sounds[sID]; |
| 470 | + return result; |
| 471 | + }; |
| 472 | + this.onready = function(oMethod, oScope) { |
| 473 | + var sType = 'onready'; |
| 474 | + if (oMethod && oMethod instanceof Function) { |
| 475 | + if (!oScope) { |
| 476 | + oScope = _win; |
| 477 | + } |
| 478 | + _addOnEvent(sType, oMethod, oScope); |
| 479 | + _processOnEvents(); |
| 480 | + return true; |
| 481 | + } else { |
| 482 | + throw _str('needFunction', sType); |
| 483 | + } |
| 484 | + }; |
| 485 | + this.ontimeout = function(oMethod, oScope) { |
| 486 | + var sType = 'ontimeout'; |
| 487 | + if (oMethod && oMethod instanceof Function) { |
| 488 | + if (!oScope) { |
| 489 | + oScope = _win; |
| 490 | + } |
| 491 | + _addOnEvent(sType, oMethod, oScope); |
| 492 | + _processOnEvents({type:sType}); |
| 493 | + return true; |
| 494 | + } else { |
| 495 | + throw _str('needFunction', sType); |
| 496 | + } |
| 497 | + }; |
| 498 | + this._writeDebug = function(sText, sType, _bTimestamp) { |
| 499 | + return true; |
| 500 | + }; |
| 501 | + this._wD = this._writeDebug; |
| 502 | + this._debug = function() { |
| 503 | + }; |
| 504 | + this.reboot = function() { |
| 505 | + var i, j; |
| 506 | + for (i = _s.soundIDs.length; i--;) { |
| 507 | + _s.sounds[_s.soundIDs[i]].destruct(); |
| 508 | + } |
| 509 | + try { |
| 510 | + if (_isIE) { |
| 511 | + _oRemovedHTML = _s.o.innerHTML; |
| 512 | + } |
| 513 | + _oRemoved = _s.o.parentNode.removeChild(_s.o); |
| 514 | + } catch(e) { |
| 515 | + } |
| 516 | + _oRemovedHTML = _oRemoved = _needsFlash = null; |
| 517 | + _s.enabled = _didDCLoaded = _didInit = _waitingForEI = _initPending = _didAppend = _appendSuccess = _disabled = _s.swfLoaded = false; |
| 518 | + _s.soundIDs = _s.sounds = []; |
| 519 | + _s.o = null; |
| 520 | + for (i in _on_queue) { |
| 521 | + if (_on_queue.hasOwnProperty(i)) { |
| 522 | + for (j = _on_queue[i].length; j--;) { |
| 523 | + _on_queue[i][j].fired = false; |
| 524 | + } |
| 525 | + } |
| 526 | + } |
| 527 | + _win.setTimeout(_s.beginDelayedInit, 20); |
| 528 | + }; |
| 529 | + this.getMoviePercent = function() { |
| 530 | + return (_s.o && typeof _s.o.PercentLoaded !== 'undefined' ? _s.o.PercentLoaded() : null); |
| 531 | + }; |
| 532 | + this.beginDelayedInit = function() { |
| 533 | + _windowLoaded = true; |
| 534 | + _domContentLoaded(); |
| 535 | + setTimeout(function() { |
| 536 | + if (_initPending) { |
| 537 | + return false; |
| 538 | + } |
| 539 | + _createMovie(); |
| 540 | + _initMovie(); |
| 541 | + _initPending = true; |
| 542 | + return true; |
| 543 | + }, 20); |
| 544 | + _delayWaitForEI(); |
| 545 | + }; |
| 546 | + this.destruct = function() { |
| 547 | + _s.disable(true); |
| 548 | + }; |
| 549 | + SMSound = function(oOptions) { |
| 550 | + var _t = this, _resetProperties, _stop_html5_timer, _start_html5_timer; |
| 551 | + this.sID = oOptions.id; |
| 552 | + this.url = oOptions.url; |
| 553 | + this.options = _mixin(oOptions); |
| 554 | + this.instanceOptions = this.options; |
| 555 | + this._iO = this.instanceOptions; |
| 556 | + this.pan = this.options.pan; |
| 557 | + this.volume = this.options.volume; |
| 558 | + this._lastURL = null; |
| 559 | + this.isHTML5 = false; |
| 560 | + this._a = null; |
| 561 | + this.id3 = {}; |
| 562 | + this._debug = function() { |
| 563 | + }; |
| 564 | + this.load = function(oOptions) { |
| 565 | + var oS = null; |
| 566 | + if (typeof oOptions !== 'undefined') { |
| 567 | + _t._iO = _mixin(oOptions, _t.options); |
| 568 | + _t.instanceOptions = _t._iO; |
| 569 | + } else { |
| 570 | + oOptions = _t.options; |
| 571 | + _t._iO = oOptions; |
| 572 | + _t.instanceOptions = _t._iO; |
| 573 | + if (_t._lastURL && _t._lastURL !== _t.url) { |
| 574 | + _t._iO.url = _t.url; |
| 575 | + _t.url = null; |
| 576 | + } |
| 577 | + } |
| 578 | + if (!_t._iO.url) { |
| 579 | + _t._iO.url = _t.url; |
| 580 | + } |
| 581 | + if (_t._iO.url === _t.url && _t.readyState !== 0 && _t.readyState !== 2) { |
| 582 | + return _t; |
| 583 | + } |
| 584 | + _t._lastURL = _t.url; |
| 585 | + _t.loaded = false; |
| 586 | + _t.readyState = 1; |
| 587 | + _t.playState = 0; |
| 588 | + if (_html5OK(_t._iO)) { |
| 589 | + oS = _t._setup_html5(_t._iO); |
| 590 | + if (!oS._called_load) { |
| 591 | + _t._html5_canplay = false; |
| 592 | + oS.load(); |
| 593 | + oS._called_load = true; |
| 594 | + if (_t._iO.autoPlay) { |
| 595 | + _t.play(); |
| 596 | + } |
| 597 | + } else { |
| 598 | + } |
| 599 | + } else { |
| 600 | + try { |
| 601 | + _t.isHTML5 = false; |
| 602 | + _t._iO = _policyFix(_loopFix(_t._iO)); |
| 603 | + if (_fV === 8) { |
| 604 | + _s.o._load(_t.sID, _t._iO.url, _t._iO.stream, _t._iO.autoPlay, (_t._iO.whileloading?1:0), _t._iO.loops||1, _t._iO.usePolicyFile); |
| 605 | + } else { |
| 606 | + _s.o._load(_t.sID, _t._iO.url, !!(_t._iO.stream), !!(_t._iO.autoPlay), _t._iO.loops||1, !!(_t._iO.autoLoad), _t._iO.usePolicyFile); |
| 607 | + } |
| 608 | + } catch(e) { |
| 609 | + _catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true}); |
| 610 | + } |
| 611 | + } |
| 612 | + return _t; |
| 613 | + }; |
| 614 | + this.unload = function() { |
| 615 | + if (_t.readyState !== 0) { |
| 616 | + if (!_t.isHTML5) { |
| 617 | + if (_fV === 8) { |
| 618 | + _s.o._unload(_t.sID, _emptyURL); |
| 619 | + } else { |
| 620 | + _s.o._unload(_t.sID); |
| 621 | + } |
| 622 | + } else { |
| 623 | + _stop_html5_timer(); |
| 624 | + if (_t._a) { |
| 625 | + _t._a.pause(); |
| 626 | + _html5Unload(_t._a); |
| 627 | + } |
| 628 | + } |
| 629 | + _resetProperties(); |
| 630 | + } |
| 631 | + return _t; |
| 632 | + }; |
| 633 | + this.destruct = function(_bFromSM) { |
| 634 | + if (!_t.isHTML5) { |
| 635 | + _t._iO.onfailure = null; |
| 636 | + _s.o._destroySound(_t.sID); |
| 637 | + } else { |
| 638 | + _stop_html5_timer(); |
| 639 | + if (_t._a) { |
| 640 | + _t._a.pause(); |
| 641 | + _html5Unload(_t._a); |
| 642 | + if (!_useGlobalHTML5Audio) { |
| 643 | + _t._remove_html5_events(); |
| 644 | + } |
| 645 | + _t._a._t = null; |
| 646 | + _t._a = null; |
| 647 | + } |
| 648 | + } |
| 649 | + if (!_bFromSM) { |
| 650 | + _s.destroySound(_t.sID, true); |
| 651 | + } |
| 652 | + }; |
| 653 | + this.play = function(oOptions, _updatePlayState) { |
| 654 | + var fN = 'SMSound.play(): ', allowMulti, a; |
| 655 | + _updatePlayState = _updatePlayState === undefined ? true : _updatePlayState; |
| 656 | + if (!oOptions) { |
| 657 | + oOptions = {}; |
| 658 | + } |
| 659 | + _t._iO = _mixin(oOptions, _t._iO); |
| 660 | + _t._iO = _mixin(_t._iO, _t.options); |
| 661 | + _t.instanceOptions = _t._iO; |
| 662 | + if (_t._iO.serverURL && !_t.connected) { |
| 663 | + if (!_t.getAutoPlay()) { |
| 664 | + _t.setAutoPlay(true); |
| 665 | + } |
| 666 | + return _t; |
| 667 | + } |
| 668 | + if (_html5OK(_t._iO)) { |
| 669 | + _t._setup_html5(_t._iO); |
| 670 | + _start_html5_timer(); |
| 671 | + } |
| 672 | + if (_t.playState === 1 && !_t.paused) { |
| 673 | + allowMulti = _t._iO.multiShot; |
| 674 | + if (!allowMulti) { |
| 675 | + return _t; |
| 676 | + } else { |
| 677 | + } |
| 678 | + } |
| 679 | + if (!_t.loaded) { |
| 680 | + if (_t.readyState === 0) { |
| 681 | + if (!_t.isHTML5) { |
| 682 | + _t._iO.autoPlay = true; |
| 683 | + } |
| 684 | + _t.load(_t._iO); |
| 685 | + } else if (_t.readyState === 2) { |
| 686 | + return _t; |
| 687 | + } else { |
| 688 | + } |
| 689 | + } else { |
| 690 | + } |
| 691 | + if (!_t.isHTML5 && _fV === 9 && _t.position > 0 && _t.position === _t.duration) { |
| 692 | + _t._iO.position = 0; |
| 693 | + } |
| 694 | + if (_t.paused && _t.position && _t.position > 0) { |
| 695 | + _t.resume(); |
| 696 | + } else { |
| 697 | + _t.playState = 1; |
| 698 | + _t.paused = false; |
| 699 | + if (!_t.instanceCount || _t._iO.multiShotEvents || (!_t.isHTML5 && _fV > 8 && !_t.getAutoPlay())) { |
| 700 | + _t.instanceCount++; |
| 701 | + } |
| 702 | + _t.position = (typeof _t._iO.position !== 'undefined' && !isNaN(_t._iO.position)?_t._iO.position:0); |
| 703 | + if (!_t.isHTML5) { |
| 704 | + _t._iO = _policyFix(_loopFix(_t._iO)); |
| 705 | + } |
| 706 | + if (_t._iO.onplay && _updatePlayState) { |
| 707 | + _t._iO.onplay.apply(_t); |
| 708 | + _t._onplay_called = true; |
| 709 | + } |
| 710 | + _t.setVolume(_t._iO.volume, true); |
| 711 | + _t.setPan(_t._iO.pan, true); |
| 712 | + if (!_t.isHTML5) { |
| 713 | + _s.o._start(_t.sID, _t._iO.loops || 1, (_fV === 9?_t._iO.position:_t._iO.position / 1000)); |
| 714 | + } else { |
| 715 | + _start_html5_timer(); |
| 716 | + a = _t._setup_html5(); |
| 717 | + _t.setPosition(_t._iO.position); |
| 718 | + a.play(); |
| 719 | + } |
| 720 | + } |
| 721 | + return _t; |
| 722 | + }; |
| 723 | + this.start = this.play; |
| 724 | + this.stop = function(bAll) { |
| 725 | + if (_t.playState === 1) { |
| 726 | + _t._onbufferchange(0); |
| 727 | + _t.resetOnPosition(0); |
| 728 | + _t.paused = false; |
| 729 | + if (!_t.isHTML5) { |
| 730 | + _t.playState = 0; |
| 731 | + } |
| 732 | + if (_t._iO.onstop) { |
| 733 | + _t._iO.onstop.apply(_t); |
| 734 | + } |
| 735 | + if (!_t.isHTML5) { |
| 736 | + _s.o._stop(_t.sID, bAll); |
| 737 | + if (_t._iO.serverURL) { |
| 738 | + _t.unload(); |
| 739 | + } |
| 740 | + } else { |
| 741 | + if (_t._a) { |
| 742 | + _t.setPosition(0); |
| 743 | + _t._a.pause(); |
| 744 | + _t.playState = 0; |
| 745 | + _t._onTimer(); |
| 746 | + _stop_html5_timer(); |
| 747 | + } |
| 748 | + } |
| 749 | + _t.instanceCount = 0; |
| 750 | + _t._iO = {}; |
| 751 | + } |
| 752 | + return _t; |
| 753 | + }; |
| 754 | + this.setAutoPlay = function(autoPlay) { |
| 755 | + _t._iO.autoPlay = autoPlay; |
| 756 | + if (!_t.isHTML5) { |
| 757 | + _s.o._setAutoPlay(_t.sID, autoPlay); |
| 758 | + if (autoPlay) { |
| 759 | + if (!_t.instanceCount && _t.readyState === 1) { |
| 760 | + _t.instanceCount++; |
| 761 | + } |
| 762 | + } |
| 763 | + } |
| 764 | + }; |
| 765 | + this.getAutoPlay = function() { |
| 766 | + return _t._iO.autoPlay; |
| 767 | + }; |
| 768 | + this.setPosition = function(nMsecOffset) { |
| 769 | + if (nMsecOffset === undefined) { |
| 770 | + nMsecOffset = 0; |
| 771 | + } |
| 772 | + var original_pos, |
| 773 | + position, position1K, |
| 774 | + offset = (_t.isHTML5 ? Math.max(nMsecOffset,0) : Math.min(_t.duration || _t._iO.duration, Math.max(nMsecOffset, 0))); |
| 775 | + original_pos = _t.position; |
| 776 | + _t.position = offset; |
| 777 | + position1K = _t.position/1000; |
| 778 | + _t.resetOnPosition(_t.position); |
| 779 | + _t._iO.position = offset; |
| 780 | + if (!_t.isHTML5) { |
| 781 | + position = (_fV === 9 ? _t.position : position1K); |
| 782 | + if (_t.readyState && _t.readyState !== 2) { |
| 783 | + _s.o._setPosition(_t.sID, position, (_t.paused || !_t.playState)); |
| 784 | + } |
| 785 | + } else if (_t._a) { |
| 786 | + if (_t._html5_canplay) { |
| 787 | + if (_t._a.currentTime !== position1K) { |
| 788 | + try { |
| 789 | + _t._a.currentTime = position1K; |
| 790 | + if (_t.playState === 0 || _t.paused) { |
| 791 | + _t._a.pause(); |
| 792 | + } |
| 793 | + } catch(e) { |
| 794 | + } |
| 795 | + } |
| 796 | + } else { |
| 797 | + } |
| 798 | + } |
| 799 | + if (_t.isHTML5) { |
| 800 | + if (_t.paused) { |
| 801 | + _t._onTimer(true); |
| 802 | + } |
| 803 | + } |
| 804 | + return _t; |
| 805 | + }; |
| 806 | + this.pause = function(_bCallFlash) { |
| 807 | + if (_t.paused || (_t.playState === 0 && _t.readyState !== 1)) { |
| 808 | + return _t; |
| 809 | + } |
| 810 | + _t.paused = true; |
| 811 | + if (!_t.isHTML5) { |
| 812 | + if (_bCallFlash || _bCallFlash === undefined) { |
| 813 | + _s.o._pause(_t.sID); |
| 814 | + } |
| 815 | + } else { |
| 816 | + _t._setup_html5().pause(); |
| 817 | + _stop_html5_timer(); |
| 818 | + } |
| 819 | + if (_t._iO.onpause) { |
| 820 | + _t._iO.onpause.apply(_t); |
| 821 | + } |
| 822 | + return _t; |
| 823 | + }; |
| 824 | + this.resume = function() { |
| 825 | + if (!_t.paused) { |
| 826 | + return _t; |
| 827 | + } |
| 828 | + _t.paused = false; |
| 829 | + _t.playState = 1; |
| 830 | + if (!_t.isHTML5) { |
| 831 | + if (_t._iO.isMovieStar) { |
| 832 | + _t.setPosition(_t.position); |
| 833 | + } |
| 834 | + _s.o._pause(_t.sID); |
| 835 | + } else { |
| 836 | + _t._setup_html5().play(); |
| 837 | + _start_html5_timer(); |
| 838 | + } |
| 839 | + if (!_t._onplay_called && _t._iO.onplay) { |
| 840 | + _t._iO.onplay.apply(_t); |
| 841 | + _t._onplay_called = true; |
| 842 | + } else if (_t._iO.onresume) { |
| 843 | + _t._iO.onresume.apply(_t); |
| 844 | + } |
| 845 | + return _t; |
| 846 | + }; |
| 847 | + this.togglePause = function() { |
| 848 | + if (_t.playState === 0) { |
| 849 | + _t.play({ |
| 850 | + position: (_fV === 9 && !_t.isHTML5 ? _t.position : _t.position / 1000) |
| 851 | + }); |
| 852 | + return _t; |
| 853 | + } |
| 854 | + if (_t.paused) { |
| 855 | + _t.resume(); |
| 856 | + } else { |
| 857 | + _t.pause(); |
| 858 | + } |
| 859 | + return _t; |
| 860 | + }; |
| 861 | + this.setPan = function(nPan, bInstanceOnly) { |
| 862 | + if (typeof nPan === 'undefined') { |
| 863 | + nPan = 0; |
| 864 | + } |
| 865 | + if (typeof bInstanceOnly === 'undefined') { |
| 866 | + bInstanceOnly = false; |
| 867 | + } |
| 868 | + if (!_t.isHTML5) { |
| 869 | + _s.o._setPan(_t.sID, nPan); |
| 870 | + } |
| 871 | + _t._iO.pan = nPan; |
| 872 | + if (!bInstanceOnly) { |
| 873 | + _t.pan = nPan; |
| 874 | + _t.options.pan = nPan; |
| 875 | + } |
| 876 | + return _t; |
| 877 | + }; |
| 878 | + this.setVolume = function(nVol, _bInstanceOnly) { |
| 879 | + if (typeof nVol === 'undefined') { |
| 880 | + nVol = 100; |
| 881 | + } |
| 882 | + if (typeof _bInstanceOnly === 'undefined') { |
| 883 | + _bInstanceOnly = false; |
| 884 | + } |
| 885 | + if (!_t.isHTML5) { |
| 886 | + _s.o._setVolume(_t.sID, (_s.muted && !_t.muted) || _t.muted?0:nVol); |
| 887 | + } else if (_t._a) { |
| 888 | + _t._a.volume = Math.max(0, Math.min(1, nVol/100)); |
| 889 | + } |
| 890 | + _t._iO.volume = nVol; |
| 891 | + if (!_bInstanceOnly) { |
| 892 | + _t.volume = nVol; |
| 893 | + _t.options.volume = nVol; |
| 894 | + } |
| 895 | + return _t; |
| 896 | + }; |
| 897 | + this.mute = function() { |
| 898 | + _t.muted = true; |
| 899 | + if (!_t.isHTML5) { |
| 900 | + _s.o._setVolume(_t.sID, 0); |
| 901 | + } else if (_t._a) { |
| 902 | + _t._a.muted = true; |
| 903 | + } |
| 904 | + return _t; |
| 905 | + }; |
| 906 | + this.unmute = function() { |
| 907 | + _t.muted = false; |
| 908 | + var hasIO = typeof _t._iO.volume !== 'undefined'; |
| 909 | + if (!_t.isHTML5) { |
| 910 | + _s.o._setVolume(_t.sID, hasIO?_t._iO.volume:_t.options.volume); |
| 911 | + } else if (_t._a) { |
| 912 | + _t._a.muted = false; |
| 913 | + } |
| 914 | + return _t; |
| 915 | + }; |
| 916 | + this.toggleMute = function() { |
| 917 | + return (_t.muted?_t.unmute():_t.mute()); |
| 918 | + }; |
| 919 | + this.onposition = function(nPosition, oMethod, oScope) { |
| 920 | + _t._onPositionItems.push({ |
| 921 | + position: nPosition, |
| 922 | + method: oMethod, |
| 923 | + scope: (typeof oScope !== 'undefined'?oScope:_t), |
| 924 | + fired: false |
| 925 | + }); |
| 926 | + return _t; |
| 927 | + }; |
| 928 | + this.processOnPosition = function() { |
| 929 | + var i, item, j = _t._onPositionItems.length; |
| 930 | + if (!j || !_t.playState || _t._onPositionFired >= j) { |
| 931 | + return false; |
| 932 | + } |
| 933 | + for (i=j; i--;) { |
| 934 | + item = _t._onPositionItems[i]; |
| 935 | + if (!item.fired && _t.position >= item.position) { |
| 936 | + item.fired = true; |
| 937 | + _s._onPositionFired++; |
| 938 | + item.method.apply(item.scope,[item.position]); |
| 939 | + } |
| 940 | + } |
| 941 | + return true; |
| 942 | + }; |
| 943 | + this.resetOnPosition = function(nPosition) { |
| 944 | + var i, item, j = _t._onPositionItems.length; |
| 945 | + if (!j) { |
| 946 | + return false; |
| 947 | + } |
| 948 | + for (i=j; i--;) { |
| 949 | + item = _t._onPositionItems[i]; |
| 950 | + if (item.fired && nPosition <= item.position) { |
| 951 | + item.fired = false; |
| 952 | + _s._onPositionFired--; |
| 953 | + } |
| 954 | + } |
| 955 | + return true; |
| 956 | + }; |
| 957 | + _start_html5_timer = function() { |
| 958 | + if (_t.isHTML5) { |
| 959 | + _startTimer(_t); |
| 960 | + } |
| 961 | + }; |
| 962 | + _stop_html5_timer = function() { |
| 963 | + if (_t.isHTML5) { |
| 964 | + _stopTimer(_t); |
| 965 | + } |
| 966 | + }; |
| 967 | + _resetProperties = function() { |
| 968 | + _t._onPositionItems = []; |
| 969 | + _t._onPositionFired = 0; |
| 970 | + _t._hasTimer = null; |
| 971 | + _t._onplay_called = false; |
| 972 | + _t._a = null; |
| 973 | + _t._html5_canplay = false; |
| 974 | + _t.bytesLoaded = null; |
| 975 | + _t.bytesTotal = null; |
| 976 | + _t.position = null; |
| 977 | + _t.duration = (_t._iO && _t._iO.duration?_t._iO.duration:null); |
| 978 | + _t.durationEstimate = null; |
| 979 | + _t.failures = 0; |
| 980 | + _t.loaded = false; |
| 981 | + _t.playState = 0; |
| 982 | + _t.paused = false; |
| 983 | + _t.readyState = 0; |
| 984 | + _t.muted = false; |
| 985 | + _t.isBuffering = false; |
| 986 | + _t.instanceOptions = {}; |
| 987 | + _t.instanceCount = 0; |
| 988 | + _t.peakData = { |
| 989 | + left: 0, |
| 990 | + right: 0 |
| 991 | + }; |
| 992 | + _t.waveformData = { |
| 993 | + left: [], |
| 994 | + right: [] |
| 995 | + }; |
| 996 | + _t.eqData = []; |
| 997 | + _t.eqData.left = []; |
| 998 | + _t.eqData.right = []; |
| 999 | + }; |
| 1000 | + _resetProperties(); |
| 1001 | + this._onTimer = function(bForce) { |
| 1002 | + var time, x = {}; |
| 1003 | + if (_t._hasTimer || bForce) { |
| 1004 | + if (_t._a && (bForce || ((_t.playState > 0 || _t.readyState === 1) && !_t.paused))) { |
| 1005 | + _t.duration = _t._get_html5_duration(); |
| 1006 | + _t.durationEstimate = _t.duration; |
| 1007 | + time = _t._a.currentTime?_t._a.currentTime*1000:0; |
| 1008 | + _t._whileplaying(time,x,x,x,x); |
| 1009 | + return true; |
| 1010 | + } else { |
| 1011 | + return false; |
| 1012 | + } |
| 1013 | + } |
| 1014 | + }; |
| 1015 | + this._get_html5_duration = function() { |
| 1016 | + var d = (_t._a ? _t._a.duration*1000 : (_t._iO ? _t._iO.duration : undefined)), |
| 1017 | + result = (d && !isNaN(d) && d !== Infinity ? d : (_t._iO ? _t._iO.duration : null)); |
| 1018 | + return result; |
| 1019 | + }; |
| 1020 | + this._setup_html5 = function(oOptions) { |
| 1021 | + var _iO = _mixin(_t._iO, oOptions), d = decodeURI, |
| 1022 | + _a = _useGlobalHTML5Audio ? _s._global_a : _t._a, |
| 1023 | + _dURL = d(_iO.url), |
| 1024 | + _oldIO = (_a && _a._t ? _a._t.instanceOptions : null); |
| 1025 | + if (_a) { |
| 1026 | + if (_a._t && _oldIO.url === _iO.url && (!_t._lastURL || (_t._lastURL === _oldIO.url))) { |
| 1027 | + return _a; |
| 1028 | + } |
| 1029 | + if (_useGlobalHTML5Audio && _a._t && _a._t.playState && _iO.url !== _oldIO.url) { |
| 1030 | + _a._t.stop(); |
| 1031 | + } |
| 1032 | + _resetProperties(); |
| 1033 | + _a.src = _iO.url; |
| 1034 | + _t.url = _iO.url; |
| 1035 | + _t._lastURL = _iO.url; |
| 1036 | + _a._called_load = false; |
| 1037 | + } else { |
| 1038 | + _a = new Audio(_iO.url); |
| 1039 | + _a._called_load = false; |
| 1040 | + if (_is_android) { |
| 1041 | + _a._called_load = true; |
| 1042 | + } |
| 1043 | + if (_useGlobalHTML5Audio) { |
| 1044 | + _s._global_a = _a; |
| 1045 | + } |
| 1046 | + } |
| 1047 | + _t.isHTML5 = true; |
| 1048 | + _t._a = _a; |
| 1049 | + _a._t = _t; |
| 1050 | + _t._add_html5_events(); |
| 1051 | + _a.loop = (_iO.loops>1?'loop':''); |
| 1052 | + if (_iO.autoLoad || _iO.autoPlay) { |
| 1053 | + _a.autobuffer = 'auto'; |
| 1054 | + _a.preload = 'auto'; |
| 1055 | + _t.load(); |
| 1056 | + _a._called_load = true; |
| 1057 | + } else { |
| 1058 | + _a.autobuffer = false; |
| 1059 | + _a.preload = 'none'; |
| 1060 | + } |
| 1061 | + _a.loop = (_iO.loops>1?'loop':''); |
| 1062 | + return _a; |
| 1063 | + }; |
| 1064 | + this._add_html5_events = function() { |
| 1065 | + if (_t._a._added_events) { |
| 1066 | + return false; |
| 1067 | + } |
| 1068 | + var f; |
| 1069 | + function add(oEvt, oFn, bCapture) { |
| 1070 | + return _t._a ? _t._a.addEventListener(oEvt, oFn, bCapture||false) : null; |
| 1071 | + } |
| 1072 | + _t._a._added_events = true; |
| 1073 | + for (f in _html5_events) { |
| 1074 | + if (_html5_events.hasOwnProperty(f)) { |
| 1075 | + add(f, _html5_events[f]); |
| 1076 | + } |
| 1077 | + } |
| 1078 | + return true; |
| 1079 | + }; |
| 1080 | + this._remove_html5_events = function() { |
| 1081 | + var f; |
| 1082 | + function remove(oEvt, oFn, bCapture) { |
| 1083 | + return (_t._a ? _t._a.removeEventListener(oEvt, oFn, bCapture||false) : null); |
| 1084 | + } |
| 1085 | + _t._a._added_events = false; |
| 1086 | + for (f in _html5_events) { |
| 1087 | + if (_html5_events.hasOwnProperty(f)) { |
| 1088 | + remove(f, _html5_events[f]); |
| 1089 | + } |
| 1090 | + } |
| 1091 | + }; |
| 1092 | + this._onload = function(nSuccess) { |
| 1093 | + var fN = 'SMSound._onload(): ', loadOK = !!(nSuccess); |
| 1094 | + _t.loaded = loadOK; |
| 1095 | + _t.readyState = loadOK?3:2; |
| 1096 | + _t._onbufferchange(0); |
| 1097 | + if (_t._iO.onload) { |
| 1098 | + _t._iO.onload.apply(_t, [loadOK]); |
| 1099 | + } |
| 1100 | + return true; |
| 1101 | + }; |
| 1102 | + this._onbufferchange = function(nIsBuffering) { |
| 1103 | + var fN = 'SMSound._onbufferchange()'; |
| 1104 | + if (_t.playState === 0) { |
| 1105 | + return false; |
| 1106 | + } |
| 1107 | + if ((nIsBuffering && _t.isBuffering) || (!nIsBuffering && !_t.isBuffering)) { |
| 1108 | + return false; |
| 1109 | + } |
| 1110 | + _t.isBuffering = (nIsBuffering === 1); |
| 1111 | + if (_t._iO.onbufferchange) { |
| 1112 | + _t._iO.onbufferchange.apply(_t); |
| 1113 | + } |
| 1114 | + return true; |
| 1115 | + }; |
| 1116 | + this._onsuspend = function () { |
| 1117 | + if (_t._iO.onsuspend) { |
| 1118 | + _t._iO.onsuspend.apply(_t); |
| 1119 | + } |
| 1120 | + return true; |
| 1121 | + }; |
| 1122 | + this._onfailure = function(msg, level, code) { |
| 1123 | + _t.failures++; |
| 1124 | + if (_t._iO.onfailure && _t.failures === 1) { |
| 1125 | + _t._iO.onfailure(_t, msg, level, code); |
| 1126 | + } else { |
| 1127 | + } |
| 1128 | + }; |
| 1129 | + this._onfinish = function() { |
| 1130 | + var _io_onfinish = _t._iO.onfinish; |
| 1131 | + _t._onbufferchange(0); |
| 1132 | + _t.resetOnPosition(0); |
| 1133 | + if (_t.instanceCount) { |
| 1134 | + _t.instanceCount--; |
| 1135 | + if (!_t.instanceCount) { |
| 1136 | + _t.playState = 0; |
| 1137 | + _t.paused = false; |
| 1138 | + _t.instanceCount = 0; |
| 1139 | + _t.instanceOptions = {}; |
| 1140 | + _t._iO = {}; |
| 1141 | + _stop_html5_timer(); |
| 1142 | + } |
| 1143 | + if (!_t.instanceCount || _t._iO.multiShotEvents) { |
| 1144 | + if (_io_onfinish) { |
| 1145 | + _io_onfinish.apply(_t); |
| 1146 | + } |
| 1147 | + } |
| 1148 | + } |
| 1149 | + }; |
| 1150 | + this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) { |
| 1151 | + _t.bytesLoaded = nBytesLoaded; |
| 1152 | + _t.bytesTotal = nBytesTotal; |
| 1153 | + _t.duration = Math.floor(nDuration); |
| 1154 | + _t.bufferLength = nBufferLength; |
| 1155 | + if (!_t._iO.isMovieStar) { |
| 1156 | + if (_t._iO.duration) { |
| 1157 | + _t.durationEstimate = (_t.duration > _t._iO.duration) ? _t.duration : _t._iO.duration; |
| 1158 | + } else { |
| 1159 | + _t.durationEstimate = parseInt((_t.bytesTotal / _t.bytesLoaded) * _t.duration, 10); |
| 1160 | + } |
| 1161 | + if (_t.durationEstimate === undefined) { |
| 1162 | + _t.durationEstimate = _t.duration; |
| 1163 | + } |
| 1164 | + if (_t.readyState !== 3 && _t._iO.whileloading) { |
| 1165 | + _t._iO.whileloading.apply(_t); |
| 1166 | + } |
| 1167 | + } else { |
| 1168 | + _t.durationEstimate = _t.duration; |
| 1169 | + if (_t.readyState !== 3 && _t._iO.whileloading) { |
| 1170 | + _t._iO.whileloading.apply(_t); |
| 1171 | + } |
| 1172 | + } |
| 1173 | + }; |
| 1174 | + this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) { |
| 1175 | + if (isNaN(nPosition) || nPosition === null) { |
| 1176 | + return false; |
| 1177 | + } |
| 1178 | + _t.position = nPosition; |
| 1179 | + _t.processOnPosition(); |
| 1180 | + if (!_t.isHTML5 && _fV > 8) { |
| 1181 | + if (_t._iO.usePeakData && typeof oPeakData !== 'undefined' && oPeakData) { |
| 1182 | + _t.peakData = { |
| 1183 | + left: oPeakData.leftPeak, |
| 1184 | + right: oPeakData.rightPeak |
| 1185 | + }; |
| 1186 | + } |
| 1187 | + if (_t._iO.useWaveformData && typeof oWaveformDataLeft !== 'undefined' && oWaveformDataLeft) { |
| 1188 | + _t.waveformData = { |
| 1189 | + left: oWaveformDataLeft.split(','), |
| 1190 | + right: oWaveformDataRight.split(',') |
| 1191 | + }; |
| 1192 | + } |
| 1193 | + if (_t._iO.useEQData) { |
| 1194 | + if (typeof oEQData !== 'undefined' && oEQData && oEQData.leftEQ) { |
| 1195 | + var eqLeft = oEQData.leftEQ.split(','); |
| 1196 | + _t.eqData = eqLeft; |
| 1197 | + _t.eqData.left = eqLeft; |
| 1198 | + if (typeof oEQData.rightEQ !== 'undefined' && oEQData.rightEQ) { |
| 1199 | + _t.eqData.right = oEQData.rightEQ.split(','); |
| 1200 | + } |
| 1201 | + } |
| 1202 | + } |
| 1203 | + } |
| 1204 | + if (_t.playState === 1) { |
| 1205 | + if (!_t.isHTML5 && _fV === 8 && !_t.position && _t.isBuffering) { |
| 1206 | + _t._onbufferchange(0); |
| 1207 | + } |
| 1208 | + if (_t._iO.whileplaying) { |
| 1209 | + _t._iO.whileplaying.apply(_t); |
| 1210 | + } |
| 1211 | + } |
| 1212 | + return true; |
| 1213 | + }; |
| 1214 | + this._onid3 = function(oID3PropNames, oID3Data) { |
| 1215 | + var oData = [], i, j; |
| 1216 | + for (i = 0, j = oID3PropNames.length; i < j; i++) { |
| 1217 | + oData[oID3PropNames[i]] = oID3Data[i]; |
| 1218 | + } |
| 1219 | + _t.id3 = _mixin(_t.id3, oData); |
| 1220 | + if (_t._iO.onid3) { |
| 1221 | + _t._iO.onid3.apply(_t); |
| 1222 | + } |
| 1223 | + }; |
| 1224 | + this._onconnect = function(bSuccess) { |
| 1225 | + var fN = 'SMSound._onconnect(): '; |
| 1226 | + bSuccess = (bSuccess === 1); |
| 1227 | + _t.connected = bSuccess; |
| 1228 | + if (bSuccess) { |
| 1229 | + _t.failures = 0; |
| 1230 | + if (_idCheck(_t.sID)) { |
| 1231 | + if (_t.getAutoPlay()) { |
| 1232 | + _t.play(undefined, _t.getAutoPlay()); |
| 1233 | + } else if (_t._iO.autoLoad) { |
| 1234 | + _t.load(); |
| 1235 | + } |
| 1236 | + } |
| 1237 | + if (_t._iO.onconnect) { |
| 1238 | + _t._iO.onconnect.apply(_t,[bSuccess]); |
| 1239 | + } |
| 1240 | + } |
| 1241 | + }; |
| 1242 | + this._ondataerror = function(sError) { |
| 1243 | + if (_t.playState > 0) { |
| 1244 | + if (_t._iO.ondataerror) { |
| 1245 | + _t._iO.ondataerror.apply(_t); |
| 1246 | + } |
| 1247 | + } |
| 1248 | + }; |
| 1249 | + }; |
| 1250 | + _getDocument = function() { |
| 1251 | + return (_doc.body || _doc._docElement || _doc.getElementsByTagName('div')[0]); |
| 1252 | + }; |
| 1253 | + _id = function(sID) { |
| 1254 | + return _doc.getElementById(sID); |
| 1255 | + }; |
| 1256 | + _mixin = function(oMain, oAdd) { |
| 1257 | + var o1 = {}, i, o2, o; |
| 1258 | + for (i in oMain) { |
| 1259 | + if (oMain.hasOwnProperty(i)) { |
| 1260 | + o1[i] = oMain[i]; |
| 1261 | + } |
| 1262 | + } |
| 1263 | + o2 = (typeof oAdd === 'undefined'?_s.defaultOptions:oAdd); |
| 1264 | + for (o in o2) { |
| 1265 | + if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') { |
| 1266 | + o1[o] = o2[o]; |
| 1267 | + } |
| 1268 | + } |
| 1269 | + return o1; |
| 1270 | + }; |
| 1271 | + _event = (function() { |
| 1272 | + var old = (_win.attachEvent), |
| 1273 | + evt = { |
| 1274 | + add: (old?'attachEvent':'addEventListener'), |
| 1275 | + remove: (old?'detachEvent':'removeEventListener') |
| 1276 | + }; |
| 1277 | + function getArgs(oArgs) { |
| 1278 | + var args = _slice.call(oArgs), len = args.length; |
| 1279 | + if (old) { |
| 1280 | + args[1] = 'on' + args[1]; |
| 1281 | + if (len > 3) { |
| 1282 | + args.pop(); |
| 1283 | + } |
| 1284 | + } else if (len === 3) { |
| 1285 | + args.push(false); |
| 1286 | + } |
| 1287 | + return args; |
| 1288 | + } |
| 1289 | + function apply(args, sType) { |
| 1290 | + var element = args.shift(), |
| 1291 | + method = [evt[sType]]; |
| 1292 | + if (old) { |
| 1293 | + element[method](args[0], args[1]); |
| 1294 | + } else { |
| 1295 | + element[method].apply(element, args); |
| 1296 | + } |
| 1297 | + } |
| 1298 | + function add() { |
| 1299 | + apply(getArgs(arguments), 'add'); |
| 1300 | + } |
| 1301 | + function remove() { |
| 1302 | + apply(getArgs(arguments), 'remove'); |
| 1303 | + } |
| 1304 | + return { |
| 1305 | + 'add': add, |
| 1306 | + 'remove': remove |
| 1307 | + }; |
| 1308 | + }()); |
| 1309 | + function _html5_event(oFn) { |
| 1310 | + return function(e) { |
| 1311 | + if (!this._t || !this._t._a) { |
| 1312 | + return null; |
| 1313 | + } else { |
| 1314 | + return oFn.call(this, e); |
| 1315 | + } |
| 1316 | + }; |
| 1317 | + } |
| 1318 | + _html5_events = { |
| 1319 | + abort: _html5_event(function(e) { |
| 1320 | + }), |
| 1321 | + canplay: _html5_event(function(e) { |
| 1322 | + if (this._t._html5_canplay) { |
| 1323 | + return true; |
| 1324 | + } |
| 1325 | + this._t._html5_canplay = true; |
| 1326 | + this._t._onbufferchange(0); |
| 1327 | + var position1K = (!isNaN(this._t.position)?this._t.position/1000:null); |
| 1328 | + if (this._t.position && this.currentTime !== position1K) { |
| 1329 | + try { |
| 1330 | + this.currentTime = position1K; |
| 1331 | + } catch(ee) { |
| 1332 | + } |
| 1333 | + } |
| 1334 | + }), |
| 1335 | + load: _html5_event(function(e) { |
| 1336 | + if (!this._t.loaded) { |
| 1337 | + this._t._onbufferchange(0); |
| 1338 | + this._t._whileloading(this._t.bytesTotal, this._t.bytesTotal, this._t._get_html5_duration()); |
| 1339 | + this._t._onload(true); |
| 1340 | + } |
| 1341 | + }), |
| 1342 | + emptied: _html5_event(function(e) { |
| 1343 | + }), |
| 1344 | + ended: _html5_event(function(e) { |
| 1345 | + this._t._onfinish(); |
| 1346 | + }), |
| 1347 | + error: _html5_event(function(e) { |
| 1348 | + this._t._onload(false); |
| 1349 | + }), |
| 1350 | + loadeddata: _html5_event(function(e) { |
| 1351 | + var t = this._t, |
| 1352 | + bytesTotal = t.bytesTotal || 1; |
| 1353 | + if (!t._loaded && !_isSafari) { |
| 1354 | + t.duration = t._get_html5_duration(); |
| 1355 | + t._whileloading(bytesTotal, bytesTotal, t._get_html5_duration()); |
| 1356 | + t._onload(true); |
| 1357 | + } |
| 1358 | + }), |
| 1359 | + loadedmetadata: _html5_event(function(e) { |
| 1360 | + }), |
| 1361 | + loadstart: _html5_event(function(e) { |
| 1362 | + this._t._onbufferchange(1); |
| 1363 | + }), |
| 1364 | + play: _html5_event(function(e) { |
| 1365 | + this._t._onbufferchange(0); |
| 1366 | + }), |
| 1367 | + playing: _html5_event(function(e) { |
| 1368 | + this._t._onbufferchange(0); |
| 1369 | + }), |
| 1370 | + progress: _html5_event(function(e) { |
| 1371 | + if (this._t.loaded) { |
| 1372 | + return false; |
| 1373 | + } |
| 1374 | + var i, j, str, buffered = 0, |
| 1375 | + isProgress = (e.type === 'progress'), |
| 1376 | + ranges = e.target.buffered, |
| 1377 | + loaded = (e.loaded||0), |
| 1378 | + total = (e.total||1); |
| 1379 | + if (ranges && ranges.length) { |
| 1380 | + for (i=ranges.length; i--;) { |
| 1381 | + buffered = (ranges.end(i) - ranges.start(i)); |
| 1382 | + } |
| 1383 | + loaded = buffered/e.target.duration; |
| 1384 | + } |
| 1385 | + if (!isNaN(loaded)) { |
| 1386 | + this._t._onbufferchange(0); |
| 1387 | + this._t._whileloading(loaded, total, this._t._get_html5_duration()); |
| 1388 | + if (loaded && total && loaded === total) { |
| 1389 | + _html5_events.load.call(this, e); |
| 1390 | + } |
| 1391 | + } |
| 1392 | + }), |
| 1393 | + ratechange: _html5_event(function(e) { |
| 1394 | + }), |
| 1395 | + suspend: _html5_event(function(e) { |
| 1396 | + _html5_events.progress.call(this, e); |
| 1397 | + this._t._onsuspend(); |
| 1398 | + }), |
| 1399 | + stalled: _html5_event(function(e) { |
| 1400 | + }), |
| 1401 | + timeupdate: _html5_event(function(e) { |
| 1402 | + this._t._onTimer(); |
| 1403 | + }), |
| 1404 | + waiting: _html5_event(function(e) { |
| 1405 | + this._t._onbufferchange(1); |
| 1406 | + }) |
| 1407 | + }; |
| 1408 | + _html5OK = function(iO) { |
| 1409 | + return (!iO.serverURL && (iO.type?_html5CanPlay({type:iO.type}):_html5CanPlay({url:iO.url})||_s.html5Only)); |
| 1410 | + }; |
| 1411 | + _html5Unload = function(oAudio) { |
| 1412 | + if (oAudio) { |
| 1413 | + oAudio.src = (_is_firefox ? '' : _emptyURL); |
| 1414 | + } |
| 1415 | + }; |
| 1416 | + _html5CanPlay = function(o) { |
| 1417 | + if (!_s.useHTML5Audio || !_s.hasHTML5) { |
| 1418 | + return false; |
| 1419 | + } |
| 1420 | + var url = (o.url || null), |
| 1421 | + mime = (o.type || null), |
| 1422 | + aF = _s.audioFormats, |
| 1423 | + result, |
| 1424 | + offset, |
| 1425 | + fileExt, |
| 1426 | + item; |
| 1427 | + function preferFlashCheck(kind) { |
| 1428 | + return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind])); |
| 1429 | + } |
| 1430 | + if (mime && _s.html5[mime] !== 'undefined') { |
| 1431 | + return (_s.html5[mime] && !preferFlashCheck(mime)); |
| 1432 | + } |
| 1433 | + if (!_html5Ext) { |
| 1434 | + _html5Ext = []; |
| 1435 | + for (item in aF) { |
| 1436 | + if (aF.hasOwnProperty(item)) { |
| 1437 | + _html5Ext.push(item); |
| 1438 | + if (aF[item].related) { |
| 1439 | + _html5Ext = _html5Ext.concat(aF[item].related); |
| 1440 | + } |
| 1441 | + } |
| 1442 | + } |
| 1443 | + _html5Ext = new RegExp('\\.('+_html5Ext.join('|')+')(\\?.*)?$','i'); |
| 1444 | + } |
| 1445 | + fileExt = (url ? url.toLowerCase().match(_html5Ext) : null); |
| 1446 | + if (!fileExt || !fileExt.length) { |
| 1447 | + if (!mime) { |
| 1448 | + return false; |
| 1449 | + } else { |
| 1450 | + offset = mime.indexOf(';'); |
| 1451 | + fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6); |
| 1452 | + } |
| 1453 | + } else { |
| 1454 | + fileExt = fileExt[1]; |
| 1455 | + } |
| 1456 | + if (fileExt && typeof _s.html5[fileExt] !== 'undefined') { |
| 1457 | + return (_s.html5[fileExt] && !preferFlashCheck(fileExt)); |
| 1458 | + } else { |
| 1459 | + mime = 'audio/'+fileExt; |
| 1460 | + result = _s.html5.canPlayType({type:mime}); |
| 1461 | + _s.html5[fileExt] = result; |
| 1462 | + return (result && _s.html5[mime] && !preferFlashCheck(mime)); |
| 1463 | + } |
| 1464 | + }; |
| 1465 | + _testHTML5 = function() { |
| 1466 | + if (!_s.useHTML5Audio || typeof Audio === 'undefined') { |
| 1467 | + return false; |
| 1468 | + } |
| 1469 | + var a = (typeof Audio !== 'undefined' ? (_isOpera ? new Audio(null) : new Audio()) : null), |
| 1470 | + item, support = {}, aF, i; |
| 1471 | + function _cp(m) { |
| 1472 | + var canPlay, i, j, isOK = false; |
| 1473 | + if (!a || typeof a.canPlayType !== 'function') { |
| 1474 | + return false; |
| 1475 | + } |
| 1476 | + if (m instanceof Array) { |
| 1477 | + for (i=0, j=m.length; i<j && !isOK; i++) { |
| 1478 | + if (_s.html5[m[i]] || a.canPlayType(m[i]).match(_s.html5Test)) { |
| 1479 | + isOK = true; |
| 1480 | + _s.html5[m[i]] = true; |
| 1481 | + _s.flash[m[i]] = !!(_s.preferFlash && _hasFlash && m[i].match(_flashMIME)); |
| 1482 | + } |
| 1483 | + } |
| 1484 | + return isOK; |
| 1485 | + } else { |
| 1486 | + canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false); |
| 1487 | + return !!(canPlay && (canPlay.match(_s.html5Test))); |
| 1488 | + } |
| 1489 | + } |
| 1490 | + aF = _s.audioFormats; |
| 1491 | + for (item in aF) { |
| 1492 | + if (aF.hasOwnProperty(item)) { |
| 1493 | + support[item] = _cp(aF[item].type); |
| 1494 | + support['audio/'+item] = support[item]; |
| 1495 | + if (_s.preferFlash && !_s.ignoreFlash && item.match(_flashMIME)) { |
| 1496 | + _s.flash[item] = true; |
| 1497 | + } else { |
| 1498 | + _s.flash[item] = false; |
| 1499 | + } |
| 1500 | + if (aF[item] && aF[item].related) { |
| 1501 | + for (i=aF[item].related.length; i--;) { |
| 1502 | + support['audio/'+aF[item].related[i]] = support[item]; |
| 1503 | + _s.html5[aF[item].related[i]] = support[item]; |
| 1504 | + _s.flash[aF[item].related[i]] = support[item]; |
| 1505 | + } |
| 1506 | + } |
| 1507 | + } |
| 1508 | + } |
| 1509 | + support.canPlayType = (a?_cp:null); |
| 1510 | + _s.html5 = _mixin(_s.html5, support); |
| 1511 | + return true; |
| 1512 | + }; |
| 1513 | + _strings = { |
| 1514 | + }; |
| 1515 | + _str = function() { |
| 1516 | + }; |
| 1517 | + _loopFix = function(sOpt) { |
| 1518 | + if (_fV === 8 && sOpt.loops > 1 && sOpt.stream) { |
| 1519 | + sOpt.stream = false; |
| 1520 | + } |
| 1521 | + return sOpt; |
| 1522 | + }; |
| 1523 | + _policyFix = function(sOpt, sPre) { |
| 1524 | + if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) { |
| 1525 | + sOpt.usePolicyFile = true; |
| 1526 | + } |
| 1527 | + return sOpt; |
| 1528 | + }; |
| 1529 | + _complain = function(sMsg) { |
| 1530 | + }; |
| 1531 | + _doNothing = function() { |
| 1532 | + return false; |
| 1533 | + }; |
| 1534 | + _disableObject = function(o) { |
| 1535 | + var oProp; |
| 1536 | + for (oProp in o) { |
| 1537 | + if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') { |
| 1538 | + o[oProp] = _doNothing; |
| 1539 | + } |
| 1540 | + } |
| 1541 | + oProp = null; |
| 1542 | + }; |
| 1543 | + _failSafely = function(bNoDisable) { |
| 1544 | + if (typeof bNoDisable === 'undefined') { |
| 1545 | + bNoDisable = false; |
| 1546 | + } |
| 1547 | + if (_disabled || bNoDisable) { |
| 1548 | + _s.disable(bNoDisable); |
| 1549 | + } |
| 1550 | + }; |
| 1551 | + _normalizeMovieURL = function(smURL) { |
| 1552 | + var urlParams = null, url; |
| 1553 | + if (smURL) { |
| 1554 | + if (smURL.match(/\.swf(\?.*)?$/i)) { |
| 1555 | + urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4); |
| 1556 | + if (urlParams) { |
| 1557 | + return smURL; |
| 1558 | + } |
| 1559 | + } else if (smURL.lastIndexOf('/') !== smURL.length - 1) { |
| 1560 | + smURL += '/'; |
| 1561 | + } |
| 1562 | + } |
| 1563 | + url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + _s.movieURL; |
| 1564 | + if (_s.noSWFCache) { |
| 1565 | + url += ('?ts=' + new Date().getTime()); |
| 1566 | + } |
| 1567 | + return url; |
| 1568 | + }; |
| 1569 | + _setVersionInfo = function() { |
| 1570 | + _fV = parseInt(_s.flashVersion, 10); |
| 1571 | + if (_fV !== 8 && _fV !== 9) { |
| 1572 | + _s.flashVersion = _fV = _defaultFlashVersion; |
| 1573 | + } |
| 1574 | + var isDebug = (_s.debugMode || _s.debugFlash?'_debug.swf':'.swf'); |
| 1575 | + if (_s.useHTML5Audio && !_s.html5Only && _s.audioFormats.mp4.required && _fV < 9) { |
| 1576 | + _s.flashVersion = _fV = 9; |
| 1577 | + } |
| 1578 | + _s.version = _s.versionNumber + (_s.html5Only?' (HTML5-only mode)':(_fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)')); |
| 1579 | + if (_fV > 8) { |
| 1580 | + _s.defaultOptions = _mixin(_s.defaultOptions, _s.flash9Options); |
| 1581 | + _s.features.buffering = true; |
| 1582 | + _s.defaultOptions = _mixin(_s.defaultOptions, _s.movieStarOptions); |
| 1583 | + _s.filePatterns.flash9 = new RegExp('\\.(mp3|' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); |
| 1584 | + _s.features.movieStar = true; |
| 1585 | + } else { |
| 1586 | + _s.features.movieStar = false; |
| 1587 | + } |
| 1588 | + _s.filePattern = _s.filePatterns[(_fV !== 8?'flash9':'flash8')]; |
| 1589 | + _s.movieURL = (_fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug); |
| 1590 | + _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_fV > 8); |
| 1591 | + }; |
| 1592 | + _setPolling = function(bPolling, bHighPerformance) { |
| 1593 | + if (!_s.o) { |
| 1594 | + return false; |
| 1595 | + } |
| 1596 | + _s.o._setPolling(bPolling, bHighPerformance); |
| 1597 | + }; |
| 1598 | + _initDebug = function() { |
| 1599 | + if (_s.debugURLParam.test(_wl)) { |
| 1600 | + _s.debugMode = true; |
| 1601 | + } |
| 1602 | + }; |
| 1603 | + _idCheck = this.getSoundById; |
| 1604 | + _getSWFCSS = function() { |
| 1605 | + var css = []; |
| 1606 | + if (_s.debugMode) { |
| 1607 | + css.push(_s.swfCSS.sm2Debug); |
| 1608 | + } |
| 1609 | + if (_s.debugFlash) { |
| 1610 | + css.push(_s.swfCSS.flashDebug); |
| 1611 | + } |
| 1612 | + if (_s.useHighPerformance) { |
| 1613 | + css.push(_s.swfCSS.highPerf); |
| 1614 | + } |
| 1615 | + return css.join(' '); |
| 1616 | + }; |
| 1617 | + _flashBlockHandler = function() { |
| 1618 | + var name = _str('fbHandler'), |
| 1619 | + p = _s.getMoviePercent(), |
| 1620 | + css = _s.swfCSS, |
| 1621 | + error = {type:'FLASHBLOCK'}; |
| 1622 | + if (_s.html5Only) { |
| 1623 | + return false; |
| 1624 | + } |
| 1625 | + if (!_s.ok()) { |
| 1626 | + if (_needsFlash) { |
| 1627 | + _s.oMC.className = _getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError); |
| 1628 | + } |
| 1629 | + _s.didFlashBlock = true; |
| 1630 | + _processOnEvents({type:'ontimeout', ignoreInit:true, error:error}); |
| 1631 | + _catchError(error); |
| 1632 | + } else { |
| 1633 | + if (_s.didFlashBlock) { |
| 1634 | + } |
| 1635 | + if (_s.oMC) { |
| 1636 | + _s.oMC.className = [_getSWFCSS(), css.swfDefault, css.swfLoaded + (_s.didFlashBlock?' '+css.swfUnblocked:'')].join(' '); |
| 1637 | + } |
| 1638 | + } |
| 1639 | + }; |
| 1640 | + _addOnEvent = function(sType, oMethod, oScope) { |
| 1641 | + if (typeof _on_queue[sType] === 'undefined') { |
| 1642 | + _on_queue[sType] = []; |
| 1643 | + } |
| 1644 | + _on_queue[sType].push({ |
| 1645 | + 'method': oMethod, |
| 1646 | + 'scope': (oScope || null), |
| 1647 | + 'fired': false |
| 1648 | + }); |
| 1649 | + }; |
| 1650 | + _processOnEvents = function(oOptions) { |
| 1651 | + if (!oOptions) { |
| 1652 | + oOptions = { |
| 1653 | + type: 'onready' |
| 1654 | + }; |
| 1655 | + } |
| 1656 | + if (!_didInit && oOptions && !oOptions.ignoreInit) { |
| 1657 | + return false; |
| 1658 | + } |
| 1659 | + if (oOptions.type === 'ontimeout' && _s.ok()) { |
| 1660 | + return false; |
| 1661 | + } |
| 1662 | + var status = { |
| 1663 | + success: (oOptions && oOptions.ignoreInit?_s.ok():!_disabled) |
| 1664 | + }, |
| 1665 | + srcQueue = (oOptions && oOptions.type?_on_queue[oOptions.type]||[]:[]), |
| 1666 | + queue = [], i, j, |
| 1667 | + args = [status], |
| 1668 | + canRetry = (_needsFlash && _s.useFlashBlock && !_s.ok()); |
| 1669 | + if (oOptions.error) { |
| 1670 | + args[0].error = oOptions.error; |
| 1671 | + } |
| 1672 | + for (i = 0, j = srcQueue.length; i < j; i++) { |
| 1673 | + if (srcQueue[i].fired !== true) { |
| 1674 | + queue.push(srcQueue[i]); |
| 1675 | + } |
| 1676 | + } |
| 1677 | + if (queue.length) { |
| 1678 | + for (i = 0, j = queue.length; i < j; i++) { |
| 1679 | + if (queue[i].scope) { |
| 1680 | + queue[i].method.apply(queue[i].scope, args); |
| 1681 | + } else { |
| 1682 | + queue[i].method.apply(this, args); |
| 1683 | + } |
| 1684 | + if (!canRetry) { |
| 1685 | + queue[i].fired = true; |
| 1686 | + } |
| 1687 | + } |
| 1688 | + } |
| 1689 | + return true; |
| 1690 | + }; |
| 1691 | + _initUserOnload = function() { |
| 1692 | + _win.setTimeout(function() { |
| 1693 | + if (_s.useFlashBlock) { |
| 1694 | + _flashBlockHandler(); |
| 1695 | + } |
| 1696 | + _processOnEvents(); |
| 1697 | + if (_s.onload instanceof Function) { |
| 1698 | + _s.onload.apply(_win); |
| 1699 | + } |
| 1700 | + if (_s.waitForWindowLoad) { |
| 1701 | + _event.add(_win, 'load', _initUserOnload); |
| 1702 | + } |
| 1703 | + },1); |
| 1704 | + }; |
| 1705 | + _detectFlash = function() { |
| 1706 | + if (_hasFlash !== undefined) { |
| 1707 | + return _hasFlash; |
| 1708 | + } |
| 1709 | + var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = _win.ActiveXObject; |
| 1710 | + if (nP && nP.length) { |
| 1711 | + type = 'application/x-shockwave-flash'; |
| 1712 | + types = n.mimeTypes; |
| 1713 | + if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) { |
| 1714 | + hasPlugin = true; |
| 1715 | + } |
| 1716 | + } else if (typeof AX !== 'undefined') { |
| 1717 | + try { |
| 1718 | + obj = new AX('ShockwaveFlash.ShockwaveFlash'); |
| 1719 | + } catch(e) { |
| 1720 | + } |
| 1721 | + hasPlugin = (!!obj); |
| 1722 | + } |
| 1723 | + _hasFlash = hasPlugin; |
| 1724 | + return hasPlugin; |
| 1725 | + }; |
| 1726 | + _featureCheck = function() { |
| 1727 | + var needsFlash, item, |
| 1728 | + isSpecial = (_is_iDevice && !!(_ua.match(/os (1|2|3_0|3_1)/i))); |
| 1729 | + if (isSpecial) { |
| 1730 | + _s.hasHTML5 = false; |
| 1731 | + _s.html5Only = true; |
| 1732 | + if (_s.oMC) { |
| 1733 | + _s.oMC.style.display = 'none'; |
| 1734 | + } |
| 1735 | + return false; |
| 1736 | + } |
| 1737 | + if (_s.useHTML5Audio) { |
| 1738 | + if (!_s.html5 || !_s.html5.canPlayType) { |
| 1739 | + _s.hasHTML5 = false; |
| 1740 | + return true; |
| 1741 | + } else { |
| 1742 | + _s.hasHTML5 = true; |
| 1743 | + } |
| 1744 | + if (_isBadSafari) { |
| 1745 | + if (_detectFlash()) { |
| 1746 | + return true; |
| 1747 | + } |
| 1748 | + } |
| 1749 | + } else { |
| 1750 | + return true; |
| 1751 | + } |
| 1752 | + for (item in _s.audioFormats) { |
| 1753 | + if (_s.audioFormats.hasOwnProperty(item)) { |
| 1754 | + if ((_s.audioFormats[item].required && !_s.html5.canPlayType(_s.audioFormats[item].type)) || _s.flash[item] || _s.flash[_s.audioFormats[item].type]) { |
| 1755 | + needsFlash = true; |
| 1756 | + } |
| 1757 | + } |
| 1758 | + } |
| 1759 | + if (_s.ignoreFlash) { |
| 1760 | + needsFlash = false; |
| 1761 | + } |
| 1762 | + _s.html5Only = (_s.hasHTML5 && _s.useHTML5Audio && !needsFlash); |
| 1763 | + return (!_s.html5Only); |
| 1764 | + }; |
| 1765 | + _startTimer = function(oSound) { |
| 1766 | + if (!oSound._hasTimer) { |
| 1767 | + oSound._hasTimer = true; |
| 1768 | + } |
| 1769 | + }; |
| 1770 | + _stopTimer = function(oSound) { |
| 1771 | + if (oSound._hasTimer) { |
| 1772 | + oSound._hasTimer = false; |
| 1773 | + } |
| 1774 | + }; |
| 1775 | + _catchError = function(options) { |
| 1776 | + options = (typeof options !== 'undefined' ? options : {}); |
| 1777 | + if (_s.onerror instanceof Function) { |
| 1778 | + _s.onerror.apply(_win, [{type:(typeof options.type !== 'undefined' ? options.type : null)}]); |
| 1779 | + } |
| 1780 | + if (typeof options.fatal !== 'undefined' && options.fatal) { |
| 1781 | + _s.disable(); |
| 1782 | + } |
| 1783 | + }; |
| 1784 | + _badSafariFix = function() { |
| 1785 | + if (!_isBadSafari || !_detectFlash()) { |
| 1786 | + return false; |
| 1787 | + } |
| 1788 | + var aF = _s.audioFormats, i, item; |
| 1789 | + for (item in aF) { |
| 1790 | + if (aF.hasOwnProperty(item)) { |
| 1791 | + if (item === 'mp3' || item === 'mp4') { |
| 1792 | + _s.html5[item] = false; |
| 1793 | + if (aF[item] && aF[item].related) { |
| 1794 | + for (i = aF[item].related.length; i--;) { |
| 1795 | + _s.html5[aF[item].related[i]] = false; |
| 1796 | + } |
| 1797 | + } |
| 1798 | + } |
| 1799 | + } |
| 1800 | + } |
| 1801 | + }; |
| 1802 | + this._setSandboxType = function(sandboxType) { |
| 1803 | + }; |
| 1804 | + this._externalInterfaceOK = function(flashDate) { |
| 1805 | + if (_s.swfLoaded) { |
| 1806 | + return false; |
| 1807 | + } |
| 1808 | + var eiTime = new Date().getTime(); |
| 1809 | + _s.swfLoaded = true; |
| 1810 | + _tryInitOnFocus = false; |
| 1811 | + if (_isBadSafari) { |
| 1812 | + _badSafariFix(); |
| 1813 | + } |
| 1814 | + if (_isIE) { |
| 1815 | + setTimeout(_init, 100); |
| 1816 | + } else { |
| 1817 | + _init(); |
| 1818 | + } |
| 1819 | + }; |
| 1820 | + _createMovie = function(smID, smURL) { |
| 1821 | + if (_didAppend && _appendSuccess) { |
| 1822 | + return false; |
| 1823 | + } |
| 1824 | + function _initMsg() { |
| 1825 | + } |
| 1826 | + if (_s.html5Only) { |
| 1827 | + _setVersionInfo(); |
| 1828 | + _initMsg(); |
| 1829 | + _s.oMC = _id(_s.movieID); |
| 1830 | + _init(); |
| 1831 | + _didAppend = true; |
| 1832 | + _appendSuccess = true; |
| 1833 | + return false; |
| 1834 | + } |
| 1835 | + var remoteURL = (smURL || _s.url), |
| 1836 | + localURL = (_s.altURL || remoteURL), |
| 1837 | + swfTitle = 'JS/Flash audio component (SoundManager 2)', |
| 1838 | + oEmbed, oMovie, oTarget = _getDocument(), tmp, movieHTML, oEl, extraClass = _getSWFCSS(), |
| 1839 | + s, x, sClass, side = 'auto', isRTL = null, |
| 1840 | + html = _doc.getElementsByTagName('html')[0]; |
| 1841 | + isRTL = (html && html.dir && html.dir.match(/rtl/i)); |
| 1842 | + smID = (typeof smID === 'undefined'?_s.id:smID); |
| 1843 | + function param(name, value) { |
| 1844 | + return '<param name="'+name+'" value="'+value+'" />'; |
| 1845 | + } |
| 1846 | + _setVersionInfo(); |
| 1847 | + _s.url = _normalizeMovieURL(_overHTTP?remoteURL:localURL); |
| 1848 | + smURL = _s.url; |
| 1849 | + _s.wmode = (!_s.wmode && _s.useHighPerformance ? 'transparent' : _s.wmode); |
| 1850 | + if (_s.wmode !== null && (_ua.match(/msie 8/i) || (!_isIE && !_s.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) { |
| 1851 | + _s.specialWmodeCase = true; |
| 1852 | + _s.wmode = null; |
| 1853 | + } |
| 1854 | + oEmbed = { |
| 1855 | + 'name': smID, |
| 1856 | + 'id': smID, |
| 1857 | + 'src': smURL, |
| 1858 | + 'width': side, |
| 1859 | + 'height': side, |
| 1860 | + 'quality': 'high', |
| 1861 | + 'allowScriptAccess': _s.allowScriptAccess, |
| 1862 | + 'bgcolor': _s.bgColor, |
| 1863 | + 'pluginspage': _http+'www.macromedia.com/go/getflashplayer', |
| 1864 | + 'title': swfTitle, |
| 1865 | + 'type': 'application/x-shockwave-flash', |
| 1866 | + 'wmode': _s.wmode, |
| 1867 | + 'hasPriority': 'true' |
| 1868 | + }; |
| 1869 | + if (_s.debugFlash) { |
| 1870 | + oEmbed.FlashVars = 'debug=1'; |
| 1871 | + } |
| 1872 | + if (!_s.wmode) { |
| 1873 | + delete oEmbed.wmode; |
| 1874 | + } |
| 1875 | + if (_isIE) { |
| 1876 | + oMovie = _doc.createElement('div'); |
| 1877 | + movieHTML = [ |
| 1878 | + '<object id="' + smID + '" data="' + smURL + '" type="' + oEmbed.type + '" title="' + oEmbed.title +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + _http+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="' + oEmbed.width + '" height="' + oEmbed.height + '">', |
| 1879 | + param('movie', smURL), |
| 1880 | + param('AllowScriptAccess', _s.allowScriptAccess), |
| 1881 | + param('quality', oEmbed.quality), |
| 1882 | + (_s.wmode? param('wmode', _s.wmode): ''), |
| 1883 | + param('bgcolor', _s.bgColor), |
| 1884 | + param('hasPriority', 'true'), |
| 1885 | + (_s.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''), |
| 1886 | + '</object>' |
| 1887 | + ].join(''); |
| 1888 | + } else { |
| 1889 | + oMovie = _doc.createElement('embed'); |
| 1890 | + for (tmp in oEmbed) { |
| 1891 | + if (oEmbed.hasOwnProperty(tmp)) { |
| 1892 | + oMovie.setAttribute(tmp, oEmbed[tmp]); |
| 1893 | + } |
| 1894 | + } |
| 1895 | + } |
| 1896 | + _initDebug(); |
| 1897 | + extraClass = _getSWFCSS(); |
| 1898 | + oTarget = _getDocument(); |
| 1899 | + if (oTarget) { |
| 1900 | + _s.oMC = (_id(_s.movieID) || _doc.createElement('div')); |
| 1901 | + if (!_s.oMC.id) { |
| 1902 | + _s.oMC.id = _s.movieID; |
| 1903 | + _s.oMC.className = _s.swfCSS.swfDefault + ' ' + extraClass; |
| 1904 | + s = null; |
| 1905 | + oEl = null; |
| 1906 | + if (!_s.useFlashBlock) { |
| 1907 | + if (_s.useHighPerformance) { |
| 1908 | + s = { |
| 1909 | + 'position': 'fixed', |
| 1910 | + 'width': '8px', |
| 1911 | + 'height': '8px', |
| 1912 | + 'bottom': '0px', |
| 1913 | + 'left': '0px', |
| 1914 | + 'overflow': 'hidden' |
| 1915 | + }; |
| 1916 | + } else { |
| 1917 | + s = { |
| 1918 | + 'position': 'absolute', |
| 1919 | + 'width': '6px', |
| 1920 | + 'height': '6px', |
| 1921 | + 'top': '-9999px', |
| 1922 | + 'left': '-9999px' |
| 1923 | + }; |
| 1924 | + if (isRTL) { |
| 1925 | + s.left = Math.abs(parseInt(s.left,10))+'px'; |
| 1926 | + } |
| 1927 | + } |
| 1928 | + } |
| 1929 | + if (_isWebkit) { |
| 1930 | + _s.oMC.style.zIndex = 10000; |
| 1931 | + } |
| 1932 | + if (!_s.debugFlash) { |
| 1933 | + for (x in s) { |
| 1934 | + if (s.hasOwnProperty(x)) { |
| 1935 | + _s.oMC.style[x] = s[x]; |
| 1936 | + } |
| 1937 | + } |
| 1938 | + } |
| 1939 | + try { |
| 1940 | + if (!_isIE) { |
| 1941 | + _s.oMC.appendChild(oMovie); |
| 1942 | + } |
| 1943 | + oTarget.appendChild(_s.oMC); |
| 1944 | + if (_isIE) { |
| 1945 | + oEl = _s.oMC.appendChild(_doc.createElement('div')); |
| 1946 | + oEl.className = _s.swfCSS.swfBox; |
| 1947 | + oEl.innerHTML = movieHTML; |
| 1948 | + } |
| 1949 | + _appendSuccess = true; |
| 1950 | + } catch(e) { |
| 1951 | + throw new Error(_str('domError')+' \n'+e.toString()); |
| 1952 | + } |
| 1953 | + } else { |
| 1954 | + sClass = _s.oMC.className; |
| 1955 | + _s.oMC.className = (sClass?sClass+' ':_s.swfCSS.swfDefault) + (extraClass?' '+extraClass:''); |
| 1956 | + _s.oMC.appendChild(oMovie); |
| 1957 | + if (_isIE) { |
| 1958 | + oEl = _s.oMC.appendChild(_doc.createElement('div')); |
| 1959 | + oEl.className = _s.swfCSS.swfBox; |
| 1960 | + oEl.innerHTML = movieHTML; |
| 1961 | + } |
| 1962 | + _appendSuccess = true; |
| 1963 | + } |
| 1964 | + } |
| 1965 | + _didAppend = true; |
| 1966 | + _initMsg(); |
| 1967 | + return true; |
| 1968 | + }; |
| 1969 | + _initMovie = function() { |
| 1970 | + if (_s.html5Only) { |
| 1971 | + _createMovie(); |
| 1972 | + return false; |
| 1973 | + } |
| 1974 | + if (_s.o) { |
| 1975 | + return false; |
| 1976 | + } |
| 1977 | + _s.o = _s.getMovie(_s.id); |
| 1978 | + if (!_s.o) { |
| 1979 | + if (!_oRemoved) { |
| 1980 | + _createMovie(_s.id, _s.url); |
| 1981 | + } else { |
| 1982 | + if (!_isIE) { |
| 1983 | + _s.oMC.appendChild(_oRemoved); |
| 1984 | + } else { |
| 1985 | + _s.oMC.innerHTML = _oRemovedHTML; |
| 1986 | + } |
| 1987 | + _oRemoved = null; |
| 1988 | + _didAppend = true; |
| 1989 | + } |
| 1990 | + _s.o = _s.getMovie(_s.id); |
| 1991 | + } |
| 1992 | + if (_s.oninitmovie instanceof Function) { |
| 1993 | + setTimeout(_s.oninitmovie, 1); |
| 1994 | + } |
| 1995 | + return true; |
| 1996 | + }; |
| 1997 | + _delayWaitForEI = function() { |
| 1998 | + setTimeout(_waitForEI, 1000); |
| 1999 | + }; |
| 2000 | + _waitForEI = function() { |
| 2001 | + if (_waitingForEI) { |
| 2002 | + return false; |
| 2003 | + } |
| 2004 | + _waitingForEI = true; |
| 2005 | + _event.remove(_win, 'load', _delayWaitForEI); |
| 2006 | + if (_tryInitOnFocus && !_isFocused) { |
| 2007 | + return false; |
| 2008 | + } |
| 2009 | + var p; |
| 2010 | + if (!_didInit) { |
| 2011 | + p = _s.getMoviePercent(); |
| 2012 | + } |
| 2013 | + setTimeout(function() { |
| 2014 | + p = _s.getMoviePercent(); |
| 2015 | + if (!_didInit && _okToDisable) { |
| 2016 | + if (p === null) { |
| 2017 | + if (_s.useFlashBlock || _s.flashLoadTimeout === 0) { |
| 2018 | + if (_s.useFlashBlock) { |
| 2019 | + _flashBlockHandler(); |
| 2020 | + } |
| 2021 | + } else { |
| 2022 | + _failSafely(true); |
| 2023 | + } |
| 2024 | + } else { |
| 2025 | + if (_s.flashLoadTimeout === 0) { |
| 2026 | + } else { |
| 2027 | + _failSafely(true); |
| 2028 | + } |
| 2029 | + } |
| 2030 | + } |
| 2031 | + }, _s.flashLoadTimeout); |
| 2032 | + }; |
| 2033 | + _handleFocus = function() { |
| 2034 | + function cleanup() { |
| 2035 | + _event.remove(_win, 'focus', _handleFocus); |
| 2036 | + _event.remove(_win, 'load', _handleFocus); |
| 2037 | + } |
| 2038 | + if (_isFocused || !_tryInitOnFocus) { |
| 2039 | + cleanup(); |
| 2040 | + return true; |
| 2041 | + } |
| 2042 | + _okToDisable = true; |
| 2043 | + _isFocused = true; |
| 2044 | + if (_isSafari && _tryInitOnFocus) { |
| 2045 | + _event.remove(_win, 'mousemove', _handleFocus); |
| 2046 | + } |
| 2047 | + _waitingForEI = false; |
| 2048 | + cleanup(); |
| 2049 | + return true; |
| 2050 | + }; |
| 2051 | + _showSupport = function() { |
| 2052 | + var item, tests = []; |
| 2053 | + if (_s.useHTML5Audio && _s.hasHTML5) { |
| 2054 | + for (item in _s.audioFormats) { |
| 2055 | + if (_s.audioFormats.hasOwnProperty(item)) { |
| 2056 | + tests.push(item + ': ' + _s.html5[item] + (!_s.html5[item] && _hasFlash && _s.flash[item] ? ' (using flash)' : (_s.preferFlash && _s.flash[item] && _hasFlash ? ' (preferring flash)': (!_s.html5[item] ? ' (' + (_s.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : '')))); |
| 2057 | + } |
| 2058 | + } |
| 2059 | + } |
| 2060 | + }; |
| 2061 | + _initComplete = function(bNoDisable) { |
| 2062 | + if (_didInit) { |
| 2063 | + return false; |
| 2064 | + } |
| 2065 | + if (_s.html5Only) { |
| 2066 | + _didInit = true; |
| 2067 | + _initUserOnload(); |
| 2068 | + return true; |
| 2069 | + } |
| 2070 | + var wasTimeout = (_s.useFlashBlock && _s.flashLoadTimeout && !_s.getMoviePercent()), |
| 2071 | + error; |
| 2072 | + if (!wasTimeout) { |
| 2073 | + _didInit = true; |
| 2074 | + if (_disabled) { |
| 2075 | + error = {type: (!_hasFlash && _needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')}; |
| 2076 | + } |
| 2077 | + } |
| 2078 | + if (_disabled || bNoDisable) { |
| 2079 | + if (_s.useFlashBlock && _s.oMC) { |
| 2080 | + _s.oMC.className = _getSWFCSS() + ' ' + (_s.getMoviePercent() === null?_s.swfCSS.swfTimedout:_s.swfCSS.swfError); |
| 2081 | + } |
| 2082 | + _processOnEvents({type:'ontimeout', error:error}); |
| 2083 | + _catchError(error); |
| 2084 | + return false; |
| 2085 | + } else { |
| 2086 | + } |
| 2087 | + if (_s.waitForWindowLoad && !_windowLoaded) { |
| 2088 | + _event.add(_win, 'load', _initUserOnload); |
| 2089 | + return false; |
| 2090 | + } else { |
| 2091 | + _initUserOnload(); |
| 2092 | + } |
| 2093 | + return true; |
| 2094 | + }; |
| 2095 | + _init = function() { |
| 2096 | + if (_didInit) { |
| 2097 | + return false; |
| 2098 | + } |
| 2099 | + function _cleanup() { |
| 2100 | + _event.remove(_win, 'load', _s.beginDelayedInit); |
| 2101 | + } |
| 2102 | + if (_s.html5Only) { |
| 2103 | + if (!_didInit) { |
| 2104 | + _cleanup(); |
| 2105 | + _s.enabled = true; |
| 2106 | + _initComplete(); |
| 2107 | + } |
| 2108 | + return true; |
| 2109 | + } |
| 2110 | + _initMovie(); |
| 2111 | + try { |
| 2112 | + _s.o._externalInterfaceTest(false); |
| 2113 | + _setPolling(true, (_s.flashPollingInterval || (_s.useHighPerformance ? 10 : 50))); |
| 2114 | + if (!_s.debugMode) { |
| 2115 | + _s.o._disableDebug(); |
| 2116 | + } |
| 2117 | + _s.enabled = true; |
| 2118 | + if (!_s.html5Only) { |
| 2119 | + _event.add(_win, 'unload', _doNothing); |
| 2120 | + } |
| 2121 | + } catch(e) { |
| 2122 | + _catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true}); |
| 2123 | + _failSafely(true); |
| 2124 | + _initComplete(); |
| 2125 | + return false; |
| 2126 | + } |
| 2127 | + _initComplete(); |
| 2128 | + _cleanup(); |
| 2129 | + return true; |
| 2130 | + }; |
| 2131 | + _domContentLoaded = function() { |
| 2132 | + if (_didDCLoaded) { |
| 2133 | + return false; |
| 2134 | + } |
| 2135 | + _didDCLoaded = true; |
| 2136 | + _initDebug(); |
| 2137 | + if (!_hasFlash && _s.hasHTML5) { |
| 2138 | + _s.useHTML5Audio = true; |
| 2139 | + _s.preferFlash = false; |
| 2140 | + } |
| 2141 | + _testHTML5(); |
| 2142 | + _s.html5.usingFlash = _featureCheck(); |
| 2143 | + _needsFlash = _s.html5.usingFlash; |
| 2144 | + _showSupport(); |
| 2145 | + if (!_hasFlash && _needsFlash) { |
| 2146 | + _s.flashLoadTimeout = 1; |
| 2147 | + } |
| 2148 | + if (_doc.removeEventListener) { |
| 2149 | + _doc.removeEventListener('DOMContentLoaded', _domContentLoaded, false); |
| 2150 | + } |
| 2151 | + _initMovie(); |
| 2152 | + return true; |
| 2153 | + }; |
| 2154 | + _domContentLoadedIE = function() { |
| 2155 | + if (_doc.readyState === 'complete') { |
| 2156 | + _domContentLoaded(); |
| 2157 | + _doc.detachEvent('onreadystatechange', _domContentLoadedIE); |
| 2158 | + } |
| 2159 | + return true; |
| 2160 | + }; |
| 2161 | + _detectFlash(); |
| 2162 | + _event.add(_win, 'focus', _handleFocus); |
| 2163 | + _event.add(_win, 'load', _handleFocus); |
| 2164 | + _event.add(_win, 'load', _delayWaitForEI); |
| 2165 | + if (_isSafari && _tryInitOnFocus) { |
| 2166 | + _event.add(_win, 'mousemove', _handleFocus); |
| 2167 | + } |
| 2168 | + if (_doc.addEventListener) { |
| 2169 | + _doc.addEventListener('DOMContentLoaded', _domContentLoaded, false); |
| 2170 | + } else if (_doc.attachEvent) { |
| 2171 | + _doc.attachEvent('onreadystatechange', _domContentLoadedIE); |
| 2172 | + } else { |
| 2173 | + _catchError({type:'NO_DOM2_EVENTS', fatal:true}); |
| 2174 | + } |
| 2175 | + if (_doc.readyState === 'complete') { |
| 2176 | + setTimeout(_domContentLoaded,100); |
| 2177 | + } |
| 2178 | +} |
| 2179 | +// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading |
| 2180 | +if (typeof SM2_DEFER === 'undefined' || !SM2_DEFER) { |
| 2181 | + soundManager = new SoundManager(); |
| 2182 | +} |
| 2183 | +window.SoundManager = SoundManager; |
| 2184 | +window.soundManager = soundManager; |
| 2185 | +}(window)); |
\ No newline at end of file |
Property changes on: trunk/extensions/SoundManager2Button/script/soundmanager2-nodebug.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 2186 | + native |
Index: trunk/extensions/SoundManager2Button/script/args.js |
— | — | @@ -0,0 +1,2 @@ |
| 2 | +soundManager.url = mw.config.get( 'wgExtensionAssetsPath' ) +'/SoundManager2Button/swf/'; |
| 3 | +soundManager.debugMode = false; |
Property changes on: trunk/extensions/SoundManager2Button/script/args.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 4 | + native |
Index: trunk/extensions/SoundManager2Button/script/mp3-player-button.js |
— | — | @@ -0,0 +1,261 @@ |
| 2 | +/** |
| 3 | + * SoundManager 2 Demo: Play MP3 links via button |
| 4 | + * ---------------------------------------------- |
| 5 | + * |
| 6 | + * http://schillmania.com/projects/soundmanager2/ |
| 7 | + * |
| 8 | + * A simple demo making MP3s playable "inline" |
| 9 | + * and easily styled/customizable via CSS. |
| 10 | + * |
| 11 | + * A variation of the "play mp3 links" demo. |
| 12 | + * |
| 13 | + * Requires SoundManager 2 Javascript API. |
| 14 | + */ |
| 15 | + |
| 16 | +/*jslint white: false, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, regexp: false, newcap: true, immed: true */ |
| 17 | +/*global document, window, soundManager, navigator */ |
| 18 | + |
| 19 | +function BasicMP3Player() { |
| 20 | + var self = this, |
| 21 | + pl = this, |
| 22 | + sm = soundManager, // soundManager instance |
| 23 | + isTouchDevice = (navigator.userAgent.match(/ipad|iphone/i)), |
| 24 | + isIE = (navigator.userAgent.match(/msie/i)); |
| 25 | + this.excludeClass = 'button-exclude'; // CSS class for ignoring MP3 links |
| 26 | + this.links = []; |
| 27 | + this.sounds = []; |
| 28 | + this.soundsByURL = []; |
| 29 | + this.indexByURL = []; |
| 30 | + this.lastSound = null; |
| 31 | + this.soundCount = 0; |
| 32 | + |
| 33 | + this.config = { |
| 34 | + // configuration options |
| 35 | + playNext: false, // stop after one sound, or play through list until end |
| 36 | + autoPlay: false // start playing the first sound right away |
| 37 | + }; |
| 38 | + |
| 39 | + this.css = { |
| 40 | + // CSS class names appended to link during various states |
| 41 | + sDefault: 'sm2_button', // default state |
| 42 | + sLoading: 'sm2_loading', |
| 43 | + sPlaying: 'sm2_playing', |
| 44 | + sPaused: 'sm2_paused' |
| 45 | + }; |
| 46 | + |
| 47 | + // event + DOM utils |
| 48 | + |
| 49 | + this.includeClass = this.css.sDefault; |
| 50 | + |
| 51 | + this.addEventHandler = (typeof window.addEventListener !== 'undefined' ? function(o, evtName, evtHandler) { |
| 52 | + return o.addEventListener(evtName,evtHandler,false); |
| 53 | + } : function(o, evtName, evtHandler) { |
| 54 | + o.attachEvent('on'+evtName,evtHandler); |
| 55 | + }); |
| 56 | + |
| 57 | + this.removeEventHandler = (typeof window.removeEventListener !== 'undefined' ? function(o, evtName, evtHandler) { |
| 58 | + return o.removeEventListener(evtName,evtHandler,false); |
| 59 | + } : function(o, evtName, evtHandler) { |
| 60 | + return o.detachEvent('on'+evtName,evtHandler); |
| 61 | + }); |
| 62 | + |
| 63 | + this.classContains = function(o,cStr) { |
| 64 | + return (typeof(o.className)!=='undefined'?o.className.match(new RegExp('(\\s|^)'+cStr+'(\\s|$)')):false); |
| 65 | + }; |
| 66 | + |
| 67 | + this.addClass = function(o,cStr) { |
| 68 | + if (!o || !cStr || self.classContains(o,cStr)) { |
| 69 | + return false; |
| 70 | + } |
| 71 | + o.className = (o.className?o.className+' ':'')+cStr; |
| 72 | + }; |
| 73 | + |
| 74 | + this.removeClass = function(o,cStr) { |
| 75 | + if (!o || !cStr || !self.classContains(o,cStr)) { |
| 76 | + return false; |
| 77 | + } |
| 78 | + o.className = o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),''); |
| 79 | + }; |
| 80 | + |
| 81 | + this.getSoundByURL = function(sURL) { |
| 82 | + return (typeof self.soundsByURL[sURL] !== 'undefined' ? self.soundsByURL[sURL] : null); |
| 83 | + }; |
| 84 | + |
| 85 | + this.isChildOfNode = function(o,sNodeName) { |
| 86 | + if (!o || !o.parentNode) { |
| 87 | + return false; |
| 88 | + } |
| 89 | + sNodeName = sNodeName.toLowerCase(); |
| 90 | + do { |
| 91 | + o = o.parentNode; |
| 92 | + } while (o && o.parentNode && o.nodeName.toLowerCase() !== sNodeName); |
| 93 | + return (o.nodeName.toLowerCase() === sNodeName ? o : null); |
| 94 | + }; |
| 95 | + |
| 96 | + this.events = { |
| 97 | + |
| 98 | + // handlers for sound events as they're started/stopped/played |
| 99 | + |
| 100 | + play: function() { |
| 101 | + pl.removeClass(this._data.oLink,this._data.className); |
| 102 | + this._data.className = pl.css.sPlaying; |
| 103 | + pl.addClass(this._data.oLink,this._data.className); |
| 104 | + }, |
| 105 | + |
| 106 | + stop: function() { |
| 107 | + pl.removeClass(this._data.oLink,this._data.className); |
| 108 | + this._data.className = ''; |
| 109 | + }, |
| 110 | + |
| 111 | + pause: function() { |
| 112 | + pl.removeClass(this._data.oLink,this._data.className); |
| 113 | + this._data.className = pl.css.sPaused; |
| 114 | + pl.addClass(this._data.oLink,this._data.className); |
| 115 | + }, |
| 116 | + |
| 117 | + resume: function() { |
| 118 | + pl.removeClass(this._data.oLink,this._data.className); |
| 119 | + this._data.className = pl.css.sPlaying; |
| 120 | + pl.addClass(this._data.oLink,this._data.className); |
| 121 | + }, |
| 122 | + |
| 123 | + finish: function() { |
| 124 | + pl.removeClass(this._data.oLink,this._data.className); |
| 125 | + this._data.className = ''; |
| 126 | + if (pl.config.playNext) { |
| 127 | + var nextLink = (pl.indexByURL[this._data.oLink.href]+1); |
| 128 | + if (nextLink<pl.links.length) { |
| 129 | + pl.handleClick({'target':pl.links[nextLink]}); |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + }; |
| 135 | + |
| 136 | + this.stopEvent = function(e) { |
| 137 | + if (typeof e !== 'undefined' && typeof e.preventDefault !== 'undefined') { |
| 138 | + e.preventDefault(); |
| 139 | + } else if (typeof window.event !== 'undefined' && typeof window.event.returnValue !== 'undefined') { |
| 140 | + window.event.returnValue = false; |
| 141 | + } |
| 142 | + return false; |
| 143 | + }; |
| 144 | + |
| 145 | + this.getTheDamnLink = (isIE) ? function(e) { |
| 146 | + // I really didn't want to have to do this. |
| 147 | + return (e && e.target ? e.target : window.event.srcElement); |
| 148 | + } : function(e) { |
| 149 | + return e.target; |
| 150 | + }; |
| 151 | + |
| 152 | + this.handleClick = function(e) { |
| 153 | + // a sound link was clicked |
| 154 | + if (typeof e.button !== 'undefined' && e.button>1) { |
| 155 | + // ignore right-click |
| 156 | + return true; |
| 157 | + } |
| 158 | + var o = self.getTheDamnLink(e), |
| 159 | + sURL, |
| 160 | + soundURL, |
| 161 | + thisSound; |
| 162 | + if (o.nodeName.toLowerCase() !== 'a') { |
| 163 | + o = self.isChildOfNode(o,'a'); |
| 164 | + if (!o) { |
| 165 | + return true; |
| 166 | + } |
| 167 | + } |
| 168 | + sURL = o.getAttribute('href'); |
| 169 | + if (!o.href || !soundManager.canPlayLink(o) || self.classContains(o,self.excludeClass)) { |
| 170 | + return true; // pass-thru for non-MP3/non-links |
| 171 | + } |
| 172 | + if (!self.classContains(o,self.includeClass)) { |
| 173 | + return true; |
| 174 | + } |
| 175 | + sm._writeDebug('handleClick()'); |
| 176 | + soundURL = (o.href); |
| 177 | + thisSound = self.getSoundByURL(soundURL); |
| 178 | + if (thisSound) { |
| 179 | + // already exists |
| 180 | + if (thisSound === self.lastSound) { |
| 181 | + // and was playing (or paused) |
| 182 | + thisSound.togglePause(); |
| 183 | + } else { |
| 184 | + // different sound |
| 185 | + thisSound.togglePause(); // start playing current |
| 186 | + sm._writeDebug('sound different than last sound: '+self.lastSound.sID); |
| 187 | + if (self.lastSound) { |
| 188 | + self.stopSound(self.lastSound); |
| 189 | + } |
| 190 | + } |
| 191 | + } else { |
| 192 | + // create sound |
| 193 | + thisSound = sm.createSound({ |
| 194 | + id:'basicMP3Sound'+(self.soundCount++), |
| 195 | + url:soundURL, |
| 196 | + onplay:self.events.play, |
| 197 | + onstop:self.events.stop, |
| 198 | + onpause:self.events.pause, |
| 199 | + onresume:self.events.resume, |
| 200 | + onfinish:self.events.finish |
| 201 | + }); |
| 202 | + // tack on some custom data |
| 203 | + thisSound._data = { |
| 204 | + oLink: o, // DOM node for reference within SM2 object event handlers |
| 205 | + className: self.css.sPlaying |
| 206 | + }; |
| 207 | + self.soundsByURL[soundURL] = thisSound; |
| 208 | + self.sounds.push(thisSound); |
| 209 | + if (self.lastSound) { |
| 210 | + // stop last sound |
| 211 | + self.stopSound(self.lastSound); |
| 212 | + } |
| 213 | + thisSound.play(); |
| 214 | + } |
| 215 | + self.lastSound = thisSound; // reference for next call |
| 216 | + self.stopEvent(e); |
| 217 | + return false; |
| 218 | + }; |
| 219 | + |
| 220 | + this.stopSound = function(oSound) { |
| 221 | + soundManager.stop(oSound.sID); |
| 222 | + if (!isTouchDevice) { // iOS 4.2+ security blocks onfinish() -> playNext() if we set a .src in-between(?) |
| 223 | + soundManager.unload(oSound.sID); |
| 224 | + } |
| 225 | + }; |
| 226 | + |
| 227 | + this.init = function() { |
| 228 | + sm._writeDebug('basicMP3Player.init()'); |
| 229 | + var i, j, |
| 230 | + foundItems = 0, |
| 231 | + oLinks = document.getElementsByTagName('a'); |
| 232 | + // grab all links, look for .mp3 |
| 233 | + for (i=0, j=oLinks.length; i<j; i++) { |
| 234 | + if (self.classContains(oLinks[i],self.css.sDefault) && !self.classContains(oLinks[i],self.excludeClass)) { |
| 235 | + // self.addClass(oLinks[i],self.css.sDefault); // add default CSS decoration - good if you're lazy and want ALL MP3/playable links to do this |
| 236 | + self.links[foundItems] = (oLinks[i]); |
| 237 | + self.indexByURL[oLinks[i].href] = foundItems; // hack for indexing |
| 238 | + foundItems++; |
| 239 | + } |
| 240 | + } |
| 241 | + if (foundItems>0) { |
| 242 | + self.addEventHandler(document,'click',self.handleClick); |
| 243 | + if (self.config.autoPlay) { |
| 244 | + self.handleClick({target:self.links[0],preventDefault:function(){}}); |
| 245 | + } |
| 246 | + } |
| 247 | + sm._writeDebug('basicMP3Player.init(): Found '+foundItems+' relevant items.'); |
| 248 | + }; |
| 249 | + |
| 250 | + this.init(); |
| 251 | + |
| 252 | +} |
| 253 | + |
| 254 | +var basicMP3Player = null; |
| 255 | + |
| 256 | +// use HTML5 audio for MP3/MP4, if available |
| 257 | +soundManager.preferFlash = false; |
| 258 | + |
| 259 | +soundManager.onready(function() { |
| 260 | + // soundManager.createSound() etc. may now be called |
| 261 | + basicMP3Player = new BasicMP3Player(); |
| 262 | +}); |
\ No newline at end of file |
Property changes on: trunk/extensions/SoundManager2Button/script/mp3-player-button.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 263 | + native |
Index: trunk/extensions/SoundManager2Button/script/soundmanager2-jsmin.js |
— | — | @@ -0,0 +1,103 @@ |
| 2 | +/** @license |
| 3 | + |
| 4 | + |
| 5 | + SoundManager 2: JavaScript Sound for the Web |
| 6 | + ---------------------------------------------- |
| 7 | + http://schillmania.com/projects/soundmanager2/ |
| 8 | + |
| 9 | + Copyright (c) 2007, Scott Schiller. All rights reserved. |
| 10 | + Code provided under the BSD License: |
| 11 | + http://schillmania.com/projects/soundmanager2/license.txt |
| 12 | + |
| 13 | + V2.97a.20111030 |
| 14 | +*/ |
| 15 | +(function(S){function T(T,fa){function k(b){return function(a){return!this._t||!this._t._a?(this._t&&this._t.sID?c._wD(h+"ignoring "+a.type+": "+this._t.sID):c._wD(h+"ignoring "+a.type),null):b.call(this,a)}}this.flashVersion=8;this.debugMode=true;this.debugFlash=false;this.useConsole=true;this.waitForWindowLoad=this.consoleOnly=false;this.bgColor="#ffffff";this.useHighPerformance=false;this.flashPollingInterval=null;this.flashLoadTimeout=1E3;this.wmode=null;this.allowScriptAccess="always";this.useFlashBlock= |
| 16 | +false;this.useHTML5Audio=true;this.html5Test=/^(probably|maybe)$/i;this.preferFlash=true;this.noSWFCache=false;this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:true},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:false},ogg:{type:["audio/ogg; codecs=vorbis"],required:false},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave", |
| 17 | +"audio/x-wav"],required:false}};this.defaultOptions={autoLoad:false,stream:true,autoPlay:false,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onstop:null,onfailure:null,onfinish:null,multiShot:true,multiShotEvents:false,position:null,pan:0,type:null,usePolicyFile:false,volume:100};this.flash9Options={isMovieStar:null,usePeakData:false,useWaveformData:false,useEQData:false,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3, |
| 18 | +serverURL:null,onconnect:null,duration:null};this.movieID="sm2-container";this.id=fa||"sm2movie";this.swfCSS={swfBox:"sm2-object-box",swfDefault:"movieContainer",swfError:"swf_error",swfTimedout:"swf_timedout",swfLoaded:"swf_loaded",swfUnblocked:"swf_unblocked",sm2Debug:"sm2_debug",highPerf:"high_performance",flashDebug:"flash_debug"};this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20111030";this.movieURL=this.version=null;this.url=T||null;this.altURL= |
| 19 | +null;this.enabled=this.swfLoaded=false;this.oMC=this.o=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.specialWmodeCase=this.muted=false;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:false,peakData:false,waveformData:false,eqData:false,movieStar:false};this.sandbox={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)", |
| 20 | +localTrusted:"local, trusted (local+internet access)"},description:null,noRemote:null,noLocal:null};var J;try{J=typeof Audio!=="undefined"&&typeof(new Audio).canPlayType!=="undefined"}catch(Xa){J=false}this.hasHTML5=J;this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=false;var ya,c=this,h="HTML5::",u,q=navigator.userAgent,i=S,K=i.location.href.toString(),g=document,ga,U,j,y=[],ha=true,r,L=false,M=false,m=false,v=false,ia=false,l,Qa=0,N,s,ja,C,D,V,za,ka,B,W,X,E,la,Y,Z,F,Aa, |
| 21 | +ma,Ra=["log","info","warn","error"],Ba,$,Ca,O=null,na=null,n,oa,G,Da,aa,ba,pa,o,ca=false,qa=false,Ea,Fa,w=null,Ga,da,P,z,ra,sa,Ha,p,Ia=Array.prototype.slice,Q=false,t,ea,Ja,x,Ka,ta=q.match(/(ipad|iphone|ipod)/i),Sa=q.match(/firefox/i),Ta=q.match(/droid/i),A=q.match(/msie/i),Ua=q.match(/webkit/i),R=q.match(/safari/i)&&!q.match(/chrome/i),Va=q.match(/opera/i);J=q.match(/(mobile|pre\/|xoom)/i)||ta;var ua=!K.match(/usehtml5audio/i)&&!K.match(/sm2\-ignorebadua/i)&&R&&q.match(/OS X 10_6_([3-7])/i),va=typeof console!== |
| 22 | +"undefined"&&typeof console.log!=="undefined",wa=typeof g.hasFocus!=="undefined"?g.hasFocus():null,H=R&&typeof g.hasFocus==="undefined",La=!H,Ma=/(mp3|mp4|mpa)/i,I=g.location?g.location.protocol.match(/http/i):null,Na=!I?"http://":"",Oa=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i,Pa="mpeg4,aac,flv,mov,mp4,m4v,f4v,m4a,mp4v,3gp,3g2".split(","),Wa=RegExp("\\.("+Pa.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL= |
| 23 | +!I;this._global_a=null;if(J&&(c.useHTML5Audio=true,c.preferFlash=false,ta))Q=c.ignoreFlash=true;this.supported=this.ok=function(){return w?m&&!v:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return u(c)||g[c]||i[c]};this.createSound=function(b){function a(){e=aa(e);c.sounds[d.id]=new ya(d);c.soundIDs.push(d.id);return c.sounds[d.id]}var e=null,f=null,d=null;if(!m||!c.ok())return pa("soundManager.createSound(): "+n(!m?"notReady":"notOK")),false;arguments.length===2&&(b={id:arguments[0],url:arguments[1]}); |
| 24 | +d=e=s(b);d.id.toString().charAt(0).match(/^[0-9]$/)&&c._wD("soundManager.createSound(): "+n("badID",d.id),2);c._wD("soundManager.createSound(): "+d.id+" ("+d.url+")",1);if(o(d.id,true))return c._wD("soundManager.createSound(): "+d.id+" exists",1),c.sounds[d.id];if(da(d))f=a(),c._wD("Loading sound "+d.id+" via HTML5"),f._setup_html5(d);else{if(j>8){if(d.isMovieStar===null)d.isMovieStar=d.serverURL||(d.type?d.type.match(Oa):false)||d.url.match(Wa);d.isMovieStar&&c._wD("soundManager.createSound(): using MovieStar handling"); |
| 25 | +if(d.isMovieStar){if(d.usePeakData)l("noPeak"),d.usePeakData=false;d.loops>1&&l("noNSLoop")}}d=ba(d,"soundManager.createSound(): ");f=a();if(j===8)c.o._createSound(d.id,d.loops||1,d.usePolicyFile);else if(c.o._createSound(d.id,d.url,d.usePeakData,d.useWaveformData,d.useEQData,d.isMovieStar,d.isMovieStar?d.bufferTime:false,d.loops||1,d.serverURL,d.duration||null,d.autoPlay,true,d.autoLoad,d.usePolicyFile),!d.serverURL)f.connected=true,d.onconnect&&d.onconnect.apply(f);!d.serverURL&&(d.autoLoad||d.autoPlay)&& |
| 26 | +f.load(d)}!d.serverURL&&d.autoPlay&&f.play();return f};this.destroySound=function(b,a){if(!o(b))return false;var e=c.sounds[b],f;e._iO={};e.stop();e.unload();for(f=0;f<c.soundIDs.length;f++)if(c.soundIDs[f]===b){c.soundIDs.splice(f,1);break}a||e.destruct(true);delete c.sounds[b];return true};this.load=function(b,a){return!o(b)?false:c.sounds[b].load(a)};this.unload=function(b){return!o(b)?false:c.sounds[b].unload()};this.onposition=function(b,a,e,f){return!o(b)?false:c.sounds[b].onposition(a,e,f)}; |
| 27 | +this.start=this.play=function(b,a){if(!m||!c.ok())return pa("soundManager.play(): "+n(!m?"notReady":"notOK")),false;return!o(b)?(a instanceof Object||(a={url:a}),a&&a.url?(c._wD('soundManager.play(): attempting to create "'+b+'"',1),a.id=b,c.createSound(a).play()):false):c.sounds[b].play(a)};this.setPosition=function(b,a){return!o(b)?false:c.sounds[b].setPosition(a)};this.stop=function(b){if(!o(b))return false;c._wD("soundManager.stop("+b+")",1);return c.sounds[b].stop()};this.stopAll=function(){var b; |
| 28 | +c._wD("soundManager.stopAll()",1);for(b in c.sounds)c.sounds.hasOwnProperty(b)&&c.sounds[b].stop()};this.pause=function(b){return!o(b)?false:c.sounds[b].pause()};this.pauseAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].pause()};this.resume=function(b){return!o(b)?false:c.sounds[b].resume()};this.resumeAll=function(){var b;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].resume()};this.togglePause=function(b){return!o(b)?false:c.sounds[b].togglePause()};this.setPan=function(b, |
| 29 | +a){return!o(b)?false:c.sounds[b].setPan(a)};this.setVolume=function(b,a){return!o(b)?false:c.sounds[b].setVolume(a)};this.mute=function(b){var a=0;typeof b!=="string"&&(b=null);if(b){if(!o(b))return false;c._wD('soundManager.mute(): Muting "'+b+'"');return c.sounds[b].mute()}else{c._wD("soundManager.mute(): Muting all sounds");for(a=c.soundIDs.length;a--;)c.sounds[c.soundIDs[a]].mute();c.muted=true}return true};this.muteAll=function(){c.mute()};this.unmute=function(b){typeof b!=="string"&&(b=null); |
| 30 | +if(b){if(!o(b))return false;c._wD('soundManager.unmute(): Unmuting "'+b+'"');return c.sounds[b].unmute()}else{c._wD("soundManager.unmute(): Unmuting all sounds");for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].unmute();c.muted=false}return true};this.unmuteAll=function(){c.unmute()};this.toggleMute=function(b){return!o(b)?false:c.sounds[b].toggleMute()};this.getMemoryUse=function(){var b=0;c.o&&j!==8&&(b=parseInt(c.o._getMemoryUse(),10));return b};this.disable=function(b){var a;typeof b==="undefined"&& |
| 31 | +(b=false);if(v)return false;v=true;l("shutdown",1);for(a=c.soundIDs.length;a--;)Ba(c.sounds[c.soundIDs[a]]);N(b);p.remove(i,"load",D);return true};this.canPlayMIME=function(b){var a;c.hasHTML5&&(a=P({type:b}));return!w||a?a:b?!!(j>8&&b.match(Oa)||b.match(c.mimePattern)):null};this.canPlayURL=function(b){var a;c.hasHTML5&&(a=P({url:b}));return!w||a?a:b?!!b.match(c.filePattern):null};this.canPlayLink=function(b){return typeof b.type!=="undefined"&&b.type&&c.canPlayMIME(b.type)?true:c.canPlayURL(b.href)}; |
| 32 | +this.getSoundById=function(b,a){if(!b)throw Error("soundManager.getSoundById(): sID is null/undefined");var e=c.sounds[b];!e&&!a&&c._wD('"'+b+'" is an invalid sound ID.',2);return e};this.onready=function(b,a){if(b&&b instanceof Function)return m&&c._wD(n("queue","onready")),a||(a=i),ja("onready",b,a),C(),true;else throw n("needFunction","onready");};this.ontimeout=function(b,a){if(b&&b instanceof Function)return m&&c._wD(n("queue","ontimeout")),a||(a=i),ja("ontimeout",b,a),C({type:"ontimeout"}), |
| 33 | +true;else throw n("needFunction","ontimeout");};this._wD=this._writeDebug=function(b,a,e){var f,d;if(!c.debugMode)return false;typeof e!=="undefined"&&e&&(b=b+" | "+(new Date).getTime());if(va&&c.useConsole){e=Ra[a];if(typeof console[e]!=="undefined")console[e](b);else console.log(b);if(c.useConsoleOnly)return true}try{f=u("soundmanager-debug");if(!f)return false;d=g.createElement("div");if(++Qa%2===0)d.className="sm2-alt";a=typeof a==="undefined"?0:parseInt(a,10);d.appendChild(g.createTextNode(b)); |
| 34 | +if(a){if(a>=2)d.style.fontWeight="bold";if(a===3)d.style.color="#ff3333"}f.insertBefore(d,f.firstChild)}catch(Ya){}return true};this._debug=function(){var b,a;l("currentObj",1);for(b=0,a=c.soundIDs.length;b<a;b++)c.sounds[c.soundIDs[b]]._debug()};this.reboot=function(){c._wD("soundManager.reboot()");c.soundIDs.length&&c._wD("Destroying "+c.soundIDs.length+" SMSound objects...");var b,a;for(b=c.soundIDs.length;b--;)c.sounds[c.soundIDs[b]].destruct();try{if(A)na=c.o.innerHTML;O=c.o.parentNode.removeChild(c.o); |
| 35 | +c._wD("Flash movie removed.")}catch(e){l("badRemove",2)}na=O=w=null;c.enabled=la=m=ca=qa=L=M=v=c.swfLoaded=false;c.soundIDs=c.sounds=[];c.o=null;for(b in y)if(y.hasOwnProperty(b))for(a=y[b].length;a--;)y[b][a].fired=false;c._wD("soundManager: Rebooting...");i.setTimeout(c.beginDelayedInit,20)};this.getMoviePercent=function(){return c.o&&typeof c.o.PercentLoaded!=="undefined"?c.o.PercentLoaded():null};this.beginDelayedInit=function(){ia=true;E();setTimeout(function(){if(qa)return false;Z();X();return qa= |
| 36 | +true},20);V()};this.destruct=function(){c._wD("soundManager.destruct()");c.disable(true)};ya=function(b){var a=this,e,f,d;this.sID=b.id;this.url=b.url;this._iO=this.instanceOptions=this.options=s(b);this.pan=this.options.pan;this.volume=this.options.volume;this._lastURL=null;this.isHTML5=false;this._a=null;this.id3={};this._debug=function(){if(c.debugMode){var b=null,d=[],e,f;for(b in a.options)a.options[b]!==null&&(a.options[b]instanceof Function?(e=a.options[b].toString(),e=e.replace(/\s\s+/g," "), |
| 37 | +f=e.indexOf("{"),d.push(" "+b+": {"+e.substr(f+1,Math.min(Math.max(e.indexOf("\n")-1,64),64)).replace(/\n/g,"")+"... }")):d.push(" "+b+": "+a.options[b]));c._wD("SMSound() merged options: {\n"+d.join(", \n")+"\n}")}};this._debug();this.load=function(b){var d=null;if(typeof b!=="undefined")a._iO=s(b,a.options),a.instanceOptions=a._iO;else if(b=a.options,a._iO=b,a.instanceOptions=a._iO,a._lastURL&&a._lastURL!==a.url)l("manURL"),a._iO.url=a.url,a.url=null;if(!a._iO.url)a._iO.url=a.url;c._wD("SMSound.load(): "+ |
| 38 | +a._iO.url,1);if(a._iO.url===a.url&&a.readyState!==0&&a.readyState!==2)return l("onURL",1),a;a._lastURL=a.url;a.loaded=false;a.readyState=1;a.playState=0;if(da(a._iO))d=a._setup_html5(a._iO),d._called_load?c._wD(h+"ignoring request to load again: "+a.sID):(c._wD(h+"load: "+a.sID),a._html5_canplay=false,d.load(),d._called_load=true,a._iO.autoPlay&&a.play());else try{a.isHTML5=false,a._iO=ba(aa(a._iO)),j===8?c.o._load(a.sID,a._iO.url,a._iO.stream,a._iO.autoPlay,a._iO.whileloading?1:0,a._iO.loops||1, |
| 39 | +a._iO.usePolicyFile):c.o._load(a.sID,a._iO.url,!!a._iO.stream,!!a._iO.autoPlay,a._iO.loops||1,!!a._iO.autoLoad,a._iO.usePolicyFile)}catch(e){l("smError",2),r("onload",false),F({type:"SMSOUND_LOAD_JS_EXCEPTION",fatal:true})}return a};this.unload=function(){a.readyState!==0&&(c._wD('SMSound.unload(): "'+a.sID+'"'),a.isHTML5?(f(),a._a&&(a._a.pause(),ra(a._a))):j===8?c.o._unload(a.sID,"about:blank"):c.o._unload(a.sID),e());return a};this.destruct=function(b){c._wD('SMSound.destruct(): "'+a.sID+'"');if(a.isHTML5){if(f(), |
| 40 | +a._a)a._a.pause(),ra(a._a),Q||a._remove_html5_events(),a._a._t=null,a._a=null}else a._iO.onfailure=null,c.o._destroySound(a.sID);b||c.destroySound(a.sID,true)};this.start=this.play=function(b,e){var f,e=e===void 0?true:e;b||(b={});a._iO=s(b,a._iO);a._iO=s(a._iO,a.options);a.instanceOptions=a._iO;if(a._iO.serverURL&&!a.connected)return a.getAutoPlay()||(c._wD("SMSound.play(): Netstream not connected yet - setting autoPlay"),a.setAutoPlay(true)),a;da(a._iO)&&(a._setup_html5(a._iO),d());if(a.playState=== |
| 41 | +1&&!a.paused)if(f=a._iO.multiShot)c._wD('SMSound.play(): "'+a.sID+'" already playing (multi-shot)',1);else return c._wD('SMSound.play(): "'+a.sID+'" already playing (one-shot)',1),a;if(a.loaded)c._wD('SMSound.play(): "'+a.sID+'"');else if(a.readyState===0){c._wD('SMSound.play(): Attempting to load "'+a.sID+'"',1);if(!a.isHTML5)a._iO.autoPlay=true;a.load(a._iO)}else if(a.readyState===2)return c._wD('SMSound.play(): Could not load "'+a.sID+'" - exiting',2),a;else c._wD('SMSound.play(): "'+a.sID+'" is loading - attempting to play..', |
| 42 | +1);if(!a.isHTML5&&j===9&&a.position>0&&a.position===a.duration)c._wD('SMSound.play(): "'+a.sID+'": Sound at end, resetting to position:0'),a._iO.position=0;if(a.paused&&a.position&&a.position>0)c._wD('SMSound.play(): "'+a.sID+'" is resuming from paused state',1),a.resume();else{c._wD('SMSound.play(): "'+a.sID+'" is starting to play');a.playState=1;a.paused=false;(!a.instanceCount||a._iO.multiShotEvents||!a.isHTML5&&j>8&&!a.getAutoPlay())&&a.instanceCount++;a.position=typeof a._iO.position!=="undefined"&& |
| 43 | +!isNaN(a._iO.position)?a._iO.position:0;if(!a.isHTML5)a._iO=ba(aa(a._iO));if(a._iO.onplay&&e)a._iO.onplay.apply(a),a._onplay_called=true;a.setVolume(a._iO.volume,true);a.setPan(a._iO.pan,true);a.isHTML5?(d(),f=a._setup_html5(),a.setPosition(a._iO.position),f.play()):c.o._start(a.sID,a._iO.loops||1,j===9?a._iO.position:a._iO.position/1E3)}return a};this.stop=function(b){if(a.playState===1){a._onbufferchange(0);a.resetOnPosition(0);a.paused=false;if(!a.isHTML5)a.playState=0;a._iO.onstop&&a._iO.onstop.apply(a); |
| 44 | +if(a.isHTML5){if(a._a)a.setPosition(0),a._a.pause(),a.playState=0,a._onTimer(),f()}else c.o._stop(a.sID,b),a._iO.serverURL&&a.unload();a.instanceCount=0;a._iO={}}return a};this.setAutoPlay=function(b){c._wD("sound "+a.sID+" turned autoplay "+(b?"on":"off"));a._iO.autoPlay=b;a.isHTML5||(c.o._setAutoPlay(a.sID,b),b&&!a.instanceCount&&a.readyState===1&&(a.instanceCount++,c._wD("sound "+a.sID+" incremented instance count to "+a.instanceCount)))};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition= |
| 45 | +function(b){b===void 0&&(b=0);var d=a.isHTML5?Math.max(b,0):Math.min(a.duration||a._iO.duration,Math.max(b,0));a.position=d;b=a.position/1E3;a.resetOnPosition(a.position);a._iO.position=d;if(a.isHTML5){if(a._a)if(a._html5_canplay){if(a._a.currentTime!==b){c._wD("setPosition("+b+"): setting position");try{a._a.currentTime=b,(a.playState===0||a.paused)&&a._a.pause()}catch(e){c._wD("setPosition("+b+"): setting position failed: "+e.message,2)}}}else c._wD("setPosition("+b+"): delaying, sound not ready")}else b= |
| 46 | +j===9?a.position:b,a.readyState&&a.readyState!==2&&c.o._setPosition(a.sID,b,a.paused||!a.playState);a.isHTML5&&a.paused&&a._onTimer(true);return a};this.pause=function(b){if(a.paused||a.playState===0&&a.readyState!==1)return a;c._wD("SMSound.pause()");a.paused=true;a.isHTML5?(a._setup_html5().pause(),f()):(b||b===void 0)&&c.o._pause(a.sID);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){if(!a.paused)return a;c._wD("SMSound.resume()");a.paused=false;a.playState=1;a.isHTML5?(a._setup_html5().play(), |
| 47 | +d()):(a._iO.isMovieStar&&a.setPosition(a.position),c.o._pause(a.sID));!a._onplay_called&&a._iO.onplay?(a._iO.onplay.apply(a),a._onplay_called=true):a._iO.onresume&&a._iO.onresume.apply(a);return a};this.togglePause=function(){c._wD("SMSound.togglePause()");if(a.playState===0)return a.play({position:j===9&&!a.isHTML5?a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,d){typeof b==="undefined"&&(b=0);typeof d==="undefined"&&(d=false);a.isHTML5||c.o._setPan(a.sID, |
| 48 | +b);a._iO.pan=b;if(!d)a.pan=b,a.options.pan=b;return a};this.setVolume=function(b,d){typeof b==="undefined"&&(b=100);typeof d==="undefined"&&(d=false);if(a.isHTML5){if(a._a)a._a.volume=Math.max(0,Math.min(1,b/100))}else c.o._setVolume(a.sID,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;if(!d)a.volume=b,a.options.volume=b;return a};this.mute=function(){a.muted=true;if(a.isHTML5){if(a._a)a._a.muted=true}else c.o._setVolume(a.sID,0);return a};this.unmute=function(){a.muted=false;var b=typeof a._iO.volume!== |
| 49 | +"undefined";if(a.isHTML5){if(a._a)a._a.muted=false}else c.o._setVolume(a.sID,b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=function(c,b,d){a._onPositionItems.push({position:c,method:b,scope:typeof d!=="undefined"?d:a,fired:false});return a};this.processOnPosition=function(){var b,d;b=a._onPositionItems.length;if(!b||!a.playState||a._onPositionFired>=b)return false;for(;b--;)if(d=a._onPositionItems[b],!d.fired&&a.position>= |
| 50 | +d.position)d.fired=true,c._onPositionFired++,d.method.apply(d.scope,[d.position]);return true};this.resetOnPosition=function(b){var d,e;d=a._onPositionItems.length;if(!d)return false;for(;d--;)if(e=a._onPositionItems[d],e.fired&&b<=e.position)e.fired=false,c._onPositionFired--;return true};d=function(){a.isHTML5&&Ea(a)};f=function(){a.isHTML5&&Fa(a)};e=function(){a._onPositionItems=[];a._onPositionFired=0;a._hasTimer=null;a._onplay_called=false;a._a=null;a._html5_canplay=false;a.bytesLoaded=null; |
| 51 | +a.bytesTotal=null;a.position=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.failures=0;a.loaded=false;a.playState=0;a.paused=false;a.readyState=0;a.muted=false;a.isBuffering=false;a.instanceOptions={};a.instanceCount=0;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.eqData=[];a.eqData.left=[];a.eqData.right=[]};e();this._onTimer=function(b){var d={};if(a._hasTimer||b)return a._a&&(b||(a.playState>0||a.readyState===1)&&!a.paused)?(a.duration=a._get_html5_duration(), |
| 52 | +a.durationEstimate=a.duration,b=a._a.currentTime?a._a.currentTime*1E3:0,a._whileplaying(b,d,d,d,d),true):(c._wD('_onTimer: Warn for "'+a.sID+'": '+(!a._a?"Could not find element. ":"")+(a.playState===0?"playState bad, 0?":"playState = "+a.playState+", OK")),false)};this._get_html5_duration=function(){var c=a._a?a._a.duration*1E3:a._iO?a._iO.duration:void 0;return c&&!isNaN(c)&&c!==Infinity?c:a._iO?a._iO.duration:null};this._setup_html5=function(b){var b=s(a._iO,b),d=Q?c._global_a:a._a,f=decodeURI(b.url), |
| 53 | +g=d&&d._t?d._t.instanceOptions:null;if(d){if(d._t&&g.url===b.url&&(!a._lastURL||a._lastURL===g.url))return d;c._wD("setting new URL on existing object: "+f+(a._lastURL?", old URL: "+a._lastURL:""));Q&&d._t&&d._t.playState&&b.url!==g.url&&d._t.stop();e();d.src=b.url;a.url=b.url;a._lastURL=b.url;d._called_load=false}else{c._wD("creating HTML5 Audio() element with URL: "+f);d=new Audio(b.url);d._called_load=false;if(Ta)d._called_load=true;if(Q)c._global_a=d}a.isHTML5=true;a._a=d;d._t=a;a._add_html5_events(); |
| 54 | +d.loop=b.loops>1?"loop":"";b.autoLoad||b.autoPlay?(d.autobuffer="auto",d.preload="auto",a.load(),d._called_load=true):(d.autobuffer=false,d.preload="none");d.loop=b.loops>1?"loop":"";return d};this._add_html5_events=function(){if(a._a._added_events)return false;var b;c._wD(h+"adding event listeners: "+a.sID);a._a._added_events=true;for(b in x)x.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,x[b],false);return true};this._remove_html5_events=function(){var b;c._wD(h+"removing event listeners: "+ |
| 55 | +a.sID);a._a._added_events=false;for(b in x)x.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,x[b],false)};this._onload=function(b){b=!!b;c._wD('SMSound._onload(): "'+a.sID+'"'+(b?" loaded.":" failed to load? - "+a.url),b?1:2);!b&&!a.isHTML5&&(c.sandbox.noRemote===true&&c._wD("SMSound._onload(): "+n("noNet"),1),c.sandbox.noLocal===true&&c._wD("SMSound._onload(): "+n("noLocal"),1));a.loaded=b;a.readyState=b?3:2;a._onbufferchange(0);a._iO.onload&&a._iO.onload.apply(a,[b]);return true};this._onbufferchange= |
| 56 | +function(b){if(a.playState===0)return false;if(b&&a.isBuffering||!b&&!a.isBuffering)return false;a.isBuffering=b===1;a._iO.onbufferchange&&(c._wD("SMSound._onbufferchange(): "+b),a._iO.onbufferchange.apply(a));return true};this._onsuspend=function(){a._iO.onsuspend&&(c._wD("SMSound._onsuspend()"),a._iO.onsuspend.apply(a));return true};this._onfailure=function(b,d,e){a.failures++;c._wD('SMSound._onfailure(): "'+a.sID+'" count '+a.failures);if(a._iO.onfailure&&a.failures===1)a._iO.onfailure(a,b,d,e); |
| 57 | +else c._wD("SMSound._onfailure(): ignoring")};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a.resetOnPosition(0);if(a.instanceCount){a.instanceCount--;if(!a.instanceCount)a.playState=0,a.paused=false,a.instanceCount=0,a.instanceOptions={},a._iO={},f();if((!a.instanceCount||a._iO.multiShotEvents)&&b)c._wD('SMSound._onfinish(): "'+a.sID+'"'),b.apply(a)}};this._whileloading=function(c,b,d,e){a.bytesLoaded=c;a.bytesTotal=b;a.duration=Math.floor(d);a.bufferLength=e;if(a._iO.isMovieStar)a.durationEstimate= |
| 58 | +a.duration;else if(a.durationEstimate=a._iO.duration?a.duration>a._iO.duration?a.duration:a._iO.duration:parseInt(a.bytesTotal/a.bytesLoaded*a.duration,10),a.durationEstimate===void 0)a.durationEstimate=a.duration;a.readyState!==3&&a._iO.whileloading&&a._iO.whileloading.apply(a)};this._whileplaying=function(c,b,d,e,f){if(isNaN(c)||c===null)return false;a.position=c;a.processOnPosition();if(!a.isHTML5&&j>8){if(a._iO.usePeakData&&typeof b!=="undefined"&&b)a.peakData={left:b.leftPeak,right:b.rightPeak}; |
| 59 | +if(a._iO.useWaveformData&&typeof d!=="undefined"&&d)a.waveformData={left:d.split(","),right:e.split(",")};if(a._iO.useEQData&&typeof f!=="undefined"&&f&&f.leftEQ&&(c=f.leftEQ.split(","),a.eqData=c,a.eqData.left=c,typeof f.rightEQ!=="undefined"&&f.rightEQ))a.eqData.right=f.rightEQ.split(",")}a.playState===1&&(!a.isHTML5&&j===8&&!a.position&&a.isBuffering&&a._onbufferchange(0),a._iO.whileplaying&&a._iO.whileplaying.apply(a));return true};this._onid3=function(b,d){c._wD('SMSound._onid3(): "'+this.sID+ |
| 60 | +'" ID3 data received.');var e=[],f,g;for(f=0,g=b.length;f<g;f++)e[b[f]]=d[f];a.id3=s(a.id3,e);a._iO.onid3&&a._iO.onid3.apply(a)};this._onconnect=function(b){b=b===1;c._wD('SMSound._onconnect(): "'+a.sID+'"'+(b?" connected.":" failed to connect? - "+a.url),b?1:2);if(a.connected=b)a.failures=0,o(a.sID)&&(a.getAutoPlay()?a.play(void 0,a.getAutoPlay()):a._iO.autoLoad&&a.load()),a._iO.onconnect&&a._iO.onconnect.apply(a,[b])};this._ondataerror=function(b){a.playState>0&&(c._wD("SMSound._ondataerror(): "+ |
| 61 | +b),a._iO.ondataerror&&a._iO.ondataerror.apply(a))}};Y=function(){return g.body||g._docElement||g.getElementsByTagName("div")[0]};u=function(b){return g.getElementById(b)};s=function(b,a){var e={},f,d;for(f in b)b.hasOwnProperty(f)&&(e[f]=b[f]);f=typeof a==="undefined"?c.defaultOptions:a;for(d in f)f.hasOwnProperty(d)&&typeof e[d]==="undefined"&&(e[d]=f[d]);return e};p=function(){function b(a){var a=Ia.call(a),b=a.length;c?(a[1]="on"+a[1],b>3&&a.pop()):b===3&&a.push(false);return a}function a(a,b){var g= |
| 62 | +a.shift(),j=[f[b]];if(c)g[j](a[0],a[1]);else g[j].apply(g,a)}var c=i.attachEvent,f={add:c?"attachEvent":"addEventListener",remove:c?"detachEvent":"removeEventListener"};return{add:function(){a(b(arguments),"add")},remove:function(){a(b(arguments),"remove")}}}();x={abort:k(function(){c._wD(h+"abort: "+this._t.sID)}),canplay:k(function(){if(this._t._html5_canplay)return true;this._t._html5_canplay=true;c._wD(h+"canplay: "+this._t.sID+", "+this._t.url);this._t._onbufferchange(0);var b=!isNaN(this._t.position)? |
| 63 | +this._t.position/1E3:null;if(this._t.position&&this.currentTime!==b){c._wD(h+"canplay: setting position to "+b);try{this.currentTime=b}catch(a){c._wD(h+"setting position failed: "+a.message,2)}}}),load:k(function(){this._t.loaded||(this._t._onbufferchange(0),this._t._whileloading(this._t.bytesTotal,this._t.bytesTotal,this._t._get_html5_duration()),this._t._onload(true))}),emptied:k(function(){c._wD(h+"emptied: "+this._t.sID)}),ended:k(function(){c._wD(h+"ended: "+this._t.sID);this._t._onfinish()}), |
| 64 | +error:k(function(){c._wD(h+"error: "+this.error.code);this._t._onload(false)}),loadeddata:k(function(){var b=this._t,a=b.bytesTotal||1;c._wD(h+"loadeddata: "+this._t.sID);if(!b._loaded&&!R)b.duration=b._get_html5_duration(),b._whileloading(a,a,b._get_html5_duration()),b._onload(true)}),loadedmetadata:k(function(){c._wD(h+"loadedmetadata: "+this._t.sID)}),loadstart:k(function(){c._wD(h+"loadstart: "+this._t.sID);this._t._onbufferchange(1)}),play:k(function(){c._wD(h+"play: "+this._t.sID+", "+this._t.url); |
| 65 | +this._t._onbufferchange(0)}),playing:k(function(){c._wD(h+"playing: "+this._t.sID+", "+this._t.url);this._t._onbufferchange(0)}),progress:k(function(b){if(this._t.loaded)return false;var a,e,f;f=0;var d=b.type==="progress";e=b.target.buffered;var g=b.loaded||0,xa=b.total||1;if(e&&e.length){for(a=e.length;a--;)f=e.end(a)-e.start(a);g=f/b.target.duration;if(d&&e.length>1){f=[];e=e.length;for(a=0;a<e;a++)f.push(b.target.buffered.start(a)+"-"+b.target.buffered.end(a));c._wD(h+"progress: timeRanges: "+ |
| 66 | +f.join(", "))}d&&!isNaN(g)&&c._wD(h+"progress: "+this._t.sID+": "+Math.floor(g*100)+"% loaded")}isNaN(g)||(this._t._onbufferchange(0),this._t._whileloading(g,xa,this._t._get_html5_duration()),g&&xa&&g===xa&&x.load.call(this,b))}),ratechange:k(function(){c._wD(h+"ratechange: "+this._t.sID)}),suspend:k(function(b){c._wD(h+"suspend: "+this._t.sID);x.progress.call(this,b);this._t._onsuspend()}),stalled:k(function(){c._wD(h+"stalled: "+this._t.sID)}),timeupdate:k(function(){this._t._onTimer()}),waiting:k(function(){c._wD(h+ |
| 67 | +"waiting: "+this._t.sID);this._t._onbufferchange(1)})};da=function(b){return!b.serverURL&&(b.type?P({type:b.type}):P({url:b.url})||c.html5Only)};ra=function(b){if(b)b.src=Sa?"":"about:blank"};P=function(b){function a(a){return c.preferFlash&&t&&!c.ignoreFlash&&typeof c.flash[a]!=="undefined"&&c.flash[a]}if(!c.useHTML5Audio||!c.hasHTML5)return false;var e=b.url||null,b=b.type||null,f=c.audioFormats,d;if(b&&c.html5[b]!=="undefined")return c.html5[b]&&!a(b);if(!z){z=[];for(d in f)f.hasOwnProperty(d)&& |
| 68 | +(z.push(d),f[d].related&&(z=z.concat(f[d].related)));z=RegExp("\\.("+z.join("|")+")(\\?.*)?$","i")}d=e?e.toLowerCase().match(z):null;if(!d||!d.length)if(b)e=b.indexOf(";"),d=(e!==-1?b.substr(0,e):b).substr(6);else return false;else d=d[1];return d&&typeof c.html5[d]!=="undefined"?c.html5[d]&&!a(d):(b="audio/"+d,e=c.html5.canPlayType({type:b}),(c.html5[d]=e)&&c.html5[b]&&!a(b))};Ha=function(){function b(b){var d,e,f=false;if(!a||typeof a.canPlayType!=="function")return false;if(b instanceof Array){for(d= |
| 69 | +0,e=b.length;d<e&&!f;d++)if(c.html5[b[d]]||a.canPlayType(b[d]).match(c.html5Test))f=true,c.html5[b[d]]=true,c.flash[b[d]]=!(!c.preferFlash||!t||!b[d].match(Ma));return f}else return b=a&&typeof a.canPlayType==="function"?a.canPlayType(b):false,!(!b||!b.match(c.html5Test))}if(!c.useHTML5Audio||typeof Audio==="undefined")return false;var a=typeof Audio!=="undefined"?Va?new Audio(null):new Audio:null,e,f={},d,g;d=c.audioFormats;for(e in d)if(d.hasOwnProperty(e)&&(f[e]=b(d[e].type),f["audio/"+e]=f[e], |
| 70 | +c.flash[e]=c.preferFlash&&!c.ignoreFlash&&e.match(Ma)?true:false,d[e]&&d[e].related))for(g=d[e].related.length;g--;)f["audio/"+d[e].related[g]]=f[e],c.html5[d[e].related[g]]=f[e],c.flash[d[e].related[g]]=f[e];f.canPlayType=a?b:null;c.html5=s(c.html5,f);return true};W={notReady:"Not loaded yet - wait for soundManager.onload()/onready()",notOK:"Audio support is not available.",domError:"soundManager::createMovie(): appendChild/innerHTML call failed. DOM not ready or other error.",spcWmode:"soundManager::createMovie(): Removing wmode, preventing known SWF loading issue(s)", |
| 71 | +swf404:"soundManager: Verify that %s is a valid path.",tryDebug:"Try soundManager.debugFlash = true for more security details (output goes to SWF.)",checkSWF:"See SWF output for more debug info.",localFail:"soundManager: Non-HTTP page ("+g.location.protocol+" URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/",waitFocus:"soundManager: Special case: Waiting for focus-related event..", |
| 72 | +waitImpatient:"soundManager: Getting impatient, still waiting for Flash%s...",waitForever:"soundManager: Waiting indefinitely for Flash (will recover if unblocked)...",needFunction:"soundManager: Function object expected for %s",badID:'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',currentObj:"--- soundManager._debug(): Current sound objects ---",waitEI:"soundManager::initMovie(): Waiting for ExternalInterface call from Flash..",waitOnload:"soundManager: Waiting for window.onload()", |
| 73 | +docLoaded:"soundManager: Document already loaded",onload:"soundManager::initComplete(): calling soundManager.onload()",onloadOK:"soundManager.onload() complete",init:"soundManager::init()",didInit:"soundManager::init(): Already called?",flashJS:"soundManager: Attempting to call Flash from JS..",secNote:"Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html", |
| 74 | +badRemove:"Warning: Failed to remove flash movie.",noPeak:"Warning: peakData features unsupported for movieStar formats",shutdown:"soundManager.disable(): Shutting down",queue:"soundManager: Queueing %s handler",smFail:"soundManager: Failed to initialise.",smError:"SMSound.load(): Exception: JS-Flash communication failed, or JS error.",fbTimeout:"No flash response, applying ."+c.swfCSS.swfTimedout+" CSS..",fbLoaded:"Flash loaded",fbHandler:"soundManager::flashBlockHandler()",manURL:"SMSound.load(): Using manually-assigned URL", |
| 75 | +onURL:"soundManager.load(): current URL already assigned.",badFV:'soundManager.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',as2loop:"Note: Setting stream:false so looping can work (flash 8 limitation)",noNSLoop:"Note: Looping not implemented for MovieStar formats",needfl9:"Note: Switching to flash 9, required for MP4 formats.",mfTimeout:"Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case",mfOn:"mobileFlash::enabling on-screen flash repositioning",policy:"Enabling usePolicyFile for data access"}; |
| 76 | +n=function(){var b=Ia.call(arguments),a=b.shift(),a=W&&W[a]?W[a]:"",c,f;if(a&&b&&b.length)for(c=0,f=b.length;c<f;c++)a=a.replace("%s",b[c]);return a};aa=function(b){if(j===8&&b.loops>1&&b.stream)l("as2loop"),b.stream=false;return b};ba=function(b,a){if(b&&!b.usePolicyFile&&(b.onid3||b.usePeakData||b.useWaveformData||b.useEQData))c._wD((a||"")+n("policy")),b.usePolicyFile=true;return b};pa=function(b){typeof console!=="undefined"&&typeof console.warn!=="undefined"?console.warn(b):c._wD(b)};ga=function(){return false}; |
| 77 | +Ba=function(b){for(var a in b)b.hasOwnProperty(a)&&typeof b[a]==="function"&&(b[a]=ga)};$=function(b){typeof b==="undefined"&&(b=false);if(v||b)l("smFail",2),c.disable(b)};Ca=function(b){var a=null;if(b)if(b.match(/\.swf(\?.*)?$/i)){if(a=b.substr(b.toLowerCase().lastIndexOf(".swf?")+4))return b}else b.lastIndexOf("/")!==b.length-1&&(b+="/");b=(b&&b.lastIndexOf("/")!==-1?b.substr(0,b.lastIndexOf("/")+1):"./")+c.movieURL;c.noSWFCache&&(b+="?ts="+(new Date).getTime());return b};ka=function(){j=parseInt(c.flashVersion, |
| 78 | +10);if(j!==8&&j!==9)c._wD(n("badFV",j,8)),c.flashVersion=j=8;var b=c.debugMode||c.debugFlash?"_debug.swf":".swf";if(c.useHTML5Audio&&!c.html5Only&&c.audioFormats.mp4.required&&j<9)c._wD(n("needfl9")),c.flashVersion=j=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":j===9?" (AS3/Flash 9)":" (AS2/Flash 8)");j>8?(c.defaultOptions=s(c.defaultOptions,c.flash9Options),c.features.buffering=true,c.defaultOptions=s(c.defaultOptions,c.movieStarOptions),c.filePatterns.flash9=RegExp("\\.(mp3|"+Pa.join("|")+ |
| 79 | +")(\\?.*)?$","i"),c.features.movieStar=true):c.features.movieStar=false;c.filePattern=c.filePatterns[j!==8?"flash9":"flash8"];c.movieURL=(j===8?"soundmanager2.swf":"soundmanager2_flash9.swf").replace(".swf",b);c.features.peakData=c.features.waveformData=c.features.eqData=j>8};Aa=function(b,a){if(!c.o)return false;c.o._setPolling(b,a)};ma=function(){if(c.debugURLParam.test(K))c.debugMode=true;if(u(c.debugID))return false;var b,a,e,f;if(c.debugMode&&!u(c.debugID)&&(!va||!c.useConsole||c.useConsole&& |
| 80 | +va&&!c.consoleOnly)){b=g.createElement("div");b.id=c.debugID+"-toggle";a={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};b.appendChild(g.createTextNode("-"));b.onclick=Da;b.title="Toggle SM2 debug console";if(q.match(/msie 6/i))b.style.position="absolute",b.style.cursor="hand";for(f in a)a.hasOwnProperty(f)&&(b.style[f]=a[f]);a=g.createElement("div"); |
| 81 | +a.id=c.debugID;a.style.display=c.debugMode?"block":"none";if(c.debugMode&&!u(b.id)){try{e=Y(),e.appendChild(b)}catch(d){throw Error(n("domError")+" \n"+d.toString());}e.appendChild(a)}}};o=this.getSoundById;l=function(b,a){return b?c._wD(n(b),a):""};if(K.indexOf("sm2-debug=alert")+1&&c.debugMode)c._wD=function(b){S.alert(b)};Da=function(){var b=u(c.debugID),a=u(c.debugID+"-toggle");if(!b)return false;ha?(a.innerHTML="+",b.style.display="none"):(a.innerHTML="-",b.style.display="block");ha=!ha};r=function(b, |
| 82 | +a,c){if(typeof sm2Debugger!=="undefined")try{sm2Debugger.handleEvent(b,a,c)}catch(f){}return true};G=function(){var b=[];c.debugMode&&b.push(c.swfCSS.sm2Debug);c.debugFlash&&b.push(c.swfCSS.flashDebug);c.useHighPerformance&&b.push(c.swfCSS.highPerf);return b.join(" ")};oa=function(){var b=n("fbHandler"),a=c.getMoviePercent(),e=c.swfCSS,f={type:"FLASHBLOCK"};if(c.html5Only)return false;if(c.ok()){if(c.didFlashBlock&&c._wD(b+": Unblocked"),c.oMC)c.oMC.className=[G(),e.swfDefault,e.swfLoaded+(c.didFlashBlock? |
| 83 | +" "+e.swfUnblocked:"")].join(" ")}else{if(w)c.oMC.className=G()+" "+e.swfDefault+" "+(a===null?e.swfTimedout:e.swfError),c._wD(b+": "+n("fbTimeout")+(a?" ("+n("fbLoaded")+")":""));c.didFlashBlock=true;C({type:"ontimeout",ignoreInit:true,error:f});F(f)}};ja=function(b,a,c){typeof y[b]==="undefined"&&(y[b]=[]);y[b].push({method:a,scope:c||null,fired:false})};C=function(b){b||(b={type:"onready"});if(!m&&b&&!b.ignoreInit)return false;if(b.type==="ontimeout"&&c.ok())return false;var a={success:b&&b.ignoreInit? |
| 84 | +c.ok():!v},e=b&&b.type?y[b.type]||[]:[],f=[],d,g=[a],j=w&&c.useFlashBlock&&!c.ok();if(b.error)g[0].error=b.error;for(a=0,d=e.length;a<d;a++)e[a].fired!==true&&f.push(e[a]);if(f.length){c._wD("soundManager: Firing "+f.length+" "+b.type+"() item"+(f.length===1?"":"s"));for(a=0,d=f.length;a<d;a++)if(f[a].scope?f[a].method.apply(f[a].scope,g):f[a].method.apply(this,g),!j)f[a].fired=true}return true};D=function(){i.setTimeout(function(){c.useFlashBlock&&oa();C();c.onload instanceof Function&&(l("onload", |
| 85 | +1),c.onload.apply(i),l("onloadOK",1));c.waitForWindowLoad&&p.add(i,"load",D)},1)};ea=function(){if(t!==void 0)return t;var b=false,a=navigator,c=a.plugins,f,d=i.ActiveXObject;if(c&&c.length)(a=a.mimeTypes)&&a["application/x-shockwave-flash"]&&a["application/x-shockwave-flash"].enabledPlugin&&a["application/x-shockwave-flash"].enabledPlugin.description&&(b=true);else if(typeof d!=="undefined"){try{f=new d("ShockwaveFlash.ShockwaveFlash")}catch(g){}b=!!f}return t=b};Ga=function(){var b,a;if(ta&&q.match(/os (1|2|3_0|3_1)/i)){c.hasHTML5= |
| 86 | +false;c.html5Only=true;if(c.oMC)c.oMC.style.display="none";return false}if(c.useHTML5Audio){if(!c.html5||!c.html5.canPlayType)return c._wD("SoundManager: No HTML5 Audio() support detected."),c.hasHTML5=false,true;else c.hasHTML5=true;if(ua&&(c._wD("soundManager::Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - "+(!t?" would use flash fallback for MP3/MP4, but none detected.":"will use flash fallback for MP3/MP4, if available"),1),ea()))return true}else return true; |
| 87 | +for(a in c.audioFormats)if(c.audioFormats.hasOwnProperty(a)&&(c.audioFormats[a].required&&!c.html5.canPlayType(c.audioFormats[a].type)||c.flash[a]||c.flash[c.audioFormats[a].type]))b=true;c.ignoreFlash&&(b=false);c.html5Only=c.hasHTML5&&c.useHTML5Audio&&!b;return!c.html5Only};Ea=function(b){if(!b._hasTimer)b._hasTimer=true};Fa=function(b){if(b._hasTimer)b._hasTimer=false};F=function(b){b=typeof b!=="undefined"?b:{};c.onerror instanceof Function&&c.onerror.apply(i,[{type:typeof b.type!=="undefined"? |
| 88 | +b.type:null}]);typeof b.fatal!=="undefined"&&b.fatal&&c.disable()};Ja=function(){if(!ua||!ea())return false;var b=c.audioFormats,a,e;for(e in b)if(b.hasOwnProperty(e)&&(e==="mp3"||e==="mp4"))if(c._wD("soundManager: Using flash fallback for "+e+" format"),c.html5[e]=false,b[e]&&b[e].related)for(a=b[e].related.length;a--;)c.html5[b[e].related[a]]=false};this._setSandboxType=function(b){var a=c.sandbox;a.type=b;a.description=a.types[typeof a.types[b]!=="undefined"?b:"unknown"];c._wD("Flash security sandbox type: "+ |
| 89 | +a.type);if(a.type==="localWithFile")a.noRemote=true,a.noLocal=false,l("secNote",2);else if(a.type==="localWithNetwork")a.noRemote=false,a.noLocal=true;else if(a.type==="localTrusted")a.noRemote=false,a.noLocal=false};this._externalInterfaceOK=function(b){if(c.swfLoaded)return false;var a=(new Date).getTime();c._wD("soundManager::externalInterfaceOK()"+(b?" (~"+(a-b)+" ms)":""));r("swf",true);r("flashtojs",true);c.swfLoaded=true;H=false;ua&&Ja();A?setTimeout(U,100):U()};Z=function(b,a){function e(){c._wD("-- SoundManager 2 "+ |
| 90 | +c.version+(!c.html5Only&&c.useHTML5Audio?c.hasHTML5?" + HTML5 audio":", no HTML5 audio support":"")+(!c.html5Only?(c.useHighPerformance?", high performance mode, ":", ")+((c.flashPollingInterval?"custom ("+c.flashPollingInterval+"ms)":"normal")+" polling")+(c.wmode?", wmode: "+c.wmode:"")+(c.debugFlash?", flash debug mode":"")+(c.useFlashBlock?", flashBlock mode":""):"")+" --",1)}function f(a,b){return'<param name="'+a+'" value="'+b+'" />'}if(L&&M)return false;if(c.html5Only)return ka(),e(),c.oMC= |
| 91 | +u(c.movieID),U(),M=L=true,false;var d=a||c.url,j=c.altURL||d,h;h=Y();var i,o,k=G(),m,p=null,p=(p=g.getElementsByTagName("html")[0])&&p.dir&&p.dir.match(/rtl/i),b=typeof b==="undefined"?c.id:b;ka();c.url=Ca(I?d:j);a=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(c.wmode!==null&&(q.match(/msie 8/i)||!A&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))c.specialWmodeCase=true,l("spcWmode"),c.wmode=null;h={name:b,id:b,src:a,width:"auto",height:"auto",quality:"high", |
| 92 | +allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Na+"www.macromedia.com/go/getflashplayer",title:"JS/Flash audio component (SoundManager 2)",type:"application/x-shockwave-flash",wmode:c.wmode,hasPriority:"true"};if(c.debugFlash)h.FlashVars="debug=1";c.wmode||delete h.wmode;if(A)d=g.createElement("div"),o=['<object id="'+b+'" data="'+a+'" type="'+h.type+'" title="'+h.title+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+Na+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+ |
| 93 | +h.width+'" height="'+h.height+'">',f("movie",a),f("AllowScriptAccess",c.allowScriptAccess),f("quality",h.quality),c.wmode?f("wmode",c.wmode):"",f("bgcolor",c.bgColor),f("hasPriority","true"),c.debugFlash?f("FlashVars",h.FlashVars):"","</object>"].join("");else for(i in d=g.createElement("embed"),h)h.hasOwnProperty(i)&&d.setAttribute(i,h[i]);ma();k=G();if(h=Y())if(c.oMC=u(c.movieID)||g.createElement("div"),c.oMC.id){m=c.oMC.className;c.oMC.className=(m?m+" ":c.swfCSS.swfDefault)+(k?" "+k:"");c.oMC.appendChild(d); |
| 94 | +if(A)i=c.oMC.appendChild(g.createElement("div")),i.className=c.swfCSS.swfBox,i.innerHTML=o;M=true}else{c.oMC.id=c.movieID;c.oMC.className=c.swfCSS.swfDefault+" "+k;i=k=null;if(!c.useFlashBlock)if(c.useHighPerformance)k={position:"fixed",width:"8px",height:"8px",bottom:"0px",left:"0px",overflow:"hidden"};else if(k={position:"absolute",width:"6px",height:"6px",top:"-9999px",left:"-9999px"},p)k.left=Math.abs(parseInt(k.left,10))+"px";if(Ua)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(m in k)k.hasOwnProperty(m)&& |
| 95 | +(c.oMC.style[m]=k[m]);try{A||c.oMC.appendChild(d);h.appendChild(c.oMC);if(A)i=c.oMC.appendChild(g.createElement("div")),i.className=c.swfCSS.swfBox,i.innerHTML=o;M=true}catch(r){throw Error(n("domError")+" \n"+r.toString());}}L=true;e();c._wD("soundManager::createMovie(): Trying to load "+a+(!I&&c.altURL?" (alternate URL)":""),1);return true};X=function(){if(c.html5Only)return Z(),false;if(c.o)return false;c.o=c.getMovie(c.id);if(!c.o)O?(A?c.oMC.innerHTML=na:c.oMC.appendChild(O),O=null,L=true):Z(c.id, |
| 96 | +c.url),c.o=c.getMovie(c.id);c.o&&l("waitEI");c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return true};V=function(){setTimeout(za,1E3)};za=function(){if(ca)return false;ca=true;p.remove(i,"load",V);if(H&&!wa)return l("waitFocus"),false;var b;m||(b=c.getMoviePercent(),c._wD(n("waitImpatient",b===100?" (SWF loaded)":b>0?" (SWF "+b+"% loaded)":"")));setTimeout(function(){b=c.getMoviePercent();m||(c._wD("soundManager: No Flash response within expected time.\nLikely causes: "+(b===0? |
| 97 | +"Loading "+c.movieURL+" may have failed (and/or Flash "+j+"+ not present?), ":"")+"Flash blocked or JS-Flash security error."+(c.debugFlash?" "+n("checkSWF"):""),2),!I&&b&&(l("localFail",2),c.debugFlash||l("tryDebug",2)),b===0&&c._wD(n("swf404",c.url)),r("flashtojs",false,": Timed out"+I?" (Check flash security or flash blockers)":" (No plugin/missing SWF?)"));!m&&La&&(b===null?c.useFlashBlock||c.flashLoadTimeout===0?(c.useFlashBlock&&oa(),l("waitForever")):$(true):c.flashLoadTimeout===0?l("waitForever"): |
| 98 | +$(true))},c.flashLoadTimeout)};B=function(){function b(){p.remove(i,"focus",B);p.remove(i,"load",B)}if(wa||!H)return b(),true;wa=La=true;c._wD("soundManager::handleFocus()");R&&H&&p.remove(i,"mousemove",B);ca=false;b();return true};Ka=function(){var b,a=[];if(c.useHTML5Audio&&c.hasHTML5){for(b in c.audioFormats)c.audioFormats.hasOwnProperty(b)&&a.push(b+": "+c.html5[b]+(!c.html5[b]&&t&&c.flash[b]?" (using flash)":c.preferFlash&&c.flash[b]&&t?" (preferring flash)":!c.html5[b]?" ("+(c.audioFormats[b].required? |
| 99 | +"required, ":"")+"and no flash support)":""));c._wD("-- SoundManager 2: HTML5 support tests ("+c.html5Test+"): "+a.join(", ")+" --",1)}};N=function(b){if(m)return false;if(c.html5Only)return c._wD("-- SoundManager 2: loaded --"),m=true,D(),r("onload",true),true;var a;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())m=true,v&&(a={type:!t&&w?"NO_FLASH":"INIT_TIMEOUT"});c._wD("-- SoundManager 2 "+(v?"failed to load":"loaded")+" ("+(v?"security/load error":"OK")+") --",1);if(v||b){if(c.useFlashBlock&& |
| 100 | +c.oMC)c.oMC.className=G()+" "+(c.getMoviePercent()===null?c.swfCSS.swfTimedout:c.swfCSS.swfError);C({type:"ontimeout",error:a});r("onload",false);F(a);return false}else r("onload",true);if(c.waitForWindowLoad&&!ia)return l("waitOnload"),p.add(i,"load",D),false;else c.waitForWindowLoad&&ia&&l("docLoaded"),D();return true};U=function(){l("init");if(m)return l("didInit"),false;if(c.html5Only){if(!m)p.remove(i,"load",c.beginDelayedInit),c.enabled=true,N();return true}X();try{l("flashJS"),c.o._externalInterfaceTest(false), |
| 101 | +Aa(true,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||c.o._disableDebug(),c.enabled=true,r("jstoflash",true),c.html5Only||p.add(i,"unload",ga)}catch(b){return c._wD("js/flash exception: "+b.toString()),r("jstoflash",false),F({type:"JS_TO_FLASH_EXCEPTION",fatal:true}),$(true),N(),false}N();p.remove(i,"load",c.beginDelayedInit);return true};E=function(){if(la)return false;la=true;ma();var b=K.toLowerCase(),a=null,a=null,e=typeof console!=="undefined"&&typeof console.log!=="undefined"; |
| 102 | +if(b.indexOf("sm2-usehtml5audio=")!==-1)a=b.charAt(b.indexOf("sm2-usehtml5audio=")+18)==="1",e&&console.log((a?"Enabling ":"Disabling ")+"useHTML5Audio via URL parameter"),c.useHTML5Audio=a;if(b.indexOf("sm2-preferflash=")!==-1)a=b.charAt(b.indexOf("sm2-preferflash=")+16)==="1",e&&console.log((a?"Enabling ":"Disabling ")+"preferFlash via URL parameter"),c.preferFlash=a;if(!t&&c.hasHTML5)c._wD("SoundManager: No Flash detected"+(!c.useHTML5Audio?", enabling HTML5.":". Trying HTML5-only mode.")),c.useHTML5Audio= |
| 103 | +true,c.preferFlash=false;Ha();c.html5.usingFlash=Ga();w=c.html5.usingFlash;Ka();if(!t&&w)c._wD("SoundManager: Fatal error: Flash is needed to play some required formats, but is not available."),c.flashLoadTimeout=1;g.removeEventListener&&g.removeEventListener("DOMContentLoaded",E,false);X();return true};sa=function(){g.readyState==="complete"&&(E(),g.detachEvent("onreadystatechange",sa));return true};ea();p.add(i,"focus",B);p.add(i,"load",B);p.add(i,"load",V);R&&H&&p.add(i,"mousemove",B);g.addEventListener? |
| 104 | +g.addEventListener("DOMContentLoaded",E,false):g.attachEvent?g.attachEvent("onreadystatechange",sa):(r("onload",false),F({type:"NO_DOM2_EVENTS",fatal:true}));g.readyState==="complete"&&setTimeout(E,100)}var fa=null;if(typeof SM2_DEFER==="undefined"||!SM2_DEFER)fa=new T;S.SoundManager=T;S.soundManager=fa})(window); |
\ No newline at end of file |
Property changes on: trunk/extensions/SoundManager2Button/script/soundmanager2-jsmin.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 105 | + native |
Index: trunk/extensions/SoundManager2Button/SoundManager2Button.i18n.php |
— | — | @@ -0,0 +1,21 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# Internationalisation file for SoundManager2Button extension. |
| 5 | +# |
| 6 | +# @file SoundManager2Button.i18n.php |
| 7 | +# @ingroup SoundManager2Button |
| 8 | +# |
| 9 | +# @author kroocsiogsi |
| 10 | + |
| 11 | +$messages = array(); |
| 12 | + |
| 13 | +$messages['en'] = array( |
| 14 | + 'soundmanager2button-desc' => 'Embeds a SoundManager 2 MP3 player into a wiki page', |
| 15 | + 'play' => 'Play.', |
| 16 | +); |
| 17 | + |
| 18 | +# Message documentation (Message documentation) |
| 19 | +$messages['qqq'] = array( |
| 20 | + 'soundmanager2button-desc' => '{{desc}}', |
| 21 | + 'play' => 'Play button text, primarily for screenreaders.', |
| 22 | +); |
Property changes on: trunk/extensions/SoundManager2Button/SoundManager2Button.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 23 | + native |
Index: trunk/extensions/SoundManager2Button/SoundManager2Button.php |
— | — | @@ -0,0 +1,96 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# Initialization file for SoundManager2Button extension. |
| 5 | +# |
| 6 | +# @file SoundManager2Button.php |
| 7 | +# @ingroup SoundManager2Button |
| 8 | +# @defgroup SoundManager2Button SoundManager2Button |
| 9 | +# |
| 10 | +# @author kroocsiogsi |
| 11 | +# |
| 12 | +# @license GNU GPL v3 |
| 13 | +# The SoundManager 2 files are licensed under a BSD license, |
| 14 | +# which is included with this extension. |
| 15 | +# |
| 16 | +# Tag: |
| 17 | +# <sm2>uploaded filename.mp3</sm2> |
| 18 | +# |
| 19 | +# Required in $wgExtensionAssetsPath/SoundManager2: |
| 20 | +# |
| 21 | +# SoundManager2Button.php |
| 22 | +# SoundManager2Button.i18n.php |
| 23 | +# |
| 24 | +# css/mp3-player-button.css |
| 25 | +# css/debug.css |
| 26 | +# |
| 27 | +# image/arrow-right-black.gif |
| 28 | +# image/arrow-right-black.png |
| 29 | +# image/arrow-right-white.gif |
| 30 | +# image/arrow-right-white.png |
| 31 | +# |
| 32 | +# script/args.js |
| 33 | +# script/mp3-player-button.js |
| 34 | +# |
| 35 | +# script/soundmanager2.js |
| 36 | +# script/soundmanager2-jsmin.js |
| 37 | +# script/soundmanager2-nodebug.js |
| 38 | +# script/soundmanager2-nodebug-jsmin.js <- We use this one in production. |
| 39 | +# |
| 40 | +# swf/soundmanager2.swf <- We use this one in production. |
| 41 | +# swf/soundmanager2_debug.swf |
| 42 | +# swf/soundmanager2_flash9.swf |
| 43 | +# swf/soundmanager2_flash9_debug.swf |
| 44 | +# |
| 45 | +# To activate the extension: |
| 46 | +# At the end of your LocalSettings.php: require_once("extensions/SoundManager2Button/SoundManager2Button.php"); |
| 47 | +# |
| 48 | +# For debug mode: |
| 49 | +# In $wgResourceModules: add css/debug.css |
| 50 | +# In $wgResourceModules: replace script/soundmanager2-nodebug-jsmin.js with script/soundmanager2.js |
| 51 | +# In args.js : toggle soundManager.debugMode = false; |
| 52 | + |
| 53 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 54 | + echo "This is the SoundManager2Button MediaWiki extension. It cannot be run standalone.\n"; |
| 55 | + die( -1 ); |
| 56 | +} |
| 57 | + |
| 58 | +$wgExtensionCredits['media'][] = array( |
| 59 | + 'path' => __FILE__, |
| 60 | + 'name' => 'SoundManager2Button', |
| 61 | + 'author' => 'kroocsiogsi', |
| 62 | + 'url' => 'https://www.mediawiki.org/wiki/Extension:SoundManager2Button', |
| 63 | + 'description' => 'Embeds a SoundManager 2 MP3 player into a wiki page', |
| 64 | + 'descriptionmsg' => 'soundmanager2button-desc', |
| 65 | + 'version' => '0.3.0', |
| 66 | +); |
| 67 | + |
| 68 | +$wgExtensionMessagesFiles['SoundManager2Button'] = dirname( __FILE__ ) . '/SoundManager2Button.i18n.php'; |
| 69 | + |
| 70 | +$wgHooks['ParserFirstCallInit'][] = 'wfSoundManager2Button'; |
| 71 | + |
| 72 | +$wgResourceModules['ext.wfSoundManager2Button'] = array( |
| 73 | + 'scripts' => array( 'script/soundmanager2-nodebug-jsmin.js', 'script/mp3-player-button.js', 'script/args.js' ), |
| 74 | + 'styles' => 'css/mp3-player-button.css', |
| 75 | + 'localBasePath' => dirname( __FILE__ ), |
| 76 | + 'remoteExtPath' => 'SoundManager2Button', |
| 77 | +); |
| 78 | + |
| 79 | +// Hook our callback function into the parser |
| 80 | +function wfSoundManager2Button( &$parser ) { |
| 81 | + $parser->setHook( 'sm2', 'renderSM2' ); |
| 82 | + return true; |
| 83 | +} |
| 84 | + |
| 85 | +// Execute |
| 86 | +function renderSM2( $input, $args, $parser ) { |
| 87 | + global $wgExtensionAssetsPath; |
| 88 | + $parser->getOutput()->addModules( 'ext.wfSoundManager2Button' ); |
| 89 | + |
| 90 | + $file = wfFindFile($input); |
| 91 | + if( $file ) { |
| 92 | + $url = $file->getFullURL(); |
| 93 | + $output='<a href="'.$url.'" title="'.wfMsgForContent('play').'" class="sm2_button">'.wfMsgForContent('play').'</a>'; |
| 94 | + }; |
| 95 | + |
| 96 | + return $output; |
| 97 | +} |
Property changes on: trunk/extensions/SoundManager2Button/SoundManager2Button.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 98 | + native |
Index: trunk/extensions/SoundManager2Button/css/mp3-player-button.css |
— | — | @@ -0,0 +1,120 @@ |
| 2 | +/* |
| 3 | + |
| 4 | + SoundManager 2: Basic MP3 player CSS |
| 5 | + ------------------------------------ |
| 6 | + |
| 7 | + Clicks on links to MP3s are intercepted via JS, calls are |
| 8 | + made to SoundManager to load/play sounds. CSS classes are |
| 9 | + appended to the link, which are used to highlight the |
| 10 | + current play state and so on. |
| 11 | + |
| 12 | + Class names are applied in addition to "sm2_button" base. |
| 13 | + |
| 14 | + Default: |
| 15 | + |
| 16 | + sm2_button |
| 17 | + |
| 18 | + Additional states: |
| 19 | + |
| 20 | + sm2_playing |
| 21 | + sm2_paused |
| 22 | + |
| 23 | + eg. |
| 24 | + |
| 25 | + <!-- default --> |
| 26 | + <a href="some.mp3" class="sm2_button">some.mp3</a> |
| 27 | + |
| 28 | + <!-- playing --> |
| 29 | + <a href="some.mp3" class="sm2_button sm2_playing">some.mp3</a> |
| 30 | + |
| 31 | + |
| 32 | + Note you don't require ul.graphic / ul.flat etc. for your use |
| 33 | + if only using one style on a page. You can just use .sm2_button{} |
| 34 | + and so on, but isolate the CSS you want. |
| 35 | + |
| 36 | + Side note: Would do multiple class definitions eg. |
| 37 | + |
| 38 | + a.sm2_default.sm2_playing{} |
| 39 | + |
| 40 | + .. except IE 6 has a parsing bug which may break behaviour, |
| 41 | + applying sm2_playing {} even when the class is set to sm2_default. |
| 42 | + |
| 43 | + |
| 44 | + If you want to make your own UI from scratch, here is the base: |
| 45 | + |
| 46 | + Default + hover state, "click to play": |
| 47 | + |
| 48 | + a.sm2_button {} |
| 49 | + a.sm2_button:hover {} |
| 50 | + |
| 51 | + Playing + hover state, "click to pause": |
| 52 | + |
| 53 | + a.sm2_playing {} |
| 54 | + a.sm2_playing:hover {} |
| 55 | + |
| 56 | + Paused + hover state, "click to resume": |
| 57 | + |
| 58 | + a.sm2_paused {} |
| 59 | + a.sm2_paused:hover {} |
| 60 | + |
| 61 | +*/ |
| 62 | + |
| 63 | +a.sm2_button { |
| 64 | + position:relative; |
| 65 | + display:inline-block; /* If you worry about old browser bugs, Firefox 2 might not like this and may need -moz-inline-box instead. :D */ |
| 66 | + width:18px; |
| 67 | + height:18px; |
| 68 | + text-indent:-9999px; /* don't show link text */ |
| 69 | + overflow:hidden; /* don't draw inner link text */ |
| 70 | + vertical-align:middle; |
| 71 | + /* and, a bit of round-ness for the cool browsers. */ |
| 72 | + -moz-border-radius:6px; |
| 73 | + -webkit-border-radius:6px; |
| 74 | + -o-border-radius:6px; |
| 75 | + border-radius:6px; |
| 76 | + margin-top:-1px; /* vertical align tweak */ |
| 77 | + /* safari 3.1+ fun (/W3 working draft extension, TBD.) */ |
| 78 | + -webkit-transition-property: hover; |
| 79 | + -webkit-transition: all 0.2s ease-in-out; |
| 80 | + -moz-transition: all 0.2s ease-in-out 0s; /* firefox 4 (couldn't sort out -moz-transform vs. MozTransform, so, "all" for now) */ |
| 81 | + -o-transition-property: background-color; /* opera 10.5 */ |
| 82 | + -o-transition-duration: 0.15s; |
| 83 | + /* weird IE 6/7 display fixes, and/or I'm doing it wrong */ |
| 84 | + *text-indent:0px; |
| 85 | + *line-height:99em; |
| 86 | + *vertical-align: top; |
| 87 | +} |
| 88 | + |
| 89 | +a.sm2_button:focus { |
| 90 | + outline:none; /* maybe evil, but don't show the slight border outline on focus. */ |
| 91 | +} |
| 92 | + |
| 93 | +a.sm2_button, |
| 94 | +a.sm2_button.sm2_paused:hover { |
| 95 | + background-color:#3399cc; |
| 96 | + background-image:url(../image/arrow-right-white.png); |
| 97 | + /* where possible, use data: and skip the HTTP request. Fancy-pants. Would use short-hand background: for above, but IE 8 doesn't override background-image. */ |
| 98 | + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAKCAYAAABmBXS+AAAAbklEQVQY02NgQAL//v1jZMAF/v//vwuIs9HEUBUBTbj4HwIeA3EGVsVAxtn/qOAVUGM8uknIiv4hsV8A5ZKxKfoLVvnvHwifAzLtMKwDSQLBVSBti27dJajkcSD2RJODO3wtkOOMz/tMSJJYAxMA5dmsL0IfubQAAAAASUVORK5CYII=); |
| 99 | + *background-image:url(../image/arrow-right-white.gif); /* IE 6+7 don't do DATA: URIs */ |
| 100 | + background-repeat:no-repeat; |
| 101 | + background-position:5px 50%; |
| 102 | + *background-position:5px 4px; /* IE 6 again */ |
| 103 | +} |
| 104 | + |
| 105 | +a.sm2_button:hover, |
| 106 | +a.sm2_button.sm2_playing, |
| 107 | +a.sm2_button.sm2_playing:hover { |
| 108 | + background-color:#cc3333; |
| 109 | +} |
| 110 | + |
| 111 | +a.sm2_button.sm2_playing, |
| 112 | +a.sm2_button.sm2_playing:hover { |
| 113 | + -moz-transform:rotate(90deg); |
| 114 | + -webkit-transform:rotate(90deg); |
| 115 | + -ms-transform:rotate(90deg); |
| 116 | +} |
| 117 | + |
| 118 | +a.sm2_button.sm2_paused, |
| 119 | +a.sm2_button.sm2_paused:hover { |
| 120 | + background-color:#666; |
| 121 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/SoundManager2Button/css/mp3-player-button.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 122 | + native |
Index: trunk/extensions/SoundManager2Button/css/debug.css |
— | — | @@ -0,0 +1 @@ |
| 2 | +#soundmanager-debug { position:absolute;position:fixed;*position:absolute;bottom:10px;right:10px;width:50em;height:18em;overflow:auto;background:#fff;margin:1em;padding:1em;border:1px solid #999;font-family:"lucida console",verdana,tahoma,"sans serif";font-size:x-small;line-height:1.5em;opacity:0.9;filter:alpha(opacity=90); } |
Property changes on: trunk/extensions/SoundManager2Button/css/debug.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 3 | + native |