123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724 |
- (function(window, _undefined) {
- "use strict";
- 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','m4b'],
- '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
- },
- 'opus': {
- 'type': ['audio/ogg; codecs=opus', 'audio/opus'],
- '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.20130324';
- 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 = {
-
- 'type': null,
- 'types': {
- 'remote': 'remote (domain-based) rules',
- 'localWithFile': 'local with file access (no internet access)',
- 'localWithNetwork': 'local with network (internet access only, no local access)',
- 'localTrusted': 'local, trusted (local+internet access)'
- },
- 'description': null,
- 'noRemote': null,
- 'noLocal': null
-
- };
-
- this.html5 = {
- 'usingFlash': null
- };
-
- this.flash = {};
-
- this.html5Only = false;
-
- this.ignoreFlash = false;
-
- var SMSound,
- sm2 = this, globalHTML5Audio = null, flash = null, sm = 'soundManager', smc = sm + ': ', h5 = 'HTML5::', id, ua = navigator.userAgent, wl = window.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, preInit, 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, messages = [],
- needsFlash = null, featureCheck, html5OK, html5CanPlay, html5Ext, html5Unload, domContentLoadedIE, testHTML5, event, slice = Array.prototype.slice, useGlobalHTML5Audio = false, lastGlobalHTML5URL, hasFlash, detectFlash, badSafariFix, html5_events, showSupport, flushMessages, wrapCallback,
- is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/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 || isAndroid),
- 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 = (window.console !== _undefined && console.log !== _undefined), isFocused = (doc.hasFocus !== _undefined?doc.hasFocus():null), tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())), okToDisable = !tryInitOnFocus, flashMIME = /(mp3|mp4|mpa|m4a|m4b)/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|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,
-
- netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'],
- netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');
- this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;
-
- this.useAltURL = !overHTTP;
- swfCSS = {
- 'swfBox': 'sm2-object-box',
- 'swfDefault': 'movieContainer',
- 'swfError': 'swf_error',
- 'swfTimedout': 'swf_timedout',
- 'swfLoaded': 'swf_loaded',
- 'swfUnblocked': 'swf_unblocked',
- 'sm2Debug': 'sm2_debug',
- 'highPerf': 'high_performance',
- 'flashDebug': 'flash_debug'
- };
-
- this.hasHTML5 = (function() {
- try {
-
- return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined);
- } catch(e) {
- return false;
- }
- }());
-
-
- this.setup = function(options) {
- var noURL = (!sm2.url);
-
- if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) {
- complain(str('setupLate'));
- }
-
- assign(options);
-
- if (noURL && didDCLoaded && options.url !== _undefined) {
- sm2.beginDelayedInit();
- }
-
- if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') {
- setTimeout(domContentLoaded, 1);
- }
- return sm2;
- };
- this.ok = function() {
- return (needsFlash?(didInit && !disabled):(sm2.useHTML5Audio && sm2.hasHTML5));
- };
- this.supported = this.ok;
- this.getMovie = function(smID) {
-
- return id(smID) || doc[smID] || window[smID];
- };
-
- this.createSound = function(oOptions, _url) {
- var cs, cs_string, options, oSound = null;
-
- cs = sm + '.createSound(): ';
- cs_string = cs + str(!didInit?'notReady':'notOK');
-
- if (!didInit || !sm2.ok()) {
- complain(cs_string);
- return false;
- }
- if (_url !== _undefined) {
-
- oOptions = {
- 'id': oOptions,
- 'url': _url
- };
- }
-
- options = mixin(oOptions);
- options.url = parseURL(options.url);
-
- if (options.id.toString().charAt(0).match(/^[0-9]$/)) {
- sm2._wD(cs + str('badID', options.id), 2);
- }
- sm2._wD(cs + options.id + ' (' + options.url + ')', 1);
-
- if (idCheck(options.id, true)) {
- sm2._wD(cs + options.id + ' exists', 1);
- return sm2.sounds[options.id];
- }
- function make() {
- options = loopFix(options);
- sm2.sounds[options.id] = new SMSound(options);
- sm2.soundIDs.push(options.id);
- return sm2.sounds[options.id];
- }
- if (html5OK(options)) {
- oSound = make();
- sm2._wD(options.id + ': Using HTML5');
- oSound._setup_html5(options);
- } else {
- if (fV > 8) {
- if (options.isMovieStar === null) {
-
- options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || options.url.match(netStreamPattern));
- }
-
- if (options.isMovieStar) {
- sm2._wD(cs + 'using MovieStar handling');
- if (options.loops > 1) {
- _wDS('noNSLoop');
- }
- }
-
- }
- options = policyFix(options, cs);
- oSound = make();
- if (fV === 8) {
- flash._createSound(options.id, options.loops||1, options.usePolicyFile);
- } else {
- flash._createSound(options.id, options.url, options.usePeakData, options.useWaveformData, options.useEQData, options.isMovieStar, (options.isMovieStar?options.bufferTime:false), options.loops||1, options.serverURL, options.duration||null, options.autoPlay, true, options.autoLoad, options.usePolicyFile);
- if (!options.serverURL) {
-
- oSound.connected = true;
- if (options.onconnect) {
- options.onconnect.apply(oSound);
- }
- }
- }
- if (!options.serverURL && (options.autoLoad || options.autoPlay)) {
-
- oSound.load(options);
- }
- }
-
- if (!options.serverURL && options.autoPlay) {
- oSound.play();
- }
- return oSound;
- };
-
- this.destroySound = function(sID, _bFromSound) {
-
- if (!idCheck(sID)) {
- return false;
- }
- var oS = sm2.sounds[sID], i;
-
- oS._iO = {};
- oS.stop();
- oS.unload();
- for (i = 0; i < sm2.soundIDs.length; i++) {
- if (sm2.soundIDs[i] === sID) {
- sm2.soundIDs.splice(i, 1);
- break;
- }
- }
- if (!_bFromSound) {
-
- oS.destruct(true);
- }
- oS = null;
- delete sm2.sounds[sID];
- return true;
- };
-
- this.load = function(sID, oOptions) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].load(oOptions);
- };
-
- this.unload = function(sID) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].unload();
- };
-
- this.onPosition = function(sID, nPosition, oMethod, oScope) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].onposition(nPosition, oMethod, oScope);
- };
-
- this.onposition = this.onPosition;
-
- this.clearOnPosition = function(sID, nPosition, oMethod) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].clearOnPosition(nPosition, oMethod);
- };
-
- this.play = function(sID, oOptions) {
- var result = false;
- if (!didInit || !sm2.ok()) {
- complain(sm + '.play(): ' + str(!didInit?'notReady':'notOK'));
- return result;
- }
- if (!idCheck(sID)) {
- if (!(oOptions instanceof Object)) {
-
- oOptions = {
- url: oOptions
- };
- }
- if (oOptions && oOptions.url) {
-
- sm2._wD(sm + '.play(): attempting to create "' + sID + '"', 1);
- oOptions.id = sID;
- result = sm2.createSound(oOptions).play();
- }
- return result;
- }
- return sm2.sounds[sID].play(oOptions);
- };
- this.start = this.play;
-
- this.setPosition = function(sID, nMsecOffset) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].setPosition(nMsecOffset);
- };
-
- this.stop = function(sID) {
- if (!idCheck(sID)) {
- return false;
- }
- sm2._wD(sm + '.stop(' + sID + ')', 1);
- return sm2.sounds[sID].stop();
- };
-
- this.stopAll = function() {
- var oSound;
- sm2._wD(sm + '.stopAll()', 1);
- for (oSound in sm2.sounds) {
- if (sm2.sounds.hasOwnProperty(oSound)) {
-
- sm2.sounds[oSound].stop();
- }
- }
- };
-
- this.pause = function(sID) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].pause();
- };
-
- this.pauseAll = function() {
- var i;
- for (i = sm2.soundIDs.length-1; i >= 0; i--) {
- sm2.sounds[sm2.soundIDs[i]].pause();
- }
- };
-
- this.resume = function(sID) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].resume();
- };
-
- this.resumeAll = function() {
- var i;
- for (i = sm2.soundIDs.length-1; i >= 0; i--) {
- sm2.sounds[sm2.soundIDs[i]].resume();
- }
- };
-
- this.togglePause = function(sID) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].togglePause();
- };
-
- this.setPan = function(sID, nPan) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].setPan(nPan);
- };
-
- this.setVolume = function(sID, nVol) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.sounds[sID].setVolume(nVol);
- };
-
- this.mute = function(sID) {
- var i = 0;
- if (sID instanceof String) {
- sID = null;
- }
- if (!sID) {
- sm2._wD(sm + '.mute(): Muting all sounds');
- for (i = sm2.soundIDs.length-1; i >= 0; i--) {
- sm2.sounds[sm2.soundIDs[i]].mute();
- }
- sm2.muted = true;
- } else {
- if (!idCheck(sID)) {
- return false;
- }
- sm2._wD(sm + '.mute(): Muting "' + sID + '"');
- return sm2.sounds[sID].mute();
- }
- return true;
- };
-
- this.muteAll = function() {
- sm2.mute();
- };
-
- this.unmute = function(sID) {
- var i;
- if (sID instanceof String) {
- sID = null;
- }
- if (!sID) {
- sm2._wD(sm + '.unmute(): Unmuting all sounds');
- for (i = sm2.soundIDs.length-1; i >= 0; i--) {
- sm2.sounds[sm2.soundIDs[i]].unmute();
- }
- sm2.muted = false;
- } else {
- if (!idCheck(sID)) {
- return false;
- }
- sm2._wD(sm + '.unmute(): Unmuting "' + sID + '"');
- return sm2.sounds[sID].unmute();
- }
- return true;
- };
-
- this.unmuteAll = function() {
- sm2.unmute();
- };
-
- this.toggleMute = function(sID) {
- if (!idCheck(sID)) {
- return false;
- }
- return sm2.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 (bNoDisable === _undefined) {
- bNoDisable = false;
- }
- if (disabled) {
- return false;
- }
- disabled = true;
- _wDS('shutdown', 1);
- for (i = sm2.soundIDs.length-1; i >= 0; i--) {
- disableObject(sm2.sounds[sm2.soundIDs[i]]);
- }
-
- initComplete(bNoDisable);
- event.remove(window, 'load', initUserOnload);
- return true;
- };
-
- this.canPlayMIME = function(sMIME) {
- var result;
- if (sm2.hasHTML5) {
- result = html5CanPlay({type:sMIME});
- }
- if (!result && needsFlash) {
-
- result = (sMIME && sm2.ok() ? !!((fV > 8 ? sMIME.match(netStreamMimeTypes) : null) || sMIME.match(sm2.mimePattern)) : null);
- }
- return result;
- };
-
- this.canPlayURL = function(sURL) {
- var result;
- if (sm2.hasHTML5) {
- result = html5CanPlay({url: sURL});
- }
- if (!result && needsFlash) {
- result = (sURL && sm2.ok() ? !!(sURL.match(sm2.filePattern)) : null);
- }
- return result;
- };
-
- this.canPlayLink = function(oLink) {
- if (oLink.type !== _undefined && oLink.type) {
- if (sm2.canPlayMIME(oLink.type)) {
- return true;
- }
- }
- return sm2.canPlayURL(oLink.href);
- };
-
- this.getSoundById = function(sID, _suppressDebug) {
- if (!sID) {
- throw new Error(sm + '.getSoundById(): sID is null/_undefined');
- }
- var result = sm2.sounds[sID];
-
- if (!result && !_suppressDebug) {
- sm2._wD('"' + sID + '" is an invalid sound ID.', 2);
- }
-
- return result;
- };
-
- this.onready = function(oMethod, oScope) {
- var sType = 'onready',
- result = false;
- if (typeof oMethod === 'function') {
-
- if (didInit) {
- sm2._wD(str('queue', sType));
- }
-
- if (!oScope) {
- oScope = window;
- }
- 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 (didInit) {
- sm2._wD(str('queue', sType));
- }
-
- if (!oScope) {
- oScope = window;
- }
- addOnEvent(sType, oMethod, oScope);
- processOnEvents({type:sType});
- result = true;
- } else {
- throw str('needFunction', sType);
- }
- return result;
- };
-
- this._writeDebug = function(sText, sTypeOrObject) {
-
-
- var sDID = 'soundmanager-debug', o, oItem;
- if (!sm2.debugMode) {
- return false;
- }
- if (hasConsole && sm2.useConsole) {
- if (sTypeOrObject && typeof sTypeOrObject === 'object') {
-
- console.log(sText, sTypeOrObject);
- } else if (debugLevels[sTypeOrObject] !== _undefined) {
- console[debugLevels[sTypeOrObject]](sText);
- } else {
- console.log(sText);
- }
- if (sm2.consoleOnly) {
- return true;
- }
- }
- o = id(sDID);
- if (!o) {
- return false;
- }
- oItem = doc.createElement('div');
- if (++wdCount % 2 === 0) {
- oItem.className = 'sm2-alt';
- }
- if (sTypeOrObject === _undefined) {
- sTypeOrObject = 0;
- } else {
- sTypeOrObject = parseInt(sTypeOrObject, 10);
- }
- oItem.appendChild(doc.createTextNode(sText));
- if (sTypeOrObject) {
- if (sTypeOrObject >= 2) {
- oItem.style.fontWeight = 'bold';
- }
- if (sTypeOrObject === 3) {
- oItem.style.color = '#ff3333';
- }
- }
-
-
-
- o.insertBefore(oItem, o.firstChild);
- o = null;
-
- return true;
- };
-
-
- if (wl.indexOf('sm2-debug=alert') !== -1) {
- this._writeDebug = function(sText) {
- window.alert(sText);
- };
- }
-
-
- this._wD = this._writeDebug;
-
- this._debug = function() {
-
- var i, j;
- _wDS('currentObj', 1);
- for (i = 0, j = sm2.soundIDs.length; i < j; i++) {
- sm2.sounds[sm2.soundIDs[i]]._debug();
- }
-
- };
-
- this.reboot = function(resetEvents, excludeInit) {
-
-
- if (sm2.soundIDs.length) {
- sm2._wD('Destroying ' + sm2.soundIDs.length + ' SMSound objects...');
- }
-
- var i, j, k;
- for (i = sm2.soundIDs.length-1; i >= 0; i--) {
- sm2.sounds[sm2.soundIDs[i]].destruct();
- }
-
- if (flash) {
- try {
- if (isIE) {
- oRemovedHTML = flash.innerHTML;
- }
- oRemoved = flash.parentNode.removeChild(flash);
- _wDS('flRemoved');
- } catch(e) {
-
- _wDS('badRemove', 2);
- }
- }
-
- oRemovedHTML = oRemoved = needsFlash = flash = null;
- sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false;
- sm2.soundIDs = [];
- sm2.sounds = {};
- if (!resetEvents) {
-
- for (i in on_queue) {
- if (on_queue.hasOwnProperty(i)) {
- for (j = 0, k = on_queue[i].length; j < k; j++) {
- on_queue[i][j].fired = false;
- }
- }
- }
- } else {
-
- on_queue = [];
- }
-
- if (!excludeInit) {
- sm2._wD(sm + ': Rebooting...');
- }
-
-
- sm2.html5 = {
- 'usingFlash': null
- };
- sm2.flash = {};
-
- sm2.html5Only = false;
- sm2.ignoreFlash = false;
- window.setTimeout(function() {
- preInit();
-
- if (!excludeInit) {
- sm2.beginDelayedInit();
- }
- }, 20);
- return sm2;
- };
- this.reset = function() {
-
- _wDS('reset');
- return sm2.reboot(true, true);
- };
-
- this.getMoviePercent = function() {
-
- return (flash && 'PercentLoaded' in flash ? 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() {
- sm2._wD(sm + '.destruct()');
- sm2.disable(true);
- };
-
- SMSound = function(oOptions) {
- var s = 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() {
-
- sm2._wD(s.id + ': Merged options:', s.options);
-
- };
-
- this.load = function(oOptions) {
- var oSound = null, instanceOptions;
- if (oOptions !== _undefined) {
- s._iO = mixin(oOptions, s.options);
- } else {
- oOptions = s.options;
- s._iO = oOptions;
- if (lastURL && lastURL !== s.url) {
- _wDS('manURL');
- s._iO.url = s.url;
- s.url = null;
- }
- }
- if (!s._iO.url) {
- s._iO.url = s.url;
- }
- s._iO.url = parseURL(s._iO.url);
-
- s.instanceOptions = s._iO;
-
- instanceOptions = s._iO;
- sm2._wD(s.id + ': load (' + instanceOptions.url + ')');
- if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) {
- _wDS('onURL', 1);
-
- if (s.readyState === 3 && instanceOptions.onload) {
-
- wrapCallback(s, function() {
- instanceOptions.onload.apply(s, [(!!s.duration)]);
- });
- }
- return s;
- }
-
- s.loaded = false;
- s.readyState = 1;
- s.playState = 0;
- s.id3 = {};
-
- if (html5OK(instanceOptions)) {
- oSound = s._setup_html5(instanceOptions);
- if (!oSound._called_load) {
- s._html5_canplay = false;
-
-
- if (s.url !== instanceOptions.url) {
- sm2._wD(_wDS('manURL') + ': ' + instanceOptions.url);
- s._a.src = instanceOptions.url;
-
-
- s.setPosition(0);
- }
-
-
- s._a.autobuffer = 'auto';
-
- s._a.preload = 'auto';
- s._a._called_load = true;
- if (instanceOptions.autoPlay) {
- s.play();
- }
- } else {
- sm2._wD(s.id + ': Ignoring request to load again');
- }
- } else {
- try {
- s.isHTML5 = false;
- s._iO = policyFix(loopFix(instanceOptions));
-
- instanceOptions = s._iO;
- if (fV === 8) {
- flash._load(s.id, instanceOptions.url, instanceOptions.stream, instanceOptions.autoPlay, instanceOptions.usePolicyFile);
- } else {
- flash._load(s.id, instanceOptions.url, !!(instanceOptions.stream), !!(instanceOptions.autoPlay), instanceOptions.loops||1, !!(instanceOptions.autoLoad), instanceOptions.usePolicyFile);
- }
- } catch(e) {
- _wDS('smError', 2);
- debugTS('onload', false);
- catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true});
- }
- }
-
- s.url = instanceOptions.url;
- return s;
- };
-
- this.unload = function() {
-
-
-
- if (s.readyState !== 0) {
- sm2._wD(s.id + ': unload()');
- if (!s.isHTML5) {
- if (fV === 8) {
- flash._unload(s.id, emptyURL);
- } else {
- flash._unload(s.id);
- }
- } else {
- stop_html5_timer();
- if (s._a) {
- s._a.pause();
- html5Unload(s._a, emptyURL);
-
- lastURL = emptyURL;
- }
- }
-
- resetProperties();
- }
- return s;
- };
-
- this.destruct = function(_bFromSM) {
- sm2._wD(s.id + ': Destruct');
- if (!s.isHTML5) {
-
-
- s._iO.onfailure = null;
- flash._destroySound(s.id);
- } else {
- stop_html5_timer();
- if (s._a) {
- s._a.pause();
- html5Unload(s._a);
- if (!useGlobalHTML5Audio) {
- remove_html5_events();
- }
-
- s._a._s = null;
- s._a = null;
- }
- }
- if (!_bFromSM) {
-
- sm2.destroySound(s.id, true);
- }
- };
-
- this.play = function(oOptions, _updatePlayState) {
- var fN, allowMulti, a, onready, startOK = true,
- exit = null;
-
- fN = s.id + ': play(): ';
-
-
- _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState);
- if (!oOptions) {
- oOptions = {};
- }
-
- if (s.url) {
- s._iO.url = s.url;
- }
-
- s._iO = mixin(s._iO, s.options);
-
- s._iO = mixin(oOptions, s._iO);
- s._iO.url = parseURL(s._iO.url);
- s.instanceOptions = s._iO;
-
- if (s._iO.serverURL && !s.connected) {
- if (!s.getAutoPlay()) {
- sm2._wD(fN +' Netstream not connected yet - setting autoPlay');
- s.setAutoPlay(true);
- }
-
- return s;
- }
- if (html5OK(s._iO)) {
- s._setup_html5(s._iO);
- start_html5_timer();
- }
- if (s.playState === 1 && !s.paused) {
- allowMulti = s._iO.multiShot;
- if (!allowMulti) {
- sm2._wD(fN + 'Already playing (one-shot)', 1);
- exit = s;
- } else {
- sm2._wD(fN + 'Already playing (multi-shot)', 1);
- }
- }
- if (exit !== null) {
- return exit;
- }
-
- if (oOptions.url && oOptions.url !== s.url) {
-
- s.load(s._iO);
- }
- if (!s.loaded) {
- if (s.readyState === 0) {
- sm2._wD(fN + 'Attempting to load');
-
- if (!s.isHTML5) {
-
- s._iO.autoPlay = true;
- s.load(s._iO);
- } else {
-
- s.load(s._iO);
- }
-
- s.instanceOptions = s._iO;
- } else if (s.readyState === 2) {
- sm2._wD(fN + 'Could not load - exiting', 2);
- exit = s;
- } else {
- sm2._wD(fN + 'Loading - attempting to play...');
- }
- } else {
-
- sm2._wD(fN.substr(0, fN.lastIndexOf(':')));
- }
- if (exit !== null) {
- return exit;
- }
- if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) {
-
- sm2._wD(fN + 'Sound at end, resetting to position:0');
- oOptions.position = 0;
- }
-
- if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position > 0)) {
-
- sm2._wD(fN + 'Resuming from paused state', 1);
- s.resume();
- } else {
- s._iO = mixin(oOptions, s._iO);
-
- if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {
- onready = function() {
-
-
- s._iO = mixin(oOptions, s._iO);
- s.play(s._iO);
- };
-
- if (s.isHTML5 && !s._html5_canplay) {
-
- sm2._wD(fN + 'Beginning load for from/to case');
- s.load({
-
- oncanplay: onready
- });
- exit = false;
- } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) {
-
- sm2._wD(fN + 'Preloading for from/to case');
- s.load({
- onload: onready
- });
- exit = false;
- }
- if (exit !== null) {
- return exit;
- }
-
- s._iO = applyFromTo();
- }
- sm2._wD(fN + 'Starting to play');
- if (!s.instanceCount || s._iO.multiShotEvents || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) {
- s.instanceCount++;
- }
-
- if (s._iO.onposition && s.playState === 0) {
- attachOnPosition(s);
- }
- s.playState = 1;
- s.paused = false;
- s.position = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position : 0);
- if (!s.isHTML5) {
- s._iO = policyFix(loopFix(s._iO));
- }
- if (s._iO.onplay && _updatePlayState) {
- s._iO.onplay.apply(s);
- onplay_called = true;
- }
- s.setVolume(s._iO.volume, true);
- s.setPan(s._iO.pan, true);
- if (!s.isHTML5) {
- startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / 1000), s._iO.multiShot || false);
- if (fV === 9 && !startOK) {
-
-
-
- sm2._wD(fN + 'No sound hardware, or 32-sound ceiling hit');
- if (s._iO.onplayerror) {
- s._iO.onplayerror.apply(s);
- }
- }
- } else {
- start_html5_timer();
- a = s._setup_html5();
- s.setPosition(s._iO.position);
- a.play();
- }
- }
- return s;
- };
-
- this.start = this.play;
-
- this.stop = function(bAll) {
- var instanceOptions = s._iO,
- originalPosition;
- if (s.playState === 1) {
- sm2._wD(s.id + ': stop()');
- s._onbufferchange(0);
- s._resetOnPosition(0);
- s.paused = false;
- if (!s.isHTML5) {
- s.playState = 0;
- }
-
- detachOnPosition();
-
- if (instanceOptions.to) {
- s.clearOnPosition(instanceOptions.to);
- }
- if (!s.isHTML5) {
- flash._stop(s.id, bAll);
-
- if (instanceOptions.serverURL) {
- s.unload();
- }
- } else {
- if (s._a) {
- originalPosition = s.position;
-
- s.setPosition(0);
-
- s.position = originalPosition;
-
-
- s._a.pause();
- s.playState = 0;
-
- s._onTimer();
- stop_html5_timer();
- }
- }
- s.instanceCount = 0;
- s._iO = {};
- if (instanceOptions.onstop) {
- instanceOptions.onstop.apply(s);
- }
- }
- return s;
- };
- this.getSpectrum = function(pos) {
- if (!s.isHTML5) {
- return flash._getSpectrum(s.id, pos).split(',');
- }
- };
-
- this.setAutoPlay = function(autoPlay) {
- sm2._wD(s.id + ': Autoplay turned ' + (autoPlay ? 'on' : 'off'));
- s._iO.autoPlay = autoPlay;
- if (!s.isHTML5) {
- flash._setAutoPlay(s.id, autoPlay);
- if (autoPlay) {
-
- if (!s.instanceCount && s.readyState === 1) {
- s.instanceCount++;
- sm2._wD(s.id + ': Incremented instance count to '+s.instanceCount);
- }
- }
- }
- };
-
- this.getAutoPlay = function() {
- return s._iO.autoPlay;
- };
-
- this.setPosition = function(nMsecOffset) {
- if (nMsecOffset === _undefined) {
- nMsecOffset = 0;
- }
- var original_pos,
- position, position1K,
-
-
- offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0)));
- original_pos = s.position;
- s.position = offset;
- position1K = s.position/1000;
- s._resetOnPosition(s.position);
- s._iO.position = offset;
- if (!s.isHTML5) {
- position = (fV === 9 ? s.position : position1K);
- if (s.readyState && s.readyState !== 2) {
-
- flash._setPosition(s.id, position, (s.paused || !s.playState), s._iO.multiShot);
- }
- } else if (s._a) {
-
- if (s._html5_canplay) {
- if (s._a.currentTime !== position1K) {
-
- sm2._wD(s.id + ': setPosition('+position1K+')');
- try {
- s._a.currentTime = position1K;
- if (s.playState === 0 || s.paused) {
-
- s._a.pause();
- }
- } catch(e) {
- sm2._wD(s.id + ': setPosition(' + position1K + ') failed: ' + e.message, 2);
- }
- }
- } else {
- sm2._wD(s.id + ': setPosition(' + position1K + '): Cannot seek yet, sound not ready');
- }
- }
- if (s.isHTML5) {
- if (s.paused) {
-
-
- s._onTimer(true);
- }
- }
- return s;
- };
-
- this.pause = function(_bCallFlash) {
- if (s.paused || (s.playState === 0 && s.readyState !== 1)) {
- return s;
- }
- sm2._wD(s.id + ': pause()');
- s.paused = true;
- if (!s.isHTML5) {
- if (_bCallFlash || _bCallFlash === _undefined) {
- flash._pause(s.id, s._iO.multiShot);
- }
- } else {
- s._setup_html5().pause();
- stop_html5_timer();
- }
- if (s._iO.onpause) {
- s._iO.onpause.apply(s);
- }
- return s;
- };
-
-
- this.resume = function() {
- var instanceOptions = s._iO;
- if (!s.paused) {
- return s;
- }
- sm2._wD(s.id + ': resume()');
- s.paused = false;
- s.playState = 1;
- if (!s.isHTML5) {
- if (instanceOptions.isMovieStar && !instanceOptions.serverURL) {
-
- s.setPosition(s.position);
- }
-
- flash._pause(s.id, instanceOptions.multiShot);
- } else {
- s._setup_html5().play();
- start_html5_timer();
- }
- if (!onplay_called && instanceOptions.onplay) {
- instanceOptions.onplay.apply(s);
- onplay_called = true;
- } else if (instanceOptions.onresume) {
- instanceOptions.onresume.apply(s);
- }
- return s;
- };
-
- this.togglePause = function() {
- sm2._wD(s.id + ': togglePause()');
- if (s.playState === 0) {
- s.play({
- position: (fV === 9 && !s.isHTML5 ? s.position : s.position / 1000)
- });
- return s;
- }
- if (s.paused) {
- s.resume();
- } else {
- s.pause();
- }
- return s;
- };
-
- this.setPan = function(nPan, bInstanceOnly) {
- if (nPan === _undefined) {
- nPan = 0;
- }
- if (bInstanceOnly === _undefined) {
- bInstanceOnly = false;
- }
- if (!s.isHTML5) {
- flash._setPan(s.id, nPan);
- }
- s._iO.pan = nPan;
- if (!bInstanceOnly) {
- s.pan = nPan;
- s.options.pan = nPan;
- }
- return s;
- };
-
- this.setVolume = function(nVol, _bInstanceOnly) {
-
- if (nVol === _undefined) {
- nVol = 100;
- }
- if (_bInstanceOnly === _undefined) {
- _bInstanceOnly = false;
- }
- if (!s.isHTML5) {
- flash._setVolume(s.id, (sm2.muted && !s.muted) || s.muted?0:nVol);
- } else if (s._a) {
-
- s._a.volume = Math.max(0, Math.min(1, nVol/100));
- }
- s._iO.volume = nVol;
- if (!_bInstanceOnly) {
- s.volume = nVol;
- s.options.volume = nVol;
- }
- return s;
- };
-
- this.mute = function() {
- s.muted = true;
- if (!s.isHTML5) {
- flash._setVolume(s.id, 0);
- } else if (s._a) {
- s._a.muted = true;
- }
- return s;
- };
-
- this.unmute = function() {
- s.muted = false;
- var hasIO = (s._iO.volume !== _undefined);
- if (!s.isHTML5) {
- flash._setVolume(s.id, hasIO?s._iO.volume:s.options.volume);
- } else if (s._a) {
- s._a.muted = false;
- }
- return s;
- };
-
- this.toggleMute = function() {
- return (s.muted?s.unmute():s.mute());
- };
-
- this.onPosition = function(nPosition, oMethod, oScope) {
-
- onPositionItems.push({
- position: parseInt(nPosition, 10),
- method: oMethod,
- scope: (oScope !== _undefined ? oScope : s),
- fired: false
- });
- return s;
- };
-
- 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 || !s.playState || onPositionFired >= j) {
- return false;
- }
- for (i=j-1; i >= 0; i--) {
- item = onPositionItems[i];
- if (!item.fired && s.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 instanceOptions = s._iO,
- f = instanceOptions.from,
- t = instanceOptions.to,
- start, end;
- end = function() {
-
- sm2._wD(s.id + ': "To" time of ' + t + ' reached.');
-
- s.clearOnPosition(t, end);
-
- s.stop();
- };
- start = function() {
- sm2._wD(s.id + ': Playing "from" ' + f);
-
- if (t !== null && !isNaN(t)) {
- s.onPosition(t, end);
- }
- };
- if (f !== null && !isNaN(f)) {
-
- instanceOptions.position = f;
-
- instanceOptions.multiShot = false;
- start();
- }
-
- return instanceOptions;
- };
- attachOnPosition = function() {
- var item,
- op = s._iO.onposition;
-
- if (op) {
- for (item in op) {
- if (op.hasOwnProperty(item)) {
- s.onPosition(parseInt(item, 10), op[item]);
- }
- }
- }
- };
- detachOnPosition = function() {
- var item,
- op = s._iO.onposition;
-
- if (op) {
- for (item in op) {
- if (op.hasOwnProperty(item)) {
- s.clearOnPosition(parseInt(item, 10));
- }
- }
- }
- };
- start_html5_timer = function() {
- if (s.isHTML5) {
- startTimer(s);
- }
- };
- stop_html5_timer = function() {
- if (s.isHTML5) {
- stopTimer(s);
- }
- };
- resetProperties = function(retainPosition) {
- if (!retainPosition) {
- onPositionItems = [];
- onPositionFired = 0;
- }
- onplay_called = false;
- s._hasTimer = null;
- s._a = null;
- s._html5_canplay = false;
- s.bytesLoaded = null;
- s.bytesTotal = null;
- s.duration = (s._iO && s._iO.duration ? s._iO.duration : null);
- s.durationEstimate = null;
- s.buffered = [];
-
- s.eqData = [];
- s.eqData.left = [];
- s.eqData.right = [];
- s.failures = 0;
- s.isBuffering = false;
- s.instanceOptions = {};
- s.instanceCount = 0;
- s.loaded = false;
- s.metadata = {};
-
- s.readyState = 0;
- s.muted = false;
- s.paused = false;
- s.peakData = {
- left: 0,
- right: 0
- };
- s.waveformData = {
- left: [],
- right: []
- };
- s.playState = 0;
- s.position = null;
- s.id3 = {};
- };
- resetProperties();
-
- this._onTimer = function(bForce) {
-
- var duration, isNew = false, time, x = {};
- if (s._hasTimer || bForce) {
-
- if (s._a && (bForce || ((s.playState > 0 || s.readyState === 1) && !s.paused))) {
- duration = s._get_html5_duration();
- if (duration !== lastHTML5State.duration) {
- lastHTML5State.duration = duration;
- s.duration = duration;
- isNew = true;
- }
-
- s.durationEstimate = s.duration;
- time = (s._a.currentTime * 1000 || 0);
- if (time !== lastHTML5State.time) {
- lastHTML5State.time = time;
- isNew = true;
- }
- if (isNew || bForce) {
- s._whileplaying(time,x,x,x,x);
- }
- }
- return isNew;
- }
- };
- this._get_html5_duration = function() {
- var instanceOptions = s._iO,
-
- d = (s._a && s._a.duration ? s._a.duration*1000 : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)),
- result = (d && !isNaN(d) && d !== Infinity ? d : null);
- return result;
- };
- this._apply_loop = function(a, nLoops) {
-
-
- if (!a.loop && nLoops > 1) {
- sm2._wD('Note: Native HTML5 looping is infinite.', 1);
- }
-
- a.loop = (nLoops > 1 ? 'loop' : '');
- };
- this._setup_html5 = function(oOptions) {
- var instanceOptions = mixin(s._iO, oOptions),
- a = useGlobalHTML5Audio ? globalHTML5Audio : s._a,
- dURL = decodeURI(instanceOptions.url),
- sameURL;
-
- if (useGlobalHTML5Audio) {
- if (dURL === decodeURI(lastGlobalHTML5URL)) {
-
- sameURL = true;
- }
- } else if (dURL === decodeURI(lastURL)) {
-
- sameURL = true;
- }
- if (a) {
- if (a._s) {
- if (useGlobalHTML5Audio) {
- if (a._s && a._s.playState && !sameURL) {
-
- a._s.stop();
- }
- } else if (!useGlobalHTML5Audio && dURL === decodeURI(lastURL)) {
-
- s._apply_loop(a, instanceOptions.loops);
- return a;
- }
- }
- if (!sameURL) {
-
- resetProperties(false);
-
- a.src = instanceOptions.url;
- s.url = instanceOptions.url;
- lastURL = instanceOptions.url;
- lastGlobalHTML5URL = instanceOptions.url;
- a._called_load = false;
- }
- } else {
- if (instanceOptions.autoLoad || instanceOptions.autoPlay) {
- s._a = new Audio(instanceOptions.url);
- } else {
-
- s._a = (isOpera && opera.version() < 10 ? new Audio(null) : new Audio());
- }
-
- a = s._a;
- a._called_load = false;
- if (useGlobalHTML5Audio) {
- globalHTML5Audio = a;
- }
- }
- s.isHTML5 = true;
-
- s._a = a;
-
- a._s = s;
- add_html5_events();
- s._apply_loop(a, instanceOptions.loops);
- if (instanceOptions.autoLoad || instanceOptions.autoPlay) {
- s.load();
- } else {
-
- a.autobuffer = false;
-
- a.preload = 'auto';
- }
- return a;
- };
- add_html5_events = function() {
- if (s._a._added_events) {
- return false;
- }
- var f;
- function add(oEvt, oFn, bCapture) {
- return s._a ? s._a.addEventListener(oEvt, oFn, bCapture||false) : null;
- }
- s._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 (s._a ? s._a.removeEventListener(oEvt, oFn, bCapture||false) : null);
- }
- sm2._wD(s.id + ': Removing event listeners');
- s._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 || (!s.isHTML5 && fV === 8 && s.duration);
-
- fN = s.id + ': ';
- sm2._wD(fN + (loadOK ? 'onload()' : 'Failed to load? - ' + s.url), (loadOK ? 1 : 2));
- if (!loadOK && !s.isHTML5) {
- if (sm2.sandbox.noRemote === true) {
- sm2._wD(fN + str('noNet'), 1);
- }
- if (sm2.sandbox.noLocal === true) {
- sm2._wD(fN + str('noLocal'), 1);
- }
- }
-
- s.loaded = loadOK;
- s.readyState = loadOK?3:2;
- s._onbufferchange(0);
- if (s._iO.onload) {
- wrapCallback(s, function() {
- s._iO.onload.apply(s, [loadOK]);
- });
- }
- return true;
- };
- this._onbufferchange = function(nIsBuffering) {
- if (s.playState === 0) {
-
- return false;
- }
- if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) {
- return false;
- }
- s.isBuffering = (nIsBuffering === 1);
- if (s._iO.onbufferchange) {
- sm2._wD(s.id + ': Buffer state change: ' + nIsBuffering);
- s._iO.onbufferchange.apply(s);
- }
- return true;
- };
-
- this._onsuspend = function() {
- if (s._iO.onsuspend) {
- sm2._wD(s.id + ': Playback suspended');
- s._iO.onsuspend.apply(s);
- }
- return true;
- };
-
- this._onfailure = function(msg, level, code) {
- s.failures++;
- sm2._wD(s.id + ': Failures = ' + s.failures);
- if (s._iO.onfailure && s.failures === 1) {
- s._iO.onfailure(s, msg, level, code);
- } else {
- sm2._wD(s.id + ': Ignoring failure');
- }
- };
- this._onfinish = function() {
-
- var io_onfinish = s._iO.onfinish;
- s._onbufferchange(0);
- s._resetOnPosition(0);
-
- if (s.instanceCount) {
- s.instanceCount--;
- if (!s.instanceCount) {
-
- detachOnPosition();
-
- s.playState = 0;
- s.paused = false;
- s.instanceCount = 0;
- s.instanceOptions = {};
- s._iO = {};
- stop_html5_timer();
-
- if (s.isHTML5) {
- s.position = 0;
- }
- }
- if (!s.instanceCount || s._iO.multiShotEvents) {
-
- if (io_onfinish) {
- sm2._wD(s.id + ': onfinish()');
- wrapCallback(s, function() {
- io_onfinish.apply(s);
- });
- }
- }
- }
- };
- this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) {
- var instanceOptions = s._iO;
- s.bytesLoaded = nBytesLoaded;
- s.bytesTotal = nBytesTotal;
- s.duration = Math.floor(nDuration);
- s.bufferLength = nBufferLength;
- if (!s.isHTML5 && !instanceOptions.isMovieStar) {
- if (instanceOptions.duration) {
-
- s.durationEstimate = (s.duration > instanceOptions.duration) ? s.duration : instanceOptions.duration;
- } else {
- s.durationEstimate = parseInt((s.bytesTotal / s.bytesLoaded) * s.duration, 10);
- }
- } else {
- s.durationEstimate = s.duration;
- }
-
- if (!s.isHTML5) {
- s.buffered = [{
- 'start': 0,
- 'end': s.duration
- }];
- }
-
- if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) {
- instanceOptions.whileloading.apply(s);
- }
- };
- this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {
- var instanceOptions = s._iO,
- eqLeft;
- if (isNaN(nPosition) || nPosition === null) {
-
- return false;
- }
-
- s.position = Math.max(0, nPosition);
- s._processOnPosition();
- if (!s.isHTML5 && fV > 8) {
- if (instanceOptions.usePeakData && oPeakData !== _undefined && oPeakData) {
- s.peakData = {
- left: oPeakData.leftPeak,
- right: oPeakData.rightPeak
- };
- }
- if (instanceOptions.useWaveformData && oWaveformDataLeft !== _undefined && oWaveformDataLeft) {
- s.waveformData = {
- left: oWaveformDataLeft.split(','),
- right: oWaveformDataRight.split(',')
- };
- }
- if (instanceOptions.useEQData) {
- if (oEQData !== _undefined && oEQData && oEQData.leftEQ) {
- eqLeft = oEQData.leftEQ.split(',');
- s.eqData = eqLeft;
- s.eqData.left = eqLeft;
- if (oEQData.rightEQ !== _undefined && oEQData.rightEQ) {
- s.eqData.right = oEQData.rightEQ.split(',');
- }
- }
- }
- }
- if (s.playState === 1) {
-
- if (!s.isHTML5 && fV === 8 && !s.position && s.isBuffering) {
- s._onbufferchange(0);
- }
- if (instanceOptions.whileplaying) {
-
- instanceOptions.whileplaying.apply(s);
- }
- }
- return true;
- };
- this._oncaptiondata = function(oData) {
-
- sm2._wD(s.id + ': Caption data received.');
- s.captiondata = oData;
- if (s._iO.oncaptiondata) {
- s._iO.oncaptiondata.apply(s, [oData]);
- }
- };
- this._onmetadata = function(oMDProps, oMDData) {
-
- sm2._wD(s.id + ': Metadata received.');
- var oData = {}, i, j;
- for (i = 0, j = oMDProps.length; i < j; i++) {
- oData[oMDProps[i]] = oMDData[i];
- }
- s.metadata = oData;
- if (s._iO.onmetadata) {
- s._iO.onmetadata.apply(s);
- }
- };
- this._onid3 = function(oID3Props, oID3Data) {
-
- sm2._wD(s.id + ': ID3 data received.');
- var oData = [], i, j;
- for (i = 0, j = oID3Props.length; i < j; i++) {
- oData[oID3Props[i]] = oID3Data[i];
- }
- s.id3 = mixin(s.id3, oData);
- if (s._iO.onid3) {
- s._iO.onid3.apply(s);
- }
- };
-
- this._onconnect = function(bSuccess) {
- bSuccess = (bSuccess === 1);
- sm2._wD(s.id + ': ' + (bSuccess ? 'Connected.' : 'Failed to connect? - ' + s.url), (bSuccess ? 1 : 2));
- s.connected = bSuccess;
- if (bSuccess) {
- s.failures = 0;
- if (idCheck(s.id)) {
- if (s.getAutoPlay()) {
-
- s.play(_undefined, s.getAutoPlay());
- } else if (s._iO.autoLoad) {
- s.load();
- }
- }
- if (s._iO.onconnect) {
- s._iO.onconnect.apply(s, [bSuccess]);
- }
- }
- };
- this._ondataerror = function(sError) {
-
-
- if (s.playState > 0) {
- sm2._wD(s.id + ': Data error: ' + sError);
- if (s._iO.ondataerror) {
- s._iO.ondataerror.apply(s);
- }
- }
- };
-
- this._debug();
-
- };
-
- 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 = (oAdd === _undefined ? sm2.defaultOptions : oAdd);
- for (o in o2) {
- if (o2.hasOwnProperty(o) && 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;
- };
- wrapCallback = function(oSound, callback) {
-
- if (!oSound.isHTML5 && fV === 8) {
- window.setTimeout(callback, 0);
- } else {
- callback();
- }
- };
-
- extraOptions = {
- 'onready': 1,
- 'ontimeout': 1,
- 'defaultOptions': 1,
- 'flash9Options': 1,
- 'movieStarOptions': 1
- };
- assign = function(o, oParent) {
-
- var i,
- result = true,
- hasParent = (oParent !== _undefined),
- setupOptions = sm2.setupOptions,
- bonusOptions = extraOptions;
-
-
- if (o === _undefined) {
- result = [];
- for (i in setupOptions) {
- if (setupOptions.hasOwnProperty(i)) {
- result.push(i);
- }
- }
- for (i in bonusOptions) {
- if (bonusOptions.hasOwnProperty(i)) {
- if (typeof sm2[i] === 'object') {
- result.push(i+': {...}');
- } else if (sm2[i] instanceof Function) {
- result.push(i+': function() {...}');
- } else {
- result.push(i);
- }
- }
- }
- sm2._wD(str('setup', result.join(', ')));
- return false;
- }
-
- for (i in o) {
- if (o.hasOwnProperty(i)) {
-
- if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array || o[i] instanceof RegExp) {
-
- if (hasParent && bonusOptions[oParent] !== _undefined) {
-
- sm2[oParent][i] = o[i];
- } else if (setupOptions[i] !== _undefined) {
-
- sm2.setupOptions[i] = o[i];
-
- sm2[i] = o[i];
- } else if (bonusOptions[i] === _undefined) {
-
- complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);
- result = false;
- } else {
-
- if (sm2[i] instanceof Function) {
- sm2[i].apply(sm2, (o[i] instanceof Array? o[i] : [o[i]]));
- } else {
-
- sm2[i] = o[i];
- }
- }
- } else {
-
- if (bonusOptions[i] === _undefined) {
-
- complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);
- result = false;
- } else {
-
- return assign(o[i], i);
- }
- }
- }
- }
- return result;
- };
- function preferFlashCheck(kind) {
-
- return (sm2.preferFlash && hasFlash && !sm2.ignoreFlash && (sm2.flash[kind] !== _undefined && sm2.flash[kind]));
- }
-
- event = (function() {
-
- var old = (window.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 s = this._s,
- result;
- if (!s || !s._a) {
-
- if (s && s.id) {
- sm2._wD(s.id + ': Ignoring ' + e.type);
- } else {
- sm2._wD(h5 + 'Ignoring ' + e.type);
- }
-
- result = null;
- } else {
- result = oFn.call(this, e);
- }
- return result;
- };
- }
- html5_events = {
-
- abort: html5_event(function() {
- sm2._wD(this._s.id + ': abort');
- }),
-
- canplay: html5_event(function() {
- var s = this._s,
- position1K;
- if (s._html5_canplay) {
-
- return true;
- }
- s._html5_canplay = true;
- sm2._wD(s.id + ': canplay');
- s._onbufferchange(0);
-
- position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/1000:null);
-
- if (s.position && this.currentTime !== position1K) {
- sm2._wD(s.id + ': canplay: Setting position to ' + position1K);
- try {
- this.currentTime = position1K;
- } catch(ee) {
- sm2._wD(s.id + ': canplay: Setting position of ' + position1K + ' failed: ' + ee.message, 2);
- }
- }
-
- if (s._iO._oncanplay) {
- s._iO._oncanplay();
- }
- }),
- canplaythrough: html5_event(function() {
- var s = this._s;
- if (!s.loaded) {
- s._onbufferchange(0);
- s._whileloading(s.bytesLoaded, s.bytesTotal, s._get_html5_duration());
- s._onload(true);
- }
- }),
-
-
- ended: html5_event(function() {
- var s = this._s;
- sm2._wD(s.id + ': ended');
- s._onfinish();
- }),
- error: html5_event(function() {
- sm2._wD(this._s.id + ': HTML5 error, code ' + this.error.code);
-
- this._s._onload(false);
- }),
- loadeddata: html5_event(function() {
- var s = this._s;
- sm2._wD(s.id + ': loadeddata');
-
- if (!s._loaded && !isSafari) {
- s.duration = s._get_html5_duration();
- }
- }),
- loadedmetadata: html5_event(function() {
- sm2._wD(this._s.id + ': loadedmetadata');
- }),
- loadstart: html5_event(function() {
- sm2._wD(this._s.id + ': loadstart');
-
- this._s._onbufferchange(1);
- }),
- play: html5_event(function() {
- sm2._wD(this._s.id + ': play()');
-
- this._s._onbufferchange(0);
- }),
- playing: html5_event(function() {
- sm2._wD(this._s.id + ': playing');
-
- this._s._onbufferchange(0);
- }),
- progress: html5_event(function(e) {
-
- var s = this._s,
- i, j, str, buffered = 0,
- isProgress = (e.type === 'progress'),
- ranges = e.target.buffered,
-
- loaded = (e.loaded||0),
- total = (e.total||1),
-
- scale = 1000;
-
- s.buffered = [];
- if (ranges && ranges.length) {
-
-
-
- for (i=0, j=ranges.length; i<j; i++) {
- s.buffered.push({
- 'start': ranges.start(i) * scale,
- 'end': ranges.end(i) * scale
- });
- }
-
- buffered = (ranges.end(0) - ranges.start(0)) * scale;
-
- loaded = buffered/(e.target.duration*scale);
-
- if (isProgress && ranges.length > 1) {
- str = [];
- j = ranges.length;
- for (i=0; i<j; i++) {
- str.push(e.target.buffered.start(i)*scale +'-'+ e.target.buffered.end(i)*scale);
- }
- sm2._wD(this._s.id + ': progress, timeRanges: ' + str.join(', '));
- }
- if (isProgress && !isNaN(loaded)) {
- sm2._wD(this._s.id + ': progress, ' + Math.floor(loaded*100) + '% loaded');
- }
-
- }
- if (!isNaN(loaded)) {
-
- s._onbufferchange(0);
-
- s._whileloading(loaded, total, s._get_html5_duration());
- if (loaded && total && loaded === total) {
-
- html5_events.canplaythrough.call(this, e);
- }
- }
- }),
- ratechange: html5_event(function() {
- sm2._wD(this._s.id + ': ratechange');
- }),
- suspend: html5_event(function(e) {
-
- var s = this._s;
- sm2._wD(this._s.id + ': suspend');
- html5_events.progress.call(this, e);
- s._onsuspend();
- }),
- stalled: html5_event(function() {
- sm2._wD(this._s.id + ': stalled');
- }),
- timeupdate: html5_event(function() {
- this._s._onTimer();
- }),
- waiting: html5_event(function() {
- var s = this._s;
-
- sm2._wD(this._s.id + ': waiting');
-
- s._onbufferchange(1);
- })
- };
- html5OK = function(iO) {
-
- var result;
- if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {
-
- result = false;
- } else {
-
- result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only));
- }
- return result;
- };
- html5Unload = function(oAudio, url) {
-
- if (oAudio) {
-
- oAudio.src = url;
-
- oAudio._called_load = false;
- }
- if (useGlobalHTML5Audio) {
-
- lastGlobalHTML5URL = null;
- }
- };
- html5CanPlay = function(o) {
-
- if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
- return false;
- }
- var url = (o.url || null),
- mime = (o.type || null),
- aF = sm2.audioFormats,
- result,
- offset,
- fileExt,
- item;
-
- if (mime && sm2.html5[mime] !== _undefined) {
- return (sm2.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) {
- result = false;
- } else {
-
- offset = mime.indexOf(';');
-
- fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6);
- }
- } else {
-
- fileExt = fileExt[1];
- }
- if (fileExt && sm2.html5[fileExt] !== _undefined) {
-
- result = (sm2.html5[fileExt] && !preferFlashCheck(fileExt));
- } else {
- mime = 'audio/'+fileExt;
- result = sm2.html5.canPlayType({type:mime});
- sm2.html5[fileExt] = result;
-
- result = (result && sm2.html5[mime] && !preferFlashCheck(mime));
- }
- return result;
- };
- testHTML5 = function() {
-
- if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
- return false;
- }
-
- var a = (Audio !== _undefined ? (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()) : null),
- item, lookup, support = {}, aF, i;
- function cp(m) {
- var canPlay, i, j,
- result = false,
- isOK = false;
- if (!a || typeof a.canPlayType !== 'function') {
- return result;
- }
- if (m instanceof Array) {
-
- for (i=0, j=m.length; i<j; i++) {
- if (sm2.html5[m[i]] || a.canPlayType(m[i]).match(sm2.html5Test)) {
- isOK = true;
- sm2.html5[m[i]] = true;
-
- sm2.flash[m[i]] = !!(m[i].match(flashMIME));
- }
- }
- result = isOK;
- } else {
- canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);
- result = !!(canPlay && (canPlay.match(sm2.html5Test)));
- }
- return result;
- }
-
- aF = sm2.audioFormats;
- for (item in aF) {
- if (aF.hasOwnProperty(item)) {
- lookup = 'audio/' + item;
- support[item] = cp(aF[item].type);
-
- support[lookup] = support[item];
-
- if (item.match(flashMIME)) {
- sm2.flash[item] = true;
- sm2.flash[lookup] = true;
- } else {
- sm2.flash[item] = false;
- sm2.flash[lookup] = 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];
- sm2.html5[aF[item].related[i]] = support[item];
- sm2.flash[aF[item].related[i]] = support[item];
- }
- }
- }
- }
- support.canPlayType = (a?cp:null);
- sm2.html5 = mixin(sm2.html5, support);
- return true;
- };
- strings = {
-
- notReady: 'Unavailable - wait until onready() has fired.',
- notOK: 'Audio support is not available.',
- domError: sm + 'exception caught while appending SWF to DOM.',
- spcWmode: 'Removing wmode, preventing known SWF loading issue(s)',
- swf404: smc + 'Verify that %s is a valid path.',
- tryDebug: 'Try ' + sm + '.debugFlash = true for more security details (output goes to SWF.)',
- checkSWF: 'See SWF output for more debug info.',
- localFail: smc + 'Non-HTTP page (' + doc.location.protocol + ' URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/',
- waitFocus: smc + 'Special case: Waiting for SWF to load with window focus...',
- waitForever: smc + 'Waiting indefinitely for Flash (will recover if unblocked)...',
- waitSWF: smc + 'Waiting for 100% SWF load...',
- needFunction: smc + 'Function object expected for %s',
- badID: 'Warning: Sound ID "%s" should be a string, starting with a non-numeric character',
- currentObj: smc + '_debug(): Current sound objects',
- waitOnload: smc + 'Waiting for window.onload()',
- docLoaded: smc + 'Document already loaded',
- onload: smc + 'initComplete(): calling soundManager.onload()',
- onloadOK: sm + '.onload() complete',
- didInit: smc + 'init(): Already called?',
- secNote: 'Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html',
- badRemove: smc + 'Failed to remove Flash node.',
- shutdown: sm + '.disable(): Shutting down',
- queue: smc + 'Queueing %s handler',
- smError: 'SMSound.load(): Exception: JS-Flash communication failed, or JS error.',
- fbTimeout: 'No flash response, applying .'+swfCSS.swfTimedout+' CSS...',
- fbLoaded: 'Flash loaded',
- flRemoved: smc + 'Flash movie removed.',
- fbHandler: smc + 'flashBlockHandler()',
- manURL: 'SMSound.load(): Using manually-assigned URL',
- onURL: sm + '.load(): current URL already assigned.',
- badFV: sm + '.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',
- as2loop: 'Note: Setting stream:false so looping can work (flash 8 limitation)',
- noNSLoop: 'Note: Looping not implemented for MovieStar formats',
- needfl9: 'Note: Switching to flash 9, required for MP4 formats.',
- mfTimeout: 'Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case',
- needFlash: smc + 'Fatal error: Flash is needed to play some required formats, but is not available.',
- gotFocus: smc + 'Got window focus.',
- 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 and html5Test property changes will not take effect until reboot().',
- noURL: smc + 'Flash URL required. Call soundManager.setup({url:...}) to get started.',
- sm2Loaded: 'SoundManager 2: Ready.',
- reset: sm + '.reset(): Removing event callbacks',
- mobileUA: 'Mobile UA detected, preferring HTML5 by default.',
- globalHTML5: 'Using singleton HTML5 Audio() pattern for this device.'
-
- };
- str = function() {
-
-
-
-
- var args = slice.call(arguments),
-
- o = args.shift(),
- str = (strings && strings[o]?strings[o]:''), i, j;
- if (str && args && args.length) {
- for (i = 0, j = args.length; i < j; i++) {
- str = str.replace('%s', args[i]);
- }
- }
- return str;
-
- };
- loopFix = function(sOpt) {
-
- if (fV === 8 && sOpt.loops > 1 && sOpt.stream) {
- _wDS('as2loop');
- sOpt.stream = false;
- }
- return sOpt;
- };
- policyFix = function(sOpt, sPre) {
- if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) {
- sm2._wD((sPre || '') + str('policy'));
- sOpt.usePolicyFile = true;
- }
- return sOpt;
- };
- complain = function(sMsg) {
-
- if (console !== _undefined && console.warn !== _undefined) {
- console.warn(sMsg);
- } else {
- sm2._wD(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 (bNoDisable === _undefined) {
- bNoDisable = false;
- }
- if (disabled || bNoDisable) {
- sm2.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) : './') + sm2.movieURL;
- if (sm2.noSWFCache) {
- url += ('?ts=' + new Date().getTime());
- }
- return url;
- };
- setVersionInfo = function() {
-
- fV = parseInt(sm2.flashVersion, 10);
- if (fV !== 8 && fV !== 9) {
- sm2._wD(str('badFV', fV, defaultFlashVersion));
- sm2.flashVersion = fV = defaultFlashVersion;
- }
-
- var isDebug = (sm2.debugMode || sm2.debugFlash?'_debug.swf':'.swf');
- if (sm2.useHTML5Audio && !sm2.html5Only && sm2.audioFormats.mp4.required && fV < 9) {
- sm2._wD(str('needfl9'));
- sm2.flashVersion = fV = 9;
- }
- sm2.version = sm2.versionNumber + (sm2.html5Only?' (HTML5-only mode)':(fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)'));
-
- if (fV > 8) {
-
- sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.flash9Options);
- sm2.features.buffering = true;
-
- sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.movieStarOptions);
- sm2.filePatterns.flash9 = new RegExp('\\.(mp3|' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');
- sm2.features.movieStar = true;
- } else {
- sm2.features.movieStar = false;
- }
-
- sm2.filePattern = sm2.filePatterns[(fV !== 8?'flash9':'flash8')];
-
- sm2.movieURL = (fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug);
- sm2.features.peakData = sm2.features.waveformData = sm2.features.eqData = (fV > 8);
- };
- setPolling = function(bPolling, bHighPerformance) {
- if (!flash) {
- return false;
- }
- flash._setPolling(bPolling, bHighPerformance);
- };
- initDebug = function() {
-
-
- if (sm2.debugURLParam.test(wl)) {
- sm2.debugMode = true;
- }
-
- if (id(sm2.debugID)) {
- return false;
- }
- var oD, oDebug, oTarget, oToggle, tmp;
- if (sm2.debugMode && !id(sm2.debugID) && (!hasConsole || !sm2.useConsole || !sm2.consoleOnly)) {
- oD = doc.createElement('div');
- oD.id = sm2.debugID + '-toggle';
- oToggle = {
- 'position': 'fixed',
- 'bottom': '0px',
- 'right': '0px',
- 'width': '1.2em',
- 'height': '1.2em',
- 'lineHeight': '1.2em',
- 'margin': '2px',
- 'textAlign': 'center',
- 'border': '1px solid #999',
- 'cursor': 'pointer',
- 'background': '#fff',
- 'color': '#333',
- 'zIndex': 10001
- };
- oD.appendChild(doc.createTextNode('-'));
- oD.onclick = toggleDebug;
- oD.title = 'Toggle SM2 debug console';
- if (ua.match(/msie 6/i)) {
- oD.style.position = 'absolute';
- oD.style.cursor = 'hand';
- }
- for (tmp in oToggle) {
- if (oToggle.hasOwnProperty(tmp)) {
- oD.style[tmp] = oToggle[tmp];
- }
- }
- oDebug = doc.createElement('div');
- oDebug.id = sm2.debugID;
- oDebug.style.display = (sm2.debugMode?'block':'none');
- if (sm2.debugMode && !id(oD.id)) {
- try {
- oTarget = getDocument();
- oTarget.appendChild(oD);
- } catch(e2) {
- throw new Error(str('domError')+' \n'+e2.toString());
- }
- oTarget.appendChild(oDebug);
- }
- }
- oTarget = null;
-
- };
- idCheck = this.getSoundById;
-
- _wDS = function(o, errorLevel) {
- return (!o ? '' : sm2._wD(str(o), errorLevel));
- };
- toggleDebug = function() {
- var o = id(sm2.debugID),
- oT = id(sm2.debugID + '-toggle');
- if (!o) {
- return false;
- }
- if (debugOpen) {
-
- oT.innerHTML = '+';
- o.style.display = 'none';
- } else {
- oT.innerHTML = '-';
- o.style.display = 'block';
- }
- debugOpen = !debugOpen;
- };
- debugTS = function(sEventType, bSuccess, sMessage) {
-
- if (window.sm2Debugger !== _undefined) {
- try {
- sm2Debugger.handleEvent(sEventType, bSuccess, sMessage);
- } catch(e) {
-
- }
- }
- return true;
- };
-
- getSWFCSS = function() {
- var css = [];
- if (sm2.debugMode) {
- css.push(swfCSS.sm2Debug);
- }
- if (sm2.debugFlash) {
- css.push(swfCSS.flashDebug);
- }
- if (sm2.useHighPerformance) {
- css.push(swfCSS.highPerf);
- }
- return css.join(' ');
- };
- flashBlockHandler = function() {
-
- var name = str('fbHandler'),
- p = sm2.getMoviePercent(),
- css = swfCSS,
- error = {type:'FLASHBLOCK'};
- if (sm2.html5Only) {
- return false;
- }
- if (!sm2.ok()) {
- if (needsFlash) {
-
- sm2.oMC.className = getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);
- sm2._wD(name + ': ' + str('fbTimeout') + (p ? ' (' + str('fbLoaded') + ')' : ''));
- }
- sm2.didFlashBlock = true;
-
- processOnEvents({type:'ontimeout', ignoreInit:true, error:error});
- catchError(error);
- } else {
-
-
- if (sm2.didFlashBlock) {
- sm2._wD(name + ': Unblocked');
- }
-
- if (sm2.oMC) {
- sm2.oMC.className = [getSWFCSS(), css.swfDefault, css.swfLoaded + (sm2.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');
- }
- }
- };
- addOnEvent = function(sType, oMethod, oScope) {
- if (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: (sm2.ok() ? 'onready' : 'ontimeout')
- };
- }
- if (!didInit && oOptions && !oOptions.ignoreInit) {
-
- return false;
- }
- if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) {
-
- return false;
- }
- var status = {
- success: (oOptions && oOptions.ignoreInit?sm2.ok():!disabled)
- },
-
- srcQueue = (oOptions && oOptions.type?on_queue[oOptions.type]||[]:[]),
- queue = [], i, j,
- args = [status],
- canRetry = (needsFlash && !sm2.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() {
- window.setTimeout(function() {
- if (sm2.useFlashBlock) {
- flashBlockHandler();
- }
- processOnEvents();
-
- if (typeof sm2.onload === 'function') {
- _wDS('onload', 1);
- sm2.onload.apply(window);
- _wDS('onloadOK', 1);
- }
- if (sm2.waitForWindowLoad) {
- event.add(window, 'load', initUserOnload);
- }
- },1);
- };
- detectFlash = function() {
-
- if (hasFlash !== _undefined) {
-
- return hasFlash;
- }
- var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.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 (AX !== _undefined && !ua.match(/MSAppHost/i)) {
-
- try {
- obj = new AX('ShockwaveFlash.ShockwaveFlash');
- } catch(e) {
-
- }
- hasPlugin = (!!obj);
-
- obj = null;
- }
- hasFlash = hasPlugin;
- return hasPlugin;
- };
- featureCheck = function() {
- var needsFlash,
- item,
- result = true,
- formats = sm2.audioFormats,
-
- isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i)));
- if (isSpecial) {
-
- sm2.hasHTML5 = false;
-
- sm2.html5Only = true;
- if (sm2.oMC) {
- sm2.oMC.style.display = 'none';
- }
- result = false;
- } else {
- if (sm2.useHTML5Audio) {
- if (!sm2.html5 || !sm2.html5.canPlayType) {
- sm2._wD('SoundManager: No HTML5 Audio() support detected.');
- sm2.hasHTML5 = false;
- }
-
- if (isBadSafari) {
- sm2._wD(smc + 'Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - ' + (!hasFlash ?' would use flash fallback for MP3/MP4, but none detected.' : 'will use flash fallback for MP3/MP4, if available'), 1);
- }
-
- }
- }
- if (sm2.useHTML5Audio && sm2.hasHTML5) {
- for (item in formats) {
- if (formats.hasOwnProperty(item)) {
- if ((formats[item].required && !sm2.html5.canPlayType(formats[item].type)) || (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type]))) {
-
- needsFlash = true;
- }
- }
- }
- }
-
- if (sm2.ignoreFlash) {
- needsFlash = false;
- }
- sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !needsFlash);
- return (!sm2.html5Only);
- };
- parseURL = function(url) {
-
- var i, j, urlResult = 0, result;
- if (url instanceof Array) {
-
- for (i=0, j=url.length; i<j; i++) {
- if (url[i] instanceof Object) {
-
- if (sm2.canPlayMIME(url[i].type)) {
- urlResult = i;
- break;
- }
- } else if (sm2.canPlayURL(url[i])) {
-
- urlResult = i;
- break;
- }
- }
-
- if (url[urlResult].url) {
- url[urlResult] = url[urlResult].url;
- }
- result = url[urlResult];
- } else {
-
- result = url;
- }
- return result;
- };
- startTimer = function(oSound) {
-
- if (!oSound._hasTimer) {
- oSound._hasTimer = true;
- if (!mobileHTML5 && sm2.html5PollingInterval) {
- if (h5IntervalTimer === null && h5TimerCount === 0) {
- h5IntervalTimer = setInterval(timerExecute, sm2.html5PollingInterval);
- }
- h5TimerCount++;
- }
- }
- };
- stopTimer = function(oSound) {
-
- if (oSound._hasTimer) {
- oSound._hasTimer = false;
- if (!mobileHTML5 && sm2.html5PollingInterval) {
-
- h5TimerCount--;
- }
- }
- };
- timerExecute = function() {
-
- var i;
- if (h5IntervalTimer !== null && !h5TimerCount) {
-
- clearInterval(h5IntervalTimer);
- h5IntervalTimer = null;
- return false;
- }
-
- for (i = sm2.soundIDs.length-1; i >= 0; i--) {
- if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) {
- sm2.sounds[sm2.soundIDs[i]]._onTimer();
- }
- }
- };
- catchError = function(options) {
- options = (options !== _undefined ? options : {});
- if (typeof sm2.onerror === 'function') {
- sm2.onerror.apply(window, [{type:(options.type !== _undefined ? options.type : null)}]);
- }
- if (options.fatal !== _undefined && options.fatal) {
- sm2.disable();
- }
- };
- badSafariFix = function() {
-
- if (!isBadSafari || !detectFlash()) {
-
- return false;
- }
- var aF = sm2.audioFormats, i, item;
- for (item in aF) {
- if (aF.hasOwnProperty(item)) {
- if (item === 'mp3' || item === 'mp4') {
- sm2._wD(sm + ': Using flash fallback for ' + item + ' format');
- sm2.html5[item] = false;
-
- if (aF[item] && aF[item].related) {
- for (i = aF[item].related.length-1; i >= 0; i--) {
- sm2.html5[aF[item].related[i]] = false;
- }
- }
- }
- }
- }
- };
-
- this._setSandboxType = function(sandboxType) {
-
- var sb = sm2.sandbox;
- sb.type = sandboxType;
- sb.description = sb.types[(sb.types[sandboxType] !== _undefined?sandboxType:'unknown')];
- if (sb.type === 'localWithFile') {
- sb.noRemote = true;
- sb.noLocal = false;
- _wDS('secNote', 2);
- } else if (sb.type === 'localWithNetwork') {
- sb.noRemote = false;
- sb.noLocal = true;
- } else if (sb.type === 'localTrusted') {
- sb.noRemote = false;
- sb.noLocal = false;
- }
-
- };
- this._externalInterfaceOK = function(flashDate, swfVersion) {
-
-
-
- if (sm2.swfLoaded) {
- return false;
- }
- var e;
- debugTS('swf', true);
- debugTS('flashtojs', true);
- sm2.swfLoaded = true;
- tryInitOnFocus = false;
- if (isBadSafari) {
- badSafariFix();
- }
-
-
- if (!swfVersion || swfVersion.replace(/\+dev/i,'') !== sm2.versionNumber.replace(/\+dev/i, '')) {
- e = sm + ': Fatal: JavaScript file build "' + sm2.versionNumber + '" does not match Flash SWF build "' + swfVersion + '" at ' + sm2.url + '. Ensure both are up-to-date.';
-
- setTimeout(function versionMismatch() {
- throw new Error(e);
- }, 0);
-
- return false;
- }
-
-
- setTimeout(init, isIE ? 100 : 1);
- };
-
- createMovie = function(smID, smURL) {
- if (didAppend && appendSuccess) {
-
- return false;
- }
- function initMsg() {
-
- var options = [], title, str = [], delimiter = ' + ';
- title = 'SoundManager ' + sm2.version + (!sm2.html5Only && sm2.useHTML5Audio ? (sm2.hasHTML5 ? ' + HTML5 audio' : ', no HTML5 audio support') : '');
- if (!sm2.html5Only) {
- if (sm2.preferFlash) {
- options.push('preferFlash');
- }
- if (sm2.useHighPerformance) {
- options.push('useHighPerformance');
- }
- if (sm2.flashPollingInterval) {
- options.push('flashPollingInterval (' + sm2.flashPollingInterval + 'ms)');
- }
- if (sm2.html5PollingInterval) {
- options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)');
- }
- if (sm2.wmode) {
- options.push('wmode (' + sm2.wmode + ')');
- }
- if (sm2.debugFlash) {
- options.push('debugFlash');
- }
- if (sm2.useFlashBlock) {
- options.push('flashBlock');
- }
- } else {
- if (sm2.html5PollingInterval) {
- options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)');
- }
- }
- if (options.length) {
- str = str.concat([options.join(delimiter)]);
- }
- sm2._wD(title + (str.length ? delimiter + str.join(', ') : ''), 1);
- showSupport();
-
- }
- if (sm2.html5Only) {
-
- setVersionInfo();
- initMsg();
- sm2.oMC = id(sm2.movieID);
- init();
-
- didAppend = true;
- appendSuccess = true;
- return false;
- }
-
- var remoteURL = (smURL || sm2.url),
- localURL = (sm2.altURL || remoteURL),
- swfTitle = 'JS/Flash audio component (SoundManager 2)',
- oTarget = getDocument(),
- extraClass = getSWFCSS(),
- isRTL = null,
- html = doc.getElementsByTagName('html')[0],
- oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass;
- isRTL = (html && html.dir && html.dir.match(/rtl/i));
- smID = (smID === _undefined?sm2.id:smID);
- function param(name, value) {
- return '<param name="'+name+'" value="'+value+'" />';
- }
-
- setVersionInfo();
- sm2.url = normalizeMovieURL(overHTTP?remoteURL:localURL);
- smURL = sm2.url;
- sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode);
- if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) {
-
- messages.push(strings.spcWmode);
- sm2.wmode = null;
- }
- oEmbed = {
- 'name': smID,
- 'id': smID,
- 'src': smURL,
- 'quality': 'high',
- 'allowScriptAccess': sm2.allowScriptAccess,
- 'bgcolor': sm2.bgColor,
- 'pluginspage': http+'www.macromedia.com/go/getflashplayer',
- 'title': swfTitle,
- 'type': 'application/x-shockwave-flash',
- 'wmode': sm2.wmode,
-
- 'hasPriority': 'true'
- };
- if (sm2.debugFlash) {
- oEmbed.FlashVars = 'debug=1';
- }
- if (!sm2.wmode) {
-
- delete oEmbed.wmode;
- }
- if (isIE) {
-
- oMovie = doc.createElement('div');
- movieHTML = [
- '<object id="' + smID + '" data="' + smURL + '" type="' + oEmbed.type + '" title="' + oEmbed.title +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + http+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">',
- param('movie', smURL),
- param('AllowScriptAccess', sm2.allowScriptAccess),
- param('quality', oEmbed.quality),
- (sm2.wmode? param('wmode', sm2.wmode): ''),
- param('bgcolor', sm2.bgColor),
- param('hasPriority', 'true'),
- (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''),
- '</object>'
- ].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) {
- sm2.oMC = (id(sm2.movieID) || doc.createElement('div'));
- if (!sm2.oMC.id) {
- sm2.oMC.id = sm2.movieID;
- sm2.oMC.className = swfCSS.swfDefault + ' ' + extraClass;
- s = null;
- oEl = null;
- if (!sm2.useFlashBlock) {
- if (sm2.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) {
-
- sm2.oMC.style.zIndex = 10000;
- }
- if (!sm2.debugFlash) {
- for (x in s) {
- if (s.hasOwnProperty(x)) {
- sm2.oMC.style[x] = s[x];
- }
- }
- }
- try {
- if (!isIE) {
- sm2.oMC.appendChild(oMovie);
- }
- oTarget.appendChild(sm2.oMC);
- if (isIE) {
- oEl = sm2.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 = sm2.oMC.className;
- sm2.oMC.className = (sClass?sClass+' ':swfCSS.swfDefault) + (extraClass?' '+extraClass:'');
- sm2.oMC.appendChild(oMovie);
- if (isIE) {
- oEl = sm2.oMC.appendChild(doc.createElement('div'));
- oEl.className = swfCSS.swfBox;
- oEl.innerHTML = movieHTML;
- }
- appendSuccess = true;
- }
- }
- didAppend = true;
- initMsg();
-
- return true;
- };
- initMovie = function() {
- if (sm2.html5Only) {
- createMovie();
- return false;
- }
-
- if (flash) {
- return false;
- }
- if (!sm2.url) {
-
- _wDS('noURL');
- return false;
- }
-
- flash = sm2.getMovie(sm2.id);
- if (!flash) {
- if (!oRemoved) {
-
- createMovie(sm2.id, sm2.url);
- } else {
-
- if (!isIE) {
- sm2.oMC.appendChild(oRemoved);
- } else {
- sm2.oMC.innerHTML = oRemovedHTML;
- }
- oRemoved = null;
- didAppend = true;
- }
- flash = sm2.getMovie(sm2.id);
- }
- if (typeof sm2.oninitmovie === 'function') {
- setTimeout(sm2.oninitmovie, 1);
- }
-
- flushMessages();
-
- return true;
- };
- delayWaitForEI = function() {
- setTimeout(waitForEI, 1000);
- };
- waitForEI = function() {
- var p,
- loadIncomplete = false;
- if (!sm2.url) {
-
- return false;
- }
- if (waitingForEI) {
- return false;
- }
- waitingForEI = true;
- event.remove(window, 'load', delayWaitForEI);
- if (tryInitOnFocus && !isFocused) {
-
- _wDS('waitFocus');
- return false;
- }
- if (!didInit) {
- p = sm2.getMoviePercent();
- if (p > 0 && p < 100) {
- loadIncomplete = true;
- }
- }
- setTimeout(function() {
- p = sm2.getMoviePercent();
- if (loadIncomplete) {
-
- waitingForEI = false;
- sm2._wD(str('waitSWF'));
- window.setTimeout(delayWaitForEI, 1);
- return false;
- }
-
- if (!didInit) {
- sm2._wD(sm + ': No Flash response within expected time. Likely causes: ' + (p === 0 ? 'SWF load failed, ':'') + 'Flash blocked or JS-Flash security error.' + (sm2.debugFlash?' ' + str('checkSWF'):''), 2);
- if (!overHTTP && p) {
- _wDS('localFail', 2);
- if (!sm2.debugFlash) {
- _wDS('tryDebug', 2);
- }
- }
- if (p === 0) {
-
- sm2._wD(str('swf404', sm2.url), 1);
- }
- debugTS('flashtojs', false, ': Timed out' + overHTTP?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)');
- }
-
-
- if (!didInit && okToDisable) {
- if (p === null) {
-
- if (sm2.useFlashBlock || sm2.flashLoadTimeout === 0) {
- if (sm2.useFlashBlock) {
- flashBlockHandler();
- }
- _wDS('waitForever');
- } else {
-
- _wDS('waitForever');
-
- processOnEvents({type:'ontimeout', ignoreInit: true});
- }
- } else {
-
- if (sm2.flashLoadTimeout === 0) {
- _wDS('waitForever');
- } else {
- failSafely(true);
- }
- }
- }
- }, sm2.flashLoadTimeout);
- };
- handleFocus = function() {
- function cleanup() {
- event.remove(window, 'focus', handleFocus);
- }
- if (isFocused || !tryInitOnFocus) {
-
- cleanup();
- return true;
- }
- okToDisable = true;
- isFocused = true;
- _wDS('gotFocus');
-
- waitingForEI = false;
-
- delayWaitForEI();
- cleanup();
- return true;
- };
- flushMessages = function() {
-
-
- if (messages.length) {
- sm2._wD('SoundManager 2: ' + messages.join(' '), 1);
- messages = [];
- }
-
- };
- showSupport = function() {
-
- flushMessages();
- var item, tests = [];
- if (sm2.useHTML5Audio && sm2.hasHTML5) {
- for (item in sm2.audioFormats) {
- if (sm2.audioFormats.hasOwnProperty(item)) {
- tests.push(item + ' = ' + sm2.html5[item] + (!sm2.html5[item] && hasFlash && sm2.flash[item] ? ' (using flash)' : (sm2.preferFlash && sm2.flash[item] && hasFlash ? ' (preferring flash)': (!sm2.html5[item] ? ' (' + (sm2.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : ''))));
- }
- }
- sm2._wD('SoundManager 2 HTML5 support: ' + tests.join(', '), 1);
- }
-
- };
- initComplete = function(bNoDisable) {
- if (didInit) {
- return false;
- }
- if (sm2.html5Only) {
-
- _wDS('sm2Loaded');
- didInit = true;
- initUserOnload();
- debugTS('onload', true);
- return true;
- }
- var wasTimeout = (sm2.useFlashBlock && sm2.flashLoadTimeout && !sm2.getMoviePercent()),
- result = true,
- error;
- if (!wasTimeout) {
- didInit = true;
- if (disabled) {
- error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')};
- }
- }
- sm2._wD('SoundManager 2 ' + (disabled ? 'failed to load' : 'loaded') + ' (' + (disabled ? 'Flash security/load error' : 'OK') + ')', disabled ? 2: 1);
- if (disabled || bNoDisable) {
- if (sm2.useFlashBlock && sm2.oMC) {
- sm2.oMC.className = getSWFCSS() + ' ' + (sm2.getMoviePercent() === null?swfCSS.swfTimedout:swfCSS.swfError);
- }
- processOnEvents({type:'ontimeout', error:error, ignoreInit: true});
- debugTS('onload', false);
- catchError(error);
- result = false;
- } else {
- debugTS('onload', true);
- }
- if (!disabled) {
- if (sm2.waitForWindowLoad && !windowLoaded) {
- _wDS('waitOnload');
- event.add(window, 'load', initUserOnload);
- } else {
-
- if (sm2.waitForWindowLoad && windowLoaded) {
- _wDS('docLoaded');
- }
-
- initUserOnload();
- }
- }
- return result;
- };
-
- setProperties = function() {
- var i,
- o = sm2.setupOptions;
- for (i in o) {
- if (o.hasOwnProperty(i)) {
-
- if (sm2[i] === _undefined) {
- sm2[i] = o[i];
- } else if (sm2[i] !== o[i]) {
-
- sm2.setupOptions[i] = sm2[i];
- }
- }
- }
- };
- init = function() {
-
- if (didInit) {
- _wDS('didInit');
- return false;
- }
- function cleanup() {
- event.remove(window, 'load', sm2.beginDelayedInit);
- }
- if (sm2.html5Only) {
- if (!didInit) {
-
- cleanup();
- sm2.enabled = true;
- initComplete();
- }
- return true;
- }
-
- initMovie();
- try {
-
- flash._externalInterfaceTest(false);
-
-
- setPolling(true, (sm2.flashPollingInterval || (sm2.useHighPerformance ? 10 : 50)));
- if (!sm2.debugMode) {
-
- flash._disableDebug();
- }
- sm2.enabled = true;
- debugTS('jstoflash', true);
- if (!sm2.html5Only) {
-
-
- event.add(window, 'unload', doNothing);
- }
- } catch(e) {
- sm2._wD('js/flash exception: ' + e.toString());
- debugTS('jstoflash', false);
- 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();
-
-
- (function(){
- var a = 'sm2-usehtml5audio=',
- a2 = 'sm2-preferflash=',
- b = null,
- b2 = null,
- hasCon = (window.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');
- }
- sm2.setup({
- 'useHTML5Audio': b
- });
- }
- if (l.indexOf(a2) !== -1) {
- b2 = (l.charAt(l.indexOf(a2)+a2.length) === '1');
- if (hasCon) {
- console.log((b2?'Enabling ':'Disabling ')+'preferFlash via URL parameter');
- }
- sm2.setup({
- 'preferFlash': b2
- });
- }
- }());
-
- if (!hasFlash && sm2.hasHTML5) {
- sm2._wD('SoundManager: No Flash detected' + (!sm2.useHTML5Audio ? ', enabling HTML5.' : '. Trying HTML5-only mode.'), 1);
- sm2.setup({
- 'useHTML5Audio': true,
-
-
- 'preferFlash': false
- });
- }
- testHTML5();
- sm2.html5.usingFlash = featureCheck();
- needsFlash = sm2.html5.usingFlash;
- if (!hasFlash && needsFlash) {
- messages.push(strings.needFlash);
-
-
- sm2.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(window, 'load', winOnLoad);
- };
-
- preInit = function() {
- if (mobileHTML5) {
-
-
- if (!sm2.setupOptions.useHTML5Audio || sm2.setupOptions.preferFlash) {
-
- messages.push(strings.mobileUA);
- }
-
- sm2.setupOptions.useHTML5Audio = true;
- sm2.setupOptions.preferFlash = false;
- if (is_iDevice || (isAndroid && !ua.match(/android\s2\.3/i))) {
-
-
-
- messages.push(strings.globalHTML5);
-
- if (is_iDevice) {
- sm2.ignoreFlash = true;
- }
- useGlobalHTML5Audio = true;
- }
- }
- };
- preInit();
-
- detectFlash();
-
- event.add(window, 'focus', handleFocus);
- event.add(window, 'load', delayWaitForEI);
- event.add(window, 'load', winOnLoad);
- if (doc.addEventListener) {
- doc.addEventListener('DOMContentLoaded', domContentLoaded, false);
- } else if (doc.attachEvent) {
- doc.attachEvent('onreadystatechange', domContentLoadedIE);
- } else {
-
- debugTS('onload', false);
- catchError({type:'NO_DOM2_EVENTS', fatal:true});
- }
- }
- if (window.SM2_DEFER === undefined || !SM2_DEFER) {
- soundManager = new SoundManager();
- }
- window.SoundManager = SoundManager;
- window.soundManager = soundManager;
- }(window));
|