1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080 |
- let createjs: any = window.createjs || {};
- (function () {
-
- var s = createjs.SoundJS = createjs.SoundJS || {};
-
- s.version = "NEXT";
-
- s.buildDate = "Thu, 12 Oct 2017 16:33:45 GMT";
- })();
- createjs.extend = function(subclass, superclass) {
- "use strict";
- function o() { this.constructor = subclass; }
- o.prototype = superclass.prototype;
- return (subclass.prototype = new o());
- };
- createjs.promote = function(subclass, prefix) {
- "use strict";
- var subP = subclass.prototype, supP = (Object.getPrototypeOf&&Object.getPrototypeOf(subP))||subP.__proto__;
- if (supP) {
- subP[(prefix+="_") + "constructor"] = supP.constructor;
- for (var n in supP) {
- if (subP.hasOwnProperty(n) && (typeof supP[n] == "function")) { subP[prefix + n] = supP[n]; }
- }
- }
- return subclass;
- };
- createjs.deprecate = function(fallbackMethod, name) {
- "use strict";
- return function() {
- var msg = "Deprecated property or method '"+name+"'. See docs for info.";
- console && (console.warn ? console.warn(msg) : console.log(msg));
- return fallbackMethod && fallbackMethod.apply(this, arguments);
- }
- };
- createjs.indexOf = function (array, searchElement){
- "use strict";
- for (var i = 0,l=array.length; i < l; i++) {
- if (searchElement === array[i]) {
- return i;
- }
- }
- return -1;
- };
- (function() {
- "use strict";
-
- createjs.proxy = function (method, scope) {
- var aArgs = Array.prototype.slice.call(arguments, 2);
- return function () {
- return method.apply(scope, Array.prototype.slice.call(arguments, 0).concat(aArgs));
- };
- }
- }());
- (function() {
- "use strict";
-
- function BrowserDetect() {
- throw "BrowserDetect cannot be instantiated";
- };
- var agent = BrowserDetect.agent = window.navigator.userAgent;
- BrowserDetect.isWindowPhone = (agent.indexOf("IEMobile") > -1) || (agent.indexOf("Windows Phone") > -1);
- BrowserDetect.isFirefox = (agent.indexOf("Firefox") > -1);
- BrowserDetect.isOpera = (window.opera != null);
- BrowserDetect.isChrome = (agent.indexOf("Chrome") > -1);
- BrowserDetect.isIOS = (agent.indexOf("iPod") > -1 || agent.indexOf("iPhone") > -1 || agent.indexOf("iPad") > -1) && !BrowserDetect.isWindowPhone;
- BrowserDetect.isAndroid = (agent.indexOf("Android") > -1) && !BrowserDetect.isWindowPhone;
- BrowserDetect.isBlackberry = (agent.indexOf("Blackberry") > -1);
- createjs.BrowserDetect = BrowserDetect;
- }());
- (function() {
- "use strict";
-
- function EventDispatcher() {
-
-
- this._listeners = null;
-
- this._captureListeners = null;
- }
- var p = EventDispatcher.prototype;
-
- EventDispatcher.initialize = function(target) {
- target.addEventListener = p.addEventListener;
- target.on = p.on;
- target.removeEventListener = target.off = p.removeEventListener;
- target.removeAllEventListeners = p.removeAllEventListeners;
- target.hasEventListener = p.hasEventListener;
- target.dispatchEvent = p.dispatchEvent;
- target._dispatchEvent = p._dispatchEvent;
- target.willTrigger = p.willTrigger;
- };
-
- p.addEventListener = function(type, listener, useCapture) {
- var listeners;
- if (useCapture) {
- listeners = this._captureListeners = this._captureListeners||{};
- } else {
- listeners = this._listeners = this._listeners||{};
- }
- var arr = listeners[type];
- if (arr) { this.removeEventListener(type, listener, useCapture); }
- arr = listeners[type];
- if (!arr) { listeners[type] = [listener]; }
- else { arr.push(listener); }
- return listener;
- };
-
- p.on = function(type, listener, scope, once, data, useCapture) {
- if (listener.handleEvent) {
- scope = scope||listener;
- listener = listener.handleEvent;
- }
- scope = scope||this;
- return this.addEventListener(type, function(evt) {
- listener.call(scope, evt, data);
- once&&evt.remove();
- }, useCapture);
- };
-
- p.removeEventListener = function(type, listener, useCapture) {
- var listeners = useCapture ? this._captureListeners : this._listeners;
- if (!listeners) { return; }
- var arr = listeners[type];
- if (!arr) { return; }
- for (var i=0,l=arr.length; i<l; i++) {
- if (arr[i] == listener) {
- if (l==1) { delete(listeners[type]); }
- else { arr.splice(i,1); }
- break;
- }
- }
- };
-
- p.off = p.removeEventListener;
-
- p.removeAllEventListeners = function(type) {
- if (!type) { this._listeners = this._captureListeners = null; }
- else {
- if (this._listeners) { delete(this._listeners[type]); }
- if (this._captureListeners) { delete(this._captureListeners[type]); }
- }
- };
-
- p.dispatchEvent = function(eventObj, bubbles, cancelable) {
- if (typeof eventObj == "string") {
-
- var listeners = this._listeners;
- if (!bubbles && (!listeners || !listeners[eventObj])) { return true; }
- eventObj = new createjs.Event(eventObj, bubbles, cancelable);
- } else if (eventObj.target && eventObj.clone) {
-
- eventObj = eventObj.clone();
- }
-
- try { eventObj.target = this; } catch (e) {}
- if (!eventObj.bubbles || !this.parent) {
- this._dispatchEvent(eventObj, 2);
- } else {
- var top=this, list=[top];
- while (top.parent) { list.push(top = top.parent); }
- var i, l=list.length;
-
- for (i=l-1; i>=0 && !eventObj.propagationStopped; i--) {
- list[i]._dispatchEvent(eventObj, 1+(i==0));
- }
-
- for (i=1; i<l && !eventObj.propagationStopped; i++) {
- list[i]._dispatchEvent(eventObj, 3);
- }
- }
- return !eventObj.defaultPrevented;
- };
-
- p.hasEventListener = function(type) {
- var listeners = this._listeners, captureListeners = this._captureListeners;
- return !!((listeners && listeners[type]) || (captureListeners && captureListeners[type]));
- };
-
- p.willTrigger = function(type) {
- var o = this;
- while (o) {
- if (o.hasEventListener(type)) { return true; }
- o = o.parent;
- }
- return false;
- };
-
- p.toString = function() {
- return "[EventDispatcher]";
- };
-
- p._dispatchEvent = function(eventObj, eventPhase) {
- var l, arr, listeners = (eventPhase <= 2) ? this._captureListeners : this._listeners;
- if (eventObj && listeners && (arr = listeners[eventObj.type]) && (l=arr.length)) {
- try { eventObj.currentTarget = this; } catch (e) {}
- try { eventObj.eventPhase = eventPhase|0; } catch (e) {}
- eventObj.removed = false;
- arr = arr.slice();
- for (var i=0; i<l && !eventObj.immediatePropagationStopped; i++) {
- var o = arr[i];
- if (o.handleEvent) { o.handleEvent(eventObj); }
- else { o(eventObj); }
- if (eventObj.removed) {
- this.off(eventObj.type, o, eventPhase==1);
- eventObj.removed = false;
- }
- }
- }
- if (eventPhase === 2) { this._dispatchEvent(eventObj, 2.1); }
- };
- createjs.EventDispatcher = EventDispatcher;
- }());
- (function() {
- "use strict";
-
- function Event(type, bubbles, cancelable) {
-
-
- this.type = type;
-
- this.target = null;
-
- this.currentTarget = null;
-
- this.eventPhase = 0;
-
- this.bubbles = !!bubbles;
-
- this.cancelable = !!cancelable;
-
- this.timeStamp = (new Date()).getTime();
-
- this.defaultPrevented = false;
-
- this.propagationStopped = false;
-
- this.immediatePropagationStopped = false;
-
- this.removed = false;
- }
- var p = Event.prototype;
-
- p.preventDefault = function() {
- this.defaultPrevented = this.cancelable&&true;
- };
-
- p.stopPropagation = function() {
- this.propagationStopped = true;
- };
-
- p.stopImmediatePropagation = function() {
- this.immediatePropagationStopped = this.propagationStopped = true;
- };
-
- p.remove = function() {
- this.removed = true;
- };
-
- p.clone = function() {
- return new Event(this.type, this.bubbles, this.cancelable);
- };
-
- p.set = function(props) {
- for (var n in props) { this[n] = props[n]; }
- return this;
- };
-
- p.toString = function() {
- return "[Event (type="+this.type+")]";
- };
- createjs.Event = Event;
- }());
- (function() {
- "use strict";
-
- function ErrorEvent(title, message, data) {
- this.Event_constructor("error");
-
- this.title = title;
-
- this.message = message;
-
- this.data = data;
- }
- var p = createjs.extend(ErrorEvent, createjs.Event);
- p.clone = function() {
- return new createjs.ErrorEvent(this.title, this.message, this.data);
- };
- createjs.ErrorEvent = createjs.promote(ErrorEvent, "Event");
- }());
- (function (scope) {
- "use strict";
-
-
- function ProgressEvent(loaded, total) {
- this.Event_constructor("progress");
-
- this.loaded = loaded;
-
- this.total = (total == null) ? 1 : total;
-
- this.progress = (total == 0) ? 0 : this.loaded / this.total;
- };
- var p = createjs.extend(ProgressEvent, createjs.Event);
-
- p.clone = function() {
- return new createjs.ProgressEvent(this.loaded, this.total);
- };
- createjs.ProgressEvent = createjs.promote(ProgressEvent, "Event");
- }(window));
- (function () {
- "use strict";
-
- function LoadItem() {
-
- this.src = null;
-
- this.type = null;
-
- this.id = null;
-
- this.maintainOrder = false;
-
- this.callback = null;
-
- this.data = null;
-
- this.method = createjs.Methods.GET;
-
- this.values = null;
-
- this.headers = null;
-
- this.withCredentials = false;
-
- this.mimeType = null;
-
- this.crossOrigin = null;
-
- this.loadTimeout = s.LOAD_TIMEOUT_DEFAULT;
- };
- var p = LoadItem.prototype = {};
- var s = LoadItem;
-
- s.LOAD_TIMEOUT_DEFAULT = 8000;
-
- s.create = function (value) {
- if (typeof value == "string") {
- var item = new LoadItem();
- item.src = value;
- return item;
- } else if (value instanceof s) {
- return value;
- } else if (value instanceof Object && value.src) {
- if (value.loadTimeout == null) {
- value.loadTimeout = s.LOAD_TIMEOUT_DEFAULT;
- }
- return value;
- } else {
- throw new Error("Type not recognized.");
- }
- };
-
- p.set = function(props) {
- for (var n in props) { this[n] = props[n]; }
- return this;
- };
- createjs.LoadItem = s;
- }());
- (function() {
- var s = {};
-
- s.POST = "POST";
-
- s.GET = "GET";
- createjs.Methods = s;
- }());
- (function() {
- var s = {};
-
- s.BINARY = "binary";
-
- s.CSS = "css";
-
- s.FONT = "font";
-
- s.FONTCSS = "fontcss";
-
- s.IMAGE = "image";
-
- s.JAVASCRIPT = "javascript";
-
- s.JSON = "json";
-
- s.JSONP = "jsonp";
-
- s.MANIFEST = "manifest";
-
- s.SOUND = "sound";
-
- s.VIDEO = "video";
-
- s.SPRITESHEET = "spritesheet";
-
- s.SVG = "svg";
-
- s.TEXT = "text";
-
- s.XML = "xml";
- createjs.Types = s;
- }());
- (function () {
-
- var s = {};
- s.a = function() {
- return s.el("a");
- }
- s.svg = function() {
- return s.el("svg");
- }
- s.object = function() {
- return s.el("object");
- }
- s.image = function() {
- return s.el("image");
- }
- s.img = function() {
- return s.el("img");
- }
- s.style = function() {
- return s.el("style");
- }
- s.link = function() {
- return s.el("link");
- }
- s.script = function() {
- return s.el("script");
- }
- s.audio = function() {
- return s.el("audio");
- }
- s.video = function() {
- return s.el("video");
- }
- s.text = function(value) {
- return document.createTextNode(value);
- }
- s.el = function(name) {
- return document.createElement(name);
- }
- createjs.Elements = s;
- }());
- (function () {
-
- var s = {
- container: null
- };
- s.appendToHead = function (el) {
- s.getHead().appendChild(el);
- }
- s.appendToBody = function (el) {
- if (s.container == null) {
- s.container = document.createElement("div");
- s.container.id = "preloadjs-container";
- var style = s.container.style;
- style.visibility = "hidden";
- style.position = "absolute";
- style.width = s.container.style.height = "10px";
- style.overflow = "hidden";
- style.transform = style.msTransform = style.webkitTransform = style.oTransform = "translate(-10px, -10px)";
- s.getBody().appendChild(s.container);
- }
- s.container.appendChild(el);
- }
- s.getHead = function () {
- return document.head || document.getElementsByTagName("head")[0];
- }
- s.getBody = function () {
- return document.body || document.getElementsByTagName("body")[0];
- }
- s.removeChild = function(el) {
- if (el.parent) {
- el.parent.removeChild(el);
- }
- }
-
- s.isImageTag = function(item) {
- return item instanceof HTMLImageElement;
- };
-
- s.isAudioTag = function(item) {
- if (window.HTMLAudioElement) {
- return item instanceof HTMLAudioElement;
- } else {
- return false;
- }
- };
-
- s.isVideoTag = function(item) {
- if (window.HTMLVideoElement) {
- return item instanceof HTMLVideoElement;
- } else {
- return false;
- }
- };
- createjs.DomUtils = s;
- }());
- (function () {
-
- var s = {};
-
- s.isBinary = function (type) {
- switch (type) {
- case createjs.Types.IMAGE:
- case createjs.Types.BINARY:
- return true;
- default:
- return false;
- }
- };
-
- s.isText = function (type) {
- switch (type) {
- case createjs.Types.TEXT:
- case createjs.Types.JSON:
- case createjs.Types.MANIFEST:
- case createjs.Types.XML:
- case createjs.Types.CSS:
- case createjs.Types.SVG:
- case createjs.Types.JAVASCRIPT:
- case createjs.Types.SPRITESHEET:
- return true;
- default:
- return false;
- }
- };
-
- s.getTypeByExtension = function (extension) {
- if (extension == null) {
- return createjs.Types.TEXT;
- }
- switch (extension.toLowerCase()) {
- case "jpeg":
- case "jpg":
- case "gif":
- case "png":
- case "webp":
- case "bmp":
- return createjs.Types.IMAGE;
- case "ogg":
- case "mp3":
- case "webm":
- return createjs.Types.SOUND;
- case "mp4":
- case "webm":
- case "ts":
- return createjs.Types.VIDEO;
- case "json":
- return createjs.Types.JSON;
- case "xml":
- return createjs.Types.XML;
- case "css":
- return createjs.Types.CSS;
- case "js":
- return createjs.Types.JAVASCRIPT;
- case 'svg':
- return createjs.Types.SVG;
- default:
- return createjs.Types.TEXT;
- }
- };
- createjs.RequestUtils = s;
- }());
- (function () {
-
- var s = {};
-
- s.ABSOLUTE_PATT = /^(?:\w+:)?\/{2}/i;
-
- s.RELATIVE_PATT = (/^[./]*?\//i);
-
- s.EXTENSION_PATT = /\/?[^/]+\.(\w{1,5})$/i;
-
- s.parseURI = function (path) {
- var info = {
- absolute: false,
- relative: false,
- protocol: null,
- hostname: null,
- port: null,
- pathname: null,
- search: null,
- hash: null,
- host: null
- };
- if (path == null) { return info; }
-
- var parser = createjs.Elements.a();
- parser.href = path;
- for (var n in info) {
- if (n in parser) {
- info[n] = parser[n];
- }
- }
-
- var queryIndex = path.indexOf("?");
- if (queryIndex > -1) {
- path = path.substr(0, queryIndex);
- }
-
- var match;
- if (s.ABSOLUTE_PATT.test(path)) {
- info.absolute = true;
-
- } else if (s.RELATIVE_PATT.test(path)) {
- info.relative = true;
- }
-
- if (match = path.match(s.EXTENSION_PATT)) {
- info.extension = match[1].toLowerCase();
- }
- return info;
- };
-
- s.formatQueryString = function (data, query) {
- if (data == null) {
- throw new Error("You must specify data.");
- }
- var params = [];
- for (var n in data) {
- params.push(n + "=" + escape(data[n]));
- }
- if (query) {
- params = params.concat(query);
- }
- return params.join("&");
- };
-
- s.buildURI = function (src, data) {
- if (data == null) {
- return src;
- }
- var query = [];
- var idx = src.indexOf("?");
- if (idx != -1) {
- var q = src.slice(idx + 1);
- query = query.concat(q.split("&"));
- }
- if (idx != -1) {
- return src.slice(0, idx) + "?" + this.formatQueryString(data, query);
- } else {
- return src + "?" + this.formatQueryString(data, query);
- }
- };
-
- s.isCrossDomain = function (item) {
- var target = createjs.Elements.a();
- target.href = item.src;
- var host = createjs.Elements.a();
- host.href = location.href;
- var crossdomain = (target.hostname != "") &&
- (target.port != host.port ||
- target.protocol != host.protocol ||
- target.hostname != host.hostname);
- return crossdomain;
- };
-
- s.isLocal = function (item) {
- var target = createjs.Elements.a();
- target.href = item.src;
- return target.hostname == "" && target.protocol == "file:";
- };
- createjs.URLUtils = s;
- }());
- (function () {
- "use strict";
-
- function AbstractLoader(loadItem, preferXHR, type) {
- this.EventDispatcher_constructor();
-
-
- this.loaded = false;
-
- this.canceled = false;
-
- this.progress = 0;
-
- this.type = type;
-
- this.resultFormatter = null;
-
-
- if (loadItem) {
- this._item = createjs.LoadItem.create(loadItem);
- } else {
- this._item = null;
- }
-
- this._preferXHR = preferXHR;
-
- this._result = null;
-
- this._rawResult = null;
-
- this._loadedItems = null;
-
- this._tagSrcAttribute = null;
-
- this._tag = null;
- };
- var p = createjs.extend(AbstractLoader, createjs.EventDispatcher);
- var s = AbstractLoader;
-
- try {
- Object.defineProperties(s, {
- POST: { get: createjs.deprecate(function() { return createjs.Methods.POST; }, "AbstractLoader.POST") },
- GET: { get: createjs.deprecate(function() { return createjs.Methods.GET; }, "AbstractLoader.GET") },
- BINARY: { get: createjs.deprecate(function() { return createjs.Types.BINARY; }, "AbstractLoader.BINARY") },
- CSS: { get: createjs.deprecate(function() { return createjs.Types.CSS; }, "AbstractLoader.CSS") },
- FONT: { get: createjs.deprecate(function() { return createjs.Types.FONT; }, "AbstractLoader.FONT") },
- FONTCSS: { get: createjs.deprecate(function() { return createjs.Types.FONTCSS; }, "AbstractLoader.FONTCSS") },
- IMAGE: { get: createjs.deprecate(function() { return createjs.Types.IMAGE; }, "AbstractLoader.IMAGE") },
- JAVASCRIPT: { get: createjs.deprecate(function() { return createjs.Types.JAVASCRIPT; }, "AbstractLoader.JAVASCRIPT") },
- JSON: { get: createjs.deprecate(function() { return createjs.Types.JSON; }, "AbstractLoader.JSON") },
- JSONP: { get: createjs.deprecate(function() { return createjs.Types.JSONP; }, "AbstractLoader.JSONP") },
- MANIFEST: { get: createjs.deprecate(function() { return createjs.Types.MANIFEST; }, "AbstractLoader.MANIFEST") },
- SOUND: { get: createjs.deprecate(function() { return createjs.Types.SOUND; }, "AbstractLoader.SOUND") },
- VIDEO: { get: createjs.deprecate(function() { return createjs.Types.VIDEO; }, "AbstractLoader.VIDEO") },
- SPRITESHEET: { get: createjs.deprecate(function() { return createjs.Types.SPRITESHEET; }, "AbstractLoader.SPRITESHEET") },
- SVG: { get: createjs.deprecate(function() { return createjs.Types.SVG; }, "AbstractLoader.SVG") },
- TEXT: { get: createjs.deprecate(function() { return createjs.Types.TEXT; }, "AbstractLoader.TEXT") },
- XML: { get: createjs.deprecate(function() { return createjs.Types.XML; }, "AbstractLoader.XML") }
- });
- } catch (e) {}
-
-
-
-
-
-
-
-
- p.getItem = function () {
- return this._item;
- };
-
- p.getResult = function (raw) {
- return raw ? this._rawResult : this._result;
- };
-
- p.getTag = function () {
- return this._tag;
- };
-
- p.setTag = function(tag) {
- this._tag = tag;
- };
-
- p.load = function () {
- this._createRequest();
- this._request.on("complete", this, this);
- this._request.on("progress", this, this);
- this._request.on("loadStart", this, this);
- this._request.on("abort", this, this);
- this._request.on("timeout", this, this);
- this._request.on("error", this, this);
- var evt = new createjs.Event("initialize");
- evt.loader = this._request;
- this.dispatchEvent(evt);
- this._request.load();
- };
-
- p.cancel = function () {
- this.canceled = true;
- this.destroy();
- };
-
- p.destroy = function() {
- if (this._request) {
- this._request.removeAllEventListeners();
- this._request.destroy();
- }
- this._request = null;
- this._item = null;
- this._rawResult = null;
- this._result = null;
- this._loadItems = null;
- this.removeAllEventListeners();
- };
-
- p.getLoadedItems = function () {
- return this._loadedItems;
- };
-
-
- p._createRequest = function() {
- if (!this._preferXHR) {
- this._request = new createjs.TagRequest(this._item, this._tag || this._createTag(), this._tagSrcAttribute);
- } else {
- this._request = new createjs.XHRRequest(this._item);
- }
- };
-
- p._createTag = function(src) { return null; };
-
- p._sendLoadStart = function () {
- if (this._isCanceled()) { return; }
- this.dispatchEvent("loadstart");
- };
-
- p._sendProgress = function (value) {
- if (this._isCanceled()) { return; }
- var event = null;
- if (typeof(value) == "number") {
- this.progress = value;
- event = new createjs.ProgressEvent(this.progress);
- } else {
- event = value;
- this.progress = value.loaded / value.total;
- event.progress = this.progress;
- if (isNaN(this.progress) || this.progress == Infinity) { this.progress = 0; }
- }
- this.hasEventListener("progress") && this.dispatchEvent(event);
- };
-
- p._sendComplete = function () {
- if (this._isCanceled()) { return; }
- this.loaded = true;
- var event = new createjs.Event("complete");
- event.rawResult = this._rawResult;
- if (this._result != null) {
- event.result = this._result;
- }
- this.dispatchEvent(event);
- };
-
- p._sendError = function (event) {
- if (this._isCanceled() || !this.hasEventListener("error")) { return; }
- if (event == null) {
- event = new createjs.ErrorEvent("PRELOAD_ERROR_EMPTY");
- }
- this.dispatchEvent(event);
- };
-
- p._isCanceled = function () {
- if (window.createjs == null || this.canceled) {
- return true;
- }
- return false;
- };
-
- p.resultFormatter = null;
-
- p.handleEvent = function (event) {
- switch (event.type) {
- case "complete":
- this._rawResult = event.target._response;
- var result = this.resultFormatter && this.resultFormatter(this);
-
- if (result instanceof Function) {
- result.call(this,
- createjs.proxy(this._resultFormatSuccess, this),
- createjs.proxy(this._resultFormatFailed, this)
- );
-
- } else {
- this._result = result || this._rawResult;
- this._sendComplete();
- }
- break;
- case "progress":
- this._sendProgress(event);
- break;
- case "error":
- this._sendError(event);
- break;
- case "loadstart":
- this._sendLoadStart();
- break;
- case "abort":
- case "timeout":
- if (!this._isCanceled()) {
- this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_" + event.type.toUpperCase() + "_ERROR"));
- }
- break;
- }
- };
-
- p._resultFormatSuccess = function (result) {
- this._result = result;
- this._sendComplete();
- };
-
- p._resultFormatFailed = function (event) {
- this._sendError(event);
- };
-
- p.toString = function () {
- return "[PreloadJS AbstractLoader]";
- };
- createjs.AbstractLoader = createjs.promote(AbstractLoader, "EventDispatcher");
- }());
- (function () {
- "use strict";
-
-
- function AbstractMediaLoader(loadItem, preferXHR, type) {
- this.AbstractLoader_constructor(loadItem, preferXHR, type);
-
- this.resultFormatter = this._formatResult;
-
- this._tagSrcAttribute = "src";
- this.on("initialize", this._updateXHR, this);
- };
- var p = createjs.extend(AbstractMediaLoader, createjs.AbstractLoader);
-
-
- p.load = function () {
-
- if (!this._tag) {
- this._tag = this._createTag(this._item.src);
- }
- this._tag.preload = "auto";
- this._tag.load();
- this.AbstractLoader_load();
- };
-
-
- p._createTag = function () {};
- p._createRequest = function() {
- if (!this._preferXHR) {
- this._request = new createjs.MediaTagRequest(this._item, this._tag || this._createTag(), this._tagSrcAttribute);
- } else {
- this._request = new createjs.XHRRequest(this._item);
- }
- };
-
-
- p._updateXHR = function (event) {
-
- if (event.loader.setResponseType) {
- event.loader.setResponseType("blob");
- }
- };
-
- p._formatResult = function (loader) {
- this._tag.removeEventListener && this._tag.removeEventListener("canplaythrough", this._loadedHandler);
- this._tag.onstalled = null;
- if (this._preferXHR) {
- var URL = window.URL || window.webkitURL;
- var result = loader.getResult(true);
- loader.getTag().src = URL.createObjectURL(result);
- }
- return loader.getTag();
- };
- createjs.AbstractMediaLoader = createjs.promote(AbstractMediaLoader, "AbstractLoader");
- }());
- (function () {
- "use strict";
-
- var AbstractRequest = function (item) {
- this._item = item;
- };
- var p = createjs.extend(AbstractRequest, createjs.EventDispatcher);
-
-
- p.load = function() {};
-
- p.destroy = function() {};
-
- p.cancel = function() {};
- createjs.AbstractRequest = createjs.promote(AbstractRequest, "EventDispatcher");
- }());
- (function () {
- "use strict";
-
-
- function TagRequest(loadItem, tag, srcAttribute) {
- this.AbstractRequest_constructor(loadItem);
-
-
- this._tag = tag;
-
- this._tagSrcAttribute = srcAttribute;
-
- this._loadedHandler = createjs.proxy(this._handleTagComplete, this);
-
- this._addedToDOM = false;
- };
- var p = createjs.extend(TagRequest, createjs.AbstractRequest);
-
- p.load = function () {
- this._tag.onload = createjs.proxy(this._handleTagComplete, this);
- this._tag.onreadystatechange = createjs.proxy(this._handleReadyStateChange, this);
- this._tag.onerror = createjs.proxy(this._handleError, this);
- var evt = new createjs.Event("initialize");
- evt.loader = this._tag;
- this.dispatchEvent(evt);
- this._loadTimeout = setTimeout(createjs.proxy(this._handleTimeout, this), this._item.loadTimeout);
- this._tag[this._tagSrcAttribute] = this._item.src;
-
- if (this._tag.parentNode == null) {
- createjs.DomUtils.appendToBody(this._tag);
- this._addedToDOM = true;
- }
- };
- p.destroy = function() {
- this._clean();
- this._tag = null;
- this.AbstractRequest_destroy();
- };
-
-
- p._handleReadyStateChange = function () {
- clearTimeout(this._loadTimeout);
-
- var tag = this._tag;
-
- if (tag.readyState == "loaded" || tag.readyState == "complete") {
- this._handleTagComplete();
- }
- };
-
- p._handleError = function() {
- this._clean();
- this.dispatchEvent("error");
- };
-
- p._handleTagComplete = function () {
- this._rawResult = this._tag;
- this._result = this.resultFormatter && this.resultFormatter(this) || this._rawResult;
- this._clean();
- this.dispatchEvent("complete");
- };
-
- p._handleTimeout = function () {
- this._clean();
- this.dispatchEvent(new createjs.Event("timeout"));
- };
-
- p._clean = function() {
- this._tag.onload = null;
- this._tag.onreadystatechange = null;
- this._tag.onerror = null;
- if (this._addedToDOM && this._tag.parentNode != null) {
- this._tag.parentNode.removeChild(this._tag);
- }
- clearTimeout(this._loadTimeout);
- };
-
- p._handleStalled = function () {
-
- };
- createjs.TagRequest = createjs.promote(TagRequest, "AbstractRequest");
- }());
- (function () {
- "use strict";
-
-
- function MediaTagRequest(loadItem, tag, srcAttribute) {
- this.AbstractRequest_constructor(loadItem);
-
- this._tag = tag;
- this._tagSrcAttribute = srcAttribute;
- this._loadedHandler = createjs.proxy(this._handleTagComplete, this);
- };
- var p = createjs.extend(MediaTagRequest, createjs.TagRequest);
- var s = MediaTagRequest;
-
- p.load = function () {
- var sc = createjs.proxy(this._handleStalled, this);
- this._stalledCallback = sc;
- var pc = createjs.proxy(this._handleProgress, this);
- this._handleProgress = pc;
- this._tag.addEventListener("stalled", sc);
- this._tag.addEventListener("progress", pc);
-
-
- this._tag.addEventListener && this._tag.addEventListener("canplaythrough", this._loadedHandler, false);
- this.TagRequest_load();
- };
-
- p._handleReadyStateChange = function () {
- clearTimeout(this._loadTimeout);
-
- var tag = this._tag;
-
- if (tag.readyState == "loaded" || tag.readyState == "complete") {
- this._handleTagComplete();
- }
- };
- p._handleStalled = function () {
-
- };
-
- p._handleProgress = function (event) {
- if (!event || event.loaded > 0 && event.total == 0) {
- return;
- }
- var newEvent = new createjs.ProgressEvent(event.loaded, event.total);
- this.dispatchEvent(newEvent);
- };
-
- p._clean = function () {
- this._tag.removeEventListener && this._tag.removeEventListener("canplaythrough", this._loadedHandler);
- this._tag.removeEventListener("stalled", this._stalledCallback);
- this._tag.removeEventListener("progress", this._progressCallback);
- this.TagRequest__clean();
- };
- createjs.MediaTagRequest = createjs.promote(MediaTagRequest, "TagRequest");
- }());
- (function () {
- "use strict";
-
- function XHRRequest (item) {
- this.AbstractRequest_constructor(item);
-
-
- this._request = null;
-
- this._loadTimeout = null;
-
- this._xhrLevel = 1;
-
- this._response = null;
-
- this._rawResponse = null;
- this._canceled = false;
-
- this._handleLoadStartProxy = createjs.proxy(this._handleLoadStart, this);
- this._handleProgressProxy = createjs.proxy(this._handleProgress, this);
- this._handleAbortProxy = createjs.proxy(this._handleAbort, this);
- this._handleErrorProxy = createjs.proxy(this._handleError, this);
- this._handleTimeoutProxy = createjs.proxy(this._handleTimeout, this);
- this._handleLoadProxy = createjs.proxy(this._handleLoad, this);
- this._handleReadyStateChangeProxy = createjs.proxy(this._handleReadyStateChange, this);
- if (!this._createXHR(item)) {
-
- }
- };
- var p = createjs.extend(XHRRequest, createjs.AbstractRequest);
-
- XHRRequest.ACTIVEX_VERSIONS = [
- "Msxml2.XMLHTTP.6.0",
- "Msxml2.XMLHTTP.5.0",
- "Msxml2.XMLHTTP.4.0",
- "MSXML2.XMLHTTP.3.0",
- "MSXML2.XMLHTTP",
- "Microsoft.XMLHTTP"
- ];
-
- p.getResult = function (raw) {
- if (raw && this._rawResponse) {
- return this._rawResponse;
- }
- return this._response;
- };
-
- p.cancel = function () {
- this.canceled = true;
- this._clean();
- this._request.abort();
- };
-
- p.load = function () {
- if (this._request == null) {
- this._handleError();
- return;
- }
-
- if (this._request.addEventListener != null) {
- this._request.addEventListener("loadstart", this._handleLoadStartProxy, false);
- this._request.addEventListener("progress", this._handleProgressProxy, false);
- this._request.addEventListener("abort", this._handleAbortProxy, false);
- this._request.addEventListener("error", this._handleErrorProxy, false);
- this._request.addEventListener("timeout", this._handleTimeoutProxy, false);
-
- this._request.addEventListener("load", this._handleLoadProxy, false);
- this._request.addEventListener("readystatechange", this._handleReadyStateChangeProxy, false);
- } else {
-
- this._request.onloadstart = this._handleLoadStartProxy;
- this._request.onprogress = this._handleProgressProxy;
- this._request.onabort = this._handleAbortProxy;
- this._request.onerror = this._handleErrorProxy;
- this._request.ontimeout = this._handleTimeoutProxy;
-
- this._request.onload = this._handleLoadProxy;
- this._request.onreadystatechange = this._handleReadyStateChangeProxy;
- }
-
- if (this._xhrLevel == 1) {
- this._loadTimeout = setTimeout(createjs.proxy(this._handleTimeout, this), this._item.loadTimeout);
- }
-
- try {
- if (!this._item.values) {
- this._request.send();
- } else {
- this._request.send(createjs.URLUtils.formatQueryString(this._item.values));
- }
- } catch (error) {
- this.dispatchEvent(new createjs.ErrorEvent("XHR_SEND", null, error));
- }
- };
- p.setResponseType = function (type) {
-
- if (type === 'blob') {
- type = window.URL ? 'blob' : 'arraybuffer';
- this._responseType = type;
- }
- this._request.responseType = type;
- };
-
- p.getAllResponseHeaders = function () {
- if (this._request.getAllResponseHeaders instanceof Function) {
- return this._request.getAllResponseHeaders();
- } else {
- return null;
- }
- };
-
- p.getResponseHeader = function (header) {
- if (this._request.getResponseHeader instanceof Function) {
- return this._request.getResponseHeader(header);
- } else {
- return null;
- }
- };
-
- p._handleProgress = function (event) {
- if (!event || event.loaded > 0 && event.total == 0) {
- return;
- }
- var newEvent = new createjs.ProgressEvent(event.loaded, event.total);
- this.dispatchEvent(newEvent);
- };
-
- p._handleLoadStart = function (event) {
- clearTimeout(this._loadTimeout);
- this.dispatchEvent("loadstart");
- };
-
- p._handleAbort = function (event) {
- this._clean();
- this.dispatchEvent(new createjs.ErrorEvent("XHR_ABORTED", null, event));
- };
-
- p._handleError = function (event) {
- this._clean();
- this.dispatchEvent(new createjs.ErrorEvent(event.message));
- };
-
- p._handleReadyStateChange = function (event) {
- if (this._request.readyState == 4) {
- this._handleLoad();
- }
- };
-
- p._handleLoad = function (event) {
- if (this.loaded) {
- return;
- }
- this.loaded = true;
- var error = this._checkError();
- if (error) {
- this._handleError(error);
- return;
- }
- this._response = this._getResponse();
-
- if (this._responseType === 'arraybuffer') {
- try {
- this._response = new Blob([this._response]);
- } catch (e) {
-
-
- window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
- if (e.name === 'TypeError' && window.BlobBuilder) {
- var builder = new BlobBuilder();
- builder.append(this._response);
- this._response = builder.getBlob();
- }
- }
- }
- this._clean();
- this.dispatchEvent(new createjs.Event("complete"));
- };
-
- p._handleTimeout = function (event) {
- this._clean();
- this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_TIMEOUT", null, event));
- };
-
- p._checkError = function () {
- var status = parseInt(this._request.status);
- if (status >= 400 && status <= 599) {
- return new Error(status);
- } else if (status == 0) {
- if ((/^https?:/).test(location.protocol)) { return new Error(0); }
- return null;
- } else {
- return null;
- }
- };
-
- p._getResponse = function () {
- if (this._response != null) {
- return this._response;
- }
- if (this._request.response != null) {
- return this._request.response;
- }
-
- try {
- if (this._request.responseText != null) {
- return this._request.responseText;
- }
- } catch (e) {
- }
-
- try {
- if (this._request.responseXML != null) {
- return this._request.responseXML;
- }
- } catch (e) {
- }
- return null;
- };
-
- p._createXHR = function (item) {
-
- var crossdomain = createjs.URLUtils.isCrossDomain(item);
- var headers = {};
-
- var req = null;
- if (window.XMLHttpRequest) {
- req = new XMLHttpRequest();
-
- if (crossdomain && req.withCredentials === undefined && window.XDomainRequest) {
- req = new XDomainRequest();
- }
- } else {
- for (var i = 0, l = s.ACTIVEX_VERSIONS.length; i < l; i++) {
- var axVersion = s.ACTIVEX_VERSIONS[i];
- try {
- req = new ActiveXObject(axVersion);
- break;
- } catch (e) {
- }
- }
- if (req == null) {
- return false;
- }
- }
-
- if (item.mimeType == null && createjs.RequestUtils.isText(item.type)) {
- item.mimeType = "text/plain; charset=utf-8";
- }
-
- if (item.mimeType && req.overrideMimeType) {
- req.overrideMimeType(item.mimeType);
- }
-
- this._xhrLevel = (typeof req.responseType === "string") ? 2 : 1;
- var src = null;
- if (item.method == createjs.Methods.GET) {
- src = createjs.URLUtils.buildURI(item.src, item.values);
- } else {
- src = item.src;
- }
-
- req.open(item.method || createjs.Methods.GET, src, true);
- if (crossdomain && req instanceof XMLHttpRequest && this._xhrLevel == 1) {
- headers["Origin"] = location.origin;
- }
-
- if (item.values && item.method == createjs.Methods.POST) {
- headers["Content-Type"] = "application/x-www-form-urlencoded";
- }
- if (!crossdomain && !headers["X-Requested-With"]) {
- headers["X-Requested-With"] = "XMLHttpRequest";
- }
- if (item.headers) {
- for (var n in item.headers) {
- headers[n] = item.headers[n];
- }
- }
- for (n in headers) {
- req.setRequestHeader(n, headers[n])
- }
- if (req instanceof XMLHttpRequest && item.withCredentials !== undefined) {
- req.withCredentials = item.withCredentials;
- }
- this._request = req;
- return true;
- };
-
- p._clean = function () {
- clearTimeout(this._loadTimeout);
- if (this._request.removeEventListener != null) {
- this._request.removeEventListener("loadstart", this._handleLoadStartProxy);
- this._request.removeEventListener("progress", this._handleProgressProxy);
- this._request.removeEventListener("abort", this._handleAbortProxy);
- this._request.removeEventListener("error", this._handleErrorProxy);
- this._request.removeEventListener("timeout", this._handleTimeoutProxy);
- this._request.removeEventListener("load", this._handleLoadProxy);
- this._request.removeEventListener("readystatechange", this._handleReadyStateChangeProxy);
- } else {
- this._request.onloadstart = null;
- this._request.onprogress = null;
- this._request.onabort = null;
- this._request.onerror = null;
- this._request.ontimeout = null;
- this._request.onload = null;
- this._request.onreadystatechange = null;
- }
- };
- p.toString = function () {
- return "[PreloadJS XHRRequest]";
- };
- createjs.XHRRequest = createjs.promote(XHRRequest, "AbstractRequest");
- }());
- (function () {
- "use strict";
-
-
- function SoundLoader(loadItem, preferXHR) {
- this.AbstractMediaLoader_constructor(loadItem, preferXHR, createjs.Types.SOUND);
-
- if (createjs.DomUtils.isAudioTag(loadItem)) {
- this._tag = loadItem;
- } else if (createjs.DomUtils.isAudioTag(loadItem.src)) {
- this._tag = loadItem;
- } else if (createjs.DomUtils.isAudioTag(loadItem.tag)) {
- this._tag = createjs.DomUtils.isAudioTag(loadItem) ? loadItem : loadItem.src;
- }
- if (this._tag != null) {
- this._preferXHR = false;
- }
- };
- var p = createjs.extend(SoundLoader, createjs.AbstractMediaLoader);
- var s = SoundLoader;
-
-
- s.canLoadItem = function (item) {
- return item.type == createjs.Types.SOUND;
- };
-
- p._createTag = function (src) {
- var tag = createjs.Elements.audio();
- tag.autoplay = false;
- tag.preload = "none";
-
- tag.src = src;
- return tag;
- };
- createjs.SoundLoader = createjs.promote(SoundLoader, "AbstractMediaLoader");
- }());
- (function () {
- "use strict";
-
-
- var PlayPropsConfig = function () {
-
- this.interrupt = null;
-
- this.delay = null;
-
- this.offset = null;
-
- this.loop = null;
-
- this.volume = null;
-
- this.pan = null;
-
- this.startTime = null;
-
- this.duration = null;
- };
- var p = PlayPropsConfig.prototype = {};
- var s = PlayPropsConfig;
-
- s.create = function (value) {
- if (typeof(value) === "string") {
-
- console && (console.warn || console.log)("Deprecated behaviour. Sound.play takes a configuration object instead of individual arguments. See docs for info.");
- return new createjs.PlayPropsConfig().set({interrupt:value});
- } else if (value == null || value instanceof s || value instanceof Object) {
- return new createjs.PlayPropsConfig().set(value);
- } else if (value == null) {
- throw new Error("PlayProps configuration not recognized.");
- }
- };
-
- p.set = function(props) {
- if (props != null) {
- for (var n in props) { this[n] = props[n]; }
- }
- return this;
- };
- p.toString = function() {
- return "[PlayPropsConfig]";
- };
- createjs.PlayPropsConfig = s;
- }());
- (function () {
- "use strict";
-
- function Sound() {
- throw "Sound cannot be instantiated";
- }
- var s = Sound;
-
- s.INTERRUPT_ANY = "any";
-
- s.INTERRUPT_EARLY = "early";
-
- s.INTERRUPT_LATE = "late";
-
- s.INTERRUPT_NONE = "none";
-
- s.PLAY_INITED = "playInited";
-
- s.PLAY_SUCCEEDED = "playSucceeded";
-
- s.PLAY_INTERRUPTED = "playInterrupted";
-
- s.PLAY_FINISHED = "playFinished";
-
- s.PLAY_FAILED = "playFailed";
-
- s.SUPPORTED_EXTENSIONS = ["mp3", "ogg", "opus", "mpeg", "wav", "m4a", "mp4", "aiff", "wma", "mid"];
-
- s.EXTENSION_MAP = {
- m4a:"mp4"
- };
-
- s.FILE_PATTERN = /^(?:(\w+:)\/{2}(\w+(?:\.\w+)*\/?))?([/.]*?(?:[^?]+)?\/)?((?:[^/?]+)\.(\w+))(?:\?(\S+)?)?$/;
-
- s.defaultInterruptBehavior = s.INTERRUPT_NONE;
-
- s.alternateExtensions = [];
-
- s.activePlugin = null;
-
-
- s._masterVolume = 1;
-
- s._getMasterVolume = function() {
- return this._masterVolume;
- };
-
- s.getVolume = createjs.deprecate(s._getMasterVolume, "Sound.getVolume");
-
- s._setMasterVolume = function(value) {
- if (Number(value) == null) { return; }
- value = Math.max(0, Math.min(1, value));
- s._masterVolume = value;
- if (!this.activePlugin || !this.activePlugin.setVolume || !this.activePlugin.setVolume(value)) {
- var instances = this._instances;
- for (var i = 0, l = instances.length; i < l; i++) {
- instances[i].setMasterVolume(value);
- }
- }
- };
-
- s.setVolume = createjs.deprecate(s._setMasterVolume, "Sound.setVolume");
-
- s._masterMute = false;
-
- s._getMute = function () {
- return this._masterMute;
- };
-
- s.getMute = createjs.deprecate(s._getMute, "Sound.getMute");
-
- s._setMute = function (value) {
- if (value == null) { return; }
- this._masterMute = value;
- if (!this.activePlugin || !this.activePlugin.setMute || !this.activePlugin.setMute(value)) {
- var instances = this._instances;
- for (var i = 0, l = instances.length; i < l; i++) {
- instances[i].setMasterMute(value);
- }
- }
- };
-
- s.setMute = createjs.deprecate(s._setMute, "Sound.setMute");
-
-
- s._getCapabilities = function() {
- if (s.activePlugin == null) { return null; }
- return s.activePlugin._capabilities;
- };
-
- s.getCapabilities = createjs.deprecate(s._getCapabilities, "Sound.getCapabilities");
- Object.defineProperties(s, {
- volume: { get: s._getMasterVolume, set: s._setMasterVolume },
- muted: { get: s._getMute, set: s._setMute },
- capabilities: { get: s._getCapabilities }
- });
-
- s._pluginsRegistered = false;
-
- s._lastID = 0;
-
- s._instances = [];
-
- s._idHash = {};
-
- s._preloadHash = {};
-
- s._defaultPlayPropsHash = {};
- s.addEventListener = null;
- s.removeEventListener = null;
- s.removeAllEventListeners = null;
- s.dispatchEvent = null;
- s.hasEventListener = null;
- s._listeners = null;
- createjs.EventDispatcher.initialize(s);
-
-
-
- s.getPreloadHandlers = function () {
- return {
- callback:createjs.proxy(s.initLoad, s),
- types:["sound"],
- extensions:s.SUPPORTED_EXTENSIONS
- };
- };
-
- s._handleLoadComplete = function(event) {
- var src = event.target.getItem().src;
- if (!s._preloadHash[src]) {return;}
- for (var i = 0, l = s._preloadHash[src].length; i < l; i++) {
- var item = s._preloadHash[src][i];
- s._preloadHash[src][i] = true;
- if (!s.hasEventListener("fileload")) { continue; }
- var event = new createjs.Event("fileload");
- event.src = item.src;
- event.id = item.id;
- event.data = item.data;
- event.sprite = item.sprite;
- s.dispatchEvent(event);
- }
- };
-
- s._handleLoadError = function(event) {
- var src = event.target.getItem().src;
- if (!s._preloadHash[src]) {return;}
- for (var i = 0, l = s._preloadHash[src].length; i < l; i++) {
- var item = s._preloadHash[src][i];
- s._preloadHash[src][i] = false;
- if (!s.hasEventListener("fileerror")) { continue; }
- var event = new createjs.Event("fileerror");
- event.src = item.src;
- event.id = item.id;
- event.data = item.data;
- event.sprite = item.sprite;
- s.dispatchEvent(event);
- }
- };
-
- s._registerPlugin = function (plugin) {
-
- if (plugin.isSupported()) {
- s.activePlugin = new plugin();
- return true;
- }
- return false;
- };
-
- s.registerPlugins = function (plugins) {
- s._pluginsRegistered = true;
- for (var i = 0, l = plugins.length; i < l; i++) {
- if (s._registerPlugin(plugins[i])) {
- return true;
- }
- }
- return false;
- };
-
- s.initializeDefaultPlugins = function () {
- if (s.activePlugin != null) {return true;}
- if (s._pluginsRegistered) {return false;}
- if (s.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin])) {return true;}
- return false;
- };
-
- s.isReady = function () {
- return (s.activePlugin != null);
- };
-
- s.initLoad = function (loadItem) {
- if (loadItem.type == "video") { return true; }
- return s._registerSound(loadItem);
- };
-
- s._registerSound = function (loadItem) {
- if (!s.initializeDefaultPlugins()) {return false;}
- var details;
- if (loadItem.src instanceof Object) {
- details = s._parseSrc(loadItem.src);
- details.src = loadItem.path + details.src;
- } else {
- details = s._parsePath(loadItem.src);
- }
- if (details == null) {return false;}
- loadItem.src = details.src;
- loadItem.type = "sound";
- var data = loadItem.data;
- var numChannels = null;
- if (data != null) {
- if (!isNaN(data.channels)) {
- numChannels = parseInt(data.channels);
- } else if (!isNaN(data)) {
- numChannels = parseInt(data);
- }
- if(data.audioSprite) {
- var sp;
- for(var i = data.audioSprite.length; i--; ) {
- sp = data.audioSprite[i];
- s._idHash[sp.id] = {src: loadItem.src, startTime: parseInt(sp.startTime), duration: parseInt(sp.duration)};
- if (sp.defaultPlayProps) {
- s._defaultPlayPropsHash[sp.id] = createjs.PlayPropsConfig.create(sp.defaultPlayProps);
- }
- }
- }
- }
- if (loadItem.id != null) {s._idHash[loadItem.id] = {src: loadItem.src}};
- var loader = s.activePlugin.register(loadItem);
- SoundChannel.create(loadItem.src, numChannels);
-
- if (data == null || !isNaN(data)) {
- loadItem.data = numChannels || SoundChannel.maxPerChannel();
- } else {
- loadItem.data.channels = numChannels || SoundChannel.maxPerChannel();
- }
- if (loader.type) {loadItem.type = loader.type;}
- if (loadItem.defaultPlayProps) {
- s._defaultPlayPropsHash[loadItem.src] = createjs.PlayPropsConfig.create(loadItem.defaultPlayProps);
- }
- return loader;
- };
-
- s.registerSound = function (src, id, data, basePath, defaultPlayProps) {
- var loadItem = {src: src, id: id, data:data, defaultPlayProps:defaultPlayProps};
- if (src instanceof Object && src.src) {
- basePath = id;
- loadItem = src;
- }
- loadItem = createjs.LoadItem.create(loadItem);
- loadItem.path = basePath;
- if (basePath != null && !(loadItem.src instanceof Object)) {loadItem.src = basePath + loadItem.src;}
- var loader = s._registerSound(loadItem);
- if(!loader) {return false;}
- if (!s._preloadHash[loadItem.src]) { s._preloadHash[loadItem.src] = [];}
- s._preloadHash[loadItem.src].push(loadItem);
- if (s._preloadHash[loadItem.src].length == 1) {
-
- loader.on("complete", this._handleLoadComplete, this);
- loader.on("error", this._handleLoadError, this);
- s.activePlugin.preload(loader);
- } else {
- if (s._preloadHash[loadItem.src][0] == true) {return true;}
- }
- return loadItem;
- };
-
- s.registerSounds = function (sounds, basePath) {
- var returnValues = [];
- if (sounds.path) {
- if (!basePath) {
- basePath = sounds.path;
- } else {
- basePath = basePath + sounds.path;
- }
- sounds = sounds.manifest;
-
- }
- for (var i = 0, l = sounds.length; i < l; i++) {
- returnValues[i] = createjs.Sound.registerSound(sounds[i].src, sounds[i].id, sounds[i].data, basePath, sounds[i].defaultPlayProps);
- }
- return returnValues;
- };
-
- s.removeSound = function(src, basePath) {
- if (s.activePlugin == null) {return false;}
- if (src instanceof Object && src.src) {src = src.src;}
- var details;
- if (src instanceof Object) {
- details = s._parseSrc(src);
- } else {
- src = s._getSrcById(src).src;
- details = s._parsePath(src);
- }
- if (details == null) {return false;}
- src = details.src;
- if (basePath != null) {src = basePath + src;}
- for(var prop in s._idHash){
- if(s._idHash[prop].src == src) {
- delete(s._idHash[prop]);
- }
- }
-
- SoundChannel.removeSrc(src);
- delete(s._preloadHash[src]);
- s.activePlugin.removeSound(src);
- return true;
- };
-
- s.removeSounds = function (sounds, basePath) {
- var returnValues = [];
- if (sounds.path) {
- if (!basePath) {
- basePath = sounds.path;
- } else {
- basePath = basePath + sounds.path;
- }
- sounds = sounds.manifest;
- }
- for (var i = 0, l = sounds.length; i < l; i++) {
- returnValues[i] = createjs.Sound.removeSound(sounds[i].src, basePath);
- }
- return returnValues;
- };
-
- s.removeAllSounds = function() {
- s._idHash = {};
- s._preloadHash = {};
- SoundChannel.removeAll();
- if (s.activePlugin) {s.activePlugin.removeAllSounds();}
- };
-
- s.loadComplete = function (src) {
- if (!s.isReady()) { return false; }
- var details = s._parsePath(src);
- if (details) {
- src = s._getSrcById(details.src).src;
- } else {
- src = s._getSrcById(src).src;
- }
- if(s._preloadHash[src] == undefined) {return false;}
- return (s._preloadHash[src][0] == true);
- };
-
- s._parsePath = function (value) {
- if (typeof(value) != "string") {value = value.toString();}
- var match = value.match(s.FILE_PATTERN);
- if (match == null) {return false;}
- var name = match[4];
- var ext = match[5];
- var c = s.capabilities;
- var i = 0;
- while (!c[ext]) {
- ext = s.alternateExtensions[i++];
- if (i > s.alternateExtensions.length) { return null;}
- }
- value = value.replace("."+match[5], "."+ext);
- var ret = {name:name, src:value, extension:ext};
- return ret;
- };
-
- s._parseSrc = function (value) {
- var ret = {name:undefined, src:undefined, extension:undefined};
- var c = s.capabilities;
- for (var prop in value) {
- if(value.hasOwnProperty(prop) && c[prop]) {
- ret.src = value[prop];
- ret.extension = prop;
- break;
- }
- }
- if (!ret.src) {return false;}
- var i = ret.src.lastIndexOf("/");
- if (i != -1) {
- ret.name = ret.src.slice(i+1);
- } else {
- ret.name = ret.src;
- }
- return ret;
- };
-
-
- s.play = function (src, props) {
- var playProps = createjs.PlayPropsConfig.create(props);
- var instance = s.createInstance(src, playProps.startTime, playProps.duration);
- var ok = s._playInstance(instance, playProps);
- if (!ok) {instance._playFailed();}
- return instance;
- };
-
- s.createInstance = function (src, startTime, duration) {
- if (!s.initializeDefaultPlugins()) { return new createjs.DefaultSoundInstance(src, startTime, duration); }
- var defaultPlayProps = s._defaultPlayPropsHash[src];
- src = s._getSrcById(src);
- var details = s._parsePath(src.src);
- var instance = null;
- if (details != null && details.src != null) {
- SoundChannel.create(details.src);
- if (startTime == null) { startTime = src.startTime; }
- instance = s.activePlugin.create(details.src, startTime, duration || src.duration);
- defaultPlayProps = defaultPlayProps || s._defaultPlayPropsHash[details.src];
- if (defaultPlayProps) {
- instance.applyPlayProps(defaultPlayProps);
- }
- } else {
- instance = new createjs.DefaultSoundInstance(src, startTime, duration);
- }
- instance.uniqueId = s._lastID++;
- return instance;
- };
-
- s.stop = function () {
- var instances = this._instances;
- for (var i = instances.length; i--; ) {
- instances[i].stop();
- }
- };
-
- s.setDefaultPlayProps = function(src, playProps) {
- src = s._getSrcById(src);
- s._defaultPlayPropsHash[s._parsePath(src.src).src] = createjs.PlayPropsConfig.create(playProps);
- };
-
- s.getDefaultPlayProps = function(src) {
- src = s._getSrcById(src);
- return s._defaultPlayPropsHash[s._parsePath(src.src).src];
- };
-
-
- s._playInstance = function (instance, playProps) {
- var defaultPlayProps = s._defaultPlayPropsHash[instance.src] || {};
- if (playProps.interrupt == null) {playProps.interrupt = defaultPlayProps.interrupt || s.defaultInterruptBehavior};
- if (playProps.delay == null) {playProps.delay = defaultPlayProps.delay || 0;}
- if (playProps.offset == null) {playProps.offset = instance.position;}
- if (playProps.loop == null) {playProps.loop = instance.loop;}
- if (playProps.volume == null) {playProps.volume = instance.volume;}
- if (playProps.pan == null) {playProps.pan = instance.pan;}
- if (playProps.delay == 0) {
- var ok = s._beginPlaying(instance, playProps);
- if (!ok) {return false;}
- } else {
-
-
- var delayTimeoutId = setTimeout(function () {
- s._beginPlaying(instance, playProps);
- }, playProps.delay);
- instance.delayTimeoutId = delayTimeoutId;
- }
- this._instances.push(instance);
- return true;
- };
-
- s._beginPlaying = function (instance, playProps) {
- if (!SoundChannel.add(instance, playProps.interrupt)) {
- return false;
- }
- var result = instance._beginPlaying(playProps);
- if (!result) {
- var index = createjs.indexOf(this._instances, instance);
- if (index > -1) {this._instances.splice(index, 1);}
- return false;
- }
- return true;
- };
-
- s._getSrcById = function (value) {
- return s._idHash[value] || {src: value};
- };
-
- s._playFinished = function (instance) {
- SoundChannel.remove(instance);
- var index = createjs.indexOf(this._instances, instance);
- if (index > -1) {this._instances.splice(index, 1);}
- };
- createjs.Sound = Sound;
-
- function SoundChannel(src, max) {
- this.init(src, max);
- }
-
-
- SoundChannel.channels = {};
-
- SoundChannel.create = function (src, max) {
- var channel = SoundChannel.get(src);
- if (channel == null) {
- SoundChannel.channels[src] = new SoundChannel(src, max);
- return true;
- }
- return false;
- };
-
- SoundChannel.removeSrc = function (src) {
- var channel = SoundChannel.get(src);
- if (channel == null) {return false;}
- channel._removeAll();
- delete(SoundChannel.channels[src]);
- return true;
- };
-
- SoundChannel.removeAll = function () {
- for(var channel in SoundChannel.channels) {
- SoundChannel.channels[channel]._removeAll();
- }
- SoundChannel.channels = {};
- };
-
- SoundChannel.add = function (instance, interrupt) {
- var channel = SoundChannel.get(instance.src);
- if (channel == null) {return false;}
- return channel._add(instance, interrupt);
- };
-
- SoundChannel.remove = function (instance) {
- var channel = SoundChannel.get(instance.src);
- if (channel == null) {return false;}
- channel._remove(instance);
- return true;
- };
-
- SoundChannel.maxPerChannel = function () {
- return p.maxDefault;
- };
-
- SoundChannel.get = function (src) {
- return SoundChannel.channels[src];
- };
- var p = SoundChannel.prototype;
- p.constructor = SoundChannel;
-
- p.src = null;
-
- p.max = null;
-
- p.maxDefault = 100;
-
- p.length = 0;
-
- p.init = function (src, max) {
- this.src = src;
- this.max = max || this.maxDefault;
- if (this.max == -1) {this.max = this.maxDefault;}
- this._instances = [];
- };
-
- p._get = function (index) {
- return this._instances[index];
- };
-
- p._add = function (instance, interrupt) {
- if (!this._getSlot(interrupt, instance)) {return false;}
- this._instances.push(instance);
- this.length++;
- return true;
- };
-
- p._remove = function (instance) {
- var index = createjs.indexOf(this._instances, instance);
- if (index == -1) {return false;}
- this._instances.splice(index, 1);
- this.length--;
- return true;
- };
-
- p._removeAll = function () {
-
- for (var i=this.length-1; i>=0; i--) {
- this._instances[i].stop();
- }
- };
-
- p._getSlot = function (interrupt, instance) {
- var target, replacement;
- if (interrupt != Sound.INTERRUPT_NONE) {
-
- replacement = this._get(0);
- if (replacement == null) {
- return true;
- }
- }
- for (var i = 0, l = this.max; i < l; i++) {
- target = this._get(i);
-
- if (target == null) {
- return true;
- }
-
- if (target.playState == Sound.PLAY_FINISHED ||
- target.playState == Sound.PLAY_INTERRUPTED ||
- target.playState == Sound.PLAY_FAILED) {
- replacement = target;
- break;
- }
- if (interrupt == Sound.INTERRUPT_NONE) {
- continue;
- }
-
- if ((interrupt == Sound.INTERRUPT_EARLY && target.position < replacement.position) ||
- (interrupt == Sound.INTERRUPT_LATE && target.position > replacement.position)) {
- replacement = target;
- }
- }
- if (replacement != null) {
- replacement._interrupt();
- this._remove(replacement);
- return true;
- }
- return false;
- };
- p.toString = function () {
- return "[Sound SoundChannel]";
- };
-
- }());
- (function () {
- "use strict";
- var AbstractSoundInstance = function (src, startTime, duration, playbackResource) {
- this.EventDispatcher_constructor();
-
-
- this.src = src;
-
- this.uniqueId = -1;
-
- this.playState = null;
-
- this.delayTimeoutId = null;
-
-
-
-
-
- this._volume = 1;
- Object.defineProperty(this, "volume", {
- get: this._getVolume,
- set: this._setVolume
- });
- this.getVolume = createjs.deprecate(this._getVolume, "AbstractSoundInstance.getVolume");
- this.setVolume = createjs.deprecate(this._setVolume, "AbstractSoundInstance.setVolume");
-
- this._pan = 0;
- Object.defineProperty(this, "pan", {
- get: this._getPan,
- set: this._setPan
- });
- this.getPan = createjs.deprecate(this._getPan, "AbstractSoundInstance.getPan");
- this.setPan = createjs.deprecate(this._setPan, "AbstractSoundInstance.setPan");
-
- this._startTime = Math.max(0, startTime || 0);
- Object.defineProperty(this, "startTime", {
- get: this._getStartTime,
- set: this._setStartTime
- });
- this.getStartTime = createjs.deprecate(this._getStartTime, "AbstractSoundInstance.getStartTime");
- this.setStartTime = createjs.deprecate(this._setStartTime, "AbstractSoundInstance.setStartTime");
-
- this._duration = Math.max(0, duration || 0);
- Object.defineProperty(this, "duration", {
- get: this._getDuration,
- set: this._setDuration
- });
- this.getDuration = createjs.deprecate(this._getDuration, "AbstractSoundInstance.getDuration");
- this.setDuration = createjs.deprecate(this._setDuration, "AbstractSoundInstance.setDuration");
-
- this._playbackResource = null;
- Object.defineProperty(this, "playbackResource", {
- get: this._getPlaybackResource,
- set: this._setPlaybackResource
- });
- if(playbackResource !== false && playbackResource !== true) { this._setPlaybackResource(playbackResource); }
- this.getPlaybackResource = createjs.deprecate(this._getPlaybackResource, "AbstractSoundInstance.getPlaybackResource");
- this.setPlaybackResource = createjs.deprecate(this._setPlaybackResource, "AbstractSoundInstance.setPlaybackResource");
-
- this._position = 0;
- Object.defineProperty(this, "position", {
- get: this._getPosition,
- set: this._setPosition
- });
- this.getPosition = createjs.deprecate(this._getPosition, "AbstractSoundInstance.getPosition");
- this.setPosition = createjs.deprecate(this._setPosition, "AbstractSoundInstance.setPosition");
-
- this._loop = 0;
- Object.defineProperty(this, "loop", {
- get: this._getLoop,
- set: this._setLoop
- });
- this.getLoop = createjs.deprecate(this._getLoop, "AbstractSoundInstance.getLoop");
- this.setLoop = createjs.deprecate(this._setLoop, "AbstractSoundInstance.setLoop");
-
- this._muted = false;
- Object.defineProperty(this, "muted", {
- get: this._getMuted,
- set: this._setMuted
- });
- this.getMuted = createjs.deprecate(this._getMuted, "AbstractSoundInstance.getMuted");
- this.setMuted = createjs.deprecate(this._setMuted, "AbstractSoundInstance.setMuted");
-
- this._paused = false;
- Object.defineProperty(this, "paused", {
- get: this._getPaused,
- set: this._setPaused
- });
- this.getPaused = createjs.deprecate(this._getPaused, "AbstractSoundInstance.getPaused");
- this.setPaused = createjs.deprecate(this._setPaused, "AbstractSoundInstance.setPaused");
-
-
-
-
-
-
- };
- var p = createjs.extend(AbstractSoundInstance, createjs.EventDispatcher);
-
- p.play = function (props) {
- var playProps = createjs.PlayPropsConfig.create(props);
- if (this.playState == createjs.Sound.PLAY_SUCCEEDED) {
- this.applyPlayProps(playProps);
- if (this._paused) { this._setPaused(false); }
- return;
- }
- this._cleanUp();
- createjs.Sound._playInstance(this, playProps);
- return this;
- };
-
- p.stop = function () {
- this._position = 0;
- this._paused = false;
- this._handleStop();
- this._cleanUp();
- this.playState = createjs.Sound.PLAY_FINISHED;
- return this;
- };
-
- p.destroy = function() {
- this._cleanUp();
- this.src = null;
- this.playbackResource = null;
- this.removeAllEventListeners();
- };
-
- p.applyPlayProps = function(playProps) {
- if (playProps.offset != null) { this._setPosition(playProps.offset) }
- if (playProps.loop != null) { this._setLoop(playProps.loop); }
- if (playProps.volume != null) { this._setVolume(playProps.volume); }
- if (playProps.pan != null) { this._setPan(playProps.pan); }
- if (playProps.startTime != null) {
- this._setStartTime(playProps.startTime);
- this._setDuration(playProps.duration);
- }
- return this;
- };
- p.toString = function () {
- return "[AbstractSoundInstance]";
- };
-
- p._getPaused = function() {
- return this._paused;
- };
-
- p._setPaused = function (value) {
- if ((value !== true && value !== false) || this._paused == value) {return;}
- if (value == true && this.playState != createjs.Sound.PLAY_SUCCEEDED) {return;}
- this._paused = value;
- if(value) {
- this._pause();
- } else {
- this._resume();
- }
- clearTimeout(this.delayTimeoutId);
- return this;
- };
-
- p._setVolume = function (value) {
- if (value == this._volume) { return this; }
- this._volume = Math.max(0, Math.min(1, value));
- if (!this._muted) {
- this._updateVolume();
- }
- return this;
- };
-
- p._getVolume = function () {
- return this._volume;
- };
-
- p._setMuted = function (value) {
- if (value !== true && value !== false) {return;}
- this._muted = value;
- this._updateVolume();
- return this;
- };
-
- p._getMuted = function () {
- return this._muted;
- };
-
- p._setPan = function (value) {
- if(value == this._pan) { return this; }
- this._pan = Math.max(-1, Math.min(1, value));
- this._updatePan();
- return this;
- };
-
- p._getPan = function () {
- return this._pan;
- };
-
- p._getPosition = function () {
- if (!this._paused && this.playState == createjs.Sound.PLAY_SUCCEEDED) {
- this._position = this._calculateCurrentPosition();
- }
- return this._position;
- };
-
- p._setPosition = function (value) {
- this._position = Math.max(0, value);
- if (this.playState == createjs.Sound.PLAY_SUCCEEDED) {
- this._updatePosition();
- }
- return this;
- };
-
- p._getStartTime = function () {
- return this._startTime;
- };
-
- p._setStartTime = function (value) {
- if (value == this._startTime) { return this; }
- this._startTime = Math.max(0, value || 0);
- this._updateStartTime();
- return this;
- };
-
- p._getDuration = function () {
- return this._duration;
- };
-
- p._setDuration = function (value) {
- if (value == this._duration) { return this; }
- this._duration = Math.max(0, value || 0);
- this._updateDuration();
- return this;
- };
-
- p._setPlaybackResource = function (value) {
- this._playbackResource = value;
- if (this._duration == 0 && this._playbackResource) { this._setDurationFromSource(); }
- return this;
- };
-
- p._getPlaybackResource = function () {
- return this._playbackResource;
- };
-
- p._getLoop = function () {
- return this._loop;
- };
-
- p._setLoop = function (value) {
- if(this._playbackResource != null) {
-
- if (this._loop != 0 && value == 0) {
- this._removeLooping(value);
- }
-
- else if (this._loop == 0 && value != 0) {
- this._addLooping(value);
- }
- }
- this._loop = value;
- };
-
- p._sendEvent = function (type) {
- var event = new createjs.Event(type);
- this.dispatchEvent(event);
- };
-
- p._cleanUp = function () {
- clearTimeout(this.delayTimeoutId);
- this._handleCleanUp();
- this._paused = false;
- createjs.Sound._playFinished(this);
- };
-
- p._interrupt = function () {
- this._cleanUp();
- this.playState = createjs.Sound.PLAY_INTERRUPTED;
- this._sendEvent("interrupted");
- };
-
-
- p._beginPlaying = function (playProps) {
- this._setPosition(playProps.offset);
- this._setLoop(playProps.loop);
- this._setVolume(playProps.volume);
- this._setPan(playProps.pan);
- if (playProps.startTime != null) {
- this._setStartTime(playProps.startTime);
- this._setDuration(playProps.duration);
- }
- if (this._playbackResource != null && this._position < this._duration) {
- this._paused = false;
- this._handleSoundReady();
- this.playState = createjs.Sound.PLAY_SUCCEEDED;
- this._sendEvent("succeeded");
- return true;
- } else {
- this._playFailed();
- return false;
- }
- };
-
- p._playFailed = function () {
- this._cleanUp();
- this.playState = createjs.Sound.PLAY_FAILED;
- this._sendEvent("failed");
- };
-
- p._handleSoundComplete = function (event) {
- this._position = 0;
- if (this._loop != 0) {
- this._loop--;
- this._handleLoop();
- this._sendEvent("loop");
- return;
- }
- this._cleanUp();
- this.playState = createjs.Sound.PLAY_FINISHED;
- this._sendEvent("complete");
- };
-
- p._handleSoundReady = function () {
-
- };
-
- p._updateVolume = function () {
-
- };
-
- p._updatePan = function () {
-
- };
-
- p._updateStartTime = function () {
-
- };
-
- p._updateDuration = function () {
-
- };
-
- p._setDurationFromSource = function () {
-
- };
-
- p._calculateCurrentPosition = function () {
-
- };
-
- p._updatePosition = function () {
-
- };
-
- p._removeLooping = function (value) {
-
- };
-
- p._addLooping = function (value) {
-
- };
-
- p._pause = function () {
-
- };
-
- p._resume = function () {
-
- };
-
- p._handleStop = function() {
-
- };
-
- p._handleCleanUp = function() {
-
- };
-
- p._handleLoop = function () {
-
- };
- createjs.AbstractSoundInstance = createjs.promote(AbstractSoundInstance, "EventDispatcher");
- createjs.DefaultSoundInstance = createjs.AbstractSoundInstance;
- }());
- (function () {
- "use strict";
-
- var AbstractPlugin = function () {
-
-
- this._capabilities = null;
-
- this._loaders = {};
-
- this._audioSources = {};
-
- this._soundInstances = {};
-
- this._volume = 1;
-
- this._loaderClass;
-
- this._soundInstanceClass;
- };
- var p = AbstractPlugin.prototype;
-
- AbstractPlugin._capabilities = null;
-
- AbstractPlugin.isSupported = function () {
- return true;
- };
-
- p.register = function (loadItem) {
- var loader = this._loaders[loadItem.src];
- if(loader && !loader.canceled) {return this._loaders[loadItem.src];}
-
- this._audioSources[loadItem.src] = true;
- this._soundInstances[loadItem.src] = [];
- loader = new this._loaderClass(loadItem);
- loader.on("complete", this._handlePreloadComplete, this);
- this._loaders[loadItem.src] = loader;
- return loader;
- };
-
-
- p.preload = function (loader) {
- loader.on("error", this._handlePreloadError, this);
- loader.load();
- };
-
- p.isPreloadStarted = function (src) {
- return (this._audioSources[src] != null);
- };
-
- p.isPreloadComplete = function (src) {
- return (!(this._audioSources[src] == null || this._audioSources[src] == true));
- };
-
- p.removeSound = function (src) {
- if (!this._soundInstances[src]) { return; }
- for (var i = this._soundInstances[src].length; i--; ) {
- var item = this._soundInstances[src][i];
- item.destroy();
- }
- delete(this._soundInstances[src]);
- delete(this._audioSources[src]);
- if(this._loaders[src]) { this._loaders[src].destroy(); }
- delete(this._loaders[src]);
- };
-
- p.removeAllSounds = function () {
- for(var key in this._audioSources) {
- this.removeSound(key);
- }
- };
-
- p.create = function (src, startTime, duration) {
- if (!this.isPreloadStarted(src)) {
- this.preload(this.register(src));
- }
- var si = new this._soundInstanceClass(src, startTime, duration, this._audioSources[src]);
- if(this._soundInstances[src]){
- this._soundInstances[src].push(si);
- }
-
-
- si.setMasterVolume && si.setMasterVolume(createjs.Sound.volume);
- si.setMasterMute && si.setMasterMute(createjs.Sound.muted);
- return si;
- };
-
-
- p.setVolume = function (value) {
- this._volume = value;
- this._updateVolume();
- return true;
- };
-
- p.getVolume = function () {
- return this._volume;
- };
-
- p.setMute = function (value) {
- this._updateVolume();
- return true;
- };
-
- p.toString = function () {
- return "[AbstractPlugin]";
- };
-
- p._handlePreloadComplete = function (event) {
- var src = event.target.getItem().src;
- this._audioSources[src] = event.result;
- for (var i = 0, l = this._soundInstances[src].length; i < l; i++) {
- var item = this._soundInstances[src][i];
- item.playbackResource = this._audioSources[src];
-
- this._soundInstances[src] = null;
- }
- };
-
- p._handlePreloadError = function(event) {
-
- };
-
- p._updateVolume = function () {
-
- };
- createjs.AbstractPlugin = AbstractPlugin;
- }());
- (function () {
- "use strict";
-
- function Loader(loadItem) {
- this.AbstractLoader_constructor(loadItem, true, createjs.Types.SOUND);
- };
- var p = createjs.extend(Loader, createjs.AbstractLoader);
-
- Loader.context = null;
- p.toString = function () {
- return "[WebAudioLoader]";
- };
- p._createRequest = function() {
- this._request = new createjs.XHRRequest(this._item, false);
- this._request.setResponseType("arraybuffer");
- };
- p._sendComplete = function (event) {
-
- Loader.context.decodeAudioData(this._rawResult,
- createjs.proxy(this._handleAudioDecoded, this),
- createjs.proxy(this._sendError, this));
- };
-
- p._handleAudioDecoded = function (decodedAudio) {
- this._result = decodedAudio;
- this.AbstractLoader__sendComplete();
- };
- createjs.WebAudioLoader = createjs.promote(Loader, "AbstractLoader");
- }());
- (function () {
- "use strict";
- function WebAudioSoundInstance(src, startTime, duration, playbackResource) {
- this.AbstractSoundInstance_constructor(src, startTime, duration, playbackResource);
-
- this.gainNode = s.context.createGain();
-
- this.panNode = s.context.createPanner();
- this.panNode.panningModel = s._panningModel;
- this.panNode.connect(this.gainNode);
- this._updatePan();
-
- this.sourceNode = null;
-
- this._soundCompleteTimeout = null;
-
- this._sourceNodeNext = null;
-
- this._playbackStartTime = 0;
-
- this._endedHandler = createjs.proxy(this._handleSoundComplete, this);
- };
- var p = createjs.extend(WebAudioSoundInstance, createjs.AbstractSoundInstance);
- var s = WebAudioSoundInstance;
-
- s.context = null;
-
- s._scratchBuffer = null;
-
- s.destinationNode = null;
-
- s._panningModel = "equalpower";
- p.destroy = function() {
- this.AbstractSoundInstance_destroy();
- this.panNode.disconnect(0);
- this.panNode = null;
- this.gainNode.disconnect(0);
- this.gainNode = null;
- };
- p.toString = function () {
- return "[WebAudioSoundInstance]";
- };
- p._updatePan = function() {
- this.panNode.setPosition(this._pan, 0, -0.5);
-
- };
- p._removeLooping = function(value) {
- this._sourceNodeNext = this._cleanUpAudioNode(this._sourceNodeNext);
- };
- p._addLooping = function(value) {
- if (this.playState != createjs.Sound.PLAY_SUCCEEDED) { return; }
- this._sourceNodeNext = this._createAndPlayAudioNode(this._playbackStartTime, 0);
- };
- p._setDurationFromSource = function () {
- this._duration = this.playbackResource.duration * 1000;
- };
- p._handleCleanUp = function () {
- if (this.sourceNode && this.playState == createjs.Sound.PLAY_SUCCEEDED) {
- this.sourceNode = this._cleanUpAudioNode(this.sourceNode);
- this._sourceNodeNext = this._cleanUpAudioNode(this._sourceNodeNext);
- }
- if (this.gainNode.numberOfOutputs != 0) {this.gainNode.disconnect(0);}
-
- clearTimeout(this._soundCompleteTimeout);
- this._playbackStartTime = 0;
- };
-
- p._cleanUpAudioNode = function(audioNode) {
- if(audioNode) {
- audioNode.stop(0);
- audioNode.disconnect(0);
-
-
- if ( createjs.BrowserDetect.isIOS ) {
- try { audioNode.buffer = s._scratchBuffer; } catch(e) {}
- }
- audioNode = null;
- }
- return audioNode;
- };
- p._handleSoundReady = function (event) {
- this.gainNode.connect(s.destinationNode);
- var dur = this._duration * 0.001,
- pos = Math.min(Math.max(0, this._position) * 0.001, dur);
- this.sourceNode = this._createAndPlayAudioNode((s.context.currentTime - dur), pos);
- this._playbackStartTime = this.sourceNode.startTime - pos;
- this._soundCompleteTimeout = setTimeout(this._endedHandler, (dur - pos) * 1000);
- if(this._loop != 0) {
- this._sourceNodeNext = this._createAndPlayAudioNode(this._playbackStartTime, 0);
- }
- };
-
- p._createAndPlayAudioNode = function(startTime, offset) {
- var audioNode = s.context.createBufferSource();
- audioNode.buffer = this.playbackResource;
- audioNode.connect(this.panNode);
- var dur = this._duration * 0.001;
- audioNode.startTime = startTime + dur;
- audioNode.start(audioNode.startTime, offset+(this._startTime*0.001), dur - offset);
- return audioNode;
- };
- p._pause = function () {
- this._position = (s.context.currentTime - this._playbackStartTime) * 1000;
- this.sourceNode = this._cleanUpAudioNode(this.sourceNode);
- this._sourceNodeNext = this._cleanUpAudioNode(this._sourceNodeNext);
- if (this.gainNode.numberOfOutputs != 0) {this.gainNode.disconnect(0);}
- clearTimeout(this._soundCompleteTimeout);
- };
- p._resume = function () {
- this._handleSoundReady();
- };
-
- p._updateVolume = function () {
- var newVolume = this._muted ? 0 : this._volume;
- if (newVolume != this.gainNode.gain.value) {
- this.gainNode.gain.value = newVolume;
- }
- };
- p._calculateCurrentPosition = function () {
- return ((s.context.currentTime - this._playbackStartTime) * 1000);
- };
- p._updatePosition = function () {
- this.sourceNode = this._cleanUpAudioNode(this.sourceNode);
- this._sourceNodeNext = this._cleanUpAudioNode(this._sourceNodeNext);
- clearTimeout(this._soundCompleteTimeout);
- if (!this._paused) {this._handleSoundReady();}
- };
-
-
-
-
- p._handleLoop = function () {
- this._cleanUpAudioNode(this.sourceNode);
- this.sourceNode = this._sourceNodeNext;
- this._playbackStartTime = this.sourceNode.startTime;
- this._sourceNodeNext = this._createAndPlayAudioNode(this._playbackStartTime, 0);
- this._soundCompleteTimeout = setTimeout(this._endedHandler, this._duration);
- };
- p._updateDuration = function () {
- if(this.playState == createjs.Sound.PLAY_SUCCEEDED) {
- this._pause();
- this._resume();
- }
- };
- createjs.WebAudioSoundInstance = createjs.promote(WebAudioSoundInstance, "AbstractSoundInstance");
- }());
- (function () {
- "use strict";
-
- function WebAudioPlugin() {
- this.AbstractPlugin_constructor();
-
- this._panningModel = s._panningModel;;
-
- this.context = s.context;
-
- this.dynamicsCompressorNode = this.context.createDynamicsCompressor();
- this.dynamicsCompressorNode.connect(this.context.destination);
-
- this.gainNode = this.context.createGain();
- this.gainNode.connect(this.dynamicsCompressorNode);
- createjs.WebAudioSoundInstance.destinationNode = this.gainNode;
- this._capabilities = s._capabilities;
- this._loaderClass = createjs.WebAudioLoader;
- this._soundInstanceClass = createjs.WebAudioSoundInstance;
- this._addPropsToClasses();
- }
- var p = createjs.extend(WebAudioPlugin, createjs.AbstractPlugin);
- var s = WebAudioPlugin;
-
- s._capabilities = null;
-
- s._panningModel = "equalpower";
-
- s.context = null;
-
- s._scratchBuffer = null;
-
- s._unlocked = false;
-
- s.DEFAULT_SAMPLE_RATE = 44100;
-
- s.isSupported = function () {
-
- var isMobilePhoneGap = createjs.BrowserDetect.isIOS || createjs.BrowserDetect.isAndroid || createjs.BrowserDetect.isBlackberry;
-
- if (location.protocol == "file:" && !isMobilePhoneGap && !this._isFileXHRSupported()) { return false; }
- s._generateCapabilities();
- if (s.context == null) {return false;}
- return true;
- };
-
- s.playEmptySound = function() {
- if (s.context == null) {return;}
- var source = s.context.createBufferSource();
- source.buffer = s._scratchBuffer;
- source.connect(s.context.destination);
- source.start(0, 0, 0);
- };
-
- s._isFileXHRSupported = function() {
-
- var supported = true;
- var xhr = new XMLHttpRequest();
- try {
- xhr.open("GET", "WebAudioPluginTest.fail", false);
- } catch (error) {
-
- supported = false;
- return supported;
- }
- xhr.onerror = function() { supported = false; };
-
- xhr.onload = function() { supported = this.status == 404 || (this.status == 200 || (this.status == 0 && this.response != "")); };
- try {
- xhr.send();
- } catch (error) {
-
- supported = false;
- }
- return supported;
- };
-
- s._generateCapabilities = function () {
- if (s._capabilities != null) {return;}
-
- var t = document.createElement("audio");
- if (t.canPlayType == null) {return null;}
- if (s.context == null) {
- s.context = s._createAudioContext();
- if (s.context == null) { return null; }
- }
- if (s._scratchBuffer == null) {
- s._scratchBuffer = s.context.createBuffer(1, 1, 22050);
- }
- s._compatibilitySetUp();
-
- if ("ontouchstart" in window && s.context.state != "running") {
- s._unlock();
- document.addEventListener("mousedown", s._unlock, true);
- document.addEventListener("touchstart", s._unlock, true);
- document.addEventListener("touchend", s._unlock, true);
- }
- s._capabilities = {
- panning:true,
- volume:true,
- tracks:-1
- };
-
- var supportedExtensions = createjs.Sound.SUPPORTED_EXTENSIONS;
- var extensionMap = createjs.Sound.EXTENSION_MAP;
- for (var i = 0, l = supportedExtensions.length; i < l; i++) {
- var ext = supportedExtensions[i];
- var playType = extensionMap[ext] || ext;
- s._capabilities[ext] = (t.canPlayType("audio/" + ext) != "no" && t.canPlayType("audio/" + ext) != "") || (t.canPlayType("audio/" + playType) != "no" && t.canPlayType("audio/" + playType) != "");
- }
-
-
- if (s.context.destination.numberOfChannels < 2) {
- s._capabilities.panning = false;
- }
- };
-
- s._createAudioContext = function() {
-
-
- var AudioCtor = (window.AudioContext || window.webkitAudioContext);
- if (AudioCtor == null) { return null; }
- var context = new AudioCtor();
-
-
-
- if (/(iPhone|iPad)/i.test(navigator.userAgent)
- && context.sampleRate !== s.DEFAULT_SAMPLE_RATE) {
- var buffer = context.createBuffer(1, 1, s.DEFAULT_SAMPLE_RATE),
- dummy = context.createBufferSource();
- dummy.buffer = buffer;
- dummy.connect(context.destination);
- dummy.start(0);
- dummy.disconnect();
- context.close()
- context = new AudioCtor();
- }
- return context;
- }
-
- s._compatibilitySetUp = function() {
- s._panningModel = "equalpower";
-
- if (s.context.createGain) { return; }
-
- s.context.createGain = s.context.createGainNode;
-
- var audioNode = s.context.createBufferSource();
- audioNode.__proto__.start = audioNode.__proto__.noteGrainOn;
- audioNode.__proto__.stop = audioNode.__proto__.noteOff;
-
- s._panningModel = 0;
- };
-
- s._unlock = function() {
- if (s._unlocked) { return; }
- s.playEmptySound();
- if (s.context.state == "running") {
- document.removeEventListener("mousedown", s._unlock, true);
- document.removeEventListener("touchend", s._unlock, true);
- document.removeEventListener("touchstart", s._unlock, true);
- s._unlocked = true;
- }
- };
- p.toString = function () {
- return "[WebAudioPlugin]";
- };
-
- p._addPropsToClasses = function() {
- var c = this._soundInstanceClass;
- c.context = this.context;
- c._scratchBuffer = s._scratchBuffer;
- c.destinationNode = this.gainNode;
- c._panningModel = this._panningModel;
- this._loaderClass.context = this.context;
- };
-
- p._updateVolume = function () {
- var newVolume = createjs.Sound._masterMute ? 0 : this._volume;
- if (newVolume != this.gainNode.gain.value) {
- this.gainNode.gain.value = newVolume;
- }
- };
- createjs.WebAudioPlugin = createjs.promote(WebAudioPlugin, "AbstractPlugin");
- }());
- (function () {
- "use strict";
-
- function HTMLAudioTagPool() {
- throw "HTMLAudioTagPool cannot be instantiated";
- }
- var s = HTMLAudioTagPool;
-
- s._tags = {};
-
- s._tagPool = new TagPool();
-
- s._tagUsed = {};
-
- s.get = function (src) {
- var t = s._tags[src];
- if (t == null) {
-
- t = s._tags[src] = s._tagPool.get();
- t.src = src;
- } else {
-
- if (s._tagUsed[src]) {
- t = s._tagPool.get();
- t.src = src;
- } else {
- s._tagUsed[src] = true;
- }
- }
- return t;
- };
-
- s.set = function (src, tag) {
-
- if(tag == s._tags[src]) {
- s._tagUsed[src] = false;
- } else {
- s._tagPool.set(tag);
- }
- };
-
- s.remove = function (src) {
- var tag = s._tags[src];
- if (tag == null) {return false;}
- s._tagPool.set(tag);
- delete(s._tags[src]);
- delete(s._tagUsed[src]);
- return true;
- };
-
- s.getDuration= function (src) {
- var t = s._tags[src];
- if (t == null || !t.duration) {return 0;}
- return t.duration * 1000;
- };
- createjs.HTMLAudioTagPool = HTMLAudioTagPool;
-
- function TagPool(src) {
-
- this._tags = [];
- };
- var p = TagPool.prototype;
- p.constructor = TagPool;
-
- p.get = function () {
- var tag;
- if (this._tags.length == 0) {
- tag = this._createTag();
- } else {
- tag = this._tags.pop();
- }
- if (tag.parentNode == null) {document.body.appendChild(tag);}
- return tag;
- };
-
- p.set = function (tag) {
-
- var index = createjs.indexOf(this._tags, tag);
- if (index == -1) {
- this._tags.src = null;
- this._tags.push(tag);
- }
- };
- p.toString = function () {
- return "[TagPool]";
- };
-
- p._createTag = function () {
- var tag = document.createElement("audio");
- tag.autoplay = false;
- tag.preload = "none";
-
- return tag;
- };
- }());
- (function () {
- "use strict";
-
- function HTMLAudioSoundInstance(src, startTime, duration, playbackResource) {
- this.AbstractSoundInstance_constructor(src, startTime, duration, playbackResource);
- this._audioSpriteStopTime = null;
- this._delayTimeoutId = null;
-
- this._endedHandler = createjs.proxy(this._handleSoundComplete, this);
- this._readyHandler = createjs.proxy(this._handleTagReady, this);
- this._stalledHandler = createjs.proxy(this._playFailed, this);
- this._audioSpriteEndHandler = createjs.proxy(this._handleAudioSpriteLoop, this);
- this._loopHandler = createjs.proxy(this._handleSoundComplete, this);
- if (duration) {
- this._audioSpriteStopTime = (startTime + duration) * 0.001;
- } else {
- this._duration = createjs.HTMLAudioTagPool.getDuration(this.src);
- }
- }
- var p = createjs.extend(HTMLAudioSoundInstance, createjs.AbstractSoundInstance);
-
- p.setMasterVolume = function (value) {
- this._updateVolume();
- };
-
- p.setMasterMute = function (isMuted) {
- this._updateVolume();
- };
- p.toString = function () {
- return "[HTMLAudioSoundInstance]";
- };
- p._removeLooping = function() {
- if(this._playbackResource == null) {return;}
- this._playbackResource.loop = false;
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._loopHandler, false);
- };
- p._addLooping = function() {
- if(this._playbackResource == null || this._audioSpriteStopTime) {return;}
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._loopHandler, false);
- this._playbackResource.loop = true;
- };
- p._handleCleanUp = function () {
- var tag = this._playbackResource;
- if (tag != null) {
- tag.pause();
- tag.loop = false;
- tag.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED, this._endedHandler, false);
- tag.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_READY, this._readyHandler, false);
- tag.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_STALLED, this._stalledHandler, false);
- tag.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._loopHandler, false);
- tag.removeEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE, this._audioSpriteEndHandler, false);
- try {
- tag.currentTime = this._startTime;
- } catch (e) {
- }
- createjs.HTMLAudioTagPool.set(this.src, tag);
- this._playbackResource = null;
- }
- };
- p._beginPlaying = function (playProps) {
- this._playbackResource = createjs.HTMLAudioTagPool.get(this.src);
- return this.AbstractSoundInstance__beginPlaying(playProps);
- };
- p._handleSoundReady = function (event) {
- if (this._playbackResource.readyState !== 4) {
- var tag = this._playbackResource;
- tag.addEventListener(createjs.HTMLAudioPlugin._AUDIO_READY, this._readyHandler, false);
- tag.addEventListener(createjs.HTMLAudioPlugin._AUDIO_STALLED, this._stalledHandler, false);
- tag.preload = "auto";
- tag.load();
- return;
- }
- this._updateVolume();
- this._playbackResource.currentTime = (this._startTime + this._position) * 0.001;
- if (this._audioSpriteStopTime) {
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE, this._audioSpriteEndHandler, false);
- } else {
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED, this._endedHandler, false);
- if(this._loop != 0) {
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._loopHandler, false);
- this._playbackResource.loop = true;
- }
- }
- this._playbackResource.play();
- };
-
- p._handleTagReady = function (event) {
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_READY, this._readyHandler, false);
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_STALLED, this._stalledHandler, false);
- this._handleSoundReady();
- };
- p._pause = function () {
- this._playbackResource.pause();
- };
- p._resume = function () {
- this._playbackResource.play();
- };
- p._updateVolume = function () {
- if (this._playbackResource != null) {
- var newVolume = (this._muted || createjs.Sound._masterMute) ? 0 : this._volume * createjs.Sound._masterVolume;
- if (newVolume != this._playbackResource.volume) {this._playbackResource.volume = newVolume;}
- }
- };
- p._calculateCurrentPosition = function() {
- return (this._playbackResource.currentTime * 1000) - this._startTime;
- };
- p._updatePosition = function() {
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._loopHandler, false);
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._handleSetPositionSeek, false);
- try {
- this._playbackResource.currentTime = (this._position + this._startTime) * 0.001;
- } catch (error) {
- this._handleSetPositionSeek(null);
- }
- };
-
- p._handleSetPositionSeek = function(event) {
- if (this._playbackResource == null) { return; }
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._handleSetPositionSeek, false);
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._loopHandler, false);
- };
-
- p._handleAudioSpriteLoop = function (event) {
- if(this._playbackResource.currentTime <= this._audioSpriteStopTime) {return;}
- this._playbackResource.pause();
- if(this._loop == 0) {
- this._handleSoundComplete(null);
- } else {
- this._position = 0;
- this._loop--;
- this._playbackResource.currentTime = this._startTime * 0.001;
- if(!this._paused) {this._playbackResource.play();}
- this._sendEvent("loop");
- }
- };
-
-
- p._handleLoop = function (event) {
- if(this._loop == 0) {
- this._playbackResource.loop = false;
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED, this._loopHandler, false);
- }
- };
- p._updateStartTime = function () {
- this._audioSpriteStopTime = (this._startTime + this._duration) * 0.001;
- if(this.playState == createjs.Sound.PLAY_SUCCEEDED) {
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED, this._endedHandler, false);
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE, this._audioSpriteEndHandler, false);
- }
- };
- p._updateDuration = function () {
- this._audioSpriteStopTime = (this._startTime + this._duration) * 0.001;
- if(this.playState == createjs.Sound.PLAY_SUCCEEDED) {
- this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED, this._endedHandler, false);
- this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE, this._audioSpriteEndHandler, false);
- }
- };
- p._setDurationFromSource = function () {
- this._duration = createjs.HTMLAudioTagPool.getDuration(this.src);
- this._playbackResource = null;
- };
- createjs.HTMLAudioSoundInstance = createjs.promote(HTMLAudioSoundInstance, "AbstractSoundInstance");
- }());
- (function () {
- "use strict";
-
- function HTMLAudioPlugin() {
- this.AbstractPlugin_constructor();
-
- this._capabilities = s._capabilities;
- this._loaderClass = createjs.SoundLoader;
- this._soundInstanceClass = createjs.HTMLAudioSoundInstance;
- }
- var p = createjs.extend(HTMLAudioPlugin, createjs.AbstractPlugin);
- var s = HTMLAudioPlugin;
-
- s.MAX_INSTANCES = 30;
-
- s._AUDIO_READY = "canplaythrough";
-
- s._AUDIO_ENDED = "ended";
-
- s._AUDIO_SEEKED = "seeked";
-
- s._AUDIO_STALLED = "stalled";
-
- s._TIME_UPDATE = "timeupdate";
-
- s._capabilities = null;
-
- s.isSupported = function () {
- s._generateCapabilities();
- return (s._capabilities != null);
- };
-
- s._generateCapabilities = function () {
- if (s._capabilities != null) {return;}
- var t = document.createElement("audio");
- if (t.canPlayType == null) {return null;}
- s._capabilities = {
- panning:false,
- volume:true,
- tracks:-1
- };
-
- var supportedExtensions = createjs.Sound.SUPPORTED_EXTENSIONS;
- var extensionMap = createjs.Sound.EXTENSION_MAP;
- for (var i = 0, l = supportedExtensions.length; i < l; i++) {
- var ext = supportedExtensions[i];
- var playType = extensionMap[ext] || ext;
- s._capabilities[ext] = (t.canPlayType("audio/" + ext) != "no" && t.canPlayType("audio/" + ext) != "") || (t.canPlayType("audio/" + playType) != "no" && t.canPlayType("audio/" + playType) != "");
- }
- };
- p.register = function (loadItem) {
- var tag = createjs.HTMLAudioTagPool.get(loadItem.src);
- var loader = this.AbstractPlugin_register(loadItem);
- loader.setTag(tag);
- return loader;
- };
- p.removeSound = function (src) {
- this.AbstractPlugin_removeSound(src);
- createjs.HTMLAudioTagPool.remove(src);
- };
- p.create = function (src, startTime, duration) {
- var si = this.AbstractPlugin_create(src, startTime, duration);
- si.playbackResource = null;
- return si;
- };
- p.toString = function () {
- return "[HTMLAudioPlugin]";
- };
-
- p.setVolume = p.getVolume = p.setMute = null;
- createjs.HTMLAudioPlugin = createjs.promote(HTMLAudioPlugin, "AbstractPlugin");
- }());
- export default createjs
|