video.js 848 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082
  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 || 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. var 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. var maxTimeoutId
  133. var result
  134. var stamp
  135. var thisArg
  136. var timeoutId
  137. var trailingCall
  138. var lastCalled = 0
  139. var maxWait = false
  140. var 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. var 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. } else if (!maxTimeoutId) {
  207. maxTimeoutId = setTimeout(maxDelayed, remaining)
  208. }
  209. }
  210. if (isCalled && timeoutId) {
  211. timeoutId = clearTimeout(timeoutId)
  212. } else if (!timeoutId && wait !== maxWait) {
  213. timeoutId = setTimeout(delayed, wait)
  214. }
  215. if (leadingCall) {
  216. isCalled = true
  217. result = func.apply(thisArg, args)
  218. }
  219. if (isCalled && !timeoutId && !maxTimeoutId) {
  220. args = thisArg = undefined
  221. }
  222. return result
  223. }
  224. debounced.cancel = cancel
  225. return debounced
  226. }
  227. module.exports = debounce
  228. }, { '../date/now': 4, '../lang/isObject': 33 }], 6: [function(_dereq_, module, exports) {
  229. /** Used as the `TypeError` message for "Functions" methods. */
  230. var FUNC_ERROR_TEXT = 'Expected a function'
  231. /* Native method references for those with the same name as other `lodash` methods. */
  232. var nativeMax = Math.max
  233. /**
  234. * Creates a function that invokes `func` with the `this` binding of the
  235. * created function and arguments from `start` and beyond provided as an array.
  236. *
  237. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
  238. *
  239. * @static
  240. * @memberOf _
  241. * @category Function
  242. * @param {Function} func The function to apply a rest parameter to.
  243. * @param {number} [start=func.length-1] The start position of the rest parameter.
  244. * @returns {Function} Returns the new function.
  245. * @example
  246. *
  247. * var say = _.restParam(function(what, names) {
  248. * return what + ' ' + _.initial(names).join(', ') +
  249. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  250. * });
  251. *
  252. * say('hello', 'fred', 'barney', 'pebbles');
  253. * // => 'hello fred, barney, & pebbles'
  254. */
  255. function restParam(func, start) {
  256. if (typeof func != 'function') {
  257. throw new TypeError(FUNC_ERROR_TEXT)
  258. }
  259. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0)
  260. return function() {
  261. var args = arguments
  262. var index = -1
  263. var length = nativeMax(args.length - start, 0)
  264. var rest = Array(length)
  265. while (++index < length) {
  266. rest[index] = args[start + index]
  267. }
  268. switch (start) {
  269. case 0: return func.call(this, rest)
  270. case 1: return func.call(this, args[0], rest)
  271. case 2: return func.call(this, args[0], args[1], rest)
  272. }
  273. var otherArgs = Array(start + 1)
  274. index = -1
  275. while (++index < start) {
  276. otherArgs[index] = args[index]
  277. }
  278. otherArgs[start] = rest
  279. return func.apply(this, otherArgs)
  280. }
  281. }
  282. module.exports = restParam
  283. }, {}], 7: [function(_dereq_, module, exports) {
  284. var debounce = _dereq_('./debounce')
  285. var isObject = _dereq_('../lang/isObject')
  286. /** Used as the `TypeError` message for "Functions" methods. */
  287. var FUNC_ERROR_TEXT = 'Expected a function'
  288. /**
  289. * Creates a throttled function that only invokes `func` at most once per
  290. * every `wait` milliseconds. The throttled function comes with a `cancel`
  291. * method to cancel delayed invocations. Provide an options object to indicate
  292. * that `func` should be invoked on the leading and/or trailing edge of the
  293. * `wait` timeout. Subsequent calls to the throttled function return the
  294. * result of the last `func` call.
  295. *
  296. * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
  297. * on the trailing edge of the timeout only if the the throttled function is
  298. * invoked more than once during the `wait` timeout.
  299. *
  300. * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
  301. * for details over the differences between `_.throttle` and `_.debounce`.
  302. *
  303. * @static
  304. * @memberOf _
  305. * @category Function
  306. * @param {Function} func The function to throttle.
  307. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  308. * @param {Object} [options] The options object.
  309. * @param {boolean} [options.leading=true] Specify invoking on the leading
  310. * edge of the timeout.
  311. * @param {boolean} [options.trailing=true] Specify invoking on the trailing
  312. * edge of the timeout.
  313. * @returns {Function} Returns the new throttled function.
  314. * @example
  315. *
  316. * // avoid excessively updating the position while scrolling
  317. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  318. *
  319. * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes
  320. * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
  321. * 'trailing': false
  322. * }));
  323. *
  324. * // cancel a trailing throttled call
  325. * jQuery(window).on('popstate', throttled.cancel);
  326. */
  327. function throttle(func, wait, options) {
  328. var leading = true
  329. var trailing = true
  330. if (typeof func != 'function') {
  331. throw new TypeError(FUNC_ERROR_TEXT)
  332. }
  333. if (options === false) {
  334. leading = false
  335. } else if (isObject(options)) {
  336. leading = 'leading' in options ? !!options.leading : leading
  337. trailing = 'trailing' in options ? !!options.trailing : trailing
  338. }
  339. return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing })
  340. }
  341. module.exports = throttle
  342. }, { '../lang/isObject': 33, './debounce': 5 }], 8: [function(_dereq_, module, exports) {
  343. /**
  344. * Copies the values of `source` to `array`.
  345. *
  346. * @private
  347. * @param {Array} source The array to copy values from.
  348. * @param {Array} [array=[]] The array to copy values to.
  349. * @returns {Array} Returns `array`.
  350. */
  351. function arrayCopy(source, array) {
  352. var index = -1
  353. var length = source.length
  354. array || (array = Array(length))
  355. while (++index < length) {
  356. array[index] = source[index]
  357. }
  358. return array
  359. }
  360. module.exports = arrayCopy
  361. }, {}], 9: [function(_dereq_, module, exports) {
  362. /**
  363. * A specialized version of `_.forEach` for arrays without support for callback
  364. * shorthands and `this` binding.
  365. *
  366. * @private
  367. * @param {Array} array The array to iterate over.
  368. * @param {Function} iteratee The function invoked per iteration.
  369. * @returns {Array} Returns `array`.
  370. */
  371. function arrayEach(array, iteratee) {
  372. var index = -1
  373. var length = array.length
  374. while (++index < length) {
  375. if (iteratee(array[index], index, array) === false) {
  376. break
  377. }
  378. }
  379. return array
  380. }
  381. module.exports = arrayEach
  382. }, {}], 10: [function(_dereq_, module, exports) {
  383. /**
  384. * Copies properties of `source` to `object`.
  385. *
  386. * @private
  387. * @param {Object} source The object to copy properties from.
  388. * @param {Array} props The property names to copy.
  389. * @param {Object} [object={}] The object to copy properties to.
  390. * @returns {Object} Returns `object`.
  391. */
  392. function baseCopy(source, props, object) {
  393. object || (object = {})
  394. var index = -1
  395. var length = props.length
  396. while (++index < length) {
  397. var key = props[index]
  398. object[key] = source[key]
  399. }
  400. return object
  401. }
  402. module.exports = baseCopy
  403. }, {}], 11: [function(_dereq_, module, exports) {
  404. var createBaseFor = _dereq_('./createBaseFor')
  405. /**
  406. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  407. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  408. * each property. Iteratee functions may exit iteration early by explicitly
  409. * returning `false`.
  410. *
  411. * @private
  412. * @param {Object} object The object to iterate over.
  413. * @param {Function} iteratee The function invoked per iteration.
  414. * @param {Function} keysFunc The function to get the keys of `object`.
  415. * @returns {Object} Returns `object`.
  416. */
  417. var baseFor = createBaseFor()
  418. module.exports = baseFor
  419. }, { './createBaseFor': 18 }], 12: [function(_dereq_, module, exports) {
  420. var baseFor = _dereq_('./baseFor')
  421. var keysIn = _dereq_('../object/keysIn')
  422. /**
  423. * The base implementation of `_.forIn` without support for callback
  424. * shorthands and `this` binding.
  425. *
  426. * @private
  427. * @param {Object} object The object to iterate over.
  428. * @param {Function} iteratee The function invoked per iteration.
  429. * @returns {Object} Returns `object`.
  430. */
  431. function baseForIn(object, iteratee) {
  432. return baseFor(object, iteratee, keysIn)
  433. }
  434. module.exports = baseForIn
  435. }, { '../object/keysIn': 39, './baseFor': 11 }], 13: [function(_dereq_, module, exports) {
  436. var arrayEach = _dereq_('./arrayEach')
  437. var baseMergeDeep = _dereq_('./baseMergeDeep')
  438. var isArray = _dereq_('../lang/isArray')
  439. var isArrayLike = _dereq_('./isArrayLike')
  440. var isObject = _dereq_('../lang/isObject')
  441. var isObjectLike = _dereq_('./isObjectLike')
  442. var isTypedArray = _dereq_('../lang/isTypedArray')
  443. var keys = _dereq_('../object/keys')
  444. /**
  445. * The base implementation of `_.merge` without support for argument juggling,
  446. * multiple sources, and `this` binding `customizer` functions.
  447. *
  448. * @private
  449. * @param {Object} object The destination object.
  450. * @param {Object} source The source object.
  451. * @param {Function} [customizer] The function to customize merged values.
  452. * @param {Array} [stackA=[]] Tracks traversed source objects.
  453. * @param {Array} [stackB=[]] Associates values with source counterparts.
  454. * @returns {Object} Returns `object`.
  455. */
  456. function baseMerge(object, source, customizer, stackA, stackB) {
  457. if (!isObject(object)) {
  458. return object
  459. }
  460. var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source))
  461. var props = isSrcArr ? undefined : keys(source)
  462. arrayEach(props || source, function(srcValue, key) {
  463. if (props) {
  464. key = srcValue
  465. srcValue = source[key]
  466. }
  467. if (isObjectLike(srcValue)) {
  468. stackA || (stackA = [])
  469. stackB || (stackB = [])
  470. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB)
  471. } else {
  472. var value = object[key]
  473. var result = customizer ? customizer(value, srcValue, key, object, source) : undefined
  474. var isCommon = result === undefined
  475. if (isCommon) {
  476. result = srcValue
  477. }
  478. if ((result !== undefined || (isSrcArr && !(key in object))) &&
  479. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  480. object[key] = result
  481. }
  482. }
  483. })
  484. return object
  485. }
  486. module.exports = baseMerge
  487. }, { '../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) {
  488. var arrayCopy = _dereq_('./arrayCopy')
  489. var isArguments = _dereq_('../lang/isArguments')
  490. var isArray = _dereq_('../lang/isArray')
  491. var isArrayLike = _dereq_('./isArrayLike')
  492. var isPlainObject = _dereq_('../lang/isPlainObject')
  493. var isTypedArray = _dereq_('../lang/isTypedArray')
  494. var toPlainObject = _dereq_('../lang/toPlainObject')
  495. /**
  496. * A specialized version of `baseMerge` for arrays and objects which performs
  497. * deep merges and tracks traversed objects enabling objects with circular
  498. * references to be merged.
  499. *
  500. * @private
  501. * @param {Object} object The destination object.
  502. * @param {Object} source The source object.
  503. * @param {string} key The key of the value to merge.
  504. * @param {Function} mergeFunc The function to merge values.
  505. * @param {Function} [customizer] The function to customize merged values.
  506. * @param {Array} [stackA=[]] Tracks traversed source objects.
  507. * @param {Array} [stackB=[]] Associates values with source counterparts.
  508. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  509. */
  510. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  511. var length = stackA.length
  512. var srcValue = source[key]
  513. while (length--) {
  514. if (stackA[length] == srcValue) {
  515. object[key] = stackB[length]
  516. return
  517. }
  518. }
  519. var value = object[key]
  520. var result = customizer ? customizer(value, srcValue, key, object, source) : undefined
  521. var isCommon = result === undefined
  522. if (isCommon) {
  523. result = srcValue
  524. if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
  525. result = isArray(value)
  526. ? value
  527. : (isArrayLike(value) ? arrayCopy(value) : [])
  528. } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  529. result = isArguments(value)
  530. ? toPlainObject(value)
  531. : (isPlainObject(value) ? value : {})
  532. } else {
  533. isCommon = false
  534. }
  535. }
  536. // Add the source value to the stack of traversed objects and associate
  537. // it with its merged value.
  538. stackA.push(srcValue)
  539. stackB.push(result)
  540. if (isCommon) {
  541. // Recursively merge objects and arrays (susceptible to call stack limits).
  542. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB)
  543. } else if (result === result ? (result !== value) : (value === value)) {
  544. object[key] = result
  545. }
  546. }
  547. module.exports = baseMergeDeep
  548. }, { '../lang/isArguments': 29, '../lang/isArray': 30, '../lang/isPlainObject': 34, '../lang/isTypedArray': 36, '../lang/toPlainObject': 37, './arrayCopy': 8, './isArrayLike': 21 }], 15: [function(_dereq_, module, exports) {
  549. var toObject = _dereq_('./toObject')
  550. /**
  551. * The base implementation of `_.property` without support for deep paths.
  552. *
  553. * @private
  554. * @param {string} key The key of the property to get.
  555. * @returns {Function} Returns the new function.
  556. */
  557. function baseProperty(key) {
  558. return function(object) {
  559. return object == null ? undefined : toObject(object)[key]
  560. }
  561. }
  562. module.exports = baseProperty
  563. }, { './toObject': 28 }], 16: [function(_dereq_, module, exports) {
  564. var identity = _dereq_('../utility/identity')
  565. /**
  566. * A specialized version of `baseCallback` which only supports `this` binding
  567. * and specifying the number of arguments to provide to `func`.
  568. *
  569. * @private
  570. * @param {Function} func The function to bind.
  571. * @param {*} thisArg The `this` binding of `func`.
  572. * @param {number} [argCount] The number of arguments to provide to `func`.
  573. * @returns {Function} Returns the callback.
  574. */
  575. function bindCallback(func, thisArg, argCount) {
  576. if (typeof func != 'function') {
  577. return identity
  578. }
  579. if (thisArg === undefined) {
  580. return func
  581. }
  582. switch (argCount) {
  583. case 1: return function(value) {
  584. return func.call(thisArg, value)
  585. }
  586. case 3: return function(value, index, collection) {
  587. return func.call(thisArg, value, index, collection)
  588. }
  589. case 4: return function(accumulator, value, index, collection) {
  590. return func.call(thisArg, accumulator, value, index, collection)
  591. }
  592. case 5: return function(value, other, key, object, source) {
  593. return func.call(thisArg, value, other, key, object, source)
  594. }
  595. }
  596. return function() {
  597. return func.apply(thisArg, arguments)
  598. }
  599. }
  600. module.exports = bindCallback
  601. }, { '../utility/identity': 42 }], 17: [function(_dereq_, module, exports) {
  602. var bindCallback = _dereq_('./bindCallback')
  603. var isIterateeCall = _dereq_('./isIterateeCall')
  604. var restParam = _dereq_('../function/restParam')
  605. /**
  606. * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
  607. *
  608. * @private
  609. * @param {Function} assigner The function to assign values.
  610. * @returns {Function} Returns the new assigner function.
  611. */
  612. function createAssigner(assigner) {
  613. return restParam(function(object, sources) {
  614. var index = -1
  615. var length = object == null ? 0 : sources.length
  616. var customizer = length > 2 ? sources[length - 2] : undefined
  617. var guard = length > 2 ? sources[2] : undefined
  618. var thisArg = length > 1 ? sources[length - 1] : undefined
  619. if (typeof customizer == 'function') {
  620. customizer = bindCallback(customizer, thisArg, 5)
  621. length -= 2
  622. } else {
  623. customizer = typeof thisArg == 'function' ? thisArg : undefined
  624. length -= (customizer ? 1 : 0)
  625. }
  626. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  627. customizer = length < 3 ? undefined : customizer
  628. length = 1
  629. }
  630. while (++index < length) {
  631. var source = sources[index]
  632. if (source) {
  633. assigner(object, source, customizer)
  634. }
  635. }
  636. return object
  637. })
  638. }
  639. module.exports = createAssigner
  640. }, { '../function/restParam': 6, './bindCallback': 16, './isIterateeCall': 24 }], 18: [function(_dereq_, module, exports) {
  641. var toObject = _dereq_('./toObject')
  642. /**
  643. * Creates a base function for `_.forIn` or `_.forInRight`.
  644. *
  645. * @private
  646. * @param {boolean} [fromRight] Specify iterating from right to left.
  647. * @returns {Function} Returns the new base function.
  648. */
  649. function createBaseFor(fromRight) {
  650. return function(object, iteratee, keysFunc) {
  651. var iterable = toObject(object)
  652. var props = keysFunc(object)
  653. var length = props.length
  654. var index = fromRight ? length : -1
  655. while ((fromRight ? index-- : ++index < length)) {
  656. var key = props[index]
  657. if (iteratee(iterable[key], key, iterable) === false) {
  658. break
  659. }
  660. }
  661. return object
  662. }
  663. }
  664. module.exports = createBaseFor
  665. }, { './toObject': 28 }], 19: [function(_dereq_, module, exports) {
  666. var baseProperty = _dereq_('./baseProperty')
  667. /**
  668. * Gets the "length" property value of `object`.
  669. *
  670. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  671. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  672. *
  673. * @private
  674. * @param {Object} object The object to query.
  675. * @returns {*} Returns the "length" value.
  676. */
  677. var getLength = baseProperty('length')
  678. module.exports = getLength
  679. }, { './baseProperty': 15 }], 20: [function(_dereq_, module, exports) {
  680. var isNative = _dereq_('../lang/isNative')
  681. /**
  682. * Gets the native function at `key` of `object`.
  683. *
  684. * @private
  685. * @param {Object} object The object to query.
  686. * @param {string} key The key of the method to get.
  687. * @returns {*} Returns the function if it's native, else `undefined`.
  688. */
  689. function getNative(object, key) {
  690. var value = object == null ? undefined : object[key]
  691. return isNative(value) ? value : undefined
  692. }
  693. module.exports = getNative
  694. }, { '../lang/isNative': 32 }], 21: [function(_dereq_, module, exports) {
  695. var getLength = _dereq_('./getLength')
  696. var isLength = _dereq_('./isLength')
  697. /**
  698. * Checks if `value` is array-like.
  699. *
  700. * @private
  701. * @param {*} value The value to check.
  702. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  703. */
  704. function isArrayLike(value) {
  705. return value != null && isLength(getLength(value))
  706. }
  707. module.exports = isArrayLike
  708. }, { './getLength': 19, './isLength': 25 }], 22: [function(_dereq_, module, exports) {
  709. /**
  710. * Checks if `value` is a host object in IE < 9.
  711. *
  712. * @private
  713. * @param {*} value The value to check.
  714. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  715. */
  716. var isHostObject = (function() {
  717. try {
  718. Object({ 'toString': 0 } + '')
  719. } catch (e) {
  720. return function() { return false }
  721. }
  722. return function(value) {
  723. // IE < 9 presents many host objects as `Object` objects that can coerce
  724. // to strings despite having improperly defined `toString` methods.
  725. return typeof value.toString != 'function' && typeof (value + '') == 'string'
  726. }
  727. }())
  728. module.exports = isHostObject
  729. }, {}], 23: [function(_dereq_, module, exports) {
  730. /** Used to detect unsigned integer values. */
  731. var reIsUint = /^\d+$/
  732. /**
  733. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  734. * of an array-like value.
  735. */
  736. var MAX_SAFE_INTEGER = 9007199254740991
  737. /**
  738. * Checks if `value` is a valid array-like index.
  739. *
  740. * @private
  741. * @param {*} value The value to check.
  742. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  743. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  744. */
  745. function isIndex(value, length) {
  746. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1
  747. length = length == null ? MAX_SAFE_INTEGER : length
  748. return value > -1 && value % 1 == 0 && value < length
  749. }
  750. module.exports = isIndex
  751. }, {}], 24: [function(_dereq_, module, exports) {
  752. var isArrayLike = _dereq_('./isArrayLike')
  753. var isIndex = _dereq_('./isIndex')
  754. var isObject = _dereq_('../lang/isObject')
  755. /**
  756. * Checks if the provided arguments are from an iteratee call.
  757. *
  758. * @private
  759. * @param {*} value The potential iteratee value argument.
  760. * @param {*} index The potential iteratee index or key argument.
  761. * @param {*} object The potential iteratee object argument.
  762. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  763. */
  764. function isIterateeCall(value, index, object) {
  765. if (!isObject(object)) {
  766. return false
  767. }
  768. var type = typeof index
  769. if (type == 'number'
  770. ? (isArrayLike(object) && isIndex(index, object.length))
  771. : (type == 'string' && index in object)) {
  772. var other = object[index]
  773. return value === value ? (value === other) : (other !== other)
  774. }
  775. return false
  776. }
  777. module.exports = isIterateeCall
  778. }, { '../lang/isObject': 33, './isArrayLike': 21, './isIndex': 23 }], 25: [function(_dereq_, module, exports) {
  779. /**
  780. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  781. * of an array-like value.
  782. */
  783. var MAX_SAFE_INTEGER = 9007199254740991
  784. /**
  785. * Checks if `value` is a valid array-like length.
  786. *
  787. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  788. *
  789. * @private
  790. * @param {*} value The value to check.
  791. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  792. */
  793. function isLength(value) {
  794. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER
  795. }
  796. module.exports = isLength
  797. }, {}], 26: [function(_dereq_, module, exports) {
  798. /**
  799. * Checks if `value` is object-like.
  800. *
  801. * @private
  802. * @param {*} value The value to check.
  803. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  804. */
  805. function isObjectLike(value) {
  806. return !!value && typeof value == 'object'
  807. }
  808. module.exports = isObjectLike
  809. }, {}], 27: [function(_dereq_, module, exports) {
  810. var isArguments = _dereq_('../lang/isArguments')
  811. var isArray = _dereq_('../lang/isArray')
  812. var isIndex = _dereq_('./isIndex')
  813. var isLength = _dereq_('./isLength')
  814. var isString = _dereq_('../lang/isString')
  815. var keysIn = _dereq_('../object/keysIn')
  816. /** Used for native method references. */
  817. var objectProto = Object.prototype
  818. /** Used to check objects for own properties. */
  819. var hasOwnProperty = objectProto.hasOwnProperty
  820. /**
  821. * A fallback implementation of `Object.keys` which creates an array of the
  822. * own enumerable property names of `object`.
  823. *
  824. * @private
  825. * @param {Object} object The object to query.
  826. * @returns {Array} Returns the array of property names.
  827. */
  828. function shimKeys(object) {
  829. var props = keysIn(object)
  830. var propsLength = props.length
  831. var length = propsLength && object.length
  832. var allowIndexes = !!length && isLength(length) &&
  833. (isArray(object) || isArguments(object) || isString(object))
  834. var index = -1
  835. var result = []
  836. while (++index < propsLength) {
  837. var key = props[index]
  838. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  839. result.push(key)
  840. }
  841. }
  842. return result
  843. }
  844. module.exports = shimKeys
  845. }, { '../lang/isArguments': 29, '../lang/isArray': 30, '../lang/isString': 35, '../object/keysIn': 39, './isIndex': 23, './isLength': 25 }], 28: [function(_dereq_, module, exports) {
  846. var isObject = _dereq_('../lang/isObject')
  847. var isString = _dereq_('../lang/isString')
  848. var support = _dereq_('../support')
  849. /**
  850. * Converts `value` to an object if it's not one.
  851. *
  852. * @private
  853. * @param {*} value The value to process.
  854. * @returns {Object} Returns the object.
  855. */
  856. function toObject(value) {
  857. if (support.unindexedChars && isString(value)) {
  858. var index = -1
  859. var length = value.length
  860. var result = Object(value)
  861. while (++index < length) {
  862. result[index] = value.charAt(index)
  863. }
  864. return result
  865. }
  866. return isObject(value) ? value : Object(value)
  867. }
  868. module.exports = toObject
  869. }, { '../lang/isObject': 33, '../lang/isString': 35, '../support': 41 }], 29: [function(_dereq_, module, exports) {
  870. var isArrayLike = _dereq_('../internal/isArrayLike')
  871. var isObjectLike = _dereq_('../internal/isObjectLike')
  872. /** Used for native method references. */
  873. var objectProto = Object.prototype
  874. /** Used to check objects for own properties. */
  875. var hasOwnProperty = objectProto.hasOwnProperty
  876. /** Native method references. */
  877. var propertyIsEnumerable = objectProto.propertyIsEnumerable
  878. /**
  879. * Checks if `value` is classified as an `arguments` object.
  880. *
  881. * @static
  882. * @memberOf _
  883. * @category Lang
  884. * @param {*} value The value to check.
  885. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  886. * @example
  887. *
  888. * _.isArguments(function() { return arguments; }());
  889. * // => true
  890. *
  891. * _.isArguments([1, 2, 3]);
  892. * // => false
  893. */
  894. function isArguments(value) {
  895. return isObjectLike(value) && isArrayLike(value) &&
  896. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee')
  897. }
  898. module.exports = isArguments
  899. }, { '../internal/isArrayLike': 21, '../internal/isObjectLike': 26 }], 30: [function(_dereq_, module, exports) {
  900. var getNative = _dereq_('../internal/getNative')
  901. var isLength = _dereq_('../internal/isLength')
  902. var isObjectLike = _dereq_('../internal/isObjectLike')
  903. /** `Object#toString` result references. */
  904. var arrayTag = '[object Array]'
  905. /** Used for native method references. */
  906. var objectProto = Object.prototype
  907. /**
  908. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  909. * of values.
  910. */
  911. var objToString = objectProto.toString
  912. /* Native method references for those with the same name as other `lodash` methods. */
  913. var nativeIsArray = getNative(Array, 'isArray')
  914. /**
  915. * Checks if `value` is classified as an `Array` object.
  916. *
  917. * @static
  918. * @memberOf _
  919. * @category Lang
  920. * @param {*} value The value to check.
  921. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  922. * @example
  923. *
  924. * _.isArray([1, 2, 3]);
  925. * // => true
  926. *
  927. * _.isArray(function() { return arguments; }());
  928. * // => false
  929. */
  930. var isArray = nativeIsArray || function(value) {
  931. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag
  932. }
  933. module.exports = isArray
  934. }, { '../internal/getNative': 20, '../internal/isLength': 25, '../internal/isObjectLike': 26 }], 31: [function(_dereq_, module, exports) {
  935. var isObject = _dereq_('./isObject')
  936. /** `Object#toString` result references. */
  937. var funcTag = '[object Function]'
  938. /** Used for native method references. */
  939. var objectProto = Object.prototype
  940. /**
  941. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  942. * of values.
  943. */
  944. var objToString = objectProto.toString
  945. /**
  946. * Checks if `value` is classified as a `Function` object.
  947. *
  948. * @static
  949. * @memberOf _
  950. * @category Lang
  951. * @param {*} value The value to check.
  952. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  953. * @example
  954. *
  955. * _.isFunction(_);
  956. * // => true
  957. *
  958. * _.isFunction(/abc/);
  959. * // => false
  960. */
  961. function isFunction(value) {
  962. // The use of `Object#toString` avoids issues with the `typeof` operator
  963. // in older versions of Chrome and Safari which return 'function' for regexes
  964. // and Safari 8 which returns 'object' for typed array constructors.
  965. return isObject(value) && objToString.call(value) == funcTag
  966. }
  967. module.exports = isFunction
  968. }, { './isObject': 33 }], 32: [function(_dereq_, module, exports) {
  969. var isFunction = _dereq_('./isFunction')
  970. var isHostObject = _dereq_('../internal/isHostObject')
  971. var isObjectLike = _dereq_('../internal/isObjectLike')
  972. /** Used to detect host constructors (Safari > 5). */
  973. var reIsHostCtor = /^\[object .+?Constructor\]$/
  974. /** Used for native method references. */
  975. var objectProto = Object.prototype
  976. /** Used to resolve the decompiled source of functions. */
  977. var fnToString = Function.prototype.toString
  978. /** Used to check objects for own properties. */
  979. var hasOwnProperty = objectProto.hasOwnProperty
  980. /** Used to detect if a method is native. */
  981. var reIsNative = RegExp('^' +
  982. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  983. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  984. )
  985. /**
  986. * Checks if `value` is a native function.
  987. *
  988. * @static
  989. * @memberOf _
  990. * @category Lang
  991. * @param {*} value The value to check.
  992. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  993. * @example
  994. *
  995. * _.isNative(Array.prototype.push);
  996. * // => true
  997. *
  998. * _.isNative(_);
  999. * // => false
  1000. */
  1001. function isNative(value) {
  1002. if (value == null) {
  1003. return false
  1004. }
  1005. if (isFunction(value)) {
  1006. return reIsNative.test(fnToString.call(value))
  1007. }
  1008. return isObjectLike(value) && (isHostObject(value) ? reIsNative : reIsHostCtor).test(value)
  1009. }
  1010. module.exports = isNative
  1011. }, { '../internal/isHostObject': 22, '../internal/isObjectLike': 26, './isFunction': 31 }], 33: [function(_dereq_, module, exports) {
  1012. /**
  1013. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  1014. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1015. *
  1016. * @static
  1017. * @memberOf _
  1018. * @category Lang
  1019. * @param {*} value The value to check.
  1020. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1021. * @example
  1022. *
  1023. * _.isObject({});
  1024. * // => true
  1025. *
  1026. * _.isObject([1, 2, 3]);
  1027. * // => true
  1028. *
  1029. * _.isObject(1);
  1030. * // => false
  1031. */
  1032. function isObject(value) {
  1033. // Avoid a V8 JIT bug in Chrome 19-20.
  1034. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  1035. var type = typeof value
  1036. return !!value && (type == 'object' || type == 'function')
  1037. }
  1038. module.exports = isObject
  1039. }, {}], 34: [function(_dereq_, module, exports) {
  1040. var baseForIn = _dereq_('../internal/baseForIn')
  1041. var isArguments = _dereq_('./isArguments')
  1042. var isHostObject = _dereq_('../internal/isHostObject')
  1043. var isObjectLike = _dereq_('../internal/isObjectLike')
  1044. var support = _dereq_('../support')
  1045. /** `Object#toString` result references. */
  1046. var objectTag = '[object Object]'
  1047. /** Used for native method references. */
  1048. var objectProto = Object.prototype
  1049. /** Used to check objects for own properties. */
  1050. var hasOwnProperty = objectProto.hasOwnProperty
  1051. /**
  1052. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1053. * of values.
  1054. */
  1055. var objToString = objectProto.toString
  1056. /**
  1057. * Checks if `value` is a plain object, that is, an object created by the
  1058. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  1059. *
  1060. * **Note:** This method assumes objects created by the `Object` constructor
  1061. * have no inherited enumerable properties.
  1062. *
  1063. * @static
  1064. * @memberOf _
  1065. * @category Lang
  1066. * @param {*} value The value to check.
  1067. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  1068. * @example
  1069. *
  1070. * function Foo() {
  1071. * this.a = 1;
  1072. * }
  1073. *
  1074. * _.isPlainObject(new Foo);
  1075. * // => false
  1076. *
  1077. * _.isPlainObject([1, 2, 3]);
  1078. * // => false
  1079. *
  1080. * _.isPlainObject({ 'x': 0, 'y': 0 });
  1081. * // => true
  1082. *
  1083. * _.isPlainObject(Object.create(null));
  1084. * // => true
  1085. */
  1086. function isPlainObject(value) {
  1087. var Ctor
  1088. // Exit early for non `Object` objects.
  1089. if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isHostObject(value) && !isArguments(value)) ||
  1090. (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  1091. return false
  1092. }
  1093. // IE < 9 iterates inherited properties before own properties. If the first
  1094. // iterated property is an object's own property then there are no inherited
  1095. // enumerable properties.
  1096. var result
  1097. if (support.ownLast) {
  1098. baseForIn(value, function(subValue, key, object) {
  1099. result = hasOwnProperty.call(object, key)
  1100. return false
  1101. })
  1102. return result !== false
  1103. }
  1104. // In most environments an object's own properties are iterated before
  1105. // its inherited properties. If the last iterated property is an object's
  1106. // own property then there are no inherited enumerable properties.
  1107. baseForIn(value, function(subValue, key) {
  1108. result = key
  1109. })
  1110. return result === undefined || hasOwnProperty.call(value, result)
  1111. }
  1112. module.exports = isPlainObject
  1113. }, { '../internal/baseForIn': 12, '../internal/isHostObject': 22, '../internal/isObjectLike': 26, '../support': 41, './isArguments': 29 }], 35: [function(_dereq_, module, exports) {
  1114. var isObjectLike = _dereq_('../internal/isObjectLike')
  1115. /** `Object#toString` result references. */
  1116. var stringTag = '[object String]'
  1117. /** Used for native method references. */
  1118. var objectProto = Object.prototype
  1119. /**
  1120. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1121. * of values.
  1122. */
  1123. var objToString = objectProto.toString
  1124. /**
  1125. * Checks if `value` is classified as a `String` primitive or object.
  1126. *
  1127. * @static
  1128. * @memberOf _
  1129. * @category Lang
  1130. * @param {*} value The value to check.
  1131. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1132. * @example
  1133. *
  1134. * _.isString('abc');
  1135. * // => true
  1136. *
  1137. * _.isString(1);
  1138. * // => false
  1139. */
  1140. function isString(value) {
  1141. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag)
  1142. }
  1143. module.exports = isString
  1144. }, { '../internal/isObjectLike': 26 }], 36: [function(_dereq_, module, exports) {
  1145. var isLength = _dereq_('../internal/isLength')
  1146. var isObjectLike = _dereq_('../internal/isObjectLike')
  1147. /** `Object#toString` result references. */
  1148. var argsTag = '[object Arguments]'
  1149. var arrayTag = '[object Array]'
  1150. var boolTag = '[object Boolean]'
  1151. var dateTag = '[object Date]'
  1152. var errorTag = '[object Error]'
  1153. var funcTag = '[object Function]'
  1154. var mapTag = '[object Map]'
  1155. var numberTag = '[object Number]'
  1156. var objectTag = '[object Object]'
  1157. var regexpTag = '[object RegExp]'
  1158. var setTag = '[object Set]'
  1159. var stringTag = '[object String]'
  1160. var weakMapTag = '[object WeakMap]'
  1161. var arrayBufferTag = '[object ArrayBuffer]'
  1162. var float32Tag = '[object Float32Array]'
  1163. var float64Tag = '[object Float64Array]'
  1164. var int8Tag = '[object Int8Array]'
  1165. var int16Tag = '[object Int16Array]'
  1166. var int32Tag = '[object Int32Array]'
  1167. var uint8Tag = '[object Uint8Array]'
  1168. var uint8ClampedTag = '[object Uint8ClampedArray]'
  1169. var uint16Tag = '[object Uint16Array]'
  1170. var uint32Tag = '[object Uint32Array]'
  1171. /** Used to identify `toStringTag` values of typed arrays. */
  1172. var typedArrayTags = {}
  1173. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1174. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1175. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1176. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1177. typedArrayTags[uint32Tag] = true
  1178. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1179. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1180. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  1181. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  1182. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  1183. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  1184. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false
  1185. /** Used for native method references. */
  1186. var objectProto = Object.prototype
  1187. /**
  1188. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1189. * of values.
  1190. */
  1191. var objToString = objectProto.toString
  1192. /**
  1193. * Checks if `value` is classified as a typed array.
  1194. *
  1195. * @static
  1196. * @memberOf _
  1197. * @category Lang
  1198. * @param {*} value The value to check.
  1199. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1200. * @example
  1201. *
  1202. * _.isTypedArray(new Uint8Array);
  1203. * // => true
  1204. *
  1205. * _.isTypedArray([]);
  1206. * // => false
  1207. */
  1208. function isTypedArray(value) {
  1209. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]
  1210. }
  1211. module.exports = isTypedArray
  1212. }, { '../internal/isLength': 25, '../internal/isObjectLike': 26 }], 37: [function(_dereq_, module, exports) {
  1213. var baseCopy = _dereq_('../internal/baseCopy')
  1214. var keysIn = _dereq_('../object/keysIn')
  1215. /**
  1216. * Converts `value` to a plain object flattening inherited enumerable
  1217. * properties of `value` to own properties of the plain object.
  1218. *
  1219. * @static
  1220. * @memberOf _
  1221. * @category Lang
  1222. * @param {*} value The value to convert.
  1223. * @returns {Object} Returns the converted plain object.
  1224. * @example
  1225. *
  1226. * function Foo() {
  1227. * this.b = 2;
  1228. * }
  1229. *
  1230. * Foo.prototype.c = 3;
  1231. *
  1232. * _.assign({ 'a': 1 }, new Foo);
  1233. * // => { 'a': 1, 'b': 2 }
  1234. *
  1235. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  1236. * // => { 'a': 1, 'b': 2, 'c': 3 }
  1237. */
  1238. function toPlainObject(value) {
  1239. return baseCopy(value, keysIn(value))
  1240. }
  1241. module.exports = toPlainObject
  1242. }, { '../internal/baseCopy': 10, '../object/keysIn': 39 }], 38: [function(_dereq_, module, exports) {
  1243. var getNative = _dereq_('../internal/getNative')
  1244. var isArrayLike = _dereq_('../internal/isArrayLike')
  1245. var isObject = _dereq_('../lang/isObject')
  1246. var shimKeys = _dereq_('../internal/shimKeys')
  1247. var support = _dereq_('../support')
  1248. /* Native method references for those with the same name as other `lodash` methods. */
  1249. var nativeKeys = getNative(Object, 'keys')
  1250. /**
  1251. * Creates an array of the own enumerable property names of `object`.
  1252. *
  1253. * **Note:** Non-object values are coerced to objects. See the
  1254. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  1255. * for more details.
  1256. *
  1257. * @static
  1258. * @memberOf _
  1259. * @category Object
  1260. * @param {Object} object The object to query.
  1261. * @returns {Array} Returns the array of property names.
  1262. * @example
  1263. *
  1264. * function Foo() {
  1265. * this.a = 1;
  1266. * this.b = 2;
  1267. * }
  1268. *
  1269. * Foo.prototype.c = 3;
  1270. *
  1271. * _.keys(new Foo);
  1272. * // => ['a', 'b'] (iteration order is not guaranteed)
  1273. *
  1274. * _.keys('hi');
  1275. * // => ['0', '1']
  1276. */
  1277. var keys = !nativeKeys ? shimKeys : function(object) {
  1278. var Ctor = object == null ? undefined : object.constructor
  1279. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  1280. (typeof object == 'function' ? support.enumPrototypes : isArrayLike(object))) {
  1281. return shimKeys(object)
  1282. }
  1283. return isObject(object) ? nativeKeys(object) : []
  1284. }
  1285. module.exports = keys
  1286. }, { '../internal/getNative': 20, '../internal/isArrayLike': 21, '../internal/shimKeys': 27, '../lang/isObject': 33, '../support': 41 }], 39: [function(_dereq_, module, exports) {
  1287. var arrayEach = _dereq_('../internal/arrayEach')
  1288. var isArguments = _dereq_('../lang/isArguments')
  1289. var isArray = _dereq_('../lang/isArray')
  1290. var isFunction = _dereq_('../lang/isFunction')
  1291. var isIndex = _dereq_('../internal/isIndex')
  1292. var isLength = _dereq_('../internal/isLength')
  1293. var isObject = _dereq_('../lang/isObject')
  1294. var isString = _dereq_('../lang/isString')
  1295. var support = _dereq_('../support')
  1296. /** `Object#toString` result references. */
  1297. var arrayTag = '[object Array]'
  1298. var boolTag = '[object Boolean]'
  1299. var dateTag = '[object Date]'
  1300. var errorTag = '[object Error]'
  1301. var funcTag = '[object Function]'
  1302. var numberTag = '[object Number]'
  1303. var objectTag = '[object Object]'
  1304. var regexpTag = '[object RegExp]'
  1305. var stringTag = '[object String]'
  1306. /** Used to fix the JScript `[[DontEnum]]` bug. */
  1307. var shadowProps = [
  1308. 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',
  1309. 'toLocaleString', 'toString', 'valueOf'
  1310. ]
  1311. /** Used for native method references. */
  1312. var errorProto = Error.prototype
  1313. var objectProto = Object.prototype
  1314. var stringProto = String.prototype
  1315. /** Used to check objects for own properties. */
  1316. var hasOwnProperty = objectProto.hasOwnProperty
  1317. /**
  1318. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1319. * of values.
  1320. */
  1321. var objToString = objectProto.toString
  1322. /** Used to avoid iterating over non-enumerable properties in IE < 9. */
  1323. var nonEnumProps = {}
  1324. nonEnumProps[arrayTag] = nonEnumProps[dateTag] = nonEnumProps[numberTag] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true }
  1325. nonEnumProps[boolTag] = nonEnumProps[stringTag] = { 'constructor': true, 'toString': true, 'valueOf': true }
  1326. nonEnumProps[errorTag] = nonEnumProps[funcTag] = nonEnumProps[regexpTag] = { 'constructor': true, 'toString': true }
  1327. nonEnumProps[objectTag] = { 'constructor': true }
  1328. arrayEach(shadowProps, function(key) {
  1329. for (var tag in nonEnumProps) {
  1330. if (hasOwnProperty.call(nonEnumProps, tag)) {
  1331. var props = nonEnumProps[tag]
  1332. props[key] = hasOwnProperty.call(props, key)
  1333. }
  1334. }
  1335. })
  1336. /**
  1337. * Creates an array of the own and inherited enumerable property names of `object`.
  1338. *
  1339. * **Note:** Non-object values are coerced to objects.
  1340. *
  1341. * @static
  1342. * @memberOf _
  1343. * @category Object
  1344. * @param {Object} object The object to query.
  1345. * @returns {Array} Returns the array of property names.
  1346. * @example
  1347. *
  1348. * function Foo() {
  1349. * this.a = 1;
  1350. * this.b = 2;
  1351. * }
  1352. *
  1353. * Foo.prototype.c = 3;
  1354. *
  1355. * _.keysIn(new Foo);
  1356. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  1357. */
  1358. function keysIn(object) {
  1359. if (object == null) {
  1360. return []
  1361. }
  1362. if (!isObject(object)) {
  1363. object = Object(object)
  1364. }
  1365. var length = object.length
  1366. length = (length && isLength(length) &&
  1367. (isArray(object) || isArguments(object) || isString(object)) && length) || 0
  1368. var Ctor = object.constructor
  1369. var index = -1
  1370. var proto = (isFunction(Ctor) && Ctor.prototype) || objectProto
  1371. var isProto = proto === object
  1372. var result = Array(length)
  1373. var skipIndexes = length > 0
  1374. var skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error)
  1375. var skipProto = support.enumPrototypes && isFunction(object)
  1376. while (++index < length) {
  1377. result[index] = (index + '')
  1378. }
  1379. // lodash skips the `constructor` property when it infers it's iterating
  1380. // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]`
  1381. // attribute of an existing property and the `constructor` property of a
  1382. // prototype defaults to non-enumerable.
  1383. for (var key in object) {
  1384. if (!(skipProto && key == 'prototype') &&
  1385. !(skipErrorProps && (key == 'message' || key == 'name')) &&
  1386. !(skipIndexes && isIndex(key, length)) &&
  1387. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  1388. result.push(key)
  1389. }
  1390. }
  1391. if (support.nonEnumShadows && object !== objectProto) {
  1392. var tag = object === stringProto ? stringTag : (object === errorProto ? errorTag : objToString.call(object))
  1393. var nonEnums = nonEnumProps[tag] || nonEnumProps[objectTag]
  1394. if (tag == objectTag) {
  1395. proto = objectProto
  1396. }
  1397. length = shadowProps.length
  1398. while (length--) {
  1399. key = shadowProps[length]
  1400. var nonEnum = nonEnums[key]
  1401. if (!(isProto && nonEnum) &&
  1402. (nonEnum ? hasOwnProperty.call(object, key) : object[key] !== proto[key])) {
  1403. result.push(key)
  1404. }
  1405. }
  1406. }
  1407. return result
  1408. }
  1409. module.exports = keysIn
  1410. }, { '../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) {
  1411. var baseMerge = _dereq_('../internal/baseMerge')
  1412. var createAssigner = _dereq_('../internal/createAssigner')
  1413. /**
  1414. * Recursively merges own enumerable properties of the source object(s), that
  1415. * don't resolve to `undefined` into the destination object. Subsequent sources
  1416. * overwrite property assignments of previous sources. If `customizer` is
  1417. * provided it's invoked to produce the merged values of the destination and
  1418. * source properties. If `customizer` returns `undefined` merging is handled
  1419. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  1420. * with five arguments: (objectValue, sourceValue, key, object, source).
  1421. *
  1422. * @static
  1423. * @memberOf _
  1424. * @category Object
  1425. * @param {Object} object The destination object.
  1426. * @param {...Object} [sources] The source objects.
  1427. * @param {Function} [customizer] The function to customize assigned values.
  1428. * @param {*} [thisArg] The `this` binding of `customizer`.
  1429. * @returns {Object} Returns `object`.
  1430. * @example
  1431. *
  1432. * var users = {
  1433. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  1434. * };
  1435. *
  1436. * var ages = {
  1437. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  1438. * };
  1439. *
  1440. * _.merge(users, ages);
  1441. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  1442. *
  1443. * // using a customizer callback
  1444. * var object = {
  1445. * 'fruits': ['apple'],
  1446. * 'vegetables': ['beet']
  1447. * };
  1448. *
  1449. * var other = {
  1450. * 'fruits': ['banana'],
  1451. * 'vegetables': ['carrot']
  1452. * };
  1453. *
  1454. * _.merge(object, other, function(a, b) {
  1455. * if (_.isArray(a)) {
  1456. * return a.concat(b);
  1457. * }
  1458. * });
  1459. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  1460. */
  1461. var merge = createAssigner(baseMerge)
  1462. module.exports = merge
  1463. }, { '../internal/baseMerge': 13, '../internal/createAssigner': 17 }], 41: [function(_dereq_, module, exports) {
  1464. /** Used for native method references. */
  1465. var arrayProto = Array.prototype
  1466. var errorProto = Error.prototype
  1467. var objectProto = Object.prototype
  1468. /** Native method references. */
  1469. var propertyIsEnumerable = objectProto.propertyIsEnumerable
  1470. var splice = arrayProto.splice
  1471. /**
  1472. * An object environment feature flags.
  1473. *
  1474. * @static
  1475. * @memberOf _
  1476. * @type Object
  1477. */
  1478. var support = {};
  1479. (function(x) {
  1480. var Ctor = function() { this.x = x }
  1481. var object = { '0': x, 'length': x }
  1482. var props = []
  1483. Ctor.prototype = { 'valueOf': x, 'y': x }
  1484. for (var key in new Ctor()) { props.push(key) }
  1485. /**
  1486. * Detect if `name` or `message` properties of `Error.prototype` are
  1487. * enumerable by default (IE < 9, Safari < 5.1).
  1488. *
  1489. * @memberOf _.support
  1490. * @type boolean
  1491. */
  1492. support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') ||
  1493. propertyIsEnumerable.call(errorProto, 'name')
  1494. /**
  1495. * Detect if `prototype` properties are enumerable by default.
  1496. *
  1497. * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
  1498. * (if the prototype or a property on the prototype has been set)
  1499. * incorrectly set the `[[Enumerable]]` value of a function's `prototype`
  1500. * property to `true`.
  1501. *
  1502. * @memberOf _.support
  1503. * @type boolean
  1504. */
  1505. support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype')
  1506. /**
  1507. * Detect if properties shadowing those on `Object.prototype` are non-enumerable.
  1508. *
  1509. * In IE < 9 an object's own properties, shadowing non-enumerable ones,
  1510. * are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug).
  1511. *
  1512. * @memberOf _.support
  1513. * @type boolean
  1514. */
  1515. support.nonEnumShadows = !/valueOf/.test(props)
  1516. /**
  1517. * Detect if own properties are iterated after inherited properties (IE < 9).
  1518. *
  1519. * @memberOf _.support
  1520. * @type boolean
  1521. */
  1522. support.ownLast = props[0] != 'x'
  1523. /**
  1524. * Detect if `Array#shift` and `Array#splice` augment array-like objects
  1525. * correctly.
  1526. *
  1527. * Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array
  1528. * `shift()` and `splice()` functions that fail to remove the last element,
  1529. * `value[0]`, of array-like objects even though the "length" property is
  1530. * set to `0`. The `shift()` method is buggy in compatibility modes of IE 8,
  1531. * while `splice()` is buggy regardless of mode in IE < 9.
  1532. *
  1533. * @memberOf _.support
  1534. * @type boolean
  1535. */
  1536. support.spliceObjects = (splice.call(object, 0, 1), !object[0])
  1537. /**
  1538. * Detect lack of support for accessing string characters by index.
  1539. *
  1540. * IE < 8 can't access characters by index. IE 8 can only access characters
  1541. * by index on string literals, not string objects.
  1542. *
  1543. * @memberOf _.support
  1544. * @type boolean
  1545. */
  1546. support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx'
  1547. }(1, 0))
  1548. module.exports = support
  1549. }, {}], 42: [function(_dereq_, module, exports) {
  1550. /**
  1551. * This method returns the first argument provided to it.
  1552. *
  1553. * @static
  1554. * @memberOf _
  1555. * @category Utility
  1556. * @param {*} value Any value.
  1557. * @returns {*} Returns `value`.
  1558. * @example
  1559. *
  1560. * var object = { 'user': 'fred' };
  1561. *
  1562. * _.identity(object) === object;
  1563. * // => true
  1564. */
  1565. function identity(value) {
  1566. return value
  1567. }
  1568. module.exports = identity
  1569. }, {}], 43: [function(_dereq_, module, exports) {
  1570. 'use strict'
  1571. var keys = _dereq_('object-keys')
  1572. module.exports = function hasSymbols() {
  1573. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false }
  1574. if (typeof Symbol.iterator === 'symbol') { return true }
  1575. var obj = {}
  1576. var sym = Symbol('test')
  1577. if (typeof sym === 'string') { return false }
  1578. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  1579. // if (sym instanceof Symbol) { return false; }
  1580. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  1581. // if (!(Object(sym) instanceof Symbol)) { return false; }
  1582. var symVal = 42
  1583. obj[sym] = symVal
  1584. for (sym in obj) { return false }
  1585. if (keys(obj).length !== 0) { return false }
  1586. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false }
  1587. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false }
  1588. var syms = Object.getOwnPropertySymbols(obj)
  1589. if (syms.length !== 1 || syms[0] !== sym) { return false }
  1590. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false }
  1591. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  1592. var descriptor = Object.getOwnPropertyDescriptor(obj, sym)
  1593. if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false }
  1594. }
  1595. return true
  1596. }
  1597. }, { 'object-keys': 50 }], 44: [function(_dereq_, module, exports) {
  1598. 'use strict'
  1599. // modified from https://github.com/es-shims/es6-shim
  1600. var keys = _dereq_('object-keys')
  1601. var bind = _dereq_('function-bind')
  1602. var canBeObject = function(obj) {
  1603. return typeof obj !== 'undefined' && obj !== null
  1604. }
  1605. var hasSymbols = _dereq_('./hasSymbols')()
  1606. var toObject = Object
  1607. var push = bind.call(Function.call, Array.prototype.push)
  1608. var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable)
  1609. module.exports = function assign(target, source1) {
  1610. if (!canBeObject(target)) { throw new TypeError('target must be an object') }
  1611. var objTarget = toObject(target)
  1612. var s, source, i, props, syms, value, key
  1613. for (s = 1; s < arguments.length; ++s) {
  1614. source = toObject(arguments[s])
  1615. props = keys(source)
  1616. if (hasSymbols && Object.getOwnPropertySymbols) {
  1617. syms = Object.getOwnPropertySymbols(source)
  1618. for (i = 0; i < syms.length; ++i) {
  1619. key = syms[i]
  1620. if (propIsEnumerable(source, key)) {
  1621. push(props, key)
  1622. }
  1623. }
  1624. }
  1625. for (i = 0; i < props.length; ++i) {
  1626. key = props[i]
  1627. value = source[key]
  1628. if (propIsEnumerable(source, key)) {
  1629. objTarget[key] = value
  1630. }
  1631. }
  1632. }
  1633. return objTarget
  1634. }
  1635. }, { './hasSymbols': 43, 'function-bind': 49, 'object-keys': 50 }], 45: [function(_dereq_, module, exports) {
  1636. 'use strict'
  1637. var defineProperties = _dereq_('define-properties')
  1638. var implementation = _dereq_('./implementation')
  1639. var getPolyfill = _dereq_('./polyfill')
  1640. var shim = _dereq_('./shim')
  1641. defineProperties(implementation, {
  1642. implementation: implementation,
  1643. getPolyfill: getPolyfill,
  1644. shim: shim
  1645. })
  1646. module.exports = implementation
  1647. }, { './implementation': 44, './polyfill': 52, './shim': 53, 'define-properties': 46 }], 46: [function(_dereq_, module, exports) {
  1648. 'use strict'
  1649. var keys = _dereq_('object-keys')
  1650. var foreach = _dereq_('foreach')
  1651. var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'
  1652. var toStr = Object.prototype.toString
  1653. var isFunction = function(fn) {
  1654. return typeof fn === 'function' && toStr.call(fn) === '[object Function]'
  1655. }
  1656. var arePropertyDescriptorsSupported = function() {
  1657. var obj = {}
  1658. try {
  1659. Object.defineProperty(obj, 'x', { enumerable: false, value: obj })
  1660. /* eslint-disable no-unused-vars, no-restricted-syntax */
  1661. for (var _ in obj) { return false }
  1662. /* eslint-enable no-unused-vars, no-restricted-syntax */
  1663. return obj.x === obj
  1664. } catch (e) { /* this is IE 8. */
  1665. return false
  1666. }
  1667. }
  1668. var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported()
  1669. var defineProperty = function(object, name, value, predicate) {
  1670. if (name in object && (!isFunction(predicate) || !predicate())) {
  1671. return
  1672. }
  1673. if (supportsDescriptors) {
  1674. Object.defineProperty(object, name, {
  1675. configurable: true,
  1676. enumerable: false,
  1677. value: value,
  1678. writable: true
  1679. })
  1680. } else {
  1681. object[name] = value
  1682. }
  1683. }
  1684. var defineProperties = function(object, map) {
  1685. var predicates = arguments.length > 2 ? arguments[2] : {}
  1686. var props = keys(map)
  1687. if (hasSymbols) {
  1688. props = props.concat(Object.getOwnPropertySymbols(map))
  1689. }
  1690. foreach(props, function(name) {
  1691. defineProperty(object, name, map[name], predicates[name])
  1692. })
  1693. }
  1694. defineProperties.supportsDescriptors = !!supportsDescriptors
  1695. module.exports = defineProperties
  1696. }, { 'foreach': 47, 'object-keys': 50 }], 47: [function(_dereq_, module, exports) {
  1697. var hasOwn = Object.prototype.hasOwnProperty
  1698. var toString = Object.prototype.toString
  1699. module.exports = function forEach(obj, fn, ctx) {
  1700. if (toString.call(fn) !== '[object Function]') {
  1701. throw new TypeError('iterator must be a function')
  1702. }
  1703. var l = obj.length
  1704. if (l === +l) {
  1705. for (var i = 0; i < l; i++) {
  1706. fn.call(ctx, obj[i], i, obj)
  1707. }
  1708. } else {
  1709. for (var k in obj) {
  1710. if (hasOwn.call(obj, k)) {
  1711. fn.call(ctx, obj[k], k, obj)
  1712. }
  1713. }
  1714. }
  1715. }
  1716. }, {}], 48: [function(_dereq_, module, exports) {
  1717. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '
  1718. var slice = Array.prototype.slice
  1719. var toStr = Object.prototype.toString
  1720. var funcType = '[object Function]'
  1721. module.exports = function bind(that) {
  1722. var target = this
  1723. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  1724. throw new TypeError(ERROR_MESSAGE + target)
  1725. }
  1726. var args = slice.call(arguments, 1)
  1727. var bound
  1728. var binder = function() {
  1729. if (this instanceof bound) {
  1730. var result = target.apply(
  1731. this,
  1732. args.concat(slice.call(arguments))
  1733. )
  1734. if (Object(result) === result) {
  1735. return result
  1736. }
  1737. return this
  1738. } else {
  1739. return target.apply(
  1740. that,
  1741. args.concat(slice.call(arguments))
  1742. )
  1743. }
  1744. }
  1745. var boundLength = Math.max(0, target.length - args.length)
  1746. var boundArgs = []
  1747. for (var i = 0; i < boundLength; i++) {
  1748. boundArgs.push('$' + i)
  1749. }
  1750. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder)
  1751. if (target.prototype) {
  1752. var Empty = function Empty() { }
  1753. Empty.prototype = target.prototype
  1754. bound.prototype = new Empty()
  1755. Empty.prototype = null
  1756. }
  1757. return bound
  1758. }
  1759. }, {}], 49: [function(_dereq_, module, exports) {
  1760. var implementation = _dereq_('./implementation')
  1761. module.exports = Function.prototype.bind || implementation
  1762. }, { './implementation': 48 }], 50: [function(_dereq_, module, exports) {
  1763. 'use strict'
  1764. // modified from https://github.com/es-shims/es5-shim
  1765. var has = Object.prototype.hasOwnProperty
  1766. var toStr = Object.prototype.toString
  1767. var slice = Array.prototype.slice
  1768. var isArgs = _dereq_('./isArguments')
  1769. var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString')
  1770. var hasProtoEnumBug = function() { }.propertyIsEnumerable('prototype')
  1771. var dontEnums = [
  1772. 'toString',
  1773. 'toLocaleString',
  1774. 'valueOf',
  1775. 'hasOwnProperty',
  1776. 'isPrototypeOf',
  1777. 'propertyIsEnumerable',
  1778. 'constructor'
  1779. ]
  1780. var equalsConstructorPrototype = function(o) {
  1781. var ctor = o.constructor
  1782. return ctor && ctor.prototype === o
  1783. }
  1784. var blacklistedKeys = {
  1785. $console: true,
  1786. $frame: true,
  1787. $frameElement: true,
  1788. $frames: true,
  1789. $parent: true,
  1790. $self: true,
  1791. $webkitIndexedDB: true,
  1792. $webkitStorageInfo: true,
  1793. $window: true
  1794. }
  1795. var hasAutomationEqualityBug = (function() {
  1796. /* global window */
  1797. if (typeof window === 'undefined') { return false }
  1798. for (var k in window) {
  1799. try {
  1800. if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  1801. try {
  1802. equalsConstructorPrototype(window[k])
  1803. } catch (e) {
  1804. return true
  1805. }
  1806. }
  1807. } catch (e) {
  1808. return true
  1809. }
  1810. }
  1811. return false
  1812. }())
  1813. var equalsConstructorPrototypeIfNotBuggy = function(o) {
  1814. /* global window */
  1815. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  1816. return equalsConstructorPrototype(o)
  1817. }
  1818. try {
  1819. return equalsConstructorPrototype(o)
  1820. } catch (e) {
  1821. return false
  1822. }
  1823. }
  1824. var keysShim = function keys(object) {
  1825. var isObject = object !== null && typeof object === 'object'
  1826. var isFunction = toStr.call(object) === '[object Function]'
  1827. var isArguments = isArgs(object)
  1828. var isString = isObject && toStr.call(object) === '[object String]'
  1829. var theKeys = []
  1830. if (!isObject && !isFunction && !isArguments) {
  1831. throw new TypeError('Object.keys called on a non-object')
  1832. }
  1833. var skipProto = hasProtoEnumBug && isFunction
  1834. if (isString && object.length > 0 && !has.call(object, 0)) {
  1835. for (var i = 0; i < object.length; ++i) {
  1836. theKeys.push(String(i))
  1837. }
  1838. }
  1839. if (isArguments && object.length > 0) {
  1840. for (var j = 0; j < object.length; ++j) {
  1841. theKeys.push(String(j))
  1842. }
  1843. } else {
  1844. for (var name in object) {
  1845. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  1846. theKeys.push(String(name))
  1847. }
  1848. }
  1849. }
  1850. if (hasDontEnumBug) {
  1851. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object)
  1852. for (var k = 0; k < dontEnums.length; ++k) {
  1853. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  1854. theKeys.push(dontEnums[k])
  1855. }
  1856. }
  1857. }
  1858. return theKeys
  1859. }
  1860. keysShim.shim = function shimObjectKeys() {
  1861. if (Object.keys) {
  1862. var keysWorksWithArguments = (function() {
  1863. // Safari 5.0 bug
  1864. return (Object.keys(arguments) || '').length === 2
  1865. }(1, 2))
  1866. if (!keysWorksWithArguments) {
  1867. var originalKeys = Object.keys
  1868. Object.keys = function keys(object) {
  1869. if (isArgs(object)) {
  1870. return originalKeys(slice.call(object))
  1871. } else {
  1872. return originalKeys(object)
  1873. }
  1874. }
  1875. }
  1876. } else {
  1877. Object.keys = keysShim
  1878. }
  1879. return Object.keys || keysShim
  1880. }
  1881. module.exports = keysShim
  1882. }, { './isArguments': 51 }], 51: [function(_dereq_, module, exports) {
  1883. 'use strict'
  1884. var toStr = Object.prototype.toString
  1885. module.exports = function isArguments(value) {
  1886. var str = toStr.call(value)
  1887. var isArgs = str === '[object Arguments]'
  1888. if (!isArgs) {
  1889. isArgs = str !== '[object Array]' &&
  1890. value !== null &&
  1891. typeof value === 'object' &&
  1892. typeof value.length === 'number' &&
  1893. value.length >= 0 &&
  1894. toStr.call(value.callee) === '[object Function]'
  1895. }
  1896. return isArgs
  1897. }
  1898. }, {}], 52: [function(_dereq_, module, exports) {
  1899. 'use strict'
  1900. var implementation = _dereq_('./implementation')
  1901. var lacksProperEnumerationOrder = function() {
  1902. if (!Object.assign) {
  1903. return false
  1904. }
  1905. // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
  1906. // note: this does not detect the bug unless there's 20 characters
  1907. var str = 'abcdefghijklmnopqrst'
  1908. var letters = str.split('')
  1909. var map = {}
  1910. for (var i = 0; i < letters.length; ++i) {
  1911. map[letters[i]] = letters[i]
  1912. }
  1913. var obj = Object.assign({}, map)
  1914. var actual = ''
  1915. for (var k in obj) {
  1916. actual += k
  1917. }
  1918. return str !== actual
  1919. }
  1920. var assignHasPendingExceptions = function() {
  1921. if (!Object.assign || !Object.preventExtensions) {
  1922. return false
  1923. }
  1924. // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
  1925. // which is 72% slower than our shim, and Firefox 40's native implementation.
  1926. var thrower = Object.preventExtensions({ 1: 2 })
  1927. try {
  1928. Object.assign(thrower, 'xy')
  1929. } catch (e) {
  1930. return thrower[1] === 'y'
  1931. }
  1932. }
  1933. module.exports = function getPolyfill() {
  1934. if (!Object.assign) {
  1935. return implementation
  1936. }
  1937. if (lacksProperEnumerationOrder()) {
  1938. return implementation
  1939. }
  1940. if (assignHasPendingExceptions()) {
  1941. return implementation
  1942. }
  1943. return Object.assign
  1944. }
  1945. }, { './implementation': 44 }], 53: [function(_dereq_, module, exports) {
  1946. 'use strict'
  1947. var define = _dereq_('define-properties')
  1948. var getPolyfill = _dereq_('./polyfill')
  1949. module.exports = function shimAssign() {
  1950. var polyfill = getPolyfill()
  1951. define(
  1952. Object,
  1953. { assign: polyfill },
  1954. { assign: function() { return Object.assign !== polyfill } }
  1955. )
  1956. return polyfill
  1957. }
  1958. }, { './polyfill': 52, 'define-properties': 46 }], 54: [function(_dereq_, module, exports) {
  1959. module.exports = SafeParseTuple
  1960. function SafeParseTuple(obj, reviver) {
  1961. var json
  1962. var error = null
  1963. try {
  1964. json = JSON.parse(obj, reviver)
  1965. } catch (err) {
  1966. error = err
  1967. }
  1968. return [error, json]
  1969. }
  1970. }, {}], 55: [function(_dereq_, module, exports) {
  1971. function clean(s) {
  1972. return s.replace(/\n\r?\s*/g, '')
  1973. }
  1974. module.exports = function tsml(sa) {
  1975. var s = ''
  1976. var i = 0
  1977. for (; i < arguments.length; i++) { s += clean(sa[i]) + (arguments[i + 1] || '') }
  1978. return s
  1979. }
  1980. }, {}], 56: [function(_dereq_, module, exports) {
  1981. 'use strict'
  1982. var window = _dereq_('global/window')
  1983. var once = _dereq_('once')
  1984. var isFunction = _dereq_('is-function')
  1985. var parseHeaders = _dereq_('parse-headers')
  1986. var xtend = _dereq_('xtend')
  1987. module.exports = createXHR
  1988. createXHR.XMLHttpRequest = window.XMLHttpRequest || noop
  1989. createXHR.XDomainRequest = 'withCredentials' in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest
  1990. forEachArray(['get', 'put', 'post', 'patch', 'head', 'delete'], function(method) {
  1991. createXHR[method === 'delete' ? 'del' : method] = function(uri, options, callback) {
  1992. options = initParams(uri, options, callback)
  1993. options.method = method.toUpperCase()
  1994. return _createXHR(options)
  1995. }
  1996. })
  1997. function forEachArray(array, iterator) {
  1998. for (var i = 0; i < array.length; i++) {
  1999. iterator(array[i])
  2000. }
  2001. }
  2002. function isEmpty(obj) {
  2003. for (var i in obj) {
  2004. if (obj.hasOwnProperty(i)) return false
  2005. }
  2006. return true
  2007. }
  2008. function initParams(uri, options, callback) {
  2009. var params = uri
  2010. if (isFunction(options)) {
  2011. callback = options
  2012. if (typeof uri === 'string') {
  2013. params = { uri: uri }
  2014. }
  2015. } else {
  2016. params = xtend(options, { uri: uri })
  2017. }
  2018. params.callback = callback
  2019. return params
  2020. }
  2021. function createXHR(uri, options, callback) {
  2022. options = initParams(uri, options, callback)
  2023. return _createXHR(options)
  2024. }
  2025. function _createXHR(options) {
  2026. var callback = options.callback
  2027. if (typeof callback === 'undefined') {
  2028. throw new Error('callback argument missing')
  2029. }
  2030. callback = once(callback)
  2031. function readystatechange() {
  2032. if (xhr.readyState === 4) {
  2033. loadFunc()
  2034. }
  2035. }
  2036. function getBody() {
  2037. // Chrome with requestType=blob throws errors arround when even testing access to responseText
  2038. var body = undefined
  2039. if (xhr.response) {
  2040. body = xhr.response
  2041. } else if (xhr.responseType === 'text' || !xhr.responseType) {
  2042. body = xhr.responseText || xhr.responseXML
  2043. }
  2044. if (isJson) {
  2045. try {
  2046. body = JSON.parse(body)
  2047. } catch (e) { }
  2048. }
  2049. return body
  2050. }
  2051. var failureResponse = {
  2052. body: undefined,
  2053. headers: {},
  2054. statusCode: 0,
  2055. method: method,
  2056. url: uri,
  2057. rawRequest: xhr
  2058. }
  2059. function errorFunc(evt) {
  2060. clearTimeout(timeoutTimer)
  2061. if (!(evt instanceof Error)) {
  2062. evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'))
  2063. }
  2064. evt.statusCode = 0
  2065. callback(evt, failureResponse)
  2066. }
  2067. // will load the data & process the response in a special response object
  2068. function loadFunc() {
  2069. if (aborted) return
  2070. var status
  2071. clearTimeout(timeoutTimer)
  2072. if (options.useXDR && xhr.status === undefined) {
  2073. // IE8 CORS GET successful response doesn't have a status field, but body is fine
  2074. status = 200
  2075. } else {
  2076. status = (xhr.status === 1223 ? 204 : xhr.status)
  2077. }
  2078. var response = failureResponse
  2079. var err = null
  2080. if (status !== 0) {
  2081. response = {
  2082. body: getBody(),
  2083. statusCode: status,
  2084. method: method,
  2085. headers: {},
  2086. url: uri,
  2087. rawRequest: xhr
  2088. }
  2089. if (xhr.getAllResponseHeaders) { // remember xhr can in fact be XDR for CORS in IE
  2090. response.headers = parseHeaders(xhr.getAllResponseHeaders())
  2091. }
  2092. } else {
  2093. err = new Error('Internal XMLHttpRequest Error')
  2094. }
  2095. callback(err, response, response.body)
  2096. }
  2097. var xhr = options.xhr || null
  2098. if (!xhr) {
  2099. if (options.cors || options.useXDR) {
  2100. xhr = new createXHR.XDomainRequest()
  2101. } else {
  2102. xhr = new createXHR.XMLHttpRequest()
  2103. }
  2104. }
  2105. var key
  2106. var aborted
  2107. var uri = xhr.url = options.uri || options.url
  2108. var method = xhr.method = options.method || 'GET'
  2109. var body = options.body || options.data || null
  2110. var headers = xhr.headers = options.headers || {}
  2111. var sync = !!options.sync
  2112. var isJson = false
  2113. var timeoutTimer
  2114. if ('json' in options) {
  2115. isJson = true
  2116. headers['accept'] || headers['Accept'] || (headers['Accept'] = 'application/json') // Don't override existing accept header declared by user
  2117. if (method !== 'GET' && method !== 'HEAD') {
  2118. headers['content-type'] || headers['Content-Type'] || (headers['Content-Type'] = 'application/json') // Don't override existing accept header declared by user
  2119. body = JSON.stringify(options.json)
  2120. }
  2121. }
  2122. xhr.onreadystatechange = readystatechange
  2123. xhr.onload = loadFunc
  2124. xhr.onerror = errorFunc
  2125. // IE9 must have onprogress be set to a unique function.
  2126. xhr.onprogress = function() {
  2127. // IE must die
  2128. }
  2129. xhr.ontimeout = errorFunc
  2130. xhr.open(method, uri, !sync, options.username, options.password)
  2131. // has to be after open
  2132. if (!sync) {
  2133. xhr.withCredentials = !!options.withCredentials
  2134. }
  2135. // Cannot set timeout with sync request
  2136. // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
  2137. // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
  2138. if (!sync && options.timeout > 0) {
  2139. timeoutTimer = setTimeout(function() {
  2140. aborted = true// IE9 may still call readystatechange
  2141. xhr.abort('timeout')
  2142. var e = new Error('XMLHttpRequest timeout')
  2143. e.code = 'ETIMEDOUT'
  2144. errorFunc(e)
  2145. }, options.timeout)
  2146. }
  2147. if (xhr.setRequestHeader) {
  2148. for (key in headers) {
  2149. if (headers.hasOwnProperty(key)) {
  2150. xhr.setRequestHeader(key, headers[key])
  2151. }
  2152. }
  2153. } else if (options.headers && !isEmpty(options.headers)) {
  2154. throw new Error('Headers cannot be set on an XDomainRequest object')
  2155. }
  2156. if ('responseType' in options) {
  2157. xhr.responseType = options.responseType
  2158. }
  2159. if ('beforeSend' in options &&
  2160. typeof options.beforeSend === 'function'
  2161. ) {
  2162. options.beforeSend(xhr)
  2163. }
  2164. xhr.send(body)
  2165. return xhr
  2166. }
  2167. function noop() { }
  2168. }, { 'global/window': 2, 'is-function': 57, 'once': 58, 'parse-headers': 61, 'xtend': 62 }], 57: [function(_dereq_, module, exports) {
  2169. module.exports = isFunction
  2170. var toString = Object.prototype.toString
  2171. function isFunction(fn) {
  2172. var string = toString.call(fn)
  2173. return string === '[object Function]' ||
  2174. (typeof fn === 'function' && string !== '[object RegExp]') ||
  2175. (typeof window !== 'undefined' &&
  2176. // IE8 and below
  2177. (fn === window.setTimeout ||
  2178. fn === window.alert ||
  2179. fn === window.confirm ||
  2180. fn === window.prompt))
  2181. }
  2182. }, {}], 58: [function(_dereq_, module, exports) {
  2183. module.exports = once
  2184. once.proto = once(function() {
  2185. Object.defineProperty(Function.prototype, 'once', {
  2186. value: function() {
  2187. return once(this)
  2188. },
  2189. configurable: true
  2190. })
  2191. })
  2192. function once(fn) {
  2193. var called = false
  2194. return function() {
  2195. if (called) return
  2196. called = true
  2197. return fn.apply(this, arguments)
  2198. }
  2199. }
  2200. }, {}], 59: [function(_dereq_, module, exports) {
  2201. var isFunction = _dereq_('is-function')
  2202. module.exports = forEach
  2203. var toString = Object.prototype.toString
  2204. var hasOwnProperty = Object.prototype.hasOwnProperty
  2205. function forEach(list, iterator, context) {
  2206. if (!isFunction(iterator)) {
  2207. throw new TypeError('iterator must be a function')
  2208. }
  2209. if (arguments.length < 3) {
  2210. context = this
  2211. }
  2212. if (toString.call(list) === '[object Array]') { forEachArray(list, iterator, context) } else if (typeof list === 'string') { forEachString(list, iterator, context) } else { forEachObject(list, iterator, context) }
  2213. }
  2214. function forEachArray(array, iterator, context) {
  2215. for (var i = 0, len = array.length; i < len; i++) {
  2216. if (hasOwnProperty.call(array, i)) {
  2217. iterator.call(context, array[i], i, array)
  2218. }
  2219. }
  2220. }
  2221. function forEachString(string, iterator, context) {
  2222. for (var i = 0, len = string.length; i < len; i++) {
  2223. // no such thing as a sparse string.
  2224. iterator.call(context, string.charAt(i), i, string)
  2225. }
  2226. }
  2227. function forEachObject(object, iterator, context) {
  2228. for (var k in object) {
  2229. if (hasOwnProperty.call(object, k)) {
  2230. iterator.call(context, object[k], k, object)
  2231. }
  2232. }
  2233. }
  2234. }, { 'is-function': 57 }], 60: [function(_dereq_, module, exports) {
  2235. exports = module.exports = trim
  2236. function trim(str) {
  2237. return str.replace(/^\s*|\s*$/g, '')
  2238. }
  2239. exports.left = function(str) {
  2240. return str.replace(/^\s*/, '')
  2241. }
  2242. exports.right = function(str) {
  2243. return str.replace(/\s*$/, '')
  2244. }
  2245. }, {}], 61: [function(_dereq_, module, exports) {
  2246. var trim = _dereq_('trim')
  2247. var forEach = _dereq_('for-each')
  2248. var isArray = function(arg) {
  2249. return Object.prototype.toString.call(arg) === '[object Array]'
  2250. }
  2251. module.exports = function(headers) {
  2252. if (!headers) { return {} }
  2253. var result = {}
  2254. forEach(
  2255. trim(headers).split('\n')
  2256. , function(row) {
  2257. var index = row.indexOf(':')
  2258. var key = trim(row.slice(0, index)).toLowerCase()
  2259. var value = trim(row.slice(index + 1))
  2260. if (typeof (result[key]) === 'undefined') {
  2261. result[key] = value
  2262. } else if (isArray(result[key])) {
  2263. result[key].push(value)
  2264. } else {
  2265. result[key] = [result[key], value]
  2266. }
  2267. }
  2268. )
  2269. return result
  2270. }
  2271. }, { 'for-each': 59, 'trim': 60 }], 62: [function(_dereq_, module, exports) {
  2272. module.exports = extend
  2273. var hasOwnProperty = Object.prototype.hasOwnProperty
  2274. function extend() {
  2275. var target = {}
  2276. for (var i = 0; i < arguments.length; i++) {
  2277. var source = arguments[i]
  2278. for (var key in source) {
  2279. if (hasOwnProperty.call(source, key)) {
  2280. target[key] = source[key]
  2281. }
  2282. }
  2283. }
  2284. return target
  2285. }
  2286. }, {}], 63: [function(_dereq_, module, exports) {
  2287. /**
  2288. * @file big-play-button.js
  2289. */
  2290. 'use strict'
  2291. exports.__esModule = true
  2292. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  2293. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  2294. 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 }
  2295. var _buttonJs = _dereq_('./button.js')
  2296. var _buttonJs2 = _interopRequireDefault(_buttonJs)
  2297. var _componentJs = _dereq_('./component.js')
  2298. var _componentJs2 = _interopRequireDefault(_componentJs)
  2299. /**
  2300. * Initial play button. Shows before the video has played. The hiding of the
  2301. * big play button is done via CSS and player states.
  2302. *
  2303. * @param {Object} player Main Player
  2304. * @param {Object=} options Object of option names and values
  2305. * @extends Button
  2306. * @class BigPlayButton
  2307. */
  2308. var BigPlayButton = (function(_Button) {
  2309. _inherits(BigPlayButton, _Button)
  2310. function BigPlayButton(player, options) {
  2311. _classCallCheck(this, BigPlayButton)
  2312. _Button.call(this, player, options)
  2313. }
  2314. /**
  2315. * Allow sub components to stack CSS class names
  2316. *
  2317. * @return {String} The constructed class name
  2318. * @method buildCSSClass
  2319. */
  2320. BigPlayButton.prototype.buildCSSClass = function buildCSSClass() {
  2321. return 'vjs-big-play-button'
  2322. }
  2323. /**
  2324. * Handles click for play
  2325. *
  2326. * @method handleClick
  2327. */
  2328. BigPlayButton.prototype.handleClick = function handleClick() {
  2329. this.player_.play()
  2330. }
  2331. return BigPlayButton
  2332. })(_buttonJs2['default'])
  2333. BigPlayButton.prototype.controlText_ = 'Play Video'
  2334. _componentJs2['default'].registerComponent('BigPlayButton', BigPlayButton)
  2335. exports['default'] = BigPlayButton
  2336. module.exports = exports['default']
  2337. }, { './button.js': 64, './component.js': 67 }], 64: [function(_dereq_, module, exports) {
  2338. /**
  2339. * @file button.js
  2340. */
  2341. 'use strict'
  2342. exports.__esModule = true
  2343. 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 } }
  2344. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  2345. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  2346. 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 }
  2347. var _clickableComponentJs = _dereq_('./clickable-component.js')
  2348. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs)
  2349. var _component = _dereq_('./component')
  2350. var _component2 = _interopRequireDefault(_component)
  2351. var _utilsEventsJs = _dereq_('./utils/events.js')
  2352. var Events = _interopRequireWildcard(_utilsEventsJs)
  2353. var _utilsFnJs = _dereq_('./utils/fn.js')
  2354. var Fn = _interopRequireWildcard(_utilsFnJs)
  2355. var _utilsLogJs = _dereq_('./utils/log.js')
  2356. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  2357. var _globalDocument = _dereq_('global/document')
  2358. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  2359. var _objectAssign = _dereq_('object.assign')
  2360. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  2361. /**
  2362. * Base class for all buttons
  2363. *
  2364. * @param {Object} player Main Player
  2365. * @param {Object=} options Object of option names and values
  2366. * @extends ClickableComponent
  2367. * @class Button
  2368. */
  2369. var Button = (function(_ClickableComponent) {
  2370. _inherits(Button, _ClickableComponent)
  2371. function Button(player, options) {
  2372. _classCallCheck(this, Button)
  2373. _ClickableComponent.call(this, player, options)
  2374. }
  2375. /**
  2376. * Create the component's DOM element
  2377. *
  2378. * @param {String=} type Element's node type. e.g. 'div'
  2379. * @param {Object=} props An object of properties that should be set on the element
  2380. * @param {Object=} attributes An object of attributes that should be set on the element
  2381. * @return {Element}
  2382. * @method createEl
  2383. */
  2384. Button.prototype.createEl = function createEl() {
  2385. var tag = arguments.length <= 0 || arguments[0] === undefined ? 'button' : arguments[0]
  2386. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  2387. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]
  2388. props = _objectAssign2['default']({
  2389. className: this.buildCSSClass()
  2390. }, props)
  2391. if (tag !== 'button') {
  2392. _utilsLogJs2['default'].warn('Creating a Button with an HTML element of ' + tag + ' is deprecated; use ClickableComponent instead.')
  2393. // Add properties for clickable element which is not a native HTML button
  2394. props = _objectAssign2['default']({
  2395. tabIndex: 0
  2396. }, props)
  2397. // Add ARIA attributes for clickable element which is not a native HTML button
  2398. attributes = _objectAssign2['default']({
  2399. role: 'button'
  2400. }, attributes)
  2401. }
  2402. // Add attributes for button element
  2403. attributes = _objectAssign2['default']({
  2404. type: 'button', // Necessary since the default button type is "submit"
  2405. 'aria-live': 'polite' // let the screen reader user know that the text of the button may change
  2406. }, attributes)
  2407. var el = _component2['default'].prototype.createEl.call(this, tag, props, attributes)
  2408. this.createControlTextEl(el)
  2409. return el
  2410. }
  2411. /**
  2412. * Adds a child component inside this button
  2413. *
  2414. * @param {String|Component} child The class name or instance of a child to add
  2415. * @param {Object=} options Options, including options to be passed to children of the child.
  2416. * @return {Component} The child component (created by this process if a string was used)
  2417. * @deprecated
  2418. * @method addChild
  2419. */
  2420. Button.prototype.addChild = function addChild(child) {
  2421. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  2422. var className = this.constructor.name
  2423. _utilsLogJs2['default'].warn('Adding an actionable (user controllable) child to a Button (' + className + ') is not supported; use a ClickableComponent instead.')
  2424. // Avoid the error message generated by ClickableComponent's addChild method
  2425. return _component2['default'].prototype.addChild.call(this, child, options)
  2426. }
  2427. /**
  2428. * Handle KeyPress (document level) - Extend with specific functionality for button
  2429. *
  2430. * @method handleKeyPress
  2431. */
  2432. Button.prototype.handleKeyPress = function handleKeyPress(event) {
  2433. // Ignore Space (32) or Enter (13) key operation, which is handled by the browser for a button.
  2434. if (event.which === 32 || event.which === 13) { } else {
  2435. _ClickableComponent.prototype.handleKeyPress.call(this, event) // Pass keypress handling up for unsupported keys
  2436. }
  2437. }
  2438. return Button
  2439. })(_clickableComponentJs2['default'])
  2440. _component2['default'].registerComponent('Button', Button)
  2441. exports['default'] = Button
  2442. module.exports = exports['default']
  2443. }, { './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) {
  2444. /**
  2445. * @file button.js
  2446. */
  2447. 'use strict'
  2448. exports.__esModule = true
  2449. 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 } }
  2450. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  2451. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  2452. 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 }
  2453. var _component = _dereq_('./component')
  2454. var _component2 = _interopRequireDefault(_component)
  2455. var _utilsDomJs = _dereq_('./utils/dom.js')
  2456. var Dom = _interopRequireWildcard(_utilsDomJs)
  2457. var _utilsEventsJs = _dereq_('./utils/events.js')
  2458. var Events = _interopRequireWildcard(_utilsEventsJs)
  2459. var _utilsFnJs = _dereq_('./utils/fn.js')
  2460. var Fn = _interopRequireWildcard(_utilsFnJs)
  2461. var _utilsLogJs = _dereq_('./utils/log.js')
  2462. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  2463. var _globalDocument = _dereq_('global/document')
  2464. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  2465. var _objectAssign = _dereq_('object.assign')
  2466. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  2467. /**
  2468. * Clickable Component which is clickable or keyboard actionable, but is not a native HTML button
  2469. *
  2470. * @param {Object} player Main Player
  2471. * @param {Object=} options Object of option names and values
  2472. * @extends Component
  2473. * @class ClickableComponent
  2474. */
  2475. var ClickableComponent = (function(_Component) {
  2476. _inherits(ClickableComponent, _Component)
  2477. function ClickableComponent(player, options) {
  2478. _classCallCheck(this, ClickableComponent)
  2479. _Component.call(this, player, options)
  2480. this.emitTapEvents()
  2481. this.on('tap', this.handleClick)
  2482. this.on('click', this.handleClick)
  2483. this.on('focus', this.handleFocus)
  2484. this.on('blur', this.handleBlur)
  2485. }
  2486. /**
  2487. * Create the component's DOM element
  2488. *
  2489. * @param {String=} type Element's node type. e.g. 'div'
  2490. * @param {Object=} props An object of properties that should be set on the element
  2491. * @param {Object=} attributes An object of attributes that should be set on the element
  2492. * @return {Element}
  2493. * @method createEl
  2494. */
  2495. ClickableComponent.prototype.createEl = function createEl() {
  2496. var tag = arguments.length <= 0 || arguments[0] === undefined ? 'div' : arguments[0]
  2497. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  2498. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]
  2499. props = _objectAssign2['default']({
  2500. className: this.buildCSSClass(),
  2501. tabIndex: 0
  2502. }, props)
  2503. if (tag === 'button') {
  2504. _utilsLogJs2['default'].error('Creating a ClickableComponent with an HTML element of ' + tag + ' is not supported; use a Button instead.')
  2505. }
  2506. // Add ARIA attributes for clickable element which is not a native HTML button
  2507. attributes = _objectAssign2['default']({
  2508. role: 'button',
  2509. 'aria-live': 'polite' // let the screen reader user know that the text of the element may change
  2510. }, attributes)
  2511. var el = _Component.prototype.createEl.call(this, tag, props, attributes)
  2512. this.createControlTextEl(el)
  2513. return el
  2514. }
  2515. /**
  2516. * create control text
  2517. *
  2518. * @param {Element} el Parent element for the control text
  2519. * @return {Element}
  2520. * @method controlText
  2521. */
  2522. ClickableComponent.prototype.createControlTextEl = function createControlTextEl(el) {
  2523. this.controlTextEl_ = Dom.createEl('span', {
  2524. className: 'vjs-control-text'
  2525. })
  2526. if (el) {
  2527. el.appendChild(this.controlTextEl_)
  2528. }
  2529. this.controlText(this.controlText_)
  2530. return this.controlTextEl_
  2531. }
  2532. /**
  2533. * Controls text - both request and localize
  2534. *
  2535. * @param {String} text Text for element
  2536. * @return {String}
  2537. * @method controlText
  2538. */
  2539. ClickableComponent.prototype.controlText = function controlText(text) {
  2540. if (!text) return this.controlText_ || 'Need Text'
  2541. this.controlText_ = text
  2542. this.controlTextEl_.innerHTML = this.localize(this.controlText_)
  2543. return this
  2544. }
  2545. /**
  2546. * Allows sub components to stack CSS class names
  2547. *
  2548. * @return {String}
  2549. * @method buildCSSClass
  2550. */
  2551. ClickableComponent.prototype.buildCSSClass = function buildCSSClass() {
  2552. return 'vjs-control vjs-button ' + _Component.prototype.buildCSSClass.call(this)
  2553. }
  2554. /**
  2555. * Adds a child component inside this clickable-component
  2556. *
  2557. * @param {String|Component} child The class name or instance of a child to add
  2558. * @param {Object=} options Options, including options to be passed to children of the child.
  2559. * @return {Component} The child component (created by this process if a string was used)
  2560. * @method addChild
  2561. */
  2562. ClickableComponent.prototype.addChild = function addChild(child) {
  2563. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  2564. // TODO: Fix adding an actionable child to a ClickableComponent; currently
  2565. // it will cause issues with assistive technology (e.g. screen readers)
  2566. // which support ARIA, since an element with role="button" cannot have
  2567. // actionable child elements.
  2568. // let className = this.constructor.name;
  2569. // 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.`);
  2570. return _Component.prototype.addChild.call(this, child, options)
  2571. }
  2572. /**
  2573. * Enable the component element
  2574. *
  2575. * @return {Component}
  2576. * @method enable
  2577. */
  2578. ClickableComponent.prototype.enable = function enable() {
  2579. this.removeClass('vjs-disabled')
  2580. this.el_.setAttribute('aria-disabled', 'false')
  2581. return this
  2582. }
  2583. /**
  2584. * Disable the component element
  2585. *
  2586. * @return {Component}
  2587. * @method disable
  2588. */
  2589. ClickableComponent.prototype.disable = function disable() {
  2590. this.addClass('vjs-disabled')
  2591. this.el_.setAttribute('aria-disabled', 'true')
  2592. return this
  2593. }
  2594. /**
  2595. * Handle Click - Override with specific functionality for component
  2596. *
  2597. * @method handleClick
  2598. */
  2599. ClickableComponent.prototype.handleClick = function handleClick() { }
  2600. /**
  2601. * Handle Focus - Add keyboard functionality to element
  2602. *
  2603. * @method handleFocus
  2604. */
  2605. ClickableComponent.prototype.handleFocus = function handleFocus() {
  2606. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress))
  2607. }
  2608. /**
  2609. * Handle KeyPress (document level) - Trigger click when Space or Enter key is pressed
  2610. *
  2611. * @method handleKeyPress
  2612. */
  2613. ClickableComponent.prototype.handleKeyPress = function handleKeyPress(event) {
  2614. // Support Space (32) or Enter (13) key operation to fire a click event
  2615. if (event.which === 32 || event.which === 13) {
  2616. event.preventDefault()
  2617. this.handleClick(event)
  2618. } else if (_Component.prototype.handleKeyPress) {
  2619. _Component.prototype.handleKeyPress.call(this, event) // Pass keypress handling up for unsupported keys
  2620. }
  2621. }
  2622. /**
  2623. * Handle Blur - Remove keyboard triggers
  2624. *
  2625. * @method handleBlur
  2626. */
  2627. ClickableComponent.prototype.handleBlur = function handleBlur() {
  2628. Events.off(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress))
  2629. }
  2630. return ClickableComponent
  2631. })(_component2['default'])
  2632. _component2['default'].registerComponent('ClickableComponent', ClickableComponent)
  2633. exports['default'] = ClickableComponent
  2634. module.exports = exports['default']
  2635. }, { './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) {
  2636. 'use strict'
  2637. exports.__esModule = true
  2638. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  2639. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  2640. 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 }
  2641. var _button = _dereq_('./button')
  2642. var _button2 = _interopRequireDefault(_button)
  2643. var _component = _dereq_('./component')
  2644. var _component2 = _interopRequireDefault(_component)
  2645. /**
  2646. * The `CloseButton` component is a button which fires a "close" event
  2647. * when it is activated.
  2648. *
  2649. * @extends Button
  2650. * @class CloseButton
  2651. */
  2652. var CloseButton = (function(_Button) {
  2653. _inherits(CloseButton, _Button)
  2654. function CloseButton(player, options) {
  2655. _classCallCheck(this, CloseButton)
  2656. _Button.call(this, player, options)
  2657. this.controlText(options && options.controlText || this.localize('Close'))
  2658. }
  2659. CloseButton.prototype.buildCSSClass = function buildCSSClass() {
  2660. return 'vjs-close-button ' + _Button.prototype.buildCSSClass.call(this)
  2661. }
  2662. CloseButton.prototype.handleClick = function handleClick() {
  2663. this.trigger({ type: 'close', bubbles: false })
  2664. }
  2665. return CloseButton
  2666. })(_button2['default'])
  2667. _component2['default'].registerComponent('CloseButton', CloseButton)
  2668. exports['default'] = CloseButton
  2669. module.exports = exports['default']
  2670. }, { './button': 64, './component': 67 }], 67: [function(_dereq_, module, exports) {
  2671. /**
  2672. * @file component.js
  2673. *
  2674. * Player Component - Base class for all UI objects
  2675. */
  2676. 'use strict'
  2677. exports.__esModule = true
  2678. 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 } }
  2679. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  2680. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  2681. var _globalWindow = _dereq_('global/window')
  2682. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  2683. var _utilsDomJs = _dereq_('./utils/dom.js')
  2684. var Dom = _interopRequireWildcard(_utilsDomJs)
  2685. var _utilsFnJs = _dereq_('./utils/fn.js')
  2686. var Fn = _interopRequireWildcard(_utilsFnJs)
  2687. var _utilsGuidJs = _dereq_('./utils/guid.js')
  2688. var Guid = _interopRequireWildcard(_utilsGuidJs)
  2689. var _utilsEventsJs = _dereq_('./utils/events.js')
  2690. var Events = _interopRequireWildcard(_utilsEventsJs)
  2691. var _utilsLogJs = _dereq_('./utils/log.js')
  2692. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  2693. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js')
  2694. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs)
  2695. var _objectAssign = _dereq_('object.assign')
  2696. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  2697. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js')
  2698. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs)
  2699. /**
  2700. * Base UI Component class
  2701. * Components are embeddable UI objects that are represented by both a
  2702. * javascript object and an element in the DOM. They can be children of other
  2703. * components, and can have many children themselves.
  2704. * ```js
  2705. * // adding a button to the player
  2706. * var button = player.addChild('button');
  2707. * button.el(); // -> button element
  2708. * ```
  2709. * ```html
  2710. * <div class="video-js">
  2711. * <div class="vjs-button">Button</div>
  2712. * </div>
  2713. * ```
  2714. * Components are also event targets.
  2715. * ```js
  2716. * button.on('click', function(){
  2717. * console.log('Button Clicked!');
  2718. * });
  2719. * button.trigger('customevent');
  2720. * ```
  2721. *
  2722. * @param {Object} player Main Player
  2723. * @param {Object=} options Object of option names and values
  2724. * @param {Function=} ready Ready callback function
  2725. * @class Component
  2726. */
  2727. var Component = (function() {
  2728. function Component(player, options, ready) {
  2729. _classCallCheck(this, Component)
  2730. // The component might be the player itself and we can't pass `this` to super
  2731. if (!player && this.play) {
  2732. this.player_ = player = this; // eslint-disable-line
  2733. } else {
  2734. this.player_ = player
  2735. }
  2736. // Make a copy of prototype.options_ to protect against overriding defaults
  2737. this.options_ = _utilsMergeOptionsJs2['default']({}, this.options_)
  2738. // Updated options with supplied options
  2739. options = this.options_ = _utilsMergeOptionsJs2['default'](this.options_, options)
  2740. // Get ID from options or options element if one is supplied
  2741. this.id_ = options.id || options.el && options.el.id
  2742. // If there was no ID from the options, generate one
  2743. if (!this.id_) {
  2744. // Don't require the player ID function in the case of mock players
  2745. var id = player && player.id && player.id() || 'no_player'
  2746. this.id_ = id + '_component_' + Guid.newGUID()
  2747. }
  2748. this.name_ = options.name || null
  2749. // Create element if one wasn't provided in options
  2750. if (options.el) {
  2751. this.el_ = options.el
  2752. } else if (options.createEl !== false) {
  2753. this.el_ = this.createEl()
  2754. }
  2755. this.children_ = []
  2756. this.childIndex_ = {}
  2757. this.childNameIndex_ = {}
  2758. // Add any child components in options
  2759. if (options.initChildren !== false) {
  2760. this.initChildren()
  2761. }
  2762. this.ready(ready)
  2763. // Don't want to trigger ready here or it will before init is actually
  2764. // finished for all children that run this constructor
  2765. if (options.reportTouchActivity !== false) {
  2766. this.enableTouchActivity()
  2767. }
  2768. }
  2769. /**
  2770. * Dispose of the component and all child components
  2771. *
  2772. * @method dispose
  2773. */
  2774. Component.prototype.dispose = function dispose() {
  2775. this.trigger({ type: 'dispose', bubbles: false })
  2776. // Dispose all children.
  2777. if (this.children_) {
  2778. for (var i = this.children_.length - 1; i >= 0; i--) {
  2779. if (this.children_[i].dispose) {
  2780. this.children_[i].dispose()
  2781. }
  2782. }
  2783. }
  2784. // Delete child references
  2785. this.children_ = null
  2786. this.childIndex_ = null
  2787. this.childNameIndex_ = null
  2788. // Remove all event listeners.
  2789. this.off()
  2790. // Remove element from DOM
  2791. if (this.el_.parentNode) {
  2792. this.el_.parentNode.removeChild(this.el_)
  2793. }
  2794. Dom.removeElData(this.el_)
  2795. this.el_ = null
  2796. }
  2797. /**
  2798. * Return the component's player
  2799. *
  2800. * @return {Player}
  2801. * @method player
  2802. */
  2803. Component.prototype.player = function player() {
  2804. return this.player_
  2805. }
  2806. /**
  2807. * Deep merge of options objects
  2808. * Whenever a property is an object on both options objects
  2809. * the two properties will be merged using mergeOptions.
  2810. *
  2811. * ```js
  2812. * Parent.prototype.options_ = {
  2813. * optionSet: {
  2814. * 'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
  2815. * 'childTwo': {},
  2816. * 'childThree': {}
  2817. * }
  2818. * }
  2819. * newOptions = {
  2820. * optionSet: {
  2821. * 'childOne': { 'foo': 'baz', 'abc': '123' }
  2822. * 'childTwo': null,
  2823. * 'childFour': {}
  2824. * }
  2825. * }
  2826. *
  2827. * this.options(newOptions);
  2828. * ```
  2829. * RESULT
  2830. * ```js
  2831. * {
  2832. * optionSet: {
  2833. * 'childOne': { 'foo': 'baz', 'asdf': 'fdsa', 'abc': '123' },
  2834. * 'childTwo': null, // Disabled. Won't be initialized.
  2835. * 'childThree': {},
  2836. * 'childFour': {}
  2837. * }
  2838. * }
  2839. * ```
  2840. *
  2841. * @param {Object} obj Object of new option values
  2842. * @return {Object} A NEW object of this.options_ and obj merged
  2843. * @method options
  2844. */
  2845. Component.prototype.options = function options(obj) {
  2846. _utilsLogJs2['default'].warn('this.options() has been deprecated and will be moved to the constructor in 6.0')
  2847. if (!obj) {
  2848. return this.options_
  2849. }
  2850. this.options_ = _utilsMergeOptionsJs2['default'](this.options_, obj)
  2851. return this.options_
  2852. }
  2853. /**
  2854. * Get the component's DOM element
  2855. * ```js
  2856. * var domEl = myComponent.el();
  2857. * ```
  2858. *
  2859. * @return {Element}
  2860. * @method el
  2861. */
  2862. Component.prototype.el = function el() {
  2863. return this.el_
  2864. }
  2865. /**
  2866. * Create the component's DOM element
  2867. *
  2868. * @param {String=} tagName Element's node type. e.g. 'div'
  2869. * @param {Object=} properties An object of properties that should be set
  2870. * @param {Object=} attributes An object of attributes that should be set
  2871. * @return {Element}
  2872. * @method createEl
  2873. */
  2874. Component.prototype.createEl = function createEl(tagName, properties, attributes) {
  2875. return Dom.createEl(tagName, properties, attributes)
  2876. }
  2877. Component.prototype.localize = function localize(string) {
  2878. var code = this.player_.language && this.player_.language()
  2879. var languages = this.player_.languages && this.player_.languages()
  2880. if (!code || !languages) {
  2881. return string
  2882. }
  2883. var language = languages[code]
  2884. if (language && language[string]) {
  2885. return language[string]
  2886. }
  2887. var primaryCode = code.split('-')[0]
  2888. var primaryLang = languages[primaryCode]
  2889. if (primaryLang && primaryLang[string]) {
  2890. return primaryLang[string]
  2891. }
  2892. return string
  2893. }
  2894. /**
  2895. * Return the component's DOM element where children are inserted.
  2896. * Will either be the same as el() or a new element defined in createEl().
  2897. *
  2898. * @return {Element}
  2899. * @method contentEl
  2900. */
  2901. Component.prototype.contentEl = function contentEl() {
  2902. return this.contentEl_ || this.el_
  2903. }
  2904. /**
  2905. * Get the component's ID
  2906. * ```js
  2907. * var id = myComponent.id();
  2908. * ```
  2909. *
  2910. * @return {String}
  2911. * @method id
  2912. */
  2913. Component.prototype.id = function id() {
  2914. return this.id_
  2915. }
  2916. /**
  2917. * Get the component's name. The name is often used to reference the component.
  2918. * ```js
  2919. * var name = myComponent.name();
  2920. * ```
  2921. *
  2922. * @return {String}
  2923. * @method name
  2924. */
  2925. Component.prototype.name = function name() {
  2926. return this.name_
  2927. }
  2928. /**
  2929. * Get an array of all child components
  2930. * ```js
  2931. * var kids = myComponent.children();
  2932. * ```
  2933. *
  2934. * @return {Array} The children
  2935. * @method children
  2936. */
  2937. Component.prototype.children = function children() {
  2938. return this.children_
  2939. }
  2940. /**
  2941. * Returns a child component with the provided ID
  2942. *
  2943. * @return {Component}
  2944. * @method getChildById
  2945. */
  2946. Component.prototype.getChildById = function getChildById(id) {
  2947. return this.childIndex_[id]
  2948. }
  2949. /**
  2950. * Returns a child component with the provided name
  2951. *
  2952. * @return {Component}
  2953. * @method getChild
  2954. */
  2955. Component.prototype.getChild = function getChild(name) {
  2956. return this.childNameIndex_[name]
  2957. }
  2958. /**
  2959. * Adds a child component inside this component
  2960. * ```js
  2961. * myComponent.el();
  2962. * // -> <div class='my-component'></div>
  2963. * myComponent.children();
  2964. * // [empty array]
  2965. *
  2966. * var myButton = myComponent.addChild('MyButton');
  2967. * // -> <div class='my-component'><div class="my-button">myButton<div></div>
  2968. * // -> myButton === myComponent.children()[0];
  2969. * ```
  2970. * Pass in options for child constructors and options for children of the child
  2971. * ```js
  2972. * var myButton = myComponent.addChild('MyButton', {
  2973. * text: 'Press Me',
  2974. * buttonChildExample: {
  2975. * buttonChildOption: true
  2976. * }
  2977. * });
  2978. * ```
  2979. *
  2980. * @param {String|Component} child The class name or instance of a child to add
  2981. * @param {Object=} options Options, including options to be passed to children of the child.
  2982. * @param {Number} index into our children array to attempt to add the child
  2983. * @return {Component} The child component (created by this process if a string was used)
  2984. * @method addChild
  2985. */
  2986. Component.prototype.addChild = function addChild(child) {
  2987. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  2988. var index = arguments.length <= 2 || arguments[2] === undefined ? this.children_.length : arguments[2]
  2989. var component = undefined
  2990. var componentName = undefined
  2991. // If child is a string, create nt with options
  2992. if (typeof child === 'string') {
  2993. componentName = child
  2994. // Options can also be specified as a boolean, so convert to an empty object if false.
  2995. if (!options) {
  2996. options = {}
  2997. }
  2998. // Same as above, but true is deprecated so show a warning.
  2999. if (options === true) {
  3000. _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`.')
  3001. options = {}
  3002. }
  3003. // If no componentClass in options, assume componentClass is the name lowercased
  3004. // (e.g. playButton)
  3005. var componentClassName = options.componentClass || _utilsToTitleCaseJs2['default'](componentName)
  3006. // Set name through options
  3007. options.name = componentName
  3008. // Create a new object & element for this controls set
  3009. // If there's no .player_, this is a player
  3010. var ComponentClass = Component.getComponent(componentClassName)
  3011. if (!ComponentClass) {
  3012. throw new Error('Component ' + componentClassName + ' does not exist')
  3013. }
  3014. // data stored directly on the videojs object may be
  3015. // misidentified as a component to retain
  3016. // backwards-compatibility with 4.x. check to make sure the
  3017. // component class can be instantiated.
  3018. if (typeof ComponentClass !== 'function') {
  3019. return null
  3020. }
  3021. component = new ComponentClass(this.player_ || this, options)
  3022. // child is a component instance
  3023. } else {
  3024. component = child
  3025. }
  3026. this.children_.splice(index, 0, component)
  3027. if (typeof component.id === 'function') {
  3028. this.childIndex_[component.id()] = component
  3029. }
  3030. // If a name wasn't used to create the component, check if we can use the
  3031. // name function of the component
  3032. componentName = componentName || component.name && component.name()
  3033. if (componentName) {
  3034. this.childNameIndex_[componentName] = component
  3035. }
  3036. // Add the UI object's element to the container div (box)
  3037. // Having an element is not required
  3038. if (typeof component.el === 'function' && component.el()) {
  3039. var childNodes = this.contentEl().children
  3040. var refNode = childNodes[index] || null
  3041. this.contentEl().insertBefore(component.el(), refNode)
  3042. }
  3043. // Return so it can stored on parent object if desired.
  3044. return component
  3045. }
  3046. /**
  3047. * Remove a child component from this component's list of children, and the
  3048. * child component's element from this component's element
  3049. *
  3050. * @param {Component} component Component to remove
  3051. * @method removeChild
  3052. */
  3053. Component.prototype.removeChild = function removeChild(component) {
  3054. if (typeof component === 'string') {
  3055. component = this.getChild(component)
  3056. }
  3057. if (!component || !this.children_) {
  3058. return
  3059. }
  3060. var childFound = false
  3061. for (var i = this.children_.length - 1; i >= 0; i--) {
  3062. if (this.children_[i] === component) {
  3063. childFound = true
  3064. this.children_.splice(i, 1)
  3065. break
  3066. }
  3067. }
  3068. if (!childFound) {
  3069. return
  3070. }
  3071. this.childIndex_[component.id()] = null
  3072. this.childNameIndex_[component.name()] = null
  3073. var compEl = component.el()
  3074. if (compEl && compEl.parentNode === this.contentEl()) {
  3075. this.contentEl().removeChild(component.el())
  3076. }
  3077. }
  3078. /**
  3079. * Add and initialize default child components from options
  3080. * ```js
  3081. * // when an instance of MyComponent is created, all children in options
  3082. * // will be added to the instance by their name strings and options
  3083. * MyComponent.prototype.options_ = {
  3084. * children: [
  3085. * 'myChildComponent'
  3086. * ],
  3087. * myChildComponent: {
  3088. * myChildOption: true
  3089. * }
  3090. * };
  3091. *
  3092. * // Or when creating the component
  3093. * var myComp = new MyComponent(player, {
  3094. * children: [
  3095. * 'myChildComponent'
  3096. * ],
  3097. * myChildComponent: {
  3098. * myChildOption: true
  3099. * }
  3100. * });
  3101. * ```
  3102. * The children option can also be an array of
  3103. * child options objects (that also include a 'name' key).
  3104. * This can be used if you have two child components of the
  3105. * same type that need different options.
  3106. * ```js
  3107. * var myComp = new MyComponent(player, {
  3108. * children: [
  3109. * 'button',
  3110. * {
  3111. * name: 'button',
  3112. * someOtherOption: true
  3113. * },
  3114. * {
  3115. * name: 'button',
  3116. * someOtherOption: false
  3117. * }
  3118. * ]
  3119. * });
  3120. * ```
  3121. *
  3122. * @method initChildren
  3123. */
  3124. Component.prototype.initChildren = function initChildren() {
  3125. var _this = this
  3126. var children = this.options_.children
  3127. if (children) {
  3128. (function() {
  3129. // `this` is `parent`
  3130. var parentOptions = _this.options_
  3131. var handleAdd = function handleAdd(child) {
  3132. var name = child.name
  3133. var opts = child.opts
  3134. // Allow options for children to be set at the parent options
  3135. // e.g. videojs(id, { controlBar: false });
  3136. // instead of videojs(id, { children: { controlBar: false });
  3137. if (parentOptions[name] !== undefined) {
  3138. opts = parentOptions[name]
  3139. }
  3140. // Allow for disabling default components
  3141. // e.g. options['children']['posterImage'] = false
  3142. if (opts === false) {
  3143. return
  3144. }
  3145. // Allow options to be passed as a simple boolean if no configuration
  3146. // is necessary.
  3147. if (opts === true) {
  3148. opts = {}
  3149. }
  3150. // We also want to pass the original player options to each component as well so they don't need to
  3151. // reach back into the player for options later.
  3152. opts.playerOptions = _this.options_.playerOptions
  3153. // Create and add the child component.
  3154. // Add a direct reference to the child by name on the parent instance.
  3155. // If two of the same component are used, different names should be supplied
  3156. // for each
  3157. var newChild = _this.addChild(name, opts)
  3158. if (newChild) {
  3159. _this[name] = newChild
  3160. }
  3161. }
  3162. // Allow for an array of children details to passed in the options
  3163. var workingChildren = undefined
  3164. var Tech = Component.getComponent('Tech')
  3165. if (Array.isArray(children)) {
  3166. workingChildren = children
  3167. } else {
  3168. workingChildren = Object.keys(children)
  3169. }
  3170. workingChildren
  3171. // children that are in this.options_ but also in workingChildren would
  3172. // give us extra children we do not want. So, we want to filter them out.
  3173. .concat(Object.keys(_this.options_).filter(function(child) {
  3174. return !workingChildren.some(function(wchild) {
  3175. if (typeof wchild === 'string') {
  3176. return child === wchild
  3177. } else {
  3178. return child === wchild.name
  3179. }
  3180. })
  3181. })).map(function(child) {
  3182. var name = undefined
  3183. var opts = undefined
  3184. if (typeof child === 'string') {
  3185. name = child
  3186. opts = children[name] || _this.options_[name] || {}
  3187. } else {
  3188. name = child.name
  3189. opts = child
  3190. }
  3191. return { name: name, opts: opts }
  3192. }).filter(function(child) {
  3193. // we have to make sure that child.name isn't in the techOrder since
  3194. // techs are registerd as Components but can't aren't compatible
  3195. // See https://github.com/videojs/video.js/issues/2772
  3196. var c = Component.getComponent(child.opts.componentClass || _utilsToTitleCaseJs2['default'](child.name))
  3197. return c && !Tech.isTech(c)
  3198. }).forEach(handleAdd)
  3199. })()
  3200. }
  3201. }
  3202. /**
  3203. * Allows sub components to stack CSS class names
  3204. *
  3205. * @return {String} The constructed class name
  3206. * @method buildCSSClass
  3207. */
  3208. Component.prototype.buildCSSClass = function buildCSSClass() {
  3209. // Child classes can include a function that does:
  3210. // return 'CLASS NAME' + this._super();
  3211. return ''
  3212. }
  3213. /**
  3214. * Add an event listener to this component's element
  3215. * ```js
  3216. * var myFunc = function(){
  3217. * var myComponent = this;
  3218. * // Do something when the event is fired
  3219. * };
  3220. *
  3221. * myComponent.on('eventType', myFunc);
  3222. * ```
  3223. * The context of myFunc will be myComponent unless previously bound.
  3224. * Alternatively, you can add a listener to another element or component.
  3225. * ```js
  3226. * myComponent.on(otherElement, 'eventName', myFunc);
  3227. * myComponent.on(otherComponent, 'eventName', myFunc);
  3228. * ```
  3229. * The benefit of using this over `VjsEvents.on(otherElement, 'eventName', myFunc)`
  3230. * and `otherComponent.on('eventName', myFunc)` is that this way the listeners
  3231. * will be automatically cleaned up when either component is disposed.
  3232. * It will also bind myComponent as the context of myFunc.
  3233. * **NOTE**: When using this on elements in the page other than window
  3234. * and document (both permanent), if you remove the element from the DOM
  3235. * you need to call `myComponent.trigger(el, 'dispose')` on it to clean up
  3236. * references to it and allow the browser to garbage collect it.
  3237. *
  3238. * @param {String|Component} first The event type or other component
  3239. * @param {Function|String} second The event handler or event type
  3240. * @param {Function} third The event handler
  3241. * @return {Component}
  3242. * @method on
  3243. */
  3244. Component.prototype.on = function on(first, second, third) {
  3245. var _this2 = this
  3246. if (typeof first === 'string' || Array.isArray(first)) {
  3247. Events.on(this.el_, first, Fn.bind(this, second))
  3248. // Targeting another component or element
  3249. } else {
  3250. (function() {
  3251. var target = first
  3252. var type = second
  3253. var fn = Fn.bind(_this2, third)
  3254. // When this component is disposed, remove the listener from the other component
  3255. var removeOnDispose = function removeOnDispose() {
  3256. return _this2.off(target, type, fn)
  3257. }
  3258. // Use the same function ID so we can remove it later it using the ID
  3259. // of the original listener
  3260. removeOnDispose.guid = fn.guid
  3261. _this2.on('dispose', removeOnDispose)
  3262. // If the other component is disposed first we need to clean the reference
  3263. // to the other component in this component's removeOnDispose listener
  3264. // Otherwise we create a memory leak.
  3265. var cleanRemover = function cleanRemover() {
  3266. return _this2.off('dispose', removeOnDispose)
  3267. }
  3268. // Add the same function ID so we can easily remove it later
  3269. cleanRemover.guid = fn.guid
  3270. // Check if this is a DOM node
  3271. if (first.nodeName) {
  3272. // Add the listener to the other element
  3273. Events.on(target, type, fn)
  3274. Events.on(target, 'dispose', cleanRemover)
  3275. // Should be a component
  3276. // Not using `instanceof Component` because it makes mock players difficult
  3277. } else if (typeof first.on === 'function') {
  3278. // Add the listener to the other component
  3279. target.on(type, fn)
  3280. target.on('dispose', cleanRemover)
  3281. }
  3282. })()
  3283. }
  3284. return this
  3285. }
  3286. /**
  3287. * Remove an event listener from this component's element
  3288. * ```js
  3289. * myComponent.off('eventType', myFunc);
  3290. * ```
  3291. * If myFunc is excluded, ALL listeners for the event type will be removed.
  3292. * If eventType is excluded, ALL listeners will be removed from the component.
  3293. * Alternatively you can use `off` to remove listeners that were added to other
  3294. * elements or components using `myComponent.on(otherComponent...`.
  3295. * In this case both the event type and listener function are REQUIRED.
  3296. * ```js
  3297. * myComponent.off(otherElement, 'eventType', myFunc);
  3298. * myComponent.off(otherComponent, 'eventType', myFunc);
  3299. * ```
  3300. *
  3301. * @param {String=|Component} first The event type or other component
  3302. * @param {Function=|String} second The listener function or event type
  3303. * @param {Function=} third The listener for other component
  3304. * @return {Component}
  3305. * @method off
  3306. */
  3307. Component.prototype.off = function off(first, second, third) {
  3308. if (!first || typeof first === 'string' || Array.isArray(first)) {
  3309. Events.off(this.el_, first, second)
  3310. } else {
  3311. var target = first
  3312. var type = second
  3313. // Ensure there's at least a guid, even if the function hasn't been used
  3314. var fn = Fn.bind(this, third)
  3315. // Remove the dispose listener on this component,
  3316. // which was given the same guid as the event listener
  3317. this.off('dispose', fn)
  3318. if (first.nodeName) {
  3319. // Remove the listener
  3320. Events.off(target, type, fn)
  3321. // Remove the listener for cleaning the dispose listener
  3322. Events.off(target, 'dispose', fn)
  3323. } else {
  3324. target.off(type, fn)
  3325. target.off('dispose', fn)
  3326. }
  3327. }
  3328. return this
  3329. }
  3330. /**
  3331. * Add an event listener to be triggered only once and then removed
  3332. * ```js
  3333. * myComponent.one('eventName', myFunc);
  3334. * ```
  3335. * Alternatively you can add a listener to another element or component
  3336. * that will be triggered only once.
  3337. * ```js
  3338. * myComponent.one(otherElement, 'eventName', myFunc);
  3339. * myComponent.one(otherComponent, 'eventName', myFunc);
  3340. * ```
  3341. *
  3342. * @param {String|Component} first The event type or other component
  3343. * @param {Function|String} second The listener function or event type
  3344. * @param {Function=} third The listener function for other component
  3345. * @return {Component}
  3346. * @method one
  3347. */
  3348. Component.prototype.one = function one(first, second, third) {
  3349. var _this3 = this
  3350. var _arguments = arguments
  3351. if (typeof first === 'string' || Array.isArray(first)) {
  3352. Events.one(this.el_, first, Fn.bind(this, second))
  3353. } else {
  3354. (function() {
  3355. var target = first
  3356. var type = second
  3357. var fn = Fn.bind(_this3, third)
  3358. var newFunc = function newFunc() {
  3359. _this3.off(target, type, newFunc)
  3360. fn.apply(null, _arguments)
  3361. }
  3362. // Keep the same function ID so we can remove it later
  3363. newFunc.guid = fn.guid
  3364. _this3.on(target, type, newFunc)
  3365. })()
  3366. }
  3367. return this
  3368. }
  3369. /**
  3370. * Trigger an event on an element
  3371. * ```js
  3372. * myComponent.trigger('eventName');
  3373. * myComponent.trigger({'type':'eventName'});
  3374. * myComponent.trigger('eventName', {data: 'some data'});
  3375. * myComponent.trigger({'type':'eventName'}, {data: 'some data'});
  3376. * ```
  3377. *
  3378. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  3379. * @param {Object} [hash] data hash to pass along with the event
  3380. * @return {Component} self
  3381. * @method trigger
  3382. */
  3383. Component.prototype.trigger = function trigger(event, hash) {
  3384. Events.trigger(this.el_, event, hash)
  3385. return this
  3386. }
  3387. /**
  3388. * Bind a listener to the component's ready state.
  3389. * Different from event listeners in that if the ready event has already happened
  3390. * it will trigger the function immediately.
  3391. *
  3392. * @param {Function} fn Ready listener
  3393. * @param {Boolean} sync Exec the listener synchronously if component is ready
  3394. * @return {Component}
  3395. * @method ready
  3396. */
  3397. Component.prototype.ready = function ready(fn) {
  3398. var sync = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]
  3399. if (fn) {
  3400. if (this.isReady_) {
  3401. if (sync) {
  3402. fn.call(this)
  3403. } else {
  3404. // Call the function asynchronously by default for consistency
  3405. this.setTimeout(fn, 1)
  3406. }
  3407. } else {
  3408. this.readyQueue_ = this.readyQueue_ || []
  3409. this.readyQueue_.push(fn)
  3410. }
  3411. }
  3412. return this
  3413. }
  3414. /**
  3415. * Trigger the ready listeners
  3416. *
  3417. * @return {Component}
  3418. * @method triggerReady
  3419. */
  3420. Component.prototype.triggerReady = function triggerReady() {
  3421. this.isReady_ = true
  3422. // Ensure ready is triggerd asynchronously
  3423. this.setTimeout(function() {
  3424. var readyQueue = this.readyQueue_
  3425. // Reset Ready Queue
  3426. this.readyQueue_ = []
  3427. if (readyQueue && readyQueue.length > 0) {
  3428. readyQueue.forEach(function(fn) {
  3429. fn.call(this)
  3430. }, this)
  3431. }
  3432. // Allow for using event listeners also
  3433. this.trigger('ready')
  3434. }, 1)
  3435. }
  3436. /**
  3437. * Finds a single DOM element matching `selector` within the component's
  3438. * `contentEl` or another custom context.
  3439. *
  3440. * @method $
  3441. * @param {String} selector
  3442. * A valid CSS selector, which will be passed to `querySelector`.
  3443. *
  3444. * @param {Element|String} [context=document]
  3445. * A DOM element within which to query. Can also be a selector
  3446. * string in which case the first matching element will be used
  3447. * as context. If missing (or no element matches selector), falls
  3448. * back to `document`.
  3449. *
  3450. * @return {Element|null}
  3451. */
  3452. Component.prototype.$ = function $(selector, context) {
  3453. return Dom.$(selector, context || this.contentEl())
  3454. }
  3455. /**
  3456. * Finds a all DOM elements matching `selector` within the component's
  3457. * `contentEl` or another custom context.
  3458. *
  3459. * @method $$
  3460. * @param {String} selector
  3461. * A valid CSS selector, which will be passed to `querySelectorAll`.
  3462. *
  3463. * @param {Element|String} [context=document]
  3464. * A DOM element within which to query. Can also be a selector
  3465. * string in which case the first matching element will be used
  3466. * as context. If missing (or no element matches selector), falls
  3467. * back to `document`.
  3468. *
  3469. * @return {NodeList}
  3470. */
  3471. Component.prototype.$$ = function $$(selector, context) {
  3472. return Dom.$$(selector, context || this.contentEl())
  3473. }
  3474. /**
  3475. * Check if a component's element has a CSS class name
  3476. *
  3477. * @param {String} classToCheck Classname to check
  3478. * @return {Component}
  3479. * @method hasClass
  3480. */
  3481. Component.prototype.hasClass = function hasClass(classToCheck) {
  3482. return Dom.hasElClass(this.el_, classToCheck)
  3483. }
  3484. /**
  3485. * Add a CSS class name to the component's element
  3486. *
  3487. * @param {String} classToAdd Classname to add
  3488. * @return {Component}
  3489. * @method addClass
  3490. */
  3491. Component.prototype.addClass = function addClass(classToAdd) {
  3492. Dom.addElClass(this.el_, classToAdd)
  3493. return this
  3494. }
  3495. /**
  3496. * Remove a CSS class name from the component's element
  3497. *
  3498. * @param {String} classToRemove Classname to remove
  3499. * @return {Component}
  3500. * @method removeClass
  3501. */
  3502. Component.prototype.removeClass = function removeClass(classToRemove) {
  3503. Dom.removeElClass(this.el_, classToRemove)
  3504. return this
  3505. }
  3506. /**
  3507. * Add or remove a CSS class name from the component's element
  3508. *
  3509. * @param {String} classToToggle
  3510. * @param {Boolean|Function} [predicate]
  3511. * Can be a function that returns a Boolean. If `true`, the class
  3512. * will be added; if `false`, the class will be removed. If not
  3513. * given, the class will be added if not present and vice versa.
  3514. *
  3515. * @return {Component}
  3516. * @method toggleClass
  3517. */
  3518. Component.prototype.toggleClass = function toggleClass(classToToggle, predicate) {
  3519. Dom.toggleElClass(this.el_, classToToggle, predicate)
  3520. return this
  3521. }
  3522. /**
  3523. * Show the component element if hidden
  3524. *
  3525. * @return {Component}
  3526. * @method show
  3527. */
  3528. Component.prototype.show = function show() {
  3529. this.removeClass('vjs-hidden')
  3530. return this
  3531. }
  3532. /**
  3533. * Hide the component element if currently showing
  3534. *
  3535. * @return {Component}
  3536. * @method hide
  3537. */
  3538. Component.prototype.hide = function hide() {
  3539. this.addClass('vjs-hidden')
  3540. return this
  3541. }
  3542. /**
  3543. * Lock an item in its visible state
  3544. * To be used with fadeIn/fadeOut.
  3545. *
  3546. * @return {Component}
  3547. * @private
  3548. * @method lockShowing
  3549. */
  3550. Component.prototype.lockShowing = function lockShowing() {
  3551. this.addClass('vjs-lock-showing')
  3552. return this
  3553. }
  3554. /**
  3555. * Unlock an item to be hidden
  3556. * To be used with fadeIn/fadeOut.
  3557. *
  3558. * @return {Component}
  3559. * @private
  3560. * @method unlockShowing
  3561. */
  3562. Component.prototype.unlockShowing = function unlockShowing() {
  3563. this.removeClass('vjs-lock-showing')
  3564. return this
  3565. }
  3566. /**
  3567. * Set or get the width of the component (CSS values)
  3568. * Setting the video tag dimension values only works with values in pixels.
  3569. * Percent values will not work.
  3570. * Some percents can be used, but width()/height() will return the number + %,
  3571. * not the actual computed width/height.
  3572. *
  3573. * @param {Number|String=} num Optional width number
  3574. * @param {Boolean} skipListeners Skip the 'resize' event trigger
  3575. * @return {Component} This component, when setting the width
  3576. * @return {Number|String} The width, when getting
  3577. * @method width
  3578. */
  3579. Component.prototype.width = function width(num, skipListeners) {
  3580. return this.dimension('width', num, skipListeners)
  3581. }
  3582. /**
  3583. * Get or set the height of the component (CSS values)
  3584. * Setting the video tag dimension values only works with values in pixels.
  3585. * Percent values will not work.
  3586. * Some percents can be used, but width()/height() will return the number + %,
  3587. * not the actual computed width/height.
  3588. *
  3589. * @param {Number|String=} num New component height
  3590. * @param {Boolean=} skipListeners Skip the resize event trigger
  3591. * @return {Component} This component, when setting the height
  3592. * @return {Number|String} The height, when getting
  3593. * @method height
  3594. */
  3595. Component.prototype.height = function height(num, skipListeners) {
  3596. return this.dimension('height', num, skipListeners)
  3597. }
  3598. /**
  3599. * Set both width and height at the same time
  3600. *
  3601. * @param {Number|String} width Width of player
  3602. * @param {Number|String} height Height of player
  3603. * @return {Component} The component
  3604. * @method dimensions
  3605. */
  3606. Component.prototype.dimensions = function dimensions(width, height) {
  3607. // Skip resize listeners on width for optimization
  3608. return this.width(width, true).height(height)
  3609. }
  3610. /**
  3611. * Get or set width or height
  3612. * This is the shared code for the width() and height() methods.
  3613. * All for an integer, integer + 'px' or integer + '%';
  3614. * Known issue: Hidden elements officially have a width of 0. We're defaulting
  3615. * to the style.width value and falling back to computedStyle which has the
  3616. * hidden element issue. Info, but probably not an efficient fix:
  3617. * http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/
  3618. *
  3619. * @param {String} widthOrHeight 'width' or 'height'
  3620. * @param {Number|String=} num New dimension
  3621. * @param {Boolean=} skipListeners Skip resize event trigger
  3622. * @return {Component} The component if a dimension was set
  3623. * @return {Number|String} The dimension if nothing was set
  3624. * @private
  3625. * @method dimension
  3626. */
  3627. Component.prototype.dimension = function dimension(widthOrHeight, num, skipListeners) {
  3628. if (num !== undefined) {
  3629. // Set to zero if null or literally NaN (NaN !== NaN)
  3630. if (num === null || num !== num) {
  3631. num = 0
  3632. }
  3633. // Check if using css width/height (% or px) and adjust
  3634. if (('' + num).indexOf('%') !== -1 || ('' + num).indexOf('px') !== -1) {
  3635. this.el_.style[widthOrHeight] = num
  3636. } else if (num === 'auto') {
  3637. this.el_.style[widthOrHeight] = ''
  3638. } else {
  3639. this.el_.style[widthOrHeight] = num + 'px'
  3640. }
  3641. // skipListeners allows us to avoid triggering the resize event when setting both width and height
  3642. if (!skipListeners) {
  3643. this.trigger('resize')
  3644. }
  3645. // Return component
  3646. return this
  3647. }
  3648. // Not setting a value, so getting it
  3649. // Make sure element exists
  3650. if (!this.el_) {
  3651. return 0
  3652. }
  3653. // Get dimension value from style
  3654. var val = this.el_.style[widthOrHeight]
  3655. var pxIndex = val.indexOf('px')
  3656. if (pxIndex !== -1) {
  3657. // Return the pixel value with no 'px'
  3658. return parseInt(val.slice(0, pxIndex), 10)
  3659. }
  3660. // No px so using % or no style was set, so falling back to offsetWidth/height
  3661. // If component has display:none, offset will return 0
  3662. // TODO: handle display:none and no dimension style using px
  3663. return parseInt(this.el_['offset' + _utilsToTitleCaseJs2['default'](widthOrHeight)], 10)
  3664. }
  3665. /**
  3666. * Get width or height of computed style
  3667. * @param {String} widthOrHeight 'width' or 'height'
  3668. * @return {Number|Boolean} The bolean false if nothing was set
  3669. * @method currentDimension
  3670. */
  3671. Component.prototype.currentDimension = function currentDimension(widthOrHeight) {
  3672. var computedWidthOrHeight = 0
  3673. if (widthOrHeight !== 'width' && widthOrHeight !== 'height') {
  3674. throw new Error('currentDimension only accepts width or height value')
  3675. }
  3676. if (typeof _globalWindow2['default'].getComputedStyle === 'function') {
  3677. var computedStyle = _globalWindow2['default'].getComputedStyle(this.el_)
  3678. computedWidthOrHeight = computedStyle.getPropertyValue(widthOrHeight) || computedStyle[widthOrHeight]
  3679. } else if (this.el_.currentStyle) {
  3680. // ie 8 doesn't support computed style, shim it
  3681. // return clientWidth or clientHeight instead for better accuracy
  3682. var rule = 'offset' + _utilsToTitleCaseJs2['default'](widthOrHeight)
  3683. computedWidthOrHeight = this.el_[rule]
  3684. }
  3685. // remove 'px' from variable and parse as integer
  3686. computedWidthOrHeight = parseFloat(computedWidthOrHeight)
  3687. return computedWidthOrHeight
  3688. }
  3689. /**
  3690. * Get an object which contains width and height values of computed style
  3691. * @return {Object} The dimensions of element
  3692. * @method currentDimensions
  3693. */
  3694. Component.prototype.currentDimensions = function currentDimensions() {
  3695. return {
  3696. width: this.currentDimension('width'),
  3697. height: this.currentDimension('height')
  3698. }
  3699. }
  3700. /**
  3701. * Get width of computed style
  3702. * @return {Integer}
  3703. * @method currentWidth
  3704. */
  3705. Component.prototype.currentWidth = function currentWidth() {
  3706. return this.currentDimension('width')
  3707. }
  3708. /**
  3709. * Get height of computed style
  3710. * @return {Integer}
  3711. * @method currentHeight
  3712. */
  3713. Component.prototype.currentHeight = function currentHeight() {
  3714. return this.currentDimension('height')
  3715. }
  3716. /**
  3717. * Emit 'tap' events when touch events are supported
  3718. * This is used to support toggling the controls through a tap on the video.
  3719. * We're requiring them to be enabled because otherwise every component would
  3720. * have this extra overhead unnecessarily, on mobile devices where extra
  3721. * overhead is especially bad.
  3722. *
  3723. * @private
  3724. * @method emitTapEvents
  3725. */
  3726. Component.prototype.emitTapEvents = function emitTapEvents() {
  3727. // Track the start time so we can determine how long the touch lasted
  3728. var touchStart = 0
  3729. var firstTouch = null
  3730. // Maximum movement allowed during a touch event to still be considered a tap
  3731. // Other popular libs use anywhere from 2 (hammer.js) to 15, so 10 seems like a nice, round number.
  3732. var tapMovementThreshold = 10
  3733. // The maximum length a touch can be while still being considered a tap
  3734. var touchTimeThreshold = 200
  3735. var couldBeTap = undefined
  3736. this.on('touchstart', function(event) {
  3737. // If more than one finger, don't consider treating this as a click
  3738. if (event.touches.length === 1) {
  3739. // Copy the touches object to prevent modifying the original
  3740. firstTouch = _objectAssign2['default']({}, event.touches[0])
  3741. // Record start time so we can detect a tap vs. "touch and hold"
  3742. touchStart = new Date().getTime()
  3743. // Reset couldBeTap tracking
  3744. couldBeTap = true
  3745. }
  3746. })
  3747. this.on('touchmove', function(event) {
  3748. // If more than one finger, don't consider treating this as a click
  3749. if (event.touches.length > 1) {
  3750. couldBeTap = false
  3751. } else if (firstTouch) {
  3752. // Some devices will throw touchmoves for all but the slightest of taps.
  3753. // So, if we moved only a small distance, this could still be a tap
  3754. var xdiff = event.touches[0].pageX - firstTouch.pageX
  3755. var ydiff = event.touches[0].pageY - firstTouch.pageY
  3756. var touchDistance = Math.sqrt(xdiff * xdiff + ydiff * ydiff)
  3757. if (touchDistance > tapMovementThreshold) {
  3758. couldBeTap = false
  3759. }
  3760. }
  3761. })
  3762. var noTap = function noTap() {
  3763. couldBeTap = false
  3764. }
  3765. // TODO: Listen to the original target. http://youtu.be/DujfpXOKUp8?t=13m8s
  3766. this.on('touchleave', noTap)
  3767. this.on('touchcancel', noTap)
  3768. // When the touch ends, measure how long it took and trigger the appropriate
  3769. // event
  3770. this.on('touchend', function(event) {
  3771. firstTouch = null
  3772. // Proceed only if the touchmove/leave/cancel event didn't happen
  3773. if (couldBeTap === true) {
  3774. // Measure how long the touch lasted
  3775. var touchTime = new Date().getTime() - touchStart
  3776. // Make sure the touch was less than the threshold to be considered a tap
  3777. if (touchTime < touchTimeThreshold) {
  3778. // Don't let browser turn this into a click
  3779. event.preventDefault()
  3780. this.trigger('tap')
  3781. // It may be good to copy the touchend event object and change the
  3782. // type to tap, if the other event properties aren't exact after
  3783. // Events.fixEvent runs (e.g. event.target)
  3784. }
  3785. }
  3786. })
  3787. }
  3788. /**
  3789. * Report user touch activity when touch events occur
  3790. * User activity is used to determine when controls should show/hide. It's
  3791. * relatively simple when it comes to mouse events, because any mouse event
  3792. * should show the controls. So we capture mouse events that bubble up to the
  3793. * player and report activity when that happens.
  3794. * With touch events it isn't as easy. We can't rely on touch events at the
  3795. * player level, because a tap (touchstart + touchend) on the video itself on
  3796. * mobile devices is meant to turn controls off (and on). User activity is
  3797. * checked asynchronously, so what could happen is a tap event on the video
  3798. * turns the controls off, then the touchend event bubbles up to the player,
  3799. * which if it reported user activity, would turn the controls right back on.
  3800. * (We also don't want to completely block touch events from bubbling up)
  3801. * Also a touchmove, touch+hold, and anything other than a tap is not supposed
  3802. * to turn the controls back on on a mobile device.
  3803. * Here we're setting the default component behavior to report user activity
  3804. * whenever touch events happen, and this can be turned off by components that
  3805. * want touch events to act differently.
  3806. *
  3807. * @method enableTouchActivity
  3808. */
  3809. Component.prototype.enableTouchActivity = function enableTouchActivity() {
  3810. // Don't continue if the root player doesn't support reporting user activity
  3811. if (!this.player() || !this.player().reportUserActivity) {
  3812. return
  3813. }
  3814. // listener for reporting that the user is active
  3815. var report = Fn.bind(this.player(), this.player().reportUserActivity)
  3816. var touchHolding = undefined
  3817. this.on('touchstart', function() {
  3818. report()
  3819. // For as long as the they are touching the device or have their mouse down,
  3820. // we consider them active even if they're not moving their finger or mouse.
  3821. // So we want to continue to update that they are active
  3822. this.clearInterval(touchHolding)
  3823. // report at the same interval as activityCheck
  3824. touchHolding = this.setInterval(report, 250)
  3825. })
  3826. var touchEnd = function touchEnd(event) {
  3827. report()
  3828. // stop the interval that maintains activity if the touch is holding
  3829. this.clearInterval(touchHolding)
  3830. }
  3831. this.on('touchmove', report)
  3832. this.on('touchend', touchEnd)
  3833. this.on('touchcancel', touchEnd)
  3834. }
  3835. /**
  3836. * Creates timeout and sets up disposal automatically.
  3837. *
  3838. * @param {Function} fn The function to run after the timeout.
  3839. * @param {Number} timeout Number of ms to delay before executing specified function.
  3840. * @return {Number} Returns the timeout ID
  3841. * @method setTimeout
  3842. */
  3843. Component.prototype.setTimeout = function setTimeout(fn, timeout) {
  3844. fn = Fn.bind(this, fn)
  3845. // window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't.
  3846. var timeoutId = _globalWindow2['default'].setTimeout(fn, timeout)
  3847. var disposeFn = function disposeFn() {
  3848. this.clearTimeout(timeoutId)
  3849. }
  3850. disposeFn.guid = 'vjs-timeout-' + timeoutId
  3851. this.on('dispose', disposeFn)
  3852. return timeoutId
  3853. }
  3854. /**
  3855. * Clears a timeout and removes the associated dispose listener
  3856. *
  3857. * @param {Number} timeoutId The id of the timeout to clear
  3858. * @return {Number} Returns the timeout ID
  3859. * @method clearTimeout
  3860. */
  3861. Component.prototype.clearTimeout = function clearTimeout(timeoutId) {
  3862. _globalWindow2['default'].clearTimeout(timeoutId)
  3863. var disposeFn = function disposeFn() { }
  3864. disposeFn.guid = 'vjs-timeout-' + timeoutId
  3865. this.off('dispose', disposeFn)
  3866. return timeoutId
  3867. }
  3868. /**
  3869. * Creates an interval and sets up disposal automatically.
  3870. *
  3871. * @param {Function} fn The function to run every N seconds.
  3872. * @param {Number} interval Number of ms to delay before executing specified function.
  3873. * @return {Number} Returns the interval ID
  3874. * @method setInterval
  3875. */
  3876. Component.prototype.setInterval = function setInterval(fn, interval) {
  3877. fn = Fn.bind(this, fn)
  3878. var intervalId = _globalWindow2['default'].setInterval(fn, interval)
  3879. var disposeFn = function disposeFn() {
  3880. this.clearInterval(intervalId)
  3881. }
  3882. disposeFn.guid = 'vjs-interval-' + intervalId
  3883. this.on('dispose', disposeFn)
  3884. return intervalId
  3885. }
  3886. /**
  3887. * Clears an interval and removes the associated dispose listener
  3888. *
  3889. * @param {Number} intervalId The id of the interval to clear
  3890. * @return {Number} Returns the interval ID
  3891. * @method clearInterval
  3892. */
  3893. Component.prototype.clearInterval = function clearInterval(intervalId) {
  3894. _globalWindow2['default'].clearInterval(intervalId)
  3895. var disposeFn = function disposeFn() { }
  3896. disposeFn.guid = 'vjs-interval-' + intervalId
  3897. this.off('dispose', disposeFn)
  3898. return intervalId
  3899. }
  3900. /**
  3901. * Registers a component
  3902. *
  3903. * @param {String} name Name of the component to register
  3904. * @param {Object} comp The component to register
  3905. * @static
  3906. * @method registerComponent
  3907. */
  3908. Component.registerComponent = function registerComponent(name, comp) {
  3909. if (!Component.components_) {
  3910. Component.components_ = {}
  3911. }
  3912. Component.components_[name] = comp
  3913. return comp
  3914. }
  3915. /**
  3916. * Gets a component by name
  3917. *
  3918. * @param {String} name Name of the component to get
  3919. * @return {Component}
  3920. * @static
  3921. * @method getComponent
  3922. */
  3923. Component.getComponent = function getComponent(name) {
  3924. if (Component.components_ && Component.components_[name]) {
  3925. return Component.components_[name]
  3926. }
  3927. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  3928. _utilsLogJs2['default'].warn('The ' + name + ' component was added to the videojs object when it should be registered using videojs.registerComponent(name, component)')
  3929. return _globalWindow2['default'].videojs[name]
  3930. }
  3931. }
  3932. /**
  3933. * Sets up the constructor using the supplied init method
  3934. * or uses the init of the parent object
  3935. *
  3936. * @param {Object} props An object of properties
  3937. * @static
  3938. * @deprecated
  3939. * @method extend
  3940. */
  3941. Component.extend = function extend(props) {
  3942. props = props || {}
  3943. _utilsLogJs2['default'].warn('Component.extend({}) has been deprecated, use videojs.extend(Component, {}) instead')
  3944. // Set up the constructor using the supplied init method
  3945. // or using the init of the parent object
  3946. // Make sure to check the unobfuscated version for external libs
  3947. var init = props.init || props.init || this.prototype.init || this.prototype.init || function() { }
  3948. // In Resig's simple class inheritance (previously used) the constructor
  3949. // is a function that calls `this.init.apply(arguments)`
  3950. // However that would prevent us from using `ParentObject.call(this);`
  3951. // in a Child constructor because the `this` in `this.init`
  3952. // would still refer to the Child and cause an infinite loop.
  3953. // We would instead have to do
  3954. // `ParentObject.prototype.init.apply(this, arguments);`
  3955. // Bleh. We're not creating a _super() function, so it's good to keep
  3956. // the parent constructor reference simple.
  3957. var subObj = function subObj() {
  3958. init.apply(this, arguments)
  3959. }
  3960. // Inherit from this object's prototype
  3961. subObj.prototype = Object.create(this.prototype)
  3962. // Reset the constructor property for subObj otherwise
  3963. // instances of subObj would have the constructor of the parent Object
  3964. subObj.prototype.constructor = subObj
  3965. // Make the class extendable
  3966. subObj.extend = Component.extend
  3967. // Extend subObj's prototype with functions and other properties from props
  3968. for (var _name in props) {
  3969. if (props.hasOwnProperty(_name)) {
  3970. subObj.prototype[_name] = props[_name]
  3971. }
  3972. }
  3973. return subObj
  3974. }
  3975. return Component
  3976. })()
  3977. Component.registerComponent('Component', Component)
  3978. exports['default'] = Component
  3979. module.exports = exports['default']
  3980. }, { './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) {
  3981. /**
  3982. * @file audio-track-button.js
  3983. */
  3984. 'use strict'
  3985. exports.__esModule = true
  3986. 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 } }
  3987. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  3988. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  3989. 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 }
  3990. var _trackButtonJs = _dereq_('../track-button.js')
  3991. var _trackButtonJs2 = _interopRequireDefault(_trackButtonJs)
  3992. var _componentJs = _dereq_('../../component.js')
  3993. var _componentJs2 = _interopRequireDefault(_componentJs)
  3994. var _utilsFnJs = _dereq_('../../utils/fn.js')
  3995. var Fn = _interopRequireWildcard(_utilsFnJs)
  3996. var _audioTrackMenuItemJs = _dereq_('./audio-track-menu-item.js')
  3997. var _audioTrackMenuItemJs2 = _interopRequireDefault(_audioTrackMenuItemJs)
  3998. /**
  3999. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  4000. *
  4001. * @param {Player|Object} player
  4002. * @param {Object=} options
  4003. * @extends TrackButton
  4004. * @class AudioTrackButton
  4005. */
  4006. var AudioTrackButton = (function(_TrackButton) {
  4007. _inherits(AudioTrackButton, _TrackButton)
  4008. function AudioTrackButton(player) {
  4009. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  4010. _classCallCheck(this, AudioTrackButton)
  4011. options.tracks = player.audioTracks && player.audioTracks()
  4012. _TrackButton.call(this, player, options)
  4013. this.el_.setAttribute('aria-label', 'Audio Menu')
  4014. }
  4015. /**
  4016. * Allow sub components to stack CSS class names
  4017. *
  4018. * @return {String} The constructed class name
  4019. * @method buildCSSClass
  4020. */
  4021. AudioTrackButton.prototype.buildCSSClass = function buildCSSClass() {
  4022. return 'vjs-audio-button ' + _TrackButton.prototype.buildCSSClass.call(this)
  4023. }
  4024. /**
  4025. * Create a menu item for each audio track
  4026. *
  4027. * @return {Array} Array of menu items
  4028. * @method createItems
  4029. */
  4030. AudioTrackButton.prototype.createItems = function createItems() {
  4031. var items = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]
  4032. var tracks = this.player_.audioTracks && this.player_.audioTracks()
  4033. if (!tracks) {
  4034. return items
  4035. }
  4036. for (var i = 0; i < tracks.length; i++) {
  4037. var track = tracks[i]
  4038. items.push(new _audioTrackMenuItemJs2['default'](this.player_, {
  4039. // MenuItem is selectable
  4040. 'selectable': true,
  4041. 'track': track
  4042. }))
  4043. }
  4044. return items
  4045. }
  4046. return AudioTrackButton
  4047. })(_trackButtonJs2['default'])
  4048. _componentJs2['default'].registerComponent('AudioTrackButton', AudioTrackButton)
  4049. exports['default'] = AudioTrackButton
  4050. module.exports = exports['default']
  4051. }, { '../../component.js': 67, '../../utils/fn.js': 145, '../track-button.js': 98, './audio-track-menu-item.js': 69 }], 69: [function(_dereq_, module, exports) {
  4052. /**
  4053. * @file audio-track-menu-item.js
  4054. */
  4055. 'use strict'
  4056. exports.__esModule = true
  4057. 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 } }
  4058. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4059. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4060. 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 }
  4061. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js')
  4062. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs)
  4063. var _componentJs = _dereq_('../../component.js')
  4064. var _componentJs2 = _interopRequireDefault(_componentJs)
  4065. var _utilsFnJs = _dereq_('../../utils/fn.js')
  4066. var Fn = _interopRequireWildcard(_utilsFnJs)
  4067. /**
  4068. * The audio track menu item
  4069. *
  4070. * @param {Player|Object} player
  4071. * @param {Object=} options
  4072. * @extends MenuItem
  4073. * @class AudioTrackMenuItem
  4074. */
  4075. var AudioTrackMenuItem = (function(_MenuItem) {
  4076. _inherits(AudioTrackMenuItem, _MenuItem)
  4077. function AudioTrackMenuItem(player, options) {
  4078. var _this = this
  4079. _classCallCheck(this, AudioTrackMenuItem)
  4080. var track = options.track
  4081. var tracks = player.audioTracks()
  4082. // Modify options for parent MenuItem class's init.
  4083. options.label = track.label || track.language || 'Unknown'
  4084. options.selected = track.enabled
  4085. _MenuItem.call(this, player, options)
  4086. this.track = track
  4087. if (tracks) {
  4088. (function() {
  4089. var changeHandler = Fn.bind(_this, _this.handleTracksChange)
  4090. tracks.addEventListener('change', changeHandler)
  4091. _this.on('dispose', function() {
  4092. tracks.removeEventListener('change', changeHandler)
  4093. })
  4094. })()
  4095. }
  4096. }
  4097. /**
  4098. * Handle click on audio track
  4099. *
  4100. * @method handleClick
  4101. */
  4102. AudioTrackMenuItem.prototype.handleClick = function handleClick(event) {
  4103. var tracks = this.player_.audioTracks()
  4104. _MenuItem.prototype.handleClick.call(this, event)
  4105. if (!tracks) return
  4106. for (var i = 0; i < tracks.length; i++) {
  4107. var track = tracks[i]
  4108. if (track === this.track) {
  4109. track.enabled = true
  4110. }
  4111. }
  4112. }
  4113. /**
  4114. * Handle audio track change
  4115. *
  4116. * @method handleTracksChange
  4117. */
  4118. AudioTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  4119. this.selected(this.track.enabled)
  4120. }
  4121. return AudioTrackMenuItem
  4122. })(_menuMenuItemJs2['default'])
  4123. _componentJs2['default'].registerComponent('AudioTrackMenuItem', AudioTrackMenuItem)
  4124. exports['default'] = AudioTrackMenuItem
  4125. module.exports = exports['default']
  4126. }, { '../../component.js': 67, '../../menu/menu-item.js': 110, '../../utils/fn.js': 145 }], 70: [function(_dereq_, module, exports) {
  4127. /**
  4128. * @file control-bar.js
  4129. */
  4130. 'use strict'
  4131. exports.__esModule = true
  4132. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4133. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4134. 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 }
  4135. var _componentJs = _dereq_('../component.js')
  4136. var _componentJs2 = _interopRequireDefault(_componentJs)
  4137. // Required children
  4138. var _playToggleJs = _dereq_('./play-toggle.js')
  4139. var _playToggleJs2 = _interopRequireDefault(_playToggleJs)
  4140. var _timeControlsCurrentTimeDisplayJs = _dereq_('./time-controls/current-time-display.js')
  4141. var _timeControlsCurrentTimeDisplayJs2 = _interopRequireDefault(_timeControlsCurrentTimeDisplayJs)
  4142. var _timeControlsDurationDisplayJs = _dereq_('./time-controls/duration-display.js')
  4143. var _timeControlsDurationDisplayJs2 = _interopRequireDefault(_timeControlsDurationDisplayJs)
  4144. var _timeControlsTimeDividerJs = _dereq_('./time-controls/time-divider.js')
  4145. var _timeControlsTimeDividerJs2 = _interopRequireDefault(_timeControlsTimeDividerJs)
  4146. var _timeControlsRemainingTimeDisplayJs = _dereq_('./time-controls/remaining-time-display.js')
  4147. var _timeControlsRemainingTimeDisplayJs2 = _interopRequireDefault(_timeControlsRemainingTimeDisplayJs)
  4148. var _liveDisplayJs = _dereq_('./live-display.js')
  4149. var _liveDisplayJs2 = _interopRequireDefault(_liveDisplayJs)
  4150. var _progressControlProgressControlJs = _dereq_('./progress-control/progress-control.js')
  4151. var _progressControlProgressControlJs2 = _interopRequireDefault(_progressControlProgressControlJs)
  4152. var _fullscreenToggleJs = _dereq_('./fullscreen-toggle.js')
  4153. var _fullscreenToggleJs2 = _interopRequireDefault(_fullscreenToggleJs)
  4154. var _volumeControlVolumeControlJs = _dereq_('./volume-control/volume-control.js')
  4155. var _volumeControlVolumeControlJs2 = _interopRequireDefault(_volumeControlVolumeControlJs)
  4156. var _volumeMenuButtonJs = _dereq_('./volume-menu-button.js')
  4157. var _volumeMenuButtonJs2 = _interopRequireDefault(_volumeMenuButtonJs)
  4158. var _muteToggleJs = _dereq_('./mute-toggle.js')
  4159. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs)
  4160. var _textTrackControlsChaptersButtonJs = _dereq_('./text-track-controls/chapters-button.js')
  4161. var _textTrackControlsChaptersButtonJs2 = _interopRequireDefault(_textTrackControlsChaptersButtonJs)
  4162. var _textTrackControlsDescriptionsButtonJs = _dereq_('./text-track-controls/descriptions-button.js')
  4163. var _textTrackControlsDescriptionsButtonJs2 = _interopRequireDefault(_textTrackControlsDescriptionsButtonJs)
  4164. var _textTrackControlsSubtitlesButtonJs = _dereq_('./text-track-controls/subtitles-button.js')
  4165. var _textTrackControlsSubtitlesButtonJs2 = _interopRequireDefault(_textTrackControlsSubtitlesButtonJs)
  4166. var _textTrackControlsCaptionsButtonJs = _dereq_('./text-track-controls/captions-button.js')
  4167. var _textTrackControlsCaptionsButtonJs2 = _interopRequireDefault(_textTrackControlsCaptionsButtonJs)
  4168. var _audioTrackControlsAudioTrackButtonJs = _dereq_('./audio-track-controls/audio-track-button.js')
  4169. var _audioTrackControlsAudioTrackButtonJs2 = _interopRequireDefault(_audioTrackControlsAudioTrackButtonJs)
  4170. var _playbackRateMenuPlaybackRateMenuButtonJs = _dereq_('./playback-rate-menu/playback-rate-menu-button.js')
  4171. var _playbackRateMenuPlaybackRateMenuButtonJs2 = _interopRequireDefault(_playbackRateMenuPlaybackRateMenuButtonJs)
  4172. var _spacerControlsCustomControlSpacerJs = _dereq_('./spacer-controls/custom-control-spacer.js')
  4173. var _spacerControlsCustomControlSpacerJs2 = _interopRequireDefault(_spacerControlsCustomControlSpacerJs)
  4174. /**
  4175. * Container of main controls
  4176. *
  4177. * @extends Component
  4178. * @class ControlBar
  4179. */
  4180. var ControlBar = (function(_Component) {
  4181. _inherits(ControlBar, _Component)
  4182. function ControlBar() {
  4183. _classCallCheck(this, ControlBar)
  4184. _Component.apply(this, arguments)
  4185. }
  4186. /**
  4187. * Create the component's DOM element
  4188. *
  4189. * @return {Element}
  4190. * @method createEl
  4191. */
  4192. ControlBar.prototype.createEl = function createEl() {
  4193. return _Component.prototype.createEl.call(this, 'div', {
  4194. className: 'vjs-control-bar',
  4195. dir: 'ltr'
  4196. }, {
  4197. 'role': 'group' // The control bar is a group, so it can contain menuitems
  4198. })
  4199. }
  4200. return ControlBar
  4201. })(_componentJs2['default'])
  4202. ControlBar.prototype.options_ = {
  4203. loadEvent: 'play',
  4204. children: ['playToggle', 'volumeMenuButton', 'currentTimeDisplay', 'timeDivider', 'durationDisplay', 'progressControl', 'liveDisplay', 'remainingTimeDisplay', 'customControlSpacer', 'playbackRateMenuButton', 'chaptersButton', 'descriptionsButton', 'subtitlesButton', 'captionsButton', 'audioTrackButton', 'fullscreenToggle']
  4205. }
  4206. _componentJs2['default'].registerComponent('ControlBar', ControlBar)
  4207. exports['default'] = ControlBar
  4208. module.exports = exports['default']
  4209. }, { '../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) {
  4210. /**
  4211. * @file fullscreen-toggle.js
  4212. */
  4213. 'use strict'
  4214. exports.__esModule = true
  4215. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4216. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4217. 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 }
  4218. var _buttonJs = _dereq_('../button.js')
  4219. var _buttonJs2 = _interopRequireDefault(_buttonJs)
  4220. var _componentJs = _dereq_('../component.js')
  4221. var _componentJs2 = _interopRequireDefault(_componentJs)
  4222. /**
  4223. * Toggle fullscreen video
  4224. *
  4225. * @extends Button
  4226. * @class FullscreenToggle
  4227. */
  4228. var FullscreenToggle = (function(_Button) {
  4229. _inherits(FullscreenToggle, _Button)
  4230. function FullscreenToggle() {
  4231. _classCallCheck(this, FullscreenToggle)
  4232. _Button.apply(this, arguments)
  4233. }
  4234. /**
  4235. * Allow sub components to stack CSS class names
  4236. *
  4237. * @return {String} The constructed class name
  4238. * @method buildCSSClass
  4239. */
  4240. FullscreenToggle.prototype.buildCSSClass = function buildCSSClass() {
  4241. return 'vjs-fullscreen-control ' + _Button.prototype.buildCSSClass.call(this)
  4242. }
  4243. /**
  4244. * Handles click for full screen
  4245. *
  4246. * @method handleClick
  4247. */
  4248. FullscreenToggle.prototype.handleClick = function handleClick() {
  4249. if (!this.player_.isFullscreen()) {
  4250. this.player_.requestFullscreen()
  4251. this.controlText('Non-Fullscreen')
  4252. } else {
  4253. this.player_.exitFullscreen()
  4254. this.controlText('Fullscreen')
  4255. }
  4256. }
  4257. return FullscreenToggle
  4258. })(_buttonJs2['default'])
  4259. FullscreenToggle.prototype.controlText_ = 'Fullscreen'
  4260. _componentJs2['default'].registerComponent('FullscreenToggle', FullscreenToggle)
  4261. exports['default'] = FullscreenToggle
  4262. module.exports = exports['default']
  4263. }, { '../button.js': 64, '../component.js': 67 }], 72: [function(_dereq_, module, exports) {
  4264. /**
  4265. * @file live-display.js
  4266. */
  4267. 'use strict'
  4268. exports.__esModule = true
  4269. 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 } }
  4270. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4271. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4272. 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 }
  4273. var _component = _dereq_('../component')
  4274. var _component2 = _interopRequireDefault(_component)
  4275. var _utilsDomJs = _dereq_('../utils/dom.js')
  4276. var Dom = _interopRequireWildcard(_utilsDomJs)
  4277. /**
  4278. * Displays the live indicator
  4279. * TODO - Future make it click to snap to live
  4280. *
  4281. * @extends Component
  4282. * @class LiveDisplay
  4283. */
  4284. var LiveDisplay = (function(_Component) {
  4285. _inherits(LiveDisplay, _Component)
  4286. function LiveDisplay(player, options) {
  4287. _classCallCheck(this, LiveDisplay)
  4288. _Component.call(this, player, options)
  4289. this.updateShowing()
  4290. this.on(this.player(), 'durationchange', this.updateShowing)
  4291. }
  4292. /**
  4293. * Create the component's DOM element
  4294. *
  4295. * @return {Element}
  4296. * @method createEl
  4297. */
  4298. LiveDisplay.prototype.createEl = function createEl() {
  4299. var el = _Component.prototype.createEl.call(this, 'div', {
  4300. className: 'vjs-live-control vjs-control'
  4301. })
  4302. this.contentEl_ = Dom.createEl('div', {
  4303. className: 'vjs-live-display',
  4304. innerHTML: '<span class="vjs-control-text">' + this.localize('Stream Type') + '</span>' + this.localize('直播中')
  4305. }, {
  4306. 'aria-live': 'off'
  4307. })
  4308. el.appendChild(this.contentEl_)
  4309. return el
  4310. }
  4311. LiveDisplay.prototype.updateShowing = function updateShowing() {
  4312. if (this.player().duration() === Infinity) {
  4313. this.show()
  4314. } else {
  4315. this.hide()
  4316. }
  4317. }
  4318. return LiveDisplay
  4319. })(_component2['default'])
  4320. _component2['default'].registerComponent('LiveDisplay', LiveDisplay)
  4321. exports['default'] = LiveDisplay
  4322. module.exports = exports['default']
  4323. }, { '../component': 67, '../utils/dom.js': 143 }], 73: [function(_dereq_, module, exports) {
  4324. /**
  4325. * @file mute-toggle.js
  4326. */
  4327. 'use strict'
  4328. exports.__esModule = true
  4329. 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 } }
  4330. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4331. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4332. 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 }
  4333. var _button = _dereq_('../button')
  4334. var _button2 = _interopRequireDefault(_button)
  4335. var _component = _dereq_('../component')
  4336. var _component2 = _interopRequireDefault(_component)
  4337. var _utilsDomJs = _dereq_('../utils/dom.js')
  4338. var Dom = _interopRequireWildcard(_utilsDomJs)
  4339. /**
  4340. * A button component for muting the audio
  4341. *
  4342. * @param {Player|Object} player
  4343. * @param {Object=} options
  4344. * @extends Button
  4345. * @class MuteToggle
  4346. */
  4347. var MuteToggle = (function(_Button) {
  4348. _inherits(MuteToggle, _Button)
  4349. function MuteToggle(player, options) {
  4350. _classCallCheck(this, MuteToggle)
  4351. _Button.call(this, player, options)
  4352. this.on(player, 'volumechange', this.update)
  4353. // hide mute toggle if the current tech doesn't support volume control
  4354. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  4355. this.addClass('vjs-hidden')
  4356. }
  4357. this.on(player, 'loadstart', function() {
  4358. this.update() // We need to update the button to account for a default muted state.
  4359. if (player.tech_['featuresVolumeControl'] === false) {
  4360. this.addClass('vjs-hidden')
  4361. } else {
  4362. this.removeClass('vjs-hidden')
  4363. }
  4364. })
  4365. }
  4366. /**
  4367. * Allow sub components to stack CSS class names
  4368. *
  4369. * @return {String} The constructed class name
  4370. * @method buildCSSClass
  4371. */
  4372. MuteToggle.prototype.buildCSSClass = function buildCSSClass() {
  4373. return 'vjs-mute-control ' + _Button.prototype.buildCSSClass.call(this)
  4374. }
  4375. /**
  4376. * Handle click on mute
  4377. *
  4378. * @method handleClick
  4379. */
  4380. MuteToggle.prototype.handleClick = function handleClick() {
  4381. this.player_.muted(!this.player_.muted())
  4382. }
  4383. /**
  4384. * Update volume
  4385. *
  4386. * @method update
  4387. */
  4388. MuteToggle.prototype.update = function update() {
  4389. var vol = this.player_.volume()
  4390. var level = 3
  4391. if (vol === 0 || this.player_.muted()) {
  4392. level = 0
  4393. } else if (vol < 0.33) {
  4394. level = 1
  4395. } else if (vol < 0.67) {
  4396. level = 2
  4397. }
  4398. // Don't rewrite the button text if the actual text doesn't change.
  4399. // This causes unnecessary and confusing information for screen reader users.
  4400. // This check is needed because this function gets called every time the volume level is changed.
  4401. var toMute = this.player_.muted() ? 'Unmute' : 'Mute'
  4402. if (this.controlText() !== toMute) {
  4403. this.controlText(toMute)
  4404. }
  4405. /* TODO improve muted icon classes */
  4406. for (var i = 0; i < 4; i++) {
  4407. Dom.removeElClass(this.el_, 'vjs-vol-' + i)
  4408. }
  4409. Dom.addElClass(this.el_, 'vjs-vol-' + level)
  4410. }
  4411. return MuteToggle
  4412. })(_button2['default'])
  4413. MuteToggle.prototype.controlText_ = 'Mute'
  4414. _component2['default'].registerComponent('MuteToggle', MuteToggle)
  4415. exports['default'] = MuteToggle
  4416. module.exports = exports['default']
  4417. }, { '../button': 64, '../component': 67, '../utils/dom.js': 143 }], 74: [function(_dereq_, module, exports) {
  4418. /**
  4419. * @file play-toggle.js
  4420. */
  4421. 'use strict'
  4422. exports.__esModule = true
  4423. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4424. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4425. 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 }
  4426. var _buttonJs = _dereq_('../button.js')
  4427. var _buttonJs2 = _interopRequireDefault(_buttonJs)
  4428. var _componentJs = _dereq_('../component.js')
  4429. var _componentJs2 = _interopRequireDefault(_componentJs)
  4430. /**
  4431. * Button to toggle between play and pause
  4432. *
  4433. * @param {Player|Object} player
  4434. * @param {Object=} options
  4435. * @extends Button
  4436. * @class PlayToggle
  4437. */
  4438. var PlayToggle = (function(_Button) {
  4439. _inherits(PlayToggle, _Button)
  4440. function PlayToggle(player, options) {
  4441. _classCallCheck(this, PlayToggle)
  4442. _Button.call(this, player, options)
  4443. this.on(player, 'play', this.handlePlay)
  4444. this.on(player, 'pause', this.handlePause)
  4445. }
  4446. /**
  4447. * Allow sub components to stack CSS class names
  4448. *
  4449. * @return {String} The constructed class name
  4450. * @method buildCSSClass
  4451. */
  4452. PlayToggle.prototype.buildCSSClass = function buildCSSClass() {
  4453. return 'vjs-play-control ' + _Button.prototype.buildCSSClass.call(this)
  4454. }
  4455. /**
  4456. * Handle click to toggle between play and pause
  4457. *
  4458. * @method handleClick
  4459. */
  4460. PlayToggle.prototype.handleClick = function handleClick() {
  4461. if (this.player_.paused()) {
  4462. this.player_.play()
  4463. } else {
  4464. this.player_.pause()
  4465. }
  4466. }
  4467. /**
  4468. * Add the vjs-playing class to the element so it can change appearance
  4469. *
  4470. * @method handlePlay
  4471. */
  4472. PlayToggle.prototype.handlePlay = function handlePlay() {
  4473. this.removeClass('vjs-paused')
  4474. this.addClass('vjs-playing')
  4475. this.controlText('Pause') // change the button text to "Pause"
  4476. }
  4477. /**
  4478. * Add the vjs-paused class to the element so it can change appearance
  4479. *
  4480. * @method handlePause
  4481. */
  4482. PlayToggle.prototype.handlePause = function handlePause() {
  4483. this.removeClass('vjs-playing')
  4484. this.addClass('vjs-paused')
  4485. this.controlText('Play') // change the button text to "Play"
  4486. }
  4487. return PlayToggle
  4488. })(_buttonJs2['default'])
  4489. PlayToggle.prototype.controlText_ = 'Play'
  4490. _componentJs2['default'].registerComponent('PlayToggle', PlayToggle)
  4491. exports['default'] = PlayToggle
  4492. module.exports = exports['default']
  4493. }, { '../button.js': 64, '../component.js': 67 }], 75: [function(_dereq_, module, exports) {
  4494. /**
  4495. * @file playback-rate-menu-button.js
  4496. */
  4497. 'use strict'
  4498. exports.__esModule = true
  4499. 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 } }
  4500. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4501. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4502. 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 }
  4503. var _menuMenuButtonJs = _dereq_('../../menu/menu-button.js')
  4504. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs)
  4505. var _menuMenuJs = _dereq_('../../menu/menu.js')
  4506. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs)
  4507. var _playbackRateMenuItemJs = _dereq_('./playback-rate-menu-item.js')
  4508. var _playbackRateMenuItemJs2 = _interopRequireDefault(_playbackRateMenuItemJs)
  4509. var _componentJs = _dereq_('../../component.js')
  4510. var _componentJs2 = _interopRequireDefault(_componentJs)
  4511. var _utilsDomJs = _dereq_('../../utils/dom.js')
  4512. var Dom = _interopRequireWildcard(_utilsDomJs)
  4513. /**
  4514. * The component for controlling the playback rate
  4515. *
  4516. * @param {Player|Object} player
  4517. * @param {Object=} options
  4518. * @extends MenuButton
  4519. * @class PlaybackRateMenuButton
  4520. */
  4521. var PlaybackRateMenuButton = (function(_MenuButton) {
  4522. _inherits(PlaybackRateMenuButton, _MenuButton)
  4523. function PlaybackRateMenuButton(player, options) {
  4524. _classCallCheck(this, PlaybackRateMenuButton)
  4525. _MenuButton.call(this, player, options)
  4526. this.updateVisibility()
  4527. this.updateLabel()
  4528. this.on(player, 'loadstart', this.updateVisibility)
  4529. this.on(player, 'ratechange', this.updateLabel)
  4530. }
  4531. /**
  4532. * Create the component's DOM element
  4533. *
  4534. * @return {Element}
  4535. * @method createEl
  4536. */
  4537. PlaybackRateMenuButton.prototype.createEl = function createEl() {
  4538. var el = _MenuButton.prototype.createEl.call(this)
  4539. this.labelEl_ = Dom.createEl('div', {
  4540. className: 'vjs-playback-rate-value',
  4541. innerHTML: 1.0
  4542. })
  4543. el.appendChild(this.labelEl_)
  4544. return el
  4545. }
  4546. /**
  4547. * Allow sub components to stack CSS class names
  4548. *
  4549. * @return {String} The constructed class name
  4550. * @method buildCSSClass
  4551. */
  4552. PlaybackRateMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  4553. return 'vjs-playback-rate ' + _MenuButton.prototype.buildCSSClass.call(this)
  4554. }
  4555. /**
  4556. * Create the playback rate menu
  4557. *
  4558. * @return {Menu} Menu object populated with items
  4559. * @method createMenu
  4560. */
  4561. PlaybackRateMenuButton.prototype.createMenu = function createMenu() {
  4562. var menu = new _menuMenuJs2['default'](this.player())
  4563. var rates = this.playbackRates()
  4564. if (rates) {
  4565. for (var i = rates.length - 1; i >= 0; i--) {
  4566. menu.addChild(new _playbackRateMenuItemJs2['default'](this.player(), { 'rate': rates[i] + 'x' }))
  4567. }
  4568. }
  4569. return menu
  4570. }
  4571. /**
  4572. * Updates ARIA accessibility attributes
  4573. *
  4574. * @method updateARIAAttributes
  4575. */
  4576. PlaybackRateMenuButton.prototype.updateARIAAttributes = function updateARIAAttributes() {
  4577. // Current playback rate
  4578. this.el().setAttribute('aria-valuenow', this.player().playbackRate())
  4579. }
  4580. /**
  4581. * Handle menu item click
  4582. *
  4583. * @method handleClick
  4584. */
  4585. PlaybackRateMenuButton.prototype.handleClick = function handleClick() {
  4586. // select next rate option
  4587. var currentRate = this.player().playbackRate()
  4588. var rates = this.playbackRates()
  4589. // this will select first one if the last one currently selected
  4590. var newRate = rates[0]
  4591. for (var i = 0; i < rates.length; i++) {
  4592. if (rates[i] > currentRate) {
  4593. newRate = rates[i]
  4594. break
  4595. }
  4596. }
  4597. this.player().playbackRate(newRate)
  4598. }
  4599. /**
  4600. * Get possible playback rates
  4601. *
  4602. * @return {Array} Possible playback rates
  4603. * @method playbackRates
  4604. */
  4605. PlaybackRateMenuButton.prototype.playbackRates = function playbackRates() {
  4606. return this.options_['playbackRates'] || this.options_.playerOptions && this.options_.playerOptions['playbackRates']
  4607. }
  4608. /**
  4609. * Get whether playback rates is supported by the tech
  4610. * and an array of playback rates exists
  4611. *
  4612. * @return {Boolean} Whether changing playback rate is supported
  4613. * @method playbackRateSupported
  4614. */
  4615. PlaybackRateMenuButton.prototype.playbackRateSupported = function playbackRateSupported() {
  4616. return this.player().tech_ && this.player().tech_['featuresPlaybackRate'] && this.playbackRates() && this.playbackRates().length > 0
  4617. }
  4618. /**
  4619. * Hide playback rate controls when they're no playback rate options to select
  4620. *
  4621. * @method updateVisibility
  4622. */
  4623. PlaybackRateMenuButton.prototype.updateVisibility = function updateVisibility() {
  4624. if (this.playbackRateSupported()) {
  4625. this.removeClass('vjs-hidden')
  4626. } else {
  4627. this.addClass('vjs-hidden')
  4628. }
  4629. }
  4630. /**
  4631. * Update button label when rate changed
  4632. *
  4633. * @method updateLabel
  4634. */
  4635. PlaybackRateMenuButton.prototype.updateLabel = function updateLabel() {
  4636. if (this.playbackRateSupported()) {
  4637. this.labelEl_.innerHTML = this.player().playbackRate() + 'x'
  4638. }
  4639. }
  4640. return PlaybackRateMenuButton
  4641. })(_menuMenuButtonJs2['default'])
  4642. PlaybackRateMenuButton.prototype.controlText_ = 'Playback Rate'
  4643. _componentJs2['default'].registerComponent('PlaybackRateMenuButton', PlaybackRateMenuButton)
  4644. exports['default'] = PlaybackRateMenuButton
  4645. module.exports = exports['default']
  4646. }, { '../../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) {
  4647. /**
  4648. * @file playback-rate-menu-item.js
  4649. */
  4650. 'use strict'
  4651. exports.__esModule = true
  4652. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4653. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4654. 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 }
  4655. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js')
  4656. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs)
  4657. var _componentJs = _dereq_('../../component.js')
  4658. var _componentJs2 = _interopRequireDefault(_componentJs)
  4659. /**
  4660. * The specific menu item type for selecting a playback rate
  4661. *
  4662. * @param {Player|Object} player
  4663. * @param {Object=} options
  4664. * @extends MenuItem
  4665. * @class PlaybackRateMenuItem
  4666. */
  4667. var PlaybackRateMenuItem = (function(_MenuItem) {
  4668. _inherits(PlaybackRateMenuItem, _MenuItem)
  4669. function PlaybackRateMenuItem(player, options) {
  4670. _classCallCheck(this, PlaybackRateMenuItem)
  4671. var label = options['rate']
  4672. var rate = parseFloat(label, 10)
  4673. // Modify options for parent MenuItem class's init.
  4674. options['label'] = label
  4675. options['selected'] = rate === 1
  4676. _MenuItem.call(this, player, options)
  4677. this.label = label
  4678. this.rate = rate
  4679. this.on(player, 'ratechange', this.update)
  4680. }
  4681. /**
  4682. * Handle click on menu item
  4683. *
  4684. * @method handleClick
  4685. */
  4686. PlaybackRateMenuItem.prototype.handleClick = function handleClick() {
  4687. _MenuItem.prototype.handleClick.call(this)
  4688. this.player().playbackRate(this.rate)
  4689. }
  4690. /**
  4691. * Update playback rate with selected rate
  4692. *
  4693. * @method update
  4694. */
  4695. PlaybackRateMenuItem.prototype.update = function update() {
  4696. this.selected(this.player().playbackRate() === this.rate)
  4697. }
  4698. return PlaybackRateMenuItem
  4699. })(_menuMenuItemJs2['default'])
  4700. PlaybackRateMenuItem.prototype.contentElType = 'button'
  4701. _componentJs2['default'].registerComponent('PlaybackRateMenuItem', PlaybackRateMenuItem)
  4702. exports['default'] = PlaybackRateMenuItem
  4703. module.exports = exports['default']
  4704. }, { '../../component.js': 67, '../../menu/menu-item.js': 110 }], 77: [function(_dereq_, module, exports) {
  4705. /**
  4706. * @file load-progress-bar.js
  4707. */
  4708. 'use strict'
  4709. exports.__esModule = true
  4710. 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 } }
  4711. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4712. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4713. 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 }
  4714. var _componentJs = _dereq_('../../component.js')
  4715. var _componentJs2 = _interopRequireDefault(_componentJs)
  4716. var _utilsDomJs = _dereq_('../../utils/dom.js')
  4717. var Dom = _interopRequireWildcard(_utilsDomJs)
  4718. /**
  4719. * Shows load progress
  4720. *
  4721. * @param {Player|Object} player
  4722. * @param {Object=} options
  4723. * @extends Component
  4724. * @class LoadProgressBar
  4725. */
  4726. var LoadProgressBar = (function(_Component) {
  4727. _inherits(LoadProgressBar, _Component)
  4728. function LoadProgressBar(player, options) {
  4729. _classCallCheck(this, LoadProgressBar)
  4730. _Component.call(this, player, options)
  4731. this.on(player, 'progress', this.update)
  4732. }
  4733. /**
  4734. * Create the component's DOM element
  4735. *
  4736. * @return {Element}
  4737. * @method createEl
  4738. */
  4739. LoadProgressBar.prototype.createEl = function createEl() {
  4740. return _Component.prototype.createEl.call(this, 'div', {
  4741. className: 'vjs-load-progress',
  4742. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Loaded') + '</span>: 0%</span>'
  4743. })
  4744. }
  4745. /**
  4746. * Update progress bar
  4747. *
  4748. * @method update
  4749. */
  4750. LoadProgressBar.prototype.update = function update() {
  4751. var buffered = this.player_.buffered()
  4752. var duration = this.player_.duration()
  4753. var bufferedEnd = this.player_.bufferedEnd()
  4754. var children = this.el_.children
  4755. // get the percent width of a time compared to the total end
  4756. var percentify = function percentify(time, end) {
  4757. var percent = time / end || 0 // no NaN
  4758. return (percent >= 1 ? 1 : percent) * 100 + '%'
  4759. }
  4760. // update the width of the progress bar
  4761. this.el_.style.width = percentify(bufferedEnd, duration)
  4762. // add child elements to represent the individual buffered time ranges
  4763. for (var i = 0; i < buffered.length; i++) {
  4764. var start = buffered.start(i)
  4765. var end = buffered.end(i)
  4766. var part = children[i]
  4767. if (!part) {
  4768. part = this.el_.appendChild(Dom.createEl())
  4769. }
  4770. // set the percent based on the width of the progress bar (bufferedEnd)
  4771. part.style.left = percentify(start, bufferedEnd)
  4772. part.style.width = percentify(end - start, bufferedEnd)
  4773. }
  4774. // remove unused buffered range elements
  4775. for (var i = children.length; i > buffered.length; i--) {
  4776. this.el_.removeChild(children[i - 1])
  4777. }
  4778. }
  4779. return LoadProgressBar
  4780. })(_componentJs2['default'])
  4781. _componentJs2['default'].registerComponent('LoadProgressBar', LoadProgressBar)
  4782. exports['default'] = LoadProgressBar
  4783. module.exports = exports['default']
  4784. }, { '../../component.js': 67, '../../utils/dom.js': 143 }], 78: [function(_dereq_, module, exports) {
  4785. /**
  4786. * @file mouse-time-display.js
  4787. */
  4788. 'use strict'
  4789. exports.__esModule = true
  4790. 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 } }
  4791. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4792. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4793. 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 }
  4794. var _globalWindow = _dereq_('global/window')
  4795. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  4796. var _componentJs = _dereq_('../../component.js')
  4797. var _componentJs2 = _interopRequireDefault(_componentJs)
  4798. var _utilsDomJs = _dereq_('../../utils/dom.js')
  4799. var Dom = _interopRequireWildcard(_utilsDomJs)
  4800. var _utilsFnJs = _dereq_('../../utils/fn.js')
  4801. var Fn = _interopRequireWildcard(_utilsFnJs)
  4802. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js')
  4803. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  4804. var _lodashCompatFunctionThrottle = _dereq_('lodash-compat/function/throttle')
  4805. var _lodashCompatFunctionThrottle2 = _interopRequireDefault(_lodashCompatFunctionThrottle)
  4806. /**
  4807. * The Mouse Time Display component shows the time you will seek to
  4808. * when hovering over the progress bar
  4809. *
  4810. * @param {Player|Object} player
  4811. * @param {Object=} options
  4812. * @extends Component
  4813. * @class MouseTimeDisplay
  4814. */
  4815. var MouseTimeDisplay = (function(_Component) {
  4816. _inherits(MouseTimeDisplay, _Component)
  4817. function MouseTimeDisplay(player, options) {
  4818. var _this = this
  4819. _classCallCheck(this, MouseTimeDisplay)
  4820. _Component.call(this, player, options)
  4821. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  4822. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside
  4823. }
  4824. if (this.keepTooltipsInside) {
  4825. this.tooltip = Dom.createEl('div', { className: 'vjs-time-tooltip' })
  4826. this.el().appendChild(this.tooltip)
  4827. this.addClass('vjs-keep-tooltips-inside')
  4828. }
  4829. this.update(0, 0)
  4830. player.on('ready', function() {
  4831. _this.on(player.controlBar.progressControl.el(), 'mousemove', _lodashCompatFunctionThrottle2['default'](Fn.bind(_this, _this.handleMouseMove), 25))
  4832. })
  4833. }
  4834. /**
  4835. * Create the component's DOM element
  4836. *
  4837. * @return {Element}
  4838. * @method createEl
  4839. */
  4840. MouseTimeDisplay.prototype.createEl = function createEl() {
  4841. return _Component.prototype.createEl.call(this, 'div', {
  4842. className: 'vjs-mouse-display'
  4843. })
  4844. }
  4845. MouseTimeDisplay.prototype.handleMouseMove = function handleMouseMove(event) {
  4846. var duration = this.player_.duration()
  4847. var newTime = this.calculateDistance(event) * duration
  4848. var position = event.pageX - Dom.findElPosition(this.el().parentNode).left
  4849. this.update(newTime, position)
  4850. }
  4851. MouseTimeDisplay.prototype.update = function update(newTime, position) {
  4852. var time = _utilsFormatTimeJs2['default'](newTime, this.player_.duration())
  4853. this.el().style.left = position + 'px'
  4854. this.el().setAttribute('data-current-time', time)
  4855. if (this.keepTooltipsInside) {
  4856. var clampedPosition = this.clampPosition_(position)
  4857. var difference = position - clampedPosition + 1
  4858. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltip).width)
  4859. var tooltipWidthHalf = tooltipWidth / 2
  4860. this.tooltip.innerHTML = time
  4861. this.tooltip.style.right = '-' + (tooltipWidthHalf - difference) + 'px'
  4862. }
  4863. }
  4864. MouseTimeDisplay.prototype.calculateDistance = function calculateDistance(event) {
  4865. return Dom.getPointerPosition(this.el().parentNode, event).x
  4866. }
  4867. /**
  4868. * This takes in a horizontal position for the bar and returns a clamped position.
  4869. * Clamped position means that it will keep the position greater than half the width
  4870. * of the tooltip and smaller than the player width minus half the width o the tooltip.
  4871. * It will only clamp the position if `keepTooltipsInside` option is set.
  4872. *
  4873. * @param {Number} position the position the bar wants to be
  4874. * @return {Number} newPosition the (potentially) clamped position
  4875. * @method clampPosition_
  4876. */
  4877. MouseTimeDisplay.prototype.clampPosition_ = function clampPosition_(position) {
  4878. if (!this.keepTooltipsInside) {
  4879. return position
  4880. }
  4881. var playerWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.player().el()).width)
  4882. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltip).width)
  4883. var tooltipWidthHalf = tooltipWidth / 2
  4884. var actualPosition = position
  4885. if (position < tooltipWidthHalf) {
  4886. actualPosition = Math.ceil(tooltipWidthHalf)
  4887. } else if (position > playerWidth - tooltipWidthHalf) {
  4888. actualPosition = Math.floor(playerWidth - tooltipWidthHalf)
  4889. }
  4890. return actualPosition
  4891. }
  4892. return MouseTimeDisplay
  4893. })(_componentJs2['default'])
  4894. _componentJs2['default'].registerComponent('MouseTimeDisplay', MouseTimeDisplay)
  4895. exports['default'] = MouseTimeDisplay
  4896. module.exports = exports['default']
  4897. }, { '../../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) {
  4898. /**
  4899. * @file play-progress-bar.js
  4900. */
  4901. 'use strict'
  4902. exports.__esModule = true
  4903. 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 } }
  4904. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4905. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4906. 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 }
  4907. var _componentJs = _dereq_('../../component.js')
  4908. var _componentJs2 = _interopRequireDefault(_componentJs)
  4909. var _utilsFnJs = _dereq_('../../utils/fn.js')
  4910. var Fn = _interopRequireWildcard(_utilsFnJs)
  4911. var _utilsDomJs = _dereq_('../../utils/dom.js')
  4912. var Dom = _interopRequireWildcard(_utilsDomJs)
  4913. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js')
  4914. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  4915. /**
  4916. * Shows play progress
  4917. *
  4918. * @param {Player|Object} player
  4919. * @param {Object=} options
  4920. * @extends Component
  4921. * @class PlayProgressBar
  4922. */
  4923. var PlayProgressBar = (function(_Component) {
  4924. _inherits(PlayProgressBar, _Component)
  4925. function PlayProgressBar(player, options) {
  4926. _classCallCheck(this, PlayProgressBar)
  4927. _Component.call(this, player, options)
  4928. this.updateDataAttr()
  4929. this.on(player, 'timeupdate', this.updateDataAttr)
  4930. player.ready(Fn.bind(this, this.updateDataAttr))
  4931. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  4932. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside
  4933. }
  4934. if (this.keepTooltipsInside) {
  4935. this.addClass('vjs-keep-tooltips-inside')
  4936. }
  4937. }
  4938. /**
  4939. * Create the component's DOM element
  4940. *
  4941. * @return {Element}
  4942. * @method createEl
  4943. */
  4944. PlayProgressBar.prototype.createEl = function createEl() {
  4945. return _Component.prototype.createEl.call(this, 'div', {
  4946. className: 'vjs-play-progress vjs-slider-bar',
  4947. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
  4948. })
  4949. }
  4950. PlayProgressBar.prototype.updateDataAttr = function updateDataAttr() {
  4951. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime()
  4952. this.el_.setAttribute('data-current-time', _utilsFormatTimeJs2['default'](time, this.player_.duration()))
  4953. }
  4954. return PlayProgressBar
  4955. })(_componentJs2['default'])
  4956. _componentJs2['default'].registerComponent('PlayProgressBar', PlayProgressBar)
  4957. exports['default'] = PlayProgressBar
  4958. module.exports = exports['default']
  4959. }, { '../../component.js': 67, '../../utils/dom.js': 143, '../../utils/fn.js': 145, '../../utils/format-time.js': 146 }], 80: [function(_dereq_, module, exports) {
  4960. /**
  4961. * @file progress-control.js
  4962. */
  4963. 'use strict'
  4964. exports.__esModule = true
  4965. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  4966. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  4967. 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 }
  4968. var _componentJs = _dereq_('../../component.js')
  4969. var _componentJs2 = _interopRequireDefault(_componentJs)
  4970. var _seekBarJs = _dereq_('./seek-bar.js')
  4971. var _seekBarJs2 = _interopRequireDefault(_seekBarJs)
  4972. var _mouseTimeDisplayJs = _dereq_('./mouse-time-display.js')
  4973. var _mouseTimeDisplayJs2 = _interopRequireDefault(_mouseTimeDisplayJs)
  4974. /**
  4975. * The Progress Control component contains the seek bar, load progress,
  4976. * and play progress
  4977. *
  4978. * @param {Player|Object} player
  4979. * @param {Object=} options
  4980. * @extends Component
  4981. * @class ProgressControl
  4982. */
  4983. var ProgressControl = (function(_Component) {
  4984. _inherits(ProgressControl, _Component)
  4985. function ProgressControl() {
  4986. _classCallCheck(this, ProgressControl)
  4987. _Component.apply(this, arguments)
  4988. }
  4989. /**
  4990. * Create the component's DOM element
  4991. *
  4992. * @return {Element}
  4993. * @method createEl
  4994. */
  4995. ProgressControl.prototype.createEl = function createEl() {
  4996. return _Component.prototype.createEl.call(this, 'div', {
  4997. className: 'vjs-progress-control vjs-control'
  4998. })
  4999. }
  5000. return ProgressControl
  5001. })(_componentJs2['default'])
  5002. ProgressControl.prototype.options_ = {
  5003. children: ['seekBar']
  5004. }
  5005. _componentJs2['default'].registerComponent('ProgressControl', ProgressControl)
  5006. exports['default'] = ProgressControl
  5007. module.exports = exports['default']
  5008. }, { '../../component.js': 67, './mouse-time-display.js': 78, './seek-bar.js': 81 }], 81: [function(_dereq_, module, exports) {
  5009. /**
  5010. * @file seek-bar.js
  5011. */
  5012. 'use strict'
  5013. exports.__esModule = true
  5014. 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 } }
  5015. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5016. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5017. 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 }
  5018. var _globalWindow = _dereq_('global/window')
  5019. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  5020. var _sliderSliderJs = _dereq_('../../slider/slider.js')
  5021. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs)
  5022. var _componentJs = _dereq_('../../component.js')
  5023. var _componentJs2 = _interopRequireDefault(_componentJs)
  5024. var _loadProgressBarJs = _dereq_('./load-progress-bar.js')
  5025. var _loadProgressBarJs2 = _interopRequireDefault(_loadProgressBarJs)
  5026. var _playProgressBarJs = _dereq_('./play-progress-bar.js')
  5027. var _playProgressBarJs2 = _interopRequireDefault(_playProgressBarJs)
  5028. var _tooltipProgressBarJs = _dereq_('./tooltip-progress-bar.js')
  5029. var _tooltipProgressBarJs2 = _interopRequireDefault(_tooltipProgressBarJs)
  5030. var _utilsFnJs = _dereq_('../../utils/fn.js')
  5031. var Fn = _interopRequireWildcard(_utilsFnJs)
  5032. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js')
  5033. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  5034. var _objectAssign = _dereq_('object.assign')
  5035. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  5036. /**
  5037. * Seek Bar and holder for the progress bars
  5038. *
  5039. * @param {Player|Object} player
  5040. * @param {Object=} options
  5041. * @extends Slider
  5042. * @class SeekBar
  5043. */
  5044. var SeekBar = (function(_Slider) {
  5045. _inherits(SeekBar, _Slider)
  5046. function SeekBar(player, options) {
  5047. _classCallCheck(this, SeekBar)
  5048. _Slider.call(this, player, options)
  5049. this.on(player, 'timeupdate', this.updateProgress)
  5050. this.on(player, 'ended', this.updateProgress)
  5051. player.ready(Fn.bind(this, this.updateProgress))
  5052. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  5053. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside
  5054. }
  5055. if (this.keepTooltipsInside) {
  5056. this.tooltipProgressBar = this.addChild('TooltipProgressBar')
  5057. }
  5058. }
  5059. /**
  5060. * Create the component's DOM element
  5061. *
  5062. * @return {Element}
  5063. * @method createEl
  5064. */
  5065. SeekBar.prototype.createEl = function createEl() {
  5066. return _Slider.prototype.createEl.call(this, 'div', {
  5067. className: 'vjs-progress-holder'
  5068. }, {
  5069. 'aria-label': 'progress bar'
  5070. })
  5071. }
  5072. /**
  5073. * Update ARIA accessibility attributes
  5074. *
  5075. * @method updateARIAAttributes
  5076. */
  5077. SeekBar.prototype.updateProgress = function updateProgress() {
  5078. this.updateAriaAttributes(this.el_)
  5079. if (this.keepTooltipsInside) {
  5080. this.updateAriaAttributes(this.tooltipProgressBar.el_)
  5081. this.tooltipProgressBar.el_.style.width = this.bar.el_.style.width
  5082. var playerWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.player().el()).width)
  5083. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltipProgressBar.tooltip).width)
  5084. var tooltipStyle = this.tooltipProgressBar.el().style
  5085. tooltipStyle.maxWidth = Math.floor(playerWidth - tooltipWidth / 2) + 'px'
  5086. tooltipStyle.minWidth = Math.ceil(tooltipWidth / 2) + 'px'
  5087. tooltipStyle.right = '-' + tooltipWidth / 2 + 'px'
  5088. }
  5089. }
  5090. SeekBar.prototype.updateAriaAttributes = function updateAriaAttributes(el) {
  5091. // Allows for smooth scrubbing, when player can't keep up.
  5092. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime()
  5093. el.setAttribute('aria-valuenow', (this.getPercent() * 100).toFixed(2)) // machine readable value of progress bar (percentage complete)
  5094. el.setAttribute('aria-valuetext', _utilsFormatTimeJs2['default'](time, this.player_.duration())) // human readable value of progress bar (time complete)
  5095. }
  5096. /**
  5097. * Get percentage of video played
  5098. *
  5099. * @return {Number} Percentage played
  5100. * @method getPercent
  5101. */
  5102. SeekBar.prototype.getPercent = function getPercent() {
  5103. var percent = this.player_.currentTime() / this.player_.duration()
  5104. return percent >= 1 ? 1 : percent
  5105. }
  5106. /**
  5107. * Handle mouse down on seek bar
  5108. *
  5109. * @method handleMouseDown
  5110. */
  5111. SeekBar.prototype.handleMouseDown = function handleMouseDown(event) {
  5112. _Slider.prototype.handleMouseDown.call(this, event)
  5113. this.player_.scrubbing(true)
  5114. this.videoWasPlaying = !this.player_.paused()
  5115. this.player_.pause()
  5116. }
  5117. /**
  5118. * Handle mouse move on seek bar
  5119. *
  5120. * @method handleMouseMove
  5121. */
  5122. SeekBar.prototype.handleMouseMove = function handleMouseMove(event) {
  5123. var newTime = this.calculateDistance(event) * this.player_.duration()
  5124. // Don't let video end while scrubbing.
  5125. if (newTime === this.player_.duration()) {
  5126. newTime = newTime - 0.1
  5127. }
  5128. // Set new time (tell player to seek to new time)
  5129. this.player_.currentTime(newTime)
  5130. }
  5131. /**
  5132. * Handle mouse up on seek bar
  5133. *
  5134. * @method handleMouseUp
  5135. */
  5136. SeekBar.prototype.handleMouseUp = function handleMouseUp(event) {
  5137. _Slider.prototype.handleMouseUp.call(this, event)
  5138. this.player_.scrubbing(false)
  5139. if (this.videoWasPlaying) {
  5140. this.player_.play()
  5141. }
  5142. }
  5143. /**
  5144. * Move more quickly fast forward for keyboard-only users
  5145. *
  5146. * @method stepForward
  5147. */
  5148. SeekBar.prototype.stepForward = function stepForward() {
  5149. this.player_.currentTime(this.player_.currentTime() + 5) // more quickly fast forward for keyboard-only users
  5150. }
  5151. /**
  5152. * Move more quickly rewind for keyboard-only users
  5153. *
  5154. * @method stepBack
  5155. */
  5156. SeekBar.prototype.stepBack = function stepBack() {
  5157. this.player_.currentTime(this.player_.currentTime() - 5) // more quickly rewind for keyboard-only users
  5158. }
  5159. return SeekBar
  5160. })(_sliderSliderJs2['default'])
  5161. SeekBar.prototype.options_ = {
  5162. children: ['loadProgressBar', 'mouseTimeDisplay', 'playProgressBar'],
  5163. 'barName': 'playProgressBar'
  5164. }
  5165. SeekBar.prototype.playerEvent = 'timeupdate'
  5166. _componentJs2['default'].registerComponent('SeekBar', SeekBar)
  5167. exports['default'] = SeekBar
  5168. module.exports = exports['default']
  5169. }, { '../../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) {
  5170. /**
  5171. * @file play-progress-bar.js
  5172. */
  5173. 'use strict'
  5174. exports.__esModule = true
  5175. 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 } }
  5176. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5177. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5178. 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 }
  5179. var _componentJs = _dereq_('../../component.js')
  5180. var _componentJs2 = _interopRequireDefault(_componentJs)
  5181. var _utilsFnJs = _dereq_('../../utils/fn.js')
  5182. var Fn = _interopRequireWildcard(_utilsFnJs)
  5183. var _utilsDomJs = _dereq_('../../utils/dom.js')
  5184. var Dom = _interopRequireWildcard(_utilsDomJs)
  5185. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js')
  5186. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  5187. /**
  5188. * Shows play progress
  5189. *
  5190. * @param {Player|Object} player
  5191. * @param {Object=} options
  5192. * @extends Component
  5193. * @class PlayProgressBar
  5194. */
  5195. var TooltipProgressBar = (function(_Component) {
  5196. _inherits(TooltipProgressBar, _Component)
  5197. function TooltipProgressBar(player, options) {
  5198. _classCallCheck(this, TooltipProgressBar)
  5199. _Component.call(this, player, options)
  5200. this.updateDataAttr()
  5201. this.on(player, 'timeupdate', this.updateDataAttr)
  5202. player.ready(Fn.bind(this, this.updateDataAttr))
  5203. }
  5204. /**
  5205. * Create the component's DOM element
  5206. *
  5207. * @return {Element}
  5208. * @method createEl
  5209. */
  5210. TooltipProgressBar.prototype.createEl = function createEl() {
  5211. var el = _Component.prototype.createEl.call(this, 'div', {
  5212. className: 'vjs-tooltip-progress-bar vjs-slider-bar',
  5213. innerHTML: '<div class="vjs-time-tooltip"></div>\n <span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
  5214. })
  5215. this.tooltip = el.querySelector('.vjs-time-tooltip')
  5216. return el
  5217. }
  5218. TooltipProgressBar.prototype.updateDataAttr = function updateDataAttr() {
  5219. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime()
  5220. var formattedTime = _utilsFormatTimeJs2['default'](time, this.player_.duration())
  5221. this.el_.setAttribute('data-current-time', formattedTime)
  5222. this.tooltip.innerHTML = formattedTime
  5223. }
  5224. return TooltipProgressBar
  5225. })(_componentJs2['default'])
  5226. _componentJs2['default'].registerComponent('TooltipProgressBar', TooltipProgressBar)
  5227. exports['default'] = TooltipProgressBar
  5228. module.exports = exports['default']
  5229. }, { '../../component.js': 67, '../../utils/dom.js': 143, '../../utils/fn.js': 145, '../../utils/format-time.js': 146 }], 83: [function(_dereq_, module, exports) {
  5230. /**
  5231. * @file custom-control-spacer.js
  5232. */
  5233. 'use strict'
  5234. exports.__esModule = true
  5235. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5236. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5237. 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 }
  5238. var _spacerJs = _dereq_('./spacer.js')
  5239. var _spacerJs2 = _interopRequireDefault(_spacerJs)
  5240. var _componentJs = _dereq_('../../component.js')
  5241. var _componentJs2 = _interopRequireDefault(_componentJs)
  5242. /**
  5243. * Spacer specifically meant to be used as an insertion point for new plugins, etc.
  5244. *
  5245. * @extends Spacer
  5246. * @class CustomControlSpacer
  5247. */
  5248. var CustomControlSpacer = (function(_Spacer) {
  5249. _inherits(CustomControlSpacer, _Spacer)
  5250. function CustomControlSpacer() {
  5251. _classCallCheck(this, CustomControlSpacer)
  5252. _Spacer.apply(this, arguments)
  5253. }
  5254. /**
  5255. * Allow sub components to stack CSS class names
  5256. *
  5257. * @return {String} The constructed class name
  5258. * @method buildCSSClass
  5259. */
  5260. CustomControlSpacer.prototype.buildCSSClass = function buildCSSClass() {
  5261. return 'vjs-custom-control-spacer ' + _Spacer.prototype.buildCSSClass.call(this)
  5262. }
  5263. /**
  5264. * Create the component's DOM element
  5265. *
  5266. * @return {Element}
  5267. * @method createEl
  5268. */
  5269. CustomControlSpacer.prototype.createEl = function createEl() {
  5270. var el = _Spacer.prototype.createEl.call(this, {
  5271. className: this.buildCSSClass()
  5272. })
  5273. // No-flex/table-cell mode requires there be some content
  5274. // in the cell to fill the remaining space of the table.
  5275. el.innerHTML = '&nbsp;'
  5276. return el
  5277. }
  5278. return CustomControlSpacer
  5279. })(_spacerJs2['default'])
  5280. _componentJs2['default'].registerComponent('CustomControlSpacer', CustomControlSpacer)
  5281. exports['default'] = CustomControlSpacer
  5282. module.exports = exports['default']
  5283. }, { '../../component.js': 67, './spacer.js': 84 }], 84: [function(_dereq_, module, exports) {
  5284. /**
  5285. * @file spacer.js
  5286. */
  5287. 'use strict'
  5288. exports.__esModule = true
  5289. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5290. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5291. 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 }
  5292. var _componentJs = _dereq_('../../component.js')
  5293. var _componentJs2 = _interopRequireDefault(_componentJs)
  5294. /**
  5295. * Just an empty spacer element that can be used as an append point for plugins, etc.
  5296. * Also can be used to create space between elements when necessary.
  5297. *
  5298. * @extends Component
  5299. * @class Spacer
  5300. */
  5301. var Spacer = (function(_Component) {
  5302. _inherits(Spacer, _Component)
  5303. function Spacer() {
  5304. _classCallCheck(this, Spacer)
  5305. _Component.apply(this, arguments)
  5306. }
  5307. /**
  5308. * Allow sub components to stack CSS class names
  5309. *
  5310. * @return {String} The constructed class name
  5311. * @method buildCSSClass
  5312. */
  5313. Spacer.prototype.buildCSSClass = function buildCSSClass() {
  5314. return 'vjs-spacer ' + _Component.prototype.buildCSSClass.call(this)
  5315. }
  5316. /**
  5317. * Create the component's DOM element
  5318. *
  5319. * @return {Element}
  5320. * @method createEl
  5321. */
  5322. Spacer.prototype.createEl = function createEl() {
  5323. return _Component.prototype.createEl.call(this, 'div', {
  5324. className: this.buildCSSClass()
  5325. })
  5326. }
  5327. return Spacer
  5328. })(_componentJs2['default'])
  5329. _componentJs2['default'].registerComponent('Spacer', Spacer)
  5330. exports['default'] = Spacer
  5331. module.exports = exports['default']
  5332. }, { '../../component.js': 67 }], 85: [function(_dereq_, module, exports) {
  5333. /**
  5334. * @file caption-settings-menu-item.js
  5335. */
  5336. 'use strict'
  5337. exports.__esModule = true
  5338. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5339. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5340. 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 }
  5341. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js')
  5342. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs)
  5343. var _componentJs = _dereq_('../../component.js')
  5344. var _componentJs2 = _interopRequireDefault(_componentJs)
  5345. /**
  5346. * The menu item for caption track settings menu
  5347. *
  5348. * @param {Player|Object} player
  5349. * @param {Object=} options
  5350. * @extends TextTrackMenuItem
  5351. * @class CaptionSettingsMenuItem
  5352. */
  5353. var CaptionSettingsMenuItem = (function(_TextTrackMenuItem) {
  5354. _inherits(CaptionSettingsMenuItem, _TextTrackMenuItem)
  5355. function CaptionSettingsMenuItem(player, options) {
  5356. _classCallCheck(this, CaptionSettingsMenuItem)
  5357. options['track'] = {
  5358. 'kind': options['kind'],
  5359. 'player': player,
  5360. 'label': options['kind'] + ' settings',
  5361. 'selectable': false,
  5362. 'default': false,
  5363. mode: 'disabled'
  5364. }
  5365. // CaptionSettingsMenuItem has no concept of 'selected'
  5366. options['selectable'] = false
  5367. _TextTrackMenuItem.call(this, player, options)
  5368. this.addClass('vjs-texttrack-settings')
  5369. this.controlText(', opens ' + options['kind'] + ' settings dialog')
  5370. }
  5371. /**
  5372. * Handle click on menu item
  5373. *
  5374. * @method handleClick
  5375. */
  5376. CaptionSettingsMenuItem.prototype.handleClick = function handleClick() {
  5377. this.player().getChild('textTrackSettings').show()
  5378. this.player().getChild('textTrackSettings').el_.focus()
  5379. }
  5380. return CaptionSettingsMenuItem
  5381. })(_textTrackMenuItemJs2['default'])
  5382. _componentJs2['default'].registerComponent('CaptionSettingsMenuItem', CaptionSettingsMenuItem)
  5383. exports['default'] = CaptionSettingsMenuItem
  5384. module.exports = exports['default']
  5385. }, { '../../component.js': 67, './text-track-menu-item.js': 93 }], 86: [function(_dereq_, module, exports) {
  5386. /**
  5387. * @file captions-button.js
  5388. */
  5389. 'use strict'
  5390. exports.__esModule = true
  5391. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5392. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5393. 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 }
  5394. var _textTrackButtonJs = _dereq_('./text-track-button.js')
  5395. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs)
  5396. var _componentJs = _dereq_('../../component.js')
  5397. var _componentJs2 = _interopRequireDefault(_componentJs)
  5398. var _captionSettingsMenuItemJs = _dereq_('./caption-settings-menu-item.js')
  5399. var _captionSettingsMenuItemJs2 = _interopRequireDefault(_captionSettingsMenuItemJs)
  5400. /**
  5401. * The button component for toggling and selecting captions
  5402. *
  5403. * @param {Object} player Player object
  5404. * @param {Object=} options Object of option names and values
  5405. * @param {Function=} ready Ready callback function
  5406. * @extends TextTrackButton
  5407. * @class CaptionsButton
  5408. */
  5409. var CaptionsButton = (function(_TextTrackButton) {
  5410. _inherits(CaptionsButton, _TextTrackButton)
  5411. function CaptionsButton(player, options, ready) {
  5412. _classCallCheck(this, CaptionsButton)
  5413. _TextTrackButton.call(this, player, options, ready)
  5414. this.el_.setAttribute('aria-label', 'Captions Menu')
  5415. }
  5416. /**
  5417. * Allow sub components to stack CSS class names
  5418. *
  5419. * @return {String} The constructed class name
  5420. * @method buildCSSClass
  5421. */
  5422. CaptionsButton.prototype.buildCSSClass = function buildCSSClass() {
  5423. return 'vjs-captions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this)
  5424. }
  5425. /**
  5426. * Update caption menu items
  5427. *
  5428. * @method update
  5429. */
  5430. CaptionsButton.prototype.update = function update() {
  5431. var threshold = 2
  5432. _TextTrackButton.prototype.update.call(this)
  5433. // if native, then threshold is 1 because no settings button
  5434. if (this.player().tech_ && this.player().tech_['featuresNativeTextTracks']) {
  5435. threshold = 1
  5436. }
  5437. if (this.items && this.items.length > threshold) {
  5438. this.show()
  5439. } else {
  5440. this.hide()
  5441. }
  5442. }
  5443. /**
  5444. * Create caption menu items
  5445. *
  5446. * @return {Array} Array of menu items
  5447. * @method createItems
  5448. */
  5449. CaptionsButton.prototype.createItems = function createItems() {
  5450. var items = []
  5451. if (!(this.player().tech_ && this.player().tech_['featuresNativeTextTracks'])) {
  5452. items.push(new _captionSettingsMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }))
  5453. }
  5454. return _TextTrackButton.prototype.createItems.call(this, items)
  5455. }
  5456. return CaptionsButton
  5457. })(_textTrackButtonJs2['default'])
  5458. CaptionsButton.prototype.kind_ = 'captions'
  5459. CaptionsButton.prototype.controlText_ = 'Captions'
  5460. _componentJs2['default'].registerComponent('CaptionsButton', CaptionsButton)
  5461. exports['default'] = CaptionsButton
  5462. module.exports = exports['default']
  5463. }, { '../../component.js': 67, './caption-settings-menu-item.js': 85, './text-track-button.js': 92 }], 87: [function(_dereq_, module, exports) {
  5464. /**
  5465. * @file chapters-button.js
  5466. */
  5467. 'use strict'
  5468. exports.__esModule = true
  5469. 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 } }
  5470. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5471. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5472. 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 }
  5473. var _textTrackButtonJs = _dereq_('./text-track-button.js')
  5474. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs)
  5475. var _componentJs = _dereq_('../../component.js')
  5476. var _componentJs2 = _interopRequireDefault(_componentJs)
  5477. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js')
  5478. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs)
  5479. var _chaptersTrackMenuItemJs = _dereq_('./chapters-track-menu-item.js')
  5480. var _chaptersTrackMenuItemJs2 = _interopRequireDefault(_chaptersTrackMenuItemJs)
  5481. var _menuMenuJs = _dereq_('../../menu/menu.js')
  5482. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs)
  5483. var _utilsDomJs = _dereq_('../../utils/dom.js')
  5484. var Dom = _interopRequireWildcard(_utilsDomJs)
  5485. var _utilsFnJs = _dereq_('../../utils/fn.js')
  5486. var Fn = _interopRequireWildcard(_utilsFnJs)
  5487. var _utilsToTitleCaseJs = _dereq_('../../utils/to-title-case.js')
  5488. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs)
  5489. var _globalWindow = _dereq_('global/window')
  5490. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  5491. /**
  5492. * The button component for toggling and selecting chapters
  5493. * Chapters act much differently than other text tracks
  5494. * Cues are navigation vs. other tracks of alternative languages
  5495. *
  5496. * @param {Object} player Player object
  5497. * @param {Object=} options Object of option names and values
  5498. * @param {Function=} ready Ready callback function
  5499. * @extends TextTrackButton
  5500. * @class ChaptersButton
  5501. */
  5502. var ChaptersButton = (function(_TextTrackButton) {
  5503. _inherits(ChaptersButton, _TextTrackButton)
  5504. function ChaptersButton(player, options, ready) {
  5505. _classCallCheck(this, ChaptersButton)
  5506. _TextTrackButton.call(this, player, options, ready)
  5507. this.el_.setAttribute('aria-label', 'Chapters Menu')
  5508. }
  5509. /**
  5510. * Allow sub components to stack CSS class names
  5511. *
  5512. * @return {String} The constructed class name
  5513. * @method buildCSSClass
  5514. */
  5515. ChaptersButton.prototype.buildCSSClass = function buildCSSClass() {
  5516. return 'vjs-chapters-button ' + _TextTrackButton.prototype.buildCSSClass.call(this)
  5517. }
  5518. /**
  5519. * Create a menu item for each text track
  5520. *
  5521. * @return {Array} Array of menu items
  5522. * @method createItems
  5523. */
  5524. ChaptersButton.prototype.createItems = function createItems() {
  5525. var items = []
  5526. var tracks = this.player_.textTracks()
  5527. if (!tracks) {
  5528. return items
  5529. }
  5530. for (var i = 0; i < tracks.length; i++) {
  5531. var track = tracks[i]
  5532. if (track['kind'] === this.kind_) {
  5533. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5534. 'track': track
  5535. }))
  5536. }
  5537. }
  5538. return items
  5539. }
  5540. /**
  5541. * Create menu from chapter buttons
  5542. *
  5543. * @return {Menu} Menu of chapter buttons
  5544. * @method createMenu
  5545. */
  5546. ChaptersButton.prototype.createMenu = function createMenu() {
  5547. var _this = this
  5548. var tracks = this.player_.textTracks() || []
  5549. var chaptersTrack = undefined
  5550. var items = this.items = []
  5551. for (var i = 0, _length = tracks.length; i < _length; i++) {
  5552. var track = tracks[i]
  5553. if (track['kind'] === this.kind_) {
  5554. chaptersTrack = track
  5555. break
  5556. }
  5557. }
  5558. var menu = this.menu
  5559. if (menu === undefined) {
  5560. menu = new _menuMenuJs2['default'](this.player_)
  5561. var title = Dom.createEl('li', {
  5562. className: 'vjs-menu-title',
  5563. innerHTML: _utilsToTitleCaseJs2['default'](this.kind_),
  5564. tabIndex: -1
  5565. })
  5566. menu.children_.unshift(title)
  5567. Dom.insertElFirst(title, menu.contentEl())
  5568. }
  5569. if (chaptersTrack && chaptersTrack.cues == null) {
  5570. chaptersTrack['mode'] = 'hidden'
  5571. var remoteTextTrackEl = this.player_.remoteTextTrackEls().getTrackElementByTrack_(chaptersTrack)
  5572. if (remoteTextTrackEl) {
  5573. remoteTextTrackEl.addEventListener('load', function(event) {
  5574. return _this.update()
  5575. })
  5576. }
  5577. }
  5578. if (chaptersTrack && chaptersTrack.cues && chaptersTrack.cues.length > 0) {
  5579. var cues = chaptersTrack['cues']
  5580. var cue = undefined
  5581. for (var i = 0, l = cues.length; i < l; i++) {
  5582. cue = cues[i]
  5583. var mi = new _chaptersTrackMenuItemJs2['default'](this.player_, {
  5584. 'track': chaptersTrack,
  5585. 'cue': cue
  5586. })
  5587. items.push(mi)
  5588. menu.addChild(mi)
  5589. }
  5590. this.addChild(menu)
  5591. }
  5592. if (this.items.length > 0) {
  5593. this.show()
  5594. }
  5595. return menu
  5596. }
  5597. return ChaptersButton
  5598. })(_textTrackButtonJs2['default'])
  5599. ChaptersButton.prototype.kind_ = 'chapters'
  5600. ChaptersButton.prototype.controlText_ = 'Chapters'
  5601. _componentJs2['default'].registerComponent('ChaptersButton', ChaptersButton)
  5602. exports['default'] = ChaptersButton
  5603. module.exports = exports['default']
  5604. }, { '../../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) {
  5605. /**
  5606. * @file chapters-track-menu-item.js
  5607. */
  5608. 'use strict'
  5609. exports.__esModule = true
  5610. 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 } }
  5611. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5612. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5613. 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 }
  5614. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js')
  5615. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs)
  5616. var _componentJs = _dereq_('../../component.js')
  5617. var _componentJs2 = _interopRequireDefault(_componentJs)
  5618. var _utilsFnJs = _dereq_('../../utils/fn.js')
  5619. var Fn = _interopRequireWildcard(_utilsFnJs)
  5620. /**
  5621. * The chapter track menu item
  5622. *
  5623. * @param {Player|Object} player
  5624. * @param {Object=} options
  5625. * @extends MenuItem
  5626. * @class ChaptersTrackMenuItem
  5627. */
  5628. var ChaptersTrackMenuItem = (function(_MenuItem) {
  5629. _inherits(ChaptersTrackMenuItem, _MenuItem)
  5630. function ChaptersTrackMenuItem(player, options) {
  5631. _classCallCheck(this, ChaptersTrackMenuItem)
  5632. var track = options['track']
  5633. var cue = options['cue']
  5634. var currentTime = player.currentTime()
  5635. // Modify options for parent MenuItem class's init.
  5636. options['label'] = cue.text
  5637. options['selected'] = cue['startTime'] <= currentTime && currentTime < cue['endTime']
  5638. _MenuItem.call(this, player, options)
  5639. this.track = track
  5640. this.cue = cue
  5641. track.addEventListener('cuechange', Fn.bind(this, this.update))
  5642. }
  5643. /**
  5644. * Handle click on menu item
  5645. *
  5646. * @method handleClick
  5647. */
  5648. ChaptersTrackMenuItem.prototype.handleClick = function handleClick() {
  5649. _MenuItem.prototype.handleClick.call(this)
  5650. this.player_.currentTime(this.cue.startTime)
  5651. this.update(this.cue.startTime)
  5652. }
  5653. /**
  5654. * Update chapter menu item
  5655. *
  5656. * @method update
  5657. */
  5658. ChaptersTrackMenuItem.prototype.update = function update() {
  5659. var cue = this.cue
  5660. var currentTime = this.player_.currentTime()
  5661. // vjs.log(currentTime, cue.startTime);
  5662. this.selected(cue['startTime'] <= currentTime && currentTime < cue['endTime'])
  5663. }
  5664. return ChaptersTrackMenuItem
  5665. })(_menuMenuItemJs2['default'])
  5666. _componentJs2['default'].registerComponent('ChaptersTrackMenuItem', ChaptersTrackMenuItem)
  5667. exports['default'] = ChaptersTrackMenuItem
  5668. module.exports = exports['default']
  5669. }, { '../../component.js': 67, '../../menu/menu-item.js': 110, '../../utils/fn.js': 145 }], 89: [function(_dereq_, module, exports) {
  5670. /**
  5671. * @file descriptions-button.js
  5672. */
  5673. 'use strict'
  5674. exports.__esModule = true
  5675. 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 } }
  5676. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5677. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5678. 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 }
  5679. var _textTrackButtonJs = _dereq_('./text-track-button.js')
  5680. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs)
  5681. var _componentJs = _dereq_('../../component.js')
  5682. var _componentJs2 = _interopRequireDefault(_componentJs)
  5683. var _utilsFnJs = _dereq_('../../utils/fn.js')
  5684. var Fn = _interopRequireWildcard(_utilsFnJs)
  5685. /**
  5686. * The button component for toggling and selecting descriptions
  5687. *
  5688. * @param {Object} player Player object
  5689. * @param {Object=} options Object of option names and values
  5690. * @param {Function=} ready Ready callback function
  5691. * @extends TextTrackButton
  5692. * @class DescriptionsButton
  5693. */
  5694. var DescriptionsButton = (function(_TextTrackButton) {
  5695. _inherits(DescriptionsButton, _TextTrackButton)
  5696. function DescriptionsButton(player, options, ready) {
  5697. var _this = this
  5698. _classCallCheck(this, DescriptionsButton)
  5699. _TextTrackButton.call(this, player, options, ready)
  5700. this.el_.setAttribute('aria-label', 'Descriptions Menu')
  5701. var tracks = player.textTracks()
  5702. if (tracks) {
  5703. (function() {
  5704. var changeHandler = Fn.bind(_this, _this.handleTracksChange)
  5705. tracks.addEventListener('change', changeHandler)
  5706. _this.on('dispose', function() {
  5707. tracks.removeEventListener('change', changeHandler)
  5708. })
  5709. })()
  5710. }
  5711. }
  5712. /**
  5713. * Handle text track change
  5714. *
  5715. * @method handleTracksChange
  5716. */
  5717. DescriptionsButton.prototype.handleTracksChange = function handleTracksChange(event) {
  5718. var tracks = this.player().textTracks()
  5719. var disabled = false
  5720. // Check whether a track of a different kind is showing
  5721. for (var i = 0, l = tracks.length; i < l; i++) {
  5722. var track = tracks[i]
  5723. if (track['kind'] !== this.kind_ && track['mode'] === 'showing') {
  5724. disabled = true
  5725. break
  5726. }
  5727. }
  5728. // If another track is showing, disable this menu button
  5729. if (disabled) {
  5730. this.disable()
  5731. } else {
  5732. this.enable()
  5733. }
  5734. }
  5735. /**
  5736. * Allow sub components to stack CSS class names
  5737. *
  5738. * @return {String} The constructed class name
  5739. * @method buildCSSClass
  5740. */
  5741. DescriptionsButton.prototype.buildCSSClass = function buildCSSClass() {
  5742. return 'vjs-descriptions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this)
  5743. }
  5744. return DescriptionsButton
  5745. })(_textTrackButtonJs2['default'])
  5746. DescriptionsButton.prototype.kind_ = 'descriptions'
  5747. DescriptionsButton.prototype.controlText_ = 'Descriptions'
  5748. _componentJs2['default'].registerComponent('DescriptionsButton', DescriptionsButton)
  5749. exports['default'] = DescriptionsButton
  5750. module.exports = exports['default']
  5751. }, { '../../component.js': 67, '../../utils/fn.js': 145, './text-track-button.js': 92 }], 90: [function(_dereq_, module, exports) {
  5752. /**
  5753. * @file off-text-track-menu-item.js
  5754. */
  5755. 'use strict'
  5756. exports.__esModule = true
  5757. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5758. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5759. 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 }
  5760. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js')
  5761. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs)
  5762. var _componentJs = _dereq_('../../component.js')
  5763. var _componentJs2 = _interopRequireDefault(_componentJs)
  5764. /**
  5765. * A special menu item for turning of a specific type of text track
  5766. *
  5767. * @param {Player|Object} player
  5768. * @param {Object=} options
  5769. * @extends TextTrackMenuItem
  5770. * @class OffTextTrackMenuItem
  5771. */
  5772. var OffTextTrackMenuItem = (function(_TextTrackMenuItem) {
  5773. _inherits(OffTextTrackMenuItem, _TextTrackMenuItem)
  5774. function OffTextTrackMenuItem(player, options) {
  5775. _classCallCheck(this, OffTextTrackMenuItem)
  5776. // Create pseudo track info
  5777. // Requires options['kind']
  5778. options['track'] = {
  5779. 'kind': options['kind'],
  5780. 'player': player,
  5781. 'label': options['kind'] + ' off',
  5782. 'default': false,
  5783. 'mode': 'disabled'
  5784. }
  5785. // MenuItem is selectable
  5786. options['selectable'] = true
  5787. _TextTrackMenuItem.call(this, player, options)
  5788. this.selected(true)
  5789. }
  5790. /**
  5791. * Handle text track change
  5792. *
  5793. * @param {Object} event Event object
  5794. * @method handleTracksChange
  5795. */
  5796. OffTextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  5797. var tracks = this.player().textTracks()
  5798. var selected = true
  5799. for (var i = 0, l = tracks.length; i < l; i++) {
  5800. var track = tracks[i]
  5801. if (track['kind'] === this.track['kind'] && track['mode'] === 'showing') {
  5802. selected = false
  5803. break
  5804. }
  5805. }
  5806. this.selected(selected)
  5807. }
  5808. return OffTextTrackMenuItem
  5809. })(_textTrackMenuItemJs2['default'])
  5810. _componentJs2['default'].registerComponent('OffTextTrackMenuItem', OffTextTrackMenuItem)
  5811. exports['default'] = OffTextTrackMenuItem
  5812. module.exports = exports['default']
  5813. }, { '../../component.js': 67, './text-track-menu-item.js': 93 }], 91: [function(_dereq_, module, exports) {
  5814. /**
  5815. * @file subtitles-button.js
  5816. */
  5817. 'use strict'
  5818. exports.__esModule = true
  5819. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5820. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5821. 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 }
  5822. var _textTrackButtonJs = _dereq_('./text-track-button.js')
  5823. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs)
  5824. var _componentJs = _dereq_('../../component.js')
  5825. var _componentJs2 = _interopRequireDefault(_componentJs)
  5826. /**
  5827. * The button component for toggling and selecting subtitles
  5828. *
  5829. * @param {Object} player Player object
  5830. * @param {Object=} options Object of option names and values
  5831. * @param {Function=} ready Ready callback function
  5832. * @extends TextTrackButton
  5833. * @class SubtitlesButton
  5834. */
  5835. var SubtitlesButton = (function(_TextTrackButton) {
  5836. _inherits(SubtitlesButton, _TextTrackButton)
  5837. function SubtitlesButton(player, options, ready) {
  5838. _classCallCheck(this, SubtitlesButton)
  5839. _TextTrackButton.call(this, player, options, ready)
  5840. this.el_.setAttribute('aria-label', 'Subtitles Menu')
  5841. }
  5842. /**
  5843. * Allow sub components to stack CSS class names
  5844. *
  5845. * @return {String} The constructed class name
  5846. * @method buildCSSClass
  5847. */
  5848. SubtitlesButton.prototype.buildCSSClass = function buildCSSClass() {
  5849. return 'vjs-subtitles-button ' + _TextTrackButton.prototype.buildCSSClass.call(this)
  5850. }
  5851. return SubtitlesButton
  5852. })(_textTrackButtonJs2['default'])
  5853. SubtitlesButton.prototype.kind_ = 'subtitles'
  5854. SubtitlesButton.prototype.controlText_ = 'Subtitles'
  5855. _componentJs2['default'].registerComponent('SubtitlesButton', SubtitlesButton)
  5856. exports['default'] = SubtitlesButton
  5857. module.exports = exports['default']
  5858. }, { '../../component.js': 67, './text-track-button.js': 92 }], 92: [function(_dereq_, module, exports) {
  5859. /**
  5860. * @file text-track-button.js
  5861. */
  5862. 'use strict'
  5863. exports.__esModule = true
  5864. 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 } }
  5865. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5866. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5867. 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 }
  5868. var _trackButtonJs = _dereq_('../track-button.js')
  5869. var _trackButtonJs2 = _interopRequireDefault(_trackButtonJs)
  5870. var _componentJs = _dereq_('../../component.js')
  5871. var _componentJs2 = _interopRequireDefault(_componentJs)
  5872. var _utilsFnJs = _dereq_('../../utils/fn.js')
  5873. var Fn = _interopRequireWildcard(_utilsFnJs)
  5874. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js')
  5875. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs)
  5876. var _offTextTrackMenuItemJs = _dereq_('./off-text-track-menu-item.js')
  5877. var _offTextTrackMenuItemJs2 = _interopRequireDefault(_offTextTrackMenuItemJs)
  5878. /**
  5879. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  5880. *
  5881. * @param {Player|Object} player
  5882. * @param {Object=} options
  5883. * @extends MenuButton
  5884. * @class TextTrackButton
  5885. */
  5886. var TextTrackButton = (function(_TrackButton) {
  5887. _inherits(TextTrackButton, _TrackButton)
  5888. function TextTrackButton(player) {
  5889. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  5890. _classCallCheck(this, TextTrackButton)
  5891. options.tracks = player.textTracks()
  5892. _TrackButton.call(this, player, options)
  5893. }
  5894. /**
  5895. * Create a menu item for each text track
  5896. *
  5897. * @return {Array} Array of menu items
  5898. * @method createItems
  5899. */
  5900. TextTrackButton.prototype.createItems = function createItems() {
  5901. var items = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]
  5902. // Add an OFF menu item to turn all tracks off
  5903. items.push(new _offTextTrackMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }))
  5904. var tracks = this.player_.textTracks()
  5905. if (!tracks) {
  5906. return items
  5907. }
  5908. for (var i = 0; i < tracks.length; i++) {
  5909. var track = tracks[i]
  5910. // only add tracks that are of the appropriate kind and have a label
  5911. if (track['kind'] === this.kind_) {
  5912. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5913. // MenuItem is selectable
  5914. 'selectable': true,
  5915. 'track': track
  5916. }))
  5917. }
  5918. }
  5919. return items
  5920. }
  5921. return TextTrackButton
  5922. })(_trackButtonJs2['default'])
  5923. _componentJs2['default'].registerComponent('TextTrackButton', TextTrackButton)
  5924. exports['default'] = TextTrackButton
  5925. module.exports = exports['default']
  5926. }, { '../../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) {
  5927. /**
  5928. * @file text-track-menu-item.js
  5929. */
  5930. 'use strict'
  5931. exports.__esModule = true
  5932. 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 } }
  5933. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  5934. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  5935. 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 }
  5936. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js')
  5937. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs)
  5938. var _componentJs = _dereq_('../../component.js')
  5939. var _componentJs2 = _interopRequireDefault(_componentJs)
  5940. var _utilsFnJs = _dereq_('../../utils/fn.js')
  5941. var Fn = _interopRequireWildcard(_utilsFnJs)
  5942. var _globalWindow = _dereq_('global/window')
  5943. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  5944. var _globalDocument = _dereq_('global/document')
  5945. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  5946. /**
  5947. * The specific menu item type for selecting a language within a text track kind
  5948. *
  5949. * @param {Player|Object} player
  5950. * @param {Object=} options
  5951. * @extends MenuItem
  5952. * @class TextTrackMenuItem
  5953. */
  5954. var TextTrackMenuItem = (function(_MenuItem) {
  5955. _inherits(TextTrackMenuItem, _MenuItem)
  5956. function TextTrackMenuItem(player, options) {
  5957. var _this = this
  5958. _classCallCheck(this, TextTrackMenuItem)
  5959. var track = options['track']
  5960. var tracks = player.textTracks()
  5961. // Modify options for parent MenuItem class's init.
  5962. options['label'] = track['label'] || track['language'] || 'Unknown'
  5963. options['selected'] = track['default'] || track['mode'] === 'showing'
  5964. _MenuItem.call(this, player, options)
  5965. this.track = track
  5966. if (tracks) {
  5967. (function() {
  5968. var changeHandler = Fn.bind(_this, _this.handleTracksChange)
  5969. tracks.addEventListener('change', changeHandler)
  5970. _this.on('dispose', function() {
  5971. tracks.removeEventListener('change', changeHandler)
  5972. })
  5973. })()
  5974. }
  5975. // iOS7 doesn't dispatch change events to TextTrackLists when an
  5976. // associated track's mode changes. Without something like
  5977. // Object.observe() (also not present on iOS7), it's not
  5978. // possible to detect changes to the mode attribute and polyfill
  5979. // the change event. As a poor substitute, we manually dispatch
  5980. // change events whenever the controls modify the mode.
  5981. if (tracks && tracks.onchange === undefined) {
  5982. (function() {
  5983. var event = undefined
  5984. _this.on(['tap', 'click'], function() {
  5985. if (typeof _globalWindow2['default'].Event !== 'object') {
  5986. // Android 2.3 throws an Illegal Constructor error for window.Event
  5987. try {
  5988. event = new _globalWindow2['default'].Event('change')
  5989. } catch (err) { }
  5990. }
  5991. if (!event) {
  5992. event = _globalDocument2['default'].createEvent('Event')
  5993. event.initEvent('change', true, true)
  5994. }
  5995. tracks.dispatchEvent(event)
  5996. })
  5997. })()
  5998. }
  5999. }
  6000. /**
  6001. * Handle click on text track
  6002. *
  6003. * @method handleClick
  6004. */
  6005. TextTrackMenuItem.prototype.handleClick = function handleClick(event) {
  6006. var kind = this.track['kind']
  6007. var tracks = this.player_.textTracks()
  6008. _MenuItem.prototype.handleClick.call(this, event)
  6009. if (!tracks) return
  6010. for (var i = 0; i < tracks.length; i++) {
  6011. var track = tracks[i]
  6012. if (track['kind'] !== kind) {
  6013. continue
  6014. }
  6015. if (track === this.track) {
  6016. track['mode'] = 'showing'
  6017. } else {
  6018. track['mode'] = 'disabled'
  6019. }
  6020. }
  6021. }
  6022. /**
  6023. * Handle text track change
  6024. *
  6025. * @method handleTracksChange
  6026. */
  6027. TextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  6028. this.selected(this.track['mode'] === 'showing')
  6029. }
  6030. return TextTrackMenuItem
  6031. })(_menuMenuItemJs2['default'])
  6032. _componentJs2['default'].registerComponent('TextTrackMenuItem', TextTrackMenuItem)
  6033. exports['default'] = TextTrackMenuItem
  6034. module.exports = exports['default']
  6035. }, { '../../component.js': 67, '../../menu/menu-item.js': 110, '../../utils/fn.js': 145, 'global/document': 1, 'global/window': 2 }], 94: [function(_dereq_, module, exports) {
  6036. /**
  6037. * @file current-time-display.js
  6038. */
  6039. 'use strict'
  6040. exports.__esModule = true
  6041. 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 } }
  6042. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6043. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6044. 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 }
  6045. var _componentJs = _dereq_('../../component.js')
  6046. var _componentJs2 = _interopRequireDefault(_componentJs)
  6047. var _utilsDomJs = _dereq_('../../utils/dom.js')
  6048. var Dom = _interopRequireWildcard(_utilsDomJs)
  6049. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js')
  6050. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  6051. /**
  6052. * Displays the current time
  6053. *
  6054. * @param {Player|Object} player
  6055. * @param {Object=} options
  6056. * @extends Component
  6057. * @class CurrentTimeDisplay
  6058. */
  6059. var CurrentTimeDisplay = (function(_Component) {
  6060. _inherits(CurrentTimeDisplay, _Component)
  6061. function CurrentTimeDisplay(player, options) {
  6062. _classCallCheck(this, CurrentTimeDisplay)
  6063. _Component.call(this, player, options)
  6064. this.on(player, 'timeupdate', this.updateContent)
  6065. }
  6066. /**
  6067. * Create the component's DOM element
  6068. *
  6069. * @return {Element}
  6070. * @method createEl
  6071. */
  6072. CurrentTimeDisplay.prototype.createEl = function createEl() {
  6073. var el = _Component.prototype.createEl.call(this, 'div', {
  6074. className: 'vjs-current-time vjs-time-control vjs-control'
  6075. })
  6076. this.contentEl_ = Dom.createEl('div', {
  6077. className: 'vjs-current-time-display',
  6078. // label the current time for screen reader users
  6079. innerHTML: '<span class="vjs-control-text">Current Time </span>' + '0:00'
  6080. }, {
  6081. // tell screen readers not to automatically read the time as it changes
  6082. 'aria-live': 'off'
  6083. })
  6084. el.appendChild(this.contentEl_)
  6085. return el
  6086. }
  6087. /**
  6088. * Update current time display
  6089. *
  6090. * @method updateContent
  6091. */
  6092. CurrentTimeDisplay.prototype.updateContent = function updateContent() {
  6093. // Allows for smooth scrubbing, when player can't keep up.
  6094. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime()
  6095. var localizedText = this.localize('Current Time')
  6096. var formattedTime = _utilsFormatTimeJs2['default'](time, this.player_.duration())
  6097. if (formattedTime !== this.formattedTime_) {
  6098. this.formattedTime_ = formattedTime
  6099. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime
  6100. }
  6101. }
  6102. return CurrentTimeDisplay
  6103. })(_componentJs2['default'])
  6104. _componentJs2['default'].registerComponent('CurrentTimeDisplay', CurrentTimeDisplay)
  6105. exports['default'] = CurrentTimeDisplay
  6106. module.exports = exports['default']
  6107. }, { '../../component.js': 67, '../../utils/dom.js': 143, '../../utils/format-time.js': 146 }], 95: [function(_dereq_, module, exports) {
  6108. /**
  6109. * @file duration-display.js
  6110. */
  6111. 'use strict'
  6112. exports.__esModule = true
  6113. 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 } }
  6114. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6115. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6116. 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 }
  6117. var _componentJs = _dereq_('../../component.js')
  6118. var _componentJs2 = _interopRequireDefault(_componentJs)
  6119. var _utilsDomJs = _dereq_('../../utils/dom.js')
  6120. var Dom = _interopRequireWildcard(_utilsDomJs)
  6121. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js')
  6122. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  6123. /**
  6124. * Displays the duration
  6125. *
  6126. * @param {Player|Object} player
  6127. * @param {Object=} options
  6128. * @extends Component
  6129. * @class DurationDisplay
  6130. */
  6131. var DurationDisplay = (function(_Component) {
  6132. _inherits(DurationDisplay, _Component)
  6133. function DurationDisplay(player, options) {
  6134. _classCallCheck(this, DurationDisplay)
  6135. _Component.call(this, player, options)
  6136. // this might need to be changed to 'durationchange' instead of 'timeupdate' eventually,
  6137. // however the durationchange event fires before this.player_.duration() is set,
  6138. // so the value cannot be written out using this method.
  6139. // Once the order of durationchange and this.player_.duration() being set is figured out,
  6140. // this can be updated.
  6141. this.on(player, 'timeupdate', this.updateContent)
  6142. this.on(player, 'loadedmetadata', this.updateContent)
  6143. }
  6144. /**
  6145. * Create the component's DOM element
  6146. *
  6147. * @return {Element}
  6148. * @method createEl
  6149. */
  6150. DurationDisplay.prototype.createEl = function createEl() {
  6151. var el = _Component.prototype.createEl.call(this, 'div', {
  6152. className: 'vjs-duration vjs-time-control vjs-control'
  6153. })
  6154. this.contentEl_ = Dom.createEl('div', {
  6155. className: 'vjs-duration-display',
  6156. // label the duration time for screen reader users
  6157. innerHTML: '<span class="vjs-control-text">' + this.localize('Duration Time') + '</span> 0:00'
  6158. }, {
  6159. // tell screen readers not to automatically read the time as it changes
  6160. 'aria-live': 'off'
  6161. })
  6162. el.appendChild(this.contentEl_)
  6163. return el
  6164. }
  6165. /**
  6166. * Update duration time display
  6167. *
  6168. * @method updateContent
  6169. */
  6170. DurationDisplay.prototype.updateContent = function updateContent() {
  6171. var duration = this.player_.duration()
  6172. if (duration && this.duration_ !== duration) {
  6173. this.duration_ = duration
  6174. var localizedText = this.localize('Duration Time')
  6175. var formattedTime = _utilsFormatTimeJs2['default'](duration)
  6176. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime // label the duration time for screen reader users
  6177. }
  6178. }
  6179. return DurationDisplay
  6180. })(_componentJs2['default'])
  6181. _componentJs2['default'].registerComponent('DurationDisplay', DurationDisplay)
  6182. exports['default'] = DurationDisplay
  6183. module.exports = exports['default']
  6184. }, { '../../component.js': 67, '../../utils/dom.js': 143, '../../utils/format-time.js': 146 }], 96: [function(_dereq_, module, exports) {
  6185. /**
  6186. * @file remaining-time-display.js
  6187. */
  6188. 'use strict'
  6189. exports.__esModule = true
  6190. 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 } }
  6191. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6192. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6193. 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 }
  6194. var _componentJs = _dereq_('../../component.js')
  6195. var _componentJs2 = _interopRequireDefault(_componentJs)
  6196. var _utilsDomJs = _dereq_('../../utils/dom.js')
  6197. var Dom = _interopRequireWildcard(_utilsDomJs)
  6198. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js')
  6199. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  6200. /**
  6201. * Displays the time left in the video
  6202. *
  6203. * @param {Player|Object} player
  6204. * @param {Object=} options
  6205. * @extends Component
  6206. * @class RemainingTimeDisplay
  6207. */
  6208. var RemainingTimeDisplay = (function(_Component) {
  6209. _inherits(RemainingTimeDisplay, _Component)
  6210. function RemainingTimeDisplay(player, options) {
  6211. _classCallCheck(this, RemainingTimeDisplay)
  6212. _Component.call(this, player, options)
  6213. this.on(player, 'timeupdate', this.updateContent)
  6214. }
  6215. /**
  6216. * Create the component's DOM element
  6217. *
  6218. * @return {Element}
  6219. * @method createEl
  6220. */
  6221. RemainingTimeDisplay.prototype.createEl = function createEl() {
  6222. var el = _Component.prototype.createEl.call(this, 'div', {
  6223. className: 'vjs-remaining-time vjs-time-control vjs-control'
  6224. })
  6225. this.contentEl_ = Dom.createEl('div', {
  6226. className: 'vjs-remaining-time-display',
  6227. // label the remaining time for screen reader users
  6228. innerHTML: '<span class="vjs-control-text">' + this.localize('Remaining Time') + '</span> -0:00'
  6229. }, {
  6230. // tell screen readers not to automatically read the time as it changes
  6231. 'aria-live': 'off'
  6232. })
  6233. el.appendChild(this.contentEl_)
  6234. return el
  6235. }
  6236. /**
  6237. * Update remaining time display
  6238. *
  6239. * @method updateContent
  6240. */
  6241. RemainingTimeDisplay.prototype.updateContent = function updateContent() {
  6242. if (this.player_.duration()) {
  6243. var localizedText = this.localize('Remaining Time')
  6244. var formattedTime = _utilsFormatTimeJs2['default'](this.player_.remainingTime())
  6245. if (formattedTime !== this.formattedTime_) {
  6246. this.formattedTime_ = formattedTime
  6247. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> -' + formattedTime
  6248. }
  6249. }
  6250. // Allows for smooth scrubbing, when player can't keep up.
  6251. // var time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
  6252. // this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
  6253. }
  6254. return RemainingTimeDisplay
  6255. })(_componentJs2['default'])
  6256. _componentJs2['default'].registerComponent('RemainingTimeDisplay', RemainingTimeDisplay)
  6257. exports['default'] = RemainingTimeDisplay
  6258. module.exports = exports['default']
  6259. }, { '../../component.js': 67, '../../utils/dom.js': 143, '../../utils/format-time.js': 146 }], 97: [function(_dereq_, module, exports) {
  6260. /**
  6261. * @file time-divider.js
  6262. */
  6263. 'use strict'
  6264. exports.__esModule = true
  6265. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6266. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6267. 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 }
  6268. var _componentJs = _dereq_('../../component.js')
  6269. var _componentJs2 = _interopRequireDefault(_componentJs)
  6270. /**
  6271. * The separator between the current time and duration.
  6272. * Can be hidden if it's not needed in the design.
  6273. *
  6274. * @param {Player|Object} player
  6275. * @param {Object=} options
  6276. * @extends Component
  6277. * @class TimeDivider
  6278. */
  6279. var TimeDivider = (function(_Component) {
  6280. _inherits(TimeDivider, _Component)
  6281. function TimeDivider() {
  6282. _classCallCheck(this, TimeDivider)
  6283. _Component.apply(this, arguments)
  6284. }
  6285. /**
  6286. * Create the component's DOM element
  6287. *
  6288. * @return {Element}
  6289. * @method createEl
  6290. */
  6291. TimeDivider.prototype.createEl = function createEl() {
  6292. return _Component.prototype.createEl.call(this, 'div', {
  6293. className: 'vjs-time-control vjs-time-divider',
  6294. innerHTML: '<div><span>/</span></div>'
  6295. })
  6296. }
  6297. return TimeDivider
  6298. })(_componentJs2['default'])
  6299. _componentJs2['default'].registerComponent('TimeDivider', TimeDivider)
  6300. exports['default'] = TimeDivider
  6301. module.exports = exports['default']
  6302. }, { '../../component.js': 67 }], 98: [function(_dereq_, module, exports) {
  6303. /**
  6304. * @file track-button.js
  6305. */
  6306. 'use strict'
  6307. exports.__esModule = true
  6308. 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 } }
  6309. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6310. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6311. 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 }
  6312. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js')
  6313. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs)
  6314. var _componentJs = _dereq_('../component.js')
  6315. var _componentJs2 = _interopRequireDefault(_componentJs)
  6316. var _utilsFnJs = _dereq_('../utils/fn.js')
  6317. var Fn = _interopRequireWildcard(_utilsFnJs)
  6318. /**
  6319. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  6320. *
  6321. * @param {Player|Object} player
  6322. * @param {Object=} options
  6323. * @extends MenuButton
  6324. * @class TrackButton
  6325. */
  6326. var TrackButton = (function(_MenuButton) {
  6327. _inherits(TrackButton, _MenuButton)
  6328. function TrackButton(player, options) {
  6329. _classCallCheck(this, TrackButton)
  6330. var tracks = options.tracks
  6331. _MenuButton.call(this, player, options)
  6332. if (this.items.length <= 1) {
  6333. this.hide()
  6334. }
  6335. if (!tracks) {
  6336. return
  6337. }
  6338. var updateHandler = Fn.bind(this, this.update)
  6339. tracks.addEventListener('removetrack', updateHandler)
  6340. tracks.addEventListener('addtrack', updateHandler)
  6341. this.player_.on('dispose', function() {
  6342. tracks.removeEventListener('removetrack', updateHandler)
  6343. tracks.removeEventListener('addtrack', updateHandler)
  6344. })
  6345. }
  6346. return TrackButton
  6347. })(_menuMenuButtonJs2['default'])
  6348. _componentJs2['default'].registerComponent('TrackButton', TrackButton)
  6349. exports['default'] = TrackButton
  6350. module.exports = exports['default']
  6351. }, { '../component.js': 67, '../menu/menu-button.js': 109, '../utils/fn.js': 145 }], 99: [function(_dereq_, module, exports) {
  6352. /**
  6353. * @file volume-bar.js
  6354. */
  6355. 'use strict'
  6356. exports.__esModule = true
  6357. 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 } }
  6358. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6359. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6360. 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 }
  6361. var _sliderSliderJs = _dereq_('../../slider/slider.js')
  6362. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs)
  6363. var _componentJs = _dereq_('../../component.js')
  6364. var _componentJs2 = _interopRequireDefault(_componentJs)
  6365. var _utilsFnJs = _dereq_('../../utils/fn.js')
  6366. var Fn = _interopRequireWildcard(_utilsFnJs)
  6367. // Required children
  6368. var _volumeLevelJs = _dereq_('./volume-level.js')
  6369. var _volumeLevelJs2 = _interopRequireDefault(_volumeLevelJs)
  6370. /**
  6371. * The bar that contains the volume level and can be clicked on to adjust the level
  6372. *
  6373. * @param {Player|Object} player
  6374. * @param {Object=} options
  6375. * @extends Slider
  6376. * @class VolumeBar
  6377. */
  6378. var VolumeBar = (function(_Slider) {
  6379. _inherits(VolumeBar, _Slider)
  6380. function VolumeBar(player, options) {
  6381. _classCallCheck(this, VolumeBar)
  6382. _Slider.call(this, player, options)
  6383. this.on(player, 'volumechange', this.updateARIAAttributes)
  6384. player.ready(Fn.bind(this, this.updateARIAAttributes))
  6385. }
  6386. /**
  6387. * Create the component's DOM element
  6388. *
  6389. * @return {Element}
  6390. * @method createEl
  6391. */
  6392. VolumeBar.prototype.createEl = function createEl() {
  6393. return _Slider.prototype.createEl.call(this, 'div', {
  6394. className: 'vjs-volume-bar vjs-slider-bar'
  6395. }, {
  6396. 'aria-label': 'volume level'
  6397. })
  6398. }
  6399. /**
  6400. * Handle mouse move on volume bar
  6401. *
  6402. * @method handleMouseMove
  6403. */
  6404. VolumeBar.prototype.handleMouseMove = function handleMouseMove(event) {
  6405. this.checkMuted()
  6406. this.player_.volume(this.calculateDistance(event))
  6407. }
  6408. VolumeBar.prototype.checkMuted = function checkMuted() {
  6409. if (this.player_.muted()) {
  6410. this.player_.muted(false)
  6411. }
  6412. }
  6413. /**
  6414. * Get percent of volume level
  6415. *
  6416. * @retun {Number} Volume level percent
  6417. * @method getPercent
  6418. */
  6419. VolumeBar.prototype.getPercent = function getPercent() {
  6420. if (this.player_.muted()) {
  6421. return 0
  6422. } else {
  6423. return this.player_.volume()
  6424. }
  6425. }
  6426. /**
  6427. * Increase volume level for keyboard users
  6428. *
  6429. * @method stepForward
  6430. */
  6431. VolumeBar.prototype.stepForward = function stepForward() {
  6432. this.checkMuted()
  6433. this.player_.volume(this.player_.volume() + 0.1)
  6434. }
  6435. /**
  6436. * Decrease volume level for keyboard users
  6437. *
  6438. * @method stepBack
  6439. */
  6440. VolumeBar.prototype.stepBack = function stepBack() {
  6441. this.checkMuted()
  6442. this.player_.volume(this.player_.volume() - 0.1)
  6443. }
  6444. /**
  6445. * Update ARIA accessibility attributes
  6446. *
  6447. * @method updateARIAAttributes
  6448. */
  6449. VolumeBar.prototype.updateARIAAttributes = function updateARIAAttributes() {
  6450. // Current value of volume bar as a percentage
  6451. var volume = (this.player_.volume() * 100).toFixed(2)
  6452. this.el_.setAttribute('aria-valuenow', volume)
  6453. this.el_.setAttribute('aria-valuetext', volume + '%')
  6454. }
  6455. return VolumeBar
  6456. })(_sliderSliderJs2['default'])
  6457. VolumeBar.prototype.options_ = {
  6458. children: ['volumeLevel'],
  6459. 'barName': 'volumeLevel'
  6460. }
  6461. VolumeBar.prototype.playerEvent = 'volumechange'
  6462. _componentJs2['default'].registerComponent('VolumeBar', VolumeBar)
  6463. exports['default'] = VolumeBar
  6464. module.exports = exports['default']
  6465. }, { '../../component.js': 67, '../../slider/slider.js': 119, '../../utils/fn.js': 145, './volume-level.js': 101 }], 100: [function(_dereq_, module, exports) {
  6466. /**
  6467. * @file volume-control.js
  6468. */
  6469. 'use strict'
  6470. exports.__esModule = true
  6471. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6472. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6473. 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 }
  6474. var _componentJs = _dereq_('../../component.js')
  6475. var _componentJs2 = _interopRequireDefault(_componentJs)
  6476. // Required children
  6477. var _volumeBarJs = _dereq_('./volume-bar.js')
  6478. var _volumeBarJs2 = _interopRequireDefault(_volumeBarJs)
  6479. /**
  6480. * The component for controlling the volume level
  6481. *
  6482. * @param {Player|Object} player
  6483. * @param {Object=} options
  6484. * @extends Component
  6485. * @class VolumeControl
  6486. */
  6487. var VolumeControl = (function(_Component) {
  6488. _inherits(VolumeControl, _Component)
  6489. function VolumeControl(player, options) {
  6490. _classCallCheck(this, VolumeControl)
  6491. _Component.call(this, player, options)
  6492. // hide volume controls when they're not supported by the current tech
  6493. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  6494. this.addClass('vjs-hidden')
  6495. }
  6496. this.on(player, 'loadstart', function() {
  6497. if (player.tech_['featuresVolumeControl'] === false) {
  6498. this.addClass('vjs-hidden')
  6499. } else {
  6500. this.removeClass('vjs-hidden')
  6501. }
  6502. })
  6503. }
  6504. /**
  6505. * Create the component's DOM element
  6506. *
  6507. * @return {Element}
  6508. * @method createEl
  6509. */
  6510. VolumeControl.prototype.createEl = function createEl() {
  6511. return _Component.prototype.createEl.call(this, 'div', {
  6512. className: 'vjs-volume-control vjs-control'
  6513. })
  6514. }
  6515. return VolumeControl
  6516. })(_componentJs2['default'])
  6517. VolumeControl.prototype.options_ = {
  6518. children: ['volumeBar']
  6519. }
  6520. _componentJs2['default'].registerComponent('VolumeControl', VolumeControl)
  6521. exports['default'] = VolumeControl
  6522. module.exports = exports['default']
  6523. }, { '../../component.js': 67, './volume-bar.js': 99 }], 101: [function(_dereq_, module, exports) {
  6524. /**
  6525. * @file volume-level.js
  6526. */
  6527. 'use strict'
  6528. exports.__esModule = true
  6529. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6530. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6531. 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 }
  6532. var _componentJs = _dereq_('../../component.js')
  6533. var _componentJs2 = _interopRequireDefault(_componentJs)
  6534. /**
  6535. * Shows volume level
  6536. *
  6537. * @param {Player|Object} player
  6538. * @param {Object=} options
  6539. * @extends Component
  6540. * @class VolumeLevel
  6541. */
  6542. var VolumeLevel = (function(_Component) {
  6543. _inherits(VolumeLevel, _Component)
  6544. function VolumeLevel() {
  6545. _classCallCheck(this, VolumeLevel)
  6546. _Component.apply(this, arguments)
  6547. }
  6548. /**
  6549. * Create the component's DOM element
  6550. *
  6551. * @return {Element}
  6552. * @method createEl
  6553. */
  6554. VolumeLevel.prototype.createEl = function createEl() {
  6555. return _Component.prototype.createEl.call(this, 'div', {
  6556. className: 'vjs-volume-level',
  6557. innerHTML: '<span class="vjs-control-text"></span>'
  6558. })
  6559. }
  6560. return VolumeLevel
  6561. })(_componentJs2['default'])
  6562. _componentJs2['default'].registerComponent('VolumeLevel', VolumeLevel)
  6563. exports['default'] = VolumeLevel
  6564. module.exports = exports['default']
  6565. }, { '../../component.js': 67 }], 102: [function(_dereq_, module, exports) {
  6566. /**
  6567. * @file volume-menu-button.js
  6568. */
  6569. 'use strict'
  6570. exports.__esModule = true
  6571. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6572. 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 } }
  6573. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6574. 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 }
  6575. var _utilsFnJs = _dereq_('../utils/fn.js')
  6576. var Fn = _interopRequireWildcard(_utilsFnJs)
  6577. var _componentJs = _dereq_('../component.js')
  6578. var _componentJs2 = _interopRequireDefault(_componentJs)
  6579. var _popupPopupJs = _dereq_('../popup/popup.js')
  6580. var _popupPopupJs2 = _interopRequireDefault(_popupPopupJs)
  6581. var _popupPopupButtonJs = _dereq_('../popup/popup-button.js')
  6582. var _popupPopupButtonJs2 = _interopRequireDefault(_popupPopupButtonJs)
  6583. var _muteToggleJs = _dereq_('./mute-toggle.js')
  6584. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs)
  6585. var _volumeControlVolumeBarJs = _dereq_('./volume-control/volume-bar.js')
  6586. var _volumeControlVolumeBarJs2 = _interopRequireDefault(_volumeControlVolumeBarJs)
  6587. /**
  6588. * Button for volume popup
  6589. *
  6590. * @param {Player|Object} player
  6591. * @param {Object=} options
  6592. * @extends PopupButton
  6593. * @class VolumeMenuButton
  6594. */
  6595. var VolumeMenuButton = (function(_PopupButton) {
  6596. _inherits(VolumeMenuButton, _PopupButton)
  6597. function VolumeMenuButton(player) {
  6598. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  6599. _classCallCheck(this, VolumeMenuButton)
  6600. // Default to inline
  6601. if (options.inline === undefined) {
  6602. options.inline = true
  6603. }
  6604. // If the vertical option isn't passed at all, default to true.
  6605. if (options.vertical === undefined) {
  6606. // If an inline volumeMenuButton is used, we should default to using
  6607. // a horizontal slider for obvious reasons.
  6608. if (options.inline) {
  6609. options.vertical = false
  6610. } else {
  6611. options.vertical = true
  6612. }
  6613. }
  6614. // The vertical option needs to be set on the volumeBar as well,
  6615. // since that will need to be passed along to the VolumeBar constructor
  6616. options.volumeBar = options.volumeBar || {}
  6617. options.volumeBar.vertical = !!options.vertical
  6618. _PopupButton.call(this, player, options)
  6619. // Same listeners as MuteToggle
  6620. this.on(player, 'volumechange', this.volumeUpdate)
  6621. this.on(player, 'loadstart', this.volumeUpdate)
  6622. // hide mute toggle if the current tech doesn't support volume control
  6623. function updateVisibility() {
  6624. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  6625. this.addClass('vjs-hidden')
  6626. } else {
  6627. this.removeClass('vjs-hidden')
  6628. }
  6629. }
  6630. updateVisibility.call(this)
  6631. this.on(player, 'loadstart', updateVisibility)
  6632. this.on(this.volumeBar, ['slideractive', 'focus'], function() {
  6633. this.addClass('vjs-slider-active')
  6634. })
  6635. this.on(this.volumeBar, ['sliderinactive', 'blur'], function() {
  6636. this.removeClass('vjs-slider-active')
  6637. })
  6638. this.on(this.volumeBar, ['focus'], function() {
  6639. this.addClass('vjs-lock-showing')
  6640. })
  6641. this.on(this.volumeBar, ['blur'], function() {
  6642. this.removeClass('vjs-lock-showing')
  6643. })
  6644. }
  6645. /**
  6646. * Allow sub components to stack CSS class names
  6647. *
  6648. * @return {String} The constructed class name
  6649. * @method buildCSSClass
  6650. */
  6651. VolumeMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  6652. var orientationClass = ''
  6653. if (this.options_.vertical) {
  6654. orientationClass = 'vjs-volume-menu-button-vertical'
  6655. } else {
  6656. orientationClass = 'vjs-volume-menu-button-horizontal'
  6657. }
  6658. return 'vjs-volume-menu-button ' + _PopupButton.prototype.buildCSSClass.call(this) + ' ' + orientationClass
  6659. }
  6660. /**
  6661. * Allow sub components to stack CSS class names
  6662. *
  6663. * @return {Popup} The volume popup button
  6664. * @method createPopup
  6665. */
  6666. VolumeMenuButton.prototype.createPopup = function createPopup() {
  6667. var popup = new _popupPopupJs2['default'](this.player_, {
  6668. contentElType: 'div'
  6669. })
  6670. var vb = new _volumeControlVolumeBarJs2['default'](this.player_, this.options_.volumeBar)
  6671. popup.addChild(vb)
  6672. this.menuContent = popup
  6673. this.volumeBar = vb
  6674. this.attachVolumeBarEvents()
  6675. return popup
  6676. }
  6677. /**
  6678. * Handle click on volume popup and calls super
  6679. *
  6680. * @method handleClick
  6681. */
  6682. VolumeMenuButton.prototype.handleClick = function handleClick() {
  6683. _muteToggleJs2['default'].prototype.handleClick.call(this)
  6684. _PopupButton.prototype.handleClick.call(this)
  6685. }
  6686. VolumeMenuButton.prototype.attachVolumeBarEvents = function attachVolumeBarEvents() {
  6687. this.menuContent.on(['mousedown', 'touchdown'], Fn.bind(this, this.handleMouseDown))
  6688. }
  6689. VolumeMenuButton.prototype.handleMouseDown = function handleMouseDown(event) {
  6690. this.on(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove))
  6691. this.on(this.el_.ownerDocument, ['mouseup', 'touchend'], this.handleMouseUp)
  6692. }
  6693. VolumeMenuButton.prototype.handleMouseUp = function handleMouseUp(event) {
  6694. this.off(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove))
  6695. }
  6696. return VolumeMenuButton
  6697. })(_popupPopupButtonJs2['default'])
  6698. VolumeMenuButton.prototype.volumeUpdate = _muteToggleJs2['default'].prototype.update
  6699. VolumeMenuButton.prototype.controlText_ = 'Mute'
  6700. _componentJs2['default'].registerComponent('VolumeMenuButton', VolumeMenuButton)
  6701. exports['default'] = VolumeMenuButton
  6702. module.exports = exports['default']
  6703. }, { '../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) {
  6704. /**
  6705. * @file error-display.js
  6706. */
  6707. 'use strict'
  6708. exports.__esModule = true
  6709. 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 } }
  6710. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6711. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6712. 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 }
  6713. var _component = _dereq_('./component')
  6714. var _component2 = _interopRequireDefault(_component)
  6715. var _modalDialog = _dereq_('./modal-dialog')
  6716. var _modalDialog2 = _interopRequireDefault(_modalDialog)
  6717. var _utilsDom = _dereq_('./utils/dom')
  6718. var Dom = _interopRequireWildcard(_utilsDom)
  6719. var _utilsMergeOptions = _dereq_('./utils/merge-options')
  6720. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions)
  6721. /**
  6722. * Display that an error has occurred making the video unplayable.
  6723. *
  6724. * @extends ModalDialog
  6725. * @class ErrorDisplay
  6726. */
  6727. var ErrorDisplay = (function(_ModalDialog) {
  6728. _inherits(ErrorDisplay, _ModalDialog)
  6729. /**
  6730. * Constructor for error display modal.
  6731. *
  6732. * @param {Player} player
  6733. * @param {Object} [options]
  6734. */
  6735. function ErrorDisplay(player, options) {
  6736. _classCallCheck(this, ErrorDisplay)
  6737. _ModalDialog.call(this, player, options)
  6738. this.on(player, 'error', this.open)
  6739. }
  6740. /**
  6741. * Include the old class for backward-compatibility.
  6742. *
  6743. * This can be removed in 6.0.
  6744. *
  6745. * @method buildCSSClass
  6746. * @deprecated
  6747. * @return {String}
  6748. */
  6749. ErrorDisplay.prototype.buildCSSClass = function buildCSSClass() {
  6750. return 'vjs-error-display ' + _ModalDialog.prototype.buildCSSClass.call(this)
  6751. }
  6752. /**
  6753. * Generates the modal content based on the player error.
  6754. *
  6755. * @return {String|Null}
  6756. */
  6757. ErrorDisplay.prototype.content = function content() {
  6758. var error = this.player().error()
  6759. return error ? this.localize(error.message) : ''
  6760. }
  6761. return ErrorDisplay
  6762. })(_modalDialog2['default'])
  6763. ErrorDisplay.prototype.options_ = _utilsMergeOptions2['default'](_modalDialog2['default'].prototype.options_, {
  6764. fillAlways: true,
  6765. temporary: false,
  6766. uncloseable: true
  6767. })
  6768. _component2['default'].registerComponent('ErrorDisplay', ErrorDisplay)
  6769. exports['default'] = ErrorDisplay
  6770. module.exports = exports['default']
  6771. }, { './component': 67, './modal-dialog': 112, './utils/dom': 143, './utils/merge-options': 149 }], 104: [function(_dereq_, module, exports) {
  6772. /**
  6773. * @file event-target.js
  6774. */
  6775. 'use strict'
  6776. exports.__esModule = true
  6777. 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 } }
  6778. var _utilsEventsJs = _dereq_('./utils/events.js')
  6779. var Events = _interopRequireWildcard(_utilsEventsJs)
  6780. var EventTarget = function EventTarget() { }
  6781. EventTarget.prototype.allowedEvents_ = {}
  6782. EventTarget.prototype.on = function(type, fn) {
  6783. // Remove the addEventListener alias before calling Events.on
  6784. // so we don't get into an infinite type loop
  6785. var ael = this.addEventListener
  6786. this.addEventListener = function() { }
  6787. Events.on(this, type, fn)
  6788. this.addEventListener = ael
  6789. }
  6790. EventTarget.prototype.addEventListener = EventTarget.prototype.on
  6791. EventTarget.prototype.off = function(type, fn) {
  6792. Events.off(this, type, fn)
  6793. }
  6794. EventTarget.prototype.removeEventListener = EventTarget.prototype.off
  6795. EventTarget.prototype.one = function(type, fn) {
  6796. // Remove the addEventListener alias before calling Events.on
  6797. // so we don't get into an infinite type loop
  6798. var ael = this.addEventListener
  6799. this.addEventListener = function() { }
  6800. Events.one(this, type, fn)
  6801. this.addEventListener = ael
  6802. }
  6803. EventTarget.prototype.trigger = function(event) {
  6804. var type = event.type || event
  6805. if (typeof event === 'string') {
  6806. event = {
  6807. type: type
  6808. }
  6809. }
  6810. event = Events.fixEvent(event)
  6811. if (this.allowedEvents_[type] && this['on' + type]) {
  6812. this['on' + type](event)
  6813. }
  6814. Events.trigger(this, event)
  6815. }
  6816. // The standard DOM EventTarget.dispatchEvent() is aliased to trigger()
  6817. EventTarget.prototype.dispatchEvent = EventTarget.prototype.trigger
  6818. exports['default'] = EventTarget
  6819. module.exports = exports['default']
  6820. }, { './utils/events.js': 144 }], 105: [function(_dereq_, module, exports) {
  6821. 'use strict'
  6822. exports.__esModule = true
  6823. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6824. var _utilsLog = _dereq_('./utils/log')
  6825. var _utilsLog2 = _interopRequireDefault(_utilsLog)
  6826. /*
  6827. * @file extend.js
  6828. *
  6829. * A combination of node inherits and babel's inherits (after transpile).
  6830. * Both work the same but node adds `super_` to the subClass
  6831. * and Bable adds the superClass as __proto__. Both seem useful.
  6832. */
  6833. var _inherits = function _inherits(subClass, superClass) {
  6834. if (typeof superClass !== 'function' && superClass !== null) {
  6835. throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass)
  6836. }
  6837. subClass.prototype = Object.create(superClass && superClass.prototype, {
  6838. constructor: {
  6839. value: subClass,
  6840. enumerable: false,
  6841. writable: true,
  6842. configurable: true
  6843. }
  6844. })
  6845. if (superClass) {
  6846. // node
  6847. subClass.super_ = superClass
  6848. }
  6849. }
  6850. /*
  6851. * Function for subclassing using the same inheritance that
  6852. * videojs uses internally
  6853. * ```js
  6854. * var Button = videojs.getComponent('Button');
  6855. * ```
  6856. * ```js
  6857. * var MyButton = videojs.extend(Button, {
  6858. * constructor: function(player, options) {
  6859. * Button.call(this, player, options);
  6860. * },
  6861. * onClick: function() {
  6862. * // doSomething
  6863. * }
  6864. * });
  6865. * ```
  6866. */
  6867. var extendFn = function extendFn(superClass) {
  6868. var subClassMethods = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  6869. var subClass = function subClass() {
  6870. superClass.apply(this, arguments)
  6871. }
  6872. var methods = {}
  6873. if (typeof subClassMethods === 'object') {
  6874. if (typeof subClassMethods.init === 'function') {
  6875. _utilsLog2['default'].warn('Constructor logic via init() is deprecated; please use constructor() instead.')
  6876. subClassMethods.constructor = subClassMethods.init
  6877. }
  6878. if (subClassMethods.constructor !== Object.prototype.constructor) {
  6879. subClass = subClassMethods.constructor
  6880. }
  6881. methods = subClassMethods
  6882. } else if (typeof subClassMethods === 'function') {
  6883. subClass = subClassMethods
  6884. }
  6885. _inherits(subClass, superClass)
  6886. // Extend subObj's prototype with functions and other properties from props
  6887. for (var name in methods) {
  6888. if (methods.hasOwnProperty(name)) {
  6889. subClass.prototype[name] = methods[name]
  6890. }
  6891. }
  6892. return subClass
  6893. }
  6894. exports['default'] = extendFn
  6895. module.exports = exports['default']
  6896. }, { './utils/log': 148 }], 106: [function(_dereq_, module, exports) {
  6897. /**
  6898. * @file fullscreen-api.js
  6899. */
  6900. 'use strict'
  6901. exports.__esModule = true
  6902. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6903. var _globalDocument = _dereq_('global/document')
  6904. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  6905. /*
  6906. * Store the browser-specific methods for the fullscreen API
  6907. * @type {Object|undefined}
  6908. * @private
  6909. */
  6910. var FullscreenApi = {}
  6911. // browser API methods
  6912. // map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js
  6913. var apiMap = [
  6914. // Spec: https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
  6915. ['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
  6916. // WebKit
  6917. ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6918. // Old WebKit (Safari 5.1)
  6919. ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6920. // Mozilla
  6921. ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'],
  6922. // Microsoft
  6923. ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']]
  6924. var specApi = apiMap[0]
  6925. var browserApi = undefined
  6926. // determine the supported set of functions
  6927. for (var i = 0; i < apiMap.length; i++) {
  6928. // check for exitFullscreen function
  6929. if (apiMap[i][1] in _globalDocument2['default']) {
  6930. browserApi = apiMap[i]
  6931. break
  6932. }
  6933. }
  6934. // map the browser API names to the spec API names
  6935. if (browserApi) {
  6936. for (var i = 0; i < browserApi.length; i++) {
  6937. FullscreenApi[specApi[i]] = browserApi[i]
  6938. }
  6939. }
  6940. exports['default'] = FullscreenApi
  6941. module.exports = exports['default']
  6942. }, { 'global/document': 1 }], 107: [function(_dereq_, module, exports) {
  6943. /**
  6944. * @file loading-spinner.js
  6945. */
  6946. 'use strict'
  6947. exports.__esModule = true
  6948. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6949. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  6950. 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 }
  6951. var _component = _dereq_('./component')
  6952. var _component2 = _interopRequireDefault(_component)
  6953. /* Loading Spinner
  6954. ================================================================================ */
  6955. /**
  6956. * Loading spinner for waiting events
  6957. *
  6958. * @extends Component
  6959. * @class LoadingSpinner
  6960. */
  6961. var LoadingSpinner = (function(_Component) {
  6962. _inherits(LoadingSpinner, _Component)
  6963. function LoadingSpinner() {
  6964. _classCallCheck(this, LoadingSpinner)
  6965. _Component.apply(this, arguments)
  6966. }
  6967. /**
  6968. * Create the component's DOM element
  6969. *
  6970. * @method createEl
  6971. */
  6972. LoadingSpinner.prototype.createEl = function createEl() {
  6973. return _Component.prototype.createEl.call(this, 'div', {
  6974. className: 'vjs-loading-spinner',
  6975. dir: 'ltr'
  6976. })
  6977. }
  6978. return LoadingSpinner
  6979. })(_component2['default'])
  6980. _component2['default'].registerComponent('LoadingSpinner', LoadingSpinner)
  6981. exports['default'] = LoadingSpinner
  6982. module.exports = exports['default']
  6983. }, { './component': 67 }], 108: [function(_dereq_, module, exports) {
  6984. /**
  6985. * @file media-error.js
  6986. */
  6987. 'use strict'
  6988. exports.__esModule = true
  6989. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  6990. var _objectAssign = _dereq_('object.assign')
  6991. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  6992. /*
  6993. * Custom MediaError to mimic the HTML5 MediaError
  6994. *
  6995. * @param {Number} code The media error code
  6996. */
  6997. var MediaError = function MediaError(code) {
  6998. if (typeof code === 'number') {
  6999. this.code = code
  7000. } else if (typeof code === 'string') {
  7001. // default code is zero, so this is a custom error
  7002. this.message = code
  7003. } else if (typeof code === 'object') {
  7004. // object
  7005. _objectAssign2['default'](this, code)
  7006. }
  7007. if (!this.message) {
  7008. this.message = MediaError.defaultMessages[this.code] || ''
  7009. }
  7010. }
  7011. /*
  7012. * The error code that refers two one of the defined
  7013. * MediaError types
  7014. *
  7015. * @type {Number}
  7016. */
  7017. MediaError.prototype.code = 0
  7018. /*
  7019. * An optional message to be shown with the error.
  7020. * Message is not part of the HTML5 video spec
  7021. * but allows for more informative custom errors.
  7022. *
  7023. * @type {String}
  7024. */
  7025. MediaError.prototype.message = ''
  7026. /*
  7027. * An optional status code that can be set by plugins
  7028. * to allow even more detail about the error.
  7029. * For example the HLS plugin might provide the specific
  7030. * HTTP status code that was returned when the error
  7031. * occurred, then allowing a custom error overlay
  7032. * to display more information.
  7033. *
  7034. * @type {Array}
  7035. */
  7036. MediaError.prototype.status = null
  7037. MediaError.errorTypes = ['MEDIA_ERR_CUSTOM', // = 0
  7038. 'MEDIA_ERR_ABORTED', // = 1
  7039. 'MEDIA_ERR_NETWORK', // = 2
  7040. 'MEDIA_ERR_DECODE', // = 3
  7041. 'MEDIA_ERR_SRC_NOT_SUPPORTED', // = 4
  7042. 'MEDIA_ERR_ENCRYPTED' // = 5
  7043. ]
  7044. MediaError.defaultMessages = {
  7045. 1: 'You aborted the media playback',
  7046. 2: 'A network error caused the media download to fail part-way.',
  7047. 3: 'The media playback was aborted due to a corruption problem or because the media used features your browser did not support.',
  7048. 4: 'The media could not be loaded, either because the server or network failed or because the format is not supported.',
  7049. 5: 'The media is encrypted and we do not have the keys to decrypt it.'
  7050. }
  7051. // Add types as properties on MediaError
  7052. // e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
  7053. for (var errNum = 0; errNum < MediaError.errorTypes.length; errNum++) {
  7054. MediaError[MediaError.errorTypes[errNum]] = errNum
  7055. // values should be accessible on both the class and instance
  7056. MediaError.prototype[MediaError.errorTypes[errNum]] = errNum
  7057. }
  7058. exports['default'] = MediaError
  7059. module.exports = exports['default']
  7060. }, { 'object.assign': 45 }], 109: [function(_dereq_, module, exports) {
  7061. /**
  7062. * @file menu-button.js
  7063. */
  7064. 'use strict'
  7065. exports.__esModule = true
  7066. 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 } }
  7067. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  7068. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  7069. 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 }
  7070. var _clickableComponentJs = _dereq_('../clickable-component.js')
  7071. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs)
  7072. var _componentJs = _dereq_('../component.js')
  7073. var _componentJs2 = _interopRequireDefault(_componentJs)
  7074. var _menuJs = _dereq_('./menu.js')
  7075. var _menuJs2 = _interopRequireDefault(_menuJs)
  7076. var _utilsDomJs = _dereq_('../utils/dom.js')
  7077. var Dom = _interopRequireWildcard(_utilsDomJs)
  7078. var _utilsFnJs = _dereq_('../utils/fn.js')
  7079. var Fn = _interopRequireWildcard(_utilsFnJs)
  7080. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js')
  7081. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs)
  7082. /**
  7083. * A button class with a popup menu
  7084. *
  7085. * @param {Player|Object} player
  7086. * @param {Object=} options
  7087. * @extends Button
  7088. * @class MenuButton
  7089. */
  7090. var MenuButton = (function(_ClickableComponent) {
  7091. _inherits(MenuButton, _ClickableComponent)
  7092. function MenuButton(player) {
  7093. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  7094. _classCallCheck(this, MenuButton)
  7095. _ClickableComponent.call(this, player, options)
  7096. this.update()
  7097. this.enabled_ = true
  7098. this.el_.setAttribute('aria-haspopup', 'true')
  7099. this.el_.setAttribute('role', 'menuitem')
  7100. this.on('keydown', this.handleSubmenuKeyPress)
  7101. }
  7102. /**
  7103. * Update menu
  7104. *
  7105. * @method update
  7106. */
  7107. MenuButton.prototype.update = function update() {
  7108. var menu = this.createMenu()
  7109. if (this.menu) {
  7110. this.removeChild(this.menu)
  7111. }
  7112. this.menu = menu
  7113. this.addChild(menu)
  7114. /**
  7115. * Track the state of the menu button
  7116. *
  7117. * @type {Boolean}
  7118. * @private
  7119. */
  7120. this.buttonPressed_ = false
  7121. this.el_.setAttribute('aria-expanded', 'false')
  7122. if (this.items && this.items.length === 0) {
  7123. this.hide()
  7124. } else if (this.items && this.items.length > 1) {
  7125. this.show()
  7126. }
  7127. }
  7128. /**
  7129. * Create menu
  7130. *
  7131. * @return {Menu} The constructed menu
  7132. * @method createMenu
  7133. */
  7134. MenuButton.prototype.createMenu = function createMenu() {
  7135. var menu = new _menuJs2['default'](this.player_)
  7136. // Add a title list item to the top
  7137. if (this.options_.title) {
  7138. var title = Dom.createEl('li', {
  7139. className: 'vjs-menu-title',
  7140. innerHTML: _utilsToTitleCaseJs2['default'](this.options_.title),
  7141. tabIndex: -1
  7142. })
  7143. menu.children_.unshift(title)
  7144. Dom.insertElFirst(title, menu.contentEl())
  7145. }
  7146. this.items = this['createItems']()
  7147. if (this.items) {
  7148. // Add menu items to the menu
  7149. for (var i = 0; i < this.items.length; i++) {
  7150. menu.addItem(this.items[i])
  7151. }
  7152. }
  7153. return menu
  7154. }
  7155. /**
  7156. * Create the list of menu items. Specific to each subclass.
  7157. *
  7158. * @method createItems
  7159. */
  7160. MenuButton.prototype.createItems = function createItems() { }
  7161. /**
  7162. * Create the component's DOM element
  7163. *
  7164. * @return {Element}
  7165. * @method createEl
  7166. */
  7167. MenuButton.prototype.createEl = function createEl() {
  7168. return _ClickableComponent.prototype.createEl.call(this, 'div', {
  7169. className: this.buildCSSClass()
  7170. })
  7171. }
  7172. /**
  7173. * Allow sub components to stack CSS class names
  7174. *
  7175. * @return {String} The constructed class name
  7176. * @method buildCSSClass
  7177. */
  7178. MenuButton.prototype.buildCSSClass = function buildCSSClass() {
  7179. var menuButtonClass = 'vjs-menu-button'
  7180. // If the inline option is passed, we want to use different styles altogether.
  7181. if (this.options_.inline === true) {
  7182. menuButtonClass += '-inline'
  7183. } else {
  7184. menuButtonClass += '-popup'
  7185. }
  7186. return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this)
  7187. }
  7188. /**
  7189. * When you click the button it adds focus, which
  7190. * will show the menu indefinitely.
  7191. * So we'll remove focus when the mouse leaves the button.
  7192. * Focus is needed for tab navigation.
  7193. * Allow sub components to stack CSS class names
  7194. *
  7195. * @method handleClick
  7196. */
  7197. MenuButton.prototype.handleClick = function handleClick() {
  7198. this.one('mouseout', Fn.bind(this, function() {
  7199. this.menu.unlockShowing()
  7200. this.el_.blur()
  7201. }))
  7202. if (this.buttonPressed_) {
  7203. this.unpressButton()
  7204. } else {
  7205. this.pressButton()
  7206. }
  7207. }
  7208. /**
  7209. * Handle key press on menu
  7210. *
  7211. * @param {Object} event Key press event
  7212. * @method handleKeyPress
  7213. */
  7214. MenuButton.prototype.handleKeyPress = function handleKeyPress(event) {
  7215. // Escape (27) key or Tab (9) key unpress the 'button'
  7216. if (event.which === 27 || event.which === 9) {
  7217. if (this.buttonPressed_) {
  7218. this.unpressButton()
  7219. }
  7220. // Don't preventDefault for Tab key - we still want to lose focus
  7221. if (event.which !== 9) {
  7222. event.preventDefault()
  7223. }
  7224. // Up (38) key or Down (40) key press the 'button'
  7225. } else if (event.which === 38 || event.which === 40) {
  7226. if (!this.buttonPressed_) {
  7227. this.pressButton()
  7228. event.preventDefault()
  7229. }
  7230. } else {
  7231. _ClickableComponent.prototype.handleKeyPress.call(this, event)
  7232. }
  7233. }
  7234. /**
  7235. * Handle key press on submenu
  7236. *
  7237. * @param {Object} event Key press event
  7238. * @method handleSubmenuKeyPress
  7239. */
  7240. MenuButton.prototype.handleSubmenuKeyPress = function handleSubmenuKeyPress(event) {
  7241. // Escape (27) key or Tab (9) key unpress the 'button'
  7242. if (event.which === 27 || event.which === 9) {
  7243. if (this.buttonPressed_) {
  7244. this.unpressButton()
  7245. }
  7246. // Don't preventDefault for Tab key - we still want to lose focus
  7247. if (event.which !== 9) {
  7248. event.preventDefault()
  7249. }
  7250. }
  7251. }
  7252. /**
  7253. * Makes changes based on button pressed
  7254. *
  7255. * @method pressButton
  7256. */
  7257. MenuButton.prototype.pressButton = function pressButton() {
  7258. if (this.enabled_) {
  7259. this.buttonPressed_ = true
  7260. this.menu.lockShowing()
  7261. this.el_.setAttribute('aria-expanded', 'true')
  7262. this.menu.focus() // set the focus into the submenu
  7263. }
  7264. }
  7265. /**
  7266. * Makes changes based on button unpressed
  7267. *
  7268. * @method unpressButton
  7269. */
  7270. MenuButton.prototype.unpressButton = function unpressButton() {
  7271. if (this.enabled_) {
  7272. this.buttonPressed_ = false
  7273. this.menu.unlockShowing()
  7274. this.el_.setAttribute('aria-expanded', 'false')
  7275. this.el_.focus() // Set focus back to this menu button
  7276. }
  7277. }
  7278. /**
  7279. * Disable the menu button
  7280. *
  7281. * @return {Component}
  7282. * @method disable
  7283. */
  7284. MenuButton.prototype.disable = function disable() {
  7285. // Unpress, but don't force focus on this button
  7286. this.buttonPressed_ = false
  7287. this.menu.unlockShowing()
  7288. this.el_.setAttribute('aria-expanded', 'false')
  7289. this.enabled_ = false
  7290. return _ClickableComponent.prototype.disable.call(this)
  7291. }
  7292. /**
  7293. * Enable the menu button
  7294. *
  7295. * @return {Component}
  7296. * @method disable
  7297. */
  7298. MenuButton.prototype.enable = function enable() {
  7299. this.enabled_ = true
  7300. return _ClickableComponent.prototype.enable.call(this)
  7301. }
  7302. return MenuButton
  7303. })(_clickableComponentJs2['default'])
  7304. _componentJs2['default'].registerComponent('MenuButton', MenuButton)
  7305. exports['default'] = MenuButton
  7306. module.exports = exports['default']
  7307. }, { '../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) {
  7308. /**
  7309. * @file menu-item.js
  7310. */
  7311. 'use strict'
  7312. exports.__esModule = true
  7313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  7314. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  7315. 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 }
  7316. var _clickableComponentJs = _dereq_('../clickable-component.js')
  7317. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs)
  7318. var _componentJs = _dereq_('../component.js')
  7319. var _componentJs2 = _interopRequireDefault(_componentJs)
  7320. var _objectAssign = _dereq_('object.assign')
  7321. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  7322. /**
  7323. * The component for a menu item. `<li>`
  7324. *
  7325. * @param {Player|Object} player
  7326. * @param {Object=} options
  7327. * @extends Button
  7328. * @class MenuItem
  7329. */
  7330. var MenuItem = (function(_ClickableComponent) {
  7331. _inherits(MenuItem, _ClickableComponent)
  7332. function MenuItem(player, options) {
  7333. _classCallCheck(this, MenuItem)
  7334. _ClickableComponent.call(this, player, options)
  7335. this.selectable = options['selectable']
  7336. this.selected(options['selected'])
  7337. if (this.selectable) {
  7338. // TODO: May need to be either menuitemcheckbox or menuitemradio,
  7339. // and may need logical grouping of menu items.
  7340. this.el_.setAttribute('role', 'menuitemcheckbox')
  7341. } else {
  7342. this.el_.setAttribute('role', 'menuitem')
  7343. }
  7344. }
  7345. /**
  7346. * Create the component's DOM element
  7347. *
  7348. * @param {String=} type Desc
  7349. * @param {Object=} props Desc
  7350. * @return {Element}
  7351. * @method createEl
  7352. */
  7353. MenuItem.prototype.createEl = function createEl(type, props, attrs) {
  7354. return _ClickableComponent.prototype.createEl.call(this, 'li', _objectAssign2['default']({
  7355. className: 'vjs-menu-item',
  7356. innerHTML: this.localize(this.options_['label']),
  7357. tabIndex: -1
  7358. }, props), attrs)
  7359. }
  7360. /**
  7361. * Handle a click on the menu item, and set it to selected
  7362. *
  7363. * @method handleClick
  7364. */
  7365. MenuItem.prototype.handleClick = function handleClick() {
  7366. this.selected(true)
  7367. }
  7368. /**
  7369. * Set this menu item as selected or not
  7370. *
  7371. * @param {Boolean} selected
  7372. * @method selected
  7373. */
  7374. MenuItem.prototype.selected = function selected(_selected) {
  7375. if (this.selectable) {
  7376. if (_selected) {
  7377. this.addClass('vjs-selected')
  7378. this.el_.setAttribute('aria-checked', 'true')
  7379. // aria-checked isn't fully supported by browsers/screen readers,
  7380. // so indicate selected state to screen reader in the control text.
  7381. this.controlText(', selected')
  7382. } else {
  7383. this.removeClass('vjs-selected')
  7384. this.el_.setAttribute('aria-checked', 'false')
  7385. // Indicate un-selected state to screen reader
  7386. // Note that a space clears out the selected state text
  7387. this.controlText(' ')
  7388. }
  7389. }
  7390. }
  7391. return MenuItem
  7392. })(_clickableComponentJs2['default'])
  7393. _componentJs2['default'].registerComponent('MenuItem', MenuItem)
  7394. exports['default'] = MenuItem
  7395. module.exports = exports['default']
  7396. }, { '../clickable-component.js': 65, '../component.js': 67, 'object.assign': 45 }], 111: [function(_dereq_, module, exports) {
  7397. /**
  7398. * @file menu.js
  7399. */
  7400. 'use strict'
  7401. exports.__esModule = true
  7402. 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 } }
  7403. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  7404. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  7405. 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 }
  7406. var _componentJs = _dereq_('../component.js')
  7407. var _componentJs2 = _interopRequireDefault(_componentJs)
  7408. var _utilsDomJs = _dereq_('../utils/dom.js')
  7409. var Dom = _interopRequireWildcard(_utilsDomJs)
  7410. var _utilsFnJs = _dereq_('../utils/fn.js')
  7411. var Fn = _interopRequireWildcard(_utilsFnJs)
  7412. var _utilsEventsJs = _dereq_('../utils/events.js')
  7413. var Events = _interopRequireWildcard(_utilsEventsJs)
  7414. /**
  7415. * The Menu component is used to build pop up menus, including subtitle and
  7416. * captions selection menus.
  7417. *
  7418. * @extends Component
  7419. * @class Menu
  7420. */
  7421. var Menu = (function(_Component) {
  7422. _inherits(Menu, _Component)
  7423. function Menu(player, options) {
  7424. _classCallCheck(this, Menu)
  7425. _Component.call(this, player, options)
  7426. this.focusedChild_ = -1
  7427. this.on('keydown', this.handleKeyPress)
  7428. }
  7429. /**
  7430. * Add a menu item to the menu
  7431. *
  7432. * @param {Object|String} component Component or component type to add
  7433. * @method addItem
  7434. */
  7435. Menu.prototype.addItem = function addItem(component) {
  7436. this.addChild(component)
  7437. component.on('click', Fn.bind(this, function() {
  7438. this.unlockShowing()
  7439. // TODO: Need to set keyboard focus back to the menuButton
  7440. }))
  7441. }
  7442. /**
  7443. * Create the component's DOM element
  7444. *
  7445. * @return {Element}
  7446. * @method createEl
  7447. */
  7448. Menu.prototype.createEl = function createEl() {
  7449. var contentElType = this.options_.contentElType || 'ul'
  7450. this.contentEl_ = Dom.createEl(contentElType, {
  7451. className: 'vjs-menu-content'
  7452. })
  7453. this.contentEl_.setAttribute('role', 'menu')
  7454. var el = _Component.prototype.createEl.call(this, 'div', {
  7455. append: this.contentEl_,
  7456. className: 'vjs-menu'
  7457. })
  7458. el.setAttribute('role', 'presentation')
  7459. el.appendChild(this.contentEl_)
  7460. // Prevent clicks from bubbling up. Needed for Menu Buttons,
  7461. // where a click on the parent is significant
  7462. Events.on(el, 'click', function(event) {
  7463. event.preventDefault()
  7464. event.stopImmediatePropagation()
  7465. })
  7466. return el
  7467. }
  7468. /**
  7469. * Handle key press for menu
  7470. *
  7471. * @param {Object} event Event object
  7472. * @method handleKeyPress
  7473. */
  7474. Menu.prototype.handleKeyPress = function handleKeyPress(event) {
  7475. if (event.which === 37 || event.which === 40) {
  7476. // Left and Down Arrows
  7477. event.preventDefault()
  7478. this.stepForward()
  7479. } else if (event.which === 38 || event.which === 39) {
  7480. // Up and Right Arrows
  7481. event.preventDefault()
  7482. this.stepBack()
  7483. }
  7484. }
  7485. /**
  7486. * Move to next (lower) menu item for keyboard users
  7487. *
  7488. * @method stepForward
  7489. */
  7490. Menu.prototype.stepForward = function stepForward() {
  7491. var stepChild = 0
  7492. if (this.focusedChild_ !== undefined) {
  7493. stepChild = this.focusedChild_ + 1
  7494. }
  7495. this.focus(stepChild)
  7496. }
  7497. /**
  7498. * Move to previous (higher) menu item for keyboard users
  7499. *
  7500. * @method stepBack
  7501. */
  7502. Menu.prototype.stepBack = function stepBack() {
  7503. var stepChild = 0
  7504. if (this.focusedChild_ !== undefined) {
  7505. stepChild = this.focusedChild_ - 1
  7506. }
  7507. this.focus(stepChild)
  7508. }
  7509. /**
  7510. * Set focus on a menu item in the menu
  7511. *
  7512. * @param {Object|String} item Index of child item set focus on
  7513. * @method focus
  7514. */
  7515. Menu.prototype.focus = function focus() {
  7516. var item = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]
  7517. var children = this.children().slice()
  7518. var haveTitle = children.length && children[0].className && /vjs-menu-title/.test(children[0].className)
  7519. if (haveTitle) {
  7520. children.shift()
  7521. }
  7522. if (children.length > 0) {
  7523. if (item < 0) {
  7524. item = 0
  7525. } else if (item >= children.length) {
  7526. item = children.length - 1
  7527. }
  7528. this.focusedChild_ = item
  7529. children[item].el_.focus()
  7530. }
  7531. }
  7532. return Menu
  7533. })(_componentJs2['default'])
  7534. _componentJs2['default'].registerComponent('Menu', Menu)
  7535. exports['default'] = Menu
  7536. module.exports = exports['default']
  7537. }, { '../component.js': 67, '../utils/dom.js': 143, '../utils/events.js': 144, '../utils/fn.js': 145 }], 112: [function(_dereq_, module, exports) {
  7538. /**
  7539. * @file modal-dialog.js
  7540. */
  7541. 'use strict'
  7542. exports.__esModule = true
  7543. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  7544. 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 } }
  7545. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  7546. 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 }
  7547. var _utilsDom = _dereq_('./utils/dom')
  7548. var Dom = _interopRequireWildcard(_utilsDom)
  7549. var _utilsFn = _dereq_('./utils/fn')
  7550. var Fn = _interopRequireWildcard(_utilsFn)
  7551. var _utilsLog = _dereq_('./utils/log')
  7552. var _utilsLog2 = _interopRequireDefault(_utilsLog)
  7553. var _component = _dereq_('./component')
  7554. var _component2 = _interopRequireDefault(_component)
  7555. var _closeButton = _dereq_('./close-button')
  7556. var _closeButton2 = _interopRequireDefault(_closeButton)
  7557. var MODAL_CLASS_NAME = 'vjs-modal-dialog'
  7558. var ESC = 27
  7559. /**
  7560. * The `ModalDialog` displays over the video and its controls, which blocks
  7561. * interaction with the player until it is closed.
  7562. *
  7563. * Modal dialogs include a "Close" button and will close when that button
  7564. * is activated - or when ESC is pressed anywhere.
  7565. *
  7566. * @extends Component
  7567. * @class ModalDialog
  7568. */
  7569. var ModalDialog = (function(_Component) {
  7570. _inherits(ModalDialog, _Component)
  7571. /**
  7572. * Constructor for modals.
  7573. *
  7574. * @param {Player} player
  7575. * @param {Object} [options]
  7576. * @param {Mixed} [options.content=undefined]
  7577. * Provide customized content for this modal.
  7578. *
  7579. * @param {String} [options.description]
  7580. * A text description for the modal, primarily for accessibility.
  7581. *
  7582. * @param {Boolean} [options.fillAlways=false]
  7583. * Normally, modals are automatically filled only the first time
  7584. * they open. This tells the modal to refresh its content
  7585. * every time it opens.
  7586. *
  7587. * @param {String} [options.label]
  7588. * A text label for the modal, primarily for accessibility.
  7589. *
  7590. * @param {Boolean} [options.temporary=true]
  7591. * If `true`, the modal can only be opened once; it will be
  7592. * disposed as soon as it's closed.
  7593. *
  7594. * @param {Boolean} [options.uncloseable=false]
  7595. * If `true`, the user will not be able to close the modal
  7596. * through the UI in the normal ways. Programmatic closing is
  7597. * still possible.
  7598. *
  7599. */
  7600. function ModalDialog(player, options) {
  7601. _classCallCheck(this, ModalDialog)
  7602. _Component.call(this, player, options)
  7603. this.opened_ = this.hasBeenOpened_ = this.hasBeenFilled_ = false
  7604. this.closeable(!this.options_.uncloseable)
  7605. this.content(this.options_.content)
  7606. // Make sure the contentEl is defined AFTER any children are initialized
  7607. // because we only want the contents of the modal in the contentEl
  7608. // (not the UI elements like the close button).
  7609. this.contentEl_ = Dom.createEl('div', {
  7610. className: MODAL_CLASS_NAME + '-content'
  7611. }, {
  7612. role: 'document'
  7613. })
  7614. this.descEl_ = Dom.createEl('p', {
  7615. className: MODAL_CLASS_NAME + '-description vjs-offscreen',
  7616. id: this.el().getAttribute('aria-describedby')
  7617. })
  7618. Dom.textContent(this.descEl_, this.description())
  7619. this.el_.appendChild(this.descEl_)
  7620. this.el_.appendChild(this.contentEl_)
  7621. }
  7622. /*
  7623. * Modal dialog default options.
  7624. *
  7625. * @type {Object}
  7626. * @private
  7627. */
  7628. /**
  7629. * Create the modal's DOM element
  7630. *
  7631. * @method createEl
  7632. * @return {Element}
  7633. */
  7634. ModalDialog.prototype.createEl = function createEl() {
  7635. return _Component.prototype.createEl.call(this, 'div', {
  7636. className: this.buildCSSClass(),
  7637. tabIndex: -1
  7638. }, {
  7639. 'aria-describedby': this.id() + '_description',
  7640. 'aria-hidden': 'true',
  7641. 'aria-label': this.label(),
  7642. role: 'dialog'
  7643. })
  7644. }
  7645. /**
  7646. * Build the modal's CSS class.
  7647. *
  7648. * @method buildCSSClass
  7649. * @return {String}
  7650. */
  7651. ModalDialog.prototype.buildCSSClass = function buildCSSClass() {
  7652. return MODAL_CLASS_NAME + ' vjs-hidden ' + _Component.prototype.buildCSSClass.call(this)
  7653. }
  7654. /**
  7655. * Handles key presses on the document, looking for ESC, which closes
  7656. * the modal.
  7657. *
  7658. * @method handleKeyPress
  7659. * @param {Event} e
  7660. */
  7661. ModalDialog.prototype.handleKeyPress = function handleKeyPress(e) {
  7662. if (e.which === ESC && this.closeable()) {
  7663. this.close()
  7664. }
  7665. }
  7666. /**
  7667. * Returns the label string for this modal. Primarily used for accessibility.
  7668. *
  7669. * @return {String}
  7670. */
  7671. ModalDialog.prototype.label = function label() {
  7672. return this.options_.label || this.localize('Modal Window')
  7673. }
  7674. /**
  7675. * Returns the description string for this modal. Primarily used for
  7676. * accessibility.
  7677. *
  7678. * @return {String}
  7679. */
  7680. ModalDialog.prototype.description = function description() {
  7681. var desc = this.options_.description || this.localize('This is a modal window.')
  7682. // Append a universal closeability message if the modal is closeable.
  7683. if (this.closeable()) {
  7684. desc += ' ' + this.localize('This modal can be closed by pressing the Escape key or activating the close button.')
  7685. }
  7686. return desc
  7687. }
  7688. /**
  7689. * Opens the modal.
  7690. *
  7691. * @method open
  7692. * @return {ModalDialog}
  7693. */
  7694. ModalDialog.prototype.open = function open() {
  7695. if (!this.opened_) {
  7696. var player = this.player()
  7697. this.trigger('beforemodalopen')
  7698. this.opened_ = true
  7699. // Fill content if the modal has never opened before and
  7700. // never been filled.
  7701. if (this.options_.fillAlways || !this.hasBeenOpened_ && !this.hasBeenFilled_) {
  7702. this.fill()
  7703. }
  7704. // If the player was playing, pause it and take note of its previously
  7705. // playing state.
  7706. this.wasPlaying_ = !player.paused()
  7707. if (this.wasPlaying_) {
  7708. player.pause()
  7709. }
  7710. if (this.closeable()) {
  7711. this.on(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress))
  7712. }
  7713. player.controls(false)
  7714. this.show()
  7715. this.el().setAttribute('aria-hidden', 'false')
  7716. this.trigger('modalopen')
  7717. this.hasBeenOpened_ = true
  7718. }
  7719. return this
  7720. }
  7721. /**
  7722. * Whether or not the modal is opened currently.
  7723. *
  7724. * @method opened
  7725. * @param {Boolean} [value]
  7726. * If given, it will open (`true`) or close (`false`) the modal.
  7727. *
  7728. * @return {Boolean}
  7729. */
  7730. ModalDialog.prototype.opened = function opened(value) {
  7731. if (typeof value === 'boolean') {
  7732. this[value ? 'open' : 'close']()
  7733. }
  7734. return this.opened_
  7735. }
  7736. /**
  7737. * Closes the modal.
  7738. *
  7739. * @method close
  7740. * @return {ModalDialog}
  7741. */
  7742. ModalDialog.prototype.close = function close() {
  7743. if (this.opened_) {
  7744. var player = this.player()
  7745. this.trigger('beforemodalclose')
  7746. this.opened_ = false
  7747. if (this.wasPlaying_) {
  7748. player.play()
  7749. }
  7750. if (this.closeable()) {
  7751. this.off(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress))
  7752. }
  7753. player.controls(true)
  7754. this.hide()
  7755. this.el().setAttribute('aria-hidden', 'true')
  7756. this.trigger('modalclose')
  7757. if (this.options_.temporary) {
  7758. this.dispose()
  7759. }
  7760. }
  7761. return this
  7762. }
  7763. /**
  7764. * Whether or not the modal is closeable via the UI.
  7765. *
  7766. * @method closeable
  7767. * @param {Boolean} [value]
  7768. * If given as a Boolean, it will set the `closeable` option.
  7769. *
  7770. * @return {Boolean}
  7771. */
  7772. ModalDialog.prototype.closeable = function closeable(value) {
  7773. if (typeof value === 'boolean') {
  7774. var closeable = this.closeable_ = !!value
  7775. var _close = this.getChild('closeButton')
  7776. // If this is being made closeable and has no close button, add one.
  7777. if (closeable && !_close) {
  7778. // The close button should be a child of the modal - not its
  7779. // content element, so temporarily change the content element.
  7780. var temp = this.contentEl_
  7781. this.contentEl_ = this.el_
  7782. _close = this.addChild('closeButton')
  7783. this.contentEl_ = temp
  7784. this.on(_close, 'close', this.close)
  7785. }
  7786. // If this is being made uncloseable and has a close button, remove it.
  7787. if (!closeable && _close) {
  7788. this.off(_close, 'close', this.close)
  7789. this.removeChild(_close)
  7790. _close.dispose()
  7791. }
  7792. }
  7793. return this.closeable_
  7794. }
  7795. /**
  7796. * Fill the modal's content element with the modal's "content" option.
  7797. *
  7798. * The content element will be emptied before this change takes place.
  7799. *
  7800. * @method fill
  7801. * @return {ModalDialog}
  7802. */
  7803. ModalDialog.prototype.fill = function fill() {
  7804. return this.fillWith(this.content())
  7805. }
  7806. /**
  7807. * Fill the modal's content element with arbitrary content.
  7808. *
  7809. * The content element will be emptied before this change takes place.
  7810. *
  7811. * @method fillWith
  7812. * @param {Mixed} [content]
  7813. * The same rules apply to this as apply to the `content` option.
  7814. *
  7815. * @return {ModalDialog}
  7816. */
  7817. ModalDialog.prototype.fillWith = function fillWith(content) {
  7818. var contentEl = this.contentEl()
  7819. var parentEl = contentEl.parentNode
  7820. var nextSiblingEl = contentEl.nextSibling
  7821. this.trigger('beforemodalfill')
  7822. this.hasBeenFilled_ = true
  7823. // Detach the content element from the DOM before performing
  7824. // manipulation to avoid modifying the live DOM multiple times.
  7825. parentEl.removeChild(contentEl)
  7826. this.empty()
  7827. Dom.insertContent(contentEl, content)
  7828. this.trigger('modalfill')
  7829. // Re-inject the re-filled content element.
  7830. if (nextSiblingEl) {
  7831. parentEl.insertBefore(contentEl, nextSiblingEl)
  7832. } else {
  7833. parentEl.appendChild(contentEl)
  7834. }
  7835. return this
  7836. }
  7837. /**
  7838. * Empties the content element.
  7839. *
  7840. * This happens automatically anytime the modal is filled.
  7841. *
  7842. * @method empty
  7843. * @return {ModalDialog}
  7844. */
  7845. ModalDialog.prototype.empty = function empty() {
  7846. this.trigger('beforemodalempty')
  7847. Dom.emptyEl(this.contentEl())
  7848. this.trigger('modalempty')
  7849. return this
  7850. }
  7851. /**
  7852. * Gets or sets the modal content, which gets normalized before being
  7853. * rendered into the DOM.
  7854. *
  7855. * This does not update the DOM or fill the modal, but it is called during
  7856. * that process.
  7857. *
  7858. * @method content
  7859. * @param {Mixed} [value]
  7860. * If defined, sets the internal content value to be used on the
  7861. * next call(s) to `fill`. This value is normalized before being
  7862. * inserted. To "clear" the internal content value, pass `null`.
  7863. *
  7864. * @return {Mixed}
  7865. */
  7866. ModalDialog.prototype.content = function content(value) {
  7867. if (typeof value !== 'undefined') {
  7868. this.content_ = value
  7869. }
  7870. return this.content_
  7871. }
  7872. return ModalDialog
  7873. })(_component2['default'])
  7874. ModalDialog.prototype.options_ = {
  7875. temporary: true
  7876. }
  7877. _component2['default'].registerComponent('ModalDialog', ModalDialog)
  7878. exports['default'] = ModalDialog
  7879. module.exports = exports['default']
  7880. }, { './close-button': 66, './component': 67, './utils/dom': 143, './utils/fn': 145, './utils/log': 148 }], 113: [function(_dereq_, module, exports) {
  7881. /**
  7882. * @file player.js
  7883. */
  7884. // Subclasses Component
  7885. 'use strict'
  7886. exports.__esModule = true
  7887. 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 } }
  7888. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  7889. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  7890. 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 }
  7891. var _componentJs = _dereq_('./component.js')
  7892. var _componentJs2 = _interopRequireDefault(_componentJs)
  7893. var _globalDocument = _dereq_('global/document')
  7894. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  7895. var _globalWindow = _dereq_('global/window')
  7896. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  7897. var _utilsEventsJs = _dereq_('./utils/events.js')
  7898. var Events = _interopRequireWildcard(_utilsEventsJs)
  7899. var _utilsDomJs = _dereq_('./utils/dom.js')
  7900. var Dom = _interopRequireWildcard(_utilsDomJs)
  7901. var _utilsFnJs = _dereq_('./utils/fn.js')
  7902. var Fn = _interopRequireWildcard(_utilsFnJs)
  7903. var _utilsGuidJs = _dereq_('./utils/guid.js')
  7904. var Guid = _interopRequireWildcard(_utilsGuidJs)
  7905. var _utilsBrowserJs = _dereq_('./utils/browser.js')
  7906. var browser = _interopRequireWildcard(_utilsBrowserJs)
  7907. var _utilsLogJs = _dereq_('./utils/log.js')
  7908. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  7909. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js')
  7910. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs)
  7911. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js')
  7912. var _utilsBufferJs = _dereq_('./utils/buffer.js')
  7913. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js')
  7914. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs)
  7915. var _fullscreenApiJs = _dereq_('./fullscreen-api.js')
  7916. var _fullscreenApiJs2 = _interopRequireDefault(_fullscreenApiJs)
  7917. var _mediaErrorJs = _dereq_('./media-error.js')
  7918. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs)
  7919. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple')
  7920. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple)
  7921. var _objectAssign = _dereq_('object.assign')
  7922. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  7923. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js')
  7924. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs)
  7925. var _tracksTextTrackListConverterJs = _dereq_('./tracks/text-track-list-converter.js')
  7926. var _tracksTextTrackListConverterJs2 = _interopRequireDefault(_tracksTextTrackListConverterJs)
  7927. var _tracksAudioTrackListJs = _dereq_('./tracks/audio-track-list.js')
  7928. var _tracksAudioTrackListJs2 = _interopRequireDefault(_tracksAudioTrackListJs)
  7929. var _tracksVideoTrackListJs = _dereq_('./tracks/video-track-list.js')
  7930. var _tracksVideoTrackListJs2 = _interopRequireDefault(_tracksVideoTrackListJs)
  7931. // Include required child components (importing also registers them)
  7932. var _techLoaderJs = _dereq_('./tech/loader.js')
  7933. var _techLoaderJs2 = _interopRequireDefault(_techLoaderJs)
  7934. var _posterImageJs = _dereq_('./poster-image.js')
  7935. var _posterImageJs2 = _interopRequireDefault(_posterImageJs)
  7936. var _tracksTextTrackDisplayJs = _dereq_('./tracks/text-track-display.js')
  7937. var _tracksTextTrackDisplayJs2 = _interopRequireDefault(_tracksTextTrackDisplayJs)
  7938. var _loadingSpinnerJs = _dereq_('./loading-spinner.js')
  7939. var _loadingSpinnerJs2 = _interopRequireDefault(_loadingSpinnerJs)
  7940. var _bigPlayButtonJs = _dereq_('./big-play-button.js')
  7941. var _bigPlayButtonJs2 = _interopRequireDefault(_bigPlayButtonJs)
  7942. var _controlBarControlBarJs = _dereq_('./control-bar/control-bar.js')
  7943. var _controlBarControlBarJs2 = _interopRequireDefault(_controlBarControlBarJs)
  7944. var _errorDisplayJs = _dereq_('./error-display.js')
  7945. var _errorDisplayJs2 = _interopRequireDefault(_errorDisplayJs)
  7946. var _tracksTextTrackSettingsJs = _dereq_('./tracks/text-track-settings.js')
  7947. var _tracksTextTrackSettingsJs2 = _interopRequireDefault(_tracksTextTrackSettingsJs)
  7948. var _modalDialog = _dereq_('./modal-dialog')
  7949. var _modalDialog2 = _interopRequireDefault(_modalDialog)
  7950. // Require html5 tech, at least for disposing the original video tag
  7951. var _techTechJs = _dereq_('./tech/tech.js')
  7952. var _techTechJs2 = _interopRequireDefault(_techTechJs)
  7953. var _techHtml5Js = _dereq_('./tech/html5.js')
  7954. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js)
  7955. /**
  7956. * An instance of the `Player` class is created when any of the Video.js setup methods are used to initialize a video.
  7957. * ```js
  7958. * var myPlayer = videojs('example_video_1');
  7959. * ```
  7960. * In the following example, the `data-setup` attribute tells the Video.js library to create a player instance when the library is ready.
  7961. * ```html
  7962. * <video id="example_video_1" data-setup='{}' controls>
  7963. * <source src="my-source.mp4" type="video/mp4">
  7964. * </video>
  7965. * ```
  7966. * After an instance has been created it can be accessed globally using `Video('example_video_1')`.
  7967. *
  7968. * @param {Element} tag The original video tag used for configuring options
  7969. * @param {Object=} options Object of option names and values
  7970. * @param {Function=} ready Ready callback function
  7971. * @extends Component
  7972. * @class Player
  7973. */
  7974. var Player = (function(_Component) {
  7975. _inherits(Player, _Component)
  7976. /**
  7977. * player's constructor function
  7978. *
  7979. * @constructs
  7980. * @method init
  7981. * @param {Element} tag The original video tag used for configuring options
  7982. * @param {Object=} options Player options
  7983. * @param {Function=} ready Ready callback function
  7984. */
  7985. function Player(tag, options, ready) {
  7986. var _this = this
  7987. _classCallCheck(this, Player)
  7988. // Make sure tag ID exists
  7989. tag.id = tag.id || 'vjs_video_' + Guid.newGUID()
  7990. // Set Options
  7991. // The options argument overrides options set in the video tag
  7992. // which overrides globally set options.
  7993. // This latter part coincides with the load order
  7994. // (tag must exist before Player)
  7995. options = _objectAssign2['default'](Player.getTagSettings(tag), options)
  7996. // Delay the initialization of children because we need to set up
  7997. // player properties first, and can't use `this` before `super()`
  7998. options.initChildren = false
  7999. // Same with creating the element
  8000. options.createEl = false
  8001. // we don't want the player to report touch activity on itself
  8002. // see enableTouchActivity in Component
  8003. options.reportTouchActivity = false
  8004. // Run base component initializing with new options
  8005. _Component.call(this, null, options, ready)
  8006. // if the global option object was accidentally blown away by
  8007. // someone, bail early with an informative error
  8008. if (!this.options_ || !this.options_.techOrder || !this.options_.techOrder.length) {
  8009. throw new Error('No techOrder specified. Did you overwrite ' + 'videojs.options instead of just changing the ' + 'properties you want to override?')
  8010. }
  8011. this.tag = tag // Store the original tag used to set options
  8012. // Store the tag attributes used to restore html5 element
  8013. this.tagAttributes = tag && Dom.getElAttributes(tag)
  8014. // Update current language
  8015. this.language(this.options_.language)
  8016. // Update Supported Languages
  8017. if (options.languages) {
  8018. (function() {
  8019. // Normalise player option languages to lowercase
  8020. var languagesToLower = {}
  8021. Object.getOwnPropertyNames(options.languages).forEach(function(name) {
  8022. languagesToLower[name.toLowerCase()] = options.languages[name]
  8023. })
  8024. _this.languages_ = languagesToLower
  8025. })()
  8026. } else {
  8027. this.languages_ = Player.prototype.options_.languages
  8028. }
  8029. // Cache for video property values.
  8030. this.cache_ = {}
  8031. // Set poster
  8032. this.poster_ = options.poster || ''
  8033. // Set controls
  8034. this.controls_ = !!options.controls
  8035. // Original tag settings stored in options
  8036. // now remove immediately so native controls don't flash.
  8037. // May be turned back on by HTML5 tech if nativeControlsForTouch is true
  8038. tag.controls = false
  8039. /*
  8040. * Store the internal state of scrubbing
  8041. *
  8042. * @private
  8043. * @return {Boolean} True if the user is scrubbing
  8044. */
  8045. this.scrubbing_ = false
  8046. this.el_ = this.createEl()
  8047. // We also want to pass the original player options to each component and plugin
  8048. // as well so they don't need to reach back into the player for options later.
  8049. // We also need to do another copy of this.options_ so we don't end up with
  8050. // an infinite loop.
  8051. var playerOptionsCopy = _utilsMergeOptionsJs2['default'](this.options_)
  8052. // Load plugins
  8053. if (options.plugins) {
  8054. (function() {
  8055. var plugins = options.plugins
  8056. Object.getOwnPropertyNames(plugins).forEach(function(name) {
  8057. if (typeof this[name] === 'function') {
  8058. this[name](plugins[name])
  8059. } else {
  8060. _utilsLogJs2['default'].error('Unable to find plugin:', name)
  8061. }
  8062. }, _this)
  8063. })()
  8064. }
  8065. this.options_.playerOptions = playerOptionsCopy
  8066. this.initChildren()
  8067. // Set isAudio based on whether or not an audio tag was used
  8068. this.isAudio(tag.nodeName.toLowerCase() === 'audio')
  8069. // Update controls className. Can't do this when the controls are initially
  8070. // set because the element doesn't exist yet.
  8071. if (this.controls()) {
  8072. this.addClass('vjs-controls-enabled')
  8073. } else {
  8074. this.addClass('vjs-controls-disabled')
  8075. }
  8076. // Set ARIA label and region role depending on player type
  8077. this.el_.setAttribute('role', 'region')
  8078. if (this.isAudio()) {
  8079. this.el_.setAttribute('aria-label', 'audio player')
  8080. } else {
  8081. this.el_.setAttribute('aria-label', 'video player')
  8082. }
  8083. if (this.isAudio()) {
  8084. this.addClass('vjs-audio')
  8085. }
  8086. if (this.flexNotSupported_()) {
  8087. this.addClass('vjs-no-flex')
  8088. }
  8089. // TODO: Make this smarter. Toggle user state between touching/mousing
  8090. // using events, since devices can have both touch and mouse events.
  8091. // if (browser.TOUCH_ENABLED) {
  8092. // this.addClass('vjs-touch-enabled');
  8093. // }
  8094. // iOS Safari has broken hover handling
  8095. if (!browser.IS_IOS) {
  8096. this.addClass('vjs-workinghover')
  8097. }
  8098. // Make player easily findable by ID
  8099. Player.players[this.id_] = this
  8100. // When the player is first initialized, trigger activity so components
  8101. // like the control bar show themselves if needed
  8102. this.userActive(true)
  8103. this.reportUserActivity()
  8104. this.listenForUserActivity_()
  8105. this.on('fullscreenchange', this.handleFullscreenChange_)
  8106. this.on('stageclick', this.handleStageClick_)
  8107. }
  8108. /*
  8109. * Global player list
  8110. *
  8111. * @type {Object}
  8112. */
  8113. /**
  8114. * Destroys the video player and does any necessary cleanup
  8115. * ```js
  8116. * myPlayer.dispose();
  8117. * ```
  8118. * This is especially helpful if you are dynamically adding and removing videos
  8119. * to/from the DOM.
  8120. *
  8121. * @method dispose
  8122. */
  8123. Player.prototype.dispose = function dispose() {
  8124. this.trigger('dispose')
  8125. // prevent dispose from being called twice
  8126. this.off('dispose')
  8127. if (this.styleEl_ && this.styleEl_.parentNode) {
  8128. this.styleEl_.parentNode.removeChild(this.styleEl_)
  8129. }
  8130. // Kill reference to this player
  8131. Player.players[this.id_] = null
  8132. if (this.tag && this.tag.player) {
  8133. this.tag.player = null
  8134. }
  8135. if (this.el_ && this.el_.player) {
  8136. this.el_.player = null
  8137. }
  8138. if (this.tech_) {
  8139. this.tech_.dispose()
  8140. }
  8141. _Component.prototype.dispose.call(this)
  8142. }
  8143. /**
  8144. * Create the component's DOM element
  8145. *
  8146. * @return {Element}
  8147. * @method createEl
  8148. */
  8149. Player.prototype.createEl = function createEl() {
  8150. var el = this.el_ = _Component.prototype.createEl.call(this, 'div')
  8151. var tag = this.tag
  8152. // Remove width/height attrs from tag so CSS can make it 100% width/height
  8153. tag.removeAttribute('width')
  8154. tag.removeAttribute('height')
  8155. // Copy over all the attributes from the tag, including ID and class
  8156. // ID will now reference player box, not the video tag
  8157. var attrs = Dom.getElAttributes(tag)
  8158. Object.getOwnPropertyNames(attrs).forEach(function(attr) {
  8159. // workaround so we don't totally break IE7
  8160. // http://stackoverflow.com/questions/3653444/css-styles-not-applied-on-dynamic-elements-in-internet-explorer-7
  8161. if (attr === 'class') {
  8162. el.className = attrs[attr]
  8163. } else {
  8164. el.setAttribute(attr, attrs[attr])
  8165. }
  8166. })
  8167. // Update tag id/class for use as HTML5 playback tech
  8168. // Might think we should do this after embedding in container so .vjs-tech class
  8169. // doesn't flash 100% width/height, but class only applies with .video-js parent
  8170. tag.playerId = tag.id
  8171. tag.id += '_html5_api'
  8172. tag.className = 'vjs-tech'
  8173. // Make player findable on elements
  8174. tag.player = el.player = this
  8175. // Default state of video is paused
  8176. this.addClass('vjs-paused')
  8177. // Add a style element in the player that we'll use to set the width/height
  8178. // of the player in a way that's still overrideable by CSS, just like the
  8179. // video element
  8180. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE !== true) {
  8181. this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions')
  8182. var defaultsStyleEl = Dom.$('.vjs-styles-defaults')
  8183. var head = Dom.$('head')
  8184. head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild)
  8185. }
  8186. // Pass in the width/height/aspectRatio options which will update the style el
  8187. this.width(this.options_.width)
  8188. this.height(this.options_.height)
  8189. this.fluid(this.options_.fluid)
  8190. this.aspectRatio(this.options_.aspectRatio)
  8191. // Hide any links within the video/audio tag, because IE doesn't hide them completely.
  8192. var links = tag.getElementsByTagName('a')
  8193. for (var i = 0; i < links.length; i++) {
  8194. var linkEl = links.item(i)
  8195. Dom.addElClass(linkEl, 'vjs-hidden')
  8196. linkEl.setAttribute('hidden', 'hidden')
  8197. }
  8198. // insertElFirst seems to cause the networkState to flicker from 3 to 2, so
  8199. // keep track of the original for later so we can know if the source originally failed
  8200. tag.initNetworkState_ = tag.networkState
  8201. // Wrap video tag in div (el/box) container
  8202. if (tag.parentNode) {
  8203. tag.parentNode.insertBefore(el, tag)
  8204. }
  8205. // insert the tag as the first child of the player element
  8206. // then manually add it to the children array so that this.addChild
  8207. // will work properly for other components
  8208. Dom.insertElFirst(tag, el) // Breaks iPhone, fixed in HTML5 setup.
  8209. this.children_.unshift(tag)
  8210. this.el_ = el
  8211. return el
  8212. }
  8213. /**
  8214. * Get/set player width
  8215. *
  8216. * @param {Number=} value Value for width
  8217. * @return {Number} Width when getting
  8218. * @method width
  8219. */
  8220. Player.prototype.width = function width(value) {
  8221. return this.dimension('width', value)
  8222. }
  8223. /**
  8224. * Get/set player height
  8225. *
  8226. * @param {Number=} value Value for height
  8227. * @return {Number} Height when getting
  8228. * @method height
  8229. */
  8230. Player.prototype.height = function height(value) {
  8231. return this.dimension('height', value)
  8232. }
  8233. /**
  8234. * Get/set dimension for player
  8235. *
  8236. * @param {String} dimension Either width or height
  8237. * @param {Number=} value Value for dimension
  8238. * @return {Component}
  8239. * @method dimension
  8240. */
  8241. Player.prototype.dimension = function dimension(_dimension, value) {
  8242. var privDimension = _dimension + '_'
  8243. if (value === undefined) {
  8244. return this[privDimension] || 0
  8245. }
  8246. if (value === '') {
  8247. // If an empty string is given, reset the dimension to be automatic
  8248. this[privDimension] = undefined
  8249. } else {
  8250. var parsedVal = parseFloat(value)
  8251. if (isNaN(parsedVal)) {
  8252. _utilsLogJs2['default'].error('Improper value "' + value + '" supplied for for ' + _dimension)
  8253. return this
  8254. }
  8255. this[privDimension] = parsedVal
  8256. }
  8257. this.updateStyleEl_()
  8258. return this
  8259. }
  8260. /**
  8261. * Add/remove the vjs-fluid class
  8262. *
  8263. * @param {Boolean} bool Value of true adds the class, value of false removes the class
  8264. * @method fluid
  8265. */
  8266. Player.prototype.fluid = function fluid(bool) {
  8267. if (bool === undefined) {
  8268. return !!this.fluid_
  8269. }
  8270. this.fluid_ = !!bool
  8271. if (bool) {
  8272. this.addClass('vjs-fluid')
  8273. } else {
  8274. this.removeClass('vjs-fluid')
  8275. }
  8276. }
  8277. /**
  8278. * Get/Set the aspect ratio
  8279. *
  8280. * @param {String=} ratio Aspect ratio for player
  8281. * @return aspectRatio
  8282. * @method aspectRatio
  8283. */
  8284. Player.prototype.aspectRatio = function aspectRatio(ratio) {
  8285. if (ratio === undefined) {
  8286. return this.aspectRatio_
  8287. }
  8288. // Check for width:height format
  8289. if (!/^\d+\:\d+$/.test(ratio)) {
  8290. throw new Error('Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.')
  8291. }
  8292. this.aspectRatio_ = ratio
  8293. // We're assuming if you set an aspect ratio you want fluid mode,
  8294. // because in fixed mode you could calculate width and height yourself.
  8295. this.fluid(true)
  8296. this.updateStyleEl_()
  8297. }
  8298. /**
  8299. * Update styles of the player element (height, width and aspect ratio)
  8300. *
  8301. * @method updateStyleEl_
  8302. */
  8303. Player.prototype.updateStyleEl_ = function updateStyleEl_() {
  8304. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE === true) {
  8305. var _width = typeof this.width_ === 'number' ? this.width_ : this.options_.width
  8306. var _height = typeof this.height_ === 'number' ? this.height_ : this.options_.height
  8307. var techEl = this.tech_ && this.tech_.el()
  8308. if (techEl) {
  8309. if (_width >= 0) {
  8310. techEl.width = _width
  8311. }
  8312. if (_height >= 0) {
  8313. techEl.height = _height
  8314. }
  8315. }
  8316. return
  8317. }
  8318. var width = undefined
  8319. var height = undefined
  8320. var aspectRatio = undefined
  8321. var idClass = undefined
  8322. // The aspect ratio is either used directly or to calculate width and height.
  8323. if (this.aspectRatio_ !== undefined && this.aspectRatio_ !== 'auto') {
  8324. // Use any aspectRatio that's been specifically set
  8325. aspectRatio = this.aspectRatio_
  8326. } else if (this.videoWidth()) {
  8327. // Otherwise try to get the aspect ratio from the video metadata
  8328. aspectRatio = this.videoWidth() + ':' + this.videoHeight()
  8329. } else {
  8330. // Or use a default. The video element's is 2:1, but 16:9 is more common.
  8331. aspectRatio = '16:9'
  8332. }
  8333. // Get the ratio as a decimal we can use to calculate dimensions
  8334. var ratioParts = aspectRatio.split(':')
  8335. var ratioMultiplier = ratioParts[1] / ratioParts[0]
  8336. if (this.width_ !== undefined) {
  8337. // Use any width that's been specifically set
  8338. width = this.width_
  8339. } else if (this.height_ !== undefined) {
  8340. // Or calulate the width from the aspect ratio if a height has been set
  8341. width = this.height_ / ratioMultiplier
  8342. } else {
  8343. // Or use the video's metadata, or use the video el's default of 300
  8344. width = this.videoWidth() || 300
  8345. }
  8346. if (this.height_ !== undefined) {
  8347. // Use any height that's been specifically set
  8348. height = this.height_
  8349. } else {
  8350. // Otherwise calculate the height from the ratio and the width
  8351. height = width * ratioMultiplier
  8352. }
  8353. // Ensure the CSS class is valid by starting with an alpha character
  8354. if (/^[^a-zA-Z]/.test(this.id())) {
  8355. idClass = 'dimensions-' + this.id()
  8356. } else {
  8357. idClass = this.id() + '-dimensions'
  8358. }
  8359. // Ensure the right class is still on the player for the style element
  8360. this.addClass(idClass)
  8361. // 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 ');
  8362. 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 ')
  8363. }
  8364. /**
  8365. * Load the Media Playback Technology (tech)
  8366. * Load/Create an instance of playback technology including element and API methods
  8367. * And append playback element in player div.
  8368. *
  8369. * @param {String} techName Name of the playback technology
  8370. * @param {String} source Video source
  8371. * @method loadTech_
  8372. * @private
  8373. */
  8374. Player.prototype.loadTech_ = function loadTech_(techName, source) {
  8375. // Pause and remove current playback technology
  8376. if (this.tech_) {
  8377. this.unloadTech_()
  8378. }
  8379. // get rid of the HTML5 video tag as soon as we are using another tech
  8380. if (techName !== 'Html5' && this.tag) {
  8381. _techTechJs2['default'].getTech('Html5').disposeMediaElement(this.tag)
  8382. this.tag.player = null
  8383. this.tag = null
  8384. }
  8385. this.techName_ = techName
  8386. // Turn off API access because we're loading a new tech that might load asynchronously
  8387. this.isReady_ = false
  8388. // Grab tech-specific options from player options and add source and parent element to use.
  8389. var techOptions = _objectAssign2['default']({
  8390. 'nativeControlsForTouch': this.options_.nativeControlsForTouch,
  8391. 'source': source,
  8392. 'playerId': this.id(),
  8393. 'techId': this.id() + '_' + techName + '_api',
  8394. 'videoTracks': this.videoTracks_,
  8395. 'textTracks': this.textTracks_,
  8396. 'audioTracks': this.audioTracks_,
  8397. 'autoplay': this.options_.autoplay,
  8398. 'preload': this.options_.preload,
  8399. 'loop': this.options_.loop,
  8400. 'muted': this.options_.muted,
  8401. 'poster': this.poster(),
  8402. 'language': this.language(),
  8403. 'vtt.js': this.options_['vtt.js']
  8404. }, this.options_[techName.toLowerCase()])
  8405. if (this.tag) {
  8406. techOptions.tag = this.tag
  8407. }
  8408. if (source) {
  8409. this.currentType_ = source.type
  8410. if (source.src === this.cache_.src && this.cache_.currentTime > 0) {
  8411. techOptions.startTime = this.cache_.currentTime
  8412. }
  8413. this.cache_.src = source.src
  8414. }
  8415. // Initialize tech instance
  8416. var techComponent = _techTechJs2['default'].getTech(techName)
  8417. // Support old behavior of techs being registered as components.
  8418. // Remove once that deprecated behavior is removed.
  8419. if (!techComponent) {
  8420. techComponent = _componentJs2['default'].getComponent(techName)
  8421. }
  8422. this.tech_ = new techComponent(techOptions)
  8423. // player.triggerReady is always async, so don't need this to be async
  8424. this.tech_.ready(Fn.bind(this, this.handleTechReady_), true)
  8425. _tracksTextTrackListConverterJs2['default'].jsonToTextTracks(this.textTracksJson_ || [], this.tech_)
  8426. // Listen to all HTML5-defined events and trigger them on the player
  8427. this.on(this.tech_, 'loadstart', this.handleTechLoadStart_)
  8428. this.on(this.tech_, 'waiting', this.handleTechWaiting_)
  8429. this.on(this.tech_, 'canplay', this.handleTechCanPlay_)
  8430. this.on(this.tech_, 'canplaythrough', this.handleTechCanPlayThrough_)
  8431. this.on(this.tech_, 'playing', this.handleTechPlaying_)
  8432. this.on(this.tech_, 'ended', this.handleTechEnded_)
  8433. this.on(this.tech_, 'seeking', this.handleTechSeeking_)
  8434. this.on(this.tech_, 'seeked', this.handleTechSeeked_)
  8435. this.on(this.tech_, 'play', this.handleTechPlay_)
  8436. this.on(this.tech_, 'firstplay', this.handleTechFirstPlay_)
  8437. this.on(this.tech_, 'pause', this.handleTechPause_)
  8438. this.on(this.tech_, 'progress', this.handleTechProgress_)
  8439. this.on(this.tech_, 'durationchange', this.handleTechDurationChange_)
  8440. this.on(this.tech_, 'fullscreenchange', this.handleTechFullscreenChange_)
  8441. this.on(this.tech_, 'error', this.handleTechError_)
  8442. this.on(this.tech_, 'suspend', this.handleTechSuspend_)
  8443. this.on(this.tech_, 'abort', this.handleTechAbort_)
  8444. this.on(this.tech_, 'emptied', this.handleTechEmptied_)
  8445. this.on(this.tech_, 'stalled', this.handleTechStalled_)
  8446. this.on(this.tech_, 'loadedmetadata', this.handleTechLoadedMetaData_)
  8447. this.on(this.tech_, 'loadeddata', this.handleTechLoadedData_)
  8448. this.on(this.tech_, 'timeupdate', this.handleTechTimeUpdate_)
  8449. this.on(this.tech_, 'ratechange', this.handleTechRateChange_)
  8450. this.on(this.tech_, 'volumechange', this.handleTechVolumeChange_)
  8451. this.on(this.tech_, 'texttrackchange', this.handleTechTextTrackChange_)
  8452. this.on(this.tech_, 'loadedmetadata', this.updateStyleEl_)
  8453. this.on(this.tech_, 'posterchange', this.handleTechPosterChange_)
  8454. this.usingNativeControls(this.techGet_('controls'))
  8455. if (this.controls() && !this.usingNativeControls()) {
  8456. this.addTechControlsListeners_()
  8457. }
  8458. // Add the tech element in the DOM if it was not already there
  8459. // Make sure to not insert the original video element if using Html5
  8460. if (this.tech_.el().parentNode !== this.el() && (techName !== 'Html5' || !this.tag)) {
  8461. Dom.insertElFirst(this.tech_.el(), this.el())
  8462. }
  8463. // Get rid of the original video tag reference after the first tech is loaded
  8464. if (this.tag) {
  8465. this.tag.player = null
  8466. this.tag = null
  8467. }
  8468. }
  8469. /**
  8470. * Unload playback technology
  8471. *
  8472. * @method unloadTech_
  8473. * @private
  8474. */
  8475. Player.prototype.unloadTech_ = function unloadTech_() {
  8476. // Save the current text tracks so that we can reuse the same text tracks with the next tech
  8477. this.videoTracks_ = this.videoTracks()
  8478. this.textTracks_ = this.textTracks()
  8479. this.audioTracks_ = this.audioTracks()
  8480. this.textTracksJson_ = _tracksTextTrackListConverterJs2['default'].textTracksToJson(this.tech_)
  8481. this.isReady_ = false
  8482. this.tech_.dispose()
  8483. this.tech_ = false
  8484. }
  8485. /**
  8486. * Return a reference to the current tech.
  8487. * It will only return a reference to the tech if given an object with the
  8488. * `IWillNotUseThisInPlugins` property on it. This is try and prevent misuse
  8489. * of techs by plugins.
  8490. *
  8491. * @param {Object}
  8492. * @return {Object} The Tech
  8493. * @method tech
  8494. */
  8495. Player.prototype.tech = function tech(safety) {
  8496. if (safety && safety.IWillNotUseThisInPlugins) {
  8497. return this.tech_
  8498. }
  8499. 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 '
  8500. _globalWindow2['default'].alert(errorText)
  8501. throw new Error(errorText)
  8502. }
  8503. /**
  8504. * Set up click and touch listeners for the playback element
  8505. *
  8506. * On desktops, a click on the video itself will toggle playback,
  8507. * on a mobile device a click on the video toggles controls.
  8508. * (toggling controls is done by toggling the user state between active and
  8509. * inactive)
  8510. * A tap can signal that a user has become active, or has become inactive
  8511. * e.g. a quick tap on an iPhone movie should reveal the controls. Another
  8512. * quick tap should hide them again (signaling the user is in an inactive
  8513. * viewing state)
  8514. * In addition to this, we still want the user to be considered inactive after
  8515. * a few seconds of inactivity.
  8516. * Note: the only part of iOS interaction we can't mimic with this setup
  8517. * is a touch and hold on the video element counting as activity in order to
  8518. * keep the controls showing, but that shouldn't be an issue. A touch and hold
  8519. * on any controls will still keep the user active
  8520. *
  8521. * @private
  8522. * @method addTechControlsListeners_
  8523. */
  8524. Player.prototype.addTechControlsListeners_ = function addTechControlsListeners_() {
  8525. // Make sure to remove all the previous listeners in case we are called multiple times.
  8526. this.removeTechControlsListeners_()
  8527. // Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
  8528. // trigger mousedown/up.
  8529. // http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
  8530. // Any touch events are set to block the mousedown event from happening
  8531. this.on(this.tech_, 'mousedown', this.handleTechClick_)
  8532. // If the controls were hidden we don't want that to change without a tap event
  8533. // so we'll check if the controls were already showing before reporting user
  8534. // activity
  8535. this.on(this.tech_, 'touchstart', this.handleTechTouchStart_)
  8536. this.on(this.tech_, 'touchmove', this.handleTechTouchMove_)
  8537. this.on(this.tech_, 'touchend', this.handleTechTouchEnd_)
  8538. // The tap listener needs to come after the touchend listener because the tap
  8539. // listener cancels out any reportedUserActivity when setting userActive(false)
  8540. this.on(this.tech_, 'tap', this.handleTechTap_)
  8541. }
  8542. /**
  8543. * Remove the listeners used for click and tap controls. This is needed for
  8544. * toggling to controls disabled, where a tap/touch should do nothing.
  8545. *
  8546. * @method removeTechControlsListeners_
  8547. * @private
  8548. */
  8549. Player.prototype.removeTechControlsListeners_ = function removeTechControlsListeners_() {
  8550. // We don't want to just use `this.off()` because there might be other needed
  8551. // listeners added by techs that extend this.
  8552. this.off(this.tech_, 'tap', this.handleTechTap_)
  8553. this.off(this.tech_, 'touchstart', this.handleTechTouchStart_)
  8554. this.off(this.tech_, 'touchmove', this.handleTechTouchMove_)
  8555. this.off(this.tech_, 'touchend', this.handleTechTouchEnd_)
  8556. this.off(this.tech_, 'mousedown', this.handleTechClick_)
  8557. }
  8558. /**
  8559. * Player waits for the tech to be ready
  8560. *
  8561. * @method handleTechReady_
  8562. * @private
  8563. */
  8564. Player.prototype.handleTechReady_ = function handleTechReady_() {
  8565. this.triggerReady()
  8566. // Keep the same volume as before
  8567. if (this.cache_.volume) {
  8568. this.techCall_('setVolume', this.cache_.volume)
  8569. }
  8570. // Look if the tech found a higher resolution poster while loading
  8571. this.handleTechPosterChange_()
  8572. // Update the duration if available
  8573. this.handleTechDurationChange_()
  8574. // Chrome and Safari both have issues with autoplay.
  8575. // In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
  8576. // In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
  8577. // This fixes both issues. Need to wait for API, so it updates displays correctly
  8578. if (this.src() && this.tag && this.options_.autoplay && this.paused()) {
  8579. delete this.tag.poster // Chrome Fix. Fixed in Chrome v16.
  8580. this.play()
  8581. }
  8582. }
  8583. /**
  8584. * Fired when the user agent begins looking for media data
  8585. *
  8586. * @private
  8587. * @method handleTechLoadStart_
  8588. */
  8589. Player.prototype.handleTechLoadStart_ = function handleTechLoadStart_() {
  8590. // TODO: Update to use `emptied` event instead. See #1277.
  8591. this.removeClass('vjs-ended')
  8592. // reset the error state
  8593. this.error(null)
  8594. // If it's already playing we want to trigger a firstplay event now.
  8595. // The firstplay event relies on both the play and loadstart events
  8596. // which can happen in any order for a new source
  8597. if (!this.paused()) {
  8598. this.trigger('loadstart')
  8599. this.trigger('firstplay')
  8600. } else {
  8601. // reset the hasStarted state
  8602. this.hasStarted(false)
  8603. this.trigger('loadstart')
  8604. }
  8605. }
  8606. /**
  8607. * Add/remove the vjs-has-started class
  8608. *
  8609. * @param {Boolean} hasStarted The value of true adds the class the value of false remove the class
  8610. * @return {Boolean} Boolean value if has started
  8611. * @private
  8612. * @method hasStarted
  8613. */
  8614. Player.prototype.hasStarted = function hasStarted(_hasStarted) {
  8615. if (_hasStarted !== undefined) {
  8616. // only update if this is a new value
  8617. if (this.hasStarted_ !== _hasStarted) {
  8618. this.hasStarted_ = _hasStarted
  8619. if (_hasStarted) {
  8620. this.addClass('vjs-has-started')
  8621. // trigger the firstplay event if this newly has played
  8622. this.trigger('firstplay')
  8623. } else {
  8624. this.removeClass('vjs-has-started')
  8625. }
  8626. }
  8627. return this
  8628. }
  8629. return !!this.hasStarted_
  8630. }
  8631. /**
  8632. * Fired whenever the media begins or resumes playback
  8633. *
  8634. * @private
  8635. * @method handleTechPlay_
  8636. */
  8637. Player.prototype.handleTechPlay_ = function handleTechPlay_() {
  8638. this.removeClass('vjs-ended')
  8639. this.removeClass('vjs-paused')
  8640. this.addClass('vjs-playing')
  8641. // hide the poster when the user hits play
  8642. // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play
  8643. this.hasStarted(true)
  8644. this.trigger('play')
  8645. }
  8646. /**
  8647. * Fired whenever the media begins waiting
  8648. *
  8649. * @private
  8650. * @method handleTechWaiting_
  8651. */
  8652. Player.prototype.handleTechWaiting_ = function handleTechWaiting_() {
  8653. var _this2 = this
  8654. this.addClass('vjs-waiting')
  8655. this.trigger('waiting')
  8656. this.one('timeupdate', function() {
  8657. return _this2.removeClass('vjs-waiting')
  8658. })
  8659. }
  8660. /**
  8661. * A handler for events that signal that waiting has ended
  8662. * which is not consistent between browsers. See #1351
  8663. *
  8664. * @private
  8665. * @method handleTechCanPlay_
  8666. */
  8667. Player.prototype.handleTechCanPlay_ = function handleTechCanPlay_() {
  8668. this.removeClass('vjs-waiting')
  8669. this.trigger('canplay')
  8670. }
  8671. /**
  8672. * A handler for events that signal that waiting has ended
  8673. * which is not consistent between browsers. See #1351
  8674. *
  8675. * @private
  8676. * @method handleTechCanPlayThrough_
  8677. */
  8678. Player.prototype.handleTechCanPlayThrough_ = function handleTechCanPlayThrough_() {
  8679. this.removeClass('vjs-waiting')
  8680. this.trigger('canplaythrough')
  8681. }
  8682. /**
  8683. * A handler for events that signal that waiting has ended
  8684. * which is not consistent between browsers. See #1351
  8685. *
  8686. * @private
  8687. * @method handleTechPlaying_
  8688. */
  8689. Player.prototype.handleTechPlaying_ = function handleTechPlaying_() {
  8690. this.removeClass('vjs-waiting')
  8691. this.trigger('playing')
  8692. }
  8693. /**
  8694. * Fired whenever the player is jumping to a new time
  8695. *
  8696. * @private
  8697. * @method handleTechSeeking_
  8698. */
  8699. Player.prototype.handleTechSeeking_ = function handleTechSeeking_() {
  8700. this.addClass('vjs-seeking')
  8701. this.trigger('seeking')
  8702. }
  8703. /**
  8704. * Fired when the player has finished jumping to a new time
  8705. *
  8706. * @private
  8707. * @method handleTechSeeked_
  8708. */
  8709. Player.prototype.handleTechSeeked_ = function handleTechSeeked_() {
  8710. this.removeClass('vjs-seeking')
  8711. this.trigger('seeked')
  8712. }
  8713. /**
  8714. * Fired the first time a video is played
  8715. * Not part of the HLS spec, and we're not sure if this is the best
  8716. * implementation yet, so use sparingly. If you don't have a reason to
  8717. * prevent playback, use `myPlayer.one('play');` instead.
  8718. *
  8719. * @private
  8720. * @method handleTechFirstPlay_
  8721. */
  8722. Player.prototype.handleTechFirstPlay_ = function handleTechFirstPlay_() {
  8723. // If the first starttime attribute is specified
  8724. // then we will start at the given offset in seconds
  8725. if (this.options_.starttime) {
  8726. this.currentTime(this.options_.starttime)
  8727. }
  8728. this.addClass('vjs-has-started')
  8729. this.trigger('firstplay')
  8730. }
  8731. /**
  8732. * Fired whenever the media has been paused
  8733. *
  8734. * @private
  8735. * @method handleTechPause_
  8736. */
  8737. Player.prototype.handleTechPause_ = function handleTechPause_() {
  8738. this.removeClass('vjs-playing')
  8739. this.addClass('vjs-paused')
  8740. this.trigger('pause')
  8741. }
  8742. /**
  8743. * Fired while the user agent is downloading media data
  8744. *
  8745. * @private
  8746. * @method handleTechProgress_
  8747. */
  8748. Player.prototype.handleTechProgress_ = function handleTechProgress_() {
  8749. this.trigger('progress')
  8750. }
  8751. /**
  8752. * Fired when the end of the media resource is reached (currentTime == duration)
  8753. *
  8754. * @private
  8755. * @method handleTechEnded_
  8756. */
  8757. Player.prototype.handleTechEnded_ = function handleTechEnded_() {
  8758. this.addClass('vjs-ended')
  8759. if (this.options_.loop) {
  8760. this.currentTime(0)
  8761. this.play()
  8762. } else if (!this.paused()) {
  8763. this.pause()
  8764. }
  8765. this.trigger('ended')
  8766. }
  8767. /**
  8768. * Fired when the duration of the media resource is first known or changed
  8769. *
  8770. * @private
  8771. * @method handleTechDurationChange_
  8772. */
  8773. Player.prototype.handleTechDurationChange_ = function handleTechDurationChange_() {
  8774. this.duration(this.techGet_('duration'))
  8775. }
  8776. /**
  8777. * Handle a click on the media element to play/pause
  8778. *
  8779. * @param {Object=} event Event object
  8780. * @private
  8781. * @method handleTechClick_
  8782. */
  8783. Player.prototype.handleTechClick_ = function handleTechClick_(event) {
  8784. // We're using mousedown to detect clicks thanks to Flash, but mousedown
  8785. // will also be triggered with right-clicks, so we need to prevent that
  8786. if (event.button !== 0) return
  8787. // When controls are disabled a click should not toggle playback because
  8788. // the click is considered a control
  8789. if (this.controls()) {
  8790. if (this.paused()) {
  8791. this.play()
  8792. } else {
  8793. this.pause()
  8794. }
  8795. }
  8796. }
  8797. /**
  8798. * Handle a tap on the media element. It will toggle the user
  8799. * activity state, which hides and shows the controls.
  8800. *
  8801. * @private
  8802. * @method handleTechTap_
  8803. */
  8804. Player.prototype.handleTechTap_ = function handleTechTap_() {
  8805. this.userActive(!this.userActive())
  8806. }
  8807. /**
  8808. * Handle touch to start
  8809. *
  8810. * @private
  8811. * @method handleTechTouchStart_
  8812. */
  8813. Player.prototype.handleTechTouchStart_ = function handleTechTouchStart_() {
  8814. this.userWasActive = this.userActive()
  8815. }
  8816. /**
  8817. * Handle touch to move
  8818. *
  8819. * @private
  8820. * @method handleTechTouchMove_
  8821. */
  8822. Player.prototype.handleTechTouchMove_ = function handleTechTouchMove_() {
  8823. if (this.userWasActive) {
  8824. this.reportUserActivity()
  8825. }
  8826. }
  8827. /**
  8828. * Handle touch to end
  8829. *
  8830. * @private
  8831. * @method handleTechTouchEnd_
  8832. */
  8833. Player.prototype.handleTechTouchEnd_ = function handleTechTouchEnd_(event) {
  8834. // Stop the mouse events from also happening
  8835. event.preventDefault()
  8836. }
  8837. /**
  8838. * Fired when the player switches in or out of fullscreen mode
  8839. *
  8840. * @private
  8841. * @method handleFullscreenChange_
  8842. */
  8843. Player.prototype.handleFullscreenChange_ = function handleFullscreenChange_() {
  8844. if (this.isFullscreen()) {
  8845. this.addClass('vjs-fullscreen')
  8846. } else {
  8847. this.removeClass('vjs-fullscreen')
  8848. }
  8849. }
  8850. /**
  8851. * native click events on the SWF aren't triggered on IE11, Win8.1RT
  8852. * use stageclick events triggered from inside the SWF instead
  8853. *
  8854. * @private
  8855. * @method handleStageClick_
  8856. */
  8857. Player.prototype.handleStageClick_ = function handleStageClick_() {
  8858. this.reportUserActivity()
  8859. }
  8860. /**
  8861. * Handle Tech Fullscreen Change
  8862. *
  8863. * @private
  8864. * @method handleTechFullscreenChange_
  8865. */
  8866. Player.prototype.handleTechFullscreenChange_ = function handleTechFullscreenChange_(event, data) {
  8867. if (data) {
  8868. this.isFullscreen(data.isFullscreen)
  8869. }
  8870. this.trigger('fullscreenchange')
  8871. }
  8872. /**
  8873. * Fires when an error occurred during the loading of an audio/video
  8874. *
  8875. * @private
  8876. * @method handleTechError_
  8877. */
  8878. Player.prototype.handleTechError_ = function handleTechError_() {
  8879. var error = this.tech_.error()
  8880. this.error(error && error.code)
  8881. }
  8882. /**
  8883. * Fires when the browser is intentionally not getting media data
  8884. *
  8885. * @private
  8886. * @method handleTechSuspend_
  8887. */
  8888. Player.prototype.handleTechSuspend_ = function handleTechSuspend_() {
  8889. this.trigger('suspend')
  8890. }
  8891. /**
  8892. * Fires when the loading of an audio/video is aborted
  8893. *
  8894. * @private
  8895. * @method handleTechAbort_
  8896. */
  8897. Player.prototype.handleTechAbort_ = function handleTechAbort_() {
  8898. this.trigger('abort')
  8899. }
  8900. /**
  8901. * Fires when the current playlist is empty
  8902. *
  8903. * @private
  8904. * @method handleTechEmptied_
  8905. */
  8906. Player.prototype.handleTechEmptied_ = function handleTechEmptied_() {
  8907. this.trigger('emptied')
  8908. }
  8909. /**
  8910. * Fires when the browser is trying to get media data, but data is not available
  8911. *
  8912. * @private
  8913. * @method handleTechStalled_
  8914. */
  8915. Player.prototype.handleTechStalled_ = function handleTechStalled_() {
  8916. this.trigger('stalled')
  8917. }
  8918. /**
  8919. * Fires when the browser has loaded meta data for the audio/video
  8920. *
  8921. * @private
  8922. * @method handleTechLoadedMetaData_
  8923. */
  8924. Player.prototype.handleTechLoadedMetaData_ = function handleTechLoadedMetaData_() {
  8925. this.trigger('loadedmetadata')
  8926. }
  8927. /**
  8928. * Fires when the browser has loaded the current frame of the audio/video
  8929. *
  8930. * @private
  8931. * @method handleTechLoadedData_
  8932. */
  8933. Player.prototype.handleTechLoadedData_ = function handleTechLoadedData_() {
  8934. this.trigger('loadeddata')
  8935. }
  8936. /**
  8937. * Fires when the current playback position has changed
  8938. *
  8939. * @private
  8940. * @method handleTechTimeUpdate_
  8941. */
  8942. Player.prototype.handleTechTimeUpdate_ = function handleTechTimeUpdate_() {
  8943. this.trigger('timeupdate')
  8944. }
  8945. /**
  8946. * Fires when the playing speed of the audio/video is changed
  8947. *
  8948. * @private
  8949. * @method handleTechRateChange_
  8950. */
  8951. Player.prototype.handleTechRateChange_ = function handleTechRateChange_() {
  8952. this.trigger('ratechange')
  8953. }
  8954. /**
  8955. * Fires when the volume has been changed
  8956. *
  8957. * @private
  8958. * @method handleTechVolumeChange_
  8959. */
  8960. Player.prototype.handleTechVolumeChange_ = function handleTechVolumeChange_() {
  8961. this.trigger('volumechange')
  8962. }
  8963. /**
  8964. * Fires when the text track has been changed
  8965. *
  8966. * @private
  8967. * @method handleTechTextTrackChange_
  8968. */
  8969. Player.prototype.handleTechTextTrackChange_ = function handleTechTextTrackChange_() {
  8970. this.trigger('texttrackchange')
  8971. }
  8972. /**
  8973. * Get object for cached values.
  8974. *
  8975. * @return {Object}
  8976. * @method getCache
  8977. */
  8978. Player.prototype.getCache = function getCache() {
  8979. return this.cache_
  8980. }
  8981. /**
  8982. * Pass values to the playback tech
  8983. *
  8984. * @param {String=} method Method
  8985. * @param {Object=} arg Argument
  8986. * @private
  8987. * @method techCall_
  8988. */
  8989. Player.prototype.techCall_ = function techCall_(method, arg) {
  8990. // If it's not ready yet, call method when it is
  8991. if (this.tech_ && !this.tech_.isReady_) {
  8992. this.tech_.ready(function() {
  8993. this[method](arg)
  8994. }, true)
  8995. // Otherwise call method now
  8996. } else {
  8997. try {
  8998. this.tech_[method](arg)
  8999. } catch (e) {
  9000. _utilsLogJs2['default'](e)
  9001. throw e
  9002. }
  9003. }
  9004. }
  9005. /**
  9006. * Get calls can't wait for the tech, and sometimes don't need to.
  9007. *
  9008. * @param {String} method Tech method
  9009. * @return {Method}
  9010. * @private
  9011. * @method techGet_
  9012. */
  9013. Player.prototype.techGet_ = function techGet_(method) {
  9014. if (this.tech_ && this.tech_.isReady_) {
  9015. // Flash likes to die and reload when you hide or reposition it.
  9016. // In these cases the object methods go away and we get errors.
  9017. // When that happens we'll catch the errors and inform tech that it's not ready any more.
  9018. try {
  9019. return this.tech_[method]()
  9020. } catch (e) {
  9021. // When building additional tech libs, an expected method may not be defined yet
  9022. if (this.tech_[method] === undefined) {
  9023. _utilsLogJs2['default']('Video.js: ' + method + ' method not defined for ' + this.techName_ + ' playback technology.', e)
  9024. } else {
  9025. // When a method isn't available on the object it throws a TypeError
  9026. if (e.name === 'TypeError') {
  9027. _utilsLogJs2['default']('Video.js: ' + method + ' unavailable on ' + this.techName_ + ' playback technology element.', e)
  9028. this.tech_.isReady_ = false
  9029. } else {
  9030. _utilsLogJs2['default'](e)
  9031. }
  9032. }
  9033. throw e
  9034. }
  9035. }
  9036. return
  9037. }
  9038. /**
  9039. * start media playback
  9040. * ```js
  9041. * myPlayer.play();
  9042. * ```
  9043. *
  9044. * @return {Player} self
  9045. * @method play
  9046. */
  9047. Player.prototype.play = function play() {
  9048. this.techCall_('play')
  9049. return this
  9050. }
  9051. /**
  9052. * Pause the video playback
  9053. * ```js
  9054. * myPlayer.pause();
  9055. * ```
  9056. *
  9057. * @return {Player} self
  9058. * @method pause
  9059. */
  9060. Player.prototype.pause = function pause() {
  9061. this.techCall_('pause')
  9062. return this
  9063. }
  9064. /**
  9065. * Check if the player is paused
  9066. * ```js
  9067. * var isPaused = myPlayer.paused();
  9068. * var isPlaying = !myPlayer.paused();
  9069. * ```
  9070. *
  9071. * @return {Boolean} false if the media is currently playing, or true otherwise
  9072. * @method paused
  9073. */
  9074. Player.prototype.paused = function paused() {
  9075. // The initial state of paused should be true (in Safari it's actually false)
  9076. return this.techGet_('paused') !== false
  9077. }
  9078. /**
  9079. * Returns whether or not the user is "scrubbing". Scrubbing is when the user
  9080. * has clicked the progress bar handle and is dragging it along the progress bar.
  9081. *
  9082. * @param {Boolean} isScrubbing True/false the user is scrubbing
  9083. * @return {Boolean} The scrubbing status when getting
  9084. * @return {Object} The player when setting
  9085. * @method scrubbing
  9086. */
  9087. Player.prototype.scrubbing = function scrubbing(isScrubbing) {
  9088. if (isScrubbing !== undefined) {
  9089. this.scrubbing_ = !!isScrubbing
  9090. if (isScrubbing) {
  9091. this.addClass('vjs-scrubbing')
  9092. } else {
  9093. this.removeClass('vjs-scrubbing')
  9094. }
  9095. return this
  9096. }
  9097. return this.scrubbing_
  9098. }
  9099. /**
  9100. * Get or set the current time (in seconds)
  9101. * ```js
  9102. * // get
  9103. * var whereYouAt = myPlayer.currentTime();
  9104. * // set
  9105. * myPlayer.currentTime(120); // 2 minutes into the video
  9106. * ```
  9107. *
  9108. * @param {Number|String=} seconds The time to seek to
  9109. * @return {Number} The time in seconds, when not setting
  9110. * @return {Player} self, when the current time is set
  9111. * @method currentTime
  9112. */
  9113. Player.prototype.currentTime = function currentTime(seconds) {
  9114. if (seconds !== undefined) {
  9115. this.techCall_('setCurrentTime', seconds)
  9116. return this
  9117. }
  9118. // cache last currentTime and return. default to 0 seconds
  9119. //
  9120. // Caching the currentTime is meant to prevent a massive amount of reads on the tech's
  9121. // currentTime when scrubbing, but may not provide much performance benefit afterall.
  9122. // Should be tested. Also something has to read the actual current time or the cache will
  9123. // never get updated.
  9124. return this.cache_.currentTime = this.techGet_('currentTime') || 0
  9125. }
  9126. /**
  9127. * Get the length in time of the video in seconds
  9128. * ```js
  9129. * var lengthOfVideo = myPlayer.duration();
  9130. * ```
  9131. * **NOTE**: The video must have started loading before the duration can be
  9132. * known, and in the case of Flash, may not be known until the video starts
  9133. * playing.
  9134. *
  9135. * @param {Number} seconds Duration when setting
  9136. * @return {Number} The duration of the video in seconds when getting
  9137. * @method duration
  9138. */
  9139. Player.prototype.duration = function duration(seconds) {
  9140. if (seconds === undefined) {
  9141. return this.cache_.duration || 0
  9142. }
  9143. seconds = parseFloat(seconds) || 0
  9144. // Standardize on Inifity for signaling video is live
  9145. if (seconds < 0) {
  9146. seconds = Infinity
  9147. }
  9148. if (seconds !== this.cache_.duration) {
  9149. // Cache the last set value for optimized scrubbing (esp. Flash)
  9150. this.cache_.duration = seconds
  9151. if (seconds === Infinity) {
  9152. this.addClass('vjs-live')
  9153. } else {
  9154. this.removeClass('vjs-live')
  9155. }
  9156. this.trigger('durationchange')
  9157. }
  9158. return this
  9159. }
  9160. /**
  9161. * Calculates how much time is left.
  9162. * ```js
  9163. * var timeLeft = myPlayer.remainingTime();
  9164. * ```
  9165. * Not a native video element function, but useful
  9166. *
  9167. * @return {Number} The time remaining in seconds
  9168. * @method remainingTime
  9169. */
  9170. Player.prototype.remainingTime = function remainingTime() {
  9171. return this.duration() - this.currentTime()
  9172. }
  9173. // http://dev.w3.org/html5/spec/video.html#dom-media-buffered
  9174. // Buffered returns a timerange object.
  9175. // Kind of like an array of portions of the video that have been downloaded.
  9176. /**
  9177. * Get a TimeRange object with the times of the video that have been downloaded
  9178. * If you just want the percent of the video that's been downloaded,
  9179. * use bufferedPercent.
  9180. * ```js
  9181. * // Number of different ranges of time have been buffered. Usually 1.
  9182. * numberOfRanges = bufferedTimeRange.length,
  9183. * // Time in seconds when the first range starts. Usually 0.
  9184. * firstRangeStart = bufferedTimeRange.start(0),
  9185. * // Time in seconds when the first range ends
  9186. * firstRangeEnd = bufferedTimeRange.end(0),
  9187. * // Length in seconds of the first time range
  9188. * firstRangeLength = firstRangeEnd - firstRangeStart;
  9189. * ```
  9190. *
  9191. * @return {Object} A mock TimeRange object (following HTML spec)
  9192. * @method buffered
  9193. */
  9194. Player.prototype.buffered = function buffered() {
  9195. var buffered = this.techGet_('buffered')
  9196. if (!buffered || !buffered.length) {
  9197. buffered = _utilsTimeRangesJs.createTimeRange(0, 0)
  9198. }
  9199. return buffered
  9200. }
  9201. /**
  9202. * Get the percent (as a decimal) of the video that's been downloaded
  9203. * ```js
  9204. * var howMuchIsDownloaded = myPlayer.bufferedPercent();
  9205. * ```
  9206. * 0 means none, 1 means all.
  9207. * (This method isn't in the HTML5 spec, but it's very convenient)
  9208. *
  9209. * @return {Number} A decimal between 0 and 1 representing the percent
  9210. * @method bufferedPercent
  9211. */
  9212. Player.prototype.bufferedPercent = function bufferedPercent() {
  9213. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration())
  9214. }
  9215. /**
  9216. * Get the ending time of the last buffered time range
  9217. * This is used in the progress bar to encapsulate all time ranges.
  9218. *
  9219. * @return {Number} The end of the last buffered time range
  9220. * @method bufferedEnd
  9221. */
  9222. Player.prototype.bufferedEnd = function bufferedEnd() {
  9223. var buffered = this.buffered()
  9224. var duration = this.duration()
  9225. var end = buffered.end(buffered.length - 1)
  9226. if (end > duration) {
  9227. end = duration
  9228. }
  9229. return end
  9230. }
  9231. /**
  9232. * Get or set the current volume of the media
  9233. * ```js
  9234. * // get
  9235. * var howLoudIsIt = myPlayer.volume();
  9236. * // set
  9237. * myPlayer.volume(0.5); // Set volume to half
  9238. * ```
  9239. * 0 is off (muted), 1.0 is all the way up, 0.5 is half way.
  9240. *
  9241. * @param {Number} percentAsDecimal The new volume as a decimal percent
  9242. * @return {Number} The current volume when getting
  9243. * @return {Player} self when setting
  9244. * @method volume
  9245. */
  9246. Player.prototype.volume = function volume(percentAsDecimal) {
  9247. var vol = undefined
  9248. if (percentAsDecimal !== undefined) {
  9249. vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))) // Force value to between 0 and 1
  9250. this.cache_.volume = vol
  9251. this.techCall_('setVolume', vol)
  9252. return this
  9253. }
  9254. // Default to 1 when returning current volume.
  9255. vol = parseFloat(this.techGet_('volume'))
  9256. return isNaN(vol) ? 1 : vol
  9257. }
  9258. /**
  9259. * Get the current muted state, or turn mute on or off
  9260. * ```js
  9261. * // get
  9262. * var isVolumeMuted = myPlayer.muted();
  9263. * // set
  9264. * myPlayer.muted(true); // mute the volume
  9265. * ```
  9266. *
  9267. * @param {Boolean=} muted True to mute, false to unmute
  9268. * @return {Boolean} True if mute is on, false if not when getting
  9269. * @return {Player} self when setting mute
  9270. * @method muted
  9271. */
  9272. Player.prototype.muted = function muted(_muted) {
  9273. if (_muted !== undefined) {
  9274. this.techCall_('setMuted', _muted)
  9275. return this
  9276. }
  9277. return this.techGet_('muted') || false // Default to false
  9278. }
  9279. // Check if current tech can support native fullscreen
  9280. // (e.g. with built in controls like iOS, so not our flash swf)
  9281. /**
  9282. * Check to see if fullscreen is supported
  9283. *
  9284. * @return {Boolean}
  9285. * @method supportsFullScreen
  9286. */
  9287. Player.prototype.supportsFullScreen = function supportsFullScreen() {
  9288. return this.techGet_('supportsFullScreen') || false
  9289. }
  9290. /**
  9291. * Check if the player is in fullscreen mode
  9292. * ```js
  9293. * // get
  9294. * var fullscreenOrNot = myPlayer.isFullscreen();
  9295. * // set
  9296. * myPlayer.isFullscreen(true); // tell the player it's in fullscreen
  9297. * ```
  9298. * NOTE: As of the latest HTML5 spec, isFullscreen is no longer an official
  9299. * property and instead document.fullscreenElement is used. But isFullscreen is
  9300. * still a valuable property for internal player workings.
  9301. *
  9302. * @param {Boolean=} isFS Update the player's fullscreen state
  9303. * @return {Boolean} true if fullscreen false if not when getting
  9304. * @return {Player} self when setting
  9305. * @method isFullscreen
  9306. */
  9307. Player.prototype.isFullscreen = function isFullscreen(isFS) {
  9308. if (isFS !== undefined) {
  9309. this.isFullscreen_ = !!isFS
  9310. return this
  9311. }
  9312. return !!this.isFullscreen_
  9313. }
  9314. /**
  9315. * Increase the size of the video to full screen
  9316. * ```js
  9317. * myPlayer.requestFullscreen();
  9318. * ```
  9319. * In some browsers, full screen is not supported natively, so it enters
  9320. * "full window mode", where the video fills the browser window.
  9321. * In browsers and devices that support native full screen, sometimes the
  9322. * browser's default controls will be shown, and not the Video.js custom skin.
  9323. * This includes most mobile devices (iOS, Android) and older versions of
  9324. * Safari.
  9325. *
  9326. * @return {Player} self
  9327. * @method requestFullscreen
  9328. */
  9329. Player.prototype.requestFullscreen = function requestFullscreen() {
  9330. var fsApi = _fullscreenApiJs2['default']
  9331. this.isFullscreen(true)
  9332. if (fsApi.requestFullscreen) {
  9333. // the browser supports going fullscreen at the element level so we can
  9334. // take the controls fullscreen as well as the video
  9335. // Trigger fullscreenchange event after change
  9336. // We have to specifically add this each time, and remove
  9337. // when canceling fullscreen. Otherwise if there's multiple
  9338. // players on a page, they would all be reacting to the same fullscreen
  9339. // events
  9340. Events.on(_globalDocument2['default'], fsApi.fullscreenchange, Fn.bind(this, function documentFullscreenChange(e) {
  9341. this.isFullscreen(_globalDocument2['default'][fsApi.fullscreenElement])
  9342. // If cancelling fullscreen, remove event listener.
  9343. if (this.isFullscreen() === false) {
  9344. Events.off(_globalDocument2['default'], fsApi.fullscreenchange, documentFullscreenChange)
  9345. }
  9346. this.trigger('fullscreenchange')
  9347. }))
  9348. this.el_[fsApi.requestFullscreen]()
  9349. } else if (this.tech_.supportsFullScreen()) {
  9350. // we can't take the video.js controls fullscreen but we can go fullscreen
  9351. // with native controls
  9352. this.techCall_('enterFullScreen')
  9353. } else {
  9354. // fullscreen isn't supported so we'll just stretch the video element to
  9355. // fill the viewport
  9356. this.enterFullWindow()
  9357. this.trigger('fullscreenchange')
  9358. }
  9359. return this
  9360. }
  9361. /**
  9362. * Return the video to its normal size after having been in full screen mode
  9363. * ```js
  9364. * myPlayer.exitFullscreen();
  9365. * ```
  9366. *
  9367. * @return {Player} self
  9368. * @method exitFullscreen
  9369. */
  9370. Player.prototype.exitFullscreen = function exitFullscreen() {
  9371. var fsApi = _fullscreenApiJs2['default']
  9372. this.isFullscreen(false)
  9373. // Check for browser element fullscreen support
  9374. if (fsApi.requestFullscreen) {
  9375. _globalDocument2['default'][fsApi.exitFullscreen]()
  9376. } else if (this.tech_.supportsFullScreen()) {
  9377. this.techCall_('exitFullScreen')
  9378. } else {
  9379. this.exitFullWindow()
  9380. this.trigger('fullscreenchange')
  9381. }
  9382. return this
  9383. }
  9384. /**
  9385. * When fullscreen isn't supported we can stretch the video container to as wide as the browser will let us.
  9386. *
  9387. * @method enterFullWindow
  9388. */
  9389. Player.prototype.enterFullWindow = function enterFullWindow() {
  9390. this.isFullWindow = true
  9391. // Storing original doc overflow value to return to when fullscreen is off
  9392. this.docOrigOverflow = _globalDocument2['default'].documentElement.style.overflow
  9393. // Add listener for esc key to exit fullscreen
  9394. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.fullWindowOnEscKey))
  9395. // Hide any scroll bars
  9396. _globalDocument2['default'].documentElement.style.overflow = 'hidden'
  9397. // Apply fullscreen styles
  9398. Dom.addElClass(_globalDocument2['default'].body, 'vjs-full-window')
  9399. this.trigger('enterFullWindow')
  9400. }
  9401. /**
  9402. * Check for call to either exit full window or full screen on ESC key
  9403. *
  9404. * @param {String} event Event to check for key press
  9405. * @method fullWindowOnEscKey
  9406. */
  9407. Player.prototype.fullWindowOnEscKey = function fullWindowOnEscKey(event) {
  9408. if (event.keyCode === 27) {
  9409. if (this.isFullscreen() === true) {
  9410. this.exitFullscreen()
  9411. } else {
  9412. this.exitFullWindow()
  9413. }
  9414. }
  9415. }
  9416. /**
  9417. * Exit full window
  9418. *
  9419. * @method exitFullWindow
  9420. */
  9421. Player.prototype.exitFullWindow = function exitFullWindow() {
  9422. this.isFullWindow = false
  9423. Events.off(_globalDocument2['default'], 'keydown', this.fullWindowOnEscKey)
  9424. // Unhide scroll bars.
  9425. _globalDocument2['default'].documentElement.style.overflow = this.docOrigOverflow
  9426. // Remove fullscreen styles
  9427. Dom.removeElClass(_globalDocument2['default'].body, 'vjs-full-window')
  9428. // Resize the box, controller, and poster to original sizes
  9429. // this.positionAll();
  9430. this.trigger('exitFullWindow')
  9431. }
  9432. /**
  9433. * Check whether the player can play a given mimetype
  9434. *
  9435. * @param {String} type The mimetype to check
  9436. * @return {String} 'probably', 'maybe', or '' (empty string)
  9437. * @method canPlayType
  9438. */
  9439. Player.prototype.canPlayType = function canPlayType(type) {
  9440. var can = undefined
  9441. // Loop through each playback technology in the options order
  9442. for (var i = 0, j = this.options_.techOrder; i < j.length; i++) {
  9443. var techName = _utilsToTitleCaseJs2['default'](j[i])
  9444. var tech = _techTechJs2['default'].getTech(techName)
  9445. // Support old behavior of techs being registered as components.
  9446. // Remove once that deprecated behavior is removed.
  9447. if (!tech) {
  9448. tech = _componentJs2['default'].getComponent(techName)
  9449. }
  9450. // Check if the current tech is defined before continuing
  9451. if (!tech) {
  9452. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.')
  9453. continue
  9454. }
  9455. // Check if the browser supports this technology
  9456. if (tech.isSupported()) {
  9457. can = tech.canPlayType(type)
  9458. if (can) {
  9459. return can
  9460. }
  9461. }
  9462. }
  9463. return ''
  9464. }
  9465. /**
  9466. * Select source based on tech-order or source-order
  9467. * Uses source-order selection if `options.sourceOrder` is truthy. Otherwise,
  9468. * defaults to tech-order selection
  9469. *
  9470. * @param {Array} sources The sources for a media asset
  9471. * @return {Object|Boolean} Object of source and tech order, otherwise false
  9472. * @method selectSource
  9473. */
  9474. Player.prototype.selectSource = function selectSource(sources) {
  9475. // Get only the techs specified in `techOrder` that exist and are supported by the
  9476. // current platform
  9477. var techs = this.options_.techOrder.map(_utilsToTitleCaseJs2['default']).map(function(techName) {
  9478. // `Component.getComponent(...)` is for support of old behavior of techs
  9479. // being registered as components.
  9480. // Remove once that deprecated behavior is removed.
  9481. return [techName, _techTechJs2['default'].getTech(techName) || _componentJs2['default'].getComponent(techName)]
  9482. }).filter(function(_ref) {
  9483. var techName = _ref[0]
  9484. var tech = _ref[1]
  9485. // Check if the current tech is defined before continuing
  9486. if (tech) {
  9487. // Check if the browser supports this technology
  9488. return tech.isSupported()
  9489. }
  9490. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.')
  9491. return false
  9492. })
  9493. // Iterate over each `innerArray` element once per `outerArray` element and execute
  9494. // `tester` with both. If `tester` returns a non-falsy value, exit early and return
  9495. // that value.
  9496. var findFirstPassingTechSourcePair = function findFirstPassingTechSourcePair(outerArray, innerArray, tester) {
  9497. var found = undefined
  9498. outerArray.some(function(outerChoice) {
  9499. return innerArray.some(function(innerChoice) {
  9500. found = tester(outerChoice, innerChoice)
  9501. if (found) {
  9502. return true
  9503. }
  9504. })
  9505. })
  9506. return found
  9507. }
  9508. var foundSourceAndTech = undefined
  9509. var flip = function flip(fn) {
  9510. return function(a, b) {
  9511. return fn(b, a)
  9512. }
  9513. }
  9514. var finder = function finder(_ref2, source) {
  9515. var techName = _ref2[0]
  9516. var tech = _ref2[1]
  9517. if (tech.canPlaySource(source)) {
  9518. return { source: source, tech: techName }
  9519. }
  9520. }
  9521. // Depending on the truthiness of `options.sourceOrder`, we swap the order of techs and sources
  9522. // to select from them based on their priority.
  9523. if (this.options_.sourceOrder) {
  9524. // Source-first ordering
  9525. foundSourceAndTech = findFirstPassingTechSourcePair(sources, techs, flip(finder))
  9526. } else {
  9527. // Tech-first ordering
  9528. foundSourceAndTech = findFirstPassingTechSourcePair(techs, sources, finder)
  9529. }
  9530. return foundSourceAndTech || false
  9531. }
  9532. /**
  9533. * The source function updates the video source
  9534. * There are three types of variables you can pass as the argument.
  9535. * **URL String**: A URL to the the video file. Use this method if you are sure
  9536. * the current playback technology (HTML5/Flash) can support the source you
  9537. * provide. Currently only MP4 files can be used in both HTML5 and Flash.
  9538. * ```js
  9539. * myPlayer.src("http://www.example.com/path/to/video.mp4");
  9540. * ```
  9541. * **Source Object (or element):* * A javascript object containing information
  9542. * about the source file. Use this method if you want the player to determine if
  9543. * it can support the file using the type information.
  9544. * ```js
  9545. * myPlayer.src({ type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" });
  9546. * ```
  9547. * **Array of Source Objects:* * To provide multiple versions of the source so
  9548. * that it can be played using HTML5 across browsers you can use an array of
  9549. * source objects. Video.js will detect which version is supported and load that
  9550. * file.
  9551. * ```js
  9552. * myPlayer.src([
  9553. * { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" },
  9554. * { type: "video/webm", src: "http://www.example.com/path/to/video.webm" },
  9555. * { type: "video/ogg", src: "http://www.example.com/path/to/video.ogv" }
  9556. * ]);
  9557. * ```
  9558. *
  9559. * @param {String|Object|Array=} source The source URL, object, or array of sources
  9560. * @return {String} The current video source when getting
  9561. * @return {String} The player when setting
  9562. * @method src
  9563. */
  9564. Player.prototype.src = function src(source) {
  9565. if (source === undefined) {
  9566. return this.techGet_('src')
  9567. }
  9568. var currentTech = _techTechJs2['default'].getTech(this.techName_)
  9569. // Support old behavior of techs being registered as components.
  9570. // Remove once that deprecated behavior is removed.
  9571. if (!currentTech) {
  9572. currentTech = _componentJs2['default'].getComponent(this.techName_)
  9573. }
  9574. // case: Array of source objects to choose from and pick the best to play
  9575. if (Array.isArray(source)) {
  9576. this.sourceList_(source)
  9577. // case: URL String (http://myvideo...)
  9578. } else if (typeof source === 'string') {
  9579. // create a source object from the string
  9580. this.src({ src: source })
  9581. // case: Source object { src: '', type: '' ... }
  9582. } else if (source instanceof Object) {
  9583. // check if the source has a type and the loaded tech cannot play the source
  9584. // if there's no type we'll just try the current tech
  9585. if (source.type && !currentTech.canPlaySource(source)) {
  9586. // create a source list with the current source and send through
  9587. // the tech loop to check for a compatible technology
  9588. this.sourceList_([source])
  9589. } else {
  9590. this.cache_.src = source.src
  9591. this.currentType_ = source.type || ''
  9592. // wait until the tech is ready to set the source
  9593. this.ready(function() {
  9594. // The setSource tech method was added with source handlers
  9595. // so older techs won't support it
  9596. // We need to check the direct prototype for the case where subclasses
  9597. // of the tech do not support source handlers
  9598. if (currentTech.prototype.hasOwnProperty('setSource')) {
  9599. this.techCall_('setSource', source)
  9600. } else {
  9601. this.techCall_('src', source.src)
  9602. }
  9603. if (this.options_.preload === 'auto') {
  9604. this.load()
  9605. }
  9606. if (this.options_.autoplay) {
  9607. this.play()
  9608. }
  9609. // Set the source synchronously if possible (#2326)
  9610. }, true)
  9611. }
  9612. }
  9613. return this
  9614. }
  9615. /**
  9616. * Handle an array of source objects
  9617. *
  9618. * @param {Array} sources Array of source objects
  9619. * @private
  9620. * @method sourceList_
  9621. */
  9622. Player.prototype.sourceList_ = function sourceList_(sources) {
  9623. var sourceTech = this.selectSource(sources)
  9624. if (sourceTech) {
  9625. if (sourceTech.tech === this.techName_) {
  9626. // if this technology is already loaded, set the source
  9627. this.src(sourceTech.source)
  9628. } else {
  9629. // load this technology with the chosen source
  9630. this.loadTech_(sourceTech.tech, sourceTech.source)
  9631. }
  9632. } else {
  9633. // We need to wrap this in a timeout to give folks a chance to add error event handlers
  9634. this.setTimeout(function() {
  9635. this.error({ code: 4, message: this.localize(this.options_.notSupportedMessage) })
  9636. }, 0)
  9637. // we could not find an appropriate tech, but let's still notify the delegate that this is it
  9638. // this needs a better comment about why this is needed
  9639. this.triggerReady()
  9640. }
  9641. }
  9642. /**
  9643. * Begin loading the src data.
  9644. *
  9645. * @return {Player} Returns the player
  9646. * @method load
  9647. */
  9648. Player.prototype.load = function load() {
  9649. this.techCall_('load')
  9650. return this
  9651. }
  9652. /**
  9653. * Reset the player. Loads the first tech in the techOrder,
  9654. * and calls `reset` on the tech`.
  9655. *
  9656. * @return {Player} Returns the player
  9657. * @method reset
  9658. */
  9659. Player.prototype.reset = function reset() {
  9660. this.loadTech_(_utilsToTitleCaseJs2['default'](this.options_.techOrder[0]), null)
  9661. this.techCall_('reset')
  9662. return this
  9663. }
  9664. /**
  9665. * Returns the fully qualified URL of the current source value e.g. http://mysite.com/video.mp4
  9666. * Can be used in conjuction with `currentType` to assist in rebuilding the current source object.
  9667. *
  9668. * @return {String} The current source
  9669. * @method currentSrc
  9670. */
  9671. Player.prototype.currentSrc = function currentSrc() {
  9672. return this.techGet_('currentSrc') || this.cache_.src || ''
  9673. }
  9674. /**
  9675. * Get the current source type e.g. video/mp4
  9676. * This can allow you rebuild the current source object so that you could load the same
  9677. * source and tech later
  9678. *
  9679. * @return {String} The source MIME type
  9680. * @method currentType
  9681. */
  9682. Player.prototype.currentType = function currentType() {
  9683. return this.currentType_ || ''
  9684. }
  9685. /**
  9686. * Get or set the preload attribute
  9687. *
  9688. * @param {Boolean} value Boolean to determine if preload should be used
  9689. * @return {String} The preload attribute value when getting
  9690. * @return {Player} Returns the player when setting
  9691. * @method preload
  9692. */
  9693. Player.prototype.preload = function preload(value) {
  9694. if (value !== undefined) {
  9695. this.techCall_('setPreload', value)
  9696. this.options_.preload = value
  9697. return this
  9698. }
  9699. return this.techGet_('preload')
  9700. }
  9701. /**
  9702. * Get or set the autoplay attribute.
  9703. *
  9704. * @param {Boolean} value Boolean to determine if video should autoplay
  9705. * @return {String} The autoplay attribute value when getting
  9706. * @return {Player} Returns the player when setting
  9707. * @method autoplay
  9708. */
  9709. Player.prototype.autoplay = function autoplay(value) {
  9710. if (value !== undefined) {
  9711. this.techCall_('setAutoplay', value)
  9712. this.options_.autoplay = value
  9713. return this
  9714. }
  9715. return this.techGet_('autoplay', value)
  9716. }
  9717. /**
  9718. * Get or set the loop attribute on the video element.
  9719. *
  9720. * @param {Boolean} value Boolean to determine if video should loop
  9721. * @return {String} The loop attribute value when getting
  9722. * @return {Player} Returns the player when setting
  9723. * @method loop
  9724. */
  9725. Player.prototype.loop = function loop(value) {
  9726. if (value !== undefined) {
  9727. this.techCall_('setLoop', value)
  9728. this.options_['loop'] = value
  9729. return this
  9730. }
  9731. return this.techGet_('loop')
  9732. }
  9733. /**
  9734. * Get or set the poster image source url
  9735. *
  9736. * ##### EXAMPLE:
  9737. * ```js
  9738. * // get
  9739. * var currentPoster = myPlayer.poster();
  9740. * // set
  9741. * myPlayer.poster('http://example.com/myImage.jpg');
  9742. * ```
  9743. *
  9744. * @param {String=} src Poster image source URL
  9745. * @return {String} poster URL when getting
  9746. * @return {Player} self when setting
  9747. * @method poster
  9748. */
  9749. Player.prototype.poster = function poster(src) {
  9750. if (src === undefined) {
  9751. return this.poster_
  9752. }
  9753. // The correct way to remove a poster is to set as an empty string
  9754. // other falsey values will throw errors
  9755. if (!src) {
  9756. src = ''
  9757. }
  9758. // update the internal poster variable
  9759. this.poster_ = src
  9760. // update the tech's poster
  9761. this.techCall_('setPoster', src)
  9762. // alert components that the poster has been set
  9763. this.trigger('posterchange')
  9764. return this
  9765. }
  9766. /**
  9767. * Some techs (e.g. YouTube) can provide a poster source in an
  9768. * asynchronous way. We want the poster component to use this
  9769. * poster source so that it covers up the tech's controls.
  9770. * (YouTube's play button). However we only want to use this
  9771. * soruce if the player user hasn't set a poster through
  9772. * the normal APIs.
  9773. *
  9774. * @private
  9775. * @method handleTechPosterChange_
  9776. */
  9777. Player.prototype.handleTechPosterChange_ = function handleTechPosterChange_() {
  9778. if (!this.poster_ && this.tech_ && this.tech_.poster) {
  9779. this.poster_ = this.tech_.poster() || ''
  9780. // Let components know the poster has changed
  9781. this.trigger('posterchange')
  9782. }
  9783. }
  9784. /**
  9785. * Get or set whether or not the controls are showing.
  9786. *
  9787. * @param {Boolean} bool Set controls to showing or not
  9788. * @return {Boolean} Controls are showing
  9789. * @method controls
  9790. */
  9791. Player.prototype.controls = function controls(bool) {
  9792. if (bool !== undefined) {
  9793. bool = !!bool // force boolean
  9794. // Don't trigger a change event unless it actually changed
  9795. if (this.controls_ !== bool) {
  9796. this.controls_ = bool
  9797. if (this.usingNativeControls()) {
  9798. this.techCall_('setControls', bool)
  9799. }
  9800. if (bool) {
  9801. this.removeClass('vjs-controls-disabled')
  9802. this.addClass('vjs-controls-enabled')
  9803. this.trigger('controlsenabled')
  9804. if (!this.usingNativeControls()) {
  9805. this.addTechControlsListeners_()
  9806. }
  9807. } else {
  9808. this.removeClass('vjs-controls-enabled')
  9809. this.addClass('vjs-controls-disabled')
  9810. this.trigger('controlsdisabled')
  9811. if (!this.usingNativeControls()) {
  9812. this.removeTechControlsListeners_()
  9813. }
  9814. }
  9815. }
  9816. return this
  9817. }
  9818. return !!this.controls_
  9819. }
  9820. /**
  9821. * Toggle native controls on/off. Native controls are the controls built into
  9822. * devices (e.g. default iPhone controls), Flash, or other techs
  9823. * (e.g. Vimeo Controls)
  9824. * **This should only be set by the current tech, because only the tech knows
  9825. * if it can support native controls**
  9826. *
  9827. * @param {Boolean} bool True signals that native controls are on
  9828. * @return {Player} Returns the player
  9829. * @private
  9830. * @method usingNativeControls
  9831. */
  9832. Player.prototype.usingNativeControls = function usingNativeControls(bool) {
  9833. if (bool !== undefined) {
  9834. bool = !!bool // force boolean
  9835. // Don't trigger a change event unless it actually changed
  9836. if (this.usingNativeControls_ !== bool) {
  9837. this.usingNativeControls_ = bool
  9838. if (bool) {
  9839. this.addClass('vjs-using-native-controls')
  9840. /**
  9841. * player is using the native device controls
  9842. *
  9843. * @event usingnativecontrols
  9844. * @memberof Player
  9845. * @instance
  9846. * @private
  9847. */
  9848. this.trigger('usingnativecontrols')
  9849. } else {
  9850. this.removeClass('vjs-using-native-controls')
  9851. /**
  9852. * player is using the custom HTML controls
  9853. *
  9854. * @event usingcustomcontrols
  9855. * @memberof Player
  9856. * @instance
  9857. * @private
  9858. */
  9859. this.trigger('usingcustomcontrols')
  9860. }
  9861. }
  9862. return this
  9863. }
  9864. return !!this.usingNativeControls_
  9865. }
  9866. /**
  9867. * Set or get the current MediaError
  9868. *
  9869. * @param {*} err A MediaError or a String/Number to be turned into a MediaError
  9870. * @return {MediaError|null} when getting
  9871. * @return {Player} when setting
  9872. * @method error
  9873. */
  9874. Player.prototype.error = function error(err) {
  9875. if (err === undefined) {
  9876. return this.error_ || null
  9877. }
  9878. // restoring to default
  9879. if (err === null) {
  9880. this.error_ = err
  9881. this.removeClass('vjs-error')
  9882. this.errorDisplay.close()
  9883. return this
  9884. }
  9885. // error instance
  9886. if (err instanceof _mediaErrorJs2['default']) {
  9887. this.error_ = err
  9888. } else {
  9889. this.error_ = new _mediaErrorJs2['default'](err)
  9890. }
  9891. // add the vjs-error classname to the player
  9892. this.addClass('vjs-error')
  9893. // log the name of the error type and any message
  9894. // ie8 just logs "[object object]" if you just log the error object
  9895. _utilsLogJs2['default'].error('(CODE:' + this.error_.code + ' ' + _mediaErrorJs2['default'].errorTypes[this.error_.code] + ')', this.error_.message, this.error_)
  9896. // fire an error event on the player
  9897. this.trigger('error')
  9898. return this
  9899. }
  9900. /**
  9901. * Returns whether or not the player is in the "ended" state.
  9902. *
  9903. * @return {Boolean} True if the player is in the ended state, false if not.
  9904. * @method ended
  9905. */
  9906. Player.prototype.ended = function ended() {
  9907. return this.techGet_('ended')
  9908. }
  9909. /**
  9910. * Returns whether or not the player is in the "seeking" state.
  9911. *
  9912. * @return {Boolean} True if the player is in the seeking state, false if not.
  9913. * @method seeking
  9914. */
  9915. Player.prototype.seeking = function seeking() {
  9916. return this.techGet_('seeking')
  9917. }
  9918. /**
  9919. * Returns the TimeRanges of the media that are currently available
  9920. * for seeking to.
  9921. *
  9922. * @return {TimeRanges} the seekable intervals of the media timeline
  9923. * @method seekable
  9924. */
  9925. Player.prototype.seekable = function seekable() {
  9926. return this.techGet_('seekable')
  9927. }
  9928. /**
  9929. * Report user activity
  9930. *
  9931. * @param {Object} event Event object
  9932. * @method reportUserActivity
  9933. */
  9934. Player.prototype.reportUserActivity = function reportUserActivity(event) {
  9935. this.userActivity_ = true
  9936. }
  9937. /**
  9938. * Get/set if user is active
  9939. *
  9940. * @param {Boolean} bool Value when setting
  9941. * @return {Boolean} Value if user is active user when getting
  9942. * @method userActive
  9943. */
  9944. Player.prototype.userActive = function userActive(bool) {
  9945. if (bool !== undefined) {
  9946. bool = !!bool
  9947. if (bool !== this.userActive_) {
  9948. this.userActive_ = bool
  9949. if (bool) {
  9950. // If the user was inactive and is now active we want to reset the
  9951. // inactivity timer
  9952. this.userActivity_ = true
  9953. this.removeClass('vjs-user-inactive')
  9954. this.addClass('vjs-user-active')
  9955. this.trigger('useractive')
  9956. } else {
  9957. // We're switching the state to inactive manually, so erase any other
  9958. // activity
  9959. this.userActivity_ = false
  9960. // Chrome/Safari/IE have bugs where when you change the cursor it can
  9961. // trigger a mousemove event. This causes an issue when you're hiding
  9962. // the cursor when the user is inactive, and a mousemove signals user
  9963. // activity. Making it impossible to go into inactive mode. Specifically
  9964. // this happens in fullscreen when we really need to hide the cursor.
  9965. //
  9966. // When this gets resolved in ALL browsers it can be removed
  9967. // https://code.google.com/p/chromium/issues/detail?id=103041
  9968. if (this.tech_) {
  9969. this.tech_.one('mousemove', function(e) {
  9970. e.stopPropagation()
  9971. e.preventDefault()
  9972. })
  9973. }
  9974. this.removeClass('vjs-user-active')
  9975. this.addClass('vjs-user-inactive')
  9976. this.trigger('userinactive')
  9977. }
  9978. }
  9979. return this
  9980. }
  9981. return this.userActive_
  9982. }
  9983. /**
  9984. * Listen for user activity based on timeout value
  9985. *
  9986. * @private
  9987. * @method listenForUserActivity_
  9988. */
  9989. Player.prototype.listenForUserActivity_ = function listenForUserActivity_() {
  9990. var mouseInProgress = undefined
  9991. var lastMoveX = undefined
  9992. var lastMoveY = undefined
  9993. var handleActivity = Fn.bind(this, this.reportUserActivity)
  9994. var handleMouseMove = function handleMouseMove(e) {
  9995. // #1068 - Prevent mousemove spamming
  9996. // Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
  9997. if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) {
  9998. lastMoveX = e.screenX
  9999. lastMoveY = e.screenY
  10000. handleActivity()
  10001. }
  10002. }
  10003. var handleMouseDown = function handleMouseDown() {
  10004. handleActivity()
  10005. // For as long as the they are touching the device or have their mouse down,
  10006. // we consider them active even if they're not moving their finger or mouse.
  10007. // So we want to continue to update that they are active
  10008. this.clearInterval(mouseInProgress)
  10009. // Setting userActivity=true now and setting the interval to the same time
  10010. // as the activityCheck interval (250) should ensure we never miss the
  10011. // next activityCheck
  10012. mouseInProgress = this.setInterval(handleActivity, 250)
  10013. }
  10014. var handleMouseUp = function handleMouseUp(event) {
  10015. handleActivity()
  10016. // Stop the interval that maintains activity if the mouse/touch is down
  10017. this.clearInterval(mouseInProgress)
  10018. }
  10019. // Any mouse movement will be considered user activity
  10020. this.on('mousedown', handleMouseDown)
  10021. this.on('mousemove', handleMouseMove)
  10022. this.on('mouseup', handleMouseUp)
  10023. // Listen for keyboard navigation
  10024. // Shouldn't need to use inProgress interval because of key repeat
  10025. this.on('keydown', handleActivity)
  10026. this.on('keyup', handleActivity)
  10027. // Run an interval every 250 milliseconds instead of stuffing everything into
  10028. // the mousemove/touchmove function itself, to prevent performance degradation.
  10029. // `this.reportUserActivity` simply sets this.userActivity_ to true, which
  10030. // then gets picked up by this loop
  10031. // http://ejohn.org/blog/learning-from-twitter/
  10032. var inactivityTimeout = undefined
  10033. var activityCheck = this.setInterval(function() {
  10034. // Check to see if mouse/touch activity has happened
  10035. if (this.userActivity_) {
  10036. // Reset the activity tracker
  10037. this.userActivity_ = false
  10038. // If the user state was inactive, set the state to active
  10039. this.userActive(true)
  10040. // Clear any existing inactivity timeout to start the timer over
  10041. this.clearTimeout(inactivityTimeout)
  10042. var timeout = this.options_['inactivityTimeout']
  10043. if (timeout > 0) {
  10044. // In <timeout> milliseconds, if no more activity has occurred the
  10045. // user will be considered inactive
  10046. inactivityTimeout = this.setTimeout(function() {
  10047. // Protect against the case where the inactivityTimeout can trigger just
  10048. // before the next user activity is picked up by the activityCheck loop
  10049. // causing a flicker
  10050. if (!this.userActivity_) {
  10051. this.userActive(false)
  10052. }
  10053. }, timeout)
  10054. }
  10055. }
  10056. }, 250)
  10057. }
  10058. /**
  10059. * Gets or sets the current playback rate. A playback rate of
  10060. * 1.0 represents normal speed and 0.5 would indicate half-speed
  10061. * playback, for instance.
  10062. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-playbackrate
  10063. *
  10064. * @param {Number} rate New playback rate to set.
  10065. * @return {Number} Returns the new playback rate when setting
  10066. * @return {Number} Returns the current playback rate when getting
  10067. * @method playbackRate
  10068. */
  10069. Player.prototype.playbackRate = function playbackRate(rate) {
  10070. if (rate !== undefined) {
  10071. this.techCall_('setPlaybackRate', rate)
  10072. return this
  10073. }
  10074. if (this.tech_ && this.tech_['featuresPlaybackRate']) {
  10075. return this.techGet_('playbackRate')
  10076. } else {
  10077. return 1.0
  10078. }
  10079. }
  10080. /**
  10081. * Gets or sets the audio flag
  10082. *
  10083. * @param {Boolean} bool True signals that this is an audio player.
  10084. * @return {Boolean} Returns true if player is audio, false if not when getting
  10085. * @return {Player} Returns the player if setting
  10086. * @private
  10087. * @method isAudio
  10088. */
  10089. Player.prototype.isAudio = function isAudio(bool) {
  10090. if (bool !== undefined) {
  10091. this.isAudio_ = !!bool
  10092. return this
  10093. }
  10094. return !!this.isAudio_
  10095. }
  10096. /**
  10097. * Returns the current state of network activity for the element, from
  10098. * the codes in the list below.
  10099. * - NETWORK_EMPTY (numeric value 0)
  10100. * The element has not yet been initialised. All attributes are in
  10101. * their initial states.
  10102. * - NETWORK_IDLE (numeric value 1)
  10103. * The element's resource selection algorithm is active and has
  10104. * selected a resource, but it is not actually using the network at
  10105. * this time.
  10106. * - NETWORK_LOADING (numeric value 2)
  10107. * The user agent is actively trying to download data.
  10108. * - NETWORK_NO_SOURCE (numeric value 3)
  10109. * The element's resource selection algorithm is active, but it has
  10110. * not yet found a resource to use.
  10111. *
  10112. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#network-states
  10113. * @return {Number} the current network activity state
  10114. * @method networkState
  10115. */
  10116. Player.prototype.networkState = function networkState() {
  10117. return this.techGet_('networkState')
  10118. }
  10119. /**
  10120. * Returns a value that expresses the current state of the element
  10121. * with respect to rendering the current playback position, from the
  10122. * codes in the list below.
  10123. * - HAVE_NOTHING (numeric value 0)
  10124. * No information regarding the media resource is available.
  10125. * - HAVE_METADATA (numeric value 1)
  10126. * Enough of the resource has been obtained that the duration of the
  10127. * resource is available.
  10128. * - HAVE_CURRENT_DATA (numeric value 2)
  10129. * Data for the immediate current playback position is available.
  10130. * - HAVE_FUTURE_DATA (numeric value 3)
  10131. * Data for the immediate current playback position is available, as
  10132. * well as enough data for the user agent to advance the current
  10133. * playback position in the direction of playback.
  10134. * - HAVE_ENOUGH_DATA (numeric value 4)
  10135. * The user agent estimates that enough data is available for
  10136. * playback to proceed uninterrupted.
  10137. *
  10138. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-readystate
  10139. * @return {Number} the current playback rendering state
  10140. * @method readyState
  10141. */
  10142. Player.prototype.readyState = function readyState() {
  10143. return this.techGet_('readyState')
  10144. }
  10145. /**
  10146. * Get a video track list
  10147. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist
  10148. *
  10149. * @return {VideoTrackList} thes current video track list
  10150. * @method videoTracks
  10151. */
  10152. Player.prototype.videoTracks = function videoTracks() {
  10153. // if we have not yet loadTech_, we create videoTracks_
  10154. // these will be passed to the tech during loading
  10155. if (!this.tech_) {
  10156. this.videoTracks_ = this.videoTracks_ || new _tracksVideoTrackListJs2['default']()
  10157. return this.videoTracks_
  10158. }
  10159. return this.tech_.videoTracks()
  10160. }
  10161. /**
  10162. * Get an audio track list
  10163. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist
  10164. *
  10165. * @return {AudioTrackList} thes current audio track list
  10166. * @method audioTracks
  10167. */
  10168. Player.prototype.audioTracks = function audioTracks() {
  10169. // if we have not yet loadTech_, we create videoTracks_
  10170. // these will be passed to the tech during loading
  10171. if (!this.tech_) {
  10172. this.audioTracks_ = this.audioTracks_ || new _tracksAudioTrackListJs2['default']()
  10173. return this.audioTracks_
  10174. }
  10175. return this.tech_.audioTracks()
  10176. }
  10177. /*
  10178. * Text tracks are tracks of timed text events.
  10179. * Captions - text displayed over the video for the hearing impaired
  10180. * Subtitles - text displayed over the video for those who don't understand language in the video
  10181. * Chapters - text displayed in a menu allowing the user to jump to particular points (chapters) in the video
  10182. * Descriptions (not supported yet) - audio descriptions that are read back to the user by a screen reading device
  10183. */
  10184. /**
  10185. * Get an array of associated text tracks. captions, subtitles, chapters, descriptions
  10186. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-texttracks
  10187. *
  10188. * @return {Array} Array of track objects
  10189. * @method textTracks
  10190. */
  10191. Player.prototype.textTracks = function textTracks() {
  10192. // cannot use techGet_ directly because it checks to see whether the tech is ready.
  10193. // Flash is unlikely to be ready in time but textTracks should still work.
  10194. return this.tech_ && this.tech_['textTracks']()
  10195. }
  10196. /**
  10197. * Get an array of remote text tracks
  10198. *
  10199. * @return {Array}
  10200. * @method remoteTextTracks
  10201. */
  10202. Player.prototype.remoteTextTracks = function remoteTextTracks() {
  10203. return this.tech_ && this.tech_['remoteTextTracks']()
  10204. }
  10205. /**
  10206. * Get an array of remote html track elements
  10207. *
  10208. * @return {HTMLTrackElement[]}
  10209. * @method remoteTextTrackEls
  10210. */
  10211. Player.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  10212. return this.tech_ && this.tech_['remoteTextTrackEls']()
  10213. }
  10214. /**
  10215. * Add a text track
  10216. * In addition to the W3C settings we allow adding additional info through options.
  10217. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-addtexttrack
  10218. *
  10219. * @param {String} kind Captions, subtitles, chapters, descriptions, or metadata
  10220. * @param {String=} label Optional label
  10221. * @param {String=} language Optional language
  10222. * @method addTextTrack
  10223. */
  10224. Player.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  10225. return this.tech_ && this.tech_['addTextTrack'](kind, label, language)
  10226. }
  10227. /**
  10228. * Add a remote text track
  10229. *
  10230. * @param {Object} options Options for remote text track
  10231. * @method addRemoteTextTrack
  10232. */
  10233. Player.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  10234. return this.tech_ && this.tech_['addRemoteTextTrack'](options)
  10235. }
  10236. /**
  10237. * Remove a remote text track
  10238. *
  10239. * @param {Object} track Remote text track to remove
  10240. * @method removeRemoteTextTrack
  10241. */
  10242. // destructure the input into an object with a track argument, defaulting to arguments[0]
  10243. // default the whole argument to an empty object if nothing was passed in
  10244. Player.prototype.removeRemoteTextTrack = function removeRemoteTextTrack() {
  10245. var _ref3 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  10246. var _ref3$track = _ref3.track
  10247. var track = _ref3$track === undefined ? arguments[0] : _ref3$track
  10248. // jshint ignore:line
  10249. this.tech_ && this.tech_['removeRemoteTextTrack'](track)
  10250. }
  10251. /**
  10252. * Get video width
  10253. *
  10254. * @return {Number} Video width
  10255. * @method videoWidth
  10256. */
  10257. Player.prototype.videoWidth = function videoWidth() {
  10258. return this.tech_ && this.tech_.videoWidth && this.tech_.videoWidth() || 0
  10259. }
  10260. /**
  10261. * Get video height
  10262. *
  10263. * @return {Number} Video height
  10264. * @method videoHeight
  10265. */
  10266. Player.prototype.videoHeight = function videoHeight() {
  10267. return this.tech_ && this.tech_.videoHeight && this.tech_.videoHeight() || 0
  10268. }
  10269. // Methods to add support for
  10270. // initialTime: function(){ return this.techCall_('initialTime'); },
  10271. // startOffsetTime: function(){ return this.techCall_('startOffsetTime'); },
  10272. // played: function(){ return this.techCall_('played'); },
  10273. // defaultPlaybackRate: function(){ return this.techCall_('defaultPlaybackRate'); },
  10274. // defaultMuted: function(){ return this.techCall_('defaultMuted'); }
  10275. /**
  10276. * The player's language code
  10277. * NOTE: The language should be set in the player options if you want the
  10278. * the controls to be built with a specific language. Changing the lanugage
  10279. * later will not update controls text.
  10280. *
  10281. * @param {String} code The locale string
  10282. * @return {String} The locale string when getting
  10283. * @return {Player} self when setting
  10284. * @method language
  10285. */
  10286. Player.prototype.language = function language(code) {
  10287. if (code === undefined) {
  10288. return this.language_
  10289. }
  10290. this.language_ = ('' + code).toLowerCase()
  10291. return this
  10292. }
  10293. /**
  10294. * Get the player's language dictionary
  10295. * Merge every time, because a newly added plugin might call videojs.addLanguage() at any time
  10296. * Languages specified directly in the player options have precedence
  10297. *
  10298. * @return {Array} Array of languages
  10299. * @method languages
  10300. */
  10301. Player.prototype.languages = function languages() {
  10302. return _utilsMergeOptionsJs2['default'](Player.prototype.options_.languages, this.languages_)
  10303. }
  10304. /**
  10305. * Converts track info to JSON
  10306. *
  10307. * @return {Object} JSON object of options
  10308. * @method toJSON
  10309. */
  10310. Player.prototype.toJSON = function toJSON() {
  10311. var options = _utilsMergeOptionsJs2['default'](this.options_)
  10312. var tracks = options.tracks
  10313. options.tracks = []
  10314. for (var i = 0; i < tracks.length; i++) {
  10315. var track = tracks[i]
  10316. // deep merge tracks and null out player so no circular references
  10317. track = _utilsMergeOptionsJs2['default'](track)
  10318. track.player = undefined
  10319. options.tracks[i] = track
  10320. }
  10321. return options
  10322. }
  10323. /**
  10324. * Creates a simple modal dialog (an instance of the `ModalDialog`
  10325. * component) that immediately overlays the player with arbitrary
  10326. * content and removes itself when closed.
  10327. *
  10328. * @param {String|Function|Element|Array|Null} content
  10329. * Same as `ModalDialog#content`'s param of the same name.
  10330. *
  10331. * The most straight-forward usage is to provide a string or DOM
  10332. * element.
  10333. *
  10334. * @param {Object} [options]
  10335. * Extra options which will be passed on to the `ModalDialog`.
  10336. *
  10337. * @return {ModalDialog}
  10338. */
  10339. Player.prototype.createModal = function createModal(content, options) {
  10340. var player = this
  10341. options = options || {}
  10342. options.content = content || ''
  10343. var modal = new _modalDialog2['default'](player, options)
  10344. player.addChild(modal)
  10345. modal.on('dispose', function() {
  10346. player.removeChild(modal)
  10347. })
  10348. return modal.open()
  10349. }
  10350. /**
  10351. * Gets tag settings
  10352. *
  10353. * @param {Element} tag The player tag
  10354. * @return {Array} An array of sources and track objects
  10355. * @static
  10356. * @method getTagSettings
  10357. */
  10358. Player.getTagSettings = function getTagSettings(tag) {
  10359. var baseOptions = {
  10360. 'sources': [],
  10361. 'tracks': []
  10362. }
  10363. var tagOptions = Dom.getElAttributes(tag)
  10364. var dataSetup = tagOptions['data-setup']
  10365. // Check if data-setup attr exists.
  10366. if (dataSetup !== null) {
  10367. // Parse options JSON
  10368. var _safeParseTuple = _safeJsonParseTuple2['default'](dataSetup || '{}')
  10369. var err = _safeParseTuple[0]
  10370. var data = _safeParseTuple[1]
  10371. if (err) {
  10372. _utilsLogJs2['default'].error(err)
  10373. }
  10374. _objectAssign2['default'](tagOptions, data)
  10375. }
  10376. _objectAssign2['default'](baseOptions, tagOptions)
  10377. // Get tag children settings
  10378. if (tag.hasChildNodes()) {
  10379. var children = tag.childNodes
  10380. for (var i = 0, j = children.length; i < j; i++) {
  10381. var child = children[i]
  10382. // Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
  10383. var childName = child.nodeName.toLowerCase()
  10384. if (childName === 'source') {
  10385. baseOptions.sources.push(Dom.getElAttributes(child))
  10386. } else if (childName === 'track') {
  10387. baseOptions.tracks.push(Dom.getElAttributes(child))
  10388. }
  10389. }
  10390. }
  10391. return baseOptions
  10392. }
  10393. return Player
  10394. })(_componentJs2['default'])
  10395. Player.players = {}
  10396. var navigator = _globalWindow2['default'].navigator
  10397. /*
  10398. * Player instance options, surfaced using options
  10399. * options = Player.prototype.options_
  10400. * Make changes in options, not here.
  10401. *
  10402. * @type {Object}
  10403. * @private
  10404. */
  10405. Player.prototype.options_ = {
  10406. // Default order of fallback technology
  10407. techOrder: ['html5', 'flash'],
  10408. // techOrder: ['flash','html5'],
  10409. html5: {},
  10410. flash: {},
  10411. // defaultVolume: 0.85,
  10412. defaultVolume: 0.00, // The freakin seaguls are driving me crazy!
  10413. // default inactivity timeout
  10414. inactivityTimeout: 2000,
  10415. // default playback rates
  10416. playbackRates: [],
  10417. // Add playback rate selection by adding rates
  10418. // 'playbackRates': [0.5, 1, 1.5, 2],
  10419. // Included control sets
  10420. children: ['mediaLoader', 'posterImage', 'textTrackDisplay', 'loadingSpinner', 'bigPlayButton', 'controlBar', 'errorDisplay', 'textTrackSettings'],
  10421. language: _globalDocument2['default'].getElementsByTagName('html')[0].getAttribute('lang') || navigator.languages && navigator.languages[0] || navigator.userLanguage || navigator.language || 'en',
  10422. // locales and their language translations
  10423. languages: {},
  10424. // Default message to show when a video cannot be played.
  10425. notSupportedMessage: 'No compatible source was found for this media.'
  10426. }
  10427. /**
  10428. * Fired when the player has initial duration and dimension information
  10429. *
  10430. * @event loadedmetadata
  10431. */
  10432. Player.prototype.handleLoadedMetaData_
  10433. /**
  10434. * Fired when the player has downloaded data at the current playback position
  10435. *
  10436. * @event loadeddata
  10437. */
  10438. Player.prototype.handleLoadedData_
  10439. /**
  10440. * Fired when the user is active, e.g. moves the mouse over the player
  10441. *
  10442. * @event useractive
  10443. */
  10444. Player.prototype.handleUserActive_
  10445. /**
  10446. * Fired when the user is inactive, e.g. a short delay after the last mouse move or control interaction
  10447. *
  10448. * @event userinactive
  10449. */
  10450. Player.prototype.handleUserInactive_
  10451. /**
  10452. * Fired when the current playback position has changed *
  10453. * During playback this is fired every 15-250 milliseconds, depending on the
  10454. * playback technology in use.
  10455. *
  10456. * @event timeupdate
  10457. */
  10458. Player.prototype.handleTimeUpdate_
  10459. /**
  10460. * Fired when video playback ends
  10461. *
  10462. * @event ended
  10463. */
  10464. Player.prototype.handleTechEnded_
  10465. /**
  10466. * Fired when the volume changes
  10467. *
  10468. * @event volumechange
  10469. */
  10470. Player.prototype.handleVolumeChange_
  10471. /**
  10472. * Fired when an error occurs
  10473. *
  10474. * @event error
  10475. */
  10476. Player.prototype.handleError_
  10477. Player.prototype.flexNotSupported_ = function() {
  10478. var elem = _globalDocument2['default'].createElement('i')
  10479. // Note: We don't actually use flexBasis (or flexOrder), but it's one of the more
  10480. // common flex features that we can rely on when checking for flex support.
  10481. 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) */
  10482. }
  10483. _componentJs2['default'].registerComponent('Player', Player)
  10484. exports['default'] = Player
  10485. module.exports = exports['default']
  10486. // If empty string, make it a parsable json object.
  10487. }, { './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) {
  10488. /**
  10489. * @file plugins.js
  10490. */
  10491. 'use strict'
  10492. exports.__esModule = true
  10493. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  10494. var _playerJs = _dereq_('./player.js')
  10495. var _playerJs2 = _interopRequireDefault(_playerJs)
  10496. /**
  10497. * The method for registering a video.js plugin
  10498. *
  10499. * @param {String} name The name of the plugin
  10500. * @param {Function} init The function that is run when the player inits
  10501. * @method plugin
  10502. */
  10503. var plugin = function plugin(name, init) {
  10504. _playerJs2['default'].prototype[name] = init
  10505. }
  10506. exports['default'] = plugin
  10507. module.exports = exports['default']
  10508. }, { './player.js': 113 }], 115: [function(_dereq_, module, exports) {
  10509. /**
  10510. * @file popup-button.js
  10511. */
  10512. 'use strict'
  10513. exports.__esModule = true
  10514. 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 } }
  10515. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  10516. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  10517. 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 }
  10518. var _clickableComponentJs = _dereq_('../clickable-component.js')
  10519. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs)
  10520. var _componentJs = _dereq_('../component.js')
  10521. var _componentJs2 = _interopRequireDefault(_componentJs)
  10522. var _popupJs = _dereq_('./popup.js')
  10523. var _popupJs2 = _interopRequireDefault(_popupJs)
  10524. var _utilsDomJs = _dereq_('../utils/dom.js')
  10525. var Dom = _interopRequireWildcard(_utilsDomJs)
  10526. var _utilsFnJs = _dereq_('../utils/fn.js')
  10527. var Fn = _interopRequireWildcard(_utilsFnJs)
  10528. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js')
  10529. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs)
  10530. /**
  10531. * A button class with a popup control
  10532. *
  10533. * @param {Player|Object} player
  10534. * @param {Object=} options
  10535. * @extends ClickableComponent
  10536. * @class PopupButton
  10537. */
  10538. var PopupButton = (function(_ClickableComponent) {
  10539. _inherits(PopupButton, _ClickableComponent)
  10540. function PopupButton(player) {
  10541. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  10542. _classCallCheck(this, PopupButton)
  10543. _ClickableComponent.call(this, player, options)
  10544. this.update()
  10545. }
  10546. /**
  10547. * Update popup
  10548. *
  10549. * @method update
  10550. */
  10551. PopupButton.prototype.update = function update() {
  10552. var popup = this.createPopup()
  10553. if (this.popup) {
  10554. this.removeChild(this.popup)
  10555. }
  10556. this.popup = popup
  10557. this.addChild(popup)
  10558. if (this.items && this.items.length === 0) {
  10559. this.hide()
  10560. } else if (this.items && this.items.length > 1) {
  10561. this.show()
  10562. }
  10563. }
  10564. /**
  10565. * Create popup - Override with specific functionality for component
  10566. *
  10567. * @return {Popup} The constructed popup
  10568. * @method createPopup
  10569. */
  10570. PopupButton.prototype.createPopup = function createPopup() { }
  10571. /**
  10572. * Create the component's DOM element
  10573. *
  10574. * @return {Element}
  10575. * @method createEl
  10576. */
  10577. PopupButton.prototype.createEl = function createEl() {
  10578. return _ClickableComponent.prototype.createEl.call(this, 'div', {
  10579. className: this.buildCSSClass()
  10580. })
  10581. }
  10582. /**
  10583. * Allow sub components to stack CSS class names
  10584. *
  10585. * @return {String} The constructed class name
  10586. * @method buildCSSClass
  10587. */
  10588. PopupButton.prototype.buildCSSClass = function buildCSSClass() {
  10589. var menuButtonClass = 'vjs-menu-button'
  10590. // If the inline option is passed, we want to use different styles altogether.
  10591. if (this.options_.inline === true) {
  10592. menuButtonClass += '-inline'
  10593. } else {
  10594. menuButtonClass += '-popup'
  10595. }
  10596. return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this)
  10597. }
  10598. return PopupButton
  10599. })(_clickableComponentJs2['default'])
  10600. _componentJs2['default'].registerComponent('PopupButton', PopupButton)
  10601. exports['default'] = PopupButton
  10602. module.exports = exports['default']
  10603. }, { '../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) {
  10604. /**
  10605. * @file popup.js
  10606. */
  10607. 'use strict'
  10608. exports.__esModule = true
  10609. 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 } }
  10610. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  10611. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  10612. 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 }
  10613. var _componentJs = _dereq_('../component.js')
  10614. var _componentJs2 = _interopRequireDefault(_componentJs)
  10615. var _utilsDomJs = _dereq_('../utils/dom.js')
  10616. var Dom = _interopRequireWildcard(_utilsDomJs)
  10617. var _utilsFnJs = _dereq_('../utils/fn.js')
  10618. var Fn = _interopRequireWildcard(_utilsFnJs)
  10619. var _utilsEventsJs = _dereq_('../utils/events.js')
  10620. var Events = _interopRequireWildcard(_utilsEventsJs)
  10621. /**
  10622. * The Popup component is used to build pop up controls.
  10623. *
  10624. * @extends Component
  10625. * @class Popup
  10626. */
  10627. var Popup = (function(_Component) {
  10628. _inherits(Popup, _Component)
  10629. function Popup() {
  10630. _classCallCheck(this, Popup)
  10631. _Component.apply(this, arguments)
  10632. }
  10633. /**
  10634. * Add a popup item to the popup
  10635. *
  10636. * @param {Object|String} component Component or component type to add
  10637. * @method addItem
  10638. */
  10639. Popup.prototype.addItem = function addItem(component) {
  10640. this.addChild(component)
  10641. component.on('click', Fn.bind(this, function() {
  10642. this.unlockShowing()
  10643. }))
  10644. }
  10645. /**
  10646. * Create the component's DOM element
  10647. *
  10648. * @return {Element}
  10649. * @method createEl
  10650. */
  10651. Popup.prototype.createEl = function createEl() {
  10652. var contentElType = this.options_.contentElType || 'ul'
  10653. this.contentEl_ = Dom.createEl(contentElType, {
  10654. className: 'vjs-menu-content'
  10655. })
  10656. var el = _Component.prototype.createEl.call(this, 'div', {
  10657. append: this.contentEl_,
  10658. className: 'vjs-menu'
  10659. })
  10660. el.appendChild(this.contentEl_)
  10661. // Prevent clicks from bubbling up. Needed for Popup Buttons,
  10662. // where a click on the parent is significant
  10663. Events.on(el, 'click', function(event) {
  10664. event.preventDefault()
  10665. event.stopImmediatePropagation()
  10666. })
  10667. return el
  10668. }
  10669. return Popup
  10670. })(_componentJs2['default'])
  10671. _componentJs2['default'].registerComponent('Popup', Popup)
  10672. exports['default'] = Popup
  10673. module.exports = exports['default']
  10674. }, { '../component.js': 67, '../utils/dom.js': 143, '../utils/events.js': 144, '../utils/fn.js': 145 }], 117: [function(_dereq_, module, exports) {
  10675. /**
  10676. * @file poster-image.js
  10677. */
  10678. 'use strict'
  10679. exports.__esModule = true
  10680. 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 } }
  10681. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  10682. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  10683. 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 }
  10684. var _clickableComponentJs = _dereq_('./clickable-component.js')
  10685. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs)
  10686. var _componentJs = _dereq_('./component.js')
  10687. var _componentJs2 = _interopRequireDefault(_componentJs)
  10688. var _utilsFnJs = _dereq_('./utils/fn.js')
  10689. var Fn = _interopRequireWildcard(_utilsFnJs)
  10690. var _utilsDomJs = _dereq_('./utils/dom.js')
  10691. var Dom = _interopRequireWildcard(_utilsDomJs)
  10692. var _utilsBrowserJs = _dereq_('./utils/browser.js')
  10693. var browser = _interopRequireWildcard(_utilsBrowserJs)
  10694. /**
  10695. * The component that handles showing the poster image.
  10696. *
  10697. * @param {Player|Object} player
  10698. * @param {Object=} options
  10699. * @extends Button
  10700. * @class PosterImage
  10701. */
  10702. var PosterImage = (function(_ClickableComponent) {
  10703. _inherits(PosterImage, _ClickableComponent)
  10704. function PosterImage(player, options) {
  10705. _classCallCheck(this, PosterImage)
  10706. _ClickableComponent.call(this, player, options)
  10707. this.update()
  10708. player.on('posterchange', Fn.bind(this, this.update))
  10709. }
  10710. /**
  10711. * Clean up the poster image
  10712. *
  10713. * @method dispose
  10714. */
  10715. PosterImage.prototype.dispose = function dispose() {
  10716. this.player().off('posterchange', this.update)
  10717. _ClickableComponent.prototype.dispose.call(this)
  10718. }
  10719. /**
  10720. * Create the poster's image element
  10721. *
  10722. * @return {Element}
  10723. * @method createEl
  10724. */
  10725. PosterImage.prototype.createEl = function createEl() {
  10726. var el = Dom.createEl('div', {
  10727. className: 'vjs-poster',
  10728. // Don't want poster to be tabbable.
  10729. tabIndex: -1
  10730. })
  10731. // To ensure the poster image resizes while maintaining its original aspect
  10732. // ratio, use a div with `background-size` when available. For browsers that
  10733. // do not support `background-size` (e.g. IE8), fall back on using a regular
  10734. // img element.
  10735. if (!browser.BACKGROUND_SIZE_SUPPORTED) {
  10736. this.fallbackImg_ = Dom.createEl('img')
  10737. el.appendChild(this.fallbackImg_)
  10738. }
  10739. return el
  10740. }
  10741. /**
  10742. * Event handler for updates to the player's poster source
  10743. *
  10744. * @method update
  10745. */
  10746. PosterImage.prototype.update = function update() {
  10747. var url = this.player().poster()
  10748. this.setSrc(url)
  10749. // If there's no poster source we should display:none on this component
  10750. // so it's not still clickable or right-clickable
  10751. if (url) {
  10752. this.show()
  10753. } else {
  10754. this.hide()
  10755. }
  10756. }
  10757. /**
  10758. * Set the poster source depending on the display method
  10759. *
  10760. * @param {String} url The URL to the poster source
  10761. * @method setSrc
  10762. */
  10763. PosterImage.prototype.setSrc = function setSrc(url) {
  10764. if (this.fallbackImg_) {
  10765. this.fallbackImg_.src = url
  10766. } else {
  10767. var backgroundImage = ''
  10768. // Any falsey values should stay as an empty string, otherwise
  10769. // this will throw an extra error
  10770. if (url) {
  10771. backgroundImage = 'url("' + url + '")'
  10772. }
  10773. this.el_.style.backgroundImage = backgroundImage
  10774. }
  10775. }
  10776. /**
  10777. * Event handler for clicks on the poster image
  10778. *
  10779. * @method handleClick
  10780. */
  10781. PosterImage.prototype.handleClick = function handleClick() {
  10782. // We don't want a click to trigger playback when controls are disabled
  10783. // but CSS should be hiding the poster to prevent that from happening
  10784. if (this.player_.paused()) {
  10785. this.player_.play()
  10786. } else {
  10787. this.player_.pause()
  10788. }
  10789. }
  10790. return PosterImage
  10791. })(_clickableComponentJs2['default'])
  10792. _componentJs2['default'].registerComponent('PosterImage', PosterImage)
  10793. exports['default'] = PosterImage
  10794. module.exports = exports['default']
  10795. }, { './clickable-component.js': 65, './component.js': 67, './utils/browser.js': 140, './utils/dom.js': 143, './utils/fn.js': 145 }], 118: [function(_dereq_, module, exports) {
  10796. /**
  10797. * @file setup.js
  10798. *
  10799. * Functions for automatically setting up a player
  10800. * based on the data-setup attribute of the video tag
  10801. */
  10802. 'use strict'
  10803. exports.__esModule = true
  10804. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  10805. 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 } }
  10806. var _utilsEventsJs = _dereq_('./utils/events.js')
  10807. var Events = _interopRequireWildcard(_utilsEventsJs)
  10808. var _globalDocument = _dereq_('global/document')
  10809. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  10810. var _globalWindow = _dereq_('global/window')
  10811. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  10812. var _windowLoaded = false
  10813. var videojs = undefined
  10814. // Automatically set up any tags that have a data-setup attribute
  10815. var autoSetup = function autoSetup() {
  10816. // One day, when we stop supporting IE8, go back to this, but in the meantime...*hack hack hack*
  10817. // var vids = Array.prototype.slice.call(document.getElementsByTagName('video'));
  10818. // var audios = Array.prototype.slice.call(document.getElementsByTagName('audio'));
  10819. // var mediaEls = vids.concat(audios);
  10820. // Because IE8 doesn't support calling slice on a node list, we need to loop through each list of elements
  10821. // to build up a new, combined list of elements.
  10822. var vids = _globalDocument2['default'].getElementsByTagName('video')
  10823. var audios = _globalDocument2['default'].getElementsByTagName('audio')
  10824. var mediaEls = []
  10825. if (vids && vids.length > 0) {
  10826. for (var i = 0, e = vids.length; i < e; i++) {
  10827. mediaEls.push(vids[i])
  10828. }
  10829. }
  10830. if (audios && audios.length > 0) {
  10831. for (var i = 0, e = audios.length; i < e; i++) {
  10832. mediaEls.push(audios[i])
  10833. }
  10834. }
  10835. // Check if any media elements exist
  10836. if (mediaEls && mediaEls.length > 0) {
  10837. for (var i = 0, e = mediaEls.length; i < e; i++) {
  10838. var mediaEl = mediaEls[i]
  10839. // Check if element exists, has getAttribute func.
  10840. // IE seems to consider typeof el.getAttribute == 'object' instead of 'function' like expected, at least when loading the player immediately.
  10841. if (mediaEl && mediaEl.getAttribute) {
  10842. // Make sure this player hasn't already been set up.
  10843. if (mediaEl['player'] === undefined) {
  10844. var options = mediaEl.getAttribute('data-setup')
  10845. // Check if data-setup attr exists.
  10846. // We only auto-setup if they've added the data-setup attr.
  10847. if (options !== null) {
  10848. // Create new video.js instance.
  10849. var player = videojs(mediaEl)
  10850. }
  10851. }
  10852. // If getAttribute isn't defined, we need to wait for the DOM.
  10853. } else {
  10854. autoSetupTimeout(1)
  10855. break
  10856. }
  10857. }
  10858. // No videos were found, so keep looping unless page is finished loading.
  10859. } else if (!_windowLoaded) {
  10860. autoSetupTimeout(1)
  10861. }
  10862. }
  10863. // Pause to let the DOM keep processing
  10864. var autoSetupTimeout = function autoSetupTimeout(wait, vjs) {
  10865. if (vjs) {
  10866. videojs = vjs
  10867. }
  10868. setTimeout(autoSetup, wait)
  10869. }
  10870. if (_globalDocument2['default'].readyState === 'complete') {
  10871. _windowLoaded = true
  10872. } else {
  10873. Events.one(_globalWindow2['default'], 'load', function() {
  10874. _windowLoaded = true
  10875. })
  10876. }
  10877. var hasLoaded = function hasLoaded() {
  10878. return _windowLoaded
  10879. }
  10880. exports.autoSetup = autoSetup
  10881. exports.autoSetupTimeout = autoSetupTimeout
  10882. exports.hasLoaded = hasLoaded
  10883. }, { './utils/events.js': 144, 'global/document': 1, 'global/window': 2 }], 119: [function(_dereq_, module, exports) {
  10884. /**
  10885. * @file slider.js
  10886. */
  10887. 'use strict'
  10888. exports.__esModule = true
  10889. 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 } }
  10890. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  10891. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  10892. 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 }
  10893. var _componentJs = _dereq_('../component.js')
  10894. var _componentJs2 = _interopRequireDefault(_componentJs)
  10895. var _utilsDomJs = _dereq_('../utils/dom.js')
  10896. var Dom = _interopRequireWildcard(_utilsDomJs)
  10897. var _objectAssign = _dereq_('object.assign')
  10898. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  10899. /**
  10900. * The base functionality for sliders like the volume bar and seek bar
  10901. *
  10902. * @param {Player|Object} player
  10903. * @param {Object=} options
  10904. * @extends Component
  10905. * @class Slider
  10906. */
  10907. var Slider = (function(_Component) {
  10908. _inherits(Slider, _Component)
  10909. function Slider(player, options) {
  10910. _classCallCheck(this, Slider)
  10911. _Component.call(this, player, options)
  10912. // Set property names to bar to match with the child Slider class is looking for
  10913. this.bar = this.getChild(this.options_.barName)
  10914. // Set a horizontal or vertical class on the slider depending on the slider type
  10915. this.vertical(!!this.options_.vertical)
  10916. this.on('mousedown', this.handleMouseDown)
  10917. this.on('touchstart', this.handleMouseDown)
  10918. this.on('focus', this.handleFocus)
  10919. this.on('blur', this.handleBlur)
  10920. this.on('click', this.handleClick)
  10921. this.on(player, 'controlsvisible', this.update)
  10922. this.on(player, this.playerEvent, this.update)
  10923. }
  10924. /**
  10925. * Create the component's DOM element
  10926. *
  10927. * @param {String} type Type of element to create
  10928. * @param {Object=} props List of properties in Object form
  10929. * @return {Element}
  10930. * @method createEl
  10931. */
  10932. Slider.prototype.createEl = function createEl(type) {
  10933. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  10934. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]
  10935. // Add the slider element class to all sub classes
  10936. props.className = props.className + ' vjs-slider'
  10937. props = _objectAssign2['default']({
  10938. tabIndex: 0
  10939. }, props)
  10940. attributes = _objectAssign2['default']({
  10941. 'role': 'slider',
  10942. 'aria-valuenow': 0,
  10943. 'aria-valuemin': 0,
  10944. 'aria-valuemax': 100,
  10945. tabIndex: 0
  10946. }, attributes)
  10947. return _Component.prototype.createEl.call(this, type, props, attributes)
  10948. }
  10949. /**
  10950. * Handle mouse down on slider
  10951. *
  10952. * @param {Object} event Mouse down event object
  10953. * @method handleMouseDown
  10954. */
  10955. Slider.prototype.handleMouseDown = function handleMouseDown(event) {
  10956. var doc = this.bar.el_.ownerDocument
  10957. event.preventDefault()
  10958. Dom.blockTextSelection()
  10959. this.addClass('vjs-sliding')
  10960. this.trigger('slideractive')
  10961. this.on(doc, 'mousemove', this.handleMouseMove)
  10962. this.on(doc, 'mouseup', this.handleMouseUp)
  10963. this.on(doc, 'touchmove', this.handleMouseMove)
  10964. this.on(doc, 'touchend', this.handleMouseUp)
  10965. this.handleMouseMove(event)
  10966. }
  10967. /**
  10968. * To be overridden by a subclass
  10969. *
  10970. * @method handleMouseMove
  10971. */
  10972. Slider.prototype.handleMouseMove = function handleMouseMove() { }
  10973. /**
  10974. * Handle mouse up on Slider
  10975. *
  10976. * @method handleMouseUp
  10977. */
  10978. Slider.prototype.handleMouseUp = function handleMouseUp() {
  10979. var doc = this.bar.el_.ownerDocument
  10980. Dom.unblockTextSelection()
  10981. this.removeClass('vjs-sliding')
  10982. this.trigger('sliderinactive')
  10983. this.off(doc, 'mousemove', this.handleMouseMove)
  10984. this.off(doc, 'mouseup', this.handleMouseUp)
  10985. this.off(doc, 'touchmove', this.handleMouseMove)
  10986. this.off(doc, 'touchend', this.handleMouseUp)
  10987. this.update()
  10988. }
  10989. /**
  10990. * Update slider
  10991. *
  10992. * @method update
  10993. */
  10994. Slider.prototype.update = function update() {
  10995. // In VolumeBar init we have a setTimeout for update that pops and update to the end of the
  10996. // execution stack. The player is destroyed before then update will cause an error
  10997. if (!this.el_) return
  10998. // If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
  10999. // On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
  11000. // var progress = (this.player_.scrubbing()) ? this.player_.getCache().currentTime / this.player_.duration() : this.player_.currentTime() / this.player_.duration();
  11001. var progress = this.getPercent()
  11002. var bar = this.bar
  11003. // If there's no bar...
  11004. if (!bar) return
  11005. // Protect against no duration and other division issues
  11006. if (typeof progress !== 'number' || progress !== progress || progress < 0 || progress === Infinity) {
  11007. progress = 0
  11008. }
  11009. // Convert to a percentage for setting
  11010. var percentage = (progress * 100).toFixed(2) + '%'
  11011. // Set the new bar width or height
  11012. if (this.vertical()) {
  11013. bar.el().style.height = percentage
  11014. } else {
  11015. bar.el().style.width = percentage
  11016. }
  11017. }
  11018. /**
  11019. * Calculate distance for slider
  11020. *
  11021. * @param {Object} event Event object
  11022. * @method calculateDistance
  11023. */
  11024. Slider.prototype.calculateDistance = function calculateDistance(event) {
  11025. var position = Dom.getPointerPosition(this.el_, event)
  11026. if (this.vertical()) {
  11027. return position.y
  11028. }
  11029. return position.x
  11030. }
  11031. /**
  11032. * Handle on focus for slider
  11033. *
  11034. * @method handleFocus
  11035. */
  11036. Slider.prototype.handleFocus = function handleFocus() {
  11037. this.on(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress)
  11038. }
  11039. /**
  11040. * Handle key press for slider
  11041. *
  11042. * @param {Object} event Event object
  11043. * @method handleKeyPress
  11044. */
  11045. Slider.prototype.handleKeyPress = function handleKeyPress(event) {
  11046. if (event.which === 37 || event.which === 40) {
  11047. // Left and Down Arrows
  11048. event.preventDefault()
  11049. this.stepBack()
  11050. } else if (event.which === 38 || event.which === 39) {
  11051. // Up and Right Arrows
  11052. event.preventDefault()
  11053. this.stepForward()
  11054. }
  11055. }
  11056. /**
  11057. * Handle on blur for slider
  11058. *
  11059. * @method handleBlur
  11060. */
  11061. Slider.prototype.handleBlur = function handleBlur() {
  11062. this.off(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress)
  11063. }
  11064. /**
  11065. * Listener for click events on slider, used to prevent clicks
  11066. * from bubbling up to parent elements like button menus.
  11067. *
  11068. * @param {Object} event Event object
  11069. * @method handleClick
  11070. */
  11071. Slider.prototype.handleClick = function handleClick(event) {
  11072. event.stopImmediatePropagation()
  11073. event.preventDefault()
  11074. }
  11075. /**
  11076. * Get/set if slider is horizontal for vertical
  11077. *
  11078. * @param {Boolean} bool True if slider is vertical, false is horizontal
  11079. * @return {Boolean} True if slider is vertical, false is horizontal
  11080. * @method vertical
  11081. */
  11082. Slider.prototype.vertical = function vertical(bool) {
  11083. if (bool === undefined) {
  11084. return this.vertical_ || false
  11085. }
  11086. this.vertical_ = !!bool
  11087. if (this.vertical_) {
  11088. this.addClass('vjs-slider-vertical')
  11089. } else {
  11090. this.addClass('vjs-slider-horizontal')
  11091. }
  11092. return this
  11093. }
  11094. return Slider
  11095. })(_componentJs2['default'])
  11096. _componentJs2['default'].registerComponent('Slider', Slider)
  11097. exports['default'] = Slider
  11098. module.exports = exports['default']
  11099. }, { '../component.js': 67, '../utils/dom.js': 143, 'object.assign': 45 }], 120: [function(_dereq_, module, exports) {
  11100. /**
  11101. * @file flash-rtmp.js
  11102. */
  11103. 'use strict'
  11104. exports.__esModule = true
  11105. function FlashRtmpDecorator(Flash) {
  11106. Flash.streamingFormats = {
  11107. 'rtmp/mp4': 'MP4',
  11108. 'rtmp/flv': 'FLV'
  11109. }
  11110. Flash.streamFromParts = function(connection, stream) {
  11111. return connection + '&' + stream
  11112. }
  11113. Flash.streamToParts = function(src) {
  11114. var parts = {
  11115. connection: '',
  11116. stream: ''
  11117. }
  11118. if (!src) return parts
  11119. // Look for the normal URL separator we expect, '&'.
  11120. // If found, we split the URL into two pieces around the
  11121. // first '&'.
  11122. var connEnd = src.search(/&(?!\w+=)/)
  11123. var streamBegin = undefined
  11124. if (connEnd !== -1) {
  11125. streamBegin = connEnd + 1
  11126. } else {
  11127. // If there's not a '&', we use the last '/' as the delimiter.
  11128. connEnd = streamBegin = src.lastIndexOf('/') + 1
  11129. if (connEnd === 0) {
  11130. // really, there's not a '/'?
  11131. connEnd = streamBegin = src.length
  11132. }
  11133. }
  11134. parts.connection = src.substring(0, connEnd)
  11135. parts.stream = src.substring(streamBegin, src.length)
  11136. return parts
  11137. }
  11138. Flash.isStreamingType = function(srcType) {
  11139. return srcType in Flash.streamingFormats
  11140. }
  11141. // RTMP has four variations, any string starting
  11142. // with one of these protocols should be valid
  11143. Flash.RTMP_RE = /^rtmp[set]?:\/\//i
  11144. Flash.isStreamingSrc = function(src) {
  11145. return Flash.RTMP_RE.test(src)
  11146. }
  11147. /**
  11148. * A source handler for RTMP urls
  11149. * @type {Object}
  11150. */
  11151. Flash.rtmpSourceHandler = {}
  11152. /**
  11153. * Check if Flash can play the given videotype
  11154. * @param {String} type The mimetype to check
  11155. * @return {String} 'probably', 'maybe', or '' (empty string)
  11156. */
  11157. Flash.rtmpSourceHandler.canPlayType = function(type) {
  11158. if (Flash.isStreamingType(type)) {
  11159. return 'maybe'
  11160. }
  11161. return ''
  11162. }
  11163. /**
  11164. * Check if Flash can handle the source natively
  11165. * @param {Object} source The source object
  11166. * @return {String} 'probably', 'maybe', or '' (empty string)
  11167. */
  11168. Flash.rtmpSourceHandler.canHandleSource = function(source) {
  11169. var can = Flash.rtmpSourceHandler.canPlayType(source.type)
  11170. if (can) {
  11171. return can
  11172. }
  11173. if (Flash.isStreamingSrc(source.src)) {
  11174. return 'maybe'
  11175. }
  11176. return ''
  11177. }
  11178. /**
  11179. * Pass the source to the flash object
  11180. * Adaptive source handlers will have more complicated workflows before passing
  11181. * video data to the video element
  11182. * @param {Object} source The source object
  11183. * @param {Flash} tech The instance of the Flash tech
  11184. * @param {Object} options The options to pass to the source
  11185. */
  11186. Flash.rtmpSourceHandler.handleSource = function(source, tech, options) {
  11187. var srcParts = Flash.streamToParts(source.src)
  11188. tech['setRtmpConnection'](srcParts.connection)
  11189. tech['setRtmpStream'](srcParts.stream)
  11190. }
  11191. // Register the native source handler
  11192. Flash.registerSourceHandler(Flash.rtmpSourceHandler)
  11193. return Flash
  11194. }
  11195. exports['default'] = FlashRtmpDecorator
  11196. module.exports = exports['default']
  11197. }, {}], 121: [function(_dereq_, module, exports) {
  11198. /**
  11199. * @file flash.js
  11200. * VideoJS-SWF - Custom Flash Player with HTML5-ish API
  11201. * https://github.com/zencoder/video-js-swf
  11202. * Not using setupTriggers. Using global onEvent func to distribute events
  11203. */
  11204. 'use strict'
  11205. exports.__esModule = true
  11206. 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 } }
  11207. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  11208. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  11209. 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 }
  11210. var _tech = _dereq_('./tech')
  11211. var _tech2 = _interopRequireDefault(_tech)
  11212. var _utilsDomJs = _dereq_('../utils/dom.js')
  11213. var Dom = _interopRequireWildcard(_utilsDomJs)
  11214. var _utilsUrlJs = _dereq_('../utils/url.js')
  11215. var Url = _interopRequireWildcard(_utilsUrlJs)
  11216. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js')
  11217. var _flashRtmp = _dereq_('./flash-rtmp')
  11218. var _flashRtmp2 = _interopRequireDefault(_flashRtmp)
  11219. var _component = _dereq_('../component')
  11220. var _component2 = _interopRequireDefault(_component)
  11221. var _globalWindow = _dereq_('global/window')
  11222. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  11223. var _objectAssign = _dereq_('object.assign')
  11224. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  11225. var navigator = _globalWindow2['default'].navigator
  11226. /**
  11227. * Flash Media Controller - Wrapper for fallback SWF API
  11228. *
  11229. * @param {Object=} options Object of option names and values
  11230. * @param {Function=} ready Ready callback function
  11231. * @extends Tech
  11232. * @class Flash
  11233. */
  11234. var Flash = (function(_Tech) {
  11235. _inherits(Flash, _Tech)
  11236. function Flash(options, ready) {
  11237. _classCallCheck(this, Flash)
  11238. _Tech.call(this, options, ready)
  11239. // Set the source when ready
  11240. if (options.source) {
  11241. this.ready(function() {
  11242. this.setSource(options.source)
  11243. }, true)
  11244. }
  11245. // Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
  11246. // This allows resetting the playhead when we catch the reload
  11247. if (options.startTime) {
  11248. this.ready(function() {
  11249. this.load()
  11250. this.play()
  11251. this.currentTime(options.startTime)
  11252. }, true)
  11253. }
  11254. // Add global window functions that the swf expects
  11255. // A 4.x workflow we weren't able to solve for in 5.0
  11256. // because of the need to hard code these functions
  11257. // into the swf for security reasons
  11258. _globalWindow2['default'].videojs = _globalWindow2['default'].videojs || {}
  11259. _globalWindow2['default'].videojs.Flash = _globalWindow2['default'].videojs.Flash || {}
  11260. _globalWindow2['default'].videojs.Flash.onReady = Flash.onReady
  11261. _globalWindow2['default'].videojs.Flash.onEvent = Flash.onEvent
  11262. _globalWindow2['default'].videojs.Flash.onError = Flash.onError
  11263. this.on('seeked', function() {
  11264. this.lastSeekTarget_ = undefined
  11265. })
  11266. }
  11267. // Create setters and getters for attributes
  11268. /**
  11269. * Create the component's DOM element
  11270. *
  11271. * @return {Element}
  11272. * @method createEl
  11273. */
  11274. Flash.prototype.createEl = function createEl() {
  11275. var options = this.options_
  11276. // If video.js is hosted locally you should also set the location
  11277. // for the hosted swf, which should be relative to the page (not video.js)
  11278. // Otherwise this adds a CDN url.
  11279. // The CDN also auto-adds a swf URL for that specific version.
  11280. if (!options.swf) {
  11281. options.swf = '//vjs.zencdn.net/swf/5.0.1/video-js.swf'
  11282. }
  11283. // Generate ID for swf object
  11284. var objId = options.techId
  11285. // Merge default flashvars with ones passed in to init
  11286. var flashVars = _objectAssign2['default']({
  11287. // SWF Callback Functions
  11288. 'readyFunction': 'videojs.Flash.onReady',
  11289. 'eventProxyFunction': 'videojs.Flash.onEvent',
  11290. 'errorEventProxyFunction': 'videojs.Flash.onError',
  11291. // Player Settings
  11292. 'autoplay': options.autoplay,
  11293. 'preload': options.preload,
  11294. 'loop': options.loop,
  11295. 'muted': options.muted
  11296. }, options.flashVars)
  11297. // Merge default parames with ones passed in
  11298. var params = _objectAssign2['default']({
  11299. 'wmode': 'opaque', // Opaque is needed to overlay controls, but can affect playback performance
  11300. 'bgcolor': '#000000' // Using bgcolor prevents a white flash when the object is loading
  11301. }, options.params)
  11302. // Merge default attributes with ones passed in
  11303. var attributes = _objectAssign2['default']({
  11304. 'id': objId,
  11305. 'name': objId, // Both ID and Name needed or swf to identify itself
  11306. 'class': 'vjs-tech'
  11307. }, options.attributes)
  11308. this.el_ = Flash.embed(options.swf, flashVars, params, attributes)
  11309. this.el_.tech = this
  11310. return this.el_
  11311. }
  11312. /**
  11313. * Play for flash tech
  11314. *
  11315. * @method play
  11316. */
  11317. Flash.prototype.play = function play() {
  11318. if (this.ended()) {
  11319. this.setCurrentTime(0)
  11320. }
  11321. this.el_.vjs_play()
  11322. }
  11323. /**
  11324. * Pause for flash tech
  11325. *
  11326. * @method pause
  11327. */
  11328. Flash.prototype.pause = function pause() {
  11329. this.el_.vjs_pause()
  11330. }
  11331. /**
  11332. * Get/set video
  11333. *
  11334. * @param {Object=} src Source object
  11335. * @return {Object}
  11336. * @method src
  11337. */
  11338. Flash.prototype.src = function src(_src) {
  11339. if (_src === undefined) {
  11340. return this.currentSrc()
  11341. }
  11342. // Setting src through `src` not `setSrc` will be deprecated
  11343. return this.setSrc(_src)
  11344. }
  11345. /**
  11346. * Set video
  11347. *
  11348. * @param {Object=} src Source object
  11349. * @deprecated
  11350. * @method setSrc
  11351. */
  11352. Flash.prototype.setSrc = function setSrc(src) {
  11353. // Make sure source URL is absolute.
  11354. src = Url.getAbsoluteURL(src)
  11355. this.el_.vjs_src(src)
  11356. // Currently the SWF doesn't autoplay if you load a source later.
  11357. // e.g. Load player w/ no source, wait 2s, set src.
  11358. if (this.autoplay()) {
  11359. var tech = this
  11360. this.setTimeout(function() {
  11361. tech.play()
  11362. }, 0)
  11363. }
  11364. }
  11365. /**
  11366. * Returns true if the tech is currently seeking.
  11367. * @return {boolean} true if seeking
  11368. */
  11369. Flash.prototype.seeking = function seeking() {
  11370. return this.lastSeekTarget_ !== undefined
  11371. }
  11372. /**
  11373. * Set current time
  11374. *
  11375. * @param {Number} time Current time of video
  11376. * @method setCurrentTime
  11377. */
  11378. Flash.prototype.setCurrentTime = function setCurrentTime(time) {
  11379. var seekable = this.seekable()
  11380. if (seekable.length) {
  11381. // clamp to the current seekable range
  11382. time = time > seekable.start(0) ? time : seekable.start(0)
  11383. time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1)
  11384. this.lastSeekTarget_ = time
  11385. this.trigger('seeking')
  11386. this.el_.vjs_setProperty('currentTime', time)
  11387. _Tech.prototype.setCurrentTime.call(this)
  11388. }
  11389. }
  11390. /**
  11391. * Get current time
  11392. *
  11393. * @param {Number=} time Current time of video
  11394. * @return {Number} Current time
  11395. * @method currentTime
  11396. */
  11397. Flash.prototype.currentTime = function currentTime(time) {
  11398. // when seeking make the reported time keep up with the requested time
  11399. // by reading the time we're seeking to
  11400. if (this.seeking()) {
  11401. return this.lastSeekTarget_ || 0
  11402. }
  11403. return this.el_.vjs_getProperty('currentTime')
  11404. }
  11405. /**
  11406. * Get current source
  11407. *
  11408. * @method currentSrc
  11409. */
  11410. Flash.prototype.currentSrc = function currentSrc() {
  11411. if (this.currentSource_) {
  11412. return this.currentSource_.src
  11413. } else {
  11414. return this.el_.vjs_getProperty('currentSrc')
  11415. }
  11416. }
  11417. /**
  11418. * Load media into player
  11419. *
  11420. * @method load
  11421. */
  11422. Flash.prototype.load = function load() {
  11423. this.el_.vjs_load()
  11424. }
  11425. /**
  11426. * Get poster
  11427. *
  11428. * @method poster
  11429. */
  11430. Flash.prototype.poster = function poster() {
  11431. this.el_.vjs_getProperty('poster')
  11432. }
  11433. /**
  11434. * Poster images are not handled by the Flash tech so make this a no-op
  11435. *
  11436. * @method setPoster
  11437. */
  11438. Flash.prototype.setPoster = function setPoster() { }
  11439. /**
  11440. * Determine if can seek in media
  11441. *
  11442. * @return {TimeRangeObject}
  11443. * @method seekable
  11444. */
  11445. Flash.prototype.seekable = function seekable() {
  11446. var duration = this.duration()
  11447. if (duration === 0) {
  11448. return _utilsTimeRangesJs.createTimeRange()
  11449. }
  11450. return _utilsTimeRangesJs.createTimeRange(0, duration)
  11451. }
  11452. /**
  11453. * Get buffered time range
  11454. *
  11455. * @return {TimeRangeObject}
  11456. * @method buffered
  11457. */
  11458. Flash.prototype.buffered = function buffered() {
  11459. var ranges = this.el_.vjs_getProperty('buffered')
  11460. if (ranges.length === 0) {
  11461. return _utilsTimeRangesJs.createTimeRange()
  11462. }
  11463. return _utilsTimeRangesJs.createTimeRange(ranges[0][0], ranges[0][1])
  11464. }
  11465. /**
  11466. * Get fullscreen support -
  11467. * Flash does not allow fullscreen through javascript
  11468. * so always returns false
  11469. *
  11470. * @return {Boolean} false
  11471. * @method supportsFullScreen
  11472. */
  11473. Flash.prototype.supportsFullScreen = function supportsFullScreen() {
  11474. return false // Flash does not allow fullscreen through javascript
  11475. }
  11476. /**
  11477. * Request to enter fullscreen
  11478. * Flash does not allow fullscreen through javascript
  11479. * so always returns false
  11480. *
  11481. * @return {Boolean} false
  11482. * @method enterFullScreen
  11483. */
  11484. Flash.prototype.enterFullScreen = function enterFullScreen() {
  11485. return false
  11486. }
  11487. return Flash
  11488. })(_tech2['default'])
  11489. var _api = Flash.prototype
  11490. var _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',')
  11491. var _readOnly = 'networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(',')
  11492. function _createSetter(attr) {
  11493. var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1)
  11494. _api['set' + attrUpper] = function(val) {
  11495. return this.el_.vjs_setProperty(attr, val)
  11496. }
  11497. }
  11498. function _createGetter(attr) {
  11499. _api[attr] = function() {
  11500. return this.el_.vjs_getProperty(attr)
  11501. }
  11502. }
  11503. // Create getter and setters for all read/write attributes
  11504. for (var i = 0; i < _readWrite.length; i++) {
  11505. _createGetter(_readWrite[i])
  11506. _createSetter(_readWrite[i])
  11507. }
  11508. // Create getters for read-only attributes
  11509. for (var i = 0; i < _readOnly.length; i++) {
  11510. _createGetter(_readOnly[i])
  11511. }
  11512. /* Flash Support Testing -------------------------------------------------------- */
  11513. Flash.isSupported = function() {
  11514. return Flash.version()[0] >= 10
  11515. // return swfobject.hasFlashPlayerVersion('10');
  11516. }
  11517. // Add Source Handler pattern functions to this tech
  11518. _tech2['default'].withSourceHandlers(Flash)
  11519. /*
  11520. * The default native source handler.
  11521. * This simply passes the source to the video element. Nothing fancy.
  11522. *
  11523. * @param {Object} source The source object
  11524. * @param {Flash} tech The instance of the Flash tech
  11525. */
  11526. Flash.nativeSourceHandler = {}
  11527. /**
  11528. * Check if Flash can play the given videotype
  11529. * @param {String} type The mimetype to check
  11530. * @return {String} 'probably', 'maybe', or '' (empty string)
  11531. */
  11532. Flash.nativeSourceHandler.canPlayType = function(type) {
  11533. if (type in Flash.formats) {
  11534. return 'maybe'
  11535. }
  11536. return ''
  11537. }
  11538. /*
  11539. * Check Flash can handle the source natively
  11540. *
  11541. * @param {Object} source The source object
  11542. * @return {String} 'probably', 'maybe', or '' (empty string)
  11543. */
  11544. Flash.nativeSourceHandler.canHandleSource = function(source) {
  11545. var type
  11546. function guessMimeType(src) {
  11547. var ext = Url.getFileExtension(src)
  11548. if (ext) {
  11549. return 'video/' + ext
  11550. }
  11551. return ''
  11552. }
  11553. if (!source.type) {
  11554. type = guessMimeType(source.src)
  11555. } else {
  11556. // Strip code information from the type because we don't get that specific
  11557. type = source.type.replace(/;.*/, '').toLowerCase()
  11558. }
  11559. return Flash.nativeSourceHandler.canPlayType(type)
  11560. }
  11561. /*
  11562. * Pass the source to the flash object
  11563. * Adaptive source handlers will have more complicated workflows before passing
  11564. * video data to the video element
  11565. *
  11566. * @param {Object} source The source object
  11567. * @param {Flash} tech The instance of the Flash tech
  11568. * @param {Object} options The options to pass to the source
  11569. */
  11570. Flash.nativeSourceHandler.handleSource = function(source, tech, options) {
  11571. tech.setSrc(source.src)
  11572. }
  11573. /*
  11574. * Clean up the source handler when disposing the player or switching sources..
  11575. * (no cleanup is needed when supporting the format natively)
  11576. */
  11577. Flash.nativeSourceHandler.dispose = function() { }
  11578. // Register the native source handler
  11579. Flash.registerSourceHandler(Flash.nativeSourceHandler)
  11580. Flash.formats = {
  11581. 'video/flv': 'FLV',
  11582. 'video/x-flv': 'FLV',
  11583. 'video/mp4': 'MP4',
  11584. 'video/m4v': 'MP4'
  11585. }
  11586. Flash.onReady = function(currSwf) {
  11587. var el = Dom.getEl(currSwf)
  11588. var tech = el && el.tech
  11589. // if there is no el then the tech has been disposed
  11590. // and the tech element was removed from the player div
  11591. if (tech && tech.el()) {
  11592. // check that the flash object is really ready
  11593. Flash.checkReady(tech)
  11594. }
  11595. }
  11596. // The SWF isn't always ready when it says it is. Sometimes the API functions still need to be added to the object.
  11597. // If it's not ready, we set a timeout to check again shortly.
  11598. Flash.checkReady = function(tech) {
  11599. // stop worrying if the tech has been disposed
  11600. if (!tech.el()) {
  11601. return
  11602. }
  11603. // check if API property exists
  11604. if (tech.el().vjs_getProperty) {
  11605. // tell tech it's ready
  11606. tech.triggerReady()
  11607. } else {
  11608. // wait longer
  11609. this.setTimeout(function() {
  11610. Flash['checkReady'](tech)
  11611. }, 50)
  11612. }
  11613. }
  11614. // Trigger events from the swf on the player
  11615. Flash.onEvent = function(swfID, eventName) {
  11616. var tech = Dom.getEl(swfID).tech
  11617. tech.trigger(eventName)
  11618. }
  11619. // Log errors from the swf
  11620. Flash.onError = function(swfID, err) {
  11621. var tech = Dom.getEl(swfID).tech
  11622. // trigger MEDIA_ERR_SRC_NOT_SUPPORTED
  11623. if (err === 'srcnotfound') {
  11624. return tech.error(4)
  11625. }
  11626. // trigger a custom error
  11627. tech.error('FLASH: ' + err)
  11628. }
  11629. // Flash Version Check
  11630. Flash.version = function() {
  11631. var version = '0,0,0'
  11632. // IE
  11633. try {
  11634. version = new _globalWindow2['default'].ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]
  11635. // other browsers
  11636. } catch (e) {
  11637. try {
  11638. if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
  11639. version = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]
  11640. }
  11641. } catch (err) { }
  11642. }
  11643. return version.split(',')
  11644. }
  11645. // Flash embedding method. Only used in non-iframe mode
  11646. Flash.embed = function(swf, flashVars, params, attributes) {
  11647. var code = Flash.getEmbedCode(swf, flashVars, params, attributes)
  11648. // Get element by embedding code and retrieving created element
  11649. var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0]
  11650. return obj
  11651. }
  11652. Flash.getEmbedCode = function(swf, flashVars, params, attributes) {
  11653. var objTag = '<object type="application/x-shockwave-flash" '
  11654. var flashVarsString = ''
  11655. var paramsString = ''
  11656. var attrsString = ''
  11657. // Convert flash vars to string
  11658. if (flashVars) {
  11659. Object.getOwnPropertyNames(flashVars).forEach(function(key) {
  11660. flashVarsString += key + '=' + flashVars[key] + '&amp;'
  11661. })
  11662. }
  11663. // Add swf, flashVars, and other default params
  11664. params = _objectAssign2['default']({
  11665. 'movie': swf,
  11666. 'flashvars': flashVarsString,
  11667. 'allowScriptAccess': 'always', // Required to talk to swf
  11668. 'allowNetworking': 'all' // All should be default, but having security issues.
  11669. }, params)
  11670. // Create param tags string
  11671. Object.getOwnPropertyNames(params).forEach(function(key) {
  11672. paramsString += '<param name="' + key + '" value="' + params[key] + '" />'
  11673. })
  11674. attributes = _objectAssign2['default']({
  11675. // Add swf to attributes (need both for IE and Others to work)
  11676. 'data': swf,
  11677. // Default to 100% width/height
  11678. 'width': '100%',
  11679. 'height': '100%'
  11680. }, attributes)
  11681. // Create Attributes string
  11682. Object.getOwnPropertyNames(attributes).forEach(function(key) {
  11683. attrsString += key + '="' + attributes[key] + '" '
  11684. })
  11685. return '' + objTag + attrsString + '>' + paramsString + '</object>'
  11686. }
  11687. // Run Flash through the RTMP decorator
  11688. _flashRtmp2['default'](Flash)
  11689. _component2['default'].registerComponent('Flash', Flash)
  11690. _tech2['default'].registerTech('Flash', Flash)
  11691. exports['default'] = Flash
  11692. module.exports = exports['default']
  11693. }, { '../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) {
  11694. /**
  11695. * @file html5.js
  11696. * HTML5 Media Controller - Wrapper for HTML5 Media API
  11697. */
  11698. 'use strict'
  11699. exports.__esModule = true
  11700. 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.'])
  11701. 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 } }
  11702. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  11703. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  11704. 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 }
  11705. function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings }
  11706. var _techJs = _dereq_('./tech.js')
  11707. var _techJs2 = _interopRequireDefault(_techJs)
  11708. var _component = _dereq_('../component')
  11709. var _component2 = _interopRequireDefault(_component)
  11710. var _utilsDomJs = _dereq_('../utils/dom.js')
  11711. var Dom = _interopRequireWildcard(_utilsDomJs)
  11712. var _utilsUrlJs = _dereq_('../utils/url.js')
  11713. var Url = _interopRequireWildcard(_utilsUrlJs)
  11714. var _utilsFnJs = _dereq_('../utils/fn.js')
  11715. var Fn = _interopRequireWildcard(_utilsFnJs)
  11716. var _utilsLogJs = _dereq_('../utils/log.js')
  11717. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  11718. var _tsml = _dereq_('tsml')
  11719. var _tsml2 = _interopRequireDefault(_tsml)
  11720. var _srcJsTracksTextTrackJs = _dereq_('../../../src/js/tracks/text-track.js')
  11721. var _srcJsTracksTextTrackJs2 = _interopRequireDefault(_srcJsTracksTextTrackJs)
  11722. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  11723. var browser = _interopRequireWildcard(_utilsBrowserJs)
  11724. var _globalDocument = _dereq_('global/document')
  11725. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  11726. var _globalWindow = _dereq_('global/window')
  11727. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  11728. var _objectAssign = _dereq_('object.assign')
  11729. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  11730. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js')
  11731. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs)
  11732. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js')
  11733. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs)
  11734. /**
  11735. * HTML5 Media Controller - Wrapper for HTML5 Media API
  11736. *
  11737. * @param {Object=} options Object of option names and values
  11738. * @param {Function=} ready Ready callback function
  11739. * @extends Tech
  11740. * @class Html5
  11741. */
  11742. var Html5 = (function(_Tech) {
  11743. _inherits(Html5, _Tech)
  11744. function Html5(options, ready) {
  11745. var _this = this
  11746. _classCallCheck(this, Html5)
  11747. _Tech.call(this, options, ready)
  11748. var source = options.source
  11749. var crossoriginTracks = false
  11750. // Set the source if one is provided
  11751. // 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted)
  11752. // 2) Check to see if the network state of the tag was failed at init, and if so, reset the source
  11753. // anyway so the error gets fired.
  11754. if (source && (this.el_.currentSrc !== source.src || options.tag && options.tag.initNetworkState_ === 3)) {
  11755. this.setSource(source)
  11756. } else {
  11757. this.handleLateInit_(this.el_)
  11758. }
  11759. if (this.el_.hasChildNodes()) {
  11760. var nodes = this.el_.childNodes
  11761. var nodesLength = nodes.length
  11762. var removeNodes = []
  11763. while (nodesLength--) {
  11764. var node = nodes[nodesLength]
  11765. var nodeName = node.nodeName.toLowerCase()
  11766. if (nodeName === 'track') {
  11767. if (!this.featuresNativeTextTracks) {
  11768. // Empty video tag tracks so the built-in player doesn't use them also.
  11769. // This may not be fast enough to stop HTML5 browsers from reading the tags
  11770. // so we'll need to turn off any default tracks if we're manually doing
  11771. // captions and subtitles. videoElement.textTracks
  11772. removeNodes.push(node)
  11773. } else {
  11774. // store HTMLTrackElement and TextTrack to remote list
  11775. this.remoteTextTrackEls().addTrackElement_(node)
  11776. this.remoteTextTracks().addTrack_(node.track)
  11777. if (!crossoriginTracks && !this.el_.hasAttribute('crossorigin') && Url.isCrossOrigin(node.src)) {
  11778. crossoriginTracks = true
  11779. }
  11780. }
  11781. }
  11782. }
  11783. for (var i = 0; i < removeNodes.length; i++) {
  11784. this.el_.removeChild(removeNodes[i])
  11785. }
  11786. }
  11787. var trackTypes = ['audio', 'video']
  11788. // ProxyNativeTextTracks
  11789. trackTypes.forEach(function(type) {
  11790. var capitalType = _utilsToTitleCaseJs2['default'](type)
  11791. if (!_this['featuresNative' + capitalType + 'Tracks']) {
  11792. return
  11793. }
  11794. var tl = _this.el()[type + 'Tracks']
  11795. if (tl && tl.addEventListener) {
  11796. tl.addEventListener('change', Fn.bind(_this, _this['handle' + capitalType + 'TrackChange_']))
  11797. tl.addEventListener('addtrack', Fn.bind(_this, _this['handle' + capitalType + 'TrackAdd_']))
  11798. tl.addEventListener('removetrack', Fn.bind(_this, _this['handle' + capitalType + 'TrackRemove_']))
  11799. }
  11800. })
  11801. if (this.featuresNativeTextTracks) {
  11802. if (crossoriginTracks) {
  11803. _utilsLogJs2['default'].warn(_tsml2['default'](_templateObject))
  11804. }
  11805. this.handleTextTrackChange_ = Fn.bind(this, this.handleTextTrackChange)
  11806. this.handleTextTrackAdd_ = Fn.bind(this, this.handleTextTrackAdd)
  11807. this.handleTextTrackRemove_ = Fn.bind(this, this.handleTextTrackRemove)
  11808. this.proxyNativeTextTracks_()
  11809. }
  11810. // Determine if native controls should be used
  11811. // Our goal should be to get the custom controls on mobile solid everywhere
  11812. // so we can remove this all together. Right now this will block custom
  11813. // controls on touch enabled laptops like the Chrome Pixel
  11814. if (browser.TOUCH_ENABLED && options.nativeControlsForTouch === true || browser.IS_IPHONE || browser.IS_NATIVE_ANDROID) {
  11815. this.setControls(true)
  11816. }
  11817. this.triggerReady()
  11818. }
  11819. /* HTML5 Support Testing ---------------------------------------------------- */
  11820. /*
  11821. * Element for testing browser HTML5 video capabilities
  11822. *
  11823. * @type {Element}
  11824. * @constant
  11825. * @private
  11826. */
  11827. /**
  11828. * Dispose of html5 media element
  11829. *
  11830. * @method dispose
  11831. */
  11832. Html5.prototype.dispose = function dispose() {
  11833. var _this2 = this;
  11834. // Un-ProxyNativeTracks
  11835. ['audio', 'video', 'text'].forEach(function(type) {
  11836. var capitalType = _utilsToTitleCaseJs2['default'](type)
  11837. var tl = _this2.el_[type + 'Tracks']
  11838. if (tl && tl.removeEventListener) {
  11839. tl.removeEventListener('change', _this2['handle' + capitalType + 'TrackChange_'])
  11840. tl.removeEventListener('addtrack', _this2['handle' + capitalType + 'TrackAdd_'])
  11841. tl.removeEventListener('removetrack', _this2['handle' + capitalType + 'TrackRemove_'])
  11842. }
  11843. })
  11844. Html5.disposeMediaElement(this.el_)
  11845. // tech will handle clearing of the emulated track list
  11846. _Tech.prototype.dispose.call(this)
  11847. }
  11848. /**
  11849. * Create the component's DOM element
  11850. *
  11851. * @return {Element}
  11852. * @method createEl
  11853. */
  11854. Html5.prototype.createEl = function createEl() {
  11855. var el = this.options_.tag
  11856. // Check if this browser supports moving the element into the box.
  11857. // On the iPhone video will break if you move the element,
  11858. // So we have to create a brand new element.
  11859. if (!el || this['movingMediaElementInDOM'] === false) {
  11860. // If the original tag is still there, clone and remove it.
  11861. if (el) {
  11862. var clone = el.cloneNode(true)
  11863. el.parentNode.insertBefore(clone, el)
  11864. Html5.disposeMediaElement(el)
  11865. el = clone
  11866. } else {
  11867. el = _globalDocument2['default'].createElement('video')
  11868. // determine if native controls should be used
  11869. var tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag)
  11870. var attributes = _utilsMergeOptionsJs2['default']({}, tagAttributes)
  11871. if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
  11872. delete attributes.controls
  11873. }
  11874. Dom.setElAttributes(el, _objectAssign2['default'](attributes, {
  11875. id: this.options_.techId,
  11876. 'class': 'vjs-tech'
  11877. }))
  11878. }
  11879. }
  11880. // Update specific tag settings, in case they were overridden
  11881. var settingsAttrs = ['autoplay', 'preload', 'loop', 'muted']
  11882. for (var i = settingsAttrs.length - 1; i >= 0; i--) {
  11883. var attr = settingsAttrs[i]
  11884. var overwriteAttrs = {}
  11885. if (typeof this.options_[attr] !== 'undefined') {
  11886. overwriteAttrs[attr] = this.options_[attr]
  11887. }
  11888. Dom.setElAttributes(el, overwriteAttrs)
  11889. }
  11890. return el
  11891. // jenniisawesome = true;
  11892. }
  11893. // If we're loading the playback object after it has started loading
  11894. // or playing the video (often with autoplay on) then the loadstart event
  11895. // has already fired and we need to fire it manually because many things
  11896. // rely on it.
  11897. Html5.prototype.handleLateInit_ = function handleLateInit_(el) {
  11898. var _this3 = this
  11899. if (el.networkState === 0 || el.networkState === 3) {
  11900. // The video element hasn't started loading the source yet
  11901. // or didn't find a source
  11902. return
  11903. }
  11904. if (el.readyState === 0) {
  11905. var _ret = (function() {
  11906. // NetworkState is set synchronously BUT loadstart is fired at the
  11907. // end of the current stack, usually before setInterval(fn, 0).
  11908. // So at this point we know loadstart may have already fired or is
  11909. // about to fire, and either way the player hasn't seen it yet.
  11910. // We don't want to fire loadstart prematurely here and cause a
  11911. // double loadstart so we'll wait and see if it happens between now
  11912. // and the next loop, and fire it if not.
  11913. // HOWEVER, we also want to make sure it fires before loadedmetadata
  11914. // which could also happen between now and the next loop, so we'll
  11915. // watch for that also.
  11916. var loadstartFired = false
  11917. var setLoadstartFired = function setLoadstartFired() {
  11918. loadstartFired = true
  11919. }
  11920. _this3.on('loadstart', setLoadstartFired)
  11921. var triggerLoadstart = function triggerLoadstart() {
  11922. // We did miss the original loadstart. Make sure the player
  11923. // sees loadstart before loadedmetadata
  11924. if (!loadstartFired) {
  11925. this.trigger('loadstart')
  11926. }
  11927. }
  11928. _this3.on('loadedmetadata', triggerLoadstart)
  11929. _this3.ready(function() {
  11930. this.off('loadstart', setLoadstartFired)
  11931. this.off('loadedmetadata', triggerLoadstart)
  11932. if (!loadstartFired) {
  11933. // We did miss the original native loadstart. Fire it now.
  11934. this.trigger('loadstart')
  11935. }
  11936. })
  11937. return {
  11938. v: undefined
  11939. }
  11940. })()
  11941. if (typeof _ret === 'object') return _ret.v
  11942. }
  11943. // From here on we know that loadstart already fired and we missed it.
  11944. // The other readyState events aren't as much of a problem if we double
  11945. // them, so not going to go to as much trouble as loadstart to prevent
  11946. // that unless we find reason to.
  11947. var eventsToTrigger = ['loadstart']
  11948. // loadedmetadata: newly equal to HAVE_METADATA (1) or greater
  11949. eventsToTrigger.push('loadedmetadata')
  11950. // loadeddata: newly increased to HAVE_CURRENT_DATA (2) or greater
  11951. if (el.readyState >= 2) {
  11952. eventsToTrigger.push('loadeddata')
  11953. }
  11954. // canplay: newly increased to HAVE_FUTURE_DATA (3) or greater
  11955. if (el.readyState >= 3) {
  11956. eventsToTrigger.push('canplay')
  11957. }
  11958. // canplaythrough: newly equal to HAVE_ENOUGH_DATA (4)
  11959. if (el.readyState >= 4) {
  11960. eventsToTrigger.push('canplaythrough')
  11961. }
  11962. // We still need to give the player time to add event listeners
  11963. this.ready(function() {
  11964. eventsToTrigger.forEach(function(type) {
  11965. this.trigger(type)
  11966. }, this)
  11967. })
  11968. }
  11969. Html5.prototype.proxyNativeTextTracks_ = function proxyNativeTextTracks_() {
  11970. var tt = this.el().textTracks
  11971. if (tt) {
  11972. // Add tracks - if player is initialised after DOM loaded, textTracks
  11973. // will not trigger addtrack
  11974. for (var i = 0; i < tt.length; i++) {
  11975. this.textTracks().addTrack_(tt[i])
  11976. }
  11977. if (tt.addEventListener) {
  11978. tt.addEventListener('change', this.handleTextTrackChange_)
  11979. tt.addEventListener('addtrack', this.handleTextTrackAdd_)
  11980. tt.addEventListener('removetrack', this.handleTextTrackRemove_)
  11981. }
  11982. }
  11983. }
  11984. Html5.prototype.handleTextTrackChange = function handleTextTrackChange(e) {
  11985. var tt = this.textTracks()
  11986. this.textTracks().trigger({
  11987. type: 'change',
  11988. target: tt,
  11989. currentTarget: tt,
  11990. srcElement: tt
  11991. })
  11992. }
  11993. Html5.prototype.handleTextTrackAdd = function handleTextTrackAdd(e) {
  11994. this.textTracks().addTrack_(e.track)
  11995. }
  11996. Html5.prototype.handleTextTrackRemove = function handleTextTrackRemove(e) {
  11997. this.textTracks().removeTrack_(e.track)
  11998. }
  11999. Html5.prototype.handleVideoTrackChange_ = function handleVideoTrackChange_(e) {
  12000. var vt = this.videoTracks()
  12001. this.videoTracks().trigger({
  12002. type: 'change',
  12003. target: vt,
  12004. currentTarget: vt,
  12005. srcElement: vt
  12006. })
  12007. }
  12008. Html5.prototype.handleVideoTrackAdd_ = function handleVideoTrackAdd_(e) {
  12009. this.videoTracks().addTrack_(e.track)
  12010. }
  12011. Html5.prototype.handleVideoTrackRemove_ = function handleVideoTrackRemove_(e) {
  12012. this.videoTracks().removeTrack_(e.track)
  12013. }
  12014. Html5.prototype.handleAudioTrackChange_ = function handleAudioTrackChange_(e) {
  12015. var audioTrackList = this.audioTracks()
  12016. this.audioTracks().trigger({
  12017. type: 'change',
  12018. target: audioTrackList,
  12019. currentTarget: audioTrackList,
  12020. srcElement: audioTrackList
  12021. })
  12022. }
  12023. Html5.prototype.handleAudioTrackAdd_ = function handleAudioTrackAdd_(e) {
  12024. this.audioTracks().addTrack_(e.track)
  12025. }
  12026. Html5.prototype.handleAudioTrackRemove_ = function handleAudioTrackRemove_(e) {
  12027. this.audioTracks().removeTrack_(e.track)
  12028. }
  12029. /**
  12030. * Play for html5 tech
  12031. *
  12032. * @method play
  12033. */
  12034. Html5.prototype.play = function play() {
  12035. this.el_.play()
  12036. }
  12037. /**
  12038. * Pause for html5 tech
  12039. *
  12040. * @method pause
  12041. */
  12042. Html5.prototype.pause = function pause() {
  12043. this.el_.pause()
  12044. }
  12045. /**
  12046. * Paused for html5 tech
  12047. *
  12048. * @return {Boolean}
  12049. * @method paused
  12050. */
  12051. Html5.prototype.paused = function paused() {
  12052. return this.el_.paused
  12053. }
  12054. /**
  12055. * Get current time
  12056. *
  12057. * @return {Number}
  12058. * @method currentTime
  12059. */
  12060. Html5.prototype.currentTime = function currentTime() {
  12061. return this.el_.currentTime
  12062. }
  12063. /**
  12064. * Set current time
  12065. *
  12066. * @param {Number} seconds Current time of video
  12067. * @method setCurrentTime
  12068. */
  12069. Html5.prototype.setCurrentTime = function setCurrentTime(seconds) {
  12070. try {
  12071. this.el_.currentTime = seconds
  12072. } catch (e) {
  12073. _utilsLogJs2['default'](e, 'Video is not ready. (Video.js)')
  12074. // this.warning(VideoJS.warnings.videoNotReady);
  12075. }
  12076. }
  12077. /**
  12078. * Get duration
  12079. *
  12080. * @return {Number}
  12081. * @method duration
  12082. */
  12083. Html5.prototype.duration = function duration() {
  12084. return this.el_.duration || 0
  12085. }
  12086. /**
  12087. * Get a TimeRange object that represents the intersection
  12088. * of the time ranges for which the user agent has all
  12089. * relevant media
  12090. *
  12091. * @return {TimeRangeObject}
  12092. * @method buffered
  12093. */
  12094. Html5.prototype.buffered = function buffered() {
  12095. return this.el_.buffered
  12096. }
  12097. /**
  12098. * Get volume level
  12099. *
  12100. * @return {Number}
  12101. * @method volume
  12102. */
  12103. Html5.prototype.volume = function volume() {
  12104. return this.el_.volume
  12105. }
  12106. /**
  12107. * Set volume level
  12108. *
  12109. * @param {Number} percentAsDecimal Volume percent as a decimal
  12110. * @method setVolume
  12111. */
  12112. Html5.prototype.setVolume = function setVolume(percentAsDecimal) {
  12113. this.el_.volume = percentAsDecimal
  12114. }
  12115. /**
  12116. * Get if muted
  12117. *
  12118. * @return {Boolean}
  12119. * @method muted
  12120. */
  12121. Html5.prototype.muted = function muted() {
  12122. return this.el_.muted
  12123. }
  12124. /**
  12125. * Set muted
  12126. *
  12127. * @param {Boolean} If player is to be muted or note
  12128. * @method setMuted
  12129. */
  12130. Html5.prototype.setMuted = function setMuted(muted) {
  12131. this.el_.muted = muted
  12132. }
  12133. /**
  12134. * Get player width
  12135. *
  12136. * @return {Number}
  12137. * @method width
  12138. */
  12139. Html5.prototype.width = function width() {
  12140. return this.el_.offsetWidth
  12141. }
  12142. /**
  12143. * Get player height
  12144. *
  12145. * @return {Number}
  12146. * @method height
  12147. */
  12148. Html5.prototype.height = function height() {
  12149. return this.el_.offsetHeight
  12150. }
  12151. /**
  12152. * Get if there is fullscreen support
  12153. *
  12154. * @return {Boolean}
  12155. * @method supportsFullScreen
  12156. */
  12157. Html5.prototype.supportsFullScreen = function supportsFullScreen() {
  12158. if (typeof this.el_.webkitEnterFullScreen === 'function') {
  12159. var userAgent = _globalWindow2['default'].navigator.userAgent
  12160. // Seems to be broken in Chromium/Chrome && Safari in Leopard
  12161. if (/Android/.test(userAgent) || !/Chrome|Mac OS X 10.5/.test(userAgent)) {
  12162. return true
  12163. }
  12164. }
  12165. return false
  12166. }
  12167. /**
  12168. * Request to enter fullscreen
  12169. *
  12170. * @method enterFullScreen
  12171. */
  12172. Html5.prototype.enterFullScreen = function enterFullScreen() {
  12173. var video = this.el_
  12174. if ('webkitDisplayingFullscreen' in video) {
  12175. this.one('webkitbeginfullscreen', function() {
  12176. this.one('webkitendfullscreen', function() {
  12177. this.trigger('fullscreenchange', { isFullscreen: false })
  12178. })
  12179. this.trigger('fullscreenchange', { isFullscreen: true })
  12180. })
  12181. }
  12182. if (video.paused && video.networkState <= video.HAVE_METADATA) {
  12183. // attempt to prime the video element for programmatic access
  12184. // this isn't necessary on the desktop but shouldn't hurt
  12185. this.el_.play()
  12186. // playing and pausing synchronously during the transition to fullscreen
  12187. // can get iOS ~6.1 devices into a play/pause loop
  12188. this.setTimeout(function() {
  12189. video.pause()
  12190. video.webkitEnterFullScreen()
  12191. }, 0)
  12192. } else {
  12193. video.webkitEnterFullScreen()
  12194. }
  12195. }
  12196. /**
  12197. * Request to exit fullscreen
  12198. *
  12199. * @method exitFullScreen
  12200. */
  12201. Html5.prototype.exitFullScreen = function exitFullScreen() {
  12202. this.el_.webkitExitFullScreen()
  12203. }
  12204. /**
  12205. * Get/set video
  12206. *
  12207. * @param {Object=} src Source object
  12208. * @return {Object}
  12209. * @method src
  12210. */
  12211. Html5.prototype.src = function src(_src) {
  12212. if (_src === undefined) {
  12213. return this.el_.src
  12214. } else {
  12215. // Setting src through `src` instead of `setSrc` will be deprecated
  12216. this.setSrc(_src)
  12217. }
  12218. }
  12219. /**
  12220. * Set video
  12221. *
  12222. * @param {Object} src Source object
  12223. * @deprecated
  12224. * @method setSrc
  12225. */
  12226. Html5.prototype.setSrc = function setSrc(src) {
  12227. this.el_.src = src
  12228. }
  12229. /**
  12230. * Load media into player
  12231. *
  12232. * @method load
  12233. */
  12234. Html5.prototype.load = function load() {
  12235. this.el_.load()
  12236. }
  12237. /**
  12238. * Reset the tech. Removes all sources and calls `load`.
  12239. *
  12240. * @method reset
  12241. */
  12242. Html5.prototype.reset = function reset() {
  12243. Html5.resetMediaElement(this.el_)
  12244. }
  12245. /**
  12246. * Get current source
  12247. *
  12248. * @return {Object}
  12249. * @method currentSrc
  12250. */
  12251. Html5.prototype.currentSrc = function currentSrc() {
  12252. if (this.currentSource_) {
  12253. return this.currentSource_.src
  12254. } else {
  12255. return this.el_.currentSrc
  12256. }
  12257. }
  12258. /**
  12259. * Get poster
  12260. *
  12261. * @return {String}
  12262. * @method poster
  12263. */
  12264. Html5.prototype.poster = function poster() {
  12265. return this.el_.poster
  12266. }
  12267. /**
  12268. * Set poster
  12269. *
  12270. * @param {String} val URL to poster image
  12271. * @method
  12272. */
  12273. Html5.prototype.setPoster = function setPoster(val) {
  12274. this.el_.poster = val
  12275. }
  12276. /**
  12277. * Get preload attribute
  12278. *
  12279. * @return {String}
  12280. * @method preload
  12281. */
  12282. Html5.prototype.preload = function preload() {
  12283. return this.el_.preload
  12284. }
  12285. /**
  12286. * Set preload attribute
  12287. *
  12288. * @param {String} val Value for preload attribute
  12289. * @method setPreload
  12290. */
  12291. Html5.prototype.setPreload = function setPreload(val) {
  12292. this.el_.preload = val
  12293. }
  12294. /**
  12295. * Get autoplay attribute
  12296. *
  12297. * @return {String}
  12298. * @method autoplay
  12299. */
  12300. Html5.prototype.autoplay = function autoplay() {
  12301. return this.el_.autoplay
  12302. }
  12303. /**
  12304. * Set autoplay attribute
  12305. *
  12306. * @param {String} val Value for preload attribute
  12307. * @method setAutoplay
  12308. */
  12309. Html5.prototype.setAutoplay = function setAutoplay(val) {
  12310. this.el_.autoplay = val
  12311. }
  12312. /**
  12313. * Get controls attribute
  12314. *
  12315. * @return {String}
  12316. * @method controls
  12317. */
  12318. Html5.prototype.controls = function controls() {
  12319. return this.el_.controls
  12320. }
  12321. /**
  12322. * Set controls attribute
  12323. *
  12324. * @param {String} val Value for controls attribute
  12325. * @method setControls
  12326. */
  12327. Html5.prototype.setControls = function setControls(val) {
  12328. this.el_.controls = !!val
  12329. }
  12330. /**
  12331. * Get loop attribute
  12332. *
  12333. * @return {String}
  12334. * @method loop
  12335. */
  12336. Html5.prototype.loop = function loop() {
  12337. return this.el_.loop
  12338. }
  12339. /**
  12340. * Set loop attribute
  12341. *
  12342. * @param {String} val Value for loop attribute
  12343. * @method setLoop
  12344. */
  12345. Html5.prototype.setLoop = function setLoop(val) {
  12346. this.el_.loop = val
  12347. }
  12348. /**
  12349. * Get error value
  12350. *
  12351. * @return {String}
  12352. * @method error
  12353. */
  12354. Html5.prototype.error = function error() {
  12355. return this.el_.error
  12356. }
  12357. /**
  12358. * Get whether or not the player is in the "seeking" state
  12359. *
  12360. * @return {Boolean}
  12361. * @method seeking
  12362. */
  12363. Html5.prototype.seeking = function seeking() {
  12364. return this.el_.seeking
  12365. }
  12366. /**
  12367. * Get a TimeRanges object that represents the
  12368. * ranges of the media resource to which it is possible
  12369. * for the user agent to seek.
  12370. *
  12371. * @return {TimeRangeObject}
  12372. * @method seekable
  12373. */
  12374. Html5.prototype.seekable = function seekable() {
  12375. return this.el_.seekable
  12376. }
  12377. /**
  12378. * Get if video ended
  12379. *
  12380. * @return {Boolean}
  12381. * @method ended
  12382. */
  12383. Html5.prototype.ended = function ended() {
  12384. return this.el_.ended
  12385. }
  12386. /**
  12387. * Get the value of the muted content attribute
  12388. * This attribute has no dynamic effect, it only
  12389. * controls the default state of the element
  12390. *
  12391. * @return {Boolean}
  12392. * @method defaultMuted
  12393. */
  12394. Html5.prototype.defaultMuted = function defaultMuted() {
  12395. return this.el_.defaultMuted
  12396. }
  12397. /**
  12398. * Get desired speed at which the media resource is to play
  12399. *
  12400. * @return {Number}
  12401. * @method playbackRate
  12402. */
  12403. Html5.prototype.playbackRate = function playbackRate() {
  12404. return this.el_.playbackRate
  12405. }
  12406. /**
  12407. * Returns a TimeRanges object that represents the ranges of the
  12408. * media resource that the user agent has played.
  12409. * @return {TimeRangeObject} the range of points on the media
  12410. * timeline that has been reached through normal playback
  12411. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-played
  12412. */
  12413. Html5.prototype.played = function played() {
  12414. return this.el_.played
  12415. }
  12416. /**
  12417. * Set desired speed at which the media resource is to play
  12418. *
  12419. * @param {Number} val Speed at which the media resource is to play
  12420. * @method setPlaybackRate
  12421. */
  12422. Html5.prototype.setPlaybackRate = function setPlaybackRate(val) {
  12423. this.el_.playbackRate = val
  12424. }
  12425. /**
  12426. * Get the current state of network activity for the element, from
  12427. * the list below
  12428. * NETWORK_EMPTY (numeric value 0)
  12429. * NETWORK_IDLE (numeric value 1)
  12430. * NETWORK_LOADING (numeric value 2)
  12431. * NETWORK_NO_SOURCE (numeric value 3)
  12432. *
  12433. * @return {Number}
  12434. * @method networkState
  12435. */
  12436. Html5.prototype.networkState = function networkState() {
  12437. return this.el_.networkState
  12438. }
  12439. /**
  12440. * Get a value that expresses the current state of the element
  12441. * with respect to rendering the current playback position, from
  12442. * the codes in the list below
  12443. * HAVE_NOTHING (numeric value 0)
  12444. * HAVE_METADATA (numeric value 1)
  12445. * HAVE_CURRENT_DATA (numeric value 2)
  12446. * HAVE_FUTURE_DATA (numeric value 3)
  12447. * HAVE_ENOUGH_DATA (numeric value 4)
  12448. *
  12449. * @return {Number}
  12450. * @method readyState
  12451. */
  12452. Html5.prototype.readyState = function readyState() {
  12453. return this.el_.readyState
  12454. }
  12455. /**
  12456. * Get width of video
  12457. *
  12458. * @return {Number}
  12459. * @method videoWidth
  12460. */
  12461. Html5.prototype.videoWidth = function videoWidth() {
  12462. return this.el_.videoWidth
  12463. }
  12464. /**
  12465. * Get height of video
  12466. *
  12467. * @return {Number}
  12468. * @method videoHeight
  12469. */
  12470. Html5.prototype.videoHeight = function videoHeight() {
  12471. return this.el_.videoHeight
  12472. }
  12473. /**
  12474. * Get text tracks
  12475. *
  12476. * @return {TextTrackList}
  12477. * @method textTracks
  12478. */
  12479. Html5.prototype.textTracks = function textTracks() {
  12480. return _Tech.prototype.textTracks.call(this)
  12481. }
  12482. /**
  12483. * Creates and returns a text track object
  12484. *
  12485. * @param {String} kind Text track kind (subtitles, captions, descriptions
  12486. * chapters and metadata)
  12487. * @param {String=} label Label to identify the text track
  12488. * @param {String=} language Two letter language abbreviation
  12489. * @return {TextTrackObject}
  12490. * @method addTextTrack
  12491. */
  12492. Html5.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  12493. if (!this['featuresNativeTextTracks']) {
  12494. return _Tech.prototype.addTextTrack.call(this, kind, label, language)
  12495. }
  12496. return this.el_.addTextTrack(kind, label, language)
  12497. }
  12498. /**
  12499. * Creates a remote text track object and returns a html track element
  12500. *
  12501. * @param {Object} options The object should contain values for
  12502. * kind, language, label and src (location of the WebVTT file)
  12503. * @return {HTMLTrackElement}
  12504. * @method addRemoteTextTrack
  12505. */
  12506. Html5.prototype.addRemoteTextTrack = function addRemoteTextTrack() {
  12507. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  12508. if (!this['featuresNativeTextTracks']) {
  12509. return _Tech.prototype.addRemoteTextTrack.call(this, options)
  12510. }
  12511. var htmlTrackElement = _globalDocument2['default'].createElement('track')
  12512. if (options.kind) {
  12513. htmlTrackElement.kind = options.kind
  12514. }
  12515. if (options.label) {
  12516. htmlTrackElement.label = options.label
  12517. }
  12518. if (options.language || options.srclang) {
  12519. htmlTrackElement.srclang = options.language || options.srclang
  12520. }
  12521. if (options['default']) {
  12522. htmlTrackElement['default'] = options['default']
  12523. }
  12524. if (options.id) {
  12525. htmlTrackElement.id = options.id
  12526. }
  12527. if (options.src) {
  12528. htmlTrackElement.src = options.src
  12529. }
  12530. this.el().appendChild(htmlTrackElement)
  12531. // store HTMLTrackElement and TextTrack to remote list
  12532. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement)
  12533. this.remoteTextTracks().addTrack_(htmlTrackElement.track)
  12534. return htmlTrackElement
  12535. }
  12536. /**
  12537. * Remove remote text track from TextTrackList object
  12538. *
  12539. * @param {TextTrackObject} track Texttrack object to remove
  12540. * @method removeRemoteTextTrack
  12541. */
  12542. Html5.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  12543. if (!this['featuresNativeTextTracks']) {
  12544. return _Tech.prototype.removeRemoteTextTrack.call(this, track)
  12545. }
  12546. var tracks = undefined
  12547. var i = undefined
  12548. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track)
  12549. // remove HTMLTrackElement and TextTrack from remote list
  12550. this.remoteTextTrackEls().removeTrackElement_(trackElement)
  12551. this.remoteTextTracks().removeTrack_(track)
  12552. tracks = this.$$('track')
  12553. i = tracks.length
  12554. while (i--) {
  12555. if (track === tracks[i] || track === tracks[i].track) {
  12556. this.el().removeChild(tracks[i])
  12557. }
  12558. }
  12559. }
  12560. return Html5
  12561. })(_techJs2['default'])
  12562. Html5.TEST_VID = _globalDocument2['default'].createElement('video')
  12563. var track = _globalDocument2['default'].createElement('track')
  12564. track.kind = 'captions'
  12565. track.srclang = 'en'
  12566. track.label = 'English'
  12567. Html5.TEST_VID.appendChild(track)
  12568. /*
  12569. * Check if HTML5 video is supported by this browser/device
  12570. *
  12571. * @return {Boolean}
  12572. */
  12573. Html5.isSupported = function() {
  12574. // IE9 with no Media Player is a LIAR! (#984)
  12575. try {
  12576. Html5.TEST_VID['volume'] = 0.5
  12577. } catch (e) {
  12578. return false
  12579. }
  12580. return !!Html5.TEST_VID.canPlayType
  12581. }
  12582. // Add Source Handler pattern functions to this tech
  12583. _techJs2['default'].withSourceHandlers(Html5)
  12584. /*
  12585. * The default native source handler.
  12586. * This simply passes the source to the video element. Nothing fancy.
  12587. *
  12588. * @param {Object} source The source object
  12589. * @param {Html5} tech The instance of the HTML5 tech
  12590. */
  12591. Html5.nativeSourceHandler = {}
  12592. /*
  12593. * Check if the video element can play the given videotype
  12594. *
  12595. * @param {String} type The mimetype to check
  12596. * @return {String} 'probably', 'maybe', or '' (empty string)
  12597. */
  12598. Html5.nativeSourceHandler.canPlayType = function(type) {
  12599. // IE9 on Windows 7 without MediaPlayer throws an error here
  12600. // https://github.com/videojs/video.js/issues/519
  12601. try {
  12602. return Html5.TEST_VID.canPlayType(type)
  12603. } catch (e) {
  12604. return ''
  12605. }
  12606. }
  12607. /*
  12608. * Check if the video element can handle the source natively
  12609. *
  12610. * @param {Object} source The source object
  12611. * @return {String} 'probably', 'maybe', or '' (empty string)
  12612. */
  12613. Html5.nativeSourceHandler.canHandleSource = function(source) {
  12614. var match, ext
  12615. // If a type was provided we should rely on that
  12616. if (source.type) {
  12617. return Html5.nativeSourceHandler.canPlayType(source.type)
  12618. } else if (source.src) {
  12619. // If no type, fall back to checking 'video/[EXTENSION]'
  12620. ext = Url.getFileExtension(source.src)
  12621. return Html5.nativeSourceHandler.canPlayType('video/' + ext)
  12622. }
  12623. return ''
  12624. }
  12625. /*
  12626. * Pass the source to the video element
  12627. * Adaptive source handlers will have more complicated workflows before passing
  12628. * video data to the video element
  12629. *
  12630. * @param {Object} source The source object
  12631. * @param {Html5} tech The instance of the Html5 tech
  12632. * @param {Object} options The options to pass to the source
  12633. */
  12634. Html5.nativeSourceHandler.handleSource = function(source, tech, options) {
  12635. tech.setSrc(source.src)
  12636. }
  12637. /*
  12638. * Clean up the source handler when disposing the player or switching sources..
  12639. * (no cleanup is needed when supporting the format natively)
  12640. */
  12641. Html5.nativeSourceHandler.dispose = function() { }
  12642. // Register the native source handler
  12643. Html5.registerSourceHandler(Html5.nativeSourceHandler)
  12644. /*
  12645. * Check if the volume can be changed in this browser/device.
  12646. * Volume cannot be changed in a lot of mobile devices.
  12647. * Specifically, it can't be changed from 1 on iOS.
  12648. *
  12649. * @return {Boolean}
  12650. */
  12651. Html5.canControlVolume = function() {
  12652. var volume = Html5.TEST_VID.volume
  12653. Html5.TEST_VID.volume = volume / 2 + 0.1
  12654. return volume !== Html5.TEST_VID.volume
  12655. }
  12656. /*
  12657. * Check if playbackRate is supported in this browser/device.
  12658. *
  12659. * @return {Boolean}
  12660. */
  12661. Html5.canControlPlaybackRate = function() {
  12662. // Playback rate API is implemented in Android Chrome, but doesn't do anything
  12663. // https://github.com/videojs/video.js/issues/3180
  12664. if (browser.IS_ANDROID && browser.IS_CHROME) {
  12665. return false
  12666. }
  12667. var playbackRate = Html5.TEST_VID.playbackRate
  12668. Html5.TEST_VID.playbackRate = playbackRate / 2 + 0.1
  12669. return playbackRate !== Html5.TEST_VID.playbackRate
  12670. }
  12671. /*
  12672. * Check to see if native text tracks are supported by this browser/device
  12673. *
  12674. * @return {Boolean}
  12675. */
  12676. Html5.supportsNativeTextTracks = function() {
  12677. var supportsTextTracks
  12678. // Figure out native text track support
  12679. // If mode is a number, we cannot change it because it'll disappear from view.
  12680. // Browsers with numeric modes include IE10 and older (<=2013) samsung android models.
  12681. // Firefox isn't playing nice either with modifying the mode
  12682. // TODO: Investigate firefox: https://github.com/videojs/video.js/issues/1862
  12683. supportsTextTracks = !!Html5.TEST_VID.textTracks
  12684. if (supportsTextTracks && Html5.TEST_VID.textTracks.length > 0) {
  12685. supportsTextTracks = typeof Html5.TEST_VID.textTracks[0]['mode'] !== 'number'
  12686. }
  12687. if (supportsTextTracks && browser.IS_FIREFOX) {
  12688. supportsTextTracks = false
  12689. }
  12690. if (supportsTextTracks && !('onremovetrack' in Html5.TEST_VID.textTracks)) {
  12691. supportsTextTracks = false
  12692. }
  12693. return supportsTextTracks
  12694. }
  12695. /*
  12696. * Check to see if native video tracks are supported by this browser/device
  12697. *
  12698. * @return {Boolean}
  12699. */
  12700. Html5.supportsNativeVideoTracks = function() {
  12701. var supportsVideoTracks = !!Html5.TEST_VID.videoTracks
  12702. return supportsVideoTracks
  12703. }
  12704. /*
  12705. * Check to see if native audio tracks are supported by this browser/device
  12706. *
  12707. * @return {Boolean}
  12708. */
  12709. Html5.supportsNativeAudioTracks = function() {
  12710. var supportsAudioTracks = !!Html5.TEST_VID.audioTracks
  12711. return supportsAudioTracks
  12712. }
  12713. /**
  12714. * An array of events available on the Html5 tech.
  12715. *
  12716. * @private
  12717. * @type {Array}
  12718. */
  12719. Html5.Events = ['loadstart', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', 'playing', 'waiting', 'seeking', 'seeked', 'ended', 'durationchange', 'timeupdate', 'progress', 'play', 'pause', 'ratechange', 'volumechange']
  12720. /*
  12721. * Set the tech's volume control support status
  12722. *
  12723. * @type {Boolean}
  12724. */
  12725. Html5.prototype['featuresVolumeControl'] = Html5.canControlVolume()
  12726. /*
  12727. * Set the tech's playbackRate support status
  12728. *
  12729. * @type {Boolean}
  12730. */
  12731. Html5.prototype['featuresPlaybackRate'] = Html5.canControlPlaybackRate()
  12732. /*
  12733. * Set the tech's status on moving the video element.
  12734. * In iOS, if you move a video element in the DOM, it breaks video playback.
  12735. *
  12736. * @type {Boolean}
  12737. */
  12738. Html5.prototype['movingMediaElementInDOM'] = !browser.IS_IOS
  12739. /*
  12740. * Set the the tech's fullscreen resize support status.
  12741. * HTML video is able to automatically resize when going to fullscreen.
  12742. * (No longer appears to be used. Can probably be removed.)
  12743. */
  12744. Html5.prototype['featuresFullscreenResize'] = true
  12745. /*
  12746. * Set the tech's progress event support status
  12747. * (this disables the manual progress events of the Tech)
  12748. */
  12749. Html5.prototype['featuresProgressEvents'] = true
  12750. /*
  12751. * Sets the tech's status on native text track support
  12752. *
  12753. * @type {Boolean}
  12754. */
  12755. Html5.prototype['featuresNativeTextTracks'] = Html5.supportsNativeTextTracks()
  12756. /**
  12757. * Sets the tech's status on native text track support
  12758. *
  12759. * @type {Boolean}
  12760. */
  12761. Html5.prototype['featuresNativeVideoTracks'] = Html5.supportsNativeVideoTracks()
  12762. /**
  12763. * Sets the tech's status on native audio track support
  12764. *
  12765. * @type {Boolean}
  12766. */
  12767. Html5.prototype['featuresNativeAudioTracks'] = Html5.supportsNativeAudioTracks()
  12768. // HTML5 Feature detection and Device Fixes --------------------------------- //
  12769. var canPlayType = undefined
  12770. var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i
  12771. var mp4RE = /^video\/mp4/i
  12772. Html5.patchCanPlayType = function() {
  12773. // Android 4.0 and above can play HLS to some extent but it reports being unable to do so
  12774. if (browser.ANDROID_VERSION >= 4.0) {
  12775. if (!canPlayType) {
  12776. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType
  12777. }
  12778. Html5.TEST_VID.constructor.prototype.canPlayType = function(type) {
  12779. if (type && mpegurlRE.test(type)) {
  12780. return 'maybe'
  12781. }
  12782. return canPlayType.call(this, type)
  12783. }
  12784. }
  12785. // Override Android 2.2 and less canPlayType method which is broken
  12786. if (browser.IS_OLD_ANDROID) {
  12787. if (!canPlayType) {
  12788. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType
  12789. }
  12790. Html5.TEST_VID.constructor.prototype.canPlayType = function(type) {
  12791. if (type && mp4RE.test(type)) {
  12792. return 'maybe'
  12793. }
  12794. return canPlayType.call(this, type)
  12795. }
  12796. }
  12797. }
  12798. Html5.unpatchCanPlayType = function() {
  12799. var r = Html5.TEST_VID.constructor.prototype.canPlayType
  12800. Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType
  12801. canPlayType = null
  12802. return r
  12803. }
  12804. // by default, patch the video element
  12805. Html5.patchCanPlayType()
  12806. Html5.disposeMediaElement = function(el) {
  12807. if (!el) {
  12808. return
  12809. }
  12810. if (el.parentNode) {
  12811. el.parentNode.removeChild(el)
  12812. }
  12813. // remove any child track or source nodes to prevent their loading
  12814. while (el.hasChildNodes()) {
  12815. el.removeChild(el.firstChild)
  12816. }
  12817. // remove any src reference. not setting `src=''` because that causes a warning
  12818. // in firefox
  12819. el.removeAttribute('src')
  12820. // force the media element to update its loading state by calling load()
  12821. // however IE on Windows 7N has a bug that throws an error so need a try/catch (#793)
  12822. if (typeof el.load === 'function') {
  12823. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  12824. (function() {
  12825. try {
  12826. el.load()
  12827. } catch (e) {
  12828. // not supported
  12829. }
  12830. })()
  12831. }
  12832. }
  12833. Html5.resetMediaElement = function(el) {
  12834. if (!el) {
  12835. return
  12836. }
  12837. var sources = el.querySelectorAll('source')
  12838. var i = sources.length
  12839. while (i--) {
  12840. el.removeChild(sources[i])
  12841. }
  12842. // remove any src reference.
  12843. // not setting `src=''` because that throws an error
  12844. el.removeAttribute('src')
  12845. if (typeof el.load === 'function') {
  12846. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  12847. (function() {
  12848. try {
  12849. el.load()
  12850. } catch (e) { }
  12851. })()
  12852. }
  12853. }
  12854. _component2['default'].registerComponent('Html5', Html5)
  12855. _techJs2['default'].registerTech('Html5', Html5)
  12856. exports['default'] = Html5
  12857. module.exports = exports['default']
  12858. }, { '../../../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) {
  12859. /**
  12860. * @file loader.js
  12861. */
  12862. 'use strict'
  12863. exports.__esModule = true
  12864. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  12865. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  12866. 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 }
  12867. var _componentJs = _dereq_('../component.js')
  12868. var _componentJs2 = _interopRequireDefault(_componentJs)
  12869. var _techJs = _dereq_('./tech.js')
  12870. var _techJs2 = _interopRequireDefault(_techJs)
  12871. var _globalWindow = _dereq_('global/window')
  12872. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  12873. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js')
  12874. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs)
  12875. /**
  12876. * The Media Loader is the component that decides which playback technology to load
  12877. * when the player is initialized.
  12878. *
  12879. * @param {Object} player Main Player
  12880. * @param {Object=} options Object of option names and values
  12881. * @param {Function=} ready Ready callback function
  12882. * @extends Component
  12883. * @class MediaLoader
  12884. */
  12885. var MediaLoader = (function(_Component) {
  12886. _inherits(MediaLoader, _Component)
  12887. function MediaLoader(player, options, ready) {
  12888. _classCallCheck(this, MediaLoader)
  12889. _Component.call(this, player, options, ready)
  12890. // If there are no sources when the player is initialized,
  12891. // load the first supported playback technology.
  12892. if (!options.playerOptions['sources'] || options.playerOptions['sources'].length === 0) {
  12893. for (var i = 0, j = options.playerOptions['techOrder']; i < j.length; i++) {
  12894. var techName = _utilsToTitleCaseJs2['default'](j[i])
  12895. var tech = _techJs2['default'].getTech(techName)
  12896. // Support old behavior of techs being registered as components.
  12897. // Remove once that deprecated behavior is removed.
  12898. if (!techName) {
  12899. tech = _componentJs2['default'].getComponent(techName)
  12900. }
  12901. // Check if the browser supports this technology
  12902. if (tech && tech.isSupported()) {
  12903. player.loadTech_(techName)
  12904. break
  12905. }
  12906. }
  12907. } else {
  12908. // // Loop through playback technologies (HTML5, Flash) and check for support.
  12909. // // Then load the best source.
  12910. // // A few assumptions here:
  12911. // // All playback technologies respect preload false.
  12912. player.src(options.playerOptions['sources'])
  12913. }
  12914. }
  12915. return MediaLoader
  12916. })(_componentJs2['default'])
  12917. _componentJs2['default'].registerComponent('MediaLoader', MediaLoader)
  12918. exports['default'] = MediaLoader
  12919. module.exports = exports['default']
  12920. }, { '../component.js': 67, '../utils/to-title-case.js': 152, './tech.js': 124, 'global/window': 2 }], 124: [function(_dereq_, module, exports) {
  12921. /**
  12922. * @file tech.js
  12923. * Media Technology Controller - Base class for media playback
  12924. * technology controllers like Flash and HTML5
  12925. */
  12926. 'use strict'
  12927. exports.__esModule = true
  12928. 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 } }
  12929. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  12930. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  12931. 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 }
  12932. var _component = _dereq_('../component')
  12933. var _component2 = _interopRequireDefault(_component)
  12934. var _tracksHtmlTrackElement = _dereq_('../tracks/html-track-element')
  12935. var _tracksHtmlTrackElement2 = _interopRequireDefault(_tracksHtmlTrackElement)
  12936. var _tracksHtmlTrackElementList = _dereq_('../tracks/html-track-element-list')
  12937. var _tracksHtmlTrackElementList2 = _interopRequireDefault(_tracksHtmlTrackElementList)
  12938. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js')
  12939. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs)
  12940. var _tracksTextTrack = _dereq_('../tracks/text-track')
  12941. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack)
  12942. var _tracksTextTrackList = _dereq_('../tracks/text-track-list')
  12943. var _tracksTextTrackList2 = _interopRequireDefault(_tracksTextTrackList)
  12944. var _tracksVideoTrack = _dereq_('../tracks/video-track')
  12945. var _tracksVideoTrack2 = _interopRequireDefault(_tracksVideoTrack)
  12946. var _tracksVideoTrackList = _dereq_('../tracks/video-track-list')
  12947. var _tracksVideoTrackList2 = _interopRequireDefault(_tracksVideoTrackList)
  12948. var _tracksAudioTrackList = _dereq_('../tracks/audio-track-list')
  12949. var _tracksAudioTrackList2 = _interopRequireDefault(_tracksAudioTrackList)
  12950. var _tracksAudioTrack = _dereq_('../tracks/audio-track')
  12951. var _tracksAudioTrack2 = _interopRequireDefault(_tracksAudioTrack)
  12952. var _utilsFnJs = _dereq_('../utils/fn.js')
  12953. var Fn = _interopRequireWildcard(_utilsFnJs)
  12954. var _utilsLogJs = _dereq_('../utils/log.js')
  12955. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  12956. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js')
  12957. var _utilsBufferJs = _dereq_('../utils/buffer.js')
  12958. var _mediaErrorJs = _dereq_('../media-error.js')
  12959. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs)
  12960. var _globalWindow = _dereq_('global/window')
  12961. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  12962. var _globalDocument = _dereq_('global/document')
  12963. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  12964. /**
  12965. * Base class for media (HTML5 Video, Flash) controllers
  12966. *
  12967. * @param {Object=} options Options object
  12968. * @param {Function=} ready Ready callback function
  12969. * @extends Component
  12970. * @class Tech
  12971. */
  12972. var Tech = (function(_Component) {
  12973. _inherits(Tech, _Component)
  12974. function Tech() {
  12975. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  12976. var ready = arguments.length <= 1 || arguments[1] === undefined ? function() { } : arguments[1]
  12977. _classCallCheck(this, Tech)
  12978. // we don't want the tech to report user activity automatically.
  12979. // This is done manually in addControlsListeners
  12980. options.reportTouchActivity = false
  12981. _Component.call(this, null, options, ready)
  12982. // keep track of whether the current source has played at all to
  12983. // implement a very limited played()
  12984. this.hasStarted_ = false
  12985. this.on('playing', function() {
  12986. this.hasStarted_ = true
  12987. })
  12988. this.on('loadstart', function() {
  12989. this.hasStarted_ = false
  12990. })
  12991. this.textTracks_ = options.textTracks
  12992. this.videoTracks_ = options.videoTracks
  12993. this.audioTracks_ = options.audioTracks
  12994. // Manually track progress in cases where the browser/flash player doesn't report it.
  12995. if (!this.featuresProgressEvents) {
  12996. this.manualProgressOn()
  12997. }
  12998. // Manually track timeupdates in cases where the browser/flash player doesn't report it.
  12999. if (!this.featuresTimeupdateEvents) {
  13000. this.manualTimeUpdatesOn()
  13001. }
  13002. if (options.nativeCaptions === false || options.nativeTextTracks === false) {
  13003. this.featuresNativeTextTracks = false
  13004. }
  13005. if (!this.featuresNativeTextTracks) {
  13006. this.on('ready', this.emulateTextTracks)
  13007. }
  13008. this.initTextTrackListeners()
  13009. this.initTrackListeners()
  13010. // Turn on component tap events
  13011. this.emitTapEvents()
  13012. }
  13013. /**
  13014. * List of associated text tracks
  13015. *
  13016. * @type {TextTrackList}
  13017. * @private
  13018. */
  13019. /* Fallbacks for unsupported event types
  13020. ================================================================================ */
  13021. // Manually trigger progress events based on changes to the buffered amount
  13022. // Many flash players and older HTML5 browsers don't send progress or progress-like events
  13023. /**
  13024. * Turn on progress events
  13025. *
  13026. * @method manualProgressOn
  13027. */
  13028. Tech.prototype.manualProgressOn = function manualProgressOn() {
  13029. this.on('durationchange', this.onDurationChange)
  13030. this.manualProgress = true
  13031. // Trigger progress watching when a source begins loading
  13032. this.one('ready', this.trackProgress)
  13033. }
  13034. /**
  13035. * Turn off progress events
  13036. *
  13037. * @method manualProgressOff
  13038. */
  13039. Tech.prototype.manualProgressOff = function manualProgressOff() {
  13040. this.manualProgress = false
  13041. this.stopTrackingProgress()
  13042. this.off('durationchange', this.onDurationChange)
  13043. }
  13044. /**
  13045. * Track progress
  13046. *
  13047. * @method trackProgress
  13048. */
  13049. Tech.prototype.trackProgress = function trackProgress() {
  13050. this.stopTrackingProgress()
  13051. this.progressInterval = this.setInterval(Fn.bind(this, function() {
  13052. // Don't trigger unless buffered amount is greater than last time
  13053. var numBufferedPercent = this.bufferedPercent()
  13054. if (this.bufferedPercent_ !== numBufferedPercent) {
  13055. this.trigger('progress')
  13056. }
  13057. this.bufferedPercent_ = numBufferedPercent
  13058. if (numBufferedPercent === 1) {
  13059. this.stopTrackingProgress()
  13060. }
  13061. }), 500)
  13062. }
  13063. /**
  13064. * Update duration
  13065. *
  13066. * @method onDurationChange
  13067. */
  13068. Tech.prototype.onDurationChange = function onDurationChange() {
  13069. this.duration_ = this.duration()
  13070. }
  13071. /**
  13072. * Create and get TimeRange object for buffering
  13073. *
  13074. * @return {TimeRangeObject}
  13075. * @method buffered
  13076. */
  13077. Tech.prototype.buffered = function buffered() {
  13078. return _utilsTimeRangesJs.createTimeRange(0, 0)
  13079. }
  13080. /**
  13081. * Get buffered percent
  13082. *
  13083. * @return {Number}
  13084. * @method bufferedPercent
  13085. */
  13086. Tech.prototype.bufferedPercent = function bufferedPercent() {
  13087. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration_)
  13088. }
  13089. /**
  13090. * Stops tracking progress by clearing progress interval
  13091. *
  13092. * @method stopTrackingProgress
  13093. */
  13094. Tech.prototype.stopTrackingProgress = function stopTrackingProgress() {
  13095. this.clearInterval(this.progressInterval)
  13096. }
  13097. /*! Time Tracking -------------------------------------------------------------- */
  13098. /**
  13099. * Set event listeners for on play and pause and tracking current time
  13100. *
  13101. * @method manualTimeUpdatesOn
  13102. */
  13103. Tech.prototype.manualTimeUpdatesOn = function manualTimeUpdatesOn() {
  13104. this.manualTimeUpdates = true
  13105. this.on('play', this.trackCurrentTime)
  13106. this.on('pause', this.stopTrackingCurrentTime)
  13107. }
  13108. /**
  13109. * Remove event listeners for on play and pause and tracking current time
  13110. *
  13111. * @method manualTimeUpdatesOff
  13112. */
  13113. Tech.prototype.manualTimeUpdatesOff = function manualTimeUpdatesOff() {
  13114. this.manualTimeUpdates = false
  13115. this.stopTrackingCurrentTime()
  13116. this.off('play', this.trackCurrentTime)
  13117. this.off('pause', this.stopTrackingCurrentTime)
  13118. }
  13119. /**
  13120. * Tracks current time
  13121. *
  13122. * @method trackCurrentTime
  13123. */
  13124. Tech.prototype.trackCurrentTime = function trackCurrentTime() {
  13125. if (this.currentTimeInterval) {
  13126. this.stopTrackingCurrentTime()
  13127. }
  13128. this.currentTimeInterval = this.setInterval(function() {
  13129. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true })
  13130. }, 250) // 42 = 24 fps // 250 is what Webkit uses // FF uses 15
  13131. }
  13132. /**
  13133. * Turn off play progress tracking (when paused or dragging)
  13134. *
  13135. * @method stopTrackingCurrentTime
  13136. */
  13137. Tech.prototype.stopTrackingCurrentTime = function stopTrackingCurrentTime() {
  13138. this.clearInterval(this.currentTimeInterval)
  13139. // #1002 - if the video ends right before the next timeupdate would happen,
  13140. // the progress bar won't make it all the way to the end
  13141. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true })
  13142. }
  13143. /**
  13144. * Turn off any manual progress or timeupdate tracking
  13145. *
  13146. * @method dispose
  13147. */
  13148. Tech.prototype.dispose = function dispose() {
  13149. // clear out all tracks because we can't reuse them between techs
  13150. this.clearTracks(['audio', 'video', 'text'])
  13151. // Turn off any manual progress or timeupdate tracking
  13152. if (this.manualProgress) {
  13153. this.manualProgressOff()
  13154. }
  13155. if (this.manualTimeUpdates) {
  13156. this.manualTimeUpdatesOff()
  13157. }
  13158. _Component.prototype.dispose.call(this)
  13159. }
  13160. /**
  13161. * clear out a track list, or multiple track lists
  13162. *
  13163. * Note: Techs without source handlers should call this between
  13164. * sources for video & audio tracks, as usually you don't want
  13165. * to use them between tracks and we have no automatic way to do
  13166. * it for you
  13167. *
  13168. * @method clearTracks
  13169. * @param {Array|String} types type(s) of track lists to empty
  13170. */
  13171. Tech.prototype.clearTracks = function clearTracks(types) {
  13172. var _this = this
  13173. types = [].concat(types)
  13174. // clear out all tracks because we can't reuse them between techs
  13175. types.forEach(function(type) {
  13176. var list = _this[type + 'Tracks']() || []
  13177. var i = list.length
  13178. while (i--) {
  13179. var track = list[i]
  13180. if (type === 'text') {
  13181. _this.removeRemoteTextTrack(track)
  13182. }
  13183. list.removeTrack_(track)
  13184. }
  13185. })
  13186. }
  13187. /**
  13188. * Reset the tech. Removes all sources and resets readyState.
  13189. *
  13190. * @method reset
  13191. */
  13192. Tech.prototype.reset = function reset() { }
  13193. /**
  13194. * When invoked without an argument, returns a MediaError object
  13195. * representing the current error state of the player or null if
  13196. * there is no error. When invoked with an argument, set the current
  13197. * error state of the player.
  13198. * @param {MediaError=} err Optional an error object
  13199. * @return {MediaError} the current error object or null
  13200. * @method error
  13201. */
  13202. Tech.prototype.error = function error(err) {
  13203. if (err !== undefined) {
  13204. if (err instanceof _mediaErrorJs2['default']) {
  13205. this.error_ = err
  13206. } else {
  13207. this.error_ = new _mediaErrorJs2['default'](err)
  13208. }
  13209. this.trigger('error')
  13210. }
  13211. return this.error_
  13212. }
  13213. /**
  13214. * Return the time ranges that have been played through for the
  13215. * current source. This implementation is incomplete. It does not
  13216. * track the played time ranges, only whether the source has played
  13217. * at all or not.
  13218. * @return {TimeRangeObject} a single time range if this video has
  13219. * played or an empty set of ranges if not.
  13220. * @method played
  13221. */
  13222. Tech.prototype.played = function played() {
  13223. if (this.hasStarted_) {
  13224. return _utilsTimeRangesJs.createTimeRange(0, 0)
  13225. }
  13226. return _utilsTimeRangesJs.createTimeRange()
  13227. }
  13228. /**
  13229. * Set current time
  13230. *
  13231. * @method setCurrentTime
  13232. */
  13233. Tech.prototype.setCurrentTime = function setCurrentTime() {
  13234. // improve the accuracy of manual timeupdates
  13235. if (this.manualTimeUpdates) {
  13236. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true })
  13237. }
  13238. }
  13239. /**
  13240. * Initialize texttrack listeners
  13241. *
  13242. * @method initTextTrackListeners
  13243. */
  13244. Tech.prototype.initTextTrackListeners = function initTextTrackListeners() {
  13245. var textTrackListChanges = Fn.bind(this, function() {
  13246. this.trigger('texttrackchange')
  13247. })
  13248. var tracks = this.textTracks()
  13249. if (!tracks) return
  13250. tracks.addEventListener('removetrack', textTrackListChanges)
  13251. tracks.addEventListener('addtrack', textTrackListChanges)
  13252. this.on('dispose', Fn.bind(this, function() {
  13253. tracks.removeEventListener('removetrack', textTrackListChanges)
  13254. tracks.removeEventListener('addtrack', textTrackListChanges)
  13255. }))
  13256. }
  13257. /**
  13258. * Initialize audio and video track listeners
  13259. *
  13260. * @method initTrackListeners
  13261. */
  13262. Tech.prototype.initTrackListeners = function initTrackListeners() {
  13263. var _this2 = this
  13264. var trackTypes = ['video', 'audio']
  13265. trackTypes.forEach(function(type) {
  13266. var trackListChanges = function trackListChanges() {
  13267. _this2.trigger(type + 'trackchange')
  13268. }
  13269. var tracks = _this2[type + 'Tracks']()
  13270. tracks.addEventListener('removetrack', trackListChanges)
  13271. tracks.addEventListener('addtrack', trackListChanges)
  13272. _this2.on('dispose', function() {
  13273. tracks.removeEventListener('removetrack', trackListChanges)
  13274. tracks.removeEventListener('addtrack', trackListChanges)
  13275. })
  13276. })
  13277. }
  13278. /**
  13279. * Emulate texttracks
  13280. *
  13281. * @method emulateTextTracks
  13282. */
  13283. Tech.prototype.emulateTextTracks = function emulateTextTracks() {
  13284. var _this3 = this
  13285. var tracks = this.textTracks()
  13286. if (!tracks) {
  13287. return
  13288. }
  13289. if (!_globalWindow2['default']['WebVTT'] && this.el().parentNode != null) {
  13290. (function() {
  13291. var script = _globalDocument2['default'].createElement('script')
  13292. script.src = _this3.options_['vtt.js'] || 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.min.js'
  13293. script.onload = function() {
  13294. _this3.trigger('vttjsloaded')
  13295. }
  13296. script.onerror = function() {
  13297. _this3.trigger('vttjserror')
  13298. }
  13299. _this3.on('dispose', function() {
  13300. script.onload = null
  13301. script.onerror = null
  13302. })
  13303. // but have not loaded yet and we set it to true before the inject so that
  13304. // we don't overwrite the injected window.WebVTT if it loads right away
  13305. _globalWindow2['default']['WebVTT'] = true
  13306. _this3.el().parentNode.appendChild(script)
  13307. })()
  13308. }
  13309. var updateDisplay = function updateDisplay() {
  13310. return _this3.trigger('texttrackchange')
  13311. }
  13312. var textTracksChanges = function textTracksChanges() {
  13313. updateDisplay()
  13314. for (var i = 0; i < tracks.length; i++) {
  13315. var track = tracks[i]
  13316. track.removeEventListener('cuechange', updateDisplay)
  13317. if (track.mode === 'showing') {
  13318. track.addEventListener('cuechange', updateDisplay)
  13319. }
  13320. }
  13321. }
  13322. textTracksChanges()
  13323. tracks.addEventListener('change', textTracksChanges)
  13324. this.on('dispose', function() {
  13325. tracks.removeEventListener('change', textTracksChanges)
  13326. })
  13327. }
  13328. /**
  13329. * Get videotracks
  13330. *
  13331. * @returns {VideoTrackList}
  13332. * @method videoTracks
  13333. */
  13334. Tech.prototype.videoTracks = function videoTracks() {
  13335. this.videoTracks_ = this.videoTracks_ || new _tracksVideoTrackList2['default']()
  13336. return this.videoTracks_
  13337. }
  13338. /**
  13339. * Get audiotracklist
  13340. *
  13341. * @returns {AudioTrackList}
  13342. * @method audioTracks
  13343. */
  13344. Tech.prototype.audioTracks = function audioTracks() {
  13345. this.audioTracks_ = this.audioTracks_ || new _tracksAudioTrackList2['default']()
  13346. return this.audioTracks_
  13347. }
  13348. /*
  13349. * Provide default methods for text tracks.
  13350. *
  13351. * Html5 tech overrides these.
  13352. */
  13353. /**
  13354. * Get texttracks
  13355. *
  13356. * @returns {TextTrackList}
  13357. * @method textTracks
  13358. */
  13359. Tech.prototype.textTracks = function textTracks() {
  13360. this.textTracks_ = this.textTracks_ || new _tracksTextTrackList2['default']()
  13361. return this.textTracks_
  13362. }
  13363. /**
  13364. * Get remote texttracks
  13365. *
  13366. * @returns {TextTrackList}
  13367. * @method remoteTextTracks
  13368. */
  13369. Tech.prototype.remoteTextTracks = function remoteTextTracks() {
  13370. this.remoteTextTracks_ = this.remoteTextTracks_ || new _tracksTextTrackList2['default']()
  13371. return this.remoteTextTracks_
  13372. }
  13373. /**
  13374. * Get remote htmltrackelements
  13375. *
  13376. * @returns {HTMLTrackElementList}
  13377. * @method remoteTextTrackEls
  13378. */
  13379. Tech.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  13380. this.remoteTextTrackEls_ = this.remoteTextTrackEls_ || new _tracksHtmlTrackElementList2['default']()
  13381. return this.remoteTextTrackEls_
  13382. }
  13383. /**
  13384. * Creates and returns a remote text track object
  13385. *
  13386. * @param {String} kind Text track kind (subtitles, captions, descriptions
  13387. * chapters and metadata)
  13388. * @param {String=} label Label to identify the text track
  13389. * @param {String=} language Two letter language abbreviation
  13390. * @return {TextTrackObject}
  13391. * @method addTextTrack
  13392. */
  13393. Tech.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  13394. if (!kind) {
  13395. throw new Error('TextTrack kind is required but was not provided')
  13396. }
  13397. return createTrackHelper(this, kind, label, language)
  13398. }
  13399. /**
  13400. * Creates a remote text track object and returns a emulated html track element
  13401. *
  13402. * @param {Object} options The object should contain values for
  13403. * kind, language, label and src (location of the WebVTT file)
  13404. * @return {HTMLTrackElement}
  13405. * @method addRemoteTextTrack
  13406. */
  13407. Tech.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  13408. var track = _utilsMergeOptionsJs2['default'](options, {
  13409. tech: this
  13410. })
  13411. var htmlTrackElement = new _tracksHtmlTrackElement2['default'](track)
  13412. // store HTMLTrackElement and TextTrack to remote list
  13413. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement)
  13414. this.remoteTextTracks().addTrack_(htmlTrackElement.track)
  13415. // must come after remoteTextTracks()
  13416. this.textTracks().addTrack_(htmlTrackElement.track)
  13417. return htmlTrackElement
  13418. }
  13419. /**
  13420. * Remove remote texttrack
  13421. *
  13422. * @param {TextTrackObject} track Texttrack to remove
  13423. * @method removeRemoteTextTrack
  13424. */
  13425. Tech.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  13426. this.textTracks().removeTrack_(track)
  13427. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track)
  13428. // remove HTMLTrackElement and TextTrack from remote list
  13429. this.remoteTextTrackEls().removeTrackElement_(trackElement)
  13430. this.remoteTextTracks().removeTrack_(track)
  13431. }
  13432. /**
  13433. * Provide a default setPoster method for techs
  13434. * Poster support for techs should be optional, so we don't want techs to
  13435. * break if they don't have a way to set a poster.
  13436. *
  13437. * @method setPoster
  13438. */
  13439. Tech.prototype.setPoster = function setPoster() { }
  13440. /*
  13441. * Check if the tech can support the given type
  13442. *
  13443. * The base tech does not support any type, but source handlers might
  13444. * overwrite this.
  13445. *
  13446. * @param {String} type The mimetype to check
  13447. * @return {String} 'probably', 'maybe', or '' (empty string)
  13448. */
  13449. Tech.prototype.canPlayType = function canPlayType() {
  13450. return ''
  13451. }
  13452. /*
  13453. * Return whether the argument is a Tech or not.
  13454. * Can be passed either a Class like `Html5` or a instance like `player.tech_`
  13455. *
  13456. * @param {Object} component An item to check
  13457. * @return {Boolean} Whether it is a tech or not
  13458. */
  13459. Tech.isTech = function isTech(component) {
  13460. return component.prototype instanceof Tech || component instanceof Tech || component === Tech
  13461. }
  13462. /**
  13463. * Registers a Tech
  13464. *
  13465. * @param {String} name Name of the Tech to register
  13466. * @param {Object} tech The tech to register
  13467. * @static
  13468. * @method registerComponent
  13469. */
  13470. Tech.registerTech = function registerTech(name, tech) {
  13471. if (!Tech.techs_) {
  13472. Tech.techs_ = {}
  13473. }
  13474. if (!Tech.isTech(tech)) {
  13475. throw new Error('Tech ' + name + ' must be a Tech')
  13476. }
  13477. Tech.techs_[name] = tech
  13478. return tech
  13479. }
  13480. /**
  13481. * Gets a component by name
  13482. *
  13483. * @param {String} name Name of the component to get
  13484. * @return {Component}
  13485. * @static
  13486. * @method getComponent
  13487. */
  13488. Tech.getTech = function getTech(name) {
  13489. if (Tech.techs_ && Tech.techs_[name]) {
  13490. return Tech.techs_[name]
  13491. }
  13492. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  13493. _utilsLogJs2['default'].warn('The ' + name + ' tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)')
  13494. return _globalWindow2['default'].videojs[name]
  13495. }
  13496. }
  13497. return Tech
  13498. })(_component2['default'])
  13499. Tech.prototype.textTracks_
  13500. /**
  13501. * List of associated audio tracks
  13502. *
  13503. * @type {AudioTrackList}
  13504. * @private
  13505. */
  13506. Tech.prototype.audioTracks_
  13507. /**
  13508. * List of associated video tracks
  13509. *
  13510. * @type {VideoTrackList}
  13511. * @private
  13512. */
  13513. Tech.prototype.videoTracks_
  13514. var createTrackHelper = function createTrackHelper(self, kind, label, language) {
  13515. var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4]
  13516. var tracks = self.textTracks()
  13517. options.kind = kind
  13518. if (label) {
  13519. options.label = label
  13520. }
  13521. if (language) {
  13522. options.language = language
  13523. }
  13524. options.tech = self
  13525. var track = new _tracksTextTrack2['default'](options)
  13526. tracks.addTrack_(track)
  13527. return track
  13528. }
  13529. Tech.prototype.featuresVolumeControl = true
  13530. // Resizing plugins using request fullscreen reloads the plugin
  13531. Tech.prototype.featuresFullscreenResize = false
  13532. Tech.prototype.featuresPlaybackRate = false
  13533. // Optional events that we can manually mimic with timers
  13534. // currently not triggered by video-js-swf
  13535. Tech.prototype.featuresProgressEvents = false
  13536. Tech.prototype.featuresTimeupdateEvents = false
  13537. Tech.prototype.featuresNativeTextTracks = false
  13538. /*
  13539. * A functional mixin for techs that want to use the Source Handler pattern.
  13540. *
  13541. * ##### EXAMPLE:
  13542. *
  13543. * Tech.withSourceHandlers.call(MyTech);
  13544. *
  13545. */
  13546. Tech.withSourceHandlers = function(_Tech) {
  13547. /*
  13548. * Register a source handler
  13549. * Source handlers are scripts for handling specific formats.
  13550. * The source handler pattern is used for adaptive formats (HLS, DASH) that
  13551. * manually load video data and feed it into a Source Buffer (Media Source Extensions)
  13552. * @param {Function} handler The source handler
  13553. * @param {Boolean} first Register it before any existing handlers
  13554. */
  13555. _Tech.registerSourceHandler = function(handler, index) {
  13556. var handlers = _Tech.sourceHandlers
  13557. if (!handlers) {
  13558. handlers = _Tech.sourceHandlers = []
  13559. }
  13560. if (index === undefined) {
  13561. // add to the end of the list
  13562. index = handlers.length
  13563. }
  13564. handlers.splice(index, 0, handler)
  13565. }
  13566. /*
  13567. * Check if the tech can support the given type
  13568. * @param {String} type The mimetype to check
  13569. * @return {String} 'probably', 'maybe', or '' (empty string)
  13570. */
  13571. _Tech.canPlayType = function(type) {
  13572. var handlers = _Tech.sourceHandlers || []
  13573. var can = undefined
  13574. for (var i = 0; i < handlers.length; i++) {
  13575. can = handlers[i].canPlayType(type)
  13576. if (can) {
  13577. return can
  13578. }
  13579. }
  13580. return ''
  13581. }
  13582. /*
  13583. * Return the first source handler that supports the source
  13584. * TODO: Answer question: should 'probably' be prioritized over 'maybe'
  13585. * @param {Object} source The source object
  13586. * @returns {Object} The first source handler that supports the source
  13587. * @returns {null} Null if no source handler is found
  13588. */
  13589. _Tech.selectSourceHandler = function(source) {
  13590. var handlers = _Tech.sourceHandlers || []
  13591. var can = undefined
  13592. for (var i = 0; i < handlers.length; i++) {
  13593. can = handlers[i].canHandleSource(source)
  13594. if (can) {
  13595. return handlers[i]
  13596. }
  13597. }
  13598. return null
  13599. }
  13600. /*
  13601. * Check if the tech can support the given source
  13602. * @param {Object} srcObj The source object
  13603. * @return {String} 'probably', 'maybe', or '' (empty string)
  13604. */
  13605. _Tech.canPlaySource = function(srcObj) {
  13606. var sh = _Tech.selectSourceHandler(srcObj)
  13607. if (sh) {
  13608. return sh.canHandleSource(srcObj)
  13609. }
  13610. return ''
  13611. }
  13612. /*
  13613. * When using a source handler, prefer its implementation of
  13614. * any function normally provided by the tech.
  13615. */
  13616. var deferrable = ['seekable', 'duration']
  13617. deferrable.forEach(function(fnName) {
  13618. var originalFn = this[fnName]
  13619. if (typeof originalFn !== 'function') {
  13620. return
  13621. }
  13622. this[fnName] = function() {
  13623. if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
  13624. return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments)
  13625. }
  13626. return originalFn.apply(this, arguments)
  13627. }
  13628. }, _Tech.prototype)
  13629. /*
  13630. * Create a function for setting the source using a source object
  13631. * and source handlers.
  13632. * Should never be called unless a source handler was found.
  13633. * @param {Object} source A source object with src and type keys
  13634. * @return {Tech} self
  13635. */
  13636. _Tech.prototype.setSource = function(source) {
  13637. var sh = _Tech.selectSourceHandler(source)
  13638. if (!sh) {
  13639. // Fall back to a native source hander when unsupported sources are
  13640. // deliberately set
  13641. if (_Tech.nativeSourceHandler) {
  13642. sh = _Tech.nativeSourceHandler
  13643. } else {
  13644. _utilsLogJs2['default'].error('No source hander found for the current source.')
  13645. }
  13646. }
  13647. // Dispose any existing source handler
  13648. this.disposeSourceHandler()
  13649. this.off('dispose', this.disposeSourceHandler)
  13650. // if we have a source and get another one
  13651. // then we are loading something new
  13652. // than clear all of our current tracks
  13653. if (this.currentSource_) {
  13654. this.clearTracks(['audio', 'video'])
  13655. this.currentSource_ = null
  13656. }
  13657. if (sh !== _Tech.nativeSourceHandler) {
  13658. this.currentSource_ = source
  13659. // Catch if someone replaced the src without calling setSource.
  13660. // If they do, set currentSource_ to null and dispose our source handler.
  13661. this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_)
  13662. this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_)
  13663. this.one(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_)
  13664. }
  13665. this.sourceHandler_ = sh.handleSource(source, this, this.options_)
  13666. this.on('dispose', this.disposeSourceHandler)
  13667. return this
  13668. }
  13669. // On the first loadstart after setSource
  13670. _Tech.prototype.firstLoadStartListener_ = function() {
  13671. this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_)
  13672. }
  13673. // On successive loadstarts when setSource has not been called again
  13674. _Tech.prototype.successiveLoadStartListener_ = function() {
  13675. this.currentSource_ = null
  13676. this.disposeSourceHandler()
  13677. this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_)
  13678. }
  13679. /*
  13680. * Clean up any existing source handler
  13681. */
  13682. _Tech.prototype.disposeSourceHandler = function() {
  13683. if (this.sourceHandler_ && this.sourceHandler_.dispose) {
  13684. this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_)
  13685. this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_)
  13686. this.sourceHandler_.dispose()
  13687. }
  13688. }
  13689. }
  13690. _component2['default'].registerComponent('Tech', Tech)
  13691. // Old name for Tech
  13692. _component2['default'].registerComponent('MediaTechController', Tech)
  13693. Tech.registerTech('Tech', Tech)
  13694. exports['default'] = Tech
  13695. module.exports = exports['default']
  13696. }, { '../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) {
  13697. /**
  13698. * @file audio-track-list.js
  13699. */
  13700. 'use strict'
  13701. exports.__esModule = true
  13702. 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 } }
  13703. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  13704. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  13705. 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 }
  13706. var _trackList = _dereq_('./track-list')
  13707. var _trackList2 = _interopRequireDefault(_trackList)
  13708. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  13709. var browser = _interopRequireWildcard(_utilsBrowserJs)
  13710. var _globalDocument = _dereq_('global/document')
  13711. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  13712. /**
  13713. * anywhere we call this function we diverge from the spec
  13714. * as we only support one enabled audiotrack at a time
  13715. *
  13716. * @param {Array|AudioTrackList} list list to work on
  13717. * @param {AudioTrack} track the track to skip
  13718. */
  13719. var disableOthers = function disableOthers(list, track) {
  13720. for (var i = 0; i < list.length; i++) {
  13721. if (track.id === list[i].id) {
  13722. continue
  13723. }
  13724. // another audio track is enabled, disable it
  13725. list[i].enabled = false
  13726. }
  13727. }
  13728. /**
  13729. * A list of possible audio tracks. All functionality is in the
  13730. * base class Tracklist and the spec for AudioTrackList is located at:
  13731. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist
  13732. *
  13733. * interface AudioTrackList : EventTarget {
  13734. * readonly attribute unsigned long length;
  13735. * getter AudioTrack (unsigned long index);
  13736. * AudioTrack? getTrackById(DOMString id);
  13737. *
  13738. * attribute EventHandler onchange;
  13739. * attribute EventHandler onaddtrack;
  13740. * attribute EventHandler onremovetrack;
  13741. * };
  13742. *
  13743. * @param {AudioTrack[]} tracks a list of audio tracks to instantiate the list with
  13744. * @extends TrackList
  13745. * @class AudioTrackList
  13746. */
  13747. var AudioTrackList = (function(_TrackList) {
  13748. _inherits(AudioTrackList, _TrackList)
  13749. function AudioTrackList() {
  13750. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]
  13751. _classCallCheck(this, AudioTrackList)
  13752. var list = undefined
  13753. // make sure only 1 track is enabled
  13754. // sorted from last index to first index
  13755. for (var i = tracks.length - 1; i >= 0; i--) {
  13756. if (tracks[i].enabled) {
  13757. disableOthers(tracks, tracks[i])
  13758. break
  13759. }
  13760. }
  13761. // IE8 forces us to implement inheritance ourselves
  13762. // as it does not support Object.defineProperty properly
  13763. if (browser.IS_IE8) {
  13764. list = _globalDocument2['default'].createElement('custom')
  13765. for (var prop in _trackList2['default'].prototype) {
  13766. if (prop !== 'constructor') {
  13767. list[prop] = _trackList2['default'].prototype[prop]
  13768. }
  13769. }
  13770. for (var prop in AudioTrackList.prototype) {
  13771. if (prop !== 'constructor') {
  13772. list[prop] = AudioTrackList.prototype[prop]
  13773. }
  13774. }
  13775. }
  13776. list = _TrackList.call(this, tracks, list)
  13777. list.changing_ = false
  13778. return list
  13779. }
  13780. AudioTrackList.prototype.addTrack_ = function addTrack_(track) {
  13781. var _this = this
  13782. if (track.enabled) {
  13783. disableOthers(this, track)
  13784. }
  13785. _TrackList.prototype.addTrack_.call(this, track)
  13786. // native tracks don't have this
  13787. if (!track.addEventListener) {
  13788. return
  13789. }
  13790. track.addEventListener('enabledchange', function() {
  13791. // when we are disabling other tracks (since we don't support
  13792. // more than one track at a time) we will set changing_
  13793. // to true so that we don't trigger additional change events
  13794. if (_this.changing_) {
  13795. return
  13796. }
  13797. _this.changing_ = true
  13798. disableOthers(_this, track)
  13799. _this.changing_ = false
  13800. _this.trigger('change')
  13801. })
  13802. }
  13803. AudioTrackList.prototype.addTrack = function addTrack(track) {
  13804. this.addTrack_(track)
  13805. }
  13806. AudioTrackList.prototype.removeTrack = function removeTrack(track) {
  13807. _TrackList.prototype.removeTrack_.call(this, track)
  13808. }
  13809. return AudioTrackList
  13810. })(_trackList2['default'])
  13811. exports['default'] = AudioTrackList
  13812. module.exports = exports['default']
  13813. }, { '../utils/browser.js': 140, './track-list': 136, 'global/document': 1 }], 126: [function(_dereq_, module, exports) {
  13814. 'use strict'
  13815. exports.__esModule = true
  13816. 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 } }
  13817. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  13818. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  13819. 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 }
  13820. var _trackEnums = _dereq_('./track-enums')
  13821. var _track = _dereq_('./track')
  13822. var _track2 = _interopRequireDefault(_track)
  13823. var _utilsMergeOptions = _dereq_('../utils/merge-options')
  13824. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions)
  13825. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  13826. var browser = _interopRequireWildcard(_utilsBrowserJs)
  13827. /**
  13828. * A single audio text track as defined in:
  13829. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack
  13830. *
  13831. * interface AudioTrack {
  13832. * readonly attribute DOMString id;
  13833. * readonly attribute DOMString kind;
  13834. * readonly attribute DOMString label;
  13835. * readonly attribute DOMString language;
  13836. * attribute boolean enabled;
  13837. * };
  13838. *
  13839. * @param {Object=} options Object of option names and values
  13840. * @class AudioTrack
  13841. */
  13842. var AudioTrack = (function(_Track) {
  13843. _inherits(AudioTrack, _Track)
  13844. function AudioTrack() {
  13845. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  13846. _classCallCheck(this, AudioTrack)
  13847. var settings = _utilsMergeOptions2['default'](options, {
  13848. kind: _trackEnums.AudioTrackKind[options.kind] || ''
  13849. })
  13850. // on IE8 this will be a document element
  13851. // for every other browser this will be a normal object
  13852. var track = _Track.call(this, settings)
  13853. var enabled = false
  13854. if (browser.IS_IE8) {
  13855. for (var prop in AudioTrack.prototype) {
  13856. if (prop !== 'constructor') {
  13857. track[prop] = AudioTrack.prototype[prop]
  13858. }
  13859. }
  13860. }
  13861. Object.defineProperty(track, 'enabled', {
  13862. get: function get() {
  13863. return enabled
  13864. },
  13865. set: function set(newEnabled) {
  13866. // an invalid or unchanged value
  13867. if (typeof newEnabled !== 'boolean' || newEnabled === enabled) {
  13868. return
  13869. }
  13870. enabled = newEnabled
  13871. this.trigger('enabledchange')
  13872. }
  13873. })
  13874. // if the user sets this track to selected then
  13875. // set selected to that true value otherwise
  13876. // we keep it false
  13877. if (settings.enabled) {
  13878. track.enabled = settings.enabled
  13879. }
  13880. track.loaded_ = true
  13881. return track
  13882. }
  13883. return AudioTrack
  13884. })(_track2['default'])
  13885. exports['default'] = AudioTrack
  13886. module.exports = exports['default']
  13887. }, { '../utils/browser.js': 140, '../utils/merge-options': 149, './track': 137, './track-enums': 135 }], 127: [function(_dereq_, module, exports) {
  13888. /**
  13889. * @file html-track-element-list.js
  13890. */
  13891. 'use strict'
  13892. exports.__esModule = true
  13893. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  13894. 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 } }
  13895. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  13896. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  13897. var browser = _interopRequireWildcard(_utilsBrowserJs)
  13898. var _globalDocument = _dereq_('global/document')
  13899. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  13900. var HtmlTrackElementList = (function() {
  13901. function HtmlTrackElementList() {
  13902. var trackElements = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]
  13903. _classCallCheck(this, HtmlTrackElementList)
  13904. var list = this
  13905. if (browser.IS_IE8) {
  13906. list = _globalDocument2['default'].createElement('custom')
  13907. for (var prop in HtmlTrackElementList.prototype) {
  13908. if (prop !== 'constructor') {
  13909. list[prop] = HtmlTrackElementList.prototype[prop]
  13910. }
  13911. }
  13912. }
  13913. list.trackElements_ = []
  13914. Object.defineProperty(list, 'length', {
  13915. get: function get() {
  13916. return this.trackElements_.length
  13917. }
  13918. })
  13919. for (var i = 0, _length = trackElements.length; i < _length; i++) {
  13920. list.addTrackElement_(trackElements[i])
  13921. }
  13922. if (browser.IS_IE8) {
  13923. return list
  13924. }
  13925. }
  13926. HtmlTrackElementList.prototype.addTrackElement_ = function addTrackElement_(trackElement) {
  13927. this.trackElements_.push(trackElement)
  13928. }
  13929. HtmlTrackElementList.prototype.getTrackElementByTrack_ = function getTrackElementByTrack_(track) {
  13930. var trackElement_ = undefined
  13931. for (var i = 0, _length2 = this.trackElements_.length; i < _length2; i++) {
  13932. if (track === this.trackElements_[i].track) {
  13933. trackElement_ = this.trackElements_[i]
  13934. break
  13935. }
  13936. }
  13937. return trackElement_
  13938. }
  13939. HtmlTrackElementList.prototype.removeTrackElement_ = function removeTrackElement_(trackElement) {
  13940. for (var i = 0, _length3 = this.trackElements_.length; i < _length3; i++) {
  13941. if (trackElement === this.trackElements_[i]) {
  13942. this.trackElements_.splice(i, 1)
  13943. break
  13944. }
  13945. }
  13946. }
  13947. return HtmlTrackElementList
  13948. })()
  13949. exports['default'] = HtmlTrackElementList
  13950. module.exports = exports['default']
  13951. }, { '../utils/browser.js': 140, 'global/document': 1 }], 128: [function(_dereq_, module, exports) {
  13952. /**
  13953. * @file html-track-element.js
  13954. */
  13955. 'use strict'
  13956. exports.__esModule = true
  13957. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  13958. 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 } }
  13959. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  13960. 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 }
  13961. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  13962. var browser = _interopRequireWildcard(_utilsBrowserJs)
  13963. var _globalDocument = _dereq_('global/document')
  13964. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  13965. var _eventTarget = _dereq_('../event-target')
  13966. var _eventTarget2 = _interopRequireDefault(_eventTarget)
  13967. var _tracksTextTrack = _dereq_('../tracks/text-track')
  13968. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack)
  13969. var NONE = 0
  13970. var LOADING = 1
  13971. var LOADED = 2
  13972. var ERROR = 3
  13973. /**
  13974. * https://html.spec.whatwg.org/multipage/embedded-content.html#htmltrackelement
  13975. *
  13976. * interface HTMLTrackElement : HTMLElement {
  13977. * attribute DOMString kind;
  13978. * attribute DOMString src;
  13979. * attribute DOMString srclang;
  13980. * attribute DOMString label;
  13981. * attribute boolean default;
  13982. *
  13983. * const unsigned short NONE = 0;
  13984. * const unsigned short LOADING = 1;
  13985. * const unsigned short LOADED = 2;
  13986. * const unsigned short ERROR = 3;
  13987. * readonly attribute unsigned short readyState;
  13988. *
  13989. * readonly attribute TextTrack track;
  13990. * };
  13991. *
  13992. * @param {Object} options TextTrack configuration
  13993. * @class HTMLTrackElement
  13994. */
  13995. var HTMLTrackElement = (function(_EventTarget) {
  13996. _inherits(HTMLTrackElement, _EventTarget)
  13997. function HTMLTrackElement() {
  13998. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  13999. _classCallCheck(this, HTMLTrackElement)
  14000. _EventTarget.call(this)
  14001. var readyState = undefined
  14002. var trackElement = this
  14003. if (browser.IS_IE8) {
  14004. trackElement = _globalDocument2['default'].createElement('custom')
  14005. for (var prop in HTMLTrackElement.prototype) {
  14006. if (prop !== 'constructor') {
  14007. trackElement[prop] = HTMLTrackElement.prototype[prop]
  14008. }
  14009. }
  14010. }
  14011. var track = new _tracksTextTrack2['default'](options)
  14012. trackElement.kind = track.kind
  14013. trackElement.src = track.src
  14014. trackElement.srclang = track.language
  14015. trackElement.label = track.label
  14016. trackElement['default'] = track['default']
  14017. Object.defineProperty(trackElement, 'readyState', {
  14018. get: function get() {
  14019. return readyState
  14020. }
  14021. })
  14022. Object.defineProperty(trackElement, 'track', {
  14023. get: function get() {
  14024. return track
  14025. }
  14026. })
  14027. readyState = NONE
  14028. track.addEventListener('loadeddata', function() {
  14029. readyState = LOADED
  14030. trackElement.trigger({
  14031. type: 'load',
  14032. target: trackElement
  14033. })
  14034. })
  14035. if (browser.IS_IE8) {
  14036. return trackElement
  14037. }
  14038. }
  14039. return HTMLTrackElement
  14040. })(_eventTarget2['default'])
  14041. HTMLTrackElement.prototype.allowedEvents_ = {
  14042. load: 'load'
  14043. }
  14044. HTMLTrackElement.NONE = NONE
  14045. HTMLTrackElement.LOADING = LOADING
  14046. HTMLTrackElement.LOADED = LOADED
  14047. HTMLTrackElement.ERROR = ERROR
  14048. exports['default'] = HTMLTrackElement
  14049. module.exports = exports['default']
  14050. }, { '../event-target': 104, '../tracks/text-track': 134, '../utils/browser.js': 140, 'global/document': 1 }], 129: [function(_dereq_, module, exports) {
  14051. /**
  14052. * @file text-track-cue-list.js
  14053. */
  14054. 'use strict'
  14055. exports.__esModule = true
  14056. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  14057. 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 } }
  14058. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  14059. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  14060. var browser = _interopRequireWildcard(_utilsBrowserJs)
  14061. var _globalDocument = _dereq_('global/document')
  14062. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  14063. /**
  14064. * A List of text track cues as defined in:
  14065. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist
  14066. *
  14067. * interface TextTrackCueList {
  14068. * readonly attribute unsigned long length;
  14069. * getter TextTrackCue (unsigned long index);
  14070. * TextTrackCue? getCueById(DOMString id);
  14071. * };
  14072. *
  14073. * @param {Array} cues A list of cues to be initialized with
  14074. * @class TextTrackCueList
  14075. */
  14076. var TextTrackCueList = (function() {
  14077. function TextTrackCueList(cues) {
  14078. _classCallCheck(this, TextTrackCueList)
  14079. var list = this
  14080. if (browser.IS_IE8) {
  14081. list = _globalDocument2['default'].createElement('custom')
  14082. for (var prop in TextTrackCueList.prototype) {
  14083. if (prop !== 'constructor') {
  14084. list[prop] = TextTrackCueList.prototype[prop]
  14085. }
  14086. }
  14087. }
  14088. TextTrackCueList.prototype.setCues_.call(list, cues)
  14089. Object.defineProperty(list, 'length', {
  14090. get: function get() {
  14091. return this.length_
  14092. }
  14093. })
  14094. if (browser.IS_IE8) {
  14095. return list
  14096. }
  14097. }
  14098. /**
  14099. * A setter for cues in this list
  14100. *
  14101. * @param {Array} cues an array of cues
  14102. * @method setCues_
  14103. * @private
  14104. */
  14105. TextTrackCueList.prototype.setCues_ = function setCues_(cues) {
  14106. var oldLength = this.length || 0
  14107. var i = 0
  14108. var l = cues.length
  14109. this.cues_ = cues
  14110. this.length_ = cues.length
  14111. var defineProp = function defineProp(index) {
  14112. if (!('' + index in this)) {
  14113. Object.defineProperty(this, '' + index, {
  14114. get: function get() {
  14115. return this.cues_[index]
  14116. }
  14117. })
  14118. }
  14119. }
  14120. if (oldLength < l) {
  14121. i = oldLength
  14122. for (; i < l; i++) {
  14123. defineProp.call(this, i)
  14124. }
  14125. }
  14126. }
  14127. /**
  14128. * Get a cue that is currently in the Cue list by id
  14129. *
  14130. * @param {String} id
  14131. * @method getCueById
  14132. * @return {Object} a single cue
  14133. */
  14134. TextTrackCueList.prototype.getCueById = function getCueById(id) {
  14135. var result = null
  14136. for (var i = 0, l = this.length; i < l; i++) {
  14137. var cue = this[i]
  14138. if (cue.id === id) {
  14139. result = cue
  14140. break
  14141. }
  14142. }
  14143. return result
  14144. }
  14145. return TextTrackCueList
  14146. })()
  14147. exports['default'] = TextTrackCueList
  14148. module.exports = exports['default']
  14149. }, { '../utils/browser.js': 140, 'global/document': 1 }], 130: [function(_dereq_, module, exports) {
  14150. /**
  14151. * @file text-track-display.js
  14152. */
  14153. 'use strict'
  14154. exports.__esModule = true
  14155. 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 } }
  14156. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  14157. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  14158. 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 }
  14159. var _component = _dereq_('../component')
  14160. var _component2 = _interopRequireDefault(_component)
  14161. var _menuMenuJs = _dereq_('../menu/menu.js')
  14162. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs)
  14163. var _menuMenuItemJs = _dereq_('../menu/menu-item.js')
  14164. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs)
  14165. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js')
  14166. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs)
  14167. var _utilsFnJs = _dereq_('../utils/fn.js')
  14168. var Fn = _interopRequireWildcard(_utilsFnJs)
  14169. var _globalDocument = _dereq_('global/document')
  14170. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  14171. var _globalWindow = _dereq_('global/window')
  14172. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  14173. var darkGray = '#222'
  14174. var lightGray = '#ccc'
  14175. var fontMap = {
  14176. monospace: 'monospace',
  14177. sansSerif: 'sans-serif',
  14178. serif: 'serif',
  14179. monospaceSansSerif: '"Andale Mono", "Lucida Console", monospace',
  14180. monospaceSerif: '"Courier New", monospace',
  14181. proportionalSansSerif: 'sans-serif',
  14182. proportionalSerif: 'serif',
  14183. casual: '"Comic Sans MS", Impact, fantasy',
  14184. script: '"Monotype Corsiva", cursive',
  14185. smallcaps: '"Andale Mono", "Lucida Console", monospace, sans-serif'
  14186. }
  14187. /**
  14188. * The component for displaying text track cues
  14189. *
  14190. * @param {Object} player Main Player
  14191. * @param {Object=} options Object of option names and values
  14192. * @param {Function=} ready Ready callback function
  14193. * @extends Component
  14194. * @class TextTrackDisplay
  14195. */
  14196. var TextTrackDisplay = (function(_Component) {
  14197. _inherits(TextTrackDisplay, _Component)
  14198. function TextTrackDisplay(player, options, ready) {
  14199. _classCallCheck(this, TextTrackDisplay)
  14200. _Component.call(this, player, options, ready)
  14201. player.on('loadstart', Fn.bind(this, this.toggleDisplay))
  14202. player.on('texttrackchange', Fn.bind(this, this.updateDisplay))
  14203. // This used to be called during player init, but was causing an error
  14204. // if a track should show by default and the display hadn't loaded yet.
  14205. // Should probably be moved to an external track loader when we support
  14206. // tracks that don't need a display.
  14207. player.ready(Fn.bind(this, function() {
  14208. if (player.tech_ && player.tech_['featuresNativeTextTracks']) {
  14209. this.hide()
  14210. return
  14211. }
  14212. player.on('fullscreenchange', Fn.bind(this, this.updateDisplay))
  14213. var tracks = this.options_.playerOptions['tracks'] || []
  14214. for (var i = 0; i < tracks.length; i++) {
  14215. var track = tracks[i]
  14216. this.player_.addRemoteTextTrack(track)
  14217. }
  14218. var modes = { 'captions': 1, 'subtitles': 1 }
  14219. var trackList = this.player_.textTracks()
  14220. var firstDesc = undefined
  14221. var firstCaptions = undefined
  14222. if (trackList) {
  14223. for (var i = 0; i < trackList.length; i++) {
  14224. var track = trackList[i]
  14225. if (track['default']) {
  14226. if (track.kind === 'descriptions' && !firstDesc) {
  14227. firstDesc = track
  14228. } else if (track.kind in modes && !firstCaptions) {
  14229. firstCaptions = track
  14230. }
  14231. }
  14232. }
  14233. // We want to show the first default track but captions and subtitles
  14234. // take precedence over descriptions.
  14235. // So, display the first default captions or subtitles track
  14236. // and otherwise the first default descriptions track.
  14237. if (firstCaptions) {
  14238. firstCaptions.mode = 'showing'
  14239. } else if (firstDesc) {
  14240. firstDesc.mode = 'showing'
  14241. }
  14242. }
  14243. }))
  14244. }
  14245. /**
  14246. * Add cue HTML to display
  14247. *
  14248. * @param {Number} color Hex number for color, like #f0e
  14249. * @param {Number} opacity Value for opacity,0.0 - 1.0
  14250. * @return {RGBAColor} In the form 'rgba(255, 0, 0, 0.3)'
  14251. * @method constructColor
  14252. */
  14253. /**
  14254. * Toggle display texttracks
  14255. *
  14256. * @method toggleDisplay
  14257. */
  14258. TextTrackDisplay.prototype.toggleDisplay = function toggleDisplay() {
  14259. if (this.player_.tech_ && this.player_.tech_['featuresNativeTextTracks']) {
  14260. this.hide()
  14261. } else {
  14262. this.show()
  14263. }
  14264. }
  14265. /**
  14266. * Create the component's DOM element
  14267. *
  14268. * @return {Element}
  14269. * @method createEl
  14270. */
  14271. TextTrackDisplay.prototype.createEl = function createEl() {
  14272. return _Component.prototype.createEl.call(this, 'div', {
  14273. className: 'vjs-text-track-display'
  14274. }, {
  14275. 'aria-live': 'assertive',
  14276. 'aria-atomic': 'true'
  14277. })
  14278. }
  14279. /**
  14280. * Clear display texttracks
  14281. *
  14282. * @method clearDisplay
  14283. */
  14284. TextTrackDisplay.prototype.clearDisplay = function clearDisplay() {
  14285. if (typeof _globalWindow2['default']['WebVTT'] === 'function') {
  14286. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], [], this.el_)
  14287. }
  14288. }
  14289. /**
  14290. * Update display texttracks
  14291. *
  14292. * @method updateDisplay
  14293. */
  14294. TextTrackDisplay.prototype.updateDisplay = function updateDisplay() {
  14295. var tracks = this.player_.textTracks()
  14296. this.clearDisplay()
  14297. if (!tracks) {
  14298. return
  14299. }
  14300. // Track display prioritization model: if multiple tracks are 'showing',
  14301. // display the first 'subtitles' or 'captions' track which is 'showing',
  14302. // otherwise display the first 'descriptions' track which is 'showing'
  14303. var descriptionsTrack = null
  14304. var captionsSubtitlesTrack = null
  14305. var i = tracks.length
  14306. while (i--) {
  14307. var track = tracks[i]
  14308. if (track['mode'] === 'showing') {
  14309. if (track['kind'] === 'descriptions') {
  14310. descriptionsTrack = track
  14311. } else {
  14312. captionsSubtitlesTrack = track
  14313. }
  14314. }
  14315. }
  14316. if (captionsSubtitlesTrack) {
  14317. this.updateForTrack(captionsSubtitlesTrack)
  14318. } else if (descriptionsTrack) {
  14319. this.updateForTrack(descriptionsTrack)
  14320. }
  14321. }
  14322. /**
  14323. * Add texttrack to texttrack list
  14324. *
  14325. * @param {TextTrackObject} track Texttrack object to be added to list
  14326. * @method updateForTrack
  14327. */
  14328. TextTrackDisplay.prototype.updateForTrack = function updateForTrack(track) {
  14329. if (typeof _globalWindow2['default']['WebVTT'] !== 'function' || !track['activeCues']) {
  14330. return
  14331. }
  14332. var overrides = this.player_['textTrackSettings'].getValues()
  14333. var cues = []
  14334. for (var _i = 0; _i < track['activeCues'].length; _i++) {
  14335. cues.push(track['activeCues'][_i])
  14336. }
  14337. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], cues, this.el_)
  14338. var i = cues.length
  14339. while (i--) {
  14340. var cue = cues[i]
  14341. if (!cue) {
  14342. continue
  14343. }
  14344. var cueDiv = cue.displayState
  14345. if (overrides.color) {
  14346. cueDiv.firstChild.style.color = overrides.color
  14347. }
  14348. if (overrides.textOpacity) {
  14349. tryUpdateStyle(cueDiv.firstChild, 'color', constructColor(overrides.color || '#fff', overrides.textOpacity))
  14350. }
  14351. if (overrides.backgroundColor) {
  14352. cueDiv.firstChild.style.backgroundColor = overrides.backgroundColor
  14353. }
  14354. if (overrides.backgroundOpacity) {
  14355. tryUpdateStyle(cueDiv.firstChild, 'backgroundColor', constructColor(overrides.backgroundColor || '#000', overrides.backgroundOpacity))
  14356. }
  14357. if (overrides.windowColor) {
  14358. if (overrides.windowOpacity) {
  14359. tryUpdateStyle(cueDiv, 'backgroundColor', constructColor(overrides.windowColor, overrides.windowOpacity))
  14360. } else {
  14361. cueDiv.style.backgroundColor = overrides.windowColor
  14362. }
  14363. }
  14364. if (overrides.edgeStyle) {
  14365. if (overrides.edgeStyle === 'dropshadow') {
  14366. cueDiv.firstChild.style.textShadow = '2px 2px 3px ' + darkGray + ', 2px 2px 4px ' + darkGray + ', 2px 2px 5px ' + darkGray
  14367. } else if (overrides.edgeStyle === 'raised') {
  14368. cueDiv.firstChild.style.textShadow = '1px 1px ' + darkGray + ', 2px 2px ' + darkGray + ', 3px 3px ' + darkGray
  14369. } else if (overrides.edgeStyle === 'depressed') {
  14370. cueDiv.firstChild.style.textShadow = '1px 1px ' + lightGray + ', 0 1px ' + lightGray + ', -1px -1px ' + darkGray + ', 0 -1px ' + darkGray
  14371. } else if (overrides.edgeStyle === 'uniform') {
  14372. cueDiv.firstChild.style.textShadow = '0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray
  14373. }
  14374. }
  14375. if (overrides.fontPercent && overrides.fontPercent !== 1) {
  14376. var fontSize = _globalWindow2['default'].parseFloat(cueDiv.style.fontSize)
  14377. cueDiv.style.fontSize = fontSize * overrides.fontPercent + 'px'
  14378. cueDiv.style.height = 'auto'
  14379. cueDiv.style.top = 'auto'
  14380. cueDiv.style.bottom = '2px'
  14381. }
  14382. if (overrides.fontFamily && overrides.fontFamily !== 'default') {
  14383. if (overrides.fontFamily === 'small-caps') {
  14384. cueDiv.firstChild.style.fontVariant = 'small-caps'
  14385. } else {
  14386. cueDiv.firstChild.style.fontFamily = fontMap[overrides.fontFamily]
  14387. }
  14388. }
  14389. }
  14390. }
  14391. return TextTrackDisplay
  14392. })(_component2['default'])
  14393. function constructColor(color, opacity) {
  14394. return 'rgba(' +
  14395. // color looks like "#f0e"
  14396. parseInt(color[1] + color[1], 16) + ',' + parseInt(color[2] + color[2], 16) + ',' + parseInt(color[3] + color[3], 16) + ',' + opacity + ')'
  14397. }
  14398. /**
  14399. * Try to update style
  14400. * Some style changes will throw an error, particularly in IE8. Those should be noops.
  14401. *
  14402. * @param {Element} el The element to be styles
  14403. * @param {CSSProperty} style The CSS property to be styled
  14404. * @param {CSSStyle} rule The actual style to be applied to the property
  14405. * @method tryUpdateStyle
  14406. */
  14407. function tryUpdateStyle(el, style, rule) {
  14408. //
  14409. try {
  14410. el.style[style] = rule
  14411. } catch (e) { }
  14412. }
  14413. _component2['default'].registerComponent('TextTrackDisplay', TextTrackDisplay)
  14414. exports['default'] = TextTrackDisplay
  14415. module.exports = exports['default']
  14416. }, { '../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) {
  14417. /**
  14418. * Utilities for capturing text track state and re-creating tracks
  14419. * based on a capture.
  14420. *
  14421. * @file text-track-list-converter.js
  14422. */
  14423. /**
  14424. * Examine a single text track and return a JSON-compatible javascript
  14425. * object that represents the text track's state.
  14426. * @param track {TextTrackObject} the text track to query
  14427. * @return {Object} a serializable javascript representation of the
  14428. * @private
  14429. */
  14430. 'use strict'
  14431. exports.__esModule = true
  14432. var trackToJson_ = function trackToJson_(track) {
  14433. var ret = ['kind', 'label', 'language', 'id', 'inBandMetadataTrackDispatchType', 'mode', 'src'].reduce(function(acc, prop, i) {
  14434. if (track[prop]) {
  14435. acc[prop] = track[prop]
  14436. }
  14437. return acc
  14438. }, {
  14439. cues: track.cues && Array.prototype.map.call(track.cues, function(cue) {
  14440. return {
  14441. startTime: cue.startTime,
  14442. endTime: cue.endTime,
  14443. text: cue.text,
  14444. id: cue.id
  14445. }
  14446. })
  14447. })
  14448. return ret
  14449. }
  14450. /**
  14451. * Examine a tech and return a JSON-compatible javascript array that
  14452. * represents the state of all text tracks currently configured. The
  14453. * return array is compatible with `jsonToTextTracks`.
  14454. * @param tech {tech} the tech object to query
  14455. * @return {Array} a serializable javascript representation of the
  14456. * @function textTracksToJson
  14457. */
  14458. var textTracksToJson = function textTracksToJson(tech) {
  14459. var trackEls = tech.$$('track')
  14460. var trackObjs = Array.prototype.map.call(trackEls, function(t) {
  14461. return t.track
  14462. })
  14463. var tracks = Array.prototype.map.call(trackEls, function(trackEl) {
  14464. var json = trackToJson_(trackEl.track)
  14465. if (trackEl.src) {
  14466. json.src = trackEl.src
  14467. }
  14468. return json
  14469. })
  14470. return tracks.concat(Array.prototype.filter.call(tech.textTracks(), function(track) {
  14471. return trackObjs.indexOf(track) === -1
  14472. }).map(trackToJson_))
  14473. }
  14474. /**
  14475. * Creates a set of remote text tracks on a tech based on an array of
  14476. * javascript text track representations.
  14477. * @param json {Array} an array of text track representation objects,
  14478. * like those that would be produced by `textTracksToJson`
  14479. * @param tech {tech} the tech to create text tracks on
  14480. * @function jsonToTextTracks
  14481. */
  14482. var jsonToTextTracks = function jsonToTextTracks(json, tech) {
  14483. json.forEach(function(track) {
  14484. var addedTrack = tech.addRemoteTextTrack(track).track
  14485. if (!track.src && track.cues) {
  14486. track.cues.forEach(function(cue) {
  14487. return addedTrack.addCue(cue)
  14488. })
  14489. }
  14490. })
  14491. return tech.textTracks()
  14492. }
  14493. exports['default'] = { textTracksToJson: textTracksToJson, jsonToTextTracks: jsonToTextTracks, trackToJson_: trackToJson_ }
  14494. module.exports = exports['default']
  14495. }, {}], 132: [function(_dereq_, module, exports) {
  14496. /**
  14497. * @file text-track-list.js
  14498. */
  14499. 'use strict'
  14500. exports.__esModule = true
  14501. 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 } }
  14502. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  14503. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  14504. 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 }
  14505. var _trackList = _dereq_('./track-list')
  14506. var _trackList2 = _interopRequireDefault(_trackList)
  14507. var _utilsFnJs = _dereq_('../utils/fn.js')
  14508. var Fn = _interopRequireWildcard(_utilsFnJs)
  14509. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  14510. var browser = _interopRequireWildcard(_utilsBrowserJs)
  14511. var _globalDocument = _dereq_('global/document')
  14512. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  14513. /**
  14514. * A list of possible text tracks. All functionality is in the
  14515. * base class TrackList. The spec for TextTrackList is located at:
  14516. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#texttracklist
  14517. *
  14518. * interface TextTrackList : EventTarget {
  14519. * readonly attribute unsigned long length;
  14520. * getter TextTrack (unsigned long index);
  14521. * TextTrack? getTrackById(DOMString id);
  14522. *
  14523. * attribute EventHandler onchange;
  14524. * attribute EventHandler onaddtrack;
  14525. * attribute EventHandler onremovetrack;
  14526. * };
  14527. *
  14528. * @param {TextTrack[]} tracks A list of tracks to initialize the list with
  14529. * @extends TrackList
  14530. * @class TextTrackList
  14531. */
  14532. var TextTrackList = (function(_TrackList) {
  14533. _inherits(TextTrackList, _TrackList)
  14534. function TextTrackList() {
  14535. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]
  14536. _classCallCheck(this, TextTrackList)
  14537. var list = undefined
  14538. // IE8 forces us to implement inheritance ourselves
  14539. // as it does not support Object.defineProperty properly
  14540. if (browser.IS_IE8) {
  14541. list = _globalDocument2['default'].createElement('custom')
  14542. for (var prop in _trackList2['default'].prototype) {
  14543. if (prop !== 'constructor') {
  14544. list[prop] = _trackList2['default'].prototype[prop]
  14545. }
  14546. }
  14547. for (var prop in TextTrackList.prototype) {
  14548. if (prop !== 'constructor') {
  14549. list[prop] = TextTrackList.prototype[prop]
  14550. }
  14551. }
  14552. }
  14553. list = _TrackList.call(this, tracks, list)
  14554. return list
  14555. }
  14556. TextTrackList.prototype.addTrack_ = function addTrack_(track) {
  14557. _TrackList.prototype.addTrack_.call(this, track)
  14558. track.addEventListener('modechange', Fn.bind(this, function() {
  14559. this.trigger('change')
  14560. }))
  14561. }
  14562. /**
  14563. * Remove TextTrack from TextTrackList
  14564. * NOTE: Be mindful of what is passed in as it may be a HTMLTrackElement
  14565. *
  14566. * @param {TextTrack} rtrack
  14567. * @method removeTrack_
  14568. * @private
  14569. */
  14570. TextTrackList.prototype.removeTrack_ = function removeTrack_(rtrack) {
  14571. var track = undefined
  14572. for (var i = 0, l = this.length; i < l; i++) {
  14573. if (this[i] === rtrack) {
  14574. track = this[i]
  14575. if (track.off) {
  14576. track.off()
  14577. }
  14578. this.tracks_.splice(i, 1)
  14579. break
  14580. }
  14581. }
  14582. if (!track) {
  14583. return
  14584. }
  14585. this.trigger({
  14586. track: track,
  14587. type: 'removetrack'
  14588. })
  14589. }
  14590. /**
  14591. * Get a TextTrack from TextTrackList by a tracks id
  14592. *
  14593. * @param {String} id - the id of the track to get
  14594. * @method getTrackById
  14595. * @return {TextTrack}
  14596. * @private
  14597. */
  14598. TextTrackList.prototype.getTrackById = function getTrackById(id) {
  14599. var result = null
  14600. for (var i = 0, l = this.length; i < l; i++) {
  14601. var track = this[i]
  14602. if (track.id === id) {
  14603. result = track
  14604. break
  14605. }
  14606. }
  14607. return result
  14608. }
  14609. return TextTrackList
  14610. })(_trackList2['default'])
  14611. exports['default'] = TextTrackList
  14612. module.exports = exports['default']
  14613. }, { '../utils/browser.js': 140, '../utils/fn.js': 145, './track-list': 136, 'global/document': 1 }], 133: [function(_dereq_, module, exports) {
  14614. /**
  14615. * @file text-track-settings.js
  14616. */
  14617. 'use strict'
  14618. exports.__esModule = true
  14619. 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 } }
  14620. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  14621. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  14622. 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 }
  14623. var _component = _dereq_('../component')
  14624. var _component2 = _interopRequireDefault(_component)
  14625. var _utilsEventsJs = _dereq_('../utils/events.js')
  14626. var Events = _interopRequireWildcard(_utilsEventsJs)
  14627. var _utilsFnJs = _dereq_('../utils/fn.js')
  14628. var Fn = _interopRequireWildcard(_utilsFnJs)
  14629. var _utilsLogJs = _dereq_('../utils/log.js')
  14630. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  14631. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple')
  14632. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple)
  14633. var _globalWindow = _dereq_('global/window')
  14634. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  14635. /**
  14636. * Manipulate settings of texttracks
  14637. *
  14638. * @param {Object} player Main Player
  14639. * @param {Object=} options Object of option names and values
  14640. * @extends Component
  14641. * @class TextTrackSettings
  14642. */
  14643. var TextTrackSettings = (function(_Component) {
  14644. _inherits(TextTrackSettings, _Component)
  14645. function TextTrackSettings(player, options) {
  14646. _classCallCheck(this, TextTrackSettings)
  14647. _Component.call(this, player, options)
  14648. this.hide()
  14649. // Grab `persistTextTrackSettings` from the player options if not passed in child options
  14650. if (options.persistTextTrackSettings === undefined) {
  14651. this.options_.persistTextTrackSettings = this.options_.playerOptions.persistTextTrackSettings
  14652. }
  14653. Events.on(this.$('.vjs-done-button'), 'click', Fn.bind(this, function() {
  14654. this.saveSettings()
  14655. this.hide()
  14656. }))
  14657. Events.on(this.$('.vjs-default-button'), 'click', Fn.bind(this, function() {
  14658. this.$('.vjs-fg-color > select').selectedIndex = 0
  14659. this.$('.vjs-bg-color > select').selectedIndex = 0
  14660. this.$('.window-color > select').selectedIndex = 0
  14661. this.$('.vjs-text-opacity > select').selectedIndex = 0
  14662. this.$('.vjs-bg-opacity > select').selectedIndex = 0
  14663. this.$('.vjs-window-opacity > select').selectedIndex = 0
  14664. this.$('.vjs-edge-style select').selectedIndex = 0
  14665. this.$('.vjs-font-family select').selectedIndex = 0
  14666. this.$('.vjs-font-percent select').selectedIndex = 2
  14667. this.updateDisplay()
  14668. }))
  14669. Events.on(this.$('.vjs-fg-color > select'), 'change', Fn.bind(this, this.updateDisplay))
  14670. Events.on(this.$('.vjs-bg-color > select'), 'change', Fn.bind(this, this.updateDisplay))
  14671. Events.on(this.$('.window-color > select'), 'change', Fn.bind(this, this.updateDisplay))
  14672. Events.on(this.$('.vjs-text-opacity > select'), 'change', Fn.bind(this, this.updateDisplay))
  14673. Events.on(this.$('.vjs-bg-opacity > select'), 'change', Fn.bind(this, this.updateDisplay))
  14674. Events.on(this.$('.vjs-window-opacity > select'), 'change', Fn.bind(this, this.updateDisplay))
  14675. Events.on(this.$('.vjs-font-percent select'), 'change', Fn.bind(this, this.updateDisplay))
  14676. Events.on(this.$('.vjs-edge-style select'), 'change', Fn.bind(this, this.updateDisplay))
  14677. Events.on(this.$('.vjs-font-family select'), 'change', Fn.bind(this, this.updateDisplay))
  14678. if (this.options_.persistTextTrackSettings) {
  14679. this.restoreSettings()
  14680. }
  14681. }
  14682. /**
  14683. * Create the component's DOM element
  14684. *
  14685. * @return {Element}
  14686. * @method createEl
  14687. */
  14688. TextTrackSettings.prototype.createEl = function createEl() {
  14689. return _Component.prototype.createEl.call(this, 'div', {
  14690. className: 'vjs-caption-settings vjs-modal-overlay',
  14691. innerHTML: captionOptionsMenuTemplate()
  14692. })
  14693. }
  14694. /**
  14695. * Get texttrack settings
  14696. * Settings are
  14697. * .vjs-edge-style
  14698. * .vjs-font-family
  14699. * .vjs-fg-color
  14700. * .vjs-text-opacity
  14701. * .vjs-bg-color
  14702. * .vjs-bg-opacity
  14703. * .window-color
  14704. * .vjs-window-opacity
  14705. *
  14706. * @return {Object}
  14707. * @method getValues
  14708. */
  14709. TextTrackSettings.prototype.getValues = function getValues() {
  14710. var textEdge = getSelectedOptionValue(this.$('.vjs-edge-style select'))
  14711. var fontFamily = getSelectedOptionValue(this.$('.vjs-font-family select'))
  14712. var fgColor = getSelectedOptionValue(this.$('.vjs-fg-color > select'))
  14713. var textOpacity = getSelectedOptionValue(this.$('.vjs-text-opacity > select'))
  14714. var bgColor = getSelectedOptionValue(this.$('.vjs-bg-color > select'))
  14715. var bgOpacity = getSelectedOptionValue(this.$('.vjs-bg-opacity > select'))
  14716. var windowColor = getSelectedOptionValue(this.$('.window-color > select'))
  14717. var windowOpacity = getSelectedOptionValue(this.$('.vjs-window-opacity > select'))
  14718. var fontPercent = _globalWindow2['default']['parseFloat'](getSelectedOptionValue(this.$('.vjs-font-percent > select')))
  14719. var result = {
  14720. 'backgroundOpacity': bgOpacity,
  14721. 'textOpacity': textOpacity,
  14722. 'windowOpacity': windowOpacity,
  14723. 'edgeStyle': textEdge,
  14724. 'fontFamily': fontFamily,
  14725. 'color': fgColor,
  14726. 'backgroundColor': bgColor,
  14727. 'windowColor': windowColor,
  14728. 'fontPercent': fontPercent
  14729. }
  14730. for (var _name in result) {
  14731. if (result[_name] === '' || result[_name] === 'none' || _name === 'fontPercent' && result[_name] === 1.00) {
  14732. delete result[_name]
  14733. }
  14734. }
  14735. return result
  14736. }
  14737. /**
  14738. * Set texttrack settings
  14739. * Settings are
  14740. * .vjs-edge-style
  14741. * .vjs-font-family
  14742. * .vjs-fg-color
  14743. * .vjs-text-opacity
  14744. * .vjs-bg-color
  14745. * .vjs-bg-opacity
  14746. * .window-color
  14747. * .vjs-window-opacity
  14748. *
  14749. * @param {Object} values Object with texttrack setting values
  14750. * @method setValues
  14751. */
  14752. TextTrackSettings.prototype.setValues = function setValues(values) {
  14753. setSelectedOption(this.$('.vjs-edge-style select'), values.edgeStyle)
  14754. setSelectedOption(this.$('.vjs-font-family select'), values.fontFamily)
  14755. setSelectedOption(this.$('.vjs-fg-color > select'), values.color)
  14756. setSelectedOption(this.$('.vjs-text-opacity > select'), values.textOpacity)
  14757. setSelectedOption(this.$('.vjs-bg-color > select'), values.backgroundColor)
  14758. setSelectedOption(this.$('.vjs-bg-opacity > select'), values.backgroundOpacity)
  14759. setSelectedOption(this.$('.window-color > select'), values.windowColor)
  14760. setSelectedOption(this.$('.vjs-window-opacity > select'), values.windowOpacity)
  14761. var fontPercent = values.fontPercent
  14762. if (fontPercent) {
  14763. fontPercent = fontPercent.toFixed(2)
  14764. }
  14765. setSelectedOption(this.$('.vjs-font-percent > select'), fontPercent)
  14766. }
  14767. /**
  14768. * Restore texttrack settings
  14769. *
  14770. * @method restoreSettings
  14771. */
  14772. TextTrackSettings.prototype.restoreSettings = function restoreSettings() {
  14773. var err = undefined
  14774. var values = undefined
  14775. try {
  14776. var _safeParseTuple = _safeJsonParseTuple2['default'](_globalWindow2['default'].localStorage.getItem('vjs-text-track-settings'))
  14777. err = _safeParseTuple[0]
  14778. values = _safeParseTuple[1]
  14779. if (err) {
  14780. _utilsLogJs2['default'].error(err)
  14781. }
  14782. } catch (e) {
  14783. _utilsLogJs2['default'].warn(e)
  14784. }
  14785. if (values) {
  14786. this.setValues(values)
  14787. }
  14788. }
  14789. /**
  14790. * Save texttrack settings to local storage
  14791. *
  14792. * @method saveSettings
  14793. */
  14794. TextTrackSettings.prototype.saveSettings = function saveSettings() {
  14795. if (!this.options_.persistTextTrackSettings) {
  14796. return
  14797. }
  14798. var values = this.getValues()
  14799. try {
  14800. if (Object.getOwnPropertyNames(values).length > 0) {
  14801. _globalWindow2['default'].localStorage.setItem('vjs-text-track-settings', JSON.stringify(values))
  14802. } else {
  14803. _globalWindow2['default'].localStorage.removeItem('vjs-text-track-settings')
  14804. }
  14805. } catch (e) {
  14806. _utilsLogJs2['default'].warn(e)
  14807. }
  14808. }
  14809. /**
  14810. * Update display of texttrack settings
  14811. *
  14812. * @method updateDisplay
  14813. */
  14814. TextTrackSettings.prototype.updateDisplay = function updateDisplay() {
  14815. var ttDisplay = this.player_.getChild('textTrackDisplay')
  14816. if (ttDisplay) {
  14817. ttDisplay.updateDisplay()
  14818. }
  14819. }
  14820. return TextTrackSettings
  14821. })(_component2['default'])
  14822. _component2['default'].registerComponent('TextTrackSettings', TextTrackSettings)
  14823. function getSelectedOptionValue(target) {
  14824. var selectedOption = undefined
  14825. // not all browsers support selectedOptions, so, fallback to options
  14826. if (target.selectedOptions) {
  14827. selectedOption = target.selectedOptions[0]
  14828. } else if (target.options) {
  14829. selectedOption = target.options[target.options.selectedIndex]
  14830. }
  14831. return selectedOption.value
  14832. }
  14833. function setSelectedOption(target, value) {
  14834. if (!value) {
  14835. return
  14836. }
  14837. var i = undefined
  14838. for (i = 0; i < target.options.length; i++) {
  14839. var option = target.options[i]
  14840. if (option.value === value) {
  14841. break
  14842. }
  14843. }
  14844. target.selectedIndex = i
  14845. }
  14846. function captionOptionsMenuTemplate() {
  14847. 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>'
  14848. return template
  14849. }
  14850. exports['default'] = TextTrackSettings
  14851. module.exports = exports['default']
  14852. }, { '../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) {
  14853. /**
  14854. * @file text-track.js
  14855. */
  14856. 'use strict'
  14857. exports.__esModule = true
  14858. 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 } }
  14859. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  14860. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  14861. 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 }
  14862. var _textTrackCueList = _dereq_('./text-track-cue-list')
  14863. var _textTrackCueList2 = _interopRequireDefault(_textTrackCueList)
  14864. var _utilsFnJs = _dereq_('../utils/fn.js')
  14865. var Fn = _interopRequireWildcard(_utilsFnJs)
  14866. var _trackEnums = _dereq_('./track-enums')
  14867. var _utilsLogJs = _dereq_('../utils/log.js')
  14868. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  14869. var _globalDocument = _dereq_('global/document')
  14870. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  14871. var _globalWindow = _dereq_('global/window')
  14872. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  14873. var _trackJs = _dereq_('./track.js')
  14874. var _trackJs2 = _interopRequireDefault(_trackJs)
  14875. var _utilsUrlJs = _dereq_('../utils/url.js')
  14876. var _xhr = _dereq_('xhr')
  14877. var _xhr2 = _interopRequireDefault(_xhr)
  14878. var _utilsMergeOptions = _dereq_('../utils/merge-options')
  14879. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions)
  14880. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  14881. var browser = _interopRequireWildcard(_utilsBrowserJs)
  14882. /**
  14883. * takes a webvtt file contents and parses it into cues
  14884. *
  14885. * @param {String} srcContent webVTT file contents
  14886. * @param {Track} track track to addcues to
  14887. */
  14888. var parseCues = function parseCues(srcContent, track) {
  14889. var parser = new _globalWindow2['default'].WebVTT.Parser(_globalWindow2['default'], _globalWindow2['default'].vttjs, _globalWindow2['default'].WebVTT.StringDecoder())
  14890. var errors = []
  14891. parser.oncue = function(cue) {
  14892. track.addCue(cue)
  14893. }
  14894. parser.onparsingerror = function(error) {
  14895. errors.push(error)
  14896. }
  14897. parser.onflush = function() {
  14898. track.trigger({
  14899. type: 'loadeddata',
  14900. target: track
  14901. })
  14902. }
  14903. parser.parse(srcContent)
  14904. if (errors.length > 0) {
  14905. if (console.groupCollapsed) {
  14906. console.groupCollapsed('Text Track parsing errors for ' + track.src)
  14907. }
  14908. errors.forEach(function(error) {
  14909. return _utilsLogJs2['default'].error(error)
  14910. })
  14911. if (console.groupEnd) {
  14912. console.groupEnd()
  14913. }
  14914. }
  14915. parser.flush()
  14916. }
  14917. /**
  14918. * load a track from a specifed url
  14919. *
  14920. * @param {String} src url to load track from
  14921. * @param {Track} track track to addcues to
  14922. */
  14923. var loadTrack = function loadTrack(src, track) {
  14924. var opts = {
  14925. uri: src
  14926. }
  14927. var crossOrigin = _utilsUrlJs.isCrossOrigin(src)
  14928. if (crossOrigin) {
  14929. opts.cors = crossOrigin
  14930. }
  14931. _xhr2['default'](opts, Fn.bind(this, function(err, response, responseBody) {
  14932. if (err) {
  14933. return _utilsLogJs2['default'].error(err, response)
  14934. }
  14935. track.loaded_ = true
  14936. // Make sure that vttjs has loaded, otherwise, wait till it finished loading
  14937. // NOTE: this is only used for the alt/video.novtt.js build
  14938. if (typeof _globalWindow2['default'].WebVTT !== 'function') {
  14939. if (track.tech_) {
  14940. (function() {
  14941. var loadHandler = function loadHandler() {
  14942. return parseCues(responseBody, track)
  14943. }
  14944. track.tech_.on('vttjsloaded', loadHandler)
  14945. track.tech_.on('vttjserror', function() {
  14946. _utilsLogJs2['default'].error('vttjs failed to load, stopping trying to process ' + track.src)
  14947. track.tech_.off('vttjsloaded', loadHandler)
  14948. })
  14949. })()
  14950. }
  14951. } else {
  14952. parseCues(responseBody, track)
  14953. }
  14954. }))
  14955. }
  14956. /**
  14957. * A single text track as defined in:
  14958. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrack
  14959. *
  14960. * interface TextTrack : EventTarget {
  14961. * readonly attribute TextTrackKind kind;
  14962. * readonly attribute DOMString label;
  14963. * readonly attribute DOMString language;
  14964. *
  14965. * readonly attribute DOMString id;
  14966. * readonly attribute DOMString inBandMetadataTrackDispatchType;
  14967. *
  14968. * attribute TextTrackMode mode;
  14969. *
  14970. * readonly attribute TextTrackCueList? cues;
  14971. * readonly attribute TextTrackCueList? activeCues;
  14972. *
  14973. * void addCue(TextTrackCue cue);
  14974. * void removeCue(TextTrackCue cue);
  14975. *
  14976. * attribute EventHandler oncuechange;
  14977. * };
  14978. *
  14979. * @param {Object=} options Object of option names and values
  14980. * @extends Track
  14981. * @class TextTrack
  14982. */
  14983. var TextTrack = (function(_Track) {
  14984. _inherits(TextTrack, _Track)
  14985. function TextTrack() {
  14986. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  14987. _classCallCheck(this, TextTrack)
  14988. if (!options.tech) {
  14989. throw new Error('A tech was not provided.')
  14990. }
  14991. var settings = _utilsMergeOptions2['default'](options, {
  14992. kind: _trackEnums.TextTrackKind[options.kind] || 'subtitles',
  14993. language: options.language || options.srclang || ''
  14994. })
  14995. var mode = _trackEnums.TextTrackMode[settings.mode] || 'disabled'
  14996. var default_ = settings['default']
  14997. if (settings.kind === 'metadata' || settings.kind === 'chapters') {
  14998. mode = 'hidden'
  14999. }
  15000. // on IE8 this will be a document element
  15001. // for every other browser this will be a normal object
  15002. var tt = _Track.call(this, settings)
  15003. tt.tech_ = settings.tech
  15004. if (browser.IS_IE8) {
  15005. for (var prop in TextTrack.prototype) {
  15006. if (prop !== 'constructor') {
  15007. tt[prop] = TextTrack.prototype[prop]
  15008. }
  15009. }
  15010. }
  15011. tt.cues_ = []
  15012. tt.activeCues_ = []
  15013. var cues = new _textTrackCueList2['default'](tt.cues_)
  15014. var activeCues = new _textTrackCueList2['default'](tt.activeCues_)
  15015. var changed = false
  15016. var timeupdateHandler = Fn.bind(tt, function() {
  15017. this.activeCues
  15018. if (changed) {
  15019. this.trigger('cuechange')
  15020. changed = false
  15021. }
  15022. })
  15023. if (mode !== 'disabled') {
  15024. tt.tech_.on('timeupdate', timeupdateHandler)
  15025. }
  15026. Object.defineProperty(tt, 'default', {
  15027. get: function get() {
  15028. return default_
  15029. },
  15030. set: function set() { }
  15031. })
  15032. Object.defineProperty(tt, 'mode', {
  15033. get: function get() {
  15034. return mode
  15035. },
  15036. set: function set(newMode) {
  15037. if (!_trackEnums.TextTrackMode[newMode]) {
  15038. return
  15039. }
  15040. mode = newMode
  15041. if (mode === 'showing') {
  15042. this.tech_.on('timeupdate', timeupdateHandler)
  15043. }
  15044. this.trigger('modechange')
  15045. }
  15046. })
  15047. Object.defineProperty(tt, 'cues', {
  15048. get: function get() {
  15049. if (!this.loaded_) {
  15050. return null
  15051. }
  15052. return cues
  15053. },
  15054. set: function set() { }
  15055. })
  15056. Object.defineProperty(tt, 'activeCues', {
  15057. get: function get() {
  15058. if (!this.loaded_) {
  15059. return null
  15060. }
  15061. // nothing to do
  15062. if (this.cues.length === 0) {
  15063. return activeCues
  15064. }
  15065. var ct = this.tech_.currentTime()
  15066. var active = []
  15067. for (var i = 0, l = this.cues.length; i < l; i++) {
  15068. var cue = this.cues[i]
  15069. if (cue.startTime <= ct && cue.endTime >= ct) {
  15070. active.push(cue)
  15071. } else if (cue.startTime === cue.endTime && cue.startTime <= ct && cue.startTime + 0.5 >= ct) {
  15072. active.push(cue)
  15073. }
  15074. }
  15075. changed = false
  15076. if (active.length !== this.activeCues_.length) {
  15077. changed = true
  15078. } else {
  15079. for (var i = 0; i < active.length; i++) {
  15080. if (this.activeCues_.indexOf(active[i]) === -1) {
  15081. changed = true
  15082. }
  15083. }
  15084. }
  15085. this.activeCues_ = active
  15086. activeCues.setCues_(this.activeCues_)
  15087. return activeCues
  15088. },
  15089. set: function set() { }
  15090. })
  15091. if (settings.src) {
  15092. tt.src = settings.src
  15093. loadTrack(settings.src, tt)
  15094. } else {
  15095. tt.loaded_ = true
  15096. }
  15097. return tt
  15098. }
  15099. /**
  15100. * cuechange - One or more cues in the track have become active or stopped being active.
  15101. */
  15102. /**
  15103. * add a cue to the internal list of cues
  15104. *
  15105. * @param {Object} cue the cue to add to our internal list
  15106. * @method addCue
  15107. */
  15108. TextTrack.prototype.addCue = function addCue(cue) {
  15109. var tracks = this.tech_.textTracks()
  15110. if (tracks) {
  15111. for (var i = 0; i < tracks.length; i++) {
  15112. if (tracks[i] !== this) {
  15113. tracks[i].removeCue(cue)
  15114. }
  15115. }
  15116. }
  15117. this.cues_.push(cue)
  15118. this.cues.setCues_(this.cues_)
  15119. }
  15120. /**
  15121. * remvoe a cue from our internal list
  15122. *
  15123. * @param {Object} removeCue the cue to remove from our internal list
  15124. * @method removeCue
  15125. */
  15126. TextTrack.prototype.removeCue = function removeCue(_removeCue) {
  15127. var removed = false
  15128. for (var i = 0, l = this.cues_.length; i < l; i++) {
  15129. var cue = this.cues_[i]
  15130. if (cue === _removeCue) {
  15131. this.cues_.splice(i, 1)
  15132. removed = true
  15133. }
  15134. }
  15135. if (removed) {
  15136. this.cues.setCues_(this.cues_)
  15137. }
  15138. }
  15139. return TextTrack
  15140. })(_trackJs2['default'])
  15141. TextTrack.prototype.allowedEvents_ = {
  15142. cuechange: 'cuechange'
  15143. }
  15144. exports['default'] = TextTrack
  15145. module.exports = exports['default']
  15146. }, { '../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) {
  15147. /**
  15148. * @file track-kinds.js
  15149. */
  15150. /**
  15151. * https://html.spec.whatwg.org/multipage/embedded-content.html#dom-videotrack-kind
  15152. *
  15153. * enum VideoTrackKind {
  15154. * "alternative",
  15155. * "captions",
  15156. * "main",
  15157. * "sign",
  15158. * "subtitles",
  15159. * "commentary",
  15160. * "",
  15161. * };
  15162. */
  15163. 'use strict'
  15164. exports.__esModule = true
  15165. var VideoTrackKind = {
  15166. alternative: 'alternative',
  15167. captions: 'captions',
  15168. main: 'main',
  15169. sign: 'sign',
  15170. subtitles: 'subtitles',
  15171. commentary: 'commentary'
  15172. }
  15173. /**
  15174. * https://html.spec.whatwg.org/multipage/embedded-content.html#dom-audiotrack-kind
  15175. *
  15176. * enum AudioTrackKind {
  15177. * "alternative",
  15178. * "descriptions",
  15179. * "main",
  15180. * "main-desc",
  15181. * "translation",
  15182. * "commentary",
  15183. * "",
  15184. * };
  15185. */
  15186. var AudioTrackKind = {
  15187. alternative: 'alternative',
  15188. descriptions: 'descriptions',
  15189. main: 'main',
  15190. 'main-desc': 'main-desc',
  15191. translation: 'translation',
  15192. commentary: 'commentary'
  15193. }
  15194. /**
  15195. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackkind
  15196. *
  15197. * enum TextTrackKind {
  15198. * "subtitles",
  15199. * "captions",
  15200. * "descriptions",
  15201. * "chapters",
  15202. * "metadata"
  15203. * };
  15204. */
  15205. var TextTrackKind = {
  15206. subtitles: 'subtitles',
  15207. captions: 'captions',
  15208. descriptions: 'descriptions',
  15209. chapters: 'chapters',
  15210. metadata: 'metadata'
  15211. }
  15212. /**
  15213. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackmode
  15214. *
  15215. * enum TextTrackMode { "disabled", "hidden", "showing" };
  15216. */
  15217. var TextTrackMode = {
  15218. disabled: 'disabled',
  15219. hidden: 'hidden',
  15220. showing: 'showing'
  15221. }
  15222. /* jshint ignore:start */
  15223. // we ignore jshint here because it does not see
  15224. // AudioTrackKind as defined here
  15225. exports['default'] = { VideoTrackKind: VideoTrackKind, AudioTrackKind: AudioTrackKind, TextTrackKind: TextTrackKind, TextTrackMode: TextTrackMode }
  15226. /* jshint ignore:end */
  15227. module.exports = exports['default']
  15228. }, {}], 136: [function(_dereq_, module, exports) {
  15229. /**
  15230. * @file track-list.js
  15231. */
  15232. 'use strict'
  15233. exports.__esModule = true
  15234. 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 } }
  15235. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  15236. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  15237. 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 }
  15238. var _eventTarget = _dereq_('../event-target')
  15239. var _eventTarget2 = _interopRequireDefault(_eventTarget)
  15240. var _utilsFnJs = _dereq_('../utils/fn.js')
  15241. var Fn = _interopRequireWildcard(_utilsFnJs)
  15242. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  15243. var browser = _interopRequireWildcard(_utilsBrowserJs)
  15244. var _globalDocument = _dereq_('global/document')
  15245. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  15246. /**
  15247. * Common functionaliy between Text, Audio, and Video TrackLists
  15248. * Interfaces defined in the following spec:
  15249. * @link https://html.spec.whatwg.org/multipage/embedded-content.html
  15250. *
  15251. * @param {Track[]} tracks A list of tracks to initialize the list with
  15252. * @param {Object} list the child object with inheritance done manually for ie8
  15253. * @extends EventTarget
  15254. * @class TrackList
  15255. */
  15256. var TrackList = (function(_EventTarget) {
  15257. _inherits(TrackList, _EventTarget)
  15258. function TrackList() {
  15259. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]
  15260. var list = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]
  15261. _classCallCheck(this, TrackList)
  15262. _EventTarget.call(this)
  15263. if (!list) {
  15264. list = this
  15265. if (browser.IS_IE8) {
  15266. list = _globalDocument2['default'].createElement('custom')
  15267. for (var prop in TrackList.prototype) {
  15268. if (prop !== 'constructor') {
  15269. list[prop] = TrackList.prototype[prop]
  15270. }
  15271. }
  15272. }
  15273. }
  15274. list.tracks_ = []
  15275. Object.defineProperty(list, 'length', {
  15276. get: function get() {
  15277. return this.tracks_.length
  15278. }
  15279. })
  15280. for (var i = 0; i < tracks.length; i++) {
  15281. list.addTrack_(tracks[i])
  15282. }
  15283. return list
  15284. }
  15285. /**
  15286. * change - One or more tracks in the track list have been enabled or disabled.
  15287. * addtrack - A track has been added to the track list.
  15288. * removetrack - A track has been removed from the track list.
  15289. */
  15290. /**
  15291. * Add a Track from TrackList
  15292. *
  15293. * @param {Mixed} track
  15294. * @method addTrack_
  15295. * @private
  15296. */
  15297. TrackList.prototype.addTrack_ = function addTrack_(track) {
  15298. var index = this.tracks_.length
  15299. if (!('' + index in this)) {
  15300. Object.defineProperty(this, index, {
  15301. get: function get() {
  15302. return this.tracks_[index]
  15303. }
  15304. })
  15305. }
  15306. // Do not add duplicate tracks
  15307. if (this.tracks_.indexOf(track) === -1) {
  15308. this.tracks_.push(track)
  15309. this.trigger({
  15310. track: track,
  15311. type: 'addtrack'
  15312. })
  15313. }
  15314. }
  15315. /**
  15316. * Remove a Track from TrackList
  15317. *
  15318. * @param {Track} rtrack track to be removed
  15319. * @method removeTrack_
  15320. * @private
  15321. */
  15322. TrackList.prototype.removeTrack_ = function removeTrack_(rtrack) {
  15323. var track = undefined
  15324. for (var i = 0, l = this.length; i < l; i++) {
  15325. if (this[i] === rtrack) {
  15326. track = this[i]
  15327. if (track.off) {
  15328. track.off()
  15329. }
  15330. this.tracks_.splice(i, 1)
  15331. break
  15332. }
  15333. }
  15334. if (!track) {
  15335. return
  15336. }
  15337. this.trigger({
  15338. track: track,
  15339. type: 'removetrack'
  15340. })
  15341. }
  15342. /**
  15343. * Get a Track from the TrackList by a tracks id
  15344. *
  15345. * @param {String} id - the id of the track to get
  15346. * @method getTrackById
  15347. * @return {Track}
  15348. * @private
  15349. */
  15350. TrackList.prototype.getTrackById = function getTrackById(id) {
  15351. var result = null
  15352. for (var i = 0, l = this.length; i < l; i++) {
  15353. var track = this[i]
  15354. if (track.id === id) {
  15355. result = track
  15356. break
  15357. }
  15358. }
  15359. return result
  15360. }
  15361. return TrackList
  15362. })(_eventTarget2['default'])
  15363. TrackList.prototype.allowedEvents_ = {
  15364. change: 'change',
  15365. addtrack: 'addtrack',
  15366. removetrack: 'removetrack'
  15367. }
  15368. // emulate attribute EventHandler support to allow for feature detection
  15369. for (var _event in TrackList.prototype.allowedEvents_) {
  15370. TrackList.prototype['on' + _event] = null
  15371. }
  15372. exports['default'] = TrackList
  15373. module.exports = exports['default']
  15374. }, { '../event-target': 104, '../utils/browser.js': 140, '../utils/fn.js': 145, 'global/document': 1 }], 137: [function(_dereq_, module, exports) {
  15375. /**
  15376. * @file track.js
  15377. */
  15378. 'use strict'
  15379. exports.__esModule = true
  15380. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  15381. 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 } }
  15382. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  15383. 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 }
  15384. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  15385. var browser = _interopRequireWildcard(_utilsBrowserJs)
  15386. var _globalDocument = _dereq_('global/document')
  15387. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  15388. var _utilsGuidJs = _dereq_('../utils/guid.js')
  15389. var Guid = _interopRequireWildcard(_utilsGuidJs)
  15390. var _eventTarget = _dereq_('../event-target')
  15391. var _eventTarget2 = _interopRequireDefault(_eventTarget)
  15392. /**
  15393. * setup the common parts of an audio, video, or text track
  15394. * @link https://html.spec.whatwg.org/multipage/embedded-content.html
  15395. *
  15396. * @param {String} type The type of track we are dealing with audio|video|text
  15397. * @param {Object=} options Object of option names and values
  15398. * @extends EventTarget
  15399. * @class Track
  15400. */
  15401. var Track = (function(_EventTarget) {
  15402. _inherits(Track, _EventTarget)
  15403. function Track() {
  15404. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  15405. _classCallCheck(this, Track)
  15406. _EventTarget.call(this)
  15407. var track = this
  15408. if (browser.IS_IE8) {
  15409. track = _globalDocument2['default'].createElement('custom')
  15410. for (var prop in Track.prototype) {
  15411. if (prop !== 'constructor') {
  15412. track[prop] = Track.prototype[prop]
  15413. }
  15414. }
  15415. }
  15416. var trackProps = {
  15417. id: options.id || 'vjs_track_' + Guid.newGUID(),
  15418. kind: options.kind || '',
  15419. label: options.label || '',
  15420. language: options.language || ''
  15421. }
  15422. var _loop = function(key) {
  15423. Object.defineProperty(track, key, {
  15424. get: function get() {
  15425. return trackProps[key]
  15426. },
  15427. set: function set() { }
  15428. })
  15429. }
  15430. for (var key in trackProps) {
  15431. _loop(key)
  15432. }
  15433. return track
  15434. }
  15435. return Track
  15436. })(_eventTarget2['default'])
  15437. exports['default'] = Track
  15438. module.exports = exports['default']
  15439. }, { '../event-target': 104, '../utils/browser.js': 140, '../utils/guid.js': 147, 'global/document': 1 }], 138: [function(_dereq_, module, exports) {
  15440. /**
  15441. * @file video-track-list.js
  15442. */
  15443. 'use strict'
  15444. exports.__esModule = true
  15445. 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 } }
  15446. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  15447. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  15448. 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 }
  15449. var _trackList = _dereq_('./track-list')
  15450. var _trackList2 = _interopRequireDefault(_trackList)
  15451. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  15452. var browser = _interopRequireWildcard(_utilsBrowserJs)
  15453. var _globalDocument = _dereq_('global/document')
  15454. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  15455. /**
  15456. * disable other video tracks before selecting the new one
  15457. *
  15458. * @param {Array|VideoTrackList} list list to work on
  15459. * @param {VideoTrack} track the track to skip
  15460. */
  15461. var disableOthers = function disableOthers(list, track) {
  15462. for (var i = 0; i < list.length; i++) {
  15463. if (track.id === list[i].id) {
  15464. continue
  15465. }
  15466. // another audio track is enabled, disable it
  15467. list[i].selected = false
  15468. }
  15469. }
  15470. /**
  15471. * A list of possiblee video tracks. Most functionality is in the
  15472. * base class Tracklist and the spec for VideoTrackList is located at:
  15473. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist
  15474. *
  15475. * interface VideoTrackList : EventTarget {
  15476. * readonly attribute unsigned long length;
  15477. * getter VideoTrack (unsigned long index);
  15478. * VideoTrack? getTrackById(DOMString id);
  15479. * readonly attribute long selectedIndex;
  15480. *
  15481. * attribute EventHandler onchange;
  15482. * attribute EventHandler onaddtrack;
  15483. * attribute EventHandler onremovetrack;
  15484. * };
  15485. *
  15486. * @param {VideoTrack[]} tracks a list of video tracks to instantiate the list with
  15487. # @extends TrackList
  15488. * @class VideoTrackList
  15489. */
  15490. var VideoTrackList = (function(_TrackList) {
  15491. _inherits(VideoTrackList, _TrackList)
  15492. function VideoTrackList() {
  15493. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]
  15494. _classCallCheck(this, VideoTrackList)
  15495. var list = undefined
  15496. // make sure only 1 track is enabled
  15497. // sorted from last index to first index
  15498. for (var i = tracks.length - 1; i >= 0; i--) {
  15499. if (tracks[i].selected) {
  15500. disableOthers(tracks, tracks[i])
  15501. break
  15502. }
  15503. }
  15504. // IE8 forces us to implement inheritance ourselves
  15505. // as it does not support Object.defineProperty properly
  15506. if (browser.IS_IE8) {
  15507. list = _globalDocument2['default'].createElement('custom')
  15508. for (var prop in _trackList2['default'].prototype) {
  15509. if (prop !== 'constructor') {
  15510. list[prop] = _trackList2['default'].prototype[prop]
  15511. }
  15512. }
  15513. for (var prop in VideoTrackList.prototype) {
  15514. if (prop !== 'constructor') {
  15515. list[prop] = VideoTrackList.prototype[prop]
  15516. }
  15517. }
  15518. }
  15519. list = _TrackList.call(this, tracks, list)
  15520. list.changing_ = false
  15521. Object.defineProperty(list, 'selectedIndex', {
  15522. get: function get() {
  15523. for (var i = 0; i < this.length; i++) {
  15524. if (this[i].selected) {
  15525. return i
  15526. }
  15527. }
  15528. return -1
  15529. },
  15530. set: function set() { }
  15531. })
  15532. return list
  15533. }
  15534. VideoTrackList.prototype.addTrack_ = function addTrack_(track) {
  15535. var _this = this
  15536. if (track.selected) {
  15537. disableOthers(this, track)
  15538. }
  15539. _TrackList.prototype.addTrack_.call(this, track)
  15540. // native tracks don't have this
  15541. if (!track.addEventListener) {
  15542. return
  15543. }
  15544. track.addEventListener('selectedchange', function() {
  15545. if (_this.changing_) {
  15546. return
  15547. }
  15548. _this.changing_ = true
  15549. disableOthers(_this, track)
  15550. _this.changing_ = false
  15551. _this.trigger('change')
  15552. })
  15553. }
  15554. VideoTrackList.prototype.addTrack = function addTrack(track) {
  15555. this.addTrack_(track)
  15556. }
  15557. VideoTrackList.prototype.removeTrack = function removeTrack(track) {
  15558. _TrackList.prototype.removeTrack_.call(this, track)
  15559. }
  15560. return VideoTrackList
  15561. })(_trackList2['default'])
  15562. exports['default'] = VideoTrackList
  15563. module.exports = exports['default']
  15564. }, { '../utils/browser.js': 140, './track-list': 136, 'global/document': 1 }], 139: [function(_dereq_, module, exports) {
  15565. 'use strict'
  15566. exports.__esModule = true
  15567. 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 } }
  15568. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  15569. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function') } }
  15570. 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 }
  15571. var _trackEnums = _dereq_('./track-enums')
  15572. var _track = _dereq_('./track')
  15573. var _track2 = _interopRequireDefault(_track)
  15574. var _utilsMergeOptions = _dereq_('../utils/merge-options')
  15575. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions)
  15576. var _utilsBrowserJs = _dereq_('../utils/browser.js')
  15577. var browser = _interopRequireWildcard(_utilsBrowserJs)
  15578. /**
  15579. * A single video text track as defined in:
  15580. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotrack
  15581. *
  15582. * interface VideoTrack {
  15583. * readonly attribute DOMString id;
  15584. * readonly attribute DOMString kind;
  15585. * readonly attribute DOMString label;
  15586. * readonly attribute DOMString language;
  15587. * attribute boolean selected;
  15588. * };
  15589. *
  15590. * @param {Object=} options Object of option names and values
  15591. * @class VideoTrack
  15592. */
  15593. var VideoTrack = (function(_Track) {
  15594. _inherits(VideoTrack, _Track)
  15595. function VideoTrack() {
  15596. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]
  15597. _classCallCheck(this, VideoTrack)
  15598. var settings = _utilsMergeOptions2['default'](options, {
  15599. kind: _trackEnums.VideoTrackKind[options.kind] || ''
  15600. })
  15601. // on IE8 this will be a document element
  15602. // for every other browser this will be a normal object
  15603. var track = _Track.call(this, settings)
  15604. var selected = false
  15605. if (browser.IS_IE8) {
  15606. for (var prop in VideoTrack.prototype) {
  15607. if (prop !== 'constructor') {
  15608. track[prop] = VideoTrack.prototype[prop]
  15609. }
  15610. }
  15611. }
  15612. Object.defineProperty(track, 'selected', {
  15613. get: function get() {
  15614. return selected
  15615. },
  15616. set: function set(newSelected) {
  15617. // an invalid or unchanged value
  15618. if (typeof newSelected !== 'boolean' || newSelected === selected) {
  15619. return
  15620. }
  15621. selected = newSelected
  15622. this.trigger('selectedchange')
  15623. }
  15624. })
  15625. // if the user sets this track to selected then
  15626. // set selected to that true value otherwise
  15627. // we keep it false
  15628. if (settings.selected) {
  15629. track.selected = settings.selected
  15630. }
  15631. return track
  15632. }
  15633. return VideoTrack
  15634. })(_track2['default'])
  15635. exports['default'] = VideoTrack
  15636. module.exports = exports['default']
  15637. }, { '../utils/browser.js': 140, '../utils/merge-options': 149, './track': 137, './track-enums': 135 }], 140: [function(_dereq_, module, exports) {
  15638. /**
  15639. * @file browser.js
  15640. */
  15641. 'use strict'
  15642. exports.__esModule = true
  15643. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  15644. var _globalDocument = _dereq_('global/document')
  15645. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  15646. var _globalWindow = _dereq_('global/window')
  15647. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  15648. var USER_AGENT = _globalWindow2['default'].navigator.userAgent
  15649. var webkitVersionMap = /AppleWebKit\/([\d.]+)/i.exec(USER_AGENT)
  15650. var appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null
  15651. /*
  15652. * Device is an iPhone
  15653. *
  15654. * @type {Boolean}
  15655. * @constant
  15656. * @private
  15657. */
  15658. var IS_IPAD = /iPad/i.test(USER_AGENT)
  15659. exports.IS_IPAD = IS_IPAD
  15660. // The Facebook app's UIWebView identifies as both an iPhone and iPad, so
  15661. // to identify iPhones, we need to exclude iPads.
  15662. // http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/
  15663. var IS_IPHONE = /iPhone/i.test(USER_AGENT) && !IS_IPAD
  15664. exports.IS_IPHONE = IS_IPHONE
  15665. var IS_IPOD = /iPod/i.test(USER_AGENT)
  15666. exports.IS_IPOD = IS_IPOD
  15667. var IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD
  15668. exports.IS_IOS = IS_IOS
  15669. var IOS_VERSION = (function() {
  15670. var match = USER_AGENT.match(/OS (\d+)_/i)
  15671. if (match && match[1]) {
  15672. return match[1]
  15673. }
  15674. })()
  15675. exports.IOS_VERSION = IOS_VERSION
  15676. var IS_ANDROID = /Android/i.test(USER_AGENT)
  15677. exports.IS_ANDROID = IS_ANDROID
  15678. var ANDROID_VERSION = (function() {
  15679. // This matches Android Major.Minor.Patch versions
  15680. // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
  15681. var match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i)
  15682. var major
  15683. var minor
  15684. if (!match) {
  15685. return null
  15686. }
  15687. major = match[1] && parseFloat(match[1])
  15688. minor = match[2] && parseFloat(match[2])
  15689. if (major && minor) {
  15690. return parseFloat(match[1] + '.' + match[2])
  15691. } else if (major) {
  15692. return major
  15693. } else {
  15694. return null
  15695. }
  15696. })()
  15697. exports.ANDROID_VERSION = ANDROID_VERSION
  15698. // Old Android is defined as Version older than 2.3, and requiring a webkit version of the android browser
  15699. var IS_OLD_ANDROID = IS_ANDROID && /webkit/i.test(USER_AGENT) && ANDROID_VERSION < 2.3
  15700. exports.IS_OLD_ANDROID = IS_OLD_ANDROID
  15701. var IS_NATIVE_ANDROID = IS_ANDROID && ANDROID_VERSION < 5 && appleWebkitVersion < 537
  15702. exports.IS_NATIVE_ANDROID = IS_NATIVE_ANDROID
  15703. var IS_FIREFOX = /Firefox/i.test(USER_AGENT)
  15704. exports.IS_FIREFOX = IS_FIREFOX
  15705. var IS_EDGE = /Edge/i.test(USER_AGENT)
  15706. exports.IS_EDGE = IS_EDGE
  15707. var IS_CHROME = !IS_EDGE && /Chrome/i.test(USER_AGENT)
  15708. exports.IS_CHROME = IS_CHROME
  15709. var IS_IE8 = /MSIE\s8\.0/.test(USER_AGENT)
  15710. exports.IS_IE8 = IS_IE8
  15711. var TOUCH_ENABLED = !!('ontouchstart' in _globalWindow2['default'] || _globalWindow2['default'].DocumentTouch && _globalDocument2['default'] instanceof _globalWindow2['default'].DocumentTouch)
  15712. exports.TOUCH_ENABLED = TOUCH_ENABLED
  15713. var BACKGROUND_SIZE_SUPPORTED = ('backgroundSize' in _globalDocument2['default'].createElement('video').style)
  15714. exports.BACKGROUND_SIZE_SUPPORTED = BACKGROUND_SIZE_SUPPORTED
  15715. }, { 'global/document': 1, 'global/window': 2 }], 141: [function(_dereq_, module, exports) {
  15716. /**
  15717. * @file buffer.js
  15718. */
  15719. 'use strict'
  15720. exports.__esModule = true
  15721. exports.bufferedPercent = bufferedPercent
  15722. var _timeRangesJs = _dereq_('./time-ranges.js')
  15723. /**
  15724. * Compute how much your video has been buffered
  15725. *
  15726. * @param {Object} Buffered object
  15727. * @param {Number} Total duration
  15728. * @return {Number} Percent buffered of the total duration
  15729. * @private
  15730. * @function bufferedPercent
  15731. */
  15732. function bufferedPercent(buffered, duration) {
  15733. var bufferedDuration = 0
  15734. var start
  15735. var end
  15736. if (!duration) {
  15737. return 0
  15738. }
  15739. if (!buffered || !buffered.length) {
  15740. buffered = _timeRangesJs.createTimeRange(0, 0)
  15741. }
  15742. for (var i = 0; i < buffered.length; i++) {
  15743. start = buffered.start(i)
  15744. end = buffered.end(i)
  15745. // buffered end can be bigger than duration by a very small fraction
  15746. if (end > duration) {
  15747. end = duration
  15748. }
  15749. bufferedDuration += end - start
  15750. }
  15751. return bufferedDuration / duration
  15752. }
  15753. }, { './time-ranges.js': 151 }], 142: [function(_dereq_, module, exports) {
  15754. 'use strict'
  15755. exports.__esModule = true
  15756. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  15757. var _logJs = _dereq_('./log.js')
  15758. var _logJs2 = _interopRequireDefault(_logJs)
  15759. /**
  15760. * Object containing the default behaviors for available handler methods.
  15761. *
  15762. * @private
  15763. * @type {Object}
  15764. */
  15765. var defaultBehaviors = {
  15766. get: function get(obj, key) {
  15767. return obj[key]
  15768. },
  15769. set: function set(obj, key, value) {
  15770. obj[key] = value
  15771. return true
  15772. }
  15773. }
  15774. /**
  15775. * Expose private objects publicly using a Proxy to log deprecation warnings.
  15776. *
  15777. * Browsers that do not support Proxy objects will simply return the `target`
  15778. * object, so it can be directly exposed.
  15779. *
  15780. * @param {Object} target The target object.
  15781. * @param {Object} messages Messages to display from a Proxy. Only operations
  15782. * with an associated message will be proxied.
  15783. * @param {String} [messages.get]
  15784. * @param {String} [messages.set]
  15785. * @return {Object} A Proxy if supported or the `target` argument.
  15786. */
  15787. exports['default'] = function(target) {
  15788. var messages = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  15789. if (typeof Proxy === 'function') {
  15790. var _ret = (function() {
  15791. var handler = {}
  15792. // Build a handler object based on those keys that have both messages
  15793. // and default behaviors.
  15794. Object.keys(messages).forEach(function(key) {
  15795. if (defaultBehaviors.hasOwnProperty(key)) {
  15796. handler[key] = function() {
  15797. _logJs2['default'].warn(messages[key])
  15798. return defaultBehaviors[key].apply(this, arguments)
  15799. }
  15800. }
  15801. })
  15802. return {
  15803. v: new Proxy(target, handler)
  15804. }
  15805. })()
  15806. if (typeof _ret === 'object') return _ret.v
  15807. }
  15808. return target
  15809. }
  15810. module.exports = exports['default']
  15811. }, { './log.js': 148 }], 143: [function(_dereq_, module, exports) {
  15812. /**
  15813. * @file dom.js
  15814. */
  15815. 'use strict'
  15816. exports.__esModule = true
  15817. exports.getEl = getEl
  15818. exports.createEl = createEl
  15819. exports.textContent = textContent
  15820. exports.insertElFirst = insertElFirst
  15821. exports.getElData = getElData
  15822. exports.hasElData = hasElData
  15823. exports.removeElData = removeElData
  15824. exports.hasElClass = hasElClass
  15825. exports.addElClass = addElClass
  15826. exports.removeElClass = removeElClass
  15827. exports.toggleElClass = toggleElClass
  15828. exports.setElAttributes = setElAttributes
  15829. exports.getElAttributes = getElAttributes
  15830. exports.blockTextSelection = blockTextSelection
  15831. exports.unblockTextSelection = unblockTextSelection
  15832. exports.findElPosition = findElPosition
  15833. exports.getPointerPosition = getPointerPosition
  15834. exports.isEl = isEl
  15835. exports.isTextNode = isTextNode
  15836. exports.emptyEl = emptyEl
  15837. exports.normalizeContent = normalizeContent
  15838. exports.appendContent = appendContent
  15839. exports.insertContent = insertContent
  15840. 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 ', '.'])
  15841. 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 } }
  15842. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  15843. function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings }
  15844. var _globalDocument = _dereq_('global/document')
  15845. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  15846. var _globalWindow = _dereq_('global/window')
  15847. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  15848. var _guidJs = _dereq_('./guid.js')
  15849. var Guid = _interopRequireWildcard(_guidJs)
  15850. var _logJs = _dereq_('./log.js')
  15851. var _logJs2 = _interopRequireDefault(_logJs)
  15852. var _tsml = _dereq_('tsml')
  15853. var _tsml2 = _interopRequireDefault(_tsml)
  15854. /**
  15855. * Detect if a value is a string with any non-whitespace characters.
  15856. *
  15857. * @param {String} str
  15858. * @return {Boolean}
  15859. */
  15860. function isNonBlankString(str) {
  15861. return typeof str === 'string' && /\S/.test(str)
  15862. }
  15863. /**
  15864. * Throws an error if the passed string has whitespace. This is used by
  15865. * class methods to be relatively consistent with the classList API.
  15866. *
  15867. * @param {String} str
  15868. * @return {Boolean}
  15869. */
  15870. function throwIfWhitespace(str) {
  15871. if (/\s/.test(str)) {
  15872. throw new Error('class has illegal whitespace characters')
  15873. }
  15874. }
  15875. /**
  15876. * Produce a regular expression for matching a class name.
  15877. *
  15878. * @param {String} className
  15879. * @return {RegExp}
  15880. */
  15881. function classRegExp(className) {
  15882. return new RegExp('(^|\\s)' + className + '($|\\s)')
  15883. }
  15884. /**
  15885. * Creates functions to query the DOM using a given method.
  15886. *
  15887. * @function createQuerier
  15888. * @private
  15889. * @param {String} method
  15890. * @return {Function}
  15891. */
  15892. function createQuerier(method) {
  15893. return function(selector, context) {
  15894. if (!isNonBlankString(selector)) {
  15895. return _globalDocument2['default'][method](null)
  15896. }
  15897. if (isNonBlankString(context)) {
  15898. context = _globalDocument2['default'].querySelector(context)
  15899. }
  15900. return (isEl(context) ? context : _globalDocument2['default'])[method](selector)
  15901. }
  15902. }
  15903. /**
  15904. * Shorthand for document.getElementById()
  15905. * Also allows for CSS (jQuery) ID syntax. But nothing other than IDs.
  15906. *
  15907. * @param {String} id Element ID
  15908. * @return {Element} Element with supplied ID
  15909. * @function getEl
  15910. */
  15911. function getEl(id) {
  15912. if (id.indexOf('#') === 0) {
  15913. id = id.slice(1)
  15914. }
  15915. return _globalDocument2['default'].getElementById(id)
  15916. }
  15917. /**
  15918. * Creates an element and applies properties.
  15919. *
  15920. * @param {String} [tagName='div'] Name of tag to be created.
  15921. * @param {Object} [properties={}] Element properties to be applied.
  15922. * @param {Object} [attributes={}] Element attributes to be applied.
  15923. * @return {Element}
  15924. * @function createEl
  15925. */
  15926. function createEl() {
  15927. var tagName = arguments.length <= 0 || arguments[0] === undefined ? 'div' : arguments[0]
  15928. var properties = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]
  15929. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]
  15930. var el = _globalDocument2['default'].createElement(tagName)
  15931. Object.getOwnPropertyNames(properties).forEach(function(propName) {
  15932. var val = properties[propName]
  15933. // See #2176
  15934. // We originally were accepting both properties and attributes in the
  15935. // same object, but that doesn't work so well.
  15936. if (propName.indexOf('aria-') !== -1 || propName === 'role' || propName === 'type') {
  15937. _logJs2['default'].warn(_tsml2['default'](_templateObject, propName, val))
  15938. el.setAttribute(propName, val)
  15939. } else {
  15940. el[propName] = val
  15941. }
  15942. })
  15943. Object.getOwnPropertyNames(attributes).forEach(function(attrName) {
  15944. var val = attributes[attrName]
  15945. el.setAttribute(attrName, attributes[attrName])
  15946. })
  15947. return el
  15948. }
  15949. /**
  15950. * Injects text into an element, replacing any existing contents entirely.
  15951. *
  15952. * @param {Element} el
  15953. * @param {String} text
  15954. * @return {Element}
  15955. * @function textContent
  15956. */
  15957. function textContent(el, text) {
  15958. if (typeof el.textContent === 'undefined') {
  15959. el.innerText = text
  15960. } else {
  15961. el.textContent = text
  15962. }
  15963. }
  15964. /**
  15965. * Insert an element as the first child node of another
  15966. *
  15967. * @param {Element} child Element to insert
  15968. * @param {Element} parent Element to insert child into
  15969. * @private
  15970. * @function insertElFirst
  15971. */
  15972. function insertElFirst(child, parent) {
  15973. if (parent.firstChild) {
  15974. parent.insertBefore(child, parent.firstChild)
  15975. } else {
  15976. parent.appendChild(child)
  15977. }
  15978. }
  15979. /**
  15980. * Element Data Store. Allows for binding data to an element without putting it directly on the element.
  15981. * Ex. Event listeners are stored here.
  15982. * (also from jsninja.com, slightly modified and updated for closure compiler)
  15983. *
  15984. * @type {Object}
  15985. * @private
  15986. */
  15987. var elData = {}
  15988. /*
  15989. * Unique attribute name to store an element's guid in
  15990. *
  15991. * @type {String}
  15992. * @constant
  15993. * @private
  15994. */
  15995. var elIdAttr = 'vdata' + new Date().getTime()
  15996. /**
  15997. * Returns the cache object where data for an element is stored
  15998. *
  15999. * @param {Element} el Element to store data for.
  16000. * @return {Object}
  16001. * @function getElData
  16002. */
  16003. function getElData(el) {
  16004. var id = el[elIdAttr]
  16005. if (!id) {
  16006. id = el[elIdAttr] = Guid.newGUID()
  16007. }
  16008. if (!elData[id]) {
  16009. elData[id] = {}
  16010. }
  16011. return elData[id]
  16012. }
  16013. /**
  16014. * Returns whether or not an element has cached data
  16015. *
  16016. * @param {Element} el A dom element
  16017. * @return {Boolean}
  16018. * @private
  16019. * @function hasElData
  16020. */
  16021. function hasElData(el) {
  16022. var id = el[elIdAttr]
  16023. if (!id) {
  16024. return false
  16025. }
  16026. return !!Object.getOwnPropertyNames(elData[id]).length
  16027. }
  16028. /**
  16029. * Delete data for the element from the cache and the guid attr from getElementById
  16030. *
  16031. * @param {Element} el Remove data for an element
  16032. * @private
  16033. * @function removeElData
  16034. */
  16035. function removeElData(el) {
  16036. var id = el[elIdAttr]
  16037. if (!id) {
  16038. return
  16039. }
  16040. // Remove all stored data
  16041. delete elData[id]
  16042. // Remove the elIdAttr property from the DOM node
  16043. try {
  16044. delete el[elIdAttr]
  16045. } catch (e) {
  16046. if (el.removeAttribute) {
  16047. el.removeAttribute(elIdAttr)
  16048. } else {
  16049. // IE doesn't appear to support removeAttribute on the document element
  16050. el[elIdAttr] = null
  16051. }
  16052. }
  16053. }
  16054. /**
  16055. * Check if an element has a CSS class
  16056. *
  16057. * @function hasElClass
  16058. * @param {Element} element Element to check
  16059. * @param {String} classToCheck Classname to check
  16060. */
  16061. function hasElClass(element, classToCheck) {
  16062. if (element.classList) {
  16063. return element.classList.contains(classToCheck)
  16064. } else {
  16065. throwIfWhitespace(classToCheck)
  16066. return classRegExp(classToCheck).test(element.className)
  16067. }
  16068. }
  16069. /**
  16070. * Add a CSS class name to an element
  16071. *
  16072. * @function addElClass
  16073. * @param {Element} element Element to add class name to
  16074. * @param {String} classToAdd Classname to add
  16075. */
  16076. function addElClass(element, classToAdd) {
  16077. if (element.classList) {
  16078. element.classList.add(classToAdd)
  16079. // Don't need to `throwIfWhitespace` here because `hasElClass` will do it
  16080. // in the case of classList not being supported.
  16081. } else if (!hasElClass(element, classToAdd)) {
  16082. element.className = (element.className + ' ' + classToAdd).trim()
  16083. }
  16084. return element
  16085. }
  16086. /**
  16087. * Remove a CSS class name from an element
  16088. *
  16089. * @function removeElClass
  16090. * @param {Element} element Element to remove from class name
  16091. * @param {String} classToRemove Classname to remove
  16092. */
  16093. function removeElClass(element, classToRemove) {
  16094. if (element.classList) {
  16095. element.classList.remove(classToRemove)
  16096. } else {
  16097. throwIfWhitespace(classToRemove)
  16098. element.className = element.className.split(/\s+/).filter(function(c) {
  16099. return c !== classToRemove
  16100. }).join(' ')
  16101. }
  16102. return element
  16103. }
  16104. /**
  16105. * Adds or removes a CSS class name on an element depending on an optional
  16106. * condition or the presence/absence of the class name.
  16107. *
  16108. * @function toggleElClass
  16109. * @param {Element} element
  16110. * @param {String} classToToggle
  16111. * @param {Boolean|Function} [predicate]
  16112. * Can be a function that returns a Boolean. If `true`, the class
  16113. * will be added; if `false`, the class will be removed. If not
  16114. * given, the class will be added if not present and vice versa.
  16115. */
  16116. function toggleElClass(element, classToToggle, predicate) {
  16117. // This CANNOT use `classList` internally because IE does not support the
  16118. // second parameter to the `classList.toggle()` method! Which is fine because
  16119. // `classList` will be used by the add/remove functions.
  16120. var has = hasElClass(element, classToToggle)
  16121. if (typeof predicate === 'function') {
  16122. predicate = predicate(element, classToToggle)
  16123. }
  16124. if (typeof predicate !== 'boolean') {
  16125. predicate = !has
  16126. }
  16127. // If the necessary class operation matches the current state of the
  16128. // element, no action is required.
  16129. if (predicate === has) {
  16130. return
  16131. }
  16132. if (predicate) {
  16133. addElClass(element, classToToggle)
  16134. } else {
  16135. removeElClass(element, classToToggle)
  16136. }
  16137. return element
  16138. }
  16139. /**
  16140. * Apply attributes to an HTML element.
  16141. *
  16142. * @param {Element} el Target element.
  16143. * @param {Object=} attributes Element attributes to be applied.
  16144. * @private
  16145. * @function setElAttributes
  16146. */
  16147. function setElAttributes(el, attributes) {
  16148. Object.getOwnPropertyNames(attributes).forEach(function(attrName) {
  16149. var attrValue = attributes[attrName]
  16150. if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
  16151. el.removeAttribute(attrName)
  16152. } else {
  16153. el.setAttribute(attrName, attrValue === true ? '' : attrValue)
  16154. }
  16155. })
  16156. }
  16157. /**
  16158. * Get an element's attribute values, as defined on the HTML tag
  16159. * Attributes are not the same as properties. They're defined on the tag
  16160. * or with setAttribute (which shouldn't be used with HTML)
  16161. * This will return true or false for boolean attributes.
  16162. *
  16163. * @param {Element} tag Element from which to get tag attributes
  16164. * @return {Object}
  16165. * @private
  16166. * @function getElAttributes
  16167. */
  16168. function getElAttributes(tag) {
  16169. var obj, knownBooleans, attrs, attrName, attrVal
  16170. obj = {}
  16171. // known boolean attributes
  16172. // we can check for matching boolean properties, but older browsers
  16173. // won't know about HTML5 boolean attributes that we still read from
  16174. knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ','
  16175. if (tag && tag.attributes && tag.attributes.length > 0) {
  16176. attrs = tag.attributes
  16177. for (var i = attrs.length - 1; i >= 0; i--) {
  16178. attrName = attrs[i].name
  16179. attrVal = attrs[i].value
  16180. // check for known booleans
  16181. // the matching element property will return a value for typeof
  16182. if (typeof tag[attrName] === 'boolean' || knownBooleans.indexOf(',' + attrName + ',') !== -1) {
  16183. // the value of an included boolean attribute is typically an empty
  16184. // string ('') which would equal false if we just check for a false value.
  16185. // we also don't want support bad code like autoplay='false'
  16186. attrVal = attrVal !== null
  16187. }
  16188. obj[attrName] = attrVal
  16189. }
  16190. }
  16191. return obj
  16192. }
  16193. /**
  16194. * Attempt to block the ability to select text while dragging controls
  16195. *
  16196. * @return {Boolean}
  16197. * @function blockTextSelection
  16198. */
  16199. function blockTextSelection() {
  16200. _globalDocument2['default'].body.focus()
  16201. _globalDocument2['default'].onselectstart = function() {
  16202. return false
  16203. }
  16204. }
  16205. /**
  16206. * Turn off text selection blocking
  16207. *
  16208. * @return {Boolean}
  16209. * @function unblockTextSelection
  16210. */
  16211. function unblockTextSelection() {
  16212. _globalDocument2['default'].onselectstart = function() {
  16213. return true
  16214. }
  16215. }
  16216. /**
  16217. * Offset Left
  16218. * getBoundingClientRect technique from
  16219. * John Resig http://ejohn.org/blog/getboundingclientrect-is-awesome/
  16220. *
  16221. * @function findElPosition
  16222. * @param {Element} el Element from which to get offset
  16223. * @return {Object}
  16224. */
  16225. function findElPosition(el) {
  16226. var box = undefined
  16227. if (el.getBoundingClientRect && el.parentNode) {
  16228. box = el.getBoundingClientRect()
  16229. }
  16230. if (!box) {
  16231. return {
  16232. left: 0,
  16233. top: 0
  16234. }
  16235. }
  16236. var docEl = _globalDocument2['default'].documentElement
  16237. var body = _globalDocument2['default'].body
  16238. var clientLeft = docEl.clientLeft || body.clientLeft || 0
  16239. var scrollLeft = _globalWindow2['default'].pageXOffset || body.scrollLeft
  16240. var left = box.left + scrollLeft - clientLeft
  16241. var clientTop = docEl.clientTop || body.clientTop || 0
  16242. var scrollTop = _globalWindow2['default'].pageYOffset || body.scrollTop
  16243. var top = box.top + scrollTop - clientTop
  16244. // Android sometimes returns slightly off decimal values, so need to round
  16245. return {
  16246. left: Math.round(left),
  16247. top: Math.round(top)
  16248. }
  16249. }
  16250. /**
  16251. * Get pointer position in element
  16252. * Returns an object with x and y coordinates.
  16253. * The base on the coordinates are the bottom left of the element.
  16254. *
  16255. * @function getPointerPosition
  16256. * @param {Element} el Element on which to get the pointer position on
  16257. * @param {Event} event Event object
  16258. * @return {Object} This object will have x and y coordinates corresponding to the mouse position
  16259. */
  16260. function getPointerPosition(el, event) {
  16261. var position = {}
  16262. var box = findElPosition(el)
  16263. var boxW = el.offsetWidth
  16264. var boxH = el.offsetHeight
  16265. var boxY = box.top
  16266. var boxX = box.left
  16267. var pageY = event.pageY
  16268. var pageX = event.pageX
  16269. if (event.changedTouches) {
  16270. pageX = event.changedTouches[0].pageX
  16271. pageY = event.changedTouches[0].pageY
  16272. }
  16273. position.y = Math.max(0, Math.min(1, (boxY - pageY + boxH) / boxH))
  16274. position.x = Math.max(0, Math.min(1, (pageX - boxX) / boxW))
  16275. return position
  16276. }
  16277. /**
  16278. * Determines, via duck typing, whether or not a value is a DOM element.
  16279. *
  16280. * @function isEl
  16281. * @param {Mixed} value
  16282. * @return {Boolean}
  16283. */
  16284. function isEl(value) {
  16285. return !!value && typeof value === 'object' && value.nodeType === 1
  16286. }
  16287. /**
  16288. * Determines, via duck typing, whether or not a value is a text node.
  16289. *
  16290. * @param {Mixed} value
  16291. * @return {Boolean}
  16292. */
  16293. function isTextNode(value) {
  16294. return !!value && typeof value === 'object' && value.nodeType === 3
  16295. }
  16296. /**
  16297. * Empties the contents of an element.
  16298. *
  16299. * @function emptyEl
  16300. * @param {Element} el
  16301. * @return {Element}
  16302. */
  16303. function emptyEl(el) {
  16304. while (el.firstChild) {
  16305. el.removeChild(el.firstChild)
  16306. }
  16307. return el
  16308. }
  16309. /**
  16310. * Normalizes content for eventual insertion into the DOM.
  16311. *
  16312. * This allows a wide range of content definition methods, but protects
  16313. * from falling into the trap of simply writing to `innerHTML`, which is
  16314. * an XSS concern.
  16315. *
  16316. * The content for an element can be passed in multiple types and
  16317. * combinations, whose behavior is as follows:
  16318. *
  16319. * - String
  16320. * Normalized into a text node.
  16321. *
  16322. * - Element, TextNode
  16323. * Passed through.
  16324. *
  16325. * - Array
  16326. * A one-dimensional array of strings, elements, nodes, or functions (which
  16327. * return single strings, elements, or nodes).
  16328. *
  16329. * - Function
  16330. * If the sole argument, is expected to produce a string, element,
  16331. * node, or array.
  16332. *
  16333. * @function normalizeContent
  16334. * @param {String|Element|TextNode|Array|Function} content
  16335. * @return {Array}
  16336. */
  16337. function normalizeContent(content) {
  16338. // First, invoke content if it is a function. If it produces an array,
  16339. // that needs to happen before normalization.
  16340. if (typeof content === 'function') {
  16341. content = content()
  16342. }
  16343. // Next up, normalize to an array, so one or many items can be normalized,
  16344. // filtered, and returned.
  16345. return (Array.isArray(content) ? content : [content]).map(function(value) {
  16346. // First, invoke value if it is a function to produce a new value,
  16347. // which will be subsequently normalized to a Node of some kind.
  16348. if (typeof value === 'function') {
  16349. value = value()
  16350. }
  16351. if (isEl(value) || isTextNode(value)) {
  16352. return value
  16353. }
  16354. if (typeof value === 'string' && /\S/.test(value)) {
  16355. return _globalDocument2['default'].createTextNode(value)
  16356. }
  16357. }).filter(function(value) {
  16358. return value
  16359. })
  16360. }
  16361. /**
  16362. * Normalizes and appends content to an element.
  16363. *
  16364. * @function appendContent
  16365. * @param {Element} el
  16366. * @param {String|Element|TextNode|Array|Function} content
  16367. * See: `normalizeContent`
  16368. * @return {Element}
  16369. */
  16370. function appendContent(el, content) {
  16371. normalizeContent(content).forEach(function(node) {
  16372. return el.appendChild(node)
  16373. })
  16374. return el
  16375. }
  16376. /**
  16377. * Normalizes and inserts content into an element; this is identical to
  16378. * `appendContent()`, except it empties the element first.
  16379. *
  16380. * @function insertContent
  16381. * @param {Element} el
  16382. * @param {String|Element|TextNode|Array|Function} content
  16383. * See: `normalizeContent`
  16384. * @return {Element}
  16385. */
  16386. function insertContent(el, content) {
  16387. return appendContent(emptyEl(el), content)
  16388. }
  16389. /**
  16390. * Finds a single DOM element matching `selector` within the optional
  16391. * `context` of another DOM element (defaulting to `document`).
  16392. *
  16393. * @function $
  16394. * @param {String} selector
  16395. * A valid CSS selector, which will be passed to `querySelector`.
  16396. *
  16397. * @param {Element|String} [context=document]
  16398. * A DOM element within which to query. Can also be a selector
  16399. * string in which case the first matching element will be used
  16400. * as context. If missing (or no element matches selector), falls
  16401. * back to `document`.
  16402. *
  16403. * @return {Element|null}
  16404. */
  16405. var $ = createQuerier('querySelector')
  16406. exports.$ = $
  16407. /**
  16408. * Finds a all DOM elements matching `selector` within the optional
  16409. * `context` of another DOM element (defaulting to `document`).
  16410. *
  16411. * @function $$
  16412. * @param {String} selector
  16413. * A valid CSS selector, which will be passed to `querySelectorAll`.
  16414. *
  16415. * @param {Element|String} [context=document]
  16416. * A DOM element within which to query. Can also be a selector
  16417. * string in which case the first matching element will be used
  16418. * as context. If missing (or no element matches selector), falls
  16419. * back to `document`.
  16420. *
  16421. * @return {NodeList}
  16422. */
  16423. var $$ = createQuerier('querySelectorAll')
  16424. exports.$$ = $$
  16425. }, { './guid.js': 147, './log.js': 148, 'global/document': 1, 'global/window': 2, 'tsml': 55 }], 144: [function(_dereq_, module, exports) {
  16426. /**
  16427. * @file events.js
  16428. *
  16429. * Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)
  16430. * (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)
  16431. * This should work very similarly to jQuery's events, however it's based off the book version which isn't as
  16432. * robust as jquery's, so there's probably some differences.
  16433. */
  16434. 'use strict'
  16435. exports.__esModule = true
  16436. exports.on = on
  16437. exports.off = off
  16438. exports.trigger = trigger
  16439. exports.one = one
  16440. exports.fixEvent = fixEvent
  16441. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  16442. 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 } }
  16443. var _domJs = _dereq_('./dom.js')
  16444. var Dom = _interopRequireWildcard(_domJs)
  16445. var _guidJs = _dereq_('./guid.js')
  16446. var Guid = _interopRequireWildcard(_guidJs)
  16447. var _globalWindow = _dereq_('global/window')
  16448. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  16449. var _globalDocument = _dereq_('global/document')
  16450. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  16451. /**
  16452. * Add an event listener to element
  16453. * It stores the handler function in a separate cache object
  16454. * and adds a generic handler to the element's event,
  16455. * along with a unique id (guid) to the element.
  16456. *
  16457. * @param {Element|Object} elem Element or object to bind listeners to
  16458. * @param {String|Array} type Type of event to bind to.
  16459. * @param {Function} fn Event listener.
  16460. * @method on
  16461. */
  16462. function on(elem, type, fn) {
  16463. if (Array.isArray(type)) {
  16464. return _handleMultipleEvents(on, elem, type, fn)
  16465. }
  16466. var data = Dom.getElData(elem)
  16467. // We need a place to store all our handler data
  16468. if (!data.handlers) data.handlers = {}
  16469. if (!data.handlers[type]) data.handlers[type] = []
  16470. if (!fn.guid) fn.guid = Guid.newGUID()
  16471. data.handlers[type].push(fn)
  16472. if (!data.dispatcher) {
  16473. data.disabled = false
  16474. data.dispatcher = function(event, hash) {
  16475. if (data.disabled) return
  16476. event = fixEvent(event)
  16477. var handlers = data.handlers[event.type]
  16478. if (handlers) {
  16479. // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
  16480. var handlersCopy = handlers.slice(0)
  16481. for (var m = 0, n = handlersCopy.length; m < n; m++) {
  16482. if (event.isImmediatePropagationStopped()) {
  16483. break
  16484. } else {
  16485. handlersCopy[m].call(elem, event, hash)
  16486. }
  16487. }
  16488. }
  16489. }
  16490. }
  16491. if (data.handlers[type].length === 1) {
  16492. if (elem.addEventListener) {
  16493. elem.addEventListener(type, data.dispatcher, false)
  16494. } else if (elem.attachEvent) {
  16495. elem.attachEvent('on' + type, data.dispatcher)
  16496. }
  16497. }
  16498. }
  16499. /**
  16500. * Removes event listeners from an element
  16501. *
  16502. * @param {Element|Object} elem Object to remove listeners from
  16503. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  16504. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  16505. * @method off
  16506. */
  16507. function off(elem, type, fn) {
  16508. // Don't want to add a cache object through getElData if not needed
  16509. if (!Dom.hasElData(elem)) return
  16510. var data = Dom.getElData(elem)
  16511. // If no events exist, nothing to unbind
  16512. if (!data.handlers) {
  16513. return
  16514. }
  16515. if (Array.isArray(type)) {
  16516. return _handleMultipleEvents(off, elem, type, fn)
  16517. }
  16518. // Utility function
  16519. var removeType = function removeType(t) {
  16520. data.handlers[t] = []
  16521. _cleanUpEvents(elem, t)
  16522. }
  16523. // Are we removing all bound events?
  16524. if (!type) {
  16525. for (var t in data.handlers) {
  16526. removeType(t)
  16527. } return
  16528. }
  16529. var handlers = data.handlers[type]
  16530. // If no handlers exist, nothing to unbind
  16531. if (!handlers) return
  16532. // If no listener was provided, remove all listeners for type
  16533. if (!fn) {
  16534. removeType(type)
  16535. return
  16536. }
  16537. // We're only removing a single handler
  16538. if (fn.guid) {
  16539. for (var n = 0; n < handlers.length; n++) {
  16540. if (handlers[n].guid === fn.guid) {
  16541. handlers.splice(n--, 1)
  16542. }
  16543. }
  16544. }
  16545. _cleanUpEvents(elem, type)
  16546. }
  16547. /**
  16548. * Trigger an event for an element
  16549. *
  16550. * @param {Element|Object} elem Element to trigger an event on
  16551. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  16552. * @param {Object} [hash] data hash to pass along with the event
  16553. * @return {Boolean=} Returned only if default was prevented
  16554. * @method trigger
  16555. */
  16556. function trigger(elem, event, hash) {
  16557. // Fetches element data and a reference to the parent (for bubbling).
  16558. // Don't want to add a data object to cache for every parent,
  16559. // so checking hasElData first.
  16560. var elemData = Dom.hasElData(elem) ? Dom.getElData(elem) : {}
  16561. var parent = elem.parentNode || elem.ownerDocument
  16562. // type = event.type || event,
  16563. // handler;
  16564. // If an event name was passed as a string, creates an event out of it
  16565. if (typeof event === 'string') {
  16566. event = { type: event, target: elem }
  16567. }
  16568. // Normalizes the event properties.
  16569. event = fixEvent(event)
  16570. // If the passed element has a dispatcher, executes the established handlers.
  16571. if (elemData.dispatcher) {
  16572. elemData.dispatcher.call(elem, event, hash)
  16573. }
  16574. // Unless explicitly stopped or the event does not bubble (e.g. media events)
  16575. // recursively calls this function to bubble the event up the DOM.
  16576. if (parent && !event.isPropagationStopped() && event.bubbles === true) {
  16577. trigger.call(null, parent, event, hash)
  16578. // If at the top of the DOM, triggers the default action unless disabled.
  16579. } else if (!parent && !event.defaultPrevented) {
  16580. var targetData = Dom.getElData(event.target)
  16581. // Checks if the target has a default action for this event.
  16582. if (event.target[event.type]) {
  16583. // Temporarily disables event dispatching on the target as we have already executed the handler.
  16584. targetData.disabled = true
  16585. // Executes the default action.
  16586. if (typeof event.target[event.type] === 'function') {
  16587. event.target[event.type]()
  16588. }
  16589. // Re-enables event dispatching.
  16590. targetData.disabled = false
  16591. }
  16592. }
  16593. // Inform the triggerer if the default was prevented by returning false
  16594. return !event.defaultPrevented
  16595. }
  16596. /**
  16597. * Trigger a listener only once for an event
  16598. *
  16599. * @param {Element|Object} elem Element or object to
  16600. * @param {String|Array} type Name/type of event
  16601. * @param {Function} fn Event handler function
  16602. * @method one
  16603. */
  16604. function one(elem, type, fn) {
  16605. if (Array.isArray(type)) {
  16606. return _handleMultipleEvents(one, elem, type, fn)
  16607. }
  16608. var func = function func() {
  16609. off(elem, type, func)
  16610. fn.apply(this, arguments)
  16611. }
  16612. // copy the guid to the new function so it can removed using the original function's ID
  16613. func.guid = fn.guid = fn.guid || Guid.newGUID()
  16614. on(elem, type, func)
  16615. }
  16616. /**
  16617. * Fix a native event to have standard property values
  16618. *
  16619. * @param {Object} event Event object to fix
  16620. * @return {Object}
  16621. * @private
  16622. * @method fixEvent
  16623. */
  16624. function fixEvent(event) {
  16625. function returnTrue() {
  16626. return true
  16627. }
  16628. function returnFalse() {
  16629. return false
  16630. }
  16631. // Test if fixing up is needed
  16632. // Used to check if !event.stopPropagation instead of isPropagationStopped
  16633. // But native events return true for stopPropagation, but don't have
  16634. // other expected methods like isPropagationStopped. Seems to be a problem
  16635. // with the Javascript Ninja code. So we're just overriding all events now.
  16636. if (!event || !event.isPropagationStopped) {
  16637. var old = event || _globalWindow2['default'].event
  16638. event = {}
  16639. // Clone the old object so that we can modify the values event = {};
  16640. // IE8 Doesn't like when you mess with native event properties
  16641. // Firefox returns false for event.hasOwnProperty('type') and other props
  16642. // which makes copying more difficult.
  16643. // TODO: Probably best to create a whitelist of event props
  16644. for (var key in old) {
  16645. // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
  16646. // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
  16647. // and webkitMovementX/Y
  16648. if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation' && key !== 'webkitMovementX' && key !== 'webkitMovementY') {
  16649. // Chrome 32+ warns if you try to copy deprecated returnValue, but
  16650. // we still want to if preventDefault isn't supported (IE8).
  16651. if (!(key === 'returnValue' && old.preventDefault)) {
  16652. event[key] = old[key]
  16653. }
  16654. }
  16655. }
  16656. // The event occurred on this element
  16657. if (!event.target) {
  16658. event.target = event.srcElement || _globalDocument2['default']
  16659. }
  16660. // Handle which other element the event is related to
  16661. if (!event.relatedTarget) {
  16662. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement
  16663. }
  16664. // Stop the default browser action
  16665. event.preventDefault = function() {
  16666. if (old.preventDefault) {
  16667. old.preventDefault()
  16668. }
  16669. event.returnValue = false
  16670. old.returnValue = false
  16671. event.defaultPrevented = true
  16672. }
  16673. event.defaultPrevented = false
  16674. // Stop the event from bubbling
  16675. event.stopPropagation = function() {
  16676. if (old.stopPropagation) {
  16677. old.stopPropagation()
  16678. }
  16679. event.cancelBubble = true
  16680. old.cancelBubble = true
  16681. event.isPropagationStopped = returnTrue
  16682. }
  16683. event.isPropagationStopped = returnFalse
  16684. // Stop the event from bubbling and executing other handlers
  16685. event.stopImmediatePropagation = function() {
  16686. if (old.stopImmediatePropagation) {
  16687. old.stopImmediatePropagation()
  16688. }
  16689. event.isImmediatePropagationStopped = returnTrue
  16690. event.stopPropagation()
  16691. }
  16692. event.isImmediatePropagationStopped = returnFalse
  16693. // Handle mouse position
  16694. if (event.clientX != null) {
  16695. var doc = _globalDocument2['default'].documentElement
  16696. var body = _globalDocument2['default'].body
  16697. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0)
  16698. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0)
  16699. }
  16700. // Handle key presses
  16701. event.which = event.charCode || event.keyCode
  16702. // Fix button for mouse clicks:
  16703. // 0 == left; 1 == middle; 2 == right
  16704. if (event.button != null) {
  16705. event.button = event.button & 1 ? 0 : event.button & 4 ? 1 : event.button & 2 ? 2 : 0
  16706. }
  16707. }
  16708. // Returns fixed-up instance
  16709. return event
  16710. }
  16711. /**
  16712. * Clean up the listener cache and dispatchers
  16713. *
  16714. * @param {Element|Object} elem Element to clean up
  16715. * @param {String} type Type of event to clean up
  16716. * @private
  16717. * @method _cleanUpEvents
  16718. */
  16719. function _cleanUpEvents(elem, type) {
  16720. var data = Dom.getElData(elem)
  16721. // Remove the events of a particular type if there are none left
  16722. if (data.handlers[type].length === 0) {
  16723. delete data.handlers[type]
  16724. // data.handlers[type] = null;
  16725. // Setting to null was causing an error with data.handlers
  16726. // Remove the meta-handler from the element
  16727. if (elem.removeEventListener) {
  16728. elem.removeEventListener(type, data.dispatcher, false)
  16729. } else if (elem.detachEvent) {
  16730. elem.detachEvent('on' + type, data.dispatcher)
  16731. }
  16732. }
  16733. // Remove the events object if there are no types left
  16734. if (Object.getOwnPropertyNames(data.handlers).length <= 0) {
  16735. delete data.handlers
  16736. delete data.dispatcher
  16737. delete data.disabled
  16738. }
  16739. // Finally remove the element data if there is no data left
  16740. if (Object.getOwnPropertyNames(data).length === 0) {
  16741. Dom.removeElData(elem)
  16742. }
  16743. }
  16744. /**
  16745. * Loops through an array of event types and calls the requested method for each type.
  16746. *
  16747. * @param {Function} fn The event method we want to use.
  16748. * @param {Element|Object} elem Element or object to bind listeners to
  16749. * @param {String} type Type of event to bind to.
  16750. * @param {Function} callback Event listener.
  16751. * @private
  16752. * @function _handleMultipleEvents
  16753. */
  16754. function _handleMultipleEvents(fn, elem, types, callback) {
  16755. types.forEach(function(type) {
  16756. // Call the event method for each one of the types
  16757. fn(elem, type, callback)
  16758. })
  16759. }
  16760. }, { './dom.js': 143, './guid.js': 147, 'global/document': 1, 'global/window': 2 }], 145: [function(_dereq_, module, exports) {
  16761. /**
  16762. * @file fn.js
  16763. */
  16764. 'use strict'
  16765. exports.__esModule = true
  16766. var _guidJs = _dereq_('./guid.js')
  16767. /**
  16768. * Bind (a.k.a proxy or Context). A simple method for changing the context of a function
  16769. * It also stores a unique id on the function so it can be easily removed from events
  16770. *
  16771. * @param {*} context The object to bind as scope
  16772. * @param {Function} fn The function to be bound to a scope
  16773. * @param {Number=} uid An optional unique ID for the function to be set
  16774. * @return {Function}
  16775. * @private
  16776. * @method bind
  16777. */
  16778. var bind = function bind(context, fn, uid) {
  16779. // Make sure the function has a unique ID
  16780. if (!fn.guid) {
  16781. fn.guid = _guidJs.newGUID()
  16782. }
  16783. // Create the new function that changes the context
  16784. var ret = function ret() {
  16785. return fn.apply(context, arguments)
  16786. }
  16787. // Allow for the ability to individualize this function
  16788. // Needed in the case where multiple objects might share the same prototype
  16789. // IF both items add an event listener with the same function, then you try to remove just one
  16790. // it will remove both because they both have the same guid.
  16791. // when using this, you need to use the bind method when you remove the listener as well.
  16792. // currently used in text tracks
  16793. ret.guid = uid ? uid + '_' + fn.guid : fn.guid
  16794. return ret
  16795. }
  16796. exports.bind = bind
  16797. }, { './guid.js': 147 }], 146: [function(_dereq_, module, exports) {
  16798. /**
  16799. * @file format-time.js
  16800. *
  16801. * Format seconds as a time string, H:MM:SS or M:SS
  16802. * Supplying a guide (in seconds) will force a number of leading zeros
  16803. * to cover the length of the guide
  16804. *
  16805. * @param {Number} seconds Number of seconds to be turned into a string
  16806. * @param {Number} guide Number (in seconds) to model the string after
  16807. * @return {String} Time formatted as H:MM:SS or M:SS
  16808. * @private
  16809. * @function formatTime
  16810. */
  16811. 'use strict'
  16812. exports.__esModule = true
  16813. function formatTime(seconds) {
  16814. var guide = arguments.length <= 1 || arguments[1] === undefined ? seconds : arguments[1]
  16815. return (function() {
  16816. seconds = seconds < 0 ? 0 : seconds
  16817. var s = Math.floor(seconds % 60)
  16818. var m = Math.floor(seconds / 60 % 60)
  16819. var h = Math.floor(seconds / 3600)
  16820. var gm = Math.floor(guide / 60 % 60)
  16821. var gh = Math.floor(guide / 3600)
  16822. // handle invalid times
  16823. if (isNaN(seconds) || seconds === Infinity) {
  16824. // '-' is false for all relational operators (e.g. <, >=) so this setting
  16825. // will add the minimum number of fields specified by the guide
  16826. h = m = s = '-'
  16827. }
  16828. // Check if we need to show hours
  16829. h = h > 0 || gh > 0 ? h + ':' : ''
  16830. // If hours are showing, we may need to add a leading zero.
  16831. // Always show at least one digit of minutes.
  16832. m = ((h || gm >= 10) && m < 10 ? '0' + m : m) + ':'
  16833. // Check if leading zero is need for seconds
  16834. s = s < 10 ? '0' + s : s
  16835. return h + m + s
  16836. })()
  16837. }
  16838. exports['default'] = formatTime
  16839. module.exports = exports['default']
  16840. }, {}], 147: [function(_dereq_, module, exports) {
  16841. /**
  16842. * @file guid.js
  16843. *
  16844. * Unique ID for an element or function
  16845. * @type {Number}
  16846. * @private
  16847. */
  16848. 'use strict'
  16849. exports.__esModule = true
  16850. exports.newGUID = newGUID
  16851. var _guid = 1
  16852. /**
  16853. * Get the next unique ID
  16854. *
  16855. * @return {String}
  16856. * @function newGUID
  16857. */
  16858. function newGUID() {
  16859. return _guid++
  16860. }
  16861. }, {}], 148: [function(_dereq_, module, exports) {
  16862. /**
  16863. * @file log.js
  16864. */
  16865. 'use strict'
  16866. exports.__esModule = true
  16867. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  16868. var _globalWindow = _dereq_('global/window')
  16869. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  16870. /**
  16871. * Log plain debug messages
  16872. */
  16873. var log = function log() {
  16874. _logType(null, arguments)
  16875. }
  16876. /**
  16877. * Keep a history of log messages
  16878. * @type {Array}
  16879. */
  16880. log.history = []
  16881. /**
  16882. * Log error messages
  16883. */
  16884. log.error = function() {
  16885. _logType('error', arguments)
  16886. }
  16887. /**
  16888. * Log warning messages
  16889. */
  16890. log.warn = function() {
  16891. _logType('warn', arguments)
  16892. }
  16893. /**
  16894. * Log messages to the console and history based on the type of message
  16895. *
  16896. * @param {String} type The type of message, or `null` for `log`
  16897. * @param {Object} args The args to be passed to the log
  16898. * @private
  16899. * @method _logType
  16900. */
  16901. function _logType(type, args) {
  16902. // convert args to an array to get array functions
  16903. var argsArray = Array.prototype.slice.call(args)
  16904. // if there's no console then don't try to output messages
  16905. // they will still be stored in log.history
  16906. // Was setting these once outside of this function, but containing them
  16907. // in the function makes it easier to test cases where console doesn't exist
  16908. var noop = function noop() { }
  16909. var console = _globalWindow2['default']['console'] || {
  16910. 'log': noop,
  16911. 'warn': noop,
  16912. 'error': noop
  16913. }
  16914. if (type) {
  16915. // add the type to the front of the message
  16916. argsArray.unshift(type.toUpperCase() + ':')
  16917. } else {
  16918. // default to log with no prefix
  16919. type = 'log'
  16920. }
  16921. // add to history
  16922. log.history.push(argsArray)
  16923. // add console prefix after adding to history
  16924. argsArray.unshift('VIDEOJS:')
  16925. // call appropriate log function
  16926. if (console[type].apply) {
  16927. console[type].apply(console, argsArray)
  16928. } else {
  16929. // ie8 doesn't allow error.apply, but it will just join() the array anyway
  16930. console[type](argsArray.join(' '))
  16931. }
  16932. }
  16933. exports['default'] = log
  16934. module.exports = exports['default']
  16935. }, { 'global/window': 2 }], 149: [function(_dereq_, module, exports) {
  16936. /**
  16937. * @file merge-options.js
  16938. */
  16939. 'use strict'
  16940. exports.__esModule = true
  16941. exports['default'] = mergeOptions
  16942. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  16943. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge')
  16944. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge)
  16945. function isPlain(obj) {
  16946. return !!obj && typeof obj === 'object' && obj.toString() === '[object Object]' && obj.constructor === Object
  16947. }
  16948. /**
  16949. * Merge customizer. video.js simply overwrites non-simple objects
  16950. * (like arrays) instead of attempting to overlay them.
  16951. * @see https://lodash.com/docs#merge
  16952. */
  16953. var customizer = function customizer(destination, source) {
  16954. // If we're not working with a plain object, copy the value as is
  16955. // If source is an array, for instance, it will replace destination
  16956. if (!isPlain(source)) {
  16957. return source
  16958. }
  16959. // If the new value is a plain object but the first object value is not
  16960. // we need to create a new object for the first object to merge with.
  16961. // This makes it consistent with how merge() works by default
  16962. // and also protects from later changes the to first object affecting
  16963. // the second object's values.
  16964. if (!isPlain(destination)) {
  16965. return mergeOptions(source)
  16966. }
  16967. }
  16968. /**
  16969. * Merge one or more options objects, recursively merging **only**
  16970. * plain object properties. Previously `deepMerge`.
  16971. *
  16972. * @param {...Object} source One or more objects to merge
  16973. * @returns {Object} a new object that is the union of all
  16974. * provided objects
  16975. * @function mergeOptions
  16976. */
  16977. function mergeOptions() {
  16978. // contruct the call dynamically to handle the variable number of
  16979. // objects to merge
  16980. var args = Array.prototype.slice.call(arguments)
  16981. // unshift an empty object into the front of the call as the target
  16982. // of the merge
  16983. args.unshift({})
  16984. // customize conflict resolution to match our historical merge behavior
  16985. args.push(customizer)
  16986. _lodashCompatObjectMerge2['default'].apply(null, args)
  16987. // return the mutated result object
  16988. return args[0]
  16989. }
  16990. module.exports = exports['default']
  16991. }, { 'lodash-compat/object/merge': 40 }], 150: [function(_dereq_, module, exports) {
  16992. 'use strict'
  16993. exports.__esModule = true
  16994. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  16995. var _globalDocument = _dereq_('global/document')
  16996. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  16997. var createStyleElement = function createStyleElement(className) {
  16998. var style = _globalDocument2['default'].createElement('style')
  16999. style.className = className
  17000. return style
  17001. }
  17002. exports.createStyleElement = createStyleElement
  17003. var setTextContent = function setTextContent(el, content) {
  17004. if (el.styleSheet) {
  17005. el.styleSheet.cssText = content
  17006. } else {
  17007. el.textContent = content
  17008. }
  17009. }
  17010. exports.setTextContent = setTextContent
  17011. }, { 'global/document': 1 }], 151: [function(_dereq_, module, exports) {
  17012. 'use strict'
  17013. exports.__esModule = true
  17014. exports.createTimeRanges = createTimeRanges
  17015. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  17016. var _logJs = _dereq_('./log.js')
  17017. var _logJs2 = _interopRequireDefault(_logJs)
  17018. /**
  17019. * @file time-ranges.js
  17020. *
  17021. * Should create a fake TimeRange object
  17022. * Mimics an HTML5 time range instance, which has functions that
  17023. * return the start and end times for a range
  17024. * TimeRanges are returned by the buffered() method
  17025. *
  17026. * @param {(Number|Array)} Start of a single range or an array of ranges
  17027. * @param {Number} End of a single range
  17028. * @private
  17029. * @method createTimeRanges
  17030. */
  17031. function createTimeRanges(start, end) {
  17032. if (Array.isArray(start)) {
  17033. return createTimeRangesObj(start)
  17034. } else if (start === undefined || end === undefined) {
  17035. return createTimeRangesObj()
  17036. }
  17037. return createTimeRangesObj([[start, end]])
  17038. }
  17039. exports.createTimeRange = createTimeRanges
  17040. function createTimeRangesObj(ranges) {
  17041. if (ranges === undefined || ranges.length === 0) {
  17042. return {
  17043. length: 0,
  17044. start: function start() {
  17045. throw new Error('This TimeRanges object is empty')
  17046. },
  17047. end: function end() {
  17048. throw new Error('This TimeRanges object is empty')
  17049. }
  17050. }
  17051. }
  17052. return {
  17053. length: ranges.length,
  17054. start: getRange.bind(null, 'start', 0, ranges),
  17055. end: getRange.bind(null, 'end', 1, ranges)
  17056. }
  17057. }
  17058. function getRange(fnName, valueIndex, ranges, rangeIndex) {
  17059. if (rangeIndex === undefined) {
  17060. _logJs2['default'].warn('DEPRECATED: Function \'' + fnName + '\' on \'TimeRanges\' called without an index argument.')
  17061. rangeIndex = 0
  17062. }
  17063. rangeCheck(fnName, rangeIndex, ranges.length - 1)
  17064. return ranges[rangeIndex][valueIndex]
  17065. }
  17066. function rangeCheck(fnName, index, maxIndex) {
  17067. if (index < 0 || index > maxIndex) {
  17068. throw new Error('Failed to execute \'' + fnName + '\' on \'TimeRanges\': The index provided (' + index + ') is greater than or equal to the maximum bound (' + maxIndex + ').')
  17069. }
  17070. }
  17071. }, { './log.js': 148 }], 152: [function(_dereq_, module, exports) {
  17072. /**
  17073. * @file to-title-case.js
  17074. *
  17075. * Uppercase the first letter of a string
  17076. *
  17077. * @param {String} string String to be uppercased
  17078. * @return {String}
  17079. * @private
  17080. * @method toTitleCase
  17081. */
  17082. 'use strict'
  17083. exports.__esModule = true
  17084. function toTitleCase(string) {
  17085. return string.charAt(0).toUpperCase() + string.slice(1)
  17086. }
  17087. exports['default'] = toTitleCase
  17088. module.exports = exports['default']
  17089. }, {}], 153: [function(_dereq_, module, exports) {
  17090. /**
  17091. * @file url.js
  17092. */
  17093. 'use strict'
  17094. exports.__esModule = true
  17095. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  17096. var _globalDocument = _dereq_('global/document')
  17097. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  17098. var _globalWindow = _dereq_('global/window')
  17099. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  17100. /**
  17101. * Resolve and parse the elements of a URL
  17102. *
  17103. * @param {String} url The url to parse
  17104. * @return {Object} An object of url details
  17105. * @method parseUrl
  17106. */
  17107. var parseUrl = function parseUrl(url) {
  17108. var props = ['protocol', 'hostname', 'port', 'pathname', 'search', 'hash', 'host']
  17109. // add the url to an anchor and let the browser parse the URL
  17110. var a = _globalDocument2['default'].createElement('a')
  17111. a.href = url
  17112. // IE8 (and 9?) Fix
  17113. // ie8 doesn't parse the URL correctly until the anchor is actually
  17114. // added to the body, and an innerHTML is needed to trigger the parsing
  17115. var addToBody = a.host === '' && a.protocol !== 'file:'
  17116. var div = undefined
  17117. if (addToBody) {
  17118. div = _globalDocument2['default'].createElement('div')
  17119. div.innerHTML = '<a href="' + url + '"></a>'
  17120. a = div.firstChild
  17121. // prevent the div from affecting layout
  17122. div.setAttribute('style', 'display:none; position:absolute;')
  17123. _globalDocument2['default'].body.appendChild(div)
  17124. }
  17125. // Copy the specific URL properties to a new object
  17126. // This is also needed for IE8 because the anchor loses its
  17127. // properties when it's removed from the dom
  17128. var details = {}
  17129. for (var i = 0; i < props.length; i++) {
  17130. details[props[i]] = a[props[i]]
  17131. }
  17132. // IE9 adds the port to the host property unlike everyone else. If
  17133. // a port identifier is added for standard ports, strip it.
  17134. if (details.protocol === 'http:') {
  17135. details.host = details.host.replace(/:80$/, '')
  17136. }
  17137. if (details.protocol === 'https:') {
  17138. details.host = details.host.replace(/:443$/, '')
  17139. }
  17140. if (addToBody) {
  17141. _globalDocument2['default'].body.removeChild(div)
  17142. }
  17143. return details
  17144. }
  17145. exports.parseUrl = parseUrl
  17146. /**
  17147. * Get absolute version of relative URL. Used to tell flash correct URL.
  17148. * http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue
  17149. *
  17150. * @param {String} url URL to make absolute
  17151. * @return {String} Absolute URL
  17152. * @private
  17153. * @method getAbsoluteURL
  17154. */
  17155. var getAbsoluteURL = function getAbsoluteURL(url) {
  17156. // Check if absolute URL
  17157. if (!url.match(/^https?:\/\//)) {
  17158. // Convert to absolute URL. Flash hosted off-site needs an absolute URL.
  17159. var div = _globalDocument2['default'].createElement('div')
  17160. div.innerHTML = '<a href="' + url + '">x</a>'
  17161. url = div.firstChild.href
  17162. }
  17163. return url
  17164. }
  17165. exports.getAbsoluteURL = getAbsoluteURL
  17166. /**
  17167. * Returns the extension of the passed file name. It will return an empty string if you pass an invalid path
  17168. *
  17169. * @param {String} path The fileName path like '/path/to/file.mp4'
  17170. * @returns {String} The extension in lower case or an empty string if no extension could be found.
  17171. * @method getFileExtension
  17172. */
  17173. var getFileExtension = function getFileExtension(path) {
  17174. if (typeof path === 'string') {
  17175. var splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i
  17176. var pathParts = splitPathRe.exec(path)
  17177. if (pathParts) {
  17178. return pathParts.pop().toLowerCase()
  17179. }
  17180. }
  17181. return ''
  17182. }
  17183. exports.getFileExtension = getFileExtension
  17184. /**
  17185. * Returns whether the url passed is a cross domain request or not.
  17186. *
  17187. * @param {String} url The url to check
  17188. * @return {Boolean} Whether it is a cross domain request or not
  17189. * @method isCrossOrigin
  17190. */
  17191. var isCrossOrigin = function isCrossOrigin(url) {
  17192. var winLoc = _globalWindow2['default'].location
  17193. var urlInfo = parseUrl(url)
  17194. // IE8 protocol relative urls will return ':' for protocol
  17195. var srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol
  17196. // Check if url is for another domain/origin
  17197. // IE8 doesn't know location.origin, so we won't rely on it here
  17198. var crossOrigin = srcProtocol + urlInfo.host !== winLoc.protocol + winLoc.host
  17199. return crossOrigin
  17200. }
  17201. exports.isCrossOrigin = isCrossOrigin
  17202. }, { 'global/document': 1, 'global/window': 2 }], 154: [function(_dereq_, module, exports) {
  17203. /**
  17204. * @file video.js
  17205. */
  17206. 'use strict'
  17207. exports.__esModule = true
  17208. 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 } }
  17209. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj } }
  17210. var _globalWindow = _dereq_('global/window')
  17211. var _globalWindow2 = _interopRequireDefault(_globalWindow)
  17212. var _globalDocument = _dereq_('global/document')
  17213. var _globalDocument2 = _interopRequireDefault(_globalDocument)
  17214. var _setup = _dereq_('./setup')
  17215. var setup = _interopRequireWildcard(_setup)
  17216. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js')
  17217. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs)
  17218. var _component = _dereq_('./component')
  17219. var _component2 = _interopRequireDefault(_component)
  17220. var _eventTarget = _dereq_('./event-target')
  17221. var _eventTarget2 = _interopRequireDefault(_eventTarget)
  17222. var _utilsEventsJs = _dereq_('./utils/events.js')
  17223. var Events = _interopRequireWildcard(_utilsEventsJs)
  17224. var _player = _dereq_('./player')
  17225. var _player2 = _interopRequireDefault(_player)
  17226. var _pluginsJs = _dereq_('./plugins.js')
  17227. var _pluginsJs2 = _interopRequireDefault(_pluginsJs)
  17228. var _srcJsUtilsMergeOptionsJs = _dereq_('../../src/js/utils/merge-options.js')
  17229. var _srcJsUtilsMergeOptionsJs2 = _interopRequireDefault(_srcJsUtilsMergeOptionsJs)
  17230. var _utilsFnJs = _dereq_('./utils/fn.js')
  17231. var Fn = _interopRequireWildcard(_utilsFnJs)
  17232. var _tracksTextTrackJs = _dereq_('./tracks/text-track.js')
  17233. var _tracksTextTrackJs2 = _interopRequireDefault(_tracksTextTrackJs)
  17234. var _tracksAudioTrackJs = _dereq_('./tracks/audio-track.js')
  17235. var _tracksAudioTrackJs2 = _interopRequireDefault(_tracksAudioTrackJs)
  17236. var _tracksVideoTrackJs = _dereq_('./tracks/video-track.js')
  17237. var _tracksVideoTrackJs2 = _interopRequireDefault(_tracksVideoTrackJs)
  17238. var _objectAssign = _dereq_('object.assign')
  17239. var _objectAssign2 = _interopRequireDefault(_objectAssign)
  17240. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js')
  17241. var _utilsFormatTimeJs = _dereq_('./utils/format-time.js')
  17242. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs)
  17243. var _utilsLogJs = _dereq_('./utils/log.js')
  17244. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs)
  17245. var _utilsDomJs = _dereq_('./utils/dom.js')
  17246. var Dom = _interopRequireWildcard(_utilsDomJs)
  17247. var _utilsBrowserJs = _dereq_('./utils/browser.js')
  17248. var browser = _interopRequireWildcard(_utilsBrowserJs)
  17249. var _utilsUrlJs = _dereq_('./utils/url.js')
  17250. var Url = _interopRequireWildcard(_utilsUrlJs)
  17251. var _extendJs = _dereq_('./extend.js')
  17252. var _extendJs2 = _interopRequireDefault(_extendJs)
  17253. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge')
  17254. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge)
  17255. var _utilsCreateDeprecationProxyJs = _dereq_('./utils/create-deprecation-proxy.js')
  17256. var _utilsCreateDeprecationProxyJs2 = _interopRequireDefault(_utilsCreateDeprecationProxyJs)
  17257. var _xhr = _dereq_('xhr')
  17258. var _xhr2 = _interopRequireDefault(_xhr)
  17259. // Include the built-in techs
  17260. var _techTechJs = _dereq_('./tech/tech.js')
  17261. var _techTechJs2 = _interopRequireDefault(_techTechJs)
  17262. var _techHtml5Js = _dereq_('./tech/html5.js')
  17263. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js)
  17264. var _techFlashJs = _dereq_('./tech/flash.js')
  17265. var _techFlashJs2 = _interopRequireDefault(_techFlashJs)
  17266. // HTML5 Element Shim for IE8
  17267. if (typeof HTMLVideoElement === 'undefined') {
  17268. _globalDocument2['default'].createElement('video')
  17269. _globalDocument2['default'].createElement('audio')
  17270. _globalDocument2['default'].createElement('track')
  17271. }
  17272. /**
  17273. * Doubles as the main function for users to create a player instance and also
  17274. * the main library object.
  17275. * The `videojs` function can be used to initialize or retrieve a player.
  17276. * ```js
  17277. * var myPlayer = videojs('my_video_id');
  17278. * ```
  17279. *
  17280. * @param {String|Element} id Video element or video element ID
  17281. * @param {Object=} options Optional options object for config/settings
  17282. * @param {Function=} ready Optional ready callback
  17283. * @return {Player} A player instance
  17284. * @mixes videojs
  17285. * @method videojs
  17286. */
  17287. var videojs = function videojs(id, options, ready) {
  17288. var tag = undefined // Element of ID
  17289. // Allow for element or ID to be passed in
  17290. // String ID
  17291. if (typeof id === 'string') {
  17292. // Adjust for jQuery ID syntax
  17293. if (id.indexOf('#') === 0) {
  17294. id = id.slice(1)
  17295. }
  17296. // If a player instance has already been created for this ID return it.
  17297. if (videojs.getPlayers()[id]) {
  17298. // If options or ready funtion are passed, warn
  17299. if (options) {
  17300. _utilsLogJs2['default'].warn('Player "' + id + '" is already initialised. Options will not be applied.')
  17301. }
  17302. if (ready) {
  17303. videojs.getPlayers()[id].ready(ready)
  17304. }
  17305. return videojs.getPlayers()[id]
  17306. // Otherwise get element for ID
  17307. } else {
  17308. tag = Dom.getEl(id)
  17309. }
  17310. // ID is a media element
  17311. } else {
  17312. tag = id
  17313. }
  17314. // Check for a useable element
  17315. if (!tag || !tag.nodeName) {
  17316. // re: nodeName, could be a box div also
  17317. throw new TypeError('The element or ID supplied is not valid. (videojs)') // Returns
  17318. }
  17319. // Element may have a player attr referring to an already created player instance.
  17320. // If not, set up a new player and return the instance.
  17321. return tag['player'] || _player2['default'].players[tag.playerId] || new _player2['default'](tag, options, ready)
  17322. }
  17323. // Add default styles
  17324. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE !== true) {
  17325. var style = Dom.$('.vjs-styles-defaults')
  17326. if (!style) {
  17327. style = stylesheet.createStyleElement('vjs-styles-defaults')
  17328. var head = Dom.$('head')
  17329. head.insertBefore(style, head.firstChild)
  17330. stylesheet.setTextContent(style, '\n .video-js {\n width: 300px;\n height: 150px;\n }\n\n .vjs-fluid {\n padding-top: 56.25%\n }\n ')
  17331. }
  17332. }
  17333. // Run Auto-load players
  17334. // 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)
  17335. setup.autoSetupTimeout(1, videojs)
  17336. /*
  17337. * Current software version (semver)
  17338. *
  17339. * @type {String}
  17340. */
  17341. videojs.VERSION = '5.10.2'
  17342. /**
  17343. * The global options object. These are the settings that take effect
  17344. * if no overrides are specified when the player is created.
  17345. *
  17346. * ```js
  17347. * videojs.options.autoplay = true
  17348. * // -> all players will autoplay by default
  17349. * ```
  17350. *
  17351. * @type {Object}
  17352. */
  17353. videojs.options = _player2['default'].prototype.options_
  17354. /**
  17355. * Get an object with the currently created players, keyed by player ID
  17356. *
  17357. * @return {Object} The created players
  17358. * @mixes videojs
  17359. * @method getPlayers
  17360. */
  17361. videojs.getPlayers = function() {
  17362. return _player2['default'].players
  17363. }
  17364. /**
  17365. * For backward compatibility, expose players object.
  17366. *
  17367. * @deprecated
  17368. * @memberOf videojs
  17369. * @property {Object|Proxy} players
  17370. */
  17371. videojs.players = _utilsCreateDeprecationProxyJs2['default'](_player2['default'].players, {
  17372. get: 'Access to videojs.players is deprecated; use videojs.getPlayers instead',
  17373. set: 'Modification of videojs.players is deprecated'
  17374. })
  17375. /**
  17376. * Get a component class object by name
  17377. * ```js
  17378. * var VjsButton = videojs.getComponent('Button');
  17379. * // Create a new instance of the component
  17380. * var myButton = new VjsButton(myPlayer);
  17381. * ```
  17382. *
  17383. * @return {Component} Component identified by name
  17384. * @mixes videojs
  17385. * @method getComponent
  17386. */
  17387. videojs.getComponent = _component2['default'].getComponent
  17388. /**
  17389. * Register a component so it can referred to by name
  17390. * Used when adding to other
  17391. * components, either through addChild
  17392. * `component.addChild('myComponent')`
  17393. * or through default children options
  17394. * `{ children: ['myComponent'] }`.
  17395. * ```js
  17396. * // Get a component to subclass
  17397. * var VjsButton = videojs.getComponent('Button');
  17398. * // Subclass the component (see 'extend' doc for more info)
  17399. * var MySpecialButton = videojs.extend(VjsButton, {});
  17400. * // Register the new component
  17401. * VjsButton.registerComponent('MySepcialButton', MySepcialButton);
  17402. * // (optionally) add the new component as a default player child
  17403. * myPlayer.addChild('MySepcialButton');
  17404. * ```
  17405. * NOTE: You could also just initialize the component before adding.
  17406. * `component.addChild(new MyComponent());`
  17407. *
  17408. * @param {String} The class name of the component
  17409. * @param {Component} The component class
  17410. * @return {Component} The newly registered component
  17411. * @mixes videojs
  17412. * @method registerComponent
  17413. */
  17414. videojs.registerComponent = function(name, comp) {
  17415. if (_techTechJs2['default'].isTech(comp)) {
  17416. _utilsLogJs2['default'].warn('The ' + name + ' tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)')
  17417. }
  17418. _component2['default'].registerComponent.call(_component2['default'], name, comp)
  17419. }
  17420. /**
  17421. * Get a Tech class object by name
  17422. * ```js
  17423. * var Html5 = videojs.getTech('Html5');
  17424. * // Create a new instance of the component
  17425. * var html5 = new Html5(options);
  17426. * ```
  17427. *
  17428. * @return {Tech} Tech identified by name
  17429. * @mixes videojs
  17430. * @method getComponent
  17431. */
  17432. videojs.getTech = _techTechJs2['default'].getTech
  17433. /**
  17434. * Register a Tech so it can referred to by name.
  17435. * This is used in the tech order for the player.
  17436. *
  17437. * ```js
  17438. * // get the Html5 Tech
  17439. * var Html5 = videojs.getTech('Html5');
  17440. * var MyTech = videojs.extend(Html5, {});
  17441. * // Register the new Tech
  17442. * VjsButton.registerTech('Tech', MyTech);
  17443. * var player = videojs('myplayer', {
  17444. * techOrder: ['myTech', 'html5']
  17445. * });
  17446. * ```
  17447. *
  17448. * @param {String} The class name of the tech
  17449. * @param {Tech} The tech class
  17450. * @return {Tech} The newly registered Tech
  17451. * @mixes videojs
  17452. * @method registerTech
  17453. */
  17454. videojs.registerTech = _techTechJs2['default'].registerTech
  17455. /**
  17456. * A suite of browser and device tests
  17457. *
  17458. * @type {Object}
  17459. * @private
  17460. */
  17461. videojs.browser = browser
  17462. /**
  17463. * Whether or not the browser supports touch events. Included for backward
  17464. * compatibility with 4.x, but deprecated. Use `videojs.browser.TOUCH_ENABLED`
  17465. * instead going forward.
  17466. *
  17467. * @deprecated
  17468. * @type {Boolean}
  17469. */
  17470. videojs.TOUCH_ENABLED = browser.TOUCH_ENABLED
  17471. /**
  17472. * Subclass an existing class
  17473. * Mimics ES6 subclassing with the `extend` keyword
  17474. * ```js
  17475. * // Create a basic javascript 'class'
  17476. * function MyClass(name){
  17477. * // Set a property at initialization
  17478. * this.myName = name;
  17479. * }
  17480. * // Create an instance method
  17481. * MyClass.prototype.sayMyName = function(){
  17482. * alert(this.myName);
  17483. * };
  17484. * // Subclass the exisitng class and change the name
  17485. * // when initializing
  17486. * var MySubClass = videojs.extend(MyClass, {
  17487. * constructor: function(name) {
  17488. * // Call the super class constructor for the subclass
  17489. * MyClass.call(this, name)
  17490. * }
  17491. * });
  17492. * // Create an instance of the new sub class
  17493. * var myInstance = new MySubClass('John');
  17494. * myInstance.sayMyName(); // -> should alert "John"
  17495. * ```
  17496. *
  17497. * @param {Function} The Class to subclass
  17498. * @param {Object} An object including instace methods for the new class
  17499. * Optionally including a `constructor` function
  17500. * @return {Function} The newly created subclass
  17501. * @mixes videojs
  17502. * @method extend
  17503. */
  17504. videojs.extend = _extendJs2['default']
  17505. /**
  17506. * Merge two options objects recursively
  17507. * Performs a deep merge like lodash.merge but **only merges plain objects**
  17508. * (not arrays, elements, anything else)
  17509. * Other values will be copied directly from the second object.
  17510. * ```js
  17511. * var defaultOptions = {
  17512. * foo: true,
  17513. * bar: {
  17514. * a: true,
  17515. * b: [1,2,3]
  17516. * }
  17517. * };
  17518. * var newOptions = {
  17519. * foo: false,
  17520. * bar: {
  17521. * b: [4,5,6]
  17522. * }
  17523. * };
  17524. * var result = videojs.mergeOptions(defaultOptions, newOptions);
  17525. * // result.foo = false;
  17526. * // result.bar.a = true;
  17527. * // result.bar.b = [4,5,6];
  17528. * ```
  17529. *
  17530. * @param {Object} defaults The options object whose values will be overriden
  17531. * @param {Object} overrides The options object with values to override the first
  17532. * @param {Object} etc Any number of additional options objects
  17533. *
  17534. * @return {Object} a new object with the merged values
  17535. * @mixes videojs
  17536. * @method mergeOptions
  17537. */
  17538. videojs.mergeOptions = _srcJsUtilsMergeOptionsJs2['default']
  17539. /**
  17540. * Change the context (this) of a function
  17541. *
  17542. * videojs.bind(newContext, function(){
  17543. * this === newContext
  17544. * });
  17545. *
  17546. * NOTE: as of v5.0 we require an ES5 shim, so you should use the native
  17547. * `function(){}.bind(newContext);` instead of this.
  17548. *
  17549. * @param {*} context The object to bind as scope
  17550. * @param {Function} fn The function to be bound to a scope
  17551. * @param {Number=} uid An optional unique ID for the function to be set
  17552. * @return {Function}
  17553. */
  17554. videojs.bind = Fn.bind
  17555. /**
  17556. * Create a Video.js player plugin
  17557. * Plugins are only initialized when options for the plugin are included
  17558. * in the player options, or the plugin function on the player instance is
  17559. * called.
  17560. * **See the plugin guide in the docs for a more detailed example**
  17561. * ```js
  17562. * // Make a plugin that alerts when the player plays
  17563. * videojs.plugin('myPlugin', function(myPluginOptions) {
  17564. * myPluginOptions = myPluginOptions || {};
  17565. *
  17566. * var player = this;
  17567. * var alertText = myPluginOptions.text || 'Player is playing!'
  17568. *
  17569. * player.on('play', function(){
  17570. * alert(alertText);
  17571. * });
  17572. * });
  17573. * // USAGE EXAMPLES
  17574. * // EXAMPLE 1: New player with plugin options, call plugin immediately
  17575. * var player1 = videojs('idOne', {
  17576. * myPlugin: {
  17577. * text: 'Custom text!'
  17578. * }
  17579. * });
  17580. * // Click play
  17581. * // --> Should alert 'Custom text!'
  17582. * // EXAMPLE 3: New player, initialize plugin later
  17583. * var player3 = videojs('idThree');
  17584. * // Click play
  17585. * // --> NO ALERT
  17586. * // Click pause
  17587. * // Initialize plugin using the plugin function on the player instance
  17588. * player3.myPlugin({
  17589. * text: 'Plugin added later!'
  17590. * });
  17591. * // Click play
  17592. * // --> Should alert 'Plugin added later!'
  17593. * ```
  17594. *
  17595. * @param {String} name The plugin name
  17596. * @param {Function} fn The plugin function that will be called with options
  17597. * @mixes videojs
  17598. * @method plugin
  17599. */
  17600. videojs.plugin = _pluginsJs2['default']
  17601. /**
  17602. * Adding languages so that they're available to all players.
  17603. * ```js
  17604. * videojs.addLanguage('es', { 'Hello': 'Hola' });
  17605. * ```
  17606. *
  17607. * @param {String} code The language code or dictionary property
  17608. * @param {Object} data The data values to be translated
  17609. * @return {Object} The resulting language dictionary object
  17610. * @mixes videojs
  17611. * @method addLanguage
  17612. */
  17613. videojs.addLanguage = function(code, data) {
  17614. var _merge
  17615. code = ('' + code).toLowerCase()
  17616. return _lodashCompatObjectMerge2['default'](videojs.options.languages, (_merge = {}, _merge[code] = data, _merge))[code]
  17617. }
  17618. /**
  17619. * Log debug messages.
  17620. *
  17621. * @param {...Object} messages One or more messages to log
  17622. */
  17623. videojs.log = _utilsLogJs2['default']
  17624. /**
  17625. * Creates an emulated TimeRange object.
  17626. *
  17627. * @param {Number|Array} start Start time in seconds or an array of ranges
  17628. * @param {Number} end End time in seconds
  17629. * @return {Object} Fake TimeRange object
  17630. * @method createTimeRange
  17631. */
  17632. videojs.createTimeRange = videojs.createTimeRanges = _utilsTimeRangesJs.createTimeRanges
  17633. /**
  17634. * Format seconds as a time string, H:MM:SS or M:SS
  17635. * Supplying a guide (in seconds) will force a number of leading zeros
  17636. * to cover the length of the guide
  17637. *
  17638. * @param {Number} seconds Number of seconds to be turned into a string
  17639. * @param {Number} guide Number (in seconds) to model the string after
  17640. * @return {String} Time formatted as H:MM:SS or M:SS
  17641. * @method formatTime
  17642. */
  17643. videojs.formatTime = _utilsFormatTimeJs2['default']
  17644. /**
  17645. * Resolve and parse the elements of a URL
  17646. *
  17647. * @param {String} url The url to parse
  17648. * @return {Object} An object of url details
  17649. * @method parseUrl
  17650. */
  17651. videojs.parseUrl = Url.parseUrl
  17652. /**
  17653. * Returns whether the url passed is a cross domain request or not.
  17654. *
  17655. * @param {String} url The url to check
  17656. * @return {Boolean} Whether it is a cross domain request or not
  17657. * @method isCrossOrigin
  17658. */
  17659. videojs.isCrossOrigin = Url.isCrossOrigin
  17660. /**
  17661. * Event target class.
  17662. *
  17663. * @type {Function}
  17664. */
  17665. videojs.EventTarget = _eventTarget2['default']
  17666. /**
  17667. * Add an event listener to element
  17668. * It stores the handler function in a separate cache object
  17669. * and adds a generic handler to the element's event,
  17670. * along with a unique id (guid) to the element.
  17671. *
  17672. * @param {Element|Object} elem Element or object to bind listeners to
  17673. * @param {String|Array} type Type of event to bind to.
  17674. * @param {Function} fn Event listener.
  17675. * @method on
  17676. */
  17677. videojs.on = Events.on
  17678. /**
  17679. * Trigger a listener only once for an event
  17680. *
  17681. * @param {Element|Object} elem Element or object to
  17682. * @param {String|Array} type Name/type of event
  17683. * @param {Function} fn Event handler function
  17684. * @method one
  17685. */
  17686. videojs.one = Events.one
  17687. /**
  17688. * Removes event listeners from an element
  17689. *
  17690. * @param {Element|Object} elem Object to remove listeners from
  17691. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  17692. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  17693. * @method off
  17694. */
  17695. videojs.off = Events.off
  17696. /**
  17697. * Trigger an event for an element
  17698. *
  17699. * @param {Element|Object} elem Element to trigger an event on
  17700. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  17701. * @param {Object} [hash] data hash to pass along with the event
  17702. * @return {Boolean=} Returned only if default was prevented
  17703. * @method trigger
  17704. */
  17705. videojs.trigger = Events.trigger
  17706. /**
  17707. * A cross-browser XMLHttpRequest wrapper. Here's a simple example:
  17708. *
  17709. * videojs.xhr({
  17710. * body: someJSONString,
  17711. * uri: "/foo",
  17712. * headers: {
  17713. * "Content-Type": "application/json"
  17714. * }
  17715. * }, function (err, resp, body) {
  17716. * // check resp.statusCode
  17717. * });
  17718. *
  17719. * Check out the [full
  17720. * documentation](https://github.com/Raynos/xhr/blob/v2.1.0/README.md)
  17721. * for more options.
  17722. *
  17723. * @param {Object} options settings for the request.
  17724. * @return {XMLHttpRequest|XDomainRequest} the request object.
  17725. * @see https://github.com/Raynos/xhr
  17726. */
  17727. videojs.xhr = _xhr2['default']
  17728. /**
  17729. * TextTrack class
  17730. *
  17731. * @type {Function}
  17732. */
  17733. videojs.TextTrack = _tracksTextTrackJs2['default']
  17734. /**
  17735. * export the AudioTrack class so that source handlers can create
  17736. * AudioTracks and then add them to the players AudioTrackList
  17737. *
  17738. * @type {Function}
  17739. */
  17740. videojs.AudioTrack = _tracksAudioTrackJs2['default']
  17741. /**
  17742. * export the VideoTrack class so that source handlers can create
  17743. * VideoTracks and then add them to the players VideoTrackList
  17744. *
  17745. * @type {Function}
  17746. */
  17747. videojs.VideoTrack = _tracksVideoTrackJs2['default']
  17748. /**
  17749. * Determines, via duck typing, whether or not a value is a DOM element.
  17750. *
  17751. * @method isEl
  17752. * @param {Mixed} value
  17753. * @return {Boolean}
  17754. */
  17755. videojs.isEl = Dom.isEl
  17756. /**
  17757. * Determines, via duck typing, whether or not a value is a text node.
  17758. *
  17759. * @method isTextNode
  17760. * @param {Mixed} value
  17761. * @return {Boolean}
  17762. */
  17763. videojs.isTextNode = Dom.isTextNode
  17764. /**
  17765. * Creates an element and applies properties.
  17766. *
  17767. * @method createEl
  17768. * @param {String} [tagName='div'] Name of tag to be created.
  17769. * @param {Object} [properties={}] Element properties to be applied.
  17770. * @param {Object} [attributes={}] Element attributes to be applied.
  17771. * @return {Element}
  17772. */
  17773. videojs.createEl = Dom.createEl
  17774. /**
  17775. * Check if an element has a CSS class
  17776. *
  17777. * @method hasClass
  17778. * @param {Element} element Element to check
  17779. * @param {String} classToCheck Classname to check
  17780. */
  17781. videojs.hasClass = Dom.hasElClass
  17782. /**
  17783. * Add a CSS class name to an element
  17784. *
  17785. * @method addClass
  17786. * @param {Element} element Element to add class name to
  17787. * @param {String} classToAdd Classname to add
  17788. */
  17789. videojs.addClass = Dom.addElClass
  17790. /**
  17791. * Remove a CSS class name from an element
  17792. *
  17793. * @method removeClass
  17794. * @param {Element} element Element to remove from class name
  17795. * @param {String} classToRemove Classname to remove
  17796. */
  17797. videojs.removeClass = Dom.removeElClass
  17798. /**
  17799. * Adds or removes a CSS class name on an element depending on an optional
  17800. * condition or the presence/absence of the class name.
  17801. *
  17802. * @method toggleElClass
  17803. * @param {Element} element
  17804. * @param {String} classToToggle
  17805. * @param {Boolean|Function} [predicate]
  17806. * Can be a function that returns a Boolean. If `true`, the class
  17807. * will be added; if `false`, the class will be removed. If not
  17808. * given, the class will be added if not present and vice versa.
  17809. */
  17810. videojs.toggleClass = Dom.toggleElClass
  17811. /**
  17812. * Apply attributes to an HTML element.
  17813. *
  17814. * @method setAttributes
  17815. * @param {Element} el Target element.
  17816. * @param {Object=} attributes Element attributes to be applied.
  17817. */
  17818. videojs.setAttributes = Dom.setElAttributes
  17819. /**
  17820. * Get an element's attribute values, as defined on the HTML tag
  17821. * Attributes are not the same as properties. They're defined on the tag
  17822. * or with setAttribute (which shouldn't be used with HTML)
  17823. * This will return true or false for boolean attributes.
  17824. *
  17825. * @method getAttributes
  17826. * @param {Element} tag Element from which to get tag attributes
  17827. * @return {Object}
  17828. */
  17829. videojs.getAttributes = Dom.getElAttributes
  17830. /**
  17831. * Empties the contents of an element.
  17832. *
  17833. * @method emptyEl
  17834. * @param {Element} el
  17835. * @return {Element}
  17836. */
  17837. videojs.emptyEl = Dom.emptyEl
  17838. /**
  17839. * Normalizes and appends content to an element.
  17840. *
  17841. * The content for an element can be passed in multiple types and
  17842. * combinations, whose behavior is as follows:
  17843. *
  17844. * - String
  17845. * Normalized into a text node.
  17846. *
  17847. * - Element, TextNode
  17848. * Passed through.
  17849. *
  17850. * - Array
  17851. * A one-dimensional array of strings, elements, nodes, or functions (which
  17852. * return single strings, elements, or nodes).
  17853. *
  17854. * - Function
  17855. * If the sole argument, is expected to produce a string, element,
  17856. * node, or array.
  17857. *
  17858. * @method appendContent
  17859. * @param {Element} el
  17860. * @param {String|Element|TextNode|Array|Function} content
  17861. * @return {Element}
  17862. */
  17863. videojs.appendContent = Dom.appendContent
  17864. /**
  17865. * Normalizes and inserts content into an element; this is identical to
  17866. * `appendContent()`, except it empties the element first.
  17867. *
  17868. * The content for an element can be passed in multiple types and
  17869. * combinations, whose behavior is as follows:
  17870. *
  17871. * - String
  17872. * Normalized into a text node.
  17873. *
  17874. * - Element, TextNode
  17875. * Passed through.
  17876. *
  17877. * - Array
  17878. * A one-dimensional array of strings, elements, nodes, or functions (which
  17879. * return single strings, elements, or nodes).
  17880. *
  17881. * - Function
  17882. * If the sole argument, is expected to produce a string, element,
  17883. * node, or array.
  17884. *
  17885. * @method insertContent
  17886. * @param {Element} el
  17887. * @param {String|Element|TextNode|Array|Function} content
  17888. * @return {Element}
  17889. */
  17890. videojs.insertContent = Dom.insertContent
  17891. /*
  17892. * Custom Universal Module Definition (UMD)
  17893. *
  17894. * Video.js will never be a non-browser lib so we can simplify UMD a bunch and
  17895. * still support requirejs and browserify. This also needs to be closure
  17896. * compiler compatible, so string keys are used.
  17897. */
  17898. if (typeof define === 'function' && define['amd']) {
  17899. define('videojs', [], function() {
  17900. return videojs
  17901. })
  17902. // checking that module is an object too because of umdjs/umd#35
  17903. } else if (typeof exports === 'object' && typeof module === 'object') {
  17904. module['exports'] = videojs
  17905. }
  17906. exports['default'] = videojs
  17907. module.exports = exports['default']
  17908. }, { '../../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 }]
  17909. }, {}, [154])(154)
  17910. });
  17911. // # sourceMappingURL=video.js.map
  17912. /* vtt.js - v0.12.1 (https://github.com/mozilla/vtt.js) built on 08-07-2015 */
  17913. (function(root) {
  17914. var vttjs = root.vttjs = {}
  17915. var cueShim = vttjs.VTTCue
  17916. var regionShim = vttjs.VTTRegion
  17917. var oldVTTCue = root.VTTCue
  17918. var oldVTTRegion = root.VTTRegion
  17919. vttjs.shim = function() {
  17920. vttjs.VTTCue = cueShim
  17921. vttjs.VTTRegion = regionShim
  17922. }
  17923. vttjs.restore = function() {
  17924. vttjs.VTTCue = oldVTTCue
  17925. vttjs.VTTRegion = oldVTTRegion
  17926. }
  17927. }(this));
  17928. /**
  17929. * Copyright 2013 vtt.js Contributors
  17930. *
  17931. * Licensed under the Apache License, Version 2.0 (the "License");
  17932. * you may not use this file except in compliance with the License.
  17933. * You may obtain a copy of the License at
  17934. *
  17935. * http://www.apache.org/licenses/LICENSE-2.0
  17936. *
  17937. * Unless required by applicable law or agreed to in writing, software
  17938. * distributed under the License is distributed on an "AS IS" BASIS,
  17939. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17940. * See the License for the specific language governing permissions and
  17941. * limitations under the License.
  17942. */
  17943. (function(root, vttjs) {
  17944. var autoKeyword = 'auto'
  17945. var directionSetting = {
  17946. '': true,
  17947. 'lr': true,
  17948. 'rl': true
  17949. }
  17950. var alignSetting = {
  17951. 'start': true,
  17952. 'middle': true,
  17953. 'end': true,
  17954. 'left': true,
  17955. 'right': true
  17956. }
  17957. function findDirectionSetting(value) {
  17958. if (typeof value !== 'string') {
  17959. return false
  17960. }
  17961. var dir = directionSetting[value.toLowerCase()]
  17962. return dir ? value.toLowerCase() : false
  17963. }
  17964. function findAlignSetting(value) {
  17965. if (typeof value !== 'string') {
  17966. return false
  17967. }
  17968. var align = alignSetting[value.toLowerCase()]
  17969. return align ? value.toLowerCase() : false
  17970. }
  17971. function extend(obj) {
  17972. var i = 1
  17973. for (; i < arguments.length; i++) {
  17974. var cobj = arguments[i]
  17975. for (var p in cobj) {
  17976. obj[p] = cobj[p]
  17977. }
  17978. }
  17979. return obj
  17980. }
  17981. function VTTCue(startTime, endTime, text) {
  17982. var cue = this
  17983. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent)
  17984. var baseObj = {}
  17985. if (isIE8) {
  17986. cue = document.createElement('custom')
  17987. } else {
  17988. baseObj.enumerable = true
  17989. }
  17990. /**
  17991. * Shim implementation specific properties. These properties are not in
  17992. * the spec.
  17993. */
  17994. // Lets us know when the VTTCue's data has changed in such a way that we need
  17995. // to recompute its display state. This lets us compute its display state
  17996. // lazily.
  17997. cue.hasBeenReset = false
  17998. /**
  17999. * VTTCue and TextTrackCue properties
  18000. * http://dev.w3.org/html5/webvtt/#vttcue-interface
  18001. */
  18002. var _id = ''
  18003. var _pauseOnExit = false
  18004. var _startTime = startTime
  18005. var _endTime = endTime
  18006. var _text = text
  18007. var _region = null
  18008. var _vertical = ''
  18009. var _snapToLines = true
  18010. var _line = 'auto'
  18011. var _lineAlign = 'start'
  18012. var _position = 50
  18013. var _positionAlign = 'middle'
  18014. var _size = 50
  18015. var _align = 'middle'
  18016. Object.defineProperty(cue,
  18017. 'id', extend({}, baseObj, {
  18018. get: function() {
  18019. return _id
  18020. },
  18021. set: function(value) {
  18022. _id = '' + value
  18023. }
  18024. }))
  18025. Object.defineProperty(cue,
  18026. 'pauseOnExit', extend({}, baseObj, {
  18027. get: function() {
  18028. return _pauseOnExit
  18029. },
  18030. set: function(value) {
  18031. _pauseOnExit = !!value
  18032. }
  18033. }))
  18034. Object.defineProperty(cue,
  18035. 'startTime', extend({}, baseObj, {
  18036. get: function() {
  18037. return _startTime
  18038. },
  18039. set: function(value) {
  18040. if (typeof value !== 'number') {
  18041. throw new TypeError('Start time must be set to a number.')
  18042. }
  18043. _startTime = value
  18044. this.hasBeenReset = true
  18045. }
  18046. }))
  18047. Object.defineProperty(cue,
  18048. 'endTime', extend({}, baseObj, {
  18049. get: function() {
  18050. return _endTime
  18051. },
  18052. set: function(value) {
  18053. if (typeof value !== 'number') {
  18054. throw new TypeError('End time must be set to a number.')
  18055. }
  18056. _endTime = value
  18057. this.hasBeenReset = true
  18058. }
  18059. }))
  18060. Object.defineProperty(cue,
  18061. 'text', extend({}, baseObj, {
  18062. get: function() {
  18063. return _text
  18064. },
  18065. set: function(value) {
  18066. _text = '' + value
  18067. this.hasBeenReset = true
  18068. }
  18069. }))
  18070. Object.defineProperty(cue,
  18071. 'region', extend({}, baseObj, {
  18072. get: function() {
  18073. return _region
  18074. },
  18075. set: function(value) {
  18076. _region = value
  18077. this.hasBeenReset = true
  18078. }
  18079. }))
  18080. Object.defineProperty(cue,
  18081. 'vertical', extend({}, baseObj, {
  18082. get: function() {
  18083. return _vertical
  18084. },
  18085. set: function(value) {
  18086. var setting = findDirectionSetting(value)
  18087. // Have to check for false because the setting an be an empty string.
  18088. if (setting === false) {
  18089. throw new SyntaxError('An invalid or illegal string was specified.')
  18090. }
  18091. _vertical = setting
  18092. this.hasBeenReset = true
  18093. }
  18094. }))
  18095. Object.defineProperty(cue,
  18096. 'snapToLines', extend({}, baseObj, {
  18097. get: function() {
  18098. return _snapToLines
  18099. },
  18100. set: function(value) {
  18101. _snapToLines = !!value
  18102. this.hasBeenReset = true
  18103. }
  18104. }))
  18105. Object.defineProperty(cue,
  18106. 'line', extend({}, baseObj, {
  18107. get: function() {
  18108. return _line
  18109. },
  18110. set: function(value) {
  18111. if (typeof value !== 'number' && value !== autoKeyword) {
  18112. throw new SyntaxError('An invalid number or illegal string was specified.')
  18113. }
  18114. _line = value
  18115. this.hasBeenReset = true
  18116. }
  18117. }))
  18118. Object.defineProperty(cue,
  18119. 'lineAlign', extend({}, baseObj, {
  18120. get: function() {
  18121. return _lineAlign
  18122. },
  18123. set: function(value) {
  18124. var setting = findAlignSetting(value)
  18125. if (!setting) {
  18126. throw new SyntaxError('An invalid or illegal string was specified.')
  18127. }
  18128. _lineAlign = setting
  18129. this.hasBeenReset = true
  18130. }
  18131. }))
  18132. Object.defineProperty(cue,
  18133. 'position', extend({}, baseObj, {
  18134. get: function() {
  18135. return _position
  18136. },
  18137. set: function(value) {
  18138. if (value < 0 || value > 100) {
  18139. throw new Error('Position must be between 0 and 100.')
  18140. }
  18141. _position = value
  18142. this.hasBeenReset = true
  18143. }
  18144. }))
  18145. Object.defineProperty(cue,
  18146. 'positionAlign', extend({}, baseObj, {
  18147. get: function() {
  18148. return _positionAlign
  18149. },
  18150. set: function(value) {
  18151. var setting = findAlignSetting(value)
  18152. if (!setting) {
  18153. throw new SyntaxError('An invalid or illegal string was specified.')
  18154. }
  18155. _positionAlign = setting
  18156. this.hasBeenReset = true
  18157. }
  18158. }))
  18159. Object.defineProperty(cue,
  18160. 'size', extend({}, baseObj, {
  18161. get: function() {
  18162. return _size
  18163. },
  18164. set: function(value) {
  18165. if (value < 0 || value > 100) {
  18166. throw new Error('Size must be between 0 and 100.')
  18167. }
  18168. _size = value
  18169. this.hasBeenReset = true
  18170. }
  18171. }))
  18172. Object.defineProperty(cue,
  18173. 'align', extend({}, baseObj, {
  18174. get: function() {
  18175. return _align
  18176. },
  18177. set: function(value) {
  18178. var setting = findAlignSetting(value)
  18179. if (!setting) {
  18180. throw new SyntaxError('An invalid or illegal string was specified.')
  18181. }
  18182. _align = setting
  18183. this.hasBeenReset = true
  18184. }
  18185. }))
  18186. /**
  18187. * Other <track> spec defined properties
  18188. */
  18189. // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-display-state
  18190. cue.displayState = undefined
  18191. if (isIE8) {
  18192. return cue
  18193. }
  18194. }
  18195. /**
  18196. * VTTCue methods
  18197. */
  18198. VTTCue.prototype.getCueAsHTML = function() {
  18199. // Assume WebVTT.convertCueToDOMTree is on the global.
  18200. return WebVTT.convertCueToDOMTree(window, this.text)
  18201. }
  18202. root.VTTCue = root.VTTCue || VTTCue
  18203. vttjs.VTTCue = VTTCue
  18204. }(this, (this.vttjs || {})));
  18205. /**
  18206. * Copyright 2013 vtt.js Contributors
  18207. *
  18208. * Licensed under the Apache License, Version 2.0 (the "License");
  18209. * you may not use this file except in compliance with the License.
  18210. * You may obtain a copy of the License at
  18211. *
  18212. * http://www.apache.org/licenses/LICENSE-2.0
  18213. *
  18214. * Unless required by applicable law or agreed to in writing, software
  18215. * distributed under the License is distributed on an "AS IS" BASIS,
  18216. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18217. * See the License for the specific language governing permissions and
  18218. * limitations under the License.
  18219. */
  18220. (function(root, vttjs) {
  18221. var scrollSetting = {
  18222. '': true,
  18223. 'up': true
  18224. }
  18225. function findScrollSetting(value) {
  18226. if (typeof value !== 'string') {
  18227. return false
  18228. }
  18229. var scroll = scrollSetting[value.toLowerCase()]
  18230. return scroll ? value.toLowerCase() : false
  18231. }
  18232. function isValidPercentValue(value) {
  18233. return typeof value === 'number' && (value >= 0 && value <= 100)
  18234. }
  18235. // VTTRegion shim http://dev.w3.org/html5/webvtt/#vttregion-interface
  18236. function VTTRegion() {
  18237. var _width = 100
  18238. var _lines = 3
  18239. var _regionAnchorX = 0
  18240. var _regionAnchorY = 100
  18241. var _viewportAnchorX = 0
  18242. var _viewportAnchorY = 100
  18243. var _scroll = ''
  18244. Object.defineProperties(this, {
  18245. 'width': {
  18246. enumerable: true,
  18247. get: function() {
  18248. return _width
  18249. },
  18250. set: function(value) {
  18251. if (!isValidPercentValue(value)) {
  18252. throw new Error('Width must be between 0 and 100.')
  18253. }
  18254. _width = value
  18255. }
  18256. },
  18257. 'lines': {
  18258. enumerable: true,
  18259. get: function() {
  18260. return _lines
  18261. },
  18262. set: function(value) {
  18263. if (typeof value !== 'number') {
  18264. throw new TypeError('Lines must be set to a number.')
  18265. }
  18266. _lines = value
  18267. }
  18268. },
  18269. 'regionAnchorY': {
  18270. enumerable: true,
  18271. get: function() {
  18272. return _regionAnchorY
  18273. },
  18274. set: function(value) {
  18275. if (!isValidPercentValue(value)) {
  18276. throw new Error('RegionAnchorX must be between 0 and 100.')
  18277. }
  18278. _regionAnchorY = value
  18279. }
  18280. },
  18281. 'regionAnchorX': {
  18282. enumerable: true,
  18283. get: function() {
  18284. return _regionAnchorX
  18285. },
  18286. set: function(value) {
  18287. if (!isValidPercentValue(value)) {
  18288. throw new Error('RegionAnchorY must be between 0 and 100.')
  18289. }
  18290. _regionAnchorX = value
  18291. }
  18292. },
  18293. 'viewportAnchorY': {
  18294. enumerable: true,
  18295. get: function() {
  18296. return _viewportAnchorY
  18297. },
  18298. set: function(value) {
  18299. if (!isValidPercentValue(value)) {
  18300. throw new Error('ViewportAnchorY must be between 0 and 100.')
  18301. }
  18302. _viewportAnchorY = value
  18303. }
  18304. },
  18305. 'viewportAnchorX': {
  18306. enumerable: true,
  18307. get: function() {
  18308. return _viewportAnchorX
  18309. },
  18310. set: function(value) {
  18311. if (!isValidPercentValue(value)) {
  18312. throw new Error('ViewportAnchorX must be between 0 and 100.')
  18313. }
  18314. _viewportAnchorX = value
  18315. }
  18316. },
  18317. 'scroll': {
  18318. enumerable: true,
  18319. get: function() {
  18320. return _scroll
  18321. },
  18322. set: function(value) {
  18323. var setting = findScrollSetting(value)
  18324. // Have to check for false as an empty string is a legal value.
  18325. if (setting === false) {
  18326. throw new SyntaxError('An invalid or illegal string was specified.')
  18327. }
  18328. _scroll = setting
  18329. }
  18330. }
  18331. })
  18332. }
  18333. root.VTTRegion = root.VTTRegion || VTTRegion
  18334. vttjs.VTTRegion = VTTRegion
  18335. }(this, (this.vttjs || {})));
  18336. /**
  18337. * Copyright 2013 vtt.js Contributors
  18338. *
  18339. * Licensed under the Apache License, Version 2.0 (the "License");
  18340. * you may not use this file except in compliance with the License.
  18341. * You may obtain a copy of the License at
  18342. *
  18343. * http://www.apache.org/licenses/LICENSE-2.0
  18344. *
  18345. * Unless required by applicable law or agreed to in writing, software
  18346. * distributed under the License is distributed on an "AS IS" BASIS,
  18347. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18348. * See the License for the specific language governing permissions and
  18349. * limitations under the License.
  18350. */
  18351. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  18352. /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
  18353. (function(global) {
  18354. var _objCreate = Object.create || (function() {
  18355. function F() { }
  18356. return function(o) {
  18357. if (arguments.length !== 1) {
  18358. throw new Error('Object.create shim only accepts one parameter.')
  18359. }
  18360. F.prototype = o
  18361. return new F()
  18362. }
  18363. })()
  18364. // Creates a new ParserError object from an errorData object. The errorData
  18365. // object should have default code and message properties. The default message
  18366. // property can be overriden by passing in a message parameter.
  18367. // See ParsingError.Errors below for acceptable errors.
  18368. function ParsingError(errorData, message) {
  18369. this.name = 'ParsingError'
  18370. this.code = errorData.code
  18371. this.message = message || errorData.message
  18372. }
  18373. ParsingError.prototype = _objCreate(Error.prototype)
  18374. ParsingError.prototype.constructor = ParsingError
  18375. // ParsingError metadata for acceptable ParsingErrors.
  18376. ParsingError.Errors = {
  18377. BadSignature: {
  18378. code: 0,
  18379. message: 'Malformed WebVTT signature.'
  18380. },
  18381. BadTimeStamp: {
  18382. code: 1,
  18383. message: 'Malformed time stamp.'
  18384. }
  18385. }
  18386. // Try to parse input as a time stamp.
  18387. function parseTimeStamp(input) {
  18388. function computeSeconds(h, m, s, f) {
  18389. return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000
  18390. }
  18391. var m = input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/)
  18392. if (!m) {
  18393. return null
  18394. }
  18395. if (m[3]) {
  18396. // Timestamp takes the form of [hours]:[minutes]:[seconds].[milliseconds]
  18397. return computeSeconds(m[1], m[2], m[3].replace(':', ''), m[4])
  18398. } else if (m[1] > 59) {
  18399. // Timestamp takes the form of [hours]:[minutes].[milliseconds]
  18400. // First position is hours as it's over 59.
  18401. return computeSeconds(m[1], m[2], 0, m[4])
  18402. } else {
  18403. // Timestamp takes the form of [minutes]:[seconds].[milliseconds]
  18404. return computeSeconds(0, m[1], m[2], m[4])
  18405. }
  18406. }
  18407. // A settings object holds key/value pairs and will ignore anything but the first
  18408. // assignment to a specific key.
  18409. function Settings() {
  18410. this.values = _objCreate(null)
  18411. }
  18412. Settings.prototype = {
  18413. // Only accept the first assignment to any key.
  18414. set: function(k, v) {
  18415. if (!this.get(k) && v !== '') {
  18416. this.values[k] = v
  18417. }
  18418. },
  18419. // Return the value for a key, or a default value.
  18420. // If 'defaultKey' is passed then 'dflt' is assumed to be an object with
  18421. // a number of possible default values as properties where 'defaultKey' is
  18422. // the key of the property that will be chosen; otherwise it's assumed to be
  18423. // a single value.
  18424. get: function(k, dflt, defaultKey) {
  18425. if (defaultKey) {
  18426. return this.has(k) ? this.values[k] : dflt[defaultKey]
  18427. }
  18428. return this.has(k) ? this.values[k] : dflt
  18429. },
  18430. // Check whether we have a value for a key.
  18431. has: function(k) {
  18432. return k in this.values
  18433. },
  18434. // Accept a setting if its one of the given alternatives.
  18435. alt: function(k, v, a) {
  18436. for (var n = 0; n < a.length; ++n) {
  18437. if (v === a[n]) {
  18438. this.set(k, v)
  18439. break
  18440. }
  18441. }
  18442. },
  18443. // Accept a setting if its a valid (signed) integer.
  18444. integer: function(k, v) {
  18445. if (/^-?\d+$/.test(v)) { // integer
  18446. this.set(k, parseInt(v, 10))
  18447. }
  18448. },
  18449. // Accept a setting if its a valid percentage.
  18450. percent: function(k, v) {
  18451. var m
  18452. if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) {
  18453. v = parseFloat(v)
  18454. if (v >= 0 && v <= 100) {
  18455. this.set(k, v)
  18456. return true
  18457. }
  18458. }
  18459. return false
  18460. }
  18461. }
  18462. // Helper function to parse input into groups separated by 'groupDelim', and
  18463. // interprete each group as a key/value pair separated by 'keyValueDelim'.
  18464. function parseOptions(input, callback, keyValueDelim, groupDelim) {
  18465. var groups = groupDelim ? input.split(groupDelim) : [input]
  18466. for (var i in groups) {
  18467. if (typeof groups[i] !== 'string') {
  18468. continue
  18469. }
  18470. var kv = groups[i].split(keyValueDelim)
  18471. if (kv.length !== 2) {
  18472. continue
  18473. }
  18474. var k = kv[0]
  18475. var v = kv[1]
  18476. callback(k, v)
  18477. }
  18478. }
  18479. function parseCue(input, cue, regionList) {
  18480. // Remember the original input if we need to throw an error.
  18481. var oInput = input
  18482. // 4.1 WebVTT timestamp
  18483. function consumeTimeStamp() {
  18484. var ts = parseTimeStamp(input)
  18485. if (ts === null) {
  18486. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  18487. 'Malformed timestamp: ' + oInput)
  18488. }
  18489. // Remove time stamp from input.
  18490. input = input.replace(/^[^\sa-zA-Z-]+/, '')
  18491. return ts
  18492. }
  18493. // 4.4.2 WebVTT cue settings
  18494. function consumeCueSettings(input, cue) {
  18495. var settings = new Settings()
  18496. parseOptions(input, function(k, v) {
  18497. switch (k) {
  18498. case 'region':
  18499. // Find the last region we parsed with the same region id.
  18500. for (var i = regionList.length - 1; i >= 0; i--) {
  18501. if (regionList[i].id === v) {
  18502. settings.set(k, regionList[i].region)
  18503. break
  18504. }
  18505. }
  18506. break
  18507. case 'vertical':
  18508. settings.alt(k, v, ['rl', 'lr'])
  18509. break
  18510. case 'line':
  18511. var vals = v.split(',')
  18512. var vals0 = vals[0]
  18513. settings.integer(k, vals0)
  18514. settings.percent(k, vals0) ? settings.set('snapToLines', false) : null
  18515. settings.alt(k, vals0, ['auto'])
  18516. if (vals.length === 2) {
  18517. settings.alt('lineAlign', vals[1], ['start', 'middle', 'end'])
  18518. }
  18519. break
  18520. case 'position':
  18521. vals = v.split(',')
  18522. settings.percent(k, vals[0])
  18523. if (vals.length === 2) {
  18524. settings.alt('positionAlign', vals[1], ['start', 'middle', 'end'])
  18525. }
  18526. break
  18527. case 'size':
  18528. settings.percent(k, v)
  18529. break
  18530. case 'align':
  18531. settings.alt(k, v, ['start', 'middle', 'end', 'left', 'right'])
  18532. break
  18533. }
  18534. }, /:/, /\s/)
  18535. // Apply default values for any missing fields.
  18536. cue.region = settings.get('region', null)
  18537. cue.vertical = settings.get('vertical', '')
  18538. cue.line = settings.get('line', 'auto')
  18539. cue.lineAlign = settings.get('lineAlign', 'start')
  18540. cue.snapToLines = settings.get('snapToLines', true)
  18541. cue.size = settings.get('size', 100)
  18542. cue.align = settings.get('align', 'middle')
  18543. cue.position = settings.get('position', {
  18544. start: 0,
  18545. left: 0,
  18546. middle: 50,
  18547. end: 100,
  18548. right: 100
  18549. }, cue.align)
  18550. cue.positionAlign = settings.get('positionAlign', {
  18551. start: 'start',
  18552. left: 'start',
  18553. middle: 'middle',
  18554. end: 'end',
  18555. right: 'end'
  18556. }, cue.align)
  18557. }
  18558. function skipWhitespace() {
  18559. input = input.replace(/^\s+/, '')
  18560. }
  18561. // 4.1 WebVTT cue timings.
  18562. skipWhitespace()
  18563. cue.startTime = consumeTimeStamp() // (1) collect cue start time
  18564. skipWhitespace()
  18565. if (input.substr(0, 3) !== '-->') { // (3) next characters must match "-->"
  18566. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  18567. "Malformed time stamp (time stamps must be separated by '-->'): " +
  18568. oInput)
  18569. }
  18570. input = input.substr(3)
  18571. skipWhitespace()
  18572. cue.endTime = consumeTimeStamp() // (5) collect cue end time
  18573. // 4.1 WebVTT cue settings list.
  18574. skipWhitespace()
  18575. consumeCueSettings(input, cue)
  18576. }
  18577. var ESCAPE = {
  18578. '&amp;': '&',
  18579. '&lt;': '<',
  18580. '&gt;': '>',
  18581. '&lrm;': '\u200e',
  18582. '&rlm;': '\u200f',
  18583. '&nbsp;': '\u00a0'
  18584. }
  18585. var TAG_NAME = {
  18586. c: 'span',
  18587. i: 'i',
  18588. b: 'b',
  18589. u: 'u',
  18590. ruby: 'ruby',
  18591. rt: 'rt',
  18592. v: 'span',
  18593. lang: 'span'
  18594. }
  18595. var TAG_ANNOTATION = {
  18596. v: 'title',
  18597. lang: 'lang'
  18598. }
  18599. var NEEDS_PARENT = {
  18600. rt: 'ruby'
  18601. }
  18602. // Parse content into a document fragment.
  18603. function parseContent(window, input) {
  18604. function nextToken() {
  18605. // Check for end-of-string.
  18606. if (!input) {
  18607. return null
  18608. }
  18609. // Consume 'n' characters from the input.
  18610. function consume(result) {
  18611. input = input.substr(result.length)
  18612. return result
  18613. }
  18614. var m = input.match(/^([^<]*)(<[^>]+>?)?/)
  18615. // If there is some text before the next tag, return it, otherwise return
  18616. // the tag.
  18617. return consume(m[1] ? m[1] : m[2])
  18618. }
  18619. // Unescape a string 's'.
  18620. function unescape1(e) {
  18621. return ESCAPE[e]
  18622. }
  18623. function unescape(s) {
  18624. while ((m = s.match(/&(amp|lt|gt|lrm|rlm|nbsp);/))) {
  18625. s = s.replace(m[0], unescape1)
  18626. }
  18627. return s
  18628. }
  18629. function shouldAdd(current, element) {
  18630. return !NEEDS_PARENT[element.localName] ||
  18631. NEEDS_PARENT[element.localName] === current.localName
  18632. }
  18633. // Create an element for this tag.
  18634. function createElement(type, annotation) {
  18635. var tagName = TAG_NAME[type]
  18636. if (!tagName) {
  18637. return null
  18638. }
  18639. var element = window.document.createElement(tagName)
  18640. element.localName = tagName
  18641. var name = TAG_ANNOTATION[type]
  18642. if (name && annotation) {
  18643. element[name] = annotation.trim()
  18644. }
  18645. return element
  18646. }
  18647. var rootDiv = window.document.createElement('div')
  18648. var current = rootDiv
  18649. var t
  18650. var tagStack = []
  18651. while ((t = nextToken()) !== null) {
  18652. if (t[0] === '<') {
  18653. if (t[1] === '/') {
  18654. // If the closing tag matches, move back up to the parent node.
  18655. if (tagStack.length &&
  18656. tagStack[tagStack.length - 1] === t.substr(2).replace('>', '')) {
  18657. tagStack.pop()
  18658. current = current.parentNode
  18659. }
  18660. // Otherwise just ignore the end tag.
  18661. continue
  18662. }
  18663. var ts = parseTimeStamp(t.substr(1, t.length - 2))
  18664. var node
  18665. if (ts) {
  18666. // Timestamps are lead nodes as well.
  18667. node = window.document.createProcessingInstruction('timestamp', ts)
  18668. current.appendChild(node)
  18669. continue
  18670. }
  18671. var m = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)
  18672. // If we can't parse the tag, skip to the next tag.
  18673. if (!m) {
  18674. continue
  18675. }
  18676. // Try to construct an element, and ignore the tag if we couldn't.
  18677. node = createElement(m[1], m[3])
  18678. if (!node) {
  18679. continue
  18680. }
  18681. // Determine if the tag should be added based on the context of where it
  18682. // is placed in the cuetext.
  18683. if (!shouldAdd(current, node)) {
  18684. continue
  18685. }
  18686. // Set the class list (as a list of classes, separated by space).
  18687. if (m[2]) {
  18688. node.className = m[2].substr(1).replace('.', ' ')
  18689. }
  18690. // Append the node to the current node, and enter the scope of the new
  18691. // node.
  18692. tagStack.push(m[1])
  18693. current.appendChild(node)
  18694. current = node
  18695. continue
  18696. }
  18697. // Text nodes are leaf nodes.
  18698. current.appendChild(window.document.createTextNode(unescape(t)))
  18699. }
  18700. return rootDiv
  18701. }
  18702. // This is a list of all the Unicode characters that have a strong
  18703. // right-to-left category. What this means is that these characters are
  18704. // written right-to-left for sure. It was generated by pulling all the strong
  18705. // right-to-left characters out of the Unicode data table. That table can
  18706. // found at: http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
  18707. var strongRTLChars = [0x05BE, 0x05C0, 0x05C3, 0x05C6, 0x05D0, 0x05D1,
  18708. 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA,
  18709. 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3,
  18710. 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x05F0, 0x05F1,
  18711. 0x05F2, 0x05F3, 0x05F4, 0x0608, 0x060B, 0x060D, 0x061B, 0x061E, 0x061F,
  18712. 0x0620, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628,
  18713. 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631,
  18714. 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063A,
  18715. 0x063B, 0x063C, 0x063D, 0x063E, 0x063F, 0x0640, 0x0641, 0x0642, 0x0643,
  18716. 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, 0x066D, 0x066E,
  18717. 0x066F, 0x0671, 0x0672, 0x0673, 0x0674, 0x0675, 0x0676, 0x0677, 0x0678,
  18718. 0x0679, 0x067A, 0x067B, 0x067C, 0x067D, 0x067E, 0x067F, 0x0680, 0x0681,
  18719. 0x0682, 0x0683, 0x0684, 0x0685, 0x0686, 0x0687, 0x0688, 0x0689, 0x068A,
  18720. 0x068B, 0x068C, 0x068D, 0x068E, 0x068F, 0x0690, 0x0691, 0x0692, 0x0693,
  18721. 0x0694, 0x0695, 0x0696, 0x0697, 0x0698, 0x0699, 0x069A, 0x069B, 0x069C,
  18722. 0x069D, 0x069E, 0x069F, 0x06A0, 0x06A1, 0x06A2, 0x06A3, 0x06A4, 0x06A5,
  18723. 0x06A6, 0x06A7, 0x06A8, 0x06A9, 0x06AA, 0x06AB, 0x06AC, 0x06AD, 0x06AE,
  18724. 0x06AF, 0x06B0, 0x06B1, 0x06B2, 0x06B3, 0x06B4, 0x06B5, 0x06B6, 0x06B7,
  18725. 0x06B8, 0x06B9, 0x06BA, 0x06BB, 0x06BC, 0x06BD, 0x06BE, 0x06BF, 0x06C0,
  18726. 0x06C1, 0x06C2, 0x06C3, 0x06C4, 0x06C5, 0x06C6, 0x06C7, 0x06C8, 0x06C9,
  18727. 0x06CA, 0x06CB, 0x06CC, 0x06CD, 0x06CE, 0x06CF, 0x06D0, 0x06D1, 0x06D2,
  18728. 0x06D3, 0x06D4, 0x06D5, 0x06E5, 0x06E6, 0x06EE, 0x06EF, 0x06FA, 0x06FB,
  18729. 0x06FC, 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702, 0x0703, 0x0704,
  18730. 0x0705, 0x0706, 0x0707, 0x0708, 0x0709, 0x070A, 0x070B, 0x070C, 0x070D,
  18731. 0x070F, 0x0710, 0x0712, 0x0713, 0x0714, 0x0715, 0x0716, 0x0717, 0x0718,
  18732. 0x0719, 0x071A, 0x071B, 0x071C, 0x071D, 0x071E, 0x071F, 0x0720, 0x0721,
  18733. 0x0722, 0x0723, 0x0724, 0x0725, 0x0726, 0x0727, 0x0728, 0x0729, 0x072A,
  18734. 0x072B, 0x072C, 0x072D, 0x072E, 0x072F, 0x074D, 0x074E, 0x074F, 0x0750,
  18735. 0x0751, 0x0752, 0x0753, 0x0754, 0x0755, 0x0756, 0x0757, 0x0758, 0x0759,
  18736. 0x075A, 0x075B, 0x075C, 0x075D, 0x075E, 0x075F, 0x0760, 0x0761, 0x0762,
  18737. 0x0763, 0x0764, 0x0765, 0x0766, 0x0767, 0x0768, 0x0769, 0x076A, 0x076B,
  18738. 0x076C, 0x076D, 0x076E, 0x076F, 0x0770, 0x0771, 0x0772, 0x0773, 0x0774,
  18739. 0x0775, 0x0776, 0x0777, 0x0778, 0x0779, 0x077A, 0x077B, 0x077C, 0x077D,
  18740. 0x077E, 0x077F, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0786,
  18741. 0x0787, 0x0788, 0x0789, 0x078A, 0x078B, 0x078C, 0x078D, 0x078E, 0x078F,
  18742. 0x0790, 0x0791, 0x0792, 0x0793, 0x0794, 0x0795, 0x0796, 0x0797, 0x0798,
  18743. 0x0799, 0x079A, 0x079B, 0x079C, 0x079D, 0x079E, 0x079F, 0x07A0, 0x07A1,
  18744. 0x07A2, 0x07A3, 0x07A4, 0x07A5, 0x07B1, 0x07C0, 0x07C1, 0x07C2, 0x07C3,
  18745. 0x07C4, 0x07C5, 0x07C6, 0x07C7, 0x07C8, 0x07C9, 0x07CA, 0x07CB, 0x07CC,
  18746. 0x07CD, 0x07CE, 0x07CF, 0x07D0, 0x07D1, 0x07D2, 0x07D3, 0x07D4, 0x07D5,
  18747. 0x07D6, 0x07D7, 0x07D8, 0x07D9, 0x07DA, 0x07DB, 0x07DC, 0x07DD, 0x07DE,
  18748. 0x07DF, 0x07E0, 0x07E1, 0x07E2, 0x07E3, 0x07E4, 0x07E5, 0x07E6, 0x07E7,
  18749. 0x07E8, 0x07E9, 0x07EA, 0x07F4, 0x07F5, 0x07FA, 0x0800, 0x0801, 0x0802,
  18750. 0x0803, 0x0804, 0x0805, 0x0806, 0x0807, 0x0808, 0x0809, 0x080A, 0x080B,
  18751. 0x080C, 0x080D, 0x080E, 0x080F, 0x0810, 0x0811, 0x0812, 0x0813, 0x0814,
  18752. 0x0815, 0x081A, 0x0824, 0x0828, 0x0830, 0x0831, 0x0832, 0x0833, 0x0834,
  18753. 0x0835, 0x0836, 0x0837, 0x0838, 0x0839, 0x083A, 0x083B, 0x083C, 0x083D,
  18754. 0x083E, 0x0840, 0x0841, 0x0842, 0x0843, 0x0844, 0x0845, 0x0846, 0x0847,
  18755. 0x0848, 0x0849, 0x084A, 0x084B, 0x084C, 0x084D, 0x084E, 0x084F, 0x0850,
  18756. 0x0851, 0x0852, 0x0853, 0x0854, 0x0855, 0x0856, 0x0857, 0x0858, 0x085E,
  18757. 0x08A0, 0x08A2, 0x08A3, 0x08A4, 0x08A5, 0x08A6, 0x08A7, 0x08A8, 0x08A9,
  18758. 0x08AA, 0x08AB, 0x08AC, 0x200F, 0xFB1D, 0xFB1F, 0xFB20, 0xFB21, 0xFB22,
  18759. 0xFB23, 0xFB24, 0xFB25, 0xFB26, 0xFB27, 0xFB28, 0xFB2A, 0xFB2B, 0xFB2C,
  18760. 0xFB2D, 0xFB2E, 0xFB2F, 0xFB30, 0xFB31, 0xFB32, 0xFB33, 0xFB34, 0xFB35,
  18761. 0xFB36, 0xFB38, 0xFB39, 0xFB3A, 0xFB3B, 0xFB3C, 0xFB3E, 0xFB40, 0xFB41,
  18762. 0xFB43, 0xFB44, 0xFB46, 0xFB47, 0xFB48, 0xFB49, 0xFB4A, 0xFB4B, 0xFB4C,
  18763. 0xFB4D, 0xFB4E, 0xFB4F, 0xFB50, 0xFB51, 0xFB52, 0xFB53, 0xFB54, 0xFB55,
  18764. 0xFB56, 0xFB57, 0xFB58, 0xFB59, 0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D, 0xFB5E,
  18765. 0xFB5F, 0xFB60, 0xFB61, 0xFB62, 0xFB63, 0xFB64, 0xFB65, 0xFB66, 0xFB67,
  18766. 0xFB68, 0xFB69, 0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D, 0xFB6E, 0xFB6F, 0xFB70,
  18767. 0xFB71, 0xFB72, 0xFB73, 0xFB74, 0xFB75, 0xFB76, 0xFB77, 0xFB78, 0xFB79,
  18768. 0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D, 0xFB7E, 0xFB7F, 0xFB80, 0xFB81, 0xFB82,
  18769. 0xFB83, 0xFB84, 0xFB85, 0xFB86, 0xFB87, 0xFB88, 0xFB89, 0xFB8A, 0xFB8B,
  18770. 0xFB8C, 0xFB8D, 0xFB8E, 0xFB8F, 0xFB90, 0xFB91, 0xFB92, 0xFB93, 0xFB94,
  18771. 0xFB95, 0xFB96, 0xFB97, 0xFB98, 0xFB99, 0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D,
  18772. 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3, 0xFBA4, 0xFBA5, 0xFBA6,
  18773. 0xFBA7, 0xFBA8, 0xFBA9, 0xFBAA, 0xFBAB, 0xFBAC, 0xFBAD, 0xFBAE, 0xFBAF,
  18774. 0xFBB0, 0xFBB1, 0xFBB2, 0xFBB3, 0xFBB4, 0xFBB5, 0xFBB6, 0xFBB7, 0xFBB8,
  18775. 0xFBB9, 0xFBBA, 0xFBBB, 0xFBBC, 0xFBBD, 0xFBBE, 0xFBBF, 0xFBC0, 0xFBC1,
  18776. 0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6, 0xFBD7, 0xFBD8, 0xFBD9, 0xFBDA, 0xFBDB,
  18777. 0xFBDC, 0xFBDD, 0xFBDE, 0xFBDF, 0xFBE0, 0xFBE1, 0xFBE2, 0xFBE3, 0xFBE4,
  18778. 0xFBE5, 0xFBE6, 0xFBE7, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEB, 0xFBEC, 0xFBED,
  18779. 0xFBEE, 0xFBEF, 0xFBF0, 0xFBF1, 0xFBF2, 0xFBF3, 0xFBF4, 0xFBF5, 0xFBF6,
  18780. 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF,
  18781. 0xFC00, 0xFC01, 0xFC02, 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
  18782. 0xFC09, 0xFC0A, 0xFC0B, 0xFC0C, 0xFC0D, 0xFC0E, 0xFC0F, 0xFC10, 0xFC11,
  18783. 0xFC12, 0xFC13, 0xFC14, 0xFC15, 0xFC16, 0xFC17, 0xFC18, 0xFC19, 0xFC1A,
  18784. 0xFC1B, 0xFC1C, 0xFC1D, 0xFC1E, 0xFC1F, 0xFC20, 0xFC21, 0xFC22, 0xFC23,
  18785. 0xFC24, 0xFC25, 0xFC26, 0xFC27, 0xFC28, 0xFC29, 0xFC2A, 0xFC2B, 0xFC2C,
  18786. 0xFC2D, 0xFC2E, 0xFC2F, 0xFC30, 0xFC31, 0xFC32, 0xFC33, 0xFC34, 0xFC35,
  18787. 0xFC36, 0xFC37, 0xFC38, 0xFC39, 0xFC3A, 0xFC3B, 0xFC3C, 0xFC3D, 0xFC3E,
  18788. 0xFC3F, 0xFC40, 0xFC41, 0xFC42, 0xFC43, 0xFC44, 0xFC45, 0xFC46, 0xFC47,
  18789. 0xFC48, 0xFC49, 0xFC4A, 0xFC4B, 0xFC4C, 0xFC4D, 0xFC4E, 0xFC4F, 0xFC50,
  18790. 0xFC51, 0xFC52, 0xFC53, 0xFC54, 0xFC55, 0xFC56, 0xFC57, 0xFC58, 0xFC59,
  18791. 0xFC5A, 0xFC5B, 0xFC5C, 0xFC5D, 0xFC5E, 0xFC5F, 0xFC60, 0xFC61, 0xFC62,
  18792. 0xFC63, 0xFC64, 0xFC65, 0xFC66, 0xFC67, 0xFC68, 0xFC69, 0xFC6A, 0xFC6B,
  18793. 0xFC6C, 0xFC6D, 0xFC6E, 0xFC6F, 0xFC70, 0xFC71, 0xFC72, 0xFC73, 0xFC74,
  18794. 0xFC75, 0xFC76, 0xFC77, 0xFC78, 0xFC79, 0xFC7A, 0xFC7B, 0xFC7C, 0xFC7D,
  18795. 0xFC7E, 0xFC7F, 0xFC80, 0xFC81, 0xFC82, 0xFC83, 0xFC84, 0xFC85, 0xFC86,
  18796. 0xFC87, 0xFC88, 0xFC89, 0xFC8A, 0xFC8B, 0xFC8C, 0xFC8D, 0xFC8E, 0xFC8F,
  18797. 0xFC90, 0xFC91, 0xFC92, 0xFC93, 0xFC94, 0xFC95, 0xFC96, 0xFC97, 0xFC98,
  18798. 0xFC99, 0xFC9A, 0xFC9B, 0xFC9C, 0xFC9D, 0xFC9E, 0xFC9F, 0xFCA0, 0xFCA1,
  18799. 0xFCA2, 0xFCA3, 0xFCA4, 0xFCA5, 0xFCA6, 0xFCA7, 0xFCA8, 0xFCA9, 0xFCAA,
  18800. 0xFCAB, 0xFCAC, 0xFCAD, 0xFCAE, 0xFCAF, 0xFCB0, 0xFCB1, 0xFCB2, 0xFCB3,
  18801. 0xFCB4, 0xFCB5, 0xFCB6, 0xFCB7, 0xFCB8, 0xFCB9, 0xFCBA, 0xFCBB, 0xFCBC,
  18802. 0xFCBD, 0xFCBE, 0xFCBF, 0xFCC0, 0xFCC1, 0xFCC2, 0xFCC3, 0xFCC4, 0xFCC5,
  18803. 0xFCC6, 0xFCC7, 0xFCC8, 0xFCC9, 0xFCCA, 0xFCCB, 0xFCCC, 0xFCCD, 0xFCCE,
  18804. 0xFCCF, 0xFCD0, 0xFCD1, 0xFCD2, 0xFCD3, 0xFCD4, 0xFCD5, 0xFCD6, 0xFCD7,
  18805. 0xFCD8, 0xFCD9, 0xFCDA, 0xFCDB, 0xFCDC, 0xFCDD, 0xFCDE, 0xFCDF, 0xFCE0,
  18806. 0xFCE1, 0xFCE2, 0xFCE3, 0xFCE4, 0xFCE5, 0xFCE6, 0xFCE7, 0xFCE8, 0xFCE9,
  18807. 0xFCEA, 0xFCEB, 0xFCEC, 0xFCED, 0xFCEE, 0xFCEF, 0xFCF0, 0xFCF1, 0xFCF2,
  18808. 0xFCF3, 0xFCF4, 0xFCF5, 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9, 0xFCFA, 0xFCFB,
  18809. 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF, 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04,
  18810. 0xFD05, 0xFD06, 0xFD07, 0xFD08, 0xFD09, 0xFD0A, 0xFD0B, 0xFD0C, 0xFD0D,
  18811. 0xFD0E, 0xFD0F, 0xFD10, 0xFD11, 0xFD12, 0xFD13, 0xFD14, 0xFD15, 0xFD16,
  18812. 0xFD17, 0xFD18, 0xFD19, 0xFD1A, 0xFD1B, 0xFD1C, 0xFD1D, 0xFD1E, 0xFD1F,
  18813. 0xFD20, 0xFD21, 0xFD22, 0xFD23, 0xFD24, 0xFD25, 0xFD26, 0xFD27, 0xFD28,
  18814. 0xFD29, 0xFD2A, 0xFD2B, 0xFD2C, 0xFD2D, 0xFD2E, 0xFD2F, 0xFD30, 0xFD31,
  18815. 0xFD32, 0xFD33, 0xFD34, 0xFD35, 0xFD36, 0xFD37, 0xFD38, 0xFD39, 0xFD3A,
  18816. 0xFD3B, 0xFD3C, 0xFD3D, 0xFD50, 0xFD51, 0xFD52, 0xFD53, 0xFD54, 0xFD55,
  18817. 0xFD56, 0xFD57, 0xFD58, 0xFD59, 0xFD5A, 0xFD5B, 0xFD5C, 0xFD5D, 0xFD5E,
  18818. 0xFD5F, 0xFD60, 0xFD61, 0xFD62, 0xFD63, 0xFD64, 0xFD65, 0xFD66, 0xFD67,
  18819. 0xFD68, 0xFD69, 0xFD6A, 0xFD6B, 0xFD6C, 0xFD6D, 0xFD6E, 0xFD6F, 0xFD70,
  18820. 0xFD71, 0xFD72, 0xFD73, 0xFD74, 0xFD75, 0xFD76, 0xFD77, 0xFD78, 0xFD79,
  18821. 0xFD7A, 0xFD7B, 0xFD7C, 0xFD7D, 0xFD7E, 0xFD7F, 0xFD80, 0xFD81, 0xFD82,
  18822. 0xFD83, 0xFD84, 0xFD85, 0xFD86, 0xFD87, 0xFD88, 0xFD89, 0xFD8A, 0xFD8B,
  18823. 0xFD8C, 0xFD8D, 0xFD8E, 0xFD8F, 0xFD92, 0xFD93, 0xFD94, 0xFD95, 0xFD96,
  18824. 0xFD97, 0xFD98, 0xFD99, 0xFD9A, 0xFD9B, 0xFD9C, 0xFD9D, 0xFD9E, 0xFD9F,
  18825. 0xFDA0, 0xFDA1, 0xFDA2, 0xFDA3, 0xFDA4, 0xFDA5, 0xFDA6, 0xFDA7, 0xFDA8,
  18826. 0xFDA9, 0xFDAA, 0xFDAB, 0xFDAC, 0xFDAD, 0xFDAE, 0xFDAF, 0xFDB0, 0xFDB1,
  18827. 0xFDB2, 0xFDB3, 0xFDB4, 0xFDB5, 0xFDB6, 0xFDB7, 0xFDB8, 0xFDB9, 0xFDBA,
  18828. 0xFDBB, 0xFDBC, 0xFDBD, 0xFDBE, 0xFDBF, 0xFDC0, 0xFDC1, 0xFDC2, 0xFDC3,
  18829. 0xFDC4, 0xFDC5, 0xFDC6, 0xFDC7, 0xFDF0, 0xFDF1, 0xFDF2, 0xFDF3, 0xFDF4,
  18830. 0xFDF5, 0xFDF6, 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC, 0xFE70,
  18831. 0xFE71, 0xFE72, 0xFE73, 0xFE74, 0xFE76, 0xFE77, 0xFE78, 0xFE79, 0xFE7A,
  18832. 0xFE7B, 0xFE7C, 0xFE7D, 0xFE7E, 0xFE7F, 0xFE80, 0xFE81, 0xFE82, 0xFE83,
  18833. 0xFE84, 0xFE85, 0xFE86, 0xFE87, 0xFE88, 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C,
  18834. 0xFE8D, 0xFE8E, 0xFE8F, 0xFE90, 0xFE91, 0xFE92, 0xFE93, 0xFE94, 0xFE95,
  18835. 0xFE96, 0xFE97, 0xFE98, 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C, 0xFE9D, 0xFE9E,
  18836. 0xFE9F, 0xFEA0, 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4, 0xFEA5, 0xFEA6, 0xFEA7,
  18837. 0xFEA8, 0xFEA9, 0xFEAA, 0xFEAB, 0xFEAC, 0xFEAD, 0xFEAE, 0xFEAF, 0xFEB0,
  18838. 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4, 0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8, 0xFEB9,
  18839. 0xFEBA, 0xFEBB, 0xFEBC, 0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0, 0xFEC1, 0xFEC2,
  18840. 0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8, 0xFEC9, 0xFECA, 0xFECB,
  18841. 0xFECC, 0xFECD, 0xFECE, 0xFECF, 0xFED0, 0xFED1, 0xFED2, 0xFED3, 0xFED4,
  18842. 0xFED5, 0xFED6, 0xFED7, 0xFED8, 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC, 0xFEDD,
  18843. 0xFEDE, 0xFEDF, 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6,
  18844. 0xFEE7, 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF,
  18845. 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8,
  18846. 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0x10800, 0x10801, 0x10802, 0x10803,
  18847. 0x10804, 0x10805, 0x10808, 0x1080A, 0x1080B, 0x1080C, 0x1080D, 0x1080E,
  18848. 0x1080F, 0x10810, 0x10811, 0x10812, 0x10813, 0x10814, 0x10815, 0x10816,
  18849. 0x10817, 0x10818, 0x10819, 0x1081A, 0x1081B, 0x1081C, 0x1081D, 0x1081E,
  18850. 0x1081F, 0x10820, 0x10821, 0x10822, 0x10823, 0x10824, 0x10825, 0x10826,
  18851. 0x10827, 0x10828, 0x10829, 0x1082A, 0x1082B, 0x1082C, 0x1082D, 0x1082E,
  18852. 0x1082F, 0x10830, 0x10831, 0x10832, 0x10833, 0x10834, 0x10835, 0x10837,
  18853. 0x10838, 0x1083C, 0x1083F, 0x10840, 0x10841, 0x10842, 0x10843, 0x10844,
  18854. 0x10845, 0x10846, 0x10847, 0x10848, 0x10849, 0x1084A, 0x1084B, 0x1084C,
  18855. 0x1084D, 0x1084E, 0x1084F, 0x10850, 0x10851, 0x10852, 0x10853, 0x10854,
  18856. 0x10855, 0x10857, 0x10858, 0x10859, 0x1085A, 0x1085B, 0x1085C, 0x1085D,
  18857. 0x1085E, 0x1085F, 0x10900, 0x10901, 0x10902, 0x10903, 0x10904, 0x10905,
  18858. 0x10906, 0x10907, 0x10908, 0x10909, 0x1090A, 0x1090B, 0x1090C, 0x1090D,
  18859. 0x1090E, 0x1090F, 0x10910, 0x10911, 0x10912, 0x10913, 0x10914, 0x10915,
  18860. 0x10916, 0x10917, 0x10918, 0x10919, 0x1091A, 0x1091B, 0x10920, 0x10921,
  18861. 0x10922, 0x10923, 0x10924, 0x10925, 0x10926, 0x10927, 0x10928, 0x10929,
  18862. 0x1092A, 0x1092B, 0x1092C, 0x1092D, 0x1092E, 0x1092F, 0x10930, 0x10931,
  18863. 0x10932, 0x10933, 0x10934, 0x10935, 0x10936, 0x10937, 0x10938, 0x10939,
  18864. 0x1093F, 0x10980, 0x10981, 0x10982, 0x10983, 0x10984, 0x10985, 0x10986,
  18865. 0x10987, 0x10988, 0x10989, 0x1098A, 0x1098B, 0x1098C, 0x1098D, 0x1098E,
  18866. 0x1098F, 0x10990, 0x10991, 0x10992, 0x10993, 0x10994, 0x10995, 0x10996,
  18867. 0x10997, 0x10998, 0x10999, 0x1099A, 0x1099B, 0x1099C, 0x1099D, 0x1099E,
  18868. 0x1099F, 0x109A0, 0x109A1, 0x109A2, 0x109A3, 0x109A4, 0x109A5, 0x109A6,
  18869. 0x109A7, 0x109A8, 0x109A9, 0x109AA, 0x109AB, 0x109AC, 0x109AD, 0x109AE,
  18870. 0x109AF, 0x109B0, 0x109B1, 0x109B2, 0x109B3, 0x109B4, 0x109B5, 0x109B6,
  18871. 0x109B7, 0x109BE, 0x109BF, 0x10A00, 0x10A10, 0x10A11, 0x10A12, 0x10A13,
  18872. 0x10A15, 0x10A16, 0x10A17, 0x10A19, 0x10A1A, 0x10A1B, 0x10A1C, 0x10A1D,
  18873. 0x10A1E, 0x10A1F, 0x10A20, 0x10A21, 0x10A22, 0x10A23, 0x10A24, 0x10A25,
  18874. 0x10A26, 0x10A27, 0x10A28, 0x10A29, 0x10A2A, 0x10A2B, 0x10A2C, 0x10A2D,
  18875. 0x10A2E, 0x10A2F, 0x10A30, 0x10A31, 0x10A32, 0x10A33, 0x10A40, 0x10A41,
  18876. 0x10A42, 0x10A43, 0x10A44, 0x10A45, 0x10A46, 0x10A47, 0x10A50, 0x10A51,
  18877. 0x10A52, 0x10A53, 0x10A54, 0x10A55, 0x10A56, 0x10A57, 0x10A58, 0x10A60,
  18878. 0x10A61, 0x10A62, 0x10A63, 0x10A64, 0x10A65, 0x10A66, 0x10A67, 0x10A68,
  18879. 0x10A69, 0x10A6A, 0x10A6B, 0x10A6C, 0x10A6D, 0x10A6E, 0x10A6F, 0x10A70,
  18880. 0x10A71, 0x10A72, 0x10A73, 0x10A74, 0x10A75, 0x10A76, 0x10A77, 0x10A78,
  18881. 0x10A79, 0x10A7A, 0x10A7B, 0x10A7C, 0x10A7D, 0x10A7E, 0x10A7F, 0x10B00,
  18882. 0x10B01, 0x10B02, 0x10B03, 0x10B04, 0x10B05, 0x10B06, 0x10B07, 0x10B08,
  18883. 0x10B09, 0x10B0A, 0x10B0B, 0x10B0C, 0x10B0D, 0x10B0E, 0x10B0F, 0x10B10,
  18884. 0x10B11, 0x10B12, 0x10B13, 0x10B14, 0x10B15, 0x10B16, 0x10B17, 0x10B18,
  18885. 0x10B19, 0x10B1A, 0x10B1B, 0x10B1C, 0x10B1D, 0x10B1E, 0x10B1F, 0x10B20,
  18886. 0x10B21, 0x10B22, 0x10B23, 0x10B24, 0x10B25, 0x10B26, 0x10B27, 0x10B28,
  18887. 0x10B29, 0x10B2A, 0x10B2B, 0x10B2C, 0x10B2D, 0x10B2E, 0x10B2F, 0x10B30,
  18888. 0x10B31, 0x10B32, 0x10B33, 0x10B34, 0x10B35, 0x10B40, 0x10B41, 0x10B42,
  18889. 0x10B43, 0x10B44, 0x10B45, 0x10B46, 0x10B47, 0x10B48, 0x10B49, 0x10B4A,
  18890. 0x10B4B, 0x10B4C, 0x10B4D, 0x10B4E, 0x10B4F, 0x10B50, 0x10B51, 0x10B52,
  18891. 0x10B53, 0x10B54, 0x10B55, 0x10B58, 0x10B59, 0x10B5A, 0x10B5B, 0x10B5C,
  18892. 0x10B5D, 0x10B5E, 0x10B5F, 0x10B60, 0x10B61, 0x10B62, 0x10B63, 0x10B64,
  18893. 0x10B65, 0x10B66, 0x10B67, 0x10B68, 0x10B69, 0x10B6A, 0x10B6B, 0x10B6C,
  18894. 0x10B6D, 0x10B6E, 0x10B6F, 0x10B70, 0x10B71, 0x10B72, 0x10B78, 0x10B79,
  18895. 0x10B7A, 0x10B7B, 0x10B7C, 0x10B7D, 0x10B7E, 0x10B7F, 0x10C00, 0x10C01,
  18896. 0x10C02, 0x10C03, 0x10C04, 0x10C05, 0x10C06, 0x10C07, 0x10C08, 0x10C09,
  18897. 0x10C0A, 0x10C0B, 0x10C0C, 0x10C0D, 0x10C0E, 0x10C0F, 0x10C10, 0x10C11,
  18898. 0x10C12, 0x10C13, 0x10C14, 0x10C15, 0x10C16, 0x10C17, 0x10C18, 0x10C19,
  18899. 0x10C1A, 0x10C1B, 0x10C1C, 0x10C1D, 0x10C1E, 0x10C1F, 0x10C20, 0x10C21,
  18900. 0x10C22, 0x10C23, 0x10C24, 0x10C25, 0x10C26, 0x10C27, 0x10C28, 0x10C29,
  18901. 0x10C2A, 0x10C2B, 0x10C2C, 0x10C2D, 0x10C2E, 0x10C2F, 0x10C30, 0x10C31,
  18902. 0x10C32, 0x10C33, 0x10C34, 0x10C35, 0x10C36, 0x10C37, 0x10C38, 0x10C39,
  18903. 0x10C3A, 0x10C3B, 0x10C3C, 0x10C3D, 0x10C3E, 0x10C3F, 0x10C40, 0x10C41,
  18904. 0x10C42, 0x10C43, 0x10C44, 0x10C45, 0x10C46, 0x10C47, 0x10C48, 0x1EE00,
  18905. 0x1EE01, 0x1EE02, 0x1EE03, 0x1EE05, 0x1EE06, 0x1EE07, 0x1EE08, 0x1EE09,
  18906. 0x1EE0A, 0x1EE0B, 0x1EE0C, 0x1EE0D, 0x1EE0E, 0x1EE0F, 0x1EE10, 0x1EE11,
  18907. 0x1EE12, 0x1EE13, 0x1EE14, 0x1EE15, 0x1EE16, 0x1EE17, 0x1EE18, 0x1EE19,
  18908. 0x1EE1A, 0x1EE1B, 0x1EE1C, 0x1EE1D, 0x1EE1E, 0x1EE1F, 0x1EE21, 0x1EE22,
  18909. 0x1EE24, 0x1EE27, 0x1EE29, 0x1EE2A, 0x1EE2B, 0x1EE2C, 0x1EE2D, 0x1EE2E,
  18910. 0x1EE2F, 0x1EE30, 0x1EE31, 0x1EE32, 0x1EE34, 0x1EE35, 0x1EE36, 0x1EE37,
  18911. 0x1EE39, 0x1EE3B, 0x1EE42, 0x1EE47, 0x1EE49, 0x1EE4B, 0x1EE4D, 0x1EE4E,
  18912. 0x1EE4F, 0x1EE51, 0x1EE52, 0x1EE54, 0x1EE57, 0x1EE59, 0x1EE5B, 0x1EE5D,
  18913. 0x1EE5F, 0x1EE61, 0x1EE62, 0x1EE64, 0x1EE67, 0x1EE68, 0x1EE69, 0x1EE6A,
  18914. 0x1EE6C, 0x1EE6D, 0x1EE6E, 0x1EE6F, 0x1EE70, 0x1EE71, 0x1EE72, 0x1EE74,
  18915. 0x1EE75, 0x1EE76, 0x1EE77, 0x1EE79, 0x1EE7A, 0x1EE7B, 0x1EE7C, 0x1EE7E,
  18916. 0x1EE80, 0x1EE81, 0x1EE82, 0x1EE83, 0x1EE84, 0x1EE85, 0x1EE86, 0x1EE87,
  18917. 0x1EE88, 0x1EE89, 0x1EE8B, 0x1EE8C, 0x1EE8D, 0x1EE8E, 0x1EE8F, 0x1EE90,
  18918. 0x1EE91, 0x1EE92, 0x1EE93, 0x1EE94, 0x1EE95, 0x1EE96, 0x1EE97, 0x1EE98,
  18919. 0x1EE99, 0x1EE9A, 0x1EE9B, 0x1EEA1, 0x1EEA2, 0x1EEA3, 0x1EEA5, 0x1EEA6,
  18920. 0x1EEA7, 0x1EEA8, 0x1EEA9, 0x1EEAB, 0x1EEAC, 0x1EEAD, 0x1EEAE, 0x1EEAF,
  18921. 0x1EEB0, 0x1EEB1, 0x1EEB2, 0x1EEB3, 0x1EEB4, 0x1EEB5, 0x1EEB6, 0x1EEB7,
  18922. 0x1EEB8, 0x1EEB9, 0x1EEBA, 0x1EEBB, 0x10FFFD]
  18923. function determineBidi(cueDiv) {
  18924. var nodeStack = []
  18925. var text = ''
  18926. var charCode
  18927. if (!cueDiv || !cueDiv.childNodes) {
  18928. return 'ltr'
  18929. }
  18930. function pushNodes(nodeStack, node) {
  18931. for (var i = node.childNodes.length - 1; i >= 0; i--) {
  18932. nodeStack.push(node.childNodes[i])
  18933. }
  18934. }
  18935. function nextTextNode(nodeStack) {
  18936. if (!nodeStack || !nodeStack.length) {
  18937. return null
  18938. }
  18939. var node = nodeStack.pop()
  18940. var text = node.textContent || node.innerText
  18941. if (text) {
  18942. // TODO: This should match all unicode type B characters (paragraph
  18943. // separator characters). See issue #115.
  18944. var m = text.match(/^.*(\n|\r)/)
  18945. if (m) {
  18946. nodeStack.length = 0
  18947. return m[0]
  18948. }
  18949. return text
  18950. }
  18951. if (node.tagName === 'ruby') {
  18952. return nextTextNode(nodeStack)
  18953. }
  18954. if (node.childNodes) {
  18955. pushNodes(nodeStack, node)
  18956. return nextTextNode(nodeStack)
  18957. }
  18958. }
  18959. pushNodes(nodeStack, cueDiv)
  18960. while ((text = nextTextNode(nodeStack))) {
  18961. for (var i = 0; i < text.length; i++) {
  18962. charCode = text.charCodeAt(i)
  18963. for (var j = 0; j < strongRTLChars.length; j++) {
  18964. if (strongRTLChars[j] === charCode) {
  18965. return 'rtl'
  18966. }
  18967. }
  18968. }
  18969. }
  18970. return 'ltr'
  18971. }
  18972. function computeLinePos(cue) {
  18973. if (typeof cue.line === 'number' &&
  18974. (cue.snapToLines || (cue.line >= 0 && cue.line <= 100))) {
  18975. return cue.line
  18976. }
  18977. if (!cue.track || !cue.track.textTrackList ||
  18978. !cue.track.textTrackList.mediaElement) {
  18979. return -1
  18980. }
  18981. var track = cue.track
  18982. var trackList = track.textTrackList
  18983. var count = 0
  18984. for (var i = 0; i < trackList.length && trackList[i] !== track; i++) {
  18985. if (trackList[i].mode === 'showing') {
  18986. count++
  18987. }
  18988. }
  18989. return ++count * -1
  18990. }
  18991. function StyleBox() {
  18992. }
  18993. // Apply styles to a div. If there is no div passed then it defaults to the
  18994. // div on 'this'.
  18995. StyleBox.prototype.applyStyles = function(styles, div) {
  18996. div = div || this.div
  18997. for (var prop in styles) {
  18998. if (styles.hasOwnProperty(prop)) {
  18999. div.style[prop] = styles[prop]
  19000. }
  19001. }
  19002. }
  19003. StyleBox.prototype.formatStyle = function(val, unit) {
  19004. return val === 0 ? 0 : val + unit
  19005. }
  19006. // Constructs the computed display state of the cue (a div). Places the div
  19007. // into the overlay which should be a block level element (usually a div).
  19008. function CueStyleBox(window, cue, styleOptions) {
  19009. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent)
  19010. var color = 'rgba(255, 255, 255, 1)'
  19011. var backgroundColor = 'rgba(0, 0, 0, 0.8)'
  19012. if (isIE8) {
  19013. color = 'rgb(255, 255, 255)'
  19014. backgroundColor = 'rgb(0, 0, 0)'
  19015. }
  19016. StyleBox.call(this)
  19017. this.cue = cue
  19018. // Parse our cue's text into a DOM tree rooted at 'cueDiv'. This div will
  19019. // have inline positioning and will function as the cue background box.
  19020. this.cueDiv = parseContent(window, cue.text)
  19021. var styles = {
  19022. color: color,
  19023. backgroundColor: backgroundColor,
  19024. position: 'relative',
  19025. left: 0,
  19026. right: 0,
  19027. top: 0,
  19028. bottom: 0,
  19029. display: 'inline'
  19030. }
  19031. if (!isIE8) {
  19032. styles.writingMode = cue.vertical === '' ? 'horizontal-tb'
  19033. : cue.vertical === 'lr' ? 'vertical-lr'
  19034. : 'vertical-rl'
  19035. styles.unicodeBidi = 'plaintext'
  19036. }
  19037. this.applyStyles(styles, this.cueDiv)
  19038. // Create an absolutely positioned div that will be used to position the cue
  19039. // div. Note, all WebVTT cue-setting alignments are equivalent to the CSS
  19040. // mirrors of them except "middle" which is "center" in CSS.
  19041. this.div = window.document.createElement('div')
  19042. styles = {
  19043. textAlign: cue.align === 'middle' ? 'center' : cue.align,
  19044. font: styleOptions.font,
  19045. whiteSpace: 'pre-line',
  19046. position: 'absolute'
  19047. }
  19048. if (!isIE8) {
  19049. styles.direction = determineBidi(this.cueDiv)
  19050. styles.writingMode = cue.vertical === '' ? 'horizontal-tb'
  19051. : cue.vertical === 'lr' ? 'vertical-lr'
  19052. : 'vertical-rl'
  19053. .stylesunicodeBidi = 'plaintext'
  19054. }
  19055. this.applyStyles(styles)
  19056. this.div.appendChild(this.cueDiv)
  19057. // Calculate the distance from the reference edge of the viewport to the text
  19058. // position of the cue box. The reference edge will be resolved later when
  19059. // the box orientation styles are applied.
  19060. var textPos = 0
  19061. switch (cue.positionAlign) {
  19062. case 'start':
  19063. textPos = cue.position
  19064. break
  19065. case 'middle':
  19066. textPos = cue.position - (cue.size / 2)
  19067. break
  19068. case 'end':
  19069. textPos = cue.position - cue.size
  19070. break
  19071. }
  19072. // Horizontal box orientation; textPos is the distance from the left edge of the
  19073. // area to the left edge of the box and cue.size is the distance extending to
  19074. // the right from there.
  19075. if (cue.vertical === '') {
  19076. this.applyStyles({
  19077. left: this.formatStyle(textPos, '%'),
  19078. width: this.formatStyle(cue.size, '%')
  19079. })
  19080. // Vertical box orientation; textPos is the distance from the top edge of the
  19081. // area to the top edge of the box and cue.size is the height extending
  19082. // downwards from there.
  19083. } else {
  19084. this.applyStyles({
  19085. top: this.formatStyle(textPos, '%'),
  19086. height: this.formatStyle(cue.size, '%')
  19087. })
  19088. }
  19089. this.move = function(box) {
  19090. this.applyStyles({
  19091. top: this.formatStyle(box.top, 'px'),
  19092. bottom: this.formatStyle(box.bottom, 'px'),
  19093. left: this.formatStyle(box.left, 'px'),
  19094. right: this.formatStyle(box.right, 'px'),
  19095. height: this.formatStyle(box.height, 'px'),
  19096. width: this.formatStyle(box.width, 'px')
  19097. })
  19098. }
  19099. }
  19100. CueStyleBox.prototype = _objCreate(StyleBox.prototype)
  19101. CueStyleBox.prototype.constructor = CueStyleBox
  19102. // Represents the co-ordinates of an Element in a way that we can easily
  19103. // compute things with such as if it overlaps or intersects with another Element.
  19104. // Can initialize it with either a StyleBox or another BoxPosition.
  19105. function BoxPosition(obj) {
  19106. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent)
  19107. // Either a BoxPosition was passed in and we need to copy it, or a StyleBox
  19108. // was passed in and we need to copy the results of 'getBoundingClientRect'
  19109. // as the object returned is readonly. All co-ordinate values are in reference
  19110. // to the viewport origin (top left).
  19111. var lh, height, width, top
  19112. if (obj.div) {
  19113. height = obj.div.offsetHeight
  19114. width = obj.div.offsetWidth
  19115. top = obj.div.offsetTop
  19116. var rects = (rects = obj.div.childNodes) && (rects = rects[0]) &&
  19117. rects.getClientRects && rects.getClientRects()
  19118. obj = obj.div.getBoundingClientRect()
  19119. // In certain cases the outter div will be slightly larger then the sum of
  19120. // the inner div's lines. This could be due to bold text, etc, on some platforms.
  19121. // In this case we should get the average line height and use that. This will
  19122. // result in the desired behaviour.
  19123. lh = rects ? Math.max((rects[0] && rects[0].height) || 0, obj.height / rects.length)
  19124. : 0
  19125. }
  19126. this.left = obj.left
  19127. this.right = obj.right
  19128. this.top = obj.top || top
  19129. this.height = obj.height || height
  19130. this.bottom = obj.bottom || (top + (obj.height || height))
  19131. this.width = obj.width || width
  19132. this.lineHeight = lh !== undefined ? lh : obj.lineHeight
  19133. if (isIE8 && !this.lineHeight) {
  19134. this.lineHeight = 13
  19135. }
  19136. }
  19137. // Move the box along a particular axis. Optionally pass in an amount to move
  19138. // the box. If no amount is passed then the default is the line height of the
  19139. // box.
  19140. BoxPosition.prototype.move = function(axis, toMove) {
  19141. toMove = toMove !== undefined ? toMove : this.lineHeight
  19142. switch (axis) {
  19143. case '+x':
  19144. this.left += toMove
  19145. this.right += toMove
  19146. break
  19147. case '-x':
  19148. this.left -= toMove
  19149. this.right -= toMove
  19150. break
  19151. case '+y':
  19152. this.top += toMove
  19153. this.bottom += toMove
  19154. break
  19155. case '-y':
  19156. this.top -= toMove
  19157. this.bottom -= toMove
  19158. break
  19159. }
  19160. }
  19161. // Check if this box overlaps another box, b2.
  19162. BoxPosition.prototype.overlaps = function(b2) {
  19163. return this.left < b2.right &&
  19164. this.right > b2.left &&
  19165. this.top < b2.bottom &&
  19166. this.bottom > b2.top
  19167. }
  19168. // Check if this box overlaps any other boxes in boxes.
  19169. BoxPosition.prototype.overlapsAny = function(boxes) {
  19170. for (var i = 0; i < boxes.length; i++) {
  19171. if (this.overlaps(boxes[i])) {
  19172. return true
  19173. }
  19174. }
  19175. return false
  19176. }
  19177. // Check if this box is within another box.
  19178. BoxPosition.prototype.within = function(container) {
  19179. return this.top >= container.top &&
  19180. this.bottom <= container.bottom &&
  19181. this.left >= container.left &&
  19182. this.right <= container.right
  19183. }
  19184. // Check if this box is entirely within the container or it is overlapping
  19185. // on the edge opposite of the axis direction passed. For example, if "+x" is
  19186. // passed and the box is overlapping on the left edge of the container, then
  19187. // return true.
  19188. BoxPosition.prototype.overlapsOppositeAxis = function(container, axis) {
  19189. switch (axis) {
  19190. case '+x':
  19191. return this.left < container.left
  19192. case '-x':
  19193. return this.right > container.right
  19194. case '+y':
  19195. return this.top < container.top
  19196. case '-y':
  19197. return this.bottom > container.bottom
  19198. }
  19199. }
  19200. // Find the percentage of the area that this box is overlapping with another
  19201. // box.
  19202. BoxPosition.prototype.intersectPercentage = function(b2) {
  19203. var x = Math.max(0, Math.min(this.right, b2.right) - Math.max(this.left, b2.left))
  19204. var y = Math.max(0, Math.min(this.bottom, b2.bottom) - Math.max(this.top, b2.top))
  19205. var intersectArea = x * y
  19206. return intersectArea / (this.height * this.width)
  19207. }
  19208. // Convert the positions from this box to CSS compatible positions using
  19209. // the reference container's positions. This has to be done because this
  19210. // box's positions are in reference to the viewport origin, whereas, CSS
  19211. // values are in referecne to their respective edges.
  19212. BoxPosition.prototype.toCSSCompatValues = function(reference) {
  19213. return {
  19214. top: this.top - reference.top,
  19215. bottom: reference.bottom - this.bottom,
  19216. left: this.left - reference.left,
  19217. right: reference.right - this.right,
  19218. height: this.height,
  19219. width: this.width
  19220. }
  19221. }
  19222. // Get an object that represents the box's position without anything extra.
  19223. // Can pass a StyleBox, HTMLElement, or another BoxPositon.
  19224. BoxPosition.getSimpleBoxPosition = function(obj) {
  19225. var height = obj.div ? obj.div.offsetHeight : obj.tagName ? obj.offsetHeight : 0
  19226. var width = obj.div ? obj.div.offsetWidth : obj.tagName ? obj.offsetWidth : 0
  19227. var top = obj.div ? obj.div.offsetTop : obj.tagName ? obj.offsetTop : 0
  19228. obj = obj.div ? obj.div.getBoundingClientRect()
  19229. : obj.tagName ? obj.getBoundingClientRect() : obj
  19230. var ret = {
  19231. left: obj.left,
  19232. right: obj.right,
  19233. top: obj.top || top,
  19234. height: obj.height || height,
  19235. bottom: obj.bottom || (top + (obj.height || height)),
  19236. width: obj.width || width
  19237. }
  19238. return ret
  19239. }
  19240. // Move a StyleBox to its specified, or next best, position. The containerBox
  19241. // is the box that contains the StyleBox, such as a div. boxPositions are
  19242. // a list of other boxes that the styleBox can't overlap with.
  19243. function moveBoxToLinePosition(window, styleBox, containerBox, boxPositions) {
  19244. // Find the best position for a cue box, b, on the video. The axis parameter
  19245. // is a list of axis, the order of which, it will move the box along. For example:
  19246. // Passing ["+x", "-x"] will move the box first along the x axis in the positive
  19247. // direction. If it doesn't find a good position for it there it will then move
  19248. // it along the x axis in the negative direction.
  19249. function findBestPosition(b, axis) {
  19250. var bestPosition
  19251. var specifiedPosition = new BoxPosition(b)
  19252. var percentage = 1 // Highest possible so the first thing we get is better.
  19253. for (var i = 0; i < axis.length; i++) {
  19254. while (b.overlapsOppositeAxis(containerBox, axis[i]) ||
  19255. (b.within(containerBox) && b.overlapsAny(boxPositions))) {
  19256. b.move(axis[i])
  19257. }
  19258. // We found a spot where we aren't overlapping anything. This is our
  19259. // best position.
  19260. if (b.within(containerBox)) {
  19261. return b
  19262. }
  19263. var p = b.intersectPercentage(containerBox)
  19264. // If we're outside the container box less then we were on our last try
  19265. // then remember this position as the best position.
  19266. if (percentage > p) {
  19267. bestPosition = new BoxPosition(b)
  19268. percentage = p
  19269. }
  19270. // Reset the box position to the specified position.
  19271. b = new BoxPosition(specifiedPosition)
  19272. }
  19273. return bestPosition || specifiedPosition
  19274. }
  19275. var boxPosition = new BoxPosition(styleBox)
  19276. var cue = styleBox.cue
  19277. var linePos = computeLinePos(cue)
  19278. var axis = []
  19279. // If we have a line number to align the cue to.
  19280. if (cue.snapToLines) {
  19281. var size
  19282. switch (cue.vertical) {
  19283. case '':
  19284. axis = ['+y', '-y']
  19285. size = 'height'
  19286. break
  19287. case 'rl':
  19288. axis = ['+x', '-x']
  19289. size = 'width'
  19290. break
  19291. case 'lr':
  19292. axis = ['-x', '+x']
  19293. size = 'width'
  19294. break
  19295. }
  19296. var step = boxPosition.lineHeight
  19297. var position = step * Math.round(linePos)
  19298. var maxPosition = containerBox[size] + step
  19299. var initialAxis = axis[0]
  19300. // If the specified intial position is greater then the max position then
  19301. // clamp the box to the amount of steps it would take for the box to
  19302. // reach the max position.
  19303. if (Math.abs(position) > maxPosition) {
  19304. position = position < 0 ? -1 : 1
  19305. position *= Math.ceil(maxPosition / step) * step
  19306. }
  19307. // If computed line position returns negative then line numbers are
  19308. // relative to the bottom of the video instead of the top. Therefore, we
  19309. // need to increase our initial position by the length or width of the
  19310. // video, depending on the writing direction, and reverse our axis directions.
  19311. if (linePos < 0) {
  19312. position += cue.vertical === '' ? containerBox.height : containerBox.width
  19313. axis = axis.reverse()
  19314. }
  19315. // Move the box to the specified position. This may not be its best
  19316. // position.
  19317. boxPosition.move(initialAxis, position)
  19318. } else {
  19319. // If we have a percentage line value for the cue.
  19320. var calculatedPercentage = (boxPosition.lineHeight / containerBox.height) * 100
  19321. switch (cue.lineAlign) {
  19322. case 'middle':
  19323. linePos -= (calculatedPercentage / 2)
  19324. break
  19325. case 'end':
  19326. linePos -= calculatedPercentage
  19327. break
  19328. }
  19329. // Apply initial line position to the cue box.
  19330. switch (cue.vertical) {
  19331. case '':
  19332. styleBox.applyStyles({
  19333. top: styleBox.formatStyle(linePos, '%')
  19334. })
  19335. break
  19336. case 'rl':
  19337. styleBox.applyStyles({
  19338. left: styleBox.formatStyle(linePos, '%')
  19339. })
  19340. break
  19341. case 'lr':
  19342. styleBox.applyStyles({
  19343. right: styleBox.formatStyle(linePos, '%')
  19344. })
  19345. break
  19346. }
  19347. axis = ['+y', '-x', '+x', '-y']
  19348. // Get the box position again after we've applied the specified positioning
  19349. // to it.
  19350. boxPosition = new BoxPosition(styleBox)
  19351. }
  19352. var bestPosition = findBestPosition(boxPosition, axis)
  19353. styleBox.move(bestPosition.toCSSCompatValues(containerBox))
  19354. }
  19355. function WebVTT() {
  19356. // Nothing
  19357. }
  19358. // Helper to allow strings to be decoded instead of the default binary utf8 data.
  19359. WebVTT.StringDecoder = function() {
  19360. return {
  19361. decode: function(data) {
  19362. if (!data) {
  19363. return ''
  19364. }
  19365. if (typeof data !== 'string') {
  19366. throw new Error('Error - expected string data.')
  19367. }
  19368. return decodeURIComponent(encodeURIComponent(data))
  19369. }
  19370. }
  19371. }
  19372. WebVTT.convertCueToDOMTree = function(window, cuetext) {
  19373. if (!window || !cuetext) {
  19374. return null
  19375. }
  19376. return parseContent(window, cuetext)
  19377. }
  19378. var FONT_SIZE_PERCENT = 0.05
  19379. var FONT_STYLE = 'sans-serif'
  19380. var CUE_BACKGROUND_PADDING = '1.5%'
  19381. // Runs the processing model over the cues and regions passed to it.
  19382. // @param overlay A block level element (usually a div) that the computed cues
  19383. // and regions will be placed into.
  19384. WebVTT.processCues = function(window, cues, overlay) {
  19385. if (!window || !cues || !overlay) {
  19386. return null
  19387. }
  19388. // Remove all previous children.
  19389. while (overlay.firstChild) {
  19390. overlay.removeChild(overlay.firstChild)
  19391. }
  19392. var paddedOverlay = window.document.createElement('div')
  19393. paddedOverlay.style.position = 'absolute'
  19394. paddedOverlay.style.left = '0'
  19395. paddedOverlay.style.right = '0'
  19396. paddedOverlay.style.top = '0'
  19397. paddedOverlay.style.bottom = '0'
  19398. paddedOverlay.style.margin = CUE_BACKGROUND_PADDING
  19399. overlay.appendChild(paddedOverlay)
  19400. // Determine if we need to compute the display states of the cues. This could
  19401. // be the case if a cue's state has been changed since the last computation or
  19402. // if it has not been computed yet.
  19403. function shouldCompute(cues) {
  19404. for (var i = 0; i < cues.length; i++) {
  19405. if (cues[i].hasBeenReset || !cues[i].displayState) {
  19406. return true
  19407. }
  19408. }
  19409. return false
  19410. }
  19411. // We don't need to recompute the cues' display states. Just reuse them.
  19412. if (!shouldCompute(cues)) {
  19413. for (var i = 0; i < cues.length; i++) {
  19414. paddedOverlay.appendChild(cues[i].displayState)
  19415. }
  19416. return
  19417. }
  19418. var boxPositions = []
  19419. var containerBox = BoxPosition.getSimpleBoxPosition(paddedOverlay)
  19420. var fontSize = Math.round(containerBox.height * FONT_SIZE_PERCENT * 100) / 100
  19421. var styleOptions = {
  19422. font: fontSize + 'px ' + FONT_STYLE
  19423. };
  19424. (function() {
  19425. var styleBox, cue
  19426. for (var i = 0; i < cues.length; i++) {
  19427. cue = cues[i]
  19428. // Compute the intial position and styles of the cue div.
  19429. styleBox = new CueStyleBox(window, cue, styleOptions)
  19430. paddedOverlay.appendChild(styleBox.div)
  19431. // Move the cue div to it's correct line position.
  19432. moveBoxToLinePosition(window, styleBox, containerBox, boxPositions)
  19433. // Remember the computed div so that we don't have to recompute it later
  19434. // if we don't have too.
  19435. cue.displayState = styleBox.div
  19436. boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox))
  19437. }
  19438. })()
  19439. }
  19440. WebVTT.Parser = function(window, vttjs, decoder) {
  19441. if (!decoder) {
  19442. decoder = vttjs
  19443. vttjs = {}
  19444. }
  19445. if (!vttjs) {
  19446. vttjs = {}
  19447. }
  19448. this.window = window
  19449. this.vttjs = vttjs
  19450. this.state = 'INITIAL'
  19451. this.buffer = ''
  19452. this.decoder = decoder || new TextDecoder('utf8')
  19453. this.regionList = []
  19454. }
  19455. WebVTT.Parser.prototype = {
  19456. // If the error is a ParsingError then report it to the consumer if
  19457. // possible. If it's not a ParsingError then throw it like normal.
  19458. reportOrThrowError: function(e) {
  19459. if (e instanceof ParsingError) {
  19460. this.onparsingerror && this.onparsingerror(e)
  19461. } else {
  19462. throw e
  19463. }
  19464. },
  19465. parse: function(data) {
  19466. var self = this
  19467. // If there is no data then we won't decode it, but will just try to parse
  19468. // whatever is in buffer already. This may occur in circumstances, for
  19469. // example when flush() is called.
  19470. if (data) {
  19471. // Try to decode the data that we received.
  19472. self.buffer += self.decoder.decode(data, { stream: true })
  19473. }
  19474. function collectNextLine() {
  19475. var buffer = self.buffer
  19476. var pos = 0
  19477. while (pos < buffer.length && buffer[pos] !== '\r' && buffer[pos] !== '\n') {
  19478. ++pos
  19479. }
  19480. var line = buffer.substr(0, pos)
  19481. // Advance the buffer early in case we fail below.
  19482. if (buffer[pos] === '\r') {
  19483. ++pos
  19484. }
  19485. if (buffer[pos] === '\n') {
  19486. ++pos
  19487. }
  19488. self.buffer = buffer.substr(pos)
  19489. return line
  19490. }
  19491. // 3.4 WebVTT region and WebVTT region settings syntax
  19492. function parseRegion(input) {
  19493. var settings = new Settings()
  19494. parseOptions(input, function(k, v) {
  19495. switch (k) {
  19496. case 'id':
  19497. settings.set(k, v)
  19498. break
  19499. case 'width':
  19500. settings.percent(k, v)
  19501. break
  19502. case 'lines':
  19503. settings.integer(k, v)
  19504. break
  19505. case 'regionanchor':
  19506. case 'viewportanchor':
  19507. var xy = v.split(',')
  19508. if (xy.length !== 2) {
  19509. break
  19510. }
  19511. // We have to make sure both x and y parse, so use a temporary
  19512. // settings object here.
  19513. var anchor = new Settings()
  19514. anchor.percent('x', xy[0])
  19515. anchor.percent('y', xy[1])
  19516. if (!anchor.has('x') || !anchor.has('y')) {
  19517. break
  19518. }
  19519. settings.set(k + 'X', anchor.get('x'))
  19520. settings.set(k + 'Y', anchor.get('y'))
  19521. break
  19522. case 'scroll':
  19523. settings.alt(k, v, ['up'])
  19524. break
  19525. }
  19526. }, /=/, /\s/)
  19527. // Create the region, using default values for any values that were not
  19528. // specified.
  19529. if (settings.has('id')) {
  19530. var region = new (self.vttjs.VTTRegion || self.window.VTTRegion)()
  19531. region.width = settings.get('width', 100)
  19532. region.lines = settings.get('lines', 3)
  19533. region.regionAnchorX = settings.get('regionanchorX', 0)
  19534. region.regionAnchorY = settings.get('regionanchorY', 100)
  19535. region.viewportAnchorX = settings.get('viewportanchorX', 0)
  19536. region.viewportAnchorY = settings.get('viewportanchorY', 100)
  19537. region.scroll = settings.get('scroll', '')
  19538. // Register the region.
  19539. self.onregion && self.onregion(region)
  19540. // Remember the VTTRegion for later in case we parse any VTTCues that
  19541. // reference it.
  19542. self.regionList.push({
  19543. id: settings.get('id'),
  19544. region: region
  19545. })
  19546. }
  19547. }
  19548. // 3.2 WebVTT metadata header syntax
  19549. function parseHeader(input) {
  19550. parseOptions(input, function(k, v) {
  19551. switch (k) {
  19552. case 'Region':
  19553. // 3.3 WebVTT region metadata header syntax
  19554. parseRegion(v)
  19555. break
  19556. }
  19557. }, /:/)
  19558. }
  19559. // 5.1 WebVTT file parsing.
  19560. try {
  19561. var line
  19562. if (self.state === 'INITIAL') {
  19563. // We can't start parsing until we have the first line.
  19564. if (!/\r\n|\n/.test(self.buffer)) {
  19565. return this
  19566. }
  19567. line = collectNextLine()
  19568. var m = line.match(/^WEBVTT([ \t].*)?$/)
  19569. if (!m || !m[0]) {
  19570. throw new ParsingError(ParsingError.Errors.BadSignature)
  19571. }
  19572. self.state = 'HEADER'
  19573. }
  19574. var alreadyCollectedLine = false
  19575. while (self.buffer) {
  19576. // We can't parse a line until we have the full line.
  19577. if (!/\r\n|\n/.test(self.buffer)) {
  19578. return this
  19579. }
  19580. if (!alreadyCollectedLine) {
  19581. line = collectNextLine()
  19582. } else {
  19583. alreadyCollectedLine = false
  19584. }
  19585. switch (self.state) {
  19586. case 'HEADER':
  19587. // 13-18 - Allow a header (metadata) under the WEBVTT line.
  19588. if (/:/.test(line)) {
  19589. parseHeader(line)
  19590. } else if (!line) {
  19591. // An empty line terminates the header and starts the body (cues).
  19592. self.state = 'ID'
  19593. }
  19594. continue
  19595. case 'NOTE':
  19596. // Ignore NOTE blocks.
  19597. if (!line) {
  19598. self.state = 'ID'
  19599. }
  19600. continue
  19601. case 'ID':
  19602. // Check for the start of NOTE blocks.
  19603. if (/^NOTE($|[ \t])/.test(line)) {
  19604. self.state = 'NOTE'
  19605. break
  19606. }
  19607. // 19-29 - Allow any number of line terminators, then initialize new cue values.
  19608. if (!line) {
  19609. continue
  19610. }
  19611. self.cue = new (self.vttjs.VTTCue || self.window.VTTCue)(0, 0, '')
  19612. self.state = 'CUE'
  19613. // 30-39 - Check if self line contains an optional identifier or timing data.
  19614. if (line.indexOf('-->') === -1) {
  19615. self.cue.id = line
  19616. continue
  19617. }
  19618. // Process line as start of a cue.
  19619. /* falls through*/
  19620. case 'CUE':
  19621. // 40 - Collect cue timings and settings.
  19622. try {
  19623. parseCue(line, self.cue, self.regionList)
  19624. } catch (e) {
  19625. self.reportOrThrowError(e)
  19626. // In case of an error ignore rest of the cue.
  19627. self.cue = null
  19628. self.state = 'BADCUE'
  19629. continue
  19630. }
  19631. self.state = 'CUETEXT'
  19632. continue
  19633. case 'CUETEXT':
  19634. var hasSubstring = line.indexOf('-->') !== -1
  19635. // 34 - If we have an empty line then report the cue.
  19636. // 35 - If we have the special substring '-->' then report the cue,
  19637. // but do not collect the line as we need to process the current
  19638. // one as a new cue.
  19639. if (!line || hasSubstring && (alreadyCollectedLine = true)) {
  19640. // We are done parsing self cue.
  19641. self.oncue && self.oncue(self.cue)
  19642. self.cue = null
  19643. self.state = 'ID'
  19644. continue
  19645. }
  19646. if (self.cue.text) {
  19647. self.cue.text += '\n'
  19648. }
  19649. self.cue.text += line
  19650. continue
  19651. case 'BADCUE': // BADCUE
  19652. // 54-62 - Collect and discard the remaining cue.
  19653. if (!line) {
  19654. self.state = 'ID'
  19655. }
  19656. continue
  19657. }
  19658. }
  19659. } catch (e) {
  19660. self.reportOrThrowError(e)
  19661. // If we are currently parsing a cue, report what we have.
  19662. if (self.state === 'CUETEXT' && self.cue && self.oncue) {
  19663. self.oncue(self.cue)
  19664. }
  19665. self.cue = null
  19666. // Enter BADWEBVTT state if header was not parsed correctly otherwise
  19667. // another exception occurred so enter BADCUE state.
  19668. self.state = self.state === 'INITIAL' ? 'BADWEBVTT' : 'BADCUE'
  19669. }
  19670. return this
  19671. },
  19672. flush: function() {
  19673. var self = this
  19674. try {
  19675. // Finish decoding the stream.
  19676. self.buffer += self.decoder.decode()
  19677. // Synthesize the end of the current cue or region.
  19678. if (self.cue || self.state === 'HEADER') {
  19679. self.buffer += '\n\n'
  19680. self.parse()
  19681. }
  19682. // If we've flushed, parsed, and we're still on the INITIAL state then
  19683. // that means we don't have enough of the stream to parse the first
  19684. // line.
  19685. if (self.state === 'INITIAL') {
  19686. throw new ParsingError(ParsingError.Errors.BadSignature)
  19687. }
  19688. } catch (e) {
  19689. self.reportOrThrowError(e)
  19690. }
  19691. self.onflush && self.onflush()
  19692. return this
  19693. }
  19694. }
  19695. global.WebVTT = WebVTT
  19696. }(this, (this.vttjs || {})))