diff --git a/spa/audio.py b/spa/audio.py new file mode 100644 index 0000000..44829f8 --- /dev/null +++ b/spa/audio.py @@ -0,0 +1,36 @@ +from wsgiref.util import FileWrapper +from django.conf.urls import url +from django.http import HttpResponse, Http404 +import os +from spa.models.Mix import Mix + +class FixedFileWrapper(FileWrapper): + def __iter__(self): + self.filelike.seek(0) + return self + +class AudioHandler(object): + @property + def urls(self): + pattern_list = [ + url(r'^stream/(?P\d+)/$', 'spa.audio.start_streaming', name='audio_start_streaming'), + ] + return pattern_list + +def start_streaming(request, mix_id): + try: + mix = Mix.objects.get(pk=mix_id) + if mix is not None: + filename = mix.local_file.file.name # Select your file here. + wrapper = FixedFileWrapper(open(filename, 'rb')) + response = HttpResponse(wrapper, content_type='audio/mpeg') + response['Content-Length'] = os.path.getsize(filename) + response['Content-Type'] = "audio/mpeg" + response['Content-Disposition'] = "inline; filename=stream.mp3" + response['Cache-Control'] = "no-cache" + response['Content-Transfer-Encoding'] = "binary" + return response + except Exception, ex: + print ex + + raise Http404("Mix not found") \ No newline at end of file diff --git a/spa/models/Mix.py b/spa/models/Mix.py index af55b97..c3fd541 100644 --- a/spa/models/Mix.py +++ b/spa/models/Mix.py @@ -62,7 +62,7 @@ class Mix(_BaseModel): return settings.STATIC_URL + 'img/default-track.png' def get_stream_path(self): - return settings.MEDIA_URL + self.local_file.name + return '/audio/stream/%d' % self.id; @classmethod def get_listing(cls, listing_type, user=None): diff --git a/spa/urls.py b/spa/urls.py index 18ccbf9..1592a53 100644 --- a/spa/urls.py +++ b/spa/urls.py @@ -2,6 +2,8 @@ from django.conf.urls import patterns, url, include import django.conf.urls from tastypie.api import Api from spa.ajax import AjaxHandler +from spa.audio import AudioHandler + from spa.api.v1.CommentResource import CommentResource from spa.api.v1.EventResource import EventResource from spa.api.v1.MixResource import MixResource @@ -18,6 +20,7 @@ v1_api.register(ReleaseAudioResource()) v1_api.register(EventResource()) v1_api.register(UserResource()) ajax = AjaxHandler() +audio = AudioHandler() social = SocialHandler() urlpatterns = django.conf.urls.patterns( @@ -29,5 +32,6 @@ urlpatterns = django.conf.urls.patterns( url(r'^tplex/(?P\w+)/$', 'spa.templates.get_template_ex'), (r'^social/', include(social.urls)), (r'^ajax/', include(ajax.urls)), + (r'^audio/', include(audio.urls)), (r'^api/', include(v1_api.urls)), ) \ No newline at end of file diff --git a/static/bin/sm/soundmanager2.swf b/static/bin/sm/soundmanager2.swf index b74496c..8334e7f 100755 Binary files a/static/bin/sm/soundmanager2.swf and b/static/bin/sm/soundmanager2.swf differ diff --git a/static/bin/sm/soundmanager2_debug.swf b/static/bin/sm/soundmanager2_debug.swf index d840f5f..4e30adb 100755 Binary files a/static/bin/sm/soundmanager2_debug.swf and b/static/bin/sm/soundmanager2_debug.swf differ diff --git a/static/bin/sm/soundmanager2_flash9.swf b/static/bin/sm/soundmanager2_flash9.swf index 5eea89a..34d4da2 100755 Binary files a/static/bin/sm/soundmanager2_flash9.swf and b/static/bin/sm/soundmanager2_flash9.swf differ diff --git a/static/bin/sm/soundmanager2_flash9_debug.swf b/static/bin/sm/soundmanager2_flash9_debug.swf index 44f6075..ff5d695 100755 Binary files a/static/bin/sm/soundmanager2_flash9_debug.swf and b/static/bin/sm/soundmanager2_flash9_debug.swf differ diff --git a/static/bin/sm/soundmanager2_flash_xdomain.zip b/static/bin/sm/soundmanager2_flash_xdomain.zip old mode 100755 new mode 100644 index 034de77..6d46706 Binary files a/static/bin/sm/soundmanager2_flash_xdomain.zip and b/static/bin/sm/soundmanager2_flash_xdomain.zip differ diff --git a/static/js/com.podnoms.player.js b/static/js/com.podnoms.player.js index c31e806..e6afb15 100644 --- a/static/js/com.podnoms.player.js +++ b/static/js/com.podnoms.player.js @@ -1,11 +1,19 @@ if (!com) var com = {}; if (!com.podnoms) com.podnoms = {}; -soundManager.url = '/static/bin/sm/'; -soundManager.flashVersion = 9; -soundManager.debugMode = false; -soundManager.useHTML5Audio = true; -soundManager.preferFlash = false; +soundManager.setup({ + url:'/static/bin/sm/', + debugMode:true, + flashPollingInterval:15, + flashVersion:9, + useFlashBlock:false, + useHighPerformance:true, + useHTML5Audio: true, + bufferTime: 0.1, + stream: true, + wmode:'transparent' +}); +soundManager.useFastPolling = true; com.podnoms.player = { @@ -29,6 +37,10 @@ com.podnoms.player = { var percentageFinished = (this.currentSound.bytesLoaded / this.currentSound.bytesTotal) * 100; var percentageWidth = (this.waveFormWidth / 100) * percentageFinished; this.loadingEl.css('width', percentageWidth); + soundManager._writeDebug( + 'sound ' + this.currentSound.id + + ' loading, ' + this.currentSound.bytesLoaded + + ' of ' + this.currentSound.bytesTotal); }, _whilePlaying:function () { if (!this.trackLoaded) { @@ -38,7 +50,6 @@ com.podnoms.player = { this.trackLoaded = true; } - this.currentPosition = this.currentSound.position; var percentageFinished = (this.currentPosition / this.currentSound.duration) * 100; var percentageWidth = (this.waveFormWidth / 100) * percentageFinished; @@ -97,12 +108,12 @@ com.podnoms.player = { return this.currentSound.playState == 1; }, isPlayingId:function (id) { - return this.isPlaying() && this.currentSound.sID == id; + return this.isPlaying() && this.currentSound.sID == "com.podnoms.player-" + id; }, setupPlayer:function (options) { this._parseOptions(options); this._setupParams(); - if (this.isPlayingId(options.id)){ + if (this.isPlayingId(options.id)) { this.playButtonEl .removeClass('play-button-small-start') .removeClass('play-button-small-loading') @@ -115,8 +126,9 @@ com.podnoms.player = { this._destroyCurrent(function () { ref.currentSound = soundManager.createSound({ url:ref.currentPath, - id:currId.toString(), + id:"com.podnoms.player-" + currId.toString(), volume:com.podnoms.settings.volume, + bufferTime: 0.1, stream:true, whileloading:function () { ref._whileLoading(); diff --git a/static/js/libs/modernizr-2.5.3-respond-1.1.0.min.js b/static/js/libs/modernizr-2.5.3-respond-1.1.0.min.js deleted file mode 100644 index 16ed1c4..0000000 --- a/static/js/libs/modernizr-2.5.3-respond-1.1.0.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* Modernizr 2.5.3 (Custom Build) | MIT & BSD - * Build: http://www.modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load - */ -;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a)if(j[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.substr(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function L(){e.input=function(c){for(var d=0,e=c.length;d",a,""].join(""),k.id=h,m.innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e});var K=function(c,d){var f=c.join(""),g=d.length;y(f,function(c,d){var f=b.styleSheets[b.styleSheets.length-1],h=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"",i=c.childNodes,j={};while(g--)j[i[g].id]=i[g];e.touch="ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch||(j.touch&&j.touch.offsetTop)===9,e.csstransforms3d=(j.csstransforms3d&&j.csstransforms3d.offsetLeft)===9&&j.csstransforms3d.offsetHeight===3,e.generatedcontent=(j.generatedcontent&&j.generatedcontent.offsetHeight)>=1,e.fontface=/src/i.test(h)&&h.indexOf(d.split(" ")[0])===0},g,d)}(['@font-face {font-family:"font";src:url("https://")}',["@media (",n.join("touch-enabled),("),h,")","{#touch{top:9px;position:absolute}}"].join(""),["@media (",n.join("transform-3d),("),h,")","{#csstransforms3d{left:9px;position:absolute;height:3px;}}"].join(""),['#generatedcontent:after{content:"',l,'";visibility:hidden}'].join("")],["fontface","touch","csstransforms3d","generatedcontent"]);s.flexbox=function(){return J("flexOrder")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!F(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){try{var d=b.createElement("canvas"),e;e=!(!a.WebGLRenderingContext||!d.getContext("experimental-webgl")&&!d.getContext("webgl")),d=c}catch(f){e=!1}return e},s.touch=function(){return e.touch},s.geolocation=function(){return!!navigator.geolocation},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!J("indexedDB",a)},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){for(var b=-1,c=p.length;++b",d.insertBefore(c.lastChild,d.firstChild)}function h(){var a=k.elements;return typeof a=="string"?a.split(" "):a}function i(a){var b={},c=a.createElement,e=a.createDocumentFragment,f=e();a.createElement=function(a){var e=(b[a]||(b[a]=c(a))).cloneNode();return k.shivMethods&&e.canHaveChildren&&!d.test(a)?f.appendChild(e):e},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+h().join().replace(/\w+/g,function(a){return b[a]=c(a),f.createElement(a),'c("'+a+'")'})+");return n}")(k,f)}function j(a){var b;return a.documentShived?a:(k.shivCSS&&!e&&(b=!!g(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),f||(b=!i(a)),b&&(a.documentShived=b),a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea)$/i,e,f;(function(){var a=b.createElement("a");a.innerHTML="",e="hidden"in a,f=a.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var k={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:j};a.html5=k,j(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return o.call(a)=="[object Function]"}function e(a){return typeof a=="string"}function f(){}function g(a){return!a||a=="loaded"||a=="complete"||a=="uninitialized"}function h(){var a=p.shift();q=1,a?a.t?m(function(){(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){a!="img"&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l={},o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return o.call(a)=="[object Array]"},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f #mq-test-1 { width: 42px; }';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document); - -/*! Respond.js v1.1.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ -(function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var u=e.document,r=u.documentElement,h=[],j=[],p=[],n={},g=30,f=u.getElementsByTagName("head")[0]||r,b=f.getElementsByTagName("link"),d=[],a=function(){var C=b,x=C.length,A=0,z,y,B,w;for(;A-1,minw:E.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:E.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}i()},k,q,v=function(){var y,z=u.createElement("div"),w=u.body,x=false;z.style.cssText="position:absolute;font-size:1em;width:1em";if(!w){w=x=u.createElement("body")}w.appendChild(z);r.insertBefore(w,r.firstChild);y=z.offsetWidth;if(x){r.removeChild(w)}else{w.removeChild(z)}y=o=parseFloat(y);return y},o,i=function(H){var w="clientWidth",A=r[w],G=u.compatMode==="CSS1Compat"&&A||u.body[w]||A,C={},F=b[b.length-1],y=(new Date()).getTime();if(H&&k&&y-k-1?(o||v()):1)}if(!!I){I=parseFloat(I)*(I.indexOf(x)>-1?(o||v()):1)}if(!J.hasquery||(!z||!K)&&(z||G>=B)&&(K||G<=I)){if(!C[J.media]){C[J.media]=[]}C[J.media].push(j[J.rules])}}for(var D in p){if(p[D]&&p[D].parentNode===f){f.removeChild(p[D])}}for(var D in C){var L=u.createElement("style"),E=C[D].join("\n");L.type="text/css";L.media=D;f.insertBefore(L,F.nextSibling);if(L.styleSheet){L.styleSheet.cssText=E}else{L.appendChild(u.createTextNode(E))}p.push(L)}},m=function(w,y){var x=c();if(!x){return}x.open("GET",w,true);x.onreadystatechange=function(){if(x.readyState!=4||x.status!=200&&x.status!=304){return}y(x.responseText)};if(x.readyState==4){return}x.send(null)},c=(function(){var w=false;try{w=new XMLHttpRequest()}catch(x){w=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return w}})();a();respond.update=a;function s(){i(true)}if(e.addEventListener){e.addEventListener("resize",s,false)}else{if(e.attachEvent){e.attachEvent("onresize",s)}}})(this); diff --git a/static/js/libs/modernizr.js b/static/js/libs/modernizr.js new file mode 100644 index 0000000..b5958e9 --- /dev/null +++ b/static/js/libs/modernizr.js @@ -0,0 +1,4 @@ +/* Modernizr 2.6.2 (Custom Build) | MIT & BSD + * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-flexbox_legacy-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-cssclasses-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load + */ +;window.Modernizr=function(a,b,c){function C(a){j.cssText=a}function D(a,b){return C(n.join(a+";")+(b||""))}function E(a,b){return typeof a===b}function F(a,b){return!!~(""+a).indexOf(b)}function G(a,b){for(var d in a){var e=a[d];if(!F(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function H(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:E(f,"function")?f.bind(d||b):f}return!1}function I(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return E(b,"string")||E(b,"undefined")?G(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),H(e,b,c))}function J(){e.input=function(c){for(var d=0,e=c.length;d',a,""].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=E(e[d],"function"),E(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),A={}.hasOwnProperty,B;!E(A,"undefined")&&!E(A.call,"undefined")?B=function(a,b){return A.call(a,b)}:B=function(a,b){return b in a&&E(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return I("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!E(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!I("indexedDB",a)},s.hashchange=function(){return z("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return C("background-color:rgba(150,255,150,.5)"),F(j.backgroundColor,"rgba")},s.hsla=function(){return C("background-color:hsla(120,40%,100%,.5)"),F(j.backgroundColor,"rgba")||F(j.backgroundColor,"hsla")},s.multiplebgs=function(){return C("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return I("backgroundSize")},s.borderimage=function(){return I("borderImage")},s.borderradius=function(){return I("borderRadius")},s.boxshadow=function(){return I("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return D("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return I("animationName")},s.csscolumns=function(){return I("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return C((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),F(j.backgroundImage,"gradient")},s.cssreflections=function(){return I("boxReflect")},s.csstransforms=function(){return!!I("transform")},s.csstransforms3d=function(){var a=!!I("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return I("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var K in s)B(s,K)&&(x=K.toLowerCase(),e[x]=s[K](),v.push((e[x]?"":"no-")+x));return e.input||J(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)B(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},C(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.hasEvent=z,e.testProp=function(a){return G([a])},e.testAllProps=I,e.testStyles=y,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f=a)return!1;for(a-=1;0<=a;a--)if(c=l[a],!c.fired&&b.position>=c.position)c.fired=!0,n++,c.method.apply(c.scope,[c.position]);return!0};this._resetOnPosition=function(b){var a,c;a=l.length;if(!a)return!1;for(a-=1;0<=a;a--)if(c=l[a],c.fired&&b<=c.position)c.fired=!1,n--; -return!0};u=function(){var a=b._iO,d=a.from,f=a.to,e,h;h=function(){c._wD(b.sID+': "to" time of '+f+" reached.");b.clearOnPosition(f,h);b.stop()};e=function(){c._wD(b.sID+': playing "from" '+d);if(null!==f&&!isNaN(f))b.onPosition(f,h)};if(null!==d&&!isNaN(d))a.position=d,a.multiShot=!1,e();return a};Ya=function(){var a,c=b._iO.onposition;if(c)for(a in c)if(c.hasOwnProperty(a))b.onPosition(parseInt(a,10),c[a])};t=function(){var a,c=b._iO.onposition;if(c)for(a in c)c.hasOwnProperty(a)&&b.clearOnPosition(parseInt(a, -10))};i=function(){b.isHTML5&&Ka(b)};N=function(){b.isHTML5&&La(b)};f=function(){l=[];n=0;p=!1;b._hasTimer=null;b._a=null;b._html5_canplay=!1;b.bytesLoaded=null;b.bytesTotal=null;b.duration=b._iO&&b._iO.duration?b._iO.duration:null;b.durationEstimate=null;b.eqData=[];b.eqData.left=[];b.eqData.right=[];b.failures=0;b.isBuffering=!1;b.instanceOptions={};b.instanceCount=0;b.loaded=!1;b.metadata={};b.readyState=0;b.muted=!1;b.paused=!1;b.peakData={left:0,right:0};b.waveformData={left:[],right:[]};b.playState= -0;b.position=null};f();this._onTimer=function(a){var c,f=!1,h={};if(b._hasTimer||a){if(b._a&&(a||(0e.duration?b.duration:e.duration:parseInt(b.bytesTotal/b.bytesLoaded*b.duration, -10),void 0===b.durationEstimate)b.durationEstimate=b.duration;3!==b.readyState&&e.whileloading&&e.whileloading.apply(b)};this._whileplaying=function(a,c,d,f,e){var h=b._iO;if(isNaN(a)||null===a)return!1;b.position=a;b._processOnPosition();if(!b.isHTML5&&8j)c._wD(q("needfl9")),c.flashVersion=j=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===j?" (AS3/Flash 9)":" (AS2/Flash 8)");8'}if(P&&Q)return!1;if(c.html5Only)return qa(),e(),c.oMC=r(c.movieID),X(),Q=P=!0,!1;var f=d||c.url,g=c.altURL||f,h;h=ba();var i,l,j=K(),m,n=null,n=(n=k.getElementsByTagName("html")[0])&&n.dir&&n.dir.match(/rtl/i),a="undefined"===typeof a?c.id:a;qa();c.url=Ia(M?f:g);d=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(null!==c.wmode&&(t.match(/msie 8/i)||!C&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))o("spcWmode"),c.wmode=null;h={name:a, -id:a,src:d,quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Va+"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(C)f=k.createElement("div"),l=['',b("movie",d),b("AllowScriptAccess",c.allowScriptAccess),b("quality",h.quality),c.wmode?b("wmode",c.wmode):"",b("bgcolor",c.bgColor),b("hasPriority","true"),c.debugFlash?b("FlashVars",h.FlashVars):"",""].join("");else for(i in f=k.createElement("embed"),h)h.hasOwnProperty(i)&&f.setAttribute(i,h[i]);ta();j=K();if(h=ba())if(c.oMC=r(c.movieID)||k.createElement("div"),c.oMC.id){m=c.oMC.className;c.oMC.className=(m?m+" ":"movieContainer")+(j?" "+j:"");c.oMC.appendChild(f); -if(C)i=c.oMC.appendChild(k.createElement("div")),i.className="sm2-object-box",i.innerHTML=l;Q=!0}else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+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"},n)j.left=Math.abs(parseInt(j.left,10))+"px";if(cb)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(m in j)j.hasOwnProperty(m)&& -(c.oMC.style[m]=j[m]);try{C||c.oMC.appendChild(f);h.appendChild(c.oMC);if(C)i=c.oMC.appendChild(k.createElement("div")),i.className="sm2-object-box",i.innerHTML=l;Q=!0}catch(p){throw Error(q("domError")+" \n"+p.toString());}}P=!0;e();c._wD("soundManager::createMovie(): Trying to load "+d+(!M&&c.altURL?" (alternate URL)":""),1);return!0};aa=function(){if(c.html5Only)return ca(),!1;if(g)return!1;g=c.getMovie(c.id);if(!g)S?(C?c.oMC.innerHTML=ua:c.oMC.appendChild(S),S=null,P=!0):ca(c.id,c.url),g=c.getMovie(c.id); -g&&o("waitEI");c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return!0};Z=function(){setTimeout(Fa,1E3)};Fa=function(){if(ga)return!1;ga=!0;l.remove(i,"load",Z);if(L&&!Da)return o("waitFocus"),!1;var a;p||(a=c.getMoviePercent(),c._wD(q("waitImpatient",100===a?" (SWF loaded)":0=a)return!1;for(a-=1;0<=a;a--)if(c=y[a],!c.fired&&b.position>=c.position)c.fired=!0,q++,c.method.apply(c.scope,[c.position]);return!0};this._resetOnPosition=function(b){var a,c;a=y.length;if(!a)return!1;for(a-=1;0<= +a;a--)if(c=y[a],c.fired&&b<=c.position)c.fired=!1,q--;return!0};v=function(){var a=b._iO,d=a.from,e=a.to,f,g;g=function(){c._wD(b.id+': "to" time of '+e+" reached.");b.clearOnPosition(e,g);b.stop()};f=function(){c._wD(b.id+': playing "from" '+d);if(null!==e&&!isNaN(e))b.onPosition(e,g)};if(null!==d&&!isNaN(d))a.position=d,a.multiShot=!1,f();return a};l=function(){var a,c=b._iO.onposition;if(c)for(a in c)if(c.hasOwnProperty(a))b.onPosition(parseInt(a,10),c[a])};u=function(){var a,c=b._iO.onposition; +if(c)for(a in c)c.hasOwnProperty(a)&&b.clearOnPosition(parseInt(a,10))};i=function(){b.isHTML5&&Qa(b)};k=function(){b.isHTML5&&Ra(b)};g=function(a){a||(y=[],q=0);n=!1;b._hasTimer=null;b._a=null;b._html5_canplay=!1;b.bytesLoaded=null;b.bytesTotal=null;b.duration=b._iO&&b._iO.duration?b._iO.duration:null;b.durationEstimate=null;b.buffered=[];b.eqData=[];b.eqData.left=[];b.eqData.right=[];b.failures=0;b.isBuffering=!1;b.instanceOptions={};b.instanceCount=0;b.loaded=!1;b.metadata={};b.readyState=0;b.muted= +!1;b.paused=!1;b.peakData={left:0,right:0};b.waveformData={left:[],right:[]};b.playState=0;b.position=null;b.id3={}};g();this._onTimer=function(a){var c,f=!1,g={};if(b._hasTimer||a){if(b._a&&(a||(0f.duration?b.duration:f.duration:parseInt(b.bytesTotal/b.bytesLoaded*b.duration,10),"undefined"===typeof b.durationEstimate)b.durationEstimate=b.duration;if(!b.isHTML5)b.buffered=[{start:0,end:b.duration}];(3!==b.readyState||b.isHTML5)&&f.whileloading&&f.whileloading.apply(b)};this._whileplaying=function(a, +c,d,e,f){var g=b._iO;if(isNaN(a)||null===a)return!1;b.position=Math.max(0,a);b._processOnPosition();if(!b.isHTML5&&8j)c._wD(p("needfl9")),c.flashVersion=j=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===j?" (AS3/Flash 9)":" (AS2/Flash 8)");8'}if(R&&S)return!1;if(c.html5Only)return ua(),e(),c.oMC=A(c.movieID),qa(),S=R=!0,!1;var g=d||c.url,f=c.altURL||g,h;h=ea();var k,l,j=N(),m,n=null,n=(n=i.getElementsByTagName("html")[0])&&n.dir&&n.dir.match(/rtl/i), +a="undefined"===typeof a?c.id:a;ua();c.url=Oa(P?g:f);d=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(null!==c.wmode&&(v.match(/msie 8/i)||!F&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))o("spcWmode"),c.wmode=null;h={name:a,id:a,src:d,quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:bb+"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(F)g=i.createElement("div"),l=['',b("movie",d),b("AllowScriptAccess",c.allowScriptAccess),b("quality",h.quality),c.wmode?b("wmode",c.wmode):"",b("bgcolor",c.bgColor),b("hasPriority","true"),c.debugFlash? +b("FlashVars",h.FlashVars):"",""].join("");else for(k in g=i.createElement("embed"),h)h.hasOwnProperty(k)&&g.setAttribute(k,h[k]);xa();j=N();if(h=ea())if(c.oMC=A(c.movieID)||i.createElement("div"),c.oMC.id){m=c.oMC.className;c.oMC.className=(m?m+" ":"movieContainer")+(j?" "+j:"");c.oMC.appendChild(g);if(F)k=c.oMC.appendChild(i.createElement("div")),k.className="sm2-object-box",k.innerHTML=l;S=!0}else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+j;k=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"},n)j.left=Math.abs(parseInt(j.left,10))+"px";if(gb)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(m in j)j.hasOwnProperty(m)&&(c.oMC.style[m]=j[m]);try{F||c.oMC.appendChild(g);h.appendChild(c.oMC);if(F)k=c.oMC.appendChild(i.createElement("div")),k.className="sm2-object-box",k.innerHTML=l;S=!0}catch(q){throw Error(p("domError")+" \n"+ +q.toString());}}R=!0;e();c._wD("soundManager::createMovie(): Trying to load "+d+(!P&&c.altURL?" (alternate URL)":""),1);return!0};da=function(){if(c.html5Only)return fa(),!1;if(h)return!1;h=c.getMovie(c.id);if(!h)U?(F?c.oMC.innerHTML=ya:c.oMC.appendChild(U),U=null,R=!0):fa(c.id,c.url),h=c.getMovie(c.id);h&&o("waitEI");"function"===typeof c.oninitmovie&&setTimeout(c.oninitmovie,1);return!0};K=function(){setTimeout(La,1E3)};La=function(){var a,d=!1;if(V)return!1;V=!0;u.remove(l,"load",K);if(ma&&!Ia)return o("waitFocus"), +!1;n||(a=c.getMoviePercent(),c._wD(p("waitImpatient",0a&&(d=!0));setTimeout(function(){a=c.getMoviePercent();if(d)return V=!1,c._wD(p("waitSWF")),l.setTimeout(K,1),!1;n||(c._wD("soundManager: No Flash response within expected time.\nLikely causes: "+(0===a?"Loading "+c.movieURL+" may have failed (and/or Flash "+j+"+ not present?), ":"")+"Flash blocked or JS-Flash security error."+(c.debugFlash?" "+p("checkSWF"):""),2),!P&&a&&(o("localFail",2),c.debugFlash|| +o("tryDebug",2)),0===a&&c._wD(p("swf404",c.url)),x("flashtojs",!1,": Timed out"+P?" (Check flash security or flash blockers)":" (No plugin/missing SWF?)"));!n&&$a&&(null===a?c.useFlashBlock||0===c.flashLoadTimeout?(c.useFlashBlock&&za(),o("waitForever")):ga(!0):0===c.flashLoadTimeout?o("waitForever"):ga(!0))},c.flashLoadTimeout)};ba=function(){if(Ia||!ma)return u.remove(l,"focus",ba),!0;Ia=$a=!0;c._wD("soundManager: Got window focus.");V=!1;K();u.remove(l,"focus",ba);return!0};Xa=function(){var a, +d=[];if(c.useHTML5Audio&&c.hasHTML5){for(a in c.audioFormats)c.audioFormats.hasOwnProperty(a)&&d.push(a+": "+c.html5[a]+(!c.html5[a]&&z&&c.flash[a]?" (using flash)":c.preferFlash&&c.flash[a]&&z?" (preferring flash)":!c.html5[a]?" ("+(c.audioFormats[a].required?"required, ":"")+"and no flash support)":""));c._wD("-- SoundManager 2: HTML5 support tests ("+c.html5Test+"): "+d.join(", ")+" --",1)}};T=function(a){if(n)return!1;if(c.html5Only)return c._wD("-- SoundManager 2: loaded --"),n=!0,J(),x("onload", +!0),!0;var d=!0,e;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())n=!0,m&&(e={type:!z&&B?"NO_FLASH":"INIT_TIMEOUT"});c._wD("-- SoundManager 2 "+(m?"failed to load":"loaded")+" ("+(m?"security/load error":"OK")+") --",1);if(m||a){if(c.useFlashBlock&&c.oMC)c.oMC.className=N()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error");I({type:"ontimeout",error:e,ignoreInit:!0});x("onload",!1);M(e);d=!1}else x("onload",!0);m||(c.waitForWindowLoad&&!aa?(o("waitOnload"),u.add(l,"load",J)): +(c.waitForWindowLoad&&aa&&o("docLoaded"),J()));return d};Ka=function(){var a,d=c.setupOptions;for(a in d)d.hasOwnProperty(a)&&("undefined"===typeof c[a]?c[a]=d[a]:c[a]!==d[a]&&(c.setupOptions[a]=c[a]))};qa=function(){o("init");if(n)return o("didInit"),!1;if(c.html5Only){if(!n)u.remove(l,"load",c.beginDelayedInit),c.enabled=!0,T();return!0}da();try{o("flashJS"),h._externalInterfaceTest(!1),Ma(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||h._disableDebug(),c.enabled=!0,x("jstoflash", +!0),c.html5Only||u.add(l,"unload",pa)}catch(a){return c._wD("js/flash exception: "+a.toString()),x("jstoflash",!1),M({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),ga(!0),T(),!1}T();u.remove(l,"load",c.beginDelayedInit);return!0};L=function(){if(wa)return!1;wa=!0;Ka();xa();var a=null,a=null,d="undefined"!==typeof console&&"function"===typeof console.log,e=Q.toLowerCase();-1!==e.indexOf("sm2-usehtml5audio=")&&(a="1"===e.charAt(e.indexOf("sm2-usehtml5audio=")+18),d&&console.log((a?"Enabling ":"Disabling ")+ +"useHTML5Audio via URL parameter"),c.setup({useHTML5Audio:a}));-1!==e.indexOf("sm2-preferflash=")&&(a="1"===e.charAt(e.indexOf("sm2-preferflash=")+16),d&&console.log((a?"Enabling ":"Disabling ")+"preferFlash via URL parameter"),c.setup({preferFlash:a}));!z&&c.hasHTML5&&(c._wD("SoundManager: No Flash detected"+(!c.useHTML5Audio?", enabling HTML5.":". Trying HTML5-only mode.")),c.setup({useHTML5Audio:!0,preferFlash:!1}));Ua();c.html5.usingFlash=Ta();B=c.html5.usingFlash;Xa();!z&&B&&(c._wD("SoundManager: Fatal error: Flash is needed to play some required formats, but is not available."), +c.setup({flashLoadTimeout:1}));i.removeEventListener&&i.removeEventListener("DOMContentLoaded",L,!1);da();return!0};Ca=function(){"complete"===i.readyState&&(L(),i.detachEvent("onreadystatechange",Ca));return!0};va=function(){aa=!0;u.remove(l,"load",va)};Da();u.add(l,"focus",ba);u.add(l,"load",K);u.add(l,"load",va);i.addEventListener?i.addEventListener("DOMContentLoaded",L,!1):i.attachEvent?i.attachEvent("onreadystatechange",Ca):(x("onload",!1),M({type:"NO_DOM2_EVENTS",fatal:!0}));"complete"===i.readyState&& +setTimeout(L,100)}var na=null;if("undefined"===typeof SM2_DEFER||!SM2_DEFER)na=new Z;Y.SoundManager=Z;Y.soundManager=na})(window); \ No newline at end of file diff --git a/static/js/libs/sm/soundmanager2-nodebug-jsmin.js b/static/js/libs/sm/soundmanager2-nodebug-jsmin.js index 84fad06..abad43d 100644 --- a/static/js/libs/sm/soundmanager2-nodebug-jsmin.js +++ b/static/js/libs/sm/soundmanager2-nodebug-jsmin.js @@ -8,70 +8,73 @@ * Code provided under the BSD License: * http://schillmania.com/projects/soundmanager2/license.txt * - * V2.97a.20120318 + * V2.97a.20120624 */ -(function(H){function P(P,ca){function l(a){return function(c){var e=this._t;return!e||!e._a?null:a.call(this,c)}}this.flashVersion=8;this.debugFlash=this.debugMode=!1;this.consoleOnly=this.useConsole=!0;this.waitForWindowLoad=!1;this.bgColor="#ffffff";this.useHighPerformance=!1;this.html5PollingInterval=this.flashPollingInterval=null;this.flashLoadTimeout=1E3;this.wmode=null;this.allowScriptAccess="always";this.useFlashBlock=!1;this.useHTML5Audio=!0;this.html5Test=/^(probably|maybe)$/i;this.preferFlash= -!0;this.noSWFCache=!1;this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null, -onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.movieID="sm2-container";this.id=ca||"sm2movie"; -this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20120318";this.movieURL=this.version=null;this.url=P||null;this.altURL=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1};this.sandbox={};var da;try{da="undefined"!==typeof Audio&& -"undefined"!==typeof(new Audio).canPlayType}catch(Wa){da=!1}this.hasHTML5=da;this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=!1;var ya,c=this,h=null,Q,n=navigator.userAgent,g=H,ea=g.location.href.toString(),k=document,fa,R,j,q=[],I=!1,J=!1,o=!1,v=!1,ga=!1,K,s,ha,A,B,S,za,ia,y,T,C,ja,ka,la,U,D,Aa,ma,Ba,V,Ca,L=null,na=null,E,oa,F,W,X,pa,p,Y=!1,qa=!1,Da,Ea,Fa,Z=0,M=null,$,t=null,Ga,aa,N,w,ra,sa,Ha,m,Qa=Array.prototype.slice,z=!1,r,ba,Ia,u,Ja,ta=n.match(/(ipad|iphone|ipod)/i), -Ra=n.match(/firefox/i),Sa=n.match(/droid/i),x=n.match(/msie/i),Ta=n.match(/webkit/i),O=n.match(/safari/i)&&!n.match(/chrome/i),Ua=n.match(/opera/i),ua=n.match(/(mobile|pre\/|xoom)/i)||ta,va=!ea.match(/usehtml5audio/i)&&!ea.match(/sm2\-ignorebadua/i)&&O&&!n.match(/silk/i)&&n.match(/OS X 10_6_([3-7])/i),wa="undefined"!==typeof k.hasFocus?k.hasFocus():null,G=O&&"undefined"===typeof k.hasFocus,Ka=!G,La=/(mp3|mp4|mpa)/i,xa=k.location?k.location.protocol.match(/http/i):null,Ma=!xa?"http://":"",Na=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i, -Oa="mpeg4,aac,flv,mov,mp4,m4v,f4v,m4a,mp4v,3gp,3g2".split(","),Va=RegExp("\\.("+Oa.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!xa;this._global_a=null;if(ua&&(c.useHTML5Audio=!0,c.preferFlash=!1,ta))z=c.ignoreFlash=!0;this.supported=this.ok=function(){return t?o&&!v:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(a){return Q(a)||k[a]||g[a]};this.createSound=function(a){function d(){e=W(e);c.sounds[f.id]=new ya(f);c.soundIDs.push(f.id); -return c.sounds[f.id]}var e=null,b=null,f=null;if(!o||!c.ok())return pa(void 0),!1;2===arguments.length&&(a={id:arguments[0],url:arguments[1]});e=s(a);e.url=$(e.url);f=e;if(p(f.id,!0))return c.sounds[f.id];if(aa(f))b=d(),b._setup_html5(f);else{if(8=a)return!1;for(a-=1;0<=a;a--)if(c=n[a],!c.fired&&b.position>=c.position)c.fired=!0,o++,c.method.apply(c.scope,[c.position]);return!0};this._resetOnPosition=function(b){var a,c;a=n.length;if(!a)return!1;for(a-=1;0<=a;a--)if(c=n[a],c.fired&&b<=c.position)c.fired=!1,o--; -return!0};t=function(){var a=b._iO,c=a.from,d=a.to,f,e;e=function(){b.clearOnPosition(d,e);b.stop()};f=function(){if(null!==d&&!isNaN(d))b.onPosition(d,e)};if(null!==c&&!isNaN(c))a.position=c,a.multiShot=!1,f();return a};m=function(){var a,c=b._iO.onposition;if(c)for(a in c)if(c.hasOwnProperty(a))b.onPosition(parseInt(a,10),c[a])};r=function(){var a,c=b._iO.onposition;if(c)for(a in c)c.hasOwnProperty(a)&&b.clearOnPosition(parseInt(a,10))};k=function(){b.isHTML5&&Da(b)};g=function(){b.isHTML5&&Ea(b)}; -f=function(){n=[];o=0;l=!1;b._hasTimer=null;b._a=null;b._html5_canplay=!1;b.bytesLoaded=null;b.bytesTotal=null;b.duration=b._iO&&b._iO.duration?b._iO.duration:null;b.durationEstimate=null;b.eqData=[];b.eqData.left=[];b.eqData.right=[];b.failures=0;b.isBuffering=!1;b.instanceOptions={};b.instanceCount=0;b.loaded=!1;b.metadata={};b.readyState=0;b.muted=!1;b.paused=!1;b.peakData={left:0,right:0};b.waveformData={left:[],right:[]};b.playState=0;b.position=null};f();this._onTimer=function(a){var c,f=!1, -i={};if(b._hasTimer||a){if(b._a&&(a||(0f.duration?b.duration:f.duration:parseInt(b.bytesTotal/b.bytesLoaded*b.duration,10),void 0===b.durationEstimate)b.durationEstimate=b.duration;3!==b.readyState&&f.whileloading&&f.whileloading.apply(b)};this._whileplaying=function(a,c,d,e,f){var i=b._iO;if(isNaN(a)||null===a)return!1;b.position=a;b._processOnPosition(); -if(!b.isHTML5&&8j)c.flashVersion=j=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===j?" (AS3/Flash 9)":" (AS2/Flash 8)");8'}if(I&&J)return!1;if(c.html5Only)return ia(),c.oMC=Q(c.movieID),R(),J=I=!0,!1;var b=d||c.url,f=c.altURL||b,i;i=la();var g,h,j=F(),l,m=null,m=(m=k.getElementsByTagName("html")[0])&&m.dir&&m.dir.match(/rtl/i), -a="undefined"===typeof a?c.id:a;ia();c.url=Ca(xa?b:f);d=c.url;c.wmode=!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(null!==c.wmode&&(n.match(/msie 8/i)||!x&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))c.wmode=null;i={name:a,id:a,src:d,quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Ma+"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)i.FlashVars="debug=1";c.wmode||delete i.wmode;if(x)b=k.createElement("div"),h=['',e("movie",d),e("AllowScriptAccess",c.allowScriptAccess),e("quality",i.quality),c.wmode?e("wmode",c.wmode):"",e("bgcolor",c.bgColor),e("hasPriority", -"true"),c.debugFlash?e("FlashVars",i.FlashVars):"",""].join("");else for(g in b=k.createElement("embed"),i)i.hasOwnProperty(g)&&b.setAttribute(g,i[g]);ma();j=F();if(i=la())if(c.oMC=Q(c.movieID)||k.createElement("div"),c.oMC.id){l=c.oMC.className;c.oMC.className=(l?l+" ":"movieContainer")+(j?" "+j:"");c.oMC.appendChild(b);if(x)g=c.oMC.appendChild(k.createElement("div")),g.className="sm2-object-box",g.innerHTML=h;J=!0}else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+j;g=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=Math.abs(parseInt(j.left,10))+"px";if(Ta)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(l in j)j.hasOwnProperty(l)&&(c.oMC.style[l]=j[l]);try{x||c.oMC.appendChild(b);i.appendChild(c.oMC);if(x)g=c.oMC.appendChild(k.createElement("div")),g.className="sm2-object-box",g.innerHTML=h;J=!0}catch(o){throw Error(E("domError")+" \n"+ -o.toString());}}return I=!0};T=function(){if(c.html5Only)return U(),!1;if(h)return!1;h=c.getMovie(c.id);if(!h)L?(x?c.oMC.innerHTML=na:c.oMC.appendChild(L),L=null,I=!0):U(c.id,c.url),h=c.getMovie(c.id);c.oninitmovie instanceof Function&&setTimeout(c.oninitmovie,1);return!0};S=function(){setTimeout(za,1E3)};za=function(){if(Y)return!1;Y=!0;m.remove(g,"load",S);if(G&&!wa)return!1;var a;o||(a=c.getMoviePercent());setTimeout(function(){a=c.getMoviePercent();!o&&Ka&&(null===a?c.useFlashBlock||0===c.flashLoadTimeout? -c.useFlashBlock&&oa():V(!0):0!==c.flashLoadTimeout&&V(!0))},c.flashLoadTimeout)};y=function(){function a(){m.remove(g,"focus",y);m.remove(g,"load",y)}if(wa||!G)return a(),!0;wa=Ka=!0;O&&G&&m.remove(g,"mousemove",y);Y=!1;a();return!0};Ja=function(){var a,d=[];if(c.useHTML5Audio&&c.hasHTML5)for(a in c.audioFormats)c.audioFormats.hasOwnProperty(a)&&d.push(a+": "+c.html5[a]+(!c.html5[a]&&r&&c.flash[a]?" (using flash)":c.preferFlash&&c.flash[a]&&r?" (preferring flash)":!c.html5[a]?" ("+(c.audioFormats[a].required? -"required, ":"")+"and no flash support)":""))};K=function(a){if(o)return!1;if(c.html5Only)return o=!0,B(),!0;var d;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())o=!0,v&&(d={type:!r&&t?"NO_FLASH":"INIT_TIMEOUT"});if(v||a){if(c.useFlashBlock&&c.oMC)c.oMC.className=F()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error");A({type:"ontimeout",error:d});D(d);return!1}if(c.waitForWindowLoad&&!ga)return m.add(g,"load",B),!1;B();return!0};R=function(){if(o)return!1;if(c.html5Only){if(!o)m.remove(g, -"load",c.beginDelayedInit),c.enabled=!0,K();return!0}T();try{h._externalInterfaceTest(!1),Aa(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||h._disableDebug(),c.enabled=!0,c.html5Only||m.add(g,"unload",fa)}catch(a){return D({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),V(!0),K(),!1}K();m.remove(g,"load",c.beginDelayedInit);return!0};C=function(){if(ka)return!1;ka=!0;ma();if(!r&&c.hasHTML5)c.useHTML5Audio=!0,c.preferFlash=!1;Ha();c.html5.usingFlash=Ga();t=c.html5.usingFlash;Ja();if(!r&& -t)c.flashLoadTimeout=1;k.removeEventListener&&k.removeEventListener("DOMContentLoaded",C,!1);T();return!0};sa=function(){"complete"===k.readyState&&(C(),k.detachEvent("onreadystatechange",sa));return!0};ja=function(){ga=!0;m.remove(g,"load",ja)};ba();m.add(g,"focus",y);m.add(g,"load",y);m.add(g,"load",S);m.add(g,"load",ja);O&&G&&m.add(g,"mousemove",y);k.addEventListener?k.addEventListener("DOMContentLoaded",C,!1):k.attachEvent?k.attachEvent("onreadystatechange",sa):D({type:"NO_DOM2_EVENTS",fatal:!0}); -"complete"===k.readyState&&setTimeout(C,100)}var ca=null;if("undefined"===typeof SM2_DEFER||!SM2_DEFER)ca=new P;H.SoundManager=P;H.soundManager=ca})(window); \ No newline at end of file +(function(ea){function Q(Q,da){function R(a){return c.preferFlash&&t&&!c.ignoreFlash&&"undefined"!==typeof c.flash[a]&&c.flash[a]}function m(a){return function(c){var d=this._t;return!d||!d._a?null:a.call(this,c)}}this.setupOptions={url:Q||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1E3,wmode:null,allowScriptAccess:"always",useFlashBlock:!1, +useHTML5Audio:!0,html5Test:/^(probably|maybe)$/i,preferFlash:!0,noSWFCache:!1};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null, +ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.audioFormats={mp3:{type:['audio/mpeg; codecs="mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a"],type:['audio/mp4; codecs="mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs=vorbis"],required:!1},wav:{type:['audio/wav; codecs="1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}}; +this.movieID="sm2-container";this.id=da||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20120624";this.altURL=this.movieURL=this.version=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1};this.sandbox={};var fa; +try{fa="undefined"!==typeof Audio&&"undefined"!==typeof(new Audio).canPlayType}catch(Za){fa=!1}this.hasHTML5=fa;this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=!1;var Ca,c=this,i=null,S,q=navigator.userAgent,h=ea,ga=h.location.href.toString(),l=document,ha,Da,ia,j,w=[],J=!1,K=!1,k=!1,s=!1,ja=!1,L,r,ka,T,la,B,C,D,Ea,ma,U,V,E,na,oa,pa,W,F,Fa,qa,Ga,X,Ha,M=null,ra=null,u,sa,G,Y,Z,H,p,N=!1,ta=!1,Ia,Ja,Ka,$=0,O=null,aa,n=null,La,ba,P,x,ua,va,Ma,o,Wa=Array.prototype.slice,z=!1, +t,wa,Na,v,Oa,xa=q.match(/(ipad|iphone|ipod)/i),y=q.match(/msie/i),Xa=q.match(/webkit/i),ya=q.match(/safari/i)&&!q.match(/chrome/i),Pa=q.match(/opera/i),za=q.match(/(mobile|pre\/|xoom)/i)||xa,Qa=!ga.match(/usehtml5audio/i)&&!ga.match(/sm2\-ignorebadua/i)&&ya&&!q.match(/silk/i)&&q.match(/OS X 10_6_([3-7])/i),Aa="undefined"!==typeof l.hasFocus?l.hasFocus():null,ca=ya&&("undefined"===typeof l.hasFocus||!l.hasFocus()),Ra=!ca,Sa=/(mp3|mp4|mpa|m4a)/i,Ba=l.location?l.location.protocol.match(/http/i):null, +Ta=!Ba?"http://":"",Ua=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i,Va="mpeg4,aac,flv,mov,mp4,m4v,f4v,m4a,mp4v,3gp,3g2".split(","),Ya=RegExp("\\.("+Va.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!Ba;this._global_a=null;if(za&&(c.useHTML5Audio=!0,c.preferFlash=!1,xa))z=c.ignoreFlash=!0;this.setup=function(a){"undefined"!==typeof a&&k&&n&&c.ok()&&("undefined"!==typeof a.flashVersion||"undefined"!==typeof a.url)&& +H(u("setupLate"));ka(a);return c};this.supported=this.ok=function(){return n?k&&!s:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(a){return S(a)||l[a]||h[a]};this.createSound=function(a,e){function d(){b=Y(b);c.sounds[f.id]=new Ca(f);c.soundIDs.push(f.id);return c.sounds[f.id]}var b=null,g=null,f=null;if(!k||!c.ok())return H(void 0),!1;"undefined"!==typeof e&&(a={id:a,url:e});b=r(a);b.url=aa(b.url);f=b;if(p(f.id,!0))return c.sounds[f.id];if(ba(f))g=d(),g._setup_html5(f);else{if(8=a)return!1;for(a-=1;0<=a;a--)if(c=k[a],!c.fired&&b.position>=c.position)c.fired=!0,o++,c.method.apply(c.scope,[c.position]);return!0};this._resetOnPosition=function(b){var a,c;a=k.length;if(!a)return!1;for(a-=1;0<=a;a--)if(c=k[a],c.fired&&b<=c.position)c.fired=!1,o--;return!0};s=function(){var a=b._iO, +c=a.from,e=a.to,d,f;f=function(){b.clearOnPosition(e,f);b.stop()};d=function(){if(null!==e&&!isNaN(e))b.onPosition(e,f)};if(null!==c&&!isNaN(c))a.position=c,a.multiShot=!1,d();return a};l=function(){var a,c=b._iO.onposition;if(c)for(a in c)if(c.hasOwnProperty(a))b.onPosition(parseInt(a,10),c[a])};q=function(){var a,c=b._iO.onposition;if(c)for(a in c)c.hasOwnProperty(a)&&b.clearOnPosition(parseInt(a,10))};h=function(){b.isHTML5&&Ia(b)};I=function(){b.isHTML5&&Ja(b)};g=function(a){a||(k=[],o=0);m=!1; +b._hasTimer=null;b._a=null;b._html5_canplay=!1;b.bytesLoaded=null;b.bytesTotal=null;b.duration=b._iO&&b._iO.duration?b._iO.duration:null;b.durationEstimate=null;b.buffered=[];b.eqData=[];b.eqData.left=[];b.eqData.right=[];b.failures=0;b.isBuffering=!1;b.instanceOptions={};b.instanceCount=0;b.loaded=!1;b.metadata={};b.readyState=0;b.muted=!1;b.paused=!1;b.peakData={left:0,right:0};b.waveformData={left:[],right:[]};b.playState=0;b.position=null;b.id3={}};g();this._onTimer=function(a){var c,f=!1,g={}; +if(b._hasTimer||a){if(b._a&&(a||(0f.duration?b.duration:f.duration:parseInt(b.bytesTotal/b.bytesLoaded*b.duration,10),"undefined"=== +typeof b.durationEstimate)b.durationEstimate=b.duration;if(!b.isHTML5)b.buffered=[{start:0,end:b.duration}];(3!==b.readyState||b.isHTML5)&&f.whileloading&&f.whileloading.apply(b)};this._whileplaying=function(a,c,e,d,f){var g=b._iO;if(isNaN(a)||null===a)return!1;b.position=Math.max(0,a);b._processOnPosition();if(!b.isHTML5&&8j)c.flashVersion=j=9;c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===j?" (AS3/Flash 9)":" (AS2/Flash 8)");8'}if(J&&K)return!1;if(c.html5Only)return ma(),c.oMC=S(c.movieID),ia(),K=J=!0,!1;var b=e||c.url,g=c.altURL||b,f;f=pa();var h,i,j=G(),k,m=null,m=(m=l.getElementsByTagName("html")[0])&&m.dir&&m.dir.match(/rtl/i),a="undefined"===typeof a?c.id:a;ma();c.url=Ha(Ba?b:g);e=c.url;c.wmode= +!c.wmode&&c.useHighPerformance?"transparent":c.wmode;if(null!==c.wmode&&(q.match(/msie 8/i)||!y&&!c.useHighPerformance)&&navigator.platform.match(/win32|win64/i))c.wmode=null;f={name:a,id:a,src:e,quality:"high",allowScriptAccess:c.allowScriptAccess,bgcolor:c.bgColor,pluginspage:Ta+"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)f.FlashVars="debug=1";c.wmode||delete f.wmode; +if(y)b=l.createElement("div"),i=['',d("movie",e),d("AllowScriptAccess",c.allowScriptAccess),d("quality",f.quality),c.wmode?d("wmode",c.wmode):"",d("bgcolor",c.bgColor),d("hasPriority","true"),c.debugFlash?d("FlashVars",f.FlashVars):"",""].join("");else for(h in b=l.createElement("embed"), +f)f.hasOwnProperty(h)&&b.setAttribute(h,f[h]);qa();j=G();if(f=pa())if(c.oMC=S(c.movieID)||l.createElement("div"),c.oMC.id){k=c.oMC.className;c.oMC.className=(k?k+" ":"movieContainer")+(j?" "+j:"");c.oMC.appendChild(b);if(y)h=c.oMC.appendChild(l.createElement("div")),h.className="sm2-object-box",h.innerHTML=i;K=!0}else{c.oMC.id=c.movieID;c.oMC.className="movieContainer "+j;h=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=Math.abs(parseInt(j.left,10))+"px";if(Xa)c.oMC.style.zIndex=1E4;if(!c.debugFlash)for(k in j)j.hasOwnProperty(k)&&(c.oMC.style[k]=j[k]);try{y||c.oMC.appendChild(b);f.appendChild(c.oMC);if(y)h=c.oMC.appendChild(l.createElement("div")),h.className="sm2-object-box",h.innerHTML=i;K=!0}catch(n){throw Error(u("domError")+" \n"+n.toString());}}return J=!0};V=function(){if(c.html5Only)return W(),!1;if(i)return!1; +i=c.getMovie(c.id);if(!i)M?(y?c.oMC.innerHTML=ra:c.oMC.appendChild(M),M=null,J=!0):W(c.id,c.url),i=c.getMovie(c.id);"function"===typeof c.oninitmovie&&setTimeout(c.oninitmovie,1);return!0};D=function(){setTimeout(Ea,1E3)};Ea=function(){var a,e=!1;if(N)return!1;N=!0;o.remove(h,"load",D);if(ca&&!Aa)return!1;k||(a=c.getMoviePercent(),0a&&(e=!0));setTimeout(function(){a=c.getMoviePercent();if(e)return N=!1,h.setTimeout(D,1),!1;!k&&Ra&&(null===a?c.useFlashBlock||0===c.flashLoadTimeout?c.useFlashBlock&& +sa():X(!0):0!==c.flashLoadTimeout&&X(!0))},c.flashLoadTimeout)};U=function(){if(Aa||!ca)return o.remove(h,"focus",U),!0;Aa=Ra=!0;N=!1;D();o.remove(h,"focus",U);return!0};Oa=function(){var a,e=[];if(c.useHTML5Audio&&c.hasHTML5)for(a in c.audioFormats)c.audioFormats.hasOwnProperty(a)&&e.push(a+": "+c.html5[a]+(!c.html5[a]&&t&&c.flash[a]?" (using flash)":c.preferFlash&&c.flash[a]&&t?" (preferring flash)":!c.html5[a]?" ("+(c.audioFormats[a].required?"required, ":"")+"and no flash support)":""))};L=function(a){if(k)return!1; +if(c.html5Only)return k=!0,C(),!0;var e=!0,d;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())k=!0,s&&(d={type:!t&&n?"NO_FLASH":"INIT_TIMEOUT"});if(s||a){if(c.useFlashBlock&&c.oMC)c.oMC.className=G()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error");B({type:"ontimeout",error:d,ignoreInit:!0});F(d);e=!1}s||(c.waitForWindowLoad&&!ja?o.add(h,"load",C):C());return e};Da=function(){var a,e=c.setupOptions;for(a in e)e.hasOwnProperty(a)&&("undefined"===typeof c[a]?c[a]=e[a]:c[a]!== +e[a]&&(c.setupOptions[a]=c[a]))};ia=function(){if(k)return!1;if(c.html5Only){if(!k)o.remove(h,"load",c.beginDelayedInit),c.enabled=!0,L();return!0}V();try{i._externalInterfaceTest(!1),Fa(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||i._disableDebug(),c.enabled=!0,c.html5Only||o.add(h,"unload",ha)}catch(a){return F({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),X(!0),L(),!1}L();o.remove(h,"load",c.beginDelayedInit);return!0};E=function(){if(oa)return!1;oa=!0;Da();qa();!t&&c.hasHTML5&& +c.setup({useHTML5Audio:!0,preferFlash:!1});Ma();c.html5.usingFlash=La();n=c.html5.usingFlash;Oa();!t&&n&&c.setup({flashLoadTimeout:1});l.removeEventListener&&l.removeEventListener("DOMContentLoaded",E,!1);V();return!0};va=function(){"complete"===l.readyState&&(E(),l.detachEvent("onreadystatechange",va));return!0};na=function(){ja=!0;o.remove(h,"load",na)};wa();o.add(h,"focus",U);o.add(h,"load",D);o.add(h,"load",na);l.addEventListener?l.addEventListener("DOMContentLoaded",E,!1):l.attachEvent?l.attachEvent("onreadystatechange", +va):F({type:"NO_DOM2_EVENTS",fatal:!0});"complete"===l.readyState&&setTimeout(E,100)}var da=null;if("undefined"===typeof SM2_DEFER||!SM2_DEFER)da=new Q;ea.SoundManager=Q;ea.soundManager=da})(window); \ No newline at end of file diff --git a/static/js/libs/sm/soundmanager2-nodebug.js b/static/js/libs/sm/soundmanager2-nodebug.js index 381bb92..99df0e8 100644 --- a/static/js/libs/sm/soundmanager2-nodebug.js +++ b/static/js/libs/sm/soundmanager2-nodebug.js @@ -8,2396 +8,2496 @@ * Code provided under the BSD License: * http://schillmania.com/projects/soundmanager2/license.txt * - * V2.97a.20120318 + * V2.97a.20120624 */ /*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio */ /*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true */ -(function (window) { - var soundManager = null; - - function SoundManager(smURL, smID) { - this.flashVersion = 8; - this.debugMode = false; - this.debugFlash = false; - this.useConsole = true; - this.consoleOnly = true; - this.waitForWindowLoad = false; - this.bgColor = '#ffffff'; - this.useHighPerformance = false; - this.flashPollingInterval = null; - this.html5PollingInterval = null; - this.flashLoadTimeout = 1000; - this.wmode = null; - this.allowScriptAccess = 'always'; - this.useFlashBlock = 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', 'audio/x-wav'], - 'required':false - } - }; - this.defaultOptions = { - 'autoLoad':false, - 'autoPlay':false, - 'from':null, - 'loops':1, - 'onid3':null, - 'onload':null, - 'whileloading':null, - 'onplay':null, - 'onpause':null, - 'onresume':null, - 'whileplaying':null, - 'onposition':null, - 'onstop':null, - 'onfailure':null, - 'onfinish':null, - 'multiShot':true, - 'multiShotEvents':false, - 'position':null, - 'pan':0, - 'stream':true, - 'to':null, - '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 = (smID || 'sm2movie'); - this.debugID = 'soundmanager-debug'; - this.debugURLParam = /([#?&])debug=1/i; - this.versionNumber = 'V2.97a.20120318'; - this.version = null; - this.movieURL = null; - this.url = (smURL || null); - this.altURL = null; - this.swfLoaded = false; - this.enabled = false; - this.oMC = null; - this.sounds = {}; - this.soundIDs = []; - this.muted = false; - this.didFlashBlock = 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 = { - }; - this.hasHTML5 = (function () { - try { - return (typeof Audio !== 'undefined' && typeof new Audio().canPlayType !== 'undefined'); - } catch (e) { - return false; - } - }()); - this.html5 = { - 'usingFlash':null - }; - this.flash = {}; - this.html5Only = false; - this.ignoreFlash = false; - var SMSound, - _s = this, _flash = null, _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, _winOnLoad, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _swfCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _startTimer, _stopTimer, _timerExecute, _h5TimerCount = 0, _h5IntervalTimer = null, _parseURL, - _needsFlash = null, _featureCheck, _html5OK, _html5CanPlay, _html5Ext, _html5Unload, _domContentLoadedIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix, _html5_events, _showSupport, - _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)), - _likesHTML5 = (_ua.match(/(mobile|pre\/|xoom)/i) || _is_iDevice), - _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && !_ua.match(/silk/i) && _ua.match(/OS X 10_6_([3-7])/i)), - _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, - _emptyURL = 'about:blank', - _overHTTP = (_doc.location ? _doc.location.protocol.match(/http/i) : null), - _http = (!_overHTTP ? 'http:/' + '/' : ''), - _netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i, - _netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'mp4v', '3gp', '3g2'], - _netStreamPattern = new RegExp('\\.(' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); - this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; - this.useAltURL = !_overHTTP; - this._global_a = null; - _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' - }; - if (_likesHTML5) { - _s.useHTML5Audio = true; - _s.preferFlash = false; - if (_is_iDevice) { - _s.ignoreFlash = true; - _useGlobalHTML5Audio = true; - } +(function(window) { +var soundManager = null; +function SoundManager(smURL, smID) { + this.setupOptions = { + 'url': (smURL || null), + 'flashVersion': 8, + 'debugMode': true, + 'debugFlash': false, + 'useConsole': true, + 'consoleOnly': true, + 'waitForWindowLoad': false, + 'bgColor': '#ffffff', + 'useHighPerformance': false, + 'flashPollingInterval': null, + 'html5PollingInterval': null, + 'flashLoadTimeout': 1000, + 'wmode': null, + 'allowScriptAccess': 'always', + 'useFlashBlock': false, + 'useHTML5Audio': true, + 'html5Test': /^(probably|maybe)$/i, + 'preferFlash': true, + 'noSWFCache': false + }; + this.defaultOptions = { + 'autoLoad': false, + 'autoPlay': false, + 'from': null, + 'loops': 1, + 'onid3': null, + 'onload': null, + 'whileloading': null, + 'onplay': null, + 'onpause': null, + 'onresume': null, + 'whileplaying': null, + 'onposition': null, + 'onstop': null, + 'onfailure': null, + 'onfinish': null, + 'multiShot': true, + 'multiShotEvents': false, + 'position': null, + 'pan': 0, + 'stream': true, + 'to': null, + '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.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.movieID = 'sm2-container'; + this.id = (smID || 'sm2movie'); + this.debugID = 'soundmanager-debug'; + this.debugURLParam = /([#?&])debug=1/i; + this.versionNumber = 'V2.97a.20120624'; + this.version = null; + this.movieURL = null; + this.altURL = null; + this.swfLoaded = false; + this.enabled = false; + this.oMC = null; + this.sounds = {}; + this.soundIDs = []; + this.muted = false; + this.didFlashBlock = 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 = { + }; + this.hasHTML5 = (function() { + try { + return (typeof Audio !== 'undefined' && typeof new Audio().canPlayType !== 'undefined'); + } catch(e) { + return false; + } + }()); + this.html5 = { + 'usingFlash': null + }; + this.flash = {}; + this.html5Only = false; + this.ignoreFlash = false; + var SMSound, + _s = this, _flash = null, _sm = 'soundManager', _smc = _sm+'::', _h5 = 'HTML5::', _id, _ua = navigator.userAgent, _win = window, _wl = _win.location.href.toString(), _doc = document, _doNothing, _setProperties, _init, _fV, _on_queue = [], _debugOpen = true, _debugTS, _didAppend = false, _appendSuccess = false, _didInit = false, _disabled = false, _windowLoaded = false, _wDS, _wdCount = 0, _initComplete, _mixin, _assign, _extraOptions, _addOnEvent, _processOnEvents, _initUserOnload, _delayWaitForEI, _waitForEI, _setVersionInfo, _handleFocus, _strings, _initMovie, _domContentLoaded, _winOnLoad, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _swfCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _startTimer, _stopTimer, _timerExecute, _h5TimerCount = 0, _h5IntervalTimer = null, _parseURL, + _needsFlash = null, _featureCheck, _html5OK, _html5CanPlay, _html5Ext, _html5Unload, _domContentLoadedIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix, _html5_events, _showSupport, + _is_iDevice = _ua.match(/(ipad|iphone|ipod)/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)), + _mobileHTML5 = (_ua.match(/(mobile|pre\/|xoom)/i) || _is_iDevice), + _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && !_ua.match(/silk/i) && _ua.match(/OS X 10_6_([3-7])/i)), + _hasConsole = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (_isSafari && (typeof _doc.hasFocus === 'undefined' || !_doc.hasFocus())), _okToDisable = !_tryInitOnFocus, _flashMIME = /(mp3|mp4|mpa|m4a)/i, + _emptyURL = 'about:blank', + _overHTTP = (_doc.location?_doc.location.protocol.match(/http/i):null), + _http = (!_overHTTP ? 'http:/'+'/' : ''), + _netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|mp4v|3gp|3g2)\s*(?:$|;)/i, + _netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'mp4v', '3gp', '3g2'], + _netStreamPattern = new RegExp('\\.(' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); + this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; + this.useAltURL = !_overHTTP; + this._global_a = null; + _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' + }; + if (_mobileHTML5) { + _s.useHTML5Audio = true; + _s.preferFlash = false; + if (_is_iDevice) { + _s.ignoreFlash = true; + _useGlobalHTML5Audio = true; + } + } + this.setup = function(options) { + if (typeof options !== 'undefined' && _didInit && _needsFlash && _s.ok() && (typeof options.flashVersion !== 'undefined' || typeof options.url !== 'undefined')) { + _complain(_str('setupLate')); + } + _assign(options); + return _s; + }; + this.ok = function() { + return (_needsFlash?(_didInit && !_disabled):(_s.useHTML5Audio && _s.hasHTML5)); + }; + this.supported = this.ok; + this.getMovie = function(smID) { + return _id(smID) || _doc[smID] || _win[smID]; + }; + this.createSound = function(oOptions, _url) { + var _cs, _cs_string, thisOptions = null, oSound = null, _tO = null; + if (!_didInit || !_s.ok()) { + _complain(_cs_string); + return false; + } + if (typeof _url !== 'undefined') { + oOptions = { + 'id': oOptions, + 'url': _url + }; + } + thisOptions = _mixin(oOptions); + thisOptions.url = _parseURL(thisOptions.url); + _tO = thisOptions; + if (_idCheck(_tO.id, true)) { + return _s.sounds[_tO.id]; + } + function make() { + thisOptions = _loopFix(thisOptions); + _s.sounds[_tO.id] = new SMSound(_tO); + _s.soundIDs.push(_tO.id); + return _s.sounds[_tO.id]; + } + if (_html5OK(_tO)) { + oSound = make(); + oSound._setup_html5(_tO); + } else { + if (_fV > 8) { + if (_tO.isMovieStar === null) { + _tO.isMovieStar = !!(_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern)); } - this.ok = function () { - return (_needsFlash ? (_didInit && !_disabled) : (_s.useHTML5Audio && _s.hasHTML5)); - }; - this.supported = this.ok; - this.getMovie = function (smID) { - return _id(smID) || _doc[smID] || _win[smID]; - }; - this.createSound = function (oOptions) { - var _cs, _cs_string, - thisOptions = null, oSound = null, _tO = null; - if (!_didInit || !_s.ok()) { - _complain(_cs_string); - return false; - } - if (arguments.length === 2) { - oOptions = { - 'id':arguments[0], - 'url':arguments[1] - }; - } - thisOptions = _mixin(oOptions); - thisOptions.url = _parseURL(thisOptions.url); - _tO = thisOptions; - if (_idCheck(_tO.id, true)) { - return _s.sounds[_tO.id]; - } - function make() { - thisOptions = _loopFix(thisOptions); - _s.sounds[_tO.id] = new SMSound(_tO); - _s.soundIDs.push(_tO.id); - return _s.sounds[_tO.id]; - } - - if (_html5OK(_tO)) { - oSound = make(); - oSound._setup_html5(_tO); - } else { - if (_fV > 8) { - if (_tO.isMovieStar === null) { - _tO.isMovieStar = (_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern)); - } - if (_tO.isMovieStar) { - if (_tO.usePeakData) { - _tO.usePeakData = false; - } - } - } - _tO = _policyFix(_tO, _cs); - oSound = make(); - if (_fV === 8) { - _flash._createSound(_tO.id, _tO.loops || 1, _tO.usePolicyFile); - } else { - _flash._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); - if (!_tO.serverURL) { - oSound.connected = true; - if (_tO.onconnect) { - _tO.onconnect.apply(oSound); - } - } - } - if (!_tO.serverURL && (_tO.autoLoad || _tO.autoPlay)) { - oSound.load(_tO); - } - } - if (!_tO.serverURL && _tO.autoPlay) { - oSound.play(); - } - return oSound; - }; - this.destroySound = function (sID, _bFromSound) { - if (!_idCheck(sID)) { - return false; - } - var oS = _s.sounds[sID], i; - oS._iO = {}; - oS.stop(); - oS.unload(); - for (i = 0; i < _s.soundIDs.length; i++) { - if (_s.soundIDs[i] === sID) { - _s.soundIDs.splice(i, 1); - break; - } - } - if (!_bFromSound) { - oS.destruct(true); - } - oS = null; - delete _s.sounds[sID]; - return true; - }; - this.load = function (sID, oOptions) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].load(oOptions); - }; - this.unload = function (sID) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].unload(); - }; - this.onPosition = function (sID, nPosition, oMethod, oScope) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].onposition(nPosition, oMethod, oScope); - }; - this.onposition = this.onPosition; - this.clearOnPosition = function (sID, nPosition, oMethod) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].clearOnPosition(nPosition, oMethod); - }; - this.play = function (sID, oOptions) { - if (!_didInit || !_s.ok()) { - _complain(_sm + '.play(): ' + _str(!_didInit ? 'notReady' : 'notOK')); - return false; - } - if (!_idCheck(sID)) { - if (!(oOptions instanceof Object)) { - oOptions = { - url:oOptions - }; - } - if (oOptions && oOptions.url) { - oOptions.id = sID; - return _s.createSound(oOptions).play(); - } else { - return false; - } - } - return _s.sounds[sID].play(oOptions); - }; - this.start = this.play; - this.setPosition = function (sID, nMsecOffset) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].setPosition(nMsecOffset); - }; - this.stop = function (sID) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].stop(); - }; - this.stopAll = function () { - var oSound; - for (oSound in _s.sounds) { - if (_s.sounds.hasOwnProperty(oSound)) { - _s.sounds[oSound].stop(); - } - } - }; - this.pause = function (sID) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].pause(); - }; - this.pauseAll = function () { - var i; - for (i = _s.soundIDs.length - 1; i >= 0; i--) { - _s.sounds[_s.soundIDs[i]].pause(); - } - }; - this.resume = function (sID) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].resume(); - }; - this.resumeAll = function () { - var i; - for (i = _s.soundIDs.length - 1; i >= 0; i--) { - _s.sounds[_s.soundIDs[i]].resume(); - } - }; - this.togglePause = function (sID) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].togglePause(); - }; - this.setPan = function (sID, nPan) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].setPan(nPan); - }; - this.setVolume = function (sID, nVol) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].setVolume(nVol); - }; - this.mute = function (sID) { - var i = 0; - if (typeof sID !== 'string') { - sID = null; - } - if (!sID) { - for (i = _s.soundIDs.length - 1; i >= 0; i--) { - _s.sounds[_s.soundIDs[i]].mute(); - } - _s.muted = true; - } else { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].mute(); - } - return true; - }; - this.muteAll = function () { - _s.mute(); - }; - this.unmute = function (sID) { - var i; - if (typeof sID !== 'string') { - sID = null; - } - if (!sID) { - for (i = _s.soundIDs.length - 1; i >= 0; i--) { - _s.sounds[_s.soundIDs[i]].unmute(); - } - _s.muted = false; - } else { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].unmute(); - } - return true; - }; - this.unmuteAll = function () { - _s.unmute(); - }; - this.toggleMute = function (sID) { - if (!_idCheck(sID)) { - return false; - } - return _s.sounds[sID].toggleMute(); - }; - this.getMemoryUse = function () { - var ram = 0; - if (_flash && _fV !== 8) { - ram = parseInt(_flash._getMemoryUse(), 10); - } - return ram; - }; - this.disable = function (bNoDisable) { - var i; - if (typeof bNoDisable === 'undefined') { - bNoDisable = false; - } - if (_disabled) { - return false; - } - _disabled = true; - for (i = _s.soundIDs.length - 1; i >= 0; i--) { - _disableObject(_s.sounds[_s.soundIDs[i]]); - } - _initComplete(bNoDisable); - _event.remove(_win, 'load', _initUserOnload); - return true; - }; - this.canPlayMIME = function (sMIME) { - var result; - if (_s.hasHTML5) { - result = _html5CanPlay({type:sMIME}); - } - if (!_needsFlash || result) { - return result; - } else { - return (sMIME && _s.ok() ? !!((_fV > 8 ? sMIME.match(_netStreamMimeTypes) : null) || sMIME.match(_s.mimePattern)) : null); - } - }; - this.canPlayURL = function (sURL) { - var result; - if (_s.hasHTML5) { - result = _html5CanPlay({url:sURL}); - } - if (!_needsFlash || result) { - return result; - } else { - return (sURL && _s.ok() ? !!(sURL.match(_s.filePattern)) : null); - } - }; - this.canPlayLink = function (oLink) { - if (typeof oLink.type !== 'undefined' && oLink.type) { - if (_s.canPlayMIME(oLink.type)) { - return true; - } - } - return _s.canPlayURL(oLink.href); - }; - this.getSoundById = function (sID, _suppressDebug) { - if (!sID) { - throw new Error(_sm + '.getSoundById(): sID is null/undefined'); - } - var result = _s.sounds[sID]; - return result; - }; - this.onready = function (oMethod, oScope) { - var sType = 'onready'; - if (oMethod && oMethod instanceof Function) { - if (!oScope) { - oScope = _win; - } - _addOnEvent(sType, oMethod, oScope); - _processOnEvents(); - return true; - } else { - throw _str('needFunction', sType); - } - }; - this.ontimeout = function (oMethod, oScope) { - var sType = 'ontimeout'; - if (oMethod && oMethod instanceof Function) { - if (!oScope) { - oScope = _win; - } - _addOnEvent(sType, oMethod, oScope); - _processOnEvents({type:sType}); - return true; - } else { - throw _str('needFunction', sType); - } - }; - this._writeDebug = function (sText, sType, _bTimestamp) { - return true; - }; - this._wD = this._writeDebug; - this._debug = function () { - }; - this.reboot = function () { - var i, j; - for (i = _s.soundIDs.length - 1; i >= 0; i--) { - _s.sounds[_s.soundIDs[i]].destruct(); - } - try { - if (_isIE) { - _oRemovedHTML = _flash.innerHTML; - } - _oRemoved = _flash.parentNode.removeChild(_flash); - } catch (e) { - } - _oRemovedHTML = _oRemoved = _needsFlash = null; - _s.enabled = _didDCLoaded = _didInit = _waitingForEI = _initPending = _didAppend = _appendSuccess = _disabled = _s.swfLoaded = false; - _s.soundIDs = []; - _s.sounds = {}; - _flash = null; - for (i in _on_queue) { - if (_on_queue.hasOwnProperty(i)) { - for (j = _on_queue[i].length - 1; j >= 0; j--) { - _on_queue[i][j].fired = false; - } - } - } - _win.setTimeout(_s.beginDelayedInit, 20); - }; - this.getMoviePercent = function () { - return (_flash && typeof _flash.PercentLoaded !== 'undefined' ? _flash.PercentLoaded() : null); - }; - this.beginDelayedInit = function () { - _windowLoaded = true; - _domContentLoaded(); - setTimeout(function () { - if (_initPending) { - return false; - } - _createMovie(); - _initMovie(); - _initPending = true; - return true; - }, 20); - _delayWaitForEI(); - }; - this.destruct = function () { - _s.disable(true); - }; - SMSound = function (oOptions) { - var _t = this, _resetProperties, _add_html5_events, _remove_html5_events, _stop_html5_timer, _start_html5_timer, _attachOnPosition, _onplay_called = false, _onPositionItems = [], _onPositionFired = 0, _detachOnPosition, _applyFromTo, _lastURL = null, _lastHTML5State; - _lastHTML5State = { - duration:null, - time:null - }; - this.sID = oOptions.id; - this.url = oOptions.url; - this.options = _mixin(oOptions); - this.instanceOptions = this.options; - this._iO = this.instanceOptions; - this.pan = this.options.pan; - this.volume = this.options.volume; - this.isHTML5 = false; - this._a = null; - this.id3 = {}; - this._debug = function () { - }; - this.load = function (oOptions) { - var oS = null, _iO; - if (typeof oOptions !== 'undefined') { - _t._iO = _mixin(oOptions, _t.options); - _t.instanceOptions = _t._iO; - } else { - oOptions = _t.options; - _t._iO = oOptions; - _t.instanceOptions = _t._iO; - if (_lastURL && _lastURL !== _t.url) { - _t._iO.url = _t.url; - _t.url = null; - } - } - if (!_t._iO.url) { - _t._iO.url = _t.url; - } - _t._iO.url = _parseURL(_t._iO.url); - if (_t._iO.url === _t.url && _t.readyState !== 0 && _t.readyState !== 2) { - if (_t.readyState === 3 && _t._iO.onload) { - _t._iO.onload.apply(_t, [(!!_t.duration)]); - } - return _t; - } - _iO = _t._iO; - _lastURL = _t.url; - _t.loaded = false; - _t.readyState = 1; - _t.playState = 0; - if (_html5OK(_iO)) { - oS = _t._setup_html5(_iO); - if (!oS._called_load) { - _t._html5_canplay = false; - _t._a.autobuffer = 'auto'; - _t._a.preload = 'auto'; - oS.load(); - oS._called_load = true; - if (_iO.autoPlay) { - _t.play(); - } - } else { - } - } else { - try { - _t.isHTML5 = false; - _t._iO = _policyFix(_loopFix(_iO)); - _iO = _t._iO; - if (_fV === 8) { - _flash._load(_t.sID, _iO.url, _iO.stream, _iO.autoPlay, (_iO.whileloading ? 1 : 0), _iO.loops || 1, _iO.usePolicyFile); - } else { - _flash._load(_t.sID, _iO.url, !!(_iO.stream), !!(_iO.autoPlay), _iO.loops || 1, !!(_iO.autoLoad), _iO.usePolicyFile); - } - } catch (e) { - _catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true}); - } - } - return _t; - }; - this.unload = function () { - if (_t.readyState !== 0) { - if (!_t.isHTML5) { - if (_fV === 8) { - _flash._unload(_t.sID, _emptyURL); - } else { - _flash._unload(_t.sID); - } - } else { - _stop_html5_timer(); - if (_t._a) { - _t._a.pause(); - _html5Unload(_t._a); - } - } - _resetProperties(); - } - return _t; - }; - this.destruct = function (_bFromSM) { - if (!_t.isHTML5) { - _t._iO.onfailure = null; - _flash._destroySound(_t.sID); - } else { - _stop_html5_timer(); - if (_t._a) { - _t._a.pause(); - _html5Unload(_t._a); - if (!_useGlobalHTML5Audio) { - _remove_html5_events(); - } - _t._a._t = null; - _t._a = null; - } - } - if (!_bFromSM) { - _s.destroySound(_t.sID, true); - } - }; - this.play = function (oOptions, _updatePlayState) { - var fN, allowMulti, a, onready; - _updatePlayState = _updatePlayState === undefined ? true : _updatePlayState; - if (!oOptions) { - oOptions = {}; - } - _t._iO = _mixin(oOptions, _t._iO); - _t._iO = _mixin(_t._iO, _t.options); - _t._iO.url = _parseURL(_t._iO.url); - _t.instanceOptions = _t._iO; - if (_t._iO.serverURL && !_t.connected) { - if (!_t.getAutoPlay()) { - _t.setAutoPlay(true); - } - return _t; - } - if (_html5OK(_t._iO)) { - _t._setup_html5(_t._iO); - _start_html5_timer(); - } - if (_t.playState === 1 && !_t.paused) { - allowMulti = _t._iO.multiShot; - if (!allowMulti) { - return _t; - } else { - } - } - if (!_t.loaded) { - if (_t.readyState === 0) { - if (!_t.isHTML5) { - _t._iO.autoPlay = true; - } - _t.load(_t._iO); - } else if (_t.readyState === 2) { - return _t; - } else { - } - } else { - } - if (!_t.isHTML5 && _fV === 9 && _t.position > 0 && _t.position === _t.duration) { - oOptions.position = 0; - } - if (_t.paused && _t.position && _t.position > 0) { - _t.resume(); - } else { - _t._iO = _mixin(oOptions, _t._iO); - if (_t._iO.from !== null && _t._iO.to !== null && _t.instanceCount === 0 && _t.playState === 0 && !_t._iO.serverURL) { - onready = function () { - _t._iO = _mixin(oOptions, _t._iO); - _t.play(_t._iO); - }; - if (_t.isHTML5 && !_t._html5_canplay) { - _t.load({ - _oncanplay:onready - }); - return false; - } else if (!_t.isHTML5 && !_t.loaded && (!_t.readyState || _t.readyState !== 2)) { - _t.load({ - onload:onready - }); - return false; - } - _t._iO = _applyFromTo(); - } - if (!_t.instanceCount || _t._iO.multiShotEvents || (!_t.isHTML5 && _fV > 8 && !_t.getAutoPlay())) { - _t.instanceCount++; - } - if (_t.playState === 0 && _t._iO.onposition) { - _attachOnPosition(_t); - } - _t.playState = 1; - _t.paused = false; - _t.position = (typeof _t._iO.position !== 'undefined' && !isNaN(_t._iO.position) ? _t._iO.position : 0); - if (!_t.isHTML5) { - _t._iO = _policyFix(_loopFix(_t._iO)); - } - if (_t._iO.onplay && _updatePlayState) { - _t._iO.onplay.apply(_t); - _onplay_called = true; - } - _t.setVolume(_t._iO.volume, true); - _t.setPan(_t._iO.pan, true); - if (!_t.isHTML5) { - _flash._start(_t.sID, _t._iO.loops || 1, (_fV === 9 ? _t._iO.position : _t._iO.position / 1000)); - } else { - _start_html5_timer(); - a = _t._setup_html5(); - _t.setPosition(_t._iO.position); - a.play(); - } - } - return _t; - }; - this.start = this.play; - this.stop = function (bAll) { - var _iO = _t._iO, _oP; - if (_t.playState === 1) { - _t._onbufferchange(0); - _t._resetOnPosition(0); - _t.paused = false; - if (!_t.isHTML5) { - _t.playState = 0; - } - _detachOnPosition(); - if (_iO.to) { - _t.clearOnPosition(_iO.to); - } - if (!_t.isHTML5) { - _flash._stop(_t.sID, bAll); - if (_iO.serverURL) { - _t.unload(); - } - } else { - if (_t._a) { - _oP = _t.position; - _t.setPosition(0); - _t.position = _oP; - _t._a.pause(); - _t.playState = 0; - _t._onTimer(); - _stop_html5_timer(); - } - } - _t.instanceCount = 0; - _t._iO = {}; - if (_iO.onstop) { - _iO.onstop.apply(_t); - } - } - return _t; - }; - this.setAutoPlay = function (autoPlay) { - _t._iO.autoPlay = autoPlay; - if (!_t.isHTML5) { - _flash._setAutoPlay(_t.sID, autoPlay); - if (autoPlay) { - if (!_t.instanceCount && _t.readyState === 1) { - _t.instanceCount++; - } - } - } - }; - this.getAutoPlay = function () { - return _t._iO.autoPlay; - }; - this.setPosition = function (nMsecOffset) { - if (nMsecOffset === undefined) { - nMsecOffset = 0; - } - var original_pos, - position, position1K, - offset = (_t.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(_t.duration || _t._iO.duration, Math.max(nMsecOffset, 0))); - original_pos = _t.position; - _t.position = offset; - position1K = _t.position / 1000; - _t._resetOnPosition(_t.position); - _t._iO.position = offset; - if (!_t.isHTML5) { - position = (_fV === 9 ? _t.position : position1K); - if (_t.readyState && _t.readyState !== 2) { - _flash._setPosition(_t.sID, position, (_t.paused || !_t.playState)); - } - } else if (_t._a) { - if (_t._html5_canplay) { - if (_t._a.currentTime !== position1K) { - try { - _t._a.currentTime = position1K; - if (_t.playState === 0 || _t.paused) { - _t._a.pause(); - } - } catch (e) { - } - } - } else { - } - } - if (_t.isHTML5) { - if (_t.paused) { - _t._onTimer(true); - } - } - return _t; - }; - this.pause = function (_bCallFlash) { - if (_t.paused || (_t.playState === 0 && _t.readyState !== 1)) { - return _t; - } - _t.paused = true; - if (!_t.isHTML5) { - if (_bCallFlash || _bCallFlash === undefined) { - _flash._pause(_t.sID); - } - } else { - _t._setup_html5().pause(); - _stop_html5_timer(); - } - if (_t._iO.onpause) { - _t._iO.onpause.apply(_t); - } - return _t; - }; - this.resume = function () { - var _iO = _t._iO; - if (!_t.paused) { - return _t; - } - _t.paused = false; - _t.playState = 1; - if (!_t.isHTML5) { - if (_iO.isMovieStar && !_iO.serverURL) { - _t.setPosition(_t.position); - } - _flash._pause(_t.sID); - } else { - _t._setup_html5().play(); - _start_html5_timer(); - } - if (!_onplay_called && _iO.onplay) { - _iO.onplay.apply(_t); - _onplay_called = true; - } else if (_iO.onresume) { - _iO.onresume.apply(_t); - } - return _t; - }; - this.togglePause = function () { - if (_t.playState === 0) { - _t.play({ - position:(_fV === 9 && !_t.isHTML5 ? _t.position : _t.position / 1000) - }); - return _t; - } - if (_t.paused) { - _t.resume(); - } else { - _t.pause(); - } - return _t; - }; - this.setPan = function (nPan, bInstanceOnly) { - if (typeof nPan === 'undefined') { - nPan = 0; - } - if (typeof bInstanceOnly === 'undefined') { - bInstanceOnly = false; - } - if (!_t.isHTML5) { - _flash._setPan(_t.sID, nPan); - } - _t._iO.pan = nPan; - if (!bInstanceOnly) { - _t.pan = nPan; - _t.options.pan = nPan; - } - return _t; - }; - this.setVolume = function (nVol, _bInstanceOnly) { - if (typeof nVol === 'undefined') { - nVol = 100; - } - if (typeof _bInstanceOnly === 'undefined') { - _bInstanceOnly = false; - } - if (!_t.isHTML5) { - _flash._setVolume(_t.sID, (_s.muted && !_t.muted) || _t.muted ? 0 : nVol); - } else if (_t._a) { - _t._a.volume = Math.max(0, Math.min(1, nVol / 100)); - } - _t._iO.volume = nVol; - if (!_bInstanceOnly) { - _t.volume = nVol; - _t.options.volume = nVol; - } - return _t; - }; - this.mute = function () { - _t.muted = true; - if (!_t.isHTML5) { - _flash._setVolume(_t.sID, 0); - } else if (_t._a) { - _t._a.muted = true; - } - return _t; - }; - this.unmute = function () { - _t.muted = false; - var hasIO = typeof _t._iO.volume !== 'undefined'; - if (!_t.isHTML5) { - _flash._setVolume(_t.sID, hasIO ? _t._iO.volume : _t.options.volume); - } else if (_t._a) { - _t._a.muted = false; - } - return _t; - }; - this.toggleMute = function () { - return (_t.muted ? _t.unmute() : _t.mute()); - }; - this.onPosition = function (nPosition, oMethod, oScope) { - _onPositionItems.push({ - position:parseInt(nPosition, 10), - method:oMethod, - scope:(typeof oScope !== 'undefined' ? oScope : _t), - fired:false - }); - return _t; - }; - this.onposition = this.onPosition; - this.clearOnPosition = function (nPosition, oMethod) { - var i; - nPosition = parseInt(nPosition, 10); - if (isNaN(nPosition)) { - return false; - } - for (i = 0; i < _onPositionItems.length; i++) { - if (nPosition === _onPositionItems[i].position) { - if (!oMethod || (oMethod === _onPositionItems[i].method)) { - if (_onPositionItems[i].fired) { - _onPositionFired--; - } - _onPositionItems.splice(i, 1); - } - } - } - }; - this._processOnPosition = function () { - var i, item, j = _onPositionItems.length; - if (!j || !_t.playState || _onPositionFired >= j) { - return false; - } - for (i = j - 1; i >= 0; i--) { - item = _onPositionItems[i]; - if (!item.fired && _t.position >= item.position) { - item.fired = true; - _onPositionFired++; - item.method.apply(item.scope, [item.position]); - } - } - return true; - }; - this._resetOnPosition = function (nPosition) { - var i, item, j = _onPositionItems.length; - if (!j) { - return false; - } - for (i = j - 1; i >= 0; i--) { - item = _onPositionItems[i]; - if (item.fired && nPosition <= item.position) { - item.fired = false; - _onPositionFired--; - } - } - return true; - }; - _applyFromTo = function () { - var _iO = _t._iO, - f = _iO.from, - t = _iO.to, - start, end; - end = function () { - _t.clearOnPosition(t, end); - _t.stop(); - }; - start = function () { - if (t !== null && !isNaN(t)) { - _t.onPosition(t, end); - } - }; - if (f !== null && !isNaN(f)) { - _iO.position = f; - _iO.multiShot = false; - start(); - } - return _iO; - }; - _attachOnPosition = function () { - var item, - op = _t._iO.onposition; - if (op) { - for (item in op) { - if (op.hasOwnProperty(item)) { - _t.onPosition(parseInt(item, 10), op[item]); - } - } - } - }; - _detachOnPosition = function () { - var item, - op = _t._iO.onposition; - if (op) { - for (item in op) { - if (op.hasOwnProperty(item)) { - _t.clearOnPosition(parseInt(item, 10)); - } - } - } - }; - _start_html5_timer = function () { - if (_t.isHTML5) { - _startTimer(_t); - } - }; - _stop_html5_timer = function () { - if (_t.isHTML5) { - _stopTimer(_t); - } - }; - _resetProperties = function () { - _onPositionItems = []; - _onPositionFired = 0; - _onplay_called = false; - _t._hasTimer = null; - _t._a = null; - _t._html5_canplay = false; - _t.bytesLoaded = null; - _t.bytesTotal = null; - _t.duration = (_t._iO && _t._iO.duration ? _t._iO.duration : null); - _t.durationEstimate = null; - _t.eqData = []; - _t.eqData.left = []; - _t.eqData.right = []; - _t.failures = 0; - _t.isBuffering = false; - _t.instanceOptions = {}; - _t.instanceCount = 0; - _t.loaded = false; - _t.metadata = {}; - _t.readyState = 0; - _t.muted = false; - _t.paused = false; - _t.peakData = { - left:0, - right:0 - }; - _t.waveformData = { - left:[], - right:[] - }; - _t.playState = 0; - _t.position = null; - }; - _resetProperties(); - this._onTimer = function (bForce) { - var duration, isNew = false, time, x = {}; - if (_t._hasTimer || bForce) { - if (_t._a && (bForce || ((_t.playState > 0 || _t.readyState === 1) && !_t.paused))) { - duration = _t._get_html5_duration(); - if (duration !== _lastHTML5State.duration) { - _lastHTML5State.duration = duration; - _t.duration = duration; - isNew = true; - } - _t.durationEstimate = _t.duration; - time = (_t._a.currentTime * 1000 || 0); - if (time !== _lastHTML5State.time) { - _lastHTML5State.time = time; - isNew = true; - } - if (isNew || bForce) { - _t._whileplaying(time, x, x, x, x); - } - return isNew; - } else { - return false; - } - } - }; - this._get_html5_duration = function () { - var _iO = _t._iO, - d = (_t._a ? _t._a.duration * 1000 : (_iO ? _iO.duration : undefined)), - result = (d && !isNaN(d) && d !== Infinity ? d : (_iO ? _iO.duration : null)); - return result; - }; - this._setup_html5 = function (oOptions) { - var _iO = _mixin(_t._iO, oOptions), d = decodeURI, - _a = _useGlobalHTML5Audio ? _s._global_a : _t._a, - _dURL = d(_iO.url), - _oldIO = (_a && _a._t ? _a._t.instanceOptions : null); - if (_a) { - if (_a._t) { - if (!_useGlobalHTML5Audio && _dURL === d(_lastURL)) { - return _a; - } else if (_useGlobalHTML5Audio && _oldIO.url === _iO.url && (!_lastURL || (_lastURL === _oldIO.url))) { - return _a; - } - } - if (_useGlobalHTML5Audio && _a._t && _a._t.playState && _iO.url !== _oldIO.url) { - _a._t.stop(); - } - _resetProperties(); - _a.src = _iO.url; - _t.url = _iO.url; - _lastURL = _iO.url; - _a._called_load = false; - } else { - _a = new Audio(_iO.url); - _a._called_load = false; - if (_is_android) { - _a._called_load = true; - } - if (_useGlobalHTML5Audio) { - _s._global_a = _a; - } - } - _t.isHTML5 = true; - _t._a = _a; - _a._t = _t; - _add_html5_events(); - _a.loop = (_iO.loops > 1 ? 'loop' : ''); - if (_iO.autoLoad || _iO.autoPlay) { - _t.load(); - } else { - _a.autobuffer = false; - _a.preload = 'none'; - } - _a.loop = (_iO.loops > 1 ? 'loop' : ''); - return _a; - }; - _add_html5_events = function () { - if (_t._a._added_events) { - return false; - } - var f; - - function add(oEvt, oFn, bCapture) { - return _t._a ? _t._a.addEventListener(oEvt, oFn, bCapture || false) : null; - } - - _t._a._added_events = true; - for (f in _html5_events) { - if (_html5_events.hasOwnProperty(f)) { - add(f, _html5_events[f]); - } - } - return true; - }; - _remove_html5_events = function () { - var f; - - function remove(oEvt, oFn, bCapture) { - return (_t._a ? _t._a.removeEventListener(oEvt, oFn, bCapture || false) : null); - } - - _t._a._added_events = false; - for (f in _html5_events) { - if (_html5_events.hasOwnProperty(f)) { - remove(f, _html5_events[f]); - } - } - }; - this._onload = function (nSuccess) { - var fN, loadOK = !!(nSuccess); - _t.loaded = loadOK; - _t.readyState = loadOK ? 3 : 2; - _t._onbufferchange(0); - if (_t._iO.onload) { - _t._iO.onload.apply(_t, [loadOK]); - } - return true; - }; - this._onbufferchange = function (nIsBuffering) { - if (_t.playState === 0) { - return false; - } - if ((nIsBuffering && _t.isBuffering) || (!nIsBuffering && !_t.isBuffering)) { - return false; - } - _t.isBuffering = (nIsBuffering === 1); - if (_t._iO.onbufferchange) { - _t._iO.onbufferchange.apply(_t); - } - return true; - }; - this._onsuspend = function () { - if (_t._iO.onsuspend) { - _t._iO.onsuspend.apply(_t); - } - return true; - }; - this._onfailure = function (msg, level, code) { - _t.failures++; - if (_t._iO.onfailure && _t.failures === 1) { - _t._iO.onfailure(_t, msg, level, code); - } else { - } - }; - this._onfinish = function () { - var _io_onfinish = _t._iO.onfinish; - _t._onbufferchange(0); - _t._resetOnPosition(0); - if (_t.instanceCount) { - _t.instanceCount--; - if (!_t.instanceCount) { - _detachOnPosition(); - _t.playState = 0; - _t.paused = false; - _t.instanceCount = 0; - _t.instanceOptions = {}; - _t._iO = {}; - _stop_html5_timer(); - } - if (!_t.instanceCount || _t._iO.multiShotEvents) { - if (_io_onfinish) { - _io_onfinish.apply(_t); - } - } - } - }; - this._whileloading = function (nBytesLoaded, nBytesTotal, nDuration, nBufferLength) { - var _iO = _t._iO; - _t.bytesLoaded = nBytesLoaded; - _t.bytesTotal = nBytesTotal; - _t.duration = Math.floor(nDuration); - _t.bufferLength = nBufferLength; - if (!_iO.isMovieStar) { - if (_iO.duration) { - _t.durationEstimate = (_t.duration > _iO.duration) ? _t.duration : _iO.duration; - } else { - _t.durationEstimate = parseInt((_t.bytesTotal / _t.bytesLoaded) * _t.duration, 10); - } - if (_t.durationEstimate === undefined) { - _t.durationEstimate = _t.duration; - } - if (_t.readyState !== 3 && _iO.whileloading) { - _iO.whileloading.apply(_t); - } - } else { - _t.durationEstimate = _t.duration; - if (_t.readyState !== 3 && _iO.whileloading) { - _iO.whileloading.apply(_t); - } - } - }; - this._whileplaying = function (nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) { - var _iO = _t._iO, - eqLeft; - if (isNaN(nPosition) || nPosition === null) { - return false; - } - _t.position = nPosition; - _t._processOnPosition(); - if (!_t.isHTML5 && _fV > 8) { - if (_iO.usePeakData && typeof oPeakData !== 'undefined' && oPeakData) { - _t.peakData = { - left:oPeakData.leftPeak, - right:oPeakData.rightPeak - }; - } - if (_iO.useWaveformData && typeof oWaveformDataLeft !== 'undefined' && oWaveformDataLeft) { - _t.waveformData = { - left:oWaveformDataLeft.split(','), - right:oWaveformDataRight.split(',') - }; - } - if (_iO.useEQData) { - if (typeof oEQData !== 'undefined' && oEQData && oEQData.leftEQ) { - eqLeft = oEQData.leftEQ.split(','); - _t.eqData = eqLeft; - _t.eqData.left = eqLeft; - if (typeof oEQData.rightEQ !== 'undefined' && oEQData.rightEQ) { - _t.eqData.right = oEQData.rightEQ.split(','); - } - } - } - } - if (_t.playState === 1) { - if (!_t.isHTML5 && _fV === 8 && !_t.position && _t.isBuffering) { - _t._onbufferchange(0); - } - if (_iO.whileplaying) { - _iO.whileplaying.apply(_t); - } - } - return true; - }; - this._onmetadata = function (oMDProps, oMDData) { - var oData = {}, i, j; - for (i = 0, j = oMDProps.length; i < j; i++) { - oData[oMDProps[i]] = oMDData[i]; - } - _t.metadata = oData; - if (_t._iO.onmetadata) { - _t._iO.onmetadata.apply(_t); - } - }; - this._onid3 = function (oID3Props, oID3Data) { - var oData = [], i, j; - for (i = 0, j = oID3Props.length; i < j; i++) { - oData[oID3Props[i]] = oID3Data[i]; - } - _t.id3 = _mixin(_t.id3, oData); - if (_t._iO.onid3) { - _t._iO.onid3.apply(_t); - } - }; - this._onconnect = function (bSuccess) { - bSuccess = (bSuccess === 1); - _t.connected = bSuccess; - if (bSuccess) { - _t.failures = 0; - if (_idCheck(_t.sID)) { - if (_t.getAutoPlay()) { - _t.play(undefined, _t.getAutoPlay()); - } else if (_t._iO.autoLoad) { - _t.load(); - } - } - if (_t._iO.onconnect) { - _t._iO.onconnect.apply(_t, [bSuccess]); - } - } - }; - this._ondataerror = function (sError) { - if (_t.playState > 0) { - if (_t._iO.ondataerror) { - _t._iO.ondataerror.apply(_t); - } - } - }; - }; - _getDocument = function () { - return (_doc.body || _doc._docElement || _doc.getElementsByTagName('div')[0]); - }; - _id = function (sID) { - return _doc.getElementById(sID); - }; - _mixin = function (oMain, oAdd) { - var o1 = {}, i, o2, o; - for (i in oMain) { - if (oMain.hasOwnProperty(i)) { - o1[i] = oMain[i]; - } - } - o2 = (typeof oAdd === 'undefined' ? _s.defaultOptions : oAdd); - for (o in o2) { - if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') { - o1[o] = o2[o]; - } - } - return o1; - }; - _event = (function () { - var old = (_win.attachEvent), - evt = { - add:(old ? 'attachEvent' : 'addEventListener'), - remove:(old ? 'detachEvent' : 'removeEventListener') - }; - - function getArgs(oArgs) { - var args = _slice.call(oArgs), len = args.length; - if (old) { - args[1] = 'on' + args[1]; - if (len > 3) { - args.pop(); - } - } else if (len === 3) { - args.push(false); - } - return args; - } - - function apply(args, sType) { - var element = args.shift(), - method = [evt[sType]]; - if (old) { - element[method](args[0], args[1]); - } else { - element[method].apply(element, args); - } - } - - function add() { - apply(getArgs(arguments), 'add'); - } - - function remove() { - apply(getArgs(arguments), 'remove'); - } - - return { - 'add':add, - 'remove':remove - }; - }()); - function _html5_event(oFn) { - return function (e) { - var t = this._t; - if (!t || !t._a) { - return null; - } else { - return oFn.call(this, e); - } - }; + } + _tO = _policyFix(_tO, _cs); + oSound = make(); + if (_fV === 8) { + _flash._createSound(_tO.id, _tO.loops||1, _tO.usePolicyFile); + } else { + _flash._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); + if (!_tO.serverURL) { + oSound.connected = true; + if (_tO.onconnect) { + _tO.onconnect.apply(oSound); + } } - - _html5_events = { - abort:_html5_event(function () { - }), - canplay:_html5_event(function () { - var t = this._t, - position1K; - if (t._html5_canplay) { - return true; - } - t._html5_canplay = true; - t._onbufferchange(0); - position1K = (!isNaN(t.position) ? t.position / 1000 : null); - if (t.position && this.currentTime !== position1K) { - try { - this.currentTime = position1K; - } catch (ee) { - } - } - if (t._iO._oncanplay) { - t._iO._oncanplay(); - } - }), - load:_html5_event(function () { - var t = this._t; - if (!t.loaded) { - t._onbufferchange(0); - t._whileloading(t.bytesTotal, t.bytesTotal, t._get_html5_duration()); - t._onload(true); - } - }), - ended:_html5_event(function () { - var t = this._t; - t._onfinish(); - }), - error:_html5_event(function () { - this._t._onload(false); - }), - loadeddata:_html5_event(function () { - var t = this._t, - bytesTotal = t.bytesTotal || 1; - if (!t._loaded && !_isSafari) { - t.duration = t._get_html5_duration(); - t._whileloading(bytesTotal, bytesTotal, t._get_html5_duration()); - t._onload(true); - } - }), - loadedmetadata:_html5_event(function () { - }), - loadstart:_html5_event(function () { - this._t._onbufferchange(1); - }), - play:_html5_event(function () { - this._t._onbufferchange(0); - }), - playing:_html5_event(function () { - this._t._onbufferchange(0); - }), - progress:_html5_event(function (e) { - var t = this._t, - i, j, str, buffered = 0, - isProgress = (e.type === 'progress'), - ranges = e.target.buffered, - loaded = (e.loaded || 0), - total = (e.total || 1); - if (t.loaded) { - return false; - } - if (ranges && ranges.length) { - for (i = ranges.length - 1; i >= 0; i--) { - buffered = (ranges.end(i) - ranges.start(i)); - } - loaded = buffered / e.target.duration; - } - if (!isNaN(loaded)) { - t._onbufferchange(0); - t._whileloading(loaded, total, t._get_html5_duration()); - if (loaded && total && loaded === total) { - _html5_events.load.call(this, e); - } - } - }), - ratechange:_html5_event(function () { - }), - suspend:_html5_event(function (e) { - var t = this._t; - _html5_events.progress.call(this, e); - t._onsuspend(); - }), - stalled:_html5_event(function () { - }), - timeupdate:_html5_event(function () { - this._t._onTimer(); - }), - waiting:_html5_event(function () { - var t = this._t; - t._onbufferchange(1); - }) + } + if (!_tO.serverURL && (_tO.autoLoad || _tO.autoPlay)) { + oSound.load(_tO); + } + } + if (!_tO.serverURL && _tO.autoPlay) { + oSound.play(); + } + return oSound; + }; + this.destroySound = function(sID, _bFromSound) { + if (!_idCheck(sID)) { + return false; + } + var oS = _s.sounds[sID], i; + oS._iO = {}; + oS.stop(); + oS.unload(); + for (i = 0; i < _s.soundIDs.length; i++) { + if (_s.soundIDs[i] === sID) { + _s.soundIDs.splice(i, 1); + break; + } + } + if (!_bFromSound) { + oS.destruct(true); + } + oS = null; + delete _s.sounds[sID]; + return true; + }; + this.load = function(sID, oOptions) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].load(oOptions); + }; + this.unload = function(sID) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].unload(); + }; + this.onPosition = function(sID, nPosition, oMethod, oScope) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].onposition(nPosition, oMethod, oScope); + }; + this.onposition = this.onPosition; + this.clearOnPosition = function(sID, nPosition, oMethod) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].clearOnPosition(nPosition, oMethod); + }; + this.play = function(sID, oOptions) { + var result = false; + if (!_didInit || !_s.ok()) { + _complain(_sm+'.play(): ' + _str(!_didInit?'notReady':'notOK')); + return result; + } + if (!_idCheck(sID)) { + if (!(oOptions instanceof Object)) { + oOptions = { + url: oOptions }; - _html5OK = function (iO) { - return (!iO.serverURL && (iO.type ? _html5CanPlay({type:iO.type}) : _html5CanPlay({url:iO.url}) || _s.html5Only)); - }; - _html5Unload = function (oAudio) { - if (oAudio) { - oAudio.src = (_is_firefox ? '' : _emptyURL); - } - }; - _html5CanPlay = function (o) { - if (!_s.useHTML5Audio || !_s.hasHTML5) { - return false; - } - var url = (o.url || null), - mime = (o.type || null), - aF = _s.audioFormats, - result, - offset, - fileExt, - item; - - function preferFlashCheck(kind) { - return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind])); - } - - if (mime && typeof _s.html5[mime] !== 'undefined') { - return (_s.html5[mime] && !preferFlashCheck(mime)); - } - if (!_html5Ext) { - _html5Ext = []; - for (item in aF) { - if (aF.hasOwnProperty(item)) { - _html5Ext.push(item); - if (aF[item].related) { - _html5Ext = _html5Ext.concat(aF[item].related); - } - } - } - _html5Ext = new RegExp('\\.(' + _html5Ext.join('|') + ')(\\?.*)?$', 'i'); - } - fileExt = (url ? url.toLowerCase().match(_html5Ext) : null); - if (!fileExt || !fileExt.length) { - if (!mime) { - return false; - } else { - offset = mime.indexOf(';'); - fileExt = (offset !== -1 ? mime.substr(0, offset) : mime).substr(6); - } - } else { - fileExt = fileExt[1]; - } - if (fileExt && typeof _s.html5[fileExt] !== 'undefined') { - return (_s.html5[fileExt] && !preferFlashCheck(fileExt)); - } else { - mime = 'audio/' + fileExt; - result = _s.html5.canPlayType({type:mime}); - _s.html5[fileExt] = result; - return (result && _s.html5[mime] && !preferFlashCheck(mime)); - } - }; - _testHTML5 = function () { - if (!_s.useHTML5Audio || typeof Audio === 'undefined') { - return false; - } - var a = (typeof Audio !== 'undefined' ? (_isOpera ? new Audio(null) : new Audio()) : null), - item, support = {}, aF, i; - - function _cp(m) { - var canPlay, i, j, isOK = false; - if (!a || typeof a.canPlayType !== 'function') { - return false; - } - if (m instanceof Array) { - for (i = 0, j = m.length; i < j && !isOK; i++) { - if (_s.html5[m[i]] || a.canPlayType(m[i]).match(_s.html5Test)) { - isOK = true; - _s.html5[m[i]] = true; - _s.flash[m[i]] = !!(_s.preferFlash && _hasFlash && m[i].match(_flashMIME)); - } - } - return isOK; - } else { - canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false); - return !!(canPlay && (canPlay.match(_s.html5Test))); - } - } - - aF = _s.audioFormats; - for (item in aF) { - if (aF.hasOwnProperty(item)) { - support[item] = _cp(aF[item].type); - support['audio/' + item] = support[item]; - if (_s.preferFlash && !_s.ignoreFlash && item.match(_flashMIME)) { - _s.flash[item] = true; - } else { - _s.flash[item] = false; - } - if (aF[item] && aF[item].related) { - for (i = aF[item].related.length - 1; i >= 0; i--) { - support['audio/' + aF[item].related[i]] = support[item]; - _s.html5[aF[item].related[i]] = support[item]; - _s.flash[aF[item].related[i]] = support[item]; - } - } - } - } - support.canPlayType = (a ? _cp : null); - _s.html5 = _mixin(_s.html5, support); - return true; - }; - _strings = { - }; - _str = function () { - }; - _loopFix = function (sOpt) { - if (_fV === 8 && sOpt.loops > 1 && sOpt.stream) { - sOpt.stream = false; - } - return sOpt; - }; - _policyFix = function (sOpt, sPre) { - if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) { - sOpt.usePolicyFile = true; - } - return sOpt; - }; - _complain = function (sMsg) { - }; - _doNothing = function () { - return false; - }; - _disableObject = function (o) { - var oProp; - for (oProp in o) { - if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') { - o[oProp] = _doNothing; - } - } - oProp = null; - }; - _failSafely = function (bNoDisable) { - if (typeof bNoDisable === 'undefined') { - bNoDisable = false; - } - if (_disabled || bNoDisable) { - _s.disable(bNoDisable); - } - }; - _normalizeMovieURL = function (smURL) { - var urlParams = null, url; - if (smURL) { - if (smURL.match(/\.swf(\?.*)?$/i)) { - urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4); - if (urlParams) { - return smURL; - } - } else if (smURL.lastIndexOf('/') !== smURL.length - 1) { - smURL += '/'; - } - } - url = (smURL && smURL.lastIndexOf('/') !== -1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + _s.movieURL; - if (_s.noSWFCache) { - url += ('?ts=' + new Date().getTime()); - } - return url; - }; - _setVersionInfo = function () { - _fV = parseInt(_s.flashVersion, 10); - if (_fV !== 8 && _fV !== 9) { - _s.flashVersion = _fV = _defaultFlashVersion; - } - var isDebug = (_s.debugMode || _s.debugFlash ? '_debug.swf' : '.swf'); - if (_s.useHTML5Audio && !_s.html5Only && _s.audioFormats.mp4.required && _fV < 9) { - _s.flashVersion = _fV = 9; - } - _s.version = _s.versionNumber + (_s.html5Only ? ' (HTML5-only mode)' : (_fV === 9 ? ' (AS3/Flash 9)' : ' (AS2/Flash 8)')); - if (_fV > 8) { - _s.defaultOptions = _mixin(_s.defaultOptions, _s.flash9Options); - _s.features.buffering = true; - _s.defaultOptions = _mixin(_s.defaultOptions, _s.movieStarOptions); - _s.filePatterns.flash9 = new RegExp('\\.(mp3|' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); - _s.features.movieStar = true; - } else { - _s.features.movieStar = false; - } - _s.filePattern = _s.filePatterns[(_fV !== 8 ? 'flash9' : 'flash8')]; - _s.movieURL = (_fV === 8 ? 'soundmanager2.swf' : 'soundmanager2_flash9.swf').replace('.swf', isDebug); - _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_fV > 8); - }; - _setPolling = function (bPolling, bHighPerformance) { - if (!_flash) { - return false; - } - _flash._setPolling(bPolling, bHighPerformance); - }; - _initDebug = function () { - if (_s.debugURLParam.test(_wl)) { - _s.debugMode = true; - } - }; - _idCheck = this.getSoundById; - _getSWFCSS = function () { - var css = []; - if (_s.debugMode) { - css.push(_swfCSS.sm2Debug); - } - if (_s.debugFlash) { - css.push(_swfCSS.flashDebug); - } - if (_s.useHighPerformance) { - css.push(_swfCSS.highPerf); - } - return css.join(' '); - }; - _flashBlockHandler = function () { - var name = _str('fbHandler'), - p = _s.getMoviePercent(), - css = _swfCSS, - error = {type:'FLASHBLOCK'}; - if (_s.html5Only) { - return false; - } - if (!_s.ok()) { - if (_needsFlash) { - _s.oMC.className = _getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null ? css.swfTimedout : css.swfError); - } - _s.didFlashBlock = true; - _processOnEvents({type:'ontimeout', ignoreInit:true, error:error}); - _catchError(error); - } else { - if (_s.oMC) { - _s.oMC.className = [_getSWFCSS(), css.swfDefault, css.swfLoaded + (_s.didFlashBlock ? ' ' + css.swfUnblocked : '')].join(' '); - } - } - }; - _addOnEvent = function (sType, oMethod, oScope) { - if (typeof _on_queue[sType] === 'undefined') { - _on_queue[sType] = []; - } - _on_queue[sType].push({ - 'method':oMethod, - 'scope':(oScope || null), - 'fired':false - }); - }; - _processOnEvents = function (oOptions) { - if (!oOptions) { - oOptions = { - type:'onready' - }; - } - if (!_didInit && oOptions && !oOptions.ignoreInit) { - return false; - } - if (oOptions.type === 'ontimeout' && _s.ok()) { - return false; - } - var status = { - success:(oOptions && oOptions.ignoreInit ? _s.ok() : !_disabled) - }, - srcQueue = (oOptions && oOptions.type ? _on_queue[oOptions.type] || [] : []), - queue = [], i, j, - args = [status], - canRetry = (_needsFlash && _s.useFlashBlock && !_s.ok()); - if (oOptions.error) { - args[0].error = oOptions.error; - } - for (i = 0, j = srcQueue.length; i < j; i++) { - if (srcQueue[i].fired !== true) { - queue.push(srcQueue[i]); - } - } - if (queue.length) { - for (i = 0, j = queue.length; i < j; i++) { - if (queue[i].scope) { - queue[i].method.apply(queue[i].scope, args); - } else { - queue[i].method.apply(this, args); - } - if (!canRetry) { - queue[i].fired = true; - } - } - } - return true; - }; - _initUserOnload = function () { - _win.setTimeout(function () { - if (_s.useFlashBlock) { - _flashBlockHandler(); - } - _processOnEvents(); - if (_s.onload instanceof Function) { - _s.onload.apply(_win); - } - if (_s.waitForWindowLoad) { - _event.add(_win, 'load', _initUserOnload); - } - }, 1); - }; - _detectFlash = function () { - if (_hasFlash !== undefined) { - return _hasFlash; - } - var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = _win.ActiveXObject; - if (nP && nP.length) { - type = 'application/x-shockwave-flash'; - types = n.mimeTypes; - if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) { - hasPlugin = true; - } - } else if (typeof AX !== 'undefined') { - try { - obj = new AX('ShockwaveFlash.ShockwaveFlash'); - } catch (e) { - } - hasPlugin = (!!obj); - } - _hasFlash = hasPlugin; - return hasPlugin; - }; - _featureCheck = function () { - var needsFlash, item, - isSpecial = (_is_iDevice && !!(_ua.match(/os (1|2|3_0|3_1)/i))); - if (isSpecial) { - _s.hasHTML5 = false; - _s.html5Only = true; - if (_s.oMC) { - _s.oMC.style.display = 'none'; - } - return false; - } - if (_s.useHTML5Audio) { - if (!_s.html5 || !_s.html5.canPlayType) { - _s.hasHTML5 = false; - return true; - } else { - _s.hasHTML5 = true; - } - if (_isBadSafari) { - if (_detectFlash()) { - return true; - } - } - } else { - return true; - } - for (item in _s.audioFormats) { - if (_s.audioFormats.hasOwnProperty(item)) { - if ((_s.audioFormats[item].required && !_s.html5.canPlayType(_s.audioFormats[item].type)) || _s.flash[item] || _s.flash[_s.audioFormats[item].type]) { - needsFlash = true; - } - } - } - if (_s.ignoreFlash) { - needsFlash = false; - } - _s.html5Only = (_s.hasHTML5 && _s.useHTML5Audio && !needsFlash); - return (!_s.html5Only); - }; - _parseURL = function (url) { - var i, j, result = 0; - if (url instanceof Array) { - for (i = 0, j = url.length; i < j; i++) { - if (url[i] instanceof Object) { - if (_s.canPlayMIME(url[i].type)) { - result = i; - break; - } - } else if (_s.canPlayURL(url[i])) { - result = i; - break; - } - } - if (url[result].url) { - url[result] = url[result].url; - } - return url[result]; - } else { - return url; - } - }; - _startTimer = function (oSound) { - if (!oSound._hasTimer) { - oSound._hasTimer = true; - if (!_likesHTML5 && _s.html5PollingInterval) { - if (_h5IntervalTimer === null && _h5TimerCount === 0) { - _h5IntervalTimer = window.setInterval(_timerExecute, _s.html5PollingInterval); - } - _h5TimerCount++; - } - } - }; - _stopTimer = function (oSound) { - if (oSound._hasTimer) { - oSound._hasTimer = false; - if (!_likesHTML5 && _s.html5PollingInterval) { - _h5TimerCount--; - } - } - }; - _timerExecute = function () { - var i; - if (_h5IntervalTimer !== null && !_h5TimerCount) { - window.clearInterval(_h5IntervalTimer); - _h5IntervalTimer = null; - return false; - } - for (i = _s.soundIDs.length - 1; i >= 0; i--) { - if (_s.sounds[_s.soundIDs[i]].isHTML5 && _s.sounds[_s.soundIDs[i]]._hasTimer) { - _s.sounds[_s.soundIDs[i]]._onTimer(); - } - } - }; - _catchError = function (options) { - options = (typeof options !== 'undefined' ? options : {}); - if (_s.onerror instanceof Function) { - _s.onerror.apply(_win, [ - {type:(typeof options.type !== 'undefined' ? options.type : null)} - ]); - } - if (typeof options.fatal !== 'undefined' && options.fatal) { - _s.disable(); - } - }; - _badSafariFix = function () { - if (!_isBadSafari || !_detectFlash()) { - return false; - } - var aF = _s.audioFormats, i, item; - for (item in aF) { - if (aF.hasOwnProperty(item)) { - if (item === 'mp3' || item === 'mp4') { - _s.html5[item] = false; - if (aF[item] && aF[item].related) { - for (i = aF[item].related.length - 1; i >= 0; i--) { - _s.html5[aF[item].related[i]] = false; - } - } - } - } - } - }; - this._setSandboxType = function (sandboxType) { - }; - this._externalInterfaceOK = function (flashDate, swfVersion) { - if (_s.swfLoaded) { - return false; - } - var e, eiTime = new Date().getTime(); - _s.swfLoaded = true; - _tryInitOnFocus = false; - if (_isBadSafari) { - _badSafariFix(); - } - if (_isIE) { - setTimeout(_init, 100); - } else { - _init(); - } - }; - _createMovie = function (smID, smURL) { - if (_didAppend && _appendSuccess) { - return false; - } - function _initMsg() { - } - - if (_s.html5Only) { - _setVersionInfo(); - _initMsg(); - _s.oMC = _id(_s.movieID); - _init(); - _didAppend = true; - _appendSuccess = true; - return false; - } - var remoteURL = (smURL || _s.url), - localURL = (_s.altURL || remoteURL), - swfTitle = 'JS/Flash audio component (SoundManager 2)', - oEmbed, oMovie, oTarget = _getDocument(), tmp, movieHTML, oEl, extraClass = _getSWFCSS(), - s, x, sClass, side = null, isRTL = null, - html = _doc.getElementsByTagName('html')[0]; - isRTL = (html && html.dir && html.dir.match(/rtl/i)); - smID = (typeof smID === 'undefined' ? _s.id : smID); - function param(name, value) { - return ''; - } - - _setVersionInfo(); - _s.url = _normalizeMovieURL(_overHTTP ? remoteURL : localURL); - smURL = _s.url; - _s.wmode = (!_s.wmode && _s.useHighPerformance ? 'transparent' : _s.wmode); - if (_s.wmode !== null && (_ua.match(/msie 8/i) || (!_isIE && !_s.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) { - _s.wmode = null; - } - oEmbed = { - 'name':smID, - 'id':smID, - 'src':smURL, - 'quality':'high', - 'allowScriptAccess':_s.allowScriptAccess, - 'bgcolor':_s.bgColor, - 'pluginspage':_http + 'www.macromedia.com/go/getflashplayer', - 'title':swfTitle, - 'type':'application/x-shockwave-flash', - 'wmode':_s.wmode, - 'hasPriority':'true' - }; - if (side !== null) { - oEmbed.width = side; - oEmbed.height = side; - } - if (_s.debugFlash) { - oEmbed.FlashVars = 'debug=1'; - } - if (!_s.wmode) { - delete oEmbed.wmode; - } - if (_isIE) { - oMovie = _doc.createElement('div'); - movieHTML = [ - '', - param('movie', smURL), - param('AllowScriptAccess', _s.allowScriptAccess), - param('quality', oEmbed.quality), - (_s.wmode ? param('wmode', _s.wmode) : ''), - param('bgcolor', _s.bgColor), - param('hasPriority', 'true'), - (_s.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''), - '' - ].join(''); - } else { - oMovie = _doc.createElement('embed'); - for (tmp in oEmbed) { - if (oEmbed.hasOwnProperty(tmp)) { - oMovie.setAttribute(tmp, oEmbed[tmp]); - } - } - } - _initDebug(); - extraClass = _getSWFCSS(); - oTarget = _getDocument(); - if (oTarget) { - _s.oMC = (_id(_s.movieID) || _doc.createElement('div')); - if (!_s.oMC.id) { - _s.oMC.id = _s.movieID; - _s.oMC.className = _swfCSS.swfDefault + ' ' + extraClass; - s = null; - oEl = null; - if (!_s.useFlashBlock) { - if (_s.useHighPerformance) { - s = { - 'position':'fixed', - 'width':'8px', - 'height':'8px', - 'bottom':'0px', - 'left':'0px', - 'overflow':'hidden' - }; - } else { - s = { - 'position':'absolute', - 'width':'6px', - 'height':'6px', - 'top':'-9999px', - 'left':'-9999px' - }; - if (isRTL) { - s.left = Math.abs(parseInt(s.left, 10)) + 'px'; - } - } - } - if (_isWebkit) { - _s.oMC.style.zIndex = 10000; - } - if (!_s.debugFlash) { - for (x in s) { - if (s.hasOwnProperty(x)) { - _s.oMC.style[x] = s[x]; - } - } - } - try { - if (!_isIE) { - _s.oMC.appendChild(oMovie); - } - oTarget.appendChild(_s.oMC); - if (_isIE) { - oEl = _s.oMC.appendChild(_doc.createElement('div')); - oEl.className = _swfCSS.swfBox; - oEl.innerHTML = movieHTML; - } - _appendSuccess = true; - } catch (e) { - throw new Error(_str('domError') + ' \n' + e.toString()); - } - } else { - sClass = _s.oMC.className; - _s.oMC.className = (sClass ? sClass + ' ' : _swfCSS.swfDefault) + (extraClass ? ' ' + extraClass : ''); - _s.oMC.appendChild(oMovie); - if (_isIE) { - oEl = _s.oMC.appendChild(_doc.createElement('div')); - oEl.className = _swfCSS.swfBox; - oEl.innerHTML = movieHTML; - } - _appendSuccess = true; - } - } - _didAppend = true; - _initMsg(); - return true; - }; - _initMovie = function () { - if (_s.html5Only) { - _createMovie(); - return false; - } - if (_flash) { - return false; - } - _flash = _s.getMovie(_s.id); - if (!_flash) { - if (!_oRemoved) { - _createMovie(_s.id, _s.url); - } else { - if (!_isIE) { - _s.oMC.appendChild(_oRemoved); - } else { - _s.oMC.innerHTML = _oRemovedHTML; - } - _oRemoved = null; - _didAppend = true; - } - _flash = _s.getMovie(_s.id); - } - if (_s.oninitmovie instanceof Function) { - setTimeout(_s.oninitmovie, 1); - } - return true; - }; - _delayWaitForEI = function () { - setTimeout(_waitForEI, 1000); - }; - _waitForEI = function () { - if (_waitingForEI) { - return false; - } - _waitingForEI = true; - _event.remove(_win, 'load', _delayWaitForEI); - if (_tryInitOnFocus && !_isFocused) { - return false; - } - var p; - if (!_didInit) { - p = _s.getMoviePercent(); - } - setTimeout(function () { - p = _s.getMoviePercent(); - if (!_didInit && _okToDisable) { - if (p === null) { - if (_s.useFlashBlock || _s.flashLoadTimeout === 0) { - if (_s.useFlashBlock) { - _flashBlockHandler(); - } - } else { - _failSafely(true); - } - } else { - if (_s.flashLoadTimeout === 0) { - } else { - _failSafely(true); - } - } - } - }, _s.flashLoadTimeout); - }; - _handleFocus = function () { - function cleanup() { - _event.remove(_win, 'focus', _handleFocus); - _event.remove(_win, 'load', _handleFocus); - } - - if (_isFocused || !_tryInitOnFocus) { - cleanup(); - return true; - } - _okToDisable = true; - _isFocused = true; - if (_isSafari && _tryInitOnFocus) { - _event.remove(_win, 'mousemove', _handleFocus); - } - _waitingForEI = false; - cleanup(); - return true; - }; - _showSupport = function () { - var item, tests = []; - if (_s.useHTML5Audio && _s.hasHTML5) { - for (item in _s.audioFormats) { - if (_s.audioFormats.hasOwnProperty(item)) { - 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)' : '')))); - } - } - } - }; - _initComplete = function (bNoDisable) { - if (_didInit) { - return false; - } - if (_s.html5Only) { - _didInit = true; - _initUserOnload(); - return true; - } - var wasTimeout = (_s.useFlashBlock && _s.flashLoadTimeout && !_s.getMoviePercent()), - error; - if (!wasTimeout) { - _didInit = true; - if (_disabled) { - error = {type:(!_hasFlash && _needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')}; - } - } - if (_disabled || bNoDisable) { - if (_s.useFlashBlock && _s.oMC) { - _s.oMC.className = _getSWFCSS() + ' ' + (_s.getMoviePercent() === null ? _swfCSS.swfTimedout : _swfCSS.swfError); - } - _processOnEvents({type:'ontimeout', error:error}); - _catchError(error); - return false; - } else { - } - if (_s.waitForWindowLoad && !_windowLoaded) { - _event.add(_win, 'load', _initUserOnload); - return false; - } else { - _initUserOnload(); - } - return true; - }; - _init = function () { - if (_didInit) { - return false; - } - function _cleanup() { - _event.remove(_win, 'load', _s.beginDelayedInit); - } - - if (_s.html5Only) { - if (!_didInit) { - _cleanup(); - _s.enabled = true; - _initComplete(); - } - return true; - } - _initMovie(); - try { - _flash._externalInterfaceTest(false); - _setPolling(true, (_s.flashPollingInterval || (_s.useHighPerformance ? 10 : 50))); - if (!_s.debugMode) { - _flash._disableDebug(); - } - _s.enabled = true; - if (!_s.html5Only) { - _event.add(_win, 'unload', _doNothing); - } - } catch (e) { - _catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true}); - _failSafely(true); - _initComplete(); - return false; - } - _initComplete(); - _cleanup(); - return true; - }; - _domContentLoaded = function () { - if (_didDCLoaded) { - return false; - } - _didDCLoaded = true; - _initDebug(); - if (!_hasFlash && _s.hasHTML5) { - _s.useHTML5Audio = true; - _s.preferFlash = false; - } - _testHTML5(); - _s.html5.usingFlash = _featureCheck(); - _needsFlash = _s.html5.usingFlash; - _showSupport(); - if (!_hasFlash && _needsFlash) { - _s.flashLoadTimeout = 1; - } - if (_doc.removeEventListener) { - _doc.removeEventListener('DOMContentLoaded', _domContentLoaded, false); - } - _initMovie(); - return true; - }; - _domContentLoadedIE = function () { - if (_doc.readyState === 'complete') { - _domContentLoaded(); - _doc.detachEvent('onreadystatechange', _domContentLoadedIE); - } - return true; - }; - _winOnLoad = function () { - _windowLoaded = true; - _event.remove(_win, 'load', _winOnLoad); - }; - _detectFlash(); - _event.add(_win, 'focus', _handleFocus); - _event.add(_win, 'load', _handleFocus); - _event.add(_win, 'load', _delayWaitForEI); - _event.add(_win, 'load', _winOnLoad); - if (_isSafari && _tryInitOnFocus) { - _event.add(_win, 'mousemove', _handleFocus); + } + if (oOptions && oOptions.url) { + oOptions.id = sID; + result = _s.createSound(oOptions).play(); + } + return result; + } + return _s.sounds[sID].play(oOptions); + }; + this.start = this.play; + this.setPosition = function(sID, nMsecOffset) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].setPosition(nMsecOffset); + }; + this.stop = function(sID) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].stop(); + }; + this.stopAll = function() { + var oSound; + for (oSound in _s.sounds) { + if (_s.sounds.hasOwnProperty(oSound)) { + _s.sounds[oSound].stop(); + } + } + }; + this.pause = function(sID) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].pause(); + }; + this.pauseAll = function() { + var i; + for (i = _s.soundIDs.length-1; i >= 0; i--) { + _s.sounds[_s.soundIDs[i]].pause(); + } + }; + this.resume = function(sID) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].resume(); + }; + this.resumeAll = function() { + var i; + for (i = _s.soundIDs.length-1; i >= 0; i--) { + _s.sounds[_s.soundIDs[i]].resume(); + } + }; + this.togglePause = function(sID) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].togglePause(); + }; + this.setPan = function(sID, nPan) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].setPan(nPan); + }; + this.setVolume = function(sID, nVol) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].setVolume(nVol); + }; + this.mute = function(sID) { + var i = 0; + if (typeof sID !== 'string') { + sID = null; + } + if (!sID) { + for (i = _s.soundIDs.length-1; i >= 0; i--) { + _s.sounds[_s.soundIDs[i]].mute(); + } + _s.muted = true; + } else { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].mute(); + } + return true; + }; + this.muteAll = function() { + _s.mute(); + }; + this.unmute = function(sID) { + var i; + if (typeof sID !== 'string') { + sID = null; + } + if (!sID) { + for (i = _s.soundIDs.length-1; i >= 0; i--) { + _s.sounds[_s.soundIDs[i]].unmute(); + } + _s.muted = false; + } else { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].unmute(); + } + return true; + }; + this.unmuteAll = function() { + _s.unmute(); + }; + this.toggleMute = function(sID) { + if (!_idCheck(sID)) { + return false; + } + return _s.sounds[sID].toggleMute(); + }; + this.getMemoryUse = function() { + var ram = 0; + if (_flash && _fV !== 8) { + ram = parseInt(_flash._getMemoryUse(), 10); + } + return ram; + }; + this.disable = function(bNoDisable) { + var i; + if (typeof bNoDisable === 'undefined') { + bNoDisable = false; + } + if (_disabled) { + return false; + } + _disabled = true; + for (i = _s.soundIDs.length-1; i >= 0; i--) { + _disableObject(_s.sounds[_s.soundIDs[i]]); + } + _initComplete(bNoDisable); + _event.remove(_win, 'load', _initUserOnload); + return true; + }; + this.canPlayMIME = function(sMIME) { + var result; + if (_s.hasHTML5) { + result = _html5CanPlay({type:sMIME}); + } + if (!result && _needsFlash) { + result = (sMIME && _s.ok() ? !!((_fV > 8 ? sMIME.match(_netStreamMimeTypes) : null) || sMIME.match(_s.mimePattern)) : null); + } + return result; + }; + this.canPlayURL = function(sURL) { + var result; + if (_s.hasHTML5) { + result = _html5CanPlay({url: sURL}); + } + if (!result && _needsFlash) { + result = (sURL && _s.ok() ? !!(sURL.match(_s.filePattern)) : null); + } + return result; + }; + this.canPlayLink = function(oLink) { + if (typeof oLink.type !== 'undefined' && oLink.type) { + if (_s.canPlayMIME(oLink.type)) { + return true; + } + } + return _s.canPlayURL(oLink.href); + }; + this.getSoundById = function(sID, _suppressDebug) { + if (!sID) { + throw new Error(_sm+'.getSoundById(): sID is null/undefined'); + } + var result = _s.sounds[sID]; + return result; + }; + this.onready = function(oMethod, oScope) { + var sType = 'onready', + result = false; + if (typeof oMethod === 'function') { + if (!oScope) { + oScope = _win; + } + _addOnEvent(sType, oMethod, oScope); + _processOnEvents(); + result = true; + } else { + throw _str('needFunction', sType); + } + return result; + }; + this.ontimeout = function(oMethod, oScope) { + var sType = 'ontimeout', + result = false; + if (typeof oMethod === 'function') { + if (!oScope) { + oScope = _win; + } + _addOnEvent(sType, oMethod, oScope); + _processOnEvents({type:sType}); + result = true; + } else { + throw _str('needFunction', sType); + } + return result; + }; + this._writeDebug = function(sText, sType, _bTimestamp) { + return true; + }; + this._wD = this._writeDebug; + this._debug = function() { + }; + this.reboot = function() { + var i, j; + for (i = _s.soundIDs.length-1; i >= 0; i--) { + _s.sounds[_s.soundIDs[i]].destruct(); + } + if (_flash) { + try { + if (_isIE) { + _oRemovedHTML = _flash.innerHTML; } - if (_doc.addEventListener) { - _doc.addEventListener('DOMContentLoaded', _domContentLoaded, false); - } else if (_doc.attachEvent) { - _doc.attachEvent('onreadystatechange', _domContentLoadedIE); + _oRemoved = _flash.parentNode.removeChild(_flash); + } catch(e) { + } + } + _oRemovedHTML = _oRemoved = _needsFlash = null; + _s.enabled = _didDCLoaded = _didInit = _waitingForEI = _initPending = _didAppend = _appendSuccess = _disabled = _s.swfLoaded = false; + _s.soundIDs = []; + _s.sounds = {}; + _flash = null; + for (i in _on_queue) { + if (_on_queue.hasOwnProperty(i)) { + for (j = _on_queue[i].length-1; j >= 0; j--) { + _on_queue[i][j].fired = false; + } + } + } + _win.setTimeout(_s.beginDelayedInit, 20); + }; + this.getMoviePercent = function() { + return (_flash && typeof _flash.PercentLoaded !== 'undefined' ? _flash.PercentLoaded() : null); + }; + this.beginDelayedInit = function() { + _windowLoaded = true; + _domContentLoaded(); + setTimeout(function() { + if (_initPending) { + return false; + } + _createMovie(); + _initMovie(); + _initPending = true; + return true; + }, 20); + _delayWaitForEI(); + }; + this.destruct = function() { + _s.disable(true); + }; + SMSound = function(oOptions) { + var _t = this, _resetProperties, _add_html5_events, _remove_html5_events, _stop_html5_timer, _start_html5_timer, _attachOnPosition, _onplay_called = false, _onPositionItems = [], _onPositionFired = 0, _detachOnPosition, _applyFromTo, _lastURL = null, _lastHTML5State; + _lastHTML5State = { + duration: null, + time: null + }; + this.id = oOptions.id; + this.sID = this.id; + this.url = oOptions.url; + this.options = _mixin(oOptions); + this.instanceOptions = this.options; + this._iO = this.instanceOptions; + this.pan = this.options.pan; + this.volume = this.options.volume; + this.isHTML5 = false; + this._a = null; + this.id3 = {}; + this._debug = function() { + }; + this.load = function(oOptions) { + var oS = null, _iO; + if (typeof oOptions !== 'undefined') { + _t._iO = _mixin(oOptions, _t.options); + _t.instanceOptions = _t._iO; + } else { + oOptions = _t.options; + _t._iO = oOptions; + _t.instanceOptions = _t._iO; + if (_lastURL && _lastURL !== _t.url) { + _t._iO.url = _t.url; + _t.url = null; + } + } + if (!_t._iO.url) { + _t._iO.url = _t.url; + } + _t._iO.url = _parseURL(_t._iO.url); + if (_t._iO.url === _t.url && _t.readyState !== 0 && _t.readyState !== 2) { + if (_t.readyState === 3 && _t._iO.onload) { + _t._iO.onload.apply(_t, [(!!_t.duration)]); + } + return _t; + } + _iO = _t._iO; + _lastURL = _t.url; + _t.loaded = false; + _t.readyState = 1; + _t.playState = 0; + _t.id3 = {}; + if (_html5OK(_iO)) { + oS = _t._setup_html5(_iO); + if (!oS._called_load) { + _t._html5_canplay = false; + if (_t._a.src !== _iO.url) { + _t._a.src = _iO.url; + _t.setPosition(0); + } + _t._a.autobuffer = 'auto'; + _t._a.preload = 'auto'; + oS._called_load = true; + if (_iO.autoPlay) { + _t.play(); + } } else { - _catchError({type:'NO_DOM2_EVENTS', fatal:true}); } - if (_doc.readyState === 'complete') { - setTimeout(_domContentLoaded, 100); + } else { + try { + _t.isHTML5 = false; + _t._iO = _policyFix(_loopFix(_iO)); + _iO = _t._iO; + if (_fV === 8) { + _flash._load(_t.id, _iO.url, _iO.stream, _iO.autoPlay, (_iO.whileloading?1:0), _iO.loops||1, _iO.usePolicyFile); + } else { + _flash._load(_t.id, _iO.url, !!(_iO.stream), !!(_iO.autoPlay), _iO.loops||1, !!(_iO.autoLoad), _iO.usePolicyFile); + } + } catch(e) { + _catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true}); } + } + return _t; + }; + this.unload = function() { + if (_t.readyState !== 0) { + if (!_t.isHTML5) { + if (_fV === 8) { + _flash._unload(_t.id, _emptyURL); + } else { + _flash._unload(_t.id); + } + } else { + _stop_html5_timer(); + if (_t._a) { + _t._a.pause(); + _html5Unload(_t._a, _emptyURL); + _t.url = _emptyURL; + } + } + _resetProperties(); + } + return _t; + }; + this.destruct = function(_bFromSM) { + if (!_t.isHTML5) { + _t._iO.onfailure = null; + _flash._destroySound(_t.id); + } else { + _stop_html5_timer(); + if (_t._a) { + _t._a.pause(); + _html5Unload(_t._a); + if (!_useGlobalHTML5Audio) { + _remove_html5_events(); + } + _t._a._t = null; + _t._a = null; + } + } + if (!_bFromSM) { + _s.destroySound(_t.id, true); + } + }; + this.play = function(oOptions, _updatePlayState) { + var fN, allowMulti, a, onready, startOK = true, + exit = null; + _updatePlayState = (typeof _updatePlayState === 'undefined' ? true : _updatePlayState); + if (!oOptions) { + oOptions = {}; + } + _t._iO = _mixin(oOptions, _t._iO); + _t._iO = _mixin(_t._iO, _t.options); + _t._iO.url = _parseURL(_t._iO.url); + _t.instanceOptions = _t._iO; + if (_t._iO.serverURL && !_t.connected) { + if (!_t.getAutoPlay()) { + _t.setAutoPlay(true); + } + return _t; + } + if (_html5OK(_t._iO)) { + _t._setup_html5(_t._iO); + _start_html5_timer(); + } + if (_t.playState === 1 && !_t.paused) { + allowMulti = _t._iO.multiShot; + if (!allowMulti) { + exit = _t; + } else { + } + } + if (exit !== null) { + return exit; + } + if (!_t.loaded) { + if (_t.readyState === 0) { + if (!_t.isHTML5) { + _t._iO.autoPlay = true; + _t.load(_t._iO); + } else { + _t.load(_t._iO); + } + } else if (_t.readyState === 2) { + exit = _t; + } else { + } + } else { + } + if (exit !== null) { + return exit; + } + if (!_t.isHTML5 && _fV === 9 && _t.position > 0 && _t.position === _t.duration) { + oOptions.position = 0; + } + if (_t.paused && _t.position && _t.position > 0) { + _t.resume(); + } else { + _t._iO = _mixin(oOptions, _t._iO); + if (_t._iO.from !== null && _t._iO.to !== null && _t.instanceCount === 0 && _t.playState === 0 && !_t._iO.serverURL) { + onready = function() { + _t._iO = _mixin(oOptions, _t._iO); + _t.play(_t._iO); + }; + if (_t.isHTML5 && !_t._html5_canplay) { + _t.load({ + _oncanplay: onready + }); + exit = false; + } else if (!_t.isHTML5 && !_t.loaded && (!_t.readyState || _t.readyState !== 2)) { + _t.load({ + onload: onready + }); + exit = false; + } + if (exit !== null) { + return exit; + } + _t._iO = _applyFromTo(); + } + if (!_t.instanceCount || _t._iO.multiShotEvents || (!_t.isHTML5 && _fV > 8 && !_t.getAutoPlay())) { + _t.instanceCount++; + } + if (_t._iO.onposition && _t.playState === 0) { + _attachOnPosition(_t); + } + _t.playState = 1; + _t.paused = false; + _t.position = (typeof _t._iO.position !== 'undefined' && !isNaN(_t._iO.position) ? _t._iO.position : 0); + if (!_t.isHTML5) { + _t._iO = _policyFix(_loopFix(_t._iO)); + } + if (_t._iO.onplay && _updatePlayState) { + _t._iO.onplay.apply(_t); + _onplay_called = true; + } + _t.setVolume(_t._iO.volume, true); + _t.setPan(_t._iO.pan, true); + if (!_t.isHTML5) { + startOK = _flash._start(_t.id, _t._iO.loops || 1, (_fV === 9 ? _t._iO.position : _t._iO.position / 1000), _t._iO.multiShot); + if (_fV === 9 && !startOK) { + if (_t._iO.onplayerror) { + _t._iO.onplayerror.apply(_t); + } + } + } else { + _start_html5_timer(); + a = _t._setup_html5(); + _t.setPosition(_t._iO.position); + a.play(); + } + } + return _t; + }; + this.start = this.play; + this.stop = function(bAll) { + var _iO = _t._iO, _oP; + if (_t.playState === 1) { + _t._onbufferchange(0); + _t._resetOnPosition(0); + _t.paused = false; + if (!_t.isHTML5) { + _t.playState = 0; + } + _detachOnPosition(); + if (_iO.to) { + _t.clearOnPosition(_iO.to); + } + if (!_t.isHTML5) { + _flash._stop(_t.id, bAll); + if (_iO.serverURL) { + _t.unload(); + } + } else { + if (_t._a) { + _oP = _t.position; + _t.setPosition(0); + _t.position = _oP; + _t._a.pause(); + _t.playState = 0; + _t._onTimer(); + _stop_html5_timer(); + } + } + _t.instanceCount = 0; + _t._iO = {}; + if (_iO.onstop) { + _iO.onstop.apply(_t); + } + } + return _t; + }; + this.setAutoPlay = function(autoPlay) { + _t._iO.autoPlay = autoPlay; + if (!_t.isHTML5) { + _flash._setAutoPlay(_t.id, autoPlay); + if (autoPlay) { + if (!_t.instanceCount && _t.readyState === 1) { + _t.instanceCount++; + } + } + } + }; + this.getAutoPlay = function() { + return _t._iO.autoPlay; + }; + this.setPosition = function(nMsecOffset) { + if (typeof nMsecOffset === 'undefined') { + nMsecOffset = 0; + } + var original_pos, + position, position1K, + offset = (_t.isHTML5 ? Math.max(nMsecOffset,0) : Math.min(_t.duration || _t._iO.duration, Math.max(nMsecOffset, 0))); + original_pos = _t.position; + _t.position = offset; + position1K = _t.position/1000; + _t._resetOnPosition(_t.position); + _t._iO.position = offset; + if (!_t.isHTML5) { + position = (_fV === 9 ? _t.position : position1K); + if (_t.readyState && _t.readyState !== 2) { + _flash._setPosition(_t.id, position, (_t.paused || !_t.playState), _t._iO.multiShot); + } + } else if (_t._a) { + if (_t._html5_canplay) { + if (_t._a.currentTime !== position1K) { + try { + _t._a.currentTime = position1K; + if (_t.playState === 0 || _t.paused) { + _t._a.pause(); + } + } catch(e) { + } + } + } else { + } + } + if (_t.isHTML5) { + if (_t.paused) { + _t._onTimer(true); + } + } + return _t; + }; + this.pause = function(_bCallFlash) { + if (_t.paused || (_t.playState === 0 && _t.readyState !== 1)) { + return _t; + } + _t.paused = true; + if (!_t.isHTML5) { + if (_bCallFlash || typeof _bCallFlash === 'undefined') { + _flash._pause(_t.id, _t._iO.multiShot); + } + } else { + _t._setup_html5().pause(); + _stop_html5_timer(); + } + if (_t._iO.onpause) { + _t._iO.onpause.apply(_t); + } + return _t; + }; + this.resume = function() { + var _iO = _t._iO; + if (!_t.paused) { + return _t; + } + _t.paused = false; + _t.playState = 1; + if (!_t.isHTML5) { + if (_iO.isMovieStar && !_iO.serverURL) { + _t.setPosition(_t.position); + } + _flash._pause(_t.id, _iO.multiShot); + } else { + _t._setup_html5().play(); + _start_html5_timer(); + } + if (!_onplay_called && _iO.onplay) { + _iO.onplay.apply(_t); + _onplay_called = true; + } else if (_iO.onresume) { + _iO.onresume.apply(_t); + } + return _t; + }; + this.togglePause = function() { + if (_t.playState === 0) { + _t.play({ + position: (_fV === 9 && !_t.isHTML5 ? _t.position : _t.position / 1000) + }); + return _t; + } + if (_t.paused) { + _t.resume(); + } else { + _t.pause(); + } + return _t; + }; + this.setPan = function(nPan, bInstanceOnly) { + if (typeof nPan === 'undefined') { + nPan = 0; + } + if (typeof bInstanceOnly === 'undefined') { + bInstanceOnly = false; + } + if (!_t.isHTML5) { + _flash._setPan(_t.id, nPan); + } + _t._iO.pan = nPan; + if (!bInstanceOnly) { + _t.pan = nPan; + _t.options.pan = nPan; + } + return _t; + }; + this.setVolume = function(nVol, _bInstanceOnly) { + if (typeof nVol === 'undefined') { + nVol = 100; + } + if (typeof _bInstanceOnly === 'undefined') { + _bInstanceOnly = false; + } + if (!_t.isHTML5) { + _flash._setVolume(_t.id, (_s.muted && !_t.muted) || _t.muted?0:nVol); + } else if (_t._a) { + _t._a.volume = Math.max(0, Math.min(1, nVol/100)); + } + _t._iO.volume = nVol; + if (!_bInstanceOnly) { + _t.volume = nVol; + _t.options.volume = nVol; + } + return _t; + }; + this.mute = function() { + _t.muted = true; + if (!_t.isHTML5) { + _flash._setVolume(_t.id, 0); + } else if (_t._a) { + _t._a.muted = true; + } + return _t; + }; + this.unmute = function() { + _t.muted = false; + var hasIO = (typeof _t._iO.volume !== 'undefined'); + if (!_t.isHTML5) { + _flash._setVolume(_t.id, hasIO?_t._iO.volume:_t.options.volume); + } else if (_t._a) { + _t._a.muted = false; + } + return _t; + }; + this.toggleMute = function() { + return (_t.muted?_t.unmute():_t.mute()); + }; + this.onPosition = function(nPosition, oMethod, oScope) { + _onPositionItems.push({ + position: parseInt(nPosition, 10), + method: oMethod, + scope: (typeof oScope !== 'undefined' ? oScope : _t), + fired: false + }); + return _t; + }; + this.onposition = this.onPosition; + this.clearOnPosition = function(nPosition, oMethod) { + var i; + nPosition = parseInt(nPosition, 10); + if (isNaN(nPosition)) { + return false; + } + for (i=0; i < _onPositionItems.length; i++) { + if (nPosition === _onPositionItems[i].position) { + if (!oMethod || (oMethod === _onPositionItems[i].method)) { + if (_onPositionItems[i].fired) { + _onPositionFired--; + } + _onPositionItems.splice(i, 1); + } + } + } + }; + this._processOnPosition = function() { + var i, item, j = _onPositionItems.length; + if (!j || !_t.playState || _onPositionFired >= j) { + return false; + } + for (i=j-1; i >= 0; i--) { + item = _onPositionItems[i]; + if (!item.fired && _t.position >= item.position) { + item.fired = true; + _onPositionFired++; + item.method.apply(item.scope, [item.position]); + } + } + return true; + }; + this._resetOnPosition = function(nPosition) { + var i, item, j = _onPositionItems.length; + if (!j) { + return false; + } + for (i=j-1; i >= 0; i--) { + item = _onPositionItems[i]; + if (item.fired && nPosition <= item.position) { + item.fired = false; + _onPositionFired--; + } + } + return true; + }; + _applyFromTo = function() { + var _iO = _t._iO, + f = _iO.from, + t = _iO.to, + start, end; + end = function() { + _t.clearOnPosition(t, end); + _t.stop(); + }; + start = function() { + if (t !== null && !isNaN(t)) { + _t.onPosition(t, end); + } + }; + if (f !== null && !isNaN(f)) { + _iO.position = f; + _iO.multiShot = false; + start(); + } + return _iO; + }; + _attachOnPosition = function() { + var item, + op = _t._iO.onposition; + if (op) { + for (item in op) { + if (op.hasOwnProperty(item)) { + _t.onPosition(parseInt(item, 10), op[item]); + } + } + } + }; + _detachOnPosition = function() { + var item, + op = _t._iO.onposition; + if (op) { + for (item in op) { + if (op.hasOwnProperty(item)) { + _t.clearOnPosition(parseInt(item, 10)); + } + } + } + }; + _start_html5_timer = function() { + if (_t.isHTML5) { + _startTimer(_t); + } + }; + _stop_html5_timer = function() { + if (_t.isHTML5) { + _stopTimer(_t); + } + }; + _resetProperties = function(retainPosition) { + if (!retainPosition) { + _onPositionItems = []; + _onPositionFired = 0; + } + _onplay_called = false; + _t._hasTimer = null; + _t._a = null; + _t._html5_canplay = false; + _t.bytesLoaded = null; + _t.bytesTotal = null; + _t.duration = (_t._iO && _t._iO.duration ? _t._iO.duration : null); + _t.durationEstimate = null; + _t.buffered = []; + _t.eqData = []; + _t.eqData.left = []; + _t.eqData.right = []; + _t.failures = 0; + _t.isBuffering = false; + _t.instanceOptions = {}; + _t.instanceCount = 0; + _t.loaded = false; + _t.metadata = {}; + _t.readyState = 0; + _t.muted = false; + _t.paused = false; + _t.peakData = { + left: 0, + right: 0 + }; + _t.waveformData = { + left: [], + right: [] + }; + _t.playState = 0; + _t.position = null; + _t.id3 = {}; + }; + _resetProperties(); + this._onTimer = function(bForce) { + var duration, isNew = false, time, x = {}; + if (_t._hasTimer || bForce) { + if (_t._a && (bForce || ((_t.playState > 0 || _t.readyState === 1) && !_t.paused))) { + duration = _t._get_html5_duration(); + if (duration !== _lastHTML5State.duration) { + _lastHTML5State.duration = duration; + _t.duration = duration; + isNew = true; + } + _t.durationEstimate = _t.duration; + time = (_t._a.currentTime * 1000 || 0); + if (time !== _lastHTML5State.time) { + _lastHTML5State.time = time; + isNew = true; + } + if (isNew || bForce) { + _t._whileplaying(time,x,x,x,x); + } + } + return isNew; + } + }; + this._get_html5_duration = function() { + var _iO = _t._iO, + d = (_t._a ? _t._a.duration*1000 : (_iO ? _iO.duration : undefined)), + result = (d && !isNaN(d) && d !== Infinity ? d : (_iO ? _iO.duration : null)); + return result; + }; + this._apply_loop = function(a, nLoops) { + a.loop = (nLoops > 1 ? 'loop' : ''); + }; + this._setup_html5 = function(oOptions) { + var _iO = _mixin(_t._iO, oOptions), d = decodeURI, + _a = _useGlobalHTML5Audio ? _s._global_a : _t._a, + _dURL = d(_iO.url), + _oldIO = (_a && _a._t ? _a._t.instanceOptions : null), + result; + if (_a) { + if (_a._t) { + if (!_useGlobalHTML5Audio && _dURL === d(_lastURL)) { + result = _a; + } else if (_useGlobalHTML5Audio && _oldIO.url === _iO.url && (!_lastURL || (_lastURL === _oldIO.url))) { + result = _a; + } + if (result) { + _t._apply_loop(_a, _iO.loops); + return result; + } + } + if (_useGlobalHTML5Audio && _a._t && _a._t.playState && _iO.url !== _oldIO.url) { + _a._t.stop(); + } + _resetProperties((_oldIO && _oldIO.url ? _iO.url === _oldIO.url : (_lastURL ? _lastURL === _iO.url : false))); + _a.src = _iO.url; + _t.url = _iO.url; + _lastURL = _iO.url; + _a._called_load = false; + } else { + if (_iO.autoLoad || _iO.autoPlay) { + _t._a = new Audio(_iO.url); + } else { + _t._a = (_isOpera ? new Audio(null) : new Audio()); + } + _a = _t._a; + _a._called_load = false; + if (_useGlobalHTML5Audio) { + _s._global_a = _a; + } + } + _t.isHTML5 = true; + _t._a = _a; + _a._t = _t; + _add_html5_events(); + _t._apply_loop(_a, _iO.loops); + if (_iO.autoLoad || _iO.autoPlay) { + _t.load(); + } else { + _a.autobuffer = false; + _a.preload = 'auto'; + } + return _a; + }; + _add_html5_events = function() { + if (_t._a._added_events) { + return false; + } + var f; + function add(oEvt, oFn, bCapture) { + return _t._a ? _t._a.addEventListener(oEvt, oFn, bCapture||false) : null; + } + _t._a._added_events = true; + for (f in _html5_events) { + if (_html5_events.hasOwnProperty(f)) { + add(f, _html5_events[f]); + } + } + return true; + }; + _remove_html5_events = function() { + var f; + function remove(oEvt, oFn, bCapture) { + return (_t._a ? _t._a.removeEventListener(oEvt, oFn, bCapture||false) : null); + } + _t._a._added_events = false; + for (f in _html5_events) { + if (_html5_events.hasOwnProperty(f)) { + remove(f, _html5_events[f]); + } + } + }; + this._onload = function(nSuccess) { + var fN, + loadOK = (!!(nSuccess) || (!_t.isHTML5 && _fV === 8 && _t.duration)); + _t.loaded = loadOK; + _t.readyState = loadOK?3:2; + _t._onbufferchange(0); + if (_t._iO.onload) { + _t._iO.onload.apply(_t, [loadOK]); + } + return true; + }; + this._onbufferchange = function(nIsBuffering) { + if (_t.playState === 0) { + return false; + } + if ((nIsBuffering && _t.isBuffering) || (!nIsBuffering && !_t.isBuffering)) { + return false; + } + _t.isBuffering = (nIsBuffering === 1); + if (_t._iO.onbufferchange) { + _t._iO.onbufferchange.apply(_t); + } + return true; + }; + this._onsuspend = function() { + if (_t._iO.onsuspend) { + _t._iO.onsuspend.apply(_t); + } + return true; + }; + this._onfailure = function(msg, level, code) { + _t.failures++; + if (_t._iO.onfailure && _t.failures === 1) { + _t._iO.onfailure(_t, msg, level, code); + } else { + } + }; + this._onfinish = function() { + var _io_onfinish = _t._iO.onfinish; + _t._onbufferchange(0); + _t._resetOnPosition(0); + if (_t.instanceCount) { + _t.instanceCount--; + if (!_t.instanceCount) { + _detachOnPosition(); + _t.playState = 0; + _t.paused = false; + _t.instanceCount = 0; + _t.instanceOptions = {}; + _t._iO = {}; + _stop_html5_timer(); + if (_t.isHTML5) { + _t.position = 0; + } + } + if (!_t.instanceCount || _t._iO.multiShotEvents) { + if (_io_onfinish) { + _io_onfinish.apply(_t); + } + } + } + }; + this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) { + var _iO = _t._iO; + _t.bytesLoaded = nBytesLoaded; + _t.bytesTotal = nBytesTotal; + _t.duration = Math.floor(nDuration); + _t.bufferLength = nBufferLength; + if (!_iO.isMovieStar) { + if (_iO.duration) { + _t.durationEstimate = (_t.duration > _iO.duration) ? _t.duration : _iO.duration; + } else { + _t.durationEstimate = parseInt((_t.bytesTotal / _t.bytesLoaded) * _t.duration, 10); + } + if (typeof _t.durationEstimate === 'undefined') { + _t.durationEstimate = _t.duration; + } + } else { + _t.durationEstimate = _t.duration; + } + if (!_t.isHTML5) { + _t.buffered = [{ + 'start': 0, + 'end': _t.duration + }]; + } + if ((_t.readyState !== 3 || _t.isHTML5) && _iO.whileloading) { + _iO.whileloading.apply(_t); + } + }; + this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) { + var _iO = _t._iO, + eqLeft; + if (isNaN(nPosition) || nPosition === null) { + return false; + } + _t.position = Math.max(0, nPosition); + _t._processOnPosition(); + if (!_t.isHTML5 && _fV > 8) { + if (_iO.usePeakData && typeof oPeakData !== 'undefined' && oPeakData) { + _t.peakData = { + left: oPeakData.leftPeak, + right: oPeakData.rightPeak + }; + } + if (_iO.useWaveformData && typeof oWaveformDataLeft !== 'undefined' && oWaveformDataLeft) { + _t.waveformData = { + left: oWaveformDataLeft.split(','), + right: oWaveformDataRight.split(',') + }; + } + if (_iO.useEQData) { + if (typeof oEQData !== 'undefined' && oEQData && oEQData.leftEQ) { + eqLeft = oEQData.leftEQ.split(','); + _t.eqData = eqLeft; + _t.eqData.left = eqLeft; + if (typeof oEQData.rightEQ !== 'undefined' && oEQData.rightEQ) { + _t.eqData.right = oEQData.rightEQ.split(','); + } + } + } + } + if (_t.playState === 1) { + if (!_t.isHTML5 && _fV === 8 && !_t.position && _t.isBuffering) { + _t._onbufferchange(0); + } + if (_iO.whileplaying) { + _iO.whileplaying.apply(_t); + } + } + return true; + }; + this._oncaptiondata = function(oData) { + _t.captiondata = oData; + if (_t._iO.oncaptiondata) { + _t._iO.oncaptiondata.apply(_t); + } + }; + this._onmetadata = function(oMDProps, oMDData) { + var oData = {}, i, j; + for (i = 0, j = oMDProps.length; i < j; i++) { + oData[oMDProps[i]] = oMDData[i]; + } + _t.metadata = oData; + if (_t._iO.onmetadata) { + _t._iO.onmetadata.apply(_t); + } + }; + this._onid3 = function(oID3Props, oID3Data) { + var oData = [], i, j; + for (i = 0, j = oID3Props.length; i < j; i++) { + oData[oID3Props[i]] = oID3Data[i]; + } + _t.id3 = _mixin(_t.id3, oData); + if (_t._iO.onid3) { + _t._iO.onid3.apply(_t); + } + }; + this._onconnect = function(bSuccess) { + bSuccess = (bSuccess === 1); + _t.connected = bSuccess; + if (bSuccess) { + _t.failures = 0; + if (_idCheck(_t.id)) { + if (_t.getAutoPlay()) { + _t.play(undefined, _t.getAutoPlay()); + } else if (_t._iO.autoLoad) { + _t.load(); + } + } + if (_t._iO.onconnect) { + _t._iO.onconnect.apply(_t, [bSuccess]); + } + } + }; + this._ondataerror = function(sError) { + if (_t.playState > 0) { + if (_t._iO.ondataerror) { + _t._iO.ondataerror.apply(_t); + } + } + }; + }; + _getDocument = function() { + return (_doc.body || _doc._docElement || _doc.getElementsByTagName('div')[0]); + }; + _id = function(sID) { + return _doc.getElementById(sID); + }; + _mixin = function(oMain, oAdd) { + var o1 = (oMain || {}), o2, o; + o2 = (typeof oAdd === 'undefined' ? _s.defaultOptions : oAdd); + for (o in o2) { + if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') { + if (typeof o2[o] !== 'object' || o2[o] === null) { + o1[o] = o2[o]; + } else { + o1[o] = _mixin(o1[o], o2[o]); + } + } } - + return o1; + }; + _extraOptions = { + 'onready': 1, + 'ontimeout': 1, + 'defaultOptions': 1, + 'flash9Options': 1, + 'movieStarOptions': 1 + }; + _assign = function(o, oParent) { + var i, + result = true, + hasParent = (typeof oParent !== 'undefined'), + setupOptions = _s.setupOptions, + extraOptions = _extraOptions; + for (i in o) { + if (o.hasOwnProperty(i)) { + if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array) { + if (hasParent && typeof extraOptions[oParent] !== 'undefined') { + _s[oParent][i] = o[i]; + } else if (typeof setupOptions[i] !== 'undefined') { + _s.setupOptions[i] = o[i]; + _s[i] = o[i]; + } else if (typeof extraOptions[i] === 'undefined') { + _complain(_str((typeof _s[i] === 'undefined' ? 'setupUndef' : 'setupError'), i), 2); + result = false; + } else { + if (_s[i] instanceof Function) { + _s[i].apply(_s, (o[i] instanceof Array? o[i] : [o[i]])); + } else { + _s[i] = o[i]; + } + } + } else { + if (typeof extraOptions[i] === 'undefined') { + _complain(_str((typeof _s[i] === 'undefined' ? 'setupUndef' : 'setupError'), i), 2); + result = false; + } else { + return _assign(o[i], i); + } + } + } + } + return result; + }; + _event = (function() { + var old = (_win.attachEvent), + evt = { + add: (old?'attachEvent':'addEventListener'), + remove: (old?'detachEvent':'removeEventListener') + }; + function getArgs(oArgs) { + var args = _slice.call(oArgs), len = args.length; + if (old) { + args[1] = 'on' + args[1]; + if (len > 3) { + args.pop(); + } + } else if (len === 3) { + args.push(false); + } + return args; + } + function apply(args, sType) { + var element = args.shift(), + method = [evt[sType]]; + if (old) { + element[method](args[0], args[1]); + } else { + element[method].apply(element, args); + } + } + function add() { + apply(getArgs(arguments), 'add'); + } + function remove() { + apply(getArgs(arguments), 'remove'); + } + return { + 'add': add, + 'remove': remove + }; + }()); + function _preferFlashCheck(kind) { + return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind])); + } + function _html5_event(oFn) { + return function(e) { + var t = this._t, + result; + if (!t || !t._a) { + result = null; + } else { + result = oFn.call(this, e); + } + return result; + }; + } + _html5_events = { + abort: _html5_event(function() { + }), + canplay: _html5_event(function() { + var t = this._t, + position1K; + if (t._html5_canplay) { + return true; + } + t._html5_canplay = true; + t._onbufferchange(0); + position1K = (typeof t._iO.position !== 'undefined' && !isNaN(t._iO.position)?t._iO.position/1000:null); + if (t.position && this.currentTime !== position1K) { + try { + this.currentTime = position1K; + } catch(ee) { + } + } + if (t._iO._oncanplay) { + t._iO._oncanplay(); + } + }), + canplaythrough: _html5_event(function() { + var t = this._t; + if (!t.loaded) { + t._onbufferchange(0); + t._whileloading(t.bytesLoaded, t.bytesTotal, t._get_html5_duration()); + t._onload(true); + } + }), + ended: _html5_event(function() { + var t = this._t; + t._onfinish(); + }), + error: _html5_event(function() { + this._t._onload(false); + }), + loadeddata: _html5_event(function() { + var t = this._t; + if (!t._loaded && !_isSafari) { + t.duration = t._get_html5_duration(); + } + }), + loadedmetadata: _html5_event(function() { + }), + loadstart: _html5_event(function() { + this._t._onbufferchange(1); + }), + play: _html5_event(function() { + this._t._onbufferchange(0); + }), + playing: _html5_event(function() { + this._t._onbufferchange(0); + }), + progress: _html5_event(function(e) { + var t = this._t, + i, j, str, buffered = 0, + isProgress = (e.type === 'progress'), + ranges = e.target.buffered, + loaded = (e.loaded||0), + total = (e.total||1); + t.buffered = []; + if (ranges && ranges.length) { + for (i=0, j=ranges.length; i= 0; i--) { + support['audio/'+aF[item].related[i]] = support[item]; + _s.html5[aF[item].related[i]] = support[item]; + _s.flash[aF[item].related[i]] = support[item]; + } + } + } + } + support.canPlayType = (a?_cp:null); + _s.html5 = _mixin(_s.html5, support); + return true; + }; + _strings = { + }; + _str = function() { + }; + _loopFix = function(sOpt) { + if (_fV === 8 && sOpt.loops > 1 && sOpt.stream) { + sOpt.stream = false; + } + return sOpt; + }; + _policyFix = function(sOpt, sPre) { + if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) { + sOpt.usePolicyFile = true; + } + return sOpt; + }; + _complain = function(sMsg) { + }; + _doNothing = function() { + return false; + }; + _disableObject = function(o) { + var oProp; + for (oProp in o) { + if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') { + o[oProp] = _doNothing; + } + } + oProp = null; + }; + _failSafely = function(bNoDisable) { + if (typeof bNoDisable === 'undefined') { + bNoDisable = false; + } + if (_disabled || bNoDisable) { + _s.disable(bNoDisable); + } + }; + _normalizeMovieURL = function(smURL) { + var urlParams = null, url; + if (smURL) { + if (smURL.match(/\.swf(\?.*)?$/i)) { + urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4); + if (urlParams) { + return smURL; + } + } else if (smURL.lastIndexOf('/') !== smURL.length - 1) { + smURL += '/'; + } + } + url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + _s.movieURL; + if (_s.noSWFCache) { + url += ('?ts=' + new Date().getTime()); + } + return url; + }; + _setVersionInfo = function() { + _fV = parseInt(_s.flashVersion, 10); + if (_fV !== 8 && _fV !== 9) { + _s.flashVersion = _fV = _defaultFlashVersion; + } + var isDebug = (_s.debugMode || _s.debugFlash?'_debug.swf':'.swf'); + if (_s.useHTML5Audio && !_s.html5Only && _s.audioFormats.mp4.required && _fV < 9) { + _s.flashVersion = _fV = 9; + } + _s.version = _s.versionNumber + (_s.html5Only?' (HTML5-only mode)':(_fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)')); + if (_fV > 8) { + _s.defaultOptions = _mixin(_s.defaultOptions, _s.flash9Options); + _s.features.buffering = true; + _s.defaultOptions = _mixin(_s.defaultOptions, _s.movieStarOptions); + _s.filePatterns.flash9 = new RegExp('\\.(mp3|' + _netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); + _s.features.movieStar = true; + } else { + _s.features.movieStar = false; + } + _s.filePattern = _s.filePatterns[(_fV !== 8?'flash9':'flash8')]; + _s.movieURL = (_fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug); + _s.features.peakData = _s.features.waveformData = _s.features.eqData = (_fV > 8); + }; + _setPolling = function(bPolling, bHighPerformance) { + if (!_flash) { + return false; + } + _flash._setPolling(bPolling, bHighPerformance); + }; + _initDebug = function() { + if (_s.debugURLParam.test(_wl)) { + _s.debugMode = true; + } + }; + _idCheck = this.getSoundById; + _getSWFCSS = function() { + var css = []; + if (_s.debugMode) { + css.push(_swfCSS.sm2Debug); + } + if (_s.debugFlash) { + css.push(_swfCSS.flashDebug); + } + if (_s.useHighPerformance) { + css.push(_swfCSS.highPerf); + } + return css.join(' '); + }; + _flashBlockHandler = function() { + var name = _str('fbHandler'), + p = _s.getMoviePercent(), + css = _swfCSS, + error = {type:'FLASHBLOCK'}; + if (_s.html5Only) { + return false; + } + if (!_s.ok()) { + if (_needsFlash) { + _s.oMC.className = _getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError); + } + _s.didFlashBlock = true; + _processOnEvents({type:'ontimeout', ignoreInit:true, error:error}); + _catchError(error); + } else { + if (_s.oMC) { + _s.oMC.className = [_getSWFCSS(), css.swfDefault, css.swfLoaded + (_s.didFlashBlock?' '+css.swfUnblocked:'')].join(' '); + } + } + }; + _addOnEvent = function(sType, oMethod, oScope) { + if (typeof _on_queue[sType] === 'undefined') { + _on_queue[sType] = []; + } + _on_queue[sType].push({ + 'method': oMethod, + 'scope': (oScope || null), + 'fired': false + }); + }; + _processOnEvents = function(oOptions) { + if (!oOptions) { + oOptions = { + type: (_s.ok() ? 'onready' : 'ontimeout') + }; + } + if (!_didInit && oOptions && !oOptions.ignoreInit) { + return false; + } + if (oOptions.type === 'ontimeout' && (_s.ok() || (_disabled && !oOptions.ignoreInit))) { + return false; + } + var status = { + success: (oOptions && oOptions.ignoreInit?_s.ok():!_disabled) + }, + srcQueue = (oOptions && oOptions.type?_on_queue[oOptions.type]||[]:[]), + queue = [], i, j, + args = [status], + canRetry = (_needsFlash && _s.useFlashBlock && !_s.ok()); + if (oOptions.error) { + args[0].error = oOptions.error; + } + for (i = 0, j = srcQueue.length; i < j; i++) { + if (srcQueue[i].fired !== true) { + queue.push(srcQueue[i]); + } + } + if (queue.length) { + for (i = 0, j = queue.length; i < j; i++) { + if (queue[i].scope) { + queue[i].method.apply(queue[i].scope, args); + } else { + queue[i].method.apply(this, args); + } + if (!canRetry) { + queue[i].fired = true; + } + } + } + return true; + }; + _initUserOnload = function() { + _win.setTimeout(function() { + if (_s.useFlashBlock) { + _flashBlockHandler(); + } + _processOnEvents(); + if (typeof _s.onload === 'function') { + _s.onload.apply(_win); + } + if (_s.waitForWindowLoad) { + _event.add(_win, 'load', _initUserOnload); + } + },1); + }; + _detectFlash = function() { + if (typeof _hasFlash !== 'undefined') { + return _hasFlash; + } + var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = _win.ActiveXObject; + if (nP && nP.length) { + type = 'application/x-shockwave-flash'; + types = n.mimeTypes; + if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) { + hasPlugin = true; + } + } else if (typeof AX !== 'undefined') { + try { + obj = new AX('ShockwaveFlash.ShockwaveFlash'); + } catch(e) { + } + hasPlugin = (!!obj); + } + _hasFlash = hasPlugin; + return hasPlugin; + }; + _featureCheck = function() { + var needsFlash, + item, + result = true, + formats = _s.audioFormats, + isSpecial = (_is_iDevice && !!(_ua.match(/os (1|2|3_0|3_1)/i))); + if (isSpecial) { + _s.hasHTML5 = false; + _s.html5Only = true; + if (_s.oMC) { + _s.oMC.style.display = 'none'; + } + result = false; + } else { + if (_s.useHTML5Audio) { + if (!_s.html5 || !_s.html5.canPlayType) { + _s.hasHTML5 = false; + } else { + _s.hasHTML5 = true; + } + } + } + if (_s.useHTML5Audio && _s.hasHTML5) { + for (item in formats) { + if (formats.hasOwnProperty(item)) { + if ((formats[item].required && !_s.html5.canPlayType(formats[item].type)) || (_s.preferFlash && (_s.flash[item] || _s.flash[formats[item].type]))) { + needsFlash = true; + } + } + } + } + if (_s.ignoreFlash) { + needsFlash = false; + } + _s.html5Only = (_s.hasHTML5 && _s.useHTML5Audio && !needsFlash); + return (!_s.html5Only); + }; + _parseURL = function(url) { + var i, j, urlResult = 0, result; + if (url instanceof Array) { + for (i=0, j=url.length; i= 0; i--) { + if (_s.sounds[_s.soundIDs[i]].isHTML5 && _s.sounds[_s.soundIDs[i]]._hasTimer) { + _s.sounds[_s.soundIDs[i]]._onTimer(); + } + } + }; + _catchError = function(options) { + options = (typeof options !== 'undefined' ? options : {}); + if (typeof _s.onerror === 'function') { + _s.onerror.apply(_win, [{type:(typeof options.type !== 'undefined' ? options.type : null)}]); + } + if (typeof options.fatal !== 'undefined' && options.fatal) { + _s.disable(); + } + }; + _badSafariFix = function() { + if (!_isBadSafari || !_detectFlash()) { + return false; + } + var aF = _s.audioFormats, i, item; + for (item in aF) { + if (aF.hasOwnProperty(item)) { + if (item === 'mp3' || item === 'mp4') { + _s.html5[item] = false; + if (aF[item] && aF[item].related) { + for (i = aF[item].related.length-1; i >= 0; i--) { + _s.html5[aF[item].related[i]] = false; + } + } + } + } + } + }; + this._setSandboxType = function(sandboxType) { + }; + this._externalInterfaceOK = function(flashDate, swfVersion) { + if (_s.swfLoaded) { + return false; + } + var e, eiTime = new Date().getTime(); + _s.swfLoaded = true; + _tryInitOnFocus = false; + if (_isBadSafari) { + _badSafariFix(); + } + setTimeout(_init, _isIE ? 100 : 1); + }; + _createMovie = function(smID, smURL) { + if (_didAppend && _appendSuccess) { + return false; + } + function _initMsg() { + } + if (_s.html5Only) { + _setVersionInfo(); + _initMsg(); + _s.oMC = _id(_s.movieID); + _init(); + _didAppend = true; + _appendSuccess = true; + return false; + } + var remoteURL = (smURL || _s.url), + localURL = (_s.altURL || remoteURL), + swfTitle = 'JS/Flash audio component (SoundManager 2)', + oEmbed, oMovie, oTarget = _getDocument(), tmp, movieHTML, oEl, extraClass = _getSWFCSS(), + s, x, sClass, isRTL = null, + html = _doc.getElementsByTagName('html')[0]; + isRTL = (html && html.dir && html.dir.match(/rtl/i)); + smID = (typeof smID === 'undefined'?_s.id:smID); + function param(name, value) { + return ''; + } + _setVersionInfo(); + _s.url = _normalizeMovieURL(_overHTTP?remoteURL:localURL); + smURL = _s.url; + _s.wmode = (!_s.wmode && _s.useHighPerformance ? 'transparent' : _s.wmode); + if (_s.wmode !== null && (_ua.match(/msie 8/i) || (!_isIE && !_s.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) { + _s.wmode = null; + } + oEmbed = { + 'name': smID, + 'id': smID, + 'src': smURL, + 'quality': 'high', + 'allowScriptAccess': _s.allowScriptAccess, + 'bgcolor': _s.bgColor, + 'pluginspage': _http+'www.macromedia.com/go/getflashplayer', + 'title': swfTitle, + 'type': 'application/x-shockwave-flash', + 'wmode': _s.wmode, + 'hasPriority': 'true' + }; + if (_s.debugFlash) { + oEmbed.FlashVars = 'debug=1'; + } + if (!_s.wmode) { + delete oEmbed.wmode; + } + if (_isIE) { + oMovie = _doc.createElement('div'); + movieHTML = [ + '', + param('movie', smURL), + param('AllowScriptAccess', _s.allowScriptAccess), + param('quality', oEmbed.quality), + (_s.wmode? param('wmode', _s.wmode): ''), + param('bgcolor', _s.bgColor), + param('hasPriority', 'true'), + (_s.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''), + '' + ].join(''); + } else { + oMovie = _doc.createElement('embed'); + for (tmp in oEmbed) { + if (oEmbed.hasOwnProperty(tmp)) { + oMovie.setAttribute(tmp, oEmbed[tmp]); + } + } + } + _initDebug(); + extraClass = _getSWFCSS(); + oTarget = _getDocument(); + if (oTarget) { + _s.oMC = (_id(_s.movieID) || _doc.createElement('div')); + if (!_s.oMC.id) { + _s.oMC.id = _s.movieID; + _s.oMC.className = _swfCSS.swfDefault + ' ' + extraClass; + s = null; + oEl = null; + if (!_s.useFlashBlock) { + if (_s.useHighPerformance) { + s = { + 'position': 'fixed', + 'width': '8px', + 'height': '8px', + 'bottom': '0px', + 'left': '0px', + 'overflow': 'hidden' + }; + } else { + s = { + 'position': 'absolute', + 'width': '6px', + 'height': '6px', + 'top': '-9999px', + 'left': '-9999px' + }; + if (isRTL) { + s.left = Math.abs(parseInt(s.left,10))+'px'; + } + } + } + if (_isWebkit) { + _s.oMC.style.zIndex = 10000; + } + if (!_s.debugFlash) { + for (x in s) { + if (s.hasOwnProperty(x)) { + _s.oMC.style[x] = s[x]; + } + } + } + try { + if (!_isIE) { + _s.oMC.appendChild(oMovie); + } + oTarget.appendChild(_s.oMC); + if (_isIE) { + oEl = _s.oMC.appendChild(_doc.createElement('div')); + oEl.className = _swfCSS.swfBox; + oEl.innerHTML = movieHTML; + } + _appendSuccess = true; + } catch(e) { + throw new Error(_str('domError')+' \n'+e.toString()); + } + } else { + sClass = _s.oMC.className; + _s.oMC.className = (sClass?sClass+' ':_swfCSS.swfDefault) + (extraClass?' '+extraClass:''); + _s.oMC.appendChild(oMovie); + if (_isIE) { + oEl = _s.oMC.appendChild(_doc.createElement('div')); + oEl.className = _swfCSS.swfBox; + oEl.innerHTML = movieHTML; + } + _appendSuccess = true; + } + } + _didAppend = true; + _initMsg(); + return true; + }; + _initMovie = function() { + if (_s.html5Only) { + _createMovie(); + return false; + } + if (_flash) { + return false; + } + _flash = _s.getMovie(_s.id); + if (!_flash) { + if (!_oRemoved) { + _createMovie(_s.id, _s.url); + } else { + if (!_isIE) { + _s.oMC.appendChild(_oRemoved); + } else { + _s.oMC.innerHTML = _oRemovedHTML; + } + _oRemoved = null; + _didAppend = true; + } + _flash = _s.getMovie(_s.id); + } + if (typeof _s.oninitmovie === 'function') { + setTimeout(_s.oninitmovie, 1); + } + return true; + }; + _delayWaitForEI = function() { + setTimeout(_waitForEI, 1000); + }; + _waitForEI = function() { + var p, + loadIncomplete = false; + if (_waitingForEI) { + return false; + } + _waitingForEI = true; + _event.remove(_win, 'load', _delayWaitForEI); + if (_tryInitOnFocus && !_isFocused) { + return false; + } + if (!_didInit) { + p = _s.getMoviePercent(); + if (p > 0 && p < 100) { + loadIncomplete = true; + } + } + setTimeout(function() { + p = _s.getMoviePercent(); + if (loadIncomplete) { + _waitingForEI = false; + _win.setTimeout(_delayWaitForEI, 1); + return false; + } + if (!_didInit && _okToDisable) { + if (p === null) { + if (_s.useFlashBlock || _s.flashLoadTimeout === 0) { + if (_s.useFlashBlock) { + _flashBlockHandler(); + } + } else { + _failSafely(true); + } + } else { + if (_s.flashLoadTimeout === 0) { + } else { + _failSafely(true); + } + } + } + }, _s.flashLoadTimeout); + }; + _handleFocus = function() { + function cleanup() { + _event.remove(_win, 'focus', _handleFocus); + } + if (_isFocused || !_tryInitOnFocus) { + cleanup(); + return true; + } + _okToDisable = true; + _isFocused = true; + _waitingForEI = false; + _delayWaitForEI(); + cleanup(); + return true; + }; + _showSupport = function() { + var item, tests = []; + if (_s.useHTML5Audio && _s.hasHTML5) { + for (item in _s.audioFormats) { + if (_s.audioFormats.hasOwnProperty(item)) { + 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)' : '')))); + } + } + } + }; + _initComplete = function(bNoDisable) { + if (_didInit) { + return false; + } + if (_s.html5Only) { + _didInit = true; + _initUserOnload(); + return true; + } + var wasTimeout = (_s.useFlashBlock && _s.flashLoadTimeout && !_s.getMoviePercent()), + result = true, + error; + if (!wasTimeout) { + _didInit = true; + if (_disabled) { + error = {type: (!_hasFlash && _needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')}; + } + } + if (_disabled || bNoDisable) { + if (_s.useFlashBlock && _s.oMC) { + _s.oMC.className = _getSWFCSS() + ' ' + (_s.getMoviePercent() === null?_swfCSS.swfTimedout:_swfCSS.swfError); + } + _processOnEvents({type:'ontimeout', error:error, ignoreInit: true}); + _catchError(error); + result = false; + } else { + } + if (!_disabled) { + if (_s.waitForWindowLoad && !_windowLoaded) { + _event.add(_win, 'load', _initUserOnload); + } else { + _initUserOnload(); + } + } + return result; + }; + _setProperties = function() { + var i, + o = _s.setupOptions; + for (i in o) { + if (o.hasOwnProperty(i)) { + if (typeof _s[i] === 'undefined') { + _s[i] = o[i]; + } else if (_s[i] !== o[i]) { + _s.setupOptions[i] = _s[i]; + } + } + } + }; + _init = function() { + if (_didInit) { + return false; + } + function _cleanup() { + _event.remove(_win, 'load', _s.beginDelayedInit); + } + if (_s.html5Only) { + if (!_didInit) { + _cleanup(); + _s.enabled = true; + _initComplete(); + } + return true; + } + _initMovie(); + try { + _flash._externalInterfaceTest(false); + _setPolling(true, (_s.flashPollingInterval || (_s.useHighPerformance ? 10 : 50))); + if (!_s.debugMode) { + _flash._disableDebug(); + } + _s.enabled = true; + if (!_s.html5Only) { + _event.add(_win, 'unload', _doNothing); + } + } catch(e) { + _catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true}); + _failSafely(true); + _initComplete(); + return false; + } + _initComplete(); + _cleanup(); + return true; + }; + _domContentLoaded = function() { + if (_didDCLoaded) { + return false; + } + _didDCLoaded = true; + _setProperties(); + _initDebug(); + if (!_hasFlash && _s.hasHTML5) { + _s.setup({ + 'useHTML5Audio': true, + 'preferFlash': false + }); + } + _testHTML5(); + _s.html5.usingFlash = _featureCheck(); + _needsFlash = _s.html5.usingFlash; + _showSupport(); + if (!_hasFlash && _needsFlash) { + _s.setup({ + 'flashLoadTimeout': 1 + }); + } + if (_doc.removeEventListener) { + _doc.removeEventListener('DOMContentLoaded', _domContentLoaded, false); + } + _initMovie(); + return true; + }; + _domContentLoadedIE = function() { + if (_doc.readyState === 'complete') { + _domContentLoaded(); + _doc.detachEvent('onreadystatechange', _domContentLoadedIE); + } + return true; + }; + _winOnLoad = function() { + _windowLoaded = true; + _event.remove(_win, 'load', _winOnLoad); + }; + _detectFlash(); + _event.add(_win, 'focus', _handleFocus); + _event.add(_win, 'load', _delayWaitForEI); + _event.add(_win, 'load', _winOnLoad); + if (_doc.addEventListener) { + _doc.addEventListener('DOMContentLoaded', _domContentLoaded, false); + } else if (_doc.attachEvent) { + _doc.attachEvent('onreadystatechange', _domContentLoadedIE); + } else { + _catchError({type:'NO_DOM2_EVENTS', fatal:true}); + } + if (_doc.readyState === 'complete') { + setTimeout(_domContentLoaded,100); + } +} // SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading - if (typeof SM2_DEFER === 'undefined' || !SM2_DEFER) { - soundManager = new SoundManager(); - } - window.SoundManager = SoundManager; - window.soundManager = soundManager; -}(window)); +if (typeof SM2_DEFER === 'undefined' || !SM2_DEFER) { + soundManager = new SoundManager(); +} +window.SoundManager = SoundManager; +window.soundManager = soundManager; +}(window)); \ No newline at end of file diff --git a/static/js/libs/sm/soundmanager2.js b/static/js/libs/sm/soundmanager2.js old mode 100644 new mode 100755 index ae6f2b0..4a75dfc --- a/static/js/libs/sm/soundmanager2.js +++ b/static/js/libs/sm/soundmanager2.js @@ -8,7 +8,7 @@ * Code provided under the BSD License: * http://schillmania.com/projects/soundmanager2/license.txt * - * V2.97a.20120527 + * V2.97a.20120624 */ /*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio */ @@ -46,56 +46,33 @@ var soundManager = null; function SoundManager(smURL, smID) { - // Top-level configuration options + /** + * soundManager configuration options list + * defines top-level configuration properties to be applied to the soundManager instance (eg. soundManager.flashVersion) + * to set these properties, use the setup() method - eg., soundManager.setup({url: '/swf/', flashVersion: 9}) + */ - this.flashVersion = 8; // flash build to use (8 or 9.) Some API features require 9. - this.debugMode = true; // enable debugging output (console.log() with HTML fallback) - this.debugFlash = false; // enable debugging output inside SWF, troubleshoot Flash/browser issues - this.useConsole = true; // use console.log() if available (otherwise, writes to #soundmanager-debug element) - this.consoleOnly = true; // if console is being used, do not create/write to #soundmanager-debug - this.waitForWindowLoad = false; // force SM2 to wait for window.onload() before trying to call soundManager.onload() - this.bgColor = '#ffffff'; // SWF background color. N/A when wmode = 'transparent' - this.useHighPerformance = false; // position:fixed flash movie can help increase js/flash speed, minimize lag - this.flashPollingInterval = null; // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used. - this.html5PollingInterval = null; // msec affecting whileplaying() for HTML5 audio, excluding mobile devices. If null, native HTML5 update events are used. - this.flashLoadTimeout = 1000; // msec to wait for flash movie to load before failing (0 = infinity) - this.wmode = null; // flash rendering mode - null, 'transparent', or 'opaque' (last two allow z-index to work) - this.allowScriptAccess = 'always'; // for scripting the SWF (object/embed property), 'always' or 'sameDomain' - this.useFlashBlock = false; // *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable. - 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. - this.html5Test = /^(probably|maybe)$/i; // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative. - 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. - this.noSWFCache = false; // if true, appends ?ts={date} to break aggressive SWF caching. + this.setupOptions = { - this.audioFormats = { - - /** - * determines HTML5 support + flash requirements. - * if no support (via flash and/or HTML5) for a "required" format, SM2 will fail to start. - * flash fallback is used for MP3 or MP4 if HTML5 can't play it (or if preferFlash = true) - * multiple MIME types may be tested while trying to get a positive canPlayType() response. - */ - - 'mp3': { - 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'], - 'required': true - }, - - 'mp4': { - 'related': ['aac','m4a'], // additional formats under the MP4 container - '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 - } + 'url': (smURL || null), // path (directory) where SoundManager 2 SWFs exist, eg., /path/to/swfs/ + 'flashVersion': 8, // flash build to use (8 or 9.) Some API features require 9. + 'debugMode': true, // enable debugging output (console.log() with HTML fallback) + 'debugFlash': false, // enable debugging output inside SWF, troubleshoot Flash/browser issues + 'useConsole': true, // use console.log() if available (otherwise, writes to #soundmanager-debug element) + 'consoleOnly': true, // if console is being used, do not create/write to #soundmanager-debug + 'waitForWindowLoad': false, // force SM2 to wait for window.onload() before trying to call soundManager.onload() + 'bgColor': '#ffffff', // SWF background color. N/A when wmode = 'transparent' + 'useHighPerformance': false, // position:fixed flash movie can help increase js/flash speed, minimize lag + 'flashPollingInterval': null, // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used. + 'html5PollingInterval': null, // msec affecting whileplaying() for HTML5 audio, excluding mobile devices. If null, native HTML5 update events are used. + 'flashLoadTimeout': 1000, // msec to wait for flash movie to load before failing (0 = infinity) + 'wmode': null, // flash rendering mode - null, 'transparent', or 'opaque' (last two allow z-index to work) + 'allowScriptAccess': 'always', // for scripting the SWF (object/embed property), 'always' or 'sameDomain' + 'useFlashBlock': false, // *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable. + 'useHTML5Audio': true, // use HTML5 Audio() where API is supported (most Safari, Chrome versions), Firefox (no MP3/MP4.) Ideally, transparent vs. Flash API where possible. + 'html5Test': /^(probably|maybe)$/i, // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative. + '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. + 'noSWFCache': false // if true, appends ?ts={date} to break aggressive SWF caching. }; @@ -163,6 +140,38 @@ function SoundManager(smURL, smID) { }; + this.audioFormats = { + + /** + * determines HTML5 support + flash requirements. + * if no support (via flash and/or HTML5) for a "required" format, SM2 will fail to start. + * flash fallback is used for MP3 or MP4 if HTML5 can't play it (or if preferFlash = true) + * multiple MIME types may be tested while trying to get a positive canPlayType() response. + */ + + 'mp3': { + 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'], + 'required': true + }, + + 'mp4': { + 'related': ['aac','m4a'], // additional formats under the MP4 container + '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 + } + + }; + // HTML attributes (id + class names) for the SWF container this.movieID = 'sm2-container'; @@ -173,10 +182,9 @@ function SoundManager(smURL, smID) { // dynamic attributes - this.versionNumber = 'V2.97a.20120527'; + this.versionNumber = 'V2.97a.20120624'; this.version = null; this.movieURL = null; - this.url = (smURL || null); this.altURL = null; this.swfLoaded = false; this.enabled = false; @@ -264,12 +272,12 @@ function SoundManager(smURL, smID) { */ var SMSound, - _s = this, _flash = null, _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, _winOnLoad, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _swfCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _startTimer, _stopTimer, _timerExecute, _h5TimerCount = 0, _h5IntervalTimer = null, _parseURL, + _s = this, _flash = null, _sm = 'soundManager', _smc = _sm+'::', _h5 = 'HTML5::', _id, _ua = navigator.userAgent, _win = window, _wl = _win.location.href.toString(), _doc = document, _doNothing, _setProperties, _init, _fV, _on_queue = [], _debugOpen = true, _debugTS, _didAppend = false, _appendSuccess = false, _didInit = false, _disabled = false, _windowLoaded = false, _wDS, _wdCount = 0, _initComplete, _mixin, _assign, _extraOptions, _addOnEvent, _processOnEvents, _initUserOnload, _delayWaitForEI, _waitForEI, _setVersionInfo, _handleFocus, _strings, _initMovie, _domContentLoaded, _winOnLoad, _didDCLoaded, _getDocument, _createMovie, _catchError, _setPolling, _initDebug, _debugLevels = ['log', 'info', 'warn', 'error'], _defaultFlashVersion = 8, _disableObject, _failSafely, _normalizeMovieURL, _oRemoved = null, _oRemovedHTML = null, _str, _flashBlockHandler, _getSWFCSS, _swfCSS, _toggleDebug, _loopFix, _policyFix, _complain, _idCheck, _waitingForEI = false, _initPending = false, _startTimer, _stopTimer, _timerExecute, _h5TimerCount = 0, _h5IntervalTimer = null, _parseURL, _needsFlash = null, _featureCheck, _html5OK, _html5CanPlay, _html5Ext, _html5Unload, _domContentLoadedIE, _testHTML5, _event, _slice = Array.prototype.slice, _useGlobalHTML5Audio = false, _hasFlash, _detectFlash, _badSafariFix, _html5_events, _showSupport, - _is_iDevice = _ua.match(/(ipad|iphone|ipod)/i), _is_firefox = _ua.match(/firefox/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)), + _is_iDevice = _ua.match(/(ipad|iphone|ipod)/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)), _mobileHTML5 = (_ua.match(/(mobile|pre\/|xoom)/i) || _is_iDevice), _isBadSafari = (!_wl.match(/usehtml5audio/i) && !_wl.match(/sm2\-ignorebadua/i) && _isSafari && !_ua.match(/silk/i) && _ua.match(/OS X 10_6_([3-7])/i)), // Safari 4 and 5 (excluding Kindle Fire, "Silk") 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 - _hasConsole = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (_isSafari && (typeof _doc.hasFocus === 'undefined' || !_doc.hasFocus())), _okToDisable = !_tryInitOnFocus, _flashMIME = /(mp3|mp4|mpa)/i, + _hasConsole = (typeof console !== 'undefined' && typeof console.log !== 'undefined'), _isFocused = (typeof _doc.hasFocus !== 'undefined'?_doc.hasFocus():null), _tryInitOnFocus = (_isSafari && (typeof _doc.hasFocus === 'undefined' || !_doc.hasFocus())), _okToDisable = !_tryInitOnFocus, _flashMIME = /(mp3|mp4|mpa|m4a)/i, _emptyURL = 'about:blank', // safe URL to unload, or load nothing from (flash 8 + most HTML5 UAs) _overHTTP = (_doc.location?_doc.location.protocol.match(/http/i):null), _http = (!_overHTTP ? 'http:/'+'/' : ''), @@ -283,6 +291,7 @@ function SoundManager(smURL, smID) { // use altURL if not "online" this.useAltURL = !_overHTTP; + this._global_a = null; _swfCSS = { @@ -318,6 +327,29 @@ function SoundManager(smURL, smID) { * ----------------------- */ + /** + * Configures top-level soundManager properties. + * + * @param {object} options Option parameters, eg. { flashVersion: 9, url: '/path/to/swfs/' } + * onready and ontimeout are also accepted parameters. call soundManager.setup() to see the full list. + */ + + this.setup = function(options) { + + // warn if flash options have already been applied + + if (typeof options !== 'undefined' && _didInit && _needsFlash && _s.ok() && (typeof options.flashVersion !== 'undefined' || typeof options.url !== 'undefined')) { + _complain(_str('setupLate')); + } + + // TODO: defer: true? + + _assign(options); + + return _s; + + }; + this.ok = function() { return (_needsFlash?(_didInit && !_disabled):(_s.useHTML5Audio && _s.hasHTML5)); @@ -395,7 +427,7 @@ function SoundManager(smURL, smID) { if (_html5OK(_tO)) { oSound = make(); - _s._wD('Loading sound '+_tO.id+' via HTML5'); + _s._wD('Creating sound '+_tO.id+', using HTML5'); oSound._setup_html5(_tO); } else { @@ -403,7 +435,7 @@ function SoundManager(smURL, smID) { if (_fV > 8) { if (_tO.isMovieStar === null) { // attempt to detect MPEG-4 formats - _tO.isMovieStar = (_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern)); + _tO.isMovieStar = !!(_tO.serverURL || (_tO.type ? _tO.type.match(_netStreamMimeTypes) : false) || _tO.url.match(_netStreamPattern)); } // if (_tO.isMovieStar) { @@ -1082,7 +1114,7 @@ function SoundManager(smURL, smID) { /** * Writes console.log()-style debug output to a console or in-browser element. - * Applies when SoundManager.debugMode = true + * Applies when debugMode = true * * @param {string} sText The console message * @param {string} sType Optional: Log type of 'info', 'warn' or 'error' @@ -1207,15 +1239,17 @@ function SoundManager(smURL, smID) { // trash ze flash - try { - if (_isIE) { - _oRemovedHTML = _flash.innerHTML; + if (_flash) { + try { + if (_isIE) { + _oRemovedHTML = _flash.innerHTML; + } + _oRemoved = _flash.parentNode.removeChild(_flash); + _s._wD('Flash movie removed.'); + } catch(e) { + // uh-oh. + _wDS('badRemove', 2); } - _oRemoved = _flash.parentNode.removeChild(_flash); - _s._wD('Flash movie removed.'); - } catch(e) { - // uh-oh. - _wDS('badRemove', 2); } // actually, force recreate of movie. @@ -1308,7 +1342,11 @@ function SoundManager(smURL, smID) { time: null }; - this.sID = oOptions.id; + this.id = oOptions.id; + + // legacy + this.sID = this.id; + this.url = oOptions.url; this.options = _mixin(oOptions); @@ -1421,9 +1459,13 @@ function SoundManager(smURL, smID) { _iO = _t._iO; _lastURL = _t.url; + + // reset a few state properties + _t.loaded = false; _t.readyState = 1; _t.playState = 0; + _t.id3 = {}; // TODO: If switching from HTML5 -> flash (or vice versa), stop currently-playing audio. @@ -1433,10 +1475,29 @@ function SoundManager(smURL, smID) { if (!oS._called_load) { - _s._wD(_h5+'load: '+_t.sID); + _s._wD(_h5+'load: '+_t.id); + _t._html5_canplay = false; - // given explicit load call, try to get whole file. + // TODO: review called_load / html5_canplay logic + + // if url provided directly to load(), assign it here. + + if (_t._a.src !== _iO.url) { + + _s._wD(_wDS('manURL') + ': ' + _iO.url); + + _t._a.src = _iO.url; + + // TODO: review / re-apply all relevant options (volume, loop, onposition etc.) + + // reset position for new URL + _t.setPosition(0); + + } + + // given explicit load call, try to preload. + // early HTML5 implementation (non-standard) _t._a.autobuffer = 'auto'; @@ -1447,12 +1508,12 @@ function SoundManager(smURL, smID) { if (_iO.autoPlay) { _t.play(); - } else { - oS.load(); } } else { - _s._wD(_h5+'ignoring request to load again: '+_t.sID); + + _s._wD(_h5+'ignoring request to load again: '+_t.id); + } } else { @@ -1463,9 +1524,9 @@ function SoundManager(smURL, smID) { // re-assign local shortcut _iO = _t._iO; if (_fV === 8) { - _flash._load(_t.sID, _iO.url, _iO.stream, _iO.autoPlay, (_iO.whileloading?1:0), _iO.loops||1, _iO.usePolicyFile); + _flash._load(_t.id, _iO.url, _iO.stream, _iO.autoPlay, (_iO.whileloading?1:0), _iO.loops||1, _iO.usePolicyFile); } else { - _flash._load(_t.sID, _iO.url, !!(_iO.stream), !!(_iO.autoPlay), _iO.loops||1, !!(_iO.autoLoad), _iO.usePolicyFile); + _flash._load(_t.id, _iO.url, !!(_iO.stream), !!(_iO.autoPlay), _iO.loops||1, !!(_iO.autoLoad), _iO.usePolicyFile); } } catch(e) { _wDS('smError', 2); @@ -1494,20 +1555,30 @@ function SoundManager(smURL, smID) { if (_t.readyState !== 0) { - _s._wD('SMSound.unload(): "' + _t.sID + '"'); + _s._wD('SMSound.unload(): "' + _t.id + '"'); if (!_t.isHTML5) { + if (_fV === 8) { - _flash._unload(_t.sID, _emptyURL); + _flash._unload(_t.id, _emptyURL); } else { - _flash._unload(_t.sID); + _flash._unload(_t.id); } + } else { + _stop_html5_timer(); + if (_t._a) { + _t._a.pause(); - _html5Unload(_t._a); + _html5Unload(_t._a, _emptyURL); + + // reset local URL for next load / play call, too + _t.url = _emptyURL; + } + } // reset load/status flags @@ -1525,14 +1596,14 @@ function SoundManager(smURL, smID) { this.destruct = function(_bFromSM) { - _s._wD('SMSound.destruct(): "' + _t.sID + '"'); + _s._wD('SMSound.destruct(): "' + _t.id + '"'); if (!_t.isHTML5) { // kill sound within Flash // Disable the onfailure handler _t._iO.onfailure = null; - _flash._destroySound(_t.sID); + _flash._destroySound(_t.id); } else { @@ -1553,7 +1624,7 @@ function SoundManager(smURL, smID) { if (!_bFromSM) { // ensure deletion from controller - _s.destroySound(_t.sID, true); + _s.destroySound(_t.id, true); } @@ -1568,7 +1639,7 @@ function SoundManager(smURL, smID) { this.play = function(oOptions, _updatePlayState) { - var fN, allowMulti, a, onready, startOK, + var fN, allowMulti, a, onready, startOK = true, exit = null; // @@ -1605,10 +1676,10 @@ function SoundManager(smURL, smID) { if (_t.playState === 1 && !_t.paused) { allowMulti = _t._iO.multiShot; if (!allowMulti) { - _s._wD(fN + '"' + _t.sID + '" already playing (one-shot)', 1); + _s._wD(fN + '"' + _t.id + '" already playing (one-shot)', 1); exit = _t; } else { - _s._wD(fN + '"' + _t.sID + '" already playing (multi-shot)', 1); + _s._wD(fN + '"' + _t.id + '" already playing (multi-shot)', 1); } } @@ -1620,32 +1691,32 @@ function SoundManager(smURL, smID) { if (_t.readyState === 0) { - _s._wD(fN + 'Attempting to load "' + _t.sID + '"', 1); + _s._wD(fN + 'Attempting to load "' + _t.id + '"', 1); // try to get this sound playing ASAP if (!_t.isHTML5) { // assign directly because setAutoPlay() increments the instanceCount _t._iO.autoPlay = true; _t.load(_t._iO); - } else if (_is_iDevice) { + } else { // iOS needs this when recycling sounds, loading a new URL on an existing object. _t.load(_t._iO); } } else if (_t.readyState === 2) { - _s._wD(fN + 'Could not load "' + _t.sID + '" - exiting', 2); + _s._wD(fN + 'Could not load "' + _t.id + '" - exiting', 2); exit = _t; } else { - _s._wD(fN + '"' + _t.sID + '" is loading - attempting to play..', 1); + _s._wD(fN + '"' + _t.id + '" is loading - attempting to play..', 1); } } else { - _s._wD(fN + '"' + _t.sID + '"'); + _s._wD(fN + '"' + _t.id + '"'); } @@ -1655,7 +1726,7 @@ function SoundManager(smURL, smID) { if (!_t.isHTML5 && _fV === 9 && _t.position > 0 && _t.position === _t.duration) { // flash 9 needs a position reset if play() is called while at the end of a sound. - _s._wD(fN + '"' + _t.sID + '": Sound at end, resetting to position:0'); + _s._wD(fN + '"' + _t.id + '": Sound at end, resetting to position:0'); oOptions.position = 0; } @@ -1670,7 +1741,7 @@ function SoundManager(smURL, smID) { if (_t.paused && _t.position && _t.position > 0) { // https://gist.github.com/37b17df75cc4d7a90bf6 - _s._wD(fN + '"' + _t.sID + '" is resuming from paused state',1); + _s._wD(fN + '"' + _t.id + '" is resuming from paused state',1); _t.resume(); } else { @@ -1691,7 +1762,7 @@ function SoundManager(smURL, smID) { if (_t.isHTML5 && !_t._html5_canplay) { // this hasn't been loaded yet. load it first, and then do this again. - _s._wD(fN+'Beginning load of "'+ _t.sID+'" for from/to case'); + _s._wD(fN+'Beginning load of "'+ _t.id+'" for from/to case'); _t.load({ _oncanplay: onready @@ -1703,7 +1774,7 @@ function SoundManager(smURL, smID) { // to be safe, preload the whole thing in Flash. - _s._wD(fN+'Preloading "'+ _t.sID+'" for from/to case'); + _s._wD(fN+'Preloading "'+ _t.id+'" for from/to case'); _t.load({ onload: onready @@ -1723,7 +1794,7 @@ function SoundManager(smURL, smID) { } - _s._wD(fN+'"'+ _t.sID+'" is starting to play'); + _s._wD(fN+'"'+ _t.id+'" is starting to play'); if (!_t.instanceCount || _t._iO.multiShotEvents || (!_t.isHTML5 && _fV > 8 && !_t.getAutoPlay())) { _t.instanceCount++; @@ -1753,27 +1824,31 @@ function SoundManager(smURL, smID) { if (!_t.isHTML5) { - startOK = _flash._start(_t.sID, _t._iO.loops || 1, (_fV === 9 ? _t._iO.position : _t._iO.position / 1000), _t._iO.multiShot); + startOK = _flash._start(_t.id, _t._iO.loops || 1, (_fV === 9 ? _t._iO.position : _t._iO.position / 1000), _t._iO.multiShot); + + if (_fV === 9 && !startOK) { + // edge case: no sound hardware, or 32-channel flash ceiling hit. + // applies only to Flash 9, non-NetStream/MovieStar sounds. + // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29 + _s._wD(fN+ _t.id+': No sound hardware, or 32-sound ceiling hit'); + if (_t._iO.onplayerror) { + _t._iO.onplayerror.apply(_t); + } + + } } else { _start_html5_timer(); + a = _t._setup_html5(); + _t.setPosition(_t._iO.position); + a.play(); } - if (_fV === 9 && !startOK) { - // edge case: no sound hardware, or 32-channel flash ceiling hit. - // applies only to Flash 9, non-NetStream/MovieStar sounds. - // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29 - _s._wD(fN+ _t.sID+': No sound hardware, or 32-sound ceiling hit'); - if (_t._iO.onplayerror) { - _t._iO.onplayerror.apply(_t); - } - } - } return _t; @@ -1814,7 +1889,7 @@ function SoundManager(smURL, smID) { if (!_t.isHTML5) { - _flash._stop(_t.sID, bAll); + _flash._stop(_t.id, bAll); // hack for netStream: just unload if (_iO.serverURL) { @@ -1869,16 +1944,16 @@ function SoundManager(smURL, smID) { this.setAutoPlay = function(autoPlay) { - _s._wD('sound '+_t.sID+' turned autoplay ' + (autoPlay ? 'on' : 'off')); + _s._wD('sound '+_t.id+' turned autoplay ' + (autoPlay ? 'on' : 'off')); _t._iO.autoPlay = autoPlay; if (!_t.isHTML5) { - _flash._setAutoPlay(_t.sID, autoPlay); + _flash._setAutoPlay(_t.id, autoPlay); if (autoPlay) { // only increment the instanceCount if the sound isn't loaded (TODO: verify RTMP) if (!_t.instanceCount && _t.readyState === 1) { _t.instanceCount++; - _s._wD('sound '+_t.sID+' incremented instance count to '+_t.instanceCount); + _s._wD('sound '+_t.id+' incremented instance count to '+_t.instanceCount); } } } @@ -1927,7 +2002,7 @@ function SoundManager(smURL, smID) { position = (_fV === 9 ? _t.position : position1K); if (_t.readyState && _t.readyState !== 2) { // if paused or not playing, will not resume (by playing) - _flash._setPosition(_t.sID, position, (_t.paused || !_t.playState), _t._iO.multiShot); + _flash._setPosition(_t.id, position, (_t.paused || !_t.playState), _t._iO.multiShot); } } else if (_t._a) { @@ -1986,7 +2061,7 @@ function SoundManager(smURL, smID) { if (!_t.isHTML5) { if (_bCallFlash || typeof _bCallFlash === 'undefined') { - _flash._pause(_t.sID, _t._iO.multiShot); + _flash._pause(_t.id, _t._iO.multiShot); } } else { _t._setup_html5().pause(); @@ -2033,7 +2108,7 @@ function SoundManager(smURL, smID) { _t.setPosition(_t.position); } // flash method is toggle-based (pause/resume) - _flash._pause(_t.sID, _iO.multiShot); + _flash._pause(_t.id, _iO.multiShot); } else { _t._setup_html5().play(); _start_html5_timer(); @@ -2095,7 +2170,7 @@ function SoundManager(smURL, smID) { } if (!_t.isHTML5) { - _flash._setPan(_t.sID, nPan); + _flash._setPan(_t.id, nPan); } // else { no HTML5 pan? } _t._iO.pan = nPan; @@ -2134,7 +2209,7 @@ function SoundManager(smURL, smID) { } if (!_t.isHTML5) { - _flash._setVolume(_t.sID, (_s.muted && !_t.muted) || _t.muted?0:nVol); + _flash._setVolume(_t.id, (_s.muted && !_t.muted) || _t.muted?0:nVol); } else if (_t._a) { // valid range: 0-1 _t._a.volume = Math.max(0, Math.min(1, nVol/100)); @@ -2162,7 +2237,7 @@ function SoundManager(smURL, smID) { _t.muted = true; if (!_t.isHTML5) { - _flash._setVolume(_t.sID, 0); + _flash._setVolume(_t.id, 0); } else if (_t._a) { _t._a.muted = true; } @@ -2183,7 +2258,7 @@ function SoundManager(smURL, smID) { var hasIO = (typeof _t._iO.volume !== 'undefined'); if (!_t.isHTML5) { - _flash._setVolume(_t.sID, hasIO?_t._iO.volume:_t.options.volume); + _flash._setVolume(_t.id, hasIO?_t._iO.volume:_t.options.volume); } else if (_t._a) { _t._a.muted = false; } @@ -2324,7 +2399,7 @@ function SoundManager(smURL, smID) { end = function() { // end has been reached. - _s._wD(_t.sID + ': "to" time of ' + t + ' reached.'); + _s._wD(_t.id + ': "to" time of ' + t + ' reached.'); // detach listener _t.clearOnPosition(t, end); @@ -2336,7 +2411,7 @@ function SoundManager(smURL, smID) { start = function() { - _s._wD(_t.sID + ': playing "from" ' + f); + _s._wD(_t.id + ': playing "from" ' + f); // add listener for end if (t !== null && !isNaN(t)) { @@ -2432,6 +2507,7 @@ function SoundManager(smURL, smID) { _t.bytesTotal = null; _t.duration = (_t._iO && _t._iO.duration ? _t._iO.duration : null); _t.durationEstimate = null; + _t.buffered = []; // legacy: 1D array _t.eqData = []; @@ -2465,6 +2541,8 @@ function SoundManager(smURL, smID) { _t.playState = 0; _t.position = null; + _t.id3 = {}; + }; _resetProperties(); @@ -2520,7 +2598,7 @@ function SoundManager(smURL, smID) { }/* else { - // _s._wD('_onTimer: Warn for "'+_t.sID+'": '+(!_t._a?'Could not find element. ':'')+(_t.playState === 0?'playState bad, 0?':'playState = '+_t.playState+', OK')); + // _s._wD('_onTimer: Warn for "'+_t.id+'": '+(!_t._a?'Could not find element. ':'')+(_t.playState === 0?'playState bad, 0?':'playState = '+_t.playState+', OK')); return false; @@ -2572,21 +2650,27 @@ function SoundManager(smURL, smID) { if (_a._t) { if (!_useGlobalHTML5Audio && _dURL === d(_lastURL)) { + // same url, ignore request result = _a; + } else if (_useGlobalHTML5Audio && _oldIO.url === _iO.url && (!_lastURL || (_lastURL === _oldIO.url))) { + // iOS-type reuse case result = _a; + } if (result) { + _t._apply_loop(_a, _iO.loops); return result; + } } - _s._wD('setting new URL on existing object: ' + _dURL + (_lastURL ? ', old URL: ' + _lastURL : '')); + _s._wD('setting URL on existing object: ' + _dURL + (_lastURL ? ', old URL: ' + _lastURL : '')); /** * "First things first, I, Poppa.." (reset the previous state of the old sound, if playing) @@ -2595,12 +2679,14 @@ function SoundManager(smURL, smID) { */ if (_useGlobalHTML5Audio && _a._t && _a._t.playState && _iO.url !== _oldIO.url) { + _a._t.stop(); + } // reset load/playstate, onPosition etc. if the URL is new. // somewhat-tricky object re-use vs. new SMSound object, old vs. new URL comparisons - _resetProperties((_oldIO.url ? _iO.url === _oldIO.url : (_lastURL ? _lastURL === _iO.url : false))); + _resetProperties((_oldIO && _oldIO.url ? _iO.url === _oldIO.url : (_lastURL ? _lastURL === _iO.url : false))); _a.src = _iO.url; _t.url = _iO.url; @@ -2609,13 +2695,28 @@ function SoundManager(smURL, smID) { } else { - _s._wD('creating HTML5 Audio() element with URL: '+_dURL); - _a = new Audio(_iO.url); + _wDS('h5a'); + + if (_iO.autoLoad || _iO.autoPlay) { + + _t._a = new Audio(_iO.url); + + } else { + + // null for stupid Opera 9.64 case + _t._a = (_isOpera ? new Audio(null) : new Audio()); + + } + + // assign local reference + _a = _t._a; _a._called_load = false; if (_useGlobalHTML5Audio) { + _s._global_a = _a; + } } @@ -2641,13 +2742,8 @@ function SoundManager(smURL, smID) { // early HTML5 implementation (non-standard) _a.autobuffer = false; - // standard - _a.preload = 'none'; - - if (!_mobileHTML5) { - // android 2.3 doesn't like load() -> play(). Others do. - _t.load(); - } + // standard ('none' is also an option.) + _a.preload = 'auto'; } @@ -2667,7 +2763,6 @@ function SoundManager(smURL, smID) { return _t._a ? _t._a.addEventListener(oEvt, oFn, bCapture||false) : null; } - _s._wD(_h5+'adding event listeners: '+_t.sID); _t._a._added_events = true; for (f in _html5_events) { @@ -2690,7 +2785,7 @@ function SoundManager(smURL, smID) { return (_t._a ? _t._a.removeEventListener(oEvt, oFn, bCapture||false) : null); } - _s._wD(_h5+'removing event listeners: '+_t.sID); + _s._wD(_h5+'removing event listeners: '+_t.id); _t._a._added_events = false; for (f in _html5_events) { @@ -2709,11 +2804,13 @@ function SoundManager(smURL, smID) { this._onload = function(nSuccess) { - var fN, loadOK = !!(nSuccess); + var fN, + // check for duration to prevent false positives from flash 8 when loading from cache. + loadOK = (!!(nSuccess) || (!_t.isHTML5 && _fV === 8 && _t.duration)); // fN = 'SMSound._onload(): '; - _s._wD(fN + '"' + _t.sID + '"' + (loadOK?' loaded.':' failed to load? - ' + _t.url), (loadOK?1:2)); + _s._wD(fN + '"' + _t.id + '"' + (loadOK?' loaded.':' failed to load? - ' + _t.url), (loadOK?1:2)); if (!loadOK && !_t.isHTML5) { if (_s.sandbox.noRemote === true) { _s._wD(fN + _str('noNet'), 1); @@ -2781,7 +2878,7 @@ function SoundManager(smURL, smID) { this._onfailure = function(msg, level, code) { _t.failures++; - _s._wD('SMSound._onfailure(): "'+_t.sID+'" count '+_t.failures); + _s._wD('SMSound._onfailure(): "'+_t.id+'" count '+_t.failures); if (_t._iO.onfailure && _t.failures === 1) { _t._iO.onfailure(_t, msg, level, code); @@ -2817,12 +2914,17 @@ function SoundManager(smURL, smID) { _t._iO = {}; _stop_html5_timer(); + // reset position, too + if (_t.isHTML5) { + _t.position = 0; + } + } if (!_t.instanceCount || _t._iO.multiShotEvents) { // fire onfinish for last, or every instance if (_io_onfinish) { - _s._wD('SMSound._onfinish(): "' + _t.sID + '"'); + _s._wD('SMSound._onfinish(): "' + _t.id + '"'); _io_onfinish.apply(_t); } } @@ -2843,30 +2945,35 @@ function SoundManager(smURL, smID) { if (!_iO.isMovieStar) { if (_iO.duration) { - // use options, if specified and larger + // use duration from options, if specified and larger _t.durationEstimate = (_t.duration > _iO.duration) ? _t.duration : _iO.duration; } else { _t.durationEstimate = parseInt((_t.bytesTotal / _t.bytesLoaded) * _t.duration, 10); - } if (typeof _t.durationEstimate === 'undefined') { _t.durationEstimate = _t.duration; } - if (_t.readyState !== 3 && _iO.whileloading) { - _iO.whileloading.apply(_t); - } - } else { _t.durationEstimate = _t.duration; - if (_t.readyState !== 3 && _iO.whileloading) { - _iO.whileloading.apply(_t); - } } + // for flash, reflect sequential-load-style buffering + if (!_t.isHTML5) { + _t.buffered = [{ + 'start': 0, + 'end': _t.duration + }]; + } + + // allow whileloading to fire even if "load" fired under HTML5, due to HTTP range/partials + if ((_t.readyState !== 3 || _t.isHTML5) && _iO.whileloading) { + _iO.whileloading.apply(_t); + } + }; this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) { @@ -2879,7 +2986,9 @@ function SoundManager(smURL, smID) { return false; } - _t.position = nPosition; + // Safari HTML5 play() may return small -ve values when starting from position: 0, eg. -50.120396875. Unexpected/invalid per W3, I think. Normalize to 0. + _t.position = Math.max(0, nPosition); + _t._processOnPosition(); if (!_t.isHTML5 && _fV > 8) { @@ -2937,7 +3046,7 @@ function SoundManager(smURL, smID) { * @param {object} oData */ - _s._wD('SMSound._oncaptiondata(): "' + this.sID + '" caption data received.'); + _s._wD('SMSound._oncaptiondata(): "' + this.id + '" caption data received.'); _t.captiondata = oData; @@ -2957,7 +3066,7 @@ function SoundManager(smURL, smID) { * @param {array} oMDData (values) */ - _s._wD('SMSound._onmetadata(): "' + this.sID + '" metadata received.'); + _s._wD('SMSound._onmetadata(): "' + this.id + '" metadata received.'); var oData = {}, i, j; @@ -2982,7 +3091,7 @@ function SoundManager(smURL, smID) { * @param {array} oID3Data (values) */ - _s._wD('SMSound._onid3(): "' + this.sID + '" ID3 data received.'); + _s._wD('SMSound._onid3(): "' + this.id + '" ID3 data received.'); var oData = [], i, j; @@ -3002,14 +3111,14 @@ function SoundManager(smURL, smID) { this._onconnect = function(bSuccess) { bSuccess = (bSuccess === 1); - _s._wD('SMSound._onconnect(): "'+_t.sID+'"'+(bSuccess?' connected.':' failed to connect? - '+_t.url), (bSuccess?1:2)); + _s._wD('SMSound._onconnect(): "'+_t.id+'"'+(bSuccess?' connected.':' failed to connect? - '+_t.url), (bSuccess?1:2)); _t.connected = bSuccess; if (bSuccess) { _t.failures = 0; - if (_idCheck(_t.sID)) { + if (_idCheck(_t.id)) { if (_t.getAutoPlay()) { // only update the play state if auto playing _t.play(undefined, _t.getAutoPlay()); @@ -3061,25 +3170,183 @@ function SoundManager(smURL, smID) { _mixin = function(oMain, oAdd) { // non-destructive merge - var o1 = {}, i, o2, o; + var o1 = (oMain || {}), o2, o; - // clone c1 - for (i in oMain) { - if (oMain.hasOwnProperty(i)) { - o1[i] = oMain[i]; - } - } + // if unspecified, o2 is the default options object + o2 = (typeof oAdd === 'undefined' ? _s.defaultOptions : oAdd); - o2 = (typeof oAdd === 'undefined'?_s.defaultOptions:oAdd); for (o in o2) { + if (o2.hasOwnProperty(o) && typeof o1[o] === 'undefined') { - o1[o] = o2[o]; + + if (typeof o2[o] !== 'object' || o2[o] === null) { + + // assign directly + o1[o] = o2[o]; + + } else { + + // recurse through o2 + o1[o] = _mixin(o1[o], o2[o]); + + } + } + } + return o1; }; + // additional soundManager properties that soundManager.setup() will accept + + _extraOptions = { + 'onready': 1, + 'ontimeout': 1, + 'defaultOptions': 1, + 'flash9Options': 1, + 'movieStarOptions': 1 + }; + + _assign = function(o, oParent) { + + /** + * recursive assignment of properties, soundManager.setup() helper + * allows property assignment based on whitelist + */ + + var i, + result = true, + hasParent = (typeof oParent !== 'undefined'), + setupOptions = _s.setupOptions, + extraOptions = _extraOptions; + + // + + // if soundManager.setup() called, show accepted parameters. + + if (typeof o === 'undefined') { + + result = []; + + for (i in setupOptions) { + + if (setupOptions.hasOwnProperty(i)) { + result.push(i); + } + + } + + for (i in extraOptions) { + + if (extraOptions.hasOwnProperty(i)) { + + if (typeof _s[i] === 'object') { + + result.push(i+': {...}'); + + } else if (_s[i] instanceof Function) { + + result.push(i+': function() {...}'); + + } else { + + result.push(i); + + } + + } + + } + + _s._wD(_str('setup', result.join(', '))); + + return false; + + } + + // + + for (i in o) { + + if (o.hasOwnProperty(i)) { + + // if not an {object} we want to recurse through... + + if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array) { + + // check "allowed" options + + if (hasParent && typeof extraOptions[oParent] !== 'undefined') { + + // valid recursive / nested object option, eg., { defaultOptions: { volume: 50 } } + _s[oParent][i] = o[i]; + + } else if (typeof setupOptions[i] !== 'undefined') { + + // special case: assign to setupOptions object, which soundManager property references + _s.setupOptions[i] = o[i]; + + // assign directly to soundManager, too + _s[i] = o[i]; + + } else if (typeof extraOptions[i] === 'undefined') { + + // invalid or disallowed parameter. complain. + _complain(_str((typeof _s[i] === 'undefined' ? 'setupUndef' : 'setupError'), i), 2); + + result = false; + + } else { + + /** + * valid extraOptions parameter. + * is it a method, like onready/ontimeout? call it. + * multiple parameters should be in an array, eg. soundManager.setup({onready: [myHandler, myScope]}); + */ + + if (_s[i] instanceof Function) { + + _s[i].apply(_s, (o[i] instanceof Array? o[i] : [o[i]])); + + } else { + + // good old-fashioned direct assignment + _s[i] = o[i]; + + } + + } + + } else { + + // recursion case, eg., { defaultOptions: { ... } } + + if (typeof extraOptions[i] === 'undefined') { + + // invalid or disallowed parameter. complain. + _complain(_str((typeof _s[i] === 'undefined' ? 'setupUndef' : 'setupError'), i), 2); + + result = false; + + } else { + + // recurse through object + return _assign(o[i], i); + + } + + } + + } + + } + + return result; + + }; + _event = (function() { var old = (_win.attachEvent), @@ -3139,6 +3406,13 @@ function SoundManager(smURL, smID) { }()); + function _preferFlashCheck(kind) { + + // whether flash should play a given type + return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind])); + + } + /** * Internal HTML5 event handling * ----------------------------- @@ -3155,8 +3429,8 @@ function SoundManager(smURL, smID) { if (!t || !t._a) { // - if (t && t.sID) { - _s._wD(_h5+'ignoring '+e.type+': '+t.sID); + if (t && t.id) { + _s._wD(_h5+'ignoring '+e.type+': '+t.id); } else { _s._wD(_h5+'ignoring '+e.type); } @@ -3178,7 +3452,7 @@ function SoundManager(smURL, smID) { abort: _html5_event(function() { - _s._wD(_h5+'abort: '+this._t.sID); + _s._wD(_h5+'abort: '+this._t.id); }), @@ -3195,9 +3469,11 @@ function SoundManager(smURL, smID) { } t._html5_canplay = true; - _s._wD(_h5+'canplay: '+t.sID+', '+t.url); + _s._wD(_h5+'canplay: '+t.id+', '+t.url); t._onbufferchange(0); - position1K = (!isNaN(t.position)?t.position/1000:null); + + // position according to instance options + position1K = (typeof t._iO.position !== 'undefined' && !isNaN(t._iO.position)?t._iO.position/1000:null); // set the position if position was set before the sound loaded if (t.position && this.currentTime !== position1K) { @@ -3205,7 +3481,7 @@ function SoundManager(smURL, smID) { try { this.currentTime = position1K; } catch(ee) { - _s._wD(_h5+'setting position failed: '+ee.message, 2); + _s._wD(_h5+'setting position of ' + position1K + ' failed: '+ee.message, 2); } } @@ -3216,14 +3492,13 @@ function SoundManager(smURL, smID) { }), - load: _html5_event(function() { + canplaythrough: _html5_event(function() { var t = this._t; if (!t.loaded) { t._onbufferchange(0); - // should be 1, and the same - t._whileloading(t.bytesTotal, t.bytesTotal, t._get_html5_duration()); + t._whileloading(t.bytesLoaded, t.bytesTotal, t._get_html5_duration()); t._onload(true); } @@ -3233,7 +3508,7 @@ function SoundManager(smURL, smID) { /* emptied: _html5_event(function() { - _s._wD(_h5+'emptied: '+this._t.sID); + _s._wD(_h5+'emptied: '+this._t.id); }), */ @@ -3242,7 +3517,7 @@ function SoundManager(smURL, smID) { var t = this._t; - _s._wD(_h5+'ended: '+t.sID); + _s._wD(_h5+'ended: '+t.id); t._onfinish(); }), @@ -3257,31 +3532,26 @@ function SoundManager(smURL, smID) { loadeddata: _html5_event(function() { - var t = this._t, - // at least 1 byte, so math works - bytesTotal = t.bytesTotal || 1; + var t = this._t; - _s._wD(_h5+'loadeddata: '+this._t.sID); + _s._wD(_h5+'loadeddata: '+this._t.id); // safari seems to nicely report progress events, eventually totalling 100% if (!t._loaded && !_isSafari) { t.duration = t._get_html5_duration(); - // fire whileloading() with 100% values - t._whileloading(bytesTotal, bytesTotal, t._get_html5_duration()); - t._onload(true); } }), loadedmetadata: _html5_event(function() { - _s._wD(_h5+'loadedmetadata: '+this._t.sID); + _s._wD(_h5+'loadedmetadata: '+this._t.id); }), loadstart: _html5_event(function() { - _s._wD(_h5+'loadstart: '+this._t.sID); + _s._wD(_h5+'loadstart: '+this._t.id); // assume buffering at first this._t._onbufferchange(1); @@ -3289,7 +3559,7 @@ function SoundManager(smURL, smID) { play: _html5_event(function() { - _s._wD(_h5+'play: '+this._t.sID+', '+this._t.url); + _s._wD(_h5+'play: '+this._t.id+', '+this._t.url); // once play starts, no buffering this._t._onbufferchange(0); @@ -3297,7 +3567,7 @@ function SoundManager(smURL, smID) { playing: _html5_event(function() { - _s._wD(_h5+'playing: '+this._t.sID); + _s._wD(_h5+'playing: '+this._t.id); // once play starts, no buffering this._t._onbufferchange(0); @@ -3306,6 +3576,8 @@ function SoundManager(smURL, smID) { progress: _html5_event(function(e) { + // note: can fire repeatedly after "loaded" event, due to use of HTTP range/partials + var t = this._t, i, j, str, buffered = 0, isProgress = (e.type === 'progress'), @@ -3314,19 +3586,25 @@ function SoundManager(smURL, smID) { loaded = (e.loaded||0), total = (e.total||1); - if (t.loaded) { - return false; - } + // reset the "buffered" (loaded byte ranges) array + t.buffered = []; if (ranges && ranges.length) { // if loaded is 0, try TimeRanges implementation as % of load // https://developer.mozilla.org/en/DOM/TimeRanges - for (i=ranges.length-1; i >= 0; i--) { - buffered = (ranges.end(i) - ranges.start(i)); + // re-build "buffered" array + for (i=0, j=ranges.length; i @@ -3351,10 +3629,11 @@ function SoundManager(smURL, smID) { // if progress, likely not buffering t._onbufferchange(0); + // TODO: prevent calls with duplicate values. t._whileloading(loaded, total, t._get_html5_duration()); if (loaded && total && loaded === total) { // in case "onload" doesn't fire (eg. gecko 1.9.2) - _html5_events.load.call(this, e); + _html5_events.canplaythrough.call(this, e); } } @@ -3363,7 +3642,7 @@ function SoundManager(smURL, smID) { ratechange: _html5_event(function() { - _s._wD(_h5+'ratechange: '+this._t.sID); + _s._wD(_h5+'ratechange: '+this._t.id); }), @@ -3372,7 +3651,7 @@ function SoundManager(smURL, smID) { // download paused/stopped, may have finished (eg. onload) var t = this._t; - _s._wD(_h5+'suspend: '+t.sID); + _s._wD(_h5+'suspend: '+t.id); _html5_events.progress.call(this, e); t._onsuspend(); @@ -3380,7 +3659,7 @@ function SoundManager(smURL, smID) { stalled: _html5_event(function() { - _s._wD(_h5+'stalled: '+this._t.sID); + _s._wD(_h5+'stalled: '+this._t.id); }), @@ -3395,7 +3674,7 @@ function SoundManager(smURL, smID) { var t = this._t; // see also: seeking - _s._wD(_h5+'waiting: '+t.sID); + _s._wD(_h5+'waiting: '+t.id); // playback faster than download rate, etc. t._onbufferchange(1); @@ -3406,23 +3685,39 @@ function SoundManager(smURL, smID) { _html5OK = function(iO) { - // Use type, if specified. If HTML5-only mode, no other options, so just give 'er - return (!iO.serverURL && (iO.type?_html5CanPlay({type:iO.type}):_html5CanPlay({url:iO.url})||_s.html5Only)); + // playability test based on URL or MIME type + + var result; + + if (iO.serverURL || (iO.type && _preferFlashCheck(iO.type))) { + + // RTMP, or preferring flash + result = false; + + } else { + + // Use type, if specified. If HTML5-only mode, no other options, so just give 'er + result = ((iO.type ? _html5CanPlay({type:iO.type}) : _html5CanPlay({url:iO.url}) || _s.html5Only)); + + } + + return result; }; - _html5Unload = function(oAudio) { + _html5Unload = function(oAudio, url) { /** * Internal method: Unload media, and cancel any current/pending network requests. * Firefox can load an empty URL, which allegedly destroys the decoder and stops the download. * https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Stopping_the_download_of_media + * However, Firefox has been seen loading a relative URL from '' and thus requesting the hosting page on unload. * Other UA behaviour is unclear, so everyone else gets an about:blank-style URL. */ if (oAudio) { - // Firefox likes '' for unload, most other UAs don't and fail to unload. - oAudio.src = (_is_firefox ? '' : _emptyURL); + // Firefox likes '' for unload (used to work?) - however, may request hosting page URL (bad.) Most other UAs dislike '' and fail to unload. + oAudio.src = url; } }; @@ -3449,17 +3744,10 @@ function SoundManager(smURL, smID) { fileExt, item; - function preferFlashCheck(kind) { - - // whether flash should play a given type - return (_s.preferFlash && _hasFlash && !_s.ignoreFlash && (typeof _s.flash[kind] !== 'undefined' && _s.flash[kind])); - - } - // account for known cases like audio/mp3 if (mime && typeof _s.html5[mime] !== 'undefined') { - return (_s.html5[mime] && !preferFlashCheck(mime)); + return (_s.html5[mime] && !_preferFlashCheck(mime)); } if (!_html5Ext) { @@ -3494,13 +3782,13 @@ function SoundManager(smURL, smID) { if (fileExt && typeof _s.html5[fileExt] !== 'undefined') { // result known - result = (_s.html5[fileExt] && !preferFlashCheck(fileExt)); + result = (_s.html5[fileExt] && !_preferFlashCheck(fileExt)); } else { mime = 'audio/'+fileExt; result = _s.html5.canPlayType({type:mime}); _s.html5[fileExt] = result; // _s._wD('canPlayType, found result: '+result); - result = (result && _s.html5[mime] && !preferFlashCheck(mime)); + result = (result && _s.html5[mime] && !_preferFlashCheck(mime)); } return result; @@ -3515,7 +3803,7 @@ function SoundManager(smURL, smID) { // 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. :/ var a = (typeof Audio !== 'undefined' ? (_isOpera ? new Audio(null) : new Audio()) : null), - item, support = {}, aF, i; + item, lookup, support = {}, aF, i; function _cp(m) { @@ -3533,8 +3821,8 @@ function SoundManager(smURL, smID) { if (_s.html5[m[i]] || a.canPlayType(m[i]).match(_s.html5Test)) { isOK = true; _s.html5[m[i]] = true; - // if flash can play and preferred, also mark it for use. - _s.flash[m[i]] = !!(_s.preferFlash && _hasFlash && m[i].match(_flashMIME)); + // note flash support, too + _s.flash[m[i]] = !!(m[i].match(_flashMIME)); } } result = isOK; @@ -3552,29 +3840,46 @@ function SoundManager(smURL, smID) { aF = _s.audioFormats; for (item in aF) { + if (aF.hasOwnProperty(item)) { + + lookup = 'audio/' + item; + support[item] = _cp(aF[item].type); // write back generic type too, eg. audio/mp3 - support['audio/'+item] = support[item]; + support[lookup] = support[item]; // assign flash - if (_s.preferFlash && !_s.ignoreFlash && item.match(_flashMIME)) { + if (item.match(_flashMIME)) { + _s.flash[item] = true; + _s.flash[lookup] = true; + } else { + _s.flash[item] = false; + _s.flash[lookup] = false; + } // assign result to related formats, too + if (aF[item] && aF[item].related) { + for (i=aF[item].related.length-1; i >= 0; i--) { + // eg. audio/m4a support['audio/'+aF[item].related[i]] = support[item]; _s.html5[aF[item].related[i]] = support[item]; _s.flash[aF[item].related[i]] = support[item]; + } + } + } + } support.canPlayType = (a?_cp:null); @@ -3587,7 +3892,7 @@ function SoundManager(smURL, smID) { _strings = { // - notReady: 'Not loaded yet - wait for soundManager.onload()/onready()', + notReady: 'Not loaded yet - wait for soundManager.onready()', notOK: 'Audio support is not available.', domError: _smc + 'createMovie(): appendChild/innerHTML call failed. DOM not ready or other error.', spcWmode: _smc + 'createMovie(): Removing wmode, preventing known SWF loading issue(s)', @@ -3627,7 +3932,12 @@ function SoundManager(smURL, smID) { 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' + policy: 'Enabling usePolicyFile for data access', + setup: _sm + '.setup(): allowed parameters: %s', + setupError: _sm + '.setup(): "%s" cannot be assigned with this method.', + setupUndef: _sm + '.setup(): Could not find option "%s"', + setupLate: _sm + '.setup(): url + flashVersion changes will not take effect until reboot().', + h5a: 'creating HTML5 Audio() object' // }; @@ -4137,6 +4447,7 @@ function SoundManager(smURL, smID) { var needsFlash, item, result = true, + formats = _s.audioFormats, // iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (original iPad) + iOS4 works. isSpecial = (_is_iDevice && !!(_ua.match(/os (1|2|3_0|3_1)/i))); @@ -4177,9 +4488,9 @@ function SoundManager(smURL, smID) { if (_s.useHTML5Audio && _s.hasHTML5) { - for (item in _s.audioFormats) { - if (_s.audioFormats.hasOwnProperty(item)) { - if ((_s.audioFormats[item].required && !_s.html5.canPlayType(_s.audioFormats[item].type)) || _s.flash[item] || _s.flash[_s.audioFormats[item].type]) { + for (item in formats) { + if (formats.hasOwnProperty(item)) { + if ((formats[item].required && !_s.html5.canPlayType(formats[item].type)) || (_s.preferFlash && (_s.flash[item] || _s.flash[formats[item].type]))) { // flash may be required, or preferred for this format needsFlash = true; } @@ -4898,6 +5209,40 @@ function SoundManager(smURL, smID) { }; + /** + * apply top-level setupOptions object as local properties, eg., this.setupOptions.flashVersion -> this.flashVersion (soundManager.flashVersion) + * this maintains backward compatibility, and allows properties to be defined separately for use by soundManager.setup(). + */ + + _setProperties = function() { + + var i, + o = _s.setupOptions; + + for (i in o) { + + if (o.hasOwnProperty(i)) { + + // assign local property if not already defined + + if (typeof _s[i] === 'undefined') { + + _s[i] = o[i]; + + } else if (_s[i] !== o[i]) { + + // legacy support: write manually-assigned property (eg., soundManager.url) back to setupOptions to keep things in sync + _s.setupOptions[i] = _s[i]; + + } + + } + + } + + }; + + _init = function() { _wDS('init'); @@ -4980,6 +5325,10 @@ function SoundManager(smURL, smID) { } _didDCLoaded = true; + + // assign top-level soundManager properties eg. soundManager.url + _setProperties(); + _initDebug(); /** @@ -4989,15 +5338,21 @@ function SoundManager(smURL, smID) { // (function(){ - var a = 'sm2-usehtml5audio=', l = _wl.toLowerCase(), b = null, - a2 = 'sm2-preferflash=', b2 = null, hasCon = (typeof console !== 'undefined' && typeof console.log === 'function'); + var a = 'sm2-usehtml5audio=', + a2 = 'sm2-preferflash=', + b = null, + b2 = null, + hasCon = (typeof console !== 'undefined' && typeof console.log === 'function'), + l = _wl.toLowerCase(); if (l.indexOf(a) !== -1) { b = (l.charAt(l.indexOf(a)+a.length) === '1'); if (hasCon) { console.log((b?'Enabling ':'Disabling ')+'useHTML5Audio via URL parameter'); } - _s.useHTML5Audio = b; + _s.setup({ + 'useHTML5Audio': b + }); } if (l.indexOf(a2) !== -1) { @@ -5005,7 +5360,9 @@ function SoundManager(smURL, smID) { if (hasCon) { console.log((b2?'Enabling ':'Disabling ')+'preferFlash via URL parameter'); } - _s.preferFlash = b2; + _s.setup({ + 'preferFlash': b2 + }); } }()); @@ -5013,10 +5370,12 @@ function SoundManager(smURL, smID) { if (!_hasFlash && _s.hasHTML5) { _s._wD('SoundManager: No Flash detected'+(!_s.useHTML5Audio?', enabling HTML5.':'. Trying HTML5-only mode.')); - _s.useHTML5Audio = true; - // make sure we aren't preferring flash, either - // TODO: preferFlash should not matter if flash is not installed. Currently, stuff breaks without the below tweak. - _s.preferFlash = false; + _s.setup({ + 'useHTML5Audio': true, + // make sure we aren't preferring flash, either + // TODO: preferFlash should not matter if flash is not installed. Currently, stuff breaks without the below tweak. + 'preferFlash': false + }); } _testHTML5(); @@ -5028,7 +5387,9 @@ function SoundManager(smURL, smID) { _s._wD('SoundManager: Fatal error: Flash is needed to play some required formats, but is not available.'); // TODO: Fatal here vs. timeout approach, etc. // hack: fail sooner. - _s.flashLoadTimeout = 1; + _s.setup({ + 'flashLoadTimeout': 1 + }); } if (_doc.removeEventListener) { diff --git a/static/js/dss_sound_handler.js b/static/js/old__dss_sound_handler.js similarity index 93% rename from static/js/dss_sound_handler.js rename to static/js/old__dss_sound_handler.js index 36b5b6a..0e17222 100644 --- a/static/js/dss_sound_handler.js +++ b/static/js/old__dss_sound_handler.js @@ -1,11 +1,3 @@ -$(document).ready(function () { - soundManager.url = '/static/bin/sm/'; - soundManager.flashVersion = 9; - soundManager.debugMode = false; - soundManager.useHTML5Audio = true; - soundManager.preferFlash = false; -}); - function DssSoundHandler() { var _currentSound = null; var _currentId = -1; diff --git a/templates/base.html b/templates/base.html index 68b11da..a984e9a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -85,7 +85,7 @@ - + diff --git a/templates/javascript/settings.js b/templates/javascript/settings.js index dc658e0..cca83c4 100644 --- a/templates/javascript/settings.js +++ b/templates/javascript/settings.js @@ -2,11 +2,11 @@ if (!com) var com = {}; if (!com.podnoms) com.podnoms = {}; com.podnoms.settings = { - urlRoot: '{{ API_URL }}', - liveStreamRoot: 'http://{{ LIVE_STREAM_URL }}:{{ LIVE_STREAM_PORT }}/{{ LIVE_STREAM_MOUNT }}', - streamInfoUrl: 'http://{{ LIVE_STREAM_INFO_URL }}', - volume: '{{ DEFAULT_AUDIO_VOLUME }}', - setupPlayer: function(data, id){ + urlRoot:'{{ API_URL }}', + liveStreamRoot:'http://{{ LIVE_STREAM_URL }}:{{ LIVE_STREAM_PORT }}/{{ LIVE_STREAM_MOUNT }}', + streamInfoUrl:'http://{{ LIVE_STREAM_INFO_URL }}', + volume:'{{ DEFAULT_AUDIO_VOLUME }}', + setupPlayer:function (data, id) { com.podnoms.player.setupPlayer({ id:id, waveFormEl:$('#waveform-' + id), @@ -17,4 +17,4 @@ com.podnoms.settings = { url:data.stream_url }); } -}; \ No newline at end of file +};