video.js 855 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282
  1. /**
  2. * 感谢原作者提供以下代码
  3. * 原作者github地址
  4. * https://github.com/videojs
  5. */
  6. (function (f) { if (typeof exports === "object" && typeof module !== "undefined") { module.exports = f() } else if (typeof define === "function" && define.amd) { define([], f) } else { var g; if (typeof window !== "undefined") { g = window } else if (typeof global !== "undefined") { g = global } else if (typeof self !== "undefined") { g = self } else { g = this } g.videojs = f() } })(function () {
  7. var define, module, exports; return (function e(t, n, r) { function s(o, u) { if (!n[o]) { if (!t[o]) { var a = typeof require == "function" && require; if (!u && a) return a(o, !0); if (i) return i(o, !0); var f = new Error("Cannot find module '" + o + "'"); throw f.code = "MODULE_NOT_FOUND", f } var l = n[o] = { exports: {} }; t[o][0].call(l.exports, function (e) { var n = t[o][1][e]; return s(n ? n : e) }, l, l.exports, e, t, n, r) } return n[o].exports } var i = typeof require == "function" && require; for (var o = 0; o < r.length; o++)s(r[o]); return s })({
  8. 1: [function (_dereq_, module, exports) {
  9. (function (global) {
  10. var topLevel = typeof global !== 'undefined' ? global :
  11. typeof window !== 'undefined' ? window : {}
  12. var minDoc = _dereq_('min-document');
  13. if (typeof document !== 'undefined') {
  14. module.exports = document;
  15. } else {
  16. var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
  17. if (!doccy) {
  18. doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
  19. }
  20. module.exports = doccy;
  21. }
  22. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  23. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9nbG9iYWwvZG9jdW1lbnQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwiZmlsZSI6ImdlbmVyYXRlZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgdG9wTGV2ZWwgPSB0eXBlb2YgZ2xvYmFsICE9PSAndW5kZWZpbmVkJyA/IGdsb2JhbCA6XG4gICAgdHlwZW9mIHdpbmRvdyAhPT0gJ3VuZGVmaW5lZCcgPyB3aW5kb3cgOiB7fVxudmFyIG1pbkRvYyA9IHJlcXVpcmUoJ21pbi1kb2N1bWVudCcpO1xuXG5pZiAodHlwZW9mIGRvY3VtZW50ICE9PSAndW5kZWZpbmVkJykge1xuICAgIG1vZHVsZS5leHBvcnRzID0gZG9jdW1lbnQ7XG59IGVsc2Uge1xuICAgIHZhciBkb2NjeSA9IHRvcExldmVsWydfX0dMT0JBTF9ET0NVTUVOVF9DQUNIRUA0J107XG5cbiAgICBpZiAoIWRvY2N5KSB7XG4gICAgICAgIGRvY2N5ID0gdG9wTGV2ZWxbJ19fR0xPQkFMX0RPQ1VNRU5UX0NBQ0hFQDQnXSA9IG1pbkRvYztcbiAgICB9XG5cbiAgICBtb2R1bGUuZXhwb3J0cyA9IGRvY2N5O1xufVxuIl19
  24. }, { "min-document": 3 }], 2: [function (_dereq_, module, exports) {
  25. (function (global) {
  26. if (typeof window !== "undefined") {
  27. module.exports = window;
  28. } else if (typeof global !== "undefined") {
  29. module.exports = global;
  30. } else if (typeof self !== "undefined") {
  31. module.exports = self;
  32. } else {
  33. module.exports = {};
  34. }
  35. }).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  36. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9nbG9iYWwvd2luZG93LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiaWYgKHR5cGVvZiB3aW5kb3cgIT09IFwidW5kZWZpbmVkXCIpIHtcbiAgICBtb2R1bGUuZXhwb3J0cyA9IHdpbmRvdztcbn0gZWxzZSBpZiAodHlwZW9mIGdsb2JhbCAhPT0gXCJ1bmRlZmluZWRcIikge1xuICAgIG1vZHVsZS5leHBvcnRzID0gZ2xvYmFsO1xufSBlbHNlIGlmICh0eXBlb2Ygc2VsZiAhPT0gXCJ1bmRlZmluZWRcIil7XG4gICAgbW9kdWxlLmV4cG9ydHMgPSBzZWxmO1xufSBlbHNlIHtcbiAgICBtb2R1bGUuZXhwb3J0cyA9IHt9O1xufVxuIl19
  37. }, {}], 3: [function (_dereq_, module, exports) {
  38. }, {}], 4: [function (_dereq_, module, exports) {
  39. var getNative = _dereq_('../internal/getNative');
  40. /* Native method references for those with the same name as other `lodash` methods. */
  41. var nativeNow = getNative(Date, 'now');
  42. /**
  43. * Gets the number of milliseconds that have elapsed since the Unix epoch
  44. * (1 January 1970 00:00:00 UTC).
  45. *
  46. * @static
  47. * @memberOf _
  48. * @category Date
  49. * @example
  50. *
  51. * _.defer(function(stamp) {
  52. * console.log(_.now() - stamp);
  53. * }, _.now());
  54. * // => logs the number of milliseconds it took for the deferred function to be invoked
  55. */
  56. var now = nativeNow || function () {
  57. return new Date().getTime();
  58. };
  59. module.exports = now;
  60. }, { "../internal/getNative": 20 }], 5: [function (_dereq_, module, exports) {
  61. var isObject = _dereq_('../lang/isObject'),
  62. now = _dereq_('../date/now');
  63. /** Used as the `TypeError` message for "Functions" methods. */
  64. var FUNC_ERROR_TEXT = 'Expected a function';
  65. /* Native method references for those with the same name as other `lodash` methods. */
  66. var nativeMax = Math.max;
  67. /**
  68. * Creates a debounced function that delays invoking `func` until after `wait`
  69. * milliseconds have elapsed since the last time the debounced function was
  70. * invoked. The debounced function comes with a `cancel` method to cancel
  71. * delayed invocations. Provide an options object to indicate that `func`
  72. * should be invoked on the leading and/or trailing edge of the `wait` timeout.
  73. * Subsequent calls to the debounced function return the result of the last
  74. * `func` invocation.
  75. *
  76. * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
  77. * on the trailing edge of the timeout only if the the debounced function is
  78. * invoked more than once during the `wait` timeout.
  79. *
  80. * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
  81. * for details over the differences between `_.debounce` and `_.throttle`.
  82. *
  83. * @static
  84. * @memberOf _
  85. * @category Function
  86. * @param {Function} func The function to debounce.
  87. * @param {number} [wait=0] The number of milliseconds to delay.
  88. * @param {Object} [options] The options object.
  89. * @param {boolean} [options.leading=false] Specify invoking on the leading
  90. * edge of the timeout.
  91. * @param {number} [options.maxWait] The maximum time `func` is allowed to be
  92. * delayed before it's invoked.
  93. * @param {boolean} [options.trailing=true] Specify invoking on the trailing
  94. * edge of the timeout.
  95. * @returns {Function} Returns the new debounced function.
  96. * @example
  97. *
  98. * // avoid costly calculations while the window size is in flux
  99. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  100. *
  101. * // invoke `sendMail` when the click event is fired, debouncing subsequent calls
  102. * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
  103. * 'leading': true,
  104. * 'trailing': false
  105. * }));
  106. *
  107. * // ensure `batchLog` is invoked once after 1 second of debounced calls
  108. * var source = new EventSource('/stream');
  109. * jQuery(source).on('message', _.debounce(batchLog, 250, {
  110. * 'maxWait': 1000
  111. * }));
  112. *
  113. * // cancel a debounced call
  114. * var todoChanges = _.debounce(batchLog, 1000);
  115. * Object.observe(models.todo, todoChanges);
  116. *
  117. * Object.observe(models, function(changes) {
  118. * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {
  119. * todoChanges.cancel();
  120. * }
  121. * }, ['delete']);
  122. *
  123. * // ...at some point `models.todo` is changed
  124. * models.todo.completed = true;
  125. *
  126. * // ...before 1 second has passed `models.todo` is deleted
  127. * // which cancels the debounced `todoChanges` call
  128. * delete models.todo;
  129. */
  130. function debounce(func, wait, options) {
  131. var args,
  132. maxTimeoutId,
  133. result,
  134. stamp,
  135. thisArg,
  136. timeoutId,
  137. trailingCall,
  138. lastCalled = 0,
  139. maxWait = false,
  140. trailing = true;
  141. if (typeof func != 'function') {
  142. throw new TypeError(FUNC_ERROR_TEXT);
  143. }
  144. wait = wait < 0 ? 0 : (+wait || 0);
  145. if (options === true) {
  146. var leading = true;
  147. trailing = false;
  148. } else if (isObject(options)) {
  149. leading = !!options.leading;
  150. maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
  151. trailing = 'trailing' in options ? !!options.trailing : trailing;
  152. }
  153. function cancel() {
  154. if (timeoutId) {
  155. clearTimeout(timeoutId);
  156. }
  157. if (maxTimeoutId) {
  158. clearTimeout(maxTimeoutId);
  159. }
  160. lastCalled = 0;
  161. maxTimeoutId = timeoutId = trailingCall = undefined;
  162. }
  163. function complete(isCalled, id) {
  164. if (id) {
  165. clearTimeout(id);
  166. }
  167. maxTimeoutId = timeoutId = trailingCall = undefined;
  168. if (isCalled) {
  169. lastCalled = now();
  170. result = func.apply(thisArg, args);
  171. if (!timeoutId && !maxTimeoutId) {
  172. args = thisArg = undefined;
  173. }
  174. }
  175. }
  176. function delayed() {
  177. var remaining = wait - (now() - stamp);
  178. if (remaining <= 0 || remaining > wait) {
  179. complete(trailingCall, maxTimeoutId);
  180. } else {
  181. timeoutId = setTimeout(delayed, remaining);
  182. }
  183. }
  184. function maxDelayed() {
  185. complete(trailing, timeoutId);
  186. }
  187. function debounced() {
  188. args = arguments;
  189. stamp = now();
  190. thisArg = this;
  191. trailingCall = trailing && (timeoutId || !leading);
  192. if (maxWait === false) {
  193. var leadingCall = leading && !timeoutId;
  194. } else {
  195. if (!maxTimeoutId && !leading) {
  196. lastCalled = stamp;
  197. }
  198. var remaining = maxWait - (stamp - lastCalled),
  199. isCalled = remaining <= 0 || remaining > maxWait;
  200. if (isCalled) {
  201. if (maxTimeoutId) {
  202. maxTimeoutId = clearTimeout(maxTimeoutId);
  203. }
  204. lastCalled = stamp;
  205. result = func.apply(thisArg, args);
  206. }
  207. else if (!maxTimeoutId) {
  208. maxTimeoutId = setTimeout(maxDelayed, remaining);
  209. }
  210. }
  211. if (isCalled && timeoutId) {
  212. timeoutId = clearTimeout(timeoutId);
  213. }
  214. else if (!timeoutId && wait !== maxWait) {
  215. timeoutId = setTimeout(delayed, wait);
  216. }
  217. if (leadingCall) {
  218. isCalled = true;
  219. result = func.apply(thisArg, args);
  220. }
  221. if (isCalled && !timeoutId && !maxTimeoutId) {
  222. args = thisArg = undefined;
  223. }
  224. return result;
  225. }
  226. debounced.cancel = cancel;
  227. return debounced;
  228. }
  229. module.exports = debounce;
  230. }, { "../date/now": 4, "../lang/isObject": 33 }], 6: [function (_dereq_, module, exports) {
  231. /** Used as the `TypeError` message for "Functions" methods. */
  232. var FUNC_ERROR_TEXT = 'Expected a function';
  233. /* Native method references for those with the same name as other `lodash` methods. */
  234. var nativeMax = Math.max;
  235. /**
  236. * Creates a function that invokes `func` with the `this` binding of the
  237. * created function and arguments from `start` and beyond provided as an array.
  238. *
  239. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
  240. *
  241. * @static
  242. * @memberOf _
  243. * @category Function
  244. * @param {Function} func The function to apply a rest parameter to.
  245. * @param {number} [start=func.length-1] The start position of the rest parameter.
  246. * @returns {Function} Returns the new function.
  247. * @example
  248. *
  249. * var say = _.restParam(function(what, names) {
  250. * return what + ' ' + _.initial(names).join(', ') +
  251. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  252. * });
  253. *
  254. * say('hello', 'fred', 'barney', 'pebbles');
  255. * // => 'hello fred, barney, & pebbles'
  256. */
  257. function restParam(func, start) {
  258. if (typeof func != 'function') {
  259. throw new TypeError(FUNC_ERROR_TEXT);
  260. }
  261. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  262. return function () {
  263. var args = arguments,
  264. index = -1,
  265. length = nativeMax(args.length - start, 0),
  266. rest = Array(length);
  267. while (++index < length) {
  268. rest[index] = args[start + index];
  269. }
  270. switch (start) {
  271. case 0: return func.call(this, rest);
  272. case 1: return func.call(this, args[0], rest);
  273. case 2: return func.call(this, args[0], args[1], rest);
  274. }
  275. var otherArgs = Array(start + 1);
  276. index = -1;
  277. while (++index < start) {
  278. otherArgs[index] = args[index];
  279. }
  280. otherArgs[start] = rest;
  281. return func.apply(this, otherArgs);
  282. };
  283. }
  284. module.exports = restParam;
  285. }, {}], 7: [function (_dereq_, module, exports) {
  286. var debounce = _dereq_('./debounce'),
  287. isObject = _dereq_('../lang/isObject');
  288. /** Used as the `TypeError` message for "Functions" methods. */
  289. var FUNC_ERROR_TEXT = 'Expected a function';
  290. /**
  291. * Creates a throttled function that only invokes `func` at most once per
  292. * every `wait` milliseconds. The throttled function comes with a `cancel`
  293. * method to cancel delayed invocations. Provide an options object to indicate
  294. * that `func` should be invoked on the leading and/or trailing edge of the
  295. * `wait` timeout. Subsequent calls to the throttled function return the
  296. * result of the last `func` call.
  297. *
  298. * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
  299. * on the trailing edge of the timeout only if the the throttled function is
  300. * invoked more than once during the `wait` timeout.
  301. *
  302. * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
  303. * for details over the differences between `_.throttle` and `_.debounce`.
  304. *
  305. * @static
  306. * @memberOf _
  307. * @category Function
  308. * @param {Function} func The function to throttle.
  309. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  310. * @param {Object} [options] The options object.
  311. * @param {boolean} [options.leading=true] Specify invoking on the leading
  312. * edge of the timeout.
  313. * @param {boolean} [options.trailing=true] Specify invoking on the trailing
  314. * edge of the timeout.
  315. * @returns {Function} Returns the new throttled function.
  316. * @example
  317. *
  318. * // avoid excessively updating the position while scrolling
  319. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  320. *
  321. * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes
  322. * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
  323. * 'trailing': false
  324. * }));
  325. *
  326. * // cancel a trailing throttled call
  327. * jQuery(window).on('popstate', throttled.cancel);
  328. */
  329. function throttle(func, wait, options) {
  330. var leading = true,
  331. trailing = true;
  332. if (typeof func != 'function') {
  333. throw new TypeError(FUNC_ERROR_TEXT);
  334. }
  335. if (options === false) {
  336. leading = false;
  337. } else if (isObject(options)) {
  338. leading = 'leading' in options ? !!options.leading : leading;
  339. trailing = 'trailing' in options ? !!options.trailing : trailing;
  340. }
  341. return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing });
  342. }
  343. module.exports = throttle;
  344. }, { "../lang/isObject": 33, "./debounce": 5 }], 8: [function (_dereq_, module, exports) {
  345. /**
  346. * Copies the values of `source` to `array`.
  347. *
  348. * @private
  349. * @param {Array} source The array to copy values from.
  350. * @param {Array} [array=[]] The array to copy values to.
  351. * @returns {Array} Returns `array`.
  352. */
  353. function arrayCopy(source, array) {
  354. var index = -1,
  355. length = source.length;
  356. array || (array = Array(length));
  357. while (++index < length) {
  358. array[index] = source[index];
  359. }
  360. return array;
  361. }
  362. module.exports = arrayCopy;
  363. }, {}], 9: [function (_dereq_, module, exports) {
  364. /**
  365. * A specialized version of `_.forEach` for arrays without support for callback
  366. * shorthands and `this` binding.
  367. *
  368. * @private
  369. * @param {Array} array The array to iterate over.
  370. * @param {Function} iteratee The function invoked per iteration.
  371. * @returns {Array} Returns `array`.
  372. */
  373. function arrayEach(array, iteratee) {
  374. var index = -1,
  375. length = array.length;
  376. while (++index < length) {
  377. if (iteratee(array[index], index, array) === false) {
  378. break;
  379. }
  380. }
  381. return array;
  382. }
  383. module.exports = arrayEach;
  384. }, {}], 10: [function (_dereq_, module, exports) {
  385. /**
  386. * Copies properties of `source` to `object`.
  387. *
  388. * @private
  389. * @param {Object} source The object to copy properties from.
  390. * @param {Array} props The property names to copy.
  391. * @param {Object} [object={}] The object to copy properties to.
  392. * @returns {Object} Returns `object`.
  393. */
  394. function baseCopy(source, props, object) {
  395. object || (object = {});
  396. var index = -1,
  397. length = props.length;
  398. while (++index < length) {
  399. var key = props[index];
  400. object[key] = source[key];
  401. }
  402. return object;
  403. }
  404. module.exports = baseCopy;
  405. }, {}], 11: [function (_dereq_, module, exports) {
  406. var createBaseFor = _dereq_('./createBaseFor');
  407. /**
  408. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  409. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  410. * each property. Iteratee functions may exit iteration early by explicitly
  411. * returning `false`.
  412. *
  413. * @private
  414. * @param {Object} object The object to iterate over.
  415. * @param {Function} iteratee The function invoked per iteration.
  416. * @param {Function} keysFunc The function to get the keys of `object`.
  417. * @returns {Object} Returns `object`.
  418. */
  419. var baseFor = createBaseFor();
  420. module.exports = baseFor;
  421. }, { "./createBaseFor": 18 }], 12: [function (_dereq_, module, exports) {
  422. var baseFor = _dereq_('./baseFor'),
  423. keysIn = _dereq_('../object/keysIn');
  424. /**
  425. * The base implementation of `_.forIn` without support for callback
  426. * shorthands and `this` binding.
  427. *
  428. * @private
  429. * @param {Object} object The object to iterate over.
  430. * @param {Function} iteratee The function invoked per iteration.
  431. * @returns {Object} Returns `object`.
  432. */
  433. function baseForIn(object, iteratee) {
  434. return baseFor(object, iteratee, keysIn);
  435. }
  436. module.exports = baseForIn;
  437. }, { "../object/keysIn": 39, "./baseFor": 11 }], 13: [function (_dereq_, module, exports) {
  438. var arrayEach = _dereq_('./arrayEach'),
  439. baseMergeDeep = _dereq_('./baseMergeDeep'),
  440. isArray = _dereq_('../lang/isArray'),
  441. isArrayLike = _dereq_('./isArrayLike'),
  442. isObject = _dereq_('../lang/isObject'),
  443. isObjectLike = _dereq_('./isObjectLike'),
  444. isTypedArray = _dereq_('../lang/isTypedArray'),
  445. keys = _dereq_('../object/keys');
  446. /**
  447. * The base implementation of `_.merge` without support for argument juggling,
  448. * multiple sources, and `this` binding `customizer` functions.
  449. *
  450. * @private
  451. * @param {Object} object The destination object.
  452. * @param {Object} source The source object.
  453. * @param {Function} [customizer] The function to customize merged values.
  454. * @param {Array} [stackA=[]] Tracks traversed source objects.
  455. * @param {Array} [stackB=[]] Associates values with source counterparts.
  456. * @returns {Object} Returns `object`.
  457. */
  458. function baseMerge(object, source, customizer, stackA, stackB) {
  459. if (!isObject(object)) {
  460. return object;
  461. }
  462. var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
  463. props = isSrcArr ? undefined : keys(source);
  464. arrayEach(props || source, function (srcValue, key) {
  465. if (props) {
  466. key = srcValue;
  467. srcValue = source[key];
  468. }
  469. if (isObjectLike(srcValue)) {
  470. stackA || (stackA = []);
  471. stackB || (stackB = []);
  472. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  473. }
  474. else {
  475. var value = object[key],
  476. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  477. isCommon = result === undefined;
  478. if (isCommon) {
  479. result = srcValue;
  480. }
  481. if ((result !== undefined || (isSrcArr && !(key in object))) &&
  482. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  483. object[key] = result;
  484. }
  485. }
  486. });
  487. return object;
  488. }
  489. module.exports = baseMerge;
  490. }, { "../lang/isArray": 30, "../lang/isObject": 33, "../lang/isTypedArray": 36, "../object/keys": 38, "./arrayEach": 9, "./baseMergeDeep": 14, "./isArrayLike": 21, "./isObjectLike": 26 }], 14: [function (_dereq_, module, exports) {
  491. var arrayCopy = _dereq_('./arrayCopy'),
  492. isArguments = _dereq_('../lang/isArguments'),
  493. isArray = _dereq_('../lang/isArray'),
  494. isArrayLike = _dereq_('./isArrayLike'),
  495. isPlainObject = _dereq_('../lang/isPlainObject'),
  496. isTypedArray = _dereq_('../lang/isTypedArray'),
  497. toPlainObject = _dereq_('../lang/toPlainObject');
  498. /**
  499. * A specialized version of `baseMerge` for arrays and objects which performs
  500. * deep merges and tracks traversed objects enabling objects with circular
  501. * references to be merged.
  502. *
  503. * @private
  504. * @param {Object} object The destination object.
  505. * @param {Object} source The source object.
  506. * @param {string} key The key of the value to merge.
  507. * @param {Function} mergeFunc The function to merge values.
  508. * @param {Function} [customizer] The function to customize merged values.
  509. * @param {Array} [stackA=[]] Tracks traversed source objects.
  510. * @param {Array} [stackB=[]] Associates values with source counterparts.
  511. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  512. */
  513. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  514. var length = stackA.length,
  515. srcValue = source[key];
  516. while (length--) {
  517. if (stackA[length] == srcValue) {
  518. object[key] = stackB[length];
  519. return;
  520. }
  521. }
  522. var value = object[key],
  523. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  524. isCommon = result === undefined;
  525. if (isCommon) {
  526. result = srcValue;
  527. if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
  528. result = isArray(value)
  529. ? value
  530. : (isArrayLike(value) ? arrayCopy(value) : []);
  531. }
  532. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  533. result = isArguments(value)
  534. ? toPlainObject(value)
  535. : (isPlainObject(value) ? value : {});
  536. }
  537. else {
  538. isCommon = false;
  539. }
  540. }
  541. // Add the source value to the stack of traversed objects and associate
  542. // it with its merged value.
  543. stackA.push(srcValue);
  544. stackB.push(result);
  545. if (isCommon) {
  546. // Recursively merge objects and arrays (susceptible to call stack limits).
  547. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  548. } else if (result === result ? (result !== value) : (value === value)) {
  549. object[key] = result;
  550. }
  551. }
  552. module.exports = baseMergeDeep;
  553. }, { "../lang/isArguments": 29, "../lang/isArray": 30, "../lang/isPlainObject": 34, "../lang/isTypedArray": 36, "../lang/toPlainObject": 37, "./arrayCopy": 8, "./isArrayLike": 21 }], 15: [function (_dereq_, module, exports) {
  554. var toObject = _dereq_('./toObject');
  555. /**
  556. * The base implementation of `_.property` without support for deep paths.
  557. *
  558. * @private
  559. * @param {string} key The key of the property to get.
  560. * @returns {Function} Returns the new function.
  561. */
  562. function baseProperty(key) {
  563. return function (object) {
  564. return object == null ? undefined : toObject(object)[key];
  565. };
  566. }
  567. module.exports = baseProperty;
  568. }, { "./toObject": 28 }], 16: [function (_dereq_, module, exports) {
  569. var identity = _dereq_('../utility/identity');
  570. /**
  571. * A specialized version of `baseCallback` which only supports `this` binding
  572. * and specifying the number of arguments to provide to `func`.
  573. *
  574. * @private
  575. * @param {Function} func The function to bind.
  576. * @param {*} thisArg The `this` binding of `func`.
  577. * @param {number} [argCount] The number of arguments to provide to `func`.
  578. * @returns {Function} Returns the callback.
  579. */
  580. function bindCallback(func, thisArg, argCount) {
  581. if (typeof func != 'function') {
  582. return identity;
  583. }
  584. if (thisArg === undefined) {
  585. return func;
  586. }
  587. switch (argCount) {
  588. case 1: return function (value) {
  589. return func.call(thisArg, value);
  590. };
  591. case 3: return function (value, index, collection) {
  592. return func.call(thisArg, value, index, collection);
  593. };
  594. case 4: return function (accumulator, value, index, collection) {
  595. return func.call(thisArg, accumulator, value, index, collection);
  596. };
  597. case 5: return function (value, other, key, object, source) {
  598. return func.call(thisArg, value, other, key, object, source);
  599. };
  600. }
  601. return function () {
  602. return func.apply(thisArg, arguments);
  603. };
  604. }
  605. module.exports = bindCallback;
  606. }, { "../utility/identity": 42 }], 17: [function (_dereq_, module, exports) {
  607. var bindCallback = _dereq_('./bindCallback'),
  608. isIterateeCall = _dereq_('./isIterateeCall'),
  609. restParam = _dereq_('../function/restParam');
  610. /**
  611. * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
  612. *
  613. * @private
  614. * @param {Function} assigner The function to assign values.
  615. * @returns {Function} Returns the new assigner function.
  616. */
  617. function createAssigner(assigner) {
  618. return restParam(function (object, sources) {
  619. var index = -1,
  620. length = object == null ? 0 : sources.length,
  621. customizer = length > 2 ? sources[length - 2] : undefined,
  622. guard = length > 2 ? sources[2] : undefined,
  623. thisArg = length > 1 ? sources[length - 1] : undefined;
  624. if (typeof customizer == 'function') {
  625. customizer = bindCallback(customizer, thisArg, 5);
  626. length -= 2;
  627. } else {
  628. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  629. length -= (customizer ? 1 : 0);
  630. }
  631. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  632. customizer = length < 3 ? undefined : customizer;
  633. length = 1;
  634. }
  635. while (++index < length) {
  636. var source = sources[index];
  637. if (source) {
  638. assigner(object, source, customizer);
  639. }
  640. }
  641. return object;
  642. });
  643. }
  644. module.exports = createAssigner;
  645. }, { "../function/restParam": 6, "./bindCallback": 16, "./isIterateeCall": 24 }], 18: [function (_dereq_, module, exports) {
  646. var toObject = _dereq_('./toObject');
  647. /**
  648. * Creates a base function for `_.forIn` or `_.forInRight`.
  649. *
  650. * @private
  651. * @param {boolean} [fromRight] Specify iterating from right to left.
  652. * @returns {Function} Returns the new base function.
  653. */
  654. function createBaseFor(fromRight) {
  655. return function (object, iteratee, keysFunc) {
  656. var iterable = toObject(object),
  657. props = keysFunc(object),
  658. length = props.length,
  659. index = fromRight ? length : -1;
  660. while ((fromRight ? index-- : ++index < length)) {
  661. var key = props[index];
  662. if (iteratee(iterable[key], key, iterable) === false) {
  663. break;
  664. }
  665. }
  666. return object;
  667. };
  668. }
  669. module.exports = createBaseFor;
  670. }, { "./toObject": 28 }], 19: [function (_dereq_, module, exports) {
  671. var baseProperty = _dereq_('./baseProperty');
  672. /**
  673. * Gets the "length" property value of `object`.
  674. *
  675. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  676. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  677. *
  678. * @private
  679. * @param {Object} object The object to query.
  680. * @returns {*} Returns the "length" value.
  681. */
  682. var getLength = baseProperty('length');
  683. module.exports = getLength;
  684. }, { "./baseProperty": 15 }], 20: [function (_dereq_, module, exports) {
  685. var isNative = _dereq_('../lang/isNative');
  686. /**
  687. * Gets the native function at `key` of `object`.
  688. *
  689. * @private
  690. * @param {Object} object The object to query.
  691. * @param {string} key The key of the method to get.
  692. * @returns {*} Returns the function if it's native, else `undefined`.
  693. */
  694. function getNative(object, key) {
  695. var value = object == null ? undefined : object[key];
  696. return isNative(value) ? value : undefined;
  697. }
  698. module.exports = getNative;
  699. }, { "../lang/isNative": 32 }], 21: [function (_dereq_, module, exports) {
  700. var getLength = _dereq_('./getLength'),
  701. isLength = _dereq_('./isLength');
  702. /**
  703. * Checks if `value` is array-like.
  704. *
  705. * @private
  706. * @param {*} value The value to check.
  707. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  708. */
  709. function isArrayLike(value) {
  710. return value != null && isLength(getLength(value));
  711. }
  712. module.exports = isArrayLike;
  713. }, { "./getLength": 19, "./isLength": 25 }], 22: [function (_dereq_, module, exports) {
  714. /**
  715. * Checks if `value` is a host object in IE < 9.
  716. *
  717. * @private
  718. * @param {*} value The value to check.
  719. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  720. */
  721. var isHostObject = (function () {
  722. try {
  723. Object({ 'toString': 0 } + '');
  724. } catch (e) {
  725. return function () { return false; };
  726. }
  727. return function (value) {
  728. // IE < 9 presents many host objects as `Object` objects that can coerce
  729. // to strings despite having improperly defined `toString` methods.
  730. return typeof value.toString != 'function' && typeof (value + '') == 'string';
  731. };
  732. }());
  733. module.exports = isHostObject;
  734. }, {}], 23: [function (_dereq_, module, exports) {
  735. /** Used to detect unsigned integer values. */
  736. var reIsUint = /^\d+$/;
  737. /**
  738. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  739. * of an array-like value.
  740. */
  741. var MAX_SAFE_INTEGER = 9007199254740991;
  742. /**
  743. * Checks if `value` is a valid array-like index.
  744. *
  745. * @private
  746. * @param {*} value The value to check.
  747. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  748. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  749. */
  750. function isIndex(value, length) {
  751. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  752. length = length == null ? MAX_SAFE_INTEGER : length;
  753. return value > -1 && value % 1 == 0 && value < length;
  754. }
  755. module.exports = isIndex;
  756. }, {}], 24: [function (_dereq_, module, exports) {
  757. var isArrayLike = _dereq_('./isArrayLike'),
  758. isIndex = _dereq_('./isIndex'),
  759. isObject = _dereq_('../lang/isObject');
  760. /**
  761. * Checks if the provided arguments are from an iteratee call.
  762. *
  763. * @private
  764. * @param {*} value The potential iteratee value argument.
  765. * @param {*} index The potential iteratee index or key argument.
  766. * @param {*} object The potential iteratee object argument.
  767. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  768. */
  769. function isIterateeCall(value, index, object) {
  770. if (!isObject(object)) {
  771. return false;
  772. }
  773. var type = typeof index;
  774. if (type == 'number'
  775. ? (isArrayLike(object) && isIndex(index, object.length))
  776. : (type == 'string' && index in object)) {
  777. var other = object[index];
  778. return value === value ? (value === other) : (other !== other);
  779. }
  780. return false;
  781. }
  782. module.exports = isIterateeCall;
  783. }, { "../lang/isObject": 33, "./isArrayLike": 21, "./isIndex": 23 }], 25: [function (_dereq_, module, exports) {
  784. /**
  785. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  786. * of an array-like value.
  787. */
  788. var MAX_SAFE_INTEGER = 9007199254740991;
  789. /**
  790. * Checks if `value` is a valid array-like length.
  791. *
  792. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  793. *
  794. * @private
  795. * @param {*} value The value to check.
  796. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  797. */
  798. function isLength(value) {
  799. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  800. }
  801. module.exports = isLength;
  802. }, {}], 26: [function (_dereq_, module, exports) {
  803. /**
  804. * Checks if `value` is object-like.
  805. *
  806. * @private
  807. * @param {*} value The value to check.
  808. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  809. */
  810. function isObjectLike(value) {
  811. return !!value && typeof value == 'object';
  812. }
  813. module.exports = isObjectLike;
  814. }, {}], 27: [function (_dereq_, module, exports) {
  815. var isArguments = _dereq_('../lang/isArguments'),
  816. isArray = _dereq_('../lang/isArray'),
  817. isIndex = _dereq_('./isIndex'),
  818. isLength = _dereq_('./isLength'),
  819. isString = _dereq_('../lang/isString'),
  820. keysIn = _dereq_('../object/keysIn');
  821. /** Used for native method references. */
  822. var objectProto = Object.prototype;
  823. /** Used to check objects for own properties. */
  824. var hasOwnProperty = objectProto.hasOwnProperty;
  825. /**
  826. * A fallback implementation of `Object.keys` which creates an array of the
  827. * own enumerable property names of `object`.
  828. *
  829. * @private
  830. * @param {Object} object The object to query.
  831. * @returns {Array} Returns the array of property names.
  832. */
  833. function shimKeys(object) {
  834. var props = keysIn(object),
  835. propsLength = props.length,
  836. length = propsLength && object.length;
  837. var allowIndexes = !!length && isLength(length) &&
  838. (isArray(object) || isArguments(object) || isString(object));
  839. var index = -1,
  840. result = [];
  841. while (++index < propsLength) {
  842. var key = props[index];
  843. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  844. result.push(key);
  845. }
  846. }
  847. return result;
  848. }
  849. module.exports = shimKeys;
  850. }, { "../lang/isArguments": 29, "../lang/isArray": 30, "../lang/isString": 35, "../object/keysIn": 39, "./isIndex": 23, "./isLength": 25 }], 28: [function (_dereq_, module, exports) {
  851. var isObject = _dereq_('../lang/isObject'),
  852. isString = _dereq_('../lang/isString'),
  853. support = _dereq_('../support');
  854. /**
  855. * Converts `value` to an object if it's not one.
  856. *
  857. * @private
  858. * @param {*} value The value to process.
  859. * @returns {Object} Returns the object.
  860. */
  861. function toObject(value) {
  862. if (support.unindexedChars && isString(value)) {
  863. var index = -1,
  864. length = value.length,
  865. result = Object(value);
  866. while (++index < length) {
  867. result[index] = value.charAt(index);
  868. }
  869. return result;
  870. }
  871. return isObject(value) ? value : Object(value);
  872. }
  873. module.exports = toObject;
  874. }, { "../lang/isObject": 33, "../lang/isString": 35, "../support": 41 }], 29: [function (_dereq_, module, exports) {
  875. var isArrayLike = _dereq_('../internal/isArrayLike'),
  876. isObjectLike = _dereq_('../internal/isObjectLike');
  877. /** Used for native method references. */
  878. var objectProto = Object.prototype;
  879. /** Used to check objects for own properties. */
  880. var hasOwnProperty = objectProto.hasOwnProperty;
  881. /** Native method references. */
  882. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  883. /**
  884. * Checks if `value` is classified as an `arguments` object.
  885. *
  886. * @static
  887. * @memberOf _
  888. * @category Lang
  889. * @param {*} value The value to check.
  890. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  891. * @example
  892. *
  893. * _.isArguments(function() { return arguments; }());
  894. * // => true
  895. *
  896. * _.isArguments([1, 2, 3]);
  897. * // => false
  898. */
  899. function isArguments(value) {
  900. return isObjectLike(value) && isArrayLike(value) &&
  901. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  902. }
  903. module.exports = isArguments;
  904. }, { "../internal/isArrayLike": 21, "../internal/isObjectLike": 26 }], 30: [function (_dereq_, module, exports) {
  905. var getNative = _dereq_('../internal/getNative'),
  906. isLength = _dereq_('../internal/isLength'),
  907. isObjectLike = _dereq_('../internal/isObjectLike');
  908. /** `Object#toString` result references. */
  909. var arrayTag = '[object Array]';
  910. /** Used for native method references. */
  911. var objectProto = Object.prototype;
  912. /**
  913. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  914. * of values.
  915. */
  916. var objToString = objectProto.toString;
  917. /* Native method references for those with the same name as other `lodash` methods. */
  918. var nativeIsArray = getNative(Array, 'isArray');
  919. /**
  920. * Checks if `value` is classified as an `Array` object.
  921. *
  922. * @static
  923. * @memberOf _
  924. * @category Lang
  925. * @param {*} value The value to check.
  926. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  927. * @example
  928. *
  929. * _.isArray([1, 2, 3]);
  930. * // => true
  931. *
  932. * _.isArray(function() { return arguments; }());
  933. * // => false
  934. */
  935. var isArray = nativeIsArray || function (value) {
  936. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  937. };
  938. module.exports = isArray;
  939. }, { "../internal/getNative": 20, "../internal/isLength": 25, "../internal/isObjectLike": 26 }], 31: [function (_dereq_, module, exports) {
  940. var isObject = _dereq_('./isObject');
  941. /** `Object#toString` result references. */
  942. var funcTag = '[object Function]';
  943. /** Used for native method references. */
  944. var objectProto = Object.prototype;
  945. /**
  946. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  947. * of values.
  948. */
  949. var objToString = objectProto.toString;
  950. /**
  951. * Checks if `value` is classified as a `Function` object.
  952. *
  953. * @static
  954. * @memberOf _
  955. * @category Lang
  956. * @param {*} value The value to check.
  957. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  958. * @example
  959. *
  960. * _.isFunction(_);
  961. * // => true
  962. *
  963. * _.isFunction(/abc/);
  964. * // => false
  965. */
  966. function isFunction(value) {
  967. // The use of `Object#toString` avoids issues with the `typeof` operator
  968. // in older versions of Chrome and Safari which return 'function' for regexes
  969. // and Safari 8 which returns 'object' for typed array constructors.
  970. return isObject(value) && objToString.call(value) == funcTag;
  971. }
  972. module.exports = isFunction;
  973. }, { "./isObject": 33 }], 32: [function (_dereq_, module, exports) {
  974. var isFunction = _dereq_('./isFunction'),
  975. isHostObject = _dereq_('../internal/isHostObject'),
  976. isObjectLike = _dereq_('../internal/isObjectLike');
  977. /** Used to detect host constructors (Safari > 5). */
  978. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  979. /** Used for native method references. */
  980. var objectProto = Object.prototype;
  981. /** Used to resolve the decompiled source of functions. */
  982. var fnToString = Function.prototype.toString;
  983. /** Used to check objects for own properties. */
  984. var hasOwnProperty = objectProto.hasOwnProperty;
  985. /** Used to detect if a method is native. */
  986. var reIsNative = RegExp('^' +
  987. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  988. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  989. );
  990. /**
  991. * Checks if `value` is a native function.
  992. *
  993. * @static
  994. * @memberOf _
  995. * @category Lang
  996. * @param {*} value The value to check.
  997. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  998. * @example
  999. *
  1000. * _.isNative(Array.prototype.push);
  1001. * // => true
  1002. *
  1003. * _.isNative(_);
  1004. * // => false
  1005. */
  1006. function isNative(value) {
  1007. if (value == null) {
  1008. return false;
  1009. }
  1010. if (isFunction(value)) {
  1011. return reIsNative.test(fnToString.call(value));
  1012. }
  1013. return isObjectLike(value) && (isHostObject(value) ? reIsNative : reIsHostCtor).test(value);
  1014. }
  1015. module.exports = isNative;
  1016. }, { "../internal/isHostObject": 22, "../internal/isObjectLike": 26, "./isFunction": 31 }], 33: [function (_dereq_, module, exports) {
  1017. /**
  1018. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  1019. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1020. *
  1021. * @static
  1022. * @memberOf _
  1023. * @category Lang
  1024. * @param {*} value The value to check.
  1025. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1026. * @example
  1027. *
  1028. * _.isObject({});
  1029. * // => true
  1030. *
  1031. * _.isObject([1, 2, 3]);
  1032. * // => true
  1033. *
  1034. * _.isObject(1);
  1035. * // => false
  1036. */
  1037. function isObject(value) {
  1038. // Avoid a V8 JIT bug in Chrome 19-20.
  1039. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  1040. var type = typeof value;
  1041. return !!value && (type == 'object' || type == 'function');
  1042. }
  1043. module.exports = isObject;
  1044. }, {}], 34: [function (_dereq_, module, exports) {
  1045. var baseForIn = _dereq_('../internal/baseForIn'),
  1046. isArguments = _dereq_('./isArguments'),
  1047. isHostObject = _dereq_('../internal/isHostObject'),
  1048. isObjectLike = _dereq_('../internal/isObjectLike'),
  1049. support = _dereq_('../support');
  1050. /** `Object#toString` result references. */
  1051. var objectTag = '[object Object]';
  1052. /** Used for native method references. */
  1053. var objectProto = Object.prototype;
  1054. /** Used to check objects for own properties. */
  1055. var hasOwnProperty = objectProto.hasOwnProperty;
  1056. /**
  1057. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1058. * of values.
  1059. */
  1060. var objToString = objectProto.toString;
  1061. /**
  1062. * Checks if `value` is a plain object, that is, an object created by the
  1063. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  1064. *
  1065. * **Note:** This method assumes objects created by the `Object` constructor
  1066. * have no inherited enumerable properties.
  1067. *
  1068. * @static
  1069. * @memberOf _
  1070. * @category Lang
  1071. * @param {*} value The value to check.
  1072. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  1073. * @example
  1074. *
  1075. * function Foo() {
  1076. * this.a = 1;
  1077. * }
  1078. *
  1079. * _.isPlainObject(new Foo);
  1080. * // => false
  1081. *
  1082. * _.isPlainObject([1, 2, 3]);
  1083. * // => false
  1084. *
  1085. * _.isPlainObject({ 'x': 0, 'y': 0 });
  1086. * // => true
  1087. *
  1088. * _.isPlainObject(Object.create(null));
  1089. * // => true
  1090. */
  1091. function isPlainObject(value) {
  1092. var Ctor;
  1093. // Exit early for non `Object` objects.
  1094. if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isHostObject(value) && !isArguments(value)) ||
  1095. (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  1096. return false;
  1097. }
  1098. // IE < 9 iterates inherited properties before own properties. If the first
  1099. // iterated property is an object's own property then there are no inherited
  1100. // enumerable properties.
  1101. var result;
  1102. if (support.ownLast) {
  1103. baseForIn(value, function (subValue, key, object) {
  1104. result = hasOwnProperty.call(object, key);
  1105. return false;
  1106. });
  1107. return result !== false;
  1108. }
  1109. // In most environments an object's own properties are iterated before
  1110. // its inherited properties. If the last iterated property is an object's
  1111. // own property then there are no inherited enumerable properties.
  1112. baseForIn(value, function (subValue, key) {
  1113. result = key;
  1114. });
  1115. return result === undefined || hasOwnProperty.call(value, result);
  1116. }
  1117. module.exports = isPlainObject;
  1118. }, { "../internal/baseForIn": 12, "../internal/isHostObject": 22, "../internal/isObjectLike": 26, "../support": 41, "./isArguments": 29 }], 35: [function (_dereq_, module, exports) {
  1119. var isObjectLike = _dereq_('../internal/isObjectLike');
  1120. /** `Object#toString` result references. */
  1121. var stringTag = '[object String]';
  1122. /** Used for native method references. */
  1123. var objectProto = Object.prototype;
  1124. /**
  1125. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1126. * of values.
  1127. */
  1128. var objToString = objectProto.toString;
  1129. /**
  1130. * Checks if `value` is classified as a `String` primitive or object.
  1131. *
  1132. * @static
  1133. * @memberOf _
  1134. * @category Lang
  1135. * @param {*} value The value to check.
  1136. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1137. * @example
  1138. *
  1139. * _.isString('abc');
  1140. * // => true
  1141. *
  1142. * _.isString(1);
  1143. * // => false
  1144. */
  1145. function isString(value) {
  1146. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  1147. }
  1148. module.exports = isString;
  1149. }, { "../internal/isObjectLike": 26 }], 36: [function (_dereq_, module, exports) {
  1150. var isLength = _dereq_('../internal/isLength'),
  1151. isObjectLike = _dereq_('../internal/isObjectLike');
  1152. /** `Object#toString` result references. */
  1153. var argsTag = '[object Arguments]',
  1154. arrayTag = '[object Array]',
  1155. boolTag = '[object Boolean]',
  1156. dateTag = '[object Date]',
  1157. errorTag = '[object Error]',
  1158. funcTag = '[object Function]',
  1159. mapTag = '[object Map]',
  1160. numberTag = '[object Number]',
  1161. objectTag = '[object Object]',
  1162. regexpTag = '[object RegExp]',
  1163. setTag = '[object Set]',
  1164. stringTag = '[object String]',
  1165. weakMapTag = '[object WeakMap]';
  1166. var arrayBufferTag = '[object ArrayBuffer]',
  1167. float32Tag = '[object Float32Array]',
  1168. float64Tag = '[object Float64Array]',
  1169. int8Tag = '[object Int8Array]',
  1170. int16Tag = '[object Int16Array]',
  1171. int32Tag = '[object Int32Array]',
  1172. uint8Tag = '[object Uint8Array]',
  1173. uint8ClampedTag = '[object Uint8ClampedArray]',
  1174. uint16Tag = '[object Uint16Array]',
  1175. uint32Tag = '[object Uint32Array]';
  1176. /** Used to identify `toStringTag` values of typed arrays. */
  1177. var typedArrayTags = {};
  1178. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1179. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1180. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1181. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1182. typedArrayTags[uint32Tag] = true;
  1183. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1184. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1185. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  1186. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  1187. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  1188. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  1189. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  1190. /** Used for native method references. */
  1191. var objectProto = Object.prototype;
  1192. /**
  1193. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1194. * of values.
  1195. */
  1196. var objToString = objectProto.toString;
  1197. /**
  1198. * Checks if `value` is classified as a typed array.
  1199. *
  1200. * @static
  1201. * @memberOf _
  1202. * @category Lang
  1203. * @param {*} value The value to check.
  1204. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1205. * @example
  1206. *
  1207. * _.isTypedArray(new Uint8Array);
  1208. * // => true
  1209. *
  1210. * _.isTypedArray([]);
  1211. * // => false
  1212. */
  1213. function isTypedArray(value) {
  1214. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  1215. }
  1216. module.exports = isTypedArray;
  1217. }, { "../internal/isLength": 25, "../internal/isObjectLike": 26 }], 37: [function (_dereq_, module, exports) {
  1218. var baseCopy = _dereq_('../internal/baseCopy'),
  1219. keysIn = _dereq_('../object/keysIn');
  1220. /**
  1221. * Converts `value` to a plain object flattening inherited enumerable
  1222. * properties of `value` to own properties of the plain object.
  1223. *
  1224. * @static
  1225. * @memberOf _
  1226. * @category Lang
  1227. * @param {*} value The value to convert.
  1228. * @returns {Object} Returns the converted plain object.
  1229. * @example
  1230. *
  1231. * function Foo() {
  1232. * this.b = 2;
  1233. * }
  1234. *
  1235. * Foo.prototype.c = 3;
  1236. *
  1237. * _.assign({ 'a': 1 }, new Foo);
  1238. * // => { 'a': 1, 'b': 2 }
  1239. *
  1240. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  1241. * // => { 'a': 1, 'b': 2, 'c': 3 }
  1242. */
  1243. function toPlainObject(value) {
  1244. return baseCopy(value, keysIn(value));
  1245. }
  1246. module.exports = toPlainObject;
  1247. }, { "../internal/baseCopy": 10, "../object/keysIn": 39 }], 38: [function (_dereq_, module, exports) {
  1248. var getNative = _dereq_('../internal/getNative'),
  1249. isArrayLike = _dereq_('../internal/isArrayLike'),
  1250. isObject = _dereq_('../lang/isObject'),
  1251. shimKeys = _dereq_('../internal/shimKeys'),
  1252. support = _dereq_('../support');
  1253. /* Native method references for those with the same name as other `lodash` methods. */
  1254. var nativeKeys = getNative(Object, 'keys');
  1255. /**
  1256. * Creates an array of the own enumerable property names of `object`.
  1257. *
  1258. * **Note:** Non-object values are coerced to objects. See the
  1259. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  1260. * for more details.
  1261. *
  1262. * @static
  1263. * @memberOf _
  1264. * @category Object
  1265. * @param {Object} object The object to query.
  1266. * @returns {Array} Returns the array of property names.
  1267. * @example
  1268. *
  1269. * function Foo() {
  1270. * this.a = 1;
  1271. * this.b = 2;
  1272. * }
  1273. *
  1274. * Foo.prototype.c = 3;
  1275. *
  1276. * _.keys(new Foo);
  1277. * // => ['a', 'b'] (iteration order is not guaranteed)
  1278. *
  1279. * _.keys('hi');
  1280. * // => ['0', '1']
  1281. */
  1282. var keys = !nativeKeys ? shimKeys : function (object) {
  1283. var Ctor = object == null ? undefined : object.constructor;
  1284. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  1285. (typeof object == 'function' ? support.enumPrototypes : isArrayLike(object))) {
  1286. return shimKeys(object);
  1287. }
  1288. return isObject(object) ? nativeKeys(object) : [];
  1289. };
  1290. module.exports = keys;
  1291. }, { "../internal/getNative": 20, "../internal/isArrayLike": 21, "../internal/shimKeys": 27, "../lang/isObject": 33, "../support": 41 }], 39: [function (_dereq_, module, exports) {
  1292. var arrayEach = _dereq_('../internal/arrayEach'),
  1293. isArguments = _dereq_('../lang/isArguments'),
  1294. isArray = _dereq_('../lang/isArray'),
  1295. isFunction = _dereq_('../lang/isFunction'),
  1296. isIndex = _dereq_('../internal/isIndex'),
  1297. isLength = _dereq_('../internal/isLength'),
  1298. isObject = _dereq_('../lang/isObject'),
  1299. isString = _dereq_('../lang/isString'),
  1300. support = _dereq_('../support');
  1301. /** `Object#toString` result references. */
  1302. var arrayTag = '[object Array]',
  1303. boolTag = '[object Boolean]',
  1304. dateTag = '[object Date]',
  1305. errorTag = '[object Error]',
  1306. funcTag = '[object Function]',
  1307. numberTag = '[object Number]',
  1308. objectTag = '[object Object]',
  1309. regexpTag = '[object RegExp]',
  1310. stringTag = '[object String]';
  1311. /** Used to fix the JScript `[[DontEnum]]` bug. */
  1312. var shadowProps = [
  1313. 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',
  1314. 'toLocaleString', 'toString', 'valueOf'
  1315. ];
  1316. /** Used for native method references. */
  1317. var errorProto = Error.prototype,
  1318. objectProto = Object.prototype,
  1319. stringProto = String.prototype;
  1320. /** Used to check objects for own properties. */
  1321. var hasOwnProperty = objectProto.hasOwnProperty;
  1322. /**
  1323. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1324. * of values.
  1325. */
  1326. var objToString = objectProto.toString;
  1327. /** Used to avoid iterating over non-enumerable properties in IE < 9. */
  1328. var nonEnumProps = {};
  1329. nonEnumProps[arrayTag] = nonEnumProps[dateTag] = nonEnumProps[numberTag] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true };
  1330. nonEnumProps[boolTag] = nonEnumProps[stringTag] = { 'constructor': true, 'toString': true, 'valueOf': true };
  1331. nonEnumProps[errorTag] = nonEnumProps[funcTag] = nonEnumProps[regexpTag] = { 'constructor': true, 'toString': true };
  1332. nonEnumProps[objectTag] = { 'constructor': true };
  1333. arrayEach(shadowProps, function (key) {
  1334. for (var tag in nonEnumProps) {
  1335. if (hasOwnProperty.call(nonEnumProps, tag)) {
  1336. var props = nonEnumProps[tag];
  1337. props[key] = hasOwnProperty.call(props, key);
  1338. }
  1339. }
  1340. });
  1341. /**
  1342. * Creates an array of the own and inherited enumerable property names of `object`.
  1343. *
  1344. * **Note:** Non-object values are coerced to objects.
  1345. *
  1346. * @static
  1347. * @memberOf _
  1348. * @category Object
  1349. * @param {Object} object The object to query.
  1350. * @returns {Array} Returns the array of property names.
  1351. * @example
  1352. *
  1353. * function Foo() {
  1354. * this.a = 1;
  1355. * this.b = 2;
  1356. * }
  1357. *
  1358. * Foo.prototype.c = 3;
  1359. *
  1360. * _.keysIn(new Foo);
  1361. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  1362. */
  1363. function keysIn(object) {
  1364. if (object == null) {
  1365. return [];
  1366. }
  1367. if (!isObject(object)) {
  1368. object = Object(object);
  1369. }
  1370. var length = object.length;
  1371. length = (length && isLength(length) &&
  1372. (isArray(object) || isArguments(object) || isString(object)) && length) || 0;
  1373. var Ctor = object.constructor,
  1374. index = -1,
  1375. proto = (isFunction(Ctor) && Ctor.prototype) || objectProto,
  1376. isProto = proto === object,
  1377. result = Array(length),
  1378. skipIndexes = length > 0,
  1379. skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error),
  1380. skipProto = support.enumPrototypes && isFunction(object);
  1381. while (++index < length) {
  1382. result[index] = (index + '');
  1383. }
  1384. // lodash skips the `constructor` property when it infers it's iterating
  1385. // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]`
  1386. // attribute of an existing property and the `constructor` property of a
  1387. // prototype defaults to non-enumerable.
  1388. for (var key in object) {
  1389. if (!(skipProto && key == 'prototype') &&
  1390. !(skipErrorProps && (key == 'message' || key == 'name')) &&
  1391. !(skipIndexes && isIndex(key, length)) &&
  1392. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  1393. result.push(key);
  1394. }
  1395. }
  1396. if (support.nonEnumShadows && object !== objectProto) {
  1397. var tag = object === stringProto ? stringTag : (object === errorProto ? errorTag : objToString.call(object)),
  1398. nonEnums = nonEnumProps[tag] || nonEnumProps[objectTag];
  1399. if (tag == objectTag) {
  1400. proto = objectProto;
  1401. }
  1402. length = shadowProps.length;
  1403. while (length--) {
  1404. key = shadowProps[length];
  1405. var nonEnum = nonEnums[key];
  1406. if (!(isProto && nonEnum) &&
  1407. (nonEnum ? hasOwnProperty.call(object, key) : object[key] !== proto[key])) {
  1408. result.push(key);
  1409. }
  1410. }
  1411. }
  1412. return result;
  1413. }
  1414. module.exports = keysIn;
  1415. }, { "../internal/arrayEach": 9, "../internal/isIndex": 23, "../internal/isLength": 25, "../lang/isArguments": 29, "../lang/isArray": 30, "../lang/isFunction": 31, "../lang/isObject": 33, "../lang/isString": 35, "../support": 41 }], 40: [function (_dereq_, module, exports) {
  1416. var baseMerge = _dereq_('../internal/baseMerge'),
  1417. createAssigner = _dereq_('../internal/createAssigner');
  1418. /**
  1419. * Recursively merges own enumerable properties of the source object(s), that
  1420. * don't resolve to `undefined` into the destination object. Subsequent sources
  1421. * overwrite property assignments of previous sources. If `customizer` is
  1422. * provided it's invoked to produce the merged values of the destination and
  1423. * source properties. If `customizer` returns `undefined` merging is handled
  1424. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  1425. * with five arguments: (objectValue, sourceValue, key, object, source).
  1426. *
  1427. * @static
  1428. * @memberOf _
  1429. * @category Object
  1430. * @param {Object} object The destination object.
  1431. * @param {...Object} [sources] The source objects.
  1432. * @param {Function} [customizer] The function to customize assigned values.
  1433. * @param {*} [thisArg] The `this` binding of `customizer`.
  1434. * @returns {Object} Returns `object`.
  1435. * @example
  1436. *
  1437. * var users = {
  1438. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  1439. * };
  1440. *
  1441. * var ages = {
  1442. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  1443. * };
  1444. *
  1445. * _.merge(users, ages);
  1446. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  1447. *
  1448. * // using a customizer callback
  1449. * var object = {
  1450. * 'fruits': ['apple'],
  1451. * 'vegetables': ['beet']
  1452. * };
  1453. *
  1454. * var other = {
  1455. * 'fruits': ['banana'],
  1456. * 'vegetables': ['carrot']
  1457. * };
  1458. *
  1459. * _.merge(object, other, function(a, b) {
  1460. * if (_.isArray(a)) {
  1461. * return a.concat(b);
  1462. * }
  1463. * });
  1464. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  1465. */
  1466. var merge = createAssigner(baseMerge);
  1467. module.exports = merge;
  1468. }, { "../internal/baseMerge": 13, "../internal/createAssigner": 17 }], 41: [function (_dereq_, module, exports) {
  1469. /** Used for native method references. */
  1470. var arrayProto = Array.prototype,
  1471. errorProto = Error.prototype,
  1472. objectProto = Object.prototype;
  1473. /** Native method references. */
  1474. var propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1475. splice = arrayProto.splice;
  1476. /**
  1477. * An object environment feature flags.
  1478. *
  1479. * @static
  1480. * @memberOf _
  1481. * @type Object
  1482. */
  1483. var support = {};
  1484. (function (x) {
  1485. var Ctor = function () { this.x = x; },
  1486. object = { '0': x, 'length': x },
  1487. props = [];
  1488. Ctor.prototype = { 'valueOf': x, 'y': x };
  1489. for (var key in new Ctor) { props.push(key); }
  1490. /**
  1491. * Detect if `name` or `message` properties of `Error.prototype` are
  1492. * enumerable by default (IE < 9, Safari < 5.1).
  1493. *
  1494. * @memberOf _.support
  1495. * @type boolean
  1496. */
  1497. support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') ||
  1498. propertyIsEnumerable.call(errorProto, 'name');
  1499. /**
  1500. * Detect if `prototype` properties are enumerable by default.
  1501. *
  1502. * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
  1503. * (if the prototype or a property on the prototype has been set)
  1504. * incorrectly set the `[[Enumerable]]` value of a function's `prototype`
  1505. * property to `true`.
  1506. *
  1507. * @memberOf _.support
  1508. * @type boolean
  1509. */
  1510. support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype');
  1511. /**
  1512. * Detect if properties shadowing those on `Object.prototype` are non-enumerable.
  1513. *
  1514. * In IE < 9 an object's own properties, shadowing non-enumerable ones,
  1515. * are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug).
  1516. *
  1517. * @memberOf _.support
  1518. * @type boolean
  1519. */
  1520. support.nonEnumShadows = !/valueOf/.test(props);
  1521. /**
  1522. * Detect if own properties are iterated after inherited properties (IE < 9).
  1523. *
  1524. * @memberOf _.support
  1525. * @type boolean
  1526. */
  1527. support.ownLast = props[0] != 'x';
  1528. /**
  1529. * Detect if `Array#shift` and `Array#splice` augment array-like objects
  1530. * correctly.
  1531. *
  1532. * Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array
  1533. * `shift()` and `splice()` functions that fail to remove the last element,
  1534. * `value[0]`, of array-like objects even though the "length" property is
  1535. * set to `0`. The `shift()` method is buggy in compatibility modes of IE 8,
  1536. * while `splice()` is buggy regardless of mode in IE < 9.
  1537. *
  1538. * @memberOf _.support
  1539. * @type boolean
  1540. */
  1541. support.spliceObjects = (splice.call(object, 0, 1), !object[0]);
  1542. /**
  1543. * Detect lack of support for accessing string characters by index.
  1544. *
  1545. * IE < 8 can't access characters by index. IE 8 can only access characters
  1546. * by index on string literals, not string objects.
  1547. *
  1548. * @memberOf _.support
  1549. * @type boolean
  1550. */
  1551. support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx';
  1552. }(1, 0));
  1553. module.exports = support;
  1554. }, {}], 42: [function (_dereq_, module, exports) {
  1555. /**
  1556. * This method returns the first argument provided to it.
  1557. *
  1558. * @static
  1559. * @memberOf _
  1560. * @category Utility
  1561. * @param {*} value Any value.
  1562. * @returns {*} Returns `value`.
  1563. * @example
  1564. *
  1565. * var object = { 'user': 'fred' };
  1566. *
  1567. * _.identity(object) === object;
  1568. * // => true
  1569. */
  1570. function identity(value) {
  1571. return value;
  1572. }
  1573. module.exports = identity;
  1574. }, {}], 43: [function (_dereq_, module, exports) {
  1575. 'use strict';
  1576. var keys = _dereq_('object-keys');
  1577. module.exports = function hasSymbols() {
  1578. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
  1579. if (typeof Symbol.iterator === 'symbol') { return true; }
  1580. var obj = {};
  1581. var sym = Symbol('test');
  1582. if (typeof sym === 'string') { return false; }
  1583. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  1584. // if (sym instanceof Symbol) { return false; }
  1585. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  1586. // if (!(Object(sym) instanceof Symbol)) { return false; }
  1587. var symVal = 42;
  1588. obj[sym] = symVal;
  1589. for (sym in obj) { return false; }
  1590. if (keys(obj).length !== 0) { return false; }
  1591. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
  1592. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
  1593. var syms = Object.getOwnPropertySymbols(obj);
  1594. if (syms.length !== 1 || syms[0] !== sym) { return false; }
  1595. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
  1596. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  1597. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  1598. if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
  1599. }
  1600. return true;
  1601. };
  1602. }, { "object-keys": 50 }], 44: [function (_dereq_, module, exports) {
  1603. 'use strict';
  1604. // modified from https://github.com/es-shims/es6-shim
  1605. var keys = _dereq_('object-keys');
  1606. var bind = _dereq_('function-bind');
  1607. var canBeObject = function (obj) {
  1608. return typeof obj !== 'undefined' && obj !== null;
  1609. };
  1610. var hasSymbols = _dereq_('./hasSymbols')();
  1611. var toObject = Object;
  1612. var push = bind.call(Function.call, Array.prototype.push);
  1613. var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
  1614. module.exports = function assign(target, source1) {
  1615. if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
  1616. var objTarget = toObject(target);
  1617. var s, source, i, props, syms, value, key;
  1618. for (s = 1; s < arguments.length; ++s) {
  1619. source = toObject(arguments[s]);
  1620. props = keys(source);
  1621. if (hasSymbols && Object.getOwnPropertySymbols) {
  1622. syms = Object.getOwnPropertySymbols(source);
  1623. for (i = 0; i < syms.length; ++i) {
  1624. key = syms[i];
  1625. if (propIsEnumerable(source, key)) {
  1626. push(props, key);
  1627. }
  1628. }
  1629. }
  1630. for (i = 0; i < props.length; ++i) {
  1631. key = props[i];
  1632. value = source[key];
  1633. if (propIsEnumerable(source, key)) {
  1634. objTarget[key] = value;
  1635. }
  1636. }
  1637. }
  1638. return objTarget;
  1639. };
  1640. }, { "./hasSymbols": 43, "function-bind": 49, "object-keys": 50 }], 45: [function (_dereq_, module, exports) {
  1641. 'use strict';
  1642. var defineProperties = _dereq_('define-properties');
  1643. var implementation = _dereq_('./implementation');
  1644. var getPolyfill = _dereq_('./polyfill');
  1645. var shim = _dereq_('./shim');
  1646. defineProperties(implementation, {
  1647. implementation: implementation,
  1648. getPolyfill: getPolyfill,
  1649. shim: shim
  1650. });
  1651. module.exports = implementation;
  1652. }, { "./implementation": 44, "./polyfill": 52, "./shim": 53, "define-properties": 46 }], 46: [function (_dereq_, module, exports) {
  1653. 'use strict';
  1654. var keys = _dereq_('object-keys');
  1655. var foreach = _dereq_('foreach');
  1656. var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
  1657. var toStr = Object.prototype.toString;
  1658. var isFunction = function (fn) {
  1659. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  1660. };
  1661. var arePropertyDescriptorsSupported = function () {
  1662. var obj = {};
  1663. try {
  1664. Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
  1665. /* eslint-disable no-unused-vars, no-restricted-syntax */
  1666. for (var _ in obj) { return false; }
  1667. /* eslint-enable no-unused-vars, no-restricted-syntax */
  1668. return obj.x === obj;
  1669. } catch (e) { /* this is IE 8. */
  1670. return false;
  1671. }
  1672. };
  1673. var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
  1674. var defineProperty = function (object, name, value, predicate) {
  1675. if (name in object && (!isFunction(predicate) || !predicate())) {
  1676. return;
  1677. }
  1678. if (supportsDescriptors) {
  1679. Object.defineProperty(object, name, {
  1680. configurable: true,
  1681. enumerable: false,
  1682. value: value,
  1683. writable: true
  1684. });
  1685. } else {
  1686. object[name] = value;
  1687. }
  1688. };
  1689. var defineProperties = function (object, map) {
  1690. var predicates = arguments.length > 2 ? arguments[2] : {};
  1691. var props = keys(map);
  1692. if (hasSymbols) {
  1693. props = props.concat(Object.getOwnPropertySymbols(map));
  1694. }
  1695. foreach(props, function (name) {
  1696. defineProperty(object, name, map[name], predicates[name]);
  1697. });
  1698. };
  1699. defineProperties.supportsDescriptors = !!supportsDescriptors;
  1700. module.exports = defineProperties;
  1701. }, { "foreach": 47, "object-keys": 50 }], 47: [function (_dereq_, module, exports) {
  1702. var hasOwn = Object.prototype.hasOwnProperty;
  1703. var toString = Object.prototype.toString;
  1704. module.exports = function forEach(obj, fn, ctx) {
  1705. if (toString.call(fn) !== '[object Function]') {
  1706. throw new TypeError('iterator must be a function');
  1707. }
  1708. var l = obj.length;
  1709. if (l === +l) {
  1710. for (var i = 0; i < l; i++) {
  1711. fn.call(ctx, obj[i], i, obj);
  1712. }
  1713. } else {
  1714. for (var k in obj) {
  1715. if (hasOwn.call(obj, k)) {
  1716. fn.call(ctx, obj[k], k, obj);
  1717. }
  1718. }
  1719. }
  1720. };
  1721. }, {}], 48: [function (_dereq_, module, exports) {
  1722. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  1723. var slice = Array.prototype.slice;
  1724. var toStr = Object.prototype.toString;
  1725. var funcType = '[object Function]';
  1726. module.exports = function bind(that) {
  1727. var target = this;
  1728. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  1729. throw new TypeError(ERROR_MESSAGE + target);
  1730. }
  1731. var args = slice.call(arguments, 1);
  1732. var bound;
  1733. var binder = function () {
  1734. if (this instanceof bound) {
  1735. var result = target.apply(
  1736. this,
  1737. args.concat(slice.call(arguments))
  1738. );
  1739. if (Object(result) === result) {
  1740. return result;
  1741. }
  1742. return this;
  1743. } else {
  1744. return target.apply(
  1745. that,
  1746. args.concat(slice.call(arguments))
  1747. );
  1748. }
  1749. };
  1750. var boundLength = Math.max(0, target.length - args.length);
  1751. var boundArgs = [];
  1752. for (var i = 0; i < boundLength; i++) {
  1753. boundArgs.push('$' + i);
  1754. }
  1755. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  1756. if (target.prototype) {
  1757. var Empty = function Empty() { };
  1758. Empty.prototype = target.prototype;
  1759. bound.prototype = new Empty();
  1760. Empty.prototype = null;
  1761. }
  1762. return bound;
  1763. };
  1764. }, {}], 49: [function (_dereq_, module, exports) {
  1765. var implementation = _dereq_('./implementation');
  1766. module.exports = Function.prototype.bind || implementation;
  1767. }, { "./implementation": 48 }], 50: [function (_dereq_, module, exports) {
  1768. 'use strict';
  1769. // modified from https://github.com/es-shims/es5-shim
  1770. var has = Object.prototype.hasOwnProperty;
  1771. var toStr = Object.prototype.toString;
  1772. var slice = Array.prototype.slice;
  1773. var isArgs = _dereq_('./isArguments');
  1774. var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
  1775. var hasProtoEnumBug = function () { }.propertyIsEnumerable('prototype');
  1776. var dontEnums = [
  1777. 'toString',
  1778. 'toLocaleString',
  1779. 'valueOf',
  1780. 'hasOwnProperty',
  1781. 'isPrototypeOf',
  1782. 'propertyIsEnumerable',
  1783. 'constructor'
  1784. ];
  1785. var equalsConstructorPrototype = function (o) {
  1786. var ctor = o.constructor;
  1787. return ctor && ctor.prototype === o;
  1788. };
  1789. var blacklistedKeys = {
  1790. $console: true,
  1791. $frame: true,
  1792. $frameElement: true,
  1793. $frames: true,
  1794. $parent: true,
  1795. $self: true,
  1796. $webkitIndexedDB: true,
  1797. $webkitStorageInfo: true,
  1798. $window: true
  1799. };
  1800. var hasAutomationEqualityBug = (function () {
  1801. /* global window */
  1802. if (typeof window === 'undefined') { return false; }
  1803. for (var k in window) {
  1804. try {
  1805. if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  1806. try {
  1807. equalsConstructorPrototype(window[k]);
  1808. } catch (e) {
  1809. return true;
  1810. }
  1811. }
  1812. } catch (e) {
  1813. return true;
  1814. }
  1815. }
  1816. return false;
  1817. }());
  1818. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  1819. /* global window */
  1820. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  1821. return equalsConstructorPrototype(o);
  1822. }
  1823. try {
  1824. return equalsConstructorPrototype(o);
  1825. } catch (e) {
  1826. return false;
  1827. }
  1828. };
  1829. var keysShim = function keys(object) {
  1830. var isObject = object !== null && typeof object === 'object';
  1831. var isFunction = toStr.call(object) === '[object Function]';
  1832. var isArguments = isArgs(object);
  1833. var isString = isObject && toStr.call(object) === '[object String]';
  1834. var theKeys = [];
  1835. if (!isObject && !isFunction && !isArguments) {
  1836. throw new TypeError('Object.keys called on a non-object');
  1837. }
  1838. var skipProto = hasProtoEnumBug && isFunction;
  1839. if (isString && object.length > 0 && !has.call(object, 0)) {
  1840. for (var i = 0; i < object.length; ++i) {
  1841. theKeys.push(String(i));
  1842. }
  1843. }
  1844. if (isArguments && object.length > 0) {
  1845. for (var j = 0; j < object.length; ++j) {
  1846. theKeys.push(String(j));
  1847. }
  1848. } else {
  1849. for (var name in object) {
  1850. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  1851. theKeys.push(String(name));
  1852. }
  1853. }
  1854. }
  1855. if (hasDontEnumBug) {
  1856. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  1857. for (var k = 0; k < dontEnums.length; ++k) {
  1858. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  1859. theKeys.push(dontEnums[k]);
  1860. }
  1861. }
  1862. }
  1863. return theKeys;
  1864. };
  1865. keysShim.shim = function shimObjectKeys() {
  1866. if (Object.keys) {
  1867. var keysWorksWithArguments = (function () {
  1868. // Safari 5.0 bug
  1869. return (Object.keys(arguments) || '').length === 2;
  1870. }(1, 2));
  1871. if (!keysWorksWithArguments) {
  1872. var originalKeys = Object.keys;
  1873. Object.keys = function keys(object) {
  1874. if (isArgs(object)) {
  1875. return originalKeys(slice.call(object));
  1876. } else {
  1877. return originalKeys(object);
  1878. }
  1879. };
  1880. }
  1881. } else {
  1882. Object.keys = keysShim;
  1883. }
  1884. return Object.keys || keysShim;
  1885. };
  1886. module.exports = keysShim;
  1887. }, { "./isArguments": 51 }], 51: [function (_dereq_, module, exports) {
  1888. 'use strict';
  1889. var toStr = Object.prototype.toString;
  1890. module.exports = function isArguments(value) {
  1891. var str = toStr.call(value);
  1892. var isArgs = str === '[object Arguments]';
  1893. if (!isArgs) {
  1894. isArgs = str !== '[object Array]' &&
  1895. value !== null &&
  1896. typeof value === 'object' &&
  1897. typeof value.length === 'number' &&
  1898. value.length >= 0 &&
  1899. toStr.call(value.callee) === '[object Function]';
  1900. }
  1901. return isArgs;
  1902. };
  1903. }, {}], 52: [function (_dereq_, module, exports) {
  1904. 'use strict';
  1905. var implementation = _dereq_('./implementation');
  1906. var lacksProperEnumerationOrder = function () {
  1907. if (!Object.assign) {
  1908. return false;
  1909. }
  1910. // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
  1911. // note: this does not detect the bug unless there's 20 characters
  1912. var str = 'abcdefghijklmnopqrst';
  1913. var letters = str.split('');
  1914. var map = {};
  1915. for (var i = 0; i < letters.length; ++i) {
  1916. map[letters[i]] = letters[i];
  1917. }
  1918. var obj = Object.assign({}, map);
  1919. var actual = '';
  1920. for (var k in obj) {
  1921. actual += k;
  1922. }
  1923. return str !== actual;
  1924. };
  1925. var assignHasPendingExceptions = function () {
  1926. if (!Object.assign || !Object.preventExtensions) {
  1927. return false;
  1928. }
  1929. // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
  1930. // which is 72% slower than our shim, and Firefox 40's native implementation.
  1931. var thrower = Object.preventExtensions({ 1: 2 });
  1932. try {
  1933. Object.assign(thrower, 'xy');
  1934. } catch (e) {
  1935. return thrower[1] === 'y';
  1936. }
  1937. };
  1938. module.exports = function getPolyfill() {
  1939. if (!Object.assign) {
  1940. return implementation;
  1941. }
  1942. if (lacksProperEnumerationOrder()) {
  1943. return implementation;
  1944. }
  1945. if (assignHasPendingExceptions()) {
  1946. return implementation;
  1947. }
  1948. return Object.assign;
  1949. };
  1950. }, { "./implementation": 44 }], 53: [function (_dereq_, module, exports) {
  1951. 'use strict';
  1952. var define = _dereq_('define-properties');
  1953. var getPolyfill = _dereq_('./polyfill');
  1954. module.exports = function shimAssign() {
  1955. var polyfill = getPolyfill();
  1956. define(
  1957. Object,
  1958. { assign: polyfill },
  1959. { assign: function () { return Object.assign !== polyfill; } }
  1960. );
  1961. return polyfill;
  1962. };
  1963. }, { "./polyfill": 52, "define-properties": 46 }], 54: [function (_dereq_, module, exports) {
  1964. module.exports = SafeParseTuple
  1965. function SafeParseTuple(obj, reviver) {
  1966. var json
  1967. var error = null
  1968. try {
  1969. json = JSON.parse(obj, reviver)
  1970. } catch (err) {
  1971. error = err
  1972. }
  1973. return [error, json]
  1974. }
  1975. }, {}], 55: [function (_dereq_, module, exports) {
  1976. function clean(s) {
  1977. return s.replace(/\n\r?\s*/g, '')
  1978. }
  1979. module.exports = function tsml(sa) {
  1980. var s = ''
  1981. , i = 0
  1982. for (; i < arguments.length; i++)
  1983. s += clean(sa[i]) + (arguments[i + 1] || '')
  1984. return s
  1985. }
  1986. }, {}], 56: [function (_dereq_, module, exports) {
  1987. "use strict";
  1988. var window = _dereq_("global/window")
  1989. var once = _dereq_("once")
  1990. var isFunction = _dereq_("is-function")
  1991. var parseHeaders = _dereq_("parse-headers")
  1992. var xtend = _dereq_("xtend")
  1993. module.exports = createXHR
  1994. createXHR.XMLHttpRequest = window.XMLHttpRequest || noop
  1995. createXHR.XDomainRequest = "withCredentials" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest
  1996. forEachArray(["get", "put", "post", "patch", "head", "delete"], function (method) {
  1997. createXHR[method === "delete" ? "del" : method] = function (uri, options, callback) {
  1998. options = initParams(uri, options, callback)
  1999. options.method = method.toUpperCase()
  2000. return _createXHR(options)
  2001. }
  2002. })
  2003. function forEachArray(array, iterator) {
  2004. for (var i = 0; i < array.length; i++) {
  2005. iterator(array[i])
  2006. }
  2007. }
  2008. function isEmpty(obj) {
  2009. for (var i in obj) {
  2010. if (obj.hasOwnProperty(i)) return false
  2011. }
  2012. return true
  2013. }
  2014. function initParams(uri, options, callback) {
  2015. var params = uri
  2016. if (isFunction(options)) {
  2017. callback = options
  2018. if (typeof uri === "string") {
  2019. params = { uri: uri }
  2020. }
  2021. } else {
  2022. params = xtend(options, { uri: uri })
  2023. }
  2024. params.callback = callback
  2025. return params
  2026. }
  2027. function createXHR(uri, options, callback) {
  2028. options = initParams(uri, options, callback)
  2029. return _createXHR(options)
  2030. }
  2031. function _createXHR(options) {
  2032. var callback = options.callback
  2033. if (typeof callback === "undefined") {
  2034. throw new Error("callback argument missing")
  2035. }
  2036. callback = once(callback)
  2037. function readystatechange() {
  2038. if (xhr.readyState === 4) {
  2039. loadFunc()
  2040. }
  2041. }
  2042. function getBody() {
  2043. // Chrome with requestType=blob throws errors arround when even testing access to responseText
  2044. var body = undefined
  2045. if (xhr.response) {
  2046. body = xhr.response
  2047. } else if (xhr.responseType === "text" || !xhr.responseType) {
  2048. body = xhr.responseText || xhr.responseXML
  2049. }
  2050. if (isJson) {
  2051. try {
  2052. body = JSON.parse(body)
  2053. } catch (e) { }
  2054. }
  2055. return body
  2056. }
  2057. var failureResponse = {
  2058. body: undefined,
  2059. headers: {},
  2060. statusCode: 0,
  2061. method: method,
  2062. url: uri,
  2063. rawRequest: xhr
  2064. }
  2065. function errorFunc(evt) {
  2066. clearTimeout(timeoutTimer)
  2067. if (!(evt instanceof Error)) {
  2068. evt = new Error("" + (evt || "Unknown XMLHttpRequest Error"))
  2069. }
  2070. evt.statusCode = 0
  2071. callback(evt, failureResponse)
  2072. }
  2073. // will load the data & process the response in a special response object
  2074. function loadFunc() {
  2075. if (aborted) return
  2076. var status
  2077. clearTimeout(timeoutTimer)
  2078. if (options.useXDR && xhr.status === undefined) {
  2079. //IE8 CORS GET successful response doesn't have a status field, but body is fine
  2080. status = 200
  2081. } else {
  2082. status = (xhr.status === 1223 ? 204 : xhr.status)
  2083. }
  2084. var response = failureResponse
  2085. var err = null
  2086. if (status !== 0) {
  2087. response = {
  2088. body: getBody(),
  2089. statusCode: status,
  2090. method: method,
  2091. headers: {},
  2092. url: uri,
  2093. rawRequest: xhr
  2094. }
  2095. if (xhr.getAllResponseHeaders) { //remember xhr can in fact be XDR for CORS in IE
  2096. response.headers = parseHeaders(xhr.getAllResponseHeaders())
  2097. }
  2098. } else {
  2099. err = new Error("Internal XMLHttpRequest Error")
  2100. }
  2101. callback(err, response, response.body)
  2102. }
  2103. var xhr = options.xhr || null
  2104. if (!xhr) {
  2105. if (options.cors || options.useXDR) {
  2106. xhr = new createXHR.XDomainRequest()
  2107. } else {
  2108. xhr = new createXHR.XMLHttpRequest()
  2109. }
  2110. }
  2111. var key
  2112. var aborted
  2113. var uri = xhr.url = options.uri || options.url
  2114. var method = xhr.method = options.method || "GET"
  2115. var body = options.body || options.data || null
  2116. var headers = xhr.headers = options.headers || {}
  2117. var sync = !!options.sync
  2118. var isJson = false
  2119. var timeoutTimer
  2120. if ("json" in options) {
  2121. isJson = true
  2122. headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json") //Don't override existing accept header declared by user
  2123. if (method !== "GET" && method !== "HEAD") {
  2124. headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json") //Don't override existing accept header declared by user
  2125. body = JSON.stringify(options.json)
  2126. }
  2127. }
  2128. xhr.onreadystatechange = readystatechange
  2129. xhr.onload = loadFunc
  2130. xhr.onerror = errorFunc
  2131. // IE9 must have onprogress be set to a unique function.
  2132. xhr.onprogress = function () {
  2133. // IE must die
  2134. }
  2135. xhr.ontimeout = errorFunc
  2136. xhr.open(method, uri, !sync, options.username, options.password)
  2137. //has to be after open
  2138. if (!sync) {
  2139. xhr.withCredentials = !!options.withCredentials
  2140. }
  2141. // Cannot set timeout with sync request
  2142. // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
  2143. // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
  2144. if (!sync && options.timeout > 0) {
  2145. timeoutTimer = setTimeout(function () {
  2146. aborted = true//IE9 may still call readystatechange
  2147. xhr.abort("timeout")
  2148. var e = new Error("XMLHttpRequest timeout")
  2149. e.code = "ETIMEDOUT"
  2150. errorFunc(e)
  2151. }, options.timeout)
  2152. }
  2153. if (xhr.setRequestHeader) {
  2154. for (key in headers) {
  2155. if (headers.hasOwnProperty(key)) {
  2156. xhr.setRequestHeader(key, headers[key])
  2157. }
  2158. }
  2159. } else if (options.headers && !isEmpty(options.headers)) {
  2160. throw new Error("Headers cannot be set on an XDomainRequest object")
  2161. }
  2162. if ("responseType" in options) {
  2163. xhr.responseType = options.responseType
  2164. }
  2165. if ("beforeSend" in options &&
  2166. typeof options.beforeSend === "function"
  2167. ) {
  2168. options.beforeSend(xhr)
  2169. }
  2170. xhr.send(body)
  2171. return xhr
  2172. }
  2173. function noop() { }
  2174. }, { "global/window": 2, "is-function": 57, "once": 58, "parse-headers": 61, "xtend": 62 }], 57: [function (_dereq_, module, exports) {
  2175. module.exports = isFunction
  2176. var toString = Object.prototype.toString
  2177. function isFunction(fn) {
  2178. var string = toString.call(fn)
  2179. return string === '[object Function]' ||
  2180. (typeof fn === 'function' && string !== '[object RegExp]') ||
  2181. (typeof window !== 'undefined' &&
  2182. // IE8 and below
  2183. (fn === window.setTimeout ||
  2184. fn === window.alert ||
  2185. fn === window.confirm ||
  2186. fn === window.prompt))
  2187. };
  2188. }, {}], 58: [function (_dereq_, module, exports) {
  2189. module.exports = once
  2190. once.proto = once(function () {
  2191. Object.defineProperty(Function.prototype, 'once', {
  2192. value: function () {
  2193. return once(this)
  2194. },
  2195. configurable: true
  2196. })
  2197. })
  2198. function once(fn) {
  2199. var called = false
  2200. return function () {
  2201. if (called) return
  2202. called = true
  2203. return fn.apply(this, arguments)
  2204. }
  2205. }
  2206. }, {}], 59: [function (_dereq_, module, exports) {
  2207. var isFunction = _dereq_('is-function')
  2208. module.exports = forEach
  2209. var toString = Object.prototype.toString
  2210. var hasOwnProperty = Object.prototype.hasOwnProperty
  2211. function forEach(list, iterator, context) {
  2212. if (!isFunction(iterator)) {
  2213. throw new TypeError('iterator must be a function')
  2214. }
  2215. if (arguments.length < 3) {
  2216. context = this
  2217. }
  2218. if (toString.call(list) === '[object Array]')
  2219. forEachArray(list, iterator, context)
  2220. else if (typeof list === 'string')
  2221. forEachString(list, iterator, context)
  2222. else
  2223. forEachObject(list, iterator, context)
  2224. }
  2225. function forEachArray(array, iterator, context) {
  2226. for (var i = 0, len = array.length; i < len; i++) {
  2227. if (hasOwnProperty.call(array, i)) {
  2228. iterator.call(context, array[i], i, array)
  2229. }
  2230. }
  2231. }
  2232. function forEachString(string, iterator, context) {
  2233. for (var i = 0, len = string.length; i < len; i++) {
  2234. // no such thing as a sparse string.
  2235. iterator.call(context, string.charAt(i), i, string)
  2236. }
  2237. }
  2238. function forEachObject(object, iterator, context) {
  2239. for (var k in object) {
  2240. if (hasOwnProperty.call(object, k)) {
  2241. iterator.call(context, object[k], k, object)
  2242. }
  2243. }
  2244. }
  2245. }, { "is-function": 57 }], 60: [function (_dereq_, module, exports) {
  2246. exports = module.exports = trim;
  2247. function trim(str) {
  2248. return str.replace(/^\s*|\s*$/g, '');
  2249. }
  2250. exports.left = function (str) {
  2251. return str.replace(/^\s*/, '');
  2252. };
  2253. exports.right = function (str) {
  2254. return str.replace(/\s*$/, '');
  2255. };
  2256. }, {}], 61: [function (_dereq_, module, exports) {
  2257. var trim = _dereq_('trim')
  2258. , forEach = _dereq_('for-each')
  2259. , isArray = function (arg) {
  2260. return Object.prototype.toString.call(arg) === '[object Array]';
  2261. }
  2262. module.exports = function (headers) {
  2263. if (!headers)
  2264. return {}
  2265. var result = {}
  2266. forEach(
  2267. trim(headers).split('\n')
  2268. , function (row) {
  2269. var index = row.indexOf(':')
  2270. , key = trim(row.slice(0, index)).toLowerCase()
  2271. , value = trim(row.slice(index + 1))
  2272. if (typeof (result[key]) === 'undefined') {
  2273. result[key] = value
  2274. } else if (isArray(result[key])) {
  2275. result[key].push(value)
  2276. } else {
  2277. result[key] = [result[key], value]
  2278. }
  2279. }
  2280. )
  2281. return result
  2282. }
  2283. }, { "for-each": 59, "trim": 60 }], 62: [function (_dereq_, module, exports) {
  2284. module.exports = extend
  2285. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2286. function extend() {
  2287. var target = {}
  2288. for (var i = 0; i < arguments.length; i++) {
  2289. var source = arguments[i]
  2290. for (var key in source) {
  2291. if (hasOwnProperty.call(source, key)) {
  2292. target[key] = source[key]
  2293. }
  2294. }
  2295. }
  2296. return target
  2297. }
  2298. }, {}], 63: [function (_dereq_, module, exports) {
  2299. /**
  2300. * @file big-play-button.js
  2301. */
  2302. 'use strict';
  2303. exports.__esModule = true;
  2304. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2305. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2306. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2307. var _buttonJs = _dereq_('./button.js');
  2308. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  2309. var _componentJs = _dereq_('./component.js');
  2310. var _componentJs2 = _interopRequireDefault(_componentJs);
  2311. /**
  2312. * Initial play button. Shows before the video has played. The hiding of the
  2313. * big play button is done via CSS and player states.
  2314. *
  2315. * @param {Object} player Main Player
  2316. * @param {Object=} options Object of option names and values
  2317. * @extends Button
  2318. * @class BigPlayButton
  2319. */
  2320. var BigPlayButton = (function (_Button) {
  2321. _inherits(BigPlayButton, _Button);
  2322. function BigPlayButton(player, options) {
  2323. _classCallCheck(this, BigPlayButton);
  2324. _Button.call(this, player, options);
  2325. }
  2326. /**
  2327. * Allow sub components to stack CSS class names
  2328. *
  2329. * @return {String} The constructed class name
  2330. * @method buildCSSClass
  2331. */
  2332. BigPlayButton.prototype.buildCSSClass = function buildCSSClass() {
  2333. return 'vjs-big-play-button';
  2334. };
  2335. /**
  2336. * Handles click for play
  2337. *
  2338. * @method handleClick
  2339. */
  2340. BigPlayButton.prototype.handleClick = function handleClick() {
  2341. this.player_.play();
  2342. };
  2343. return BigPlayButton;
  2344. })(_buttonJs2['default']);
  2345. BigPlayButton.prototype.controlText_ = 'Play Video';
  2346. _componentJs2['default'].registerComponent('BigPlayButton', BigPlayButton);
  2347. exports['default'] = BigPlayButton;
  2348. module.exports = exports['default'];
  2349. }, { "./button.js": 64, "./component.js": 67 }], 64: [function (_dereq_, module, exports) {
  2350. /**
  2351. * @file button.js
  2352. */
  2353. 'use strict';
  2354. exports.__esModule = true;
  2355. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  2356. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2357. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2358. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2359. var _clickableComponentJs = _dereq_('./clickable-component.js');
  2360. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  2361. var _component = _dereq_('./component');
  2362. var _component2 = _interopRequireDefault(_component);
  2363. var _utilsEventsJs = _dereq_('./utils/events.js');
  2364. var Events = _interopRequireWildcard(_utilsEventsJs);
  2365. var _utilsFnJs = _dereq_('./utils/fn.js');
  2366. var Fn = _interopRequireWildcard(_utilsFnJs);
  2367. var _utilsLogJs = _dereq_('./utils/log.js');
  2368. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  2369. var _globalDocument = _dereq_('global/document');
  2370. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  2371. var _objectAssign = _dereq_('object.assign');
  2372. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  2373. /**
  2374. * Base class for all buttons
  2375. *
  2376. * @param {Object} player Main Player
  2377. * @param {Object=} options Object of option names and values
  2378. * @extends ClickableComponent
  2379. * @class Button
  2380. */
  2381. var Button = (function (_ClickableComponent) {
  2382. _inherits(Button, _ClickableComponent);
  2383. function Button(player, options) {
  2384. _classCallCheck(this, Button);
  2385. _ClickableComponent.call(this, player, options);
  2386. }
  2387. /**
  2388. * Create the component's DOM element
  2389. *
  2390. * @param {String=} type Element's node type. e.g. 'div'
  2391. * @param {Object=} props An object of properties that should be set on the element
  2392. * @param {Object=} attributes An object of attributes that should be set on the element
  2393. * @return {Element}
  2394. * @method createEl
  2395. */
  2396. Button.prototype.createEl = function createEl() {
  2397. var tag = arguments.length <= 0 || arguments[0] === undefined ? 'button' : arguments[0];
  2398. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2399. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  2400. props = _objectAssign2['default']({
  2401. className: this.buildCSSClass()
  2402. }, props);
  2403. if (tag !== 'button') {
  2404. _utilsLogJs2['default'].warn('Creating a Button with an HTML element of ' + tag + ' is deprecated; use ClickableComponent instead.');
  2405. // Add properties for clickable element which is not a native HTML button
  2406. props = _objectAssign2['default']({
  2407. tabIndex: 0
  2408. }, props);
  2409. // Add ARIA attributes for clickable element which is not a native HTML button
  2410. attributes = _objectAssign2['default']({
  2411. role: 'button'
  2412. }, attributes);
  2413. }
  2414. // Add attributes for button element
  2415. attributes = _objectAssign2['default']({
  2416. type: 'button', // Necessary since the default button type is "submit"
  2417. 'aria-live': 'polite' // let the screen reader user know that the text of the button may change
  2418. }, attributes);
  2419. var el = _component2['default'].prototype.createEl.call(this, tag, props, attributes);
  2420. this.createControlTextEl(el);
  2421. return el;
  2422. };
  2423. /**
  2424. * Adds a child component inside this button
  2425. *
  2426. * @param {String|Component} child The class name or instance of a child to add
  2427. * @param {Object=} options Options, including options to be passed to children of the child.
  2428. * @return {Component} The child component (created by this process if a string was used)
  2429. * @deprecated
  2430. * @method addChild
  2431. */
  2432. Button.prototype.addChild = function addChild(child) {
  2433. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2434. var className = this.constructor.name;
  2435. _utilsLogJs2['default'].warn('Adding an actionable (user controllable) child to a Button (' + className + ') is not supported; use a ClickableComponent instead.');
  2436. // Avoid the error message generated by ClickableComponent's addChild method
  2437. return _component2['default'].prototype.addChild.call(this, child, options);
  2438. };
  2439. /**
  2440. * Handle KeyPress (document level) - Extend with specific functionality for button
  2441. *
  2442. * @method handleKeyPress
  2443. */
  2444. Button.prototype.handleKeyPress = function handleKeyPress(event) {
  2445. // Ignore Space (32) or Enter (13) key operation, which is handled by the browser for a button.
  2446. if (event.which === 32 || event.which === 13) { } else {
  2447. _ClickableComponent.prototype.handleKeyPress.call(this, event); // Pass keypress handling up for unsupported keys
  2448. }
  2449. };
  2450. return Button;
  2451. })(_clickableComponentJs2['default']);
  2452. _component2['default'].registerComponent('Button', Button);
  2453. exports['default'] = Button;
  2454. module.exports = exports['default'];
  2455. }, { "./clickable-component.js": 65, "./component": 67, "./utils/events.js": 144, "./utils/fn.js": 145, "./utils/log.js": 148, "global/document": 1, "object.assign": 45 }], 65: [function (_dereq_, module, exports) {
  2456. /**
  2457. * @file button.js
  2458. */
  2459. 'use strict';
  2460. exports.__esModule = true;
  2461. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  2462. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2463. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2464. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2465. var _component = _dereq_('./component');
  2466. var _component2 = _interopRequireDefault(_component);
  2467. var _utilsDomJs = _dereq_('./utils/dom.js');
  2468. var Dom = _interopRequireWildcard(_utilsDomJs);
  2469. var _utilsEventsJs = _dereq_('./utils/events.js');
  2470. var Events = _interopRequireWildcard(_utilsEventsJs);
  2471. var _utilsFnJs = _dereq_('./utils/fn.js');
  2472. var Fn = _interopRequireWildcard(_utilsFnJs);
  2473. var _utilsLogJs = _dereq_('./utils/log.js');
  2474. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  2475. var _globalDocument = _dereq_('global/document');
  2476. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  2477. var _objectAssign = _dereq_('object.assign');
  2478. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  2479. /**
  2480. * Clickable Component which is clickable or keyboard actionable, but is not a native HTML button
  2481. *
  2482. * @param {Object} player Main Player
  2483. * @param {Object=} options Object of option names and values
  2484. * @extends Component
  2485. * @class ClickableComponent
  2486. */
  2487. var ClickableComponent = (function (_Component) {
  2488. _inherits(ClickableComponent, _Component);
  2489. function ClickableComponent(player, options) {
  2490. _classCallCheck(this, ClickableComponent);
  2491. _Component.call(this, player, options);
  2492. this.emitTapEvents();
  2493. this.on('tap', this.handleClick);
  2494. this.on('click', this.handleClick);
  2495. this.on('focus', this.handleFocus);
  2496. this.on('blur', this.handleBlur);
  2497. }
  2498. /**
  2499. * Create the component's DOM element
  2500. *
  2501. * @param {String=} type Element's node type. e.g. 'div'
  2502. * @param {Object=} props An object of properties that should be set on the element
  2503. * @param {Object=} attributes An object of attributes that should be set on the element
  2504. * @return {Element}
  2505. * @method createEl
  2506. */
  2507. ClickableComponent.prototype.createEl = function createEl() {
  2508. var tag = arguments.length <= 0 || arguments[0] === undefined ? 'div' : arguments[0];
  2509. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2510. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  2511. props = _objectAssign2['default']({
  2512. className: this.buildCSSClass(),
  2513. tabIndex: 0
  2514. }, props);
  2515. if (tag === 'button') {
  2516. _utilsLogJs2['default'].error('Creating a ClickableComponent with an HTML element of ' + tag + ' is not supported; use a Button instead.');
  2517. }
  2518. // Add ARIA attributes for clickable element which is not a native HTML button
  2519. attributes = _objectAssign2['default']({
  2520. role: 'button',
  2521. 'aria-live': 'polite' // let the screen reader user know that the text of the element may change
  2522. }, attributes);
  2523. var el = _Component.prototype.createEl.call(this, tag, props, attributes);
  2524. this.createControlTextEl(el);
  2525. return el;
  2526. };
  2527. /**
  2528. * create control text
  2529. *
  2530. * @param {Element} el Parent element for the control text
  2531. * @return {Element}
  2532. * @method controlText
  2533. */
  2534. ClickableComponent.prototype.createControlTextEl = function createControlTextEl(el) {
  2535. this.controlTextEl_ = Dom.createEl('span', {
  2536. className: 'vjs-control-text'
  2537. });
  2538. if (el) {
  2539. el.appendChild(this.controlTextEl_);
  2540. }
  2541. this.controlText(this.controlText_);
  2542. return this.controlTextEl_;
  2543. };
  2544. /**
  2545. * Controls text - both request and localize
  2546. *
  2547. * @param {String} text Text for element
  2548. * @return {String}
  2549. * @method controlText
  2550. */
  2551. ClickableComponent.prototype.controlText = function controlText(text) {
  2552. if (!text) return this.controlText_ || 'Need Text';
  2553. this.controlText_ = text;
  2554. this.controlTextEl_.innerHTML = this.localize(this.controlText_);
  2555. return this;
  2556. };
  2557. /**
  2558. * Allows sub components to stack CSS class names
  2559. *
  2560. * @return {String}
  2561. * @method buildCSSClass
  2562. */
  2563. ClickableComponent.prototype.buildCSSClass = function buildCSSClass() {
  2564. return 'vjs-control vjs-button ' + _Component.prototype.buildCSSClass.call(this);
  2565. };
  2566. /**
  2567. * Adds a child component inside this clickable-component
  2568. *
  2569. * @param {String|Component} child The class name or instance of a child to add
  2570. * @param {Object=} options Options, including options to be passed to children of the child.
  2571. * @return {Component} The child component (created by this process if a string was used)
  2572. * @method addChild
  2573. */
  2574. ClickableComponent.prototype.addChild = function addChild(child) {
  2575. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2576. // TODO: Fix adding an actionable child to a ClickableComponent; currently
  2577. // it will cause issues with assistive technology (e.g. screen readers)
  2578. // which support ARIA, since an element with role="button" cannot have
  2579. // actionable child elements.
  2580. //let className = this.constructor.name;
  2581. //log.warn(`Adding a child to a ClickableComponent (${className}) can cause issues with assistive technology which supports ARIA, since an element with role="button" cannot have actionable child elements.`);
  2582. return _Component.prototype.addChild.call(this, child, options);
  2583. };
  2584. /**
  2585. * Enable the component element
  2586. *
  2587. * @return {Component}
  2588. * @method enable
  2589. */
  2590. ClickableComponent.prototype.enable = function enable() {
  2591. this.removeClass('vjs-disabled');
  2592. this.el_.setAttribute('aria-disabled', 'false');
  2593. return this;
  2594. };
  2595. /**
  2596. * Disable the component element
  2597. *
  2598. * @return {Component}
  2599. * @method disable
  2600. */
  2601. ClickableComponent.prototype.disable = function disable() {
  2602. this.addClass('vjs-disabled');
  2603. this.el_.setAttribute('aria-disabled', 'true');
  2604. return this;
  2605. };
  2606. /**
  2607. * Handle Click - Override with specific functionality for component
  2608. *
  2609. * @method handleClick
  2610. */
  2611. ClickableComponent.prototype.handleClick = function handleClick() { };
  2612. /**
  2613. * Handle Focus - Add keyboard functionality to element
  2614. *
  2615. * @method handleFocus
  2616. */
  2617. ClickableComponent.prototype.handleFocus = function handleFocus() {
  2618. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  2619. };
  2620. /**
  2621. * Handle KeyPress (document level) - Trigger click when Space or Enter key is pressed
  2622. *
  2623. * @method handleKeyPress
  2624. */
  2625. ClickableComponent.prototype.handleKeyPress = function handleKeyPress(event) {
  2626. // Support Space (32) or Enter (13) key operation to fire a click event
  2627. if (event.which === 32 || event.which === 13) {
  2628. event.preventDefault();
  2629. this.handleClick(event);
  2630. } else if (_Component.prototype.handleKeyPress) {
  2631. _Component.prototype.handleKeyPress.call(this, event); // Pass keypress handling up for unsupported keys
  2632. }
  2633. };
  2634. /**
  2635. * Handle Blur - Remove keyboard triggers
  2636. *
  2637. * @method handleBlur
  2638. */
  2639. ClickableComponent.prototype.handleBlur = function handleBlur() {
  2640. Events.off(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  2641. };
  2642. return ClickableComponent;
  2643. })(_component2['default']);
  2644. _component2['default'].registerComponent('ClickableComponent', ClickableComponent);
  2645. exports['default'] = ClickableComponent;
  2646. module.exports = exports['default'];
  2647. }, { "./component": 67, "./utils/dom.js": 143, "./utils/events.js": 144, "./utils/fn.js": 145, "./utils/log.js": 148, "global/document": 1, "object.assign": 45 }], 66: [function (_dereq_, module, exports) {
  2648. 'use strict';
  2649. exports.__esModule = true;
  2650. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2651. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2652. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2653. var _button = _dereq_('./button');
  2654. var _button2 = _interopRequireDefault(_button);
  2655. var _component = _dereq_('./component');
  2656. var _component2 = _interopRequireDefault(_component);
  2657. /**
  2658. * The `CloseButton` component is a button which fires a "close" event
  2659. * when it is activated.
  2660. *
  2661. * @extends Button
  2662. * @class CloseButton
  2663. */
  2664. var CloseButton = (function (_Button) {
  2665. _inherits(CloseButton, _Button);
  2666. function CloseButton(player, options) {
  2667. _classCallCheck(this, CloseButton);
  2668. _Button.call(this, player, options);
  2669. this.controlText(options && options.controlText || this.localize('Close'));
  2670. }
  2671. CloseButton.prototype.buildCSSClass = function buildCSSClass() {
  2672. return 'vjs-close-button ' + _Button.prototype.buildCSSClass.call(this);
  2673. };
  2674. CloseButton.prototype.handleClick = function handleClick() {
  2675. this.trigger({ type: 'close', bubbles: false });
  2676. };
  2677. return CloseButton;
  2678. })(_button2['default']);
  2679. _component2['default'].registerComponent('CloseButton', CloseButton);
  2680. exports['default'] = CloseButton;
  2681. module.exports = exports['default'];
  2682. }, { "./button": 64, "./component": 67 }], 67: [function (_dereq_, module, exports) {
  2683. /**
  2684. * @file component.js
  2685. *
  2686. * Player Component - Base class for all UI objects
  2687. */
  2688. 'use strict';
  2689. exports.__esModule = true;
  2690. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  2691. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2692. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2693. var _globalWindow = _dereq_('global/window');
  2694. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  2695. var _utilsDomJs = _dereq_('./utils/dom.js');
  2696. var Dom = _interopRequireWildcard(_utilsDomJs);
  2697. var _utilsFnJs = _dereq_('./utils/fn.js');
  2698. var Fn = _interopRequireWildcard(_utilsFnJs);
  2699. var _utilsGuidJs = _dereq_('./utils/guid.js');
  2700. var Guid = _interopRequireWildcard(_utilsGuidJs);
  2701. var _utilsEventsJs = _dereq_('./utils/events.js');
  2702. var Events = _interopRequireWildcard(_utilsEventsJs);
  2703. var _utilsLogJs = _dereq_('./utils/log.js');
  2704. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  2705. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
  2706. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  2707. var _objectAssign = _dereq_('object.assign');
  2708. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  2709. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
  2710. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  2711. /**
  2712. * Base UI Component class
  2713. * Components are embeddable UI objects that are represented by both a
  2714. * javascript object and an element in the DOM. They can be children of other
  2715. * components, and can have many children themselves.
  2716. * ```js
  2717. * // adding a button to the player
  2718. * var button = player.addChild('button');
  2719. * button.el(); // -> button element
  2720. * ```
  2721. * ```html
  2722. * <div class="video-js">
  2723. * <div class="vjs-button">Button</div>
  2724. * </div>
  2725. * ```
  2726. * Components are also event targets.
  2727. * ```js
  2728. * button.on('click', function(){
  2729. * console.log('Button Clicked!');
  2730. * });
  2731. * button.trigger('customevent');
  2732. * ```
  2733. *
  2734. * @param {Object} player Main Player
  2735. * @param {Object=} options Object of option names and values
  2736. * @param {Function=} ready Ready callback function
  2737. * @class Component
  2738. */
  2739. var Component = (function () {
  2740. function Component(player, options, ready) {
  2741. _classCallCheck(this, Component);
  2742. // The component might be the player itself and we can't pass `this` to super
  2743. if (!player && this.play) {
  2744. this.player_ = player = this; // eslint-disable-line
  2745. } else {
  2746. this.player_ = player;
  2747. }
  2748. // Make a copy of prototype.options_ to protect against overriding defaults
  2749. this.options_ = _utilsMergeOptionsJs2['default']({}, this.options_);
  2750. // Updated options with supplied options
  2751. options = this.options_ = _utilsMergeOptionsJs2['default'](this.options_, options);
  2752. // Get ID from options or options element if one is supplied
  2753. this.id_ = options.id || options.el && options.el.id;
  2754. // If there was no ID from the options, generate one
  2755. if (!this.id_) {
  2756. // Don't require the player ID function in the case of mock players
  2757. var id = player && player.id && player.id() || 'no_player';
  2758. this.id_ = id + '_component_' + Guid.newGUID();
  2759. }
  2760. this.name_ = options.name || null;
  2761. // Create element if one wasn't provided in options
  2762. if (options.el) {
  2763. this.el_ = options.el;
  2764. } else if (options.createEl !== false) {
  2765. this.el_ = this.createEl();
  2766. }
  2767. this.children_ = [];
  2768. this.childIndex_ = {};
  2769. this.childNameIndex_ = {};
  2770. // Add any child components in options
  2771. if (options.initChildren !== false) {
  2772. this.initChildren();
  2773. }
  2774. this.ready(ready);
  2775. // Don't want to trigger ready here or it will before init is actually
  2776. // finished for all children that run this constructor
  2777. if (options.reportTouchActivity !== false) {
  2778. this.enableTouchActivity();
  2779. }
  2780. }
  2781. /**
  2782. * Dispose of the component and all child components
  2783. *
  2784. * @method dispose
  2785. */
  2786. Component.prototype.dispose = function dispose() {
  2787. this.trigger({ type: 'dispose', bubbles: false });
  2788. // Dispose all children.
  2789. if (this.children_) {
  2790. for (var i = this.children_.length - 1; i >= 0; i--) {
  2791. if (this.children_[i].dispose) {
  2792. this.children_[i].dispose();
  2793. }
  2794. }
  2795. }
  2796. // Delete child references
  2797. this.children_ = null;
  2798. this.childIndex_ = null;
  2799. this.childNameIndex_ = null;
  2800. // Remove all event listeners.
  2801. this.off();
  2802. // Remove element from DOM
  2803. if (this.el_.parentNode) {
  2804. this.el_.parentNode.removeChild(this.el_);
  2805. }
  2806. Dom.removeElData(this.el_);
  2807. this.el_ = null;
  2808. };
  2809. /**
  2810. * Return the component's player
  2811. *
  2812. * @return {Player}
  2813. * @method player
  2814. */
  2815. Component.prototype.player = function player() {
  2816. return this.player_;
  2817. };
  2818. /**
  2819. * Deep merge of options objects
  2820. * Whenever a property is an object on both options objects
  2821. * the two properties will be merged using mergeOptions.
  2822. *
  2823. * ```js
  2824. * Parent.prototype.options_ = {
  2825. * optionSet: {
  2826. * 'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
  2827. * 'childTwo': {},
  2828. * 'childThree': {}
  2829. * }
  2830. * }
  2831. * newOptions = {
  2832. * optionSet: {
  2833. * 'childOne': { 'foo': 'baz', 'abc': '123' }
  2834. * 'childTwo': null,
  2835. * 'childFour': {}
  2836. * }
  2837. * }
  2838. *
  2839. * this.options(newOptions);
  2840. * ```
  2841. * RESULT
  2842. * ```js
  2843. * {
  2844. * optionSet: {
  2845. * 'childOne': { 'foo': 'baz', 'asdf': 'fdsa', 'abc': '123' },
  2846. * 'childTwo': null, // Disabled. Won't be initialized.
  2847. * 'childThree': {},
  2848. * 'childFour': {}
  2849. * }
  2850. * }
  2851. * ```
  2852. *
  2853. * @param {Object} obj Object of new option values
  2854. * @return {Object} A NEW object of this.options_ and obj merged
  2855. * @method options
  2856. */
  2857. Component.prototype.options = function options(obj) {
  2858. _utilsLogJs2['default'].warn('this.options() has been deprecated and will be moved to the constructor in 6.0');
  2859. if (!obj) {
  2860. return this.options_;
  2861. }
  2862. this.options_ = _utilsMergeOptionsJs2['default'](this.options_, obj);
  2863. return this.options_;
  2864. };
  2865. /**
  2866. * Get the component's DOM element
  2867. * ```js
  2868. * var domEl = myComponent.el();
  2869. * ```
  2870. *
  2871. * @return {Element}
  2872. * @method el
  2873. */
  2874. Component.prototype.el = function el() {
  2875. return this.el_;
  2876. };
  2877. /**
  2878. * Create the component's DOM element
  2879. *
  2880. * @param {String=} tagName Element's node type. e.g. 'div'
  2881. * @param {Object=} properties An object of properties that should be set
  2882. * @param {Object=} attributes An object of attributes that should be set
  2883. * @return {Element}
  2884. * @method createEl
  2885. */
  2886. Component.prototype.createEl = function createEl(tagName, properties, attributes) {
  2887. return Dom.createEl(tagName, properties, attributes);
  2888. };
  2889. Component.prototype.localize = function localize(string) {
  2890. var code = this.player_.language && this.player_.language();
  2891. var languages = this.player_.languages && this.player_.languages();
  2892. if (!code || !languages) {
  2893. return string;
  2894. }
  2895. var language = languages[code];
  2896. if (language && language[string]) {
  2897. return language[string];
  2898. }
  2899. var primaryCode = code.split('-')[0];
  2900. var primaryLang = languages[primaryCode];
  2901. if (primaryLang && primaryLang[string]) {
  2902. return primaryLang[string];
  2903. }
  2904. return string;
  2905. };
  2906. /**
  2907. * Return the component's DOM element where children are inserted.
  2908. * Will either be the same as el() or a new element defined in createEl().
  2909. *
  2910. * @return {Element}
  2911. * @method contentEl
  2912. */
  2913. Component.prototype.contentEl = function contentEl() {
  2914. return this.contentEl_ || this.el_;
  2915. };
  2916. /**
  2917. * Get the component's ID
  2918. * ```js
  2919. * var id = myComponent.id();
  2920. * ```
  2921. *
  2922. * @return {String}
  2923. * @method id
  2924. */
  2925. Component.prototype.id = function id() {
  2926. return this.id_;
  2927. };
  2928. /**
  2929. * Get the component's name. The name is often used to reference the component.
  2930. * ```js
  2931. * var name = myComponent.name();
  2932. * ```
  2933. *
  2934. * @return {String}
  2935. * @method name
  2936. */
  2937. Component.prototype.name = function name() {
  2938. return this.name_;
  2939. };
  2940. /**
  2941. * Get an array of all child components
  2942. * ```js
  2943. * var kids = myComponent.children();
  2944. * ```
  2945. *
  2946. * @return {Array} The children
  2947. * @method children
  2948. */
  2949. Component.prototype.children = function children() {
  2950. return this.children_;
  2951. };
  2952. /**
  2953. * Returns a child component with the provided ID
  2954. *
  2955. * @return {Component}
  2956. * @method getChildById
  2957. */
  2958. Component.prototype.getChildById = function getChildById(id) {
  2959. return this.childIndex_[id];
  2960. };
  2961. /**
  2962. * Returns a child component with the provided name
  2963. *
  2964. * @return {Component}
  2965. * @method getChild
  2966. */
  2967. Component.prototype.getChild = function getChild(name) {
  2968. return this.childNameIndex_[name];
  2969. };
  2970. /**
  2971. * Adds a child component inside this component
  2972. * ```js
  2973. * myComponent.el();
  2974. * // -> <div class='my-component'></div>
  2975. * myComponent.children();
  2976. * // [empty array]
  2977. *
  2978. * var myButton = myComponent.addChild('MyButton');
  2979. * // -> <div class='my-component'><div class="my-button">myButton<div></div>
  2980. * // -> myButton === myComponent.children()[0];
  2981. * ```
  2982. * Pass in options for child constructors and options for children of the child
  2983. * ```js
  2984. * var myButton = myComponent.addChild('MyButton', {
  2985. * text: 'Press Me',
  2986. * buttonChildExample: {
  2987. * buttonChildOption: true
  2988. * }
  2989. * });
  2990. * ```
  2991. *
  2992. * @param {String|Component} child The class name or instance of a child to add
  2993. * @param {Object=} options Options, including options to be passed to children of the child.
  2994. * @param {Number} index into our children array to attempt to add the child
  2995. * @return {Component} The child component (created by this process if a string was used)
  2996. * @method addChild
  2997. */
  2998. Component.prototype.addChild = function addChild(child) {
  2999. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  3000. var index = arguments.length <= 2 || arguments[2] === undefined ? this.children_.length : arguments[2];
  3001. var component = undefined;
  3002. var componentName = undefined;
  3003. // If child is a string, create nt with options
  3004. if (typeof child === 'string') {
  3005. componentName = child;
  3006. // Options can also be specified as a boolean, so convert to an empty object if false.
  3007. if (!options) {
  3008. options = {};
  3009. }
  3010. // Same as above, but true is deprecated so show a warning.
  3011. if (options === true) {
  3012. _utilsLogJs2['default'].warn('Initializing a child component with `true` is deprecated. Children should be defined in an array when possible, but if necessary use an object instead of `true`.');
  3013. options = {};
  3014. }
  3015. // If no componentClass in options, assume componentClass is the name lowercased
  3016. // (e.g. playButton)
  3017. var componentClassName = options.componentClass || _utilsToTitleCaseJs2['default'](componentName);
  3018. // Set name through options
  3019. options.name = componentName;
  3020. // Create a new object & element for this controls set
  3021. // If there's no .player_, this is a player
  3022. var ComponentClass = Component.getComponent(componentClassName);
  3023. if (!ComponentClass) {
  3024. throw new Error('Component ' + componentClassName + ' does not exist');
  3025. }
  3026. // data stored directly on the videojs object may be
  3027. // misidentified as a component to retain
  3028. // backwards-compatibility with 4.x. check to make sure the
  3029. // component class can be instantiated.
  3030. if (typeof ComponentClass !== 'function') {
  3031. return null;
  3032. }
  3033. component = new ComponentClass(this.player_ || this, options);
  3034. // child is a component instance
  3035. } else {
  3036. component = child;
  3037. }
  3038. this.children_.splice(index, 0, component);
  3039. if (typeof component.id === 'function') {
  3040. this.childIndex_[component.id()] = component;
  3041. }
  3042. // If a name wasn't used to create the component, check if we can use the
  3043. // name function of the component
  3044. componentName = componentName || component.name && component.name();
  3045. if (componentName) {
  3046. this.childNameIndex_[componentName] = component;
  3047. }
  3048. // Add the UI object's element to the container div (box)
  3049. // Having an element is not required
  3050. if (typeof component.el === 'function' && component.el()) {
  3051. var childNodes = this.contentEl().children;
  3052. var refNode = childNodes[index] || null;
  3053. this.contentEl().insertBefore(component.el(), refNode);
  3054. }
  3055. // Return so it can stored on parent object if desired.
  3056. return component;
  3057. };
  3058. /**
  3059. * Remove a child component from this component's list of children, and the
  3060. * child component's element from this component's element
  3061. *
  3062. * @param {Component} component Component to remove
  3063. * @method removeChild
  3064. */
  3065. Component.prototype.removeChild = function removeChild(component) {
  3066. if (typeof component === 'string') {
  3067. component = this.getChild(component);
  3068. }
  3069. if (!component || !this.children_) {
  3070. return;
  3071. }
  3072. var childFound = false;
  3073. for (var i = this.children_.length - 1; i >= 0; i--) {
  3074. if (this.children_[i] === component) {
  3075. childFound = true;
  3076. this.children_.splice(i, 1);
  3077. break;
  3078. }
  3079. }
  3080. if (!childFound) {
  3081. return;
  3082. }
  3083. this.childIndex_[component.id()] = null;
  3084. this.childNameIndex_[component.name()] = null;
  3085. var compEl = component.el();
  3086. if (compEl && compEl.parentNode === this.contentEl()) {
  3087. this.contentEl().removeChild(component.el());
  3088. }
  3089. };
  3090. /**
  3091. * Add and initialize default child components from options
  3092. * ```js
  3093. * // when an instance of MyComponent is created, all children in options
  3094. * // will be added to the instance by their name strings and options
  3095. * MyComponent.prototype.options_ = {
  3096. * children: [
  3097. * 'myChildComponent'
  3098. * ],
  3099. * myChildComponent: {
  3100. * myChildOption: true
  3101. * }
  3102. * };
  3103. *
  3104. * // Or when creating the component
  3105. * var myComp = new MyComponent(player, {
  3106. * children: [
  3107. * 'myChildComponent'
  3108. * ],
  3109. * myChildComponent: {
  3110. * myChildOption: true
  3111. * }
  3112. * });
  3113. * ```
  3114. * The children option can also be an array of
  3115. * child options objects (that also include a 'name' key).
  3116. * This can be used if you have two child components of the
  3117. * same type that need different options.
  3118. * ```js
  3119. * var myComp = new MyComponent(player, {
  3120. * children: [
  3121. * 'button',
  3122. * {
  3123. * name: 'button',
  3124. * someOtherOption: true
  3125. * },
  3126. * {
  3127. * name: 'button',
  3128. * someOtherOption: false
  3129. * }
  3130. * ]
  3131. * });
  3132. * ```
  3133. *
  3134. * @method initChildren
  3135. */
  3136. Component.prototype.initChildren = function initChildren() {
  3137. var _this = this;
  3138. var children = this.options_.children;
  3139. if (children) {
  3140. (function () {
  3141. // `this` is `parent`
  3142. var parentOptions = _this.options_;
  3143. var handleAdd = function handleAdd(child) {
  3144. var name = child.name;
  3145. var opts = child.opts;
  3146. // Allow options for children to be set at the parent options
  3147. // e.g. videojs(id, { controlBar: false });
  3148. // instead of videojs(id, { children: { controlBar: false });
  3149. if (parentOptions[name] !== undefined) {
  3150. opts = parentOptions[name];
  3151. }
  3152. // Allow for disabling default components
  3153. // e.g. options['children']['posterImage'] = false
  3154. if (opts === false) {
  3155. return;
  3156. }
  3157. // Allow options to be passed as a simple boolean if no configuration
  3158. // is necessary.
  3159. if (opts === true) {
  3160. opts = {};
  3161. }
  3162. // We also want to pass the original player options to each component as well so they don't need to
  3163. // reach back into the player for options later.
  3164. opts.playerOptions = _this.options_.playerOptions;
  3165. // Create and add the child component.
  3166. // Add a direct reference to the child by name on the parent instance.
  3167. // If two of the same component are used, different names should be supplied
  3168. // for each
  3169. var newChild = _this.addChild(name, opts);
  3170. if (newChild) {
  3171. _this[name] = newChild;
  3172. }
  3173. };
  3174. // Allow for an array of children details to passed in the options
  3175. var workingChildren = undefined;
  3176. var Tech = Component.getComponent('Tech');
  3177. if (Array.isArray(children)) {
  3178. workingChildren = children;
  3179. } else {
  3180. workingChildren = Object.keys(children);
  3181. }
  3182. workingChildren
  3183. // children that are in this.options_ but also in workingChildren would
  3184. // give us extra children we do not want. So, we want to filter them out.
  3185. .concat(Object.keys(_this.options_).filter(function (child) {
  3186. return !workingChildren.some(function (wchild) {
  3187. if (typeof wchild === 'string') {
  3188. return child === wchild;
  3189. } else {
  3190. return child === wchild.name;
  3191. }
  3192. });
  3193. })).map(function (child) {
  3194. var name = undefined,
  3195. opts = undefined;
  3196. if (typeof child === 'string') {
  3197. name = child;
  3198. opts = children[name] || _this.options_[name] || {};
  3199. } else {
  3200. name = child.name;
  3201. opts = child;
  3202. }
  3203. return { name: name, opts: opts };
  3204. }).filter(function (child) {
  3205. // we have to make sure that child.name isn't in the techOrder since
  3206. // techs are registerd as Components but can't aren't compatible
  3207. // See https://github.com/videojs/video.js/issues/2772
  3208. var c = Component.getComponent(child.opts.componentClass || _utilsToTitleCaseJs2['default'](child.name));
  3209. return c && !Tech.isTech(c);
  3210. }).forEach(handleAdd);
  3211. })();
  3212. }
  3213. };
  3214. /**
  3215. * Allows sub components to stack CSS class names
  3216. *
  3217. * @return {String} The constructed class name
  3218. * @method buildCSSClass
  3219. */
  3220. Component.prototype.buildCSSClass = function buildCSSClass() {
  3221. // Child classes can include a function that does:
  3222. // return 'CLASS NAME' + this._super();
  3223. return '';
  3224. };
  3225. /**
  3226. * Add an event listener to this component's element
  3227. * ```js
  3228. * var myFunc = function(){
  3229. * var myComponent = this;
  3230. * // Do something when the event is fired
  3231. * };
  3232. *
  3233. * myComponent.on('eventType', myFunc);
  3234. * ```
  3235. * The context of myFunc will be myComponent unless previously bound.
  3236. * Alternatively, you can add a listener to another element or component.
  3237. * ```js
  3238. * myComponent.on(otherElement, 'eventName', myFunc);
  3239. * myComponent.on(otherComponent, 'eventName', myFunc);
  3240. * ```
  3241. * The benefit of using this over `VjsEvents.on(otherElement, 'eventName', myFunc)`
  3242. * and `otherComponent.on('eventName', myFunc)` is that this way the listeners
  3243. * will be automatically cleaned up when either component is disposed.
  3244. * It will also bind myComponent as the context of myFunc.
  3245. * **NOTE**: When using this on elements in the page other than window
  3246. * and document (both permanent), if you remove the element from the DOM
  3247. * you need to call `myComponent.trigger(el, 'dispose')` on it to clean up
  3248. * references to it and allow the browser to garbage collect it.
  3249. *
  3250. * @param {String|Component} first The event type or other component
  3251. * @param {Function|String} second The event handler or event type
  3252. * @param {Function} third The event handler
  3253. * @return {Component}
  3254. * @method on
  3255. */
  3256. Component.prototype.on = function on(first, second, third) {
  3257. var _this2 = this;
  3258. if (typeof first === 'string' || Array.isArray(first)) {
  3259. Events.on(this.el_, first, Fn.bind(this, second));
  3260. // Targeting another component or element
  3261. } else {
  3262. (function () {
  3263. var target = first;
  3264. var type = second;
  3265. var fn = Fn.bind(_this2, third);
  3266. // When this component is disposed, remove the listener from the other component
  3267. var removeOnDispose = function removeOnDispose() {
  3268. return _this2.off(target, type, fn);
  3269. };
  3270. // Use the same function ID so we can remove it later it using the ID
  3271. // of the original listener
  3272. removeOnDispose.guid = fn.guid;
  3273. _this2.on('dispose', removeOnDispose);
  3274. // If the other component is disposed first we need to clean the reference
  3275. // to the other component in this component's removeOnDispose listener
  3276. // Otherwise we create a memory leak.
  3277. var cleanRemover = function cleanRemover() {
  3278. return _this2.off('dispose', removeOnDispose);
  3279. };
  3280. // Add the same function ID so we can easily remove it later
  3281. cleanRemover.guid = fn.guid;
  3282. // Check if this is a DOM node
  3283. if (first.nodeName) {
  3284. // Add the listener to the other element
  3285. Events.on(target, type, fn);
  3286. Events.on(target, 'dispose', cleanRemover);
  3287. // Should be a component
  3288. // Not using `instanceof Component` because it makes mock players difficult
  3289. } else if (typeof first.on === 'function') {
  3290. // Add the listener to the other component
  3291. target.on(type, fn);
  3292. target.on('dispose', cleanRemover);
  3293. }
  3294. })();
  3295. }
  3296. return this;
  3297. };
  3298. /**
  3299. * Remove an event listener from this component's element
  3300. * ```js
  3301. * myComponent.off('eventType', myFunc);
  3302. * ```
  3303. * If myFunc is excluded, ALL listeners for the event type will be removed.
  3304. * If eventType is excluded, ALL listeners will be removed from the component.
  3305. * Alternatively you can use `off` to remove listeners that were added to other
  3306. * elements or components using `myComponent.on(otherComponent...`.
  3307. * In this case both the event type and listener function are REQUIRED.
  3308. * ```js
  3309. * myComponent.off(otherElement, 'eventType', myFunc);
  3310. * myComponent.off(otherComponent, 'eventType', myFunc);
  3311. * ```
  3312. *
  3313. * @param {String=|Component} first The event type or other component
  3314. * @param {Function=|String} second The listener function or event type
  3315. * @param {Function=} third The listener for other component
  3316. * @return {Component}
  3317. * @method off
  3318. */
  3319. Component.prototype.off = function off(first, second, third) {
  3320. if (!first || typeof first === 'string' || Array.isArray(first)) {
  3321. Events.off(this.el_, first, second);
  3322. } else {
  3323. var target = first;
  3324. var type = second;
  3325. // Ensure there's at least a guid, even if the function hasn't been used
  3326. var fn = Fn.bind(this, third);
  3327. // Remove the dispose listener on this component,
  3328. // which was given the same guid as the event listener
  3329. this.off('dispose', fn);
  3330. if (first.nodeName) {
  3331. // Remove the listener
  3332. Events.off(target, type, fn);
  3333. // Remove the listener for cleaning the dispose listener
  3334. Events.off(target, 'dispose', fn);
  3335. } else {
  3336. target.off(type, fn);
  3337. target.off('dispose', fn);
  3338. }
  3339. }
  3340. return this;
  3341. };
  3342. /**
  3343. * Add an event listener to be triggered only once and then removed
  3344. * ```js
  3345. * myComponent.one('eventName', myFunc);
  3346. * ```
  3347. * Alternatively you can add a listener to another element or component
  3348. * that will be triggered only once.
  3349. * ```js
  3350. * myComponent.one(otherElement, 'eventName', myFunc);
  3351. * myComponent.one(otherComponent, 'eventName', myFunc);
  3352. * ```
  3353. *
  3354. * @param {String|Component} first The event type or other component
  3355. * @param {Function|String} second The listener function or event type
  3356. * @param {Function=} third The listener function for other component
  3357. * @return {Component}
  3358. * @method one
  3359. */
  3360. Component.prototype.one = function one(first, second, third) {
  3361. var _this3 = this,
  3362. _arguments = arguments;
  3363. if (typeof first === 'string' || Array.isArray(first)) {
  3364. Events.one(this.el_, first, Fn.bind(this, second));
  3365. } else {
  3366. (function () {
  3367. var target = first;
  3368. var type = second;
  3369. var fn = Fn.bind(_this3, third);
  3370. var newFunc = function newFunc() {
  3371. _this3.off(target, type, newFunc);
  3372. fn.apply(null, _arguments);
  3373. };
  3374. // Keep the same function ID so we can remove it later
  3375. newFunc.guid = fn.guid;
  3376. _this3.on(target, type, newFunc);
  3377. })();
  3378. }
  3379. return this;
  3380. };
  3381. /**
  3382. * Trigger an event on an element
  3383. * ```js
  3384. * myComponent.trigger('eventName');
  3385. * myComponent.trigger({'type':'eventName'});
  3386. * myComponent.trigger('eventName', {data: 'some data'});
  3387. * myComponent.trigger({'type':'eventName'}, {data: 'some data'});
  3388. * ```
  3389. *
  3390. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  3391. * @param {Object} [hash] data hash to pass along with the event
  3392. * @return {Component} self
  3393. * @method trigger
  3394. */
  3395. Component.prototype.trigger = function trigger(event, hash) {
  3396. Events.trigger(this.el_, event, hash);
  3397. return this;
  3398. };
  3399. /**
  3400. * Bind a listener to the component's ready state.
  3401. * Different from event listeners in that if the ready event has already happened
  3402. * it will trigger the function immediately.
  3403. *
  3404. * @param {Function} fn Ready listener
  3405. * @param {Boolean} sync Exec the listener synchronously if component is ready
  3406. * @return {Component}
  3407. * @method ready
  3408. */
  3409. Component.prototype.ready = function ready(fn) {
  3410. var sync = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
  3411. if (fn) {
  3412. if (this.isReady_) {
  3413. if (sync) {
  3414. fn.call(this);
  3415. } else {
  3416. // Call the function asynchronously by default for consistency
  3417. this.setTimeout(fn, 1);
  3418. }
  3419. } else {
  3420. this.readyQueue_ = this.readyQueue_ || [];
  3421. this.readyQueue_.push(fn);
  3422. }
  3423. }
  3424. return this;
  3425. };
  3426. /**
  3427. * Trigger the ready listeners
  3428. *
  3429. * @return {Component}
  3430. * @method triggerReady
  3431. */
  3432. Component.prototype.triggerReady = function triggerReady() {
  3433. this.isReady_ = true;
  3434. // Ensure ready is triggerd asynchronously
  3435. this.setTimeout(function () {
  3436. var readyQueue = this.readyQueue_;
  3437. // Reset Ready Queue
  3438. this.readyQueue_ = [];
  3439. if (readyQueue && readyQueue.length > 0) {
  3440. readyQueue.forEach(function (fn) {
  3441. fn.call(this);
  3442. }, this);
  3443. }
  3444. // Allow for using event listeners also
  3445. this.trigger('ready');
  3446. }, 1);
  3447. };
  3448. /**
  3449. * Finds a single DOM element matching `selector` within the component's
  3450. * `contentEl` or another custom context.
  3451. *
  3452. * @method $
  3453. * @param {String} selector
  3454. * A valid CSS selector, which will be passed to `querySelector`.
  3455. *
  3456. * @param {Element|String} [context=document]
  3457. * A DOM element within which to query. Can also be a selector
  3458. * string in which case the first matching element will be used
  3459. * as context. If missing (or no element matches selector), falls
  3460. * back to `document`.
  3461. *
  3462. * @return {Element|null}
  3463. */
  3464. Component.prototype.$ = function $(selector, context) {
  3465. return Dom.$(selector, context || this.contentEl());
  3466. };
  3467. /**
  3468. * Finds a all DOM elements matching `selector` within the component's
  3469. * `contentEl` or another custom context.
  3470. *
  3471. * @method $$
  3472. * @param {String} selector
  3473. * A valid CSS selector, which will be passed to `querySelectorAll`.
  3474. *
  3475. * @param {Element|String} [context=document]
  3476. * A DOM element within which to query. Can also be a selector
  3477. * string in which case the first matching element will be used
  3478. * as context. If missing (or no element matches selector), falls
  3479. * back to `document`.
  3480. *
  3481. * @return {NodeList}
  3482. */
  3483. Component.prototype.$$ = function $$(selector, context) {
  3484. return Dom.$$(selector, context || this.contentEl());
  3485. };
  3486. /**
  3487. * Check if a component's element has a CSS class name
  3488. *
  3489. * @param {String} classToCheck Classname to check
  3490. * @return {Component}
  3491. * @method hasClass
  3492. */
  3493. Component.prototype.hasClass = function hasClass(classToCheck) {
  3494. return Dom.hasElClass(this.el_, classToCheck);
  3495. };
  3496. /**
  3497. * Add a CSS class name to the component's element
  3498. *
  3499. * @param {String} classToAdd Classname to add
  3500. * @return {Component}
  3501. * @method addClass
  3502. */
  3503. Component.prototype.addClass = function addClass(classToAdd) {
  3504. Dom.addElClass(this.el_, classToAdd);
  3505. return this;
  3506. };
  3507. /**
  3508. * Remove a CSS class name from the component's element
  3509. *
  3510. * @param {String} classToRemove Classname to remove
  3511. * @return {Component}
  3512. * @method removeClass
  3513. */
  3514. Component.prototype.removeClass = function removeClass(classToRemove) {
  3515. Dom.removeElClass(this.el_, classToRemove);
  3516. return this;
  3517. };
  3518. /**
  3519. * Add or remove a CSS class name from the component's element
  3520. *
  3521. * @param {String} classToToggle
  3522. * @param {Boolean|Function} [predicate]
  3523. * Can be a function that returns a Boolean. If `true`, the class
  3524. * will be added; if `false`, the class will be removed. If not
  3525. * given, the class will be added if not present and vice versa.
  3526. *
  3527. * @return {Component}
  3528. * @method toggleClass
  3529. */
  3530. Component.prototype.toggleClass = function toggleClass(classToToggle, predicate) {
  3531. Dom.toggleElClass(this.el_, classToToggle, predicate);
  3532. return this;
  3533. };
  3534. /**
  3535. * Show the component element if hidden
  3536. *
  3537. * @return {Component}
  3538. * @method show
  3539. */
  3540. Component.prototype.show = function show() {
  3541. this.removeClass('vjs-hidden');
  3542. return this;
  3543. };
  3544. /**
  3545. * Hide the component element if currently showing
  3546. *
  3547. * @return {Component}
  3548. * @method hide
  3549. */
  3550. Component.prototype.hide = function hide() {
  3551. this.addClass('vjs-hidden');
  3552. return this;
  3553. };
  3554. /**
  3555. * Lock an item in its visible state
  3556. * To be used with fadeIn/fadeOut.
  3557. *
  3558. * @return {Component}
  3559. * @private
  3560. * @method lockShowing
  3561. */
  3562. Component.prototype.lockShowing = function lockShowing() {
  3563. this.addClass('vjs-lock-showing');
  3564. return this;
  3565. };
  3566. /**
  3567. * Unlock an item to be hidden
  3568. * To be used with fadeIn/fadeOut.
  3569. *
  3570. * @return {Component}
  3571. * @private
  3572. * @method unlockShowing
  3573. */
  3574. Component.prototype.unlockShowing = function unlockShowing() {
  3575. this.removeClass('vjs-lock-showing');
  3576. return this;
  3577. };
  3578. /**
  3579. * Set or get the width of the component (CSS values)
  3580. * Setting the video tag dimension values only works with values in pixels.
  3581. * Percent values will not work.
  3582. * Some percents can be used, but width()/height() will return the number + %,
  3583. * not the actual computed width/height.
  3584. *
  3585. * @param {Number|String=} num Optional width number
  3586. * @param {Boolean} skipListeners Skip the 'resize' event trigger
  3587. * @return {Component} This component, when setting the width
  3588. * @return {Number|String} The width, when getting
  3589. * @method width
  3590. */
  3591. Component.prototype.width = function width(num, skipListeners) {
  3592. return this.dimension('width', num, skipListeners);
  3593. };
  3594. /**
  3595. * Get or set the height of the component (CSS values)
  3596. * Setting the video tag dimension values only works with values in pixels.
  3597. * Percent values will not work.
  3598. * Some percents can be used, but width()/height() will return the number + %,
  3599. * not the actual computed width/height.
  3600. *
  3601. * @param {Number|String=} num New component height
  3602. * @param {Boolean=} skipListeners Skip the resize event trigger
  3603. * @return {Component} This component, when setting the height
  3604. * @return {Number|String} The height, when getting
  3605. * @method height
  3606. */
  3607. Component.prototype.height = function height(num, skipListeners) {
  3608. return this.dimension('height', num, skipListeners);
  3609. };
  3610. /**
  3611. * Set both width and height at the same time
  3612. *
  3613. * @param {Number|String} width Width of player
  3614. * @param {Number|String} height Height of player
  3615. * @return {Component} The component
  3616. * @method dimensions
  3617. */
  3618. Component.prototype.dimensions = function dimensions(width, height) {
  3619. // Skip resize listeners on width for optimization
  3620. return this.width(width, true).height(height);
  3621. };
  3622. /**
  3623. * Get or set width or height
  3624. * This is the shared code for the width() and height() methods.
  3625. * All for an integer, integer + 'px' or integer + '%';
  3626. * Known issue: Hidden elements officially have a width of 0. We're defaulting
  3627. * to the style.width value and falling back to computedStyle which has the
  3628. * hidden element issue. Info, but probably not an efficient fix:
  3629. * http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/
  3630. *
  3631. * @param {String} widthOrHeight 'width' or 'height'
  3632. * @param {Number|String=} num New dimension
  3633. * @param {Boolean=} skipListeners Skip resize event trigger
  3634. * @return {Component} The component if a dimension was set
  3635. * @return {Number|String} The dimension if nothing was set
  3636. * @private
  3637. * @method dimension
  3638. */
  3639. Component.prototype.dimension = function dimension(widthOrHeight, num, skipListeners) {
  3640. if (num !== undefined) {
  3641. // Set to zero if null or literally NaN (NaN !== NaN)
  3642. if (num === null || num !== num) {
  3643. num = 0;
  3644. }
  3645. // Check if using css width/height (% or px) and adjust
  3646. if (('' + num).indexOf('%') !== -1 || ('' + num).indexOf('px') !== -1) {
  3647. this.el_.style[widthOrHeight] = num;
  3648. } else if (num === 'auto') {
  3649. this.el_.style[widthOrHeight] = '';
  3650. } else {
  3651. this.el_.style[widthOrHeight] = num + 'px';
  3652. }
  3653. // skipListeners allows us to avoid triggering the resize event when setting both width and height
  3654. if (!skipListeners) {
  3655. this.trigger('resize');
  3656. }
  3657. // Return component
  3658. return this;
  3659. }
  3660. // Not setting a value, so getting it
  3661. // Make sure element exists
  3662. if (!this.el_) {
  3663. return 0;
  3664. }
  3665. // Get dimension value from style
  3666. var val = this.el_.style[widthOrHeight];
  3667. var pxIndex = val.indexOf('px');
  3668. if (pxIndex !== -1) {
  3669. // Return the pixel value with no 'px'
  3670. return parseInt(val.slice(0, pxIndex), 10);
  3671. }
  3672. // No px so using % or no style was set, so falling back to offsetWidth/height
  3673. // If component has display:none, offset will return 0
  3674. // TODO: handle display:none and no dimension style using px
  3675. return parseInt(this.el_['offset' + _utilsToTitleCaseJs2['default'](widthOrHeight)], 10);
  3676. };
  3677. /**
  3678. * Get width or height of computed style
  3679. * @param {String} widthOrHeight 'width' or 'height'
  3680. * @return {Number|Boolean} The bolean false if nothing was set
  3681. * @method currentDimension
  3682. */
  3683. Component.prototype.currentDimension = function currentDimension(widthOrHeight) {
  3684. var computedWidthOrHeight = 0;
  3685. if (widthOrHeight !== 'width' && widthOrHeight !== 'height') {
  3686. throw new Error('currentDimension only accepts width or height value');
  3687. }
  3688. if (typeof _globalWindow2['default'].getComputedStyle === 'function') {
  3689. var computedStyle = _globalWindow2['default'].getComputedStyle(this.el_);
  3690. computedWidthOrHeight = computedStyle.getPropertyValue(widthOrHeight) || computedStyle[widthOrHeight];
  3691. } else if (this.el_.currentStyle) {
  3692. // ie 8 doesn't support computed style, shim it
  3693. // return clientWidth or clientHeight instead for better accuracy
  3694. var rule = 'offset' + _utilsToTitleCaseJs2['default'](widthOrHeight);
  3695. computedWidthOrHeight = this.el_[rule];
  3696. }
  3697. // remove 'px' from variable and parse as integer
  3698. computedWidthOrHeight = parseFloat(computedWidthOrHeight);
  3699. return computedWidthOrHeight;
  3700. };
  3701. /**
  3702. * Get an object which contains width and height values of computed style
  3703. * @return {Object} The dimensions of element
  3704. * @method currentDimensions
  3705. */
  3706. Component.prototype.currentDimensions = function currentDimensions() {
  3707. return {
  3708. width: this.currentDimension('width'),
  3709. height: this.currentDimension('height')
  3710. };
  3711. };
  3712. /**
  3713. * Get width of computed style
  3714. * @return {Integer}
  3715. * @method currentWidth
  3716. */
  3717. Component.prototype.currentWidth = function currentWidth() {
  3718. return this.currentDimension('width');
  3719. };
  3720. /**
  3721. * Get height of computed style
  3722. * @return {Integer}
  3723. * @method currentHeight
  3724. */
  3725. Component.prototype.currentHeight = function currentHeight() {
  3726. return this.currentDimension('height');
  3727. };
  3728. /**
  3729. * Emit 'tap' events when touch events are supported
  3730. * This is used to support toggling the controls through a tap on the video.
  3731. * We're requiring them to be enabled because otherwise every component would
  3732. * have this extra overhead unnecessarily, on mobile devices where extra
  3733. * overhead is especially bad.
  3734. *
  3735. * @private
  3736. * @method emitTapEvents
  3737. */
  3738. Component.prototype.emitTapEvents = function emitTapEvents() {
  3739. // Track the start time so we can determine how long the touch lasted
  3740. var touchStart = 0;
  3741. var firstTouch = null;
  3742. // Maximum movement allowed during a touch event to still be considered a tap
  3743. // Other popular libs use anywhere from 2 (hammer.js) to 15, so 10 seems like a nice, round number.
  3744. var tapMovementThreshold = 10;
  3745. // The maximum length a touch can be while still being considered a tap
  3746. var touchTimeThreshold = 200;
  3747. var couldBeTap = undefined;
  3748. this.on('touchstart', function (event) {
  3749. // If more than one finger, don't consider treating this as a click
  3750. if (event.touches.length === 1) {
  3751. // Copy the touches object to prevent modifying the original
  3752. firstTouch = _objectAssign2['default']({}, event.touches[0]);
  3753. // Record start time so we can detect a tap vs. "touch and hold"
  3754. touchStart = new Date().getTime();
  3755. // Reset couldBeTap tracking
  3756. couldBeTap = true;
  3757. }
  3758. });
  3759. this.on('touchmove', function (event) {
  3760. // If more than one finger, don't consider treating this as a click
  3761. if (event.touches.length > 1) {
  3762. couldBeTap = false;
  3763. } else if (firstTouch) {
  3764. // Some devices will throw touchmoves for all but the slightest of taps.
  3765. // So, if we moved only a small distance, this could still be a tap
  3766. var xdiff = event.touches[0].pageX - firstTouch.pageX;
  3767. var ydiff = event.touches[0].pageY - firstTouch.pageY;
  3768. var touchDistance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);
  3769. if (touchDistance > tapMovementThreshold) {
  3770. couldBeTap = false;
  3771. }
  3772. }
  3773. });
  3774. var noTap = function noTap() {
  3775. couldBeTap = false;
  3776. };
  3777. // TODO: Listen to the original target. http://youtu.be/DujfpXOKUp8?t=13m8s
  3778. this.on('touchleave', noTap);
  3779. this.on('touchcancel', noTap);
  3780. // When the touch ends, measure how long it took and trigger the appropriate
  3781. // event
  3782. this.on('touchend', function (event) {
  3783. firstTouch = null;
  3784. // Proceed only if the touchmove/leave/cancel event didn't happen
  3785. if (couldBeTap === true) {
  3786. // Measure how long the touch lasted
  3787. var touchTime = new Date().getTime() - touchStart;
  3788. // Make sure the touch was less than the threshold to be considered a tap
  3789. if (touchTime < touchTimeThreshold) {
  3790. // Don't let browser turn this into a click
  3791. event.preventDefault();
  3792. this.trigger('tap');
  3793. // It may be good to copy the touchend event object and change the
  3794. // type to tap, if the other event properties aren't exact after
  3795. // Events.fixEvent runs (e.g. event.target)
  3796. }
  3797. }
  3798. });
  3799. };
  3800. /**
  3801. * Report user touch activity when touch events occur
  3802. * User activity is used to determine when controls should show/hide. It's
  3803. * relatively simple when it comes to mouse events, because any mouse event
  3804. * should show the controls. So we capture mouse events that bubble up to the
  3805. * player and report activity when that happens.
  3806. * With touch events it isn't as easy. We can't rely on touch events at the
  3807. * player level, because a tap (touchstart + touchend) on the video itself on
  3808. * mobile devices is meant to turn controls off (and on). User activity is
  3809. * checked asynchronously, so what could happen is a tap event on the video
  3810. * turns the controls off, then the touchend event bubbles up to the player,
  3811. * which if it reported user activity, would turn the controls right back on.
  3812. * (We also don't want to completely block touch events from bubbling up)
  3813. * Also a touchmove, touch+hold, and anything other than a tap is not supposed
  3814. * to turn the controls back on on a mobile device.
  3815. * Here we're setting the default component behavior to report user activity
  3816. * whenever touch events happen, and this can be turned off by components that
  3817. * want touch events to act differently.
  3818. *
  3819. * @method enableTouchActivity
  3820. */
  3821. Component.prototype.enableTouchActivity = function enableTouchActivity() {
  3822. // Don't continue if the root player doesn't support reporting user activity
  3823. if (!this.player() || !this.player().reportUserActivity) {
  3824. return;
  3825. }
  3826. // listener for reporting that the user is active
  3827. var report = Fn.bind(this.player(), this.player().reportUserActivity);
  3828. var touchHolding = undefined;
  3829. this.on('touchstart', function () {
  3830. report();
  3831. // For as long as the they are touching the device or have their mouse down,
  3832. // we consider them active even if they're not moving their finger or mouse.
  3833. // So we want to continue to update that they are active
  3834. this.clearInterval(touchHolding);
  3835. // report at the same interval as activityCheck
  3836. touchHolding = this.setInterval(report, 250);
  3837. });
  3838. var touchEnd = function touchEnd(event) {
  3839. report();
  3840. // stop the interval that maintains activity if the touch is holding
  3841. this.clearInterval(touchHolding);
  3842. };
  3843. this.on('touchmove', report);
  3844. this.on('touchend', touchEnd);
  3845. this.on('touchcancel', touchEnd);
  3846. };
  3847. /**
  3848. * Creates timeout and sets up disposal automatically.
  3849. *
  3850. * @param {Function} fn The function to run after the timeout.
  3851. * @param {Number} timeout Number of ms to delay before executing specified function.
  3852. * @return {Number} Returns the timeout ID
  3853. * @method setTimeout
  3854. */
  3855. Component.prototype.setTimeout = function setTimeout(fn, timeout) {
  3856. fn = Fn.bind(this, fn);
  3857. // window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't.
  3858. var timeoutId = _globalWindow2['default'].setTimeout(fn, timeout);
  3859. var disposeFn = function disposeFn() {
  3860. this.clearTimeout(timeoutId);
  3861. };
  3862. disposeFn.guid = 'vjs-timeout-' + timeoutId;
  3863. this.on('dispose', disposeFn);
  3864. return timeoutId;
  3865. };
  3866. /**
  3867. * Clears a timeout and removes the associated dispose listener
  3868. *
  3869. * @param {Number} timeoutId The id of the timeout to clear
  3870. * @return {Number} Returns the timeout ID
  3871. * @method clearTimeout
  3872. */
  3873. Component.prototype.clearTimeout = function clearTimeout(timeoutId) {
  3874. _globalWindow2['default'].clearTimeout(timeoutId);
  3875. var disposeFn = function disposeFn() { };
  3876. disposeFn.guid = 'vjs-timeout-' + timeoutId;
  3877. this.off('dispose', disposeFn);
  3878. return timeoutId;
  3879. };
  3880. /**
  3881. * Creates an interval and sets up disposal automatically.
  3882. *
  3883. * @param {Function} fn The function to run every N seconds.
  3884. * @param {Number} interval Number of ms to delay before executing specified function.
  3885. * @return {Number} Returns the interval ID
  3886. * @method setInterval
  3887. */
  3888. Component.prototype.setInterval = function setInterval(fn, interval) {
  3889. fn = Fn.bind(this, fn);
  3890. var intervalId = _globalWindow2['default'].setInterval(fn, interval);
  3891. var disposeFn = function disposeFn() {
  3892. this.clearInterval(intervalId);
  3893. };
  3894. disposeFn.guid = 'vjs-interval-' + intervalId;
  3895. this.on('dispose', disposeFn);
  3896. return intervalId;
  3897. };
  3898. /**
  3899. * Clears an interval and removes the associated dispose listener
  3900. *
  3901. * @param {Number} intervalId The id of the interval to clear
  3902. * @return {Number} Returns the interval ID
  3903. * @method clearInterval
  3904. */
  3905. Component.prototype.clearInterval = function clearInterval(intervalId) {
  3906. _globalWindow2['default'].clearInterval(intervalId);
  3907. var disposeFn = function disposeFn() { };
  3908. disposeFn.guid = 'vjs-interval-' + intervalId;
  3909. this.off('dispose', disposeFn);
  3910. return intervalId;
  3911. };
  3912. /**
  3913. * Registers a component
  3914. *
  3915. * @param {String} name Name of the component to register
  3916. * @param {Object} comp The component to register
  3917. * @static
  3918. * @method registerComponent
  3919. */
  3920. Component.registerComponent = function registerComponent(name, comp) {
  3921. if (!Component.components_) {
  3922. Component.components_ = {};
  3923. }
  3924. Component.components_[name] = comp;
  3925. return comp;
  3926. };
  3927. /**
  3928. * Gets a component by name
  3929. *
  3930. * @param {String} name Name of the component to get
  3931. * @return {Component}
  3932. * @static
  3933. * @method getComponent
  3934. */
  3935. Component.getComponent = function getComponent(name) {
  3936. if (Component.components_ && Component.components_[name]) {
  3937. return Component.components_[name];
  3938. }
  3939. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  3940. _utilsLogJs2['default'].warn('The ' + name + ' component was added to the videojs object when it should be registered using videojs.registerComponent(name, component)');
  3941. return _globalWindow2['default'].videojs[name];
  3942. }
  3943. };
  3944. /**
  3945. * Sets up the constructor using the supplied init method
  3946. * or uses the init of the parent object
  3947. *
  3948. * @param {Object} props An object of properties
  3949. * @static
  3950. * @deprecated
  3951. * @method extend
  3952. */
  3953. Component.extend = function extend(props) {
  3954. props = props || {};
  3955. _utilsLogJs2['default'].warn('Component.extend({}) has been deprecated, use videojs.extend(Component, {}) instead');
  3956. // Set up the constructor using the supplied init method
  3957. // or using the init of the parent object
  3958. // Make sure to check the unobfuscated version for external libs
  3959. var init = props.init || props.init || this.prototype.init || this.prototype.init || function () { };
  3960. // In Resig's simple class inheritance (previously used) the constructor
  3961. // is a function that calls `this.init.apply(arguments)`
  3962. // However that would prevent us from using `ParentObject.call(this);`
  3963. // in a Child constructor because the `this` in `this.init`
  3964. // would still refer to the Child and cause an infinite loop.
  3965. // We would instead have to do
  3966. // `ParentObject.prototype.init.apply(this, arguments);`
  3967. // Bleh. We're not creating a _super() function, so it's good to keep
  3968. // the parent constructor reference simple.
  3969. var subObj = function subObj() {
  3970. init.apply(this, arguments);
  3971. };
  3972. // Inherit from this object's prototype
  3973. subObj.prototype = Object.create(this.prototype);
  3974. // Reset the constructor property for subObj otherwise
  3975. // instances of subObj would have the constructor of the parent Object
  3976. subObj.prototype.constructor = subObj;
  3977. // Make the class extendable
  3978. subObj.extend = Component.extend;
  3979. // Extend subObj's prototype with functions and other properties from props
  3980. for (var _name in props) {
  3981. if (props.hasOwnProperty(_name)) {
  3982. subObj.prototype[_name] = props[_name];
  3983. }
  3984. }
  3985. return subObj;
  3986. };
  3987. return Component;
  3988. })();
  3989. Component.registerComponent('Component', Component);
  3990. exports['default'] = Component;
  3991. module.exports = exports['default'];
  3992. }, { "./utils/dom.js": 143, "./utils/events.js": 144, "./utils/fn.js": 145, "./utils/guid.js": 147, "./utils/log.js": 148, "./utils/merge-options.js": 149, "./utils/to-title-case.js": 152, "global/window": 2, "object.assign": 45 }], 68: [function (_dereq_, module, exports) {
  3993. /**
  3994. * @file audio-track-button.js
  3995. */
  3996. 'use strict';
  3997. exports.__esModule = true;
  3998. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  3999. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4000. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4001. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4002. var _trackButtonJs = _dereq_('../track-button.js');
  4003. var _trackButtonJs2 = _interopRequireDefault(_trackButtonJs);
  4004. var _componentJs = _dereq_('../../component.js');
  4005. var _componentJs2 = _interopRequireDefault(_componentJs);
  4006. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4007. var Fn = _interopRequireWildcard(_utilsFnJs);
  4008. var _audioTrackMenuItemJs = _dereq_('./audio-track-menu-item.js');
  4009. var _audioTrackMenuItemJs2 = _interopRequireDefault(_audioTrackMenuItemJs);
  4010. /**
  4011. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  4012. *
  4013. * @param {Player|Object} player
  4014. * @param {Object=} options
  4015. * @extends TrackButton
  4016. * @class AudioTrackButton
  4017. */
  4018. var AudioTrackButton = (function (_TrackButton) {
  4019. _inherits(AudioTrackButton, _TrackButton);
  4020. function AudioTrackButton(player) {
  4021. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  4022. _classCallCheck(this, AudioTrackButton);
  4023. options.tracks = player.audioTracks && player.audioTracks();
  4024. _TrackButton.call(this, player, options);
  4025. this.el_.setAttribute('aria-label', 'Audio Menu');
  4026. }
  4027. /**
  4028. * Allow sub components to stack CSS class names
  4029. *
  4030. * @return {String} The constructed class name
  4031. * @method buildCSSClass
  4032. */
  4033. AudioTrackButton.prototype.buildCSSClass = function buildCSSClass() {
  4034. return 'vjs-audio-button ' + _TrackButton.prototype.buildCSSClass.call(this);
  4035. };
  4036. /**
  4037. * Create a menu item for each audio track
  4038. *
  4039. * @return {Array} Array of menu items
  4040. * @method createItems
  4041. */
  4042. AudioTrackButton.prototype.createItems = function createItems() {
  4043. var items = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  4044. var tracks = this.player_.audioTracks && this.player_.audioTracks();
  4045. if (!tracks) {
  4046. return items;
  4047. }
  4048. for (var i = 0; i < tracks.length; i++) {
  4049. var track = tracks[i];
  4050. items.push(new _audioTrackMenuItemJs2['default'](this.player_, {
  4051. // MenuItem is selectable
  4052. 'selectable': true,
  4053. 'track': track
  4054. }));
  4055. }
  4056. return items;
  4057. };
  4058. return AudioTrackButton;
  4059. })(_trackButtonJs2['default']);
  4060. _componentJs2['default'].registerComponent('AudioTrackButton', AudioTrackButton);
  4061. exports['default'] = AudioTrackButton;
  4062. module.exports = exports['default'];
  4063. }, { "../../component.js": 67, "../../utils/fn.js": 145, "../track-button.js": 98, "./audio-track-menu-item.js": 69 }], 69: [function (_dereq_, module, exports) {
  4064. /**
  4065. * @file audio-track-menu-item.js
  4066. */
  4067. 'use strict';
  4068. exports.__esModule = true;
  4069. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  4070. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4071. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4072. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4073. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  4074. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  4075. var _componentJs = _dereq_('../../component.js');
  4076. var _componentJs2 = _interopRequireDefault(_componentJs);
  4077. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4078. var Fn = _interopRequireWildcard(_utilsFnJs);
  4079. /**
  4080. * The audio track menu item
  4081. *
  4082. * @param {Player|Object} player
  4083. * @param {Object=} options
  4084. * @extends MenuItem
  4085. * @class AudioTrackMenuItem
  4086. */
  4087. var AudioTrackMenuItem = (function (_MenuItem) {
  4088. _inherits(AudioTrackMenuItem, _MenuItem);
  4089. function AudioTrackMenuItem(player, options) {
  4090. var _this = this;
  4091. _classCallCheck(this, AudioTrackMenuItem);
  4092. var track = options.track;
  4093. var tracks = player.audioTracks();
  4094. // Modify options for parent MenuItem class's init.
  4095. options.label = track.label || track.language || 'Unknown';
  4096. options.selected = track.enabled;
  4097. _MenuItem.call(this, player, options);
  4098. this.track = track;
  4099. if (tracks) {
  4100. (function () {
  4101. var changeHandler = Fn.bind(_this, _this.handleTracksChange);
  4102. tracks.addEventListener('change', changeHandler);
  4103. _this.on('dispose', function () {
  4104. tracks.removeEventListener('change', changeHandler);
  4105. });
  4106. })();
  4107. }
  4108. }
  4109. /**
  4110. * Handle click on audio track
  4111. *
  4112. * @method handleClick
  4113. */
  4114. AudioTrackMenuItem.prototype.handleClick = function handleClick(event) {
  4115. var tracks = this.player_.audioTracks();
  4116. _MenuItem.prototype.handleClick.call(this, event);
  4117. if (!tracks) return;
  4118. for (var i = 0; i < tracks.length; i++) {
  4119. var track = tracks[i];
  4120. if (track === this.track) {
  4121. track.enabled = true;
  4122. }
  4123. }
  4124. };
  4125. /**
  4126. * Handle audio track change
  4127. *
  4128. * @method handleTracksChange
  4129. */
  4130. AudioTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  4131. this.selected(this.track.enabled);
  4132. };
  4133. return AudioTrackMenuItem;
  4134. })(_menuMenuItemJs2['default']);
  4135. _componentJs2['default'].registerComponent('AudioTrackMenuItem', AudioTrackMenuItem);
  4136. exports['default'] = AudioTrackMenuItem;
  4137. module.exports = exports['default'];
  4138. }, { "../../component.js": 67, "../../menu/menu-item.js": 110, "../../utils/fn.js": 145 }], 70: [function (_dereq_, module, exports) {
  4139. /**
  4140. * @file control-bar.js
  4141. */
  4142. 'use strict';
  4143. exports.__esModule = true;
  4144. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4145. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4146. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4147. var _componentJs = _dereq_('../component.js');
  4148. var _componentJs2 = _interopRequireDefault(_componentJs);
  4149. // Required children
  4150. var _playToggleJs = _dereq_('./play-toggle.js');
  4151. var _playToggleJs2 = _interopRequireDefault(_playToggleJs);
  4152. var _timeControlsCurrentTimeDisplayJs = _dereq_('./time-controls/current-time-display.js');
  4153. var _timeControlsCurrentTimeDisplayJs2 = _interopRequireDefault(_timeControlsCurrentTimeDisplayJs);
  4154. var _timeControlsDurationDisplayJs = _dereq_('./time-controls/duration-display.js');
  4155. var _timeControlsDurationDisplayJs2 = _interopRequireDefault(_timeControlsDurationDisplayJs);
  4156. var _timeControlsTimeDividerJs = _dereq_('./time-controls/time-divider.js');
  4157. var _timeControlsTimeDividerJs2 = _interopRequireDefault(_timeControlsTimeDividerJs);
  4158. var _timeControlsRemainingTimeDisplayJs = _dereq_('./time-controls/remaining-time-display.js');
  4159. var _timeControlsRemainingTimeDisplayJs2 = _interopRequireDefault(_timeControlsRemainingTimeDisplayJs);
  4160. var _liveDisplayJs = _dereq_('./live-display.js');
  4161. var _liveDisplayJs2 = _interopRequireDefault(_liveDisplayJs);
  4162. var _progressControlProgressControlJs = _dereq_('./progress-control/progress-control.js');
  4163. var _progressControlProgressControlJs2 = _interopRequireDefault(_progressControlProgressControlJs);
  4164. var _fullscreenToggleJs = _dereq_('./fullscreen-toggle.js');
  4165. var _fullscreenToggleJs2 = _interopRequireDefault(_fullscreenToggleJs);
  4166. var _volumeControlVolumeControlJs = _dereq_('./volume-control/volume-control.js');
  4167. var _volumeControlVolumeControlJs2 = _interopRequireDefault(_volumeControlVolumeControlJs);
  4168. var _volumeMenuButtonJs = _dereq_('./volume-menu-button.js');
  4169. var _volumeMenuButtonJs2 = _interopRequireDefault(_volumeMenuButtonJs);
  4170. var _muteToggleJs = _dereq_('./mute-toggle.js');
  4171. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs);
  4172. var _textTrackControlsChaptersButtonJs = _dereq_('./text-track-controls/chapters-button.js');
  4173. var _textTrackControlsChaptersButtonJs2 = _interopRequireDefault(_textTrackControlsChaptersButtonJs);
  4174. var _textTrackControlsDescriptionsButtonJs = _dereq_('./text-track-controls/descriptions-button.js');
  4175. var _textTrackControlsDescriptionsButtonJs2 = _interopRequireDefault(_textTrackControlsDescriptionsButtonJs);
  4176. var _textTrackControlsSubtitlesButtonJs = _dereq_('./text-track-controls/subtitles-button.js');
  4177. var _textTrackControlsSubtitlesButtonJs2 = _interopRequireDefault(_textTrackControlsSubtitlesButtonJs);
  4178. var _textTrackControlsCaptionsButtonJs = _dereq_('./text-track-controls/captions-button.js');
  4179. var _textTrackControlsCaptionsButtonJs2 = _interopRequireDefault(_textTrackControlsCaptionsButtonJs);
  4180. var _audioTrackControlsAudioTrackButtonJs = _dereq_('./audio-track-controls/audio-track-button.js');
  4181. var _audioTrackControlsAudioTrackButtonJs2 = _interopRequireDefault(_audioTrackControlsAudioTrackButtonJs);
  4182. var _playbackRateMenuPlaybackRateMenuButtonJs = _dereq_('./playback-rate-menu/playback-rate-menu-button.js');
  4183. var _playbackRateMenuPlaybackRateMenuButtonJs2 = _interopRequireDefault(_playbackRateMenuPlaybackRateMenuButtonJs);
  4184. var _spacerControlsCustomControlSpacerJs = _dereq_('./spacer-controls/custom-control-spacer.js');
  4185. var _spacerControlsCustomControlSpacerJs2 = _interopRequireDefault(_spacerControlsCustomControlSpacerJs);
  4186. /**
  4187. * Container of main controls
  4188. *
  4189. * @extends Component
  4190. * @class ControlBar
  4191. */
  4192. var ControlBar = (function (_Component) {
  4193. _inherits(ControlBar, _Component);
  4194. function ControlBar() {
  4195. _classCallCheck(this, ControlBar);
  4196. _Component.apply(this, arguments);
  4197. }
  4198. /**
  4199. * Create the component's DOM element
  4200. *
  4201. * @return {Element}
  4202. * @method createEl
  4203. */
  4204. ControlBar.prototype.createEl = function createEl() {
  4205. return _Component.prototype.createEl.call(this, 'div', {
  4206. className: 'vjs-control-bar',
  4207. dir: 'ltr'
  4208. }, {
  4209. 'role': 'group' // The control bar is a group, so it can contain menuitems
  4210. });
  4211. };
  4212. return ControlBar;
  4213. })(_componentJs2['default']);
  4214. ControlBar.prototype.options_ = {
  4215. loadEvent: 'play',
  4216. children: ['playToggle', 'volumeMenuButton', 'currentTimeDisplay', 'timeDivider', 'durationDisplay', 'progressControl', 'liveDisplay', 'remainingTimeDisplay', 'customControlSpacer', 'playbackRateMenuButton', 'chaptersButton', 'descriptionsButton', 'subtitlesButton', 'captionsButton', 'audioTrackButton', 'fullscreenToggle']
  4217. };
  4218. _componentJs2['default'].registerComponent('ControlBar', ControlBar);
  4219. exports['default'] = ControlBar;
  4220. module.exports = exports['default'];
  4221. }, { "../component.js": 67, "./audio-track-controls/audio-track-button.js": 68, "./fullscreen-toggle.js": 71, "./live-display.js": 72, "./mute-toggle.js": 73, "./play-toggle.js": 74, "./playback-rate-menu/playback-rate-menu-button.js": 75, "./progress-control/progress-control.js": 80, "./spacer-controls/custom-control-spacer.js": 83, "./text-track-controls/captions-button.js": 86, "./text-track-controls/chapters-button.js": 87, "./text-track-controls/descriptions-button.js": 89, "./text-track-controls/subtitles-button.js": 91, "./time-controls/current-time-display.js": 94, "./time-controls/duration-display.js": 95, "./time-controls/remaining-time-display.js": 96, "./time-controls/time-divider.js": 97, "./volume-control/volume-control.js": 100, "./volume-menu-button.js": 102 }], 71: [function (_dereq_, module, exports) {
  4222. /**
  4223. * @file fullscreen-toggle.js
  4224. */
  4225. 'use strict';
  4226. exports.__esModule = true;
  4227. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4228. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4229. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4230. var _buttonJs = _dereq_('../button.js');
  4231. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  4232. var _componentJs = _dereq_('../component.js');
  4233. var _componentJs2 = _interopRequireDefault(_componentJs);
  4234. /**
  4235. * Toggle fullscreen video
  4236. *
  4237. * @extends Button
  4238. * @class FullscreenToggle
  4239. */
  4240. var FullscreenToggle = (function (_Button) {
  4241. _inherits(FullscreenToggle, _Button);
  4242. function FullscreenToggle() {
  4243. _classCallCheck(this, FullscreenToggle);
  4244. _Button.apply(this, arguments);
  4245. }
  4246. /**
  4247. * Allow sub components to stack CSS class names
  4248. *
  4249. * @return {String} The constructed class name
  4250. * @method buildCSSClass
  4251. */
  4252. FullscreenToggle.prototype.buildCSSClass = function buildCSSClass() {
  4253. return 'vjs-fullscreen-control ' + _Button.prototype.buildCSSClass.call(this);
  4254. };
  4255. /**
  4256. * Handles click for full screen
  4257. *
  4258. * @method handleClick
  4259. */
  4260. FullscreenToggle.prototype.handleClick = function handleClick() {
  4261. if (!this.player_.isFullscreen()) {
  4262. this.player_.requestFullscreen();
  4263. this.controlText('Non-Fullscreen');
  4264. } else {
  4265. this.player_.exitFullscreen();
  4266. this.controlText('Fullscreen');
  4267. }
  4268. };
  4269. return FullscreenToggle;
  4270. })(_buttonJs2['default']);
  4271. FullscreenToggle.prototype.controlText_ = 'Fullscreen';
  4272. _componentJs2['default'].registerComponent('FullscreenToggle', FullscreenToggle);
  4273. exports['default'] = FullscreenToggle;
  4274. module.exports = exports['default'];
  4275. }, { "../button.js": 64, "../component.js": 67 }], 72: [function (_dereq_, module, exports) {
  4276. /**
  4277. * @file live-display.js
  4278. */
  4279. 'use strict';
  4280. exports.__esModule = true;
  4281. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  4282. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4283. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4284. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4285. var _component = _dereq_('../component');
  4286. var _component2 = _interopRequireDefault(_component);
  4287. var _utilsDomJs = _dereq_('../utils/dom.js');
  4288. var Dom = _interopRequireWildcard(_utilsDomJs);
  4289. /**
  4290. * Displays the live indicator
  4291. * TODO - Future make it click to snap to live
  4292. *
  4293. * @extends Component
  4294. * @class LiveDisplay
  4295. */
  4296. var LiveDisplay = (function (_Component) {
  4297. _inherits(LiveDisplay, _Component);
  4298. function LiveDisplay(player, options) {
  4299. _classCallCheck(this, LiveDisplay);
  4300. _Component.call(this, player, options);
  4301. this.updateShowing();
  4302. this.on(this.player(), 'durationchange', this.updateShowing);
  4303. }
  4304. /**
  4305. * Create the component's DOM element
  4306. *
  4307. * @return {Element}
  4308. * @method createEl
  4309. */
  4310. LiveDisplay.prototype.createEl = function createEl() {
  4311. var el = _Component.prototype.createEl.call(this, 'div', {
  4312. className: 'vjs-live-control vjs-control'
  4313. });
  4314. this.contentEl_ = Dom.createEl('div', {
  4315. className: 'vjs-live-display',
  4316. innerHTML: '<span class="vjs-control-text">' + this.localize('Stream Type') + '</span>' + this.localize('直播中')
  4317. }, {
  4318. 'aria-live': 'off'
  4319. });
  4320. el.appendChild(this.contentEl_);
  4321. return el;
  4322. };
  4323. LiveDisplay.prototype.updateShowing = function updateShowing() {
  4324. if (this.player().duration() === Infinity) {
  4325. this.show();
  4326. } else {
  4327. this.hide();
  4328. }
  4329. };
  4330. return LiveDisplay;
  4331. })(_component2['default']);
  4332. _component2['default'].registerComponent('LiveDisplay', LiveDisplay);
  4333. exports['default'] = LiveDisplay;
  4334. module.exports = exports['default'];
  4335. }, { "../component": 67, "../utils/dom.js": 143 }], 73: [function (_dereq_, module, exports) {
  4336. /**
  4337. * @file mute-toggle.js
  4338. */
  4339. 'use strict';
  4340. exports.__esModule = true;
  4341. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  4342. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4343. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4344. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4345. var _button = _dereq_('../button');
  4346. var _button2 = _interopRequireDefault(_button);
  4347. var _component = _dereq_('../component');
  4348. var _component2 = _interopRequireDefault(_component);
  4349. var _utilsDomJs = _dereq_('../utils/dom.js');
  4350. var Dom = _interopRequireWildcard(_utilsDomJs);
  4351. /**
  4352. * A button component for muting the audio
  4353. *
  4354. * @param {Player|Object} player
  4355. * @param {Object=} options
  4356. * @extends Button
  4357. * @class MuteToggle
  4358. */
  4359. var MuteToggle = (function (_Button) {
  4360. _inherits(MuteToggle, _Button);
  4361. function MuteToggle(player, options) {
  4362. _classCallCheck(this, MuteToggle);
  4363. _Button.call(this, player, options);
  4364. this.on(player, 'volumechange', this.update);
  4365. // hide mute toggle if the current tech doesn't support volume control
  4366. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  4367. this.addClass('vjs-hidden');
  4368. }
  4369. this.on(player, 'loadstart', function () {
  4370. this.update(); // We need to update the button to account for a default muted state.
  4371. if (player.tech_['featuresVolumeControl'] === false) {
  4372. this.addClass('vjs-hidden');
  4373. } else {
  4374. this.removeClass('vjs-hidden');
  4375. }
  4376. });
  4377. }
  4378. /**
  4379. * Allow sub components to stack CSS class names
  4380. *
  4381. * @return {String} The constructed class name
  4382. * @method buildCSSClass
  4383. */
  4384. MuteToggle.prototype.buildCSSClass = function buildCSSClass() {
  4385. return 'vjs-mute-control ' + _Button.prototype.buildCSSClass.call(this);
  4386. };
  4387. /**
  4388. * Handle click on mute
  4389. *
  4390. * @method handleClick
  4391. */
  4392. MuteToggle.prototype.handleClick = function handleClick() {
  4393. this.player_.muted(this.player_.muted() ? false : true);
  4394. };
  4395. /**
  4396. * Update volume
  4397. *
  4398. * @method update
  4399. */
  4400. MuteToggle.prototype.update = function update() {
  4401. var vol = this.player_.volume(),
  4402. level = 3;
  4403. if (vol === 0 || this.player_.muted()) {
  4404. level = 0;
  4405. } else if (vol < 0.33) {
  4406. level = 1;
  4407. } else if (vol < 0.67) {
  4408. level = 2;
  4409. }
  4410. // Don't rewrite the button text if the actual text doesn't change.
  4411. // This causes unnecessary and confusing information for screen reader users.
  4412. // This check is needed because this function gets called every time the volume level is changed.
  4413. var toMute = this.player_.muted() ? 'Unmute' : 'Mute';
  4414. if (this.controlText() !== toMute) {
  4415. this.controlText(toMute);
  4416. }
  4417. /* TODO improve muted icon classes */
  4418. for (var i = 0; i < 4; i++) {
  4419. Dom.removeElClass(this.el_, 'vjs-vol-' + i);
  4420. }
  4421. Dom.addElClass(this.el_, 'vjs-vol-' + level);
  4422. };
  4423. return MuteToggle;
  4424. })(_button2['default']);
  4425. MuteToggle.prototype.controlText_ = 'Mute';
  4426. _component2['default'].registerComponent('MuteToggle', MuteToggle);
  4427. exports['default'] = MuteToggle;
  4428. module.exports = exports['default'];
  4429. }, { "../button": 64, "../component": 67, "../utils/dom.js": 143 }], 74: [function (_dereq_, module, exports) {
  4430. /**
  4431. * @file play-toggle.js
  4432. */
  4433. 'use strict';
  4434. exports.__esModule = true;
  4435. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4436. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4437. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4438. var _buttonJs = _dereq_('../button.js');
  4439. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  4440. var _componentJs = _dereq_('../component.js');
  4441. var _componentJs2 = _interopRequireDefault(_componentJs);
  4442. /**
  4443. * Button to toggle between play and pause
  4444. *
  4445. * @param {Player|Object} player
  4446. * @param {Object=} options
  4447. * @extends Button
  4448. * @class PlayToggle
  4449. */
  4450. var PlayToggle = (function (_Button) {
  4451. _inherits(PlayToggle, _Button);
  4452. function PlayToggle(player, options) {
  4453. _classCallCheck(this, PlayToggle);
  4454. _Button.call(this, player, options);
  4455. this.on(player, 'play', this.handlePlay);
  4456. this.on(player, 'pause', this.handlePause);
  4457. }
  4458. /**
  4459. * Allow sub components to stack CSS class names
  4460. *
  4461. * @return {String} The constructed class name
  4462. * @method buildCSSClass
  4463. */
  4464. PlayToggle.prototype.buildCSSClass = function buildCSSClass() {
  4465. return 'vjs-play-control ' + _Button.prototype.buildCSSClass.call(this);
  4466. };
  4467. /**
  4468. * Handle click to toggle between play and pause
  4469. *
  4470. * @method handleClick
  4471. */
  4472. PlayToggle.prototype.handleClick = function handleClick() {
  4473. if (this.player_.paused()) {
  4474. this.player_.play();
  4475. } else {
  4476. this.player_.pause();
  4477. }
  4478. };
  4479. /**
  4480. * Add the vjs-playing class to the element so it can change appearance
  4481. *
  4482. * @method handlePlay
  4483. */
  4484. PlayToggle.prototype.handlePlay = function handlePlay() {
  4485. this.removeClass('vjs-paused');
  4486. this.addClass('vjs-playing');
  4487. this.controlText('Pause'); // change the button text to "Pause"
  4488. };
  4489. /**
  4490. * Add the vjs-paused class to the element so it can change appearance
  4491. *
  4492. * @method handlePause
  4493. */
  4494. PlayToggle.prototype.handlePause = function handlePause() {
  4495. this.removeClass('vjs-playing');
  4496. this.addClass('vjs-paused');
  4497. this.controlText('Play'); // change the button text to "Play"
  4498. };
  4499. return PlayToggle;
  4500. })(_buttonJs2['default']);
  4501. PlayToggle.prototype.controlText_ = 'Play';
  4502. _componentJs2['default'].registerComponent('PlayToggle', PlayToggle);
  4503. exports['default'] = PlayToggle;
  4504. module.exports = exports['default'];
  4505. }, { "../button.js": 64, "../component.js": 67 }], 75: [function (_dereq_, module, exports) {
  4506. /**
  4507. * @file playback-rate-menu-button.js
  4508. */
  4509. 'use strict';
  4510. exports.__esModule = true;
  4511. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  4512. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4513. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4514. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4515. var _menuMenuButtonJs = _dereq_('../../menu/menu-button.js');
  4516. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  4517. var _menuMenuJs = _dereq_('../../menu/menu.js');
  4518. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  4519. var _playbackRateMenuItemJs = _dereq_('./playback-rate-menu-item.js');
  4520. var _playbackRateMenuItemJs2 = _interopRequireDefault(_playbackRateMenuItemJs);
  4521. var _componentJs = _dereq_('../../component.js');
  4522. var _componentJs2 = _interopRequireDefault(_componentJs);
  4523. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4524. var Dom = _interopRequireWildcard(_utilsDomJs);
  4525. /**
  4526. * The component for controlling the playback rate
  4527. *
  4528. * @param {Player|Object} player
  4529. * @param {Object=} options
  4530. * @extends MenuButton
  4531. * @class PlaybackRateMenuButton
  4532. */
  4533. var PlaybackRateMenuButton = (function (_MenuButton) {
  4534. _inherits(PlaybackRateMenuButton, _MenuButton);
  4535. function PlaybackRateMenuButton(player, options) {
  4536. _classCallCheck(this, PlaybackRateMenuButton);
  4537. _MenuButton.call(this, player, options);
  4538. this.updateVisibility();
  4539. this.updateLabel();
  4540. this.on(player, 'loadstart', this.updateVisibility);
  4541. this.on(player, 'ratechange', this.updateLabel);
  4542. }
  4543. /**
  4544. * Create the component's DOM element
  4545. *
  4546. * @return {Element}
  4547. * @method createEl
  4548. */
  4549. PlaybackRateMenuButton.prototype.createEl = function createEl() {
  4550. var el = _MenuButton.prototype.createEl.call(this);
  4551. this.labelEl_ = Dom.createEl('div', {
  4552. className: 'vjs-playback-rate-value',
  4553. innerHTML: 1.0
  4554. });
  4555. el.appendChild(this.labelEl_);
  4556. return el;
  4557. };
  4558. /**
  4559. * Allow sub components to stack CSS class names
  4560. *
  4561. * @return {String} The constructed class name
  4562. * @method buildCSSClass
  4563. */
  4564. PlaybackRateMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  4565. return 'vjs-playback-rate ' + _MenuButton.prototype.buildCSSClass.call(this);
  4566. };
  4567. /**
  4568. * Create the playback rate menu
  4569. *
  4570. * @return {Menu} Menu object populated with items
  4571. * @method createMenu
  4572. */
  4573. PlaybackRateMenuButton.prototype.createMenu = function createMenu() {
  4574. var menu = new _menuMenuJs2['default'](this.player());
  4575. var rates = this.playbackRates();
  4576. if (rates) {
  4577. for (var i = rates.length - 1; i >= 0; i--) {
  4578. menu.addChild(new _playbackRateMenuItemJs2['default'](this.player(), { 'rate': rates[i] + 'x' }));
  4579. }
  4580. }
  4581. return menu;
  4582. };
  4583. /**
  4584. * Updates ARIA accessibility attributes
  4585. *
  4586. * @method updateARIAAttributes
  4587. */
  4588. PlaybackRateMenuButton.prototype.updateARIAAttributes = function updateARIAAttributes() {
  4589. // Current playback rate
  4590. this.el().setAttribute('aria-valuenow', this.player().playbackRate());
  4591. };
  4592. /**
  4593. * Handle menu item click
  4594. *
  4595. * @method handleClick
  4596. */
  4597. PlaybackRateMenuButton.prototype.handleClick = function handleClick() {
  4598. // select next rate option
  4599. var currentRate = this.player().playbackRate();
  4600. var rates = this.playbackRates();
  4601. // this will select first one if the last one currently selected
  4602. var newRate = rates[0];
  4603. for (var i = 0; i < rates.length; i++) {
  4604. if (rates[i] > currentRate) {
  4605. newRate = rates[i];
  4606. break;
  4607. }
  4608. }
  4609. this.player().playbackRate(newRate);
  4610. };
  4611. /**
  4612. * Get possible playback rates
  4613. *
  4614. * @return {Array} Possible playback rates
  4615. * @method playbackRates
  4616. */
  4617. PlaybackRateMenuButton.prototype.playbackRates = function playbackRates() {
  4618. return this.options_['playbackRates'] || this.options_.playerOptions && this.options_.playerOptions['playbackRates'];
  4619. };
  4620. /**
  4621. * Get whether playback rates is supported by the tech
  4622. * and an array of playback rates exists
  4623. *
  4624. * @return {Boolean} Whether changing playback rate is supported
  4625. * @method playbackRateSupported
  4626. */
  4627. PlaybackRateMenuButton.prototype.playbackRateSupported = function playbackRateSupported() {
  4628. return this.player().tech_ && this.player().tech_['featuresPlaybackRate'] && this.playbackRates() && this.playbackRates().length > 0;
  4629. };
  4630. /**
  4631. * Hide playback rate controls when they're no playback rate options to select
  4632. *
  4633. * @method updateVisibility
  4634. */
  4635. PlaybackRateMenuButton.prototype.updateVisibility = function updateVisibility() {
  4636. if (this.playbackRateSupported()) {
  4637. this.removeClass('vjs-hidden');
  4638. } else {
  4639. this.addClass('vjs-hidden');
  4640. }
  4641. };
  4642. /**
  4643. * Update button label when rate changed
  4644. *
  4645. * @method updateLabel
  4646. */
  4647. PlaybackRateMenuButton.prototype.updateLabel = function updateLabel() {
  4648. if (this.playbackRateSupported()) {
  4649. this.labelEl_.innerHTML = this.player().playbackRate() + 'x';
  4650. }
  4651. };
  4652. return PlaybackRateMenuButton;
  4653. })(_menuMenuButtonJs2['default']);
  4654. PlaybackRateMenuButton.prototype.controlText_ = 'Playback Rate';
  4655. _componentJs2['default'].registerComponent('PlaybackRateMenuButton', PlaybackRateMenuButton);
  4656. exports['default'] = PlaybackRateMenuButton;
  4657. module.exports = exports['default'];
  4658. }, { "../../component.js": 67, "../../menu/menu-button.js": 109, "../../menu/menu.js": 111, "../../utils/dom.js": 143, "./playback-rate-menu-item.js": 76 }], 76: [function (_dereq_, module, exports) {
  4659. /**
  4660. * @file playback-rate-menu-item.js
  4661. */
  4662. 'use strict';
  4663. exports.__esModule = true;
  4664. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4665. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4666. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4667. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  4668. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  4669. var _componentJs = _dereq_('../../component.js');
  4670. var _componentJs2 = _interopRequireDefault(_componentJs);
  4671. /**
  4672. * The specific menu item type for selecting a playback rate
  4673. *
  4674. * @param {Player|Object} player
  4675. * @param {Object=} options
  4676. * @extends MenuItem
  4677. * @class PlaybackRateMenuItem
  4678. */
  4679. var PlaybackRateMenuItem = (function (_MenuItem) {
  4680. _inherits(PlaybackRateMenuItem, _MenuItem);
  4681. function PlaybackRateMenuItem(player, options) {
  4682. _classCallCheck(this, PlaybackRateMenuItem);
  4683. var label = options['rate'];
  4684. var rate = parseFloat(label, 10);
  4685. // Modify options for parent MenuItem class's init.
  4686. options['label'] = label;
  4687. options['selected'] = rate === 1;
  4688. _MenuItem.call(this, player, options);
  4689. this.label = label;
  4690. this.rate = rate;
  4691. this.on(player, 'ratechange', this.update);
  4692. }
  4693. /**
  4694. * Handle click on menu item
  4695. *
  4696. * @method handleClick
  4697. */
  4698. PlaybackRateMenuItem.prototype.handleClick = function handleClick() {
  4699. _MenuItem.prototype.handleClick.call(this);
  4700. this.player().playbackRate(this.rate);
  4701. };
  4702. /**
  4703. * Update playback rate with selected rate
  4704. *
  4705. * @method update
  4706. */
  4707. PlaybackRateMenuItem.prototype.update = function update() {
  4708. this.selected(this.player().playbackRate() === this.rate);
  4709. };
  4710. return PlaybackRateMenuItem;
  4711. })(_menuMenuItemJs2['default']);
  4712. PlaybackRateMenuItem.prototype.contentElType = 'button';
  4713. _componentJs2['default'].registerComponent('PlaybackRateMenuItem', PlaybackRateMenuItem);
  4714. exports['default'] = PlaybackRateMenuItem;
  4715. module.exports = exports['default'];
  4716. }, { "../../component.js": 67, "../../menu/menu-item.js": 110 }], 77: [function (_dereq_, module, exports) {
  4717. /**
  4718. * @file load-progress-bar.js
  4719. */
  4720. 'use strict';
  4721. exports.__esModule = true;
  4722. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  4723. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4724. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4725. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4726. var _componentJs = _dereq_('../../component.js');
  4727. var _componentJs2 = _interopRequireDefault(_componentJs);
  4728. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4729. var Dom = _interopRequireWildcard(_utilsDomJs);
  4730. /**
  4731. * Shows load progress
  4732. *
  4733. * @param {Player|Object} player
  4734. * @param {Object=} options
  4735. * @extends Component
  4736. * @class LoadProgressBar
  4737. */
  4738. var LoadProgressBar = (function (_Component) {
  4739. _inherits(LoadProgressBar, _Component);
  4740. function LoadProgressBar(player, options) {
  4741. _classCallCheck(this, LoadProgressBar);
  4742. _Component.call(this, player, options);
  4743. this.on(player, 'progress', this.update);
  4744. }
  4745. /**
  4746. * Create the component's DOM element
  4747. *
  4748. * @return {Element}
  4749. * @method createEl
  4750. */
  4751. LoadProgressBar.prototype.createEl = function createEl() {
  4752. return _Component.prototype.createEl.call(this, 'div', {
  4753. className: 'vjs-load-progress',
  4754. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Loaded') + '</span>: 0%</span>'
  4755. });
  4756. };
  4757. /**
  4758. * Update progress bar
  4759. *
  4760. * @method update
  4761. */
  4762. LoadProgressBar.prototype.update = function update() {
  4763. var buffered = this.player_.buffered();
  4764. var duration = this.player_.duration();
  4765. var bufferedEnd = this.player_.bufferedEnd();
  4766. var children = this.el_.children;
  4767. // get the percent width of a time compared to the total end
  4768. var percentify = function percentify(time, end) {
  4769. var percent = time / end || 0; // no NaN
  4770. return (percent >= 1 ? 1 : percent) * 100 + '%';
  4771. };
  4772. // update the width of the progress bar
  4773. this.el_.style.width = percentify(bufferedEnd, duration);
  4774. // add child elements to represent the individual buffered time ranges
  4775. for (var i = 0; i < buffered.length; i++) {
  4776. var start = buffered.start(i);
  4777. var end = buffered.end(i);
  4778. var part = children[i];
  4779. if (!part) {
  4780. part = this.el_.appendChild(Dom.createEl());
  4781. }
  4782. // set the percent based on the width of the progress bar (bufferedEnd)
  4783. part.style.left = percentify(start, bufferedEnd);
  4784. part.style.width = percentify(end - start, bufferedEnd);
  4785. }
  4786. // remove unused buffered range elements
  4787. for (var i = children.length; i > buffered.length; i--) {
  4788. this.el_.removeChild(children[i - 1]);
  4789. }
  4790. };
  4791. return LoadProgressBar;
  4792. })(_componentJs2['default']);
  4793. _componentJs2['default'].registerComponent('LoadProgressBar', LoadProgressBar);
  4794. exports['default'] = LoadProgressBar;
  4795. module.exports = exports['default'];
  4796. }, { "../../component.js": 67, "../../utils/dom.js": 143 }], 78: [function (_dereq_, module, exports) {
  4797. /**
  4798. * @file mouse-time-display.js
  4799. */
  4800. 'use strict';
  4801. exports.__esModule = true;
  4802. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  4803. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4804. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4805. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4806. var _globalWindow = _dereq_('global/window');
  4807. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  4808. var _componentJs = _dereq_('../../component.js');
  4809. var _componentJs2 = _interopRequireDefault(_componentJs);
  4810. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4811. var Dom = _interopRequireWildcard(_utilsDomJs);
  4812. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4813. var Fn = _interopRequireWildcard(_utilsFnJs);
  4814. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  4815. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  4816. var _lodashCompatFunctionThrottle = _dereq_('lodash-compat/function/throttle');
  4817. var _lodashCompatFunctionThrottle2 = _interopRequireDefault(_lodashCompatFunctionThrottle);
  4818. /**
  4819. * The Mouse Time Display component shows the time you will seek to
  4820. * when hovering over the progress bar
  4821. *
  4822. * @param {Player|Object} player
  4823. * @param {Object=} options
  4824. * @extends Component
  4825. * @class MouseTimeDisplay
  4826. */
  4827. var MouseTimeDisplay = (function (_Component) {
  4828. _inherits(MouseTimeDisplay, _Component);
  4829. function MouseTimeDisplay(player, options) {
  4830. var _this = this;
  4831. _classCallCheck(this, MouseTimeDisplay);
  4832. _Component.call(this, player, options);
  4833. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  4834. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
  4835. }
  4836. if (this.keepTooltipsInside) {
  4837. this.tooltip = Dom.createEl('div', { className: 'vjs-time-tooltip' });
  4838. this.el().appendChild(this.tooltip);
  4839. this.addClass('vjs-keep-tooltips-inside');
  4840. }
  4841. this.update(0, 0);
  4842. player.on('ready', function () {
  4843. _this.on(player.controlBar.progressControl.el(), 'mousemove', _lodashCompatFunctionThrottle2['default'](Fn.bind(_this, _this.handleMouseMove), 25));
  4844. });
  4845. }
  4846. /**
  4847. * Create the component's DOM element
  4848. *
  4849. * @return {Element}
  4850. * @method createEl
  4851. */
  4852. MouseTimeDisplay.prototype.createEl = function createEl() {
  4853. return _Component.prototype.createEl.call(this, 'div', {
  4854. className: 'vjs-mouse-display'
  4855. });
  4856. };
  4857. MouseTimeDisplay.prototype.handleMouseMove = function handleMouseMove(event) {
  4858. var duration = this.player_.duration();
  4859. var newTime = this.calculateDistance(event) * duration;
  4860. var position = event.pageX - Dom.findElPosition(this.el().parentNode).left;
  4861. this.update(newTime, position);
  4862. };
  4863. MouseTimeDisplay.prototype.update = function update(newTime, position) {
  4864. var time = _utilsFormatTimeJs2['default'](newTime, this.player_.duration());
  4865. this.el().style.left = position + 'px';
  4866. this.el().setAttribute('data-current-time', time);
  4867. if (this.keepTooltipsInside) {
  4868. var clampedPosition = this.clampPosition_(position);
  4869. var difference = position - clampedPosition + 1;
  4870. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltip).width);
  4871. var tooltipWidthHalf = tooltipWidth / 2;
  4872. this.tooltip.innerHTML = time;
  4873. this.tooltip.style.right = '-' + (tooltipWidthHalf - difference) + 'px';
  4874. }
  4875. };
  4876. MouseTimeDisplay.prototype.calculateDistance = function calculateDistance(event) {
  4877. return Dom.getPointerPosition(this.el().parentNode, event).x;
  4878. };
  4879. /**
  4880. * This takes in a horizontal position for the bar and returns a clamped position.
  4881. * Clamped position means that it will keep the position greater than half the width
  4882. * of the tooltip and smaller than the player width minus half the width o the tooltip.
  4883. * It will only clamp the position if `keepTooltipsInside` option is set.
  4884. *
  4885. * @param {Number} position the position the bar wants to be
  4886. * @return {Number} newPosition the (potentially) clamped position
  4887. * @method clampPosition_
  4888. */
  4889. MouseTimeDisplay.prototype.clampPosition_ = function clampPosition_(position) {
  4890. if (!this.keepTooltipsInside) {
  4891. return position;
  4892. }
  4893. var playerWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.player().el()).width);
  4894. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltip).width);
  4895. var tooltipWidthHalf = tooltipWidth / 2;
  4896. var actualPosition = position;
  4897. if (position < tooltipWidthHalf) {
  4898. actualPosition = Math.ceil(tooltipWidthHalf);
  4899. } else if (position > playerWidth - tooltipWidthHalf) {
  4900. actualPosition = Math.floor(playerWidth - tooltipWidthHalf);
  4901. }
  4902. return actualPosition;
  4903. };
  4904. return MouseTimeDisplay;
  4905. })(_componentJs2['default']);
  4906. _componentJs2['default'].registerComponent('MouseTimeDisplay', MouseTimeDisplay);
  4907. exports['default'] = MouseTimeDisplay;
  4908. module.exports = exports['default'];
  4909. }, { "../../component.js": 67, "../../utils/dom.js": 143, "../../utils/fn.js": 145, "../../utils/format-time.js": 146, "global/window": 2, "lodash-compat/function/throttle": 7 }], 79: [function (_dereq_, module, exports) {
  4910. /**
  4911. * @file play-progress-bar.js
  4912. */
  4913. 'use strict';
  4914. exports.__esModule = true;
  4915. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  4916. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4917. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4918. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4919. var _componentJs = _dereq_('../../component.js');
  4920. var _componentJs2 = _interopRequireDefault(_componentJs);
  4921. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4922. var Fn = _interopRequireWildcard(_utilsFnJs);
  4923. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4924. var Dom = _interopRequireWildcard(_utilsDomJs);
  4925. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  4926. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  4927. /**
  4928. * Shows play progress
  4929. *
  4930. * @param {Player|Object} player
  4931. * @param {Object=} options
  4932. * @extends Component
  4933. * @class PlayProgressBar
  4934. */
  4935. var PlayProgressBar = (function (_Component) {
  4936. _inherits(PlayProgressBar, _Component);
  4937. function PlayProgressBar(player, options) {
  4938. _classCallCheck(this, PlayProgressBar);
  4939. _Component.call(this, player, options);
  4940. this.updateDataAttr();
  4941. this.on(player, 'timeupdate', this.updateDataAttr);
  4942. player.ready(Fn.bind(this, this.updateDataAttr));
  4943. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  4944. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
  4945. }
  4946. if (this.keepTooltipsInside) {
  4947. this.addClass('vjs-keep-tooltips-inside');
  4948. }
  4949. }
  4950. /**
  4951. * Create the component's DOM element
  4952. *
  4953. * @return {Element}
  4954. * @method createEl
  4955. */
  4956. PlayProgressBar.prototype.createEl = function createEl() {
  4957. return _Component.prototype.createEl.call(this, 'div', {
  4958. className: 'vjs-play-progress vjs-slider-bar',
  4959. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
  4960. });
  4961. };
  4962. PlayProgressBar.prototype.updateDataAttr = function updateDataAttr() {
  4963. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  4964. this.el_.setAttribute('data-current-time', _utilsFormatTimeJs2['default'](time, this.player_.duration()));
  4965. };
  4966. return PlayProgressBar;
  4967. })(_componentJs2['default']);
  4968. _componentJs2['default'].registerComponent('PlayProgressBar', PlayProgressBar);
  4969. exports['default'] = PlayProgressBar;
  4970. module.exports = exports['default'];
  4971. }, { "../../component.js": 67, "../../utils/dom.js": 143, "../../utils/fn.js": 145, "../../utils/format-time.js": 146 }], 80: [function (_dereq_, module, exports) {
  4972. /**
  4973. * @file progress-control.js
  4974. */
  4975. 'use strict';
  4976. exports.__esModule = true;
  4977. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4978. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4979. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4980. var _componentJs = _dereq_('../../component.js');
  4981. var _componentJs2 = _interopRequireDefault(_componentJs);
  4982. var _seekBarJs = _dereq_('./seek-bar.js');
  4983. var _seekBarJs2 = _interopRequireDefault(_seekBarJs);
  4984. var _mouseTimeDisplayJs = _dereq_('./mouse-time-display.js');
  4985. var _mouseTimeDisplayJs2 = _interopRequireDefault(_mouseTimeDisplayJs);
  4986. /**
  4987. * The Progress Control component contains the seek bar, load progress,
  4988. * and play progress
  4989. *
  4990. * @param {Player|Object} player
  4991. * @param {Object=} options
  4992. * @extends Component
  4993. * @class ProgressControl
  4994. */
  4995. var ProgressControl = (function (_Component) {
  4996. _inherits(ProgressControl, _Component);
  4997. function ProgressControl() {
  4998. _classCallCheck(this, ProgressControl);
  4999. _Component.apply(this, arguments);
  5000. }
  5001. /**
  5002. * Create the component's DOM element
  5003. *
  5004. * @return {Element}
  5005. * @method createEl
  5006. */
  5007. ProgressControl.prototype.createEl = function createEl() {
  5008. return _Component.prototype.createEl.call(this, 'div', {
  5009. className: 'vjs-progress-control vjs-control'
  5010. });
  5011. };
  5012. return ProgressControl;
  5013. })(_componentJs2['default']);
  5014. ProgressControl.prototype.options_ = {
  5015. children: ['seekBar']
  5016. };
  5017. _componentJs2['default'].registerComponent('ProgressControl', ProgressControl);
  5018. exports['default'] = ProgressControl;
  5019. module.exports = exports['default'];
  5020. }, { "../../component.js": 67, "./mouse-time-display.js": 78, "./seek-bar.js": 81 }], 81: [function (_dereq_, module, exports) {
  5021. /**
  5022. * @file seek-bar.js
  5023. */
  5024. 'use strict';
  5025. exports.__esModule = true;
  5026. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  5027. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5028. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5029. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5030. var _globalWindow = _dereq_('global/window');
  5031. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  5032. var _sliderSliderJs = _dereq_('../../slider/slider.js');
  5033. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs);
  5034. var _componentJs = _dereq_('../../component.js');
  5035. var _componentJs2 = _interopRequireDefault(_componentJs);
  5036. var _loadProgressBarJs = _dereq_('./load-progress-bar.js');
  5037. var _loadProgressBarJs2 = _interopRequireDefault(_loadProgressBarJs);
  5038. var _playProgressBarJs = _dereq_('./play-progress-bar.js');
  5039. var _playProgressBarJs2 = _interopRequireDefault(_playProgressBarJs);
  5040. var _tooltipProgressBarJs = _dereq_('./tooltip-progress-bar.js');
  5041. var _tooltipProgressBarJs2 = _interopRequireDefault(_tooltipProgressBarJs);
  5042. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5043. var Fn = _interopRequireWildcard(_utilsFnJs);
  5044. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  5045. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  5046. var _objectAssign = _dereq_('object.assign');
  5047. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  5048. /**
  5049. * Seek Bar and holder for the progress bars
  5050. *
  5051. * @param {Player|Object} player
  5052. * @param {Object=} options
  5053. * @extends Slider
  5054. * @class SeekBar
  5055. */
  5056. var SeekBar = (function (_Slider) {
  5057. _inherits(SeekBar, _Slider);
  5058. function SeekBar(player, options) {
  5059. _classCallCheck(this, SeekBar);
  5060. _Slider.call(this, player, options);
  5061. this.on(player, 'timeupdate', this.updateProgress);
  5062. this.on(player, 'ended', this.updateProgress);
  5063. player.ready(Fn.bind(this, this.updateProgress));
  5064. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  5065. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
  5066. }
  5067. if (this.keepTooltipsInside) {
  5068. this.tooltipProgressBar = this.addChild('TooltipProgressBar');
  5069. }
  5070. }
  5071. /**
  5072. * Create the component's DOM element
  5073. *
  5074. * @return {Element}
  5075. * @method createEl
  5076. */
  5077. SeekBar.prototype.createEl = function createEl() {
  5078. return _Slider.prototype.createEl.call(this, 'div', {
  5079. className: 'vjs-progress-holder'
  5080. }, {
  5081. 'aria-label': 'progress bar'
  5082. });
  5083. };
  5084. /**
  5085. * Update ARIA accessibility attributes
  5086. *
  5087. * @method updateARIAAttributes
  5088. */
  5089. SeekBar.prototype.updateProgress = function updateProgress() {
  5090. this.updateAriaAttributes(this.el_);
  5091. if (this.keepTooltipsInside) {
  5092. this.updateAriaAttributes(this.tooltipProgressBar.el_);
  5093. this.tooltipProgressBar.el_.style.width = this.bar.el_.style.width;
  5094. var playerWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.player().el()).width);
  5095. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltipProgressBar.tooltip).width);
  5096. var tooltipStyle = this.tooltipProgressBar.el().style;
  5097. tooltipStyle.maxWidth = Math.floor(playerWidth - tooltipWidth / 2) + 'px';
  5098. tooltipStyle.minWidth = Math.ceil(tooltipWidth / 2) + 'px';
  5099. tooltipStyle.right = '-' + tooltipWidth / 2 + 'px';
  5100. }
  5101. };
  5102. SeekBar.prototype.updateAriaAttributes = function updateAriaAttributes(el) {
  5103. // Allows for smooth scrubbing, when player can't keep up.
  5104. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  5105. el.setAttribute('aria-valuenow', (this.getPercent() * 100).toFixed(2)); // machine readable value of progress bar (percentage complete)
  5106. el.setAttribute('aria-valuetext', _utilsFormatTimeJs2['default'](time, this.player_.duration())); // human readable value of progress bar (time complete)
  5107. };
  5108. /**
  5109. * Get percentage of video played
  5110. *
  5111. * @return {Number} Percentage played
  5112. * @method getPercent
  5113. */
  5114. SeekBar.prototype.getPercent = function getPercent() {
  5115. var percent = this.player_.currentTime() / this.player_.duration();
  5116. return percent >= 1 ? 1 : percent;
  5117. };
  5118. /**
  5119. * Handle mouse down on seek bar
  5120. *
  5121. * @method handleMouseDown
  5122. */
  5123. SeekBar.prototype.handleMouseDown = function handleMouseDown(event) {
  5124. _Slider.prototype.handleMouseDown.call(this, event);
  5125. this.player_.scrubbing(true);
  5126. this.videoWasPlaying = !this.player_.paused();
  5127. this.player_.pause();
  5128. };
  5129. /**
  5130. * Handle mouse move on seek bar
  5131. *
  5132. * @method handleMouseMove
  5133. */
  5134. SeekBar.prototype.handleMouseMove = function handleMouseMove(event) {
  5135. var newTime = this.calculateDistance(event) * this.player_.duration();
  5136. // Don't let video end while scrubbing.
  5137. if (newTime === this.player_.duration()) {
  5138. newTime = newTime - 0.1;
  5139. }
  5140. // Set new time (tell player to seek to new time)
  5141. this.player_.currentTime(newTime);
  5142. };
  5143. /**
  5144. * Handle mouse up on seek bar
  5145. *
  5146. * @method handleMouseUp
  5147. */
  5148. SeekBar.prototype.handleMouseUp = function handleMouseUp(event) {
  5149. _Slider.prototype.handleMouseUp.call(this, event);
  5150. this.player_.scrubbing(false);
  5151. if (this.videoWasPlaying) {
  5152. this.player_.play();
  5153. }
  5154. };
  5155. /**
  5156. * Move more quickly fast forward for keyboard-only users
  5157. *
  5158. * @method stepForward
  5159. */
  5160. SeekBar.prototype.stepForward = function stepForward() {
  5161. this.player_.currentTime(this.player_.currentTime() + 5); // more quickly fast forward for keyboard-only users
  5162. };
  5163. /**
  5164. * Move more quickly rewind for keyboard-only users
  5165. *
  5166. * @method stepBack
  5167. */
  5168. SeekBar.prototype.stepBack = function stepBack() {
  5169. this.player_.currentTime(this.player_.currentTime() - 5); // more quickly rewind for keyboard-only users
  5170. };
  5171. return SeekBar;
  5172. })(_sliderSliderJs2['default']);
  5173. SeekBar.prototype.options_ = {
  5174. children: ['loadProgressBar', 'mouseTimeDisplay', 'playProgressBar'],
  5175. 'barName': 'playProgressBar'
  5176. };
  5177. SeekBar.prototype.playerEvent = 'timeupdate';
  5178. _componentJs2['default'].registerComponent('SeekBar', SeekBar);
  5179. exports['default'] = SeekBar;
  5180. module.exports = exports['default'];
  5181. }, { "../../component.js": 67, "../../slider/slider.js": 119, "../../utils/fn.js": 145, "../../utils/format-time.js": 146, "./load-progress-bar.js": 77, "./play-progress-bar.js": 79, "./tooltip-progress-bar.js": 82, "global/window": 2, "object.assign": 45 }], 82: [function (_dereq_, module, exports) {
  5182. /**
  5183. * @file play-progress-bar.js
  5184. */
  5185. 'use strict';
  5186. exports.__esModule = true;
  5187. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  5188. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5189. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5190. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5191. var _componentJs = _dereq_('../../component.js');
  5192. var _componentJs2 = _interopRequireDefault(_componentJs);
  5193. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5194. var Fn = _interopRequireWildcard(_utilsFnJs);
  5195. var _utilsDomJs = _dereq_('../../utils/dom.js');
  5196. var Dom = _interopRequireWildcard(_utilsDomJs);
  5197. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  5198. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  5199. /**
  5200. * Shows play progress
  5201. *
  5202. * @param {Player|Object} player
  5203. * @param {Object=} options
  5204. * @extends Component
  5205. * @class PlayProgressBar
  5206. */
  5207. var TooltipProgressBar = (function (_Component) {
  5208. _inherits(TooltipProgressBar, _Component);
  5209. function TooltipProgressBar(player, options) {
  5210. _classCallCheck(this, TooltipProgressBar);
  5211. _Component.call(this, player, options);
  5212. this.updateDataAttr();
  5213. this.on(player, 'timeupdate', this.updateDataAttr);
  5214. player.ready(Fn.bind(this, this.updateDataAttr));
  5215. }
  5216. /**
  5217. * Create the component's DOM element
  5218. *
  5219. * @return {Element}
  5220. * @method createEl
  5221. */
  5222. TooltipProgressBar.prototype.createEl = function createEl() {
  5223. var el = _Component.prototype.createEl.call(this, 'div', {
  5224. className: 'vjs-tooltip-progress-bar vjs-slider-bar',
  5225. innerHTML: '<div class="vjs-time-tooltip"></div>\n <span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
  5226. });
  5227. this.tooltip = el.querySelector('.vjs-time-tooltip');
  5228. return el;
  5229. };
  5230. TooltipProgressBar.prototype.updateDataAttr = function updateDataAttr() {
  5231. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  5232. var formattedTime = _utilsFormatTimeJs2['default'](time, this.player_.duration());
  5233. this.el_.setAttribute('data-current-time', formattedTime);
  5234. this.tooltip.innerHTML = formattedTime;
  5235. };
  5236. return TooltipProgressBar;
  5237. })(_componentJs2['default']);
  5238. _componentJs2['default'].registerComponent('TooltipProgressBar', TooltipProgressBar);
  5239. exports['default'] = TooltipProgressBar;
  5240. module.exports = exports['default'];
  5241. }, { "../../component.js": 67, "../../utils/dom.js": 143, "../../utils/fn.js": 145, "../../utils/format-time.js": 146 }], 83: [function (_dereq_, module, exports) {
  5242. /**
  5243. * @file custom-control-spacer.js
  5244. */
  5245. 'use strict';
  5246. exports.__esModule = true;
  5247. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5248. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5249. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5250. var _spacerJs = _dereq_('./spacer.js');
  5251. var _spacerJs2 = _interopRequireDefault(_spacerJs);
  5252. var _componentJs = _dereq_('../../component.js');
  5253. var _componentJs2 = _interopRequireDefault(_componentJs);
  5254. /**
  5255. * Spacer specifically meant to be used as an insertion point for new plugins, etc.
  5256. *
  5257. * @extends Spacer
  5258. * @class CustomControlSpacer
  5259. */
  5260. var CustomControlSpacer = (function (_Spacer) {
  5261. _inherits(CustomControlSpacer, _Spacer);
  5262. function CustomControlSpacer() {
  5263. _classCallCheck(this, CustomControlSpacer);
  5264. _Spacer.apply(this, arguments);
  5265. }
  5266. /**
  5267. * Allow sub components to stack CSS class names
  5268. *
  5269. * @return {String} The constructed class name
  5270. * @method buildCSSClass
  5271. */
  5272. CustomControlSpacer.prototype.buildCSSClass = function buildCSSClass() {
  5273. return 'vjs-custom-control-spacer ' + _Spacer.prototype.buildCSSClass.call(this);
  5274. };
  5275. /**
  5276. * Create the component's DOM element
  5277. *
  5278. * @return {Element}
  5279. * @method createEl
  5280. */
  5281. CustomControlSpacer.prototype.createEl = function createEl() {
  5282. var el = _Spacer.prototype.createEl.call(this, {
  5283. className: this.buildCSSClass()
  5284. });
  5285. // No-flex/table-cell mode requires there be some content
  5286. // in the cell to fill the remaining space of the table.
  5287. el.innerHTML = '&nbsp;';
  5288. return el;
  5289. };
  5290. return CustomControlSpacer;
  5291. })(_spacerJs2['default']);
  5292. _componentJs2['default'].registerComponent('CustomControlSpacer', CustomControlSpacer);
  5293. exports['default'] = CustomControlSpacer;
  5294. module.exports = exports['default'];
  5295. }, { "../../component.js": 67, "./spacer.js": 84 }], 84: [function (_dereq_, module, exports) {
  5296. /**
  5297. * @file spacer.js
  5298. */
  5299. 'use strict';
  5300. exports.__esModule = true;
  5301. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5302. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5303. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5304. var _componentJs = _dereq_('../../component.js');
  5305. var _componentJs2 = _interopRequireDefault(_componentJs);
  5306. /**
  5307. * Just an empty spacer element that can be used as an append point for plugins, etc.
  5308. * Also can be used to create space between elements when necessary.
  5309. *
  5310. * @extends Component
  5311. * @class Spacer
  5312. */
  5313. var Spacer = (function (_Component) {
  5314. _inherits(Spacer, _Component);
  5315. function Spacer() {
  5316. _classCallCheck(this, Spacer);
  5317. _Component.apply(this, arguments);
  5318. }
  5319. /**
  5320. * Allow sub components to stack CSS class names
  5321. *
  5322. * @return {String} The constructed class name
  5323. * @method buildCSSClass
  5324. */
  5325. Spacer.prototype.buildCSSClass = function buildCSSClass() {
  5326. return 'vjs-spacer ' + _Component.prototype.buildCSSClass.call(this);
  5327. };
  5328. /**
  5329. * Create the component's DOM element
  5330. *
  5331. * @return {Element}
  5332. * @method createEl
  5333. */
  5334. Spacer.prototype.createEl = function createEl() {
  5335. return _Component.prototype.createEl.call(this, 'div', {
  5336. className: this.buildCSSClass()
  5337. });
  5338. };
  5339. return Spacer;
  5340. })(_componentJs2['default']);
  5341. _componentJs2['default'].registerComponent('Spacer', Spacer);
  5342. exports['default'] = Spacer;
  5343. module.exports = exports['default'];
  5344. }, { "../../component.js": 67 }], 85: [function (_dereq_, module, exports) {
  5345. /**
  5346. * @file caption-settings-menu-item.js
  5347. */
  5348. 'use strict';
  5349. exports.__esModule = true;
  5350. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5351. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5352. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5353. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5354. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5355. var _componentJs = _dereq_('../../component.js');
  5356. var _componentJs2 = _interopRequireDefault(_componentJs);
  5357. /**
  5358. * The menu item for caption track settings menu
  5359. *
  5360. * @param {Player|Object} player
  5361. * @param {Object=} options
  5362. * @extends TextTrackMenuItem
  5363. * @class CaptionSettingsMenuItem
  5364. */
  5365. var CaptionSettingsMenuItem = (function (_TextTrackMenuItem) {
  5366. _inherits(CaptionSettingsMenuItem, _TextTrackMenuItem);
  5367. function CaptionSettingsMenuItem(player, options) {
  5368. _classCallCheck(this, CaptionSettingsMenuItem);
  5369. options['track'] = {
  5370. 'kind': options['kind'],
  5371. 'player': player,
  5372. 'label': options['kind'] + ' settings',
  5373. 'selectable': false,
  5374. 'default': false,
  5375. mode: 'disabled'
  5376. };
  5377. // CaptionSettingsMenuItem has no concept of 'selected'
  5378. options['selectable'] = false;
  5379. _TextTrackMenuItem.call(this, player, options);
  5380. this.addClass('vjs-texttrack-settings');
  5381. this.controlText(', opens ' + options['kind'] + ' settings dialog');
  5382. }
  5383. /**
  5384. * Handle click on menu item
  5385. *
  5386. * @method handleClick
  5387. */
  5388. CaptionSettingsMenuItem.prototype.handleClick = function handleClick() {
  5389. this.player().getChild('textTrackSettings').show();
  5390. this.player().getChild('textTrackSettings').el_.focus();
  5391. };
  5392. return CaptionSettingsMenuItem;
  5393. })(_textTrackMenuItemJs2['default']);
  5394. _componentJs2['default'].registerComponent('CaptionSettingsMenuItem', CaptionSettingsMenuItem);
  5395. exports['default'] = CaptionSettingsMenuItem;
  5396. module.exports = exports['default'];
  5397. }, { "../../component.js": 67, "./text-track-menu-item.js": 93 }], 86: [function (_dereq_, module, exports) {
  5398. /**
  5399. * @file captions-button.js
  5400. */
  5401. 'use strict';
  5402. exports.__esModule = true;
  5403. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5404. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5405. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5406. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5407. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5408. var _componentJs = _dereq_('../../component.js');
  5409. var _componentJs2 = _interopRequireDefault(_componentJs);
  5410. var _captionSettingsMenuItemJs = _dereq_('./caption-settings-menu-item.js');
  5411. var _captionSettingsMenuItemJs2 = _interopRequireDefault(_captionSettingsMenuItemJs);
  5412. /**
  5413. * The button component for toggling and selecting captions
  5414. *
  5415. * @param {Object} player Player object
  5416. * @param {Object=} options Object of option names and values
  5417. * @param {Function=} ready Ready callback function
  5418. * @extends TextTrackButton
  5419. * @class CaptionsButton
  5420. */
  5421. var CaptionsButton = (function (_TextTrackButton) {
  5422. _inherits(CaptionsButton, _TextTrackButton);
  5423. function CaptionsButton(player, options, ready) {
  5424. _classCallCheck(this, CaptionsButton);
  5425. _TextTrackButton.call(this, player, options, ready);
  5426. this.el_.setAttribute('aria-label', 'Captions Menu');
  5427. }
  5428. /**
  5429. * Allow sub components to stack CSS class names
  5430. *
  5431. * @return {String} The constructed class name
  5432. * @method buildCSSClass
  5433. */
  5434. CaptionsButton.prototype.buildCSSClass = function buildCSSClass() {
  5435. return 'vjs-captions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5436. };
  5437. /**
  5438. * Update caption menu items
  5439. *
  5440. * @method update
  5441. */
  5442. CaptionsButton.prototype.update = function update() {
  5443. var threshold = 2;
  5444. _TextTrackButton.prototype.update.call(this);
  5445. // if native, then threshold is 1 because no settings button
  5446. if (this.player().tech_ && this.player().tech_['featuresNativeTextTracks']) {
  5447. threshold = 1;
  5448. }
  5449. if (this.items && this.items.length > threshold) {
  5450. this.show();
  5451. } else {
  5452. this.hide();
  5453. }
  5454. };
  5455. /**
  5456. * Create caption menu items
  5457. *
  5458. * @return {Array} Array of menu items
  5459. * @method createItems
  5460. */
  5461. CaptionsButton.prototype.createItems = function createItems() {
  5462. var items = [];
  5463. if (!(this.player().tech_ && this.player().tech_['featuresNativeTextTracks'])) {
  5464. items.push(new _captionSettingsMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }));
  5465. }
  5466. return _TextTrackButton.prototype.createItems.call(this, items);
  5467. };
  5468. return CaptionsButton;
  5469. })(_textTrackButtonJs2['default']);
  5470. CaptionsButton.prototype.kind_ = 'captions';
  5471. CaptionsButton.prototype.controlText_ = 'Captions';
  5472. _componentJs2['default'].registerComponent('CaptionsButton', CaptionsButton);
  5473. exports['default'] = CaptionsButton;
  5474. module.exports = exports['default'];
  5475. }, { "../../component.js": 67, "./caption-settings-menu-item.js": 85, "./text-track-button.js": 92 }], 87: [function (_dereq_, module, exports) {
  5476. /**
  5477. * @file chapters-button.js
  5478. */
  5479. 'use strict';
  5480. exports.__esModule = true;
  5481. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  5482. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5483. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5484. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5485. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5486. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5487. var _componentJs = _dereq_('../../component.js');
  5488. var _componentJs2 = _interopRequireDefault(_componentJs);
  5489. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5490. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5491. var _chaptersTrackMenuItemJs = _dereq_('./chapters-track-menu-item.js');
  5492. var _chaptersTrackMenuItemJs2 = _interopRequireDefault(_chaptersTrackMenuItemJs);
  5493. var _menuMenuJs = _dereq_('../../menu/menu.js');
  5494. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  5495. var _utilsDomJs = _dereq_('../../utils/dom.js');
  5496. var Dom = _interopRequireWildcard(_utilsDomJs);
  5497. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5498. var Fn = _interopRequireWildcard(_utilsFnJs);
  5499. var _utilsToTitleCaseJs = _dereq_('../../utils/to-title-case.js');
  5500. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  5501. var _globalWindow = _dereq_('global/window');
  5502. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  5503. /**
  5504. * The button component for toggling and selecting chapters
  5505. * Chapters act much differently than other text tracks
  5506. * Cues are navigation vs. other tracks of alternative languages
  5507. *
  5508. * @param {Object} player Player object
  5509. * @param {Object=} options Object of option names and values
  5510. * @param {Function=} ready Ready callback function
  5511. * @extends TextTrackButton
  5512. * @class ChaptersButton
  5513. */
  5514. var ChaptersButton = (function (_TextTrackButton) {
  5515. _inherits(ChaptersButton, _TextTrackButton);
  5516. function ChaptersButton(player, options, ready) {
  5517. _classCallCheck(this, ChaptersButton);
  5518. _TextTrackButton.call(this, player, options, ready);
  5519. this.el_.setAttribute('aria-label', 'Chapters Menu');
  5520. }
  5521. /**
  5522. * Allow sub components to stack CSS class names
  5523. *
  5524. * @return {String} The constructed class name
  5525. * @method buildCSSClass
  5526. */
  5527. ChaptersButton.prototype.buildCSSClass = function buildCSSClass() {
  5528. return 'vjs-chapters-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5529. };
  5530. /**
  5531. * Create a menu item for each text track
  5532. *
  5533. * @return {Array} Array of menu items
  5534. * @method createItems
  5535. */
  5536. ChaptersButton.prototype.createItems = function createItems() {
  5537. var items = [];
  5538. var tracks = this.player_.textTracks();
  5539. if (!tracks) {
  5540. return items;
  5541. }
  5542. for (var i = 0; i < tracks.length; i++) {
  5543. var track = tracks[i];
  5544. if (track['kind'] === this.kind_) {
  5545. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5546. 'track': track
  5547. }));
  5548. }
  5549. }
  5550. return items;
  5551. };
  5552. /**
  5553. * Create menu from chapter buttons
  5554. *
  5555. * @return {Menu} Menu of chapter buttons
  5556. * @method createMenu
  5557. */
  5558. ChaptersButton.prototype.createMenu = function createMenu() {
  5559. var _this = this;
  5560. var tracks = this.player_.textTracks() || [];
  5561. var chaptersTrack = undefined;
  5562. var items = this.items = [];
  5563. for (var i = 0, _length = tracks.length; i < _length; i++) {
  5564. var track = tracks[i];
  5565. if (track['kind'] === this.kind_) {
  5566. chaptersTrack = track;
  5567. break;
  5568. }
  5569. }
  5570. var menu = this.menu;
  5571. if (menu === undefined) {
  5572. menu = new _menuMenuJs2['default'](this.player_);
  5573. var title = Dom.createEl('li', {
  5574. className: 'vjs-menu-title',
  5575. innerHTML: _utilsToTitleCaseJs2['default'](this.kind_),
  5576. tabIndex: -1
  5577. });
  5578. menu.children_.unshift(title);
  5579. Dom.insertElFirst(title, menu.contentEl());
  5580. }
  5581. if (chaptersTrack && chaptersTrack.cues == null) {
  5582. chaptersTrack['mode'] = 'hidden';
  5583. var remoteTextTrackEl = this.player_.remoteTextTrackEls().getTrackElementByTrack_(chaptersTrack);
  5584. if (remoteTextTrackEl) {
  5585. remoteTextTrackEl.addEventListener('load', function (event) {
  5586. return _this.update();
  5587. });
  5588. }
  5589. }
  5590. if (chaptersTrack && chaptersTrack.cues && chaptersTrack.cues.length > 0) {
  5591. var cues = chaptersTrack['cues'],
  5592. cue = undefined;
  5593. for (var i = 0, l = cues.length; i < l; i++) {
  5594. cue = cues[i];
  5595. var mi = new _chaptersTrackMenuItemJs2['default'](this.player_, {
  5596. 'track': chaptersTrack,
  5597. 'cue': cue
  5598. });
  5599. items.push(mi);
  5600. menu.addChild(mi);
  5601. }
  5602. this.addChild(menu);
  5603. }
  5604. if (this.items.length > 0) {
  5605. this.show();
  5606. }
  5607. return menu;
  5608. };
  5609. return ChaptersButton;
  5610. })(_textTrackButtonJs2['default']);
  5611. ChaptersButton.prototype.kind_ = 'chapters';
  5612. ChaptersButton.prototype.controlText_ = 'Chapters';
  5613. _componentJs2['default'].registerComponent('ChaptersButton', ChaptersButton);
  5614. exports['default'] = ChaptersButton;
  5615. module.exports = exports['default'];
  5616. }, { "../../component.js": 67, "../../menu/menu.js": 111, "../../utils/dom.js": 143, "../../utils/fn.js": 145, "../../utils/to-title-case.js": 152, "./chapters-track-menu-item.js": 88, "./text-track-button.js": 92, "./text-track-menu-item.js": 93, "global/window": 2 }], 88: [function (_dereq_, module, exports) {
  5617. /**
  5618. * @file chapters-track-menu-item.js
  5619. */
  5620. 'use strict';
  5621. exports.__esModule = true;
  5622. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  5623. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5624. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5625. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5626. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  5627. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  5628. var _componentJs = _dereq_('../../component.js');
  5629. var _componentJs2 = _interopRequireDefault(_componentJs);
  5630. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5631. var Fn = _interopRequireWildcard(_utilsFnJs);
  5632. /**
  5633. * The chapter track menu item
  5634. *
  5635. * @param {Player|Object} player
  5636. * @param {Object=} options
  5637. * @extends MenuItem
  5638. * @class ChaptersTrackMenuItem
  5639. */
  5640. var ChaptersTrackMenuItem = (function (_MenuItem) {
  5641. _inherits(ChaptersTrackMenuItem, _MenuItem);
  5642. function ChaptersTrackMenuItem(player, options) {
  5643. _classCallCheck(this, ChaptersTrackMenuItem);
  5644. var track = options['track'];
  5645. var cue = options['cue'];
  5646. var currentTime = player.currentTime();
  5647. // Modify options for parent MenuItem class's init.
  5648. options['label'] = cue.text;
  5649. options['selected'] = cue['startTime'] <= currentTime && currentTime < cue['endTime'];
  5650. _MenuItem.call(this, player, options);
  5651. this.track = track;
  5652. this.cue = cue;
  5653. track.addEventListener('cuechange', Fn.bind(this, this.update));
  5654. }
  5655. /**
  5656. * Handle click on menu item
  5657. *
  5658. * @method handleClick
  5659. */
  5660. ChaptersTrackMenuItem.prototype.handleClick = function handleClick() {
  5661. _MenuItem.prototype.handleClick.call(this);
  5662. this.player_.currentTime(this.cue.startTime);
  5663. this.update(this.cue.startTime);
  5664. };
  5665. /**
  5666. * Update chapter menu item
  5667. *
  5668. * @method update
  5669. */
  5670. ChaptersTrackMenuItem.prototype.update = function update() {
  5671. var cue = this.cue;
  5672. var currentTime = this.player_.currentTime();
  5673. // vjs.log(currentTime, cue.startTime);
  5674. this.selected(cue['startTime'] <= currentTime && currentTime < cue['endTime']);
  5675. };
  5676. return ChaptersTrackMenuItem;
  5677. })(_menuMenuItemJs2['default']);
  5678. _componentJs2['default'].registerComponent('ChaptersTrackMenuItem', ChaptersTrackMenuItem);
  5679. exports['default'] = ChaptersTrackMenuItem;
  5680. module.exports = exports['default'];
  5681. }, { "../../component.js": 67, "../../menu/menu-item.js": 110, "../../utils/fn.js": 145 }], 89: [function (_dereq_, module, exports) {
  5682. /**
  5683. * @file descriptions-button.js
  5684. */
  5685. 'use strict';
  5686. exports.__esModule = true;
  5687. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  5688. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5689. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5690. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5691. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5692. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5693. var _componentJs = _dereq_('../../component.js');
  5694. var _componentJs2 = _interopRequireDefault(_componentJs);
  5695. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5696. var Fn = _interopRequireWildcard(_utilsFnJs);
  5697. /**
  5698. * The button component for toggling and selecting descriptions
  5699. *
  5700. * @param {Object} player Player object
  5701. * @param {Object=} options Object of option names and values
  5702. * @param {Function=} ready Ready callback function
  5703. * @extends TextTrackButton
  5704. * @class DescriptionsButton
  5705. */
  5706. var DescriptionsButton = (function (_TextTrackButton) {
  5707. _inherits(DescriptionsButton, _TextTrackButton);
  5708. function DescriptionsButton(player, options, ready) {
  5709. var _this = this;
  5710. _classCallCheck(this, DescriptionsButton);
  5711. _TextTrackButton.call(this, player, options, ready);
  5712. this.el_.setAttribute('aria-label', 'Descriptions Menu');
  5713. var tracks = player.textTracks();
  5714. if (tracks) {
  5715. (function () {
  5716. var changeHandler = Fn.bind(_this, _this.handleTracksChange);
  5717. tracks.addEventListener('change', changeHandler);
  5718. _this.on('dispose', function () {
  5719. tracks.removeEventListener('change', changeHandler);
  5720. });
  5721. })();
  5722. }
  5723. }
  5724. /**
  5725. * Handle text track change
  5726. *
  5727. * @method handleTracksChange
  5728. */
  5729. DescriptionsButton.prototype.handleTracksChange = function handleTracksChange(event) {
  5730. var tracks = this.player().textTracks();
  5731. var disabled = false;
  5732. // Check whether a track of a different kind is showing
  5733. for (var i = 0, l = tracks.length; i < l; i++) {
  5734. var track = tracks[i];
  5735. if (track['kind'] !== this.kind_ && track['mode'] === 'showing') {
  5736. disabled = true;
  5737. break;
  5738. }
  5739. }
  5740. // If another track is showing, disable this menu button
  5741. if (disabled) {
  5742. this.disable();
  5743. } else {
  5744. this.enable();
  5745. }
  5746. };
  5747. /**
  5748. * Allow sub components to stack CSS class names
  5749. *
  5750. * @return {String} The constructed class name
  5751. * @method buildCSSClass
  5752. */
  5753. DescriptionsButton.prototype.buildCSSClass = function buildCSSClass() {
  5754. return 'vjs-descriptions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5755. };
  5756. return DescriptionsButton;
  5757. })(_textTrackButtonJs2['default']);
  5758. DescriptionsButton.prototype.kind_ = 'descriptions';
  5759. DescriptionsButton.prototype.controlText_ = 'Descriptions';
  5760. _componentJs2['default'].registerComponent('DescriptionsButton', DescriptionsButton);
  5761. exports['default'] = DescriptionsButton;
  5762. module.exports = exports['default'];
  5763. }, { "../../component.js": 67, "../../utils/fn.js": 145, "./text-track-button.js": 92 }], 90: [function (_dereq_, module, exports) {
  5764. /**
  5765. * @file off-text-track-menu-item.js
  5766. */
  5767. 'use strict';
  5768. exports.__esModule = true;
  5769. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5770. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5771. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5772. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5773. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5774. var _componentJs = _dereq_('../../component.js');
  5775. var _componentJs2 = _interopRequireDefault(_componentJs);
  5776. /**
  5777. * A special menu item for turning of a specific type of text track
  5778. *
  5779. * @param {Player|Object} player
  5780. * @param {Object=} options
  5781. * @extends TextTrackMenuItem
  5782. * @class OffTextTrackMenuItem
  5783. */
  5784. var OffTextTrackMenuItem = (function (_TextTrackMenuItem) {
  5785. _inherits(OffTextTrackMenuItem, _TextTrackMenuItem);
  5786. function OffTextTrackMenuItem(player, options) {
  5787. _classCallCheck(this, OffTextTrackMenuItem);
  5788. // Create pseudo track info
  5789. // Requires options['kind']
  5790. options['track'] = {
  5791. 'kind': options['kind'],
  5792. 'player': player,
  5793. 'label': options['kind'] + ' off',
  5794. 'default': false,
  5795. 'mode': 'disabled'
  5796. };
  5797. // MenuItem is selectable
  5798. options['selectable'] = true;
  5799. _TextTrackMenuItem.call(this, player, options);
  5800. this.selected(true);
  5801. }
  5802. /**
  5803. * Handle text track change
  5804. *
  5805. * @param {Object} event Event object
  5806. * @method handleTracksChange
  5807. */
  5808. OffTextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  5809. var tracks = this.player().textTracks();
  5810. var selected = true;
  5811. for (var i = 0, l = tracks.length; i < l; i++) {
  5812. var track = tracks[i];
  5813. if (track['kind'] === this.track['kind'] && track['mode'] === 'showing') {
  5814. selected = false;
  5815. break;
  5816. }
  5817. }
  5818. this.selected(selected);
  5819. };
  5820. return OffTextTrackMenuItem;
  5821. })(_textTrackMenuItemJs2['default']);
  5822. _componentJs2['default'].registerComponent('OffTextTrackMenuItem', OffTextTrackMenuItem);
  5823. exports['default'] = OffTextTrackMenuItem;
  5824. module.exports = exports['default'];
  5825. }, { "../../component.js": 67, "./text-track-menu-item.js": 93 }], 91: [function (_dereq_, module, exports) {
  5826. /**
  5827. * @file subtitles-button.js
  5828. */
  5829. 'use strict';
  5830. exports.__esModule = true;
  5831. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5832. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5833. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5834. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5835. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5836. var _componentJs = _dereq_('../../component.js');
  5837. var _componentJs2 = _interopRequireDefault(_componentJs);
  5838. /**
  5839. * The button component for toggling and selecting subtitles
  5840. *
  5841. * @param {Object} player Player object
  5842. * @param {Object=} options Object of option names and values
  5843. * @param {Function=} ready Ready callback function
  5844. * @extends TextTrackButton
  5845. * @class SubtitlesButton
  5846. */
  5847. var SubtitlesButton = (function (_TextTrackButton) {
  5848. _inherits(SubtitlesButton, _TextTrackButton);
  5849. function SubtitlesButton(player, options, ready) {
  5850. _classCallCheck(this, SubtitlesButton);
  5851. _TextTrackButton.call(this, player, options, ready);
  5852. this.el_.setAttribute('aria-label', 'Subtitles Menu');
  5853. }
  5854. /**
  5855. * Allow sub components to stack CSS class names
  5856. *
  5857. * @return {String} The constructed class name
  5858. * @method buildCSSClass
  5859. */
  5860. SubtitlesButton.prototype.buildCSSClass = function buildCSSClass() {
  5861. return 'vjs-subtitles-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5862. };
  5863. return SubtitlesButton;
  5864. })(_textTrackButtonJs2['default']);
  5865. SubtitlesButton.prototype.kind_ = 'subtitles';
  5866. SubtitlesButton.prototype.controlText_ = 'Subtitles';
  5867. _componentJs2['default'].registerComponent('SubtitlesButton', SubtitlesButton);
  5868. exports['default'] = SubtitlesButton;
  5869. module.exports = exports['default'];
  5870. }, { "../../component.js": 67, "./text-track-button.js": 92 }], 92: [function (_dereq_, module, exports) {
  5871. /**
  5872. * @file text-track-button.js
  5873. */
  5874. 'use strict';
  5875. exports.__esModule = true;
  5876. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  5877. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5878. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5879. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5880. var _trackButtonJs = _dereq_('../track-button.js');
  5881. var _trackButtonJs2 = _interopRequireDefault(_trackButtonJs);
  5882. var _componentJs = _dereq_('../../component.js');
  5883. var _componentJs2 = _interopRequireDefault(_componentJs);
  5884. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5885. var Fn = _interopRequireWildcard(_utilsFnJs);
  5886. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5887. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5888. var _offTextTrackMenuItemJs = _dereq_('./off-text-track-menu-item.js');
  5889. var _offTextTrackMenuItemJs2 = _interopRequireDefault(_offTextTrackMenuItemJs);
  5890. /**
  5891. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  5892. *
  5893. * @param {Player|Object} player
  5894. * @param {Object=} options
  5895. * @extends MenuButton
  5896. * @class TextTrackButton
  5897. */
  5898. var TextTrackButton = (function (_TrackButton) {
  5899. _inherits(TextTrackButton, _TrackButton);
  5900. function TextTrackButton(player) {
  5901. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  5902. _classCallCheck(this, TextTrackButton);
  5903. options.tracks = player.textTracks();
  5904. _TrackButton.call(this, player, options);
  5905. }
  5906. /**
  5907. * Create a menu item for each text track
  5908. *
  5909. * @return {Array} Array of menu items
  5910. * @method createItems
  5911. */
  5912. TextTrackButton.prototype.createItems = function createItems() {
  5913. var items = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  5914. // Add an OFF menu item to turn all tracks off
  5915. items.push(new _offTextTrackMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }));
  5916. var tracks = this.player_.textTracks();
  5917. if (!tracks) {
  5918. return items;
  5919. }
  5920. for (var i = 0; i < tracks.length; i++) {
  5921. var track = tracks[i];
  5922. // only add tracks that are of the appropriate kind and have a label
  5923. if (track['kind'] === this.kind_) {
  5924. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5925. // MenuItem is selectable
  5926. 'selectable': true,
  5927. 'track': track
  5928. }));
  5929. }
  5930. }
  5931. return items;
  5932. };
  5933. return TextTrackButton;
  5934. })(_trackButtonJs2['default']);
  5935. _componentJs2['default'].registerComponent('TextTrackButton', TextTrackButton);
  5936. exports['default'] = TextTrackButton;
  5937. module.exports = exports['default'];
  5938. }, { "../../component.js": 67, "../../utils/fn.js": 145, "../track-button.js": 98, "./off-text-track-menu-item.js": 90, "./text-track-menu-item.js": 93 }], 93: [function (_dereq_, module, exports) {
  5939. /**
  5940. * @file text-track-menu-item.js
  5941. */
  5942. 'use strict';
  5943. exports.__esModule = true;
  5944. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  5945. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5946. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5947. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5948. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  5949. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  5950. var _componentJs = _dereq_('../../component.js');
  5951. var _componentJs2 = _interopRequireDefault(_componentJs);
  5952. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5953. var Fn = _interopRequireWildcard(_utilsFnJs);
  5954. var _globalWindow = _dereq_('global/window');
  5955. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  5956. var _globalDocument = _dereq_('global/document');
  5957. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  5958. /**
  5959. * The specific menu item type for selecting a language within a text track kind
  5960. *
  5961. * @param {Player|Object} player
  5962. * @param {Object=} options
  5963. * @extends MenuItem
  5964. * @class TextTrackMenuItem
  5965. */
  5966. var TextTrackMenuItem = (function (_MenuItem) {
  5967. _inherits(TextTrackMenuItem, _MenuItem);
  5968. function TextTrackMenuItem(player, options) {
  5969. var _this = this;
  5970. _classCallCheck(this, TextTrackMenuItem);
  5971. var track = options['track'];
  5972. var tracks = player.textTracks();
  5973. // Modify options for parent MenuItem class's init.
  5974. options['label'] = track['label'] || track['language'] || 'Unknown';
  5975. options['selected'] = track['default'] || track['mode'] === 'showing';
  5976. _MenuItem.call(this, player, options);
  5977. this.track = track;
  5978. if (tracks) {
  5979. (function () {
  5980. var changeHandler = Fn.bind(_this, _this.handleTracksChange);
  5981. tracks.addEventListener('change', changeHandler);
  5982. _this.on('dispose', function () {
  5983. tracks.removeEventListener('change', changeHandler);
  5984. });
  5985. })();
  5986. }
  5987. // iOS7 doesn't dispatch change events to TextTrackLists when an
  5988. // associated track's mode changes. Without something like
  5989. // Object.observe() (also not present on iOS7), it's not
  5990. // possible to detect changes to the mode attribute and polyfill
  5991. // the change event. As a poor substitute, we manually dispatch
  5992. // change events whenever the controls modify the mode.
  5993. if (tracks && tracks.onchange === undefined) {
  5994. (function () {
  5995. var event = undefined;
  5996. _this.on(['tap', 'click'], function () {
  5997. if (typeof _globalWindow2['default'].Event !== 'object') {
  5998. // Android 2.3 throws an Illegal Constructor error for window.Event
  5999. try {
  6000. event = new _globalWindow2['default'].Event('change');
  6001. } catch (err) { }
  6002. }
  6003. if (!event) {
  6004. event = _globalDocument2['default'].createEvent('Event');
  6005. event.initEvent('change', true, true);
  6006. }
  6007. tracks.dispatchEvent(event);
  6008. });
  6009. })();
  6010. }
  6011. }
  6012. /**
  6013. * Handle click on text track
  6014. *
  6015. * @method handleClick
  6016. */
  6017. TextTrackMenuItem.prototype.handleClick = function handleClick(event) {
  6018. var kind = this.track['kind'];
  6019. var tracks = this.player_.textTracks();
  6020. _MenuItem.prototype.handleClick.call(this, event);
  6021. if (!tracks) return;
  6022. for (var i = 0; i < tracks.length; i++) {
  6023. var track = tracks[i];
  6024. if (track['kind'] !== kind) {
  6025. continue;
  6026. }
  6027. if (track === this.track) {
  6028. track['mode'] = 'showing';
  6029. } else {
  6030. track['mode'] = 'disabled';
  6031. }
  6032. }
  6033. };
  6034. /**
  6035. * Handle text track change
  6036. *
  6037. * @method handleTracksChange
  6038. */
  6039. TextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  6040. this.selected(this.track['mode'] === 'showing');
  6041. };
  6042. return TextTrackMenuItem;
  6043. })(_menuMenuItemJs2['default']);
  6044. _componentJs2['default'].registerComponent('TextTrackMenuItem', TextTrackMenuItem);
  6045. exports['default'] = TextTrackMenuItem;
  6046. module.exports = exports['default'];
  6047. }, { "../../component.js": 67, "../../menu/menu-item.js": 110, "../../utils/fn.js": 145, "global/document": 1, "global/window": 2 }], 94: [function (_dereq_, module, exports) {
  6048. /**
  6049. * @file current-time-display.js
  6050. */
  6051. 'use strict';
  6052. exports.__esModule = true;
  6053. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6054. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6055. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6056. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6057. var _componentJs = _dereq_('../../component.js');
  6058. var _componentJs2 = _interopRequireDefault(_componentJs);
  6059. var _utilsDomJs = _dereq_('../../utils/dom.js');
  6060. var Dom = _interopRequireWildcard(_utilsDomJs);
  6061. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  6062. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  6063. /**
  6064. * Displays the current time
  6065. *
  6066. * @param {Player|Object} player
  6067. * @param {Object=} options
  6068. * @extends Component
  6069. * @class CurrentTimeDisplay
  6070. */
  6071. var CurrentTimeDisplay = (function (_Component) {
  6072. _inherits(CurrentTimeDisplay, _Component);
  6073. function CurrentTimeDisplay(player, options) {
  6074. _classCallCheck(this, CurrentTimeDisplay);
  6075. _Component.call(this, player, options);
  6076. this.on(player, 'timeupdate', this.updateContent);
  6077. }
  6078. /**
  6079. * Create the component's DOM element
  6080. *
  6081. * @return {Element}
  6082. * @method createEl
  6083. */
  6084. CurrentTimeDisplay.prototype.createEl = function createEl() {
  6085. var el = _Component.prototype.createEl.call(this, 'div', {
  6086. className: 'vjs-current-time vjs-time-control vjs-control'
  6087. });
  6088. this.contentEl_ = Dom.createEl('div', {
  6089. className: 'vjs-current-time-display',
  6090. // label the current time for screen reader users
  6091. innerHTML: '<span class="vjs-control-text">Current Time </span>' + '0:00'
  6092. }, {
  6093. // tell screen readers not to automatically read the time as it changes
  6094. 'aria-live': 'off'
  6095. });
  6096. el.appendChild(this.contentEl_);
  6097. return el;
  6098. };
  6099. /**
  6100. * Update current time display
  6101. *
  6102. * @method updateContent
  6103. */
  6104. CurrentTimeDisplay.prototype.updateContent = function updateContent() {
  6105. // Allows for smooth scrubbing, when player can't keep up.
  6106. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  6107. var localizedText = this.localize('Current Time');
  6108. var formattedTime = _utilsFormatTimeJs2['default'](time, this.player_.duration());
  6109. if (formattedTime !== this.formattedTime_) {
  6110. this.formattedTime_ = formattedTime;
  6111. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime;
  6112. }
  6113. };
  6114. return CurrentTimeDisplay;
  6115. })(_componentJs2['default']);
  6116. _componentJs2['default'].registerComponent('CurrentTimeDisplay', CurrentTimeDisplay);
  6117. exports['default'] = CurrentTimeDisplay;
  6118. module.exports = exports['default'];
  6119. }, { "../../component.js": 67, "../../utils/dom.js": 143, "../../utils/format-time.js": 146 }], 95: [function (_dereq_, module, exports) {
  6120. /**
  6121. * @file duration-display.js
  6122. */
  6123. 'use strict';
  6124. exports.__esModule = true;
  6125. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6126. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6127. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6128. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6129. var _componentJs = _dereq_('../../component.js');
  6130. var _componentJs2 = _interopRequireDefault(_componentJs);
  6131. var _utilsDomJs = _dereq_('../../utils/dom.js');
  6132. var Dom = _interopRequireWildcard(_utilsDomJs);
  6133. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  6134. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  6135. /**
  6136. * Displays the duration
  6137. *
  6138. * @param {Player|Object} player
  6139. * @param {Object=} options
  6140. * @extends Component
  6141. * @class DurationDisplay
  6142. */
  6143. var DurationDisplay = (function (_Component) {
  6144. _inherits(DurationDisplay, _Component);
  6145. function DurationDisplay(player, options) {
  6146. _classCallCheck(this, DurationDisplay);
  6147. _Component.call(this, player, options);
  6148. // this might need to be changed to 'durationchange' instead of 'timeupdate' eventually,
  6149. // however the durationchange event fires before this.player_.duration() is set,
  6150. // so the value cannot be written out using this method.
  6151. // Once the order of durationchange and this.player_.duration() being set is figured out,
  6152. // this can be updated.
  6153. this.on(player, 'timeupdate', this.updateContent);
  6154. this.on(player, 'loadedmetadata', this.updateContent);
  6155. }
  6156. /**
  6157. * Create the component's DOM element
  6158. *
  6159. * @return {Element}
  6160. * @method createEl
  6161. */
  6162. DurationDisplay.prototype.createEl = function createEl() {
  6163. var el = _Component.prototype.createEl.call(this, 'div', {
  6164. className: 'vjs-duration vjs-time-control vjs-control'
  6165. });
  6166. this.contentEl_ = Dom.createEl('div', {
  6167. className: 'vjs-duration-display',
  6168. // label the duration time for screen reader users
  6169. innerHTML: '<span class="vjs-control-text">' + this.localize('Duration Time') + '</span> 0:00'
  6170. }, {
  6171. // tell screen readers not to automatically read the time as it changes
  6172. 'aria-live': 'off'
  6173. });
  6174. el.appendChild(this.contentEl_);
  6175. return el;
  6176. };
  6177. /**
  6178. * Update duration time display
  6179. *
  6180. * @method updateContent
  6181. */
  6182. DurationDisplay.prototype.updateContent = function updateContent() {
  6183. var duration = this.player_.duration();
  6184. if (duration && this.duration_ !== duration) {
  6185. this.duration_ = duration;
  6186. var localizedText = this.localize('Duration Time');
  6187. var formattedTime = _utilsFormatTimeJs2['default'](duration);
  6188. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime; // label the duration time for screen reader users
  6189. }
  6190. };
  6191. return DurationDisplay;
  6192. })(_componentJs2['default']);
  6193. _componentJs2['default'].registerComponent('DurationDisplay', DurationDisplay);
  6194. exports['default'] = DurationDisplay;
  6195. module.exports = exports['default'];
  6196. }, { "../../component.js": 67, "../../utils/dom.js": 143, "../../utils/format-time.js": 146 }], 96: [function (_dereq_, module, exports) {
  6197. /**
  6198. * @file remaining-time-display.js
  6199. */
  6200. 'use strict';
  6201. exports.__esModule = true;
  6202. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6203. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6204. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6205. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6206. var _componentJs = _dereq_('../../component.js');
  6207. var _componentJs2 = _interopRequireDefault(_componentJs);
  6208. var _utilsDomJs = _dereq_('../../utils/dom.js');
  6209. var Dom = _interopRequireWildcard(_utilsDomJs);
  6210. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  6211. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  6212. /**
  6213. * Displays the time left in the video
  6214. *
  6215. * @param {Player|Object} player
  6216. * @param {Object=} options
  6217. * @extends Component
  6218. * @class RemainingTimeDisplay
  6219. */
  6220. var RemainingTimeDisplay = (function (_Component) {
  6221. _inherits(RemainingTimeDisplay, _Component);
  6222. function RemainingTimeDisplay(player, options) {
  6223. _classCallCheck(this, RemainingTimeDisplay);
  6224. _Component.call(this, player, options);
  6225. this.on(player, 'timeupdate', this.updateContent);
  6226. }
  6227. /**
  6228. * Create the component's DOM element
  6229. *
  6230. * @return {Element}
  6231. * @method createEl
  6232. */
  6233. RemainingTimeDisplay.prototype.createEl = function createEl() {
  6234. var el = _Component.prototype.createEl.call(this, 'div', {
  6235. className: 'vjs-remaining-time vjs-time-control vjs-control'
  6236. });
  6237. this.contentEl_ = Dom.createEl('div', {
  6238. className: 'vjs-remaining-time-display',
  6239. // label the remaining time for screen reader users
  6240. innerHTML: '<span class="vjs-control-text">' + this.localize('Remaining Time') + '</span> -0:00'
  6241. }, {
  6242. // tell screen readers not to automatically read the time as it changes
  6243. 'aria-live': 'off'
  6244. });
  6245. el.appendChild(this.contentEl_);
  6246. return el;
  6247. };
  6248. /**
  6249. * Update remaining time display
  6250. *
  6251. * @method updateContent
  6252. */
  6253. RemainingTimeDisplay.prototype.updateContent = function updateContent() {
  6254. if (this.player_.duration()) {
  6255. var localizedText = this.localize('Remaining Time');
  6256. var formattedTime = _utilsFormatTimeJs2['default'](this.player_.remainingTime());
  6257. if (formattedTime !== this.formattedTime_) {
  6258. this.formattedTime_ = formattedTime;
  6259. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> -' + formattedTime;
  6260. }
  6261. }
  6262. // Allows for smooth scrubbing, when player can't keep up.
  6263. // var time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
  6264. // this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
  6265. };
  6266. return RemainingTimeDisplay;
  6267. })(_componentJs2['default']);
  6268. _componentJs2['default'].registerComponent('RemainingTimeDisplay', RemainingTimeDisplay);
  6269. exports['default'] = RemainingTimeDisplay;
  6270. module.exports = exports['default'];
  6271. }, { "../../component.js": 67, "../../utils/dom.js": 143, "../../utils/format-time.js": 146 }], 97: [function (_dereq_, module, exports) {
  6272. /**
  6273. * @file time-divider.js
  6274. */
  6275. 'use strict';
  6276. exports.__esModule = true;
  6277. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6278. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6279. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6280. var _componentJs = _dereq_('../../component.js');
  6281. var _componentJs2 = _interopRequireDefault(_componentJs);
  6282. /**
  6283. * The separator between the current time and duration.
  6284. * Can be hidden if it's not needed in the design.
  6285. *
  6286. * @param {Player|Object} player
  6287. * @param {Object=} options
  6288. * @extends Component
  6289. * @class TimeDivider
  6290. */
  6291. var TimeDivider = (function (_Component) {
  6292. _inherits(TimeDivider, _Component);
  6293. function TimeDivider() {
  6294. _classCallCheck(this, TimeDivider);
  6295. _Component.apply(this, arguments);
  6296. }
  6297. /**
  6298. * Create the component's DOM element
  6299. *
  6300. * @return {Element}
  6301. * @method createEl
  6302. */
  6303. TimeDivider.prototype.createEl = function createEl() {
  6304. return _Component.prototype.createEl.call(this, 'div', {
  6305. className: 'vjs-time-control vjs-time-divider',
  6306. innerHTML: '<div><span>/</span></div>'
  6307. });
  6308. };
  6309. return TimeDivider;
  6310. })(_componentJs2['default']);
  6311. _componentJs2['default'].registerComponent('TimeDivider', TimeDivider);
  6312. exports['default'] = TimeDivider;
  6313. module.exports = exports['default'];
  6314. }, { "../../component.js": 67 }], 98: [function (_dereq_, module, exports) {
  6315. /**
  6316. * @file track-button.js
  6317. */
  6318. 'use strict';
  6319. exports.__esModule = true;
  6320. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6321. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6322. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6323. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6324. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js');
  6325. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  6326. var _componentJs = _dereq_('../component.js');
  6327. var _componentJs2 = _interopRequireDefault(_componentJs);
  6328. var _utilsFnJs = _dereq_('../utils/fn.js');
  6329. var Fn = _interopRequireWildcard(_utilsFnJs);
  6330. /**
  6331. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  6332. *
  6333. * @param {Player|Object} player
  6334. * @param {Object=} options
  6335. * @extends MenuButton
  6336. * @class TrackButton
  6337. */
  6338. var TrackButton = (function (_MenuButton) {
  6339. _inherits(TrackButton, _MenuButton);
  6340. function TrackButton(player, options) {
  6341. _classCallCheck(this, TrackButton);
  6342. var tracks = options.tracks;
  6343. _MenuButton.call(this, player, options);
  6344. if (this.items.length <= 1) {
  6345. this.hide();
  6346. }
  6347. if (!tracks) {
  6348. return;
  6349. }
  6350. var updateHandler = Fn.bind(this, this.update);
  6351. tracks.addEventListener('removetrack', updateHandler);
  6352. tracks.addEventListener('addtrack', updateHandler);
  6353. this.player_.on('dispose', function () {
  6354. tracks.removeEventListener('removetrack', updateHandler);
  6355. tracks.removeEventListener('addtrack', updateHandler);
  6356. });
  6357. }
  6358. return TrackButton;
  6359. })(_menuMenuButtonJs2['default']);
  6360. _componentJs2['default'].registerComponent('TrackButton', TrackButton);
  6361. exports['default'] = TrackButton;
  6362. module.exports = exports['default'];
  6363. }, { "../component.js": 67, "../menu/menu-button.js": 109, "../utils/fn.js": 145 }], 99: [function (_dereq_, module, exports) {
  6364. /**
  6365. * @file volume-bar.js
  6366. */
  6367. 'use strict';
  6368. exports.__esModule = true;
  6369. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6370. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6371. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6372. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6373. var _sliderSliderJs = _dereq_('../../slider/slider.js');
  6374. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs);
  6375. var _componentJs = _dereq_('../../component.js');
  6376. var _componentJs2 = _interopRequireDefault(_componentJs);
  6377. var _utilsFnJs = _dereq_('../../utils/fn.js');
  6378. var Fn = _interopRequireWildcard(_utilsFnJs);
  6379. // Required children
  6380. var _volumeLevelJs = _dereq_('./volume-level.js');
  6381. var _volumeLevelJs2 = _interopRequireDefault(_volumeLevelJs);
  6382. /**
  6383. * The bar that contains the volume level and can be clicked on to adjust the level
  6384. *
  6385. * @param {Player|Object} player
  6386. * @param {Object=} options
  6387. * @extends Slider
  6388. * @class VolumeBar
  6389. */
  6390. var VolumeBar = (function (_Slider) {
  6391. _inherits(VolumeBar, _Slider);
  6392. function VolumeBar(player, options) {
  6393. _classCallCheck(this, VolumeBar);
  6394. _Slider.call(this, player, options);
  6395. this.on(player, 'volumechange', this.updateARIAAttributes);
  6396. player.ready(Fn.bind(this, this.updateARIAAttributes));
  6397. }
  6398. /**
  6399. * Create the component's DOM element
  6400. *
  6401. * @return {Element}
  6402. * @method createEl
  6403. */
  6404. VolumeBar.prototype.createEl = function createEl() {
  6405. return _Slider.prototype.createEl.call(this, 'div', {
  6406. className: 'vjs-volume-bar vjs-slider-bar'
  6407. }, {
  6408. 'aria-label': 'volume level'
  6409. });
  6410. };
  6411. /**
  6412. * Handle mouse move on volume bar
  6413. *
  6414. * @method handleMouseMove
  6415. */
  6416. VolumeBar.prototype.handleMouseMove = function handleMouseMove(event) {
  6417. this.checkMuted();
  6418. this.player_.volume(this.calculateDistance(event));
  6419. };
  6420. VolumeBar.prototype.checkMuted = function checkMuted() {
  6421. if (this.player_.muted()) {
  6422. this.player_.muted(false);
  6423. }
  6424. };
  6425. /**
  6426. * Get percent of volume level
  6427. *
  6428. * @retun {Number} Volume level percent
  6429. * @method getPercent
  6430. */
  6431. VolumeBar.prototype.getPercent = function getPercent() {
  6432. if (this.player_.muted()) {
  6433. return 0;
  6434. } else {
  6435. return this.player_.volume();
  6436. }
  6437. };
  6438. /**
  6439. * Increase volume level for keyboard users
  6440. *
  6441. * @method stepForward
  6442. */
  6443. VolumeBar.prototype.stepForward = function stepForward() {
  6444. this.checkMuted();
  6445. this.player_.volume(this.player_.volume() + 0.1);
  6446. };
  6447. /**
  6448. * Decrease volume level for keyboard users
  6449. *
  6450. * @method stepBack
  6451. */
  6452. VolumeBar.prototype.stepBack = function stepBack() {
  6453. this.checkMuted();
  6454. this.player_.volume(this.player_.volume() - 0.1);
  6455. };
  6456. /**
  6457. * Update ARIA accessibility attributes
  6458. *
  6459. * @method updateARIAAttributes
  6460. */
  6461. VolumeBar.prototype.updateARIAAttributes = function updateARIAAttributes() {
  6462. // Current value of volume bar as a percentage
  6463. var volume = (this.player_.volume() * 100).toFixed(2);
  6464. this.el_.setAttribute('aria-valuenow', volume);
  6465. this.el_.setAttribute('aria-valuetext', volume + '%');
  6466. };
  6467. return VolumeBar;
  6468. })(_sliderSliderJs2['default']);
  6469. VolumeBar.prototype.options_ = {
  6470. children: ['volumeLevel'],
  6471. 'barName': 'volumeLevel'
  6472. };
  6473. VolumeBar.prototype.playerEvent = 'volumechange';
  6474. _componentJs2['default'].registerComponent('VolumeBar', VolumeBar);
  6475. exports['default'] = VolumeBar;
  6476. module.exports = exports['default'];
  6477. }, { "../../component.js": 67, "../../slider/slider.js": 119, "../../utils/fn.js": 145, "./volume-level.js": 101 }], 100: [function (_dereq_, module, exports) {
  6478. /**
  6479. * @file volume-control.js
  6480. */
  6481. 'use strict';
  6482. exports.__esModule = true;
  6483. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6484. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6485. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6486. var _componentJs = _dereq_('../../component.js');
  6487. var _componentJs2 = _interopRequireDefault(_componentJs);
  6488. // Required children
  6489. var _volumeBarJs = _dereq_('./volume-bar.js');
  6490. var _volumeBarJs2 = _interopRequireDefault(_volumeBarJs);
  6491. /**
  6492. * The component for controlling the volume level
  6493. *
  6494. * @param {Player|Object} player
  6495. * @param {Object=} options
  6496. * @extends Component
  6497. * @class VolumeControl
  6498. */
  6499. var VolumeControl = (function (_Component) {
  6500. _inherits(VolumeControl, _Component);
  6501. function VolumeControl(player, options) {
  6502. _classCallCheck(this, VolumeControl);
  6503. _Component.call(this, player, options);
  6504. // hide volume controls when they're not supported by the current tech
  6505. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  6506. this.addClass('vjs-hidden');
  6507. }
  6508. this.on(player, 'loadstart', function () {
  6509. if (player.tech_['featuresVolumeControl'] === false) {
  6510. this.addClass('vjs-hidden');
  6511. } else {
  6512. this.removeClass('vjs-hidden');
  6513. }
  6514. });
  6515. }
  6516. /**
  6517. * Create the component's DOM element
  6518. *
  6519. * @return {Element}
  6520. * @method createEl
  6521. */
  6522. VolumeControl.prototype.createEl = function createEl() {
  6523. return _Component.prototype.createEl.call(this, 'div', {
  6524. className: 'vjs-volume-control vjs-control'
  6525. });
  6526. };
  6527. return VolumeControl;
  6528. })(_componentJs2['default']);
  6529. VolumeControl.prototype.options_ = {
  6530. children: ['volumeBar']
  6531. };
  6532. _componentJs2['default'].registerComponent('VolumeControl', VolumeControl);
  6533. exports['default'] = VolumeControl;
  6534. module.exports = exports['default'];
  6535. }, { "../../component.js": 67, "./volume-bar.js": 99 }], 101: [function (_dereq_, module, exports) {
  6536. /**
  6537. * @file volume-level.js
  6538. */
  6539. 'use strict';
  6540. exports.__esModule = true;
  6541. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6542. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6543. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6544. var _componentJs = _dereq_('../../component.js');
  6545. var _componentJs2 = _interopRequireDefault(_componentJs);
  6546. /**
  6547. * Shows volume level
  6548. *
  6549. * @param {Player|Object} player
  6550. * @param {Object=} options
  6551. * @extends Component
  6552. * @class VolumeLevel
  6553. */
  6554. var VolumeLevel = (function (_Component) {
  6555. _inherits(VolumeLevel, _Component);
  6556. function VolumeLevel() {
  6557. _classCallCheck(this, VolumeLevel);
  6558. _Component.apply(this, arguments);
  6559. }
  6560. /**
  6561. * Create the component's DOM element
  6562. *
  6563. * @return {Element}
  6564. * @method createEl
  6565. */
  6566. VolumeLevel.prototype.createEl = function createEl() {
  6567. return _Component.prototype.createEl.call(this, 'div', {
  6568. className: 'vjs-volume-level',
  6569. innerHTML: '<span class="vjs-control-text"></span>'
  6570. });
  6571. };
  6572. return VolumeLevel;
  6573. })(_componentJs2['default']);
  6574. _componentJs2['default'].registerComponent('VolumeLevel', VolumeLevel);
  6575. exports['default'] = VolumeLevel;
  6576. module.exports = exports['default'];
  6577. }, { "../../component.js": 67 }], 102: [function (_dereq_, module, exports) {
  6578. /**
  6579. * @file volume-menu-button.js
  6580. */
  6581. 'use strict';
  6582. exports.__esModule = true;
  6583. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6584. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6585. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6586. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6587. var _utilsFnJs = _dereq_('../utils/fn.js');
  6588. var Fn = _interopRequireWildcard(_utilsFnJs);
  6589. var _componentJs = _dereq_('../component.js');
  6590. var _componentJs2 = _interopRequireDefault(_componentJs);
  6591. var _popupPopupJs = _dereq_('../popup/popup.js');
  6592. var _popupPopupJs2 = _interopRequireDefault(_popupPopupJs);
  6593. var _popupPopupButtonJs = _dereq_('../popup/popup-button.js');
  6594. var _popupPopupButtonJs2 = _interopRequireDefault(_popupPopupButtonJs);
  6595. var _muteToggleJs = _dereq_('./mute-toggle.js');
  6596. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs);
  6597. var _volumeControlVolumeBarJs = _dereq_('./volume-control/volume-bar.js');
  6598. var _volumeControlVolumeBarJs2 = _interopRequireDefault(_volumeControlVolumeBarJs);
  6599. /**
  6600. * Button for volume popup
  6601. *
  6602. * @param {Player|Object} player
  6603. * @param {Object=} options
  6604. * @extends PopupButton
  6605. * @class VolumeMenuButton
  6606. */
  6607. var VolumeMenuButton = (function (_PopupButton) {
  6608. _inherits(VolumeMenuButton, _PopupButton);
  6609. function VolumeMenuButton(player) {
  6610. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  6611. _classCallCheck(this, VolumeMenuButton);
  6612. // Default to inline
  6613. if (options.inline === undefined) {
  6614. options.inline = true;
  6615. }
  6616. // If the vertical option isn't passed at all, default to true.
  6617. if (options.vertical === undefined) {
  6618. // If an inline volumeMenuButton is used, we should default to using
  6619. // a horizontal slider for obvious reasons.
  6620. if (options.inline) {
  6621. options.vertical = false;
  6622. } else {
  6623. options.vertical = true;
  6624. }
  6625. }
  6626. // The vertical option needs to be set on the volumeBar as well,
  6627. // since that will need to be passed along to the VolumeBar constructor
  6628. options.volumeBar = options.volumeBar || {};
  6629. options.volumeBar.vertical = !!options.vertical;
  6630. _PopupButton.call(this, player, options);
  6631. // Same listeners as MuteToggle
  6632. this.on(player, 'volumechange', this.volumeUpdate);
  6633. this.on(player, 'loadstart', this.volumeUpdate);
  6634. // hide mute toggle if the current tech doesn't support volume control
  6635. function updateVisibility() {
  6636. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  6637. this.addClass('vjs-hidden');
  6638. } else {
  6639. this.removeClass('vjs-hidden');
  6640. }
  6641. }
  6642. updateVisibility.call(this);
  6643. this.on(player, 'loadstart', updateVisibility);
  6644. this.on(this.volumeBar, ['slideractive', 'focus'], function () {
  6645. this.addClass('vjs-slider-active');
  6646. });
  6647. this.on(this.volumeBar, ['sliderinactive', 'blur'], function () {
  6648. this.removeClass('vjs-slider-active');
  6649. });
  6650. this.on(this.volumeBar, ['focus'], function () {
  6651. this.addClass('vjs-lock-showing');
  6652. });
  6653. this.on(this.volumeBar, ['blur'], function () {
  6654. this.removeClass('vjs-lock-showing');
  6655. });
  6656. }
  6657. /**
  6658. * Allow sub components to stack CSS class names
  6659. *
  6660. * @return {String} The constructed class name
  6661. * @method buildCSSClass
  6662. */
  6663. VolumeMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  6664. var orientationClass = '';
  6665. if (!!this.options_.vertical) {
  6666. orientationClass = 'vjs-volume-menu-button-vertical';
  6667. } else {
  6668. orientationClass = 'vjs-volume-menu-button-horizontal';
  6669. }
  6670. return 'vjs-volume-menu-button ' + _PopupButton.prototype.buildCSSClass.call(this) + ' ' + orientationClass;
  6671. };
  6672. /**
  6673. * Allow sub components to stack CSS class names
  6674. *
  6675. * @return {Popup} The volume popup button
  6676. * @method createPopup
  6677. */
  6678. VolumeMenuButton.prototype.createPopup = function createPopup() {
  6679. var popup = new _popupPopupJs2['default'](this.player_, {
  6680. contentElType: 'div'
  6681. });
  6682. var vb = new _volumeControlVolumeBarJs2['default'](this.player_, this.options_.volumeBar);
  6683. popup.addChild(vb);
  6684. this.menuContent = popup;
  6685. this.volumeBar = vb;
  6686. this.attachVolumeBarEvents();
  6687. return popup;
  6688. };
  6689. /**
  6690. * Handle click on volume popup and calls super
  6691. *
  6692. * @method handleClick
  6693. */
  6694. VolumeMenuButton.prototype.handleClick = function handleClick() {
  6695. _muteToggleJs2['default'].prototype.handleClick.call(this);
  6696. _PopupButton.prototype.handleClick.call(this);
  6697. };
  6698. VolumeMenuButton.prototype.attachVolumeBarEvents = function attachVolumeBarEvents() {
  6699. this.menuContent.on(['mousedown', 'touchdown'], Fn.bind(this, this.handleMouseDown));
  6700. };
  6701. VolumeMenuButton.prototype.handleMouseDown = function handleMouseDown(event) {
  6702. this.on(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
  6703. this.on(this.el_.ownerDocument, ['mouseup', 'touchend'], this.handleMouseUp);
  6704. };
  6705. VolumeMenuButton.prototype.handleMouseUp = function handleMouseUp(event) {
  6706. this.off(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
  6707. };
  6708. return VolumeMenuButton;
  6709. })(_popupPopupButtonJs2['default']);
  6710. VolumeMenuButton.prototype.volumeUpdate = _muteToggleJs2['default'].prototype.update;
  6711. VolumeMenuButton.prototype.controlText_ = 'Mute';
  6712. _componentJs2['default'].registerComponent('VolumeMenuButton', VolumeMenuButton);
  6713. exports['default'] = VolumeMenuButton;
  6714. module.exports = exports['default'];
  6715. }, { "../component.js": 67, "../popup/popup-button.js": 115, "../popup/popup.js": 116, "../utils/fn.js": 145, "./mute-toggle.js": 73, "./volume-control/volume-bar.js": 99 }], 103: [function (_dereq_, module, exports) {
  6716. /**
  6717. * @file error-display.js
  6718. */
  6719. 'use strict';
  6720. exports.__esModule = true;
  6721. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6722. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6723. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6724. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6725. var _component = _dereq_('./component');
  6726. var _component2 = _interopRequireDefault(_component);
  6727. var _modalDialog = _dereq_('./modal-dialog');
  6728. var _modalDialog2 = _interopRequireDefault(_modalDialog);
  6729. var _utilsDom = _dereq_('./utils/dom');
  6730. var Dom = _interopRequireWildcard(_utilsDom);
  6731. var _utilsMergeOptions = _dereq_('./utils/merge-options');
  6732. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  6733. /**
  6734. * Display that an error has occurred making the video unplayable.
  6735. *
  6736. * @extends ModalDialog
  6737. * @class ErrorDisplay
  6738. */
  6739. var ErrorDisplay = (function (_ModalDialog) {
  6740. _inherits(ErrorDisplay, _ModalDialog);
  6741. /**
  6742. * Constructor for error display modal.
  6743. *
  6744. * @param {Player} player
  6745. * @param {Object} [options]
  6746. */
  6747. function ErrorDisplay(player, options) {
  6748. _classCallCheck(this, ErrorDisplay);
  6749. _ModalDialog.call(this, player, options);
  6750. this.on(player, 'error', this.open);
  6751. }
  6752. /**
  6753. * Include the old class for backward-compatibility.
  6754. *
  6755. * This can be removed in 6.0.
  6756. *
  6757. * @method buildCSSClass
  6758. * @deprecated
  6759. * @return {String}
  6760. */
  6761. ErrorDisplay.prototype.buildCSSClass = function buildCSSClass() {
  6762. return 'vjs-error-display ' + _ModalDialog.prototype.buildCSSClass.call(this);
  6763. };
  6764. /**
  6765. * Generates the modal content based on the player error.
  6766. *
  6767. * @return {String|Null}
  6768. */
  6769. ErrorDisplay.prototype.content = function content() {
  6770. var error = this.player().error();
  6771. return error ? this.localize(error.message) : '';
  6772. };
  6773. return ErrorDisplay;
  6774. })(_modalDialog2['default']);
  6775. ErrorDisplay.prototype.options_ = _utilsMergeOptions2['default'](_modalDialog2['default'].prototype.options_, {
  6776. fillAlways: true,
  6777. temporary: false,
  6778. uncloseable: true
  6779. });
  6780. _component2['default'].registerComponent('ErrorDisplay', ErrorDisplay);
  6781. exports['default'] = ErrorDisplay;
  6782. module.exports = exports['default'];
  6783. }, { "./component": 67, "./modal-dialog": 112, "./utils/dom": 143, "./utils/merge-options": 149 }], 104: [function (_dereq_, module, exports) {
  6784. /**
  6785. * @file event-target.js
  6786. */
  6787. 'use strict';
  6788. exports.__esModule = true;
  6789. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  6790. var _utilsEventsJs = _dereq_('./utils/events.js');
  6791. var Events = _interopRequireWildcard(_utilsEventsJs);
  6792. var EventTarget = function EventTarget() { };
  6793. EventTarget.prototype.allowedEvents_ = {};
  6794. EventTarget.prototype.on = function (type, fn) {
  6795. // Remove the addEventListener alias before calling Events.on
  6796. // so we don't get into an infinite type loop
  6797. var ael = this.addEventListener;
  6798. this.addEventListener = function () { };
  6799. Events.on(this, type, fn);
  6800. this.addEventListener = ael;
  6801. };
  6802. EventTarget.prototype.addEventListener = EventTarget.prototype.on;
  6803. EventTarget.prototype.off = function (type, fn) {
  6804. Events.off(this, type, fn);
  6805. };
  6806. EventTarget.prototype.removeEventListener = EventTarget.prototype.off;
  6807. EventTarget.prototype.one = function (type, fn) {
  6808. // Remove the addEventListener alias before calling Events.on
  6809. // so we don't get into an infinite type loop
  6810. var ael = this.addEventListener;
  6811. this.addEventListener = function () { };
  6812. Events.one(this, type, fn);
  6813. this.addEventListener = ael;
  6814. };
  6815. EventTarget.prototype.trigger = function (event) {
  6816. var type = event.type || event;
  6817. if (typeof event === 'string') {
  6818. event = {
  6819. type: type
  6820. };
  6821. }
  6822. event = Events.fixEvent(event);
  6823. if (this.allowedEvents_[type] && this['on' + type]) {
  6824. this['on' + type](event);
  6825. }
  6826. Events.trigger(this, event);
  6827. };
  6828. // The standard DOM EventTarget.dispatchEvent() is aliased to trigger()
  6829. EventTarget.prototype.dispatchEvent = EventTarget.prototype.trigger;
  6830. exports['default'] = EventTarget;
  6831. module.exports = exports['default'];
  6832. }, { "./utils/events.js": 144 }], 105: [function (_dereq_, module, exports) {
  6833. 'use strict';
  6834. exports.__esModule = true;
  6835. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6836. var _utilsLog = _dereq_('./utils/log');
  6837. var _utilsLog2 = _interopRequireDefault(_utilsLog);
  6838. /*
  6839. * @file extend.js
  6840. *
  6841. * A combination of node inherits and babel's inherits (after transpile).
  6842. * Both work the same but node adds `super_` to the subClass
  6843. * and Bable adds the superClass as __proto__. Both seem useful.
  6844. */
  6845. var _inherits = function _inherits(subClass, superClass) {
  6846. if (typeof superClass !== 'function' && superClass !== null) {
  6847. throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
  6848. }
  6849. subClass.prototype = Object.create(superClass && superClass.prototype, {
  6850. constructor: {
  6851. value: subClass,
  6852. enumerable: false,
  6853. writable: true,
  6854. configurable: true
  6855. }
  6856. });
  6857. if (superClass) {
  6858. // node
  6859. subClass.super_ = superClass;
  6860. }
  6861. };
  6862. /*
  6863. * Function for subclassing using the same inheritance that
  6864. * videojs uses internally
  6865. * ```js
  6866. * var Button = videojs.getComponent('Button');
  6867. * ```
  6868. * ```js
  6869. * var MyButton = videojs.extend(Button, {
  6870. * constructor: function(player, options) {
  6871. * Button.call(this, player, options);
  6872. * },
  6873. * onClick: function() {
  6874. * // doSomething
  6875. * }
  6876. * });
  6877. * ```
  6878. */
  6879. var extendFn = function extendFn(superClass) {
  6880. var subClassMethods = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  6881. var subClass = function subClass() {
  6882. superClass.apply(this, arguments);
  6883. };
  6884. var methods = {};
  6885. if (typeof subClassMethods === 'object') {
  6886. if (typeof subClassMethods.init === 'function') {
  6887. _utilsLog2['default'].warn('Constructor logic via init() is deprecated; please use constructor() instead.');
  6888. subClassMethods.constructor = subClassMethods.init;
  6889. }
  6890. if (subClassMethods.constructor !== Object.prototype.constructor) {
  6891. subClass = subClassMethods.constructor;
  6892. }
  6893. methods = subClassMethods;
  6894. } else if (typeof subClassMethods === 'function') {
  6895. subClass = subClassMethods;
  6896. }
  6897. _inherits(subClass, superClass);
  6898. // Extend subObj's prototype with functions and other properties from props
  6899. for (var name in methods) {
  6900. if (methods.hasOwnProperty(name)) {
  6901. subClass.prototype[name] = methods[name];
  6902. }
  6903. }
  6904. return subClass;
  6905. };
  6906. exports['default'] = extendFn;
  6907. module.exports = exports['default'];
  6908. }, { "./utils/log": 148 }], 106: [function (_dereq_, module, exports) {
  6909. /**
  6910. * @file fullscreen-api.js
  6911. */
  6912. 'use strict';
  6913. exports.__esModule = true;
  6914. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6915. var _globalDocument = _dereq_('global/document');
  6916. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  6917. /*
  6918. * Store the browser-specific methods for the fullscreen API
  6919. * @type {Object|undefined}
  6920. * @private
  6921. */
  6922. var FullscreenApi = {};
  6923. // browser API methods
  6924. // map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js
  6925. var apiMap = [
  6926. // Spec: https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
  6927. ['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
  6928. // WebKit
  6929. ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6930. // Old WebKit (Safari 5.1)
  6931. ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6932. // Mozilla
  6933. ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'],
  6934. // Microsoft
  6935. ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];
  6936. var specApi = apiMap[0];
  6937. var browserApi = undefined;
  6938. // determine the supported set of functions
  6939. for (var i = 0; i < apiMap.length; i++) {
  6940. // check for exitFullscreen function
  6941. if (apiMap[i][1] in _globalDocument2['default']) {
  6942. browserApi = apiMap[i];
  6943. break;
  6944. }
  6945. }
  6946. // map the browser API names to the spec API names
  6947. if (browserApi) {
  6948. for (var i = 0; i < browserApi.length; i++) {
  6949. FullscreenApi[specApi[i]] = browserApi[i];
  6950. }
  6951. }
  6952. exports['default'] = FullscreenApi;
  6953. module.exports = exports['default'];
  6954. }, { "global/document": 1 }], 107: [function (_dereq_, module, exports) {
  6955. /**
  6956. * @file loading-spinner.js
  6957. */
  6958. 'use strict';
  6959. exports.__esModule = true;
  6960. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6961. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6962. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6963. var _component = _dereq_('./component');
  6964. var _component2 = _interopRequireDefault(_component);
  6965. /* Loading Spinner
  6966. ================================================================================ */
  6967. /**
  6968. * Loading spinner for waiting events
  6969. *
  6970. * @extends Component
  6971. * @class LoadingSpinner
  6972. */
  6973. var LoadingSpinner = (function (_Component) {
  6974. _inherits(LoadingSpinner, _Component);
  6975. function LoadingSpinner() {
  6976. _classCallCheck(this, LoadingSpinner);
  6977. _Component.apply(this, arguments);
  6978. }
  6979. /**
  6980. * Create the component's DOM element
  6981. *
  6982. * @method createEl
  6983. */
  6984. LoadingSpinner.prototype.createEl = function createEl() {
  6985. return _Component.prototype.createEl.call(this, 'div', {
  6986. className: 'vjs-loading-spinner',
  6987. dir: 'ltr'
  6988. });
  6989. };
  6990. return LoadingSpinner;
  6991. })(_component2['default']);
  6992. _component2['default'].registerComponent('LoadingSpinner', LoadingSpinner);
  6993. exports['default'] = LoadingSpinner;
  6994. module.exports = exports['default'];
  6995. }, { "./component": 67 }], 108: [function (_dereq_, module, exports) {
  6996. /**
  6997. * @file media-error.js
  6998. */
  6999. 'use strict';
  7000. exports.__esModule = true;
  7001. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7002. var _objectAssign = _dereq_('object.assign');
  7003. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  7004. /*
  7005. * Custom MediaError to mimic the HTML5 MediaError
  7006. *
  7007. * @param {Number} code The media error code
  7008. */
  7009. var MediaError = function MediaError(code) {
  7010. if (typeof code === 'number') {
  7011. this.code = code;
  7012. } else if (typeof code === 'string') {
  7013. // default code is zero, so this is a custom error
  7014. this.message = code;
  7015. } else if (typeof code === 'object') {
  7016. // object
  7017. _objectAssign2['default'](this, code);
  7018. }
  7019. if (!this.message) {
  7020. this.message = MediaError.defaultMessages[this.code] || '';
  7021. }
  7022. };
  7023. /*
  7024. * The error code that refers two one of the defined
  7025. * MediaError types
  7026. *
  7027. * @type {Number}
  7028. */
  7029. MediaError.prototype.code = 0;
  7030. /*
  7031. * An optional message to be shown with the error.
  7032. * Message is not part of the HTML5 video spec
  7033. * but allows for more informative custom errors.
  7034. *
  7035. * @type {String}
  7036. */
  7037. MediaError.prototype.message = '';
  7038. /*
  7039. * An optional status code that can be set by plugins
  7040. * to allow even more detail about the error.
  7041. * For example the HLS plugin might provide the specific
  7042. * HTTP status code that was returned when the error
  7043. * occurred, then allowing a custom error overlay
  7044. * to display more information.
  7045. *
  7046. * @type {Array}
  7047. */
  7048. MediaError.prototype.status = null;
  7049. MediaError.errorTypes = ['MEDIA_ERR_CUSTOM', // = 0
  7050. 'MEDIA_ERR_ABORTED', // = 1
  7051. 'MEDIA_ERR_NETWORK', // = 2
  7052. 'MEDIA_ERR_DECODE', // = 3
  7053. 'MEDIA_ERR_SRC_NOT_SUPPORTED', // = 4
  7054. 'MEDIA_ERR_ENCRYPTED' // = 5
  7055. ];
  7056. MediaError.defaultMessages = {
  7057. 1: 'You aborted the media playback',
  7058. 2: 'A network error caused the media download to fail part-way.',
  7059. 3: 'The media playback was aborted due to a corruption problem or because the media used features your browser did not support.',
  7060. 4: 'The media could not be loaded, either because the server or network failed or because the format is not supported.',
  7061. 5: 'The media is encrypted and we do not have the keys to decrypt it.'
  7062. };
  7063. // Add types as properties on MediaError
  7064. // e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
  7065. for (var errNum = 0; errNum < MediaError.errorTypes.length; errNum++) {
  7066. MediaError[MediaError.errorTypes[errNum]] = errNum;
  7067. // values should be accessible on both the class and instance
  7068. MediaError.prototype[MediaError.errorTypes[errNum]] = errNum;
  7069. }
  7070. exports['default'] = MediaError;
  7071. module.exports = exports['default'];
  7072. }, { "object.assign": 45 }], 109: [function (_dereq_, module, exports) {
  7073. /**
  7074. * @file menu-button.js
  7075. */
  7076. 'use strict';
  7077. exports.__esModule = true;
  7078. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  7079. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7080. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7081. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7082. var _clickableComponentJs = _dereq_('../clickable-component.js');
  7083. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  7084. var _componentJs = _dereq_('../component.js');
  7085. var _componentJs2 = _interopRequireDefault(_componentJs);
  7086. var _menuJs = _dereq_('./menu.js');
  7087. var _menuJs2 = _interopRequireDefault(_menuJs);
  7088. var _utilsDomJs = _dereq_('../utils/dom.js');
  7089. var Dom = _interopRequireWildcard(_utilsDomJs);
  7090. var _utilsFnJs = _dereq_('../utils/fn.js');
  7091. var Fn = _interopRequireWildcard(_utilsFnJs);
  7092. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  7093. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  7094. /**
  7095. * A button class with a popup menu
  7096. *
  7097. * @param {Player|Object} player
  7098. * @param {Object=} options
  7099. * @extends Button
  7100. * @class MenuButton
  7101. */
  7102. var MenuButton = (function (_ClickableComponent) {
  7103. _inherits(MenuButton, _ClickableComponent);
  7104. function MenuButton(player) {
  7105. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  7106. _classCallCheck(this, MenuButton);
  7107. _ClickableComponent.call(this, player, options);
  7108. this.update();
  7109. this.enabled_ = true;
  7110. this.el_.setAttribute('aria-haspopup', 'true');
  7111. this.el_.setAttribute('role', 'menuitem');
  7112. this.on('keydown', this.handleSubmenuKeyPress);
  7113. }
  7114. /**
  7115. * Update menu
  7116. *
  7117. * @method update
  7118. */
  7119. MenuButton.prototype.update = function update() {
  7120. var menu = this.createMenu();
  7121. if (this.menu) {
  7122. this.removeChild(this.menu);
  7123. }
  7124. this.menu = menu;
  7125. this.addChild(menu);
  7126. /**
  7127. * Track the state of the menu button
  7128. *
  7129. * @type {Boolean}
  7130. * @private
  7131. */
  7132. this.buttonPressed_ = false;
  7133. this.el_.setAttribute('aria-expanded', 'false');
  7134. if (this.items && this.items.length === 0) {
  7135. this.hide();
  7136. } else if (this.items && this.items.length > 1) {
  7137. this.show();
  7138. }
  7139. };
  7140. /**
  7141. * Create menu
  7142. *
  7143. * @return {Menu} The constructed menu
  7144. * @method createMenu
  7145. */
  7146. MenuButton.prototype.createMenu = function createMenu() {
  7147. var menu = new _menuJs2['default'](this.player_);
  7148. // Add a title list item to the top
  7149. if (this.options_.title) {
  7150. var title = Dom.createEl('li', {
  7151. className: 'vjs-menu-title',
  7152. innerHTML: _utilsToTitleCaseJs2['default'](this.options_.title),
  7153. tabIndex: -1
  7154. });
  7155. menu.children_.unshift(title);
  7156. Dom.insertElFirst(title, menu.contentEl());
  7157. }
  7158. this.items = this['createItems']();
  7159. if (this.items) {
  7160. // Add menu items to the menu
  7161. for (var i = 0; i < this.items.length; i++) {
  7162. menu.addItem(this.items[i]);
  7163. }
  7164. }
  7165. return menu;
  7166. };
  7167. /**
  7168. * Create the list of menu items. Specific to each subclass.
  7169. *
  7170. * @method createItems
  7171. */
  7172. MenuButton.prototype.createItems = function createItems() { };
  7173. /**
  7174. * Create the component's DOM element
  7175. *
  7176. * @return {Element}
  7177. * @method createEl
  7178. */
  7179. MenuButton.prototype.createEl = function createEl() {
  7180. return _ClickableComponent.prototype.createEl.call(this, 'div', {
  7181. className: this.buildCSSClass()
  7182. });
  7183. };
  7184. /**
  7185. * Allow sub components to stack CSS class names
  7186. *
  7187. * @return {String} The constructed class name
  7188. * @method buildCSSClass
  7189. */
  7190. MenuButton.prototype.buildCSSClass = function buildCSSClass() {
  7191. var menuButtonClass = 'vjs-menu-button';
  7192. // If the inline option is passed, we want to use different styles altogether.
  7193. if (this.options_.inline === true) {
  7194. menuButtonClass += '-inline';
  7195. } else {
  7196. menuButtonClass += '-popup';
  7197. }
  7198. return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this);
  7199. };
  7200. /**
  7201. * When you click the button it adds focus, which
  7202. * will show the menu indefinitely.
  7203. * So we'll remove focus when the mouse leaves the button.
  7204. * Focus is needed for tab navigation.
  7205. * Allow sub components to stack CSS class names
  7206. *
  7207. * @method handleClick
  7208. */
  7209. MenuButton.prototype.handleClick = function handleClick() {
  7210. this.one('mouseout', Fn.bind(this, function () {
  7211. this.menu.unlockShowing();
  7212. this.el_.blur();
  7213. }));
  7214. if (this.buttonPressed_) {
  7215. this.unpressButton();
  7216. } else {
  7217. this.pressButton();
  7218. }
  7219. };
  7220. /**
  7221. * Handle key press on menu
  7222. *
  7223. * @param {Object} event Key press event
  7224. * @method handleKeyPress
  7225. */
  7226. MenuButton.prototype.handleKeyPress = function handleKeyPress(event) {
  7227. // Escape (27) key or Tab (9) key unpress the 'button'
  7228. if (event.which === 27 || event.which === 9) {
  7229. if (this.buttonPressed_) {
  7230. this.unpressButton();
  7231. }
  7232. // Don't preventDefault for Tab key - we still want to lose focus
  7233. if (event.which !== 9) {
  7234. event.preventDefault();
  7235. }
  7236. // Up (38) key or Down (40) key press the 'button'
  7237. } else if (event.which === 38 || event.which === 40) {
  7238. if (!this.buttonPressed_) {
  7239. this.pressButton();
  7240. event.preventDefault();
  7241. }
  7242. } else {
  7243. _ClickableComponent.prototype.handleKeyPress.call(this, event);
  7244. }
  7245. };
  7246. /**
  7247. * Handle key press on submenu
  7248. *
  7249. * @param {Object} event Key press event
  7250. * @method handleSubmenuKeyPress
  7251. */
  7252. MenuButton.prototype.handleSubmenuKeyPress = function handleSubmenuKeyPress(event) {
  7253. // Escape (27) key or Tab (9) key unpress the 'button'
  7254. if (event.which === 27 || event.which === 9) {
  7255. if (this.buttonPressed_) {
  7256. this.unpressButton();
  7257. }
  7258. // Don't preventDefault for Tab key - we still want to lose focus
  7259. if (event.which !== 9) {
  7260. event.preventDefault();
  7261. }
  7262. }
  7263. };
  7264. /**
  7265. * Makes changes based on button pressed
  7266. *
  7267. * @method pressButton
  7268. */
  7269. MenuButton.prototype.pressButton = function pressButton() {
  7270. if (this.enabled_) {
  7271. this.buttonPressed_ = true;
  7272. this.menu.lockShowing();
  7273. this.el_.setAttribute('aria-expanded', 'true');
  7274. this.menu.focus(); // set the focus into the submenu
  7275. }
  7276. };
  7277. /**
  7278. * Makes changes based on button unpressed
  7279. *
  7280. * @method unpressButton
  7281. */
  7282. MenuButton.prototype.unpressButton = function unpressButton() {
  7283. if (this.enabled_) {
  7284. this.buttonPressed_ = false;
  7285. this.menu.unlockShowing();
  7286. this.el_.setAttribute('aria-expanded', 'false');
  7287. this.el_.focus(); // Set focus back to this menu button
  7288. }
  7289. };
  7290. /**
  7291. * Disable the menu button
  7292. *
  7293. * @return {Component}
  7294. * @method disable
  7295. */
  7296. MenuButton.prototype.disable = function disable() {
  7297. // Unpress, but don't force focus on this button
  7298. this.buttonPressed_ = false;
  7299. this.menu.unlockShowing();
  7300. this.el_.setAttribute('aria-expanded', 'false');
  7301. this.enabled_ = false;
  7302. return _ClickableComponent.prototype.disable.call(this);
  7303. };
  7304. /**
  7305. * Enable the menu button
  7306. *
  7307. * @return {Component}
  7308. * @method disable
  7309. */
  7310. MenuButton.prototype.enable = function enable() {
  7311. this.enabled_ = true;
  7312. return _ClickableComponent.prototype.enable.call(this);
  7313. };
  7314. return MenuButton;
  7315. })(_clickableComponentJs2['default']);
  7316. _componentJs2['default'].registerComponent('MenuButton', MenuButton);
  7317. exports['default'] = MenuButton;
  7318. module.exports = exports['default'];
  7319. }, { "../clickable-component.js": 65, "../component.js": 67, "../utils/dom.js": 143, "../utils/fn.js": 145, "../utils/to-title-case.js": 152, "./menu.js": 111 }], 110: [function (_dereq_, module, exports) {
  7320. /**
  7321. * @file menu-item.js
  7322. */
  7323. 'use strict';
  7324. exports.__esModule = true;
  7325. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7326. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7327. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7328. var _clickableComponentJs = _dereq_('../clickable-component.js');
  7329. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  7330. var _componentJs = _dereq_('../component.js');
  7331. var _componentJs2 = _interopRequireDefault(_componentJs);
  7332. var _objectAssign = _dereq_('object.assign');
  7333. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  7334. /**
  7335. * The component for a menu item. `<li>`
  7336. *
  7337. * @param {Player|Object} player
  7338. * @param {Object=} options
  7339. * @extends Button
  7340. * @class MenuItem
  7341. */
  7342. var MenuItem = (function (_ClickableComponent) {
  7343. _inherits(MenuItem, _ClickableComponent);
  7344. function MenuItem(player, options) {
  7345. _classCallCheck(this, MenuItem);
  7346. _ClickableComponent.call(this, player, options);
  7347. this.selectable = options['selectable'];
  7348. this.selected(options['selected']);
  7349. if (this.selectable) {
  7350. // TODO: May need to be either menuitemcheckbox or menuitemradio,
  7351. // and may need logical grouping of menu items.
  7352. this.el_.setAttribute('role', 'menuitemcheckbox');
  7353. } else {
  7354. this.el_.setAttribute('role', 'menuitem');
  7355. }
  7356. }
  7357. /**
  7358. * Create the component's DOM element
  7359. *
  7360. * @param {String=} type Desc
  7361. * @param {Object=} props Desc
  7362. * @return {Element}
  7363. * @method createEl
  7364. */
  7365. MenuItem.prototype.createEl = function createEl(type, props, attrs) {
  7366. return _ClickableComponent.prototype.createEl.call(this, 'li', _objectAssign2['default']({
  7367. className: 'vjs-menu-item',
  7368. innerHTML: this.localize(this.options_['label']),
  7369. tabIndex: -1
  7370. }, props), attrs);
  7371. };
  7372. /**
  7373. * Handle a click on the menu item, and set it to selected
  7374. *
  7375. * @method handleClick
  7376. */
  7377. MenuItem.prototype.handleClick = function handleClick() {
  7378. this.selected(true);
  7379. };
  7380. /**
  7381. * Set this menu item as selected or not
  7382. *
  7383. * @param {Boolean} selected
  7384. * @method selected
  7385. */
  7386. MenuItem.prototype.selected = function selected(_selected) {
  7387. if (this.selectable) {
  7388. if (_selected) {
  7389. this.addClass('vjs-selected');
  7390. this.el_.setAttribute('aria-checked', 'true');
  7391. // aria-checked isn't fully supported by browsers/screen readers,
  7392. // so indicate selected state to screen reader in the control text.
  7393. this.controlText(', selected');
  7394. } else {
  7395. this.removeClass('vjs-selected');
  7396. this.el_.setAttribute('aria-checked', 'false');
  7397. // Indicate un-selected state to screen reader
  7398. // Note that a space clears out the selected state text
  7399. this.controlText(' ');
  7400. }
  7401. }
  7402. };
  7403. return MenuItem;
  7404. })(_clickableComponentJs2['default']);
  7405. _componentJs2['default'].registerComponent('MenuItem', MenuItem);
  7406. exports['default'] = MenuItem;
  7407. module.exports = exports['default'];
  7408. }, { "../clickable-component.js": 65, "../component.js": 67, "object.assign": 45 }], 111: [function (_dereq_, module, exports) {
  7409. /**
  7410. * @file menu.js
  7411. */
  7412. 'use strict';
  7413. exports.__esModule = true;
  7414. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  7415. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7416. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7417. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7418. var _componentJs = _dereq_('../component.js');
  7419. var _componentJs2 = _interopRequireDefault(_componentJs);
  7420. var _utilsDomJs = _dereq_('../utils/dom.js');
  7421. var Dom = _interopRequireWildcard(_utilsDomJs);
  7422. var _utilsFnJs = _dereq_('../utils/fn.js');
  7423. var Fn = _interopRequireWildcard(_utilsFnJs);
  7424. var _utilsEventsJs = _dereq_('../utils/events.js');
  7425. var Events = _interopRequireWildcard(_utilsEventsJs);
  7426. /**
  7427. * The Menu component is used to build pop up menus, including subtitle and
  7428. * captions selection menus.
  7429. *
  7430. * @extends Component
  7431. * @class Menu
  7432. */
  7433. var Menu = (function (_Component) {
  7434. _inherits(Menu, _Component);
  7435. function Menu(player, options) {
  7436. _classCallCheck(this, Menu);
  7437. _Component.call(this, player, options);
  7438. this.focusedChild_ = -1;
  7439. this.on('keydown', this.handleKeyPress);
  7440. }
  7441. /**
  7442. * Add a menu item to the menu
  7443. *
  7444. * @param {Object|String} component Component or component type to add
  7445. * @method addItem
  7446. */
  7447. Menu.prototype.addItem = function addItem(component) {
  7448. this.addChild(component);
  7449. component.on('click', Fn.bind(this, function () {
  7450. this.unlockShowing();
  7451. //TODO: Need to set keyboard focus back to the menuButton
  7452. }));
  7453. };
  7454. /**
  7455. * Create the component's DOM element
  7456. *
  7457. * @return {Element}
  7458. * @method createEl
  7459. */
  7460. Menu.prototype.createEl = function createEl() {
  7461. var contentElType = this.options_.contentElType || 'ul';
  7462. this.contentEl_ = Dom.createEl(contentElType, {
  7463. className: 'vjs-menu-content'
  7464. });
  7465. this.contentEl_.setAttribute('role', 'menu');
  7466. var el = _Component.prototype.createEl.call(this, 'div', {
  7467. append: this.contentEl_,
  7468. className: 'vjs-menu'
  7469. });
  7470. el.setAttribute('role', 'presentation');
  7471. el.appendChild(this.contentEl_);
  7472. // Prevent clicks from bubbling up. Needed for Menu Buttons,
  7473. // where a click on the parent is significant
  7474. Events.on(el, 'click', function (event) {
  7475. event.preventDefault();
  7476. event.stopImmediatePropagation();
  7477. });
  7478. return el;
  7479. };
  7480. /**
  7481. * Handle key press for menu
  7482. *
  7483. * @param {Object} event Event object
  7484. * @method handleKeyPress
  7485. */
  7486. Menu.prototype.handleKeyPress = function handleKeyPress(event) {
  7487. if (event.which === 37 || event.which === 40) {
  7488. // Left and Down Arrows
  7489. event.preventDefault();
  7490. this.stepForward();
  7491. } else if (event.which === 38 || event.which === 39) {
  7492. // Up and Right Arrows
  7493. event.preventDefault();
  7494. this.stepBack();
  7495. }
  7496. };
  7497. /**
  7498. * Move to next (lower) menu item for keyboard users
  7499. *
  7500. * @method stepForward
  7501. */
  7502. Menu.prototype.stepForward = function stepForward() {
  7503. var stepChild = 0;
  7504. if (this.focusedChild_ !== undefined) {
  7505. stepChild = this.focusedChild_ + 1;
  7506. }
  7507. this.focus(stepChild);
  7508. };
  7509. /**
  7510. * Move to previous (higher) menu item for keyboard users
  7511. *
  7512. * @method stepBack
  7513. */
  7514. Menu.prototype.stepBack = function stepBack() {
  7515. var stepChild = 0;
  7516. if (this.focusedChild_ !== undefined) {
  7517. stepChild = this.focusedChild_ - 1;
  7518. }
  7519. this.focus(stepChild);
  7520. };
  7521. /**
  7522. * Set focus on a menu item in the menu
  7523. *
  7524. * @param {Object|String} item Index of child item set focus on
  7525. * @method focus
  7526. */
  7527. Menu.prototype.focus = function focus() {
  7528. var item = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
  7529. var children = this.children().slice();
  7530. var haveTitle = children.length && children[0].className && /vjs-menu-title/.test(children[0].className);
  7531. if (haveTitle) {
  7532. children.shift();
  7533. }
  7534. if (children.length > 0) {
  7535. if (item < 0) {
  7536. item = 0;
  7537. } else if (item >= children.length) {
  7538. item = children.length - 1;
  7539. }
  7540. this.focusedChild_ = item;
  7541. children[item].el_.focus();
  7542. }
  7543. };
  7544. return Menu;
  7545. })(_componentJs2['default']);
  7546. _componentJs2['default'].registerComponent('Menu', Menu);
  7547. exports['default'] = Menu;
  7548. module.exports = exports['default'];
  7549. }, { "../component.js": 67, "../utils/dom.js": 143, "../utils/events.js": 144, "../utils/fn.js": 145 }], 112: [function (_dereq_, module, exports) {
  7550. /**
  7551. * @file modal-dialog.js
  7552. */
  7553. 'use strict';
  7554. exports.__esModule = true;
  7555. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7556. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  7557. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7558. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7559. var _utilsDom = _dereq_('./utils/dom');
  7560. var Dom = _interopRequireWildcard(_utilsDom);
  7561. var _utilsFn = _dereq_('./utils/fn');
  7562. var Fn = _interopRequireWildcard(_utilsFn);
  7563. var _utilsLog = _dereq_('./utils/log');
  7564. var _utilsLog2 = _interopRequireDefault(_utilsLog);
  7565. var _component = _dereq_('./component');
  7566. var _component2 = _interopRequireDefault(_component);
  7567. var _closeButton = _dereq_('./close-button');
  7568. var _closeButton2 = _interopRequireDefault(_closeButton);
  7569. var MODAL_CLASS_NAME = 'vjs-modal-dialog';
  7570. var ESC = 27;
  7571. /**
  7572. * The `ModalDialog` displays over the video and its controls, which blocks
  7573. * interaction with the player until it is closed.
  7574. *
  7575. * Modal dialogs include a "Close" button and will close when that button
  7576. * is activated - or when ESC is pressed anywhere.
  7577. *
  7578. * @extends Component
  7579. * @class ModalDialog
  7580. */
  7581. var ModalDialog = (function (_Component) {
  7582. _inherits(ModalDialog, _Component);
  7583. /**
  7584. * Constructor for modals.
  7585. *
  7586. * @param {Player} player
  7587. * @param {Object} [options]
  7588. * @param {Mixed} [options.content=undefined]
  7589. * Provide customized content for this modal.
  7590. *
  7591. * @param {String} [options.description]
  7592. * A text description for the modal, primarily for accessibility.
  7593. *
  7594. * @param {Boolean} [options.fillAlways=false]
  7595. * Normally, modals are automatically filled only the first time
  7596. * they open. This tells the modal to refresh its content
  7597. * every time it opens.
  7598. *
  7599. * @param {String} [options.label]
  7600. * A text label for the modal, primarily for accessibility.
  7601. *
  7602. * @param {Boolean} [options.temporary=true]
  7603. * If `true`, the modal can only be opened once; it will be
  7604. * disposed as soon as it's closed.
  7605. *
  7606. * @param {Boolean} [options.uncloseable=false]
  7607. * If `true`, the user will not be able to close the modal
  7608. * through the UI in the normal ways. Programmatic closing is
  7609. * still possible.
  7610. *
  7611. */
  7612. function ModalDialog(player, options) {
  7613. _classCallCheck(this, ModalDialog);
  7614. _Component.call(this, player, options);
  7615. this.opened_ = this.hasBeenOpened_ = this.hasBeenFilled_ = false;
  7616. this.closeable(!this.options_.uncloseable);
  7617. this.content(this.options_.content);
  7618. // Make sure the contentEl is defined AFTER any children are initialized
  7619. // because we only want the contents of the modal in the contentEl
  7620. // (not the UI elements like the close button).
  7621. this.contentEl_ = Dom.createEl('div', {
  7622. className: MODAL_CLASS_NAME + '-content'
  7623. }, {
  7624. role: 'document'
  7625. });
  7626. this.descEl_ = Dom.createEl('p', {
  7627. className: MODAL_CLASS_NAME + '-description vjs-offscreen',
  7628. id: this.el().getAttribute('aria-describedby')
  7629. });
  7630. Dom.textContent(this.descEl_, this.description());
  7631. this.el_.appendChild(this.descEl_);
  7632. this.el_.appendChild(this.contentEl_);
  7633. }
  7634. /*
  7635. * Modal dialog default options.
  7636. *
  7637. * @type {Object}
  7638. * @private
  7639. */
  7640. /**
  7641. * Create the modal's DOM element
  7642. *
  7643. * @method createEl
  7644. * @return {Element}
  7645. */
  7646. ModalDialog.prototype.createEl = function createEl() {
  7647. return _Component.prototype.createEl.call(this, 'div', {
  7648. className: this.buildCSSClass(),
  7649. tabIndex: -1
  7650. }, {
  7651. 'aria-describedby': this.id() + '_description',
  7652. 'aria-hidden': 'true',
  7653. 'aria-label': this.label(),
  7654. role: 'dialog'
  7655. });
  7656. };
  7657. /**
  7658. * Build the modal's CSS class.
  7659. *
  7660. * @method buildCSSClass
  7661. * @return {String}
  7662. */
  7663. ModalDialog.prototype.buildCSSClass = function buildCSSClass() {
  7664. return MODAL_CLASS_NAME + ' vjs-hidden ' + _Component.prototype.buildCSSClass.call(this);
  7665. };
  7666. /**
  7667. * Handles key presses on the document, looking for ESC, which closes
  7668. * the modal.
  7669. *
  7670. * @method handleKeyPress
  7671. * @param {Event} e
  7672. */
  7673. ModalDialog.prototype.handleKeyPress = function handleKeyPress(e) {
  7674. if (e.which === ESC && this.closeable()) {
  7675. this.close();
  7676. }
  7677. };
  7678. /**
  7679. * Returns the label string for this modal. Primarily used for accessibility.
  7680. *
  7681. * @return {String}
  7682. */
  7683. ModalDialog.prototype.label = function label() {
  7684. return this.options_.label || this.localize('Modal Window');
  7685. };
  7686. /**
  7687. * Returns the description string for this modal. Primarily used for
  7688. * accessibility.
  7689. *
  7690. * @return {String}
  7691. */
  7692. ModalDialog.prototype.description = function description() {
  7693. var desc = this.options_.description || this.localize('This is a modal window.');
  7694. // Append a universal closeability message if the modal is closeable.
  7695. if (this.closeable()) {
  7696. desc += ' ' + this.localize('This modal can be closed by pressing the Escape key or activating the close button.');
  7697. }
  7698. return desc;
  7699. };
  7700. /**
  7701. * Opens the modal.
  7702. *
  7703. * @method open
  7704. * @return {ModalDialog}
  7705. */
  7706. ModalDialog.prototype.open = function open() {
  7707. if (!this.opened_) {
  7708. var player = this.player();
  7709. this.trigger('beforemodalopen');
  7710. this.opened_ = true;
  7711. // Fill content if the modal has never opened before and
  7712. // never been filled.
  7713. if (this.options_.fillAlways || !this.hasBeenOpened_ && !this.hasBeenFilled_) {
  7714. this.fill();
  7715. }
  7716. // If the player was playing, pause it and take note of its previously
  7717. // playing state.
  7718. this.wasPlaying_ = !player.paused();
  7719. if (this.wasPlaying_) {
  7720. player.pause();
  7721. }
  7722. if (this.closeable()) {
  7723. this.on(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
  7724. }
  7725. player.controls(false);
  7726. this.show();
  7727. this.el().setAttribute('aria-hidden', 'false');
  7728. this.trigger('modalopen');
  7729. this.hasBeenOpened_ = true;
  7730. }
  7731. return this;
  7732. };
  7733. /**
  7734. * Whether or not the modal is opened currently.
  7735. *
  7736. * @method opened
  7737. * @param {Boolean} [value]
  7738. * If given, it will open (`true`) or close (`false`) the modal.
  7739. *
  7740. * @return {Boolean}
  7741. */
  7742. ModalDialog.prototype.opened = function opened(value) {
  7743. if (typeof value === 'boolean') {
  7744. this[value ? 'open' : 'close']();
  7745. }
  7746. return this.opened_;
  7747. };
  7748. /**
  7749. * Closes the modal.
  7750. *
  7751. * @method close
  7752. * @return {ModalDialog}
  7753. */
  7754. ModalDialog.prototype.close = function close() {
  7755. if (this.opened_) {
  7756. var player = this.player();
  7757. this.trigger('beforemodalclose');
  7758. this.opened_ = false;
  7759. if (this.wasPlaying_) {
  7760. player.play();
  7761. }
  7762. if (this.closeable()) {
  7763. this.off(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
  7764. }
  7765. player.controls(true);
  7766. this.hide();
  7767. this.el().setAttribute('aria-hidden', 'true');
  7768. this.trigger('modalclose');
  7769. if (this.options_.temporary) {
  7770. this.dispose();
  7771. }
  7772. }
  7773. return this;
  7774. };
  7775. /**
  7776. * Whether or not the modal is closeable via the UI.
  7777. *
  7778. * @method closeable
  7779. * @param {Boolean} [value]
  7780. * If given as a Boolean, it will set the `closeable` option.
  7781. *
  7782. * @return {Boolean}
  7783. */
  7784. ModalDialog.prototype.closeable = function closeable(value) {
  7785. if (typeof value === 'boolean') {
  7786. var closeable = this.closeable_ = !!value;
  7787. var _close = this.getChild('closeButton');
  7788. // If this is being made closeable and has no close button, add one.
  7789. if (closeable && !_close) {
  7790. // The close button should be a child of the modal - not its
  7791. // content element, so temporarily change the content element.
  7792. var temp = this.contentEl_;
  7793. this.contentEl_ = this.el_;
  7794. _close = this.addChild('closeButton');
  7795. this.contentEl_ = temp;
  7796. this.on(_close, 'close', this.close);
  7797. }
  7798. // If this is being made uncloseable and has a close button, remove it.
  7799. if (!closeable && _close) {
  7800. this.off(_close, 'close', this.close);
  7801. this.removeChild(_close);
  7802. _close.dispose();
  7803. }
  7804. }
  7805. return this.closeable_;
  7806. };
  7807. /**
  7808. * Fill the modal's content element with the modal's "content" option.
  7809. *
  7810. * The content element will be emptied before this change takes place.
  7811. *
  7812. * @method fill
  7813. * @return {ModalDialog}
  7814. */
  7815. ModalDialog.prototype.fill = function fill() {
  7816. return this.fillWith(this.content());
  7817. };
  7818. /**
  7819. * Fill the modal's content element with arbitrary content.
  7820. *
  7821. * The content element will be emptied before this change takes place.
  7822. *
  7823. * @method fillWith
  7824. * @param {Mixed} [content]
  7825. * The same rules apply to this as apply to the `content` option.
  7826. *
  7827. * @return {ModalDialog}
  7828. */
  7829. ModalDialog.prototype.fillWith = function fillWith(content) {
  7830. var contentEl = this.contentEl();
  7831. var parentEl = contentEl.parentNode;
  7832. var nextSiblingEl = contentEl.nextSibling;
  7833. this.trigger('beforemodalfill');
  7834. this.hasBeenFilled_ = true;
  7835. // Detach the content element from the DOM before performing
  7836. // manipulation to avoid modifying the live DOM multiple times.
  7837. parentEl.removeChild(contentEl);
  7838. this.empty();
  7839. Dom.insertContent(contentEl, content);
  7840. this.trigger('modalfill');
  7841. // Re-inject the re-filled content element.
  7842. if (nextSiblingEl) {
  7843. parentEl.insertBefore(contentEl, nextSiblingEl);
  7844. } else {
  7845. parentEl.appendChild(contentEl);
  7846. }
  7847. return this;
  7848. };
  7849. /**
  7850. * Empties the content element.
  7851. *
  7852. * This happens automatically anytime the modal is filled.
  7853. *
  7854. * @method empty
  7855. * @return {ModalDialog}
  7856. */
  7857. ModalDialog.prototype.empty = function empty() {
  7858. this.trigger('beforemodalempty');
  7859. Dom.emptyEl(this.contentEl());
  7860. this.trigger('modalempty');
  7861. return this;
  7862. };
  7863. /**
  7864. * Gets or sets the modal content, which gets normalized before being
  7865. * rendered into the DOM.
  7866. *
  7867. * This does not update the DOM or fill the modal, but it is called during
  7868. * that process.
  7869. *
  7870. * @method content
  7871. * @param {Mixed} [value]
  7872. * If defined, sets the internal content value to be used on the
  7873. * next call(s) to `fill`. This value is normalized before being
  7874. * inserted. To "clear" the internal content value, pass `null`.
  7875. *
  7876. * @return {Mixed}
  7877. */
  7878. ModalDialog.prototype.content = function content(value) {
  7879. if (typeof value !== 'undefined') {
  7880. this.content_ = value;
  7881. }
  7882. return this.content_;
  7883. };
  7884. return ModalDialog;
  7885. })(_component2['default']);
  7886. ModalDialog.prototype.options_ = {
  7887. temporary: true
  7888. };
  7889. _component2['default'].registerComponent('ModalDialog', ModalDialog);
  7890. exports['default'] = ModalDialog;
  7891. module.exports = exports['default'];
  7892. }, { "./close-button": 66, "./component": 67, "./utils/dom": 143, "./utils/fn": 145, "./utils/log": 148 }], 113: [function (_dereq_, module, exports) {
  7893. /**
  7894. * @file player.js
  7895. */
  7896. // Subclasses Component
  7897. 'use strict';
  7898. exports.__esModule = true;
  7899. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  7900. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7901. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7902. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  7903. var _componentJs = _dereq_('./component.js');
  7904. var _componentJs2 = _interopRequireDefault(_componentJs);
  7905. var _globalDocument = _dereq_('global/document');
  7906. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  7907. var _globalWindow = _dereq_('global/window');
  7908. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  7909. var _utilsEventsJs = _dereq_('./utils/events.js');
  7910. var Events = _interopRequireWildcard(_utilsEventsJs);
  7911. var _utilsDomJs = _dereq_('./utils/dom.js');
  7912. var Dom = _interopRequireWildcard(_utilsDomJs);
  7913. var _utilsFnJs = _dereq_('./utils/fn.js');
  7914. var Fn = _interopRequireWildcard(_utilsFnJs);
  7915. var _utilsGuidJs = _dereq_('./utils/guid.js');
  7916. var Guid = _interopRequireWildcard(_utilsGuidJs);
  7917. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  7918. var browser = _interopRequireWildcard(_utilsBrowserJs);
  7919. var _utilsLogJs = _dereq_('./utils/log.js');
  7920. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  7921. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
  7922. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  7923. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js');
  7924. var _utilsBufferJs = _dereq_('./utils/buffer.js');
  7925. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js');
  7926. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs);
  7927. var _fullscreenApiJs = _dereq_('./fullscreen-api.js');
  7928. var _fullscreenApiJs2 = _interopRequireDefault(_fullscreenApiJs);
  7929. var _mediaErrorJs = _dereq_('./media-error.js');
  7930. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs);
  7931. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple');
  7932. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple);
  7933. var _objectAssign = _dereq_('object.assign');
  7934. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  7935. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
  7936. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  7937. var _tracksTextTrackListConverterJs = _dereq_('./tracks/text-track-list-converter.js');
  7938. var _tracksTextTrackListConverterJs2 = _interopRequireDefault(_tracksTextTrackListConverterJs);
  7939. var _tracksAudioTrackListJs = _dereq_('./tracks/audio-track-list.js');
  7940. var _tracksAudioTrackListJs2 = _interopRequireDefault(_tracksAudioTrackListJs);
  7941. var _tracksVideoTrackListJs = _dereq_('./tracks/video-track-list.js');
  7942. var _tracksVideoTrackListJs2 = _interopRequireDefault(_tracksVideoTrackListJs);
  7943. // Include required child components (importing also registers them)
  7944. var _techLoaderJs = _dereq_('./tech/loader.js');
  7945. var _techLoaderJs2 = _interopRequireDefault(_techLoaderJs);
  7946. var _posterImageJs = _dereq_('./poster-image.js');
  7947. var _posterImageJs2 = _interopRequireDefault(_posterImageJs);
  7948. var _tracksTextTrackDisplayJs = _dereq_('./tracks/text-track-display.js');
  7949. var _tracksTextTrackDisplayJs2 = _interopRequireDefault(_tracksTextTrackDisplayJs);
  7950. var _loadingSpinnerJs = _dereq_('./loading-spinner.js');
  7951. var _loadingSpinnerJs2 = _interopRequireDefault(_loadingSpinnerJs);
  7952. var _bigPlayButtonJs = _dereq_('./big-play-button.js');
  7953. var _bigPlayButtonJs2 = _interopRequireDefault(_bigPlayButtonJs);
  7954. var _controlBarControlBarJs = _dereq_('./control-bar/control-bar.js');
  7955. var _controlBarControlBarJs2 = _interopRequireDefault(_controlBarControlBarJs);
  7956. var _errorDisplayJs = _dereq_('./error-display.js');
  7957. var _errorDisplayJs2 = _interopRequireDefault(_errorDisplayJs);
  7958. var _tracksTextTrackSettingsJs = _dereq_('./tracks/text-track-settings.js');
  7959. var _tracksTextTrackSettingsJs2 = _interopRequireDefault(_tracksTextTrackSettingsJs);
  7960. var _modalDialog = _dereq_('./modal-dialog');
  7961. var _modalDialog2 = _interopRequireDefault(_modalDialog);
  7962. // Require html5 tech, at least for disposing the original video tag
  7963. var _techTechJs = _dereq_('./tech/tech.js');
  7964. var _techTechJs2 = _interopRequireDefault(_techTechJs);
  7965. var _techHtml5Js = _dereq_('./tech/html5.js');
  7966. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js);
  7967. /**
  7968. * An instance of the `Player` class is created when any of the Video.js setup methods are used to initialize a video.
  7969. * ```js
  7970. * var myPlayer = videojs('example_video_1');
  7971. * ```
  7972. * In the following example, the `data-setup` attribute tells the Video.js library to create a player instance when the library is ready.
  7973. * ```html
  7974. * <video id="example_video_1" data-setup='{}' controls>
  7975. * <source src="my-source.mp4" type="video/mp4">
  7976. * </video>
  7977. * ```
  7978. * After an instance has been created it can be accessed globally using `Video('example_video_1')`.
  7979. *
  7980. * @param {Element} tag The original video tag used for configuring options
  7981. * @param {Object=} options Object of option names and values
  7982. * @param {Function=} ready Ready callback function
  7983. * @extends Component
  7984. * @class Player
  7985. */
  7986. var Player = (function (_Component) {
  7987. _inherits(Player, _Component);
  7988. /**
  7989. * player's constructor function
  7990. *
  7991. * @constructs
  7992. * @method init
  7993. * @param {Element} tag The original video tag used for configuring options
  7994. * @param {Object=} options Player options
  7995. * @param {Function=} ready Ready callback function
  7996. */
  7997. function Player(tag, options, ready) {
  7998. var _this = this;
  7999. _classCallCheck(this, Player);
  8000. // Make sure tag ID exists
  8001. tag.id = tag.id || 'vjs_video_' + Guid.newGUID();
  8002. // Set Options
  8003. // The options argument overrides options set in the video tag
  8004. // which overrides globally set options.
  8005. // This latter part coincides with the load order
  8006. // (tag must exist before Player)
  8007. options = _objectAssign2['default'](Player.getTagSettings(tag), options);
  8008. // Delay the initialization of children because we need to set up
  8009. // player properties first, and can't use `this` before `super()`
  8010. options.initChildren = false;
  8011. // Same with creating the element
  8012. options.createEl = false;
  8013. // we don't want the player to report touch activity on itself
  8014. // see enableTouchActivity in Component
  8015. options.reportTouchActivity = false;
  8016. // Run base component initializing with new options
  8017. _Component.call(this, null, options, ready);
  8018. // if the global option object was accidentally blown away by
  8019. // someone, bail early with an informative error
  8020. if (!this.options_ || !this.options_.techOrder || !this.options_.techOrder.length) {
  8021. throw new Error('No techOrder specified. Did you overwrite ' + 'videojs.options instead of just changing the ' + 'properties you want to override?');
  8022. }
  8023. this.tag = tag; // Store the original tag used to set options
  8024. // Store the tag attributes used to restore html5 element
  8025. this.tagAttributes = tag && Dom.getElAttributes(tag);
  8026. // Update current language
  8027. this.language(this.options_.language);
  8028. // Update Supported Languages
  8029. if (options.languages) {
  8030. (function () {
  8031. // Normalise player option languages to lowercase
  8032. var languagesToLower = {};
  8033. Object.getOwnPropertyNames(options.languages).forEach(function (name) {
  8034. languagesToLower[name.toLowerCase()] = options.languages[name];
  8035. });
  8036. _this.languages_ = languagesToLower;
  8037. })();
  8038. } else {
  8039. this.languages_ = Player.prototype.options_.languages;
  8040. }
  8041. // Cache for video property values.
  8042. this.cache_ = {};
  8043. // Set poster
  8044. this.poster_ = options.poster || '';
  8045. // Set controls
  8046. this.controls_ = !!options.controls;
  8047. // Original tag settings stored in options
  8048. // now remove immediately so native controls don't flash.
  8049. // May be turned back on by HTML5 tech if nativeControlsForTouch is true
  8050. tag.controls = false;
  8051. /*
  8052. * Store the internal state of scrubbing
  8053. *
  8054. * @private
  8055. * @return {Boolean} True if the user is scrubbing
  8056. */
  8057. this.scrubbing_ = false;
  8058. this.el_ = this.createEl();
  8059. // We also want to pass the original player options to each component and plugin
  8060. // as well so they don't need to reach back into the player for options later.
  8061. // We also need to do another copy of this.options_ so we don't end up with
  8062. // an infinite loop.
  8063. var playerOptionsCopy = _utilsMergeOptionsJs2['default'](this.options_);
  8064. // Load plugins
  8065. if (options.plugins) {
  8066. (function () {
  8067. var plugins = options.plugins;
  8068. Object.getOwnPropertyNames(plugins).forEach(function (name) {
  8069. if (typeof this[name] === 'function') {
  8070. this[name](plugins[name]);
  8071. } else {
  8072. _utilsLogJs2['default'].error('Unable to find plugin:', name);
  8073. }
  8074. }, _this);
  8075. })();
  8076. }
  8077. this.options_.playerOptions = playerOptionsCopy;
  8078. this.initChildren();
  8079. // Set isAudio based on whether or not an audio tag was used
  8080. this.isAudio(tag.nodeName.toLowerCase() === 'audio');
  8081. // Update controls className. Can't do this when the controls are initially
  8082. // set because the element doesn't exist yet.
  8083. if (this.controls()) {
  8084. this.addClass('vjs-controls-enabled');
  8085. } else {
  8086. this.addClass('vjs-controls-disabled');
  8087. }
  8088. // Set ARIA label and region role depending on player type
  8089. this.el_.setAttribute('role', 'region');
  8090. if (this.isAudio()) {
  8091. this.el_.setAttribute('aria-label', 'audio player');
  8092. } else {
  8093. this.el_.setAttribute('aria-label', 'video player');
  8094. }
  8095. if (this.isAudio()) {
  8096. this.addClass('vjs-audio');
  8097. }
  8098. if (this.flexNotSupported_()) {
  8099. this.addClass('vjs-no-flex');
  8100. }
  8101. // TODO: Make this smarter. Toggle user state between touching/mousing
  8102. // using events, since devices can have both touch and mouse events.
  8103. // if (browser.TOUCH_ENABLED) {
  8104. // this.addClass('vjs-touch-enabled');
  8105. // }
  8106. // iOS Safari has broken hover handling
  8107. if (!browser.IS_IOS) {
  8108. this.addClass('vjs-workinghover');
  8109. }
  8110. // Make player easily findable by ID
  8111. Player.players[this.id_] = this;
  8112. // When the player is first initialized, trigger activity so components
  8113. // like the control bar show themselves if needed
  8114. this.userActive(true);
  8115. this.reportUserActivity();
  8116. this.listenForUserActivity_();
  8117. this.on('fullscreenchange', this.handleFullscreenChange_);
  8118. this.on('stageclick', this.handleStageClick_);
  8119. }
  8120. /*
  8121. * Global player list
  8122. *
  8123. * @type {Object}
  8124. */
  8125. /**
  8126. * Destroys the video player and does any necessary cleanup
  8127. * ```js
  8128. * myPlayer.dispose();
  8129. * ```
  8130. * This is especially helpful if you are dynamically adding and removing videos
  8131. * to/from the DOM.
  8132. *
  8133. * @method dispose
  8134. */
  8135. Player.prototype.dispose = function dispose() {
  8136. this.trigger('dispose');
  8137. // prevent dispose from being called twice
  8138. this.off('dispose');
  8139. if (this.styleEl_ && this.styleEl_.parentNode) {
  8140. this.styleEl_.parentNode.removeChild(this.styleEl_);
  8141. }
  8142. // Kill reference to this player
  8143. Player.players[this.id_] = null;
  8144. if (this.tag && this.tag.player) {
  8145. this.tag.player = null;
  8146. }
  8147. if (this.el_ && this.el_.player) {
  8148. this.el_.player = null;
  8149. }
  8150. if (this.tech_) {
  8151. this.tech_.dispose();
  8152. }
  8153. _Component.prototype.dispose.call(this);
  8154. };
  8155. /**
  8156. * Create the component's DOM element
  8157. *
  8158. * @return {Element}
  8159. * @method createEl
  8160. */
  8161. Player.prototype.createEl = function createEl() {
  8162. var el = this.el_ = _Component.prototype.createEl.call(this, 'div');
  8163. var tag = this.tag;
  8164. // Remove width/height attrs from tag so CSS can make it 100% width/height
  8165. tag.removeAttribute('width');
  8166. tag.removeAttribute('height');
  8167. // Copy over all the attributes from the tag, including ID and class
  8168. // ID will now reference player box, not the video tag
  8169. var attrs = Dom.getElAttributes(tag);
  8170. Object.getOwnPropertyNames(attrs).forEach(function (attr) {
  8171. // workaround so we don't totally break IE7
  8172. // http://stackoverflow.com/questions/3653444/css-styles-not-applied-on-dynamic-elements-in-internet-explorer-7
  8173. if (attr === 'class') {
  8174. el.className = attrs[attr];
  8175. } else {
  8176. el.setAttribute(attr, attrs[attr]);
  8177. }
  8178. });
  8179. // Update tag id/class for use as HTML5 playback tech
  8180. // Might think we should do this after embedding in container so .vjs-tech class
  8181. // doesn't flash 100% width/height, but class only applies with .video-js parent
  8182. tag.playerId = tag.id;
  8183. tag.id += '_html5_api';
  8184. tag.className = 'vjs-tech';
  8185. // Make player findable on elements
  8186. tag.player = el.player = this;
  8187. // Default state of video is paused
  8188. this.addClass('vjs-paused');
  8189. // Add a style element in the player that we'll use to set the width/height
  8190. // of the player in a way that's still overrideable by CSS, just like the
  8191. // video element
  8192. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE !== true) {
  8193. this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions');
  8194. var defaultsStyleEl = Dom.$('.vjs-styles-defaults');
  8195. var head = Dom.$('head');
  8196. head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild);
  8197. }
  8198. // Pass in the width/height/aspectRatio options which will update the style el
  8199. this.width(this.options_.width);
  8200. this.height(this.options_.height);
  8201. this.fluid(this.options_.fluid);
  8202. this.aspectRatio(this.options_.aspectRatio);
  8203. // Hide any links within the video/audio tag, because IE doesn't hide them completely.
  8204. var links = tag.getElementsByTagName('a');
  8205. for (var i = 0; i < links.length; i++) {
  8206. var linkEl = links.item(i);
  8207. Dom.addElClass(linkEl, 'vjs-hidden');
  8208. linkEl.setAttribute('hidden', 'hidden');
  8209. }
  8210. // insertElFirst seems to cause the networkState to flicker from 3 to 2, so
  8211. // keep track of the original for later so we can know if the source originally failed
  8212. tag.initNetworkState_ = tag.networkState;
  8213. // Wrap video tag in div (el/box) container
  8214. if (tag.parentNode) {
  8215. tag.parentNode.insertBefore(el, tag);
  8216. }
  8217. // insert the tag as the first child of the player element
  8218. // then manually add it to the children array so that this.addChild
  8219. // will work properly for other components
  8220. Dom.insertElFirst(tag, el); // Breaks iPhone, fixed in HTML5 setup.
  8221. this.children_.unshift(tag);
  8222. this.el_ = el;
  8223. return el;
  8224. };
  8225. /**
  8226. * Get/set player width
  8227. *
  8228. * @param {Number=} value Value for width
  8229. * @return {Number} Width when getting
  8230. * @method width
  8231. */
  8232. Player.prototype.width = function width(value) {
  8233. return this.dimension('width', value);
  8234. };
  8235. /**
  8236. * Get/set player height
  8237. *
  8238. * @param {Number=} value Value for height
  8239. * @return {Number} Height when getting
  8240. * @method height
  8241. */
  8242. Player.prototype.height = function height(value) {
  8243. return this.dimension('height', value);
  8244. };
  8245. /**
  8246. * Get/set dimension for player
  8247. *
  8248. * @param {String} dimension Either width or height
  8249. * @param {Number=} value Value for dimension
  8250. * @return {Component}
  8251. * @method dimension
  8252. */
  8253. Player.prototype.dimension = function dimension(_dimension, value) {
  8254. var privDimension = _dimension + '_';
  8255. if (value === undefined) {
  8256. return this[privDimension] || 0;
  8257. }
  8258. if (value === '') {
  8259. // If an empty string is given, reset the dimension to be automatic
  8260. this[privDimension] = undefined;
  8261. } else {
  8262. var parsedVal = parseFloat(value);
  8263. if (isNaN(parsedVal)) {
  8264. _utilsLogJs2['default'].error('Improper value "' + value + '" supplied for for ' + _dimension);
  8265. return this;
  8266. }
  8267. this[privDimension] = parsedVal;
  8268. }
  8269. this.updateStyleEl_();
  8270. return this;
  8271. };
  8272. /**
  8273. * Add/remove the vjs-fluid class
  8274. *
  8275. * @param {Boolean} bool Value of true adds the class, value of false removes the class
  8276. * @method fluid
  8277. */
  8278. Player.prototype.fluid = function fluid(bool) {
  8279. if (bool === undefined) {
  8280. return !!this.fluid_;
  8281. }
  8282. this.fluid_ = !!bool;
  8283. if (bool) {
  8284. this.addClass('vjs-fluid');
  8285. } else {
  8286. this.removeClass('vjs-fluid');
  8287. }
  8288. };
  8289. /**
  8290. * Get/Set the aspect ratio
  8291. *
  8292. * @param {String=} ratio Aspect ratio for player
  8293. * @return aspectRatio
  8294. * @method aspectRatio
  8295. */
  8296. Player.prototype.aspectRatio = function aspectRatio(ratio) {
  8297. if (ratio === undefined) {
  8298. return this.aspectRatio_;
  8299. }
  8300. // Check for width:height format
  8301. if (!/^\d+\:\d+$/.test(ratio)) {
  8302. throw new Error('Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.');
  8303. }
  8304. this.aspectRatio_ = ratio;
  8305. // We're assuming if you set an aspect ratio you want fluid mode,
  8306. // because in fixed mode you could calculate width and height yourself.
  8307. this.fluid(true);
  8308. this.updateStyleEl_();
  8309. };
  8310. /**
  8311. * Update styles of the player element (height, width and aspect ratio)
  8312. *
  8313. * @method updateStyleEl_
  8314. */
  8315. Player.prototype.updateStyleEl_ = function updateStyleEl_() {
  8316. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE === true) {
  8317. var _width = typeof this.width_ === 'number' ? this.width_ : this.options_.width;
  8318. var _height = typeof this.height_ === 'number' ? this.height_ : this.options_.height;
  8319. var techEl = this.tech_ && this.tech_.el();
  8320. if (techEl) {
  8321. if (_width >= 0) {
  8322. techEl.width = _width;
  8323. }
  8324. if (_height >= 0) {
  8325. techEl.height = _height;
  8326. }
  8327. }
  8328. return;
  8329. }
  8330. var width = undefined;
  8331. var height = undefined;
  8332. var aspectRatio = undefined;
  8333. var idClass = undefined;
  8334. // The aspect ratio is either used directly or to calculate width and height.
  8335. if (this.aspectRatio_ !== undefined && this.aspectRatio_ !== 'auto') {
  8336. // Use any aspectRatio that's been specifically set
  8337. aspectRatio = this.aspectRatio_;
  8338. } else if (this.videoWidth()) {
  8339. // Otherwise try to get the aspect ratio from the video metadata
  8340. aspectRatio = this.videoWidth() + ':' + this.videoHeight();
  8341. } else {
  8342. // Or use a default. The video element's is 2:1, but 16:9 is more common.
  8343. aspectRatio = '16:9';
  8344. }
  8345. // Get the ratio as a decimal we can use to calculate dimensions
  8346. var ratioParts = aspectRatio.split(':');
  8347. var ratioMultiplier = ratioParts[1] / ratioParts[0];
  8348. if (this.width_ !== undefined) {
  8349. // Use any width that's been specifically set
  8350. width = this.width_;
  8351. } else if (this.height_ !== undefined) {
  8352. // Or calulate the width from the aspect ratio if a height has been set
  8353. width = this.height_ / ratioMultiplier;
  8354. } else {
  8355. // Or use the video's metadata, or use the video el's default of 300
  8356. width = this.videoWidth() || 300;
  8357. }
  8358. if (this.height_ !== undefined) {
  8359. // Use any height that's been specifically set
  8360. height = this.height_;
  8361. } else {
  8362. // Otherwise calculate the height from the ratio and the width
  8363. height = width * ratioMultiplier;
  8364. }
  8365. // Ensure the CSS class is valid by starting with an alpha character
  8366. if (/^[^a-zA-Z]/.test(this.id())) {
  8367. idClass = 'dimensions-' + this.id();
  8368. } else {
  8369. idClass = this.id() + '-dimensions';
  8370. }
  8371. // Ensure the right class is still on the player for the style element
  8372. this.addClass(idClass);
  8373. //stylesheet.setTextContent(this.styleEl_, '\n .' + idClass + ' {\n width: ' + width + 'px;\n height: ' + height + 'px;\n }\n\n .' + idClass + '.vjs-fluid {\n padding-top: ' + ratioMultiplier * 100 + '%;\n }\n ');
  8374. stylesheet.setTextContent(this.styleEl_, '\n .' + idClass + ' {\n width: auto;\n height: ' + height + 'px;\n }\n\n .' + idClass + '.vjs-fluid {\n padding-top: ' + ratioMultiplier * 100 + '%;\n }\n ');
  8375. };
  8376. /**
  8377. * Load the Media Playback Technology (tech)
  8378. * Load/Create an instance of playback technology including element and API methods
  8379. * And append playback element in player div.
  8380. *
  8381. * @param {String} techName Name of the playback technology
  8382. * @param {String} source Video source
  8383. * @method loadTech_
  8384. * @private
  8385. */
  8386. Player.prototype.loadTech_ = function loadTech_(techName, source) {
  8387. // Pause and remove current playback technology
  8388. if (this.tech_) {
  8389. this.unloadTech_();
  8390. }
  8391. // get rid of the HTML5 video tag as soon as we are using another tech
  8392. if (techName !== 'Html5' && this.tag) {
  8393. _techTechJs2['default'].getTech('Html5').disposeMediaElement(this.tag);
  8394. this.tag.player = null;
  8395. this.tag = null;
  8396. }
  8397. this.techName_ = techName;
  8398. // Turn off API access because we're loading a new tech that might load asynchronously
  8399. this.isReady_ = false;
  8400. // Grab tech-specific options from player options and add source and parent element to use.
  8401. var techOptions = _objectAssign2['default']({
  8402. 'nativeControlsForTouch': this.options_.nativeControlsForTouch,
  8403. 'source': source,
  8404. 'playerId': this.id(),
  8405. 'techId': this.id() + '_' + techName + '_api',
  8406. 'videoTracks': this.videoTracks_,
  8407. 'textTracks': this.textTracks_,
  8408. 'audioTracks': this.audioTracks_,
  8409. 'autoplay': this.options_.autoplay,
  8410. 'preload': this.options_.preload,
  8411. 'loop': this.options_.loop,
  8412. 'muted': this.options_.muted,
  8413. 'poster': this.poster(),
  8414. 'language': this.language(),
  8415. 'vtt.js': this.options_['vtt.js']
  8416. }, this.options_[techName.toLowerCase()]);
  8417. if (this.tag) {
  8418. techOptions.tag = this.tag;
  8419. }
  8420. if (source) {
  8421. this.currentType_ = source.type;
  8422. if (source.src === this.cache_.src && this.cache_.currentTime > 0) {
  8423. techOptions.startTime = this.cache_.currentTime;
  8424. }
  8425. this.cache_.src = source.src;
  8426. }
  8427. // Initialize tech instance
  8428. var techComponent = _techTechJs2['default'].getTech(techName);
  8429. // Support old behavior of techs being registered as components.
  8430. // Remove once that deprecated behavior is removed.
  8431. if (!techComponent) {
  8432. techComponent = _componentJs2['default'].getComponent(techName);
  8433. }
  8434. this.tech_ = new techComponent(techOptions);
  8435. // player.triggerReady is always async, so don't need this to be async
  8436. this.tech_.ready(Fn.bind(this, this.handleTechReady_), true);
  8437. _tracksTextTrackListConverterJs2['default'].jsonToTextTracks(this.textTracksJson_ || [], this.tech_);
  8438. // Listen to all HTML5-defined events and trigger them on the player
  8439. this.on(this.tech_, 'loadstart', this.handleTechLoadStart_);
  8440. this.on(this.tech_, 'waiting', this.handleTechWaiting_);
  8441. this.on(this.tech_, 'canplay', this.handleTechCanPlay_);
  8442. this.on(this.tech_, 'canplaythrough', this.handleTechCanPlayThrough_);
  8443. this.on(this.tech_, 'playing', this.handleTechPlaying_);
  8444. this.on(this.tech_, 'ended', this.handleTechEnded_);
  8445. this.on(this.tech_, 'seeking', this.handleTechSeeking_);
  8446. this.on(this.tech_, 'seeked', this.handleTechSeeked_);
  8447. this.on(this.tech_, 'play', this.handleTechPlay_);
  8448. this.on(this.tech_, 'firstplay', this.handleTechFirstPlay_);
  8449. this.on(this.tech_, 'pause', this.handleTechPause_);
  8450. this.on(this.tech_, 'progress', this.handleTechProgress_);
  8451. this.on(this.tech_, 'durationchange', this.handleTechDurationChange_);
  8452. this.on(this.tech_, 'fullscreenchange', this.handleTechFullscreenChange_);
  8453. this.on(this.tech_, 'error', this.handleTechError_);
  8454. this.on(this.tech_, 'suspend', this.handleTechSuspend_);
  8455. this.on(this.tech_, 'abort', this.handleTechAbort_);
  8456. this.on(this.tech_, 'emptied', this.handleTechEmptied_);
  8457. this.on(this.tech_, 'stalled', this.handleTechStalled_);
  8458. this.on(this.tech_, 'loadedmetadata', this.handleTechLoadedMetaData_);
  8459. this.on(this.tech_, 'loadeddata', this.handleTechLoadedData_);
  8460. this.on(this.tech_, 'timeupdate', this.handleTechTimeUpdate_);
  8461. this.on(this.tech_, 'ratechange', this.handleTechRateChange_);
  8462. this.on(this.tech_, 'volumechange', this.handleTechVolumeChange_);
  8463. this.on(this.tech_, 'texttrackchange', this.handleTechTextTrackChange_);
  8464. this.on(this.tech_, 'loadedmetadata', this.updateStyleEl_);
  8465. this.on(this.tech_, 'posterchange', this.handleTechPosterChange_);
  8466. this.usingNativeControls(this.techGet_('controls'));
  8467. if (this.controls() && !this.usingNativeControls()) {
  8468. this.addTechControlsListeners_();
  8469. }
  8470. // Add the tech element in the DOM if it was not already there
  8471. // Make sure to not insert the original video element if using Html5
  8472. if (this.tech_.el().parentNode !== this.el() && (techName !== 'Html5' || !this.tag)) {
  8473. Dom.insertElFirst(this.tech_.el(), this.el());
  8474. }
  8475. // Get rid of the original video tag reference after the first tech is loaded
  8476. if (this.tag) {
  8477. this.tag.player = null;
  8478. this.tag = null;
  8479. }
  8480. };
  8481. /**
  8482. * Unload playback technology
  8483. *
  8484. * @method unloadTech_
  8485. * @private
  8486. */
  8487. Player.prototype.unloadTech_ = function unloadTech_() {
  8488. // Save the current text tracks so that we can reuse the same text tracks with the next tech
  8489. this.videoTracks_ = this.videoTracks();
  8490. this.textTracks_ = this.textTracks();
  8491. this.audioTracks_ = this.audioTracks();
  8492. this.textTracksJson_ = _tracksTextTrackListConverterJs2['default'].textTracksToJson(this.tech_);
  8493. this.isReady_ = false;
  8494. this.tech_.dispose();
  8495. this.tech_ = false;
  8496. };
  8497. /**
  8498. * Return a reference to the current tech.
  8499. * It will only return a reference to the tech if given an object with the
  8500. * `IWillNotUseThisInPlugins` property on it. This is try and prevent misuse
  8501. * of techs by plugins.
  8502. *
  8503. * @param {Object}
  8504. * @return {Object} The Tech
  8505. * @method tech
  8506. */
  8507. Player.prototype.tech = function tech(safety) {
  8508. if (safety && safety.IWillNotUseThisInPlugins) {
  8509. return this.tech_;
  8510. }
  8511. var errorText = '\n Please make sure that you are not using this inside of a plugin.\n To disable this alert and error, please pass in an object with\n `IWillNotUseThisInPlugins` to the `tech` method. See\n https://github.com/videojs/video.js/issues/2617 for more info.\n ';
  8512. _globalWindow2['default'].alert(errorText);
  8513. throw new Error(errorText);
  8514. };
  8515. /**
  8516. * Set up click and touch listeners for the playback element
  8517. *
  8518. * On desktops, a click on the video itself will toggle playback,
  8519. * on a mobile device a click on the video toggles controls.
  8520. * (toggling controls is done by toggling the user state between active and
  8521. * inactive)
  8522. * A tap can signal that a user has become active, or has become inactive
  8523. * e.g. a quick tap on an iPhone movie should reveal the controls. Another
  8524. * quick tap should hide them again (signaling the user is in an inactive
  8525. * viewing state)
  8526. * In addition to this, we still want the user to be considered inactive after
  8527. * a few seconds of inactivity.
  8528. * Note: the only part of iOS interaction we can't mimic with this setup
  8529. * is a touch and hold on the video element counting as activity in order to
  8530. * keep the controls showing, but that shouldn't be an issue. A touch and hold
  8531. * on any controls will still keep the user active
  8532. *
  8533. * @private
  8534. * @method addTechControlsListeners_
  8535. */
  8536. Player.prototype.addTechControlsListeners_ = function addTechControlsListeners_() {
  8537. // Make sure to remove all the previous listeners in case we are called multiple times.
  8538. this.removeTechControlsListeners_();
  8539. // Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
  8540. // trigger mousedown/up.
  8541. // http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
  8542. // Any touch events are set to block the mousedown event from happening
  8543. this.on(this.tech_, 'mousedown', this.handleTechClick_);
  8544. // If the controls were hidden we don't want that to change without a tap event
  8545. // so we'll check if the controls were already showing before reporting user
  8546. // activity
  8547. this.on(this.tech_, 'touchstart', this.handleTechTouchStart_);
  8548. this.on(this.tech_, 'touchmove', this.handleTechTouchMove_);
  8549. this.on(this.tech_, 'touchend', this.handleTechTouchEnd_);
  8550. // The tap listener needs to come after the touchend listener because the tap
  8551. // listener cancels out any reportedUserActivity when setting userActive(false)
  8552. this.on(this.tech_, 'tap', this.handleTechTap_);
  8553. };
  8554. /**
  8555. * Remove the listeners used for click and tap controls. This is needed for
  8556. * toggling to controls disabled, where a tap/touch should do nothing.
  8557. *
  8558. * @method removeTechControlsListeners_
  8559. * @private
  8560. */
  8561. Player.prototype.removeTechControlsListeners_ = function removeTechControlsListeners_() {
  8562. // We don't want to just use `this.off()` because there might be other needed
  8563. // listeners added by techs that extend this.
  8564. this.off(this.tech_, 'tap', this.handleTechTap_);
  8565. this.off(this.tech_, 'touchstart', this.handleTechTouchStart_);
  8566. this.off(this.tech_, 'touchmove', this.handleTechTouchMove_);
  8567. this.off(this.tech_, 'touchend', this.handleTechTouchEnd_);
  8568. this.off(this.tech_, 'mousedown', this.handleTechClick_);
  8569. };
  8570. /**
  8571. * Player waits for the tech to be ready
  8572. *
  8573. * @method handleTechReady_
  8574. * @private
  8575. */
  8576. Player.prototype.handleTechReady_ = function handleTechReady_() {
  8577. this.triggerReady();
  8578. // Keep the same volume as before
  8579. if (this.cache_.volume) {
  8580. this.techCall_('setVolume', this.cache_.volume);
  8581. }
  8582. // Look if the tech found a higher resolution poster while loading
  8583. this.handleTechPosterChange_();
  8584. // Update the duration if available
  8585. this.handleTechDurationChange_();
  8586. // Chrome and Safari both have issues with autoplay.
  8587. // In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
  8588. // In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
  8589. // This fixes both issues. Need to wait for API, so it updates displays correctly
  8590. if (this.src() && this.tag && this.options_.autoplay && this.paused()) {
  8591. delete this.tag.poster; // Chrome Fix. Fixed in Chrome v16.
  8592. this.play();
  8593. }
  8594. };
  8595. /**
  8596. * Fired when the user agent begins looking for media data
  8597. *
  8598. * @private
  8599. * @method handleTechLoadStart_
  8600. */
  8601. Player.prototype.handleTechLoadStart_ = function handleTechLoadStart_() {
  8602. // TODO: Update to use `emptied` event instead. See #1277.
  8603. this.removeClass('vjs-ended');
  8604. // reset the error state
  8605. this.error(null);
  8606. // If it's already playing we want to trigger a firstplay event now.
  8607. // The firstplay event relies on both the play and loadstart events
  8608. // which can happen in any order for a new source
  8609. if (!this.paused()) {
  8610. this.trigger('loadstart');
  8611. this.trigger('firstplay');
  8612. } else {
  8613. // reset the hasStarted state
  8614. this.hasStarted(false);
  8615. this.trigger('loadstart');
  8616. }
  8617. };
  8618. /**
  8619. * Add/remove the vjs-has-started class
  8620. *
  8621. * @param {Boolean} hasStarted The value of true adds the class the value of false remove the class
  8622. * @return {Boolean} Boolean value if has started
  8623. * @private
  8624. * @method hasStarted
  8625. */
  8626. Player.prototype.hasStarted = function hasStarted(_hasStarted) {
  8627. if (_hasStarted !== undefined) {
  8628. // only update if this is a new value
  8629. if (this.hasStarted_ !== _hasStarted) {
  8630. this.hasStarted_ = _hasStarted;
  8631. if (_hasStarted) {
  8632. this.addClass('vjs-has-started');
  8633. // trigger the firstplay event if this newly has played
  8634. this.trigger('firstplay');
  8635. } else {
  8636. this.removeClass('vjs-has-started');
  8637. }
  8638. }
  8639. return this;
  8640. }
  8641. return !!this.hasStarted_;
  8642. };
  8643. /**
  8644. * Fired whenever the media begins or resumes playback
  8645. *
  8646. * @private
  8647. * @method handleTechPlay_
  8648. */
  8649. Player.prototype.handleTechPlay_ = function handleTechPlay_() {
  8650. this.removeClass('vjs-ended');
  8651. this.removeClass('vjs-paused');
  8652. this.addClass('vjs-playing');
  8653. // hide the poster when the user hits play
  8654. // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play
  8655. this.hasStarted(true);
  8656. this.trigger('play');
  8657. };
  8658. /**
  8659. * Fired whenever the media begins waiting
  8660. *
  8661. * @private
  8662. * @method handleTechWaiting_
  8663. */
  8664. Player.prototype.handleTechWaiting_ = function handleTechWaiting_() {
  8665. var _this2 = this;
  8666. this.addClass('vjs-waiting');
  8667. this.trigger('waiting');
  8668. this.one('timeupdate', function () {
  8669. return _this2.removeClass('vjs-waiting');
  8670. });
  8671. };
  8672. /**
  8673. * A handler for events that signal that waiting has ended
  8674. * which is not consistent between browsers. See #1351
  8675. *
  8676. * @private
  8677. * @method handleTechCanPlay_
  8678. */
  8679. Player.prototype.handleTechCanPlay_ = function handleTechCanPlay_() {
  8680. this.removeClass('vjs-waiting');
  8681. this.trigger('canplay');
  8682. };
  8683. /**
  8684. * A handler for events that signal that waiting has ended
  8685. * which is not consistent between browsers. See #1351
  8686. *
  8687. * @private
  8688. * @method handleTechCanPlayThrough_
  8689. */
  8690. Player.prototype.handleTechCanPlayThrough_ = function handleTechCanPlayThrough_() {
  8691. this.removeClass('vjs-waiting');
  8692. this.trigger('canplaythrough');
  8693. };
  8694. /**
  8695. * A handler for events that signal that waiting has ended
  8696. * which is not consistent between browsers. See #1351
  8697. *
  8698. * @private
  8699. * @method handleTechPlaying_
  8700. */
  8701. Player.prototype.handleTechPlaying_ = function handleTechPlaying_() {
  8702. this.removeClass('vjs-waiting');
  8703. this.trigger('playing');
  8704. };
  8705. /**
  8706. * Fired whenever the player is jumping to a new time
  8707. *
  8708. * @private
  8709. * @method handleTechSeeking_
  8710. */
  8711. Player.prototype.handleTechSeeking_ = function handleTechSeeking_() {
  8712. this.addClass('vjs-seeking');
  8713. this.trigger('seeking');
  8714. };
  8715. /**
  8716. * Fired when the player has finished jumping to a new time
  8717. *
  8718. * @private
  8719. * @method handleTechSeeked_
  8720. */
  8721. Player.prototype.handleTechSeeked_ = function handleTechSeeked_() {
  8722. this.removeClass('vjs-seeking');
  8723. this.trigger('seeked');
  8724. };
  8725. /**
  8726. * Fired the first time a video is played
  8727. * Not part of the HLS spec, and we're not sure if this is the best
  8728. * implementation yet, so use sparingly. If you don't have a reason to
  8729. * prevent playback, use `myPlayer.one('play');` instead.
  8730. *
  8731. * @private
  8732. * @method handleTechFirstPlay_
  8733. */
  8734. Player.prototype.handleTechFirstPlay_ = function handleTechFirstPlay_() {
  8735. //If the first starttime attribute is specified
  8736. //then we will start at the given offset in seconds
  8737. if (this.options_.starttime) {
  8738. this.currentTime(this.options_.starttime);
  8739. }
  8740. this.addClass('vjs-has-started');
  8741. this.trigger('firstplay');
  8742. };
  8743. /**
  8744. * Fired whenever the media has been paused
  8745. *
  8746. * @private
  8747. * @method handleTechPause_
  8748. */
  8749. Player.prototype.handleTechPause_ = function handleTechPause_() {
  8750. this.removeClass('vjs-playing');
  8751. this.addClass('vjs-paused');
  8752. this.trigger('pause');
  8753. };
  8754. /**
  8755. * Fired while the user agent is downloading media data
  8756. *
  8757. * @private
  8758. * @method handleTechProgress_
  8759. */
  8760. Player.prototype.handleTechProgress_ = function handleTechProgress_() {
  8761. this.trigger('progress');
  8762. };
  8763. /**
  8764. * Fired when the end of the media resource is reached (currentTime == duration)
  8765. *
  8766. * @private
  8767. * @method handleTechEnded_
  8768. */
  8769. Player.prototype.handleTechEnded_ = function handleTechEnded_() {
  8770. this.addClass('vjs-ended');
  8771. if (this.options_.loop) {
  8772. this.currentTime(0);
  8773. this.play();
  8774. } else if (!this.paused()) {
  8775. this.pause();
  8776. }
  8777. this.trigger('ended');
  8778. };
  8779. /**
  8780. * Fired when the duration of the media resource is first known or changed
  8781. *
  8782. * @private
  8783. * @method handleTechDurationChange_
  8784. */
  8785. Player.prototype.handleTechDurationChange_ = function handleTechDurationChange_() {
  8786. this.duration(this.techGet_('duration'));
  8787. };
  8788. /**
  8789. * Handle a click on the media element to play/pause
  8790. *
  8791. * @param {Object=} event Event object
  8792. * @private
  8793. * @method handleTechClick_
  8794. */
  8795. Player.prototype.handleTechClick_ = function handleTechClick_(event) {
  8796. // We're using mousedown to detect clicks thanks to Flash, but mousedown
  8797. // will also be triggered with right-clicks, so we need to prevent that
  8798. if (event.button !== 0) return;
  8799. // When controls are disabled a click should not toggle playback because
  8800. // the click is considered a control
  8801. if (this.controls()) {
  8802. if (this.paused()) {
  8803. this.play();
  8804. } else {
  8805. this.pause();
  8806. }
  8807. }
  8808. };
  8809. /**
  8810. * Handle a tap on the media element. It will toggle the user
  8811. * activity state, which hides and shows the controls.
  8812. *
  8813. * @private
  8814. * @method handleTechTap_
  8815. */
  8816. Player.prototype.handleTechTap_ = function handleTechTap_() {
  8817. this.userActive(!this.userActive());
  8818. };
  8819. /**
  8820. * Handle touch to start
  8821. *
  8822. * @private
  8823. * @method handleTechTouchStart_
  8824. */
  8825. Player.prototype.handleTechTouchStart_ = function handleTechTouchStart_() {
  8826. this.userWasActive = this.userActive();
  8827. };
  8828. /**
  8829. * Handle touch to move
  8830. *
  8831. * @private
  8832. * @method handleTechTouchMove_
  8833. */
  8834. Player.prototype.handleTechTouchMove_ = function handleTechTouchMove_() {
  8835. if (this.userWasActive) {
  8836. this.reportUserActivity();
  8837. }
  8838. };
  8839. /**
  8840. * Handle touch to end
  8841. *
  8842. * @private
  8843. * @method handleTechTouchEnd_
  8844. */
  8845. Player.prototype.handleTechTouchEnd_ = function handleTechTouchEnd_(event) {
  8846. // Stop the mouse events from also happening
  8847. event.preventDefault();
  8848. };
  8849. /**
  8850. * Fired when the player switches in or out of fullscreen mode
  8851. *
  8852. * @private
  8853. * @method handleFullscreenChange_
  8854. */
  8855. Player.prototype.handleFullscreenChange_ = function handleFullscreenChange_() {
  8856. if (this.isFullscreen()) {
  8857. this.addClass('vjs-fullscreen');
  8858. } else {
  8859. this.removeClass('vjs-fullscreen');
  8860. }
  8861. };
  8862. /**
  8863. * native click events on the SWF aren't triggered on IE11, Win8.1RT
  8864. * use stageclick events triggered from inside the SWF instead
  8865. *
  8866. * @private
  8867. * @method handleStageClick_
  8868. */
  8869. Player.prototype.handleStageClick_ = function handleStageClick_() {
  8870. this.reportUserActivity();
  8871. };
  8872. /**
  8873. * Handle Tech Fullscreen Change
  8874. *
  8875. * @private
  8876. * @method handleTechFullscreenChange_
  8877. */
  8878. Player.prototype.handleTechFullscreenChange_ = function handleTechFullscreenChange_(event, data) {
  8879. if (data) {
  8880. this.isFullscreen(data.isFullscreen);
  8881. }
  8882. this.trigger('fullscreenchange');
  8883. };
  8884. /**
  8885. * Fires when an error occurred during the loading of an audio/video
  8886. *
  8887. * @private
  8888. * @method handleTechError_
  8889. */
  8890. Player.prototype.handleTechError_ = function handleTechError_() {
  8891. var error = this.tech_.error();
  8892. this.error(error && error.code);
  8893. };
  8894. /**
  8895. * Fires when the browser is intentionally not getting media data
  8896. *
  8897. * @private
  8898. * @method handleTechSuspend_
  8899. */
  8900. Player.prototype.handleTechSuspend_ = function handleTechSuspend_() {
  8901. this.trigger('suspend');
  8902. };
  8903. /**
  8904. * Fires when the loading of an audio/video is aborted
  8905. *
  8906. * @private
  8907. * @method handleTechAbort_
  8908. */
  8909. Player.prototype.handleTechAbort_ = function handleTechAbort_() {
  8910. this.trigger('abort');
  8911. };
  8912. /**
  8913. * Fires when the current playlist is empty
  8914. *
  8915. * @private
  8916. * @method handleTechEmptied_
  8917. */
  8918. Player.prototype.handleTechEmptied_ = function handleTechEmptied_() {
  8919. this.trigger('emptied');
  8920. };
  8921. /**
  8922. * Fires when the browser is trying to get media data, but data is not available
  8923. *
  8924. * @private
  8925. * @method handleTechStalled_
  8926. */
  8927. Player.prototype.handleTechStalled_ = function handleTechStalled_() {
  8928. this.trigger('stalled');
  8929. };
  8930. /**
  8931. * Fires when the browser has loaded meta data for the audio/video
  8932. *
  8933. * @private
  8934. * @method handleTechLoadedMetaData_
  8935. */
  8936. Player.prototype.handleTechLoadedMetaData_ = function handleTechLoadedMetaData_() {
  8937. this.trigger('loadedmetadata');
  8938. };
  8939. /**
  8940. * Fires when the browser has loaded the current frame of the audio/video
  8941. *
  8942. * @private
  8943. * @method handleTechLoadedData_
  8944. */
  8945. Player.prototype.handleTechLoadedData_ = function handleTechLoadedData_() {
  8946. this.trigger('loadeddata');
  8947. };
  8948. /**
  8949. * Fires when the current playback position has changed
  8950. *
  8951. * @private
  8952. * @method handleTechTimeUpdate_
  8953. */
  8954. Player.prototype.handleTechTimeUpdate_ = function handleTechTimeUpdate_() {
  8955. this.trigger('timeupdate');
  8956. };
  8957. /**
  8958. * Fires when the playing speed of the audio/video is changed
  8959. *
  8960. * @private
  8961. * @method handleTechRateChange_
  8962. */
  8963. Player.prototype.handleTechRateChange_ = function handleTechRateChange_() {
  8964. this.trigger('ratechange');
  8965. };
  8966. /**
  8967. * Fires when the volume has been changed
  8968. *
  8969. * @private
  8970. * @method handleTechVolumeChange_
  8971. */
  8972. Player.prototype.handleTechVolumeChange_ = function handleTechVolumeChange_() {
  8973. this.trigger('volumechange');
  8974. };
  8975. /**
  8976. * Fires when the text track has been changed
  8977. *
  8978. * @private
  8979. * @method handleTechTextTrackChange_
  8980. */
  8981. Player.prototype.handleTechTextTrackChange_ = function handleTechTextTrackChange_() {
  8982. this.trigger('texttrackchange');
  8983. };
  8984. /**
  8985. * Get object for cached values.
  8986. *
  8987. * @return {Object}
  8988. * @method getCache
  8989. */
  8990. Player.prototype.getCache = function getCache() {
  8991. return this.cache_;
  8992. };
  8993. /**
  8994. * Pass values to the playback tech
  8995. *
  8996. * @param {String=} method Method
  8997. * @param {Object=} arg Argument
  8998. * @private
  8999. * @method techCall_
  9000. */
  9001. Player.prototype.techCall_ = function techCall_(method, arg) {
  9002. // If it's not ready yet, call method when it is
  9003. if (this.tech_ && !this.tech_.isReady_) {
  9004. this.tech_.ready(function () {
  9005. this[method](arg);
  9006. }, true);
  9007. // Otherwise call method now
  9008. } else {
  9009. try {
  9010. this.tech_[method](arg);
  9011. } catch (e) {
  9012. _utilsLogJs2['default'](e);
  9013. throw e;
  9014. }
  9015. }
  9016. };
  9017. /**
  9018. * Get calls can't wait for the tech, and sometimes don't need to.
  9019. *
  9020. * @param {String} method Tech method
  9021. * @return {Method}
  9022. * @private
  9023. * @method techGet_
  9024. */
  9025. Player.prototype.techGet_ = function techGet_(method) {
  9026. if (this.tech_ && this.tech_.isReady_) {
  9027. // Flash likes to die and reload when you hide or reposition it.
  9028. // In these cases the object methods go away and we get errors.
  9029. // When that happens we'll catch the errors and inform tech that it's not ready any more.
  9030. try {
  9031. return this.tech_[method]();
  9032. } catch (e) {
  9033. // When building additional tech libs, an expected method may not be defined yet
  9034. if (this.tech_[method] === undefined) {
  9035. _utilsLogJs2['default']('Video.js: ' + method + ' method not defined for ' + this.techName_ + ' playback technology.', e);
  9036. } else {
  9037. // When a method isn't available on the object it throws a TypeError
  9038. if (e.name === 'TypeError') {
  9039. _utilsLogJs2['default']('Video.js: ' + method + ' unavailable on ' + this.techName_ + ' playback technology element.', e);
  9040. this.tech_.isReady_ = false;
  9041. } else {
  9042. _utilsLogJs2['default'](e);
  9043. }
  9044. }
  9045. throw e;
  9046. }
  9047. }
  9048. return;
  9049. };
  9050. /**
  9051. * start media playback
  9052. * ```js
  9053. * myPlayer.play();
  9054. * ```
  9055. *
  9056. * @return {Player} self
  9057. * @method play
  9058. */
  9059. Player.prototype.play = function play() {
  9060. this.techCall_('play');
  9061. return this;
  9062. };
  9063. /**
  9064. * Pause the video playback
  9065. * ```js
  9066. * myPlayer.pause();
  9067. * ```
  9068. *
  9069. * @return {Player} self
  9070. * @method pause
  9071. */
  9072. Player.prototype.pause = function pause() {
  9073. this.techCall_('pause');
  9074. return this;
  9075. };
  9076. /**
  9077. * Check if the player is paused
  9078. * ```js
  9079. * var isPaused = myPlayer.paused();
  9080. * var isPlaying = !myPlayer.paused();
  9081. * ```
  9082. *
  9083. * @return {Boolean} false if the media is currently playing, or true otherwise
  9084. * @method paused
  9085. */
  9086. Player.prototype.paused = function paused() {
  9087. // The initial state of paused should be true (in Safari it's actually false)
  9088. return this.techGet_('paused') === false ? false : true;
  9089. };
  9090. /**
  9091. * Returns whether or not the user is "scrubbing". Scrubbing is when the user
  9092. * has clicked the progress bar handle and is dragging it along the progress bar.
  9093. *
  9094. * @param {Boolean} isScrubbing True/false the user is scrubbing
  9095. * @return {Boolean} The scrubbing status when getting
  9096. * @return {Object} The player when setting
  9097. * @method scrubbing
  9098. */
  9099. Player.prototype.scrubbing = function scrubbing(isScrubbing) {
  9100. if (isScrubbing !== undefined) {
  9101. this.scrubbing_ = !!isScrubbing;
  9102. if (isScrubbing) {
  9103. this.addClass('vjs-scrubbing');
  9104. } else {
  9105. this.removeClass('vjs-scrubbing');
  9106. }
  9107. return this;
  9108. }
  9109. return this.scrubbing_;
  9110. };
  9111. /**
  9112. * Get or set the current time (in seconds)
  9113. * ```js
  9114. * // get
  9115. * var whereYouAt = myPlayer.currentTime();
  9116. * // set
  9117. * myPlayer.currentTime(120); // 2 minutes into the video
  9118. * ```
  9119. *
  9120. * @param {Number|String=} seconds The time to seek to
  9121. * @return {Number} The time in seconds, when not setting
  9122. * @return {Player} self, when the current time is set
  9123. * @method currentTime
  9124. */
  9125. Player.prototype.currentTime = function currentTime(seconds) {
  9126. if (seconds !== undefined) {
  9127. this.techCall_('setCurrentTime', seconds);
  9128. return this;
  9129. }
  9130. // cache last currentTime and return. default to 0 seconds
  9131. //
  9132. // Caching the currentTime is meant to prevent a massive amount of reads on the tech's
  9133. // currentTime when scrubbing, but may not provide much performance benefit afterall.
  9134. // Should be tested. Also something has to read the actual current time or the cache will
  9135. // never get updated.
  9136. return this.cache_.currentTime = this.techGet_('currentTime') || 0;
  9137. };
  9138. /**
  9139. * Get the length in time of the video in seconds
  9140. * ```js
  9141. * var lengthOfVideo = myPlayer.duration();
  9142. * ```
  9143. * **NOTE**: The video must have started loading before the duration can be
  9144. * known, and in the case of Flash, may not be known until the video starts
  9145. * playing.
  9146. *
  9147. * @param {Number} seconds Duration when setting
  9148. * @return {Number} The duration of the video in seconds when getting
  9149. * @method duration
  9150. */
  9151. Player.prototype.duration = function duration(seconds) {
  9152. if (seconds === undefined) {
  9153. return this.cache_.duration || 0;
  9154. }
  9155. seconds = parseFloat(seconds) || 0;
  9156. // Standardize on Inifity for signaling video is live
  9157. if (seconds < 0) {
  9158. seconds = Infinity;
  9159. }
  9160. if (seconds !== this.cache_.duration) {
  9161. // Cache the last set value for optimized scrubbing (esp. Flash)
  9162. this.cache_.duration = seconds;
  9163. if (seconds === Infinity) {
  9164. this.addClass('vjs-live');
  9165. } else {
  9166. this.removeClass('vjs-live');
  9167. }
  9168. this.trigger('durationchange');
  9169. }
  9170. return this;
  9171. };
  9172. /**
  9173. * Calculates how much time is left.
  9174. * ```js
  9175. * var timeLeft = myPlayer.remainingTime();
  9176. * ```
  9177. * Not a native video element function, but useful
  9178. *
  9179. * @return {Number} The time remaining in seconds
  9180. * @method remainingTime
  9181. */
  9182. Player.prototype.remainingTime = function remainingTime() {
  9183. return this.duration() - this.currentTime();
  9184. };
  9185. // http://dev.w3.org/html5/spec/video.html#dom-media-buffered
  9186. // Buffered returns a timerange object.
  9187. // Kind of like an array of portions of the video that have been downloaded.
  9188. /**
  9189. * Get a TimeRange object with the times of the video that have been downloaded
  9190. * If you just want the percent of the video that's been downloaded,
  9191. * use bufferedPercent.
  9192. * ```js
  9193. * // Number of different ranges of time have been buffered. Usually 1.
  9194. * numberOfRanges = bufferedTimeRange.length,
  9195. * // Time in seconds when the first range starts. Usually 0.
  9196. * firstRangeStart = bufferedTimeRange.start(0),
  9197. * // Time in seconds when the first range ends
  9198. * firstRangeEnd = bufferedTimeRange.end(0),
  9199. * // Length in seconds of the first time range
  9200. * firstRangeLength = firstRangeEnd - firstRangeStart;
  9201. * ```
  9202. *
  9203. * @return {Object} A mock TimeRange object (following HTML spec)
  9204. * @method buffered
  9205. */
  9206. Player.prototype.buffered = function buffered() {
  9207. var buffered = this.techGet_('buffered');
  9208. if (!buffered || !buffered.length) {
  9209. buffered = _utilsTimeRangesJs.createTimeRange(0, 0);
  9210. }
  9211. return buffered;
  9212. };
  9213. /**
  9214. * Get the percent (as a decimal) of the video that's been downloaded
  9215. * ```js
  9216. * var howMuchIsDownloaded = myPlayer.bufferedPercent();
  9217. * ```
  9218. * 0 means none, 1 means all.
  9219. * (This method isn't in the HTML5 spec, but it's very convenient)
  9220. *
  9221. * @return {Number} A decimal between 0 and 1 representing the percent
  9222. * @method bufferedPercent
  9223. */
  9224. Player.prototype.bufferedPercent = function bufferedPercent() {
  9225. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration());
  9226. };
  9227. /**
  9228. * Get the ending time of the last buffered time range
  9229. * This is used in the progress bar to encapsulate all time ranges.
  9230. *
  9231. * @return {Number} The end of the last buffered time range
  9232. * @method bufferedEnd
  9233. */
  9234. Player.prototype.bufferedEnd = function bufferedEnd() {
  9235. var buffered = this.buffered(),
  9236. duration = this.duration(),
  9237. end = buffered.end(buffered.length - 1);
  9238. if (end > duration) {
  9239. end = duration;
  9240. }
  9241. return end;
  9242. };
  9243. /**
  9244. * Get or set the current volume of the media
  9245. * ```js
  9246. * // get
  9247. * var howLoudIsIt = myPlayer.volume();
  9248. * // set
  9249. * myPlayer.volume(0.5); // Set volume to half
  9250. * ```
  9251. * 0 is off (muted), 1.0 is all the way up, 0.5 is half way.
  9252. *
  9253. * @param {Number} percentAsDecimal The new volume as a decimal percent
  9254. * @return {Number} The current volume when getting
  9255. * @return {Player} self when setting
  9256. * @method volume
  9257. */
  9258. Player.prototype.volume = function volume(percentAsDecimal) {
  9259. var vol = undefined;
  9260. if (percentAsDecimal !== undefined) {
  9261. vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); // Force value to between 0 and 1
  9262. this.cache_.volume = vol;
  9263. this.techCall_('setVolume', vol);
  9264. return this;
  9265. }
  9266. // Default to 1 when returning current volume.
  9267. vol = parseFloat(this.techGet_('volume'));
  9268. return isNaN(vol) ? 1 : vol;
  9269. };
  9270. /**
  9271. * Get the current muted state, or turn mute on or off
  9272. * ```js
  9273. * // get
  9274. * var isVolumeMuted = myPlayer.muted();
  9275. * // set
  9276. * myPlayer.muted(true); // mute the volume
  9277. * ```
  9278. *
  9279. * @param {Boolean=} muted True to mute, false to unmute
  9280. * @return {Boolean} True if mute is on, false if not when getting
  9281. * @return {Player} self when setting mute
  9282. * @method muted
  9283. */
  9284. Player.prototype.muted = function muted(_muted) {
  9285. if (_muted !== undefined) {
  9286. this.techCall_('setMuted', _muted);
  9287. return this;
  9288. }
  9289. return this.techGet_('muted') || false; // Default to false
  9290. };
  9291. // Check if current tech can support native fullscreen
  9292. // (e.g. with built in controls like iOS, so not our flash swf)
  9293. /**
  9294. * Check to see if fullscreen is supported
  9295. *
  9296. * @return {Boolean}
  9297. * @method supportsFullScreen
  9298. */
  9299. Player.prototype.supportsFullScreen = function supportsFullScreen() {
  9300. return this.techGet_('supportsFullScreen') || false;
  9301. };
  9302. /**
  9303. * Check if the player is in fullscreen mode
  9304. * ```js
  9305. * // get
  9306. * var fullscreenOrNot = myPlayer.isFullscreen();
  9307. * // set
  9308. * myPlayer.isFullscreen(true); // tell the player it's in fullscreen
  9309. * ```
  9310. * NOTE: As of the latest HTML5 spec, isFullscreen is no longer an official
  9311. * property and instead document.fullscreenElement is used. But isFullscreen is
  9312. * still a valuable property for internal player workings.
  9313. *
  9314. * @param {Boolean=} isFS Update the player's fullscreen state
  9315. * @return {Boolean} true if fullscreen false if not when getting
  9316. * @return {Player} self when setting
  9317. * @method isFullscreen
  9318. */
  9319. Player.prototype.isFullscreen = function isFullscreen(isFS) {
  9320. if (isFS !== undefined) {
  9321. this.isFullscreen_ = !!isFS;
  9322. return this;
  9323. }
  9324. return !!this.isFullscreen_;
  9325. };
  9326. /**
  9327. * Increase the size of the video to full screen
  9328. * ```js
  9329. * myPlayer.requestFullscreen();
  9330. * ```
  9331. * In some browsers, full screen is not supported natively, so it enters
  9332. * "full window mode", where the video fills the browser window.
  9333. * In browsers and devices that support native full screen, sometimes the
  9334. * browser's default controls will be shown, and not the Video.js custom skin.
  9335. * This includes most mobile devices (iOS, Android) and older versions of
  9336. * Safari.
  9337. *
  9338. * @return {Player} self
  9339. * @method requestFullscreen
  9340. */
  9341. Player.prototype.requestFullscreen = function requestFullscreen() {
  9342. var fsApi = _fullscreenApiJs2['default'];
  9343. this.isFullscreen(true);
  9344. if (fsApi.requestFullscreen) {
  9345. // the browser supports going fullscreen at the element level so we can
  9346. // take the controls fullscreen as well as the video
  9347. // Trigger fullscreenchange event after change
  9348. // We have to specifically add this each time, and remove
  9349. // when canceling fullscreen. Otherwise if there's multiple
  9350. // players on a page, they would all be reacting to the same fullscreen
  9351. // events
  9352. Events.on(_globalDocument2['default'], fsApi.fullscreenchange, Fn.bind(this, function documentFullscreenChange(e) {
  9353. this.isFullscreen(_globalDocument2['default'][fsApi.fullscreenElement]);
  9354. // If cancelling fullscreen, remove event listener.
  9355. if (this.isFullscreen() === false) {
  9356. Events.off(_globalDocument2['default'], fsApi.fullscreenchange, documentFullscreenChange);
  9357. }
  9358. this.trigger('fullscreenchange');
  9359. }));
  9360. this.el_[fsApi.requestFullscreen]();
  9361. } else if (this.tech_.supportsFullScreen()) {
  9362. // we can't take the video.js controls fullscreen but we can go fullscreen
  9363. // with native controls
  9364. this.techCall_('enterFullScreen');
  9365. } else {
  9366. // fullscreen isn't supported so we'll just stretch the video element to
  9367. // fill the viewport
  9368. this.enterFullWindow();
  9369. this.trigger('fullscreenchange');
  9370. }
  9371. return this;
  9372. };
  9373. /**
  9374. * Return the video to its normal size after having been in full screen mode
  9375. * ```js
  9376. * myPlayer.exitFullscreen();
  9377. * ```
  9378. *
  9379. * @return {Player} self
  9380. * @method exitFullscreen
  9381. */
  9382. Player.prototype.exitFullscreen = function exitFullscreen() {
  9383. var fsApi = _fullscreenApiJs2['default'];
  9384. this.isFullscreen(false);
  9385. // Check for browser element fullscreen support
  9386. if (fsApi.requestFullscreen) {
  9387. _globalDocument2['default'][fsApi.exitFullscreen]();
  9388. } else if (this.tech_.supportsFullScreen()) {
  9389. this.techCall_('exitFullScreen');
  9390. } else {
  9391. this.exitFullWindow();
  9392. this.trigger('fullscreenchange');
  9393. }
  9394. return this;
  9395. };
  9396. /**
  9397. * When fullscreen isn't supported we can stretch the video container to as wide as the browser will let us.
  9398. *
  9399. * @method enterFullWindow
  9400. */
  9401. Player.prototype.enterFullWindow = function enterFullWindow() {
  9402. this.isFullWindow = true;
  9403. // Storing original doc overflow value to return to when fullscreen is off
  9404. this.docOrigOverflow = _globalDocument2['default'].documentElement.style.overflow;
  9405. // Add listener for esc key to exit fullscreen
  9406. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.fullWindowOnEscKey));
  9407. // Hide any scroll bars
  9408. _globalDocument2['default'].documentElement.style.overflow = 'hidden';
  9409. // Apply fullscreen styles
  9410. Dom.addElClass(_globalDocument2['default'].body, 'vjs-full-window');
  9411. this.trigger('enterFullWindow');
  9412. };
  9413. /**
  9414. * Check for call to either exit full window or full screen on ESC key
  9415. *
  9416. * @param {String} event Event to check for key press
  9417. * @method fullWindowOnEscKey
  9418. */
  9419. Player.prototype.fullWindowOnEscKey = function fullWindowOnEscKey(event) {
  9420. if (event.keyCode === 27) {
  9421. if (this.isFullscreen() === true) {
  9422. this.exitFullscreen();
  9423. } else {
  9424. this.exitFullWindow();
  9425. }
  9426. }
  9427. };
  9428. /**
  9429. * Exit full window
  9430. *
  9431. * @method exitFullWindow
  9432. */
  9433. Player.prototype.exitFullWindow = function exitFullWindow() {
  9434. this.isFullWindow = false;
  9435. Events.off(_globalDocument2['default'], 'keydown', this.fullWindowOnEscKey);
  9436. // Unhide scroll bars.
  9437. _globalDocument2['default'].documentElement.style.overflow = this.docOrigOverflow;
  9438. // Remove fullscreen styles
  9439. Dom.removeElClass(_globalDocument2['default'].body, 'vjs-full-window');
  9440. // Resize the box, controller, and poster to original sizes
  9441. // this.positionAll();
  9442. this.trigger('exitFullWindow');
  9443. };
  9444. /**
  9445. * Check whether the player can play a given mimetype
  9446. *
  9447. * @param {String} type The mimetype to check
  9448. * @return {String} 'probably', 'maybe', or '' (empty string)
  9449. * @method canPlayType
  9450. */
  9451. Player.prototype.canPlayType = function canPlayType(type) {
  9452. var can = undefined;
  9453. // Loop through each playback technology in the options order
  9454. for (var i = 0, j = this.options_.techOrder; i < j.length; i++) {
  9455. var techName = _utilsToTitleCaseJs2['default'](j[i]);
  9456. var tech = _techTechJs2['default'].getTech(techName);
  9457. // Support old behavior of techs being registered as components.
  9458. // Remove once that deprecated behavior is removed.
  9459. if (!tech) {
  9460. tech = _componentJs2['default'].getComponent(techName);
  9461. }
  9462. // Check if the current tech is defined before continuing
  9463. if (!tech) {
  9464. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
  9465. continue;
  9466. }
  9467. // Check if the browser supports this technology
  9468. if (tech.isSupported()) {
  9469. can = tech.canPlayType(type);
  9470. if (can) {
  9471. return can;
  9472. }
  9473. }
  9474. }
  9475. return '';
  9476. };
  9477. /**
  9478. * Select source based on tech-order or source-order
  9479. * Uses source-order selection if `options.sourceOrder` is truthy. Otherwise,
  9480. * defaults to tech-order selection
  9481. *
  9482. * @param {Array} sources The sources for a media asset
  9483. * @return {Object|Boolean} Object of source and tech order, otherwise false
  9484. * @method selectSource
  9485. */
  9486. Player.prototype.selectSource = function selectSource(sources) {
  9487. // Get only the techs specified in `techOrder` that exist and are supported by the
  9488. // current platform
  9489. var techs = this.options_.techOrder.map(_utilsToTitleCaseJs2['default']).map(function (techName) {
  9490. // `Component.getComponent(...)` is for support of old behavior of techs
  9491. // being registered as components.
  9492. // Remove once that deprecated behavior is removed.
  9493. return [techName, _techTechJs2['default'].getTech(techName) || _componentJs2['default'].getComponent(techName)];
  9494. }).filter(function (_ref) {
  9495. var techName = _ref[0];
  9496. var tech = _ref[1];
  9497. // Check if the current tech is defined before continuing
  9498. if (tech) {
  9499. // Check if the browser supports this technology
  9500. return tech.isSupported();
  9501. }
  9502. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
  9503. return false;
  9504. });
  9505. // Iterate over each `innerArray` element once per `outerArray` element and execute
  9506. // `tester` with both. If `tester` returns a non-falsy value, exit early and return
  9507. // that value.
  9508. var findFirstPassingTechSourcePair = function findFirstPassingTechSourcePair(outerArray, innerArray, tester) {
  9509. var found = undefined;
  9510. outerArray.some(function (outerChoice) {
  9511. return innerArray.some(function (innerChoice) {
  9512. found = tester(outerChoice, innerChoice);
  9513. if (found) {
  9514. return true;
  9515. }
  9516. });
  9517. });
  9518. return found;
  9519. };
  9520. var foundSourceAndTech = undefined;
  9521. var flip = function flip(fn) {
  9522. return function (a, b) {
  9523. return fn(b, a);
  9524. };
  9525. };
  9526. var finder = function finder(_ref2, source) {
  9527. var techName = _ref2[0];
  9528. var tech = _ref2[1];
  9529. if (tech.canPlaySource(source)) {
  9530. return { source: source, tech: techName };
  9531. }
  9532. };
  9533. // Depending on the truthiness of `options.sourceOrder`, we swap the order of techs and sources
  9534. // to select from them based on their priority.
  9535. if (this.options_.sourceOrder) {
  9536. // Source-first ordering
  9537. foundSourceAndTech = findFirstPassingTechSourcePair(sources, techs, flip(finder));
  9538. } else {
  9539. // Tech-first ordering
  9540. foundSourceAndTech = findFirstPassingTechSourcePair(techs, sources, finder);
  9541. }
  9542. return foundSourceAndTech || false;
  9543. };
  9544. /**
  9545. * The source function updates the video source
  9546. * There are three types of variables you can pass as the argument.
  9547. * **URL String**: A URL to the the video file. Use this method if you are sure
  9548. * the current playback technology (HTML5/Flash) can support the source you
  9549. * provide. Currently only MP4 files can be used in both HTML5 and Flash.
  9550. * ```js
  9551. * myPlayer.src("http://www.example.com/path/to/video.mp4");
  9552. * ```
  9553. * **Source Object (or element):* * A javascript object containing information
  9554. * about the source file. Use this method if you want the player to determine if
  9555. * it can support the file using the type information.
  9556. * ```js
  9557. * myPlayer.src({ type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" });
  9558. * ```
  9559. * **Array of Source Objects:* * To provide multiple versions of the source so
  9560. * that it can be played using HTML5 across browsers you can use an array of
  9561. * source objects. Video.js will detect which version is supported and load that
  9562. * file.
  9563. * ```js
  9564. * myPlayer.src([
  9565. * { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" },
  9566. * { type: "video/webm", src: "http://www.example.com/path/to/video.webm" },
  9567. * { type: "video/ogg", src: "http://www.example.com/path/to/video.ogv" }
  9568. * ]);
  9569. * ```
  9570. *
  9571. * @param {String|Object|Array=} source The source URL, object, or array of sources
  9572. * @return {String} The current video source when getting
  9573. * @return {String} The player when setting
  9574. * @method src
  9575. */
  9576. Player.prototype.src = function src(source) {
  9577. if (source === undefined) {
  9578. return this.techGet_('src');
  9579. }
  9580. var currentTech = _techTechJs2['default'].getTech(this.techName_);
  9581. // Support old behavior of techs being registered as components.
  9582. // Remove once that deprecated behavior is removed.
  9583. if (!currentTech) {
  9584. currentTech = _componentJs2['default'].getComponent(this.techName_);
  9585. }
  9586. // case: Array of source objects to choose from and pick the best to play
  9587. if (Array.isArray(source)) {
  9588. this.sourceList_(source);
  9589. // case: URL String (http://myvideo...)
  9590. } else if (typeof source === 'string') {
  9591. // create a source object from the string
  9592. this.src({ src: source });
  9593. // case: Source object { src: '', type: '' ... }
  9594. } else if (source instanceof Object) {
  9595. // check if the source has a type and the loaded tech cannot play the source
  9596. // if there's no type we'll just try the current tech
  9597. if (source.type && !currentTech.canPlaySource(source)) {
  9598. // create a source list with the current source and send through
  9599. // the tech loop to check for a compatible technology
  9600. this.sourceList_([source]);
  9601. } else {
  9602. this.cache_.src = source.src;
  9603. this.currentType_ = source.type || '';
  9604. // wait until the tech is ready to set the source
  9605. this.ready(function () {
  9606. // The setSource tech method was added with source handlers
  9607. // so older techs won't support it
  9608. // We need to check the direct prototype for the case where subclasses
  9609. // of the tech do not support source handlers
  9610. if (currentTech.prototype.hasOwnProperty('setSource')) {
  9611. this.techCall_('setSource', source);
  9612. } else {
  9613. this.techCall_('src', source.src);
  9614. }
  9615. if (this.options_.preload === 'auto') {
  9616. this.load();
  9617. }
  9618. if (this.options_.autoplay) {
  9619. this.play();
  9620. }
  9621. // Set the source synchronously if possible (#2326)
  9622. }, true);
  9623. }
  9624. }
  9625. return this;
  9626. };
  9627. /**
  9628. * Handle an array of source objects
  9629. *
  9630. * @param {Array} sources Array of source objects
  9631. * @private
  9632. * @method sourceList_
  9633. */
  9634. Player.prototype.sourceList_ = function sourceList_(sources) {
  9635. var sourceTech = this.selectSource(sources);
  9636. if (sourceTech) {
  9637. if (sourceTech.tech === this.techName_) {
  9638. // if this technology is already loaded, set the source
  9639. this.src(sourceTech.source);
  9640. } else {
  9641. // load this technology with the chosen source
  9642. this.loadTech_(sourceTech.tech, sourceTech.source);
  9643. }
  9644. } else {
  9645. // We need to wrap this in a timeout to give folks a chance to add error event handlers
  9646. this.setTimeout(function () {
  9647. this.error({ code: 4, message: this.localize(this.options_.notSupportedMessage) });
  9648. }, 0);
  9649. // we could not find an appropriate tech, but let's still notify the delegate that this is it
  9650. // this needs a better comment about why this is needed
  9651. this.triggerReady();
  9652. }
  9653. };
  9654. /**
  9655. * Begin loading the src data.
  9656. *
  9657. * @return {Player} Returns the player
  9658. * @method load
  9659. */
  9660. Player.prototype.load = function load() {
  9661. this.techCall_('load');
  9662. return this;
  9663. };
  9664. /**
  9665. * Reset the player. Loads the first tech in the techOrder,
  9666. * and calls `reset` on the tech`.
  9667. *
  9668. * @return {Player} Returns the player
  9669. * @method reset
  9670. */
  9671. Player.prototype.reset = function reset() {
  9672. this.loadTech_(_utilsToTitleCaseJs2['default'](this.options_.techOrder[0]), null);
  9673. this.techCall_('reset');
  9674. return this;
  9675. };
  9676. /**
  9677. * Returns the fully qualified URL of the current source value e.g. http://mysite.com/video.mp4
  9678. * Can be used in conjuction with `currentType` to assist in rebuilding the current source object.
  9679. *
  9680. * @return {String} The current source
  9681. * @method currentSrc
  9682. */
  9683. Player.prototype.currentSrc = function currentSrc() {
  9684. return this.techGet_('currentSrc') || this.cache_.src || '';
  9685. };
  9686. /**
  9687. * Get the current source type e.g. video/mp4
  9688. * This can allow you rebuild the current source object so that you could load the same
  9689. * source and tech later
  9690. *
  9691. * @return {String} The source MIME type
  9692. * @method currentType
  9693. */
  9694. Player.prototype.currentType = function currentType() {
  9695. return this.currentType_ || '';
  9696. };
  9697. /**
  9698. * Get or set the preload attribute
  9699. *
  9700. * @param {Boolean} value Boolean to determine if preload should be used
  9701. * @return {String} The preload attribute value when getting
  9702. * @return {Player} Returns the player when setting
  9703. * @method preload
  9704. */
  9705. Player.prototype.preload = function preload(value) {
  9706. if (value !== undefined) {
  9707. this.techCall_('setPreload', value);
  9708. this.options_.preload = value;
  9709. return this;
  9710. }
  9711. return this.techGet_('preload');
  9712. };
  9713. /**
  9714. * Get or set the autoplay attribute.
  9715. *
  9716. * @param {Boolean} value Boolean to determine if video should autoplay
  9717. * @return {String} The autoplay attribute value when getting
  9718. * @return {Player} Returns the player when setting
  9719. * @method autoplay
  9720. */
  9721. Player.prototype.autoplay = function autoplay(value) {
  9722. if (value !== undefined) {
  9723. this.techCall_('setAutoplay', value);
  9724. this.options_.autoplay = value;
  9725. return this;
  9726. }
  9727. return this.techGet_('autoplay', value);
  9728. };
  9729. /**
  9730. * Get or set the loop attribute on the video element.
  9731. *
  9732. * @param {Boolean} value Boolean to determine if video should loop
  9733. * @return {String} The loop attribute value when getting
  9734. * @return {Player} Returns the player when setting
  9735. * @method loop
  9736. */
  9737. Player.prototype.loop = function loop(value) {
  9738. if (value !== undefined) {
  9739. this.techCall_('setLoop', value);
  9740. this.options_['loop'] = value;
  9741. return this;
  9742. }
  9743. return this.techGet_('loop');
  9744. };
  9745. /**
  9746. * Get or set the poster image source url
  9747. *
  9748. * ##### EXAMPLE:
  9749. * ```js
  9750. * // get
  9751. * var currentPoster = myPlayer.poster();
  9752. * // set
  9753. * myPlayer.poster('http://example.com/myImage.jpg');
  9754. * ```
  9755. *
  9756. * @param {String=} src Poster image source URL
  9757. * @return {String} poster URL when getting
  9758. * @return {Player} self when setting
  9759. * @method poster
  9760. */
  9761. Player.prototype.poster = function poster(src) {
  9762. if (src === undefined) {
  9763. return this.poster_;
  9764. }
  9765. // The correct way to remove a poster is to set as an empty string
  9766. // other falsey values will throw errors
  9767. if (!src) {
  9768. src = '';
  9769. }
  9770. // update the internal poster variable
  9771. this.poster_ = src;
  9772. // update the tech's poster
  9773. this.techCall_('setPoster', src);
  9774. // alert components that the poster has been set
  9775. this.trigger('posterchange');
  9776. return this;
  9777. };
  9778. /**
  9779. * Some techs (e.g. YouTube) can provide a poster source in an
  9780. * asynchronous way. We want the poster component to use this
  9781. * poster source so that it covers up the tech's controls.
  9782. * (YouTube's play button). However we only want to use this
  9783. * soruce if the player user hasn't set a poster through
  9784. * the normal APIs.
  9785. *
  9786. * @private
  9787. * @method handleTechPosterChange_
  9788. */
  9789. Player.prototype.handleTechPosterChange_ = function handleTechPosterChange_() {
  9790. if (!this.poster_ && this.tech_ && this.tech_.poster) {
  9791. this.poster_ = this.tech_.poster() || '';
  9792. // Let components know the poster has changed
  9793. this.trigger('posterchange');
  9794. }
  9795. };
  9796. /**
  9797. * Get or set whether or not the controls are showing.
  9798. *
  9799. * @param {Boolean} bool Set controls to showing or not
  9800. * @return {Boolean} Controls are showing
  9801. * @method controls
  9802. */
  9803. Player.prototype.controls = function controls(bool) {
  9804. if (bool !== undefined) {
  9805. bool = !!bool; // force boolean
  9806. // Don't trigger a change event unless it actually changed
  9807. if (this.controls_ !== bool) {
  9808. this.controls_ = bool;
  9809. if (this.usingNativeControls()) {
  9810. this.techCall_('setControls', bool);
  9811. }
  9812. if (bool) {
  9813. this.removeClass('vjs-controls-disabled');
  9814. this.addClass('vjs-controls-enabled');
  9815. this.trigger('controlsenabled');
  9816. if (!this.usingNativeControls()) {
  9817. this.addTechControlsListeners_();
  9818. }
  9819. } else {
  9820. this.removeClass('vjs-controls-enabled');
  9821. this.addClass('vjs-controls-disabled');
  9822. this.trigger('controlsdisabled');
  9823. if (!this.usingNativeControls()) {
  9824. this.removeTechControlsListeners_();
  9825. }
  9826. }
  9827. }
  9828. return this;
  9829. }
  9830. return !!this.controls_;
  9831. };
  9832. /**
  9833. * Toggle native controls on/off. Native controls are the controls built into
  9834. * devices (e.g. default iPhone controls), Flash, or other techs
  9835. * (e.g. Vimeo Controls)
  9836. * **This should only be set by the current tech, because only the tech knows
  9837. * if it can support native controls**
  9838. *
  9839. * @param {Boolean} bool True signals that native controls are on
  9840. * @return {Player} Returns the player
  9841. * @private
  9842. * @method usingNativeControls
  9843. */
  9844. Player.prototype.usingNativeControls = function usingNativeControls(bool) {
  9845. if (bool !== undefined) {
  9846. bool = !!bool; // force boolean
  9847. // Don't trigger a change event unless it actually changed
  9848. if (this.usingNativeControls_ !== bool) {
  9849. this.usingNativeControls_ = bool;
  9850. if (bool) {
  9851. this.addClass('vjs-using-native-controls');
  9852. /**
  9853. * player is using the native device controls
  9854. *
  9855. * @event usingnativecontrols
  9856. * @memberof Player
  9857. * @instance
  9858. * @private
  9859. */
  9860. this.trigger('usingnativecontrols');
  9861. } else {
  9862. this.removeClass('vjs-using-native-controls');
  9863. /**
  9864. * player is using the custom HTML controls
  9865. *
  9866. * @event usingcustomcontrols
  9867. * @memberof Player
  9868. * @instance
  9869. * @private
  9870. */
  9871. this.trigger('usingcustomcontrols');
  9872. }
  9873. }
  9874. return this;
  9875. }
  9876. return !!this.usingNativeControls_;
  9877. };
  9878. /**
  9879. * Set or get the current MediaError
  9880. *
  9881. * @param {*} err A MediaError or a String/Number to be turned into a MediaError
  9882. * @return {MediaError|null} when getting
  9883. * @return {Player} when setting
  9884. * @method error
  9885. */
  9886. Player.prototype.error = function error(err) {
  9887. if (err === undefined) {
  9888. return this.error_ || null;
  9889. }
  9890. // restoring to default
  9891. if (err === null) {
  9892. this.error_ = err;
  9893. this.removeClass('vjs-error');
  9894. this.errorDisplay.close();
  9895. return this;
  9896. }
  9897. // error instance
  9898. if (err instanceof _mediaErrorJs2['default']) {
  9899. this.error_ = err;
  9900. } else {
  9901. this.error_ = new _mediaErrorJs2['default'](err);
  9902. }
  9903. // add the vjs-error classname to the player
  9904. this.addClass('vjs-error');
  9905. // log the name of the error type and any message
  9906. // ie8 just logs "[object object]" if you just log the error object
  9907. _utilsLogJs2['default'].error('(CODE:' + this.error_.code + ' ' + _mediaErrorJs2['default'].errorTypes[this.error_.code] + ')', this.error_.message, this.error_);
  9908. // fire an error event on the player
  9909. this.trigger('error');
  9910. return this;
  9911. };
  9912. /**
  9913. * Returns whether or not the player is in the "ended" state.
  9914. *
  9915. * @return {Boolean} True if the player is in the ended state, false if not.
  9916. * @method ended
  9917. */
  9918. Player.prototype.ended = function ended() {
  9919. return this.techGet_('ended');
  9920. };
  9921. /**
  9922. * Returns whether or not the player is in the "seeking" state.
  9923. *
  9924. * @return {Boolean} True if the player is in the seeking state, false if not.
  9925. * @method seeking
  9926. */
  9927. Player.prototype.seeking = function seeking() {
  9928. return this.techGet_('seeking');
  9929. };
  9930. /**
  9931. * Returns the TimeRanges of the media that are currently available
  9932. * for seeking to.
  9933. *
  9934. * @return {TimeRanges} the seekable intervals of the media timeline
  9935. * @method seekable
  9936. */
  9937. Player.prototype.seekable = function seekable() {
  9938. return this.techGet_('seekable');
  9939. };
  9940. /**
  9941. * Report user activity
  9942. *
  9943. * @param {Object} event Event object
  9944. * @method reportUserActivity
  9945. */
  9946. Player.prototype.reportUserActivity = function reportUserActivity(event) {
  9947. this.userActivity_ = true;
  9948. };
  9949. /**
  9950. * Get/set if user is active
  9951. *
  9952. * @param {Boolean} bool Value when setting
  9953. * @return {Boolean} Value if user is active user when getting
  9954. * @method userActive
  9955. */
  9956. Player.prototype.userActive = function userActive(bool) {
  9957. if (bool !== undefined) {
  9958. bool = !!bool;
  9959. if (bool !== this.userActive_) {
  9960. this.userActive_ = bool;
  9961. if (bool) {
  9962. // If the user was inactive and is now active we want to reset the
  9963. // inactivity timer
  9964. this.userActivity_ = true;
  9965. this.removeClass('vjs-user-inactive');
  9966. this.addClass('vjs-user-active');
  9967. this.trigger('useractive');
  9968. } else {
  9969. // We're switching the state to inactive manually, so erase any other
  9970. // activity
  9971. this.userActivity_ = false;
  9972. // Chrome/Safari/IE have bugs where when you change the cursor it can
  9973. // trigger a mousemove event. This causes an issue when you're hiding
  9974. // the cursor when the user is inactive, and a mousemove signals user
  9975. // activity. Making it impossible to go into inactive mode. Specifically
  9976. // this happens in fullscreen when we really need to hide the cursor.
  9977. //
  9978. // When this gets resolved in ALL browsers it can be removed
  9979. // https://code.google.com/p/chromium/issues/detail?id=103041
  9980. if (this.tech_) {
  9981. this.tech_.one('mousemove', function (e) {
  9982. e.stopPropagation();
  9983. e.preventDefault();
  9984. });
  9985. }
  9986. this.removeClass('vjs-user-active');
  9987. this.addClass('vjs-user-inactive');
  9988. this.trigger('userinactive');
  9989. }
  9990. }
  9991. return this;
  9992. }
  9993. return this.userActive_;
  9994. };
  9995. /**
  9996. * Listen for user activity based on timeout value
  9997. *
  9998. * @private
  9999. * @method listenForUserActivity_
  10000. */
  10001. Player.prototype.listenForUserActivity_ = function listenForUserActivity_() {
  10002. var mouseInProgress = undefined,
  10003. lastMoveX = undefined,
  10004. lastMoveY = undefined;
  10005. var handleActivity = Fn.bind(this, this.reportUserActivity);
  10006. var handleMouseMove = function handleMouseMove(e) {
  10007. // #1068 - Prevent mousemove spamming
  10008. // Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
  10009. if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) {
  10010. lastMoveX = e.screenX;
  10011. lastMoveY = e.screenY;
  10012. handleActivity();
  10013. }
  10014. };
  10015. var handleMouseDown = function handleMouseDown() {
  10016. handleActivity();
  10017. // For as long as the they are touching the device or have their mouse down,
  10018. // we consider them active even if they're not moving their finger or mouse.
  10019. // So we want to continue to update that they are active
  10020. this.clearInterval(mouseInProgress);
  10021. // Setting userActivity=true now and setting the interval to the same time
  10022. // as the activityCheck interval (250) should ensure we never miss the
  10023. // next activityCheck
  10024. mouseInProgress = this.setInterval(handleActivity, 250);
  10025. };
  10026. var handleMouseUp = function handleMouseUp(event) {
  10027. handleActivity();
  10028. // Stop the interval that maintains activity if the mouse/touch is down
  10029. this.clearInterval(mouseInProgress);
  10030. };
  10031. // Any mouse movement will be considered user activity
  10032. this.on('mousedown', handleMouseDown);
  10033. this.on('mousemove', handleMouseMove);
  10034. this.on('mouseup', handleMouseUp);
  10035. // Listen for keyboard navigation
  10036. // Shouldn't need to use inProgress interval because of key repeat
  10037. this.on('keydown', handleActivity);
  10038. this.on('keyup', handleActivity);
  10039. // Run an interval every 250 milliseconds instead of stuffing everything into
  10040. // the mousemove/touchmove function itself, to prevent performance degradation.
  10041. // `this.reportUserActivity` simply sets this.userActivity_ to true, which
  10042. // then gets picked up by this loop
  10043. // http://ejohn.org/blog/learning-from-twitter/
  10044. var inactivityTimeout = undefined;
  10045. var activityCheck = this.setInterval(function () {
  10046. // Check to see if mouse/touch activity has happened
  10047. if (this.userActivity_) {
  10048. // Reset the activity tracker
  10049. this.userActivity_ = false;
  10050. // If the user state was inactive, set the state to active
  10051. this.userActive(true);
  10052. // Clear any existing inactivity timeout to start the timer over
  10053. this.clearTimeout(inactivityTimeout);
  10054. var timeout = this.options_['inactivityTimeout'];
  10055. if (timeout > 0) {
  10056. // In <timeout> milliseconds, if no more activity has occurred the
  10057. // user will be considered inactive
  10058. inactivityTimeout = this.setTimeout(function () {
  10059. // Protect against the case where the inactivityTimeout can trigger just
  10060. // before the next user activity is picked up by the activityCheck loop
  10061. // causing a flicker
  10062. if (!this.userActivity_) {
  10063. this.userActive(false);
  10064. }
  10065. }, timeout);
  10066. }
  10067. }
  10068. }, 250);
  10069. };
  10070. /**
  10071. * Gets or sets the current playback rate. A playback rate of
  10072. * 1.0 represents normal speed and 0.5 would indicate half-speed
  10073. * playback, for instance.
  10074. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-playbackrate
  10075. *
  10076. * @param {Number} rate New playback rate to set.
  10077. * @return {Number} Returns the new playback rate when setting
  10078. * @return {Number} Returns the current playback rate when getting
  10079. * @method playbackRate
  10080. */
  10081. Player.prototype.playbackRate = function playbackRate(rate) {
  10082. if (rate !== undefined) {
  10083. this.techCall_('setPlaybackRate', rate);
  10084. return this;
  10085. }
  10086. if (this.tech_ && this.tech_['featuresPlaybackRate']) {
  10087. return this.techGet_('playbackRate');
  10088. } else {
  10089. return 1.0;
  10090. }
  10091. };
  10092. /**
  10093. * Gets or sets the audio flag
  10094. *
  10095. * @param {Boolean} bool True signals that this is an audio player.
  10096. * @return {Boolean} Returns true if player is audio, false if not when getting
  10097. * @return {Player} Returns the player if setting
  10098. * @private
  10099. * @method isAudio
  10100. */
  10101. Player.prototype.isAudio = function isAudio(bool) {
  10102. if (bool !== undefined) {
  10103. this.isAudio_ = !!bool;
  10104. return this;
  10105. }
  10106. return !!this.isAudio_;
  10107. };
  10108. /**
  10109. * Returns the current state of network activity for the element, from
  10110. * the codes in the list below.
  10111. * - NETWORK_EMPTY (numeric value 0)
  10112. * The element has not yet been initialised. All attributes are in
  10113. * their initial states.
  10114. * - NETWORK_IDLE (numeric value 1)
  10115. * The element's resource selection algorithm is active and has
  10116. * selected a resource, but it is not actually using the network at
  10117. * this time.
  10118. * - NETWORK_LOADING (numeric value 2)
  10119. * The user agent is actively trying to download data.
  10120. * - NETWORK_NO_SOURCE (numeric value 3)
  10121. * The element's resource selection algorithm is active, but it has
  10122. * not yet found a resource to use.
  10123. *
  10124. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#network-states
  10125. * @return {Number} the current network activity state
  10126. * @method networkState
  10127. */
  10128. Player.prototype.networkState = function networkState() {
  10129. return this.techGet_('networkState');
  10130. };
  10131. /**
  10132. * Returns a value that expresses the current state of the element
  10133. * with respect to rendering the current playback position, from the
  10134. * codes in the list below.
  10135. * - HAVE_NOTHING (numeric value 0)
  10136. * No information regarding the media resource is available.
  10137. * - HAVE_METADATA (numeric value 1)
  10138. * Enough of the resource has been obtained that the duration of the
  10139. * resource is available.
  10140. * - HAVE_CURRENT_DATA (numeric value 2)
  10141. * Data for the immediate current playback position is available.
  10142. * - HAVE_FUTURE_DATA (numeric value 3)
  10143. * Data for the immediate current playback position is available, as
  10144. * well as enough data for the user agent to advance the current
  10145. * playback position in the direction of playback.
  10146. * - HAVE_ENOUGH_DATA (numeric value 4)
  10147. * The user agent estimates that enough data is available for
  10148. * playback to proceed uninterrupted.
  10149. *
  10150. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-readystate
  10151. * @return {Number} the current playback rendering state
  10152. * @method readyState
  10153. */
  10154. Player.prototype.readyState = function readyState() {
  10155. return this.techGet_('readyState');
  10156. };
  10157. /**
  10158. * Get a video track list
  10159. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist
  10160. *
  10161. * @return {VideoTrackList} thes current video track list
  10162. * @method videoTracks
  10163. */
  10164. Player.prototype.videoTracks = function videoTracks() {
  10165. // if we have not yet loadTech_, we create videoTracks_
  10166. // these will be passed to the tech during loading
  10167. if (!this.tech_) {
  10168. this.videoTracks_ = this.videoTracks_ || new _tracksVideoTrackListJs2['default']();
  10169. return this.videoTracks_;
  10170. }
  10171. return this.tech_.videoTracks();
  10172. };
  10173. /**
  10174. * Get an audio track list
  10175. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist
  10176. *
  10177. * @return {AudioTrackList} thes current audio track list
  10178. * @method audioTracks
  10179. */
  10180. Player.prototype.audioTracks = function audioTracks() {
  10181. // if we have not yet loadTech_, we create videoTracks_
  10182. // these will be passed to the tech during loading
  10183. if (!this.tech_) {
  10184. this.audioTracks_ = this.audioTracks_ || new _tracksAudioTrackListJs2['default']();
  10185. return this.audioTracks_;
  10186. }
  10187. return this.tech_.audioTracks();
  10188. };
  10189. /*
  10190. * Text tracks are tracks of timed text events.
  10191. * Captions - text displayed over the video for the hearing impaired
  10192. * Subtitles - text displayed over the video for those who don't understand language in the video
  10193. * Chapters - text displayed in a menu allowing the user to jump to particular points (chapters) in the video
  10194. * Descriptions (not supported yet) - audio descriptions that are read back to the user by a screen reading device
  10195. */
  10196. /**
  10197. * Get an array of associated text tracks. captions, subtitles, chapters, descriptions
  10198. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-texttracks
  10199. *
  10200. * @return {Array} Array of track objects
  10201. * @method textTracks
  10202. */
  10203. Player.prototype.textTracks = function textTracks() {
  10204. // cannot use techGet_ directly because it checks to see whether the tech is ready.
  10205. // Flash is unlikely to be ready in time but textTracks should still work.
  10206. return this.tech_ && this.tech_['textTracks']();
  10207. };
  10208. /**
  10209. * Get an array of remote text tracks
  10210. *
  10211. * @return {Array}
  10212. * @method remoteTextTracks
  10213. */
  10214. Player.prototype.remoteTextTracks = function remoteTextTracks() {
  10215. return this.tech_ && this.tech_['remoteTextTracks']();
  10216. };
  10217. /**
  10218. * Get an array of remote html track elements
  10219. *
  10220. * @return {HTMLTrackElement[]}
  10221. * @method remoteTextTrackEls
  10222. */
  10223. Player.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  10224. return this.tech_ && this.tech_['remoteTextTrackEls']();
  10225. };
  10226. /**
  10227. * Add a text track
  10228. * In addition to the W3C settings we allow adding additional info through options.
  10229. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-addtexttrack
  10230. *
  10231. * @param {String} kind Captions, subtitles, chapters, descriptions, or metadata
  10232. * @param {String=} label Optional label
  10233. * @param {String=} language Optional language
  10234. * @method addTextTrack
  10235. */
  10236. Player.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  10237. return this.tech_ && this.tech_['addTextTrack'](kind, label, language);
  10238. };
  10239. /**
  10240. * Add a remote text track
  10241. *
  10242. * @param {Object} options Options for remote text track
  10243. * @method addRemoteTextTrack
  10244. */
  10245. Player.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  10246. return this.tech_ && this.tech_['addRemoteTextTrack'](options);
  10247. };
  10248. /**
  10249. * Remove a remote text track
  10250. *
  10251. * @param {Object} track Remote text track to remove
  10252. * @method removeRemoteTextTrack
  10253. */
  10254. // destructure the input into an object with a track argument, defaulting to arguments[0]
  10255. // default the whole argument to an empty object if nothing was passed in
  10256. Player.prototype.removeRemoteTextTrack = function removeRemoteTextTrack() {
  10257. var _ref3 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  10258. var _ref3$track = _ref3.track;
  10259. var track = _ref3$track === undefined ? arguments[0] : _ref3$track;
  10260. // jshint ignore:line
  10261. this.tech_ && this.tech_['removeRemoteTextTrack'](track);
  10262. };
  10263. /**
  10264. * Get video width
  10265. *
  10266. * @return {Number} Video width
  10267. * @method videoWidth
  10268. */
  10269. Player.prototype.videoWidth = function videoWidth() {
  10270. return this.tech_ && this.tech_.videoWidth && this.tech_.videoWidth() || 0;
  10271. };
  10272. /**
  10273. * Get video height
  10274. *
  10275. * @return {Number} Video height
  10276. * @method videoHeight
  10277. */
  10278. Player.prototype.videoHeight = function videoHeight() {
  10279. return this.tech_ && this.tech_.videoHeight && this.tech_.videoHeight() || 0;
  10280. };
  10281. // Methods to add support for
  10282. // initialTime: function(){ return this.techCall_('initialTime'); },
  10283. // startOffsetTime: function(){ return this.techCall_('startOffsetTime'); },
  10284. // played: function(){ return this.techCall_('played'); },
  10285. // defaultPlaybackRate: function(){ return this.techCall_('defaultPlaybackRate'); },
  10286. // defaultMuted: function(){ return this.techCall_('defaultMuted'); }
  10287. /**
  10288. * The player's language code
  10289. * NOTE: The language should be set in the player options if you want the
  10290. * the controls to be built with a specific language. Changing the lanugage
  10291. * later will not update controls text.
  10292. *
  10293. * @param {String} code The locale string
  10294. * @return {String} The locale string when getting
  10295. * @return {Player} self when setting
  10296. * @method language
  10297. */
  10298. Player.prototype.language = function language(code) {
  10299. if (code === undefined) {
  10300. return this.language_;
  10301. }
  10302. this.language_ = ('' + code).toLowerCase();
  10303. return this;
  10304. };
  10305. /**
  10306. * Get the player's language dictionary
  10307. * Merge every time, because a newly added plugin might call videojs.addLanguage() at any time
  10308. * Languages specified directly in the player options have precedence
  10309. *
  10310. * @return {Array} Array of languages
  10311. * @method languages
  10312. */
  10313. Player.prototype.languages = function languages() {
  10314. return _utilsMergeOptionsJs2['default'](Player.prototype.options_.languages, this.languages_);
  10315. };
  10316. /**
  10317. * Converts track info to JSON
  10318. *
  10319. * @return {Object} JSON object of options
  10320. * @method toJSON
  10321. */
  10322. Player.prototype.toJSON = function toJSON() {
  10323. var options = _utilsMergeOptionsJs2['default'](this.options_);
  10324. var tracks = options.tracks;
  10325. options.tracks = [];
  10326. for (var i = 0; i < tracks.length; i++) {
  10327. var track = tracks[i];
  10328. // deep merge tracks and null out player so no circular references
  10329. track = _utilsMergeOptionsJs2['default'](track);
  10330. track.player = undefined;
  10331. options.tracks[i] = track;
  10332. }
  10333. return options;
  10334. };
  10335. /**
  10336. * Creates a simple modal dialog (an instance of the `ModalDialog`
  10337. * component) that immediately overlays the player with arbitrary
  10338. * content and removes itself when closed.
  10339. *
  10340. * @param {String|Function|Element|Array|Null} content
  10341. * Same as `ModalDialog#content`'s param of the same name.
  10342. *
  10343. * The most straight-forward usage is to provide a string or DOM
  10344. * element.
  10345. *
  10346. * @param {Object} [options]
  10347. * Extra options which will be passed on to the `ModalDialog`.
  10348. *
  10349. * @return {ModalDialog}
  10350. */
  10351. Player.prototype.createModal = function createModal(content, options) {
  10352. var player = this;
  10353. options = options || {};
  10354. options.content = content || '';
  10355. var modal = new _modalDialog2['default'](player, options);
  10356. player.addChild(modal);
  10357. modal.on('dispose', function () {
  10358. player.removeChild(modal);
  10359. });
  10360. return modal.open();
  10361. };
  10362. /**
  10363. * Gets tag settings
  10364. *
  10365. * @param {Element} tag The player tag
  10366. * @return {Array} An array of sources and track objects
  10367. * @static
  10368. * @method getTagSettings
  10369. */
  10370. Player.getTagSettings = function getTagSettings(tag) {
  10371. var baseOptions = {
  10372. 'sources': [],
  10373. 'tracks': []
  10374. };
  10375. var tagOptions = Dom.getElAttributes(tag);
  10376. var dataSetup = tagOptions['data-setup'];
  10377. // Check if data-setup attr exists.
  10378. if (dataSetup !== null) {
  10379. // Parse options JSON
  10380. var _safeParseTuple = _safeJsonParseTuple2['default'](dataSetup || '{}');
  10381. var err = _safeParseTuple[0];
  10382. var data = _safeParseTuple[1];
  10383. if (err) {
  10384. _utilsLogJs2['default'].error(err);
  10385. }
  10386. _objectAssign2['default'](tagOptions, data);
  10387. }
  10388. _objectAssign2['default'](baseOptions, tagOptions);
  10389. // Get tag children settings
  10390. if (tag.hasChildNodes()) {
  10391. var children = tag.childNodes;
  10392. for (var i = 0, j = children.length; i < j; i++) {
  10393. var child = children[i];
  10394. // Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
  10395. var childName = child.nodeName.toLowerCase();
  10396. if (childName === 'source') {
  10397. baseOptions.sources.push(Dom.getElAttributes(child));
  10398. } else if (childName === 'track') {
  10399. baseOptions.tracks.push(Dom.getElAttributes(child));
  10400. }
  10401. }
  10402. }
  10403. return baseOptions;
  10404. };
  10405. return Player;
  10406. })(_componentJs2['default']);
  10407. Player.players = {};
  10408. var navigator = _globalWindow2['default'].navigator;
  10409. /*
  10410. * Player instance options, surfaced using options
  10411. * options = Player.prototype.options_
  10412. * Make changes in options, not here.
  10413. *
  10414. * @type {Object}
  10415. * @private
  10416. */
  10417. Player.prototype.options_ = {
  10418. // Default order of fallback technology
  10419. techOrder: ['html5', 'flash'],
  10420. // techOrder: ['flash','html5'],
  10421. html5: {},
  10422. flash: {},
  10423. // defaultVolume: 0.85,
  10424. defaultVolume: 0.00, // The freakin seaguls are driving me crazy!
  10425. // default inactivity timeout
  10426. inactivityTimeout: 2000,
  10427. // default playback rates
  10428. playbackRates: [],
  10429. // Add playback rate selection by adding rates
  10430. // 'playbackRates': [0.5, 1, 1.5, 2],
  10431. // Included control sets
  10432. children: ['mediaLoader', 'posterImage', 'textTrackDisplay', 'loadingSpinner', 'bigPlayButton', 'controlBar', 'errorDisplay', 'textTrackSettings'],
  10433. language: _globalDocument2['default'].getElementsByTagName('html')[0].getAttribute('lang') || navigator.languages && navigator.languages[0] || navigator.userLanguage || navigator.language || 'en',
  10434. // locales and their language translations
  10435. languages: {},
  10436. // Default message to show when a video cannot be played.
  10437. notSupportedMessage: 'No compatible source was found for this media.'
  10438. };
  10439. /**
  10440. * Fired when the player has initial duration and dimension information
  10441. *
  10442. * @event loadedmetadata
  10443. */
  10444. Player.prototype.handleLoadedMetaData_;
  10445. /**
  10446. * Fired when the player has downloaded data at the current playback position
  10447. *
  10448. * @event loadeddata
  10449. */
  10450. Player.prototype.handleLoadedData_;
  10451. /**
  10452. * Fired when the user is active, e.g. moves the mouse over the player
  10453. *
  10454. * @event useractive
  10455. */
  10456. Player.prototype.handleUserActive_;
  10457. /**
  10458. * Fired when the user is inactive, e.g. a short delay after the last mouse move or control interaction
  10459. *
  10460. * @event userinactive
  10461. */
  10462. Player.prototype.handleUserInactive_;
  10463. /**
  10464. * Fired when the current playback position has changed *
  10465. * During playback this is fired every 15-250 milliseconds, depending on the
  10466. * playback technology in use.
  10467. *
  10468. * @event timeupdate
  10469. */
  10470. Player.prototype.handleTimeUpdate_;
  10471. /**
  10472. * Fired when video playback ends
  10473. *
  10474. * @event ended
  10475. */
  10476. Player.prototype.handleTechEnded_;
  10477. /**
  10478. * Fired when the volume changes
  10479. *
  10480. * @event volumechange
  10481. */
  10482. Player.prototype.handleVolumeChange_;
  10483. /**
  10484. * Fired when an error occurs
  10485. *
  10486. * @event error
  10487. */
  10488. Player.prototype.handleError_;
  10489. Player.prototype.flexNotSupported_ = function () {
  10490. var elem = _globalDocument2['default'].createElement('i');
  10491. // Note: We don't actually use flexBasis (or flexOrder), but it's one of the more
  10492. // common flex features that we can rely on when checking for flex support.
  10493. return !('flexBasis' in elem.style || 'webkitFlexBasis' in elem.style || 'mozFlexBasis' in elem.style || 'msFlexBasis' in elem.style || 'msFlexOrder' in elem.style) /* IE10-specific (2012 flex spec) */;
  10494. };
  10495. _componentJs2['default'].registerComponent('Player', Player);
  10496. exports['default'] = Player;
  10497. module.exports = exports['default'];
  10498. // If empty string, make it a parsable json object.
  10499. }, { "./big-play-button.js": 63, "./component.js": 67, "./control-bar/control-bar.js": 70, "./error-display.js": 103, "./fullscreen-api.js": 106, "./loading-spinner.js": 107, "./media-error.js": 108, "./modal-dialog": 112, "./poster-image.js": 117, "./tech/html5.js": 122, "./tech/loader.js": 123, "./tech/tech.js": 124, "./tracks/audio-track-list.js": 125, "./tracks/text-track-display.js": 130, "./tracks/text-track-list-converter.js": 131, "./tracks/text-track-settings.js": 133, "./tracks/video-track-list.js": 138, "./utils/browser.js": 140, "./utils/buffer.js": 141, "./utils/dom.js": 143, "./utils/events.js": 144, "./utils/fn.js": 145, "./utils/guid.js": 147, "./utils/log.js": 148, "./utils/merge-options.js": 149, "./utils/stylesheet.js": 150, "./utils/time-ranges.js": 151, "./utils/to-title-case.js": 152, "global/document": 1, "global/window": 2, "object.assign": 45, "safe-json-parse/tuple": 54 }], 114: [function (_dereq_, module, exports) {
  10500. /**
  10501. * @file plugins.js
  10502. */
  10503. 'use strict';
  10504. exports.__esModule = true;
  10505. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10506. var _playerJs = _dereq_('./player.js');
  10507. var _playerJs2 = _interopRequireDefault(_playerJs);
  10508. /**
  10509. * The method for registering a video.js plugin
  10510. *
  10511. * @param {String} name The name of the plugin
  10512. * @param {Function} init The function that is run when the player inits
  10513. * @method plugin
  10514. */
  10515. var plugin = function plugin(name, init) {
  10516. _playerJs2['default'].prototype[name] = init;
  10517. };
  10518. exports['default'] = plugin;
  10519. module.exports = exports['default'];
  10520. }, { "./player.js": 113 }], 115: [function (_dereq_, module, exports) {
  10521. /**
  10522. * @file popup-button.js
  10523. */
  10524. 'use strict';
  10525. exports.__esModule = true;
  10526. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  10527. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10528. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10529. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10530. var _clickableComponentJs = _dereq_('../clickable-component.js');
  10531. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  10532. var _componentJs = _dereq_('../component.js');
  10533. var _componentJs2 = _interopRequireDefault(_componentJs);
  10534. var _popupJs = _dereq_('./popup.js');
  10535. var _popupJs2 = _interopRequireDefault(_popupJs);
  10536. var _utilsDomJs = _dereq_('../utils/dom.js');
  10537. var Dom = _interopRequireWildcard(_utilsDomJs);
  10538. var _utilsFnJs = _dereq_('../utils/fn.js');
  10539. var Fn = _interopRequireWildcard(_utilsFnJs);
  10540. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  10541. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  10542. /**
  10543. * A button class with a popup control
  10544. *
  10545. * @param {Player|Object} player
  10546. * @param {Object=} options
  10547. * @extends ClickableComponent
  10548. * @class PopupButton
  10549. */
  10550. var PopupButton = (function (_ClickableComponent) {
  10551. _inherits(PopupButton, _ClickableComponent);
  10552. function PopupButton(player) {
  10553. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  10554. _classCallCheck(this, PopupButton);
  10555. _ClickableComponent.call(this, player, options);
  10556. this.update();
  10557. }
  10558. /**
  10559. * Update popup
  10560. *
  10561. * @method update
  10562. */
  10563. PopupButton.prototype.update = function update() {
  10564. var popup = this.createPopup();
  10565. if (this.popup) {
  10566. this.removeChild(this.popup);
  10567. }
  10568. this.popup = popup;
  10569. this.addChild(popup);
  10570. if (this.items && this.items.length === 0) {
  10571. this.hide();
  10572. } else if (this.items && this.items.length > 1) {
  10573. this.show();
  10574. }
  10575. };
  10576. /**
  10577. * Create popup - Override with specific functionality for component
  10578. *
  10579. * @return {Popup} The constructed popup
  10580. * @method createPopup
  10581. */
  10582. PopupButton.prototype.createPopup = function createPopup() { };
  10583. /**
  10584. * Create the component's DOM element
  10585. *
  10586. * @return {Element}
  10587. * @method createEl
  10588. */
  10589. PopupButton.prototype.createEl = function createEl() {
  10590. return _ClickableComponent.prototype.createEl.call(this, 'div', {
  10591. className: this.buildCSSClass()
  10592. });
  10593. };
  10594. /**
  10595. * Allow sub components to stack CSS class names
  10596. *
  10597. * @return {String} The constructed class name
  10598. * @method buildCSSClass
  10599. */
  10600. PopupButton.prototype.buildCSSClass = function buildCSSClass() {
  10601. var menuButtonClass = 'vjs-menu-button';
  10602. // If the inline option is passed, we want to use different styles altogether.
  10603. if (this.options_.inline === true) {
  10604. menuButtonClass += '-inline';
  10605. } else {
  10606. menuButtonClass += '-popup';
  10607. }
  10608. return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this);
  10609. };
  10610. return PopupButton;
  10611. })(_clickableComponentJs2['default']);
  10612. _componentJs2['default'].registerComponent('PopupButton', PopupButton);
  10613. exports['default'] = PopupButton;
  10614. module.exports = exports['default'];
  10615. }, { "../clickable-component.js": 65, "../component.js": 67, "../utils/dom.js": 143, "../utils/fn.js": 145, "../utils/to-title-case.js": 152, "./popup.js": 116 }], 116: [function (_dereq_, module, exports) {
  10616. /**
  10617. * @file popup.js
  10618. */
  10619. 'use strict';
  10620. exports.__esModule = true;
  10621. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  10622. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10623. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10624. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10625. var _componentJs = _dereq_('../component.js');
  10626. var _componentJs2 = _interopRequireDefault(_componentJs);
  10627. var _utilsDomJs = _dereq_('../utils/dom.js');
  10628. var Dom = _interopRequireWildcard(_utilsDomJs);
  10629. var _utilsFnJs = _dereq_('../utils/fn.js');
  10630. var Fn = _interopRequireWildcard(_utilsFnJs);
  10631. var _utilsEventsJs = _dereq_('../utils/events.js');
  10632. var Events = _interopRequireWildcard(_utilsEventsJs);
  10633. /**
  10634. * The Popup component is used to build pop up controls.
  10635. *
  10636. * @extends Component
  10637. * @class Popup
  10638. */
  10639. var Popup = (function (_Component) {
  10640. _inherits(Popup, _Component);
  10641. function Popup() {
  10642. _classCallCheck(this, Popup);
  10643. _Component.apply(this, arguments);
  10644. }
  10645. /**
  10646. * Add a popup item to the popup
  10647. *
  10648. * @param {Object|String} component Component or component type to add
  10649. * @method addItem
  10650. */
  10651. Popup.prototype.addItem = function addItem(component) {
  10652. this.addChild(component);
  10653. component.on('click', Fn.bind(this, function () {
  10654. this.unlockShowing();
  10655. }));
  10656. };
  10657. /**
  10658. * Create the component's DOM element
  10659. *
  10660. * @return {Element}
  10661. * @method createEl
  10662. */
  10663. Popup.prototype.createEl = function createEl() {
  10664. var contentElType = this.options_.contentElType || 'ul';
  10665. this.contentEl_ = Dom.createEl(contentElType, {
  10666. className: 'vjs-menu-content'
  10667. });
  10668. var el = _Component.prototype.createEl.call(this, 'div', {
  10669. append: this.contentEl_,
  10670. className: 'vjs-menu'
  10671. });
  10672. el.appendChild(this.contentEl_);
  10673. // Prevent clicks from bubbling up. Needed for Popup Buttons,
  10674. // where a click on the parent is significant
  10675. Events.on(el, 'click', function (event) {
  10676. event.preventDefault();
  10677. event.stopImmediatePropagation();
  10678. });
  10679. return el;
  10680. };
  10681. return Popup;
  10682. })(_componentJs2['default']);
  10683. _componentJs2['default'].registerComponent('Popup', Popup);
  10684. exports['default'] = Popup;
  10685. module.exports = exports['default'];
  10686. }, { "../component.js": 67, "../utils/dom.js": 143, "../utils/events.js": 144, "../utils/fn.js": 145 }], 117: [function (_dereq_, module, exports) {
  10687. /**
  10688. * @file poster-image.js
  10689. */
  10690. 'use strict';
  10691. exports.__esModule = true;
  10692. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  10693. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10694. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10695. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10696. var _clickableComponentJs = _dereq_('./clickable-component.js');
  10697. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  10698. var _componentJs = _dereq_('./component.js');
  10699. var _componentJs2 = _interopRequireDefault(_componentJs);
  10700. var _utilsFnJs = _dereq_('./utils/fn.js');
  10701. var Fn = _interopRequireWildcard(_utilsFnJs);
  10702. var _utilsDomJs = _dereq_('./utils/dom.js');
  10703. var Dom = _interopRequireWildcard(_utilsDomJs);
  10704. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  10705. var browser = _interopRequireWildcard(_utilsBrowserJs);
  10706. /**
  10707. * The component that handles showing the poster image.
  10708. *
  10709. * @param {Player|Object} player
  10710. * @param {Object=} options
  10711. * @extends Button
  10712. * @class PosterImage
  10713. */
  10714. var PosterImage = (function (_ClickableComponent) {
  10715. _inherits(PosterImage, _ClickableComponent);
  10716. function PosterImage(player, options) {
  10717. _classCallCheck(this, PosterImage);
  10718. _ClickableComponent.call(this, player, options);
  10719. this.update();
  10720. player.on('posterchange', Fn.bind(this, this.update));
  10721. }
  10722. /**
  10723. * Clean up the poster image
  10724. *
  10725. * @method dispose
  10726. */
  10727. PosterImage.prototype.dispose = function dispose() {
  10728. this.player().off('posterchange', this.update);
  10729. _ClickableComponent.prototype.dispose.call(this);
  10730. };
  10731. /**
  10732. * Create the poster's image element
  10733. *
  10734. * @return {Element}
  10735. * @method createEl
  10736. */
  10737. PosterImage.prototype.createEl = function createEl() {
  10738. var el = Dom.createEl('div', {
  10739. className: 'vjs-poster',
  10740. // Don't want poster to be tabbable.
  10741. tabIndex: -1
  10742. });
  10743. // To ensure the poster image resizes while maintaining its original aspect
  10744. // ratio, use a div with `background-size` when available. For browsers that
  10745. // do not support `background-size` (e.g. IE8), fall back on using a regular
  10746. // img element.
  10747. if (!browser.BACKGROUND_SIZE_SUPPORTED) {
  10748. this.fallbackImg_ = Dom.createEl('img');
  10749. el.appendChild(this.fallbackImg_);
  10750. }
  10751. return el;
  10752. };
  10753. /**
  10754. * Event handler for updates to the player's poster source
  10755. *
  10756. * @method update
  10757. */
  10758. PosterImage.prototype.update = function update() {
  10759. var url = this.player().poster();
  10760. this.setSrc(url);
  10761. // If there's no poster source we should display:none on this component
  10762. // so it's not still clickable or right-clickable
  10763. if (url) {
  10764. this.show();
  10765. } else {
  10766. this.hide();
  10767. }
  10768. };
  10769. /**
  10770. * Set the poster source depending on the display method
  10771. *
  10772. * @param {String} url The URL to the poster source
  10773. * @method setSrc
  10774. */
  10775. PosterImage.prototype.setSrc = function setSrc(url) {
  10776. if (this.fallbackImg_) {
  10777. this.fallbackImg_.src = url;
  10778. } else {
  10779. var backgroundImage = '';
  10780. // Any falsey values should stay as an empty string, otherwise
  10781. // this will throw an extra error
  10782. if (url) {
  10783. backgroundImage = 'url("' + url + '")';
  10784. }
  10785. this.el_.style.backgroundImage = backgroundImage;
  10786. }
  10787. };
  10788. /**
  10789. * Event handler for clicks on the poster image
  10790. *
  10791. * @method handleClick
  10792. */
  10793. PosterImage.prototype.handleClick = function handleClick() {
  10794. // We don't want a click to trigger playback when controls are disabled
  10795. // but CSS should be hiding the poster to prevent that from happening
  10796. if (this.player_.paused()) {
  10797. this.player_.play();
  10798. } else {
  10799. this.player_.pause();
  10800. }
  10801. };
  10802. return PosterImage;
  10803. })(_clickableComponentJs2['default']);
  10804. _componentJs2['default'].registerComponent('PosterImage', PosterImage);
  10805. exports['default'] = PosterImage;
  10806. module.exports = exports['default'];
  10807. }, { "./clickable-component.js": 65, "./component.js": 67, "./utils/browser.js": 140, "./utils/dom.js": 143, "./utils/fn.js": 145 }], 118: [function (_dereq_, module, exports) {
  10808. /**
  10809. * @file setup.js
  10810. *
  10811. * Functions for automatically setting up a player
  10812. * based on the data-setup attribute of the video tag
  10813. */
  10814. 'use strict';
  10815. exports.__esModule = true;
  10816. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10817. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  10818. var _utilsEventsJs = _dereq_('./utils/events.js');
  10819. var Events = _interopRequireWildcard(_utilsEventsJs);
  10820. var _globalDocument = _dereq_('global/document');
  10821. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  10822. var _globalWindow = _dereq_('global/window');
  10823. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  10824. var _windowLoaded = false;
  10825. var videojs = undefined;
  10826. // Automatically set up any tags that have a data-setup attribute
  10827. var autoSetup = function autoSetup() {
  10828. // One day, when we stop supporting IE8, go back to this, but in the meantime...*hack hack hack*
  10829. // var vids = Array.prototype.slice.call(document.getElementsByTagName('video'));
  10830. // var audios = Array.prototype.slice.call(document.getElementsByTagName('audio'));
  10831. // var mediaEls = vids.concat(audios);
  10832. // Because IE8 doesn't support calling slice on a node list, we need to loop through each list of elements
  10833. // to build up a new, combined list of elements.
  10834. var vids = _globalDocument2['default'].getElementsByTagName('video');
  10835. var audios = _globalDocument2['default'].getElementsByTagName('audio');
  10836. var mediaEls = [];
  10837. if (vids && vids.length > 0) {
  10838. for (var i = 0, e = vids.length; i < e; i++) {
  10839. mediaEls.push(vids[i]);
  10840. }
  10841. }
  10842. if (audios && audios.length > 0) {
  10843. for (var i = 0, e = audios.length; i < e; i++) {
  10844. mediaEls.push(audios[i]);
  10845. }
  10846. }
  10847. // Check if any media elements exist
  10848. if (mediaEls && mediaEls.length > 0) {
  10849. for (var i = 0, e = mediaEls.length; i < e; i++) {
  10850. var mediaEl = mediaEls[i];
  10851. // Check if element exists, has getAttribute func.
  10852. // IE seems to consider typeof el.getAttribute == 'object' instead of 'function' like expected, at least when loading the player immediately.
  10853. if (mediaEl && mediaEl.getAttribute) {
  10854. // Make sure this player hasn't already been set up.
  10855. if (mediaEl['player'] === undefined) {
  10856. var options = mediaEl.getAttribute('data-setup');
  10857. // Check if data-setup attr exists.
  10858. // We only auto-setup if they've added the data-setup attr.
  10859. if (options !== null) {
  10860. // Create new video.js instance.
  10861. var player = videojs(mediaEl);
  10862. }
  10863. }
  10864. // If getAttribute isn't defined, we need to wait for the DOM.
  10865. } else {
  10866. autoSetupTimeout(1);
  10867. break;
  10868. }
  10869. }
  10870. // No videos were found, so keep looping unless page is finished loading.
  10871. } else if (!_windowLoaded) {
  10872. autoSetupTimeout(1);
  10873. }
  10874. };
  10875. // Pause to let the DOM keep processing
  10876. var autoSetupTimeout = function autoSetupTimeout(wait, vjs) {
  10877. if (vjs) {
  10878. videojs = vjs;
  10879. }
  10880. setTimeout(autoSetup, wait);
  10881. };
  10882. if (_globalDocument2['default'].readyState === 'complete') {
  10883. _windowLoaded = true;
  10884. } else {
  10885. Events.one(_globalWindow2['default'], 'load', function () {
  10886. _windowLoaded = true;
  10887. });
  10888. }
  10889. var hasLoaded = function hasLoaded() {
  10890. return _windowLoaded;
  10891. };
  10892. exports.autoSetup = autoSetup;
  10893. exports.autoSetupTimeout = autoSetupTimeout;
  10894. exports.hasLoaded = hasLoaded;
  10895. }, { "./utils/events.js": 144, "global/document": 1, "global/window": 2 }], 119: [function (_dereq_, module, exports) {
  10896. /**
  10897. * @file slider.js
  10898. */
  10899. 'use strict';
  10900. exports.__esModule = true;
  10901. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  10902. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10903. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10904. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10905. var _componentJs = _dereq_('../component.js');
  10906. var _componentJs2 = _interopRequireDefault(_componentJs);
  10907. var _utilsDomJs = _dereq_('../utils/dom.js');
  10908. var Dom = _interopRequireWildcard(_utilsDomJs);
  10909. var _objectAssign = _dereq_('object.assign');
  10910. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  10911. /**
  10912. * The base functionality for sliders like the volume bar and seek bar
  10913. *
  10914. * @param {Player|Object} player
  10915. * @param {Object=} options
  10916. * @extends Component
  10917. * @class Slider
  10918. */
  10919. var Slider = (function (_Component) {
  10920. _inherits(Slider, _Component);
  10921. function Slider(player, options) {
  10922. _classCallCheck(this, Slider);
  10923. _Component.call(this, player, options);
  10924. // Set property names to bar to match with the child Slider class is looking for
  10925. this.bar = this.getChild(this.options_.barName);
  10926. // Set a horizontal or vertical class on the slider depending on the slider type
  10927. this.vertical(!!this.options_.vertical);
  10928. this.on('mousedown', this.handleMouseDown);
  10929. this.on('touchstart', this.handleMouseDown);
  10930. this.on('focus', this.handleFocus);
  10931. this.on('blur', this.handleBlur);
  10932. this.on('click', this.handleClick);
  10933. this.on(player, 'controlsvisible', this.update);
  10934. this.on(player, this.playerEvent, this.update);
  10935. }
  10936. /**
  10937. * Create the component's DOM element
  10938. *
  10939. * @param {String} type Type of element to create
  10940. * @param {Object=} props List of properties in Object form
  10941. * @return {Element}
  10942. * @method createEl
  10943. */
  10944. Slider.prototype.createEl = function createEl(type) {
  10945. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  10946. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  10947. // Add the slider element class to all sub classes
  10948. props.className = props.className + ' vjs-slider';
  10949. props = _objectAssign2['default']({
  10950. tabIndex: 0
  10951. }, props);
  10952. attributes = _objectAssign2['default']({
  10953. 'role': 'slider',
  10954. 'aria-valuenow': 0,
  10955. 'aria-valuemin': 0,
  10956. 'aria-valuemax': 100,
  10957. tabIndex: 0
  10958. }, attributes);
  10959. return _Component.prototype.createEl.call(this, type, props, attributes);
  10960. };
  10961. /**
  10962. * Handle mouse down on slider
  10963. *
  10964. * @param {Object} event Mouse down event object
  10965. * @method handleMouseDown
  10966. */
  10967. Slider.prototype.handleMouseDown = function handleMouseDown(event) {
  10968. var doc = this.bar.el_.ownerDocument;
  10969. event.preventDefault();
  10970. Dom.blockTextSelection();
  10971. this.addClass('vjs-sliding');
  10972. this.trigger('slideractive');
  10973. this.on(doc, 'mousemove', this.handleMouseMove);
  10974. this.on(doc, 'mouseup', this.handleMouseUp);
  10975. this.on(doc, 'touchmove', this.handleMouseMove);
  10976. this.on(doc, 'touchend', this.handleMouseUp);
  10977. this.handleMouseMove(event);
  10978. };
  10979. /**
  10980. * To be overridden by a subclass
  10981. *
  10982. * @method handleMouseMove
  10983. */
  10984. Slider.prototype.handleMouseMove = function handleMouseMove() { };
  10985. /**
  10986. * Handle mouse up on Slider
  10987. *
  10988. * @method handleMouseUp
  10989. */
  10990. Slider.prototype.handleMouseUp = function handleMouseUp() {
  10991. var doc = this.bar.el_.ownerDocument;
  10992. Dom.unblockTextSelection();
  10993. this.removeClass('vjs-sliding');
  10994. this.trigger('sliderinactive');
  10995. this.off(doc, 'mousemove', this.handleMouseMove);
  10996. this.off(doc, 'mouseup', this.handleMouseUp);
  10997. this.off(doc, 'touchmove', this.handleMouseMove);
  10998. this.off(doc, 'touchend', this.handleMouseUp);
  10999. this.update();
  11000. };
  11001. /**
  11002. * Update slider
  11003. *
  11004. * @method update
  11005. */
  11006. Slider.prototype.update = function update() {
  11007. // In VolumeBar init we have a setTimeout for update that pops and update to the end of the
  11008. // execution stack. The player is destroyed before then update will cause an error
  11009. if (!this.el_) return;
  11010. // If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
  11011. // On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
  11012. // var progress = (this.player_.scrubbing()) ? this.player_.getCache().currentTime / this.player_.duration() : this.player_.currentTime() / this.player_.duration();
  11013. var progress = this.getPercent();
  11014. var bar = this.bar;
  11015. // If there's no bar...
  11016. if (!bar) return;
  11017. // Protect against no duration and other division issues
  11018. if (typeof progress !== 'number' || progress !== progress || progress < 0 || progress === Infinity) {
  11019. progress = 0;
  11020. }
  11021. // Convert to a percentage for setting
  11022. var percentage = (progress * 100).toFixed(2) + '%';
  11023. // Set the new bar width or height
  11024. if (this.vertical()) {
  11025. bar.el().style.height = percentage;
  11026. } else {
  11027. bar.el().style.width = percentage;
  11028. }
  11029. };
  11030. /**
  11031. * Calculate distance for slider
  11032. *
  11033. * @param {Object} event Event object
  11034. * @method calculateDistance
  11035. */
  11036. Slider.prototype.calculateDistance = function calculateDistance(event) {
  11037. var position = Dom.getPointerPosition(this.el_, event);
  11038. if (this.vertical()) {
  11039. return position.y;
  11040. }
  11041. return position.x;
  11042. };
  11043. /**
  11044. * Handle on focus for slider
  11045. *
  11046. * @method handleFocus
  11047. */
  11048. Slider.prototype.handleFocus = function handleFocus() {
  11049. this.on(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
  11050. };
  11051. /**
  11052. * Handle key press for slider
  11053. *
  11054. * @param {Object} event Event object
  11055. * @method handleKeyPress
  11056. */
  11057. Slider.prototype.handleKeyPress = function handleKeyPress(event) {
  11058. if (event.which === 37 || event.which === 40) {
  11059. // Left and Down Arrows
  11060. event.preventDefault();
  11061. this.stepBack();
  11062. } else if (event.which === 38 || event.which === 39) {
  11063. // Up and Right Arrows
  11064. event.preventDefault();
  11065. this.stepForward();
  11066. }
  11067. };
  11068. /**
  11069. * Handle on blur for slider
  11070. *
  11071. * @method handleBlur
  11072. */
  11073. Slider.prototype.handleBlur = function handleBlur() {
  11074. this.off(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
  11075. };
  11076. /**
  11077. * Listener for click events on slider, used to prevent clicks
  11078. * from bubbling up to parent elements like button menus.
  11079. *
  11080. * @param {Object} event Event object
  11081. * @method handleClick
  11082. */
  11083. Slider.prototype.handleClick = function handleClick(event) {
  11084. event.stopImmediatePropagation();
  11085. event.preventDefault();
  11086. };
  11087. /**
  11088. * Get/set if slider is horizontal for vertical
  11089. *
  11090. * @param {Boolean} bool True if slider is vertical, false is horizontal
  11091. * @return {Boolean} True if slider is vertical, false is horizontal
  11092. * @method vertical
  11093. */
  11094. Slider.prototype.vertical = function vertical(bool) {
  11095. if (bool === undefined) {
  11096. return this.vertical_ || false;
  11097. }
  11098. this.vertical_ = !!bool;
  11099. if (this.vertical_) {
  11100. this.addClass('vjs-slider-vertical');
  11101. } else {
  11102. this.addClass('vjs-slider-horizontal');
  11103. }
  11104. return this;
  11105. };
  11106. return Slider;
  11107. })(_componentJs2['default']);
  11108. _componentJs2['default'].registerComponent('Slider', Slider);
  11109. exports['default'] = Slider;
  11110. module.exports = exports['default'];
  11111. }, { "../component.js": 67, "../utils/dom.js": 143, "object.assign": 45 }], 120: [function (_dereq_, module, exports) {
  11112. /**
  11113. * @file flash-rtmp.js
  11114. */
  11115. 'use strict';
  11116. exports.__esModule = true;
  11117. function FlashRtmpDecorator(Flash) {
  11118. Flash.streamingFormats = {
  11119. 'rtmp/mp4': 'MP4',
  11120. 'rtmp/flv': 'FLV'
  11121. };
  11122. Flash.streamFromParts = function (connection, stream) {
  11123. return connection + '&' + stream;
  11124. };
  11125. Flash.streamToParts = function (src) {
  11126. var parts = {
  11127. connection: '',
  11128. stream: ''
  11129. };
  11130. if (!src) return parts;
  11131. // Look for the normal URL separator we expect, '&'.
  11132. // If found, we split the URL into two pieces around the
  11133. // first '&'.
  11134. var connEnd = src.search(/&(?!\w+=)/);
  11135. var streamBegin = undefined;
  11136. if (connEnd !== -1) {
  11137. streamBegin = connEnd + 1;
  11138. } else {
  11139. // If there's not a '&', we use the last '/' as the delimiter.
  11140. connEnd = streamBegin = src.lastIndexOf('/') + 1;
  11141. if (connEnd === 0) {
  11142. // really, there's not a '/'?
  11143. connEnd = streamBegin = src.length;
  11144. }
  11145. }
  11146. parts.connection = src.substring(0, connEnd);
  11147. parts.stream = src.substring(streamBegin, src.length);
  11148. return parts;
  11149. };
  11150. Flash.isStreamingType = function (srcType) {
  11151. return srcType in Flash.streamingFormats;
  11152. };
  11153. // RTMP has four variations, any string starting
  11154. // with one of these protocols should be valid
  11155. Flash.RTMP_RE = /^rtmp[set]?:\/\//i;
  11156. Flash.isStreamingSrc = function (src) {
  11157. return Flash.RTMP_RE.test(src);
  11158. };
  11159. /**
  11160. * A source handler for RTMP urls
  11161. * @type {Object}
  11162. */
  11163. Flash.rtmpSourceHandler = {};
  11164. /**
  11165. * Check if Flash can play the given videotype
  11166. * @param {String} type The mimetype to check
  11167. * @return {String} 'probably', 'maybe', or '' (empty string)
  11168. */
  11169. Flash.rtmpSourceHandler.canPlayType = function (type) {
  11170. if (Flash.isStreamingType(type)) {
  11171. return 'maybe';
  11172. }
  11173. return '';
  11174. };
  11175. /**
  11176. * Check if Flash can handle the source natively
  11177. * @param {Object} source The source object
  11178. * @return {String} 'probably', 'maybe', or '' (empty string)
  11179. */
  11180. Flash.rtmpSourceHandler.canHandleSource = function (source) {
  11181. var can = Flash.rtmpSourceHandler.canPlayType(source.type);
  11182. if (can) {
  11183. return can;
  11184. }
  11185. if (Flash.isStreamingSrc(source.src)) {
  11186. return 'maybe';
  11187. }
  11188. return '';
  11189. };
  11190. /**
  11191. * Pass the source to the flash object
  11192. * Adaptive source handlers will have more complicated workflows before passing
  11193. * video data to the video element
  11194. * @param {Object} source The source object
  11195. * @param {Flash} tech The instance of the Flash tech
  11196. * @param {Object} options The options to pass to the source
  11197. */
  11198. Flash.rtmpSourceHandler.handleSource = function (source, tech, options) {
  11199. var srcParts = Flash.streamToParts(source.src);
  11200. tech['setRtmpConnection'](srcParts.connection);
  11201. tech['setRtmpStream'](srcParts.stream);
  11202. };
  11203. // Register the native source handler
  11204. Flash.registerSourceHandler(Flash.rtmpSourceHandler);
  11205. return Flash;
  11206. }
  11207. exports['default'] = FlashRtmpDecorator;
  11208. module.exports = exports['default'];
  11209. }, {}], 121: [function (_dereq_, module, exports) {
  11210. /**
  11211. * @file flash.js
  11212. * VideoJS-SWF - Custom Flash Player with HTML5-ish API
  11213. * https://github.com/zencoder/video-js-swf
  11214. * Not using setupTriggers. Using global onEvent func to distribute events
  11215. */
  11216. 'use strict';
  11217. exports.__esModule = true;
  11218. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  11219. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11220. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  11221. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  11222. var _tech = _dereq_('./tech');
  11223. var _tech2 = _interopRequireDefault(_tech);
  11224. var _utilsDomJs = _dereq_('../utils/dom.js');
  11225. var Dom = _interopRequireWildcard(_utilsDomJs);
  11226. var _utilsUrlJs = _dereq_('../utils/url.js');
  11227. var Url = _interopRequireWildcard(_utilsUrlJs);
  11228. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js');
  11229. var _flashRtmp = _dereq_('./flash-rtmp');
  11230. var _flashRtmp2 = _interopRequireDefault(_flashRtmp);
  11231. var _component = _dereq_('../component');
  11232. var _component2 = _interopRequireDefault(_component);
  11233. var _globalWindow = _dereq_('global/window');
  11234. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  11235. var _objectAssign = _dereq_('object.assign');
  11236. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  11237. var navigator = _globalWindow2['default'].navigator;
  11238. /**
  11239. * Flash Media Controller - Wrapper for fallback SWF API
  11240. *
  11241. * @param {Object=} options Object of option names and values
  11242. * @param {Function=} ready Ready callback function
  11243. * @extends Tech
  11244. * @class Flash
  11245. */
  11246. var Flash = (function (_Tech) {
  11247. _inherits(Flash, _Tech);
  11248. function Flash(options, ready) {
  11249. _classCallCheck(this, Flash);
  11250. _Tech.call(this, options, ready);
  11251. // Set the source when ready
  11252. if (options.source) {
  11253. this.ready(function () {
  11254. this.setSource(options.source);
  11255. }, true);
  11256. }
  11257. // Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
  11258. // This allows resetting the playhead when we catch the reload
  11259. if (options.startTime) {
  11260. this.ready(function () {
  11261. this.load();
  11262. this.play();
  11263. this.currentTime(options.startTime);
  11264. }, true);
  11265. }
  11266. // Add global window functions that the swf expects
  11267. // A 4.x workflow we weren't able to solve for in 5.0
  11268. // because of the need to hard code these functions
  11269. // into the swf for security reasons
  11270. _globalWindow2['default'].videojs = _globalWindow2['default'].videojs || {};
  11271. _globalWindow2['default'].videojs.Flash = _globalWindow2['default'].videojs.Flash || {};
  11272. _globalWindow2['default'].videojs.Flash.onReady = Flash.onReady;
  11273. _globalWindow2['default'].videojs.Flash.onEvent = Flash.onEvent;
  11274. _globalWindow2['default'].videojs.Flash.onError = Flash.onError;
  11275. this.on('seeked', function () {
  11276. this.lastSeekTarget_ = undefined;
  11277. });
  11278. }
  11279. // Create setters and getters for attributes
  11280. /**
  11281. * Create the component's DOM element
  11282. *
  11283. * @return {Element}
  11284. * @method createEl
  11285. */
  11286. Flash.prototype.createEl = function createEl() {
  11287. var options = this.options_;
  11288. // If video.js is hosted locally you should also set the location
  11289. // for the hosted swf, which should be relative to the page (not video.js)
  11290. // Otherwise this adds a CDN url.
  11291. // The CDN also auto-adds a swf URL for that specific version.
  11292. if (!options.swf) {
  11293. options.swf = '//vjs.zencdn.net/swf/5.0.1/video-js.swf';
  11294. }
  11295. // Generate ID for swf object
  11296. var objId = options.techId;
  11297. // Merge default flashvars with ones passed in to init
  11298. var flashVars = _objectAssign2['default']({
  11299. // SWF Callback Functions
  11300. 'readyFunction': 'videojs.Flash.onReady',
  11301. 'eventProxyFunction': 'videojs.Flash.onEvent',
  11302. 'errorEventProxyFunction': 'videojs.Flash.onError',
  11303. // Player Settings
  11304. 'autoplay': options.autoplay,
  11305. 'preload': options.preload,
  11306. 'loop': options.loop,
  11307. 'muted': options.muted
  11308. }, options.flashVars);
  11309. // Merge default parames with ones passed in
  11310. var params = _objectAssign2['default']({
  11311. 'wmode': 'opaque', // Opaque is needed to overlay controls, but can affect playback performance
  11312. 'bgcolor': '#000000' // Using bgcolor prevents a white flash when the object is loading
  11313. }, options.params);
  11314. // Merge default attributes with ones passed in
  11315. var attributes = _objectAssign2['default']({
  11316. 'id': objId,
  11317. 'name': objId, // Both ID and Name needed or swf to identify itself
  11318. 'class': 'vjs-tech'
  11319. }, options.attributes);
  11320. this.el_ = Flash.embed(options.swf, flashVars, params, attributes);
  11321. this.el_.tech = this;
  11322. return this.el_;
  11323. };
  11324. /**
  11325. * Play for flash tech
  11326. *
  11327. * @method play
  11328. */
  11329. Flash.prototype.play = function play() {
  11330. if (this.ended()) {
  11331. this.setCurrentTime(0);
  11332. }
  11333. this.el_.vjs_play();
  11334. };
  11335. /**
  11336. * Pause for flash tech
  11337. *
  11338. * @method pause
  11339. */
  11340. Flash.prototype.pause = function pause() {
  11341. this.el_.vjs_pause();
  11342. };
  11343. /**
  11344. * Get/set video
  11345. *
  11346. * @param {Object=} src Source object
  11347. * @return {Object}
  11348. * @method src
  11349. */
  11350. Flash.prototype.src = function src(_src) {
  11351. if (_src === undefined) {
  11352. return this.currentSrc();
  11353. }
  11354. // Setting src through `src` not `setSrc` will be deprecated
  11355. return this.setSrc(_src);
  11356. };
  11357. /**
  11358. * Set video
  11359. *
  11360. * @param {Object=} src Source object
  11361. * @deprecated
  11362. * @method setSrc
  11363. */
  11364. Flash.prototype.setSrc = function setSrc(src) {
  11365. // Make sure source URL is absolute.
  11366. src = Url.getAbsoluteURL(src);
  11367. this.el_.vjs_src(src);
  11368. // Currently the SWF doesn't autoplay if you load a source later.
  11369. // e.g. Load player w/ no source, wait 2s, set src.
  11370. if (this.autoplay()) {
  11371. var tech = this;
  11372. this.setTimeout(function () {
  11373. tech.play();
  11374. }, 0);
  11375. }
  11376. };
  11377. /**
  11378. * Returns true if the tech is currently seeking.
  11379. * @return {boolean} true if seeking
  11380. */
  11381. Flash.prototype.seeking = function seeking() {
  11382. return this.lastSeekTarget_ !== undefined;
  11383. };
  11384. /**
  11385. * Set current time
  11386. *
  11387. * @param {Number} time Current time of video
  11388. * @method setCurrentTime
  11389. */
  11390. Flash.prototype.setCurrentTime = function setCurrentTime(time) {
  11391. var seekable = this.seekable();
  11392. if (seekable.length) {
  11393. // clamp to the current seekable range
  11394. time = time > seekable.start(0) ? time : seekable.start(0);
  11395. time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1);
  11396. this.lastSeekTarget_ = time;
  11397. this.trigger('seeking');
  11398. this.el_.vjs_setProperty('currentTime', time);
  11399. _Tech.prototype.setCurrentTime.call(this);
  11400. }
  11401. };
  11402. /**
  11403. * Get current time
  11404. *
  11405. * @param {Number=} time Current time of video
  11406. * @return {Number} Current time
  11407. * @method currentTime
  11408. */
  11409. Flash.prototype.currentTime = function currentTime(time) {
  11410. // when seeking make the reported time keep up with the requested time
  11411. // by reading the time we're seeking to
  11412. if (this.seeking()) {
  11413. return this.lastSeekTarget_ || 0;
  11414. }
  11415. return this.el_.vjs_getProperty('currentTime');
  11416. };
  11417. /**
  11418. * Get current source
  11419. *
  11420. * @method currentSrc
  11421. */
  11422. Flash.prototype.currentSrc = function currentSrc() {
  11423. if (this.currentSource_) {
  11424. return this.currentSource_.src;
  11425. } else {
  11426. return this.el_.vjs_getProperty('currentSrc');
  11427. }
  11428. };
  11429. /**
  11430. * Load media into player
  11431. *
  11432. * @method load
  11433. */
  11434. Flash.prototype.load = function load() {
  11435. this.el_.vjs_load();
  11436. };
  11437. /**
  11438. * Get poster
  11439. *
  11440. * @method poster
  11441. */
  11442. Flash.prototype.poster = function poster() {
  11443. this.el_.vjs_getProperty('poster');
  11444. };
  11445. /**
  11446. * Poster images are not handled by the Flash tech so make this a no-op
  11447. *
  11448. * @method setPoster
  11449. */
  11450. Flash.prototype.setPoster = function setPoster() { };
  11451. /**
  11452. * Determine if can seek in media
  11453. *
  11454. * @return {TimeRangeObject}
  11455. * @method seekable
  11456. */
  11457. Flash.prototype.seekable = function seekable() {
  11458. var duration = this.duration();
  11459. if (duration === 0) {
  11460. return _utilsTimeRangesJs.createTimeRange();
  11461. }
  11462. return _utilsTimeRangesJs.createTimeRange(0, duration);
  11463. };
  11464. /**
  11465. * Get buffered time range
  11466. *
  11467. * @return {TimeRangeObject}
  11468. * @method buffered
  11469. */
  11470. Flash.prototype.buffered = function buffered() {
  11471. var ranges = this.el_.vjs_getProperty('buffered');
  11472. if (ranges.length === 0) {
  11473. return _utilsTimeRangesJs.createTimeRange();
  11474. }
  11475. return _utilsTimeRangesJs.createTimeRange(ranges[0][0], ranges[0][1]);
  11476. };
  11477. /**
  11478. * Get fullscreen support -
  11479. * Flash does not allow fullscreen through javascript
  11480. * so always returns false
  11481. *
  11482. * @return {Boolean} false
  11483. * @method supportsFullScreen
  11484. */
  11485. Flash.prototype.supportsFullScreen = function supportsFullScreen() {
  11486. return false; // Flash does not allow fullscreen through javascript
  11487. };
  11488. /**
  11489. * Request to enter fullscreen
  11490. * Flash does not allow fullscreen through javascript
  11491. * so always returns false
  11492. *
  11493. * @return {Boolean} false
  11494. * @method enterFullScreen
  11495. */
  11496. Flash.prototype.enterFullScreen = function enterFullScreen() {
  11497. return false;
  11498. };
  11499. return Flash;
  11500. })(_tech2['default']);
  11501. var _api = Flash.prototype;
  11502. var _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
  11503. var _readOnly = 'networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(',');
  11504. function _createSetter(attr) {
  11505. var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
  11506. _api['set' + attrUpper] = function (val) {
  11507. return this.el_.vjs_setProperty(attr, val);
  11508. };
  11509. }
  11510. function _createGetter(attr) {
  11511. _api[attr] = function () {
  11512. return this.el_.vjs_getProperty(attr);
  11513. };
  11514. }
  11515. // Create getter and setters for all read/write attributes
  11516. for (var i = 0; i < _readWrite.length; i++) {
  11517. _createGetter(_readWrite[i]);
  11518. _createSetter(_readWrite[i]);
  11519. }
  11520. // Create getters for read-only attributes
  11521. for (var i = 0; i < _readOnly.length; i++) {
  11522. _createGetter(_readOnly[i]);
  11523. }
  11524. /* Flash Support Testing -------------------------------------------------------- */
  11525. Flash.isSupported = function () {
  11526. return Flash.version()[0] >= 10;
  11527. // return swfobject.hasFlashPlayerVersion('10');
  11528. };
  11529. // Add Source Handler pattern functions to this tech
  11530. _tech2['default'].withSourceHandlers(Flash);
  11531. /*
  11532. * The default native source handler.
  11533. * This simply passes the source to the video element. Nothing fancy.
  11534. *
  11535. * @param {Object} source The source object
  11536. * @param {Flash} tech The instance of the Flash tech
  11537. */
  11538. Flash.nativeSourceHandler = {};
  11539. /**
  11540. * Check if Flash can play the given videotype
  11541. * @param {String} type The mimetype to check
  11542. * @return {String} 'probably', 'maybe', or '' (empty string)
  11543. */
  11544. Flash.nativeSourceHandler.canPlayType = function (type) {
  11545. if (type in Flash.formats) {
  11546. return 'maybe';
  11547. }
  11548. return '';
  11549. };
  11550. /*
  11551. * Check Flash can handle the source natively
  11552. *
  11553. * @param {Object} source The source object
  11554. * @return {String} 'probably', 'maybe', or '' (empty string)
  11555. */
  11556. Flash.nativeSourceHandler.canHandleSource = function (source) {
  11557. var type;
  11558. function guessMimeType(src) {
  11559. var ext = Url.getFileExtension(src);
  11560. if (ext) {
  11561. return 'video/' + ext;
  11562. }
  11563. return '';
  11564. }
  11565. if (!source.type) {
  11566. type = guessMimeType(source.src);
  11567. } else {
  11568. // Strip code information from the type because we don't get that specific
  11569. type = source.type.replace(/;.*/, '').toLowerCase();
  11570. }
  11571. return Flash.nativeSourceHandler.canPlayType(type);
  11572. };
  11573. /*
  11574. * Pass the source to the flash object
  11575. * Adaptive source handlers will have more complicated workflows before passing
  11576. * video data to the video element
  11577. *
  11578. * @param {Object} source The source object
  11579. * @param {Flash} tech The instance of the Flash tech
  11580. * @param {Object} options The options to pass to the source
  11581. */
  11582. Flash.nativeSourceHandler.handleSource = function (source, tech, options) {
  11583. tech.setSrc(source.src);
  11584. };
  11585. /*
  11586. * Clean up the source handler when disposing the player or switching sources..
  11587. * (no cleanup is needed when supporting the format natively)
  11588. */
  11589. Flash.nativeSourceHandler.dispose = function () { };
  11590. // Register the native source handler
  11591. Flash.registerSourceHandler(Flash.nativeSourceHandler);
  11592. Flash.formats = {
  11593. 'video/flv': 'FLV',
  11594. 'video/x-flv': 'FLV',
  11595. 'video/mp4': 'MP4',
  11596. 'video/m4v': 'MP4'
  11597. };
  11598. Flash.onReady = function (currSwf) {
  11599. var el = Dom.getEl(currSwf);
  11600. var tech = el && el.tech;
  11601. // if there is no el then the tech has been disposed
  11602. // and the tech element was removed from the player div
  11603. if (tech && tech.el()) {
  11604. // check that the flash object is really ready
  11605. Flash.checkReady(tech);
  11606. }
  11607. };
  11608. // The SWF isn't always ready when it says it is. Sometimes the API functions still need to be added to the object.
  11609. // If it's not ready, we set a timeout to check again shortly.
  11610. Flash.checkReady = function (tech) {
  11611. // stop worrying if the tech has been disposed
  11612. if (!tech.el()) {
  11613. return;
  11614. }
  11615. // check if API property exists
  11616. if (tech.el().vjs_getProperty) {
  11617. // tell tech it's ready
  11618. tech.triggerReady();
  11619. } else {
  11620. // wait longer
  11621. this.setTimeout(function () {
  11622. Flash['checkReady'](tech);
  11623. }, 50);
  11624. }
  11625. };
  11626. // Trigger events from the swf on the player
  11627. Flash.onEvent = function (swfID, eventName) {
  11628. var tech = Dom.getEl(swfID).tech;
  11629. tech.trigger(eventName);
  11630. };
  11631. // Log errors from the swf
  11632. Flash.onError = function (swfID, err) {
  11633. var tech = Dom.getEl(swfID).tech;
  11634. // trigger MEDIA_ERR_SRC_NOT_SUPPORTED
  11635. if (err === 'srcnotfound') {
  11636. return tech.error(4);
  11637. }
  11638. // trigger a custom error
  11639. tech.error('FLASH: ' + err);
  11640. };
  11641. // Flash Version Check
  11642. Flash.version = function () {
  11643. var version = '0,0,0';
  11644. // IE
  11645. try {
  11646. version = new _globalWindow2['default'].ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  11647. // other browsers
  11648. } catch (e) {
  11649. try {
  11650. if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
  11651. version = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  11652. }
  11653. } catch (err) { }
  11654. }
  11655. return version.split(',');
  11656. };
  11657. // Flash embedding method. Only used in non-iframe mode
  11658. Flash.embed = function (swf, flashVars, params, attributes) {
  11659. var code = Flash.getEmbedCode(swf, flashVars, params, attributes);
  11660. // Get element by embedding code and retrieving created element
  11661. var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0];
  11662. return obj;
  11663. };
  11664. Flash.getEmbedCode = function (swf, flashVars, params, attributes) {
  11665. var objTag = '<object type="application/x-shockwave-flash" ';
  11666. var flashVarsString = '';
  11667. var paramsString = '';
  11668. var attrsString = '';
  11669. // Convert flash vars to string
  11670. if (flashVars) {
  11671. Object.getOwnPropertyNames(flashVars).forEach(function (key) {
  11672. flashVarsString += key + '=' + flashVars[key] + '&amp;';
  11673. });
  11674. }
  11675. // Add swf, flashVars, and other default params
  11676. params = _objectAssign2['default']({
  11677. 'movie': swf,
  11678. 'flashvars': flashVarsString,
  11679. 'allowScriptAccess': 'always', // Required to talk to swf
  11680. 'allowNetworking': 'all' // All should be default, but having security issues.
  11681. }, params);
  11682. // Create param tags string
  11683. Object.getOwnPropertyNames(params).forEach(function (key) {
  11684. paramsString += '<param name="' + key + '" value="' + params[key] + '" />';
  11685. });
  11686. attributes = _objectAssign2['default']({
  11687. // Add swf to attributes (need both for IE and Others to work)
  11688. 'data': swf,
  11689. // Default to 100% width/height
  11690. 'width': '100%',
  11691. 'height': '100%'
  11692. }, attributes);
  11693. // Create Attributes string
  11694. Object.getOwnPropertyNames(attributes).forEach(function (key) {
  11695. attrsString += key + '="' + attributes[key] + '" ';
  11696. });
  11697. return '' + objTag + attrsString + '>' + paramsString + '</object>';
  11698. };
  11699. // Run Flash through the RTMP decorator
  11700. _flashRtmp2['default'](Flash);
  11701. _component2['default'].registerComponent('Flash', Flash);
  11702. _tech2['default'].registerTech('Flash', Flash);
  11703. exports['default'] = Flash;
  11704. module.exports = exports['default'];
  11705. }, { "../component": 67, "../utils/dom.js": 143, "../utils/time-ranges.js": 151, "../utils/url.js": 153, "./flash-rtmp": 120, "./tech": 124, "global/window": 2, "object.assign": 45 }], 122: [function (_dereq_, module, exports) {
  11706. /**
  11707. * @file html5.js
  11708. * HTML5 Media Controller - Wrapper for HTML5 Media API
  11709. */
  11710. 'use strict';
  11711. exports.__esModule = true;
  11712. var _templateObject = _taggedTemplateLiteralLoose(['Text Tracks are being loaded from another origin but the crossorigin attribute isn\'t used. \n This may prevent text tracks from loading.'], ['Text Tracks are being loaded from another origin but the crossorigin attribute isn\'t used. \n This may prevent text tracks from loading.']);
  11713. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  11714. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11715. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  11716. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  11717. function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings; }
  11718. var _techJs = _dereq_('./tech.js');
  11719. var _techJs2 = _interopRequireDefault(_techJs);
  11720. var _component = _dereq_('../component');
  11721. var _component2 = _interopRequireDefault(_component);
  11722. var _utilsDomJs = _dereq_('../utils/dom.js');
  11723. var Dom = _interopRequireWildcard(_utilsDomJs);
  11724. var _utilsUrlJs = _dereq_('../utils/url.js');
  11725. var Url = _interopRequireWildcard(_utilsUrlJs);
  11726. var _utilsFnJs = _dereq_('../utils/fn.js');
  11727. var Fn = _interopRequireWildcard(_utilsFnJs);
  11728. var _utilsLogJs = _dereq_('../utils/log.js');
  11729. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  11730. var _tsml = _dereq_('tsml');
  11731. var _tsml2 = _interopRequireDefault(_tsml);
  11732. var _srcJsTracksTextTrackJs = _dereq_('../../../src/js/tracks/text-track.js');
  11733. var _srcJsTracksTextTrackJs2 = _interopRequireDefault(_srcJsTracksTextTrackJs);
  11734. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  11735. var browser = _interopRequireWildcard(_utilsBrowserJs);
  11736. var _globalDocument = _dereq_('global/document');
  11737. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  11738. var _globalWindow = _dereq_('global/window');
  11739. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  11740. var _objectAssign = _dereq_('object.assign');
  11741. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  11742. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js');
  11743. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  11744. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  11745. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  11746. /**
  11747. * HTML5 Media Controller - Wrapper for HTML5 Media API
  11748. *
  11749. * @param {Object=} options Object of option names and values
  11750. * @param {Function=} ready Ready callback function
  11751. * @extends Tech
  11752. * @class Html5
  11753. */
  11754. var Html5 = (function (_Tech) {
  11755. _inherits(Html5, _Tech);
  11756. function Html5(options, ready) {
  11757. var _this = this;
  11758. _classCallCheck(this, Html5);
  11759. _Tech.call(this, options, ready);
  11760. var source = options.source;
  11761. var crossoriginTracks = false;
  11762. // Set the source if one is provided
  11763. // 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted)
  11764. // 2) Check to see if the network state of the tag was failed at init, and if so, reset the source
  11765. // anyway so the error gets fired.
  11766. if (source && (this.el_.currentSrc !== source.src || options.tag && options.tag.initNetworkState_ === 3)) {
  11767. this.setSource(source);
  11768. } else {
  11769. this.handleLateInit_(this.el_);
  11770. }
  11771. if (this.el_.hasChildNodes()) {
  11772. var nodes = this.el_.childNodes;
  11773. var nodesLength = nodes.length;
  11774. var removeNodes = [];
  11775. while (nodesLength--) {
  11776. var node = nodes[nodesLength];
  11777. var nodeName = node.nodeName.toLowerCase();
  11778. if (nodeName === 'track') {
  11779. if (!this.featuresNativeTextTracks) {
  11780. // Empty video tag tracks so the built-in player doesn't use them also.
  11781. // This may not be fast enough to stop HTML5 browsers from reading the tags
  11782. // so we'll need to turn off any default tracks if we're manually doing
  11783. // captions and subtitles. videoElement.textTracks
  11784. removeNodes.push(node);
  11785. } else {
  11786. // store HTMLTrackElement and TextTrack to remote list
  11787. this.remoteTextTrackEls().addTrackElement_(node);
  11788. this.remoteTextTracks().addTrack_(node.track);
  11789. if (!crossoriginTracks && !this.el_.hasAttribute('crossorigin') && Url.isCrossOrigin(node.src)) {
  11790. crossoriginTracks = true;
  11791. }
  11792. }
  11793. }
  11794. }
  11795. for (var i = 0; i < removeNodes.length; i++) {
  11796. this.el_.removeChild(removeNodes[i]);
  11797. }
  11798. }
  11799. var trackTypes = ['audio', 'video'];
  11800. // ProxyNativeTextTracks
  11801. trackTypes.forEach(function (type) {
  11802. var capitalType = _utilsToTitleCaseJs2['default'](type);
  11803. if (!_this['featuresNative' + capitalType + 'Tracks']) {
  11804. return;
  11805. }
  11806. var tl = _this.el()[type + 'Tracks'];
  11807. if (tl && tl.addEventListener) {
  11808. tl.addEventListener('change', Fn.bind(_this, _this['handle' + capitalType + 'TrackChange_']));
  11809. tl.addEventListener('addtrack', Fn.bind(_this, _this['handle' + capitalType + 'TrackAdd_']));
  11810. tl.addEventListener('removetrack', Fn.bind(_this, _this['handle' + capitalType + 'TrackRemove_']));
  11811. }
  11812. });
  11813. if (this.featuresNativeTextTracks) {
  11814. if (crossoriginTracks) {
  11815. _utilsLogJs2['default'].warn(_tsml2['default'](_templateObject));
  11816. }
  11817. this.handleTextTrackChange_ = Fn.bind(this, this.handleTextTrackChange);
  11818. this.handleTextTrackAdd_ = Fn.bind(this, this.handleTextTrackAdd);
  11819. this.handleTextTrackRemove_ = Fn.bind(this, this.handleTextTrackRemove);
  11820. this.proxyNativeTextTracks_();
  11821. }
  11822. // Determine if native controls should be used
  11823. // Our goal should be to get the custom controls on mobile solid everywhere
  11824. // so we can remove this all together. Right now this will block custom
  11825. // controls on touch enabled laptops like the Chrome Pixel
  11826. if (browser.TOUCH_ENABLED && options.nativeControlsForTouch === true || browser.IS_IPHONE || browser.IS_NATIVE_ANDROID) {
  11827. this.setControls(true);
  11828. }
  11829. this.triggerReady();
  11830. }
  11831. /* HTML5 Support Testing ---------------------------------------------------- */
  11832. /*
  11833. * Element for testing browser HTML5 video capabilities
  11834. *
  11835. * @type {Element}
  11836. * @constant
  11837. * @private
  11838. */
  11839. /**
  11840. * Dispose of html5 media element
  11841. *
  11842. * @method dispose
  11843. */
  11844. Html5.prototype.dispose = function dispose() {
  11845. var _this2 = this;
  11846. // Un-ProxyNativeTracks
  11847. ['audio', 'video', 'text'].forEach(function (type) {
  11848. var capitalType = _utilsToTitleCaseJs2['default'](type);
  11849. var tl = _this2.el_[type + 'Tracks'];
  11850. if (tl && tl.removeEventListener) {
  11851. tl.removeEventListener('change', _this2['handle' + capitalType + 'TrackChange_']);
  11852. tl.removeEventListener('addtrack', _this2['handle' + capitalType + 'TrackAdd_']);
  11853. tl.removeEventListener('removetrack', _this2['handle' + capitalType + 'TrackRemove_']);
  11854. }
  11855. });
  11856. Html5.disposeMediaElement(this.el_);
  11857. // tech will handle clearing of the emulated track list
  11858. _Tech.prototype.dispose.call(this);
  11859. };
  11860. /**
  11861. * Create the component's DOM element
  11862. *
  11863. * @return {Element}
  11864. * @method createEl
  11865. */
  11866. Html5.prototype.createEl = function createEl() {
  11867. var el = this.options_.tag;
  11868. // Check if this browser supports moving the element into the box.
  11869. // On the iPhone video will break if you move the element,
  11870. // So we have to create a brand new element.
  11871. if (!el || this['movingMediaElementInDOM'] === false) {
  11872. // If the original tag is still there, clone and remove it.
  11873. if (el) {
  11874. var clone = el.cloneNode(true);
  11875. el.parentNode.insertBefore(clone, el);
  11876. Html5.disposeMediaElement(el);
  11877. el = clone;
  11878. } else {
  11879. el = _globalDocument2['default'].createElement('video');
  11880. // determine if native controls should be used
  11881. var tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag);
  11882. var attributes = _utilsMergeOptionsJs2['default']({}, tagAttributes);
  11883. if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
  11884. delete attributes.controls;
  11885. }
  11886. Dom.setElAttributes(el, _objectAssign2['default'](attributes, {
  11887. id: this.options_.techId,
  11888. 'class': 'vjs-tech'
  11889. }));
  11890. }
  11891. }
  11892. // Update specific tag settings, in case they were overridden
  11893. var settingsAttrs = ['autoplay', 'preload', 'loop', 'muted'];
  11894. for (var i = settingsAttrs.length - 1; i >= 0; i--) {
  11895. var attr = settingsAttrs[i];
  11896. var overwriteAttrs = {};
  11897. if (typeof this.options_[attr] !== 'undefined') {
  11898. overwriteAttrs[attr] = this.options_[attr];
  11899. }
  11900. Dom.setElAttributes(el, overwriteAttrs);
  11901. }
  11902. return el;
  11903. // jenniisawesome = true;
  11904. };
  11905. // If we're loading the playback object after it has started loading
  11906. // or playing the video (often with autoplay on) then the loadstart event
  11907. // has already fired and we need to fire it manually because many things
  11908. // rely on it.
  11909. Html5.prototype.handleLateInit_ = function handleLateInit_(el) {
  11910. var _this3 = this;
  11911. if (el.networkState === 0 || el.networkState === 3) {
  11912. // The video element hasn't started loading the source yet
  11913. // or didn't find a source
  11914. return;
  11915. }
  11916. if (el.readyState === 0) {
  11917. var _ret = (function () {
  11918. // NetworkState is set synchronously BUT loadstart is fired at the
  11919. // end of the current stack, usually before setInterval(fn, 0).
  11920. // So at this point we know loadstart may have already fired or is
  11921. // about to fire, and either way the player hasn't seen it yet.
  11922. // We don't want to fire loadstart prematurely here and cause a
  11923. // double loadstart so we'll wait and see if it happens between now
  11924. // and the next loop, and fire it if not.
  11925. // HOWEVER, we also want to make sure it fires before loadedmetadata
  11926. // which could also happen between now and the next loop, so we'll
  11927. // watch for that also.
  11928. var loadstartFired = false;
  11929. var setLoadstartFired = function setLoadstartFired() {
  11930. loadstartFired = true;
  11931. };
  11932. _this3.on('loadstart', setLoadstartFired);
  11933. var triggerLoadstart = function triggerLoadstart() {
  11934. // We did miss the original loadstart. Make sure the player
  11935. // sees loadstart before loadedmetadata
  11936. if (!loadstartFired) {
  11937. this.trigger('loadstart');
  11938. }
  11939. };
  11940. _this3.on('loadedmetadata', triggerLoadstart);
  11941. _this3.ready(function () {
  11942. this.off('loadstart', setLoadstartFired);
  11943. this.off('loadedmetadata', triggerLoadstart);
  11944. if (!loadstartFired) {
  11945. // We did miss the original native loadstart. Fire it now.
  11946. this.trigger('loadstart');
  11947. }
  11948. });
  11949. return {
  11950. v: undefined
  11951. };
  11952. })();
  11953. if (typeof _ret === 'object') return _ret.v;
  11954. }
  11955. // From here on we know that loadstart already fired and we missed it.
  11956. // The other readyState events aren't as much of a problem if we double
  11957. // them, so not going to go to as much trouble as loadstart to prevent
  11958. // that unless we find reason to.
  11959. var eventsToTrigger = ['loadstart'];
  11960. // loadedmetadata: newly equal to HAVE_METADATA (1) or greater
  11961. eventsToTrigger.push('loadedmetadata');
  11962. // loadeddata: newly increased to HAVE_CURRENT_DATA (2) or greater
  11963. if (el.readyState >= 2) {
  11964. eventsToTrigger.push('loadeddata');
  11965. }
  11966. // canplay: newly increased to HAVE_FUTURE_DATA (3) or greater
  11967. if (el.readyState >= 3) {
  11968. eventsToTrigger.push('canplay');
  11969. }
  11970. // canplaythrough: newly equal to HAVE_ENOUGH_DATA (4)
  11971. if (el.readyState >= 4) {
  11972. eventsToTrigger.push('canplaythrough');
  11973. }
  11974. // We still need to give the player time to add event listeners
  11975. this.ready(function () {
  11976. eventsToTrigger.forEach(function (type) {
  11977. this.trigger(type);
  11978. }, this);
  11979. });
  11980. };
  11981. Html5.prototype.proxyNativeTextTracks_ = function proxyNativeTextTracks_() {
  11982. var tt = this.el().textTracks;
  11983. if (tt) {
  11984. // Add tracks - if player is initialised after DOM loaded, textTracks
  11985. // will not trigger addtrack
  11986. for (var i = 0; i < tt.length; i++) {
  11987. this.textTracks().addTrack_(tt[i]);
  11988. }
  11989. if (tt.addEventListener) {
  11990. tt.addEventListener('change', this.handleTextTrackChange_);
  11991. tt.addEventListener('addtrack', this.handleTextTrackAdd_);
  11992. tt.addEventListener('removetrack', this.handleTextTrackRemove_);
  11993. }
  11994. }
  11995. };
  11996. Html5.prototype.handleTextTrackChange = function handleTextTrackChange(e) {
  11997. var tt = this.textTracks();
  11998. this.textTracks().trigger({
  11999. type: 'change',
  12000. target: tt,
  12001. currentTarget: tt,
  12002. srcElement: tt
  12003. });
  12004. };
  12005. Html5.prototype.handleTextTrackAdd = function handleTextTrackAdd(e) {
  12006. this.textTracks().addTrack_(e.track);
  12007. };
  12008. Html5.prototype.handleTextTrackRemove = function handleTextTrackRemove(e) {
  12009. this.textTracks().removeTrack_(e.track);
  12010. };
  12011. Html5.prototype.handleVideoTrackChange_ = function handleVideoTrackChange_(e) {
  12012. var vt = this.videoTracks();
  12013. this.videoTracks().trigger({
  12014. type: 'change',
  12015. target: vt,
  12016. currentTarget: vt,
  12017. srcElement: vt
  12018. });
  12019. };
  12020. Html5.prototype.handleVideoTrackAdd_ = function handleVideoTrackAdd_(e) {
  12021. this.videoTracks().addTrack_(e.track);
  12022. };
  12023. Html5.prototype.handleVideoTrackRemove_ = function handleVideoTrackRemove_(e) {
  12024. this.videoTracks().removeTrack_(e.track);
  12025. };
  12026. Html5.prototype.handleAudioTrackChange_ = function handleAudioTrackChange_(e) {
  12027. var audioTrackList = this.audioTracks();
  12028. this.audioTracks().trigger({
  12029. type: 'change',
  12030. target: audioTrackList,
  12031. currentTarget: audioTrackList,
  12032. srcElement: audioTrackList
  12033. });
  12034. };
  12035. Html5.prototype.handleAudioTrackAdd_ = function handleAudioTrackAdd_(e) {
  12036. this.audioTracks().addTrack_(e.track);
  12037. };
  12038. Html5.prototype.handleAudioTrackRemove_ = function handleAudioTrackRemove_(e) {
  12039. this.audioTracks().removeTrack_(e.track);
  12040. };
  12041. /**
  12042. * Play for html5 tech
  12043. *
  12044. * @method play
  12045. */
  12046. Html5.prototype.play = function play() {
  12047. this.el_.play();
  12048. };
  12049. /**
  12050. * Pause for html5 tech
  12051. *
  12052. * @method pause
  12053. */
  12054. Html5.prototype.pause = function pause() {
  12055. this.el_.pause();
  12056. };
  12057. /**
  12058. * Paused for html5 tech
  12059. *
  12060. * @return {Boolean}
  12061. * @method paused
  12062. */
  12063. Html5.prototype.paused = function paused() {
  12064. return this.el_.paused;
  12065. };
  12066. /**
  12067. * Get current time
  12068. *
  12069. * @return {Number}
  12070. * @method currentTime
  12071. */
  12072. Html5.prototype.currentTime = function currentTime() {
  12073. return this.el_.currentTime;
  12074. };
  12075. /**
  12076. * Set current time
  12077. *
  12078. * @param {Number} seconds Current time of video
  12079. * @method setCurrentTime
  12080. */
  12081. Html5.prototype.setCurrentTime = function setCurrentTime(seconds) {
  12082. try {
  12083. this.el_.currentTime = seconds;
  12084. } catch (e) {
  12085. _utilsLogJs2['default'](e, 'Video is not ready. (Video.js)');
  12086. // this.warning(VideoJS.warnings.videoNotReady);
  12087. }
  12088. };
  12089. /**
  12090. * Get duration
  12091. *
  12092. * @return {Number}
  12093. * @method duration
  12094. */
  12095. Html5.prototype.duration = function duration() {
  12096. return this.el_.duration || 0;
  12097. };
  12098. /**
  12099. * Get a TimeRange object that represents the intersection
  12100. * of the time ranges for which the user agent has all
  12101. * relevant media
  12102. *
  12103. * @return {TimeRangeObject}
  12104. * @method buffered
  12105. */
  12106. Html5.prototype.buffered = function buffered() {
  12107. return this.el_.buffered;
  12108. };
  12109. /**
  12110. * Get volume level
  12111. *
  12112. * @return {Number}
  12113. * @method volume
  12114. */
  12115. Html5.prototype.volume = function volume() {
  12116. return this.el_.volume;
  12117. };
  12118. /**
  12119. * Set volume level
  12120. *
  12121. * @param {Number} percentAsDecimal Volume percent as a decimal
  12122. * @method setVolume
  12123. */
  12124. Html5.prototype.setVolume = function setVolume(percentAsDecimal) {
  12125. this.el_.volume = percentAsDecimal;
  12126. };
  12127. /**
  12128. * Get if muted
  12129. *
  12130. * @return {Boolean}
  12131. * @method muted
  12132. */
  12133. Html5.prototype.muted = function muted() {
  12134. return this.el_.muted;
  12135. };
  12136. /**
  12137. * Set muted
  12138. *
  12139. * @param {Boolean} If player is to be muted or note
  12140. * @method setMuted
  12141. */
  12142. Html5.prototype.setMuted = function setMuted(muted) {
  12143. this.el_.muted = muted;
  12144. };
  12145. /**
  12146. * Get player width
  12147. *
  12148. * @return {Number}
  12149. * @method width
  12150. */
  12151. Html5.prototype.width = function width() {
  12152. return this.el_.offsetWidth;
  12153. };
  12154. /**
  12155. * Get player height
  12156. *
  12157. * @return {Number}
  12158. * @method height
  12159. */
  12160. Html5.prototype.height = function height() {
  12161. return this.el_.offsetHeight;
  12162. };
  12163. /**
  12164. * Get if there is fullscreen support
  12165. *
  12166. * @return {Boolean}
  12167. * @method supportsFullScreen
  12168. */
  12169. Html5.prototype.supportsFullScreen = function supportsFullScreen() {
  12170. if (typeof this.el_.webkitEnterFullScreen === 'function') {
  12171. var userAgent = _globalWindow2['default'].navigator.userAgent;
  12172. // Seems to be broken in Chromium/Chrome && Safari in Leopard
  12173. if (/Android/.test(userAgent) || !/Chrome|Mac OS X 10.5/.test(userAgent)) {
  12174. return true;
  12175. }
  12176. }
  12177. return false;
  12178. };
  12179. /**
  12180. * Request to enter fullscreen
  12181. *
  12182. * @method enterFullScreen
  12183. */
  12184. Html5.prototype.enterFullScreen = function enterFullScreen() {
  12185. var video = this.el_;
  12186. if ('webkitDisplayingFullscreen' in video) {
  12187. this.one('webkitbeginfullscreen', function () {
  12188. this.one('webkitendfullscreen', function () {
  12189. this.trigger('fullscreenchange', { isFullscreen: false });
  12190. });
  12191. this.trigger('fullscreenchange', { isFullscreen: true });
  12192. });
  12193. }
  12194. if (video.paused && video.networkState <= video.HAVE_METADATA) {
  12195. // attempt to prime the video element for programmatic access
  12196. // this isn't necessary on the desktop but shouldn't hurt
  12197. this.el_.play();
  12198. // playing and pausing synchronously during the transition to fullscreen
  12199. // can get iOS ~6.1 devices into a play/pause loop
  12200. this.setTimeout(function () {
  12201. video.pause();
  12202. video.webkitEnterFullScreen();
  12203. }, 0);
  12204. } else {
  12205. video.webkitEnterFullScreen();
  12206. }
  12207. };
  12208. /**
  12209. * Request to exit fullscreen
  12210. *
  12211. * @method exitFullScreen
  12212. */
  12213. Html5.prototype.exitFullScreen = function exitFullScreen() {
  12214. this.el_.webkitExitFullScreen();
  12215. };
  12216. /**
  12217. * Get/set video
  12218. *
  12219. * @param {Object=} src Source object
  12220. * @return {Object}
  12221. * @method src
  12222. */
  12223. Html5.prototype.src = function src(_src) {
  12224. if (_src === undefined) {
  12225. return this.el_.src;
  12226. } else {
  12227. // Setting src through `src` instead of `setSrc` will be deprecated
  12228. this.setSrc(_src);
  12229. }
  12230. };
  12231. /**
  12232. * Set video
  12233. *
  12234. * @param {Object} src Source object
  12235. * @deprecated
  12236. * @method setSrc
  12237. */
  12238. Html5.prototype.setSrc = function setSrc(src) {
  12239. this.el_.src = src;
  12240. };
  12241. /**
  12242. * Load media into player
  12243. *
  12244. * @method load
  12245. */
  12246. Html5.prototype.load = function load() {
  12247. this.el_.load();
  12248. };
  12249. /**
  12250. * Reset the tech. Removes all sources and calls `load`.
  12251. *
  12252. * @method reset
  12253. */
  12254. Html5.prototype.reset = function reset() {
  12255. Html5.resetMediaElement(this.el_);
  12256. };
  12257. /**
  12258. * Get current source
  12259. *
  12260. * @return {Object}
  12261. * @method currentSrc
  12262. */
  12263. Html5.prototype.currentSrc = function currentSrc() {
  12264. if (this.currentSource_) {
  12265. return this.currentSource_.src;
  12266. } else {
  12267. return this.el_.currentSrc;
  12268. }
  12269. };
  12270. /**
  12271. * Get poster
  12272. *
  12273. * @return {String}
  12274. * @method poster
  12275. */
  12276. Html5.prototype.poster = function poster() {
  12277. return this.el_.poster;
  12278. };
  12279. /**
  12280. * Set poster
  12281. *
  12282. * @param {String} val URL to poster image
  12283. * @method
  12284. */
  12285. Html5.prototype.setPoster = function setPoster(val) {
  12286. this.el_.poster = val;
  12287. };
  12288. /**
  12289. * Get preload attribute
  12290. *
  12291. * @return {String}
  12292. * @method preload
  12293. */
  12294. Html5.prototype.preload = function preload() {
  12295. return this.el_.preload;
  12296. };
  12297. /**
  12298. * Set preload attribute
  12299. *
  12300. * @param {String} val Value for preload attribute
  12301. * @method setPreload
  12302. */
  12303. Html5.prototype.setPreload = function setPreload(val) {
  12304. this.el_.preload = val;
  12305. };
  12306. /**
  12307. * Get autoplay attribute
  12308. *
  12309. * @return {String}
  12310. * @method autoplay
  12311. */
  12312. Html5.prototype.autoplay = function autoplay() {
  12313. return this.el_.autoplay;
  12314. };
  12315. /**
  12316. * Set autoplay attribute
  12317. *
  12318. * @param {String} val Value for preload attribute
  12319. * @method setAutoplay
  12320. */
  12321. Html5.prototype.setAutoplay = function setAutoplay(val) {
  12322. this.el_.autoplay = val;
  12323. };
  12324. /**
  12325. * Get controls attribute
  12326. *
  12327. * @return {String}
  12328. * @method controls
  12329. */
  12330. Html5.prototype.controls = function controls() {
  12331. return this.el_.controls;
  12332. };
  12333. /**
  12334. * Set controls attribute
  12335. *
  12336. * @param {String} val Value for controls attribute
  12337. * @method setControls
  12338. */
  12339. Html5.prototype.setControls = function setControls(val) {
  12340. this.el_.controls = !!val;
  12341. };
  12342. /**
  12343. * Get loop attribute
  12344. *
  12345. * @return {String}
  12346. * @method loop
  12347. */
  12348. Html5.prototype.loop = function loop() {
  12349. return this.el_.loop;
  12350. };
  12351. /**
  12352. * Set loop attribute
  12353. *
  12354. * @param {String} val Value for loop attribute
  12355. * @method setLoop
  12356. */
  12357. Html5.prototype.setLoop = function setLoop(val) {
  12358. this.el_.loop = val;
  12359. };
  12360. /**
  12361. * Get error value
  12362. *
  12363. * @return {String}
  12364. * @method error
  12365. */
  12366. Html5.prototype.error = function error() {
  12367. return this.el_.error;
  12368. };
  12369. /**
  12370. * Get whether or not the player is in the "seeking" state
  12371. *
  12372. * @return {Boolean}
  12373. * @method seeking
  12374. */
  12375. Html5.prototype.seeking = function seeking() {
  12376. return this.el_.seeking;
  12377. };
  12378. /**
  12379. * Get a TimeRanges object that represents the
  12380. * ranges of the media resource to which it is possible
  12381. * for the user agent to seek.
  12382. *
  12383. * @return {TimeRangeObject}
  12384. * @method seekable
  12385. */
  12386. Html5.prototype.seekable = function seekable() {
  12387. return this.el_.seekable;
  12388. };
  12389. /**
  12390. * Get if video ended
  12391. *
  12392. * @return {Boolean}
  12393. * @method ended
  12394. */
  12395. Html5.prototype.ended = function ended() {
  12396. return this.el_.ended;
  12397. };
  12398. /**
  12399. * Get the value of the muted content attribute
  12400. * This attribute has no dynamic effect, it only
  12401. * controls the default state of the element
  12402. *
  12403. * @return {Boolean}
  12404. * @method defaultMuted
  12405. */
  12406. Html5.prototype.defaultMuted = function defaultMuted() {
  12407. return this.el_.defaultMuted;
  12408. };
  12409. /**
  12410. * Get desired speed at which the media resource is to play
  12411. *
  12412. * @return {Number}
  12413. * @method playbackRate
  12414. */
  12415. Html5.prototype.playbackRate = function playbackRate() {
  12416. return this.el_.playbackRate;
  12417. };
  12418. /**
  12419. * Returns a TimeRanges object that represents the ranges of the
  12420. * media resource that the user agent has played.
  12421. * @return {TimeRangeObject} the range of points on the media
  12422. * timeline that has been reached through normal playback
  12423. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-played
  12424. */
  12425. Html5.prototype.played = function played() {
  12426. return this.el_.played;
  12427. };
  12428. /**
  12429. * Set desired speed at which the media resource is to play
  12430. *
  12431. * @param {Number} val Speed at which the media resource is to play
  12432. * @method setPlaybackRate
  12433. */
  12434. Html5.prototype.setPlaybackRate = function setPlaybackRate(val) {
  12435. this.el_.playbackRate = val;
  12436. };
  12437. /**
  12438. * Get the current state of network activity for the element, from
  12439. * the list below
  12440. * NETWORK_EMPTY (numeric value 0)
  12441. * NETWORK_IDLE (numeric value 1)
  12442. * NETWORK_LOADING (numeric value 2)
  12443. * NETWORK_NO_SOURCE (numeric value 3)
  12444. *
  12445. * @return {Number}
  12446. * @method networkState
  12447. */
  12448. Html5.prototype.networkState = function networkState() {
  12449. return this.el_.networkState;
  12450. };
  12451. /**
  12452. * Get a value that expresses the current state of the element
  12453. * with respect to rendering the current playback position, from
  12454. * the codes in the list below
  12455. * HAVE_NOTHING (numeric value 0)
  12456. * HAVE_METADATA (numeric value 1)
  12457. * HAVE_CURRENT_DATA (numeric value 2)
  12458. * HAVE_FUTURE_DATA (numeric value 3)
  12459. * HAVE_ENOUGH_DATA (numeric value 4)
  12460. *
  12461. * @return {Number}
  12462. * @method readyState
  12463. */
  12464. Html5.prototype.readyState = function readyState() {
  12465. return this.el_.readyState;
  12466. };
  12467. /**
  12468. * Get width of video
  12469. *
  12470. * @return {Number}
  12471. * @method videoWidth
  12472. */
  12473. Html5.prototype.videoWidth = function videoWidth() {
  12474. return this.el_.videoWidth;
  12475. };
  12476. /**
  12477. * Get height of video
  12478. *
  12479. * @return {Number}
  12480. * @method videoHeight
  12481. */
  12482. Html5.prototype.videoHeight = function videoHeight() {
  12483. return this.el_.videoHeight;
  12484. };
  12485. /**
  12486. * Get text tracks
  12487. *
  12488. * @return {TextTrackList}
  12489. * @method textTracks
  12490. */
  12491. Html5.prototype.textTracks = function textTracks() {
  12492. return _Tech.prototype.textTracks.call(this);
  12493. };
  12494. /**
  12495. * Creates and returns a text track object
  12496. *
  12497. * @param {String} kind Text track kind (subtitles, captions, descriptions
  12498. * chapters and metadata)
  12499. * @param {String=} label Label to identify the text track
  12500. * @param {String=} language Two letter language abbreviation
  12501. * @return {TextTrackObject}
  12502. * @method addTextTrack
  12503. */
  12504. Html5.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  12505. if (!this['featuresNativeTextTracks']) {
  12506. return _Tech.prototype.addTextTrack.call(this, kind, label, language);
  12507. }
  12508. return this.el_.addTextTrack(kind, label, language);
  12509. };
  12510. /**
  12511. * Creates a remote text track object and returns a html track element
  12512. *
  12513. * @param {Object} options The object should contain values for
  12514. * kind, language, label and src (location of the WebVTT file)
  12515. * @return {HTMLTrackElement}
  12516. * @method addRemoteTextTrack
  12517. */
  12518. Html5.prototype.addRemoteTextTrack = function addRemoteTextTrack() {
  12519. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  12520. if (!this['featuresNativeTextTracks']) {
  12521. return _Tech.prototype.addRemoteTextTrack.call(this, options);
  12522. }
  12523. var htmlTrackElement = _globalDocument2['default'].createElement('track');
  12524. if (options.kind) {
  12525. htmlTrackElement.kind = options.kind;
  12526. }
  12527. if (options.label) {
  12528. htmlTrackElement.label = options.label;
  12529. }
  12530. if (options.language || options.srclang) {
  12531. htmlTrackElement.srclang = options.language || options.srclang;
  12532. }
  12533. if (options['default']) {
  12534. htmlTrackElement['default'] = options['default'];
  12535. }
  12536. if (options.id) {
  12537. htmlTrackElement.id = options.id;
  12538. }
  12539. if (options.src) {
  12540. htmlTrackElement.src = options.src;
  12541. }
  12542. this.el().appendChild(htmlTrackElement);
  12543. // store HTMLTrackElement and TextTrack to remote list
  12544. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
  12545. this.remoteTextTracks().addTrack_(htmlTrackElement.track);
  12546. return htmlTrackElement;
  12547. };
  12548. /**
  12549. * Remove remote text track from TextTrackList object
  12550. *
  12551. * @param {TextTrackObject} track Texttrack object to remove
  12552. * @method removeRemoteTextTrack
  12553. */
  12554. Html5.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  12555. if (!this['featuresNativeTextTracks']) {
  12556. return _Tech.prototype.removeRemoteTextTrack.call(this, track);
  12557. }
  12558. var tracks = undefined,
  12559. i = undefined;
  12560. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
  12561. // remove HTMLTrackElement and TextTrack from remote list
  12562. this.remoteTextTrackEls().removeTrackElement_(trackElement);
  12563. this.remoteTextTracks().removeTrack_(track);
  12564. tracks = this.$$('track');
  12565. i = tracks.length;
  12566. while (i--) {
  12567. if (track === tracks[i] || track === tracks[i].track) {
  12568. this.el().removeChild(tracks[i]);
  12569. }
  12570. }
  12571. };
  12572. return Html5;
  12573. })(_techJs2['default']);
  12574. Html5.TEST_VID = _globalDocument2['default'].createElement('video');
  12575. var track = _globalDocument2['default'].createElement('track');
  12576. track.kind = 'captions';
  12577. track.srclang = 'en';
  12578. track.label = 'English';
  12579. Html5.TEST_VID.appendChild(track);
  12580. /*
  12581. * Check if HTML5 video is supported by this browser/device
  12582. *
  12583. * @return {Boolean}
  12584. */
  12585. Html5.isSupported = function () {
  12586. // IE9 with no Media Player is a LIAR! (#984)
  12587. try {
  12588. Html5.TEST_VID['volume'] = 0.5;
  12589. } catch (e) {
  12590. return false;
  12591. }
  12592. return !!Html5.TEST_VID.canPlayType;
  12593. };
  12594. // Add Source Handler pattern functions to this tech
  12595. _techJs2['default'].withSourceHandlers(Html5);
  12596. /*
  12597. * The default native source handler.
  12598. * This simply passes the source to the video element. Nothing fancy.
  12599. *
  12600. * @param {Object} source The source object
  12601. * @param {Html5} tech The instance of the HTML5 tech
  12602. */
  12603. Html5.nativeSourceHandler = {};
  12604. /*
  12605. * Check if the video element can play the given videotype
  12606. *
  12607. * @param {String} type The mimetype to check
  12608. * @return {String} 'probably', 'maybe', or '' (empty string)
  12609. */
  12610. Html5.nativeSourceHandler.canPlayType = function (type) {
  12611. // IE9 on Windows 7 without MediaPlayer throws an error here
  12612. // https://github.com/videojs/video.js/issues/519
  12613. try {
  12614. return Html5.TEST_VID.canPlayType(type);
  12615. } catch (e) {
  12616. return '';
  12617. }
  12618. };
  12619. /*
  12620. * Check if the video element can handle the source natively
  12621. *
  12622. * @param {Object} source The source object
  12623. * @return {String} 'probably', 'maybe', or '' (empty string)
  12624. */
  12625. Html5.nativeSourceHandler.canHandleSource = function (source) {
  12626. var match, ext;
  12627. // If a type was provided we should rely on that
  12628. if (source.type) {
  12629. return Html5.nativeSourceHandler.canPlayType(source.type);
  12630. } else if (source.src) {
  12631. // If no type, fall back to checking 'video/[EXTENSION]'
  12632. ext = Url.getFileExtension(source.src);
  12633. return Html5.nativeSourceHandler.canPlayType('video/' + ext);
  12634. }
  12635. return '';
  12636. };
  12637. /*
  12638. * Pass the source to the video element
  12639. * Adaptive source handlers will have more complicated workflows before passing
  12640. * video data to the video element
  12641. *
  12642. * @param {Object} source The source object
  12643. * @param {Html5} tech The instance of the Html5 tech
  12644. * @param {Object} options The options to pass to the source
  12645. */
  12646. Html5.nativeSourceHandler.handleSource = function (source, tech, options) {
  12647. tech.setSrc(source.src);
  12648. };
  12649. /*
  12650. * Clean up the source handler when disposing the player or switching sources..
  12651. * (no cleanup is needed when supporting the format natively)
  12652. */
  12653. Html5.nativeSourceHandler.dispose = function () { };
  12654. // Register the native source handler
  12655. Html5.registerSourceHandler(Html5.nativeSourceHandler);
  12656. /*
  12657. * Check if the volume can be changed in this browser/device.
  12658. * Volume cannot be changed in a lot of mobile devices.
  12659. * Specifically, it can't be changed from 1 on iOS.
  12660. *
  12661. * @return {Boolean}
  12662. */
  12663. Html5.canControlVolume = function () {
  12664. var volume = Html5.TEST_VID.volume;
  12665. Html5.TEST_VID.volume = volume / 2 + 0.1;
  12666. return volume !== Html5.TEST_VID.volume;
  12667. };
  12668. /*
  12669. * Check if playbackRate is supported in this browser/device.
  12670. *
  12671. * @return {Boolean}
  12672. */
  12673. Html5.canControlPlaybackRate = function () {
  12674. // Playback rate API is implemented in Android Chrome, but doesn't do anything
  12675. // https://github.com/videojs/video.js/issues/3180
  12676. if (browser.IS_ANDROID && browser.IS_CHROME) {
  12677. return false;
  12678. }
  12679. var playbackRate = Html5.TEST_VID.playbackRate;
  12680. Html5.TEST_VID.playbackRate = playbackRate / 2 + 0.1;
  12681. return playbackRate !== Html5.TEST_VID.playbackRate;
  12682. };
  12683. /*
  12684. * Check to see if native text tracks are supported by this browser/device
  12685. *
  12686. * @return {Boolean}
  12687. */
  12688. Html5.supportsNativeTextTracks = function () {
  12689. var supportsTextTracks;
  12690. // Figure out native text track support
  12691. // If mode is a number, we cannot change it because it'll disappear from view.
  12692. // Browsers with numeric modes include IE10 and older (<=2013) samsung android models.
  12693. // Firefox isn't playing nice either with modifying the mode
  12694. // TODO: Investigate firefox: https://github.com/videojs/video.js/issues/1862
  12695. supportsTextTracks = !!Html5.TEST_VID.textTracks;
  12696. if (supportsTextTracks && Html5.TEST_VID.textTracks.length > 0) {
  12697. supportsTextTracks = typeof Html5.TEST_VID.textTracks[0]['mode'] !== 'number';
  12698. }
  12699. if (supportsTextTracks && browser.IS_FIREFOX) {
  12700. supportsTextTracks = false;
  12701. }
  12702. if (supportsTextTracks && !('onremovetrack' in Html5.TEST_VID.textTracks)) {
  12703. supportsTextTracks = false;
  12704. }
  12705. return supportsTextTracks;
  12706. };
  12707. /*
  12708. * Check to see if native video tracks are supported by this browser/device
  12709. *
  12710. * @return {Boolean}
  12711. */
  12712. Html5.supportsNativeVideoTracks = function () {
  12713. var supportsVideoTracks = !!Html5.TEST_VID.videoTracks;
  12714. return supportsVideoTracks;
  12715. };
  12716. /*
  12717. * Check to see if native audio tracks are supported by this browser/device
  12718. *
  12719. * @return {Boolean}
  12720. */
  12721. Html5.supportsNativeAudioTracks = function () {
  12722. var supportsAudioTracks = !!Html5.TEST_VID.audioTracks;
  12723. return supportsAudioTracks;
  12724. };
  12725. /**
  12726. * An array of events available on the Html5 tech.
  12727. *
  12728. * @private
  12729. * @type {Array}
  12730. */
  12731. Html5.Events = ['loadstart', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', 'playing', 'waiting', 'seeking', 'seeked', 'ended', 'durationchange', 'timeupdate', 'progress', 'play', 'pause', 'ratechange', 'volumechange'];
  12732. /*
  12733. * Set the tech's volume control support status
  12734. *
  12735. * @type {Boolean}
  12736. */
  12737. Html5.prototype['featuresVolumeControl'] = Html5.canControlVolume();
  12738. /*
  12739. * Set the tech's playbackRate support status
  12740. *
  12741. * @type {Boolean}
  12742. */
  12743. Html5.prototype['featuresPlaybackRate'] = Html5.canControlPlaybackRate();
  12744. /*
  12745. * Set the tech's status on moving the video element.
  12746. * In iOS, if you move a video element in the DOM, it breaks video playback.
  12747. *
  12748. * @type {Boolean}
  12749. */
  12750. Html5.prototype['movingMediaElementInDOM'] = !browser.IS_IOS;
  12751. /*
  12752. * Set the the tech's fullscreen resize support status.
  12753. * HTML video is able to automatically resize when going to fullscreen.
  12754. * (No longer appears to be used. Can probably be removed.)
  12755. */
  12756. Html5.prototype['featuresFullscreenResize'] = true;
  12757. /*
  12758. * Set the tech's progress event support status
  12759. * (this disables the manual progress events of the Tech)
  12760. */
  12761. Html5.prototype['featuresProgressEvents'] = true;
  12762. /*
  12763. * Sets the tech's status on native text track support
  12764. *
  12765. * @type {Boolean}
  12766. */
  12767. Html5.prototype['featuresNativeTextTracks'] = Html5.supportsNativeTextTracks();
  12768. /**
  12769. * Sets the tech's status on native text track support
  12770. *
  12771. * @type {Boolean}
  12772. */
  12773. Html5.prototype['featuresNativeVideoTracks'] = Html5.supportsNativeVideoTracks();
  12774. /**
  12775. * Sets the tech's status on native audio track support
  12776. *
  12777. * @type {Boolean}
  12778. */
  12779. Html5.prototype['featuresNativeAudioTracks'] = Html5.supportsNativeAudioTracks();
  12780. // HTML5 Feature detection and Device Fixes --------------------------------- //
  12781. var canPlayType = undefined;
  12782. var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i;
  12783. var mp4RE = /^video\/mp4/i;
  12784. Html5.patchCanPlayType = function () {
  12785. // Android 4.0 and above can play HLS to some extent but it reports being unable to do so
  12786. if (browser.ANDROID_VERSION >= 4.0) {
  12787. if (!canPlayType) {
  12788. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
  12789. }
  12790. Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
  12791. if (type && mpegurlRE.test(type)) {
  12792. return 'maybe';
  12793. }
  12794. return canPlayType.call(this, type);
  12795. };
  12796. }
  12797. // Override Android 2.2 and less canPlayType method which is broken
  12798. if (browser.IS_OLD_ANDROID) {
  12799. if (!canPlayType) {
  12800. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
  12801. }
  12802. Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
  12803. if (type && mp4RE.test(type)) {
  12804. return 'maybe';
  12805. }
  12806. return canPlayType.call(this, type);
  12807. };
  12808. }
  12809. };
  12810. Html5.unpatchCanPlayType = function () {
  12811. var r = Html5.TEST_VID.constructor.prototype.canPlayType;
  12812. Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType;
  12813. canPlayType = null;
  12814. return r;
  12815. };
  12816. // by default, patch the video element
  12817. Html5.patchCanPlayType();
  12818. Html5.disposeMediaElement = function (el) {
  12819. if (!el) {
  12820. return;
  12821. }
  12822. if (el.parentNode) {
  12823. el.parentNode.removeChild(el);
  12824. }
  12825. // remove any child track or source nodes to prevent their loading
  12826. while (el.hasChildNodes()) {
  12827. el.removeChild(el.firstChild);
  12828. }
  12829. // remove any src reference. not setting `src=''` because that causes a warning
  12830. // in firefox
  12831. el.removeAttribute('src');
  12832. // force the media element to update its loading state by calling load()
  12833. // however IE on Windows 7N has a bug that throws an error so need a try/catch (#793)
  12834. if (typeof el.load === 'function') {
  12835. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  12836. (function () {
  12837. try {
  12838. el.load();
  12839. } catch (e) {
  12840. // not supported
  12841. }
  12842. })();
  12843. }
  12844. };
  12845. Html5.resetMediaElement = function (el) {
  12846. if (!el) {
  12847. return;
  12848. }
  12849. var sources = el.querySelectorAll('source');
  12850. var i = sources.length;
  12851. while (i--) {
  12852. el.removeChild(sources[i]);
  12853. }
  12854. // remove any src reference.
  12855. // not setting `src=''` because that throws an error
  12856. el.removeAttribute('src');
  12857. if (typeof el.load === 'function') {
  12858. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  12859. (function () {
  12860. try {
  12861. el.load();
  12862. } catch (e) { }
  12863. })();
  12864. }
  12865. };
  12866. _component2['default'].registerComponent('Html5', Html5);
  12867. _techJs2['default'].registerTech('Html5', Html5);
  12868. exports['default'] = Html5;
  12869. module.exports = exports['default'];
  12870. }, { "../../../src/js/tracks/text-track.js": 134, "../component": 67, "../utils/browser.js": 140, "../utils/dom.js": 143, "../utils/fn.js": 145, "../utils/log.js": 148, "../utils/merge-options.js": 149, "../utils/to-title-case.js": 152, "../utils/url.js": 153, "./tech.js": 124, "global/document": 1, "global/window": 2, "object.assign": 45, "tsml": 55 }], 123: [function (_dereq_, module, exports) {
  12871. /**
  12872. * @file loader.js
  12873. */
  12874. 'use strict';
  12875. exports.__esModule = true;
  12876. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  12877. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  12878. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  12879. var _componentJs = _dereq_('../component.js');
  12880. var _componentJs2 = _interopRequireDefault(_componentJs);
  12881. var _techJs = _dereq_('./tech.js');
  12882. var _techJs2 = _interopRequireDefault(_techJs);
  12883. var _globalWindow = _dereq_('global/window');
  12884. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  12885. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  12886. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  12887. /**
  12888. * The Media Loader is the component that decides which playback technology to load
  12889. * when the player is initialized.
  12890. *
  12891. * @param {Object} player Main Player
  12892. * @param {Object=} options Object of option names and values
  12893. * @param {Function=} ready Ready callback function
  12894. * @extends Component
  12895. * @class MediaLoader
  12896. */
  12897. var MediaLoader = (function (_Component) {
  12898. _inherits(MediaLoader, _Component);
  12899. function MediaLoader(player, options, ready) {
  12900. _classCallCheck(this, MediaLoader);
  12901. _Component.call(this, player, options, ready);
  12902. // If there are no sources when the player is initialized,
  12903. // load the first supported playback technology.
  12904. if (!options.playerOptions['sources'] || options.playerOptions['sources'].length === 0) {
  12905. for (var i = 0, j = options.playerOptions['techOrder']; i < j.length; i++) {
  12906. var techName = _utilsToTitleCaseJs2['default'](j[i]);
  12907. var tech = _techJs2['default'].getTech(techName);
  12908. // Support old behavior of techs being registered as components.
  12909. // Remove once that deprecated behavior is removed.
  12910. if (!techName) {
  12911. tech = _componentJs2['default'].getComponent(techName);
  12912. }
  12913. // Check if the browser supports this technology
  12914. if (tech && tech.isSupported()) {
  12915. player.loadTech_(techName);
  12916. break;
  12917. }
  12918. }
  12919. } else {
  12920. // // Loop through playback technologies (HTML5, Flash) and check for support.
  12921. // // Then load the best source.
  12922. // // A few assumptions here:
  12923. // // All playback technologies respect preload false.
  12924. player.src(options.playerOptions['sources']);
  12925. }
  12926. }
  12927. return MediaLoader;
  12928. })(_componentJs2['default']);
  12929. _componentJs2['default'].registerComponent('MediaLoader', MediaLoader);
  12930. exports['default'] = MediaLoader;
  12931. module.exports = exports['default'];
  12932. }, { "../component.js": 67, "../utils/to-title-case.js": 152, "./tech.js": 124, "global/window": 2 }], 124: [function (_dereq_, module, exports) {
  12933. /**
  12934. * @file tech.js
  12935. * Media Technology Controller - Base class for media playback
  12936. * technology controllers like Flash and HTML5
  12937. */
  12938. 'use strict';
  12939. exports.__esModule = true;
  12940. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  12941. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  12942. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  12943. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  12944. var _component = _dereq_('../component');
  12945. var _component2 = _interopRequireDefault(_component);
  12946. var _tracksHtmlTrackElement = _dereq_('../tracks/html-track-element');
  12947. var _tracksHtmlTrackElement2 = _interopRequireDefault(_tracksHtmlTrackElement);
  12948. var _tracksHtmlTrackElementList = _dereq_('../tracks/html-track-element-list');
  12949. var _tracksHtmlTrackElementList2 = _interopRequireDefault(_tracksHtmlTrackElementList);
  12950. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js');
  12951. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  12952. var _tracksTextTrack = _dereq_('../tracks/text-track');
  12953. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack);
  12954. var _tracksTextTrackList = _dereq_('../tracks/text-track-list');
  12955. var _tracksTextTrackList2 = _interopRequireDefault(_tracksTextTrackList);
  12956. var _tracksVideoTrack = _dereq_('../tracks/video-track');
  12957. var _tracksVideoTrack2 = _interopRequireDefault(_tracksVideoTrack);
  12958. var _tracksVideoTrackList = _dereq_('../tracks/video-track-list');
  12959. var _tracksVideoTrackList2 = _interopRequireDefault(_tracksVideoTrackList);
  12960. var _tracksAudioTrackList = _dereq_('../tracks/audio-track-list');
  12961. var _tracksAudioTrackList2 = _interopRequireDefault(_tracksAudioTrackList);
  12962. var _tracksAudioTrack = _dereq_('../tracks/audio-track');
  12963. var _tracksAudioTrack2 = _interopRequireDefault(_tracksAudioTrack);
  12964. var _utilsFnJs = _dereq_('../utils/fn.js');
  12965. var Fn = _interopRequireWildcard(_utilsFnJs);
  12966. var _utilsLogJs = _dereq_('../utils/log.js');
  12967. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  12968. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js');
  12969. var _utilsBufferJs = _dereq_('../utils/buffer.js');
  12970. var _mediaErrorJs = _dereq_('../media-error.js');
  12971. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs);
  12972. var _globalWindow = _dereq_('global/window');
  12973. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  12974. var _globalDocument = _dereq_('global/document');
  12975. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  12976. /**
  12977. * Base class for media (HTML5 Video, Flash) controllers
  12978. *
  12979. * @param {Object=} options Options object
  12980. * @param {Function=} ready Ready callback function
  12981. * @extends Component
  12982. * @class Tech
  12983. */
  12984. var Tech = (function (_Component) {
  12985. _inherits(Tech, _Component);
  12986. function Tech() {
  12987. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  12988. var ready = arguments.length <= 1 || arguments[1] === undefined ? function () { } : arguments[1];
  12989. _classCallCheck(this, Tech);
  12990. // we don't want the tech to report user activity automatically.
  12991. // This is done manually in addControlsListeners
  12992. options.reportTouchActivity = false;
  12993. _Component.call(this, null, options, ready);
  12994. // keep track of whether the current source has played at all to
  12995. // implement a very limited played()
  12996. this.hasStarted_ = false;
  12997. this.on('playing', function () {
  12998. this.hasStarted_ = true;
  12999. });
  13000. this.on('loadstart', function () {
  13001. this.hasStarted_ = false;
  13002. });
  13003. this.textTracks_ = options.textTracks;
  13004. this.videoTracks_ = options.videoTracks;
  13005. this.audioTracks_ = options.audioTracks;
  13006. // Manually track progress in cases where the browser/flash player doesn't report it.
  13007. if (!this.featuresProgressEvents) {
  13008. this.manualProgressOn();
  13009. }
  13010. // Manually track timeupdates in cases where the browser/flash player doesn't report it.
  13011. if (!this.featuresTimeupdateEvents) {
  13012. this.manualTimeUpdatesOn();
  13013. }
  13014. if (options.nativeCaptions === false || options.nativeTextTracks === false) {
  13015. this.featuresNativeTextTracks = false;
  13016. }
  13017. if (!this.featuresNativeTextTracks) {
  13018. this.on('ready', this.emulateTextTracks);
  13019. }
  13020. this.initTextTrackListeners();
  13021. this.initTrackListeners();
  13022. // Turn on component tap events
  13023. this.emitTapEvents();
  13024. }
  13025. /**
  13026. * List of associated text tracks
  13027. *
  13028. * @type {TextTrackList}
  13029. * @private
  13030. */
  13031. /* Fallbacks for unsupported event types
  13032. ================================================================================ */
  13033. // Manually trigger progress events based on changes to the buffered amount
  13034. // Many flash players and older HTML5 browsers don't send progress or progress-like events
  13035. /**
  13036. * Turn on progress events
  13037. *
  13038. * @method manualProgressOn
  13039. */
  13040. Tech.prototype.manualProgressOn = function manualProgressOn() {
  13041. this.on('durationchange', this.onDurationChange);
  13042. this.manualProgress = true;
  13043. // Trigger progress watching when a source begins loading
  13044. this.one('ready', this.trackProgress);
  13045. };
  13046. /**
  13047. * Turn off progress events
  13048. *
  13049. * @method manualProgressOff
  13050. */
  13051. Tech.prototype.manualProgressOff = function manualProgressOff() {
  13052. this.manualProgress = false;
  13053. this.stopTrackingProgress();
  13054. this.off('durationchange', this.onDurationChange);
  13055. };
  13056. /**
  13057. * Track progress
  13058. *
  13059. * @method trackProgress
  13060. */
  13061. Tech.prototype.trackProgress = function trackProgress() {
  13062. this.stopTrackingProgress();
  13063. this.progressInterval = this.setInterval(Fn.bind(this, function () {
  13064. // Don't trigger unless buffered amount is greater than last time
  13065. var numBufferedPercent = this.bufferedPercent();
  13066. if (this.bufferedPercent_ !== numBufferedPercent) {
  13067. this.trigger('progress');
  13068. }
  13069. this.bufferedPercent_ = numBufferedPercent;
  13070. if (numBufferedPercent === 1) {
  13071. this.stopTrackingProgress();
  13072. }
  13073. }), 500);
  13074. };
  13075. /**
  13076. * Update duration
  13077. *
  13078. * @method onDurationChange
  13079. */
  13080. Tech.prototype.onDurationChange = function onDurationChange() {
  13081. this.duration_ = this.duration();
  13082. };
  13083. /**
  13084. * Create and get TimeRange object for buffering
  13085. *
  13086. * @return {TimeRangeObject}
  13087. * @method buffered
  13088. */
  13089. Tech.prototype.buffered = function buffered() {
  13090. return _utilsTimeRangesJs.createTimeRange(0, 0);
  13091. };
  13092. /**
  13093. * Get buffered percent
  13094. *
  13095. * @return {Number}
  13096. * @method bufferedPercent
  13097. */
  13098. Tech.prototype.bufferedPercent = function bufferedPercent() {
  13099. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration_);
  13100. };
  13101. /**
  13102. * Stops tracking progress by clearing progress interval
  13103. *
  13104. * @method stopTrackingProgress
  13105. */
  13106. Tech.prototype.stopTrackingProgress = function stopTrackingProgress() {
  13107. this.clearInterval(this.progressInterval);
  13108. };
  13109. /*! Time Tracking -------------------------------------------------------------- */
  13110. /**
  13111. * Set event listeners for on play and pause and tracking current time
  13112. *
  13113. * @method manualTimeUpdatesOn
  13114. */
  13115. Tech.prototype.manualTimeUpdatesOn = function manualTimeUpdatesOn() {
  13116. this.manualTimeUpdates = true;
  13117. this.on('play', this.trackCurrentTime);
  13118. this.on('pause', this.stopTrackingCurrentTime);
  13119. };
  13120. /**
  13121. * Remove event listeners for on play and pause and tracking current time
  13122. *
  13123. * @method manualTimeUpdatesOff
  13124. */
  13125. Tech.prototype.manualTimeUpdatesOff = function manualTimeUpdatesOff() {
  13126. this.manualTimeUpdates = false;
  13127. this.stopTrackingCurrentTime();
  13128. this.off('play', this.trackCurrentTime);
  13129. this.off('pause', this.stopTrackingCurrentTime);
  13130. };
  13131. /**
  13132. * Tracks current time
  13133. *
  13134. * @method trackCurrentTime
  13135. */
  13136. Tech.prototype.trackCurrentTime = function trackCurrentTime() {
  13137. if (this.currentTimeInterval) {
  13138. this.stopTrackingCurrentTime();
  13139. }
  13140. this.currentTimeInterval = this.setInterval(function () {
  13141. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  13142. }, 250); // 42 = 24 fps // 250 is what Webkit uses // FF uses 15
  13143. };
  13144. /**
  13145. * Turn off play progress tracking (when paused or dragging)
  13146. *
  13147. * @method stopTrackingCurrentTime
  13148. */
  13149. Tech.prototype.stopTrackingCurrentTime = function stopTrackingCurrentTime() {
  13150. this.clearInterval(this.currentTimeInterval);
  13151. // #1002 - if the video ends right before the next timeupdate would happen,
  13152. // the progress bar won't make it all the way to the end
  13153. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  13154. };
  13155. /**
  13156. * Turn off any manual progress or timeupdate tracking
  13157. *
  13158. * @method dispose
  13159. */
  13160. Tech.prototype.dispose = function dispose() {
  13161. // clear out all tracks because we can't reuse them between techs
  13162. this.clearTracks(['audio', 'video', 'text']);
  13163. // Turn off any manual progress or timeupdate tracking
  13164. if (this.manualProgress) {
  13165. this.manualProgressOff();
  13166. }
  13167. if (this.manualTimeUpdates) {
  13168. this.manualTimeUpdatesOff();
  13169. }
  13170. _Component.prototype.dispose.call(this);
  13171. };
  13172. /**
  13173. * clear out a track list, or multiple track lists
  13174. *
  13175. * Note: Techs without source handlers should call this between
  13176. * sources for video & audio tracks, as usually you don't want
  13177. * to use them between tracks and we have no automatic way to do
  13178. * it for you
  13179. *
  13180. * @method clearTracks
  13181. * @param {Array|String} types type(s) of track lists to empty
  13182. */
  13183. Tech.prototype.clearTracks = function clearTracks(types) {
  13184. var _this = this;
  13185. types = [].concat(types);
  13186. // clear out all tracks because we can't reuse them between techs
  13187. types.forEach(function (type) {
  13188. var list = _this[type + 'Tracks']() || [];
  13189. var i = list.length;
  13190. while (i--) {
  13191. var track = list[i];
  13192. if (type === 'text') {
  13193. _this.removeRemoteTextTrack(track);
  13194. }
  13195. list.removeTrack_(track);
  13196. }
  13197. });
  13198. };
  13199. /**
  13200. * Reset the tech. Removes all sources and resets readyState.
  13201. *
  13202. * @method reset
  13203. */
  13204. Tech.prototype.reset = function reset() { };
  13205. /**
  13206. * When invoked without an argument, returns a MediaError object
  13207. * representing the current error state of the player or null if
  13208. * there is no error. When invoked with an argument, set the current
  13209. * error state of the player.
  13210. * @param {MediaError=} err Optional an error object
  13211. * @return {MediaError} the current error object or null
  13212. * @method error
  13213. */
  13214. Tech.prototype.error = function error(err) {
  13215. if (err !== undefined) {
  13216. if (err instanceof _mediaErrorJs2['default']) {
  13217. this.error_ = err;
  13218. } else {
  13219. this.error_ = new _mediaErrorJs2['default'](err);
  13220. }
  13221. this.trigger('error');
  13222. }
  13223. return this.error_;
  13224. };
  13225. /**
  13226. * Return the time ranges that have been played through for the
  13227. * current source. This implementation is incomplete. It does not
  13228. * track the played time ranges, only whether the source has played
  13229. * at all or not.
  13230. * @return {TimeRangeObject} a single time range if this video has
  13231. * played or an empty set of ranges if not.
  13232. * @method played
  13233. */
  13234. Tech.prototype.played = function played() {
  13235. if (this.hasStarted_) {
  13236. return _utilsTimeRangesJs.createTimeRange(0, 0);
  13237. }
  13238. return _utilsTimeRangesJs.createTimeRange();
  13239. };
  13240. /**
  13241. * Set current time
  13242. *
  13243. * @method setCurrentTime
  13244. */
  13245. Tech.prototype.setCurrentTime = function setCurrentTime() {
  13246. // improve the accuracy of manual timeupdates
  13247. if (this.manualTimeUpdates) {
  13248. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  13249. }
  13250. };
  13251. /**
  13252. * Initialize texttrack listeners
  13253. *
  13254. * @method initTextTrackListeners
  13255. */
  13256. Tech.prototype.initTextTrackListeners = function initTextTrackListeners() {
  13257. var textTrackListChanges = Fn.bind(this, function () {
  13258. this.trigger('texttrackchange');
  13259. });
  13260. var tracks = this.textTracks();
  13261. if (!tracks) return;
  13262. tracks.addEventListener('removetrack', textTrackListChanges);
  13263. tracks.addEventListener('addtrack', textTrackListChanges);
  13264. this.on('dispose', Fn.bind(this, function () {
  13265. tracks.removeEventListener('removetrack', textTrackListChanges);
  13266. tracks.removeEventListener('addtrack', textTrackListChanges);
  13267. }));
  13268. };
  13269. /**
  13270. * Initialize audio and video track listeners
  13271. *
  13272. * @method initTrackListeners
  13273. */
  13274. Tech.prototype.initTrackListeners = function initTrackListeners() {
  13275. var _this2 = this;
  13276. var trackTypes = ['video', 'audio'];
  13277. trackTypes.forEach(function (type) {
  13278. var trackListChanges = function trackListChanges() {
  13279. _this2.trigger(type + 'trackchange');
  13280. };
  13281. var tracks = _this2[type + 'Tracks']();
  13282. tracks.addEventListener('removetrack', trackListChanges);
  13283. tracks.addEventListener('addtrack', trackListChanges);
  13284. _this2.on('dispose', function () {
  13285. tracks.removeEventListener('removetrack', trackListChanges);
  13286. tracks.removeEventListener('addtrack', trackListChanges);
  13287. });
  13288. });
  13289. };
  13290. /**
  13291. * Emulate texttracks
  13292. *
  13293. * @method emulateTextTracks
  13294. */
  13295. Tech.prototype.emulateTextTracks = function emulateTextTracks() {
  13296. var _this3 = this;
  13297. var tracks = this.textTracks();
  13298. if (!tracks) {
  13299. return;
  13300. }
  13301. if (!_globalWindow2['default']['WebVTT'] && this.el().parentNode != null) {
  13302. (function () {
  13303. var script = _globalDocument2['default'].createElement('script');
  13304. script.src = _this3.options_['vtt.js'] || 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.min.js';
  13305. script.onload = function () {
  13306. _this3.trigger('vttjsloaded');
  13307. };
  13308. script.onerror = function () {
  13309. _this3.trigger('vttjserror');
  13310. };
  13311. _this3.on('dispose', function () {
  13312. script.onload = null;
  13313. script.onerror = null;
  13314. });
  13315. // but have not loaded yet and we set it to true before the inject so that
  13316. // we don't overwrite the injected window.WebVTT if it loads right away
  13317. _globalWindow2['default']['WebVTT'] = true;
  13318. _this3.el().parentNode.appendChild(script);
  13319. })();
  13320. }
  13321. var updateDisplay = function updateDisplay() {
  13322. return _this3.trigger('texttrackchange');
  13323. };
  13324. var textTracksChanges = function textTracksChanges() {
  13325. updateDisplay();
  13326. for (var i = 0; i < tracks.length; i++) {
  13327. var track = tracks[i];
  13328. track.removeEventListener('cuechange', updateDisplay);
  13329. if (track.mode === 'showing') {
  13330. track.addEventListener('cuechange', updateDisplay);
  13331. }
  13332. }
  13333. };
  13334. textTracksChanges();
  13335. tracks.addEventListener('change', textTracksChanges);
  13336. this.on('dispose', function () {
  13337. tracks.removeEventListener('change', textTracksChanges);
  13338. });
  13339. };
  13340. /**
  13341. * Get videotracks
  13342. *
  13343. * @returns {VideoTrackList}
  13344. * @method videoTracks
  13345. */
  13346. Tech.prototype.videoTracks = function videoTracks() {
  13347. this.videoTracks_ = this.videoTracks_ || new _tracksVideoTrackList2['default']();
  13348. return this.videoTracks_;
  13349. };
  13350. /**
  13351. * Get audiotracklist
  13352. *
  13353. * @returns {AudioTrackList}
  13354. * @method audioTracks
  13355. */
  13356. Tech.prototype.audioTracks = function audioTracks() {
  13357. this.audioTracks_ = this.audioTracks_ || new _tracksAudioTrackList2['default']();
  13358. return this.audioTracks_;
  13359. };
  13360. /*
  13361. * Provide default methods for text tracks.
  13362. *
  13363. * Html5 tech overrides these.
  13364. */
  13365. /**
  13366. * Get texttracks
  13367. *
  13368. * @returns {TextTrackList}
  13369. * @method textTracks
  13370. */
  13371. Tech.prototype.textTracks = function textTracks() {
  13372. this.textTracks_ = this.textTracks_ || new _tracksTextTrackList2['default']();
  13373. return this.textTracks_;
  13374. };
  13375. /**
  13376. * Get remote texttracks
  13377. *
  13378. * @returns {TextTrackList}
  13379. * @method remoteTextTracks
  13380. */
  13381. Tech.prototype.remoteTextTracks = function remoteTextTracks() {
  13382. this.remoteTextTracks_ = this.remoteTextTracks_ || new _tracksTextTrackList2['default']();
  13383. return this.remoteTextTracks_;
  13384. };
  13385. /**
  13386. * Get remote htmltrackelements
  13387. *
  13388. * @returns {HTMLTrackElementList}
  13389. * @method remoteTextTrackEls
  13390. */
  13391. Tech.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  13392. this.remoteTextTrackEls_ = this.remoteTextTrackEls_ || new _tracksHtmlTrackElementList2['default']();
  13393. return this.remoteTextTrackEls_;
  13394. };
  13395. /**
  13396. * Creates and returns a remote text track object
  13397. *
  13398. * @param {String} kind Text track kind (subtitles, captions, descriptions
  13399. * chapters and metadata)
  13400. * @param {String=} label Label to identify the text track
  13401. * @param {String=} language Two letter language abbreviation
  13402. * @return {TextTrackObject}
  13403. * @method addTextTrack
  13404. */
  13405. Tech.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  13406. if (!kind) {
  13407. throw new Error('TextTrack kind is required but was not provided');
  13408. }
  13409. return createTrackHelper(this, kind, label, language);
  13410. };
  13411. /**
  13412. * Creates a remote text track object and returns a emulated html track element
  13413. *
  13414. * @param {Object} options The object should contain values for
  13415. * kind, language, label and src (location of the WebVTT file)
  13416. * @return {HTMLTrackElement}
  13417. * @method addRemoteTextTrack
  13418. */
  13419. Tech.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  13420. var track = _utilsMergeOptionsJs2['default'](options, {
  13421. tech: this
  13422. });
  13423. var htmlTrackElement = new _tracksHtmlTrackElement2['default'](track);
  13424. // store HTMLTrackElement and TextTrack to remote list
  13425. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
  13426. this.remoteTextTracks().addTrack_(htmlTrackElement.track);
  13427. // must come after remoteTextTracks()
  13428. this.textTracks().addTrack_(htmlTrackElement.track);
  13429. return htmlTrackElement;
  13430. };
  13431. /**
  13432. * Remove remote texttrack
  13433. *
  13434. * @param {TextTrackObject} track Texttrack to remove
  13435. * @method removeRemoteTextTrack
  13436. */
  13437. Tech.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  13438. this.textTracks().removeTrack_(track);
  13439. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
  13440. // remove HTMLTrackElement and TextTrack from remote list
  13441. this.remoteTextTrackEls().removeTrackElement_(trackElement);
  13442. this.remoteTextTracks().removeTrack_(track);
  13443. };
  13444. /**
  13445. * Provide a default setPoster method for techs
  13446. * Poster support for techs should be optional, so we don't want techs to
  13447. * break if they don't have a way to set a poster.
  13448. *
  13449. * @method setPoster
  13450. */
  13451. Tech.prototype.setPoster = function setPoster() { };
  13452. /*
  13453. * Check if the tech can support the given type
  13454. *
  13455. * The base tech does not support any type, but source handlers might
  13456. * overwrite this.
  13457. *
  13458. * @param {String} type The mimetype to check
  13459. * @return {String} 'probably', 'maybe', or '' (empty string)
  13460. */
  13461. Tech.prototype.canPlayType = function canPlayType() {
  13462. return '';
  13463. };
  13464. /*
  13465. * Return whether the argument is a Tech or not.
  13466. * Can be passed either a Class like `Html5` or a instance like `player.tech_`
  13467. *
  13468. * @param {Object} component An item to check
  13469. * @return {Boolean} Whether it is a tech or not
  13470. */
  13471. Tech.isTech = function isTech(component) {
  13472. return component.prototype instanceof Tech || component instanceof Tech || component === Tech;
  13473. };
  13474. /**
  13475. * Registers a Tech
  13476. *
  13477. * @param {String} name Name of the Tech to register
  13478. * @param {Object} tech The tech to register
  13479. * @static
  13480. * @method registerComponent
  13481. */
  13482. Tech.registerTech = function registerTech(name, tech) {
  13483. if (!Tech.techs_) {
  13484. Tech.techs_ = {};
  13485. }
  13486. if (!Tech.isTech(tech)) {
  13487. throw new Error('Tech ' + name + ' must be a Tech');
  13488. }
  13489. Tech.techs_[name] = tech;
  13490. return tech;
  13491. };
  13492. /**
  13493. * Gets a component by name
  13494. *
  13495. * @param {String} name Name of the component to get
  13496. * @return {Component}
  13497. * @static
  13498. * @method getComponent
  13499. */
  13500. Tech.getTech = function getTech(name) {
  13501. if (Tech.techs_ && Tech.techs_[name]) {
  13502. return Tech.techs_[name];
  13503. }
  13504. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  13505. _utilsLogJs2['default'].warn('The ' + name + ' tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)');
  13506. return _globalWindow2['default'].videojs[name];
  13507. }
  13508. };
  13509. return Tech;
  13510. })(_component2['default']);
  13511. Tech.prototype.textTracks_;
  13512. /**
  13513. * List of associated audio tracks
  13514. *
  13515. * @type {AudioTrackList}
  13516. * @private
  13517. */
  13518. Tech.prototype.audioTracks_;
  13519. /**
  13520. * List of associated video tracks
  13521. *
  13522. * @type {VideoTrackList}
  13523. * @private
  13524. */
  13525. Tech.prototype.videoTracks_;
  13526. var createTrackHelper = function createTrackHelper(self, kind, label, language) {
  13527. var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4];
  13528. var tracks = self.textTracks();
  13529. options.kind = kind;
  13530. if (label) {
  13531. options.label = label;
  13532. }
  13533. if (language) {
  13534. options.language = language;
  13535. }
  13536. options.tech = self;
  13537. var track = new _tracksTextTrack2['default'](options);
  13538. tracks.addTrack_(track);
  13539. return track;
  13540. };
  13541. Tech.prototype.featuresVolumeControl = true;
  13542. // Resizing plugins using request fullscreen reloads the plugin
  13543. Tech.prototype.featuresFullscreenResize = false;
  13544. Tech.prototype.featuresPlaybackRate = false;
  13545. // Optional events that we can manually mimic with timers
  13546. // currently not triggered by video-js-swf
  13547. Tech.prototype.featuresProgressEvents = false;
  13548. Tech.prototype.featuresTimeupdateEvents = false;
  13549. Tech.prototype.featuresNativeTextTracks = false;
  13550. /*
  13551. * A functional mixin for techs that want to use the Source Handler pattern.
  13552. *
  13553. * ##### EXAMPLE:
  13554. *
  13555. * Tech.withSourceHandlers.call(MyTech);
  13556. *
  13557. */
  13558. Tech.withSourceHandlers = function (_Tech) {
  13559. /*
  13560. * Register a source handler
  13561. * Source handlers are scripts for handling specific formats.
  13562. * The source handler pattern is used for adaptive formats (HLS, DASH) that
  13563. * manually load video data and feed it into a Source Buffer (Media Source Extensions)
  13564. * @param {Function} handler The source handler
  13565. * @param {Boolean} first Register it before any existing handlers
  13566. */
  13567. _Tech.registerSourceHandler = function (handler, index) {
  13568. var handlers = _Tech.sourceHandlers;
  13569. if (!handlers) {
  13570. handlers = _Tech.sourceHandlers = [];
  13571. }
  13572. if (index === undefined) {
  13573. // add to the end of the list
  13574. index = handlers.length;
  13575. }
  13576. handlers.splice(index, 0, handler);
  13577. };
  13578. /*
  13579. * Check if the tech can support the given type
  13580. * @param {String} type The mimetype to check
  13581. * @return {String} 'probably', 'maybe', or '' (empty string)
  13582. */
  13583. _Tech.canPlayType = function (type) {
  13584. var handlers = _Tech.sourceHandlers || [];
  13585. var can = undefined;
  13586. for (var i = 0; i < handlers.length; i++) {
  13587. can = handlers[i].canPlayType(type);
  13588. if (can) {
  13589. return can;
  13590. }
  13591. }
  13592. return '';
  13593. };
  13594. /*
  13595. * Return the first source handler that supports the source
  13596. * TODO: Answer question: should 'probably' be prioritized over 'maybe'
  13597. * @param {Object} source The source object
  13598. * @returns {Object} The first source handler that supports the source
  13599. * @returns {null} Null if no source handler is found
  13600. */
  13601. _Tech.selectSourceHandler = function (source) {
  13602. var handlers = _Tech.sourceHandlers || [];
  13603. var can = undefined;
  13604. for (var i = 0; i < handlers.length; i++) {
  13605. can = handlers[i].canHandleSource(source);
  13606. if (can) {
  13607. return handlers[i];
  13608. }
  13609. }
  13610. return null;
  13611. };
  13612. /*
  13613. * Check if the tech can support the given source
  13614. * @param {Object} srcObj The source object
  13615. * @return {String} 'probably', 'maybe', or '' (empty string)
  13616. */
  13617. _Tech.canPlaySource = function (srcObj) {
  13618. var sh = _Tech.selectSourceHandler(srcObj);
  13619. if (sh) {
  13620. return sh.canHandleSource(srcObj);
  13621. }
  13622. return '';
  13623. };
  13624. /*
  13625. * When using a source handler, prefer its implementation of
  13626. * any function normally provided by the tech.
  13627. */
  13628. var deferrable = ['seekable', 'duration'];
  13629. deferrable.forEach(function (fnName) {
  13630. var originalFn = this[fnName];
  13631. if (typeof originalFn !== 'function') {
  13632. return;
  13633. }
  13634. this[fnName] = function () {
  13635. if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
  13636. return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments);
  13637. }
  13638. return originalFn.apply(this, arguments);
  13639. };
  13640. }, _Tech.prototype);
  13641. /*
  13642. * Create a function for setting the source using a source object
  13643. * and source handlers.
  13644. * Should never be called unless a source handler was found.
  13645. * @param {Object} source A source object with src and type keys
  13646. * @return {Tech} self
  13647. */
  13648. _Tech.prototype.setSource = function (source) {
  13649. var sh = _Tech.selectSourceHandler(source);
  13650. if (!sh) {
  13651. // Fall back to a native source hander when unsupported sources are
  13652. // deliberately set
  13653. if (_Tech.nativeSourceHandler) {
  13654. sh = _Tech.nativeSourceHandler;
  13655. } else {
  13656. _utilsLogJs2['default'].error('No source hander found for the current source.');
  13657. }
  13658. }
  13659. // Dispose any existing source handler
  13660. this.disposeSourceHandler();
  13661. this.off('dispose', this.disposeSourceHandler);
  13662. // if we have a source and get another one
  13663. // then we are loading something new
  13664. // than clear all of our current tracks
  13665. if (this.currentSource_) {
  13666. this.clearTracks(['audio', 'video']);
  13667. this.currentSource_ = null;
  13668. }
  13669. if (sh !== _Tech.nativeSourceHandler) {
  13670. this.currentSource_ = source;
  13671. // Catch if someone replaced the src without calling setSource.
  13672. // If they do, set currentSource_ to null and dispose our source handler.
  13673. this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
  13674. this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13675. this.one(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
  13676. }
  13677. this.sourceHandler_ = sh.handleSource(source, this, this.options_);
  13678. this.on('dispose', this.disposeSourceHandler);
  13679. return this;
  13680. };
  13681. // On the first loadstart after setSource
  13682. _Tech.prototype.firstLoadStartListener_ = function () {
  13683. this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13684. };
  13685. // On successive loadstarts when setSource has not been called again
  13686. _Tech.prototype.successiveLoadStartListener_ = function () {
  13687. this.currentSource_ = null;
  13688. this.disposeSourceHandler();
  13689. this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13690. };
  13691. /*
  13692. * Clean up any existing source handler
  13693. */
  13694. _Tech.prototype.disposeSourceHandler = function () {
  13695. if (this.sourceHandler_ && this.sourceHandler_.dispose) {
  13696. this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
  13697. this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13698. this.sourceHandler_.dispose();
  13699. }
  13700. };
  13701. };
  13702. _component2['default'].registerComponent('Tech', Tech);
  13703. // Old name for Tech
  13704. _component2['default'].registerComponent('MediaTechController', Tech);
  13705. Tech.registerTech('Tech', Tech);
  13706. exports['default'] = Tech;
  13707. module.exports = exports['default'];
  13708. }, { "../component": 67, "../media-error.js": 108, "../tracks/audio-track": 126, "../tracks/audio-track-list": 125, "../tracks/html-track-element": 128, "../tracks/html-track-element-list": 127, "../tracks/text-track": 134, "../tracks/text-track-list": 132, "../tracks/video-track": 139, "../tracks/video-track-list": 138, "../utils/buffer.js": 141, "../utils/fn.js": 145, "../utils/log.js": 148, "../utils/merge-options.js": 149, "../utils/time-ranges.js": 151, "global/document": 1, "global/window": 2 }], 125: [function (_dereq_, module, exports) {
  13709. /**
  13710. * @file audio-track-list.js
  13711. */
  13712. 'use strict';
  13713. exports.__esModule = true;
  13714. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  13715. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13716. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13717. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  13718. var _trackList = _dereq_('./track-list');
  13719. var _trackList2 = _interopRequireDefault(_trackList);
  13720. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  13721. var browser = _interopRequireWildcard(_utilsBrowserJs);
  13722. var _globalDocument = _dereq_('global/document');
  13723. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13724. /**
  13725. * anywhere we call this function we diverge from the spec
  13726. * as we only support one enabled audiotrack at a time
  13727. *
  13728. * @param {Array|AudioTrackList} list list to work on
  13729. * @param {AudioTrack} track the track to skip
  13730. */
  13731. var disableOthers = function disableOthers(list, track) {
  13732. for (var i = 0; i < list.length; i++) {
  13733. if (track.id === list[i].id) {
  13734. continue;
  13735. }
  13736. // another audio track is enabled, disable it
  13737. list[i].enabled = false;
  13738. }
  13739. };
  13740. /**
  13741. * A list of possible audio tracks. All functionality is in the
  13742. * base class Tracklist and the spec for AudioTrackList is located at:
  13743. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist
  13744. *
  13745. * interface AudioTrackList : EventTarget {
  13746. * readonly attribute unsigned long length;
  13747. * getter AudioTrack (unsigned long index);
  13748. * AudioTrack? getTrackById(DOMString id);
  13749. *
  13750. * attribute EventHandler onchange;
  13751. * attribute EventHandler onaddtrack;
  13752. * attribute EventHandler onremovetrack;
  13753. * };
  13754. *
  13755. * @param {AudioTrack[]} tracks a list of audio tracks to instantiate the list with
  13756. * @extends TrackList
  13757. * @class AudioTrackList
  13758. */
  13759. var AudioTrackList = (function (_TrackList) {
  13760. _inherits(AudioTrackList, _TrackList);
  13761. function AudioTrackList() {
  13762. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  13763. _classCallCheck(this, AudioTrackList);
  13764. var list = undefined;
  13765. // make sure only 1 track is enabled
  13766. // sorted from last index to first index
  13767. for (var i = tracks.length - 1; i >= 0; i--) {
  13768. if (tracks[i].enabled) {
  13769. disableOthers(tracks, tracks[i]);
  13770. break;
  13771. }
  13772. }
  13773. // IE8 forces us to implement inheritance ourselves
  13774. // as it does not support Object.defineProperty properly
  13775. if (browser.IS_IE8) {
  13776. list = _globalDocument2['default'].createElement('custom');
  13777. for (var prop in _trackList2['default'].prototype) {
  13778. if (prop !== 'constructor') {
  13779. list[prop] = _trackList2['default'].prototype[prop];
  13780. }
  13781. }
  13782. for (var prop in AudioTrackList.prototype) {
  13783. if (prop !== 'constructor') {
  13784. list[prop] = AudioTrackList.prototype[prop];
  13785. }
  13786. }
  13787. }
  13788. list = _TrackList.call(this, tracks, list);
  13789. list.changing_ = false;
  13790. return list;
  13791. }
  13792. AudioTrackList.prototype.addTrack_ = function addTrack_(track) {
  13793. var _this = this;
  13794. if (track.enabled) {
  13795. disableOthers(this, track);
  13796. }
  13797. _TrackList.prototype.addTrack_.call(this, track);
  13798. // native tracks don't have this
  13799. if (!track.addEventListener) {
  13800. return;
  13801. }
  13802. track.addEventListener('enabledchange', function () {
  13803. // when we are disabling other tracks (since we don't support
  13804. // more than one track at a time) we will set changing_
  13805. // to true so that we don't trigger additional change events
  13806. if (_this.changing_) {
  13807. return;
  13808. }
  13809. _this.changing_ = true;
  13810. disableOthers(_this, track);
  13811. _this.changing_ = false;
  13812. _this.trigger('change');
  13813. });
  13814. };
  13815. AudioTrackList.prototype.addTrack = function addTrack(track) {
  13816. this.addTrack_(track);
  13817. };
  13818. AudioTrackList.prototype.removeTrack = function removeTrack(track) {
  13819. _TrackList.prototype.removeTrack_.call(this, track);
  13820. };
  13821. return AudioTrackList;
  13822. })(_trackList2['default']);
  13823. exports['default'] = AudioTrackList;
  13824. module.exports = exports['default'];
  13825. }, { "../utils/browser.js": 140, "./track-list": 136, "global/document": 1 }], 126: [function (_dereq_, module, exports) {
  13826. 'use strict';
  13827. exports.__esModule = true;
  13828. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  13829. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13830. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13831. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  13832. var _trackEnums = _dereq_('./track-enums');
  13833. var _track = _dereq_('./track');
  13834. var _track2 = _interopRequireDefault(_track);
  13835. var _utilsMergeOptions = _dereq_('../utils/merge-options');
  13836. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  13837. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  13838. var browser = _interopRequireWildcard(_utilsBrowserJs);
  13839. /**
  13840. * A single audio text track as defined in:
  13841. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack
  13842. *
  13843. * interface AudioTrack {
  13844. * readonly attribute DOMString id;
  13845. * readonly attribute DOMString kind;
  13846. * readonly attribute DOMString label;
  13847. * readonly attribute DOMString language;
  13848. * attribute boolean enabled;
  13849. * };
  13850. *
  13851. * @param {Object=} options Object of option names and values
  13852. * @class AudioTrack
  13853. */
  13854. var AudioTrack = (function (_Track) {
  13855. _inherits(AudioTrack, _Track);
  13856. function AudioTrack() {
  13857. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  13858. _classCallCheck(this, AudioTrack);
  13859. var settings = _utilsMergeOptions2['default'](options, {
  13860. kind: _trackEnums.AudioTrackKind[options.kind] || ''
  13861. });
  13862. // on IE8 this will be a document element
  13863. // for every other browser this will be a normal object
  13864. var track = _Track.call(this, settings);
  13865. var enabled = false;
  13866. if (browser.IS_IE8) {
  13867. for (var prop in AudioTrack.prototype) {
  13868. if (prop !== 'constructor') {
  13869. track[prop] = AudioTrack.prototype[prop];
  13870. }
  13871. }
  13872. }
  13873. Object.defineProperty(track, 'enabled', {
  13874. get: function get() {
  13875. return enabled;
  13876. },
  13877. set: function set(newEnabled) {
  13878. // an invalid or unchanged value
  13879. if (typeof newEnabled !== 'boolean' || newEnabled === enabled) {
  13880. return;
  13881. }
  13882. enabled = newEnabled;
  13883. this.trigger('enabledchange');
  13884. }
  13885. });
  13886. // if the user sets this track to selected then
  13887. // set selected to that true value otherwise
  13888. // we keep it false
  13889. if (settings.enabled) {
  13890. track.enabled = settings.enabled;
  13891. }
  13892. track.loaded_ = true;
  13893. return track;
  13894. }
  13895. return AudioTrack;
  13896. })(_track2['default']);
  13897. exports['default'] = AudioTrack;
  13898. module.exports = exports['default'];
  13899. }, { "../utils/browser.js": 140, "../utils/merge-options": 149, "./track": 137, "./track-enums": 135 }], 127: [function (_dereq_, module, exports) {
  13900. /**
  13901. * @file html-track-element-list.js
  13902. */
  13903. 'use strict';
  13904. exports.__esModule = true;
  13905. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13906. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  13907. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13908. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  13909. var browser = _interopRequireWildcard(_utilsBrowserJs);
  13910. var _globalDocument = _dereq_('global/document');
  13911. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13912. var HtmlTrackElementList = (function () {
  13913. function HtmlTrackElementList() {
  13914. var trackElements = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  13915. _classCallCheck(this, HtmlTrackElementList);
  13916. var list = this;
  13917. if (browser.IS_IE8) {
  13918. list = _globalDocument2['default'].createElement('custom');
  13919. for (var prop in HtmlTrackElementList.prototype) {
  13920. if (prop !== 'constructor') {
  13921. list[prop] = HtmlTrackElementList.prototype[prop];
  13922. }
  13923. }
  13924. }
  13925. list.trackElements_ = [];
  13926. Object.defineProperty(list, 'length', {
  13927. get: function get() {
  13928. return this.trackElements_.length;
  13929. }
  13930. });
  13931. for (var i = 0, _length = trackElements.length; i < _length; i++) {
  13932. list.addTrackElement_(trackElements[i]);
  13933. }
  13934. if (browser.IS_IE8) {
  13935. return list;
  13936. }
  13937. }
  13938. HtmlTrackElementList.prototype.addTrackElement_ = function addTrackElement_(trackElement) {
  13939. this.trackElements_.push(trackElement);
  13940. };
  13941. HtmlTrackElementList.prototype.getTrackElementByTrack_ = function getTrackElementByTrack_(track) {
  13942. var trackElement_ = undefined;
  13943. for (var i = 0, _length2 = this.trackElements_.length; i < _length2; i++) {
  13944. if (track === this.trackElements_[i].track) {
  13945. trackElement_ = this.trackElements_[i];
  13946. break;
  13947. }
  13948. }
  13949. return trackElement_;
  13950. };
  13951. HtmlTrackElementList.prototype.removeTrackElement_ = function removeTrackElement_(trackElement) {
  13952. for (var i = 0, _length3 = this.trackElements_.length; i < _length3; i++) {
  13953. if (trackElement === this.trackElements_[i]) {
  13954. this.trackElements_.splice(i, 1);
  13955. break;
  13956. }
  13957. }
  13958. };
  13959. return HtmlTrackElementList;
  13960. })();
  13961. exports['default'] = HtmlTrackElementList;
  13962. module.exports = exports['default'];
  13963. }, { "../utils/browser.js": 140, "global/document": 1 }], 128: [function (_dereq_, module, exports) {
  13964. /**
  13965. * @file html-track-element.js
  13966. */
  13967. 'use strict';
  13968. exports.__esModule = true;
  13969. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13970. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  13971. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13972. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  13973. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  13974. var browser = _interopRequireWildcard(_utilsBrowserJs);
  13975. var _globalDocument = _dereq_('global/document');
  13976. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13977. var _eventTarget = _dereq_('../event-target');
  13978. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  13979. var _tracksTextTrack = _dereq_('../tracks/text-track');
  13980. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack);
  13981. var NONE = 0;
  13982. var LOADING = 1;
  13983. var LOADED = 2;
  13984. var ERROR = 3;
  13985. /**
  13986. * https://html.spec.whatwg.org/multipage/embedded-content.html#htmltrackelement
  13987. *
  13988. * interface HTMLTrackElement : HTMLElement {
  13989. * attribute DOMString kind;
  13990. * attribute DOMString src;
  13991. * attribute DOMString srclang;
  13992. * attribute DOMString label;
  13993. * attribute boolean default;
  13994. *
  13995. * const unsigned short NONE = 0;
  13996. * const unsigned short LOADING = 1;
  13997. * const unsigned short LOADED = 2;
  13998. * const unsigned short ERROR = 3;
  13999. * readonly attribute unsigned short readyState;
  14000. *
  14001. * readonly attribute TextTrack track;
  14002. * };
  14003. *
  14004. * @param {Object} options TextTrack configuration
  14005. * @class HTMLTrackElement
  14006. */
  14007. var HTMLTrackElement = (function (_EventTarget) {
  14008. _inherits(HTMLTrackElement, _EventTarget);
  14009. function HTMLTrackElement() {
  14010. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  14011. _classCallCheck(this, HTMLTrackElement);
  14012. _EventTarget.call(this);
  14013. var readyState = undefined,
  14014. trackElement = this;
  14015. if (browser.IS_IE8) {
  14016. trackElement = _globalDocument2['default'].createElement('custom');
  14017. for (var prop in HTMLTrackElement.prototype) {
  14018. if (prop !== 'constructor') {
  14019. trackElement[prop] = HTMLTrackElement.prototype[prop];
  14020. }
  14021. }
  14022. }
  14023. var track = new _tracksTextTrack2['default'](options);
  14024. trackElement.kind = track.kind;
  14025. trackElement.src = track.src;
  14026. trackElement.srclang = track.language;
  14027. trackElement.label = track.label;
  14028. trackElement['default'] = track['default'];
  14029. Object.defineProperty(trackElement, 'readyState', {
  14030. get: function get() {
  14031. return readyState;
  14032. }
  14033. });
  14034. Object.defineProperty(trackElement, 'track', {
  14035. get: function get() {
  14036. return track;
  14037. }
  14038. });
  14039. readyState = NONE;
  14040. track.addEventListener('loadeddata', function () {
  14041. readyState = LOADED;
  14042. trackElement.trigger({
  14043. type: 'load',
  14044. target: trackElement
  14045. });
  14046. });
  14047. if (browser.IS_IE8) {
  14048. return trackElement;
  14049. }
  14050. }
  14051. return HTMLTrackElement;
  14052. })(_eventTarget2['default']);
  14053. HTMLTrackElement.prototype.allowedEvents_ = {
  14054. load: 'load'
  14055. };
  14056. HTMLTrackElement.NONE = NONE;
  14057. HTMLTrackElement.LOADING = LOADING;
  14058. HTMLTrackElement.LOADED = LOADED;
  14059. HTMLTrackElement.ERROR = ERROR;
  14060. exports['default'] = HTMLTrackElement;
  14061. module.exports = exports['default'];
  14062. }, { "../event-target": 104, "../tracks/text-track": 134, "../utils/browser.js": 140, "global/document": 1 }], 129: [function (_dereq_, module, exports) {
  14063. /**
  14064. * @file text-track-cue-list.js
  14065. */
  14066. 'use strict';
  14067. exports.__esModule = true;
  14068. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14069. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  14070. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14071. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14072. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14073. var _globalDocument = _dereq_('global/document');
  14074. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14075. /**
  14076. * A List of text track cues as defined in:
  14077. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist
  14078. *
  14079. * interface TextTrackCueList {
  14080. * readonly attribute unsigned long length;
  14081. * getter TextTrackCue (unsigned long index);
  14082. * TextTrackCue? getCueById(DOMString id);
  14083. * };
  14084. *
  14085. * @param {Array} cues A list of cues to be initialized with
  14086. * @class TextTrackCueList
  14087. */
  14088. var TextTrackCueList = (function () {
  14089. function TextTrackCueList(cues) {
  14090. _classCallCheck(this, TextTrackCueList);
  14091. var list = this;
  14092. if (browser.IS_IE8) {
  14093. list = _globalDocument2['default'].createElement('custom');
  14094. for (var prop in TextTrackCueList.prototype) {
  14095. if (prop !== 'constructor') {
  14096. list[prop] = TextTrackCueList.prototype[prop];
  14097. }
  14098. }
  14099. }
  14100. TextTrackCueList.prototype.setCues_.call(list, cues);
  14101. Object.defineProperty(list, 'length', {
  14102. get: function get() {
  14103. return this.length_;
  14104. }
  14105. });
  14106. if (browser.IS_IE8) {
  14107. return list;
  14108. }
  14109. }
  14110. /**
  14111. * A setter for cues in this list
  14112. *
  14113. * @param {Array} cues an array of cues
  14114. * @method setCues_
  14115. * @private
  14116. */
  14117. TextTrackCueList.prototype.setCues_ = function setCues_(cues) {
  14118. var oldLength = this.length || 0;
  14119. var i = 0;
  14120. var l = cues.length;
  14121. this.cues_ = cues;
  14122. this.length_ = cues.length;
  14123. var defineProp = function defineProp(index) {
  14124. if (!('' + index in this)) {
  14125. Object.defineProperty(this, '' + index, {
  14126. get: function get() {
  14127. return this.cues_[index];
  14128. }
  14129. });
  14130. }
  14131. };
  14132. if (oldLength < l) {
  14133. i = oldLength;
  14134. for (; i < l; i++) {
  14135. defineProp.call(this, i);
  14136. }
  14137. }
  14138. };
  14139. /**
  14140. * Get a cue that is currently in the Cue list by id
  14141. *
  14142. * @param {String} id
  14143. * @method getCueById
  14144. * @return {Object} a single cue
  14145. */
  14146. TextTrackCueList.prototype.getCueById = function getCueById(id) {
  14147. var result = null;
  14148. for (var i = 0, l = this.length; i < l; i++) {
  14149. var cue = this[i];
  14150. if (cue.id === id) {
  14151. result = cue;
  14152. break;
  14153. }
  14154. }
  14155. return result;
  14156. };
  14157. return TextTrackCueList;
  14158. })();
  14159. exports['default'] = TextTrackCueList;
  14160. module.exports = exports['default'];
  14161. }, { "../utils/browser.js": 140, "global/document": 1 }], 130: [function (_dereq_, module, exports) {
  14162. /**
  14163. * @file text-track-display.js
  14164. */
  14165. 'use strict';
  14166. exports.__esModule = true;
  14167. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  14168. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14169. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14170. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14171. var _component = _dereq_('../component');
  14172. var _component2 = _interopRequireDefault(_component);
  14173. var _menuMenuJs = _dereq_('../menu/menu.js');
  14174. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  14175. var _menuMenuItemJs = _dereq_('../menu/menu-item.js');
  14176. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  14177. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js');
  14178. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  14179. var _utilsFnJs = _dereq_('../utils/fn.js');
  14180. var Fn = _interopRequireWildcard(_utilsFnJs);
  14181. var _globalDocument = _dereq_('global/document');
  14182. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14183. var _globalWindow = _dereq_('global/window');
  14184. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  14185. var darkGray = '#222';
  14186. var lightGray = '#ccc';
  14187. var fontMap = {
  14188. monospace: 'monospace',
  14189. sansSerif: 'sans-serif',
  14190. serif: 'serif',
  14191. monospaceSansSerif: '"Andale Mono", "Lucida Console", monospace',
  14192. monospaceSerif: '"Courier New", monospace',
  14193. proportionalSansSerif: 'sans-serif',
  14194. proportionalSerif: 'serif',
  14195. casual: '"Comic Sans MS", Impact, fantasy',
  14196. script: '"Monotype Corsiva", cursive',
  14197. smallcaps: '"Andale Mono", "Lucida Console", monospace, sans-serif'
  14198. };
  14199. /**
  14200. * The component for displaying text track cues
  14201. *
  14202. * @param {Object} player Main Player
  14203. * @param {Object=} options Object of option names and values
  14204. * @param {Function=} ready Ready callback function
  14205. * @extends Component
  14206. * @class TextTrackDisplay
  14207. */
  14208. var TextTrackDisplay = (function (_Component) {
  14209. _inherits(TextTrackDisplay, _Component);
  14210. function TextTrackDisplay(player, options, ready) {
  14211. _classCallCheck(this, TextTrackDisplay);
  14212. _Component.call(this, player, options, ready);
  14213. player.on('loadstart', Fn.bind(this, this.toggleDisplay));
  14214. player.on('texttrackchange', Fn.bind(this, this.updateDisplay));
  14215. // This used to be called during player init, but was causing an error
  14216. // if a track should show by default and the display hadn't loaded yet.
  14217. // Should probably be moved to an external track loader when we support
  14218. // tracks that don't need a display.
  14219. player.ready(Fn.bind(this, function () {
  14220. if (player.tech_ && player.tech_['featuresNativeTextTracks']) {
  14221. this.hide();
  14222. return;
  14223. }
  14224. player.on('fullscreenchange', Fn.bind(this, this.updateDisplay));
  14225. var tracks = this.options_.playerOptions['tracks'] || [];
  14226. for (var i = 0; i < tracks.length; i++) {
  14227. var track = tracks[i];
  14228. this.player_.addRemoteTextTrack(track);
  14229. }
  14230. var modes = { 'captions': 1, 'subtitles': 1 };
  14231. var trackList = this.player_.textTracks();
  14232. var firstDesc = undefined;
  14233. var firstCaptions = undefined;
  14234. if (trackList) {
  14235. for (var i = 0; i < trackList.length; i++) {
  14236. var track = trackList[i];
  14237. if (track['default']) {
  14238. if (track.kind === 'descriptions' && !firstDesc) {
  14239. firstDesc = track;
  14240. } else if (track.kind in modes && !firstCaptions) {
  14241. firstCaptions = track;
  14242. }
  14243. }
  14244. }
  14245. // We want to show the first default track but captions and subtitles
  14246. // take precedence over descriptions.
  14247. // So, display the first default captions or subtitles track
  14248. // and otherwise the first default descriptions track.
  14249. if (firstCaptions) {
  14250. firstCaptions.mode = 'showing';
  14251. } else if (firstDesc) {
  14252. firstDesc.mode = 'showing';
  14253. }
  14254. }
  14255. }));
  14256. }
  14257. /**
  14258. * Add cue HTML to display
  14259. *
  14260. * @param {Number} color Hex number for color, like #f0e
  14261. * @param {Number} opacity Value for opacity,0.0 - 1.0
  14262. * @return {RGBAColor} In the form 'rgba(255, 0, 0, 0.3)'
  14263. * @method constructColor
  14264. */
  14265. /**
  14266. * Toggle display texttracks
  14267. *
  14268. * @method toggleDisplay
  14269. */
  14270. TextTrackDisplay.prototype.toggleDisplay = function toggleDisplay() {
  14271. if (this.player_.tech_ && this.player_.tech_['featuresNativeTextTracks']) {
  14272. this.hide();
  14273. } else {
  14274. this.show();
  14275. }
  14276. };
  14277. /**
  14278. * Create the component's DOM element
  14279. *
  14280. * @return {Element}
  14281. * @method createEl
  14282. */
  14283. TextTrackDisplay.prototype.createEl = function createEl() {
  14284. return _Component.prototype.createEl.call(this, 'div', {
  14285. className: 'vjs-text-track-display'
  14286. }, {
  14287. 'aria-live': 'assertive',
  14288. 'aria-atomic': 'true'
  14289. });
  14290. };
  14291. /**
  14292. * Clear display texttracks
  14293. *
  14294. * @method clearDisplay
  14295. */
  14296. TextTrackDisplay.prototype.clearDisplay = function clearDisplay() {
  14297. if (typeof _globalWindow2['default']['WebVTT'] === 'function') {
  14298. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], [], this.el_);
  14299. }
  14300. };
  14301. /**
  14302. * Update display texttracks
  14303. *
  14304. * @method updateDisplay
  14305. */
  14306. TextTrackDisplay.prototype.updateDisplay = function updateDisplay() {
  14307. var tracks = this.player_.textTracks();
  14308. this.clearDisplay();
  14309. if (!tracks) {
  14310. return;
  14311. }
  14312. // Track display prioritization model: if multiple tracks are 'showing',
  14313. // display the first 'subtitles' or 'captions' track which is 'showing',
  14314. // otherwise display the first 'descriptions' track which is 'showing'
  14315. var descriptionsTrack = null;
  14316. var captionsSubtitlesTrack = null;
  14317. var i = tracks.length;
  14318. while (i--) {
  14319. var track = tracks[i];
  14320. if (track['mode'] === 'showing') {
  14321. if (track['kind'] === 'descriptions') {
  14322. descriptionsTrack = track;
  14323. } else {
  14324. captionsSubtitlesTrack = track;
  14325. }
  14326. }
  14327. }
  14328. if (captionsSubtitlesTrack) {
  14329. this.updateForTrack(captionsSubtitlesTrack);
  14330. } else if (descriptionsTrack) {
  14331. this.updateForTrack(descriptionsTrack);
  14332. }
  14333. };
  14334. /**
  14335. * Add texttrack to texttrack list
  14336. *
  14337. * @param {TextTrackObject} track Texttrack object to be added to list
  14338. * @method updateForTrack
  14339. */
  14340. TextTrackDisplay.prototype.updateForTrack = function updateForTrack(track) {
  14341. if (typeof _globalWindow2['default']['WebVTT'] !== 'function' || !track['activeCues']) {
  14342. return;
  14343. }
  14344. var overrides = this.player_['textTrackSettings'].getValues();
  14345. var cues = [];
  14346. for (var _i = 0; _i < track['activeCues'].length; _i++) {
  14347. cues.push(track['activeCues'][_i]);
  14348. }
  14349. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], cues, this.el_);
  14350. var i = cues.length;
  14351. while (i--) {
  14352. var cue = cues[i];
  14353. if (!cue) {
  14354. continue;
  14355. }
  14356. var cueDiv = cue.displayState;
  14357. if (overrides.color) {
  14358. cueDiv.firstChild.style.color = overrides.color;
  14359. }
  14360. if (overrides.textOpacity) {
  14361. tryUpdateStyle(cueDiv.firstChild, 'color', constructColor(overrides.color || '#fff', overrides.textOpacity));
  14362. }
  14363. if (overrides.backgroundColor) {
  14364. cueDiv.firstChild.style.backgroundColor = overrides.backgroundColor;
  14365. }
  14366. if (overrides.backgroundOpacity) {
  14367. tryUpdateStyle(cueDiv.firstChild, 'backgroundColor', constructColor(overrides.backgroundColor || '#000', overrides.backgroundOpacity));
  14368. }
  14369. if (overrides.windowColor) {
  14370. if (overrides.windowOpacity) {
  14371. tryUpdateStyle(cueDiv, 'backgroundColor', constructColor(overrides.windowColor, overrides.windowOpacity));
  14372. } else {
  14373. cueDiv.style.backgroundColor = overrides.windowColor;
  14374. }
  14375. }
  14376. if (overrides.edgeStyle) {
  14377. if (overrides.edgeStyle === 'dropshadow') {
  14378. cueDiv.firstChild.style.textShadow = '2px 2px 3px ' + darkGray + ', 2px 2px 4px ' + darkGray + ', 2px 2px 5px ' + darkGray;
  14379. } else if (overrides.edgeStyle === 'raised') {
  14380. cueDiv.firstChild.style.textShadow = '1px 1px ' + darkGray + ', 2px 2px ' + darkGray + ', 3px 3px ' + darkGray;
  14381. } else if (overrides.edgeStyle === 'depressed') {
  14382. cueDiv.firstChild.style.textShadow = '1px 1px ' + lightGray + ', 0 1px ' + lightGray + ', -1px -1px ' + darkGray + ', 0 -1px ' + darkGray;
  14383. } else if (overrides.edgeStyle === 'uniform') {
  14384. cueDiv.firstChild.style.textShadow = '0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray;
  14385. }
  14386. }
  14387. if (overrides.fontPercent && overrides.fontPercent !== 1) {
  14388. var fontSize = _globalWindow2['default'].parseFloat(cueDiv.style.fontSize);
  14389. cueDiv.style.fontSize = fontSize * overrides.fontPercent + 'px';
  14390. cueDiv.style.height = 'auto';
  14391. cueDiv.style.top = 'auto';
  14392. cueDiv.style.bottom = '2px';
  14393. }
  14394. if (overrides.fontFamily && overrides.fontFamily !== 'default') {
  14395. if (overrides.fontFamily === 'small-caps') {
  14396. cueDiv.firstChild.style.fontVariant = 'small-caps';
  14397. } else {
  14398. cueDiv.firstChild.style.fontFamily = fontMap[overrides.fontFamily];
  14399. }
  14400. }
  14401. }
  14402. };
  14403. return TextTrackDisplay;
  14404. })(_component2['default']);
  14405. function constructColor(color, opacity) {
  14406. return 'rgba(' +
  14407. // color looks like "#f0e"
  14408. parseInt(color[1] + color[1], 16) + ',' + parseInt(color[2] + color[2], 16) + ',' + parseInt(color[3] + color[3], 16) + ',' + opacity + ')';
  14409. }
  14410. /**
  14411. * Try to update style
  14412. * Some style changes will throw an error, particularly in IE8. Those should be noops.
  14413. *
  14414. * @param {Element} el The element to be styles
  14415. * @param {CSSProperty} style The CSS property to be styled
  14416. * @param {CSSStyle} rule The actual style to be applied to the property
  14417. * @method tryUpdateStyle
  14418. */
  14419. function tryUpdateStyle(el, style, rule) {
  14420. //
  14421. try {
  14422. el.style[style] = rule;
  14423. } catch (e) { }
  14424. }
  14425. _component2['default'].registerComponent('TextTrackDisplay', TextTrackDisplay);
  14426. exports['default'] = TextTrackDisplay;
  14427. module.exports = exports['default'];
  14428. }, { "../component": 67, "../menu/menu-button.js": 109, "../menu/menu-item.js": 110, "../menu/menu.js": 111, "../utils/fn.js": 145, "global/document": 1, "global/window": 2 }], 131: [function (_dereq_, module, exports) {
  14429. /**
  14430. * Utilities for capturing text track state and re-creating tracks
  14431. * based on a capture.
  14432. *
  14433. * @file text-track-list-converter.js
  14434. */
  14435. /**
  14436. * Examine a single text track and return a JSON-compatible javascript
  14437. * object that represents the text track's state.
  14438. * @param track {TextTrackObject} the text track to query
  14439. * @return {Object} a serializable javascript representation of the
  14440. * @private
  14441. */
  14442. 'use strict';
  14443. exports.__esModule = true;
  14444. var trackToJson_ = function trackToJson_(track) {
  14445. var ret = ['kind', 'label', 'language', 'id', 'inBandMetadataTrackDispatchType', 'mode', 'src'].reduce(function (acc, prop, i) {
  14446. if (track[prop]) {
  14447. acc[prop] = track[prop];
  14448. }
  14449. return acc;
  14450. }, {
  14451. cues: track.cues && Array.prototype.map.call(track.cues, function (cue) {
  14452. return {
  14453. startTime: cue.startTime,
  14454. endTime: cue.endTime,
  14455. text: cue.text,
  14456. id: cue.id
  14457. };
  14458. })
  14459. });
  14460. return ret;
  14461. };
  14462. /**
  14463. * Examine a tech and return a JSON-compatible javascript array that
  14464. * represents the state of all text tracks currently configured. The
  14465. * return array is compatible with `jsonToTextTracks`.
  14466. * @param tech {tech} the tech object to query
  14467. * @return {Array} a serializable javascript representation of the
  14468. * @function textTracksToJson
  14469. */
  14470. var textTracksToJson = function textTracksToJson(tech) {
  14471. var trackEls = tech.$$('track');
  14472. var trackObjs = Array.prototype.map.call(trackEls, function (t) {
  14473. return t.track;
  14474. });
  14475. var tracks = Array.prototype.map.call(trackEls, function (trackEl) {
  14476. var json = trackToJson_(trackEl.track);
  14477. if (trackEl.src) {
  14478. json.src = trackEl.src;
  14479. }
  14480. return json;
  14481. });
  14482. return tracks.concat(Array.prototype.filter.call(tech.textTracks(), function (track) {
  14483. return trackObjs.indexOf(track) === -1;
  14484. }).map(trackToJson_));
  14485. };
  14486. /**
  14487. * Creates a set of remote text tracks on a tech based on an array of
  14488. * javascript text track representations.
  14489. * @param json {Array} an array of text track representation objects,
  14490. * like those that would be produced by `textTracksToJson`
  14491. * @param tech {tech} the tech to create text tracks on
  14492. * @function jsonToTextTracks
  14493. */
  14494. var jsonToTextTracks = function jsonToTextTracks(json, tech) {
  14495. json.forEach(function (track) {
  14496. var addedTrack = tech.addRemoteTextTrack(track).track;
  14497. if (!track.src && track.cues) {
  14498. track.cues.forEach(function (cue) {
  14499. return addedTrack.addCue(cue);
  14500. });
  14501. }
  14502. });
  14503. return tech.textTracks();
  14504. };
  14505. exports['default'] = { textTracksToJson: textTracksToJson, jsonToTextTracks: jsonToTextTracks, trackToJson_: trackToJson_ };
  14506. module.exports = exports['default'];
  14507. }, {}], 132: [function (_dereq_, module, exports) {
  14508. /**
  14509. * @file text-track-list.js
  14510. */
  14511. 'use strict';
  14512. exports.__esModule = true;
  14513. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  14514. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14515. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14516. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14517. var _trackList = _dereq_('./track-list');
  14518. var _trackList2 = _interopRequireDefault(_trackList);
  14519. var _utilsFnJs = _dereq_('../utils/fn.js');
  14520. var Fn = _interopRequireWildcard(_utilsFnJs);
  14521. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14522. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14523. var _globalDocument = _dereq_('global/document');
  14524. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14525. /**
  14526. * A list of possible text tracks. All functionality is in the
  14527. * base class TrackList. The spec for TextTrackList is located at:
  14528. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#texttracklist
  14529. *
  14530. * interface TextTrackList : EventTarget {
  14531. * readonly attribute unsigned long length;
  14532. * getter TextTrack (unsigned long index);
  14533. * TextTrack? getTrackById(DOMString id);
  14534. *
  14535. * attribute EventHandler onchange;
  14536. * attribute EventHandler onaddtrack;
  14537. * attribute EventHandler onremovetrack;
  14538. * };
  14539. *
  14540. * @param {TextTrack[]} tracks A list of tracks to initialize the list with
  14541. * @extends TrackList
  14542. * @class TextTrackList
  14543. */
  14544. var TextTrackList = (function (_TrackList) {
  14545. _inherits(TextTrackList, _TrackList);
  14546. function TextTrackList() {
  14547. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  14548. _classCallCheck(this, TextTrackList);
  14549. var list = undefined;
  14550. // IE8 forces us to implement inheritance ourselves
  14551. // as it does not support Object.defineProperty properly
  14552. if (browser.IS_IE8) {
  14553. list = _globalDocument2['default'].createElement('custom');
  14554. for (var prop in _trackList2['default'].prototype) {
  14555. if (prop !== 'constructor') {
  14556. list[prop] = _trackList2['default'].prototype[prop];
  14557. }
  14558. }
  14559. for (var prop in TextTrackList.prototype) {
  14560. if (prop !== 'constructor') {
  14561. list[prop] = TextTrackList.prototype[prop];
  14562. }
  14563. }
  14564. }
  14565. list = _TrackList.call(this, tracks, list);
  14566. return list;
  14567. }
  14568. TextTrackList.prototype.addTrack_ = function addTrack_(track) {
  14569. _TrackList.prototype.addTrack_.call(this, track);
  14570. track.addEventListener('modechange', Fn.bind(this, function () {
  14571. this.trigger('change');
  14572. }));
  14573. };
  14574. /**
  14575. * Remove TextTrack from TextTrackList
  14576. * NOTE: Be mindful of what is passed in as it may be a HTMLTrackElement
  14577. *
  14578. * @param {TextTrack} rtrack
  14579. * @method removeTrack_
  14580. * @private
  14581. */
  14582. TextTrackList.prototype.removeTrack_ = function removeTrack_(rtrack) {
  14583. var track = undefined;
  14584. for (var i = 0, l = this.length; i < l; i++) {
  14585. if (this[i] === rtrack) {
  14586. track = this[i];
  14587. if (track.off) {
  14588. track.off();
  14589. }
  14590. this.tracks_.splice(i, 1);
  14591. break;
  14592. }
  14593. }
  14594. if (!track) {
  14595. return;
  14596. }
  14597. this.trigger({
  14598. track: track,
  14599. type: 'removetrack'
  14600. });
  14601. };
  14602. /**
  14603. * Get a TextTrack from TextTrackList by a tracks id
  14604. *
  14605. * @param {String} id - the id of the track to get
  14606. * @method getTrackById
  14607. * @return {TextTrack}
  14608. * @private
  14609. */
  14610. TextTrackList.prototype.getTrackById = function getTrackById(id) {
  14611. var result = null;
  14612. for (var i = 0, l = this.length; i < l; i++) {
  14613. var track = this[i];
  14614. if (track.id === id) {
  14615. result = track;
  14616. break;
  14617. }
  14618. }
  14619. return result;
  14620. };
  14621. return TextTrackList;
  14622. })(_trackList2['default']);
  14623. exports['default'] = TextTrackList;
  14624. module.exports = exports['default'];
  14625. }, { "../utils/browser.js": 140, "../utils/fn.js": 145, "./track-list": 136, "global/document": 1 }], 133: [function (_dereq_, module, exports) {
  14626. /**
  14627. * @file text-track-settings.js
  14628. */
  14629. 'use strict';
  14630. exports.__esModule = true;
  14631. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  14632. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14633. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14634. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14635. var _component = _dereq_('../component');
  14636. var _component2 = _interopRequireDefault(_component);
  14637. var _utilsEventsJs = _dereq_('../utils/events.js');
  14638. var Events = _interopRequireWildcard(_utilsEventsJs);
  14639. var _utilsFnJs = _dereq_('../utils/fn.js');
  14640. var Fn = _interopRequireWildcard(_utilsFnJs);
  14641. var _utilsLogJs = _dereq_('../utils/log.js');
  14642. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  14643. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple');
  14644. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple);
  14645. var _globalWindow = _dereq_('global/window');
  14646. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  14647. /**
  14648. * Manipulate settings of texttracks
  14649. *
  14650. * @param {Object} player Main Player
  14651. * @param {Object=} options Object of option names and values
  14652. * @extends Component
  14653. * @class TextTrackSettings
  14654. */
  14655. var TextTrackSettings = (function (_Component) {
  14656. _inherits(TextTrackSettings, _Component);
  14657. function TextTrackSettings(player, options) {
  14658. _classCallCheck(this, TextTrackSettings);
  14659. _Component.call(this, player, options);
  14660. this.hide();
  14661. // Grab `persistTextTrackSettings` from the player options if not passed in child options
  14662. if (options.persistTextTrackSettings === undefined) {
  14663. this.options_.persistTextTrackSettings = this.options_.playerOptions.persistTextTrackSettings;
  14664. }
  14665. Events.on(this.$('.vjs-done-button'), 'click', Fn.bind(this, function () {
  14666. this.saveSettings();
  14667. this.hide();
  14668. }));
  14669. Events.on(this.$('.vjs-default-button'), 'click', Fn.bind(this, function () {
  14670. this.$('.vjs-fg-color > select').selectedIndex = 0;
  14671. this.$('.vjs-bg-color > select').selectedIndex = 0;
  14672. this.$('.window-color > select').selectedIndex = 0;
  14673. this.$('.vjs-text-opacity > select').selectedIndex = 0;
  14674. this.$('.vjs-bg-opacity > select').selectedIndex = 0;
  14675. this.$('.vjs-window-opacity > select').selectedIndex = 0;
  14676. this.$('.vjs-edge-style select').selectedIndex = 0;
  14677. this.$('.vjs-font-family select').selectedIndex = 0;
  14678. this.$('.vjs-font-percent select').selectedIndex = 2;
  14679. this.updateDisplay();
  14680. }));
  14681. Events.on(this.$('.vjs-fg-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  14682. Events.on(this.$('.vjs-bg-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  14683. Events.on(this.$('.window-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  14684. Events.on(this.$('.vjs-text-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  14685. Events.on(this.$('.vjs-bg-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  14686. Events.on(this.$('.vjs-window-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  14687. Events.on(this.$('.vjs-font-percent select'), 'change', Fn.bind(this, this.updateDisplay));
  14688. Events.on(this.$('.vjs-edge-style select'), 'change', Fn.bind(this, this.updateDisplay));
  14689. Events.on(this.$('.vjs-font-family select'), 'change', Fn.bind(this, this.updateDisplay));
  14690. if (this.options_.persistTextTrackSettings) {
  14691. this.restoreSettings();
  14692. }
  14693. }
  14694. /**
  14695. * Create the component's DOM element
  14696. *
  14697. * @return {Element}
  14698. * @method createEl
  14699. */
  14700. TextTrackSettings.prototype.createEl = function createEl() {
  14701. return _Component.prototype.createEl.call(this, 'div', {
  14702. className: 'vjs-caption-settings vjs-modal-overlay',
  14703. innerHTML: captionOptionsMenuTemplate()
  14704. });
  14705. };
  14706. /**
  14707. * Get texttrack settings
  14708. * Settings are
  14709. * .vjs-edge-style
  14710. * .vjs-font-family
  14711. * .vjs-fg-color
  14712. * .vjs-text-opacity
  14713. * .vjs-bg-color
  14714. * .vjs-bg-opacity
  14715. * .window-color
  14716. * .vjs-window-opacity
  14717. *
  14718. * @return {Object}
  14719. * @method getValues
  14720. */
  14721. TextTrackSettings.prototype.getValues = function getValues() {
  14722. var textEdge = getSelectedOptionValue(this.$('.vjs-edge-style select'));
  14723. var fontFamily = getSelectedOptionValue(this.$('.vjs-font-family select'));
  14724. var fgColor = getSelectedOptionValue(this.$('.vjs-fg-color > select'));
  14725. var textOpacity = getSelectedOptionValue(this.$('.vjs-text-opacity > select'));
  14726. var bgColor = getSelectedOptionValue(this.$('.vjs-bg-color > select'));
  14727. var bgOpacity = getSelectedOptionValue(this.$('.vjs-bg-opacity > select'));
  14728. var windowColor = getSelectedOptionValue(this.$('.window-color > select'));
  14729. var windowOpacity = getSelectedOptionValue(this.$('.vjs-window-opacity > select'));
  14730. var fontPercent = _globalWindow2['default']['parseFloat'](getSelectedOptionValue(this.$('.vjs-font-percent > select')));
  14731. var result = {
  14732. 'backgroundOpacity': bgOpacity,
  14733. 'textOpacity': textOpacity,
  14734. 'windowOpacity': windowOpacity,
  14735. 'edgeStyle': textEdge,
  14736. 'fontFamily': fontFamily,
  14737. 'color': fgColor,
  14738. 'backgroundColor': bgColor,
  14739. 'windowColor': windowColor,
  14740. 'fontPercent': fontPercent
  14741. };
  14742. for (var _name in result) {
  14743. if (result[_name] === '' || result[_name] === 'none' || _name === 'fontPercent' && result[_name] === 1.00) {
  14744. delete result[_name];
  14745. }
  14746. }
  14747. return result;
  14748. };
  14749. /**
  14750. * Set texttrack settings
  14751. * Settings are
  14752. * .vjs-edge-style
  14753. * .vjs-font-family
  14754. * .vjs-fg-color
  14755. * .vjs-text-opacity
  14756. * .vjs-bg-color
  14757. * .vjs-bg-opacity
  14758. * .window-color
  14759. * .vjs-window-opacity
  14760. *
  14761. * @param {Object} values Object with texttrack setting values
  14762. * @method setValues
  14763. */
  14764. TextTrackSettings.prototype.setValues = function setValues(values) {
  14765. setSelectedOption(this.$('.vjs-edge-style select'), values.edgeStyle);
  14766. setSelectedOption(this.$('.vjs-font-family select'), values.fontFamily);
  14767. setSelectedOption(this.$('.vjs-fg-color > select'), values.color);
  14768. setSelectedOption(this.$('.vjs-text-opacity > select'), values.textOpacity);
  14769. setSelectedOption(this.$('.vjs-bg-color > select'), values.backgroundColor);
  14770. setSelectedOption(this.$('.vjs-bg-opacity > select'), values.backgroundOpacity);
  14771. setSelectedOption(this.$('.window-color > select'), values.windowColor);
  14772. setSelectedOption(this.$('.vjs-window-opacity > select'), values.windowOpacity);
  14773. var fontPercent = values.fontPercent;
  14774. if (fontPercent) {
  14775. fontPercent = fontPercent.toFixed(2);
  14776. }
  14777. setSelectedOption(this.$('.vjs-font-percent > select'), fontPercent);
  14778. };
  14779. /**
  14780. * Restore texttrack settings
  14781. *
  14782. * @method restoreSettings
  14783. */
  14784. TextTrackSettings.prototype.restoreSettings = function restoreSettings() {
  14785. var err = undefined,
  14786. values = undefined;
  14787. try {
  14788. var _safeParseTuple = _safeJsonParseTuple2['default'](_globalWindow2['default'].localStorage.getItem('vjs-text-track-settings'));
  14789. err = _safeParseTuple[0];
  14790. values = _safeParseTuple[1];
  14791. if (err) {
  14792. _utilsLogJs2['default'].error(err);
  14793. }
  14794. } catch (e) {
  14795. _utilsLogJs2['default'].warn(e);
  14796. }
  14797. if (values) {
  14798. this.setValues(values);
  14799. }
  14800. };
  14801. /**
  14802. * Save texttrack settings to local storage
  14803. *
  14804. * @method saveSettings
  14805. */
  14806. TextTrackSettings.prototype.saveSettings = function saveSettings() {
  14807. if (!this.options_.persistTextTrackSettings) {
  14808. return;
  14809. }
  14810. var values = this.getValues();
  14811. try {
  14812. if (Object.getOwnPropertyNames(values).length > 0) {
  14813. _globalWindow2['default'].localStorage.setItem('vjs-text-track-settings', JSON.stringify(values));
  14814. } else {
  14815. _globalWindow2['default'].localStorage.removeItem('vjs-text-track-settings');
  14816. }
  14817. } catch (e) {
  14818. _utilsLogJs2['default'].warn(e);
  14819. }
  14820. };
  14821. /**
  14822. * Update display of texttrack settings
  14823. *
  14824. * @method updateDisplay
  14825. */
  14826. TextTrackSettings.prototype.updateDisplay = function updateDisplay() {
  14827. var ttDisplay = this.player_.getChild('textTrackDisplay');
  14828. if (ttDisplay) {
  14829. ttDisplay.updateDisplay();
  14830. }
  14831. };
  14832. return TextTrackSettings;
  14833. })(_component2['default']);
  14834. _component2['default'].registerComponent('TextTrackSettings', TextTrackSettings);
  14835. function getSelectedOptionValue(target) {
  14836. var selectedOption = undefined;
  14837. // not all browsers support selectedOptions, so, fallback to options
  14838. if (target.selectedOptions) {
  14839. selectedOption = target.selectedOptions[0];
  14840. } else if (target.options) {
  14841. selectedOption = target.options[target.options.selectedIndex];
  14842. }
  14843. return selectedOption.value;
  14844. }
  14845. function setSelectedOption(target, value) {
  14846. if (!value) {
  14847. return;
  14848. }
  14849. var i = undefined;
  14850. for (i = 0; i < target.options.length; i++) {
  14851. var option = target.options[i];
  14852. if (option.value === value) {
  14853. break;
  14854. }
  14855. }
  14856. target.selectedIndex = i;
  14857. }
  14858. function captionOptionsMenuTemplate() {
  14859. var template = '<div class="vjs-tracksettings">\n <div class="vjs-tracksettings-colors">\n <div class="vjs-fg-color vjs-tracksetting">\n <label class="vjs-label">Foreground</label>\n <select>\n <option value="">---</option>\n <option value="#FFF">White</option>\n <option value="#000">Black</option>\n <option value="#F00">Red</option>\n <option value="#0F0">Green</option>\n <option value="#00F">Blue</option>\n <option value="#FF0">Yellow</option>\n <option value="#F0F">Magenta</option>\n <option value="#0FF">Cyan</option>\n </select>\n <span class="vjs-text-opacity vjs-opacity">\n <select>\n <option value="">---</option>\n <option value="1">Opaque</option>\n <option value="0.5">Semi-Opaque</option>\n </select>\n </span>\n </div> <!-- vjs-fg-color -->\n <div class="vjs-bg-color vjs-tracksetting">\n <label class="vjs-label">Background</label>\n <select>\n <option value="">---</option>\n <option value="#FFF">White</option>\n <option value="#000">Black</option>\n <option value="#F00">Red</option>\n <option value="#0F0">Green</option>\n <option value="#00F">Blue</option>\n <option value="#FF0">Yellow</option>\n <option value="#F0F">Magenta</option>\n <option value="#0FF">Cyan</option>\n </select>\n <span class="vjs-bg-opacity vjs-opacity">\n <select>\n <option value="">---</option>\n <option value="1">Opaque</option>\n <option value="0.5">Semi-Transparent</option>\n <option value="0">Transparent</option>\n </select>\n </span>\n </div> <!-- vjs-bg-color -->\n <div class="window-color vjs-tracksetting">\n <label class="vjs-label">Window</label>\n <select>\n <option value="">---</option>\n <option value="#FFF">White</option>\n <option value="#000">Black</option>\n <option value="#F00">Red</option>\n <option value="#0F0">Green</option>\n <option value="#00F">Blue</option>\n <option value="#FF0">Yellow</option>\n <option value="#F0F">Magenta</option>\n <option value="#0FF">Cyan</option>\n </select>\n <span class="vjs-window-opacity vjs-opacity">\n <select>\n <option value="">---</option>\n <option value="1">Opaque</option>\n <option value="0.5">Semi-Transparent</option>\n <option value="0">Transparent</option>\n </select>\n </span>\n </div> <!-- vjs-window-color -->\n </div> <!-- vjs-tracksettings -->\n <div class="vjs-tracksettings-font">\n <div class="vjs-font-percent vjs-tracksetting">\n <label class="vjs-label">Font Size</label>\n <select>\n <option value="0.50">50%</option>\n <option value="0.75">75%</option>\n <option value="1.00" selected>100%</option>\n <option value="1.25">125%</option>\n <option value="1.50">150%</option>\n <option value="1.75">175%</option>\n <option value="2.00">200%</option>\n <option value="3.00">300%</option>\n <option value="4.00">400%</option>\n </select>\n </div> <!-- vjs-font-percent -->\n <div class="vjs-edge-style vjs-tracksetting">\n <label class="vjs-label">Text Edge Style</label>\n <select>\n <option value="none">None</option>\n <option value="raised">Raised</option>\n <option value="depressed">Depressed</option>\n <option value="uniform">Uniform</option>\n <option value="dropshadow">Dropshadow</option>\n </select>\n </div> <!-- vjs-edge-style -->\n <div class="vjs-font-family vjs-tracksetting">\n <label class="vjs-label">Font Family</label>\n <select>\n <option value="">Default</option>\n <option value="monospaceSerif">Monospace Serif</option>\n <option value="proportionalSerif">Proportional Serif</option>\n <option value="monospaceSansSerif">Monospace Sans-Serif</option>\n <option value="proportionalSansSerif">Proportional Sans-Serif</option>\n <option value="casual">Casual</option>\n <option value="script">Script</option>\n <option value="small-caps">Small Caps</option>\n </select>\n </div> <!-- vjs-font-family -->\n </div>\n </div>\n <div class="vjs-tracksettings-controls">\n <button class="vjs-default-button">Defaults</button>\n <button class="vjs-done-button">Done</button>\n </div>';
  14860. return template;
  14861. }
  14862. exports['default'] = TextTrackSettings;
  14863. module.exports = exports['default'];
  14864. }, { "../component": 67, "../utils/events.js": 144, "../utils/fn.js": 145, "../utils/log.js": 148, "global/window": 2, "safe-json-parse/tuple": 54 }], 134: [function (_dereq_, module, exports) {
  14865. /**
  14866. * @file text-track.js
  14867. */
  14868. 'use strict';
  14869. exports.__esModule = true;
  14870. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  14871. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14872. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14873. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  14874. var _textTrackCueList = _dereq_('./text-track-cue-list');
  14875. var _textTrackCueList2 = _interopRequireDefault(_textTrackCueList);
  14876. var _utilsFnJs = _dereq_('../utils/fn.js');
  14877. var Fn = _interopRequireWildcard(_utilsFnJs);
  14878. var _trackEnums = _dereq_('./track-enums');
  14879. var _utilsLogJs = _dereq_('../utils/log.js');
  14880. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  14881. var _globalDocument = _dereq_('global/document');
  14882. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14883. var _globalWindow = _dereq_('global/window');
  14884. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  14885. var _trackJs = _dereq_('./track.js');
  14886. var _trackJs2 = _interopRequireDefault(_trackJs);
  14887. var _utilsUrlJs = _dereq_('../utils/url.js');
  14888. var _xhr = _dereq_('xhr');
  14889. var _xhr2 = _interopRequireDefault(_xhr);
  14890. var _utilsMergeOptions = _dereq_('../utils/merge-options');
  14891. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  14892. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14893. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14894. /**
  14895. * takes a webvtt file contents and parses it into cues
  14896. *
  14897. * @param {String} srcContent webVTT file contents
  14898. * @param {Track} track track to addcues to
  14899. */
  14900. var parseCues = function parseCues(srcContent, track) {
  14901. var parser = new _globalWindow2['default'].WebVTT.Parser(_globalWindow2['default'], _globalWindow2['default'].vttjs, _globalWindow2['default'].WebVTT.StringDecoder());
  14902. var errors = [];
  14903. parser.oncue = function (cue) {
  14904. track.addCue(cue);
  14905. };
  14906. parser.onparsingerror = function (error) {
  14907. errors.push(error);
  14908. };
  14909. parser.onflush = function () {
  14910. track.trigger({
  14911. type: 'loadeddata',
  14912. target: track
  14913. });
  14914. };
  14915. parser.parse(srcContent);
  14916. if (errors.length > 0) {
  14917. if (console.groupCollapsed) {
  14918. console.groupCollapsed('Text Track parsing errors for ' + track.src);
  14919. }
  14920. errors.forEach(function (error) {
  14921. return _utilsLogJs2['default'].error(error);
  14922. });
  14923. if (console.groupEnd) {
  14924. console.groupEnd();
  14925. }
  14926. }
  14927. parser.flush();
  14928. };
  14929. /**
  14930. * load a track from a specifed url
  14931. *
  14932. * @param {String} src url to load track from
  14933. * @param {Track} track track to addcues to
  14934. */
  14935. var loadTrack = function loadTrack(src, track) {
  14936. var opts = {
  14937. uri: src
  14938. };
  14939. var crossOrigin = _utilsUrlJs.isCrossOrigin(src);
  14940. if (crossOrigin) {
  14941. opts.cors = crossOrigin;
  14942. }
  14943. _xhr2['default'](opts, Fn.bind(this, function (err, response, responseBody) {
  14944. if (err) {
  14945. return _utilsLogJs2['default'].error(err, response);
  14946. }
  14947. track.loaded_ = true;
  14948. // Make sure that vttjs has loaded, otherwise, wait till it finished loading
  14949. // NOTE: this is only used for the alt/video.novtt.js build
  14950. if (typeof _globalWindow2['default'].WebVTT !== 'function') {
  14951. if (track.tech_) {
  14952. (function () {
  14953. var loadHandler = function loadHandler() {
  14954. return parseCues(responseBody, track);
  14955. };
  14956. track.tech_.on('vttjsloaded', loadHandler);
  14957. track.tech_.on('vttjserror', function () {
  14958. _utilsLogJs2['default'].error('vttjs failed to load, stopping trying to process ' + track.src);
  14959. track.tech_.off('vttjsloaded', loadHandler);
  14960. });
  14961. })();
  14962. }
  14963. } else {
  14964. parseCues(responseBody, track);
  14965. }
  14966. }));
  14967. };
  14968. /**
  14969. * A single text track as defined in:
  14970. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrack
  14971. *
  14972. * interface TextTrack : EventTarget {
  14973. * readonly attribute TextTrackKind kind;
  14974. * readonly attribute DOMString label;
  14975. * readonly attribute DOMString language;
  14976. *
  14977. * readonly attribute DOMString id;
  14978. * readonly attribute DOMString inBandMetadataTrackDispatchType;
  14979. *
  14980. * attribute TextTrackMode mode;
  14981. *
  14982. * readonly attribute TextTrackCueList? cues;
  14983. * readonly attribute TextTrackCueList? activeCues;
  14984. *
  14985. * void addCue(TextTrackCue cue);
  14986. * void removeCue(TextTrackCue cue);
  14987. *
  14988. * attribute EventHandler oncuechange;
  14989. * };
  14990. *
  14991. * @param {Object=} options Object of option names and values
  14992. * @extends Track
  14993. * @class TextTrack
  14994. */
  14995. var TextTrack = (function (_Track) {
  14996. _inherits(TextTrack, _Track);
  14997. function TextTrack() {
  14998. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  14999. _classCallCheck(this, TextTrack);
  15000. if (!options.tech) {
  15001. throw new Error('A tech was not provided.');
  15002. }
  15003. var settings = _utilsMergeOptions2['default'](options, {
  15004. kind: _trackEnums.TextTrackKind[options.kind] || 'subtitles',
  15005. language: options.language || options.srclang || ''
  15006. });
  15007. var mode = _trackEnums.TextTrackMode[settings.mode] || 'disabled';
  15008. var default_ = settings['default'];
  15009. if (settings.kind === 'metadata' || settings.kind === 'chapters') {
  15010. mode = 'hidden';
  15011. }
  15012. // on IE8 this will be a document element
  15013. // for every other browser this will be a normal object
  15014. var tt = _Track.call(this, settings);
  15015. tt.tech_ = settings.tech;
  15016. if (browser.IS_IE8) {
  15017. for (var prop in TextTrack.prototype) {
  15018. if (prop !== 'constructor') {
  15019. tt[prop] = TextTrack.prototype[prop];
  15020. }
  15021. }
  15022. }
  15023. tt.cues_ = [];
  15024. tt.activeCues_ = [];
  15025. var cues = new _textTrackCueList2['default'](tt.cues_);
  15026. var activeCues = new _textTrackCueList2['default'](tt.activeCues_);
  15027. var changed = false;
  15028. var timeupdateHandler = Fn.bind(tt, function () {
  15029. this.activeCues;
  15030. if (changed) {
  15031. this.trigger('cuechange');
  15032. changed = false;
  15033. }
  15034. });
  15035. if (mode !== 'disabled') {
  15036. tt.tech_.on('timeupdate', timeupdateHandler);
  15037. }
  15038. Object.defineProperty(tt, 'default', {
  15039. get: function get() {
  15040. return default_;
  15041. },
  15042. set: function set() { }
  15043. });
  15044. Object.defineProperty(tt, 'mode', {
  15045. get: function get() {
  15046. return mode;
  15047. },
  15048. set: function set(newMode) {
  15049. if (!_trackEnums.TextTrackMode[newMode]) {
  15050. return;
  15051. }
  15052. mode = newMode;
  15053. if (mode === 'showing') {
  15054. this.tech_.on('timeupdate', timeupdateHandler);
  15055. }
  15056. this.trigger('modechange');
  15057. }
  15058. });
  15059. Object.defineProperty(tt, 'cues', {
  15060. get: function get() {
  15061. if (!this.loaded_) {
  15062. return null;
  15063. }
  15064. return cues;
  15065. },
  15066. set: function set() { }
  15067. });
  15068. Object.defineProperty(tt, 'activeCues', {
  15069. get: function get() {
  15070. if (!this.loaded_) {
  15071. return null;
  15072. }
  15073. // nothing to do
  15074. if (this.cues.length === 0) {
  15075. return activeCues;
  15076. }
  15077. var ct = this.tech_.currentTime();
  15078. var active = [];
  15079. for (var i = 0, l = this.cues.length; i < l; i++) {
  15080. var cue = this.cues[i];
  15081. if (cue.startTime <= ct && cue.endTime >= ct) {
  15082. active.push(cue);
  15083. } else if (cue.startTime === cue.endTime && cue.startTime <= ct && cue.startTime + 0.5 >= ct) {
  15084. active.push(cue);
  15085. }
  15086. }
  15087. changed = false;
  15088. if (active.length !== this.activeCues_.length) {
  15089. changed = true;
  15090. } else {
  15091. for (var i = 0; i < active.length; i++) {
  15092. if (this.activeCues_.indexOf(active[i]) === -1) {
  15093. changed = true;
  15094. }
  15095. }
  15096. }
  15097. this.activeCues_ = active;
  15098. activeCues.setCues_(this.activeCues_);
  15099. return activeCues;
  15100. },
  15101. set: function set() { }
  15102. });
  15103. if (settings.src) {
  15104. tt.src = settings.src;
  15105. loadTrack(settings.src, tt);
  15106. } else {
  15107. tt.loaded_ = true;
  15108. }
  15109. return tt;
  15110. }
  15111. /**
  15112. * cuechange - One or more cues in the track have become active or stopped being active.
  15113. */
  15114. /**
  15115. * add a cue to the internal list of cues
  15116. *
  15117. * @param {Object} cue the cue to add to our internal list
  15118. * @method addCue
  15119. */
  15120. TextTrack.prototype.addCue = function addCue(cue) {
  15121. var tracks = this.tech_.textTracks();
  15122. if (tracks) {
  15123. for (var i = 0; i < tracks.length; i++) {
  15124. if (tracks[i] !== this) {
  15125. tracks[i].removeCue(cue);
  15126. }
  15127. }
  15128. }
  15129. this.cues_.push(cue);
  15130. this.cues.setCues_(this.cues_);
  15131. };
  15132. /**
  15133. * remvoe a cue from our internal list
  15134. *
  15135. * @param {Object} removeCue the cue to remove from our internal list
  15136. * @method removeCue
  15137. */
  15138. TextTrack.prototype.removeCue = function removeCue(_removeCue) {
  15139. var removed = false;
  15140. for (var i = 0, l = this.cues_.length; i < l; i++) {
  15141. var cue = this.cues_[i];
  15142. if (cue === _removeCue) {
  15143. this.cues_.splice(i, 1);
  15144. removed = true;
  15145. }
  15146. }
  15147. if (removed) {
  15148. this.cues.setCues_(this.cues_);
  15149. }
  15150. };
  15151. return TextTrack;
  15152. })(_trackJs2['default']);
  15153. TextTrack.prototype.allowedEvents_ = {
  15154. cuechange: 'cuechange'
  15155. };
  15156. exports['default'] = TextTrack;
  15157. module.exports = exports['default'];
  15158. }, { "../utils/browser.js": 140, "../utils/fn.js": 145, "../utils/log.js": 148, "../utils/merge-options": 149, "../utils/url.js": 153, "./text-track-cue-list": 129, "./track-enums": 135, "./track.js": 137, "global/document": 1, "global/window": 2, "xhr": 56 }], 135: [function (_dereq_, module, exports) {
  15159. /**
  15160. * @file track-kinds.js
  15161. */
  15162. /**
  15163. * https://html.spec.whatwg.org/multipage/embedded-content.html#dom-videotrack-kind
  15164. *
  15165. * enum VideoTrackKind {
  15166. * "alternative",
  15167. * "captions",
  15168. * "main",
  15169. * "sign",
  15170. * "subtitles",
  15171. * "commentary",
  15172. * "",
  15173. * };
  15174. */
  15175. 'use strict';
  15176. exports.__esModule = true;
  15177. var VideoTrackKind = {
  15178. alternative: 'alternative',
  15179. captions: 'captions',
  15180. main: 'main',
  15181. sign: 'sign',
  15182. subtitles: 'subtitles',
  15183. commentary: 'commentary'
  15184. };
  15185. /**
  15186. * https://html.spec.whatwg.org/multipage/embedded-content.html#dom-audiotrack-kind
  15187. *
  15188. * enum AudioTrackKind {
  15189. * "alternative",
  15190. * "descriptions",
  15191. * "main",
  15192. * "main-desc",
  15193. * "translation",
  15194. * "commentary",
  15195. * "",
  15196. * };
  15197. */
  15198. var AudioTrackKind = {
  15199. alternative: 'alternative',
  15200. descriptions: 'descriptions',
  15201. main: 'main',
  15202. 'main-desc': 'main-desc',
  15203. translation: 'translation',
  15204. commentary: 'commentary'
  15205. };
  15206. /**
  15207. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackkind
  15208. *
  15209. * enum TextTrackKind {
  15210. * "subtitles",
  15211. * "captions",
  15212. * "descriptions",
  15213. * "chapters",
  15214. * "metadata"
  15215. * };
  15216. */
  15217. var TextTrackKind = {
  15218. subtitles: 'subtitles',
  15219. captions: 'captions',
  15220. descriptions: 'descriptions',
  15221. chapters: 'chapters',
  15222. metadata: 'metadata'
  15223. };
  15224. /**
  15225. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackmode
  15226. *
  15227. * enum TextTrackMode { "disabled", "hidden", "showing" };
  15228. */
  15229. var TextTrackMode = {
  15230. disabled: 'disabled',
  15231. hidden: 'hidden',
  15232. showing: 'showing'
  15233. };
  15234. /* jshint ignore:start */
  15235. // we ignore jshint here because it does not see
  15236. // AudioTrackKind as defined here
  15237. exports['default'] = { VideoTrackKind: VideoTrackKind, AudioTrackKind: AudioTrackKind, TextTrackKind: TextTrackKind, TextTrackMode: TextTrackMode };
  15238. /* jshint ignore:end */
  15239. module.exports = exports['default'];
  15240. }, {}], 136: [function (_dereq_, module, exports) {
  15241. /**
  15242. * @file track-list.js
  15243. */
  15244. 'use strict';
  15245. exports.__esModule = true;
  15246. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  15247. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15248. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15249. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  15250. var _eventTarget = _dereq_('../event-target');
  15251. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  15252. var _utilsFnJs = _dereq_('../utils/fn.js');
  15253. var Fn = _interopRequireWildcard(_utilsFnJs);
  15254. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15255. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15256. var _globalDocument = _dereq_('global/document');
  15257. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15258. /**
  15259. * Common functionaliy between Text, Audio, and Video TrackLists
  15260. * Interfaces defined in the following spec:
  15261. * @link https://html.spec.whatwg.org/multipage/embedded-content.html
  15262. *
  15263. * @param {Track[]} tracks A list of tracks to initialize the list with
  15264. * @param {Object} list the child object with inheritance done manually for ie8
  15265. * @extends EventTarget
  15266. * @class TrackList
  15267. */
  15268. var TrackList = (function (_EventTarget) {
  15269. _inherits(TrackList, _EventTarget);
  15270. function TrackList() {
  15271. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  15272. var list = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
  15273. _classCallCheck(this, TrackList);
  15274. _EventTarget.call(this);
  15275. if (!list) {
  15276. list = this;
  15277. if (browser.IS_IE8) {
  15278. list = _globalDocument2['default'].createElement('custom');
  15279. for (var prop in TrackList.prototype) {
  15280. if (prop !== 'constructor') {
  15281. list[prop] = TrackList.prototype[prop];
  15282. }
  15283. }
  15284. }
  15285. }
  15286. list.tracks_ = [];
  15287. Object.defineProperty(list, 'length', {
  15288. get: function get() {
  15289. return this.tracks_.length;
  15290. }
  15291. });
  15292. for (var i = 0; i < tracks.length; i++) {
  15293. list.addTrack_(tracks[i]);
  15294. }
  15295. return list;
  15296. }
  15297. /**
  15298. * change - One or more tracks in the track list have been enabled or disabled.
  15299. * addtrack - A track has been added to the track list.
  15300. * removetrack - A track has been removed from the track list.
  15301. */
  15302. /**
  15303. * Add a Track from TrackList
  15304. *
  15305. * @param {Mixed} track
  15306. * @method addTrack_
  15307. * @private
  15308. */
  15309. TrackList.prototype.addTrack_ = function addTrack_(track) {
  15310. var index = this.tracks_.length;
  15311. if (!('' + index in this)) {
  15312. Object.defineProperty(this, index, {
  15313. get: function get() {
  15314. return this.tracks_[index];
  15315. }
  15316. });
  15317. }
  15318. // Do not add duplicate tracks
  15319. if (this.tracks_.indexOf(track) === -1) {
  15320. this.tracks_.push(track);
  15321. this.trigger({
  15322. track: track,
  15323. type: 'addtrack'
  15324. });
  15325. }
  15326. };
  15327. /**
  15328. * Remove a Track from TrackList
  15329. *
  15330. * @param {Track} rtrack track to be removed
  15331. * @method removeTrack_
  15332. * @private
  15333. */
  15334. TrackList.prototype.removeTrack_ = function removeTrack_(rtrack) {
  15335. var track = undefined;
  15336. for (var i = 0, l = this.length; i < l; i++) {
  15337. if (this[i] === rtrack) {
  15338. track = this[i];
  15339. if (track.off) {
  15340. track.off();
  15341. }
  15342. this.tracks_.splice(i, 1);
  15343. break;
  15344. }
  15345. }
  15346. if (!track) {
  15347. return;
  15348. }
  15349. this.trigger({
  15350. track: track,
  15351. type: 'removetrack'
  15352. });
  15353. };
  15354. /**
  15355. * Get a Track from the TrackList by a tracks id
  15356. *
  15357. * @param {String} id - the id of the track to get
  15358. * @method getTrackById
  15359. * @return {Track}
  15360. * @private
  15361. */
  15362. TrackList.prototype.getTrackById = function getTrackById(id) {
  15363. var result = null;
  15364. for (var i = 0, l = this.length; i < l; i++) {
  15365. var track = this[i];
  15366. if (track.id === id) {
  15367. result = track;
  15368. break;
  15369. }
  15370. }
  15371. return result;
  15372. };
  15373. return TrackList;
  15374. })(_eventTarget2['default']);
  15375. TrackList.prototype.allowedEvents_ = {
  15376. change: 'change',
  15377. addtrack: 'addtrack',
  15378. removetrack: 'removetrack'
  15379. };
  15380. // emulate attribute EventHandler support to allow for feature detection
  15381. for (var _event in TrackList.prototype.allowedEvents_) {
  15382. TrackList.prototype['on' + _event] = null;
  15383. }
  15384. exports['default'] = TrackList;
  15385. module.exports = exports['default'];
  15386. }, { "../event-target": 104, "../utils/browser.js": 140, "../utils/fn.js": 145, "global/document": 1 }], 137: [function (_dereq_, module, exports) {
  15387. /**
  15388. * @file track.js
  15389. */
  15390. 'use strict';
  15391. exports.__esModule = true;
  15392. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15393. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  15394. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15395. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  15396. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15397. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15398. var _globalDocument = _dereq_('global/document');
  15399. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15400. var _utilsGuidJs = _dereq_('../utils/guid.js');
  15401. var Guid = _interopRequireWildcard(_utilsGuidJs);
  15402. var _eventTarget = _dereq_('../event-target');
  15403. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  15404. /**
  15405. * setup the common parts of an audio, video, or text track
  15406. * @link https://html.spec.whatwg.org/multipage/embedded-content.html
  15407. *
  15408. * @param {String} type The type of track we are dealing with audio|video|text
  15409. * @param {Object=} options Object of option names and values
  15410. * @extends EventTarget
  15411. * @class Track
  15412. */
  15413. var Track = (function (_EventTarget) {
  15414. _inherits(Track, _EventTarget);
  15415. function Track() {
  15416. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  15417. _classCallCheck(this, Track);
  15418. _EventTarget.call(this);
  15419. var track = this;
  15420. if (browser.IS_IE8) {
  15421. track = _globalDocument2['default'].createElement('custom');
  15422. for (var prop in Track.prototype) {
  15423. if (prop !== 'constructor') {
  15424. track[prop] = Track.prototype[prop];
  15425. }
  15426. }
  15427. }
  15428. var trackProps = {
  15429. id: options.id || 'vjs_track_' + Guid.newGUID(),
  15430. kind: options.kind || '',
  15431. label: options.label || '',
  15432. language: options.language || ''
  15433. };
  15434. var _loop = function (key) {
  15435. Object.defineProperty(track, key, {
  15436. get: function get() {
  15437. return trackProps[key];
  15438. },
  15439. set: function set() { }
  15440. });
  15441. };
  15442. for (var key in trackProps) {
  15443. _loop(key);
  15444. }
  15445. return track;
  15446. }
  15447. return Track;
  15448. })(_eventTarget2['default']);
  15449. exports['default'] = Track;
  15450. module.exports = exports['default'];
  15451. }, { "../event-target": 104, "../utils/browser.js": 140, "../utils/guid.js": 147, "global/document": 1 }], 138: [function (_dereq_, module, exports) {
  15452. /**
  15453. * @file video-track-list.js
  15454. */
  15455. 'use strict';
  15456. exports.__esModule = true;
  15457. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  15458. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15459. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15460. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  15461. var _trackList = _dereq_('./track-list');
  15462. var _trackList2 = _interopRequireDefault(_trackList);
  15463. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15464. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15465. var _globalDocument = _dereq_('global/document');
  15466. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15467. /**
  15468. * disable other video tracks before selecting the new one
  15469. *
  15470. * @param {Array|VideoTrackList} list list to work on
  15471. * @param {VideoTrack} track the track to skip
  15472. */
  15473. var disableOthers = function disableOthers(list, track) {
  15474. for (var i = 0; i < list.length; i++) {
  15475. if (track.id === list[i].id) {
  15476. continue;
  15477. }
  15478. // another audio track is enabled, disable it
  15479. list[i].selected = false;
  15480. }
  15481. };
  15482. /**
  15483. * A list of possiblee video tracks. Most functionality is in the
  15484. * base class Tracklist and the spec for VideoTrackList is located at:
  15485. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist
  15486. *
  15487. * interface VideoTrackList : EventTarget {
  15488. * readonly attribute unsigned long length;
  15489. * getter VideoTrack (unsigned long index);
  15490. * VideoTrack? getTrackById(DOMString id);
  15491. * readonly attribute long selectedIndex;
  15492. *
  15493. * attribute EventHandler onchange;
  15494. * attribute EventHandler onaddtrack;
  15495. * attribute EventHandler onremovetrack;
  15496. * };
  15497. *
  15498. * @param {VideoTrack[]} tracks a list of video tracks to instantiate the list with
  15499. # @extends TrackList
  15500. * @class VideoTrackList
  15501. */
  15502. var VideoTrackList = (function (_TrackList) {
  15503. _inherits(VideoTrackList, _TrackList);
  15504. function VideoTrackList() {
  15505. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  15506. _classCallCheck(this, VideoTrackList);
  15507. var list = undefined;
  15508. // make sure only 1 track is enabled
  15509. // sorted from last index to first index
  15510. for (var i = tracks.length - 1; i >= 0; i--) {
  15511. if (tracks[i].selected) {
  15512. disableOthers(tracks, tracks[i]);
  15513. break;
  15514. }
  15515. }
  15516. // IE8 forces us to implement inheritance ourselves
  15517. // as it does not support Object.defineProperty properly
  15518. if (browser.IS_IE8) {
  15519. list = _globalDocument2['default'].createElement('custom');
  15520. for (var prop in _trackList2['default'].prototype) {
  15521. if (prop !== 'constructor') {
  15522. list[prop] = _trackList2['default'].prototype[prop];
  15523. }
  15524. }
  15525. for (var prop in VideoTrackList.prototype) {
  15526. if (prop !== 'constructor') {
  15527. list[prop] = VideoTrackList.prototype[prop];
  15528. }
  15529. }
  15530. }
  15531. list = _TrackList.call(this, tracks, list);
  15532. list.changing_ = false;
  15533. Object.defineProperty(list, 'selectedIndex', {
  15534. get: function get() {
  15535. for (var i = 0; i < this.length; i++) {
  15536. if (this[i].selected) {
  15537. return i;
  15538. }
  15539. }
  15540. return -1;
  15541. },
  15542. set: function set() { }
  15543. });
  15544. return list;
  15545. }
  15546. VideoTrackList.prototype.addTrack_ = function addTrack_(track) {
  15547. var _this = this;
  15548. if (track.selected) {
  15549. disableOthers(this, track);
  15550. }
  15551. _TrackList.prototype.addTrack_.call(this, track);
  15552. // native tracks don't have this
  15553. if (!track.addEventListener) {
  15554. return;
  15555. }
  15556. track.addEventListener('selectedchange', function () {
  15557. if (_this.changing_) {
  15558. return;
  15559. }
  15560. _this.changing_ = true;
  15561. disableOthers(_this, track);
  15562. _this.changing_ = false;
  15563. _this.trigger('change');
  15564. });
  15565. };
  15566. VideoTrackList.prototype.addTrack = function addTrack(track) {
  15567. this.addTrack_(track);
  15568. };
  15569. VideoTrackList.prototype.removeTrack = function removeTrack(track) {
  15570. _TrackList.prototype.removeTrack_.call(this, track);
  15571. };
  15572. return VideoTrackList;
  15573. })(_trackList2['default']);
  15574. exports['default'] = VideoTrackList;
  15575. module.exports = exports['default'];
  15576. }, { "../utils/browser.js": 140, "./track-list": 136, "global/document": 1 }], 139: [function (_dereq_, module, exports) {
  15577. 'use strict';
  15578. exports.__esModule = true;
  15579. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  15580. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15581. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15582. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  15583. var _trackEnums = _dereq_('./track-enums');
  15584. var _track = _dereq_('./track');
  15585. var _track2 = _interopRequireDefault(_track);
  15586. var _utilsMergeOptions = _dereq_('../utils/merge-options');
  15587. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  15588. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15589. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15590. /**
  15591. * A single video text track as defined in:
  15592. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotrack
  15593. *
  15594. * interface VideoTrack {
  15595. * readonly attribute DOMString id;
  15596. * readonly attribute DOMString kind;
  15597. * readonly attribute DOMString label;
  15598. * readonly attribute DOMString language;
  15599. * attribute boolean selected;
  15600. * };
  15601. *
  15602. * @param {Object=} options Object of option names and values
  15603. * @class VideoTrack
  15604. */
  15605. var VideoTrack = (function (_Track) {
  15606. _inherits(VideoTrack, _Track);
  15607. function VideoTrack() {
  15608. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  15609. _classCallCheck(this, VideoTrack);
  15610. var settings = _utilsMergeOptions2['default'](options, {
  15611. kind: _trackEnums.VideoTrackKind[options.kind] || ''
  15612. });
  15613. // on IE8 this will be a document element
  15614. // for every other browser this will be a normal object
  15615. var track = _Track.call(this, settings);
  15616. var selected = false;
  15617. if (browser.IS_IE8) {
  15618. for (var prop in VideoTrack.prototype) {
  15619. if (prop !== 'constructor') {
  15620. track[prop] = VideoTrack.prototype[prop];
  15621. }
  15622. }
  15623. }
  15624. Object.defineProperty(track, 'selected', {
  15625. get: function get() {
  15626. return selected;
  15627. },
  15628. set: function set(newSelected) {
  15629. // an invalid or unchanged value
  15630. if (typeof newSelected !== 'boolean' || newSelected === selected) {
  15631. return;
  15632. }
  15633. selected = newSelected;
  15634. this.trigger('selectedchange');
  15635. }
  15636. });
  15637. // if the user sets this track to selected then
  15638. // set selected to that true value otherwise
  15639. // we keep it false
  15640. if (settings.selected) {
  15641. track.selected = settings.selected;
  15642. }
  15643. return track;
  15644. }
  15645. return VideoTrack;
  15646. })(_track2['default']);
  15647. exports['default'] = VideoTrack;
  15648. module.exports = exports['default'];
  15649. }, { "../utils/browser.js": 140, "../utils/merge-options": 149, "./track": 137, "./track-enums": 135 }], 140: [function (_dereq_, module, exports) {
  15650. /**
  15651. * @file browser.js
  15652. */
  15653. 'use strict';
  15654. exports.__esModule = true;
  15655. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15656. var _globalDocument = _dereq_('global/document');
  15657. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15658. var _globalWindow = _dereq_('global/window');
  15659. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  15660. var USER_AGENT = _globalWindow2['default'].navigator.userAgent;
  15661. var webkitVersionMap = /AppleWebKit\/([\d.]+)/i.exec(USER_AGENT);
  15662. var appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null;
  15663. /*
  15664. * Device is an iPhone
  15665. *
  15666. * @type {Boolean}
  15667. * @constant
  15668. * @private
  15669. */
  15670. var IS_IPAD = /iPad/i.test(USER_AGENT);
  15671. exports.IS_IPAD = IS_IPAD;
  15672. // The Facebook app's UIWebView identifies as both an iPhone and iPad, so
  15673. // to identify iPhones, we need to exclude iPads.
  15674. // http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/
  15675. var IS_IPHONE = /iPhone/i.test(USER_AGENT) && !IS_IPAD;
  15676. exports.IS_IPHONE = IS_IPHONE;
  15677. var IS_IPOD = /iPod/i.test(USER_AGENT);
  15678. exports.IS_IPOD = IS_IPOD;
  15679. var IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;
  15680. exports.IS_IOS = IS_IOS;
  15681. var IOS_VERSION = (function () {
  15682. var match = USER_AGENT.match(/OS (\d+)_/i);
  15683. if (match && match[1]) {
  15684. return match[1];
  15685. }
  15686. })();
  15687. exports.IOS_VERSION = IOS_VERSION;
  15688. var IS_ANDROID = /Android/i.test(USER_AGENT);
  15689. exports.IS_ANDROID = IS_ANDROID;
  15690. var ANDROID_VERSION = (function () {
  15691. // This matches Android Major.Minor.Patch versions
  15692. // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
  15693. var match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i),
  15694. major,
  15695. minor;
  15696. if (!match) {
  15697. return null;
  15698. }
  15699. major = match[1] && parseFloat(match[1]);
  15700. minor = match[2] && parseFloat(match[2]);
  15701. if (major && minor) {
  15702. return parseFloat(match[1] + '.' + match[2]);
  15703. } else if (major) {
  15704. return major;
  15705. } else {
  15706. return null;
  15707. }
  15708. })();
  15709. exports.ANDROID_VERSION = ANDROID_VERSION;
  15710. // Old Android is defined as Version older than 2.3, and requiring a webkit version of the android browser
  15711. var IS_OLD_ANDROID = IS_ANDROID && /webkit/i.test(USER_AGENT) && ANDROID_VERSION < 2.3;
  15712. exports.IS_OLD_ANDROID = IS_OLD_ANDROID;
  15713. var IS_NATIVE_ANDROID = IS_ANDROID && ANDROID_VERSION < 5 && appleWebkitVersion < 537;
  15714. exports.IS_NATIVE_ANDROID = IS_NATIVE_ANDROID;
  15715. var IS_FIREFOX = /Firefox/i.test(USER_AGENT);
  15716. exports.IS_FIREFOX = IS_FIREFOX;
  15717. var IS_EDGE = /Edge/i.test(USER_AGENT);
  15718. exports.IS_EDGE = IS_EDGE;
  15719. var IS_CHROME = !IS_EDGE && /Chrome/i.test(USER_AGENT);
  15720. exports.IS_CHROME = IS_CHROME;
  15721. var IS_IE8 = /MSIE\s8\.0/.test(USER_AGENT);
  15722. exports.IS_IE8 = IS_IE8;
  15723. var TOUCH_ENABLED = !!('ontouchstart' in _globalWindow2['default'] || _globalWindow2['default'].DocumentTouch && _globalDocument2['default'] instanceof _globalWindow2['default'].DocumentTouch);
  15724. exports.TOUCH_ENABLED = TOUCH_ENABLED;
  15725. var BACKGROUND_SIZE_SUPPORTED = ('backgroundSize' in _globalDocument2['default'].createElement('video').style);
  15726. exports.BACKGROUND_SIZE_SUPPORTED = BACKGROUND_SIZE_SUPPORTED;
  15727. }, { "global/document": 1, "global/window": 2 }], 141: [function (_dereq_, module, exports) {
  15728. /**
  15729. * @file buffer.js
  15730. */
  15731. 'use strict';
  15732. exports.__esModule = true;
  15733. exports.bufferedPercent = bufferedPercent;
  15734. var _timeRangesJs = _dereq_('./time-ranges.js');
  15735. /**
  15736. * Compute how much your video has been buffered
  15737. *
  15738. * @param {Object} Buffered object
  15739. * @param {Number} Total duration
  15740. * @return {Number} Percent buffered of the total duration
  15741. * @private
  15742. * @function bufferedPercent
  15743. */
  15744. function bufferedPercent(buffered, duration) {
  15745. var bufferedDuration = 0,
  15746. start,
  15747. end;
  15748. if (!duration) {
  15749. return 0;
  15750. }
  15751. if (!buffered || !buffered.length) {
  15752. buffered = _timeRangesJs.createTimeRange(0, 0);
  15753. }
  15754. for (var i = 0; i < buffered.length; i++) {
  15755. start = buffered.start(i);
  15756. end = buffered.end(i);
  15757. // buffered end can be bigger than duration by a very small fraction
  15758. if (end > duration) {
  15759. end = duration;
  15760. }
  15761. bufferedDuration += end - start;
  15762. }
  15763. return bufferedDuration / duration;
  15764. }
  15765. }, { "./time-ranges.js": 151 }], 142: [function (_dereq_, module, exports) {
  15766. 'use strict';
  15767. exports.__esModule = true;
  15768. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15769. var _logJs = _dereq_('./log.js');
  15770. var _logJs2 = _interopRequireDefault(_logJs);
  15771. /**
  15772. * Object containing the default behaviors for available handler methods.
  15773. *
  15774. * @private
  15775. * @type {Object}
  15776. */
  15777. var defaultBehaviors = {
  15778. get: function get(obj, key) {
  15779. return obj[key];
  15780. },
  15781. set: function set(obj, key, value) {
  15782. obj[key] = value;
  15783. return true;
  15784. }
  15785. };
  15786. /**
  15787. * Expose private objects publicly using a Proxy to log deprecation warnings.
  15788. *
  15789. * Browsers that do not support Proxy objects will simply return the `target`
  15790. * object, so it can be directly exposed.
  15791. *
  15792. * @param {Object} target The target object.
  15793. * @param {Object} messages Messages to display from a Proxy. Only operations
  15794. * with an associated message will be proxied.
  15795. * @param {String} [messages.get]
  15796. * @param {String} [messages.set]
  15797. * @return {Object} A Proxy if supported or the `target` argument.
  15798. */
  15799. exports['default'] = function (target) {
  15800. var messages = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  15801. if (typeof Proxy === 'function') {
  15802. var _ret = (function () {
  15803. var handler = {};
  15804. // Build a handler object based on those keys that have both messages
  15805. // and default behaviors.
  15806. Object.keys(messages).forEach(function (key) {
  15807. if (defaultBehaviors.hasOwnProperty(key)) {
  15808. handler[key] = function () {
  15809. _logJs2['default'].warn(messages[key]);
  15810. return defaultBehaviors[key].apply(this, arguments);
  15811. };
  15812. }
  15813. });
  15814. return {
  15815. v: new Proxy(target, handler)
  15816. };
  15817. })();
  15818. if (typeof _ret === 'object') return _ret.v;
  15819. }
  15820. return target;
  15821. };
  15822. module.exports = exports['default'];
  15823. }, { "./log.js": 148 }], 143: [function (_dereq_, module, exports) {
  15824. /**
  15825. * @file dom.js
  15826. */
  15827. 'use strict';
  15828. exports.__esModule = true;
  15829. exports.getEl = getEl;
  15830. exports.createEl = createEl;
  15831. exports.textContent = textContent;
  15832. exports.insertElFirst = insertElFirst;
  15833. exports.getElData = getElData;
  15834. exports.hasElData = hasElData;
  15835. exports.removeElData = removeElData;
  15836. exports.hasElClass = hasElClass;
  15837. exports.addElClass = addElClass;
  15838. exports.removeElClass = removeElClass;
  15839. exports.toggleElClass = toggleElClass;
  15840. exports.setElAttributes = setElAttributes;
  15841. exports.getElAttributes = getElAttributes;
  15842. exports.blockTextSelection = blockTextSelection;
  15843. exports.unblockTextSelection = unblockTextSelection;
  15844. exports.findElPosition = findElPosition;
  15845. exports.getPointerPosition = getPointerPosition;
  15846. exports.isEl = isEl;
  15847. exports.isTextNode = isTextNode;
  15848. exports.emptyEl = emptyEl;
  15849. exports.normalizeContent = normalizeContent;
  15850. exports.appendContent = appendContent;
  15851. exports.insertContent = insertContent;
  15852. var _templateObject = _taggedTemplateLiteralLoose(['Setting attributes in the second argument of createEl()\n has been deprecated. Use the third argument instead.\n createEl(type, properties, attributes). Attempting to set ', ' to ', '.'], ['Setting attributes in the second argument of createEl()\n has been deprecated. Use the third argument instead.\n createEl(type, properties, attributes). Attempting to set ', ' to ', '.']);
  15853. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  15854. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15855. function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings; }
  15856. var _globalDocument = _dereq_('global/document');
  15857. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15858. var _globalWindow = _dereq_('global/window');
  15859. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  15860. var _guidJs = _dereq_('./guid.js');
  15861. var Guid = _interopRequireWildcard(_guidJs);
  15862. var _logJs = _dereq_('./log.js');
  15863. var _logJs2 = _interopRequireDefault(_logJs);
  15864. var _tsml = _dereq_('tsml');
  15865. var _tsml2 = _interopRequireDefault(_tsml);
  15866. /**
  15867. * Detect if a value is a string with any non-whitespace characters.
  15868. *
  15869. * @param {String} str
  15870. * @return {Boolean}
  15871. */
  15872. function isNonBlankString(str) {
  15873. return typeof str === 'string' && /\S/.test(str);
  15874. }
  15875. /**
  15876. * Throws an error if the passed string has whitespace. This is used by
  15877. * class methods to be relatively consistent with the classList API.
  15878. *
  15879. * @param {String} str
  15880. * @return {Boolean}
  15881. */
  15882. function throwIfWhitespace(str) {
  15883. if (/\s/.test(str)) {
  15884. throw new Error('class has illegal whitespace characters');
  15885. }
  15886. }
  15887. /**
  15888. * Produce a regular expression for matching a class name.
  15889. *
  15890. * @param {String} className
  15891. * @return {RegExp}
  15892. */
  15893. function classRegExp(className) {
  15894. return new RegExp('(^|\\s)' + className + '($|\\s)');
  15895. }
  15896. /**
  15897. * Creates functions to query the DOM using a given method.
  15898. *
  15899. * @function createQuerier
  15900. * @private
  15901. * @param {String} method
  15902. * @return {Function}
  15903. */
  15904. function createQuerier(method) {
  15905. return function (selector, context) {
  15906. if (!isNonBlankString(selector)) {
  15907. return _globalDocument2['default'][method](null);
  15908. }
  15909. if (isNonBlankString(context)) {
  15910. context = _globalDocument2['default'].querySelector(context);
  15911. }
  15912. return (isEl(context) ? context : _globalDocument2['default'])[method](selector);
  15913. };
  15914. }
  15915. /**
  15916. * Shorthand for document.getElementById()
  15917. * Also allows for CSS (jQuery) ID syntax. But nothing other than IDs.
  15918. *
  15919. * @param {String} id Element ID
  15920. * @return {Element} Element with supplied ID
  15921. * @function getEl
  15922. */
  15923. function getEl(id) {
  15924. if (id.indexOf('#') === 0) {
  15925. id = id.slice(1);
  15926. }
  15927. return _globalDocument2['default'].getElementById(id);
  15928. }
  15929. /**
  15930. * Creates an element and applies properties.
  15931. *
  15932. * @param {String} [tagName='div'] Name of tag to be created.
  15933. * @param {Object} [properties={}] Element properties to be applied.
  15934. * @param {Object} [attributes={}] Element attributes to be applied.
  15935. * @return {Element}
  15936. * @function createEl
  15937. */
  15938. function createEl() {
  15939. var tagName = arguments.length <= 0 || arguments[0] === undefined ? 'div' : arguments[0];
  15940. var properties = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  15941. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  15942. var el = _globalDocument2['default'].createElement(tagName);
  15943. Object.getOwnPropertyNames(properties).forEach(function (propName) {
  15944. var val = properties[propName];
  15945. // See #2176
  15946. // We originally were accepting both properties and attributes in the
  15947. // same object, but that doesn't work so well.
  15948. if (propName.indexOf('aria-') !== -1 || propName === 'role' || propName === 'type') {
  15949. _logJs2['default'].warn(_tsml2['default'](_templateObject, propName, val));
  15950. el.setAttribute(propName, val);
  15951. } else {
  15952. el[propName] = val;
  15953. }
  15954. });
  15955. Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
  15956. var val = attributes[attrName];
  15957. el.setAttribute(attrName, attributes[attrName]);
  15958. });
  15959. return el;
  15960. }
  15961. /**
  15962. * Injects text into an element, replacing any existing contents entirely.
  15963. *
  15964. * @param {Element} el
  15965. * @param {String} text
  15966. * @return {Element}
  15967. * @function textContent
  15968. */
  15969. function textContent(el, text) {
  15970. if (typeof el.textContent === 'undefined') {
  15971. el.innerText = text;
  15972. } else {
  15973. el.textContent = text;
  15974. }
  15975. }
  15976. /**
  15977. * Insert an element as the first child node of another
  15978. *
  15979. * @param {Element} child Element to insert
  15980. * @param {Element} parent Element to insert child into
  15981. * @private
  15982. * @function insertElFirst
  15983. */
  15984. function insertElFirst(child, parent) {
  15985. if (parent.firstChild) {
  15986. parent.insertBefore(child, parent.firstChild);
  15987. } else {
  15988. parent.appendChild(child);
  15989. }
  15990. }
  15991. /**
  15992. * Element Data Store. Allows for binding data to an element without putting it directly on the element.
  15993. * Ex. Event listeners are stored here.
  15994. * (also from jsninja.com, slightly modified and updated for closure compiler)
  15995. *
  15996. * @type {Object}
  15997. * @private
  15998. */
  15999. var elData = {};
  16000. /*
  16001. * Unique attribute name to store an element's guid in
  16002. *
  16003. * @type {String}
  16004. * @constant
  16005. * @private
  16006. */
  16007. var elIdAttr = 'vdata' + new Date().getTime();
  16008. /**
  16009. * Returns the cache object where data for an element is stored
  16010. *
  16011. * @param {Element} el Element to store data for.
  16012. * @return {Object}
  16013. * @function getElData
  16014. */
  16015. function getElData(el) {
  16016. var id = el[elIdAttr];
  16017. if (!id) {
  16018. id = el[elIdAttr] = Guid.newGUID();
  16019. }
  16020. if (!elData[id]) {
  16021. elData[id] = {};
  16022. }
  16023. return elData[id];
  16024. }
  16025. /**
  16026. * Returns whether or not an element has cached data
  16027. *
  16028. * @param {Element} el A dom element
  16029. * @return {Boolean}
  16030. * @private
  16031. * @function hasElData
  16032. */
  16033. function hasElData(el) {
  16034. var id = el[elIdAttr];
  16035. if (!id) {
  16036. return false;
  16037. }
  16038. return !!Object.getOwnPropertyNames(elData[id]).length;
  16039. }
  16040. /**
  16041. * Delete data for the element from the cache and the guid attr from getElementById
  16042. *
  16043. * @param {Element} el Remove data for an element
  16044. * @private
  16045. * @function removeElData
  16046. */
  16047. function removeElData(el) {
  16048. var id = el[elIdAttr];
  16049. if (!id) {
  16050. return;
  16051. }
  16052. // Remove all stored data
  16053. delete elData[id];
  16054. // Remove the elIdAttr property from the DOM node
  16055. try {
  16056. delete el[elIdAttr];
  16057. } catch (e) {
  16058. if (el.removeAttribute) {
  16059. el.removeAttribute(elIdAttr);
  16060. } else {
  16061. // IE doesn't appear to support removeAttribute on the document element
  16062. el[elIdAttr] = null;
  16063. }
  16064. }
  16065. }
  16066. /**
  16067. * Check if an element has a CSS class
  16068. *
  16069. * @function hasElClass
  16070. * @param {Element} element Element to check
  16071. * @param {String} classToCheck Classname to check
  16072. */
  16073. function hasElClass(element, classToCheck) {
  16074. if (element.classList) {
  16075. return element.classList.contains(classToCheck);
  16076. } else {
  16077. throwIfWhitespace(classToCheck);
  16078. return classRegExp(classToCheck).test(element.className);
  16079. }
  16080. }
  16081. /**
  16082. * Add a CSS class name to an element
  16083. *
  16084. * @function addElClass
  16085. * @param {Element} element Element to add class name to
  16086. * @param {String} classToAdd Classname to add
  16087. */
  16088. function addElClass(element, classToAdd) {
  16089. if (element.classList) {
  16090. element.classList.add(classToAdd);
  16091. // Don't need to `throwIfWhitespace` here because `hasElClass` will do it
  16092. // in the case of classList not being supported.
  16093. } else if (!hasElClass(element, classToAdd)) {
  16094. element.className = (element.className + ' ' + classToAdd).trim();
  16095. }
  16096. return element;
  16097. }
  16098. /**
  16099. * Remove a CSS class name from an element
  16100. *
  16101. * @function removeElClass
  16102. * @param {Element} element Element to remove from class name
  16103. * @param {String} classToRemove Classname to remove
  16104. */
  16105. function removeElClass(element, classToRemove) {
  16106. if (element.classList) {
  16107. element.classList.remove(classToRemove);
  16108. } else {
  16109. throwIfWhitespace(classToRemove);
  16110. element.className = element.className.split(/\s+/).filter(function (c) {
  16111. return c !== classToRemove;
  16112. }).join(' ');
  16113. }
  16114. return element;
  16115. }
  16116. /**
  16117. * Adds or removes a CSS class name on an element depending on an optional
  16118. * condition or the presence/absence of the class name.
  16119. *
  16120. * @function toggleElClass
  16121. * @param {Element} element
  16122. * @param {String} classToToggle
  16123. * @param {Boolean|Function} [predicate]
  16124. * Can be a function that returns a Boolean. If `true`, the class
  16125. * will be added; if `false`, the class will be removed. If not
  16126. * given, the class will be added if not present and vice versa.
  16127. */
  16128. function toggleElClass(element, classToToggle, predicate) {
  16129. // This CANNOT use `classList` internally because IE does not support the
  16130. // second parameter to the `classList.toggle()` method! Which is fine because
  16131. // `classList` will be used by the add/remove functions.
  16132. var has = hasElClass(element, classToToggle);
  16133. if (typeof predicate === 'function') {
  16134. predicate = predicate(element, classToToggle);
  16135. }
  16136. if (typeof predicate !== 'boolean') {
  16137. predicate = !has;
  16138. }
  16139. // If the necessary class operation matches the current state of the
  16140. // element, no action is required.
  16141. if (predicate === has) {
  16142. return;
  16143. }
  16144. if (predicate) {
  16145. addElClass(element, classToToggle);
  16146. } else {
  16147. removeElClass(element, classToToggle);
  16148. }
  16149. return element;
  16150. }
  16151. /**
  16152. * Apply attributes to an HTML element.
  16153. *
  16154. * @param {Element} el Target element.
  16155. * @param {Object=} attributes Element attributes to be applied.
  16156. * @private
  16157. * @function setElAttributes
  16158. */
  16159. function setElAttributes(el, attributes) {
  16160. Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
  16161. var attrValue = attributes[attrName];
  16162. if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
  16163. el.removeAttribute(attrName);
  16164. } else {
  16165. el.setAttribute(attrName, attrValue === true ? '' : attrValue);
  16166. }
  16167. });
  16168. }
  16169. /**
  16170. * Get an element's attribute values, as defined on the HTML tag
  16171. * Attributes are not the same as properties. They're defined on the tag
  16172. * or with setAttribute (which shouldn't be used with HTML)
  16173. * This will return true or false for boolean attributes.
  16174. *
  16175. * @param {Element} tag Element from which to get tag attributes
  16176. * @return {Object}
  16177. * @private
  16178. * @function getElAttributes
  16179. */
  16180. function getElAttributes(tag) {
  16181. var obj, knownBooleans, attrs, attrName, attrVal;
  16182. obj = {};
  16183. // known boolean attributes
  16184. // we can check for matching boolean properties, but older browsers
  16185. // won't know about HTML5 boolean attributes that we still read from
  16186. knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ',';
  16187. if (tag && tag.attributes && tag.attributes.length > 0) {
  16188. attrs = tag.attributes;
  16189. for (var i = attrs.length - 1; i >= 0; i--) {
  16190. attrName = attrs[i].name;
  16191. attrVal = attrs[i].value;
  16192. // check for known booleans
  16193. // the matching element property will return a value for typeof
  16194. if (typeof tag[attrName] === 'boolean' || knownBooleans.indexOf(',' + attrName + ',') !== -1) {
  16195. // the value of an included boolean attribute is typically an empty
  16196. // string ('') which would equal false if we just check for a false value.
  16197. // we also don't want support bad code like autoplay='false'
  16198. attrVal = attrVal !== null ? true : false;
  16199. }
  16200. obj[attrName] = attrVal;
  16201. }
  16202. }
  16203. return obj;
  16204. }
  16205. /**
  16206. * Attempt to block the ability to select text while dragging controls
  16207. *
  16208. * @return {Boolean}
  16209. * @function blockTextSelection
  16210. */
  16211. function blockTextSelection() {
  16212. _globalDocument2['default'].body.focus();
  16213. _globalDocument2['default'].onselectstart = function () {
  16214. return false;
  16215. };
  16216. }
  16217. /**
  16218. * Turn off text selection blocking
  16219. *
  16220. * @return {Boolean}
  16221. * @function unblockTextSelection
  16222. */
  16223. function unblockTextSelection() {
  16224. _globalDocument2['default'].onselectstart = function () {
  16225. return true;
  16226. };
  16227. }
  16228. /**
  16229. * Offset Left
  16230. * getBoundingClientRect technique from
  16231. * John Resig http://ejohn.org/blog/getboundingclientrect-is-awesome/
  16232. *
  16233. * @function findElPosition
  16234. * @param {Element} el Element from which to get offset
  16235. * @return {Object}
  16236. */
  16237. function findElPosition(el) {
  16238. var box = undefined;
  16239. if (el.getBoundingClientRect && el.parentNode) {
  16240. box = el.getBoundingClientRect();
  16241. }
  16242. if (!box) {
  16243. return {
  16244. left: 0,
  16245. top: 0
  16246. };
  16247. }
  16248. var docEl = _globalDocument2['default'].documentElement;
  16249. var body = _globalDocument2['default'].body;
  16250. var clientLeft = docEl.clientLeft || body.clientLeft || 0;
  16251. var scrollLeft = _globalWindow2['default'].pageXOffset || body.scrollLeft;
  16252. var left = box.left + scrollLeft - clientLeft;
  16253. var clientTop = docEl.clientTop || body.clientTop || 0;
  16254. var scrollTop = _globalWindow2['default'].pageYOffset || body.scrollTop;
  16255. var top = box.top + scrollTop - clientTop;
  16256. // Android sometimes returns slightly off decimal values, so need to round
  16257. return {
  16258. left: Math.round(left),
  16259. top: Math.round(top)
  16260. };
  16261. }
  16262. /**
  16263. * Get pointer position in element
  16264. * Returns an object with x and y coordinates.
  16265. * The base on the coordinates are the bottom left of the element.
  16266. *
  16267. * @function getPointerPosition
  16268. * @param {Element} el Element on which to get the pointer position on
  16269. * @param {Event} event Event object
  16270. * @return {Object} This object will have x and y coordinates corresponding to the mouse position
  16271. */
  16272. function getPointerPosition(el, event) {
  16273. var position = {};
  16274. var box = findElPosition(el);
  16275. var boxW = el.offsetWidth;
  16276. var boxH = el.offsetHeight;
  16277. var boxY = box.top;
  16278. var boxX = box.left;
  16279. var pageY = event.pageY;
  16280. var pageX = event.pageX;
  16281. if (event.changedTouches) {
  16282. pageX = event.changedTouches[0].pageX;
  16283. pageY = event.changedTouches[0].pageY;
  16284. }
  16285. position.y = Math.max(0, Math.min(1, (boxY - pageY + boxH) / boxH));
  16286. position.x = Math.max(0, Math.min(1, (pageX - boxX) / boxW));
  16287. return position;
  16288. }
  16289. /**
  16290. * Determines, via duck typing, whether or not a value is a DOM element.
  16291. *
  16292. * @function isEl
  16293. * @param {Mixed} value
  16294. * @return {Boolean}
  16295. */
  16296. function isEl(value) {
  16297. return !!value && typeof value === 'object' && value.nodeType === 1;
  16298. }
  16299. /**
  16300. * Determines, via duck typing, whether or not a value is a text node.
  16301. *
  16302. * @param {Mixed} value
  16303. * @return {Boolean}
  16304. */
  16305. function isTextNode(value) {
  16306. return !!value && typeof value === 'object' && value.nodeType === 3;
  16307. }
  16308. /**
  16309. * Empties the contents of an element.
  16310. *
  16311. * @function emptyEl
  16312. * @param {Element} el
  16313. * @return {Element}
  16314. */
  16315. function emptyEl(el) {
  16316. while (el.firstChild) {
  16317. el.removeChild(el.firstChild);
  16318. }
  16319. return el;
  16320. }
  16321. /**
  16322. * Normalizes content for eventual insertion into the DOM.
  16323. *
  16324. * This allows a wide range of content definition methods, but protects
  16325. * from falling into the trap of simply writing to `innerHTML`, which is
  16326. * an XSS concern.
  16327. *
  16328. * The content for an element can be passed in multiple types and
  16329. * combinations, whose behavior is as follows:
  16330. *
  16331. * - String
  16332. * Normalized into a text node.
  16333. *
  16334. * - Element, TextNode
  16335. * Passed through.
  16336. *
  16337. * - Array
  16338. * A one-dimensional array of strings, elements, nodes, or functions (which
  16339. * return single strings, elements, or nodes).
  16340. *
  16341. * - Function
  16342. * If the sole argument, is expected to produce a string, element,
  16343. * node, or array.
  16344. *
  16345. * @function normalizeContent
  16346. * @param {String|Element|TextNode|Array|Function} content
  16347. * @return {Array}
  16348. */
  16349. function normalizeContent(content) {
  16350. // First, invoke content if it is a function. If it produces an array,
  16351. // that needs to happen before normalization.
  16352. if (typeof content === 'function') {
  16353. content = content();
  16354. }
  16355. // Next up, normalize to an array, so one or many items can be normalized,
  16356. // filtered, and returned.
  16357. return (Array.isArray(content) ? content : [content]).map(function (value) {
  16358. // First, invoke value if it is a function to produce a new value,
  16359. // which will be subsequently normalized to a Node of some kind.
  16360. if (typeof value === 'function') {
  16361. value = value();
  16362. }
  16363. if (isEl(value) || isTextNode(value)) {
  16364. return value;
  16365. }
  16366. if (typeof value === 'string' && /\S/.test(value)) {
  16367. return _globalDocument2['default'].createTextNode(value);
  16368. }
  16369. }).filter(function (value) {
  16370. return value;
  16371. });
  16372. }
  16373. /**
  16374. * Normalizes and appends content to an element.
  16375. *
  16376. * @function appendContent
  16377. * @param {Element} el
  16378. * @param {String|Element|TextNode|Array|Function} content
  16379. * See: `normalizeContent`
  16380. * @return {Element}
  16381. */
  16382. function appendContent(el, content) {
  16383. normalizeContent(content).forEach(function (node) {
  16384. return el.appendChild(node);
  16385. });
  16386. return el;
  16387. }
  16388. /**
  16389. * Normalizes and inserts content into an element; this is identical to
  16390. * `appendContent()`, except it empties the element first.
  16391. *
  16392. * @function insertContent
  16393. * @param {Element} el
  16394. * @param {String|Element|TextNode|Array|Function} content
  16395. * See: `normalizeContent`
  16396. * @return {Element}
  16397. */
  16398. function insertContent(el, content) {
  16399. return appendContent(emptyEl(el), content);
  16400. }
  16401. /**
  16402. * Finds a single DOM element matching `selector` within the optional
  16403. * `context` of another DOM element (defaulting to `document`).
  16404. *
  16405. * @function $
  16406. * @param {String} selector
  16407. * A valid CSS selector, which will be passed to `querySelector`.
  16408. *
  16409. * @param {Element|String} [context=document]
  16410. * A DOM element within which to query. Can also be a selector
  16411. * string in which case the first matching element will be used
  16412. * as context. If missing (or no element matches selector), falls
  16413. * back to `document`.
  16414. *
  16415. * @return {Element|null}
  16416. */
  16417. var $ = createQuerier('querySelector');
  16418. exports.$ = $;
  16419. /**
  16420. * Finds a all DOM elements matching `selector` within the optional
  16421. * `context` of another DOM element (defaulting to `document`).
  16422. *
  16423. * @function $$
  16424. * @param {String} selector
  16425. * A valid CSS selector, which will be passed to `querySelectorAll`.
  16426. *
  16427. * @param {Element|String} [context=document]
  16428. * A DOM element within which to query. Can also be a selector
  16429. * string in which case the first matching element will be used
  16430. * as context. If missing (or no element matches selector), falls
  16431. * back to `document`.
  16432. *
  16433. * @return {NodeList}
  16434. */
  16435. var $$ = createQuerier('querySelectorAll');
  16436. exports.$$ = $$;
  16437. }, { "./guid.js": 147, "./log.js": 148, "global/document": 1, "global/window": 2, "tsml": 55 }], 144: [function (_dereq_, module, exports) {
  16438. /**
  16439. * @file events.js
  16440. *
  16441. * Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)
  16442. * (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)
  16443. * This should work very similarly to jQuery's events, however it's based off the book version which isn't as
  16444. * robust as jquery's, so there's probably some differences.
  16445. */
  16446. 'use strict';
  16447. exports.__esModule = true;
  16448. exports.on = on;
  16449. exports.off = off;
  16450. exports.trigger = trigger;
  16451. exports.one = one;
  16452. exports.fixEvent = fixEvent;
  16453. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  16454. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  16455. var _domJs = _dereq_('./dom.js');
  16456. var Dom = _interopRequireWildcard(_domJs);
  16457. var _guidJs = _dereq_('./guid.js');
  16458. var Guid = _interopRequireWildcard(_guidJs);
  16459. var _globalWindow = _dereq_('global/window');
  16460. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  16461. var _globalDocument = _dereq_('global/document');
  16462. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  16463. /**
  16464. * Add an event listener to element
  16465. * It stores the handler function in a separate cache object
  16466. * and adds a generic handler to the element's event,
  16467. * along with a unique id (guid) to the element.
  16468. *
  16469. * @param {Element|Object} elem Element or object to bind listeners to
  16470. * @param {String|Array} type Type of event to bind to.
  16471. * @param {Function} fn Event listener.
  16472. * @method on
  16473. */
  16474. function on(elem, type, fn) {
  16475. if (Array.isArray(type)) {
  16476. return _handleMultipleEvents(on, elem, type, fn);
  16477. }
  16478. var data = Dom.getElData(elem);
  16479. // We need a place to store all our handler data
  16480. if (!data.handlers) data.handlers = {};
  16481. if (!data.handlers[type]) data.handlers[type] = [];
  16482. if (!fn.guid) fn.guid = Guid.newGUID();
  16483. data.handlers[type].push(fn);
  16484. if (!data.dispatcher) {
  16485. data.disabled = false;
  16486. data.dispatcher = function (event, hash) {
  16487. if (data.disabled) return;
  16488. event = fixEvent(event);
  16489. var handlers = data.handlers[event.type];
  16490. if (handlers) {
  16491. // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
  16492. var handlersCopy = handlers.slice(0);
  16493. for (var m = 0, n = handlersCopy.length; m < n; m++) {
  16494. if (event.isImmediatePropagationStopped()) {
  16495. break;
  16496. } else {
  16497. handlersCopy[m].call(elem, event, hash);
  16498. }
  16499. }
  16500. }
  16501. };
  16502. }
  16503. if (data.handlers[type].length === 1) {
  16504. if (elem.addEventListener) {
  16505. elem.addEventListener(type, data.dispatcher, false);
  16506. } else if (elem.attachEvent) {
  16507. elem.attachEvent('on' + type, data.dispatcher);
  16508. }
  16509. }
  16510. }
  16511. /**
  16512. * Removes event listeners from an element
  16513. *
  16514. * @param {Element|Object} elem Object to remove listeners from
  16515. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  16516. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  16517. * @method off
  16518. */
  16519. function off(elem, type, fn) {
  16520. // Don't want to add a cache object through getElData if not needed
  16521. if (!Dom.hasElData(elem)) return;
  16522. var data = Dom.getElData(elem);
  16523. // If no events exist, nothing to unbind
  16524. if (!data.handlers) {
  16525. return;
  16526. }
  16527. if (Array.isArray(type)) {
  16528. return _handleMultipleEvents(off, elem, type, fn);
  16529. }
  16530. // Utility function
  16531. var removeType = function removeType(t) {
  16532. data.handlers[t] = [];
  16533. _cleanUpEvents(elem, t);
  16534. };
  16535. // Are we removing all bound events?
  16536. if (!type) {
  16537. for (var t in data.handlers) {
  16538. removeType(t);
  16539. } return;
  16540. }
  16541. var handlers = data.handlers[type];
  16542. // If no handlers exist, nothing to unbind
  16543. if (!handlers) return;
  16544. // If no listener was provided, remove all listeners for type
  16545. if (!fn) {
  16546. removeType(type);
  16547. return;
  16548. }
  16549. // We're only removing a single handler
  16550. if (fn.guid) {
  16551. for (var n = 0; n < handlers.length; n++) {
  16552. if (handlers[n].guid === fn.guid) {
  16553. handlers.splice(n--, 1);
  16554. }
  16555. }
  16556. }
  16557. _cleanUpEvents(elem, type);
  16558. }
  16559. /**
  16560. * Trigger an event for an element
  16561. *
  16562. * @param {Element|Object} elem Element to trigger an event on
  16563. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  16564. * @param {Object} [hash] data hash to pass along with the event
  16565. * @return {Boolean=} Returned only if default was prevented
  16566. * @method trigger
  16567. */
  16568. function trigger(elem, event, hash) {
  16569. // Fetches element data and a reference to the parent (for bubbling).
  16570. // Don't want to add a data object to cache for every parent,
  16571. // so checking hasElData first.
  16572. var elemData = Dom.hasElData(elem) ? Dom.getElData(elem) : {};
  16573. var parent = elem.parentNode || elem.ownerDocument;
  16574. // type = event.type || event,
  16575. // handler;
  16576. // If an event name was passed as a string, creates an event out of it
  16577. if (typeof event === 'string') {
  16578. event = { type: event, target: elem };
  16579. }
  16580. // Normalizes the event properties.
  16581. event = fixEvent(event);
  16582. // If the passed element has a dispatcher, executes the established handlers.
  16583. if (elemData.dispatcher) {
  16584. elemData.dispatcher.call(elem, event, hash);
  16585. }
  16586. // Unless explicitly stopped or the event does not bubble (e.g. media events)
  16587. // recursively calls this function to bubble the event up the DOM.
  16588. if (parent && !event.isPropagationStopped() && event.bubbles === true) {
  16589. trigger.call(null, parent, event, hash);
  16590. // If at the top of the DOM, triggers the default action unless disabled.
  16591. } else if (!parent && !event.defaultPrevented) {
  16592. var targetData = Dom.getElData(event.target);
  16593. // Checks if the target has a default action for this event.
  16594. if (event.target[event.type]) {
  16595. // Temporarily disables event dispatching on the target as we have already executed the handler.
  16596. targetData.disabled = true;
  16597. // Executes the default action.
  16598. if (typeof event.target[event.type] === 'function') {
  16599. event.target[event.type]();
  16600. }
  16601. // Re-enables event dispatching.
  16602. targetData.disabled = false;
  16603. }
  16604. }
  16605. // Inform the triggerer if the default was prevented by returning false
  16606. return !event.defaultPrevented;
  16607. }
  16608. /**
  16609. * Trigger a listener only once for an event
  16610. *
  16611. * @param {Element|Object} elem Element or object to
  16612. * @param {String|Array} type Name/type of event
  16613. * @param {Function} fn Event handler function
  16614. * @method one
  16615. */
  16616. function one(elem, type, fn) {
  16617. if (Array.isArray(type)) {
  16618. return _handleMultipleEvents(one, elem, type, fn);
  16619. }
  16620. var func = function func() {
  16621. off(elem, type, func);
  16622. fn.apply(this, arguments);
  16623. };
  16624. // copy the guid to the new function so it can removed using the original function's ID
  16625. func.guid = fn.guid = fn.guid || Guid.newGUID();
  16626. on(elem, type, func);
  16627. }
  16628. /**
  16629. * Fix a native event to have standard property values
  16630. *
  16631. * @param {Object} event Event object to fix
  16632. * @return {Object}
  16633. * @private
  16634. * @method fixEvent
  16635. */
  16636. function fixEvent(event) {
  16637. function returnTrue() {
  16638. return true;
  16639. }
  16640. function returnFalse() {
  16641. return false;
  16642. }
  16643. // Test if fixing up is needed
  16644. // Used to check if !event.stopPropagation instead of isPropagationStopped
  16645. // But native events return true for stopPropagation, but don't have
  16646. // other expected methods like isPropagationStopped. Seems to be a problem
  16647. // with the Javascript Ninja code. So we're just overriding all events now.
  16648. if (!event || !event.isPropagationStopped) {
  16649. var old = event || _globalWindow2['default'].event;
  16650. event = {};
  16651. // Clone the old object so that we can modify the values event = {};
  16652. // IE8 Doesn't like when you mess with native event properties
  16653. // Firefox returns false for event.hasOwnProperty('type') and other props
  16654. // which makes copying more difficult.
  16655. // TODO: Probably best to create a whitelist of event props
  16656. for (var key in old) {
  16657. // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
  16658. // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
  16659. // and webkitMovementX/Y
  16660. if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation' && key !== 'webkitMovementX' && key !== 'webkitMovementY') {
  16661. // Chrome 32+ warns if you try to copy deprecated returnValue, but
  16662. // we still want to if preventDefault isn't supported (IE8).
  16663. if (!(key === 'returnValue' && old.preventDefault)) {
  16664. event[key] = old[key];
  16665. }
  16666. }
  16667. }
  16668. // The event occurred on this element
  16669. if (!event.target) {
  16670. event.target = event.srcElement || _globalDocument2['default'];
  16671. }
  16672. // Handle which other element the event is related to
  16673. if (!event.relatedTarget) {
  16674. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
  16675. }
  16676. // Stop the default browser action
  16677. event.preventDefault = function () {
  16678. if (old.preventDefault) {
  16679. old.preventDefault();
  16680. }
  16681. event.returnValue = false;
  16682. old.returnValue = false;
  16683. event.defaultPrevented = true;
  16684. };
  16685. event.defaultPrevented = false;
  16686. // Stop the event from bubbling
  16687. event.stopPropagation = function () {
  16688. if (old.stopPropagation) {
  16689. old.stopPropagation();
  16690. }
  16691. event.cancelBubble = true;
  16692. old.cancelBubble = true;
  16693. event.isPropagationStopped = returnTrue;
  16694. };
  16695. event.isPropagationStopped = returnFalse;
  16696. // Stop the event from bubbling and executing other handlers
  16697. event.stopImmediatePropagation = function () {
  16698. if (old.stopImmediatePropagation) {
  16699. old.stopImmediatePropagation();
  16700. }
  16701. event.isImmediatePropagationStopped = returnTrue;
  16702. event.stopPropagation();
  16703. };
  16704. event.isImmediatePropagationStopped = returnFalse;
  16705. // Handle mouse position
  16706. if (event.clientX != null) {
  16707. var doc = _globalDocument2['default'].documentElement,
  16708. body = _globalDocument2['default'].body;
  16709. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  16710. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  16711. }
  16712. // Handle key presses
  16713. event.which = event.charCode || event.keyCode;
  16714. // Fix button for mouse clicks:
  16715. // 0 == left; 1 == middle; 2 == right
  16716. if (event.button != null) {
  16717. event.button = event.button & 1 ? 0 : event.button & 4 ? 1 : event.button & 2 ? 2 : 0;
  16718. }
  16719. }
  16720. // Returns fixed-up instance
  16721. return event;
  16722. }
  16723. /**
  16724. * Clean up the listener cache and dispatchers
  16725. *
  16726. * @param {Element|Object} elem Element to clean up
  16727. * @param {String} type Type of event to clean up
  16728. * @private
  16729. * @method _cleanUpEvents
  16730. */
  16731. function _cleanUpEvents(elem, type) {
  16732. var data = Dom.getElData(elem);
  16733. // Remove the events of a particular type if there are none left
  16734. if (data.handlers[type].length === 0) {
  16735. delete data.handlers[type];
  16736. // data.handlers[type] = null;
  16737. // Setting to null was causing an error with data.handlers
  16738. // Remove the meta-handler from the element
  16739. if (elem.removeEventListener) {
  16740. elem.removeEventListener(type, data.dispatcher, false);
  16741. } else if (elem.detachEvent) {
  16742. elem.detachEvent('on' + type, data.dispatcher);
  16743. }
  16744. }
  16745. // Remove the events object if there are no types left
  16746. if (Object.getOwnPropertyNames(data.handlers).length <= 0) {
  16747. delete data.handlers;
  16748. delete data.dispatcher;
  16749. delete data.disabled;
  16750. }
  16751. // Finally remove the element data if there is no data left
  16752. if (Object.getOwnPropertyNames(data).length === 0) {
  16753. Dom.removeElData(elem);
  16754. }
  16755. }
  16756. /**
  16757. * Loops through an array of event types and calls the requested method for each type.
  16758. *
  16759. * @param {Function} fn The event method we want to use.
  16760. * @param {Element|Object} elem Element or object to bind listeners to
  16761. * @param {String} type Type of event to bind to.
  16762. * @param {Function} callback Event listener.
  16763. * @private
  16764. * @function _handleMultipleEvents
  16765. */
  16766. function _handleMultipleEvents(fn, elem, types, callback) {
  16767. types.forEach(function (type) {
  16768. //Call the event method for each one of the types
  16769. fn(elem, type, callback);
  16770. });
  16771. }
  16772. }, { "./dom.js": 143, "./guid.js": 147, "global/document": 1, "global/window": 2 }], 145: [function (_dereq_, module, exports) {
  16773. /**
  16774. * @file fn.js
  16775. */
  16776. 'use strict';
  16777. exports.__esModule = true;
  16778. var _guidJs = _dereq_('./guid.js');
  16779. /**
  16780. * Bind (a.k.a proxy or Context). A simple method for changing the context of a function
  16781. * It also stores a unique id on the function so it can be easily removed from events
  16782. *
  16783. * @param {*} context The object to bind as scope
  16784. * @param {Function} fn The function to be bound to a scope
  16785. * @param {Number=} uid An optional unique ID for the function to be set
  16786. * @return {Function}
  16787. * @private
  16788. * @method bind
  16789. */
  16790. var bind = function bind(context, fn, uid) {
  16791. // Make sure the function has a unique ID
  16792. if (!fn.guid) {
  16793. fn.guid = _guidJs.newGUID();
  16794. }
  16795. // Create the new function that changes the context
  16796. var ret = function ret() {
  16797. return fn.apply(context, arguments);
  16798. };
  16799. // Allow for the ability to individualize this function
  16800. // Needed in the case where multiple objects might share the same prototype
  16801. // IF both items add an event listener with the same function, then you try to remove just one
  16802. // it will remove both because they both have the same guid.
  16803. // when using this, you need to use the bind method when you remove the listener as well.
  16804. // currently used in text tracks
  16805. ret.guid = uid ? uid + '_' + fn.guid : fn.guid;
  16806. return ret;
  16807. };
  16808. exports.bind = bind;
  16809. }, { "./guid.js": 147 }], 146: [function (_dereq_, module, exports) {
  16810. /**
  16811. * @file format-time.js
  16812. *
  16813. * Format seconds as a time string, H:MM:SS or M:SS
  16814. * Supplying a guide (in seconds) will force a number of leading zeros
  16815. * to cover the length of the guide
  16816. *
  16817. * @param {Number} seconds Number of seconds to be turned into a string
  16818. * @param {Number} guide Number (in seconds) to model the string after
  16819. * @return {String} Time formatted as H:MM:SS or M:SS
  16820. * @private
  16821. * @function formatTime
  16822. */
  16823. 'use strict';
  16824. exports.__esModule = true;
  16825. function formatTime(seconds) {
  16826. var guide = arguments.length <= 1 || arguments[1] === undefined ? seconds : arguments[1];
  16827. return (function () {
  16828. seconds = seconds < 0 ? 0 : seconds;
  16829. var s = Math.floor(seconds % 60);
  16830. var m = Math.floor(seconds / 60 % 60);
  16831. var h = Math.floor(seconds / 3600);
  16832. var gm = Math.floor(guide / 60 % 60);
  16833. var gh = Math.floor(guide / 3600);
  16834. // handle invalid times
  16835. if (isNaN(seconds) || seconds === Infinity) {
  16836. // '-' is false for all relational operators (e.g. <, >=) so this setting
  16837. // will add the minimum number of fields specified by the guide
  16838. h = m = s = '-';
  16839. }
  16840. // Check if we need to show hours
  16841. h = h > 0 || gh > 0 ? h + ':' : '';
  16842. // If hours are showing, we may need to add a leading zero.
  16843. // Always show at least one digit of minutes.
  16844. m = ((h || gm >= 10) && m < 10 ? '0' + m : m) + ':';
  16845. // Check if leading zero is need for seconds
  16846. s = s < 10 ? '0' + s : s;
  16847. return h + m + s;
  16848. })();
  16849. }
  16850. exports['default'] = formatTime;
  16851. module.exports = exports['default'];
  16852. }, {}], 147: [function (_dereq_, module, exports) {
  16853. /**
  16854. * @file guid.js
  16855. *
  16856. * Unique ID for an element or function
  16857. * @type {Number}
  16858. * @private
  16859. */
  16860. "use strict";
  16861. exports.__esModule = true;
  16862. exports.newGUID = newGUID;
  16863. var _guid = 1;
  16864. /**
  16865. * Get the next unique ID
  16866. *
  16867. * @return {String}
  16868. * @function newGUID
  16869. */
  16870. function newGUID() {
  16871. return _guid++;
  16872. }
  16873. }, {}], 148: [function (_dereq_, module, exports) {
  16874. /**
  16875. * @file log.js
  16876. */
  16877. 'use strict';
  16878. exports.__esModule = true;
  16879. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  16880. var _globalWindow = _dereq_('global/window');
  16881. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  16882. /**
  16883. * Log plain debug messages
  16884. */
  16885. var log = function log() {
  16886. _logType(null, arguments);
  16887. };
  16888. /**
  16889. * Keep a history of log messages
  16890. * @type {Array}
  16891. */
  16892. log.history = [];
  16893. /**
  16894. * Log error messages
  16895. */
  16896. log.error = function () {
  16897. _logType('error', arguments);
  16898. };
  16899. /**
  16900. * Log warning messages
  16901. */
  16902. log.warn = function () {
  16903. _logType('warn', arguments);
  16904. };
  16905. /**
  16906. * Log messages to the console and history based on the type of message
  16907. *
  16908. * @param {String} type The type of message, or `null` for `log`
  16909. * @param {Object} args The args to be passed to the log
  16910. * @private
  16911. * @method _logType
  16912. */
  16913. function _logType(type, args) {
  16914. // convert args to an array to get array functions
  16915. var argsArray = Array.prototype.slice.call(args);
  16916. // if there's no console then don't try to output messages
  16917. // they will still be stored in log.history
  16918. // Was setting these once outside of this function, but containing them
  16919. // in the function makes it easier to test cases where console doesn't exist
  16920. var noop = function noop() { };
  16921. var console = _globalWindow2['default']['console'] || {
  16922. 'log': noop,
  16923. 'warn': noop,
  16924. 'error': noop
  16925. };
  16926. if (type) {
  16927. // add the type to the front of the message
  16928. argsArray.unshift(type.toUpperCase() + ':');
  16929. } else {
  16930. // default to log with no prefix
  16931. type = 'log';
  16932. }
  16933. // add to history
  16934. log.history.push(argsArray);
  16935. // add console prefix after adding to history
  16936. argsArray.unshift('VIDEOJS:');
  16937. // call appropriate log function
  16938. if (console[type].apply) {
  16939. console[type].apply(console, argsArray);
  16940. } else {
  16941. // ie8 doesn't allow error.apply, but it will just join() the array anyway
  16942. console[type](argsArray.join(' '));
  16943. }
  16944. }
  16945. exports['default'] = log;
  16946. module.exports = exports['default'];
  16947. }, { "global/window": 2 }], 149: [function (_dereq_, module, exports) {
  16948. /**
  16949. * @file merge-options.js
  16950. */
  16951. 'use strict';
  16952. exports.__esModule = true;
  16953. exports['default'] = mergeOptions;
  16954. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  16955. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge');
  16956. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge);
  16957. function isPlain(obj) {
  16958. return !!obj && typeof obj === 'object' && obj.toString() === '[object Object]' && obj.constructor === Object;
  16959. }
  16960. /**
  16961. * Merge customizer. video.js simply overwrites non-simple objects
  16962. * (like arrays) instead of attempting to overlay them.
  16963. * @see https://lodash.com/docs#merge
  16964. */
  16965. var customizer = function customizer(destination, source) {
  16966. // If we're not working with a plain object, copy the value as is
  16967. // If source is an array, for instance, it will replace destination
  16968. if (!isPlain(source)) {
  16969. return source;
  16970. }
  16971. // If the new value is a plain object but the first object value is not
  16972. // we need to create a new object for the first object to merge with.
  16973. // This makes it consistent with how merge() works by default
  16974. // and also protects from later changes the to first object affecting
  16975. // the second object's values.
  16976. if (!isPlain(destination)) {
  16977. return mergeOptions(source);
  16978. }
  16979. };
  16980. /**
  16981. * Merge one or more options objects, recursively merging **only**
  16982. * plain object properties. Previously `deepMerge`.
  16983. *
  16984. * @param {...Object} source One or more objects to merge
  16985. * @returns {Object} a new object that is the union of all
  16986. * provided objects
  16987. * @function mergeOptions
  16988. */
  16989. function mergeOptions() {
  16990. // contruct the call dynamically to handle the variable number of
  16991. // objects to merge
  16992. var args = Array.prototype.slice.call(arguments);
  16993. // unshift an empty object into the front of the call as the target
  16994. // of the merge
  16995. args.unshift({});
  16996. // customize conflict resolution to match our historical merge behavior
  16997. args.push(customizer);
  16998. _lodashCompatObjectMerge2['default'].apply(null, args);
  16999. // return the mutated result object
  17000. return args[0];
  17001. }
  17002. module.exports = exports['default'];
  17003. }, { "lodash-compat/object/merge": 40 }], 150: [function (_dereq_, module, exports) {
  17004. 'use strict';
  17005. exports.__esModule = true;
  17006. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17007. var _globalDocument = _dereq_('global/document');
  17008. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  17009. var createStyleElement = function createStyleElement(className) {
  17010. var style = _globalDocument2['default'].createElement('style');
  17011. style.className = className;
  17012. return style;
  17013. };
  17014. exports.createStyleElement = createStyleElement;
  17015. var setTextContent = function setTextContent(el, content) {
  17016. if (el.styleSheet) {
  17017. el.styleSheet.cssText = content;
  17018. } else {
  17019. el.textContent = content;
  17020. }
  17021. };
  17022. exports.setTextContent = setTextContent;
  17023. }, { "global/document": 1 }], 151: [function (_dereq_, module, exports) {
  17024. 'use strict';
  17025. exports.__esModule = true;
  17026. exports.createTimeRanges = createTimeRanges;
  17027. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17028. var _logJs = _dereq_('./log.js');
  17029. var _logJs2 = _interopRequireDefault(_logJs);
  17030. /**
  17031. * @file time-ranges.js
  17032. *
  17033. * Should create a fake TimeRange object
  17034. * Mimics an HTML5 time range instance, which has functions that
  17035. * return the start and end times for a range
  17036. * TimeRanges are returned by the buffered() method
  17037. *
  17038. * @param {(Number|Array)} Start of a single range or an array of ranges
  17039. * @param {Number} End of a single range
  17040. * @private
  17041. * @method createTimeRanges
  17042. */
  17043. function createTimeRanges(start, end) {
  17044. if (Array.isArray(start)) {
  17045. return createTimeRangesObj(start);
  17046. } else if (start === undefined || end === undefined) {
  17047. return createTimeRangesObj();
  17048. }
  17049. return createTimeRangesObj([[start, end]]);
  17050. }
  17051. exports.createTimeRange = createTimeRanges;
  17052. function createTimeRangesObj(ranges) {
  17053. if (ranges === undefined || ranges.length === 0) {
  17054. return {
  17055. length: 0,
  17056. start: function start() {
  17057. throw new Error('This TimeRanges object is empty');
  17058. },
  17059. end: function end() {
  17060. throw new Error('This TimeRanges object is empty');
  17061. }
  17062. };
  17063. }
  17064. return {
  17065. length: ranges.length,
  17066. start: getRange.bind(null, 'start', 0, ranges),
  17067. end: getRange.bind(null, 'end', 1, ranges)
  17068. };
  17069. }
  17070. function getRange(fnName, valueIndex, ranges, rangeIndex) {
  17071. if (rangeIndex === undefined) {
  17072. _logJs2['default'].warn('DEPRECATED: Function \'' + fnName + '\' on \'TimeRanges\' called without an index argument.');
  17073. rangeIndex = 0;
  17074. }
  17075. rangeCheck(fnName, rangeIndex, ranges.length - 1);
  17076. return ranges[rangeIndex][valueIndex];
  17077. }
  17078. function rangeCheck(fnName, index, maxIndex) {
  17079. if (index < 0 || index > maxIndex) {
  17080. throw new Error('Failed to execute \'' + fnName + '\' on \'TimeRanges\': The index provided (' + index + ') is greater than or equal to the maximum bound (' + maxIndex + ').');
  17081. }
  17082. }
  17083. }, { "./log.js": 148 }], 152: [function (_dereq_, module, exports) {
  17084. /**
  17085. * @file to-title-case.js
  17086. *
  17087. * Uppercase the first letter of a string
  17088. *
  17089. * @param {String} string String to be uppercased
  17090. * @return {String}
  17091. * @private
  17092. * @method toTitleCase
  17093. */
  17094. "use strict";
  17095. exports.__esModule = true;
  17096. function toTitleCase(string) {
  17097. return string.charAt(0).toUpperCase() + string.slice(1);
  17098. }
  17099. exports["default"] = toTitleCase;
  17100. module.exports = exports["default"];
  17101. }, {}], 153: [function (_dereq_, module, exports) {
  17102. /**
  17103. * @file url.js
  17104. */
  17105. 'use strict';
  17106. exports.__esModule = true;
  17107. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17108. var _globalDocument = _dereq_('global/document');
  17109. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  17110. var _globalWindow = _dereq_('global/window');
  17111. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  17112. /**
  17113. * Resolve and parse the elements of a URL
  17114. *
  17115. * @param {String} url The url to parse
  17116. * @return {Object} An object of url details
  17117. * @method parseUrl
  17118. */
  17119. var parseUrl = function parseUrl(url) {
  17120. var props = ['protocol', 'hostname', 'port', 'pathname', 'search', 'hash', 'host'];
  17121. // add the url to an anchor and let the browser parse the URL
  17122. var a = _globalDocument2['default'].createElement('a');
  17123. a.href = url;
  17124. // IE8 (and 9?) Fix
  17125. // ie8 doesn't parse the URL correctly until the anchor is actually
  17126. // added to the body, and an innerHTML is needed to trigger the parsing
  17127. var addToBody = a.host === '' && a.protocol !== 'file:';
  17128. var div = undefined;
  17129. if (addToBody) {
  17130. div = _globalDocument2['default'].createElement('div');
  17131. div.innerHTML = '<a href="' + url + '"></a>';
  17132. a = div.firstChild;
  17133. // prevent the div from affecting layout
  17134. div.setAttribute('style', 'display:none; position:absolute;');
  17135. _globalDocument2['default'].body.appendChild(div);
  17136. }
  17137. // Copy the specific URL properties to a new object
  17138. // This is also needed for IE8 because the anchor loses its
  17139. // properties when it's removed from the dom
  17140. var details = {};
  17141. for (var i = 0; i < props.length; i++) {
  17142. details[props[i]] = a[props[i]];
  17143. }
  17144. // IE9 adds the port to the host property unlike everyone else. If
  17145. // a port identifier is added for standard ports, strip it.
  17146. if (details.protocol === 'http:') {
  17147. details.host = details.host.replace(/:80$/, '');
  17148. }
  17149. if (details.protocol === 'https:') {
  17150. details.host = details.host.replace(/:443$/, '');
  17151. }
  17152. if (addToBody) {
  17153. _globalDocument2['default'].body.removeChild(div);
  17154. }
  17155. return details;
  17156. };
  17157. exports.parseUrl = parseUrl;
  17158. /**
  17159. * Get absolute version of relative URL. Used to tell flash correct URL.
  17160. * http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue
  17161. *
  17162. * @param {String} url URL to make absolute
  17163. * @return {String} Absolute URL
  17164. * @private
  17165. * @method getAbsoluteURL
  17166. */
  17167. var getAbsoluteURL = function getAbsoluteURL(url) {
  17168. // Check if absolute URL
  17169. if (!url.match(/^https?:\/\//)) {
  17170. // Convert to absolute URL. Flash hosted off-site needs an absolute URL.
  17171. var div = _globalDocument2['default'].createElement('div');
  17172. div.innerHTML = '<a href="' + url + '">x</a>';
  17173. url = div.firstChild.href;
  17174. }
  17175. return url;
  17176. };
  17177. exports.getAbsoluteURL = getAbsoluteURL;
  17178. /**
  17179. * Returns the extension of the passed file name. It will return an empty string if you pass an invalid path
  17180. *
  17181. * @param {String} path The fileName path like '/path/to/file.mp4'
  17182. * @returns {String} The extension in lower case or an empty string if no extension could be found.
  17183. * @method getFileExtension
  17184. */
  17185. var getFileExtension = function getFileExtension(path) {
  17186. if (typeof path === 'string') {
  17187. var splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
  17188. var pathParts = splitPathRe.exec(path);
  17189. if (pathParts) {
  17190. return pathParts.pop().toLowerCase();
  17191. }
  17192. }
  17193. return '';
  17194. };
  17195. exports.getFileExtension = getFileExtension;
  17196. /**
  17197. * Returns whether the url passed is a cross domain request or not.
  17198. *
  17199. * @param {String} url The url to check
  17200. * @return {Boolean} Whether it is a cross domain request or not
  17201. * @method isCrossOrigin
  17202. */
  17203. var isCrossOrigin = function isCrossOrigin(url) {
  17204. var winLoc = _globalWindow2['default'].location;
  17205. var urlInfo = parseUrl(url);
  17206. // IE8 protocol relative urls will return ':' for protocol
  17207. var srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol;
  17208. // Check if url is for another domain/origin
  17209. // IE8 doesn't know location.origin, so we won't rely on it here
  17210. var crossOrigin = srcProtocol + urlInfo.host !== winLoc.protocol + winLoc.host;
  17211. return crossOrigin;
  17212. };
  17213. exports.isCrossOrigin = isCrossOrigin;
  17214. }, { "global/document": 1, "global/window": 2 }], 154: [function (_dereq_, module, exports) {
  17215. /**
  17216. * @file video.js
  17217. */
  17218. 'use strict';
  17219. exports.__esModule = true;
  17220. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  17221. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17222. var _globalWindow = _dereq_('global/window');
  17223. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  17224. var _globalDocument = _dereq_('global/document');
  17225. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  17226. var _setup = _dereq_('./setup');
  17227. var setup = _interopRequireWildcard(_setup);
  17228. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js');
  17229. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs);
  17230. var _component = _dereq_('./component');
  17231. var _component2 = _interopRequireDefault(_component);
  17232. var _eventTarget = _dereq_('./event-target');
  17233. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  17234. var _utilsEventsJs = _dereq_('./utils/events.js');
  17235. var Events = _interopRequireWildcard(_utilsEventsJs);
  17236. var _player = _dereq_('./player');
  17237. var _player2 = _interopRequireDefault(_player);
  17238. var _pluginsJs = _dereq_('./plugins.js');
  17239. var _pluginsJs2 = _interopRequireDefault(_pluginsJs);
  17240. var _srcJsUtilsMergeOptionsJs = _dereq_('../../src/js/utils/merge-options.js');
  17241. var _srcJsUtilsMergeOptionsJs2 = _interopRequireDefault(_srcJsUtilsMergeOptionsJs);
  17242. var _utilsFnJs = _dereq_('./utils/fn.js');
  17243. var Fn = _interopRequireWildcard(_utilsFnJs);
  17244. var _tracksTextTrackJs = _dereq_('./tracks/text-track.js');
  17245. var _tracksTextTrackJs2 = _interopRequireDefault(_tracksTextTrackJs);
  17246. var _tracksAudioTrackJs = _dereq_('./tracks/audio-track.js');
  17247. var _tracksAudioTrackJs2 = _interopRequireDefault(_tracksAudioTrackJs);
  17248. var _tracksVideoTrackJs = _dereq_('./tracks/video-track.js');
  17249. var _tracksVideoTrackJs2 = _interopRequireDefault(_tracksVideoTrackJs);
  17250. var _objectAssign = _dereq_('object.assign');
  17251. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  17252. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js');
  17253. var _utilsFormatTimeJs = _dereq_('./utils/format-time.js');
  17254. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  17255. var _utilsLogJs = _dereq_('./utils/log.js');
  17256. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  17257. var _utilsDomJs = _dereq_('./utils/dom.js');
  17258. var Dom = _interopRequireWildcard(_utilsDomJs);
  17259. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  17260. var browser = _interopRequireWildcard(_utilsBrowserJs);
  17261. var _utilsUrlJs = _dereq_('./utils/url.js');
  17262. var Url = _interopRequireWildcard(_utilsUrlJs);
  17263. var _extendJs = _dereq_('./extend.js');
  17264. var _extendJs2 = _interopRequireDefault(_extendJs);
  17265. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge');
  17266. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge);
  17267. var _utilsCreateDeprecationProxyJs = _dereq_('./utils/create-deprecation-proxy.js');
  17268. var _utilsCreateDeprecationProxyJs2 = _interopRequireDefault(_utilsCreateDeprecationProxyJs);
  17269. var _xhr = _dereq_('xhr');
  17270. var _xhr2 = _interopRequireDefault(_xhr);
  17271. // Include the built-in techs
  17272. var _techTechJs = _dereq_('./tech/tech.js');
  17273. var _techTechJs2 = _interopRequireDefault(_techTechJs);
  17274. var _techHtml5Js = _dereq_('./tech/html5.js');
  17275. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js);
  17276. var _techFlashJs = _dereq_('./tech/flash.js');
  17277. var _techFlashJs2 = _interopRequireDefault(_techFlashJs);
  17278. // HTML5 Element Shim for IE8
  17279. if (typeof HTMLVideoElement === 'undefined') {
  17280. _globalDocument2['default'].createElement('video');
  17281. _globalDocument2['default'].createElement('audio');
  17282. _globalDocument2['default'].createElement('track');
  17283. }
  17284. /**
  17285. * Doubles as the main function for users to create a player instance and also
  17286. * the main library object.
  17287. * The `videojs` function can be used to initialize or retrieve a player.
  17288. * ```js
  17289. * var myPlayer = videojs('my_video_id');
  17290. * ```
  17291. *
  17292. * @param {String|Element} id Video element or video element ID
  17293. * @param {Object=} options Optional options object for config/settings
  17294. * @param {Function=} ready Optional ready callback
  17295. * @return {Player} A player instance
  17296. * @mixes videojs
  17297. * @method videojs
  17298. */
  17299. var videojs = function videojs(id, options, ready) {
  17300. var tag = undefined; // Element of ID
  17301. // Allow for element or ID to be passed in
  17302. // String ID
  17303. if (typeof id === 'string') {
  17304. // Adjust for jQuery ID syntax
  17305. if (id.indexOf('#') === 0) {
  17306. id = id.slice(1);
  17307. }
  17308. // If a player instance has already been created for this ID return it.
  17309. if (videojs.getPlayers()[id]) {
  17310. // If options or ready funtion are passed, warn
  17311. if (options) {
  17312. _utilsLogJs2['default'].warn('Player "' + id + '" is already initialised. Options will not be applied.');
  17313. }
  17314. if (ready) {
  17315. videojs.getPlayers()[id].ready(ready);
  17316. }
  17317. return videojs.getPlayers()[id];
  17318. // Otherwise get element for ID
  17319. } else {
  17320. tag = Dom.getEl(id);
  17321. }
  17322. // ID is a media element
  17323. } else {
  17324. tag = id;
  17325. }
  17326. // Check for a useable element
  17327. if (!tag || !tag.nodeName) {
  17328. // re: nodeName, could be a box div also
  17329. throw new TypeError('The element or ID supplied is not valid. (videojs)'); // Returns
  17330. }
  17331. // Element may have a player attr referring to an already created player instance.
  17332. // If not, set up a new player and return the instance.
  17333. return tag['player'] || _player2['default'].players[tag.playerId] || new _player2['default'](tag, options, ready);
  17334. };
  17335. // Add default styles
  17336. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE !== true) {
  17337. var style = Dom.$('.vjs-styles-defaults');
  17338. if (!style) {
  17339. style = stylesheet.createStyleElement('vjs-styles-defaults');
  17340. var head = Dom.$('head');
  17341. head.insertBefore(style, head.firstChild);
  17342. stylesheet.setTextContent(style, '\n .video-js {\n width: 300px;\n height: 150px;\n }\n\n .vjs-fluid {\n padding-top: 56.25%\n }\n ');
  17343. }
  17344. }
  17345. // Run Auto-load players
  17346. // You have to wait at least once in case this script is loaded after your video in the DOM (weird behavior only with minified version)
  17347. setup.autoSetupTimeout(1, videojs);
  17348. /*
  17349. * Current software version (semver)
  17350. *
  17351. * @type {String}
  17352. */
  17353. videojs.VERSION = '5.10.2';
  17354. /**
  17355. * The global options object. These are the settings that take effect
  17356. * if no overrides are specified when the player is created.
  17357. *
  17358. * ```js
  17359. * videojs.options.autoplay = true
  17360. * // -> all players will autoplay by default
  17361. * ```
  17362. *
  17363. * @type {Object}
  17364. */
  17365. videojs.options = _player2['default'].prototype.options_;
  17366. /**
  17367. * Get an object with the currently created players, keyed by player ID
  17368. *
  17369. * @return {Object} The created players
  17370. * @mixes videojs
  17371. * @method getPlayers
  17372. */
  17373. videojs.getPlayers = function () {
  17374. return _player2['default'].players;
  17375. };
  17376. /**
  17377. * For backward compatibility, expose players object.
  17378. *
  17379. * @deprecated
  17380. * @memberOf videojs
  17381. * @property {Object|Proxy} players
  17382. */
  17383. videojs.players = _utilsCreateDeprecationProxyJs2['default'](_player2['default'].players, {
  17384. get: 'Access to videojs.players is deprecated; use videojs.getPlayers instead',
  17385. set: 'Modification of videojs.players is deprecated'
  17386. });
  17387. /**
  17388. * Get a component class object by name
  17389. * ```js
  17390. * var VjsButton = videojs.getComponent('Button');
  17391. * // Create a new instance of the component
  17392. * var myButton = new VjsButton(myPlayer);
  17393. * ```
  17394. *
  17395. * @return {Component} Component identified by name
  17396. * @mixes videojs
  17397. * @method getComponent
  17398. */
  17399. videojs.getComponent = _component2['default'].getComponent;
  17400. /**
  17401. * Register a component so it can referred to by name
  17402. * Used when adding to other
  17403. * components, either through addChild
  17404. * `component.addChild('myComponent')`
  17405. * or through default children options
  17406. * `{ children: ['myComponent'] }`.
  17407. * ```js
  17408. * // Get a component to subclass
  17409. * var VjsButton = videojs.getComponent('Button');
  17410. * // Subclass the component (see 'extend' doc for more info)
  17411. * var MySpecialButton = videojs.extend(VjsButton, {});
  17412. * // Register the new component
  17413. * VjsButton.registerComponent('MySepcialButton', MySepcialButton);
  17414. * // (optionally) add the new component as a default player child
  17415. * myPlayer.addChild('MySepcialButton');
  17416. * ```
  17417. * NOTE: You could also just initialize the component before adding.
  17418. * `component.addChild(new MyComponent());`
  17419. *
  17420. * @param {String} The class name of the component
  17421. * @param {Component} The component class
  17422. * @return {Component} The newly registered component
  17423. * @mixes videojs
  17424. * @method registerComponent
  17425. */
  17426. videojs.registerComponent = function (name, comp) {
  17427. if (_techTechJs2['default'].isTech(comp)) {
  17428. _utilsLogJs2['default'].warn('The ' + name + ' tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)');
  17429. }
  17430. _component2['default'].registerComponent.call(_component2['default'], name, comp);
  17431. };
  17432. /**
  17433. * Get a Tech class object by name
  17434. * ```js
  17435. * var Html5 = videojs.getTech('Html5');
  17436. * // Create a new instance of the component
  17437. * var html5 = new Html5(options);
  17438. * ```
  17439. *
  17440. * @return {Tech} Tech identified by name
  17441. * @mixes videojs
  17442. * @method getComponent
  17443. */
  17444. videojs.getTech = _techTechJs2['default'].getTech;
  17445. /**
  17446. * Register a Tech so it can referred to by name.
  17447. * This is used in the tech order for the player.
  17448. *
  17449. * ```js
  17450. * // get the Html5 Tech
  17451. * var Html5 = videojs.getTech('Html5');
  17452. * var MyTech = videojs.extend(Html5, {});
  17453. * // Register the new Tech
  17454. * VjsButton.registerTech('Tech', MyTech);
  17455. * var player = videojs('myplayer', {
  17456. * techOrder: ['myTech', 'html5']
  17457. * });
  17458. * ```
  17459. *
  17460. * @param {String} The class name of the tech
  17461. * @param {Tech} The tech class
  17462. * @return {Tech} The newly registered Tech
  17463. * @mixes videojs
  17464. * @method registerTech
  17465. */
  17466. videojs.registerTech = _techTechJs2['default'].registerTech;
  17467. /**
  17468. * A suite of browser and device tests
  17469. *
  17470. * @type {Object}
  17471. * @private
  17472. */
  17473. videojs.browser = browser;
  17474. /**
  17475. * Whether or not the browser supports touch events. Included for backward
  17476. * compatibility with 4.x, but deprecated. Use `videojs.browser.TOUCH_ENABLED`
  17477. * instead going forward.
  17478. *
  17479. * @deprecated
  17480. * @type {Boolean}
  17481. */
  17482. videojs.TOUCH_ENABLED = browser.TOUCH_ENABLED;
  17483. /**
  17484. * Subclass an existing class
  17485. * Mimics ES6 subclassing with the `extend` keyword
  17486. * ```js
  17487. * // Create a basic javascript 'class'
  17488. * function MyClass(name){
  17489. * // Set a property at initialization
  17490. * this.myName = name;
  17491. * }
  17492. * // Create an instance method
  17493. * MyClass.prototype.sayMyName = function(){
  17494. * alert(this.myName);
  17495. * };
  17496. * // Subclass the exisitng class and change the name
  17497. * // when initializing
  17498. * var MySubClass = videojs.extend(MyClass, {
  17499. * constructor: function(name) {
  17500. * // Call the super class constructor for the subclass
  17501. * MyClass.call(this, name)
  17502. * }
  17503. * });
  17504. * // Create an instance of the new sub class
  17505. * var myInstance = new MySubClass('John');
  17506. * myInstance.sayMyName(); // -> should alert "John"
  17507. * ```
  17508. *
  17509. * @param {Function} The Class to subclass
  17510. * @param {Object} An object including instace methods for the new class
  17511. * Optionally including a `constructor` function
  17512. * @return {Function} The newly created subclass
  17513. * @mixes videojs
  17514. * @method extend
  17515. */
  17516. videojs.extend = _extendJs2['default'];
  17517. /**
  17518. * Merge two options objects recursively
  17519. * Performs a deep merge like lodash.merge but **only merges plain objects**
  17520. * (not arrays, elements, anything else)
  17521. * Other values will be copied directly from the second object.
  17522. * ```js
  17523. * var defaultOptions = {
  17524. * foo: true,
  17525. * bar: {
  17526. * a: true,
  17527. * b: [1,2,3]
  17528. * }
  17529. * };
  17530. * var newOptions = {
  17531. * foo: false,
  17532. * bar: {
  17533. * b: [4,5,6]
  17534. * }
  17535. * };
  17536. * var result = videojs.mergeOptions(defaultOptions, newOptions);
  17537. * // result.foo = false;
  17538. * // result.bar.a = true;
  17539. * // result.bar.b = [4,5,6];
  17540. * ```
  17541. *
  17542. * @param {Object} defaults The options object whose values will be overriden
  17543. * @param {Object} overrides The options object with values to override the first
  17544. * @param {Object} etc Any number of additional options objects
  17545. *
  17546. * @return {Object} a new object with the merged values
  17547. * @mixes videojs
  17548. * @method mergeOptions
  17549. */
  17550. videojs.mergeOptions = _srcJsUtilsMergeOptionsJs2['default'];
  17551. /**
  17552. * Change the context (this) of a function
  17553. *
  17554. * videojs.bind(newContext, function(){
  17555. * this === newContext
  17556. * });
  17557. *
  17558. * NOTE: as of v5.0 we require an ES5 shim, so you should use the native
  17559. * `function(){}.bind(newContext);` instead of this.
  17560. *
  17561. * @param {*} context The object to bind as scope
  17562. * @param {Function} fn The function to be bound to a scope
  17563. * @param {Number=} uid An optional unique ID for the function to be set
  17564. * @return {Function}
  17565. */
  17566. videojs.bind = Fn.bind;
  17567. /**
  17568. * Create a Video.js player plugin
  17569. * Plugins are only initialized when options for the plugin are included
  17570. * in the player options, or the plugin function on the player instance is
  17571. * called.
  17572. * **See the plugin guide in the docs for a more detailed example**
  17573. * ```js
  17574. * // Make a plugin that alerts when the player plays
  17575. * videojs.plugin('myPlugin', function(myPluginOptions) {
  17576. * myPluginOptions = myPluginOptions || {};
  17577. *
  17578. * var player = this;
  17579. * var alertText = myPluginOptions.text || 'Player is playing!'
  17580. *
  17581. * player.on('play', function(){
  17582. * alert(alertText);
  17583. * });
  17584. * });
  17585. * // USAGE EXAMPLES
  17586. * // EXAMPLE 1: New player with plugin options, call plugin immediately
  17587. * var player1 = videojs('idOne', {
  17588. * myPlugin: {
  17589. * text: 'Custom text!'
  17590. * }
  17591. * });
  17592. * // Click play
  17593. * // --> Should alert 'Custom text!'
  17594. * // EXAMPLE 3: New player, initialize plugin later
  17595. * var player3 = videojs('idThree');
  17596. * // Click play
  17597. * // --> NO ALERT
  17598. * // Click pause
  17599. * // Initialize plugin using the plugin function on the player instance
  17600. * player3.myPlugin({
  17601. * text: 'Plugin added later!'
  17602. * });
  17603. * // Click play
  17604. * // --> Should alert 'Plugin added later!'
  17605. * ```
  17606. *
  17607. * @param {String} name The plugin name
  17608. * @param {Function} fn The plugin function that will be called with options
  17609. * @mixes videojs
  17610. * @method plugin
  17611. */
  17612. videojs.plugin = _pluginsJs2['default'];
  17613. /**
  17614. * Adding languages so that they're available to all players.
  17615. * ```js
  17616. * videojs.addLanguage('es', { 'Hello': 'Hola' });
  17617. * ```
  17618. *
  17619. * @param {String} code The language code or dictionary property
  17620. * @param {Object} data The data values to be translated
  17621. * @return {Object} The resulting language dictionary object
  17622. * @mixes videojs
  17623. * @method addLanguage
  17624. */
  17625. videojs.addLanguage = function (code, data) {
  17626. var _merge;
  17627. code = ('' + code).toLowerCase();
  17628. return _lodashCompatObjectMerge2['default'](videojs.options.languages, (_merge = {}, _merge[code] = data, _merge))[code];
  17629. };
  17630. /**
  17631. * Log debug messages.
  17632. *
  17633. * @param {...Object} messages One or more messages to log
  17634. */
  17635. videojs.log = _utilsLogJs2['default'];
  17636. /**
  17637. * Creates an emulated TimeRange object.
  17638. *
  17639. * @param {Number|Array} start Start time in seconds or an array of ranges
  17640. * @param {Number} end End time in seconds
  17641. * @return {Object} Fake TimeRange object
  17642. * @method createTimeRange
  17643. */
  17644. videojs.createTimeRange = videojs.createTimeRanges = _utilsTimeRangesJs.createTimeRanges;
  17645. /**
  17646. * Format seconds as a time string, H:MM:SS or M:SS
  17647. * Supplying a guide (in seconds) will force a number of leading zeros
  17648. * to cover the length of the guide
  17649. *
  17650. * @param {Number} seconds Number of seconds to be turned into a string
  17651. * @param {Number} guide Number (in seconds) to model the string after
  17652. * @return {String} Time formatted as H:MM:SS or M:SS
  17653. * @method formatTime
  17654. */
  17655. videojs.formatTime = _utilsFormatTimeJs2['default'];
  17656. /**
  17657. * Resolve and parse the elements of a URL
  17658. *
  17659. * @param {String} url The url to parse
  17660. * @return {Object} An object of url details
  17661. * @method parseUrl
  17662. */
  17663. videojs.parseUrl = Url.parseUrl;
  17664. /**
  17665. * Returns whether the url passed is a cross domain request or not.
  17666. *
  17667. * @param {String} url The url to check
  17668. * @return {Boolean} Whether it is a cross domain request or not
  17669. * @method isCrossOrigin
  17670. */
  17671. videojs.isCrossOrigin = Url.isCrossOrigin;
  17672. /**
  17673. * Event target class.
  17674. *
  17675. * @type {Function}
  17676. */
  17677. videojs.EventTarget = _eventTarget2['default'];
  17678. /**
  17679. * Add an event listener to element
  17680. * It stores the handler function in a separate cache object
  17681. * and adds a generic handler to the element's event,
  17682. * along with a unique id (guid) to the element.
  17683. *
  17684. * @param {Element|Object} elem Element or object to bind listeners to
  17685. * @param {String|Array} type Type of event to bind to.
  17686. * @param {Function} fn Event listener.
  17687. * @method on
  17688. */
  17689. videojs.on = Events.on;
  17690. /**
  17691. * Trigger a listener only once for an event
  17692. *
  17693. * @param {Element|Object} elem Element or object to
  17694. * @param {String|Array} type Name/type of event
  17695. * @param {Function} fn Event handler function
  17696. * @method one
  17697. */
  17698. videojs.one = Events.one;
  17699. /**
  17700. * Removes event listeners from an element
  17701. *
  17702. * @param {Element|Object} elem Object to remove listeners from
  17703. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  17704. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  17705. * @method off
  17706. */
  17707. videojs.off = Events.off;
  17708. /**
  17709. * Trigger an event for an element
  17710. *
  17711. * @param {Element|Object} elem Element to trigger an event on
  17712. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  17713. * @param {Object} [hash] data hash to pass along with the event
  17714. * @return {Boolean=} Returned only if default was prevented
  17715. * @method trigger
  17716. */
  17717. videojs.trigger = Events.trigger;
  17718. /**
  17719. * A cross-browser XMLHttpRequest wrapper. Here's a simple example:
  17720. *
  17721. * videojs.xhr({
  17722. * body: someJSONString,
  17723. * uri: "/foo",
  17724. * headers: {
  17725. * "Content-Type": "application/json"
  17726. * }
  17727. * }, function (err, resp, body) {
  17728. * // check resp.statusCode
  17729. * });
  17730. *
  17731. * Check out the [full
  17732. * documentation](https://github.com/Raynos/xhr/blob/v2.1.0/README.md)
  17733. * for more options.
  17734. *
  17735. * @param {Object} options settings for the request.
  17736. * @return {XMLHttpRequest|XDomainRequest} the request object.
  17737. * @see https://github.com/Raynos/xhr
  17738. */
  17739. videojs.xhr = _xhr2['default'];
  17740. /**
  17741. * TextTrack class
  17742. *
  17743. * @type {Function}
  17744. */
  17745. videojs.TextTrack = _tracksTextTrackJs2['default'];
  17746. /**
  17747. * export the AudioTrack class so that source handlers can create
  17748. * AudioTracks and then add them to the players AudioTrackList
  17749. *
  17750. * @type {Function}
  17751. */
  17752. videojs.AudioTrack = _tracksAudioTrackJs2['default'];
  17753. /**
  17754. * export the VideoTrack class so that source handlers can create
  17755. * VideoTracks and then add them to the players VideoTrackList
  17756. *
  17757. * @type {Function}
  17758. */
  17759. videojs.VideoTrack = _tracksVideoTrackJs2['default'];
  17760. /**
  17761. * Determines, via duck typing, whether or not a value is a DOM element.
  17762. *
  17763. * @method isEl
  17764. * @param {Mixed} value
  17765. * @return {Boolean}
  17766. */
  17767. videojs.isEl = Dom.isEl;
  17768. /**
  17769. * Determines, via duck typing, whether or not a value is a text node.
  17770. *
  17771. * @method isTextNode
  17772. * @param {Mixed} value
  17773. * @return {Boolean}
  17774. */
  17775. videojs.isTextNode = Dom.isTextNode;
  17776. /**
  17777. * Creates an element and applies properties.
  17778. *
  17779. * @method createEl
  17780. * @param {String} [tagName='div'] Name of tag to be created.
  17781. * @param {Object} [properties={}] Element properties to be applied.
  17782. * @param {Object} [attributes={}] Element attributes to be applied.
  17783. * @return {Element}
  17784. */
  17785. videojs.createEl = Dom.createEl;
  17786. /**
  17787. * Check if an element has a CSS class
  17788. *
  17789. * @method hasClass
  17790. * @param {Element} element Element to check
  17791. * @param {String} classToCheck Classname to check
  17792. */
  17793. videojs.hasClass = Dom.hasElClass;
  17794. /**
  17795. * Add a CSS class name to an element
  17796. *
  17797. * @method addClass
  17798. * @param {Element} element Element to add class name to
  17799. * @param {String} classToAdd Classname to add
  17800. */
  17801. videojs.addClass = Dom.addElClass;
  17802. /**
  17803. * Remove a CSS class name from an element
  17804. *
  17805. * @method removeClass
  17806. * @param {Element} element Element to remove from class name
  17807. * @param {String} classToRemove Classname to remove
  17808. */
  17809. videojs.removeClass = Dom.removeElClass;
  17810. /**
  17811. * Adds or removes a CSS class name on an element depending on an optional
  17812. * condition or the presence/absence of the class name.
  17813. *
  17814. * @method toggleElClass
  17815. * @param {Element} element
  17816. * @param {String} classToToggle
  17817. * @param {Boolean|Function} [predicate]
  17818. * Can be a function that returns a Boolean. If `true`, the class
  17819. * will be added; if `false`, the class will be removed. If not
  17820. * given, the class will be added if not present and vice versa.
  17821. */
  17822. videojs.toggleClass = Dom.toggleElClass;
  17823. /**
  17824. * Apply attributes to an HTML element.
  17825. *
  17826. * @method setAttributes
  17827. * @param {Element} el Target element.
  17828. * @param {Object=} attributes Element attributes to be applied.
  17829. */
  17830. videojs.setAttributes = Dom.setElAttributes;
  17831. /**
  17832. * Get an element's attribute values, as defined on the HTML tag
  17833. * Attributes are not the same as properties. They're defined on the tag
  17834. * or with setAttribute (which shouldn't be used with HTML)
  17835. * This will return true or false for boolean attributes.
  17836. *
  17837. * @method getAttributes
  17838. * @param {Element} tag Element from which to get tag attributes
  17839. * @return {Object}
  17840. */
  17841. videojs.getAttributes = Dom.getElAttributes;
  17842. /**
  17843. * Empties the contents of an element.
  17844. *
  17845. * @method emptyEl
  17846. * @param {Element} el
  17847. * @return {Element}
  17848. */
  17849. videojs.emptyEl = Dom.emptyEl;
  17850. /**
  17851. * Normalizes and appends content to an element.
  17852. *
  17853. * The content for an element can be passed in multiple types and
  17854. * combinations, whose behavior is as follows:
  17855. *
  17856. * - String
  17857. * Normalized into a text node.
  17858. *
  17859. * - Element, TextNode
  17860. * Passed through.
  17861. *
  17862. * - Array
  17863. * A one-dimensional array of strings, elements, nodes, or functions (which
  17864. * return single strings, elements, or nodes).
  17865. *
  17866. * - Function
  17867. * If the sole argument, is expected to produce a string, element,
  17868. * node, or array.
  17869. *
  17870. * @method appendContent
  17871. * @param {Element} el
  17872. * @param {String|Element|TextNode|Array|Function} content
  17873. * @return {Element}
  17874. */
  17875. videojs.appendContent = Dom.appendContent;
  17876. /**
  17877. * Normalizes and inserts content into an element; this is identical to
  17878. * `appendContent()`, except it empties the element first.
  17879. *
  17880. * The content for an element can be passed in multiple types and
  17881. * combinations, whose behavior is as follows:
  17882. *
  17883. * - String
  17884. * Normalized into a text node.
  17885. *
  17886. * - Element, TextNode
  17887. * Passed through.
  17888. *
  17889. * - Array
  17890. * A one-dimensional array of strings, elements, nodes, or functions (which
  17891. * return single strings, elements, or nodes).
  17892. *
  17893. * - Function
  17894. * If the sole argument, is expected to produce a string, element,
  17895. * node, or array.
  17896. *
  17897. * @method insertContent
  17898. * @param {Element} el
  17899. * @param {String|Element|TextNode|Array|Function} content
  17900. * @return {Element}
  17901. */
  17902. videojs.insertContent = Dom.insertContent;
  17903. /*
  17904. * Custom Universal Module Definition (UMD)
  17905. *
  17906. * Video.js will never be a non-browser lib so we can simplify UMD a bunch and
  17907. * still support requirejs and browserify. This also needs to be closure
  17908. * compiler compatible, so string keys are used.
  17909. */
  17910. if (typeof define === 'function' && define['amd']) {
  17911. define('videojs', [], function () {
  17912. return videojs;
  17913. });
  17914. // checking that module is an object too because of umdjs/umd#35
  17915. } else if (typeof exports === 'object' && typeof module === 'object') {
  17916. module['exports'] = videojs;
  17917. }
  17918. exports['default'] = videojs;
  17919. module.exports = exports['default'];
  17920. }, { "../../src/js/utils/merge-options.js": 149, "./component": 67, "./event-target": 104, "./extend.js": 105, "./player": 113, "./plugins.js": 114, "./setup": 118, "./tech/flash.js": 121, "./tech/html5.js": 122, "./tech/tech.js": 124, "./tracks/audio-track.js": 126, "./tracks/text-track.js": 134, "./tracks/video-track.js": 139, "./utils/browser.js": 140, "./utils/create-deprecation-proxy.js": 142, "./utils/dom.js": 143, "./utils/events.js": 144, "./utils/fn.js": 145, "./utils/format-time.js": 146, "./utils/log.js": 148, "./utils/stylesheet.js": 150, "./utils/time-ranges.js": 151, "./utils/url.js": 153, "global/document": 1, "global/window": 2, "lodash-compat/object/merge": 40, "object.assign": 45, "xhr": 56 }]
  17921. }, {}, [154])(154)
  17922. });
  17923. //# sourceMappingURL=video.js.map
  17924. /* vtt.js - v0.12.1 (https://github.com/mozilla/vtt.js) built on 08-07-2015 */
  17925. (function (root) {
  17926. var vttjs = root.vttjs = {};
  17927. var cueShim = vttjs.VTTCue;
  17928. var regionShim = vttjs.VTTRegion;
  17929. var oldVTTCue = root.VTTCue;
  17930. var oldVTTRegion = root.VTTRegion;
  17931. vttjs.shim = function () {
  17932. vttjs.VTTCue = cueShim;
  17933. vttjs.VTTRegion = regionShim;
  17934. };
  17935. vttjs.restore = function () {
  17936. vttjs.VTTCue = oldVTTCue;
  17937. vttjs.VTTRegion = oldVTTRegion;
  17938. };
  17939. }(this));
  17940. /**
  17941. * Copyright 2013 vtt.js Contributors
  17942. *
  17943. * Licensed under the Apache License, Version 2.0 (the "License");
  17944. * you may not use this file except in compliance with the License.
  17945. * You may obtain a copy of the License at
  17946. *
  17947. * http://www.apache.org/licenses/LICENSE-2.0
  17948. *
  17949. * Unless required by applicable law or agreed to in writing, software
  17950. * distributed under the License is distributed on an "AS IS" BASIS,
  17951. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17952. * See the License for the specific language governing permissions and
  17953. * limitations under the License.
  17954. */
  17955. (function (root, vttjs) {
  17956. var autoKeyword = "auto";
  17957. var directionSetting = {
  17958. "": true,
  17959. "lr": true,
  17960. "rl": true
  17961. };
  17962. var alignSetting = {
  17963. "start": true,
  17964. "middle": true,
  17965. "end": true,
  17966. "left": true,
  17967. "right": true
  17968. };
  17969. function findDirectionSetting(value) {
  17970. if (typeof value !== "string") {
  17971. return false;
  17972. }
  17973. var dir = directionSetting[value.toLowerCase()];
  17974. return dir ? value.toLowerCase() : false;
  17975. }
  17976. function findAlignSetting(value) {
  17977. if (typeof value !== "string") {
  17978. return false;
  17979. }
  17980. var align = alignSetting[value.toLowerCase()];
  17981. return align ? value.toLowerCase() : false;
  17982. }
  17983. function extend(obj) {
  17984. var i = 1;
  17985. for (; i < arguments.length; i++) {
  17986. var cobj = arguments[i];
  17987. for (var p in cobj) {
  17988. obj[p] = cobj[p];
  17989. }
  17990. }
  17991. return obj;
  17992. }
  17993. function VTTCue(startTime, endTime, text) {
  17994. var cue = this;
  17995. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  17996. var baseObj = {};
  17997. if (isIE8) {
  17998. cue = document.createElement('custom');
  17999. } else {
  18000. baseObj.enumerable = true;
  18001. }
  18002. /**
  18003. * Shim implementation specific properties. These properties are not in
  18004. * the spec.
  18005. */
  18006. // Lets us know when the VTTCue's data has changed in such a way that we need
  18007. // to recompute its display state. This lets us compute its display state
  18008. // lazily.
  18009. cue.hasBeenReset = false;
  18010. /**
  18011. * VTTCue and TextTrackCue properties
  18012. * http://dev.w3.org/html5/webvtt/#vttcue-interface
  18013. */
  18014. var _id = "";
  18015. var _pauseOnExit = false;
  18016. var _startTime = startTime;
  18017. var _endTime = endTime;
  18018. var _text = text;
  18019. var _region = null;
  18020. var _vertical = "";
  18021. var _snapToLines = true;
  18022. var _line = "auto";
  18023. var _lineAlign = "start";
  18024. var _position = 50;
  18025. var _positionAlign = "middle";
  18026. var _size = 50;
  18027. var _align = "middle";
  18028. Object.defineProperty(cue,
  18029. "id", extend({}, baseObj, {
  18030. get: function () {
  18031. return _id;
  18032. },
  18033. set: function (value) {
  18034. _id = "" + value;
  18035. }
  18036. }));
  18037. Object.defineProperty(cue,
  18038. "pauseOnExit", extend({}, baseObj, {
  18039. get: function () {
  18040. return _pauseOnExit;
  18041. },
  18042. set: function (value) {
  18043. _pauseOnExit = !!value;
  18044. }
  18045. }));
  18046. Object.defineProperty(cue,
  18047. "startTime", extend({}, baseObj, {
  18048. get: function () {
  18049. return _startTime;
  18050. },
  18051. set: function (value) {
  18052. if (typeof value !== "number") {
  18053. throw new TypeError("Start time must be set to a number.");
  18054. }
  18055. _startTime = value;
  18056. this.hasBeenReset = true;
  18057. }
  18058. }));
  18059. Object.defineProperty(cue,
  18060. "endTime", extend({}, baseObj, {
  18061. get: function () {
  18062. return _endTime;
  18063. },
  18064. set: function (value) {
  18065. if (typeof value !== "number") {
  18066. throw new TypeError("End time must be set to a number.");
  18067. }
  18068. _endTime = value;
  18069. this.hasBeenReset = true;
  18070. }
  18071. }));
  18072. Object.defineProperty(cue,
  18073. "text", extend({}, baseObj, {
  18074. get: function () {
  18075. return _text;
  18076. },
  18077. set: function (value) {
  18078. _text = "" + value;
  18079. this.hasBeenReset = true;
  18080. }
  18081. }));
  18082. Object.defineProperty(cue,
  18083. "region", extend({}, baseObj, {
  18084. get: function () {
  18085. return _region;
  18086. },
  18087. set: function (value) {
  18088. _region = value;
  18089. this.hasBeenReset = true;
  18090. }
  18091. }));
  18092. Object.defineProperty(cue,
  18093. "vertical", extend({}, baseObj, {
  18094. get: function () {
  18095. return _vertical;
  18096. },
  18097. set: function (value) {
  18098. var setting = findDirectionSetting(value);
  18099. // Have to check for false because the setting an be an empty string.
  18100. if (setting === false) {
  18101. throw new SyntaxError("An invalid or illegal string was specified.");
  18102. }
  18103. _vertical = setting;
  18104. this.hasBeenReset = true;
  18105. }
  18106. }));
  18107. Object.defineProperty(cue,
  18108. "snapToLines", extend({}, baseObj, {
  18109. get: function () {
  18110. return _snapToLines;
  18111. },
  18112. set: function (value) {
  18113. _snapToLines = !!value;
  18114. this.hasBeenReset = true;
  18115. }
  18116. }));
  18117. Object.defineProperty(cue,
  18118. "line", extend({}, baseObj, {
  18119. get: function () {
  18120. return _line;
  18121. },
  18122. set: function (value) {
  18123. if (typeof value !== "number" && value !== autoKeyword) {
  18124. throw new SyntaxError("An invalid number or illegal string was specified.");
  18125. }
  18126. _line = value;
  18127. this.hasBeenReset = true;
  18128. }
  18129. }));
  18130. Object.defineProperty(cue,
  18131. "lineAlign", extend({}, baseObj, {
  18132. get: function () {
  18133. return _lineAlign;
  18134. },
  18135. set: function (value) {
  18136. var setting = findAlignSetting(value);
  18137. if (!setting) {
  18138. throw new SyntaxError("An invalid or illegal string was specified.");
  18139. }
  18140. _lineAlign = setting;
  18141. this.hasBeenReset = true;
  18142. }
  18143. }));
  18144. Object.defineProperty(cue,
  18145. "position", extend({}, baseObj, {
  18146. get: function () {
  18147. return _position;
  18148. },
  18149. set: function (value) {
  18150. if (value < 0 || value > 100) {
  18151. throw new Error("Position must be between 0 and 100.");
  18152. }
  18153. _position = value;
  18154. this.hasBeenReset = true;
  18155. }
  18156. }));
  18157. Object.defineProperty(cue,
  18158. "positionAlign", extend({}, baseObj, {
  18159. get: function () {
  18160. return _positionAlign;
  18161. },
  18162. set: function (value) {
  18163. var setting = findAlignSetting(value);
  18164. if (!setting) {
  18165. throw new SyntaxError("An invalid or illegal string was specified.");
  18166. }
  18167. _positionAlign = setting;
  18168. this.hasBeenReset = true;
  18169. }
  18170. }));
  18171. Object.defineProperty(cue,
  18172. "size", extend({}, baseObj, {
  18173. get: function () {
  18174. return _size;
  18175. },
  18176. set: function (value) {
  18177. if (value < 0 || value > 100) {
  18178. throw new Error("Size must be between 0 and 100.");
  18179. }
  18180. _size = value;
  18181. this.hasBeenReset = true;
  18182. }
  18183. }));
  18184. Object.defineProperty(cue,
  18185. "align", extend({}, baseObj, {
  18186. get: function () {
  18187. return _align;
  18188. },
  18189. set: function (value) {
  18190. var setting = findAlignSetting(value);
  18191. if (!setting) {
  18192. throw new SyntaxError("An invalid or illegal string was specified.");
  18193. }
  18194. _align = setting;
  18195. this.hasBeenReset = true;
  18196. }
  18197. }));
  18198. /**
  18199. * Other <track> spec defined properties
  18200. */
  18201. // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-display-state
  18202. cue.displayState = undefined;
  18203. if (isIE8) {
  18204. return cue;
  18205. }
  18206. }
  18207. /**
  18208. * VTTCue methods
  18209. */
  18210. VTTCue.prototype.getCueAsHTML = function () {
  18211. // Assume WebVTT.convertCueToDOMTree is on the global.
  18212. return WebVTT.convertCueToDOMTree(window, this.text);
  18213. };
  18214. root.VTTCue = root.VTTCue || VTTCue;
  18215. vttjs.VTTCue = VTTCue;
  18216. }(this, (this.vttjs || {})));
  18217. /**
  18218. * Copyright 2013 vtt.js Contributors
  18219. *
  18220. * Licensed under the Apache License, Version 2.0 (the "License");
  18221. * you may not use this file except in compliance with the License.
  18222. * You may obtain a copy of the License at
  18223. *
  18224. * http://www.apache.org/licenses/LICENSE-2.0
  18225. *
  18226. * Unless required by applicable law or agreed to in writing, software
  18227. * distributed under the License is distributed on an "AS IS" BASIS,
  18228. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18229. * See the License for the specific language governing permissions and
  18230. * limitations under the License.
  18231. */
  18232. (function (root, vttjs) {
  18233. var scrollSetting = {
  18234. "": true,
  18235. "up": true
  18236. };
  18237. function findScrollSetting(value) {
  18238. if (typeof value !== "string") {
  18239. return false;
  18240. }
  18241. var scroll = scrollSetting[value.toLowerCase()];
  18242. return scroll ? value.toLowerCase() : false;
  18243. }
  18244. function isValidPercentValue(value) {
  18245. return typeof value === "number" && (value >= 0 && value <= 100);
  18246. }
  18247. // VTTRegion shim http://dev.w3.org/html5/webvtt/#vttregion-interface
  18248. function VTTRegion() {
  18249. var _width = 100;
  18250. var _lines = 3;
  18251. var _regionAnchorX = 0;
  18252. var _regionAnchorY = 100;
  18253. var _viewportAnchorX = 0;
  18254. var _viewportAnchorY = 100;
  18255. var _scroll = "";
  18256. Object.defineProperties(this, {
  18257. "width": {
  18258. enumerable: true,
  18259. get: function () {
  18260. return _width;
  18261. },
  18262. set: function (value) {
  18263. if (!isValidPercentValue(value)) {
  18264. throw new Error("Width must be between 0 and 100.");
  18265. }
  18266. _width = value;
  18267. }
  18268. },
  18269. "lines": {
  18270. enumerable: true,
  18271. get: function () {
  18272. return _lines;
  18273. },
  18274. set: function (value) {
  18275. if (typeof value !== "number") {
  18276. throw new TypeError("Lines must be set to a number.");
  18277. }
  18278. _lines = value;
  18279. }
  18280. },
  18281. "regionAnchorY": {
  18282. enumerable: true,
  18283. get: function () {
  18284. return _regionAnchorY;
  18285. },
  18286. set: function (value) {
  18287. if (!isValidPercentValue(value)) {
  18288. throw new Error("RegionAnchorX must be between 0 and 100.");
  18289. }
  18290. _regionAnchorY = value;
  18291. }
  18292. },
  18293. "regionAnchorX": {
  18294. enumerable: true,
  18295. get: function () {
  18296. return _regionAnchorX;
  18297. },
  18298. set: function (value) {
  18299. if (!isValidPercentValue(value)) {
  18300. throw new Error("RegionAnchorY must be between 0 and 100.");
  18301. }
  18302. _regionAnchorX = value;
  18303. }
  18304. },
  18305. "viewportAnchorY": {
  18306. enumerable: true,
  18307. get: function () {
  18308. return _viewportAnchorY;
  18309. },
  18310. set: function (value) {
  18311. if (!isValidPercentValue(value)) {
  18312. throw new Error("ViewportAnchorY must be between 0 and 100.");
  18313. }
  18314. _viewportAnchorY = value;
  18315. }
  18316. },
  18317. "viewportAnchorX": {
  18318. enumerable: true,
  18319. get: function () {
  18320. return _viewportAnchorX;
  18321. },
  18322. set: function (value) {
  18323. if (!isValidPercentValue(value)) {
  18324. throw new Error("ViewportAnchorX must be between 0 and 100.");
  18325. }
  18326. _viewportAnchorX = value;
  18327. }
  18328. },
  18329. "scroll": {
  18330. enumerable: true,
  18331. get: function () {
  18332. return _scroll;
  18333. },
  18334. set: function (value) {
  18335. var setting = findScrollSetting(value);
  18336. // Have to check for false as an empty string is a legal value.
  18337. if (setting === false) {
  18338. throw new SyntaxError("An invalid or illegal string was specified.");
  18339. }
  18340. _scroll = setting;
  18341. }
  18342. }
  18343. });
  18344. }
  18345. root.VTTRegion = root.VTTRegion || VTTRegion;
  18346. vttjs.VTTRegion = VTTRegion;
  18347. }(this, (this.vttjs || {})));
  18348. /**
  18349. * Copyright 2013 vtt.js Contributors
  18350. *
  18351. * Licensed under the Apache License, Version 2.0 (the "License");
  18352. * you may not use this file except in compliance with the License.
  18353. * You may obtain a copy of the License at
  18354. *
  18355. * http://www.apache.org/licenses/LICENSE-2.0
  18356. *
  18357. * Unless required by applicable law or agreed to in writing, software
  18358. * distributed under the License is distributed on an "AS IS" BASIS,
  18359. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18360. * See the License for the specific language governing permissions and
  18361. * limitations under the License.
  18362. */
  18363. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  18364. /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
  18365. (function (global) {
  18366. var _objCreate = Object.create || (function () {
  18367. function F() { }
  18368. return function (o) {
  18369. if (arguments.length !== 1) {
  18370. throw new Error('Object.create shim only accepts one parameter.');
  18371. }
  18372. F.prototype = o;
  18373. return new F();
  18374. };
  18375. })();
  18376. // Creates a new ParserError object from an errorData object. The errorData
  18377. // object should have default code and message properties. The default message
  18378. // property can be overriden by passing in a message parameter.
  18379. // See ParsingError.Errors below for acceptable errors.
  18380. function ParsingError(errorData, message) {
  18381. this.name = "ParsingError";
  18382. this.code = errorData.code;
  18383. this.message = message || errorData.message;
  18384. }
  18385. ParsingError.prototype = _objCreate(Error.prototype);
  18386. ParsingError.prototype.constructor = ParsingError;
  18387. // ParsingError metadata for acceptable ParsingErrors.
  18388. ParsingError.Errors = {
  18389. BadSignature: {
  18390. code: 0,
  18391. message: "Malformed WebVTT signature."
  18392. },
  18393. BadTimeStamp: {
  18394. code: 1,
  18395. message: "Malformed time stamp."
  18396. }
  18397. };
  18398. // Try to parse input as a time stamp.
  18399. function parseTimeStamp(input) {
  18400. function computeSeconds(h, m, s, f) {
  18401. return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000;
  18402. }
  18403. var m = input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);
  18404. if (!m) {
  18405. return null;
  18406. }
  18407. if (m[3]) {
  18408. // Timestamp takes the form of [hours]:[minutes]:[seconds].[milliseconds]
  18409. return computeSeconds(m[1], m[2], m[3].replace(":", ""), m[4]);
  18410. } else if (m[1] > 59) {
  18411. // Timestamp takes the form of [hours]:[minutes].[milliseconds]
  18412. // First position is hours as it's over 59.
  18413. return computeSeconds(m[1], m[2], 0, m[4]);
  18414. } else {
  18415. // Timestamp takes the form of [minutes]:[seconds].[milliseconds]
  18416. return computeSeconds(0, m[1], m[2], m[4]);
  18417. }
  18418. }
  18419. // A settings object holds key/value pairs and will ignore anything but the first
  18420. // assignment to a specific key.
  18421. function Settings() {
  18422. this.values = _objCreate(null);
  18423. }
  18424. Settings.prototype = {
  18425. // Only accept the first assignment to any key.
  18426. set: function (k, v) {
  18427. if (!this.get(k) && v !== "") {
  18428. this.values[k] = v;
  18429. }
  18430. },
  18431. // Return the value for a key, or a default value.
  18432. // If 'defaultKey' is passed then 'dflt' is assumed to be an object with
  18433. // a number of possible default values as properties where 'defaultKey' is
  18434. // the key of the property that will be chosen; otherwise it's assumed to be
  18435. // a single value.
  18436. get: function (k, dflt, defaultKey) {
  18437. if (defaultKey) {
  18438. return this.has(k) ? this.values[k] : dflt[defaultKey];
  18439. }
  18440. return this.has(k) ? this.values[k] : dflt;
  18441. },
  18442. // Check whether we have a value for a key.
  18443. has: function (k) {
  18444. return k in this.values;
  18445. },
  18446. // Accept a setting if its one of the given alternatives.
  18447. alt: function (k, v, a) {
  18448. for (var n = 0; n < a.length; ++n) {
  18449. if (v === a[n]) {
  18450. this.set(k, v);
  18451. break;
  18452. }
  18453. }
  18454. },
  18455. // Accept a setting if its a valid (signed) integer.
  18456. integer: function (k, v) {
  18457. if (/^-?\d+$/.test(v)) { // integer
  18458. this.set(k, parseInt(v, 10));
  18459. }
  18460. },
  18461. // Accept a setting if its a valid percentage.
  18462. percent: function (k, v) {
  18463. var m;
  18464. if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) {
  18465. v = parseFloat(v);
  18466. if (v >= 0 && v <= 100) {
  18467. this.set(k, v);
  18468. return true;
  18469. }
  18470. }
  18471. return false;
  18472. }
  18473. };
  18474. // Helper function to parse input into groups separated by 'groupDelim', and
  18475. // interprete each group as a key/value pair separated by 'keyValueDelim'.
  18476. function parseOptions(input, callback, keyValueDelim, groupDelim) {
  18477. var groups = groupDelim ? input.split(groupDelim) : [input];
  18478. for (var i in groups) {
  18479. if (typeof groups[i] !== "string") {
  18480. continue;
  18481. }
  18482. var kv = groups[i].split(keyValueDelim);
  18483. if (kv.length !== 2) {
  18484. continue;
  18485. }
  18486. var k = kv[0];
  18487. var v = kv[1];
  18488. callback(k, v);
  18489. }
  18490. }
  18491. function parseCue(input, cue, regionList) {
  18492. // Remember the original input if we need to throw an error.
  18493. var oInput = input;
  18494. // 4.1 WebVTT timestamp
  18495. function consumeTimeStamp() {
  18496. var ts = parseTimeStamp(input);
  18497. if (ts === null) {
  18498. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  18499. "Malformed timestamp: " + oInput);
  18500. }
  18501. // Remove time stamp from input.
  18502. input = input.replace(/^[^\sa-zA-Z-]+/, "");
  18503. return ts;
  18504. }
  18505. // 4.4.2 WebVTT cue settings
  18506. function consumeCueSettings(input, cue) {
  18507. var settings = new Settings();
  18508. parseOptions(input, function (k, v) {
  18509. switch (k) {
  18510. case "region":
  18511. // Find the last region we parsed with the same region id.
  18512. for (var i = regionList.length - 1; i >= 0; i--) {
  18513. if (regionList[i].id === v) {
  18514. settings.set(k, regionList[i].region);
  18515. break;
  18516. }
  18517. }
  18518. break;
  18519. case "vertical":
  18520. settings.alt(k, v, ["rl", "lr"]);
  18521. break;
  18522. case "line":
  18523. var vals = v.split(","),
  18524. vals0 = vals[0];
  18525. settings.integer(k, vals0);
  18526. settings.percent(k, vals0) ? settings.set("snapToLines", false) : null;
  18527. settings.alt(k, vals0, ["auto"]);
  18528. if (vals.length === 2) {
  18529. settings.alt("lineAlign", vals[1], ["start", "middle", "end"]);
  18530. }
  18531. break;
  18532. case "position":
  18533. vals = v.split(",");
  18534. settings.percent(k, vals[0]);
  18535. if (vals.length === 2) {
  18536. settings.alt("positionAlign", vals[1], ["start", "middle", "end"]);
  18537. }
  18538. break;
  18539. case "size":
  18540. settings.percent(k, v);
  18541. break;
  18542. case "align":
  18543. settings.alt(k, v, ["start", "middle", "end", "left", "right"]);
  18544. break;
  18545. }
  18546. }, /:/, /\s/);
  18547. // Apply default values for any missing fields.
  18548. cue.region = settings.get("region", null);
  18549. cue.vertical = settings.get("vertical", "");
  18550. cue.line = settings.get("line", "auto");
  18551. cue.lineAlign = settings.get("lineAlign", "start");
  18552. cue.snapToLines = settings.get("snapToLines", true);
  18553. cue.size = settings.get("size", 100);
  18554. cue.align = settings.get("align", "middle");
  18555. cue.position = settings.get("position", {
  18556. start: 0,
  18557. left: 0,
  18558. middle: 50,
  18559. end: 100,
  18560. right: 100
  18561. }, cue.align);
  18562. cue.positionAlign = settings.get("positionAlign", {
  18563. start: "start",
  18564. left: "start",
  18565. middle: "middle",
  18566. end: "end",
  18567. right: "end"
  18568. }, cue.align);
  18569. }
  18570. function skipWhitespace() {
  18571. input = input.replace(/^\s+/, "");
  18572. }
  18573. // 4.1 WebVTT cue timings.
  18574. skipWhitespace();
  18575. cue.startTime = consumeTimeStamp(); // (1) collect cue start time
  18576. skipWhitespace();
  18577. if (input.substr(0, 3) !== "-->") { // (3) next characters must match "-->"
  18578. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  18579. "Malformed time stamp (time stamps must be separated by '-->'): " +
  18580. oInput);
  18581. }
  18582. input = input.substr(3);
  18583. skipWhitespace();
  18584. cue.endTime = consumeTimeStamp(); // (5) collect cue end time
  18585. // 4.1 WebVTT cue settings list.
  18586. skipWhitespace();
  18587. consumeCueSettings(input, cue);
  18588. }
  18589. var ESCAPE = {
  18590. "&amp;": "&",
  18591. "&lt;": "<",
  18592. "&gt;": ">",
  18593. "&lrm;": "\u200e",
  18594. "&rlm;": "\u200f",
  18595. "&nbsp;": "\u00a0"
  18596. };
  18597. var TAG_NAME = {
  18598. c: "span",
  18599. i: "i",
  18600. b: "b",
  18601. u: "u",
  18602. ruby: "ruby",
  18603. rt: "rt",
  18604. v: "span",
  18605. lang: "span"
  18606. };
  18607. var TAG_ANNOTATION = {
  18608. v: "title",
  18609. lang: "lang"
  18610. };
  18611. var NEEDS_PARENT = {
  18612. rt: "ruby"
  18613. };
  18614. // Parse content into a document fragment.
  18615. function parseContent(window, input) {
  18616. function nextToken() {
  18617. // Check for end-of-string.
  18618. if (!input) {
  18619. return null;
  18620. }
  18621. // Consume 'n' characters from the input.
  18622. function consume(result) {
  18623. input = input.substr(result.length);
  18624. return result;
  18625. }
  18626. var m = input.match(/^([^<]*)(<[^>]+>?)?/);
  18627. // If there is some text before the next tag, return it, otherwise return
  18628. // the tag.
  18629. return consume(m[1] ? m[1] : m[2]);
  18630. }
  18631. // Unescape a string 's'.
  18632. function unescape1(e) {
  18633. return ESCAPE[e];
  18634. }
  18635. function unescape(s) {
  18636. while ((m = s.match(/&(amp|lt|gt|lrm|rlm|nbsp);/))) {
  18637. s = s.replace(m[0], unescape1);
  18638. }
  18639. return s;
  18640. }
  18641. function shouldAdd(current, element) {
  18642. return !NEEDS_PARENT[element.localName] ||
  18643. NEEDS_PARENT[element.localName] === current.localName;
  18644. }
  18645. // Create an element for this tag.
  18646. function createElement(type, annotation) {
  18647. var tagName = TAG_NAME[type];
  18648. if (!tagName) {
  18649. return null;
  18650. }
  18651. var element = window.document.createElement(tagName);
  18652. element.localName = tagName;
  18653. var name = TAG_ANNOTATION[type];
  18654. if (name && annotation) {
  18655. element[name] = annotation.trim();
  18656. }
  18657. return element;
  18658. }
  18659. var rootDiv = window.document.createElement("div"),
  18660. current = rootDiv,
  18661. t,
  18662. tagStack = [];
  18663. while ((t = nextToken()) !== null) {
  18664. if (t[0] === '<') {
  18665. if (t[1] === "/") {
  18666. // If the closing tag matches, move back up to the parent node.
  18667. if (tagStack.length &&
  18668. tagStack[tagStack.length - 1] === t.substr(2).replace(">", "")) {
  18669. tagStack.pop();
  18670. current = current.parentNode;
  18671. }
  18672. // Otherwise just ignore the end tag.
  18673. continue;
  18674. }
  18675. var ts = parseTimeStamp(t.substr(1, t.length - 2));
  18676. var node;
  18677. if (ts) {
  18678. // Timestamps are lead nodes as well.
  18679. node = window.document.createProcessingInstruction("timestamp", ts);
  18680. current.appendChild(node);
  18681. continue;
  18682. }
  18683. var m = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);
  18684. // If we can't parse the tag, skip to the next tag.
  18685. if (!m) {
  18686. continue;
  18687. }
  18688. // Try to construct an element, and ignore the tag if we couldn't.
  18689. node = createElement(m[1], m[3]);
  18690. if (!node) {
  18691. continue;
  18692. }
  18693. // Determine if the tag should be added based on the context of where it
  18694. // is placed in the cuetext.
  18695. if (!shouldAdd(current, node)) {
  18696. continue;
  18697. }
  18698. // Set the class list (as a list of classes, separated by space).
  18699. if (m[2]) {
  18700. node.className = m[2].substr(1).replace('.', ' ');
  18701. }
  18702. // Append the node to the current node, and enter the scope of the new
  18703. // node.
  18704. tagStack.push(m[1]);
  18705. current.appendChild(node);
  18706. current = node;
  18707. continue;
  18708. }
  18709. // Text nodes are leaf nodes.
  18710. current.appendChild(window.document.createTextNode(unescape(t)));
  18711. }
  18712. return rootDiv;
  18713. }
  18714. // This is a list of all the Unicode characters that have a strong
  18715. // right-to-left category. What this means is that these characters are
  18716. // written right-to-left for sure. It was generated by pulling all the strong
  18717. // right-to-left characters out of the Unicode data table. That table can
  18718. // found at: http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
  18719. var strongRTLChars = [0x05BE, 0x05C0, 0x05C3, 0x05C6, 0x05D0, 0x05D1,
  18720. 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA,
  18721. 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3,
  18722. 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x05F0, 0x05F1,
  18723. 0x05F2, 0x05F3, 0x05F4, 0x0608, 0x060B, 0x060D, 0x061B, 0x061E, 0x061F,
  18724. 0x0620, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628,
  18725. 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631,
  18726. 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063A,
  18727. 0x063B, 0x063C, 0x063D, 0x063E, 0x063F, 0x0640, 0x0641, 0x0642, 0x0643,
  18728. 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, 0x066D, 0x066E,
  18729. 0x066F, 0x0671, 0x0672, 0x0673, 0x0674, 0x0675, 0x0676, 0x0677, 0x0678,
  18730. 0x0679, 0x067A, 0x067B, 0x067C, 0x067D, 0x067E, 0x067F, 0x0680, 0x0681,
  18731. 0x0682, 0x0683, 0x0684, 0x0685, 0x0686, 0x0687, 0x0688, 0x0689, 0x068A,
  18732. 0x068B, 0x068C, 0x068D, 0x068E, 0x068F, 0x0690, 0x0691, 0x0692, 0x0693,
  18733. 0x0694, 0x0695, 0x0696, 0x0697, 0x0698, 0x0699, 0x069A, 0x069B, 0x069C,
  18734. 0x069D, 0x069E, 0x069F, 0x06A0, 0x06A1, 0x06A2, 0x06A3, 0x06A4, 0x06A5,
  18735. 0x06A6, 0x06A7, 0x06A8, 0x06A9, 0x06AA, 0x06AB, 0x06AC, 0x06AD, 0x06AE,
  18736. 0x06AF, 0x06B0, 0x06B1, 0x06B2, 0x06B3, 0x06B4, 0x06B5, 0x06B6, 0x06B7,
  18737. 0x06B8, 0x06B9, 0x06BA, 0x06BB, 0x06BC, 0x06BD, 0x06BE, 0x06BF, 0x06C0,
  18738. 0x06C1, 0x06C2, 0x06C3, 0x06C4, 0x06C5, 0x06C6, 0x06C7, 0x06C8, 0x06C9,
  18739. 0x06CA, 0x06CB, 0x06CC, 0x06CD, 0x06CE, 0x06CF, 0x06D0, 0x06D1, 0x06D2,
  18740. 0x06D3, 0x06D4, 0x06D5, 0x06E5, 0x06E6, 0x06EE, 0x06EF, 0x06FA, 0x06FB,
  18741. 0x06FC, 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702, 0x0703, 0x0704,
  18742. 0x0705, 0x0706, 0x0707, 0x0708, 0x0709, 0x070A, 0x070B, 0x070C, 0x070D,
  18743. 0x070F, 0x0710, 0x0712, 0x0713, 0x0714, 0x0715, 0x0716, 0x0717, 0x0718,
  18744. 0x0719, 0x071A, 0x071B, 0x071C, 0x071D, 0x071E, 0x071F, 0x0720, 0x0721,
  18745. 0x0722, 0x0723, 0x0724, 0x0725, 0x0726, 0x0727, 0x0728, 0x0729, 0x072A,
  18746. 0x072B, 0x072C, 0x072D, 0x072E, 0x072F, 0x074D, 0x074E, 0x074F, 0x0750,
  18747. 0x0751, 0x0752, 0x0753, 0x0754, 0x0755, 0x0756, 0x0757, 0x0758, 0x0759,
  18748. 0x075A, 0x075B, 0x075C, 0x075D, 0x075E, 0x075F, 0x0760, 0x0761, 0x0762,
  18749. 0x0763, 0x0764, 0x0765, 0x0766, 0x0767, 0x0768, 0x0769, 0x076A, 0x076B,
  18750. 0x076C, 0x076D, 0x076E, 0x076F, 0x0770, 0x0771, 0x0772, 0x0773, 0x0774,
  18751. 0x0775, 0x0776, 0x0777, 0x0778, 0x0779, 0x077A, 0x077B, 0x077C, 0x077D,
  18752. 0x077E, 0x077F, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0786,
  18753. 0x0787, 0x0788, 0x0789, 0x078A, 0x078B, 0x078C, 0x078D, 0x078E, 0x078F,
  18754. 0x0790, 0x0791, 0x0792, 0x0793, 0x0794, 0x0795, 0x0796, 0x0797, 0x0798,
  18755. 0x0799, 0x079A, 0x079B, 0x079C, 0x079D, 0x079E, 0x079F, 0x07A0, 0x07A1,
  18756. 0x07A2, 0x07A3, 0x07A4, 0x07A5, 0x07B1, 0x07C0, 0x07C1, 0x07C2, 0x07C3,
  18757. 0x07C4, 0x07C5, 0x07C6, 0x07C7, 0x07C8, 0x07C9, 0x07CA, 0x07CB, 0x07CC,
  18758. 0x07CD, 0x07CE, 0x07CF, 0x07D0, 0x07D1, 0x07D2, 0x07D3, 0x07D4, 0x07D5,
  18759. 0x07D6, 0x07D7, 0x07D8, 0x07D9, 0x07DA, 0x07DB, 0x07DC, 0x07DD, 0x07DE,
  18760. 0x07DF, 0x07E0, 0x07E1, 0x07E2, 0x07E3, 0x07E4, 0x07E5, 0x07E6, 0x07E7,
  18761. 0x07E8, 0x07E9, 0x07EA, 0x07F4, 0x07F5, 0x07FA, 0x0800, 0x0801, 0x0802,
  18762. 0x0803, 0x0804, 0x0805, 0x0806, 0x0807, 0x0808, 0x0809, 0x080A, 0x080B,
  18763. 0x080C, 0x080D, 0x080E, 0x080F, 0x0810, 0x0811, 0x0812, 0x0813, 0x0814,
  18764. 0x0815, 0x081A, 0x0824, 0x0828, 0x0830, 0x0831, 0x0832, 0x0833, 0x0834,
  18765. 0x0835, 0x0836, 0x0837, 0x0838, 0x0839, 0x083A, 0x083B, 0x083C, 0x083D,
  18766. 0x083E, 0x0840, 0x0841, 0x0842, 0x0843, 0x0844, 0x0845, 0x0846, 0x0847,
  18767. 0x0848, 0x0849, 0x084A, 0x084B, 0x084C, 0x084D, 0x084E, 0x084F, 0x0850,
  18768. 0x0851, 0x0852, 0x0853, 0x0854, 0x0855, 0x0856, 0x0857, 0x0858, 0x085E,
  18769. 0x08A0, 0x08A2, 0x08A3, 0x08A4, 0x08A5, 0x08A6, 0x08A7, 0x08A8, 0x08A9,
  18770. 0x08AA, 0x08AB, 0x08AC, 0x200F, 0xFB1D, 0xFB1F, 0xFB20, 0xFB21, 0xFB22,
  18771. 0xFB23, 0xFB24, 0xFB25, 0xFB26, 0xFB27, 0xFB28, 0xFB2A, 0xFB2B, 0xFB2C,
  18772. 0xFB2D, 0xFB2E, 0xFB2F, 0xFB30, 0xFB31, 0xFB32, 0xFB33, 0xFB34, 0xFB35,
  18773. 0xFB36, 0xFB38, 0xFB39, 0xFB3A, 0xFB3B, 0xFB3C, 0xFB3E, 0xFB40, 0xFB41,
  18774. 0xFB43, 0xFB44, 0xFB46, 0xFB47, 0xFB48, 0xFB49, 0xFB4A, 0xFB4B, 0xFB4C,
  18775. 0xFB4D, 0xFB4E, 0xFB4F, 0xFB50, 0xFB51, 0xFB52, 0xFB53, 0xFB54, 0xFB55,
  18776. 0xFB56, 0xFB57, 0xFB58, 0xFB59, 0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D, 0xFB5E,
  18777. 0xFB5F, 0xFB60, 0xFB61, 0xFB62, 0xFB63, 0xFB64, 0xFB65, 0xFB66, 0xFB67,
  18778. 0xFB68, 0xFB69, 0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D, 0xFB6E, 0xFB6F, 0xFB70,
  18779. 0xFB71, 0xFB72, 0xFB73, 0xFB74, 0xFB75, 0xFB76, 0xFB77, 0xFB78, 0xFB79,
  18780. 0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D, 0xFB7E, 0xFB7F, 0xFB80, 0xFB81, 0xFB82,
  18781. 0xFB83, 0xFB84, 0xFB85, 0xFB86, 0xFB87, 0xFB88, 0xFB89, 0xFB8A, 0xFB8B,
  18782. 0xFB8C, 0xFB8D, 0xFB8E, 0xFB8F, 0xFB90, 0xFB91, 0xFB92, 0xFB93, 0xFB94,
  18783. 0xFB95, 0xFB96, 0xFB97, 0xFB98, 0xFB99, 0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D,
  18784. 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3, 0xFBA4, 0xFBA5, 0xFBA6,
  18785. 0xFBA7, 0xFBA8, 0xFBA9, 0xFBAA, 0xFBAB, 0xFBAC, 0xFBAD, 0xFBAE, 0xFBAF,
  18786. 0xFBB0, 0xFBB1, 0xFBB2, 0xFBB3, 0xFBB4, 0xFBB5, 0xFBB6, 0xFBB7, 0xFBB8,
  18787. 0xFBB9, 0xFBBA, 0xFBBB, 0xFBBC, 0xFBBD, 0xFBBE, 0xFBBF, 0xFBC0, 0xFBC1,
  18788. 0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6, 0xFBD7, 0xFBD8, 0xFBD9, 0xFBDA, 0xFBDB,
  18789. 0xFBDC, 0xFBDD, 0xFBDE, 0xFBDF, 0xFBE0, 0xFBE1, 0xFBE2, 0xFBE3, 0xFBE4,
  18790. 0xFBE5, 0xFBE6, 0xFBE7, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEB, 0xFBEC, 0xFBED,
  18791. 0xFBEE, 0xFBEF, 0xFBF0, 0xFBF1, 0xFBF2, 0xFBF3, 0xFBF4, 0xFBF5, 0xFBF6,
  18792. 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF,
  18793. 0xFC00, 0xFC01, 0xFC02, 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
  18794. 0xFC09, 0xFC0A, 0xFC0B, 0xFC0C, 0xFC0D, 0xFC0E, 0xFC0F, 0xFC10, 0xFC11,
  18795. 0xFC12, 0xFC13, 0xFC14, 0xFC15, 0xFC16, 0xFC17, 0xFC18, 0xFC19, 0xFC1A,
  18796. 0xFC1B, 0xFC1C, 0xFC1D, 0xFC1E, 0xFC1F, 0xFC20, 0xFC21, 0xFC22, 0xFC23,
  18797. 0xFC24, 0xFC25, 0xFC26, 0xFC27, 0xFC28, 0xFC29, 0xFC2A, 0xFC2B, 0xFC2C,
  18798. 0xFC2D, 0xFC2E, 0xFC2F, 0xFC30, 0xFC31, 0xFC32, 0xFC33, 0xFC34, 0xFC35,
  18799. 0xFC36, 0xFC37, 0xFC38, 0xFC39, 0xFC3A, 0xFC3B, 0xFC3C, 0xFC3D, 0xFC3E,
  18800. 0xFC3F, 0xFC40, 0xFC41, 0xFC42, 0xFC43, 0xFC44, 0xFC45, 0xFC46, 0xFC47,
  18801. 0xFC48, 0xFC49, 0xFC4A, 0xFC4B, 0xFC4C, 0xFC4D, 0xFC4E, 0xFC4F, 0xFC50,
  18802. 0xFC51, 0xFC52, 0xFC53, 0xFC54, 0xFC55, 0xFC56, 0xFC57, 0xFC58, 0xFC59,
  18803. 0xFC5A, 0xFC5B, 0xFC5C, 0xFC5D, 0xFC5E, 0xFC5F, 0xFC60, 0xFC61, 0xFC62,
  18804. 0xFC63, 0xFC64, 0xFC65, 0xFC66, 0xFC67, 0xFC68, 0xFC69, 0xFC6A, 0xFC6B,
  18805. 0xFC6C, 0xFC6D, 0xFC6E, 0xFC6F, 0xFC70, 0xFC71, 0xFC72, 0xFC73, 0xFC74,
  18806. 0xFC75, 0xFC76, 0xFC77, 0xFC78, 0xFC79, 0xFC7A, 0xFC7B, 0xFC7C, 0xFC7D,
  18807. 0xFC7E, 0xFC7F, 0xFC80, 0xFC81, 0xFC82, 0xFC83, 0xFC84, 0xFC85, 0xFC86,
  18808. 0xFC87, 0xFC88, 0xFC89, 0xFC8A, 0xFC8B, 0xFC8C, 0xFC8D, 0xFC8E, 0xFC8F,
  18809. 0xFC90, 0xFC91, 0xFC92, 0xFC93, 0xFC94, 0xFC95, 0xFC96, 0xFC97, 0xFC98,
  18810. 0xFC99, 0xFC9A, 0xFC9B, 0xFC9C, 0xFC9D, 0xFC9E, 0xFC9F, 0xFCA0, 0xFCA1,
  18811. 0xFCA2, 0xFCA3, 0xFCA4, 0xFCA5, 0xFCA6, 0xFCA7, 0xFCA8, 0xFCA9, 0xFCAA,
  18812. 0xFCAB, 0xFCAC, 0xFCAD, 0xFCAE, 0xFCAF, 0xFCB0, 0xFCB1, 0xFCB2, 0xFCB3,
  18813. 0xFCB4, 0xFCB5, 0xFCB6, 0xFCB7, 0xFCB8, 0xFCB9, 0xFCBA, 0xFCBB, 0xFCBC,
  18814. 0xFCBD, 0xFCBE, 0xFCBF, 0xFCC0, 0xFCC1, 0xFCC2, 0xFCC3, 0xFCC4, 0xFCC5,
  18815. 0xFCC6, 0xFCC7, 0xFCC8, 0xFCC9, 0xFCCA, 0xFCCB, 0xFCCC, 0xFCCD, 0xFCCE,
  18816. 0xFCCF, 0xFCD0, 0xFCD1, 0xFCD2, 0xFCD3, 0xFCD4, 0xFCD5, 0xFCD6, 0xFCD7,
  18817. 0xFCD8, 0xFCD9, 0xFCDA, 0xFCDB, 0xFCDC, 0xFCDD, 0xFCDE, 0xFCDF, 0xFCE0,
  18818. 0xFCE1, 0xFCE2, 0xFCE3, 0xFCE4, 0xFCE5, 0xFCE6, 0xFCE7, 0xFCE8, 0xFCE9,
  18819. 0xFCEA, 0xFCEB, 0xFCEC, 0xFCED, 0xFCEE, 0xFCEF, 0xFCF0, 0xFCF1, 0xFCF2,
  18820. 0xFCF3, 0xFCF4, 0xFCF5, 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9, 0xFCFA, 0xFCFB,
  18821. 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF, 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04,
  18822. 0xFD05, 0xFD06, 0xFD07, 0xFD08, 0xFD09, 0xFD0A, 0xFD0B, 0xFD0C, 0xFD0D,
  18823. 0xFD0E, 0xFD0F, 0xFD10, 0xFD11, 0xFD12, 0xFD13, 0xFD14, 0xFD15, 0xFD16,
  18824. 0xFD17, 0xFD18, 0xFD19, 0xFD1A, 0xFD1B, 0xFD1C, 0xFD1D, 0xFD1E, 0xFD1F,
  18825. 0xFD20, 0xFD21, 0xFD22, 0xFD23, 0xFD24, 0xFD25, 0xFD26, 0xFD27, 0xFD28,
  18826. 0xFD29, 0xFD2A, 0xFD2B, 0xFD2C, 0xFD2D, 0xFD2E, 0xFD2F, 0xFD30, 0xFD31,
  18827. 0xFD32, 0xFD33, 0xFD34, 0xFD35, 0xFD36, 0xFD37, 0xFD38, 0xFD39, 0xFD3A,
  18828. 0xFD3B, 0xFD3C, 0xFD3D, 0xFD50, 0xFD51, 0xFD52, 0xFD53, 0xFD54, 0xFD55,
  18829. 0xFD56, 0xFD57, 0xFD58, 0xFD59, 0xFD5A, 0xFD5B, 0xFD5C, 0xFD5D, 0xFD5E,
  18830. 0xFD5F, 0xFD60, 0xFD61, 0xFD62, 0xFD63, 0xFD64, 0xFD65, 0xFD66, 0xFD67,
  18831. 0xFD68, 0xFD69, 0xFD6A, 0xFD6B, 0xFD6C, 0xFD6D, 0xFD6E, 0xFD6F, 0xFD70,
  18832. 0xFD71, 0xFD72, 0xFD73, 0xFD74, 0xFD75, 0xFD76, 0xFD77, 0xFD78, 0xFD79,
  18833. 0xFD7A, 0xFD7B, 0xFD7C, 0xFD7D, 0xFD7E, 0xFD7F, 0xFD80, 0xFD81, 0xFD82,
  18834. 0xFD83, 0xFD84, 0xFD85, 0xFD86, 0xFD87, 0xFD88, 0xFD89, 0xFD8A, 0xFD8B,
  18835. 0xFD8C, 0xFD8D, 0xFD8E, 0xFD8F, 0xFD92, 0xFD93, 0xFD94, 0xFD95, 0xFD96,
  18836. 0xFD97, 0xFD98, 0xFD99, 0xFD9A, 0xFD9B, 0xFD9C, 0xFD9D, 0xFD9E, 0xFD9F,
  18837. 0xFDA0, 0xFDA1, 0xFDA2, 0xFDA3, 0xFDA4, 0xFDA5, 0xFDA6, 0xFDA7, 0xFDA8,
  18838. 0xFDA9, 0xFDAA, 0xFDAB, 0xFDAC, 0xFDAD, 0xFDAE, 0xFDAF, 0xFDB0, 0xFDB1,
  18839. 0xFDB2, 0xFDB3, 0xFDB4, 0xFDB5, 0xFDB6, 0xFDB7, 0xFDB8, 0xFDB9, 0xFDBA,
  18840. 0xFDBB, 0xFDBC, 0xFDBD, 0xFDBE, 0xFDBF, 0xFDC0, 0xFDC1, 0xFDC2, 0xFDC3,
  18841. 0xFDC4, 0xFDC5, 0xFDC6, 0xFDC7, 0xFDF0, 0xFDF1, 0xFDF2, 0xFDF3, 0xFDF4,
  18842. 0xFDF5, 0xFDF6, 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC, 0xFE70,
  18843. 0xFE71, 0xFE72, 0xFE73, 0xFE74, 0xFE76, 0xFE77, 0xFE78, 0xFE79, 0xFE7A,
  18844. 0xFE7B, 0xFE7C, 0xFE7D, 0xFE7E, 0xFE7F, 0xFE80, 0xFE81, 0xFE82, 0xFE83,
  18845. 0xFE84, 0xFE85, 0xFE86, 0xFE87, 0xFE88, 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C,
  18846. 0xFE8D, 0xFE8E, 0xFE8F, 0xFE90, 0xFE91, 0xFE92, 0xFE93, 0xFE94, 0xFE95,
  18847. 0xFE96, 0xFE97, 0xFE98, 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C, 0xFE9D, 0xFE9E,
  18848. 0xFE9F, 0xFEA0, 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4, 0xFEA5, 0xFEA6, 0xFEA7,
  18849. 0xFEA8, 0xFEA9, 0xFEAA, 0xFEAB, 0xFEAC, 0xFEAD, 0xFEAE, 0xFEAF, 0xFEB0,
  18850. 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4, 0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8, 0xFEB9,
  18851. 0xFEBA, 0xFEBB, 0xFEBC, 0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0, 0xFEC1, 0xFEC2,
  18852. 0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8, 0xFEC9, 0xFECA, 0xFECB,
  18853. 0xFECC, 0xFECD, 0xFECE, 0xFECF, 0xFED0, 0xFED1, 0xFED2, 0xFED3, 0xFED4,
  18854. 0xFED5, 0xFED6, 0xFED7, 0xFED8, 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC, 0xFEDD,
  18855. 0xFEDE, 0xFEDF, 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6,
  18856. 0xFEE7, 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF,
  18857. 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8,
  18858. 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0x10800, 0x10801, 0x10802, 0x10803,
  18859. 0x10804, 0x10805, 0x10808, 0x1080A, 0x1080B, 0x1080C, 0x1080D, 0x1080E,
  18860. 0x1080F, 0x10810, 0x10811, 0x10812, 0x10813, 0x10814, 0x10815, 0x10816,
  18861. 0x10817, 0x10818, 0x10819, 0x1081A, 0x1081B, 0x1081C, 0x1081D, 0x1081E,
  18862. 0x1081F, 0x10820, 0x10821, 0x10822, 0x10823, 0x10824, 0x10825, 0x10826,
  18863. 0x10827, 0x10828, 0x10829, 0x1082A, 0x1082B, 0x1082C, 0x1082D, 0x1082E,
  18864. 0x1082F, 0x10830, 0x10831, 0x10832, 0x10833, 0x10834, 0x10835, 0x10837,
  18865. 0x10838, 0x1083C, 0x1083F, 0x10840, 0x10841, 0x10842, 0x10843, 0x10844,
  18866. 0x10845, 0x10846, 0x10847, 0x10848, 0x10849, 0x1084A, 0x1084B, 0x1084C,
  18867. 0x1084D, 0x1084E, 0x1084F, 0x10850, 0x10851, 0x10852, 0x10853, 0x10854,
  18868. 0x10855, 0x10857, 0x10858, 0x10859, 0x1085A, 0x1085B, 0x1085C, 0x1085D,
  18869. 0x1085E, 0x1085F, 0x10900, 0x10901, 0x10902, 0x10903, 0x10904, 0x10905,
  18870. 0x10906, 0x10907, 0x10908, 0x10909, 0x1090A, 0x1090B, 0x1090C, 0x1090D,
  18871. 0x1090E, 0x1090F, 0x10910, 0x10911, 0x10912, 0x10913, 0x10914, 0x10915,
  18872. 0x10916, 0x10917, 0x10918, 0x10919, 0x1091A, 0x1091B, 0x10920, 0x10921,
  18873. 0x10922, 0x10923, 0x10924, 0x10925, 0x10926, 0x10927, 0x10928, 0x10929,
  18874. 0x1092A, 0x1092B, 0x1092C, 0x1092D, 0x1092E, 0x1092F, 0x10930, 0x10931,
  18875. 0x10932, 0x10933, 0x10934, 0x10935, 0x10936, 0x10937, 0x10938, 0x10939,
  18876. 0x1093F, 0x10980, 0x10981, 0x10982, 0x10983, 0x10984, 0x10985, 0x10986,
  18877. 0x10987, 0x10988, 0x10989, 0x1098A, 0x1098B, 0x1098C, 0x1098D, 0x1098E,
  18878. 0x1098F, 0x10990, 0x10991, 0x10992, 0x10993, 0x10994, 0x10995, 0x10996,
  18879. 0x10997, 0x10998, 0x10999, 0x1099A, 0x1099B, 0x1099C, 0x1099D, 0x1099E,
  18880. 0x1099F, 0x109A0, 0x109A1, 0x109A2, 0x109A3, 0x109A4, 0x109A5, 0x109A6,
  18881. 0x109A7, 0x109A8, 0x109A9, 0x109AA, 0x109AB, 0x109AC, 0x109AD, 0x109AE,
  18882. 0x109AF, 0x109B0, 0x109B1, 0x109B2, 0x109B3, 0x109B4, 0x109B5, 0x109B6,
  18883. 0x109B7, 0x109BE, 0x109BF, 0x10A00, 0x10A10, 0x10A11, 0x10A12, 0x10A13,
  18884. 0x10A15, 0x10A16, 0x10A17, 0x10A19, 0x10A1A, 0x10A1B, 0x10A1C, 0x10A1D,
  18885. 0x10A1E, 0x10A1F, 0x10A20, 0x10A21, 0x10A22, 0x10A23, 0x10A24, 0x10A25,
  18886. 0x10A26, 0x10A27, 0x10A28, 0x10A29, 0x10A2A, 0x10A2B, 0x10A2C, 0x10A2D,
  18887. 0x10A2E, 0x10A2F, 0x10A30, 0x10A31, 0x10A32, 0x10A33, 0x10A40, 0x10A41,
  18888. 0x10A42, 0x10A43, 0x10A44, 0x10A45, 0x10A46, 0x10A47, 0x10A50, 0x10A51,
  18889. 0x10A52, 0x10A53, 0x10A54, 0x10A55, 0x10A56, 0x10A57, 0x10A58, 0x10A60,
  18890. 0x10A61, 0x10A62, 0x10A63, 0x10A64, 0x10A65, 0x10A66, 0x10A67, 0x10A68,
  18891. 0x10A69, 0x10A6A, 0x10A6B, 0x10A6C, 0x10A6D, 0x10A6E, 0x10A6F, 0x10A70,
  18892. 0x10A71, 0x10A72, 0x10A73, 0x10A74, 0x10A75, 0x10A76, 0x10A77, 0x10A78,
  18893. 0x10A79, 0x10A7A, 0x10A7B, 0x10A7C, 0x10A7D, 0x10A7E, 0x10A7F, 0x10B00,
  18894. 0x10B01, 0x10B02, 0x10B03, 0x10B04, 0x10B05, 0x10B06, 0x10B07, 0x10B08,
  18895. 0x10B09, 0x10B0A, 0x10B0B, 0x10B0C, 0x10B0D, 0x10B0E, 0x10B0F, 0x10B10,
  18896. 0x10B11, 0x10B12, 0x10B13, 0x10B14, 0x10B15, 0x10B16, 0x10B17, 0x10B18,
  18897. 0x10B19, 0x10B1A, 0x10B1B, 0x10B1C, 0x10B1D, 0x10B1E, 0x10B1F, 0x10B20,
  18898. 0x10B21, 0x10B22, 0x10B23, 0x10B24, 0x10B25, 0x10B26, 0x10B27, 0x10B28,
  18899. 0x10B29, 0x10B2A, 0x10B2B, 0x10B2C, 0x10B2D, 0x10B2E, 0x10B2F, 0x10B30,
  18900. 0x10B31, 0x10B32, 0x10B33, 0x10B34, 0x10B35, 0x10B40, 0x10B41, 0x10B42,
  18901. 0x10B43, 0x10B44, 0x10B45, 0x10B46, 0x10B47, 0x10B48, 0x10B49, 0x10B4A,
  18902. 0x10B4B, 0x10B4C, 0x10B4D, 0x10B4E, 0x10B4F, 0x10B50, 0x10B51, 0x10B52,
  18903. 0x10B53, 0x10B54, 0x10B55, 0x10B58, 0x10B59, 0x10B5A, 0x10B5B, 0x10B5C,
  18904. 0x10B5D, 0x10B5E, 0x10B5F, 0x10B60, 0x10B61, 0x10B62, 0x10B63, 0x10B64,
  18905. 0x10B65, 0x10B66, 0x10B67, 0x10B68, 0x10B69, 0x10B6A, 0x10B6B, 0x10B6C,
  18906. 0x10B6D, 0x10B6E, 0x10B6F, 0x10B70, 0x10B71, 0x10B72, 0x10B78, 0x10B79,
  18907. 0x10B7A, 0x10B7B, 0x10B7C, 0x10B7D, 0x10B7E, 0x10B7F, 0x10C00, 0x10C01,
  18908. 0x10C02, 0x10C03, 0x10C04, 0x10C05, 0x10C06, 0x10C07, 0x10C08, 0x10C09,
  18909. 0x10C0A, 0x10C0B, 0x10C0C, 0x10C0D, 0x10C0E, 0x10C0F, 0x10C10, 0x10C11,
  18910. 0x10C12, 0x10C13, 0x10C14, 0x10C15, 0x10C16, 0x10C17, 0x10C18, 0x10C19,
  18911. 0x10C1A, 0x10C1B, 0x10C1C, 0x10C1D, 0x10C1E, 0x10C1F, 0x10C20, 0x10C21,
  18912. 0x10C22, 0x10C23, 0x10C24, 0x10C25, 0x10C26, 0x10C27, 0x10C28, 0x10C29,
  18913. 0x10C2A, 0x10C2B, 0x10C2C, 0x10C2D, 0x10C2E, 0x10C2F, 0x10C30, 0x10C31,
  18914. 0x10C32, 0x10C33, 0x10C34, 0x10C35, 0x10C36, 0x10C37, 0x10C38, 0x10C39,
  18915. 0x10C3A, 0x10C3B, 0x10C3C, 0x10C3D, 0x10C3E, 0x10C3F, 0x10C40, 0x10C41,
  18916. 0x10C42, 0x10C43, 0x10C44, 0x10C45, 0x10C46, 0x10C47, 0x10C48, 0x1EE00,
  18917. 0x1EE01, 0x1EE02, 0x1EE03, 0x1EE05, 0x1EE06, 0x1EE07, 0x1EE08, 0x1EE09,
  18918. 0x1EE0A, 0x1EE0B, 0x1EE0C, 0x1EE0D, 0x1EE0E, 0x1EE0F, 0x1EE10, 0x1EE11,
  18919. 0x1EE12, 0x1EE13, 0x1EE14, 0x1EE15, 0x1EE16, 0x1EE17, 0x1EE18, 0x1EE19,
  18920. 0x1EE1A, 0x1EE1B, 0x1EE1C, 0x1EE1D, 0x1EE1E, 0x1EE1F, 0x1EE21, 0x1EE22,
  18921. 0x1EE24, 0x1EE27, 0x1EE29, 0x1EE2A, 0x1EE2B, 0x1EE2C, 0x1EE2D, 0x1EE2E,
  18922. 0x1EE2F, 0x1EE30, 0x1EE31, 0x1EE32, 0x1EE34, 0x1EE35, 0x1EE36, 0x1EE37,
  18923. 0x1EE39, 0x1EE3B, 0x1EE42, 0x1EE47, 0x1EE49, 0x1EE4B, 0x1EE4D, 0x1EE4E,
  18924. 0x1EE4F, 0x1EE51, 0x1EE52, 0x1EE54, 0x1EE57, 0x1EE59, 0x1EE5B, 0x1EE5D,
  18925. 0x1EE5F, 0x1EE61, 0x1EE62, 0x1EE64, 0x1EE67, 0x1EE68, 0x1EE69, 0x1EE6A,
  18926. 0x1EE6C, 0x1EE6D, 0x1EE6E, 0x1EE6F, 0x1EE70, 0x1EE71, 0x1EE72, 0x1EE74,
  18927. 0x1EE75, 0x1EE76, 0x1EE77, 0x1EE79, 0x1EE7A, 0x1EE7B, 0x1EE7C, 0x1EE7E,
  18928. 0x1EE80, 0x1EE81, 0x1EE82, 0x1EE83, 0x1EE84, 0x1EE85, 0x1EE86, 0x1EE87,
  18929. 0x1EE88, 0x1EE89, 0x1EE8B, 0x1EE8C, 0x1EE8D, 0x1EE8E, 0x1EE8F, 0x1EE90,
  18930. 0x1EE91, 0x1EE92, 0x1EE93, 0x1EE94, 0x1EE95, 0x1EE96, 0x1EE97, 0x1EE98,
  18931. 0x1EE99, 0x1EE9A, 0x1EE9B, 0x1EEA1, 0x1EEA2, 0x1EEA3, 0x1EEA5, 0x1EEA6,
  18932. 0x1EEA7, 0x1EEA8, 0x1EEA9, 0x1EEAB, 0x1EEAC, 0x1EEAD, 0x1EEAE, 0x1EEAF,
  18933. 0x1EEB0, 0x1EEB1, 0x1EEB2, 0x1EEB3, 0x1EEB4, 0x1EEB5, 0x1EEB6, 0x1EEB7,
  18934. 0x1EEB8, 0x1EEB9, 0x1EEBA, 0x1EEBB, 0x10FFFD];
  18935. function determineBidi(cueDiv) {
  18936. var nodeStack = [],
  18937. text = "",
  18938. charCode;
  18939. if (!cueDiv || !cueDiv.childNodes) {
  18940. return "ltr";
  18941. }
  18942. function pushNodes(nodeStack, node) {
  18943. for (var i = node.childNodes.length - 1; i >= 0; i--) {
  18944. nodeStack.push(node.childNodes[i]);
  18945. }
  18946. }
  18947. function nextTextNode(nodeStack) {
  18948. if (!nodeStack || !nodeStack.length) {
  18949. return null;
  18950. }
  18951. var node = nodeStack.pop(),
  18952. text = node.textContent || node.innerText;
  18953. if (text) {
  18954. // TODO: This should match all unicode type B characters (paragraph
  18955. // separator characters). See issue #115.
  18956. var m = text.match(/^.*(\n|\r)/);
  18957. if (m) {
  18958. nodeStack.length = 0;
  18959. return m[0];
  18960. }
  18961. return text;
  18962. }
  18963. if (node.tagName === "ruby") {
  18964. return nextTextNode(nodeStack);
  18965. }
  18966. if (node.childNodes) {
  18967. pushNodes(nodeStack, node);
  18968. return nextTextNode(nodeStack);
  18969. }
  18970. }
  18971. pushNodes(nodeStack, cueDiv);
  18972. while ((text = nextTextNode(nodeStack))) {
  18973. for (var i = 0; i < text.length; i++) {
  18974. charCode = text.charCodeAt(i);
  18975. for (var j = 0; j < strongRTLChars.length; j++) {
  18976. if (strongRTLChars[j] === charCode) {
  18977. return "rtl";
  18978. }
  18979. }
  18980. }
  18981. }
  18982. return "ltr";
  18983. }
  18984. function computeLinePos(cue) {
  18985. if (typeof cue.line === "number" &&
  18986. (cue.snapToLines || (cue.line >= 0 && cue.line <= 100))) {
  18987. return cue.line;
  18988. }
  18989. if (!cue.track || !cue.track.textTrackList ||
  18990. !cue.track.textTrackList.mediaElement) {
  18991. return -1;
  18992. }
  18993. var track = cue.track,
  18994. trackList = track.textTrackList,
  18995. count = 0;
  18996. for (var i = 0; i < trackList.length && trackList[i] !== track; i++) {
  18997. if (trackList[i].mode === "showing") {
  18998. count++;
  18999. }
  19000. }
  19001. return ++count * -1;
  19002. }
  19003. function StyleBox() {
  19004. }
  19005. // Apply styles to a div. If there is no div passed then it defaults to the
  19006. // div on 'this'.
  19007. StyleBox.prototype.applyStyles = function (styles, div) {
  19008. div = div || this.div;
  19009. for (var prop in styles) {
  19010. if (styles.hasOwnProperty(prop)) {
  19011. div.style[prop] = styles[prop];
  19012. }
  19013. }
  19014. };
  19015. StyleBox.prototype.formatStyle = function (val, unit) {
  19016. return val === 0 ? 0 : val + unit;
  19017. };
  19018. // Constructs the computed display state of the cue (a div). Places the div
  19019. // into the overlay which should be a block level element (usually a div).
  19020. function CueStyleBox(window, cue, styleOptions) {
  19021. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  19022. var color = "rgba(255, 255, 255, 1)";
  19023. var backgroundColor = "rgba(0, 0, 0, 0.8)";
  19024. if (isIE8) {
  19025. color = "rgb(255, 255, 255)";
  19026. backgroundColor = "rgb(0, 0, 0)";
  19027. }
  19028. StyleBox.call(this);
  19029. this.cue = cue;
  19030. // Parse our cue's text into a DOM tree rooted at 'cueDiv'. This div will
  19031. // have inline positioning and will function as the cue background box.
  19032. this.cueDiv = parseContent(window, cue.text);
  19033. var styles = {
  19034. color: color,
  19035. backgroundColor: backgroundColor,
  19036. position: "relative",
  19037. left: 0,
  19038. right: 0,
  19039. top: 0,
  19040. bottom: 0,
  19041. display: "inline"
  19042. };
  19043. if (!isIE8) {
  19044. styles.writingMode = cue.vertical === "" ? "horizontal-tb"
  19045. : cue.vertical === "lr" ? "vertical-lr"
  19046. : "vertical-rl";
  19047. styles.unicodeBidi = "plaintext";
  19048. }
  19049. this.applyStyles(styles, this.cueDiv);
  19050. // Create an absolutely positioned div that will be used to position the cue
  19051. // div. Note, all WebVTT cue-setting alignments are equivalent to the CSS
  19052. // mirrors of them except "middle" which is "center" in CSS.
  19053. this.div = window.document.createElement("div");
  19054. styles = {
  19055. textAlign: cue.align === "middle" ? "center" : cue.align,
  19056. font: styleOptions.font,
  19057. whiteSpace: "pre-line",
  19058. position: "absolute"
  19059. };
  19060. if (!isIE8) {
  19061. styles.direction = determineBidi(this.cueDiv);
  19062. styles.writingMode = cue.vertical === "" ? "horizontal-tb"
  19063. : cue.vertical === "lr" ? "vertical-lr"
  19064. : "vertical-rl".
  19065. stylesunicodeBidi = "plaintext";
  19066. }
  19067. this.applyStyles(styles);
  19068. this.div.appendChild(this.cueDiv);
  19069. // Calculate the distance from the reference edge of the viewport to the text
  19070. // position of the cue box. The reference edge will be resolved later when
  19071. // the box orientation styles are applied.
  19072. var textPos = 0;
  19073. switch (cue.positionAlign) {
  19074. case "start":
  19075. textPos = cue.position;
  19076. break;
  19077. case "middle":
  19078. textPos = cue.position - (cue.size / 2);
  19079. break;
  19080. case "end":
  19081. textPos = cue.position - cue.size;
  19082. break;
  19083. }
  19084. // Horizontal box orientation; textPos is the distance from the left edge of the
  19085. // area to the left edge of the box and cue.size is the distance extending to
  19086. // the right from there.
  19087. if (cue.vertical === "") {
  19088. this.applyStyles({
  19089. left: this.formatStyle(textPos, "%"),
  19090. width: this.formatStyle(cue.size, "%")
  19091. });
  19092. // Vertical box orientation; textPos is the distance from the top edge of the
  19093. // area to the top edge of the box and cue.size is the height extending
  19094. // downwards from there.
  19095. } else {
  19096. this.applyStyles({
  19097. top: this.formatStyle(textPos, "%"),
  19098. height: this.formatStyle(cue.size, "%")
  19099. });
  19100. }
  19101. this.move = function (box) {
  19102. this.applyStyles({
  19103. top: this.formatStyle(box.top, "px"),
  19104. bottom: this.formatStyle(box.bottom, "px"),
  19105. left: this.formatStyle(box.left, "px"),
  19106. right: this.formatStyle(box.right, "px"),
  19107. height: this.formatStyle(box.height, "px"),
  19108. width: this.formatStyle(box.width, "px")
  19109. });
  19110. };
  19111. }
  19112. CueStyleBox.prototype = _objCreate(StyleBox.prototype);
  19113. CueStyleBox.prototype.constructor = CueStyleBox;
  19114. // Represents the co-ordinates of an Element in a way that we can easily
  19115. // compute things with such as if it overlaps or intersects with another Element.
  19116. // Can initialize it with either a StyleBox or another BoxPosition.
  19117. function BoxPosition(obj) {
  19118. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  19119. // Either a BoxPosition was passed in and we need to copy it, or a StyleBox
  19120. // was passed in and we need to copy the results of 'getBoundingClientRect'
  19121. // as the object returned is readonly. All co-ordinate values are in reference
  19122. // to the viewport origin (top left).
  19123. var lh, height, width, top;
  19124. if (obj.div) {
  19125. height = obj.div.offsetHeight;
  19126. width = obj.div.offsetWidth;
  19127. top = obj.div.offsetTop;
  19128. var rects = (rects = obj.div.childNodes) && (rects = rects[0]) &&
  19129. rects.getClientRects && rects.getClientRects();
  19130. obj = obj.div.getBoundingClientRect();
  19131. // In certain cases the outter div will be slightly larger then the sum of
  19132. // the inner div's lines. This could be due to bold text, etc, on some platforms.
  19133. // In this case we should get the average line height and use that. This will
  19134. // result in the desired behaviour.
  19135. lh = rects ? Math.max((rects[0] && rects[0].height) || 0, obj.height / rects.length)
  19136. : 0;
  19137. }
  19138. this.left = obj.left;
  19139. this.right = obj.right;
  19140. this.top = obj.top || top;
  19141. this.height = obj.height || height;
  19142. this.bottom = obj.bottom || (top + (obj.height || height));
  19143. this.width = obj.width || width;
  19144. this.lineHeight = lh !== undefined ? lh : obj.lineHeight;
  19145. if (isIE8 && !this.lineHeight) {
  19146. this.lineHeight = 13;
  19147. }
  19148. }
  19149. // Move the box along a particular axis. Optionally pass in an amount to move
  19150. // the box. If no amount is passed then the default is the line height of the
  19151. // box.
  19152. BoxPosition.prototype.move = function (axis, toMove) {
  19153. toMove = toMove !== undefined ? toMove : this.lineHeight;
  19154. switch (axis) {
  19155. case "+x":
  19156. this.left += toMove;
  19157. this.right += toMove;
  19158. break;
  19159. case "-x":
  19160. this.left -= toMove;
  19161. this.right -= toMove;
  19162. break;
  19163. case "+y":
  19164. this.top += toMove;
  19165. this.bottom += toMove;
  19166. break;
  19167. case "-y":
  19168. this.top -= toMove;
  19169. this.bottom -= toMove;
  19170. break;
  19171. }
  19172. };
  19173. // Check if this box overlaps another box, b2.
  19174. BoxPosition.prototype.overlaps = function (b2) {
  19175. return this.left < b2.right &&
  19176. this.right > b2.left &&
  19177. this.top < b2.bottom &&
  19178. this.bottom > b2.top;
  19179. };
  19180. // Check if this box overlaps any other boxes in boxes.
  19181. BoxPosition.prototype.overlapsAny = function (boxes) {
  19182. for (var i = 0; i < boxes.length; i++) {
  19183. if (this.overlaps(boxes[i])) {
  19184. return true;
  19185. }
  19186. }
  19187. return false;
  19188. };
  19189. // Check if this box is within another box.
  19190. BoxPosition.prototype.within = function (container) {
  19191. return this.top >= container.top &&
  19192. this.bottom <= container.bottom &&
  19193. this.left >= container.left &&
  19194. this.right <= container.right;
  19195. };
  19196. // Check if this box is entirely within the container or it is overlapping
  19197. // on the edge opposite of the axis direction passed. For example, if "+x" is
  19198. // passed and the box is overlapping on the left edge of the container, then
  19199. // return true.
  19200. BoxPosition.prototype.overlapsOppositeAxis = function (container, axis) {
  19201. switch (axis) {
  19202. case "+x":
  19203. return this.left < container.left;
  19204. case "-x":
  19205. return this.right > container.right;
  19206. case "+y":
  19207. return this.top < container.top;
  19208. case "-y":
  19209. return this.bottom > container.bottom;
  19210. }
  19211. };
  19212. // Find the percentage of the area that this box is overlapping with another
  19213. // box.
  19214. BoxPosition.prototype.intersectPercentage = function (b2) {
  19215. var x = Math.max(0, Math.min(this.right, b2.right) - Math.max(this.left, b2.left)),
  19216. y = Math.max(0, Math.min(this.bottom, b2.bottom) - Math.max(this.top, b2.top)),
  19217. intersectArea = x * y;
  19218. return intersectArea / (this.height * this.width);
  19219. };
  19220. // Convert the positions from this box to CSS compatible positions using
  19221. // the reference container's positions. This has to be done because this
  19222. // box's positions are in reference to the viewport origin, whereas, CSS
  19223. // values are in referecne to their respective edges.
  19224. BoxPosition.prototype.toCSSCompatValues = function (reference) {
  19225. return {
  19226. top: this.top - reference.top,
  19227. bottom: reference.bottom - this.bottom,
  19228. left: this.left - reference.left,
  19229. right: reference.right - this.right,
  19230. height: this.height,
  19231. width: this.width
  19232. };
  19233. };
  19234. // Get an object that represents the box's position without anything extra.
  19235. // Can pass a StyleBox, HTMLElement, or another BoxPositon.
  19236. BoxPosition.getSimpleBoxPosition = function (obj) {
  19237. var height = obj.div ? obj.div.offsetHeight : obj.tagName ? obj.offsetHeight : 0;
  19238. var width = obj.div ? obj.div.offsetWidth : obj.tagName ? obj.offsetWidth : 0;
  19239. var top = obj.div ? obj.div.offsetTop : obj.tagName ? obj.offsetTop : 0;
  19240. obj = obj.div ? obj.div.getBoundingClientRect() :
  19241. obj.tagName ? obj.getBoundingClientRect() : obj;
  19242. var ret = {
  19243. left: obj.left,
  19244. right: obj.right,
  19245. top: obj.top || top,
  19246. height: obj.height || height,
  19247. bottom: obj.bottom || (top + (obj.height || height)),
  19248. width: obj.width || width
  19249. };
  19250. return ret;
  19251. };
  19252. // Move a StyleBox to its specified, or next best, position. The containerBox
  19253. // is the box that contains the StyleBox, such as a div. boxPositions are
  19254. // a list of other boxes that the styleBox can't overlap with.
  19255. function moveBoxToLinePosition(window, styleBox, containerBox, boxPositions) {
  19256. // Find the best position for a cue box, b, on the video. The axis parameter
  19257. // is a list of axis, the order of which, it will move the box along. For example:
  19258. // Passing ["+x", "-x"] will move the box first along the x axis in the positive
  19259. // direction. If it doesn't find a good position for it there it will then move
  19260. // it along the x axis in the negative direction.
  19261. function findBestPosition(b, axis) {
  19262. var bestPosition,
  19263. specifiedPosition = new BoxPosition(b),
  19264. percentage = 1; // Highest possible so the first thing we get is better.
  19265. for (var i = 0; i < axis.length; i++) {
  19266. while (b.overlapsOppositeAxis(containerBox, axis[i]) ||
  19267. (b.within(containerBox) && b.overlapsAny(boxPositions))) {
  19268. b.move(axis[i]);
  19269. }
  19270. // We found a spot where we aren't overlapping anything. This is our
  19271. // best position.
  19272. if (b.within(containerBox)) {
  19273. return b;
  19274. }
  19275. var p = b.intersectPercentage(containerBox);
  19276. // If we're outside the container box less then we were on our last try
  19277. // then remember this position as the best position.
  19278. if (percentage > p) {
  19279. bestPosition = new BoxPosition(b);
  19280. percentage = p;
  19281. }
  19282. // Reset the box position to the specified position.
  19283. b = new BoxPosition(specifiedPosition);
  19284. }
  19285. return bestPosition || specifiedPosition;
  19286. }
  19287. var boxPosition = new BoxPosition(styleBox),
  19288. cue = styleBox.cue,
  19289. linePos = computeLinePos(cue),
  19290. axis = [];
  19291. // If we have a line number to align the cue to.
  19292. if (cue.snapToLines) {
  19293. var size;
  19294. switch (cue.vertical) {
  19295. case "":
  19296. axis = ["+y", "-y"];
  19297. size = "height";
  19298. break;
  19299. case "rl":
  19300. axis = ["+x", "-x"];
  19301. size = "width";
  19302. break;
  19303. case "lr":
  19304. axis = ["-x", "+x"];
  19305. size = "width";
  19306. break;
  19307. }
  19308. var step = boxPosition.lineHeight,
  19309. position = step * Math.round(linePos),
  19310. maxPosition = containerBox[size] + step,
  19311. initialAxis = axis[0];
  19312. // If the specified intial position is greater then the max position then
  19313. // clamp the box to the amount of steps it would take for the box to
  19314. // reach the max position.
  19315. if (Math.abs(position) > maxPosition) {
  19316. position = position < 0 ? -1 : 1;
  19317. position *= Math.ceil(maxPosition / step) * step;
  19318. }
  19319. // If computed line position returns negative then line numbers are
  19320. // relative to the bottom of the video instead of the top. Therefore, we
  19321. // need to increase our initial position by the length or width of the
  19322. // video, depending on the writing direction, and reverse our axis directions.
  19323. if (linePos < 0) {
  19324. position += cue.vertical === "" ? containerBox.height : containerBox.width;
  19325. axis = axis.reverse();
  19326. }
  19327. // Move the box to the specified position. This may not be its best
  19328. // position.
  19329. boxPosition.move(initialAxis, position);
  19330. } else {
  19331. // If we have a percentage line value for the cue.
  19332. var calculatedPercentage = (boxPosition.lineHeight / containerBox.height) * 100;
  19333. switch (cue.lineAlign) {
  19334. case "middle":
  19335. linePos -= (calculatedPercentage / 2);
  19336. break;
  19337. case "end":
  19338. linePos -= calculatedPercentage;
  19339. break;
  19340. }
  19341. // Apply initial line position to the cue box.
  19342. switch (cue.vertical) {
  19343. case "":
  19344. styleBox.applyStyles({
  19345. top: styleBox.formatStyle(linePos, "%")
  19346. });
  19347. break;
  19348. case "rl":
  19349. styleBox.applyStyles({
  19350. left: styleBox.formatStyle(linePos, "%")
  19351. });
  19352. break;
  19353. case "lr":
  19354. styleBox.applyStyles({
  19355. right: styleBox.formatStyle(linePos, "%")
  19356. });
  19357. break;
  19358. }
  19359. axis = ["+y", "-x", "+x", "-y"];
  19360. // Get the box position again after we've applied the specified positioning
  19361. // to it.
  19362. boxPosition = new BoxPosition(styleBox);
  19363. }
  19364. var bestPosition = findBestPosition(boxPosition, axis);
  19365. styleBox.move(bestPosition.toCSSCompatValues(containerBox));
  19366. }
  19367. function WebVTT() {
  19368. // Nothing
  19369. }
  19370. // Helper to allow strings to be decoded instead of the default binary utf8 data.
  19371. WebVTT.StringDecoder = function () {
  19372. return {
  19373. decode: function (data) {
  19374. if (!data) {
  19375. return "";
  19376. }
  19377. if (typeof data !== "string") {
  19378. throw new Error("Error - expected string data.");
  19379. }
  19380. return decodeURIComponent(encodeURIComponent(data));
  19381. }
  19382. };
  19383. };
  19384. WebVTT.convertCueToDOMTree = function (window, cuetext) {
  19385. if (!window || !cuetext) {
  19386. return null;
  19387. }
  19388. return parseContent(window, cuetext);
  19389. };
  19390. var FONT_SIZE_PERCENT = 0.05;
  19391. var FONT_STYLE = "sans-serif";
  19392. var CUE_BACKGROUND_PADDING = "1.5%";
  19393. // Runs the processing model over the cues and regions passed to it.
  19394. // @param overlay A block level element (usually a div) that the computed cues
  19395. // and regions will be placed into.
  19396. WebVTT.processCues = function (window, cues, overlay) {
  19397. if (!window || !cues || !overlay) {
  19398. return null;
  19399. }
  19400. // Remove all previous children.
  19401. while (overlay.firstChild) {
  19402. overlay.removeChild(overlay.firstChild);
  19403. }
  19404. var paddedOverlay = window.document.createElement("div");
  19405. paddedOverlay.style.position = "absolute";
  19406. paddedOverlay.style.left = "0";
  19407. paddedOverlay.style.right = "0";
  19408. paddedOverlay.style.top = "0";
  19409. paddedOverlay.style.bottom = "0";
  19410. paddedOverlay.style.margin = CUE_BACKGROUND_PADDING;
  19411. overlay.appendChild(paddedOverlay);
  19412. // Determine if we need to compute the display states of the cues. This could
  19413. // be the case if a cue's state has been changed since the last computation or
  19414. // if it has not been computed yet.
  19415. function shouldCompute(cues) {
  19416. for (var i = 0; i < cues.length; i++) {
  19417. if (cues[i].hasBeenReset || !cues[i].displayState) {
  19418. return true;
  19419. }
  19420. }
  19421. return false;
  19422. }
  19423. // We don't need to recompute the cues' display states. Just reuse them.
  19424. if (!shouldCompute(cues)) {
  19425. for (var i = 0; i < cues.length; i++) {
  19426. paddedOverlay.appendChild(cues[i].displayState);
  19427. }
  19428. return;
  19429. }
  19430. var boxPositions = [],
  19431. containerBox = BoxPosition.getSimpleBoxPosition(paddedOverlay),
  19432. fontSize = Math.round(containerBox.height * FONT_SIZE_PERCENT * 100) / 100;
  19433. var styleOptions = {
  19434. font: fontSize + "px " + FONT_STYLE
  19435. };
  19436. (function () {
  19437. var styleBox, cue;
  19438. for (var i = 0; i < cues.length; i++) {
  19439. cue = cues[i];
  19440. // Compute the intial position and styles of the cue div.
  19441. styleBox = new CueStyleBox(window, cue, styleOptions);
  19442. paddedOverlay.appendChild(styleBox.div);
  19443. // Move the cue div to it's correct line position.
  19444. moveBoxToLinePosition(window, styleBox, containerBox, boxPositions);
  19445. // Remember the computed div so that we don't have to recompute it later
  19446. // if we don't have too.
  19447. cue.displayState = styleBox.div;
  19448. boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox));
  19449. }
  19450. })();
  19451. };
  19452. WebVTT.Parser = function (window, vttjs, decoder) {
  19453. if (!decoder) {
  19454. decoder = vttjs;
  19455. vttjs = {};
  19456. }
  19457. if (!vttjs) {
  19458. vttjs = {};
  19459. }
  19460. this.window = window;
  19461. this.vttjs = vttjs;
  19462. this.state = "INITIAL";
  19463. this.buffer = "";
  19464. this.decoder = decoder || new TextDecoder("utf8");
  19465. this.regionList = [];
  19466. };
  19467. WebVTT.Parser.prototype = {
  19468. // If the error is a ParsingError then report it to the consumer if
  19469. // possible. If it's not a ParsingError then throw it like normal.
  19470. reportOrThrowError: function (e) {
  19471. if (e instanceof ParsingError) {
  19472. this.onparsingerror && this.onparsingerror(e);
  19473. } else {
  19474. throw e;
  19475. }
  19476. },
  19477. parse: function (data) {
  19478. var self = this;
  19479. // If there is no data then we won't decode it, but will just try to parse
  19480. // whatever is in buffer already. This may occur in circumstances, for
  19481. // example when flush() is called.
  19482. if (data) {
  19483. // Try to decode the data that we received.
  19484. self.buffer += self.decoder.decode(data, { stream: true });
  19485. }
  19486. function collectNextLine() {
  19487. var buffer = self.buffer;
  19488. var pos = 0;
  19489. while (pos < buffer.length && buffer[pos] !== '\r' && buffer[pos] !== '\n') {
  19490. ++pos;
  19491. }
  19492. var line = buffer.substr(0, pos);
  19493. // Advance the buffer early in case we fail below.
  19494. if (buffer[pos] === '\r') {
  19495. ++pos;
  19496. }
  19497. if (buffer[pos] === '\n') {
  19498. ++pos;
  19499. }
  19500. self.buffer = buffer.substr(pos);
  19501. return line;
  19502. }
  19503. // 3.4 WebVTT region and WebVTT region settings syntax
  19504. function parseRegion(input) {
  19505. var settings = new Settings();
  19506. parseOptions(input, function (k, v) {
  19507. switch (k) {
  19508. case "id":
  19509. settings.set(k, v);
  19510. break;
  19511. case "width":
  19512. settings.percent(k, v);
  19513. break;
  19514. case "lines":
  19515. settings.integer(k, v);
  19516. break;
  19517. case "regionanchor":
  19518. case "viewportanchor":
  19519. var xy = v.split(',');
  19520. if (xy.length !== 2) {
  19521. break;
  19522. }
  19523. // We have to make sure both x and y parse, so use a temporary
  19524. // settings object here.
  19525. var anchor = new Settings();
  19526. anchor.percent("x", xy[0]);
  19527. anchor.percent("y", xy[1]);
  19528. if (!anchor.has("x") || !anchor.has("y")) {
  19529. break;
  19530. }
  19531. settings.set(k + "X", anchor.get("x"));
  19532. settings.set(k + "Y", anchor.get("y"));
  19533. break;
  19534. case "scroll":
  19535. settings.alt(k, v, ["up"]);
  19536. break;
  19537. }
  19538. }, /=/, /\s/);
  19539. // Create the region, using default values for any values that were not
  19540. // specified.
  19541. if (settings.has("id")) {
  19542. var region = new (self.vttjs.VTTRegion || self.window.VTTRegion)();
  19543. region.width = settings.get("width", 100);
  19544. region.lines = settings.get("lines", 3);
  19545. region.regionAnchorX = settings.get("regionanchorX", 0);
  19546. region.regionAnchorY = settings.get("regionanchorY", 100);
  19547. region.viewportAnchorX = settings.get("viewportanchorX", 0);
  19548. region.viewportAnchorY = settings.get("viewportanchorY", 100);
  19549. region.scroll = settings.get("scroll", "");
  19550. // Register the region.
  19551. self.onregion && self.onregion(region);
  19552. // Remember the VTTRegion for later in case we parse any VTTCues that
  19553. // reference it.
  19554. self.regionList.push({
  19555. id: settings.get("id"),
  19556. region: region
  19557. });
  19558. }
  19559. }
  19560. // 3.2 WebVTT metadata header syntax
  19561. function parseHeader(input) {
  19562. parseOptions(input, function (k, v) {
  19563. switch (k) {
  19564. case "Region":
  19565. // 3.3 WebVTT region metadata header syntax
  19566. parseRegion(v);
  19567. break;
  19568. }
  19569. }, /:/);
  19570. }
  19571. // 5.1 WebVTT file parsing.
  19572. try {
  19573. var line;
  19574. if (self.state === "INITIAL") {
  19575. // We can't start parsing until we have the first line.
  19576. if (!/\r\n|\n/.test(self.buffer)) {
  19577. return this;
  19578. }
  19579. line = collectNextLine();
  19580. var m = line.match(/^WEBVTT([ \t].*)?$/);
  19581. if (!m || !m[0]) {
  19582. throw new ParsingError(ParsingError.Errors.BadSignature);
  19583. }
  19584. self.state = "HEADER";
  19585. }
  19586. var alreadyCollectedLine = false;
  19587. while (self.buffer) {
  19588. // We can't parse a line until we have the full line.
  19589. if (!/\r\n|\n/.test(self.buffer)) {
  19590. return this;
  19591. }
  19592. if (!alreadyCollectedLine) {
  19593. line = collectNextLine();
  19594. } else {
  19595. alreadyCollectedLine = false;
  19596. }
  19597. switch (self.state) {
  19598. case "HEADER":
  19599. // 13-18 - Allow a header (metadata) under the WEBVTT line.
  19600. if (/:/.test(line)) {
  19601. parseHeader(line);
  19602. } else if (!line) {
  19603. // An empty line terminates the header and starts the body (cues).
  19604. self.state = "ID";
  19605. }
  19606. continue;
  19607. case "NOTE":
  19608. // Ignore NOTE blocks.
  19609. if (!line) {
  19610. self.state = "ID";
  19611. }
  19612. continue;
  19613. case "ID":
  19614. // Check for the start of NOTE blocks.
  19615. if (/^NOTE($|[ \t])/.test(line)) {
  19616. self.state = "NOTE";
  19617. break;
  19618. }
  19619. // 19-29 - Allow any number of line terminators, then initialize new cue values.
  19620. if (!line) {
  19621. continue;
  19622. }
  19623. self.cue = new (self.vttjs.VTTCue || self.window.VTTCue)(0, 0, "");
  19624. self.state = "CUE";
  19625. // 30-39 - Check if self line contains an optional identifier or timing data.
  19626. if (line.indexOf("-->") === -1) {
  19627. self.cue.id = line;
  19628. continue;
  19629. }
  19630. // Process line as start of a cue.
  19631. /*falls through*/
  19632. case "CUE":
  19633. // 40 - Collect cue timings and settings.
  19634. try {
  19635. parseCue(line, self.cue, self.regionList);
  19636. } catch (e) {
  19637. self.reportOrThrowError(e);
  19638. // In case of an error ignore rest of the cue.
  19639. self.cue = null;
  19640. self.state = "BADCUE";
  19641. continue;
  19642. }
  19643. self.state = "CUETEXT";
  19644. continue;
  19645. case "CUETEXT":
  19646. var hasSubstring = line.indexOf("-->") !== -1;
  19647. // 34 - If we have an empty line then report the cue.
  19648. // 35 - If we have the special substring '-->' then report the cue,
  19649. // but do not collect the line as we need to process the current
  19650. // one as a new cue.
  19651. if (!line || hasSubstring && (alreadyCollectedLine = true)) {
  19652. // We are done parsing self cue.
  19653. self.oncue && self.oncue(self.cue);
  19654. self.cue = null;
  19655. self.state = "ID";
  19656. continue;
  19657. }
  19658. if (self.cue.text) {
  19659. self.cue.text += "\n";
  19660. }
  19661. self.cue.text += line;
  19662. continue;
  19663. case "BADCUE": // BADCUE
  19664. // 54-62 - Collect and discard the remaining cue.
  19665. if (!line) {
  19666. self.state = "ID";
  19667. }
  19668. continue;
  19669. }
  19670. }
  19671. } catch (e) {
  19672. self.reportOrThrowError(e);
  19673. // If we are currently parsing a cue, report what we have.
  19674. if (self.state === "CUETEXT" && self.cue && self.oncue) {
  19675. self.oncue(self.cue);
  19676. }
  19677. self.cue = null;
  19678. // Enter BADWEBVTT state if header was not parsed correctly otherwise
  19679. // another exception occurred so enter BADCUE state.
  19680. self.state = self.state === "INITIAL" ? "BADWEBVTT" : "BADCUE";
  19681. }
  19682. return this;
  19683. },
  19684. flush: function () {
  19685. var self = this;
  19686. try {
  19687. // Finish decoding the stream.
  19688. self.buffer += self.decoder.decode();
  19689. // Synthesize the end of the current cue or region.
  19690. if (self.cue || self.state === "HEADER") {
  19691. self.buffer += "\n\n";
  19692. self.parse();
  19693. }
  19694. // If we've flushed, parsed, and we're still on the INITIAL state then
  19695. // that means we don't have enough of the stream to parse the first
  19696. // line.
  19697. if (self.state === "INITIAL") {
  19698. throw new ParsingError(ParsingError.Errors.BadSignature);
  19699. }
  19700. } catch (e) {
  19701. self.reportOrThrowError(e);
  19702. }
  19703. self.onflush && self.onflush();
  19704. return this;
  19705. }
  19706. };
  19707. global.WebVTT = WebVTT;
  19708. }(this, (this.vttjs || {})));