video.js 662 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664
  1. /**
  2. * @license
  3. * Video.js 5.5.3 <http://videojs.com/>
  4. * Copyright Brightcove, Inc. <https://www.brightcove.com/>
  5. * Available under Apache License Version 2.0
  6. * <https://github.com/videojs/video.js/blob/master/LICENSE>
  7. *
  8. * Includes vtt.js <https://github.com/mozilla/vtt.js>
  9. * Available under Apache License Version 2.0
  10. * <https://github.com/mozilla/vtt.js/blob/master/LICENSE>
  11. */
  12. (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(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
  13. (function (global){
  14. var topLevel = typeof global !== 'undefined' ? global :
  15. typeof window !== 'undefined' ? window : {}
  16. var minDoc = _dereq_('min-document');
  17. if (typeof document !== 'undefined') {
  18. module.exports = document;
  19. } else {
  20. var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
  21. if (!doccy) {
  22. doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
  23. }
  24. module.exports = doccy;
  25. }
  26. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  27. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9nbG9iYWwvZG9jdW1lbnQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwiZmlsZSI6ImdlbmVyYXRlZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgdG9wTGV2ZWwgPSB0eXBlb2YgZ2xvYmFsICE9PSAndW5kZWZpbmVkJyA/IGdsb2JhbCA6XG4gICAgdHlwZW9mIHdpbmRvdyAhPT0gJ3VuZGVmaW5lZCcgPyB3aW5kb3cgOiB7fVxudmFyIG1pbkRvYyA9IHJlcXVpcmUoJ21pbi1kb2N1bWVudCcpO1xuXG5pZiAodHlwZW9mIGRvY3VtZW50ICE9PSAndW5kZWZpbmVkJykge1xuICAgIG1vZHVsZS5leHBvcnRzID0gZG9jdW1lbnQ7XG59IGVsc2Uge1xuICAgIHZhciBkb2NjeSA9IHRvcExldmVsWydfX0dMT0JBTF9ET0NVTUVOVF9DQUNIRUA0J107XG5cbiAgICBpZiAoIWRvY2N5KSB7XG4gICAgICAgIGRvY2N5ID0gdG9wTGV2ZWxbJ19fR0xPQkFMX0RPQ1VNRU5UX0NBQ0hFQDQnXSA9IG1pbkRvYztcbiAgICB9XG5cbiAgICBtb2R1bGUuZXhwb3J0cyA9IGRvY2N5O1xufVxuIl19
  28. },{"min-document":3}],2:[function(_dereq_,module,exports){
  29. (function (global){
  30. if (typeof window !== "undefined") {
  31. module.exports = window;
  32. } else if (typeof global !== "undefined") {
  33. module.exports = global;
  34. } else if (typeof self !== "undefined"){
  35. module.exports = self;
  36. } else {
  37. module.exports = {};
  38. }
  39. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  40. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9nbG9iYWwvd2luZG93LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiaWYgKHR5cGVvZiB3aW5kb3cgIT09IFwidW5kZWZpbmVkXCIpIHtcbiAgICBtb2R1bGUuZXhwb3J0cyA9IHdpbmRvdztcbn0gZWxzZSBpZiAodHlwZW9mIGdsb2JhbCAhPT0gXCJ1bmRlZmluZWRcIikge1xuICAgIG1vZHVsZS5leHBvcnRzID0gZ2xvYmFsO1xufSBlbHNlIGlmICh0eXBlb2Ygc2VsZiAhPT0gXCJ1bmRlZmluZWRcIil7XG4gICAgbW9kdWxlLmV4cG9ydHMgPSBzZWxmO1xufSBlbHNlIHtcbiAgICBtb2R1bGUuZXhwb3J0cyA9IHt9O1xufVxuIl19
  41. },{}],3:[function(_dereq_,module,exports){
  42. },{}],4:[function(_dereq_,module,exports){
  43. var getNative = _dereq_('../internal/getNative');
  44. /* Native method references for those with the same name as other `lodash` methods. */
  45. var nativeNow = getNative(Date, 'now');
  46. /**
  47. * Gets the number of milliseconds that have elapsed since the Unix epoch
  48. * (1 January 1970 00:00:00 UTC).
  49. *
  50. * @static
  51. * @memberOf _
  52. * @category Date
  53. * @example
  54. *
  55. * _.defer(function(stamp) {
  56. * console.log(_.now() - stamp);
  57. * }, _.now());
  58. * // => logs the number of milliseconds it took for the deferred function to be invoked
  59. */
  60. var now = nativeNow || function() {
  61. return new Date().getTime();
  62. };
  63. module.exports = now;
  64. },{"../internal/getNative":20}],5:[function(_dereq_,module,exports){
  65. var isObject = _dereq_('../lang/isObject'),
  66. now = _dereq_('../date/now');
  67. /** Used as the `TypeError` message for "Functions" methods. */
  68. var FUNC_ERROR_TEXT = 'Expected a function';
  69. /* Native method references for those with the same name as other `lodash` methods. */
  70. var nativeMax = Math.max;
  71. /**
  72. * Creates a debounced function that delays invoking `func` until after `wait`
  73. * milliseconds have elapsed since the last time the debounced function was
  74. * invoked. The debounced function comes with a `cancel` method to cancel
  75. * delayed invocations. Provide an options object to indicate that `func`
  76. * should be invoked on the leading and/or trailing edge of the `wait` timeout.
  77. * Subsequent calls to the debounced function return the result of the last
  78. * `func` invocation.
  79. *
  80. * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
  81. * on the trailing edge of the timeout only if the the debounced function is
  82. * invoked more than once during the `wait` timeout.
  83. *
  84. * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
  85. * for details over the differences between `_.debounce` and `_.throttle`.
  86. *
  87. * @static
  88. * @memberOf _
  89. * @category Function
  90. * @param {Function} func The function to debounce.
  91. * @param {number} [wait=0] The number of milliseconds to delay.
  92. * @param {Object} [options] The options object.
  93. * @param {boolean} [options.leading=false] Specify invoking on the leading
  94. * edge of the timeout.
  95. * @param {number} [options.maxWait] The maximum time `func` is allowed to be
  96. * delayed before it's invoked.
  97. * @param {boolean} [options.trailing=true] Specify invoking on the trailing
  98. * edge of the timeout.
  99. * @returns {Function} Returns the new debounced function.
  100. * @example
  101. *
  102. * // avoid costly calculations while the window size is in flux
  103. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  104. *
  105. * // invoke `sendMail` when the click event is fired, debouncing subsequent calls
  106. * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
  107. * 'leading': true,
  108. * 'trailing': false
  109. * }));
  110. *
  111. * // ensure `batchLog` is invoked once after 1 second of debounced calls
  112. * var source = new EventSource('/stream');
  113. * jQuery(source).on('message', _.debounce(batchLog, 250, {
  114. * 'maxWait': 1000
  115. * }));
  116. *
  117. * // cancel a debounced call
  118. * var todoChanges = _.debounce(batchLog, 1000);
  119. * Object.observe(models.todo, todoChanges);
  120. *
  121. * Object.observe(models, function(changes) {
  122. * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {
  123. * todoChanges.cancel();
  124. * }
  125. * }, ['delete']);
  126. *
  127. * // ...at some point `models.todo` is changed
  128. * models.todo.completed = true;
  129. *
  130. * // ...before 1 second has passed `models.todo` is deleted
  131. * // which cancels the debounced `todoChanges` call
  132. * delete models.todo;
  133. */
  134. function debounce(func, wait, options) {
  135. var args,
  136. maxTimeoutId,
  137. result,
  138. stamp,
  139. thisArg,
  140. timeoutId,
  141. trailingCall,
  142. lastCalled = 0,
  143. maxWait = false,
  144. trailing = true;
  145. if (typeof func != 'function') {
  146. throw new TypeError(FUNC_ERROR_TEXT);
  147. }
  148. wait = wait < 0 ? 0 : (+wait || 0);
  149. if (options === true) {
  150. var leading = true;
  151. trailing = false;
  152. } else if (isObject(options)) {
  153. leading = !!options.leading;
  154. maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
  155. trailing = 'trailing' in options ? !!options.trailing : trailing;
  156. }
  157. function cancel() {
  158. if (timeoutId) {
  159. clearTimeout(timeoutId);
  160. }
  161. if (maxTimeoutId) {
  162. clearTimeout(maxTimeoutId);
  163. }
  164. lastCalled = 0;
  165. maxTimeoutId = timeoutId = trailingCall = undefined;
  166. }
  167. function complete(isCalled, id) {
  168. if (id) {
  169. clearTimeout(id);
  170. }
  171. maxTimeoutId = timeoutId = trailingCall = undefined;
  172. if (isCalled) {
  173. lastCalled = now();
  174. result = func.apply(thisArg, args);
  175. if (!timeoutId && !maxTimeoutId) {
  176. args = thisArg = undefined;
  177. }
  178. }
  179. }
  180. function delayed() {
  181. var remaining = wait - (now() - stamp);
  182. if (remaining <= 0 || remaining > wait) {
  183. complete(trailingCall, maxTimeoutId);
  184. } else {
  185. timeoutId = setTimeout(delayed, remaining);
  186. }
  187. }
  188. function maxDelayed() {
  189. complete(trailing, timeoutId);
  190. }
  191. function debounced() {
  192. args = arguments;
  193. stamp = now();
  194. thisArg = this;
  195. trailingCall = trailing && (timeoutId || !leading);
  196. if (maxWait === false) {
  197. var leadingCall = leading && !timeoutId;
  198. } else {
  199. if (!maxTimeoutId && !leading) {
  200. lastCalled = stamp;
  201. }
  202. var remaining = maxWait - (stamp - lastCalled),
  203. isCalled = remaining <= 0 || remaining > maxWait;
  204. if (isCalled) {
  205. if (maxTimeoutId) {
  206. maxTimeoutId = clearTimeout(maxTimeoutId);
  207. }
  208. lastCalled = stamp;
  209. result = func.apply(thisArg, args);
  210. }
  211. else if (!maxTimeoutId) {
  212. maxTimeoutId = setTimeout(maxDelayed, remaining);
  213. }
  214. }
  215. if (isCalled && timeoutId) {
  216. timeoutId = clearTimeout(timeoutId);
  217. }
  218. else if (!timeoutId && wait !== maxWait) {
  219. timeoutId = setTimeout(delayed, wait);
  220. }
  221. if (leadingCall) {
  222. isCalled = true;
  223. result = func.apply(thisArg, args);
  224. }
  225. if (isCalled && !timeoutId && !maxTimeoutId) {
  226. args = thisArg = undefined;
  227. }
  228. return result;
  229. }
  230. debounced.cancel = cancel;
  231. return debounced;
  232. }
  233. module.exports = debounce;
  234. },{"../date/now":4,"../lang/isObject":33}],6:[function(_dereq_,module,exports){
  235. /** Used as the `TypeError` message for "Functions" methods. */
  236. var FUNC_ERROR_TEXT = 'Expected a function';
  237. /* Native method references for those with the same name as other `lodash` methods. */
  238. var nativeMax = Math.max;
  239. /**
  240. * Creates a function that invokes `func` with the `this` binding of the
  241. * created function and arguments from `start` and beyond provided as an array.
  242. *
  243. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
  244. *
  245. * @static
  246. * @memberOf _
  247. * @category Function
  248. * @param {Function} func The function to apply a rest parameter to.
  249. * @param {number} [start=func.length-1] The start position of the rest parameter.
  250. * @returns {Function} Returns the new function.
  251. * @example
  252. *
  253. * var say = _.restParam(function(what, names) {
  254. * return what + ' ' + _.initial(names).join(', ') +
  255. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  256. * });
  257. *
  258. * say('hello', 'fred', 'barney', 'pebbles');
  259. * // => 'hello fred, barney, & pebbles'
  260. */
  261. function restParam(func, start) {
  262. if (typeof func != 'function') {
  263. throw new TypeError(FUNC_ERROR_TEXT);
  264. }
  265. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  266. return function() {
  267. var args = arguments,
  268. index = -1,
  269. length = nativeMax(args.length - start, 0),
  270. rest = Array(length);
  271. while (++index < length) {
  272. rest[index] = args[start + index];
  273. }
  274. switch (start) {
  275. case 0: return func.call(this, rest);
  276. case 1: return func.call(this, args[0], rest);
  277. case 2: return func.call(this, args[0], args[1], rest);
  278. }
  279. var otherArgs = Array(start + 1);
  280. index = -1;
  281. while (++index < start) {
  282. otherArgs[index] = args[index];
  283. }
  284. otherArgs[start] = rest;
  285. return func.apply(this, otherArgs);
  286. };
  287. }
  288. module.exports = restParam;
  289. },{}],7:[function(_dereq_,module,exports){
  290. var debounce = _dereq_('./debounce'),
  291. isObject = _dereq_('../lang/isObject');
  292. /** Used as the `TypeError` message for "Functions" methods. */
  293. var FUNC_ERROR_TEXT = 'Expected a function';
  294. /**
  295. * Creates a throttled function that only invokes `func` at most once per
  296. * every `wait` milliseconds. The throttled function comes with a `cancel`
  297. * method to cancel delayed invocations. Provide an options object to indicate
  298. * that `func` should be invoked on the leading and/or trailing edge of the
  299. * `wait` timeout. Subsequent calls to the throttled function return the
  300. * result of the last `func` call.
  301. *
  302. * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
  303. * on the trailing edge of the timeout only if the the throttled function is
  304. * invoked more than once during the `wait` timeout.
  305. *
  306. * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
  307. * for details over the differences between `_.throttle` and `_.debounce`.
  308. *
  309. * @static
  310. * @memberOf _
  311. * @category Function
  312. * @param {Function} func The function to throttle.
  313. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  314. * @param {Object} [options] The options object.
  315. * @param {boolean} [options.leading=true] Specify invoking on the leading
  316. * edge of the timeout.
  317. * @param {boolean} [options.trailing=true] Specify invoking on the trailing
  318. * edge of the timeout.
  319. * @returns {Function} Returns the new throttled function.
  320. * @example
  321. *
  322. * // avoid excessively updating the position while scrolling
  323. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  324. *
  325. * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes
  326. * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
  327. * 'trailing': false
  328. * }));
  329. *
  330. * // cancel a trailing throttled call
  331. * jQuery(window).on('popstate', throttled.cancel);
  332. */
  333. function throttle(func, wait, options) {
  334. var leading = true,
  335. trailing = true;
  336. if (typeof func != 'function') {
  337. throw new TypeError(FUNC_ERROR_TEXT);
  338. }
  339. if (options === false) {
  340. leading = false;
  341. } else if (isObject(options)) {
  342. leading = 'leading' in options ? !!options.leading : leading;
  343. trailing = 'trailing' in options ? !!options.trailing : trailing;
  344. }
  345. return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing });
  346. }
  347. module.exports = throttle;
  348. },{"../lang/isObject":33,"./debounce":5}],8:[function(_dereq_,module,exports){
  349. /**
  350. * Copies the values of `source` to `array`.
  351. *
  352. * @private
  353. * @param {Array} source The array to copy values from.
  354. * @param {Array} [array=[]] The array to copy values to.
  355. * @returns {Array} Returns `array`.
  356. */
  357. function arrayCopy(source, array) {
  358. var index = -1,
  359. length = source.length;
  360. array || (array = Array(length));
  361. while (++index < length) {
  362. array[index] = source[index];
  363. }
  364. return array;
  365. }
  366. module.exports = arrayCopy;
  367. },{}],9:[function(_dereq_,module,exports){
  368. /**
  369. * A specialized version of `_.forEach` for arrays without support for callback
  370. * shorthands and `this` binding.
  371. *
  372. * @private
  373. * @param {Array} array The array to iterate over.
  374. * @param {Function} iteratee The function invoked per iteration.
  375. * @returns {Array} Returns `array`.
  376. */
  377. function arrayEach(array, iteratee) {
  378. var index = -1,
  379. length = array.length;
  380. while (++index < length) {
  381. if (iteratee(array[index], index, array) === false) {
  382. break;
  383. }
  384. }
  385. return array;
  386. }
  387. module.exports = arrayEach;
  388. },{}],10:[function(_dereq_,module,exports){
  389. /**
  390. * Copies properties of `source` to `object`.
  391. *
  392. * @private
  393. * @param {Object} source The object to copy properties from.
  394. * @param {Array} props The property names to copy.
  395. * @param {Object} [object={}] The object to copy properties to.
  396. * @returns {Object} Returns `object`.
  397. */
  398. function baseCopy(source, props, object) {
  399. object || (object = {});
  400. var index = -1,
  401. length = props.length;
  402. while (++index < length) {
  403. var key = props[index];
  404. object[key] = source[key];
  405. }
  406. return object;
  407. }
  408. module.exports = baseCopy;
  409. },{}],11:[function(_dereq_,module,exports){
  410. var createBaseFor = _dereq_('./createBaseFor');
  411. /**
  412. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  413. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  414. * each property. Iteratee functions may exit iteration early by explicitly
  415. * returning `false`.
  416. *
  417. * @private
  418. * @param {Object} object The object to iterate over.
  419. * @param {Function} iteratee The function invoked per iteration.
  420. * @param {Function} keysFunc The function to get the keys of `object`.
  421. * @returns {Object} Returns `object`.
  422. */
  423. var baseFor = createBaseFor();
  424. module.exports = baseFor;
  425. },{"./createBaseFor":18}],12:[function(_dereq_,module,exports){
  426. var baseFor = _dereq_('./baseFor'),
  427. keysIn = _dereq_('../object/keysIn');
  428. /**
  429. * The base implementation of `_.forIn` without support for callback
  430. * shorthands and `this` binding.
  431. *
  432. * @private
  433. * @param {Object} object The object to iterate over.
  434. * @param {Function} iteratee The function invoked per iteration.
  435. * @returns {Object} Returns `object`.
  436. */
  437. function baseForIn(object, iteratee) {
  438. return baseFor(object, iteratee, keysIn);
  439. }
  440. module.exports = baseForIn;
  441. },{"../object/keysIn":39,"./baseFor":11}],13:[function(_dereq_,module,exports){
  442. var arrayEach = _dereq_('./arrayEach'),
  443. baseMergeDeep = _dereq_('./baseMergeDeep'),
  444. isArray = _dereq_('../lang/isArray'),
  445. isArrayLike = _dereq_('./isArrayLike'),
  446. isObject = _dereq_('../lang/isObject'),
  447. isObjectLike = _dereq_('./isObjectLike'),
  448. isTypedArray = _dereq_('../lang/isTypedArray'),
  449. keys = _dereq_('../object/keys');
  450. /**
  451. * The base implementation of `_.merge` without support for argument juggling,
  452. * multiple sources, and `this` binding `customizer` functions.
  453. *
  454. * @private
  455. * @param {Object} object The destination object.
  456. * @param {Object} source The source object.
  457. * @param {Function} [customizer] The function to customize merged values.
  458. * @param {Array} [stackA=[]] Tracks traversed source objects.
  459. * @param {Array} [stackB=[]] Associates values with source counterparts.
  460. * @returns {Object} Returns `object`.
  461. */
  462. function baseMerge(object, source, customizer, stackA, stackB) {
  463. if (!isObject(object)) {
  464. return object;
  465. }
  466. var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
  467. props = isSrcArr ? undefined : keys(source);
  468. arrayEach(props || source, function(srcValue, key) {
  469. if (props) {
  470. key = srcValue;
  471. srcValue = source[key];
  472. }
  473. if (isObjectLike(srcValue)) {
  474. stackA || (stackA = []);
  475. stackB || (stackB = []);
  476. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  477. }
  478. else {
  479. var value = object[key],
  480. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  481. isCommon = result === undefined;
  482. if (isCommon) {
  483. result = srcValue;
  484. }
  485. if ((result !== undefined || (isSrcArr && !(key in object))) &&
  486. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  487. object[key] = result;
  488. }
  489. }
  490. });
  491. return object;
  492. }
  493. module.exports = baseMerge;
  494. },{"../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){
  495. var arrayCopy = _dereq_('./arrayCopy'),
  496. isArguments = _dereq_('../lang/isArguments'),
  497. isArray = _dereq_('../lang/isArray'),
  498. isArrayLike = _dereq_('./isArrayLike'),
  499. isPlainObject = _dereq_('../lang/isPlainObject'),
  500. isTypedArray = _dereq_('../lang/isTypedArray'),
  501. toPlainObject = _dereq_('../lang/toPlainObject');
  502. /**
  503. * A specialized version of `baseMerge` for arrays and objects which performs
  504. * deep merges and tracks traversed objects enabling objects with circular
  505. * references to be merged.
  506. *
  507. * @private
  508. * @param {Object} object The destination object.
  509. * @param {Object} source The source object.
  510. * @param {string} key The key of the value to merge.
  511. * @param {Function} mergeFunc The function to merge values.
  512. * @param {Function} [customizer] The function to customize merged values.
  513. * @param {Array} [stackA=[]] Tracks traversed source objects.
  514. * @param {Array} [stackB=[]] Associates values with source counterparts.
  515. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  516. */
  517. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  518. var length = stackA.length,
  519. srcValue = source[key];
  520. while (length--) {
  521. if (stackA[length] == srcValue) {
  522. object[key] = stackB[length];
  523. return;
  524. }
  525. }
  526. var value = object[key],
  527. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  528. isCommon = result === undefined;
  529. if (isCommon) {
  530. result = srcValue;
  531. if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
  532. result = isArray(value)
  533. ? value
  534. : (isArrayLike(value) ? arrayCopy(value) : []);
  535. }
  536. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  537. result = isArguments(value)
  538. ? toPlainObject(value)
  539. : (isPlainObject(value) ? value : {});
  540. }
  541. else {
  542. isCommon = false;
  543. }
  544. }
  545. // Add the source value to the stack of traversed objects and associate
  546. // it with its merged value.
  547. stackA.push(srcValue);
  548. stackB.push(result);
  549. if (isCommon) {
  550. // Recursively merge objects and arrays (susceptible to call stack limits).
  551. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  552. } else if (result === result ? (result !== value) : (value === value)) {
  553. object[key] = result;
  554. }
  555. }
  556. module.exports = baseMergeDeep;
  557. },{"../lang/isArguments":29,"../lang/isArray":30,"../lang/isPlainObject":34,"../lang/isTypedArray":36,"../lang/toPlainObject":37,"./arrayCopy":8,"./isArrayLike":21}],15:[function(_dereq_,module,exports){
  558. var toObject = _dereq_('./toObject');
  559. /**
  560. * The base implementation of `_.property` without support for deep paths.
  561. *
  562. * @private
  563. * @param {string} key The key of the property to get.
  564. * @returns {Function} Returns the new function.
  565. */
  566. function baseProperty(key) {
  567. return function(object) {
  568. return object == null ? undefined : toObject(object)[key];
  569. };
  570. }
  571. module.exports = baseProperty;
  572. },{"./toObject":28}],16:[function(_dereq_,module,exports){
  573. var identity = _dereq_('../utility/identity');
  574. /**
  575. * A specialized version of `baseCallback` which only supports `this` binding
  576. * and specifying the number of arguments to provide to `func`.
  577. *
  578. * @private
  579. * @param {Function} func The function to bind.
  580. * @param {*} thisArg The `this` binding of `func`.
  581. * @param {number} [argCount] The number of arguments to provide to `func`.
  582. * @returns {Function} Returns the callback.
  583. */
  584. function bindCallback(func, thisArg, argCount) {
  585. if (typeof func != 'function') {
  586. return identity;
  587. }
  588. if (thisArg === undefined) {
  589. return func;
  590. }
  591. switch (argCount) {
  592. case 1: return function(value) {
  593. return func.call(thisArg, value);
  594. };
  595. case 3: return function(value, index, collection) {
  596. return func.call(thisArg, value, index, collection);
  597. };
  598. case 4: return function(accumulator, value, index, collection) {
  599. return func.call(thisArg, accumulator, value, index, collection);
  600. };
  601. case 5: return function(value, other, key, object, source) {
  602. return func.call(thisArg, value, other, key, object, source);
  603. };
  604. }
  605. return function() {
  606. return func.apply(thisArg, arguments);
  607. };
  608. }
  609. module.exports = bindCallback;
  610. },{"../utility/identity":42}],17:[function(_dereq_,module,exports){
  611. var bindCallback = _dereq_('./bindCallback'),
  612. isIterateeCall = _dereq_('./isIterateeCall'),
  613. restParam = _dereq_('../function/restParam');
  614. /**
  615. * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
  616. *
  617. * @private
  618. * @param {Function} assigner The function to assign values.
  619. * @returns {Function} Returns the new assigner function.
  620. */
  621. function createAssigner(assigner) {
  622. return restParam(function(object, sources) {
  623. var index = -1,
  624. length = object == null ? 0 : sources.length,
  625. customizer = length > 2 ? sources[length - 2] : undefined,
  626. guard = length > 2 ? sources[2] : undefined,
  627. thisArg = length > 1 ? sources[length - 1] : undefined;
  628. if (typeof customizer == 'function') {
  629. customizer = bindCallback(customizer, thisArg, 5);
  630. length -= 2;
  631. } else {
  632. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  633. length -= (customizer ? 1 : 0);
  634. }
  635. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  636. customizer = length < 3 ? undefined : customizer;
  637. length = 1;
  638. }
  639. while (++index < length) {
  640. var source = sources[index];
  641. if (source) {
  642. assigner(object, source, customizer);
  643. }
  644. }
  645. return object;
  646. });
  647. }
  648. module.exports = createAssigner;
  649. },{"../function/restParam":6,"./bindCallback":16,"./isIterateeCall":24}],18:[function(_dereq_,module,exports){
  650. var toObject = _dereq_('./toObject');
  651. /**
  652. * Creates a base function for `_.forIn` or `_.forInRight`.
  653. *
  654. * @private
  655. * @param {boolean} [fromRight] Specify iterating from right to left.
  656. * @returns {Function} Returns the new base function.
  657. */
  658. function createBaseFor(fromRight) {
  659. return function(object, iteratee, keysFunc) {
  660. var iterable = toObject(object),
  661. props = keysFunc(object),
  662. length = props.length,
  663. index = fromRight ? length : -1;
  664. while ((fromRight ? index-- : ++index < length)) {
  665. var key = props[index];
  666. if (iteratee(iterable[key], key, iterable) === false) {
  667. break;
  668. }
  669. }
  670. return object;
  671. };
  672. }
  673. module.exports = createBaseFor;
  674. },{"./toObject":28}],19:[function(_dereq_,module,exports){
  675. var baseProperty = _dereq_('./baseProperty');
  676. /**
  677. * Gets the "length" property value of `object`.
  678. *
  679. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  680. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  681. *
  682. * @private
  683. * @param {Object} object The object to query.
  684. * @returns {*} Returns the "length" value.
  685. */
  686. var getLength = baseProperty('length');
  687. module.exports = getLength;
  688. },{"./baseProperty":15}],20:[function(_dereq_,module,exports){
  689. var isNative = _dereq_('../lang/isNative');
  690. /**
  691. * Gets the native function at `key` of `object`.
  692. *
  693. * @private
  694. * @param {Object} object The object to query.
  695. * @param {string} key The key of the method to get.
  696. * @returns {*} Returns the function if it's native, else `undefined`.
  697. */
  698. function getNative(object, key) {
  699. var value = object == null ? undefined : object[key];
  700. return isNative(value) ? value : undefined;
  701. }
  702. module.exports = getNative;
  703. },{"../lang/isNative":32}],21:[function(_dereq_,module,exports){
  704. var getLength = _dereq_('./getLength'),
  705. isLength = _dereq_('./isLength');
  706. /**
  707. * Checks if `value` is array-like.
  708. *
  709. * @private
  710. * @param {*} value The value to check.
  711. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  712. */
  713. function isArrayLike(value) {
  714. return value != null && isLength(getLength(value));
  715. }
  716. module.exports = isArrayLike;
  717. },{"./getLength":19,"./isLength":25}],22:[function(_dereq_,module,exports){
  718. /**
  719. * Checks if `value` is a host object in IE < 9.
  720. *
  721. * @private
  722. * @param {*} value The value to check.
  723. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  724. */
  725. var isHostObject = (function() {
  726. try {
  727. Object({ 'toString': 0 } + '');
  728. } catch(e) {
  729. return function() { return false; };
  730. }
  731. return function(value) {
  732. // IE < 9 presents many host objects as `Object` objects that can coerce
  733. // to strings despite having improperly defined `toString` methods.
  734. return typeof value.toString != 'function' && typeof (value + '') == 'string';
  735. };
  736. }());
  737. module.exports = isHostObject;
  738. },{}],23:[function(_dereq_,module,exports){
  739. /** Used to detect unsigned integer values. */
  740. var reIsUint = /^\d+$/;
  741. /**
  742. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  743. * of an array-like value.
  744. */
  745. var MAX_SAFE_INTEGER = 9007199254740991;
  746. /**
  747. * Checks if `value` is a valid array-like index.
  748. *
  749. * @private
  750. * @param {*} value The value to check.
  751. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  752. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  753. */
  754. function isIndex(value, length) {
  755. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  756. length = length == null ? MAX_SAFE_INTEGER : length;
  757. return value > -1 && value % 1 == 0 && value < length;
  758. }
  759. module.exports = isIndex;
  760. },{}],24:[function(_dereq_,module,exports){
  761. var isArrayLike = _dereq_('./isArrayLike'),
  762. isIndex = _dereq_('./isIndex'),
  763. isObject = _dereq_('../lang/isObject');
  764. /**
  765. * Checks if the provided arguments are from an iteratee call.
  766. *
  767. * @private
  768. * @param {*} value The potential iteratee value argument.
  769. * @param {*} index The potential iteratee index or key argument.
  770. * @param {*} object The potential iteratee object argument.
  771. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  772. */
  773. function isIterateeCall(value, index, object) {
  774. if (!isObject(object)) {
  775. return false;
  776. }
  777. var type = typeof index;
  778. if (type == 'number'
  779. ? (isArrayLike(object) && isIndex(index, object.length))
  780. : (type == 'string' && index in object)) {
  781. var other = object[index];
  782. return value === value ? (value === other) : (other !== other);
  783. }
  784. return false;
  785. }
  786. module.exports = isIterateeCall;
  787. },{"../lang/isObject":33,"./isArrayLike":21,"./isIndex":23}],25:[function(_dereq_,module,exports){
  788. /**
  789. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  790. * of an array-like value.
  791. */
  792. var MAX_SAFE_INTEGER = 9007199254740991;
  793. /**
  794. * Checks if `value` is a valid array-like length.
  795. *
  796. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  797. *
  798. * @private
  799. * @param {*} value The value to check.
  800. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  801. */
  802. function isLength(value) {
  803. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  804. }
  805. module.exports = isLength;
  806. },{}],26:[function(_dereq_,module,exports){
  807. /**
  808. * Checks if `value` is object-like.
  809. *
  810. * @private
  811. * @param {*} value The value to check.
  812. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  813. */
  814. function isObjectLike(value) {
  815. return !!value && typeof value == 'object';
  816. }
  817. module.exports = isObjectLike;
  818. },{}],27:[function(_dereq_,module,exports){
  819. var isArguments = _dereq_('../lang/isArguments'),
  820. isArray = _dereq_('../lang/isArray'),
  821. isIndex = _dereq_('./isIndex'),
  822. isLength = _dereq_('./isLength'),
  823. isString = _dereq_('../lang/isString'),
  824. keysIn = _dereq_('../object/keysIn');
  825. /** Used for native method references. */
  826. var objectProto = Object.prototype;
  827. /** Used to check objects for own properties. */
  828. var hasOwnProperty = objectProto.hasOwnProperty;
  829. /**
  830. * A fallback implementation of `Object.keys` which creates an array of the
  831. * own enumerable property names of `object`.
  832. *
  833. * @private
  834. * @param {Object} object The object to query.
  835. * @returns {Array} Returns the array of property names.
  836. */
  837. function shimKeys(object) {
  838. var props = keysIn(object),
  839. propsLength = props.length,
  840. length = propsLength && object.length;
  841. var allowIndexes = !!length && isLength(length) &&
  842. (isArray(object) || isArguments(object) || isString(object));
  843. var index = -1,
  844. result = [];
  845. while (++index < propsLength) {
  846. var key = props[index];
  847. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  848. result.push(key);
  849. }
  850. }
  851. return result;
  852. }
  853. module.exports = shimKeys;
  854. },{"../lang/isArguments":29,"../lang/isArray":30,"../lang/isString":35,"../object/keysIn":39,"./isIndex":23,"./isLength":25}],28:[function(_dereq_,module,exports){
  855. var isObject = _dereq_('../lang/isObject'),
  856. isString = _dereq_('../lang/isString'),
  857. support = _dereq_('../support');
  858. /**
  859. * Converts `value` to an object if it's not one.
  860. *
  861. * @private
  862. * @param {*} value The value to process.
  863. * @returns {Object} Returns the object.
  864. */
  865. function toObject(value) {
  866. if (support.unindexedChars && isString(value)) {
  867. var index = -1,
  868. length = value.length,
  869. result = Object(value);
  870. while (++index < length) {
  871. result[index] = value.charAt(index);
  872. }
  873. return result;
  874. }
  875. return isObject(value) ? value : Object(value);
  876. }
  877. module.exports = toObject;
  878. },{"../lang/isObject":33,"../lang/isString":35,"../support":41}],29:[function(_dereq_,module,exports){
  879. var isArrayLike = _dereq_('../internal/isArrayLike'),
  880. isObjectLike = _dereq_('../internal/isObjectLike');
  881. /** Used for native method references. */
  882. var objectProto = Object.prototype;
  883. /** Used to check objects for own properties. */
  884. var hasOwnProperty = objectProto.hasOwnProperty;
  885. /** Native method references. */
  886. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  887. /**
  888. * Checks if `value` is classified as an `arguments` object.
  889. *
  890. * @static
  891. * @memberOf _
  892. * @category Lang
  893. * @param {*} value The value to check.
  894. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  895. * @example
  896. *
  897. * _.isArguments(function() { return arguments; }());
  898. * // => true
  899. *
  900. * _.isArguments([1, 2, 3]);
  901. * // => false
  902. */
  903. function isArguments(value) {
  904. return isObjectLike(value) && isArrayLike(value) &&
  905. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  906. }
  907. module.exports = isArguments;
  908. },{"../internal/isArrayLike":21,"../internal/isObjectLike":26}],30:[function(_dereq_,module,exports){
  909. var getNative = _dereq_('../internal/getNative'),
  910. isLength = _dereq_('../internal/isLength'),
  911. isObjectLike = _dereq_('../internal/isObjectLike');
  912. /** `Object#toString` result references. */
  913. var arrayTag = '[object Array]';
  914. /** Used for native method references. */
  915. var objectProto = Object.prototype;
  916. /**
  917. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  918. * of values.
  919. */
  920. var objToString = objectProto.toString;
  921. /* Native method references for those with the same name as other `lodash` methods. */
  922. var nativeIsArray = getNative(Array, 'isArray');
  923. /**
  924. * Checks if `value` is classified as an `Array` object.
  925. *
  926. * @static
  927. * @memberOf _
  928. * @category Lang
  929. * @param {*} value The value to check.
  930. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  931. * @example
  932. *
  933. * _.isArray([1, 2, 3]);
  934. * // => true
  935. *
  936. * _.isArray(function() { return arguments; }());
  937. * // => false
  938. */
  939. var isArray = nativeIsArray || function(value) {
  940. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  941. };
  942. module.exports = isArray;
  943. },{"../internal/getNative":20,"../internal/isLength":25,"../internal/isObjectLike":26}],31:[function(_dereq_,module,exports){
  944. var isObject = _dereq_('./isObject');
  945. /** `Object#toString` result references. */
  946. var funcTag = '[object Function]';
  947. /** Used for native method references. */
  948. var objectProto = Object.prototype;
  949. /**
  950. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  951. * of values.
  952. */
  953. var objToString = objectProto.toString;
  954. /**
  955. * Checks if `value` is classified as a `Function` object.
  956. *
  957. * @static
  958. * @memberOf _
  959. * @category Lang
  960. * @param {*} value The value to check.
  961. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  962. * @example
  963. *
  964. * _.isFunction(_);
  965. * // => true
  966. *
  967. * _.isFunction(/abc/);
  968. * // => false
  969. */
  970. function isFunction(value) {
  971. // The use of `Object#toString` avoids issues with the `typeof` operator
  972. // in older versions of Chrome and Safari which return 'function' for regexes
  973. // and Safari 8 which returns 'object' for typed array constructors.
  974. return isObject(value) && objToString.call(value) == funcTag;
  975. }
  976. module.exports = isFunction;
  977. },{"./isObject":33}],32:[function(_dereq_,module,exports){
  978. var isFunction = _dereq_('./isFunction'),
  979. isHostObject = _dereq_('../internal/isHostObject'),
  980. isObjectLike = _dereq_('../internal/isObjectLike');
  981. /** Used to detect host constructors (Safari > 5). */
  982. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  983. /** Used for native method references. */
  984. var objectProto = Object.prototype;
  985. /** Used to resolve the decompiled source of functions. */
  986. var fnToString = Function.prototype.toString;
  987. /** Used to check objects for own properties. */
  988. var hasOwnProperty = objectProto.hasOwnProperty;
  989. /** Used to detect if a method is native. */
  990. var reIsNative = RegExp('^' +
  991. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  992. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  993. );
  994. /**
  995. * Checks if `value` is a native function.
  996. *
  997. * @static
  998. * @memberOf _
  999. * @category Lang
  1000. * @param {*} value The value to check.
  1001. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  1002. * @example
  1003. *
  1004. * _.isNative(Array.prototype.push);
  1005. * // => true
  1006. *
  1007. * _.isNative(_);
  1008. * // => false
  1009. */
  1010. function isNative(value) {
  1011. if (value == null) {
  1012. return false;
  1013. }
  1014. if (isFunction(value)) {
  1015. return reIsNative.test(fnToString.call(value));
  1016. }
  1017. return isObjectLike(value) && (isHostObject(value) ? reIsNative : reIsHostCtor).test(value);
  1018. }
  1019. module.exports = isNative;
  1020. },{"../internal/isHostObject":22,"../internal/isObjectLike":26,"./isFunction":31}],33:[function(_dereq_,module,exports){
  1021. /**
  1022. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  1023. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1024. *
  1025. * @static
  1026. * @memberOf _
  1027. * @category Lang
  1028. * @param {*} value The value to check.
  1029. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1030. * @example
  1031. *
  1032. * _.isObject({});
  1033. * // => true
  1034. *
  1035. * _.isObject([1, 2, 3]);
  1036. * // => true
  1037. *
  1038. * _.isObject(1);
  1039. * // => false
  1040. */
  1041. function isObject(value) {
  1042. // Avoid a V8 JIT bug in Chrome 19-20.
  1043. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  1044. var type = typeof value;
  1045. return !!value && (type == 'object' || type == 'function');
  1046. }
  1047. module.exports = isObject;
  1048. },{}],34:[function(_dereq_,module,exports){
  1049. var baseForIn = _dereq_('../internal/baseForIn'),
  1050. isArguments = _dereq_('./isArguments'),
  1051. isHostObject = _dereq_('../internal/isHostObject'),
  1052. isObjectLike = _dereq_('../internal/isObjectLike'),
  1053. support = _dereq_('../support');
  1054. /** `Object#toString` result references. */
  1055. var objectTag = '[object Object]';
  1056. /** Used for native method references. */
  1057. var objectProto = Object.prototype;
  1058. /** Used to check objects for own properties. */
  1059. var hasOwnProperty = objectProto.hasOwnProperty;
  1060. /**
  1061. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1062. * of values.
  1063. */
  1064. var objToString = objectProto.toString;
  1065. /**
  1066. * Checks if `value` is a plain object, that is, an object created by the
  1067. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  1068. *
  1069. * **Note:** This method assumes objects created by the `Object` constructor
  1070. * have no inherited enumerable properties.
  1071. *
  1072. * @static
  1073. * @memberOf _
  1074. * @category Lang
  1075. * @param {*} value The value to check.
  1076. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  1077. * @example
  1078. *
  1079. * function Foo() {
  1080. * this.a = 1;
  1081. * }
  1082. *
  1083. * _.isPlainObject(new Foo);
  1084. * // => false
  1085. *
  1086. * _.isPlainObject([1, 2, 3]);
  1087. * // => false
  1088. *
  1089. * _.isPlainObject({ 'x': 0, 'y': 0 });
  1090. * // => true
  1091. *
  1092. * _.isPlainObject(Object.create(null));
  1093. * // => true
  1094. */
  1095. function isPlainObject(value) {
  1096. var Ctor;
  1097. // Exit early for non `Object` objects.
  1098. if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isHostObject(value) && !isArguments(value)) ||
  1099. (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  1100. return false;
  1101. }
  1102. // IE < 9 iterates inherited properties before own properties. If the first
  1103. // iterated property is an object's own property then there are no inherited
  1104. // enumerable properties.
  1105. var result;
  1106. if (support.ownLast) {
  1107. baseForIn(value, function(subValue, key, object) {
  1108. result = hasOwnProperty.call(object, key);
  1109. return false;
  1110. });
  1111. return result !== false;
  1112. }
  1113. // In most environments an object's own properties are iterated before
  1114. // its inherited properties. If the last iterated property is an object's
  1115. // own property then there are no inherited enumerable properties.
  1116. baseForIn(value, function(subValue, key) {
  1117. result = key;
  1118. });
  1119. return result === undefined || hasOwnProperty.call(value, result);
  1120. }
  1121. module.exports = isPlainObject;
  1122. },{"../internal/baseForIn":12,"../internal/isHostObject":22,"../internal/isObjectLike":26,"../support":41,"./isArguments":29}],35:[function(_dereq_,module,exports){
  1123. var isObjectLike = _dereq_('../internal/isObjectLike');
  1124. /** `Object#toString` result references. */
  1125. var stringTag = '[object String]';
  1126. /** Used for native method references. */
  1127. var objectProto = Object.prototype;
  1128. /**
  1129. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1130. * of values.
  1131. */
  1132. var objToString = objectProto.toString;
  1133. /**
  1134. * Checks if `value` is classified as a `String` primitive or object.
  1135. *
  1136. * @static
  1137. * @memberOf _
  1138. * @category Lang
  1139. * @param {*} value The value to check.
  1140. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1141. * @example
  1142. *
  1143. * _.isString('abc');
  1144. * // => true
  1145. *
  1146. * _.isString(1);
  1147. * // => false
  1148. */
  1149. function isString(value) {
  1150. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  1151. }
  1152. module.exports = isString;
  1153. },{"../internal/isObjectLike":26}],36:[function(_dereq_,module,exports){
  1154. var isLength = _dereq_('../internal/isLength'),
  1155. isObjectLike = _dereq_('../internal/isObjectLike');
  1156. /** `Object#toString` result references. */
  1157. var argsTag = '[object Arguments]',
  1158. arrayTag = '[object Array]',
  1159. boolTag = '[object Boolean]',
  1160. dateTag = '[object Date]',
  1161. errorTag = '[object Error]',
  1162. funcTag = '[object Function]',
  1163. mapTag = '[object Map]',
  1164. numberTag = '[object Number]',
  1165. objectTag = '[object Object]',
  1166. regexpTag = '[object RegExp]',
  1167. setTag = '[object Set]',
  1168. stringTag = '[object String]',
  1169. weakMapTag = '[object WeakMap]';
  1170. var arrayBufferTag = '[object ArrayBuffer]',
  1171. float32Tag = '[object Float32Array]',
  1172. float64Tag = '[object Float64Array]',
  1173. int8Tag = '[object Int8Array]',
  1174. int16Tag = '[object Int16Array]',
  1175. int32Tag = '[object Int32Array]',
  1176. uint8Tag = '[object Uint8Array]',
  1177. uint8ClampedTag = '[object Uint8ClampedArray]',
  1178. uint16Tag = '[object Uint16Array]',
  1179. uint32Tag = '[object Uint32Array]';
  1180. /** Used to identify `toStringTag` values of typed arrays. */
  1181. var typedArrayTags = {};
  1182. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1183. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1184. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1185. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1186. typedArrayTags[uint32Tag] = true;
  1187. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1188. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1189. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  1190. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  1191. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  1192. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  1193. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  1194. /** Used for native method references. */
  1195. var objectProto = Object.prototype;
  1196. /**
  1197. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1198. * of values.
  1199. */
  1200. var objToString = objectProto.toString;
  1201. /**
  1202. * Checks if `value` is classified as a typed array.
  1203. *
  1204. * @static
  1205. * @memberOf _
  1206. * @category Lang
  1207. * @param {*} value The value to check.
  1208. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  1209. * @example
  1210. *
  1211. * _.isTypedArray(new Uint8Array);
  1212. * // => true
  1213. *
  1214. * _.isTypedArray([]);
  1215. * // => false
  1216. */
  1217. function isTypedArray(value) {
  1218. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  1219. }
  1220. module.exports = isTypedArray;
  1221. },{"../internal/isLength":25,"../internal/isObjectLike":26}],37:[function(_dereq_,module,exports){
  1222. var baseCopy = _dereq_('../internal/baseCopy'),
  1223. keysIn = _dereq_('../object/keysIn');
  1224. /**
  1225. * Converts `value` to a plain object flattening inherited enumerable
  1226. * properties of `value` to own properties of the plain object.
  1227. *
  1228. * @static
  1229. * @memberOf _
  1230. * @category Lang
  1231. * @param {*} value The value to convert.
  1232. * @returns {Object} Returns the converted plain object.
  1233. * @example
  1234. *
  1235. * function Foo() {
  1236. * this.b = 2;
  1237. * }
  1238. *
  1239. * Foo.prototype.c = 3;
  1240. *
  1241. * _.assign({ 'a': 1 }, new Foo);
  1242. * // => { 'a': 1, 'b': 2 }
  1243. *
  1244. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  1245. * // => { 'a': 1, 'b': 2, 'c': 3 }
  1246. */
  1247. function toPlainObject(value) {
  1248. return baseCopy(value, keysIn(value));
  1249. }
  1250. module.exports = toPlainObject;
  1251. },{"../internal/baseCopy":10,"../object/keysIn":39}],38:[function(_dereq_,module,exports){
  1252. var getNative = _dereq_('../internal/getNative'),
  1253. isArrayLike = _dereq_('../internal/isArrayLike'),
  1254. isObject = _dereq_('../lang/isObject'),
  1255. shimKeys = _dereq_('../internal/shimKeys'),
  1256. support = _dereq_('../support');
  1257. /* Native method references for those with the same name as other `lodash` methods. */
  1258. var nativeKeys = getNative(Object, 'keys');
  1259. /**
  1260. * Creates an array of the own enumerable property names of `object`.
  1261. *
  1262. * **Note:** Non-object values are coerced to objects. See the
  1263. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  1264. * for more details.
  1265. *
  1266. * @static
  1267. * @memberOf _
  1268. * @category Object
  1269. * @param {Object} object The object to query.
  1270. * @returns {Array} Returns the array of property names.
  1271. * @example
  1272. *
  1273. * function Foo() {
  1274. * this.a = 1;
  1275. * this.b = 2;
  1276. * }
  1277. *
  1278. * Foo.prototype.c = 3;
  1279. *
  1280. * _.keys(new Foo);
  1281. * // => ['a', 'b'] (iteration order is not guaranteed)
  1282. *
  1283. * _.keys('hi');
  1284. * // => ['0', '1']
  1285. */
  1286. var keys = !nativeKeys ? shimKeys : function(object) {
  1287. var Ctor = object == null ? undefined : object.constructor;
  1288. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  1289. (typeof object == 'function' ? support.enumPrototypes : isArrayLike(object))) {
  1290. return shimKeys(object);
  1291. }
  1292. return isObject(object) ? nativeKeys(object) : [];
  1293. };
  1294. module.exports = keys;
  1295. },{"../internal/getNative":20,"../internal/isArrayLike":21,"../internal/shimKeys":27,"../lang/isObject":33,"../support":41}],39:[function(_dereq_,module,exports){
  1296. var arrayEach = _dereq_('../internal/arrayEach'),
  1297. isArguments = _dereq_('../lang/isArguments'),
  1298. isArray = _dereq_('../lang/isArray'),
  1299. isFunction = _dereq_('../lang/isFunction'),
  1300. isIndex = _dereq_('../internal/isIndex'),
  1301. isLength = _dereq_('../internal/isLength'),
  1302. isObject = _dereq_('../lang/isObject'),
  1303. isString = _dereq_('../lang/isString'),
  1304. support = _dereq_('../support');
  1305. /** `Object#toString` result references. */
  1306. var arrayTag = '[object Array]',
  1307. boolTag = '[object Boolean]',
  1308. dateTag = '[object Date]',
  1309. errorTag = '[object Error]',
  1310. funcTag = '[object Function]',
  1311. numberTag = '[object Number]',
  1312. objectTag = '[object Object]',
  1313. regexpTag = '[object RegExp]',
  1314. stringTag = '[object String]';
  1315. /** Used to fix the JScript `[[DontEnum]]` bug. */
  1316. var shadowProps = [
  1317. 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',
  1318. 'toLocaleString', 'toString', 'valueOf'
  1319. ];
  1320. /** Used for native method references. */
  1321. var errorProto = Error.prototype,
  1322. objectProto = Object.prototype,
  1323. stringProto = String.prototype;
  1324. /** Used to check objects for own properties. */
  1325. var hasOwnProperty = objectProto.hasOwnProperty;
  1326. /**
  1327. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  1328. * of values.
  1329. */
  1330. var objToString = objectProto.toString;
  1331. /** Used to avoid iterating over non-enumerable properties in IE < 9. */
  1332. var nonEnumProps = {};
  1333. nonEnumProps[arrayTag] = nonEnumProps[dateTag] = nonEnumProps[numberTag] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true };
  1334. nonEnumProps[boolTag] = nonEnumProps[stringTag] = { 'constructor': true, 'toString': true, 'valueOf': true };
  1335. nonEnumProps[errorTag] = nonEnumProps[funcTag] = nonEnumProps[regexpTag] = { 'constructor': true, 'toString': true };
  1336. nonEnumProps[objectTag] = { 'constructor': true };
  1337. arrayEach(shadowProps, function(key) {
  1338. for (var tag in nonEnumProps) {
  1339. if (hasOwnProperty.call(nonEnumProps, tag)) {
  1340. var props = nonEnumProps[tag];
  1341. props[key] = hasOwnProperty.call(props, key);
  1342. }
  1343. }
  1344. });
  1345. /**
  1346. * Creates an array of the own and inherited enumerable property names of `object`.
  1347. *
  1348. * **Note:** Non-object values are coerced to objects.
  1349. *
  1350. * @static
  1351. * @memberOf _
  1352. * @category Object
  1353. * @param {Object} object The object to query.
  1354. * @returns {Array} Returns the array of property names.
  1355. * @example
  1356. *
  1357. * function Foo() {
  1358. * this.a = 1;
  1359. * this.b = 2;
  1360. * }
  1361. *
  1362. * Foo.prototype.c = 3;
  1363. *
  1364. * _.keysIn(new Foo);
  1365. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  1366. */
  1367. function keysIn(object) {
  1368. if (object == null) {
  1369. return [];
  1370. }
  1371. if (!isObject(object)) {
  1372. object = Object(object);
  1373. }
  1374. var length = object.length;
  1375. length = (length && isLength(length) &&
  1376. (isArray(object) || isArguments(object) || isString(object)) && length) || 0;
  1377. var Ctor = object.constructor,
  1378. index = -1,
  1379. proto = (isFunction(Ctor) && Ctor.prototype) || objectProto,
  1380. isProto = proto === object,
  1381. result = Array(length),
  1382. skipIndexes = length > 0,
  1383. skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error),
  1384. skipProto = support.enumPrototypes && isFunction(object);
  1385. while (++index < length) {
  1386. result[index] = (index + '');
  1387. }
  1388. // lodash skips the `constructor` property when it infers it's iterating
  1389. // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]`
  1390. // attribute of an existing property and the `constructor` property of a
  1391. // prototype defaults to non-enumerable.
  1392. for (var key in object) {
  1393. if (!(skipProto && key == 'prototype') &&
  1394. !(skipErrorProps && (key == 'message' || key == 'name')) &&
  1395. !(skipIndexes && isIndex(key, length)) &&
  1396. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  1397. result.push(key);
  1398. }
  1399. }
  1400. if (support.nonEnumShadows && object !== objectProto) {
  1401. var tag = object === stringProto ? stringTag : (object === errorProto ? errorTag : objToString.call(object)),
  1402. nonEnums = nonEnumProps[tag] || nonEnumProps[objectTag];
  1403. if (tag == objectTag) {
  1404. proto = objectProto;
  1405. }
  1406. length = shadowProps.length;
  1407. while (length--) {
  1408. key = shadowProps[length];
  1409. var nonEnum = nonEnums[key];
  1410. if (!(isProto && nonEnum) &&
  1411. (nonEnum ? hasOwnProperty.call(object, key) : object[key] !== proto[key])) {
  1412. result.push(key);
  1413. }
  1414. }
  1415. }
  1416. return result;
  1417. }
  1418. module.exports = keysIn;
  1419. },{"../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){
  1420. var baseMerge = _dereq_('../internal/baseMerge'),
  1421. createAssigner = _dereq_('../internal/createAssigner');
  1422. /**
  1423. * Recursively merges own enumerable properties of the source object(s), that
  1424. * don't resolve to `undefined` into the destination object. Subsequent sources
  1425. * overwrite property assignments of previous sources. If `customizer` is
  1426. * provided it's invoked to produce the merged values of the destination and
  1427. * source properties. If `customizer` returns `undefined` merging is handled
  1428. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  1429. * with five arguments: (objectValue, sourceValue, key, object, source).
  1430. *
  1431. * @static
  1432. * @memberOf _
  1433. * @category Object
  1434. * @param {Object} object The destination object.
  1435. * @param {...Object} [sources] The source objects.
  1436. * @param {Function} [customizer] The function to customize assigned values.
  1437. * @param {*} [thisArg] The `this` binding of `customizer`.
  1438. * @returns {Object} Returns `object`.
  1439. * @example
  1440. *
  1441. * var users = {
  1442. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  1443. * };
  1444. *
  1445. * var ages = {
  1446. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  1447. * };
  1448. *
  1449. * _.merge(users, ages);
  1450. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  1451. *
  1452. * // using a customizer callback
  1453. * var object = {
  1454. * 'fruits': ['apple'],
  1455. * 'vegetables': ['beet']
  1456. * };
  1457. *
  1458. * var other = {
  1459. * 'fruits': ['banana'],
  1460. * 'vegetables': ['carrot']
  1461. * };
  1462. *
  1463. * _.merge(object, other, function(a, b) {
  1464. * if (_.isArray(a)) {
  1465. * return a.concat(b);
  1466. * }
  1467. * });
  1468. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  1469. */
  1470. var merge = createAssigner(baseMerge);
  1471. module.exports = merge;
  1472. },{"../internal/baseMerge":13,"../internal/createAssigner":17}],41:[function(_dereq_,module,exports){
  1473. /** Used for native method references. */
  1474. var arrayProto = Array.prototype,
  1475. errorProto = Error.prototype,
  1476. objectProto = Object.prototype;
  1477. /** Native method references. */
  1478. var propertyIsEnumerable = objectProto.propertyIsEnumerable,
  1479. splice = arrayProto.splice;
  1480. /**
  1481. * An object environment feature flags.
  1482. *
  1483. * @static
  1484. * @memberOf _
  1485. * @type Object
  1486. */
  1487. var support = {};
  1488. (function(x) {
  1489. var Ctor = function() { this.x = x; },
  1490. object = { '0': x, 'length': x },
  1491. props = [];
  1492. Ctor.prototype = { 'valueOf': x, 'y': x };
  1493. for (var key in new Ctor) { props.push(key); }
  1494. /**
  1495. * Detect if `name` or `message` properties of `Error.prototype` are
  1496. * enumerable by default (IE < 9, Safari < 5.1).
  1497. *
  1498. * @memberOf _.support
  1499. * @type boolean
  1500. */
  1501. support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') ||
  1502. propertyIsEnumerable.call(errorProto, 'name');
  1503. /**
  1504. * Detect if `prototype` properties are enumerable by default.
  1505. *
  1506. * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
  1507. * (if the prototype or a property on the prototype has been set)
  1508. * incorrectly set the `[[Enumerable]]` value of a function's `prototype`
  1509. * property to `true`.
  1510. *
  1511. * @memberOf _.support
  1512. * @type boolean
  1513. */
  1514. support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype');
  1515. /**
  1516. * Detect if properties shadowing those on `Object.prototype` are non-enumerable.
  1517. *
  1518. * In IE < 9 an object's own properties, shadowing non-enumerable ones,
  1519. * are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug).
  1520. *
  1521. * @memberOf _.support
  1522. * @type boolean
  1523. */
  1524. support.nonEnumShadows = !/valueOf/.test(props);
  1525. /**
  1526. * Detect if own properties are iterated after inherited properties (IE < 9).
  1527. *
  1528. * @memberOf _.support
  1529. * @type boolean
  1530. */
  1531. support.ownLast = props[0] != 'x';
  1532. /**
  1533. * Detect if `Array#shift` and `Array#splice` augment array-like objects
  1534. * correctly.
  1535. *
  1536. * Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array
  1537. * `shift()` and `splice()` functions that fail to remove the last element,
  1538. * `value[0]`, of array-like objects even though the "length" property is
  1539. * set to `0`. The `shift()` method is buggy in compatibility modes of IE 8,
  1540. * while `splice()` is buggy regardless of mode in IE < 9.
  1541. *
  1542. * @memberOf _.support
  1543. * @type boolean
  1544. */
  1545. support.spliceObjects = (splice.call(object, 0, 1), !object[0]);
  1546. /**
  1547. * Detect lack of support for accessing string characters by index.
  1548. *
  1549. * IE < 8 can't access characters by index. IE 8 can only access characters
  1550. * by index on string literals, not string objects.
  1551. *
  1552. * @memberOf _.support
  1553. * @type boolean
  1554. */
  1555. support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx';
  1556. }(1, 0));
  1557. module.exports = support;
  1558. },{}],42:[function(_dereq_,module,exports){
  1559. /**
  1560. * This method returns the first argument provided to it.
  1561. *
  1562. * @static
  1563. * @memberOf _
  1564. * @category Utility
  1565. * @param {*} value Any value.
  1566. * @returns {*} Returns `value`.
  1567. * @example
  1568. *
  1569. * var object = { 'user': 'fred' };
  1570. *
  1571. * _.identity(object) === object;
  1572. * // => true
  1573. */
  1574. function identity(value) {
  1575. return value;
  1576. }
  1577. module.exports = identity;
  1578. },{}],43:[function(_dereq_,module,exports){
  1579. 'use strict';
  1580. var keys = _dereq_('object-keys');
  1581. module.exports = function hasSymbols() {
  1582. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
  1583. if (typeof Symbol.iterator === 'symbol') { return true; }
  1584. var obj = {};
  1585. var sym = Symbol('test');
  1586. if (typeof sym === 'string') { return false; }
  1587. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  1588. // if (sym instanceof Symbol) { return false; }
  1589. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  1590. // if (!(Object(sym) instanceof Symbol)) { return false; }
  1591. var symVal = 42;
  1592. obj[sym] = symVal;
  1593. for (sym in obj) { return false; }
  1594. if (keys(obj).length !== 0) { return false; }
  1595. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
  1596. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
  1597. var syms = Object.getOwnPropertySymbols(obj);
  1598. if (syms.length !== 1 || syms[0] !== sym) { return false; }
  1599. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
  1600. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  1601. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  1602. if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
  1603. }
  1604. return true;
  1605. };
  1606. },{"object-keys":49}],44:[function(_dereq_,module,exports){
  1607. 'use strict';
  1608. // modified from https://github.com/es-shims/es6-shim
  1609. var keys = _dereq_('object-keys');
  1610. var bind = _dereq_('function-bind');
  1611. var canBeObject = function (obj) {
  1612. return typeof obj !== 'undefined' && obj !== null;
  1613. };
  1614. var hasSymbols = _dereq_('./hasSymbols')();
  1615. var toObject = Object;
  1616. var push = bind.call(Function.call, Array.prototype.push);
  1617. var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
  1618. module.exports = function assign(target, source1) {
  1619. if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
  1620. var objTarget = toObject(target);
  1621. var s, source, i, props, syms, value, key;
  1622. for (s = 1; s < arguments.length; ++s) {
  1623. source = toObject(arguments[s]);
  1624. props = keys(source);
  1625. if (hasSymbols && Object.getOwnPropertySymbols) {
  1626. syms = Object.getOwnPropertySymbols(source);
  1627. for (i = 0; i < syms.length; ++i) {
  1628. key = syms[i];
  1629. if (propIsEnumerable(source, key)) {
  1630. push(props, key);
  1631. }
  1632. }
  1633. }
  1634. for (i = 0; i < props.length; ++i) {
  1635. key = props[i];
  1636. value = source[key];
  1637. if (propIsEnumerable(source, key)) {
  1638. objTarget[key] = value;
  1639. }
  1640. }
  1641. }
  1642. return objTarget;
  1643. };
  1644. },{"./hasSymbols":43,"function-bind":48,"object-keys":49}],45:[function(_dereq_,module,exports){
  1645. 'use strict';
  1646. var defineProperties = _dereq_('define-properties');
  1647. var implementation = _dereq_('./implementation');
  1648. var getPolyfill = _dereq_('./polyfill');
  1649. var shim = _dereq_('./shim');
  1650. defineProperties(implementation, {
  1651. implementation: implementation,
  1652. getPolyfill: getPolyfill,
  1653. shim: shim
  1654. });
  1655. module.exports = implementation;
  1656. },{"./implementation":44,"./polyfill":51,"./shim":52,"define-properties":46}],46:[function(_dereq_,module,exports){
  1657. 'use strict';
  1658. var keys = _dereq_('object-keys');
  1659. var foreach = _dereq_('foreach');
  1660. var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
  1661. var toStr = Object.prototype.toString;
  1662. var isFunction = function (fn) {
  1663. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  1664. };
  1665. var arePropertyDescriptorsSupported = function () {
  1666. var obj = {};
  1667. try {
  1668. Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
  1669. /* eslint-disable no-unused-vars, no-restricted-syntax */
  1670. for (var _ in obj) { return false; }
  1671. /* eslint-enable no-unused-vars, no-restricted-syntax */
  1672. return obj.x === obj;
  1673. } catch (e) { /* this is IE 8. */
  1674. return false;
  1675. }
  1676. };
  1677. var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
  1678. var defineProperty = function (object, name, value, predicate) {
  1679. if (name in object && (!isFunction(predicate) || !predicate())) {
  1680. return;
  1681. }
  1682. if (supportsDescriptors) {
  1683. Object.defineProperty(object, name, {
  1684. configurable: true,
  1685. enumerable: false,
  1686. value: value,
  1687. writable: true
  1688. });
  1689. } else {
  1690. object[name] = value;
  1691. }
  1692. };
  1693. var defineProperties = function (object, map) {
  1694. var predicates = arguments.length > 2 ? arguments[2] : {};
  1695. var props = keys(map);
  1696. if (hasSymbols) {
  1697. props = props.concat(Object.getOwnPropertySymbols(map));
  1698. }
  1699. foreach(props, function (name) {
  1700. defineProperty(object, name, map[name], predicates[name]);
  1701. });
  1702. };
  1703. defineProperties.supportsDescriptors = !!supportsDescriptors;
  1704. module.exports = defineProperties;
  1705. },{"foreach":47,"object-keys":49}],47:[function(_dereq_,module,exports){
  1706. var hasOwn = Object.prototype.hasOwnProperty;
  1707. var toString = Object.prototype.toString;
  1708. module.exports = function forEach (obj, fn, ctx) {
  1709. if (toString.call(fn) !== '[object Function]') {
  1710. throw new TypeError('iterator must be a function');
  1711. }
  1712. var l = obj.length;
  1713. if (l === +l) {
  1714. for (var i = 0; i < l; i++) {
  1715. fn.call(ctx, obj[i], i, obj);
  1716. }
  1717. } else {
  1718. for (var k in obj) {
  1719. if (hasOwn.call(obj, k)) {
  1720. fn.call(ctx, obj[k], k, obj);
  1721. }
  1722. }
  1723. }
  1724. };
  1725. },{}],48:[function(_dereq_,module,exports){
  1726. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  1727. var slice = Array.prototype.slice;
  1728. var toStr = Object.prototype.toString;
  1729. var funcType = '[object Function]';
  1730. module.exports = function bind(that) {
  1731. var target = this;
  1732. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  1733. throw new TypeError(ERROR_MESSAGE + target);
  1734. }
  1735. var args = slice.call(arguments, 1);
  1736. var binder = function () {
  1737. if (this instanceof bound) {
  1738. var result = target.apply(
  1739. this,
  1740. args.concat(slice.call(arguments))
  1741. );
  1742. if (Object(result) === result) {
  1743. return result;
  1744. }
  1745. return this;
  1746. } else {
  1747. return target.apply(
  1748. that,
  1749. args.concat(slice.call(arguments))
  1750. );
  1751. }
  1752. };
  1753. var boundLength = Math.max(0, target.length - args.length);
  1754. var boundArgs = [];
  1755. for (var i = 0; i < boundLength; i++) {
  1756. boundArgs.push('$' + i);
  1757. }
  1758. var bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  1759. if (target.prototype) {
  1760. var Empty = function Empty() {};
  1761. Empty.prototype = target.prototype;
  1762. bound.prototype = new Empty();
  1763. Empty.prototype = null;
  1764. }
  1765. return bound;
  1766. };
  1767. },{}],49:[function(_dereq_,module,exports){
  1768. 'use strict';
  1769. // modified from https://github.com/es-shims/es5-shim
  1770. var has = Object.prototype.hasOwnProperty;
  1771. var toStr = Object.prototype.toString;
  1772. var slice = Array.prototype.slice;
  1773. var isArgs = _dereq_('./isArguments');
  1774. var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
  1775. var hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype');
  1776. var dontEnums = [
  1777. 'toString',
  1778. 'toLocaleString',
  1779. 'valueOf',
  1780. 'hasOwnProperty',
  1781. 'isPrototypeOf',
  1782. 'propertyIsEnumerable',
  1783. 'constructor'
  1784. ];
  1785. var equalsConstructorPrototype = function (o) {
  1786. var ctor = o.constructor;
  1787. return ctor && ctor.prototype === o;
  1788. };
  1789. var blacklistedKeys = {
  1790. $console: true,
  1791. $frame: true,
  1792. $frameElement: true,
  1793. $frames: true,
  1794. $parent: true,
  1795. $self: true,
  1796. $webkitIndexedDB: true,
  1797. $webkitStorageInfo: true,
  1798. $window: true
  1799. };
  1800. var hasAutomationEqualityBug = (function () {
  1801. /* global window */
  1802. if (typeof window === 'undefined') { return false; }
  1803. for (var k in window) {
  1804. try {
  1805. if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  1806. try {
  1807. equalsConstructorPrototype(window[k]);
  1808. } catch (e) {
  1809. return true;
  1810. }
  1811. }
  1812. } catch (e) {
  1813. return true;
  1814. }
  1815. }
  1816. return false;
  1817. }());
  1818. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  1819. /* global window */
  1820. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  1821. return equalsConstructorPrototype(o);
  1822. }
  1823. try {
  1824. return equalsConstructorPrototype(o);
  1825. } catch (e) {
  1826. return false;
  1827. }
  1828. };
  1829. var keysShim = function keys(object) {
  1830. var isObject = object !== null && typeof object === 'object';
  1831. var isFunction = toStr.call(object) === '[object Function]';
  1832. var isArguments = isArgs(object);
  1833. var isString = isObject && toStr.call(object) === '[object String]';
  1834. var theKeys = [];
  1835. if (!isObject && !isFunction && !isArguments) {
  1836. throw new TypeError('Object.keys called on a non-object');
  1837. }
  1838. var skipProto = hasProtoEnumBug && isFunction;
  1839. if (isString && object.length > 0 && !has.call(object, 0)) {
  1840. for (var i = 0; i < object.length; ++i) {
  1841. theKeys.push(String(i));
  1842. }
  1843. }
  1844. if (isArguments && object.length > 0) {
  1845. for (var j = 0; j < object.length; ++j) {
  1846. theKeys.push(String(j));
  1847. }
  1848. } else {
  1849. for (var name in object) {
  1850. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  1851. theKeys.push(String(name));
  1852. }
  1853. }
  1854. }
  1855. if (hasDontEnumBug) {
  1856. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  1857. for (var k = 0; k < dontEnums.length; ++k) {
  1858. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  1859. theKeys.push(dontEnums[k]);
  1860. }
  1861. }
  1862. }
  1863. return theKeys;
  1864. };
  1865. keysShim.shim = function shimObjectKeys() {
  1866. if (Object.keys) {
  1867. var keysWorksWithArguments = (function () {
  1868. // Safari 5.0 bug
  1869. return (Object.keys(arguments) || '').length === 2;
  1870. }(1, 2));
  1871. if (!keysWorksWithArguments) {
  1872. var originalKeys = Object.keys;
  1873. Object.keys = function keys(object) {
  1874. if (isArgs(object)) {
  1875. return originalKeys(slice.call(object));
  1876. } else {
  1877. return originalKeys(object);
  1878. }
  1879. };
  1880. }
  1881. } else {
  1882. Object.keys = keysShim;
  1883. }
  1884. return Object.keys || keysShim;
  1885. };
  1886. module.exports = keysShim;
  1887. },{"./isArguments":50}],50:[function(_dereq_,module,exports){
  1888. 'use strict';
  1889. var toStr = Object.prototype.toString;
  1890. module.exports = function isArguments(value) {
  1891. var str = toStr.call(value);
  1892. var isArgs = str === '[object Arguments]';
  1893. if (!isArgs) {
  1894. isArgs = str !== '[object Array]' &&
  1895. value !== null &&
  1896. typeof value === 'object' &&
  1897. typeof value.length === 'number' &&
  1898. value.length >= 0 &&
  1899. toStr.call(value.callee) === '[object Function]';
  1900. }
  1901. return isArgs;
  1902. };
  1903. },{}],51:[function(_dereq_,module,exports){
  1904. 'use strict';
  1905. var implementation = _dereq_('./implementation');
  1906. var lacksProperEnumerationOrder = function () {
  1907. if (!Object.assign) {
  1908. return false;
  1909. }
  1910. // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
  1911. // note: this does not detect the bug unless there's 20 characters
  1912. var str = 'abcdefghijklmnopqrst';
  1913. var letters = str.split('');
  1914. var map = {};
  1915. for (var i = 0; i < letters.length; ++i) {
  1916. map[letters[i]] = letters[i];
  1917. }
  1918. var obj = Object.assign({}, map);
  1919. var actual = '';
  1920. for (var k in obj) {
  1921. actual += k;
  1922. }
  1923. return str !== actual;
  1924. };
  1925. var assignHasPendingExceptions = function () {
  1926. if (!Object.assign || !Object.preventExtensions) {
  1927. return false;
  1928. }
  1929. // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
  1930. // which is 72% slower than our shim, and Firefox 40's native implementation.
  1931. var thrower = Object.preventExtensions({ 1: 2 });
  1932. try {
  1933. Object.assign(thrower, 'xy');
  1934. } catch (e) {
  1935. return thrower[1] === 'y';
  1936. }
  1937. };
  1938. module.exports = function getPolyfill() {
  1939. if (!Object.assign) {
  1940. return implementation;
  1941. }
  1942. if (lacksProperEnumerationOrder()) {
  1943. return implementation;
  1944. }
  1945. if (assignHasPendingExceptions()) {
  1946. return implementation;
  1947. }
  1948. return Object.assign;
  1949. };
  1950. },{"./implementation":44}],52:[function(_dereq_,module,exports){
  1951. 'use strict';
  1952. var define = _dereq_('define-properties');
  1953. var getPolyfill = _dereq_('./polyfill');
  1954. module.exports = function shimAssign() {
  1955. var polyfill = getPolyfill();
  1956. define(
  1957. Object,
  1958. { assign: polyfill },
  1959. { assign: function () { return Object.assign !== polyfill; } }
  1960. );
  1961. return polyfill;
  1962. };
  1963. },{"./polyfill":51,"define-properties":46}],53:[function(_dereq_,module,exports){
  1964. module.exports = SafeParseTuple
  1965. function SafeParseTuple(obj, reviver) {
  1966. var json
  1967. var error = null
  1968. try {
  1969. json = JSON.parse(obj, reviver)
  1970. } catch (err) {
  1971. error = err
  1972. }
  1973. return [error, json]
  1974. }
  1975. },{}],54:[function(_dereq_,module,exports){
  1976. function clean (s) {
  1977. return s.replace(/\n\r?\s*/g, '')
  1978. }
  1979. module.exports = function tsml (sa) {
  1980. var s = ''
  1981. , i = 0
  1982. for (; i < arguments.length; i++)
  1983. s += clean(sa[i]) + (arguments[i + 1] || '')
  1984. return s
  1985. }
  1986. },{}],55:[function(_dereq_,module,exports){
  1987. "use strict";
  1988. var window = _dereq_("global/window")
  1989. var once = _dereq_("once")
  1990. var isFunction = _dereq_("is-function")
  1991. var parseHeaders = _dereq_("parse-headers")
  1992. var xtend = _dereq_("xtend")
  1993. module.exports = createXHR
  1994. createXHR.XMLHttpRequest = window.XMLHttpRequest || noop
  1995. createXHR.XDomainRequest = "withCredentials" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest
  1996. forEachArray(["get", "put", "post", "patch", "head", "delete"], function(method) {
  1997. createXHR[method === "delete" ? "del" : method] = function(uri, options, callback) {
  1998. options = initParams(uri, options, callback)
  1999. options.method = method.toUpperCase()
  2000. return _createXHR(options)
  2001. }
  2002. })
  2003. function forEachArray(array, iterator) {
  2004. for (var i = 0; i < array.length; i++) {
  2005. iterator(array[i])
  2006. }
  2007. }
  2008. function isEmpty(obj){
  2009. for(var i in obj){
  2010. if(obj.hasOwnProperty(i)) return false
  2011. }
  2012. return true
  2013. }
  2014. function initParams(uri, options, callback) {
  2015. var params = uri
  2016. if (isFunction(options)) {
  2017. callback = options
  2018. if (typeof uri === "string") {
  2019. params = {uri:uri}
  2020. }
  2021. } else {
  2022. params = xtend(options, {uri: uri})
  2023. }
  2024. params.callback = callback
  2025. return params
  2026. }
  2027. function createXHR(uri, options, callback) {
  2028. options = initParams(uri, options, callback)
  2029. return _createXHR(options)
  2030. }
  2031. function _createXHR(options) {
  2032. var callback = options.callback
  2033. if(typeof callback === "undefined"){
  2034. throw new Error("callback argument missing")
  2035. }
  2036. callback = once(callback)
  2037. function readystatechange() {
  2038. if (xhr.readyState === 4) {
  2039. loadFunc()
  2040. }
  2041. }
  2042. function getBody() {
  2043. // Chrome with requestType=blob throws errors arround when even testing access to responseText
  2044. var body = undefined
  2045. if (xhr.response) {
  2046. body = xhr.response
  2047. } else if (xhr.responseType === "text" || !xhr.responseType) {
  2048. body = xhr.responseText || xhr.responseXML
  2049. }
  2050. if (isJson) {
  2051. try {
  2052. body = JSON.parse(body)
  2053. } catch (e) {}
  2054. }
  2055. return body
  2056. }
  2057. var failureResponse = {
  2058. body: undefined,
  2059. headers: {},
  2060. statusCode: 0,
  2061. method: method,
  2062. url: uri,
  2063. rawRequest: xhr
  2064. }
  2065. function errorFunc(evt) {
  2066. clearTimeout(timeoutTimer)
  2067. if(!(evt instanceof Error)){
  2068. evt = new Error("" + (evt || "Unknown XMLHttpRequest Error") )
  2069. }
  2070. evt.statusCode = 0
  2071. callback(evt, failureResponse)
  2072. }
  2073. // will load the data & process the response in a special response object
  2074. function loadFunc() {
  2075. if (aborted) return
  2076. var status
  2077. clearTimeout(timeoutTimer)
  2078. if(options.useXDR && xhr.status===undefined) {
  2079. //IE8 CORS GET successful response doesn't have a status field, but body is fine
  2080. status = 200
  2081. } else {
  2082. status = (xhr.status === 1223 ? 204 : xhr.status)
  2083. }
  2084. var response = failureResponse
  2085. var err = null
  2086. if (status !== 0){
  2087. response = {
  2088. body: getBody(),
  2089. statusCode: status,
  2090. method: method,
  2091. headers: {},
  2092. url: uri,
  2093. rawRequest: xhr
  2094. }
  2095. if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE
  2096. response.headers = parseHeaders(xhr.getAllResponseHeaders())
  2097. }
  2098. } else {
  2099. err = new Error("Internal XMLHttpRequest Error")
  2100. }
  2101. callback(err, response, response.body)
  2102. }
  2103. var xhr = options.xhr || null
  2104. if (!xhr) {
  2105. if (options.cors || options.useXDR) {
  2106. xhr = new createXHR.XDomainRequest()
  2107. }else{
  2108. xhr = new createXHR.XMLHttpRequest()
  2109. }
  2110. }
  2111. var key
  2112. var aborted
  2113. var uri = xhr.url = options.uri || options.url
  2114. var method = xhr.method = options.method || "GET"
  2115. var body = options.body || options.data || null
  2116. var headers = xhr.headers = options.headers || {}
  2117. var sync = !!options.sync
  2118. var isJson = false
  2119. var timeoutTimer
  2120. if ("json" in options) {
  2121. isJson = true
  2122. headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json") //Don't override existing accept header declared by user
  2123. if (method !== "GET" && method !== "HEAD") {
  2124. headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json") //Don't override existing accept header declared by user
  2125. body = JSON.stringify(options.json)
  2126. }
  2127. }
  2128. xhr.onreadystatechange = readystatechange
  2129. xhr.onload = loadFunc
  2130. xhr.onerror = errorFunc
  2131. // IE9 must have onprogress be set to a unique function.
  2132. xhr.onprogress = function () {
  2133. // IE must die
  2134. }
  2135. xhr.ontimeout = errorFunc
  2136. xhr.open(method, uri, !sync, options.username, options.password)
  2137. //has to be after open
  2138. if(!sync) {
  2139. xhr.withCredentials = !!options.withCredentials
  2140. }
  2141. // Cannot set timeout with sync request
  2142. // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
  2143. // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
  2144. if (!sync && options.timeout > 0 ) {
  2145. timeoutTimer = setTimeout(function(){
  2146. aborted=true//IE9 may still call readystatechange
  2147. xhr.abort("timeout")
  2148. var e = new Error("XMLHttpRequest timeout")
  2149. e.code = "ETIMEDOUT"
  2150. errorFunc(e)
  2151. }, options.timeout )
  2152. }
  2153. if (xhr.setRequestHeader) {
  2154. for(key in headers){
  2155. if(headers.hasOwnProperty(key)){
  2156. xhr.setRequestHeader(key, headers[key])
  2157. }
  2158. }
  2159. } else if (options.headers && !isEmpty(options.headers)) {
  2160. throw new Error("Headers cannot be set on an XDomainRequest object")
  2161. }
  2162. if ("responseType" in options) {
  2163. xhr.responseType = options.responseType
  2164. }
  2165. if ("beforeSend" in options &&
  2166. typeof options.beforeSend === "function"
  2167. ) {
  2168. options.beforeSend(xhr)
  2169. }
  2170. xhr.send(body)
  2171. return xhr
  2172. }
  2173. function noop() {}
  2174. },{"global/window":2,"is-function":56,"once":57,"parse-headers":60,"xtend":61}],56:[function(_dereq_,module,exports){
  2175. module.exports = isFunction
  2176. var toString = Object.prototype.toString
  2177. function isFunction (fn) {
  2178. var string = toString.call(fn)
  2179. return string === '[object Function]' ||
  2180. (typeof fn === 'function' && string !== '[object RegExp]') ||
  2181. (typeof window !== 'undefined' &&
  2182. // IE8 and below
  2183. (fn === window.setTimeout ||
  2184. fn === window.alert ||
  2185. fn === window.confirm ||
  2186. fn === window.prompt))
  2187. };
  2188. },{}],57:[function(_dereq_,module,exports){
  2189. module.exports = once
  2190. once.proto = once(function () {
  2191. Object.defineProperty(Function.prototype, 'once', {
  2192. value: function () {
  2193. return once(this)
  2194. },
  2195. configurable: true
  2196. })
  2197. })
  2198. function once (fn) {
  2199. var called = false
  2200. return function () {
  2201. if (called) return
  2202. called = true
  2203. return fn.apply(this, arguments)
  2204. }
  2205. }
  2206. },{}],58:[function(_dereq_,module,exports){
  2207. var isFunction = _dereq_('is-function')
  2208. module.exports = forEach
  2209. var toString = Object.prototype.toString
  2210. var hasOwnProperty = Object.prototype.hasOwnProperty
  2211. function forEach(list, iterator, context) {
  2212. if (!isFunction(iterator)) {
  2213. throw new TypeError('iterator must be a function')
  2214. }
  2215. if (arguments.length < 3) {
  2216. context = this
  2217. }
  2218. if (toString.call(list) === '[object Array]')
  2219. forEachArray(list, iterator, context)
  2220. else if (typeof list === 'string')
  2221. forEachString(list, iterator, context)
  2222. else
  2223. forEachObject(list, iterator, context)
  2224. }
  2225. function forEachArray(array, iterator, context) {
  2226. for (var i = 0, len = array.length; i < len; i++) {
  2227. if (hasOwnProperty.call(array, i)) {
  2228. iterator.call(context, array[i], i, array)
  2229. }
  2230. }
  2231. }
  2232. function forEachString(string, iterator, context) {
  2233. for (var i = 0, len = string.length; i < len; i++) {
  2234. // no such thing as a sparse string.
  2235. iterator.call(context, string.charAt(i), i, string)
  2236. }
  2237. }
  2238. function forEachObject(object, iterator, context) {
  2239. for (var k in object) {
  2240. if (hasOwnProperty.call(object, k)) {
  2241. iterator.call(context, object[k], k, object)
  2242. }
  2243. }
  2244. }
  2245. },{"is-function":56}],59:[function(_dereq_,module,exports){
  2246. exports = module.exports = trim;
  2247. function trim(str){
  2248. return str.replace(/^\s*|\s*$/g, '');
  2249. }
  2250. exports.left = function(str){
  2251. return str.replace(/^\s*/, '');
  2252. };
  2253. exports.right = function(str){
  2254. return str.replace(/\s*$/, '');
  2255. };
  2256. },{}],60:[function(_dereq_,module,exports){
  2257. var trim = _dereq_('trim')
  2258. , forEach = _dereq_('for-each')
  2259. , isArray = function(arg) {
  2260. return Object.prototype.toString.call(arg) === '[object Array]';
  2261. }
  2262. module.exports = function (headers) {
  2263. if (!headers)
  2264. return {}
  2265. var result = {}
  2266. forEach(
  2267. trim(headers).split('\n')
  2268. , function (row) {
  2269. var index = row.indexOf(':')
  2270. , key = trim(row.slice(0, index)).toLowerCase()
  2271. , value = trim(row.slice(index + 1))
  2272. if (typeof(result[key]) === 'undefined') {
  2273. result[key] = value
  2274. } else if (isArray(result[key])) {
  2275. result[key].push(value)
  2276. } else {
  2277. result[key] = [ result[key], value ]
  2278. }
  2279. }
  2280. )
  2281. return result
  2282. }
  2283. },{"for-each":58,"trim":59}],61:[function(_dereq_,module,exports){
  2284. module.exports = extend
  2285. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2286. function extend() {
  2287. var target = {}
  2288. for (var i = 0; i < arguments.length; i++) {
  2289. var source = arguments[i]
  2290. for (var key in source) {
  2291. if (hasOwnProperty.call(source, key)) {
  2292. target[key] = source[key]
  2293. }
  2294. }
  2295. }
  2296. return target
  2297. }
  2298. },{}],62:[function(_dereq_,module,exports){
  2299. /**
  2300. * @file big-play-button.js
  2301. */
  2302. 'use strict';
  2303. exports.__esModule = true;
  2304. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2305. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2306. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2307. var _buttonJs = _dereq_('./button.js');
  2308. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  2309. var _componentJs = _dereq_('./component.js');
  2310. var _componentJs2 = _interopRequireDefault(_componentJs);
  2311. /**
  2312. * Initial play button. Shows before the video has played. The hiding of the
  2313. * big play button is done via CSS and player states.
  2314. *
  2315. * @param {Object} player Main Player
  2316. * @param {Object=} options Object of option names and values
  2317. * @extends Button
  2318. * @class BigPlayButton
  2319. */
  2320. var BigPlayButton = (function (_Button) {
  2321. _inherits(BigPlayButton, _Button);
  2322. function BigPlayButton(player, options) {
  2323. _classCallCheck(this, BigPlayButton);
  2324. _Button.call(this, player, options);
  2325. }
  2326. /**
  2327. * Allow sub components to stack CSS class names
  2328. *
  2329. * @return {String} The constructed class name
  2330. * @method buildCSSClass
  2331. */
  2332. BigPlayButton.prototype.buildCSSClass = function buildCSSClass() {
  2333. return 'vjs-big-play-button';
  2334. };
  2335. /**
  2336. * Handles click for play
  2337. *
  2338. * @method handleClick
  2339. */
  2340. BigPlayButton.prototype.handleClick = function handleClick() {
  2341. this.player_.play();
  2342. };
  2343. return BigPlayButton;
  2344. })(_buttonJs2['default']);
  2345. BigPlayButton.prototype.controlText_ = 'Play Video';
  2346. _componentJs2['default'].registerComponent('BigPlayButton', BigPlayButton);
  2347. exports['default'] = BigPlayButton;
  2348. module.exports = exports['default'];
  2349. },{"./button.js":63,"./component.js":65}],63:[function(_dereq_,module,exports){
  2350. /**
  2351. * @file button.js
  2352. */
  2353. 'use strict';
  2354. exports.__esModule = true;
  2355. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
  2356. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2357. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2358. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2359. var _component = _dereq_('./component');
  2360. var _component2 = _interopRequireDefault(_component);
  2361. var _utilsDomJs = _dereq_('./utils/dom.js');
  2362. var Dom = _interopRequireWildcard(_utilsDomJs);
  2363. var _utilsEventsJs = _dereq_('./utils/events.js');
  2364. var Events = _interopRequireWildcard(_utilsEventsJs);
  2365. var _utilsFnJs = _dereq_('./utils/fn.js');
  2366. var Fn = _interopRequireWildcard(_utilsFnJs);
  2367. var _globalDocument = _dereq_('global/document');
  2368. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  2369. var _objectAssign = _dereq_('object.assign');
  2370. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  2371. /**
  2372. * Base class for all buttons
  2373. *
  2374. * @param {Object} player Main Player
  2375. * @param {Object=} options Object of option names and values
  2376. * @extends Component
  2377. * @class Button
  2378. */
  2379. var Button = (function (_Component) {
  2380. _inherits(Button, _Component);
  2381. function Button(player, options) {
  2382. _classCallCheck(this, Button);
  2383. _Component.call(this, player, options);
  2384. this.emitTapEvents();
  2385. this.on('tap', this.handleClick);
  2386. this.on('click', this.handleClick);
  2387. this.on('focus', this.handleFocus);
  2388. this.on('blur', this.handleBlur);
  2389. }
  2390. /**
  2391. * Create the component's DOM element
  2392. *
  2393. * @param {String=} type Element's node type. e.g. 'div'
  2394. * @param {Object=} props An object of element attributes that should be set on the element Tag name
  2395. * @return {Element}
  2396. * @method createEl
  2397. */
  2398. Button.prototype.createEl = function createEl() {
  2399. var tag = arguments.length <= 0 || arguments[0] === undefined ? 'button' : arguments[0];
  2400. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2401. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  2402. props = _objectAssign2['default']({
  2403. className: this.buildCSSClass(),
  2404. tabIndex: 0
  2405. }, props);
  2406. // Add standard Aria info
  2407. attributes = _objectAssign2['default']({
  2408. role: 'button',
  2409. type: 'button', // Necessary since the default button type is "submit"
  2410. 'aria-live': 'polite' // let the screen reader user know that the text of the button may change
  2411. }, attributes);
  2412. var el = _Component.prototype.createEl.call(this, tag, props, attributes);
  2413. this.controlTextEl_ = Dom.createEl('span', {
  2414. className: 'vjs-control-text'
  2415. });
  2416. el.appendChild(this.controlTextEl_);
  2417. this.controlText(this.controlText_);
  2418. return el;
  2419. };
  2420. /**
  2421. * Controls text - both request and localize
  2422. *
  2423. * @param {String} text Text for button
  2424. * @return {String}
  2425. * @method controlText
  2426. */
  2427. Button.prototype.controlText = function controlText(text) {
  2428. if (!text) return this.controlText_ || 'Need Text';
  2429. this.controlText_ = text;
  2430. this.controlTextEl_.innerHTML = this.localize(this.controlText_);
  2431. return this;
  2432. };
  2433. /**
  2434. * Allows sub components to stack CSS class names
  2435. *
  2436. * @return {String}
  2437. * @method buildCSSClass
  2438. */
  2439. Button.prototype.buildCSSClass = function buildCSSClass() {
  2440. return 'vjs-control vjs-button ' + _Component.prototype.buildCSSClass.call(this);
  2441. };
  2442. /**
  2443. * Handle Click - Override with specific functionality for button
  2444. *
  2445. * @method handleClick
  2446. */
  2447. Button.prototype.handleClick = function handleClick() {};
  2448. /**
  2449. * Handle Focus - Add keyboard functionality to element
  2450. *
  2451. * @method handleFocus
  2452. */
  2453. Button.prototype.handleFocus = function handleFocus() {
  2454. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  2455. };
  2456. /**
  2457. * Handle KeyPress (document level) - Trigger click when keys are pressed
  2458. *
  2459. * @method handleKeyPress
  2460. */
  2461. Button.prototype.handleKeyPress = function handleKeyPress(event) {
  2462. // Check for space bar (32) or enter (13) keys
  2463. if (event.which === 32 || event.which === 13) {
  2464. event.preventDefault();
  2465. this.handleClick(event);
  2466. }
  2467. };
  2468. /**
  2469. * Handle Blur - Remove keyboard triggers
  2470. *
  2471. * @method handleBlur
  2472. */
  2473. Button.prototype.handleBlur = function handleBlur() {
  2474. Events.off(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  2475. };
  2476. return Button;
  2477. })(_component2['default']);
  2478. _component2['default'].registerComponent('Button', Button);
  2479. exports['default'] = Button;
  2480. module.exports = exports['default'];
  2481. },{"./component":65,"./utils/dom.js":128,"./utils/events.js":129,"./utils/fn.js":130,"global/document":1,"object.assign":45}],64:[function(_dereq_,module,exports){
  2482. 'use strict';
  2483. exports.__esModule = true;
  2484. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2485. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2486. 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; }
  2487. var _button = _dereq_('./button');
  2488. var _button2 = _interopRequireDefault(_button);
  2489. var _component = _dereq_('./component');
  2490. var _component2 = _interopRequireDefault(_component);
  2491. /**
  2492. * The `CloseButton` component is a button which fires a "close" event
  2493. * when it is activated.
  2494. *
  2495. * @extends Button
  2496. * @class CloseButton
  2497. */
  2498. var CloseButton = (function (_Button) {
  2499. _inherits(CloseButton, _Button);
  2500. function CloseButton(player, options) {
  2501. _classCallCheck(this, CloseButton);
  2502. _Button.call(this, player, options);
  2503. this.controlText(options && options.controlText || this.localize('Close'));
  2504. }
  2505. CloseButton.prototype.buildCSSClass = function buildCSSClass() {
  2506. return 'vjs-close-button ' + _Button.prototype.buildCSSClass.call(this);
  2507. };
  2508. CloseButton.prototype.handleClick = function handleClick() {
  2509. this.trigger({ type: 'close', bubbles: false });
  2510. };
  2511. return CloseButton;
  2512. })(_button2['default']);
  2513. _component2['default'].registerComponent('CloseButton', CloseButton);
  2514. exports['default'] = CloseButton;
  2515. module.exports = exports['default'];
  2516. },{"./button":63,"./component":65}],65:[function(_dereq_,module,exports){
  2517. /**
  2518. * @file component.js
  2519. *
  2520. * Player Component - Base class for all UI objects
  2521. */
  2522. 'use strict';
  2523. exports.__esModule = true;
  2524. 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; } }
  2525. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2526. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2527. var _globalWindow = _dereq_('global/window');
  2528. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  2529. var _utilsDomJs = _dereq_('./utils/dom.js');
  2530. var Dom = _interopRequireWildcard(_utilsDomJs);
  2531. var _utilsFnJs = _dereq_('./utils/fn.js');
  2532. var Fn = _interopRequireWildcard(_utilsFnJs);
  2533. var _utilsGuidJs = _dereq_('./utils/guid.js');
  2534. var Guid = _interopRequireWildcard(_utilsGuidJs);
  2535. var _utilsEventsJs = _dereq_('./utils/events.js');
  2536. var Events = _interopRequireWildcard(_utilsEventsJs);
  2537. var _utilsLogJs = _dereq_('./utils/log.js');
  2538. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  2539. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
  2540. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  2541. var _objectAssign = _dereq_('object.assign');
  2542. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  2543. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
  2544. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  2545. /**
  2546. * Base UI Component class
  2547. * Components are embeddable UI objects that are represented by both a
  2548. * javascript object and an element in the DOM. They can be children of other
  2549. * components, and can have many children themselves.
  2550. * ```js
  2551. * // adding a button to the player
  2552. * var button = player.addChild('button');
  2553. * button.el(); // -> button element
  2554. * ```
  2555. * ```html
  2556. * <div class="video-js">
  2557. * <div class="vjs-button">Button</div>
  2558. * </div>
  2559. * ```
  2560. * Components are also event targets.
  2561. * ```js
  2562. * button.on('click', function(){
  2563. * console.log('Button Clicked!');
  2564. * });
  2565. * button.trigger('customevent');
  2566. * ```
  2567. *
  2568. * @param {Object} player Main Player
  2569. * @param {Object=} options Object of option names and values
  2570. * @param {Function=} ready Ready callback function
  2571. * @class Component
  2572. */
  2573. var Component = (function () {
  2574. function Component(player, options, ready) {
  2575. _classCallCheck(this, Component);
  2576. // The component might be the player itself and we can't pass `this` to super
  2577. if (!player && this.play) {
  2578. this.player_ = player = this; // eslint-disable-line
  2579. } else {
  2580. this.player_ = player;
  2581. }
  2582. // Make a copy of prototype.options_ to protect against overriding defaults
  2583. this.options_ = _utilsMergeOptionsJs2['default']({}, this.options_);
  2584. // Updated options with supplied options
  2585. options = this.options_ = _utilsMergeOptionsJs2['default'](this.options_, options);
  2586. // Get ID from options or options element if one is supplied
  2587. this.id_ = options.id || options.el && options.el.id;
  2588. // If there was no ID from the options, generate one
  2589. if (!this.id_) {
  2590. // Don't require the player ID function in the case of mock players
  2591. var id = player && player.id && player.id() || 'no_player';
  2592. this.id_ = id + '_component_' + Guid.newGUID();
  2593. }
  2594. this.name_ = options.name || null;
  2595. // Create element if one wasn't provided in options
  2596. if (options.el) {
  2597. this.el_ = options.el;
  2598. } else if (options.createEl !== false) {
  2599. this.el_ = this.createEl();
  2600. }
  2601. this.children_ = [];
  2602. this.childIndex_ = {};
  2603. this.childNameIndex_ = {};
  2604. // Add any child components in options
  2605. if (options.initChildren !== false) {
  2606. this.initChildren();
  2607. }
  2608. this.ready(ready);
  2609. // Don't want to trigger ready here or it will before init is actually
  2610. // finished for all children that run this constructor
  2611. if (options.reportTouchActivity !== false) {
  2612. this.enableTouchActivity();
  2613. }
  2614. }
  2615. /**
  2616. * Dispose of the component and all child components
  2617. *
  2618. * @method dispose
  2619. */
  2620. Component.prototype.dispose = function dispose() {
  2621. this.trigger({ type: 'dispose', bubbles: false });
  2622. // Dispose all children.
  2623. if (this.children_) {
  2624. for (var i = this.children_.length - 1; i >= 0; i--) {
  2625. if (this.children_[i].dispose) {
  2626. this.children_[i].dispose();
  2627. }
  2628. }
  2629. }
  2630. // Delete child references
  2631. this.children_ = null;
  2632. this.childIndex_ = null;
  2633. this.childNameIndex_ = null;
  2634. // Remove all event listeners.
  2635. this.off();
  2636. // Remove element from DOM
  2637. if (this.el_.parentNode) {
  2638. this.el_.parentNode.removeChild(this.el_);
  2639. }
  2640. Dom.removeElData(this.el_);
  2641. this.el_ = null;
  2642. };
  2643. /**
  2644. * Return the component's player
  2645. *
  2646. * @return {Player}
  2647. * @method player
  2648. */
  2649. Component.prototype.player = function player() {
  2650. return this.player_;
  2651. };
  2652. /**
  2653. * Deep merge of options objects
  2654. * Whenever a property is an object on both options objects
  2655. * the two properties will be merged using mergeOptions.
  2656. *
  2657. * ```js
  2658. * Parent.prototype.options_ = {
  2659. * optionSet: {
  2660. * 'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
  2661. * 'childTwo': {},
  2662. * 'childThree': {}
  2663. * }
  2664. * }
  2665. * newOptions = {
  2666. * optionSet: {
  2667. * 'childOne': { 'foo': 'baz', 'abc': '123' }
  2668. * 'childTwo': null,
  2669. * 'childFour': {}
  2670. * }
  2671. * }
  2672. *
  2673. * this.options(newOptions);
  2674. * ```
  2675. * RESULT
  2676. * ```js
  2677. * {
  2678. * optionSet: {
  2679. * 'childOne': { 'foo': 'baz', 'asdf': 'fdsa', 'abc': '123' },
  2680. * 'childTwo': null, // Disabled. Won't be initialized.
  2681. * 'childThree': {},
  2682. * 'childFour': {}
  2683. * }
  2684. * }
  2685. * ```
  2686. *
  2687. * @param {Object} obj Object of new option values
  2688. * @return {Object} A NEW object of this.options_ and obj merged
  2689. * @method options
  2690. */
  2691. Component.prototype.options = function options(obj) {
  2692. _utilsLogJs2['default'].warn('this.options() has been deprecated and will be moved to the constructor in 6.0');
  2693. if (!obj) {
  2694. return this.options_;
  2695. }
  2696. this.options_ = _utilsMergeOptionsJs2['default'](this.options_, obj);
  2697. return this.options_;
  2698. };
  2699. /**
  2700. * Get the component's DOM element
  2701. * ```js
  2702. * var domEl = myComponent.el();
  2703. * ```
  2704. *
  2705. * @return {Element}
  2706. * @method el
  2707. */
  2708. Component.prototype.el = function el() {
  2709. return this.el_;
  2710. };
  2711. /**
  2712. * Create the component's DOM element
  2713. *
  2714. * @param {String=} tagName Element's node type. e.g. 'div'
  2715. * @param {Object=} properties An object of properties that should be set
  2716. * @param {Object=} attributes An object of attributes that should be set
  2717. * @return {Element}
  2718. * @method createEl
  2719. */
  2720. Component.prototype.createEl = function createEl(tagName, properties, attributes) {
  2721. return Dom.createEl(tagName, properties, attributes);
  2722. };
  2723. Component.prototype.localize = function localize(string) {
  2724. var code = this.player_.language && this.player_.language();
  2725. var languages = this.player_.languages && this.player_.languages();
  2726. if (!code || !languages) {
  2727. return string;
  2728. }
  2729. var language = languages[code];
  2730. if (language && language[string]) {
  2731. return language[string];
  2732. }
  2733. var primaryCode = code.split('-')[0];
  2734. var primaryLang = languages[primaryCode];
  2735. if (primaryLang && primaryLang[string]) {
  2736. return primaryLang[string];
  2737. }
  2738. return string;
  2739. };
  2740. /**
  2741. * Return the component's DOM element where children are inserted.
  2742. * Will either be the same as el() or a new element defined in createEl().
  2743. *
  2744. * @return {Element}
  2745. * @method contentEl
  2746. */
  2747. Component.prototype.contentEl = function contentEl() {
  2748. return this.contentEl_ || this.el_;
  2749. };
  2750. /**
  2751. * Get the component's ID
  2752. * ```js
  2753. * var id = myComponent.id();
  2754. * ```
  2755. *
  2756. * @return {String}
  2757. * @method id
  2758. */
  2759. Component.prototype.id = function id() {
  2760. return this.id_;
  2761. };
  2762. /**
  2763. * Get the component's name. The name is often used to reference the component.
  2764. * ```js
  2765. * var name = myComponent.name();
  2766. * ```
  2767. *
  2768. * @return {String}
  2769. * @method name
  2770. */
  2771. Component.prototype.name = function name() {
  2772. return this.name_;
  2773. };
  2774. /**
  2775. * Get an array of all child components
  2776. * ```js
  2777. * var kids = myComponent.children();
  2778. * ```
  2779. *
  2780. * @return {Array} The children
  2781. * @method children
  2782. */
  2783. Component.prototype.children = function children() {
  2784. return this.children_;
  2785. };
  2786. /**
  2787. * Returns a child component with the provided ID
  2788. *
  2789. * @return {Component}
  2790. * @method getChildById
  2791. */
  2792. Component.prototype.getChildById = function getChildById(id) {
  2793. return this.childIndex_[id];
  2794. };
  2795. /**
  2796. * Returns a child component with the provided name
  2797. *
  2798. * @return {Component}
  2799. * @method getChild
  2800. */
  2801. Component.prototype.getChild = function getChild(name) {
  2802. return this.childNameIndex_[name];
  2803. };
  2804. /**
  2805. * Adds a child component inside this component
  2806. * ```js
  2807. * myComponent.el();
  2808. * // -> <div class='my-component'></div>
  2809. * myComponent.children();
  2810. * // [empty array]
  2811. *
  2812. * var myButton = myComponent.addChild('MyButton');
  2813. * // -> <div class='my-component'><div class="my-button">myButton<div></div>
  2814. * // -> myButton === myComponent.children()[0];
  2815. * ```
  2816. * Pass in options for child constructors and options for children of the child
  2817. * ```js
  2818. * var myButton = myComponent.addChild('MyButton', {
  2819. * text: 'Press Me',
  2820. * buttonChildExample: {
  2821. * buttonChildOption: true
  2822. * }
  2823. * });
  2824. * ```
  2825. *
  2826. * @param {String|Component} child The class name or instance of a child to add
  2827. * @param {Object=} options Options, including options to be passed to children of the child.
  2828. * @return {Component} The child component (created by this process if a string was used)
  2829. * @method addChild
  2830. */
  2831. Component.prototype.addChild = function addChild(child) {
  2832. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2833. var component = undefined;
  2834. var componentName = undefined;
  2835. // If child is a string, create nt with options
  2836. if (typeof child === 'string') {
  2837. componentName = child;
  2838. // Options can also be specified as a boolean, so convert to an empty object if false.
  2839. if (!options) {
  2840. options = {};
  2841. }
  2842. // Same as above, but true is deprecated so show a warning.
  2843. if (options === true) {
  2844. _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`.');
  2845. options = {};
  2846. }
  2847. // If no componentClass in options, assume componentClass is the name lowercased
  2848. // (e.g. playButton)
  2849. var componentClassName = options.componentClass || _utilsToTitleCaseJs2['default'](componentName);
  2850. // Set name through options
  2851. options.name = componentName;
  2852. // Create a new object & element for this controls set
  2853. // If there's no .player_, this is a player
  2854. var ComponentClass = Component.getComponent(componentClassName);
  2855. if (!ComponentClass) {
  2856. throw new Error('Component ' + componentClassName + ' does not exist');
  2857. }
  2858. // data stored directly on the videojs object may be
  2859. // misidentified as a component to retain
  2860. // backwards-compatibility with 4.x. check to make sure the
  2861. // component class can be instantiated.
  2862. if (typeof ComponentClass !== 'function') {
  2863. return null;
  2864. }
  2865. component = new ComponentClass(this.player_ || this, options);
  2866. // child is a component instance
  2867. } else {
  2868. component = child;
  2869. }
  2870. this.children_.push(component);
  2871. if (typeof component.id === 'function') {
  2872. this.childIndex_[component.id()] = component;
  2873. }
  2874. // If a name wasn't used to create the component, check if we can use the
  2875. // name function of the component
  2876. componentName = componentName || component.name && component.name();
  2877. if (componentName) {
  2878. this.childNameIndex_[componentName] = component;
  2879. }
  2880. // Add the UI object's element to the container div (box)
  2881. // Having an element is not required
  2882. if (typeof component.el === 'function' && component.el()) {
  2883. this.contentEl().appendChild(component.el());
  2884. }
  2885. // Return so it can stored on parent object if desired.
  2886. return component;
  2887. };
  2888. /**
  2889. * Remove a child component from this component's list of children, and the
  2890. * child component's element from this component's element
  2891. *
  2892. * @param {Component} component Component to remove
  2893. * @method removeChild
  2894. */
  2895. Component.prototype.removeChild = function removeChild(component) {
  2896. if (typeof component === 'string') {
  2897. component = this.getChild(component);
  2898. }
  2899. if (!component || !this.children_) {
  2900. return;
  2901. }
  2902. var childFound = false;
  2903. for (var i = this.children_.length - 1; i >= 0; i--) {
  2904. if (this.children_[i] === component) {
  2905. childFound = true;
  2906. this.children_.splice(i, 1);
  2907. break;
  2908. }
  2909. }
  2910. if (!childFound) {
  2911. return;
  2912. }
  2913. this.childIndex_[component.id()] = null;
  2914. this.childNameIndex_[component.name()] = null;
  2915. var compEl = component.el();
  2916. if (compEl && compEl.parentNode === this.contentEl()) {
  2917. this.contentEl().removeChild(component.el());
  2918. }
  2919. };
  2920. /**
  2921. * Add and initialize default child components from options
  2922. * ```js
  2923. * // when an instance of MyComponent is created, all children in options
  2924. * // will be added to the instance by their name strings and options
  2925. * MyComponent.prototype.options_ = {
  2926. * children: [
  2927. * 'myChildComponent'
  2928. * ],
  2929. * myChildComponent: {
  2930. * myChildOption: true
  2931. * }
  2932. * };
  2933. *
  2934. * // Or when creating the component
  2935. * var myComp = new MyComponent(player, {
  2936. * children: [
  2937. * 'myChildComponent'
  2938. * ],
  2939. * myChildComponent: {
  2940. * myChildOption: true
  2941. * }
  2942. * });
  2943. * ```
  2944. * The children option can also be an array of
  2945. * child options objects (that also include a 'name' key).
  2946. * This can be used if you have two child components of the
  2947. * same type that need different options.
  2948. * ```js
  2949. * var myComp = new MyComponent(player, {
  2950. * children: [
  2951. * 'button',
  2952. * {
  2953. * name: 'button',
  2954. * someOtherOption: true
  2955. * },
  2956. * {
  2957. * name: 'button',
  2958. * someOtherOption: false
  2959. * }
  2960. * ]
  2961. * });
  2962. * ```
  2963. *
  2964. * @method initChildren
  2965. */
  2966. Component.prototype.initChildren = function initChildren() {
  2967. var _this = this;
  2968. var children = this.options_.children;
  2969. if (children) {
  2970. (function () {
  2971. // `this` is `parent`
  2972. var parentOptions = _this.options_;
  2973. var handleAdd = function handleAdd(child) {
  2974. var name = child.name;
  2975. var opts = child.opts;
  2976. // Allow options for children to be set at the parent options
  2977. // e.g. videojs(id, { controlBar: false });
  2978. // instead of videojs(id, { children: { controlBar: false });
  2979. if (parentOptions[name] !== undefined) {
  2980. opts = parentOptions[name];
  2981. }
  2982. // Allow for disabling default components
  2983. // e.g. options['children']['posterImage'] = false
  2984. if (opts === false) {
  2985. return;
  2986. }
  2987. // Allow options to be passed as a simple boolean if no configuration
  2988. // is necessary.
  2989. if (opts === true) {
  2990. opts = {};
  2991. }
  2992. // We also want to pass the original player options to each component as well so they don't need to
  2993. // reach back into the player for options later.
  2994. opts.playerOptions = _this.options_.playerOptions;
  2995. // Create and add the child component.
  2996. // Add a direct reference to the child by name on the parent instance.
  2997. // If two of the same component are used, different names should be supplied
  2998. // for each
  2999. var newChild = _this.addChild(name, opts);
  3000. if (newChild) {
  3001. _this[name] = newChild;
  3002. }
  3003. };
  3004. // Allow for an array of children details to passed in the options
  3005. var workingChildren = undefined;
  3006. var Tech = Component.getComponent('Tech');
  3007. if (Array.isArray(children)) {
  3008. workingChildren = children;
  3009. } else {
  3010. workingChildren = Object.keys(children);
  3011. }
  3012. workingChildren
  3013. // children that are in this.options_ but also in workingChildren would
  3014. // give us extra children we do not want. So, we want to filter them out.
  3015. .concat(Object.keys(_this.options_).filter(function (child) {
  3016. return !workingChildren.some(function (wchild) {
  3017. if (typeof wchild === 'string') {
  3018. return child === wchild;
  3019. } else {
  3020. return child === wchild.name;
  3021. }
  3022. });
  3023. })).map(function (child) {
  3024. var name = undefined,
  3025. opts = undefined;
  3026. if (typeof child === 'string') {
  3027. name = child;
  3028. opts = children[name] || _this.options_[name] || {};
  3029. } else {
  3030. name = child.name;
  3031. opts = child;
  3032. }
  3033. return { name: name, opts: opts };
  3034. }).filter(function (child) {
  3035. // we have to make sure that child.name isn't in the techOrder since
  3036. // techs are registerd as Components but can't aren't compatible
  3037. // See https://github.com/videojs/video.js/issues/2772
  3038. var c = Component.getComponent(child.opts.componentClass || _utilsToTitleCaseJs2['default'](child.name));
  3039. return c && !Tech.isTech(c);
  3040. }).forEach(handleAdd);
  3041. })();
  3042. }
  3043. };
  3044. /**
  3045. * Allows sub components to stack CSS class names
  3046. *
  3047. * @return {String} The constructed class name
  3048. * @method buildCSSClass
  3049. */
  3050. Component.prototype.buildCSSClass = function buildCSSClass() {
  3051. // Child classes can include a function that does:
  3052. // return 'CLASS NAME' + this._super();
  3053. return '';
  3054. };
  3055. /**
  3056. * Add an event listener to this component's element
  3057. * ```js
  3058. * var myFunc = function(){
  3059. * var myComponent = this;
  3060. * // Do something when the event is fired
  3061. * };
  3062. *
  3063. * myComponent.on('eventType', myFunc);
  3064. * ```
  3065. * The context of myFunc will be myComponent unless previously bound.
  3066. * Alternatively, you can add a listener to another element or component.
  3067. * ```js
  3068. * myComponent.on(otherElement, 'eventName', myFunc);
  3069. * myComponent.on(otherComponent, 'eventName', myFunc);
  3070. * ```
  3071. * The benefit of using this over `VjsEvents.on(otherElement, 'eventName', myFunc)`
  3072. * and `otherComponent.on('eventName', myFunc)` is that this way the listeners
  3073. * will be automatically cleaned up when either component is disposed.
  3074. * It will also bind myComponent as the context of myFunc.
  3075. * **NOTE**: When using this on elements in the page other than window
  3076. * and document (both permanent), if you remove the element from the DOM
  3077. * you need to call `myComponent.trigger(el, 'dispose')` on it to clean up
  3078. * references to it and allow the browser to garbage collect it.
  3079. *
  3080. * @param {String|Component} first The event type or other component
  3081. * @param {Function|String} second The event handler or event type
  3082. * @param {Function} third The event handler
  3083. * @return {Component}
  3084. * @method on
  3085. */
  3086. Component.prototype.on = function on(first, second, third) {
  3087. var _this2 = this;
  3088. if (typeof first === 'string' || Array.isArray(first)) {
  3089. Events.on(this.el_, first, Fn.bind(this, second));
  3090. // Targeting another component or element
  3091. } else {
  3092. (function () {
  3093. var target = first;
  3094. var type = second;
  3095. var fn = Fn.bind(_this2, third);
  3096. // When this component is disposed, remove the listener from the other component
  3097. var removeOnDispose = function removeOnDispose() {
  3098. return _this2.off(target, type, fn);
  3099. };
  3100. // Use the same function ID so we can remove it later it using the ID
  3101. // of the original listener
  3102. removeOnDispose.guid = fn.guid;
  3103. _this2.on('dispose', removeOnDispose);
  3104. // If the other component is disposed first we need to clean the reference
  3105. // to the other component in this component's removeOnDispose listener
  3106. // Otherwise we create a memory leak.
  3107. var cleanRemover = function cleanRemover() {
  3108. return _this2.off('dispose', removeOnDispose);
  3109. };
  3110. // Add the same function ID so we can easily remove it later
  3111. cleanRemover.guid = fn.guid;
  3112. // Check if this is a DOM node
  3113. if (first.nodeName) {
  3114. // Add the listener to the other element
  3115. Events.on(target, type, fn);
  3116. Events.on(target, 'dispose', cleanRemover);
  3117. // Should be a component
  3118. // Not using `instanceof Component` because it makes mock players difficult
  3119. } else if (typeof first.on === 'function') {
  3120. // Add the listener to the other component
  3121. target.on(type, fn);
  3122. target.on('dispose', cleanRemover);
  3123. }
  3124. })();
  3125. }
  3126. return this;
  3127. };
  3128. /**
  3129. * Remove an event listener from this component's element
  3130. * ```js
  3131. * myComponent.off('eventType', myFunc);
  3132. * ```
  3133. * If myFunc is excluded, ALL listeners for the event type will be removed.
  3134. * If eventType is excluded, ALL listeners will be removed from the component.
  3135. * Alternatively you can use `off` to remove listeners that were added to other
  3136. * elements or components using `myComponent.on(otherComponent...`.
  3137. * In this case both the event type and listener function are REQUIRED.
  3138. * ```js
  3139. * myComponent.off(otherElement, 'eventType', myFunc);
  3140. * myComponent.off(otherComponent, 'eventType', myFunc);
  3141. * ```
  3142. *
  3143. * @param {String=|Component} first The event type or other component
  3144. * @param {Function=|String} second The listener function or event type
  3145. * @param {Function=} third The listener for other component
  3146. * @return {Component}
  3147. * @method off
  3148. */
  3149. Component.prototype.off = function off(first, second, third) {
  3150. if (!first || typeof first === 'string' || Array.isArray(first)) {
  3151. Events.off(this.el_, first, second);
  3152. } else {
  3153. var target = first;
  3154. var type = second;
  3155. // Ensure there's at least a guid, even if the function hasn't been used
  3156. var fn = Fn.bind(this, third);
  3157. // Remove the dispose listener on this component,
  3158. // which was given the same guid as the event listener
  3159. this.off('dispose', fn);
  3160. if (first.nodeName) {
  3161. // Remove the listener
  3162. Events.off(target, type, fn);
  3163. // Remove the listener for cleaning the dispose listener
  3164. Events.off(target, 'dispose', fn);
  3165. } else {
  3166. target.off(type, fn);
  3167. target.off('dispose', fn);
  3168. }
  3169. }
  3170. return this;
  3171. };
  3172. /**
  3173. * Add an event listener to be triggered only once and then removed
  3174. * ```js
  3175. * myComponent.one('eventName', myFunc);
  3176. * ```
  3177. * Alternatively you can add a listener to another element or component
  3178. * that will be triggered only once.
  3179. * ```js
  3180. * myComponent.one(otherElement, 'eventName', myFunc);
  3181. * myComponent.one(otherComponent, 'eventName', myFunc);
  3182. * ```
  3183. *
  3184. * @param {String|Component} first The event type or other component
  3185. * @param {Function|String} second The listener function or event type
  3186. * @param {Function=} third The listener function for other component
  3187. * @return {Component}
  3188. * @method one
  3189. */
  3190. Component.prototype.one = function one(first, second, third) {
  3191. var _this3 = this,
  3192. _arguments = arguments;
  3193. if (typeof first === 'string' || Array.isArray(first)) {
  3194. Events.one(this.el_, first, Fn.bind(this, second));
  3195. } else {
  3196. (function () {
  3197. var target = first;
  3198. var type = second;
  3199. var fn = Fn.bind(_this3, third);
  3200. var newFunc = function newFunc() {
  3201. _this3.off(target, type, newFunc);
  3202. fn.apply(null, _arguments);
  3203. };
  3204. // Keep the same function ID so we can remove it later
  3205. newFunc.guid = fn.guid;
  3206. _this3.on(target, type, newFunc);
  3207. })();
  3208. }
  3209. return this;
  3210. };
  3211. /**
  3212. * Trigger an event on an element
  3213. * ```js
  3214. * myComponent.trigger('eventName');
  3215. * myComponent.trigger({'type':'eventName'});
  3216. * myComponent.trigger('eventName', {data: 'some data'});
  3217. * myComponent.trigger({'type':'eventName'}, {data: 'some data'});
  3218. * ```
  3219. *
  3220. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  3221. * @param {Object} [hash] data hash to pass along with the event
  3222. * @return {Component} self
  3223. * @method trigger
  3224. */
  3225. Component.prototype.trigger = function trigger(event, hash) {
  3226. Events.trigger(this.el_, event, hash);
  3227. return this;
  3228. };
  3229. /**
  3230. * Bind a listener to the component's ready state.
  3231. * Different from event listeners in that if the ready event has already happened
  3232. * it will trigger the function immediately.
  3233. *
  3234. * @param {Function} fn Ready listener
  3235. * @param {Boolean} sync Exec the listener synchronously if component is ready
  3236. * @return {Component}
  3237. * @method ready
  3238. */
  3239. Component.prototype.ready = function ready(fn) {
  3240. var sync = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
  3241. if (fn) {
  3242. if (this.isReady_) {
  3243. if (sync) {
  3244. fn.call(this);
  3245. } else {
  3246. // Call the function asynchronously by default for consistency
  3247. this.setTimeout(fn, 1);
  3248. }
  3249. } else {
  3250. this.readyQueue_ = this.readyQueue_ || [];
  3251. this.readyQueue_.push(fn);
  3252. }
  3253. }
  3254. return this;
  3255. };
  3256. /**
  3257. * Trigger the ready listeners
  3258. *
  3259. * @return {Component}
  3260. * @method triggerReady
  3261. */
  3262. Component.prototype.triggerReady = function triggerReady() {
  3263. this.isReady_ = true;
  3264. // Ensure ready is triggerd asynchronously
  3265. this.setTimeout(function () {
  3266. var readyQueue = this.readyQueue_;
  3267. // Reset Ready Queue
  3268. this.readyQueue_ = [];
  3269. if (readyQueue && readyQueue.length > 0) {
  3270. readyQueue.forEach(function (fn) {
  3271. fn.call(this);
  3272. }, this);
  3273. }
  3274. // Allow for using event listeners also
  3275. this.trigger('ready');
  3276. }, 1);
  3277. };
  3278. /**
  3279. * Finds a single DOM element matching `selector` within the component's
  3280. * `contentEl` or another custom context.
  3281. *
  3282. * @method $
  3283. * @param {String} selector
  3284. * A valid CSS selector, which will be passed to `querySelector`.
  3285. *
  3286. * @param {Element|String} [context=document]
  3287. * A DOM element within which to query. Can also be a selector
  3288. * string in which case the first matching element will be used
  3289. * as context. If missing (or no element matches selector), falls
  3290. * back to `document`.
  3291. *
  3292. * @return {Element|null}
  3293. */
  3294. Component.prototype.$ = function $(selector, context) {
  3295. return Dom.$(selector, context || this.contentEl());
  3296. };
  3297. /**
  3298. * Finds a all DOM elements matching `selector` within the component's
  3299. * `contentEl` or another custom context.
  3300. *
  3301. * @method $$
  3302. * @param {String} selector
  3303. * A valid CSS selector, which will be passed to `querySelectorAll`.
  3304. *
  3305. * @param {Element|String} [context=document]
  3306. * A DOM element within which to query. Can also be a selector
  3307. * string in which case the first matching element will be used
  3308. * as context. If missing (or no element matches selector), falls
  3309. * back to `document`.
  3310. *
  3311. * @return {NodeList}
  3312. */
  3313. Component.prototype.$$ = function $$(selector, context) {
  3314. return Dom.$$(selector, context || this.contentEl());
  3315. };
  3316. /**
  3317. * Check if a component's element has a CSS class name
  3318. *
  3319. * @param {String} classToCheck Classname to check
  3320. * @return {Component}
  3321. * @method hasClass
  3322. */
  3323. Component.prototype.hasClass = function hasClass(classToCheck) {
  3324. return Dom.hasElClass(this.el_, classToCheck);
  3325. };
  3326. /**
  3327. * Add a CSS class name to the component's element
  3328. *
  3329. * @param {String} classToAdd Classname to add
  3330. * @return {Component}
  3331. * @method addClass
  3332. */
  3333. Component.prototype.addClass = function addClass(classToAdd) {
  3334. Dom.addElClass(this.el_, classToAdd);
  3335. return this;
  3336. };
  3337. /**
  3338. * Remove a CSS class name from the component's element
  3339. *
  3340. * @param {String} classToRemove Classname to remove
  3341. * @return {Component}
  3342. * @method removeClass
  3343. */
  3344. Component.prototype.removeClass = function removeClass(classToRemove) {
  3345. Dom.removeElClass(this.el_, classToRemove);
  3346. return this;
  3347. };
  3348. /**
  3349. * Add or remove a CSS class name from the component's element
  3350. *
  3351. * @param {String} classToToggle
  3352. * @param {Boolean|Function} [predicate]
  3353. * Can be a function that returns a Boolean. If `true`, the class
  3354. * will be added; if `false`, the class will be removed. If not
  3355. * given, the class will be added if not present and vice versa.
  3356. *
  3357. * @return {Component}
  3358. * @method toggleClass
  3359. */
  3360. Component.prototype.toggleClass = function toggleClass(classToToggle, predicate) {
  3361. Dom.toggleElClass(this.el_, classToToggle, predicate);
  3362. return this;
  3363. };
  3364. /**
  3365. * Show the component element if hidden
  3366. *
  3367. * @return {Component}
  3368. * @method show
  3369. */
  3370. Component.prototype.show = function show() {
  3371. this.removeClass('vjs-hidden');
  3372. return this;
  3373. };
  3374. /**
  3375. * Hide the component element if currently showing
  3376. *
  3377. * @return {Component}
  3378. * @method hide
  3379. */
  3380. Component.prototype.hide = function hide() {
  3381. this.addClass('vjs-hidden');
  3382. return this;
  3383. };
  3384. /**
  3385. * Lock an item in its visible state
  3386. * To be used with fadeIn/fadeOut.
  3387. *
  3388. * @return {Component}
  3389. * @private
  3390. * @method lockShowing
  3391. */
  3392. Component.prototype.lockShowing = function lockShowing() {
  3393. this.addClass('vjs-lock-showing');
  3394. return this;
  3395. };
  3396. /**
  3397. * Unlock an item to be hidden
  3398. * To be used with fadeIn/fadeOut.
  3399. *
  3400. * @return {Component}
  3401. * @private
  3402. * @method unlockShowing
  3403. */
  3404. Component.prototype.unlockShowing = function unlockShowing() {
  3405. this.removeClass('vjs-lock-showing');
  3406. return this;
  3407. };
  3408. /**
  3409. * Set or get the width of the component (CSS values)
  3410. * Setting the video tag dimension values only works with values in pixels.
  3411. * Percent values will not work.
  3412. * Some percents can be used, but width()/height() will return the number + %,
  3413. * not the actual computed width/height.
  3414. *
  3415. * @param {Number|String=} num Optional width number
  3416. * @param {Boolean} skipListeners Skip the 'resize' event trigger
  3417. * @return {Component} This component, when setting the width
  3418. * @return {Number|String} The width, when getting
  3419. * @method width
  3420. */
  3421. Component.prototype.width = function width(num, skipListeners) {
  3422. return this.dimension('width', num, skipListeners);
  3423. };
  3424. /**
  3425. * Get or set the height of the component (CSS values)
  3426. * Setting the video tag dimension values only works with values in pixels.
  3427. * Percent values will not work.
  3428. * Some percents can be used, but width()/height() will return the number + %,
  3429. * not the actual computed width/height.
  3430. *
  3431. * @param {Number|String=} num New component height
  3432. * @param {Boolean=} skipListeners Skip the resize event trigger
  3433. * @return {Component} This component, when setting the height
  3434. * @return {Number|String} The height, when getting
  3435. * @method height
  3436. */
  3437. Component.prototype.height = function height(num, skipListeners) {
  3438. return this.dimension('height', num, skipListeners);
  3439. };
  3440. /**
  3441. * Set both width and height at the same time
  3442. *
  3443. * @param {Number|String} width Width of player
  3444. * @param {Number|String} height Height of player
  3445. * @return {Component} The component
  3446. * @method dimensions
  3447. */
  3448. Component.prototype.dimensions = function dimensions(width, height) {
  3449. // Skip resize listeners on width for optimization
  3450. return this.width(width, true).height(height);
  3451. };
  3452. /**
  3453. * Get or set width or height
  3454. * This is the shared code for the width() and height() methods.
  3455. * All for an integer, integer + 'px' or integer + '%';
  3456. * Known issue: Hidden elements officially have a width of 0. We're defaulting
  3457. * to the style.width value and falling back to computedStyle which has the
  3458. * hidden element issue. Info, but probably not an efficient fix:
  3459. * http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/
  3460. *
  3461. * @param {String} widthOrHeight 'width' or 'height'
  3462. * @param {Number|String=} num New dimension
  3463. * @param {Boolean=} skipListeners Skip resize event trigger
  3464. * @return {Component} The component if a dimension was set
  3465. * @return {Number|String} The dimension if nothing was set
  3466. * @private
  3467. * @method dimension
  3468. */
  3469. Component.prototype.dimension = function dimension(widthOrHeight, num, skipListeners) {
  3470. if (num !== undefined) {
  3471. // Set to zero if null or literally NaN (NaN !== NaN)
  3472. if (num === null || num !== num) {
  3473. num = 0;
  3474. }
  3475. // Check if using css width/height (% or px) and adjust
  3476. if (('' + num).indexOf('%') !== -1 || ('' + num).indexOf('px') !== -1) {
  3477. this.el_.style[widthOrHeight] = num;
  3478. } else if (num === 'auto') {
  3479. this.el_.style[widthOrHeight] = '';
  3480. } else {
  3481. this.el_.style[widthOrHeight] = num + 'px';
  3482. }
  3483. // skipListeners allows us to avoid triggering the resize event when setting both width and height
  3484. if (!skipListeners) {
  3485. this.trigger('resize');
  3486. }
  3487. // Return component
  3488. return this;
  3489. }
  3490. // Not setting a value, so getting it
  3491. // Make sure element exists
  3492. if (!this.el_) {
  3493. return 0;
  3494. }
  3495. // Get dimension value from style
  3496. var val = this.el_.style[widthOrHeight];
  3497. var pxIndex = val.indexOf('px');
  3498. if (pxIndex !== -1) {
  3499. // Return the pixel value with no 'px'
  3500. return parseInt(val.slice(0, pxIndex), 10);
  3501. }
  3502. // No px so using % or no style was set, so falling back to offsetWidth/height
  3503. // If component has display:none, offset will return 0
  3504. // TODO: handle display:none and no dimension style using px
  3505. return parseInt(this.el_['offset' + _utilsToTitleCaseJs2['default'](widthOrHeight)], 10);
  3506. };
  3507. /**
  3508. * Emit 'tap' events when touch events are supported
  3509. * This is used to support toggling the controls through a tap on the video.
  3510. * We're requiring them to be enabled because otherwise every component would
  3511. * have this extra overhead unnecessarily, on mobile devices where extra
  3512. * overhead is especially bad.
  3513. *
  3514. * @private
  3515. * @method emitTapEvents
  3516. */
  3517. Component.prototype.emitTapEvents = function emitTapEvents() {
  3518. // Track the start time so we can determine how long the touch lasted
  3519. var touchStart = 0;
  3520. var firstTouch = null;
  3521. // Maximum movement allowed during a touch event to still be considered a tap
  3522. // Other popular libs use anywhere from 2 (hammer.js) to 15, so 10 seems like a nice, round number.
  3523. var tapMovementThreshold = 10;
  3524. // The maximum length a touch can be while still being considered a tap
  3525. var touchTimeThreshold = 200;
  3526. var couldBeTap = undefined;
  3527. this.on('touchstart', function (event) {
  3528. // If more than one finger, don't consider treating this as a click
  3529. if (event.touches.length === 1) {
  3530. // Copy the touches object to prevent modifying the original
  3531. firstTouch = _objectAssign2['default']({}, event.touches[0]);
  3532. // Record start time so we can detect a tap vs. "touch and hold"
  3533. touchStart = new Date().getTime();
  3534. // Reset couldBeTap tracking
  3535. couldBeTap = true;
  3536. }
  3537. });
  3538. this.on('touchmove', function (event) {
  3539. // If more than one finger, don't consider treating this as a click
  3540. if (event.touches.length > 1) {
  3541. couldBeTap = false;
  3542. } else if (firstTouch) {
  3543. // Some devices will throw touchmoves for all but the slightest of taps.
  3544. // So, if we moved only a small distance, this could still be a tap
  3545. var xdiff = event.touches[0].pageX - firstTouch.pageX;
  3546. var ydiff = event.touches[0].pageY - firstTouch.pageY;
  3547. var touchDistance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);
  3548. if (touchDistance > tapMovementThreshold) {
  3549. couldBeTap = false;
  3550. }
  3551. }
  3552. });
  3553. var noTap = function noTap() {
  3554. couldBeTap = false;
  3555. };
  3556. // TODO: Listen to the original target. http://youtu.be/DujfpXOKUp8?t=13m8s
  3557. this.on('touchleave', noTap);
  3558. this.on('touchcancel', noTap);
  3559. // When the touch ends, measure how long it took and trigger the appropriate
  3560. // event
  3561. this.on('touchend', function (event) {
  3562. firstTouch = null;
  3563. // Proceed only if the touchmove/leave/cancel event didn't happen
  3564. if (couldBeTap === true) {
  3565. // Measure how long the touch lasted
  3566. var touchTime = new Date().getTime() - touchStart;
  3567. // Make sure the touch was less than the threshold to be considered a tap
  3568. if (touchTime < touchTimeThreshold) {
  3569. // Don't let browser turn this into a click
  3570. event.preventDefault();
  3571. this.trigger('tap');
  3572. // It may be good to copy the touchend event object and change the
  3573. // type to tap, if the other event properties aren't exact after
  3574. // Events.fixEvent runs (e.g. event.target)
  3575. }
  3576. }
  3577. });
  3578. };
  3579. /**
  3580. * Report user touch activity when touch events occur
  3581. * User activity is used to determine when controls should show/hide. It's
  3582. * relatively simple when it comes to mouse events, because any mouse event
  3583. * should show the controls. So we capture mouse events that bubble up to the
  3584. * player and report activity when that happens.
  3585. * With touch events it isn't as easy. We can't rely on touch events at the
  3586. * player level, because a tap (touchstart + touchend) on the video itself on
  3587. * mobile devices is meant to turn controls off (and on). User activity is
  3588. * checked asynchronously, so what could happen is a tap event on the video
  3589. * turns the controls off, then the touchend event bubbles up to the player,
  3590. * which if it reported user activity, would turn the controls right back on.
  3591. * (We also don't want to completely block touch events from bubbling up)
  3592. * Also a touchmove, touch+hold, and anything other than a tap is not supposed
  3593. * to turn the controls back on on a mobile device.
  3594. * Here we're setting the default component behavior to report user activity
  3595. * whenever touch events happen, and this can be turned off by components that
  3596. * want touch events to act differently.
  3597. *
  3598. * @method enableTouchActivity
  3599. */
  3600. Component.prototype.enableTouchActivity = function enableTouchActivity() {
  3601. // Don't continue if the root player doesn't support reporting user activity
  3602. if (!this.player() || !this.player().reportUserActivity) {
  3603. return;
  3604. }
  3605. // listener for reporting that the user is active
  3606. var report = Fn.bind(this.player(), this.player().reportUserActivity);
  3607. var touchHolding = undefined;
  3608. this.on('touchstart', function () {
  3609. report();
  3610. // For as long as the they are touching the device or have their mouse down,
  3611. // we consider them active even if they're not moving their finger or mouse.
  3612. // So we want to continue to update that they are active
  3613. this.clearInterval(touchHolding);
  3614. // report at the same interval as activityCheck
  3615. touchHolding = this.setInterval(report, 250);
  3616. });
  3617. var touchEnd = function touchEnd(event) {
  3618. report();
  3619. // stop the interval that maintains activity if the touch is holding
  3620. this.clearInterval(touchHolding);
  3621. };
  3622. this.on('touchmove', report);
  3623. this.on('touchend', touchEnd);
  3624. this.on('touchcancel', touchEnd);
  3625. };
  3626. /**
  3627. * Creates timeout and sets up disposal automatically.
  3628. *
  3629. * @param {Function} fn The function to run after the timeout.
  3630. * @param {Number} timeout Number of ms to delay before executing specified function.
  3631. * @return {Number} Returns the timeout ID
  3632. * @method setTimeout
  3633. */
  3634. Component.prototype.setTimeout = function setTimeout(fn, timeout) {
  3635. fn = Fn.bind(this, fn);
  3636. // window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't.
  3637. var timeoutId = _globalWindow2['default'].setTimeout(fn, timeout);
  3638. var disposeFn = function disposeFn() {
  3639. this.clearTimeout(timeoutId);
  3640. };
  3641. disposeFn.guid = 'vjs-timeout-' + timeoutId;
  3642. this.on('dispose', disposeFn);
  3643. return timeoutId;
  3644. };
  3645. /**
  3646. * Clears a timeout and removes the associated dispose listener
  3647. *
  3648. * @param {Number} timeoutId The id of the timeout to clear
  3649. * @return {Number} Returns the timeout ID
  3650. * @method clearTimeout
  3651. */
  3652. Component.prototype.clearTimeout = function clearTimeout(timeoutId) {
  3653. _globalWindow2['default'].clearTimeout(timeoutId);
  3654. var disposeFn = function disposeFn() {};
  3655. disposeFn.guid = 'vjs-timeout-' + timeoutId;
  3656. this.off('dispose', disposeFn);
  3657. return timeoutId;
  3658. };
  3659. /**
  3660. * Creates an interval and sets up disposal automatically.
  3661. *
  3662. * @param {Function} fn The function to run every N seconds.
  3663. * @param {Number} interval Number of ms to delay before executing specified function.
  3664. * @return {Number} Returns the interval ID
  3665. * @method setInterval
  3666. */
  3667. Component.prototype.setInterval = function setInterval(fn, interval) {
  3668. fn = Fn.bind(this, fn);
  3669. var intervalId = _globalWindow2['default'].setInterval(fn, interval);
  3670. var disposeFn = function disposeFn() {
  3671. this.clearInterval(intervalId);
  3672. };
  3673. disposeFn.guid = 'vjs-interval-' + intervalId;
  3674. this.on('dispose', disposeFn);
  3675. return intervalId;
  3676. };
  3677. /**
  3678. * Clears an interval and removes the associated dispose listener
  3679. *
  3680. * @param {Number} intervalId The id of the interval to clear
  3681. * @return {Number} Returns the interval ID
  3682. * @method clearInterval
  3683. */
  3684. Component.prototype.clearInterval = function clearInterval(intervalId) {
  3685. _globalWindow2['default'].clearInterval(intervalId);
  3686. var disposeFn = function disposeFn() {};
  3687. disposeFn.guid = 'vjs-interval-' + intervalId;
  3688. this.off('dispose', disposeFn);
  3689. return intervalId;
  3690. };
  3691. /**
  3692. * Registers a component
  3693. *
  3694. * @param {String} name Name of the component to register
  3695. * @param {Object} comp The component to register
  3696. * @static
  3697. * @method registerComponent
  3698. */
  3699. Component.registerComponent = function registerComponent(name, comp) {
  3700. if (!Component.components_) {
  3701. Component.components_ = {};
  3702. }
  3703. Component.components_[name] = comp;
  3704. return comp;
  3705. };
  3706. /**
  3707. * Gets a component by name
  3708. *
  3709. * @param {String} name Name of the component to get
  3710. * @return {Component}
  3711. * @static
  3712. * @method getComponent
  3713. */
  3714. Component.getComponent = function getComponent(name) {
  3715. if (Component.components_ && Component.components_[name]) {
  3716. return Component.components_[name];
  3717. }
  3718. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  3719. _utilsLogJs2['default'].warn('The ' + name + ' component was added to the videojs object when it should be registered using videojs.registerComponent(name, component)');
  3720. return _globalWindow2['default'].videojs[name];
  3721. }
  3722. };
  3723. /**
  3724. * Sets up the constructor using the supplied init method
  3725. * or uses the init of the parent object
  3726. *
  3727. * @param {Object} props An object of properties
  3728. * @static
  3729. * @deprecated
  3730. * @method extend
  3731. */
  3732. Component.extend = function extend(props) {
  3733. props = props || {};
  3734. _utilsLogJs2['default'].warn('Component.extend({}) has been deprecated, use videojs.extend(Component, {}) instead');
  3735. // Set up the constructor using the supplied init method
  3736. // or using the init of the parent object
  3737. // Make sure to check the unobfuscated version for external libs
  3738. var init = props.init || props.init || this.prototype.init || this.prototype.init || function () {};
  3739. // In Resig's simple class inheritance (previously used) the constructor
  3740. // is a function that calls `this.init.apply(arguments)`
  3741. // However that would prevent us from using `ParentObject.call(this);`
  3742. // in a Child constructor because the `this` in `this.init`
  3743. // would still refer to the Child and cause an infinite loop.
  3744. // We would instead have to do
  3745. // `ParentObject.prototype.init.apply(this, arguments);`
  3746. // Bleh. We're not creating a _super() function, so it's good to keep
  3747. // the parent constructor reference simple.
  3748. var subObj = function subObj() {
  3749. init.apply(this, arguments);
  3750. };
  3751. // Inherit from this object's prototype
  3752. subObj.prototype = Object.create(this.prototype);
  3753. // Reset the constructor property for subObj otherwise
  3754. // instances of subObj would have the constructor of the parent Object
  3755. subObj.prototype.constructor = subObj;
  3756. // Make the class extendable
  3757. subObj.extend = Component.extend;
  3758. // Extend subObj's prototype with functions and other properties from props
  3759. for (var _name in props) {
  3760. if (props.hasOwnProperty(_name)) {
  3761. subObj.prototype[_name] = props[_name];
  3762. }
  3763. }
  3764. return subObj;
  3765. };
  3766. return Component;
  3767. })();
  3768. Component.registerComponent('Component', Component);
  3769. exports['default'] = Component;
  3770. module.exports = exports['default'];
  3771. },{"./utils/dom.js":128,"./utils/events.js":129,"./utils/fn.js":130,"./utils/guid.js":132,"./utils/log.js":133,"./utils/merge-options.js":134,"./utils/to-title-case.js":137,"global/window":2,"object.assign":45}],66:[function(_dereq_,module,exports){
  3772. /**
  3773. * @file control-bar.js
  3774. */
  3775. 'use strict';
  3776. exports.__esModule = true;
  3777. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  3778. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  3779. 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; }
  3780. var _componentJs = _dereq_('../component.js');
  3781. var _componentJs2 = _interopRequireDefault(_componentJs);
  3782. // Required children
  3783. var _playToggleJs = _dereq_('./play-toggle.js');
  3784. var _playToggleJs2 = _interopRequireDefault(_playToggleJs);
  3785. var _timeControlsCurrentTimeDisplayJs = _dereq_('./time-controls/current-time-display.js');
  3786. var _timeControlsCurrentTimeDisplayJs2 = _interopRequireDefault(_timeControlsCurrentTimeDisplayJs);
  3787. var _timeControlsDurationDisplayJs = _dereq_('./time-controls/duration-display.js');
  3788. var _timeControlsDurationDisplayJs2 = _interopRequireDefault(_timeControlsDurationDisplayJs);
  3789. var _timeControlsTimeDividerJs = _dereq_('./time-controls/time-divider.js');
  3790. var _timeControlsTimeDividerJs2 = _interopRequireDefault(_timeControlsTimeDividerJs);
  3791. var _timeControlsRemainingTimeDisplayJs = _dereq_('./time-controls/remaining-time-display.js');
  3792. var _timeControlsRemainingTimeDisplayJs2 = _interopRequireDefault(_timeControlsRemainingTimeDisplayJs);
  3793. var _liveDisplayJs = _dereq_('./live-display.js');
  3794. var _liveDisplayJs2 = _interopRequireDefault(_liveDisplayJs);
  3795. var _progressControlProgressControlJs = _dereq_('./progress-control/progress-control.js');
  3796. var _progressControlProgressControlJs2 = _interopRequireDefault(_progressControlProgressControlJs);
  3797. var _fullscreenToggleJs = _dereq_('./fullscreen-toggle.js');
  3798. var _fullscreenToggleJs2 = _interopRequireDefault(_fullscreenToggleJs);
  3799. var _volumeControlVolumeControlJs = _dereq_('./volume-control/volume-control.js');
  3800. var _volumeControlVolumeControlJs2 = _interopRequireDefault(_volumeControlVolumeControlJs);
  3801. var _volumeMenuButtonJs = _dereq_('./volume-menu-button.js');
  3802. var _volumeMenuButtonJs2 = _interopRequireDefault(_volumeMenuButtonJs);
  3803. var _muteToggleJs = _dereq_('./mute-toggle.js');
  3804. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs);
  3805. var _textTrackControlsChaptersButtonJs = _dereq_('./text-track-controls/chapters-button.js');
  3806. var _textTrackControlsChaptersButtonJs2 = _interopRequireDefault(_textTrackControlsChaptersButtonJs);
  3807. var _textTrackControlsSubtitlesButtonJs = _dereq_('./text-track-controls/subtitles-button.js');
  3808. var _textTrackControlsSubtitlesButtonJs2 = _interopRequireDefault(_textTrackControlsSubtitlesButtonJs);
  3809. var _textTrackControlsCaptionsButtonJs = _dereq_('./text-track-controls/captions-button.js');
  3810. var _textTrackControlsCaptionsButtonJs2 = _interopRequireDefault(_textTrackControlsCaptionsButtonJs);
  3811. var _playbackRateMenuPlaybackRateMenuButtonJs = _dereq_('./playback-rate-menu/playback-rate-menu-button.js');
  3812. var _playbackRateMenuPlaybackRateMenuButtonJs2 = _interopRequireDefault(_playbackRateMenuPlaybackRateMenuButtonJs);
  3813. var _spacerControlsCustomControlSpacerJs = _dereq_('./spacer-controls/custom-control-spacer.js');
  3814. var _spacerControlsCustomControlSpacerJs2 = _interopRequireDefault(_spacerControlsCustomControlSpacerJs);
  3815. /**
  3816. * Container of main controls
  3817. *
  3818. * @extends Component
  3819. * @class ControlBar
  3820. */
  3821. var ControlBar = (function (_Component) {
  3822. _inherits(ControlBar, _Component);
  3823. function ControlBar() {
  3824. _classCallCheck(this, ControlBar);
  3825. _Component.apply(this, arguments);
  3826. }
  3827. /**
  3828. * Create the component's DOM element
  3829. *
  3830. * @return {Element}
  3831. * @method createEl
  3832. */
  3833. ControlBar.prototype.createEl = function createEl() {
  3834. return _Component.prototype.createEl.call(this, 'div', {
  3835. className: 'vjs-control-bar'
  3836. });
  3837. };
  3838. return ControlBar;
  3839. })(_componentJs2['default']);
  3840. ControlBar.prototype.options_ = {
  3841. loadEvent: 'play',
  3842. children: ['playToggle', 'volumeMenuButton', 'currentTimeDisplay', 'timeDivider', 'durationDisplay', 'progressControl', 'liveDisplay', 'remainingTimeDisplay', 'customControlSpacer', 'playbackRateMenuButton', 'chaptersButton', 'subtitlesButton', 'captionsButton', 'fullscreenToggle']
  3843. };
  3844. _componentJs2['default'].registerComponent('ControlBar', ControlBar);
  3845. exports['default'] = ControlBar;
  3846. module.exports = exports['default'];
  3847. },{"../component.js":65,"./fullscreen-toggle.js":67,"./live-display.js":68,"./mute-toggle.js":69,"./play-toggle.js":70,"./playback-rate-menu/playback-rate-menu-button.js":71,"./progress-control/progress-control.js":76,"./spacer-controls/custom-control-spacer.js":78,"./text-track-controls/captions-button.js":81,"./text-track-controls/chapters-button.js":82,"./text-track-controls/subtitles-button.js":85,"./time-controls/current-time-display.js":88,"./time-controls/duration-display.js":89,"./time-controls/remaining-time-display.js":90,"./time-controls/time-divider.js":91,"./volume-control/volume-control.js":93,"./volume-menu-button.js":95}],67:[function(_dereq_,module,exports){
  3848. /**
  3849. * @file fullscreen-toggle.js
  3850. */
  3851. 'use strict';
  3852. exports.__esModule = true;
  3853. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  3854. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  3855. 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; }
  3856. var _buttonJs = _dereq_('../button.js');
  3857. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  3858. var _componentJs = _dereq_('../component.js');
  3859. var _componentJs2 = _interopRequireDefault(_componentJs);
  3860. /**
  3861. * Toggle fullscreen video
  3862. *
  3863. * @extends Button
  3864. * @class FullscreenToggle
  3865. */
  3866. var FullscreenToggle = (function (_Button) {
  3867. _inherits(FullscreenToggle, _Button);
  3868. function FullscreenToggle() {
  3869. _classCallCheck(this, FullscreenToggle);
  3870. _Button.apply(this, arguments);
  3871. }
  3872. /**
  3873. * Allow sub components to stack CSS class names
  3874. *
  3875. * @return {String} The constructed class name
  3876. * @method buildCSSClass
  3877. */
  3878. FullscreenToggle.prototype.buildCSSClass = function buildCSSClass() {
  3879. return 'vjs-fullscreen-control ' + _Button.prototype.buildCSSClass.call(this);
  3880. };
  3881. /**
  3882. * Handles click for full screen
  3883. *
  3884. * @method handleClick
  3885. */
  3886. FullscreenToggle.prototype.handleClick = function handleClick() {
  3887. if (!this.player_.isFullscreen()) {
  3888. this.player_.requestFullscreen();
  3889. this.controlText('Non-Fullscreen');
  3890. } else {
  3891. this.player_.exitFullscreen();
  3892. this.controlText('Fullscreen');
  3893. }
  3894. };
  3895. return FullscreenToggle;
  3896. })(_buttonJs2['default']);
  3897. FullscreenToggle.prototype.controlText_ = 'Fullscreen';
  3898. _componentJs2['default'].registerComponent('FullscreenToggle', FullscreenToggle);
  3899. exports['default'] = FullscreenToggle;
  3900. module.exports = exports['default'];
  3901. },{"../button.js":63,"../component.js":65}],68:[function(_dereq_,module,exports){
  3902. /**
  3903. * @file live-display.js
  3904. */
  3905. 'use strict';
  3906. exports.__esModule = true;
  3907. 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; } }
  3908. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  3909. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  3910. 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; }
  3911. var _component = _dereq_('../component');
  3912. var _component2 = _interopRequireDefault(_component);
  3913. var _utilsDomJs = _dereq_('../utils/dom.js');
  3914. var Dom = _interopRequireWildcard(_utilsDomJs);
  3915. /**
  3916. * Displays the live indicator
  3917. * TODO - Future make it click to snap to live
  3918. *
  3919. * @extends Component
  3920. * @class LiveDisplay
  3921. */
  3922. var LiveDisplay = (function (_Component) {
  3923. _inherits(LiveDisplay, _Component);
  3924. function LiveDisplay(player, options) {
  3925. _classCallCheck(this, LiveDisplay);
  3926. _Component.call(this, player, options);
  3927. this.updateShowing();
  3928. this.on(this.player(), 'durationchange', this.updateShowing);
  3929. }
  3930. /**
  3931. * Create the component's DOM element
  3932. *
  3933. * @return {Element}
  3934. * @method createEl
  3935. */
  3936. LiveDisplay.prototype.createEl = function createEl() {
  3937. var el = _Component.prototype.createEl.call(this, 'div', {
  3938. className: 'vjs-live-control vjs-control'
  3939. });
  3940. this.contentEl_ = Dom.createEl('div', {
  3941. className: 'vjs-live-display',
  3942. innerHTML: '<span class="vjs-control-text">' + this.localize('Stream Type') + '</span>' + this.localize('LIVE')
  3943. }, {
  3944. 'aria-live': 'off'
  3945. });
  3946. el.appendChild(this.contentEl_);
  3947. return el;
  3948. };
  3949. LiveDisplay.prototype.updateShowing = function updateShowing() {
  3950. if (this.player().duration() === Infinity) {
  3951. this.show();
  3952. } else {
  3953. this.hide();
  3954. }
  3955. };
  3956. return LiveDisplay;
  3957. })(_component2['default']);
  3958. _component2['default'].registerComponent('LiveDisplay', LiveDisplay);
  3959. exports['default'] = LiveDisplay;
  3960. module.exports = exports['default'];
  3961. },{"../component":65,"../utils/dom.js":128}],69:[function(_dereq_,module,exports){
  3962. /**
  3963. * @file mute-toggle.js
  3964. */
  3965. 'use strict';
  3966. exports.__esModule = true;
  3967. 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; } }
  3968. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  3969. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  3970. 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; }
  3971. var _button = _dereq_('../button');
  3972. var _button2 = _interopRequireDefault(_button);
  3973. var _component = _dereq_('../component');
  3974. var _component2 = _interopRequireDefault(_component);
  3975. var _utilsDomJs = _dereq_('../utils/dom.js');
  3976. var Dom = _interopRequireWildcard(_utilsDomJs);
  3977. /**
  3978. * A button component for muting the audio
  3979. *
  3980. * @param {Player|Object} player
  3981. * @param {Object=} options
  3982. * @extends Button
  3983. * @class MuteToggle
  3984. */
  3985. var MuteToggle = (function (_Button) {
  3986. _inherits(MuteToggle, _Button);
  3987. function MuteToggle(player, options) {
  3988. _classCallCheck(this, MuteToggle);
  3989. _Button.call(this, player, options);
  3990. this.on(player, 'volumechange', this.update);
  3991. // hide mute toggle if the current tech doesn't support volume control
  3992. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  3993. this.addClass('vjs-hidden');
  3994. }
  3995. this.on(player, 'loadstart', function () {
  3996. this.update(); // We need to update the button to account for a default muted state.
  3997. if (player.tech_['featuresVolumeControl'] === false) {
  3998. this.addClass('vjs-hidden');
  3999. } else {
  4000. this.removeClass('vjs-hidden');
  4001. }
  4002. });
  4003. }
  4004. /**
  4005. * Allow sub components to stack CSS class names
  4006. *
  4007. * @return {String} The constructed class name
  4008. * @method buildCSSClass
  4009. */
  4010. MuteToggle.prototype.buildCSSClass = function buildCSSClass() {
  4011. return 'vjs-mute-control ' + _Button.prototype.buildCSSClass.call(this);
  4012. };
  4013. /**
  4014. * Handle click on mute
  4015. *
  4016. * @method handleClick
  4017. */
  4018. MuteToggle.prototype.handleClick = function handleClick() {
  4019. this.player_.muted(this.player_.muted() ? false : true);
  4020. };
  4021. /**
  4022. * Update volume
  4023. *
  4024. * @method update
  4025. */
  4026. MuteToggle.prototype.update = function update() {
  4027. var vol = this.player_.volume(),
  4028. level = 3;
  4029. if (vol === 0 || this.player_.muted()) {
  4030. level = 0;
  4031. } else if (vol < 0.33) {
  4032. level = 1;
  4033. } else if (vol < 0.67) {
  4034. level = 2;
  4035. }
  4036. // Don't rewrite the button text if the actual text doesn't change.
  4037. // This causes unnecessary and confusing information for screen reader users.
  4038. // This check is needed because this function gets called every time the volume level is changed.
  4039. var toMute = this.player_.muted() ? 'Unmute' : 'Mute';
  4040. var localizedMute = this.localize(toMute);
  4041. if (this.controlText() !== localizedMute) {
  4042. this.controlText(localizedMute);
  4043. }
  4044. /* TODO improve muted icon classes */
  4045. for (var i = 0; i < 4; i++) {
  4046. Dom.removeElClass(this.el_, 'vjs-vol-' + i);
  4047. }
  4048. Dom.addElClass(this.el_, 'vjs-vol-' + level);
  4049. };
  4050. return MuteToggle;
  4051. })(_button2['default']);
  4052. MuteToggle.prototype.controlText_ = 'Mute';
  4053. _component2['default'].registerComponent('MuteToggle', MuteToggle);
  4054. exports['default'] = MuteToggle;
  4055. module.exports = exports['default'];
  4056. },{"../button":63,"../component":65,"../utils/dom.js":128}],70:[function(_dereq_,module,exports){
  4057. /**
  4058. * @file play-toggle.js
  4059. */
  4060. 'use strict';
  4061. exports.__esModule = true;
  4062. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4063. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4064. 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; }
  4065. var _buttonJs = _dereq_('../button.js');
  4066. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  4067. var _componentJs = _dereq_('../component.js');
  4068. var _componentJs2 = _interopRequireDefault(_componentJs);
  4069. /**
  4070. * Button to toggle between play and pause
  4071. *
  4072. * @param {Player|Object} player
  4073. * @param {Object=} options
  4074. * @extends Button
  4075. * @class PlayToggle
  4076. */
  4077. var PlayToggle = (function (_Button) {
  4078. _inherits(PlayToggle, _Button);
  4079. function PlayToggle(player, options) {
  4080. _classCallCheck(this, PlayToggle);
  4081. _Button.call(this, player, options);
  4082. this.on(player, 'play', this.handlePlay);
  4083. this.on(player, 'pause', this.handlePause);
  4084. }
  4085. /**
  4086. * Allow sub components to stack CSS class names
  4087. *
  4088. * @return {String} The constructed class name
  4089. * @method buildCSSClass
  4090. */
  4091. PlayToggle.prototype.buildCSSClass = function buildCSSClass() {
  4092. return 'vjs-play-control ' + _Button.prototype.buildCSSClass.call(this);
  4093. };
  4094. /**
  4095. * Handle click to toggle between play and pause
  4096. *
  4097. * @method handleClick
  4098. */
  4099. PlayToggle.prototype.handleClick = function handleClick() {
  4100. if (this.player_.paused()) {
  4101. this.player_.play();
  4102. } else {
  4103. this.player_.pause();
  4104. }
  4105. };
  4106. /**
  4107. * Add the vjs-playing class to the element so it can change appearance
  4108. *
  4109. * @method handlePlay
  4110. */
  4111. PlayToggle.prototype.handlePlay = function handlePlay() {
  4112. this.removeClass('vjs-paused');
  4113. this.addClass('vjs-playing');
  4114. this.controlText('Pause'); // change the button text to "Pause"
  4115. };
  4116. /**
  4117. * Add the vjs-paused class to the element so it can change appearance
  4118. *
  4119. * @method handlePause
  4120. */
  4121. PlayToggle.prototype.handlePause = function handlePause() {
  4122. this.removeClass('vjs-playing');
  4123. this.addClass('vjs-paused');
  4124. this.controlText('Play'); // change the button text to "Play"
  4125. };
  4126. return PlayToggle;
  4127. })(_buttonJs2['default']);
  4128. PlayToggle.prototype.controlText_ = 'Play';
  4129. _componentJs2['default'].registerComponent('PlayToggle', PlayToggle);
  4130. exports['default'] = PlayToggle;
  4131. module.exports = exports['default'];
  4132. },{"../button.js":63,"../component.js":65}],71:[function(_dereq_,module,exports){
  4133. /**
  4134. * @file playback-rate-menu-button.js
  4135. */
  4136. 'use strict';
  4137. exports.__esModule = true;
  4138. 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; } }
  4139. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4140. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4141. 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; }
  4142. var _menuMenuButtonJs = _dereq_('../../menu/menu-button.js');
  4143. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  4144. var _menuMenuJs = _dereq_('../../menu/menu.js');
  4145. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  4146. var _playbackRateMenuItemJs = _dereq_('./playback-rate-menu-item.js');
  4147. var _playbackRateMenuItemJs2 = _interopRequireDefault(_playbackRateMenuItemJs);
  4148. var _componentJs = _dereq_('../../component.js');
  4149. var _componentJs2 = _interopRequireDefault(_componentJs);
  4150. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4151. var Dom = _interopRequireWildcard(_utilsDomJs);
  4152. /**
  4153. * The component for controlling the playback rate
  4154. *
  4155. * @param {Player|Object} player
  4156. * @param {Object=} options
  4157. * @extends MenuButton
  4158. * @class PlaybackRateMenuButton
  4159. */
  4160. var PlaybackRateMenuButton = (function (_MenuButton) {
  4161. _inherits(PlaybackRateMenuButton, _MenuButton);
  4162. function PlaybackRateMenuButton(player, options) {
  4163. _classCallCheck(this, PlaybackRateMenuButton);
  4164. _MenuButton.call(this, player, options);
  4165. this.updateVisibility();
  4166. this.updateLabel();
  4167. this.on(player, 'loadstart', this.updateVisibility);
  4168. this.on(player, 'ratechange', this.updateLabel);
  4169. }
  4170. /**
  4171. * Create the component's DOM element
  4172. *
  4173. * @return {Element}
  4174. * @method createEl
  4175. */
  4176. PlaybackRateMenuButton.prototype.createEl = function createEl() {
  4177. var el = _MenuButton.prototype.createEl.call(this);
  4178. this.labelEl_ = Dom.createEl('div', {
  4179. className: 'vjs-playback-rate-value',
  4180. innerHTML: 1.0
  4181. });
  4182. el.appendChild(this.labelEl_);
  4183. return el;
  4184. };
  4185. /**
  4186. * Allow sub components to stack CSS class names
  4187. *
  4188. * @return {String} The constructed class name
  4189. * @method buildCSSClass
  4190. */
  4191. PlaybackRateMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  4192. return 'vjs-playback-rate ' + _MenuButton.prototype.buildCSSClass.call(this);
  4193. };
  4194. /**
  4195. * Create the playback rate menu
  4196. *
  4197. * @return {Menu} Menu object populated with items
  4198. * @method createMenu
  4199. */
  4200. PlaybackRateMenuButton.prototype.createMenu = function createMenu() {
  4201. var menu = new _menuMenuJs2['default'](this.player());
  4202. var rates = this.playbackRates();
  4203. if (rates) {
  4204. for (var i = rates.length - 1; i >= 0; i--) {
  4205. menu.addChild(new _playbackRateMenuItemJs2['default'](this.player(), { 'rate': rates[i] + 'x' }));
  4206. }
  4207. }
  4208. return menu;
  4209. };
  4210. /**
  4211. * Updates ARIA accessibility attributes
  4212. *
  4213. * @method updateARIAAttributes
  4214. */
  4215. PlaybackRateMenuButton.prototype.updateARIAAttributes = function updateARIAAttributes() {
  4216. // Current playback rate
  4217. this.el().setAttribute('aria-valuenow', this.player().playbackRate());
  4218. };
  4219. /**
  4220. * Handle menu item click
  4221. *
  4222. * @method handleClick
  4223. */
  4224. PlaybackRateMenuButton.prototype.handleClick = function handleClick() {
  4225. // select next rate option
  4226. var currentRate = this.player().playbackRate();
  4227. var rates = this.playbackRates();
  4228. // this will select first one if the last one currently selected
  4229. var newRate = rates[0];
  4230. for (var i = 0; i < rates.length; i++) {
  4231. if (rates[i] > currentRate) {
  4232. newRate = rates[i];
  4233. break;
  4234. }
  4235. }
  4236. this.player().playbackRate(newRate);
  4237. };
  4238. /**
  4239. * Get possible playback rates
  4240. *
  4241. * @return {Array} Possible playback rates
  4242. * @method playbackRates
  4243. */
  4244. PlaybackRateMenuButton.prototype.playbackRates = function playbackRates() {
  4245. return this.options_['playbackRates'] || this.options_.playerOptions && this.options_.playerOptions['playbackRates'];
  4246. };
  4247. /**
  4248. * Get supported playback rates
  4249. *
  4250. * @return {Array} Supported playback rates
  4251. * @method playbackRateSupported
  4252. */
  4253. PlaybackRateMenuButton.prototype.playbackRateSupported = function playbackRateSupported() {
  4254. return this.player().tech_ && this.player().tech_['featuresPlaybackRate'] && this.playbackRates() && this.playbackRates().length > 0;
  4255. };
  4256. /**
  4257. * Hide playback rate controls when they're no playback rate options to select
  4258. *
  4259. * @method updateVisibility
  4260. */
  4261. PlaybackRateMenuButton.prototype.updateVisibility = function updateVisibility() {
  4262. if (this.playbackRateSupported()) {
  4263. this.removeClass('vjs-hidden');
  4264. } else {
  4265. this.addClass('vjs-hidden');
  4266. }
  4267. };
  4268. /**
  4269. * Update button label when rate changed
  4270. *
  4271. * @method updateLabel
  4272. */
  4273. PlaybackRateMenuButton.prototype.updateLabel = function updateLabel() {
  4274. if (this.playbackRateSupported()) {
  4275. this.labelEl_.innerHTML = this.player().playbackRate() + 'x';
  4276. }
  4277. };
  4278. return PlaybackRateMenuButton;
  4279. })(_menuMenuButtonJs2['default']);
  4280. PlaybackRateMenuButton.prototype.controlText_ = 'Playback Rate';
  4281. _componentJs2['default'].registerComponent('PlaybackRateMenuButton', PlaybackRateMenuButton);
  4282. exports['default'] = PlaybackRateMenuButton;
  4283. module.exports = exports['default'];
  4284. },{"../../component.js":65,"../../menu/menu-button.js":102,"../../menu/menu.js":104,"../../utils/dom.js":128,"./playback-rate-menu-item.js":72}],72:[function(_dereq_,module,exports){
  4285. /**
  4286. * @file playback-rate-menu-item.js
  4287. */
  4288. 'use strict';
  4289. exports.__esModule = true;
  4290. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4291. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4292. 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; }
  4293. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  4294. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  4295. var _componentJs = _dereq_('../../component.js');
  4296. var _componentJs2 = _interopRequireDefault(_componentJs);
  4297. /**
  4298. * The specific menu item type for selecting a playback rate
  4299. *
  4300. * @param {Player|Object} player
  4301. * @param {Object=} options
  4302. * @extends MenuItem
  4303. * @class PlaybackRateMenuItem
  4304. */
  4305. var PlaybackRateMenuItem = (function (_MenuItem) {
  4306. _inherits(PlaybackRateMenuItem, _MenuItem);
  4307. function PlaybackRateMenuItem(player, options) {
  4308. _classCallCheck(this, PlaybackRateMenuItem);
  4309. var label = options['rate'];
  4310. var rate = parseFloat(label, 10);
  4311. // Modify options for parent MenuItem class's init.
  4312. options['label'] = label;
  4313. options['selected'] = rate === 1;
  4314. _MenuItem.call(this, player, options);
  4315. this.label = label;
  4316. this.rate = rate;
  4317. this.on(player, 'ratechange', this.update);
  4318. }
  4319. /**
  4320. * Handle click on menu item
  4321. *
  4322. * @method handleClick
  4323. */
  4324. PlaybackRateMenuItem.prototype.handleClick = function handleClick() {
  4325. _MenuItem.prototype.handleClick.call(this);
  4326. this.player().playbackRate(this.rate);
  4327. };
  4328. /**
  4329. * Update playback rate with selected rate
  4330. *
  4331. * @method update
  4332. */
  4333. PlaybackRateMenuItem.prototype.update = function update() {
  4334. this.selected(this.player().playbackRate() === this.rate);
  4335. };
  4336. return PlaybackRateMenuItem;
  4337. })(_menuMenuItemJs2['default']);
  4338. PlaybackRateMenuItem.prototype.contentElType = 'button';
  4339. _componentJs2['default'].registerComponent('PlaybackRateMenuItem', PlaybackRateMenuItem);
  4340. exports['default'] = PlaybackRateMenuItem;
  4341. module.exports = exports['default'];
  4342. },{"../../component.js":65,"../../menu/menu-item.js":103}],73:[function(_dereq_,module,exports){
  4343. /**
  4344. * @file load-progress-bar.js
  4345. */
  4346. 'use strict';
  4347. exports.__esModule = true;
  4348. 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; } }
  4349. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4350. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4351. 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; }
  4352. var _componentJs = _dereq_('../../component.js');
  4353. var _componentJs2 = _interopRequireDefault(_componentJs);
  4354. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4355. var Dom = _interopRequireWildcard(_utilsDomJs);
  4356. /**
  4357. * Shows load progress
  4358. *
  4359. * @param {Player|Object} player
  4360. * @param {Object=} options
  4361. * @extends Component
  4362. * @class LoadProgressBar
  4363. */
  4364. var LoadProgressBar = (function (_Component) {
  4365. _inherits(LoadProgressBar, _Component);
  4366. function LoadProgressBar(player, options) {
  4367. _classCallCheck(this, LoadProgressBar);
  4368. _Component.call(this, player, options);
  4369. this.on(player, 'progress', this.update);
  4370. }
  4371. /**
  4372. * Create the component's DOM element
  4373. *
  4374. * @return {Element}
  4375. * @method createEl
  4376. */
  4377. LoadProgressBar.prototype.createEl = function createEl() {
  4378. return _Component.prototype.createEl.call(this, 'div', {
  4379. className: 'vjs-load-progress',
  4380. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Loaded') + '</span>: 0%</span>'
  4381. });
  4382. };
  4383. /**
  4384. * Update progress bar
  4385. *
  4386. * @method update
  4387. */
  4388. LoadProgressBar.prototype.update = function update() {
  4389. var buffered = this.player_.buffered();
  4390. var duration = this.player_.duration();
  4391. var bufferedEnd = this.player_.bufferedEnd();
  4392. var children = this.el_.children;
  4393. // get the percent width of a time compared to the total end
  4394. var percentify = function percentify(time, end) {
  4395. var percent = time / end || 0; // no NaN
  4396. return (percent >= 1 ? 1 : percent) * 100 + '%';
  4397. };
  4398. // update the width of the progress bar
  4399. this.el_.style.width = percentify(bufferedEnd, duration);
  4400. // add child elements to represent the individual buffered time ranges
  4401. for (var i = 0; i < buffered.length; i++) {
  4402. var start = buffered.start(i);
  4403. var end = buffered.end(i);
  4404. var part = children[i];
  4405. if (!part) {
  4406. part = this.el_.appendChild(Dom.createEl());
  4407. }
  4408. // set the percent based on the width of the progress bar (bufferedEnd)
  4409. part.style.left = percentify(start, bufferedEnd);
  4410. part.style.width = percentify(end - start, bufferedEnd);
  4411. }
  4412. // remove unused buffered range elements
  4413. for (var i = children.length; i > buffered.length; i--) {
  4414. this.el_.removeChild(children[i - 1]);
  4415. }
  4416. };
  4417. return LoadProgressBar;
  4418. })(_componentJs2['default']);
  4419. _componentJs2['default'].registerComponent('LoadProgressBar', LoadProgressBar);
  4420. exports['default'] = LoadProgressBar;
  4421. module.exports = exports['default'];
  4422. },{"../../component.js":65,"../../utils/dom.js":128}],74:[function(_dereq_,module,exports){
  4423. /**
  4424. * @file mouse-time-display.js
  4425. */
  4426. 'use strict';
  4427. exports.__esModule = true;
  4428. 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; } }
  4429. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4430. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4431. 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; }
  4432. var _componentJs = _dereq_('../../component.js');
  4433. var _componentJs2 = _interopRequireDefault(_componentJs);
  4434. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4435. var Dom = _interopRequireWildcard(_utilsDomJs);
  4436. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4437. var Fn = _interopRequireWildcard(_utilsFnJs);
  4438. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  4439. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  4440. var _lodashCompatFunctionThrottle = _dereq_('lodash-compat/function/throttle');
  4441. var _lodashCompatFunctionThrottle2 = _interopRequireDefault(_lodashCompatFunctionThrottle);
  4442. /**
  4443. * The Mouse Time Display component shows the time you will seek to
  4444. * when hovering over the progress bar
  4445. *
  4446. * @param {Player|Object} player
  4447. * @param {Object=} options
  4448. * @extends Component
  4449. * @class MouseTimeDisplay
  4450. */
  4451. var MouseTimeDisplay = (function (_Component) {
  4452. _inherits(MouseTimeDisplay, _Component);
  4453. function MouseTimeDisplay(player, options) {
  4454. var _this = this;
  4455. _classCallCheck(this, MouseTimeDisplay);
  4456. _Component.call(this, player, options);
  4457. this.update(0, 0);
  4458. player.on('ready', function () {
  4459. _this.on(player.controlBar.progressControl.el(), 'mousemove', _lodashCompatFunctionThrottle2['default'](Fn.bind(_this, _this.handleMouseMove), 25));
  4460. });
  4461. }
  4462. /**
  4463. * Create the component's DOM element
  4464. *
  4465. * @return {Element}
  4466. * @method createEl
  4467. */
  4468. MouseTimeDisplay.prototype.createEl = function createEl() {
  4469. return _Component.prototype.createEl.call(this, 'div', {
  4470. className: 'vjs-mouse-display'
  4471. });
  4472. };
  4473. MouseTimeDisplay.prototype.handleMouseMove = function handleMouseMove(event) {
  4474. var duration = this.player_.duration();
  4475. var newTime = this.calculateDistance(event) * duration;
  4476. var position = event.pageX - Dom.findElPosition(this.el().parentNode).left;
  4477. this.update(newTime, position);
  4478. };
  4479. MouseTimeDisplay.prototype.update = function update(newTime, position) {
  4480. var time = _utilsFormatTimeJs2['default'](newTime, this.player_.duration());
  4481. this.el().style.left = position + 'px';
  4482. this.el().setAttribute('data-current-time', time);
  4483. };
  4484. MouseTimeDisplay.prototype.calculateDistance = function calculateDistance(event) {
  4485. return Dom.getPointerPosition(this.el().parentNode, event).x;
  4486. };
  4487. return MouseTimeDisplay;
  4488. })(_componentJs2['default']);
  4489. _componentJs2['default'].registerComponent('MouseTimeDisplay', MouseTimeDisplay);
  4490. exports['default'] = MouseTimeDisplay;
  4491. module.exports = exports['default'];
  4492. },{"../../component.js":65,"../../utils/dom.js":128,"../../utils/fn.js":130,"../../utils/format-time.js":131,"lodash-compat/function/throttle":7}],75:[function(_dereq_,module,exports){
  4493. /**
  4494. * @file play-progress-bar.js
  4495. */
  4496. 'use strict';
  4497. exports.__esModule = true;
  4498. 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; } }
  4499. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4500. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4501. 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; }
  4502. var _componentJs = _dereq_('../../component.js');
  4503. var _componentJs2 = _interopRequireDefault(_componentJs);
  4504. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4505. var Fn = _interopRequireWildcard(_utilsFnJs);
  4506. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  4507. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  4508. /**
  4509. * Shows play progress
  4510. *
  4511. * @param {Player|Object} player
  4512. * @param {Object=} options
  4513. * @extends Component
  4514. * @class PlayProgressBar
  4515. */
  4516. var PlayProgressBar = (function (_Component) {
  4517. _inherits(PlayProgressBar, _Component);
  4518. function PlayProgressBar(player, options) {
  4519. _classCallCheck(this, PlayProgressBar);
  4520. _Component.call(this, player, options);
  4521. this.updateDataAttr();
  4522. this.on(player, 'timeupdate', this.updateDataAttr);
  4523. player.ready(Fn.bind(this, this.updateDataAttr));
  4524. }
  4525. /**
  4526. * Create the component's DOM element
  4527. *
  4528. * @return {Element}
  4529. * @method createEl
  4530. */
  4531. PlayProgressBar.prototype.createEl = function createEl() {
  4532. return _Component.prototype.createEl.call(this, 'div', {
  4533. className: 'vjs-play-progress vjs-slider-bar',
  4534. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
  4535. });
  4536. };
  4537. PlayProgressBar.prototype.updateDataAttr = function updateDataAttr() {
  4538. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  4539. this.el_.setAttribute('data-current-time', _utilsFormatTimeJs2['default'](time, this.player_.duration()));
  4540. };
  4541. return PlayProgressBar;
  4542. })(_componentJs2['default']);
  4543. _componentJs2['default'].registerComponent('PlayProgressBar', PlayProgressBar);
  4544. exports['default'] = PlayProgressBar;
  4545. module.exports = exports['default'];
  4546. },{"../../component.js":65,"../../utils/fn.js":130,"../../utils/format-time.js":131}],76:[function(_dereq_,module,exports){
  4547. /**
  4548. * @file progress-control.js
  4549. */
  4550. 'use strict';
  4551. exports.__esModule = true;
  4552. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4553. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4554. 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; }
  4555. var _componentJs = _dereq_('../../component.js');
  4556. var _componentJs2 = _interopRequireDefault(_componentJs);
  4557. var _seekBarJs = _dereq_('./seek-bar.js');
  4558. var _seekBarJs2 = _interopRequireDefault(_seekBarJs);
  4559. var _mouseTimeDisplayJs = _dereq_('./mouse-time-display.js');
  4560. var _mouseTimeDisplayJs2 = _interopRequireDefault(_mouseTimeDisplayJs);
  4561. /**
  4562. * The Progress Control component contains the seek bar, load progress,
  4563. * and play progress
  4564. *
  4565. * @param {Player|Object} player
  4566. * @param {Object=} options
  4567. * @extends Component
  4568. * @class ProgressControl
  4569. */
  4570. var ProgressControl = (function (_Component) {
  4571. _inherits(ProgressControl, _Component);
  4572. function ProgressControl() {
  4573. _classCallCheck(this, ProgressControl);
  4574. _Component.apply(this, arguments);
  4575. }
  4576. /**
  4577. * Create the component's DOM element
  4578. *
  4579. * @return {Element}
  4580. * @method createEl
  4581. */
  4582. ProgressControl.prototype.createEl = function createEl() {
  4583. return _Component.prototype.createEl.call(this, 'div', {
  4584. className: 'vjs-progress-control vjs-control'
  4585. });
  4586. };
  4587. return ProgressControl;
  4588. })(_componentJs2['default']);
  4589. ProgressControl.prototype.options_ = {
  4590. children: ['seekBar']
  4591. };
  4592. _componentJs2['default'].registerComponent('ProgressControl', ProgressControl);
  4593. exports['default'] = ProgressControl;
  4594. module.exports = exports['default'];
  4595. },{"../../component.js":65,"./mouse-time-display.js":74,"./seek-bar.js":77}],77:[function(_dereq_,module,exports){
  4596. /**
  4597. * @file seek-bar.js
  4598. */
  4599. 'use strict';
  4600. exports.__esModule = true;
  4601. 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; } }
  4602. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4603. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4604. 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; }
  4605. var _sliderSliderJs = _dereq_('../../slider/slider.js');
  4606. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs);
  4607. var _componentJs = _dereq_('../../component.js');
  4608. var _componentJs2 = _interopRequireDefault(_componentJs);
  4609. var _loadProgressBarJs = _dereq_('./load-progress-bar.js');
  4610. var _loadProgressBarJs2 = _interopRequireDefault(_loadProgressBarJs);
  4611. var _playProgressBarJs = _dereq_('./play-progress-bar.js');
  4612. var _playProgressBarJs2 = _interopRequireDefault(_playProgressBarJs);
  4613. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4614. var Fn = _interopRequireWildcard(_utilsFnJs);
  4615. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  4616. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  4617. var _objectAssign = _dereq_('object.assign');
  4618. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  4619. /**
  4620. * Seek Bar and holder for the progress bars
  4621. *
  4622. * @param {Player|Object} player
  4623. * @param {Object=} options
  4624. * @extends Slider
  4625. * @class SeekBar
  4626. */
  4627. var SeekBar = (function (_Slider) {
  4628. _inherits(SeekBar, _Slider);
  4629. function SeekBar(player, options) {
  4630. _classCallCheck(this, SeekBar);
  4631. _Slider.call(this, player, options);
  4632. this.on(player, 'timeupdate', this.updateARIAAttributes);
  4633. player.ready(Fn.bind(this, this.updateARIAAttributes));
  4634. }
  4635. /**
  4636. * Create the component's DOM element
  4637. *
  4638. * @return {Element}
  4639. * @method createEl
  4640. */
  4641. SeekBar.prototype.createEl = function createEl() {
  4642. return _Slider.prototype.createEl.call(this, 'div', {
  4643. className: 'vjs-progress-holder'
  4644. }, {
  4645. 'aria-label': 'video progress bar'
  4646. });
  4647. };
  4648. /**
  4649. * Update ARIA accessibility attributes
  4650. *
  4651. * @method updateARIAAttributes
  4652. */
  4653. SeekBar.prototype.updateARIAAttributes = function updateARIAAttributes() {
  4654. // Allows for smooth scrubbing, when player can't keep up.
  4655. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  4656. this.el_.setAttribute('aria-valuenow', (this.getPercent() * 100).toFixed(2)); // machine readable value of progress bar (percentage complete)
  4657. this.el_.setAttribute('aria-valuetext', _utilsFormatTimeJs2['default'](time, this.player_.duration())); // human readable value of progress bar (time complete)
  4658. };
  4659. /**
  4660. * Get percentage of video played
  4661. *
  4662. * @return {Number} Percentage played
  4663. * @method getPercent
  4664. */
  4665. SeekBar.prototype.getPercent = function getPercent() {
  4666. var percent = this.player_.currentTime() / this.player_.duration();
  4667. return percent >= 1 ? 1 : percent;
  4668. };
  4669. /**
  4670. * Handle mouse down on seek bar
  4671. *
  4672. * @method handleMouseDown
  4673. */
  4674. SeekBar.prototype.handleMouseDown = function handleMouseDown(event) {
  4675. _Slider.prototype.handleMouseDown.call(this, event);
  4676. this.player_.scrubbing(true);
  4677. this.videoWasPlaying = !this.player_.paused();
  4678. this.player_.pause();
  4679. };
  4680. /**
  4681. * Handle mouse move on seek bar
  4682. *
  4683. * @method handleMouseMove
  4684. */
  4685. SeekBar.prototype.handleMouseMove = function handleMouseMove(event) {
  4686. var newTime = this.calculateDistance(event) * this.player_.duration();
  4687. // Don't let video end while scrubbing.
  4688. if (newTime === this.player_.duration()) {
  4689. newTime = newTime - 0.1;
  4690. }
  4691. // Set new time (tell player to seek to new time)
  4692. this.player_.currentTime(newTime);
  4693. };
  4694. /**
  4695. * Handle mouse up on seek bar
  4696. *
  4697. * @method handleMouseUp
  4698. */
  4699. SeekBar.prototype.handleMouseUp = function handleMouseUp(event) {
  4700. _Slider.prototype.handleMouseUp.call(this, event);
  4701. this.player_.scrubbing(false);
  4702. if (this.videoWasPlaying) {
  4703. this.player_.play();
  4704. }
  4705. };
  4706. /**
  4707. * Move more quickly fast forward for keyboard-only users
  4708. *
  4709. * @method stepForward
  4710. */
  4711. SeekBar.prototype.stepForward = function stepForward() {
  4712. this.player_.currentTime(this.player_.currentTime() + 5); // more quickly fast forward for keyboard-only users
  4713. };
  4714. /**
  4715. * Move more quickly rewind for keyboard-only users
  4716. *
  4717. * @method stepBack
  4718. */
  4719. SeekBar.prototype.stepBack = function stepBack() {
  4720. this.player_.currentTime(this.player_.currentTime() - 5); // more quickly rewind for keyboard-only users
  4721. };
  4722. return SeekBar;
  4723. })(_sliderSliderJs2['default']);
  4724. SeekBar.prototype.options_ = {
  4725. children: ['loadProgressBar', 'mouseTimeDisplay', 'playProgressBar'],
  4726. 'barName': 'playProgressBar'
  4727. };
  4728. SeekBar.prototype.playerEvent = 'timeupdate';
  4729. _componentJs2['default'].registerComponent('SeekBar', SeekBar);
  4730. exports['default'] = SeekBar;
  4731. module.exports = exports['default'];
  4732. },{"../../component.js":65,"../../slider/slider.js":110,"../../utils/fn.js":130,"../../utils/format-time.js":131,"./load-progress-bar.js":73,"./play-progress-bar.js":75,"object.assign":45}],78:[function(_dereq_,module,exports){
  4733. /**
  4734. * @file custom-control-spacer.js
  4735. */
  4736. 'use strict';
  4737. exports.__esModule = true;
  4738. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4739. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4740. 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; }
  4741. var _spacerJs = _dereq_('./spacer.js');
  4742. var _spacerJs2 = _interopRequireDefault(_spacerJs);
  4743. var _componentJs = _dereq_('../../component.js');
  4744. var _componentJs2 = _interopRequireDefault(_componentJs);
  4745. /**
  4746. * Spacer specifically meant to be used as an insertion point for new plugins, etc.
  4747. *
  4748. * @extends Spacer
  4749. * @class CustomControlSpacer
  4750. */
  4751. var CustomControlSpacer = (function (_Spacer) {
  4752. _inherits(CustomControlSpacer, _Spacer);
  4753. function CustomControlSpacer() {
  4754. _classCallCheck(this, CustomControlSpacer);
  4755. _Spacer.apply(this, arguments);
  4756. }
  4757. /**
  4758. * Allow sub components to stack CSS class names
  4759. *
  4760. * @return {String} The constructed class name
  4761. * @method buildCSSClass
  4762. */
  4763. CustomControlSpacer.prototype.buildCSSClass = function buildCSSClass() {
  4764. return 'vjs-custom-control-spacer ' + _Spacer.prototype.buildCSSClass.call(this);
  4765. };
  4766. /**
  4767. * Create the component's DOM element
  4768. *
  4769. * @return {Element}
  4770. * @method createEl
  4771. */
  4772. CustomControlSpacer.prototype.createEl = function createEl() {
  4773. var el = _Spacer.prototype.createEl.call(this, {
  4774. className: this.buildCSSClass()
  4775. });
  4776. // No-flex/table-cell mode requires there be some content
  4777. // in the cell to fill the remaining space of the table.
  4778. el.innerHTML = '&nbsp;';
  4779. return el;
  4780. };
  4781. return CustomControlSpacer;
  4782. })(_spacerJs2['default']);
  4783. _componentJs2['default'].registerComponent('CustomControlSpacer', CustomControlSpacer);
  4784. exports['default'] = CustomControlSpacer;
  4785. module.exports = exports['default'];
  4786. },{"../../component.js":65,"./spacer.js":79}],79:[function(_dereq_,module,exports){
  4787. /**
  4788. * @file spacer.js
  4789. */
  4790. 'use strict';
  4791. exports.__esModule = true;
  4792. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4793. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4794. 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; }
  4795. var _componentJs = _dereq_('../../component.js');
  4796. var _componentJs2 = _interopRequireDefault(_componentJs);
  4797. /**
  4798. * Just an empty spacer element that can be used as an append point for plugins, etc.
  4799. * Also can be used to create space between elements when necessary.
  4800. *
  4801. * @extends Component
  4802. * @class Spacer
  4803. */
  4804. var Spacer = (function (_Component) {
  4805. _inherits(Spacer, _Component);
  4806. function Spacer() {
  4807. _classCallCheck(this, Spacer);
  4808. _Component.apply(this, arguments);
  4809. }
  4810. /**
  4811. * Allow sub components to stack CSS class names
  4812. *
  4813. * @return {String} The constructed class name
  4814. * @method buildCSSClass
  4815. */
  4816. Spacer.prototype.buildCSSClass = function buildCSSClass() {
  4817. return 'vjs-spacer ' + _Component.prototype.buildCSSClass.call(this);
  4818. };
  4819. /**
  4820. * Create the component's DOM element
  4821. *
  4822. * @return {Element}
  4823. * @method createEl
  4824. */
  4825. Spacer.prototype.createEl = function createEl() {
  4826. return _Component.prototype.createEl.call(this, 'div', {
  4827. className: this.buildCSSClass()
  4828. });
  4829. };
  4830. return Spacer;
  4831. })(_componentJs2['default']);
  4832. _componentJs2['default'].registerComponent('Spacer', Spacer);
  4833. exports['default'] = Spacer;
  4834. module.exports = exports['default'];
  4835. },{"../../component.js":65}],80:[function(_dereq_,module,exports){
  4836. /**
  4837. * @file caption-settings-menu-item.js
  4838. */
  4839. 'use strict';
  4840. exports.__esModule = true;
  4841. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4842. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4843. 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; }
  4844. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  4845. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  4846. var _componentJs = _dereq_('../../component.js');
  4847. var _componentJs2 = _interopRequireDefault(_componentJs);
  4848. /**
  4849. * The menu item for caption track settings menu
  4850. *
  4851. * @param {Player|Object} player
  4852. * @param {Object=} options
  4853. * @extends TextTrackMenuItem
  4854. * @class CaptionSettingsMenuItem
  4855. */
  4856. var CaptionSettingsMenuItem = (function (_TextTrackMenuItem) {
  4857. _inherits(CaptionSettingsMenuItem, _TextTrackMenuItem);
  4858. function CaptionSettingsMenuItem(player, options) {
  4859. _classCallCheck(this, CaptionSettingsMenuItem);
  4860. options['track'] = {
  4861. 'kind': options['kind'],
  4862. 'player': player,
  4863. 'label': options['kind'] + ' settings',
  4864. 'default': false,
  4865. mode: 'disabled'
  4866. };
  4867. _TextTrackMenuItem.call(this, player, options);
  4868. this.addClass('vjs-texttrack-settings');
  4869. }
  4870. /**
  4871. * Handle click on menu item
  4872. *
  4873. * @method handleClick
  4874. */
  4875. CaptionSettingsMenuItem.prototype.handleClick = function handleClick() {
  4876. this.player().getChild('textTrackSettings').show();
  4877. };
  4878. return CaptionSettingsMenuItem;
  4879. })(_textTrackMenuItemJs2['default']);
  4880. _componentJs2['default'].registerComponent('CaptionSettingsMenuItem', CaptionSettingsMenuItem);
  4881. exports['default'] = CaptionSettingsMenuItem;
  4882. module.exports = exports['default'];
  4883. },{"../../component.js":65,"./text-track-menu-item.js":87}],81:[function(_dereq_,module,exports){
  4884. /**
  4885. * @file captions-button.js
  4886. */
  4887. 'use strict';
  4888. exports.__esModule = true;
  4889. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4890. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4891. 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; }
  4892. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  4893. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  4894. var _componentJs = _dereq_('../../component.js');
  4895. var _componentJs2 = _interopRequireDefault(_componentJs);
  4896. var _captionSettingsMenuItemJs = _dereq_('./caption-settings-menu-item.js');
  4897. var _captionSettingsMenuItemJs2 = _interopRequireDefault(_captionSettingsMenuItemJs);
  4898. /**
  4899. * The button component for toggling and selecting captions
  4900. *
  4901. * @param {Object} player Player object
  4902. * @param {Object=} options Object of option names and values
  4903. * @param {Function=} ready Ready callback function
  4904. * @extends TextTrackButton
  4905. * @class CaptionsButton
  4906. */
  4907. var CaptionsButton = (function (_TextTrackButton) {
  4908. _inherits(CaptionsButton, _TextTrackButton);
  4909. function CaptionsButton(player, options, ready) {
  4910. _classCallCheck(this, CaptionsButton);
  4911. _TextTrackButton.call(this, player, options, ready);
  4912. this.el_.setAttribute('aria-label', 'Captions Menu');
  4913. }
  4914. /**
  4915. * Allow sub components to stack CSS class names
  4916. *
  4917. * @return {String} The constructed class name
  4918. * @method buildCSSClass
  4919. */
  4920. CaptionsButton.prototype.buildCSSClass = function buildCSSClass() {
  4921. return 'vjs-captions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  4922. };
  4923. /**
  4924. * Update caption menu items
  4925. *
  4926. * @method update
  4927. */
  4928. CaptionsButton.prototype.update = function update() {
  4929. var threshold = 2;
  4930. _TextTrackButton.prototype.update.call(this);
  4931. // if native, then threshold is 1 because no settings button
  4932. if (this.player().tech_ && this.player().tech_['featuresNativeTextTracks']) {
  4933. threshold = 1;
  4934. }
  4935. if (this.items && this.items.length > threshold) {
  4936. this.show();
  4937. } else {
  4938. this.hide();
  4939. }
  4940. };
  4941. /**
  4942. * Create caption menu items
  4943. *
  4944. * @return {Array} Array of menu items
  4945. * @method createItems
  4946. */
  4947. CaptionsButton.prototype.createItems = function createItems() {
  4948. var items = [];
  4949. if (!(this.player().tech_ && this.player().tech_['featuresNativeTextTracks'])) {
  4950. items.push(new _captionSettingsMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }));
  4951. }
  4952. return _TextTrackButton.prototype.createItems.call(this, items);
  4953. };
  4954. return CaptionsButton;
  4955. })(_textTrackButtonJs2['default']);
  4956. CaptionsButton.prototype.kind_ = 'captions';
  4957. CaptionsButton.prototype.controlText_ = 'Captions';
  4958. _componentJs2['default'].registerComponent('CaptionsButton', CaptionsButton);
  4959. exports['default'] = CaptionsButton;
  4960. module.exports = exports['default'];
  4961. },{"../../component.js":65,"./caption-settings-menu-item.js":80,"./text-track-button.js":86}],82:[function(_dereq_,module,exports){
  4962. /**
  4963. * @file chapters-button.js
  4964. */
  4965. 'use strict';
  4966. exports.__esModule = true;
  4967. 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; } }
  4968. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4969. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4970. 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; }
  4971. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  4972. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  4973. var _componentJs = _dereq_('../../component.js');
  4974. var _componentJs2 = _interopRequireDefault(_componentJs);
  4975. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  4976. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  4977. var _chaptersTrackMenuItemJs = _dereq_('./chapters-track-menu-item.js');
  4978. var _chaptersTrackMenuItemJs2 = _interopRequireDefault(_chaptersTrackMenuItemJs);
  4979. var _menuMenuJs = _dereq_('../../menu/menu.js');
  4980. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  4981. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4982. var Dom = _interopRequireWildcard(_utilsDomJs);
  4983. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4984. var Fn = _interopRequireWildcard(_utilsFnJs);
  4985. var _utilsToTitleCaseJs = _dereq_('../../utils/to-title-case.js');
  4986. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  4987. var _globalWindow = _dereq_('global/window');
  4988. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  4989. /**
  4990. * The button component for toggling and selecting chapters
  4991. * Chapters act much differently than other text tracks
  4992. * Cues are navigation vs. other tracks of alternative languages
  4993. *
  4994. * @param {Object} player Player object
  4995. * @param {Object=} options Object of option names and values
  4996. * @param {Function=} ready Ready callback function
  4997. * @extends TextTrackButton
  4998. * @class ChaptersButton
  4999. */
  5000. var ChaptersButton = (function (_TextTrackButton) {
  5001. _inherits(ChaptersButton, _TextTrackButton);
  5002. function ChaptersButton(player, options, ready) {
  5003. _classCallCheck(this, ChaptersButton);
  5004. _TextTrackButton.call(this, player, options, ready);
  5005. this.el_.setAttribute('aria-label', 'Chapters Menu');
  5006. }
  5007. /**
  5008. * Allow sub components to stack CSS class names
  5009. *
  5010. * @return {String} The constructed class name
  5011. * @method buildCSSClass
  5012. */
  5013. ChaptersButton.prototype.buildCSSClass = function buildCSSClass() {
  5014. return 'vjs-chapters-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5015. };
  5016. /**
  5017. * Create a menu item for each text track
  5018. *
  5019. * @return {Array} Array of menu items
  5020. * @method createItems
  5021. */
  5022. ChaptersButton.prototype.createItems = function createItems() {
  5023. var items = [];
  5024. var tracks = this.player_.textTracks();
  5025. if (!tracks) {
  5026. return items;
  5027. }
  5028. for (var i = 0; i < tracks.length; i++) {
  5029. var track = tracks[i];
  5030. if (track['kind'] === this.kind_) {
  5031. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5032. 'track': track
  5033. }));
  5034. }
  5035. }
  5036. return items;
  5037. };
  5038. /**
  5039. * Create menu from chapter buttons
  5040. *
  5041. * @return {Menu} Menu of chapter buttons
  5042. * @method createMenu
  5043. */
  5044. ChaptersButton.prototype.createMenu = function createMenu() {
  5045. var _this = this;
  5046. var tracks = this.player_.textTracks() || [];
  5047. var chaptersTrack = undefined;
  5048. var items = this.items = [];
  5049. for (var i = 0, _length = tracks.length; i < _length; i++) {
  5050. var track = tracks[i];
  5051. if (track['kind'] === this.kind_) {
  5052. chaptersTrack = track;
  5053. break;
  5054. }
  5055. }
  5056. var menu = this.menu;
  5057. if (menu === undefined) {
  5058. menu = new _menuMenuJs2['default'](this.player_);
  5059. menu.contentEl().appendChild(Dom.createEl('li', {
  5060. className: 'vjs-menu-title',
  5061. innerHTML: _utilsToTitleCaseJs2['default'](this.kind_),
  5062. tabIndex: -1
  5063. }));
  5064. }
  5065. if (chaptersTrack && chaptersTrack.cues == null) {
  5066. chaptersTrack['mode'] = 'hidden';
  5067. var remoteTextTrackEl = this.player_.remoteTextTrackEls().getTrackElementByTrack_(chaptersTrack);
  5068. if (remoteTextTrackEl) {
  5069. remoteTextTrackEl.addEventListener('load', function (event) {
  5070. return _this.update();
  5071. });
  5072. }
  5073. }
  5074. if (chaptersTrack && chaptersTrack.cues && chaptersTrack.cues.length > 0) {
  5075. var cues = chaptersTrack['cues'],
  5076. cue = undefined;
  5077. for (var i = 0, l = cues.length; i < l; i++) {
  5078. cue = cues[i];
  5079. var mi = new _chaptersTrackMenuItemJs2['default'](this.player_, {
  5080. 'track': chaptersTrack,
  5081. 'cue': cue
  5082. });
  5083. items.push(mi);
  5084. menu.addChild(mi);
  5085. }
  5086. this.addChild(menu);
  5087. }
  5088. if (this.items.length > 0) {
  5089. this.show();
  5090. }
  5091. return menu;
  5092. };
  5093. return ChaptersButton;
  5094. })(_textTrackButtonJs2['default']);
  5095. ChaptersButton.prototype.kind_ = 'chapters';
  5096. ChaptersButton.prototype.controlText_ = 'Chapters';
  5097. _componentJs2['default'].registerComponent('ChaptersButton', ChaptersButton);
  5098. exports['default'] = ChaptersButton;
  5099. module.exports = exports['default'];
  5100. },{"../../component.js":65,"../../menu/menu.js":104,"../../utils/dom.js":128,"../../utils/fn.js":130,"../../utils/to-title-case.js":137,"./chapters-track-menu-item.js":83,"./text-track-button.js":86,"./text-track-menu-item.js":87,"global/window":2}],83:[function(_dereq_,module,exports){
  5101. /**
  5102. * @file chapters-track-menu-item.js
  5103. */
  5104. 'use strict';
  5105. exports.__esModule = true;
  5106. 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; } }
  5107. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5108. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5109. 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; }
  5110. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  5111. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  5112. var _componentJs = _dereq_('../../component.js');
  5113. var _componentJs2 = _interopRequireDefault(_componentJs);
  5114. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5115. var Fn = _interopRequireWildcard(_utilsFnJs);
  5116. /**
  5117. * The chapter track menu item
  5118. *
  5119. * @param {Player|Object} player
  5120. * @param {Object=} options
  5121. * @extends MenuItem
  5122. * @class ChaptersTrackMenuItem
  5123. */
  5124. var ChaptersTrackMenuItem = (function (_MenuItem) {
  5125. _inherits(ChaptersTrackMenuItem, _MenuItem);
  5126. function ChaptersTrackMenuItem(player, options) {
  5127. _classCallCheck(this, ChaptersTrackMenuItem);
  5128. var track = options['track'];
  5129. var cue = options['cue'];
  5130. var currentTime = player.currentTime();
  5131. // Modify options for parent MenuItem class's init.
  5132. options['label'] = cue.text;
  5133. options['selected'] = cue['startTime'] <= currentTime && currentTime < cue['endTime'];
  5134. _MenuItem.call(this, player, options);
  5135. this.track = track;
  5136. this.cue = cue;
  5137. track.addEventListener('cuechange', Fn.bind(this, this.update));
  5138. }
  5139. /**
  5140. * Handle click on menu item
  5141. *
  5142. * @method handleClick
  5143. */
  5144. ChaptersTrackMenuItem.prototype.handleClick = function handleClick() {
  5145. _MenuItem.prototype.handleClick.call(this);
  5146. this.player_.currentTime(this.cue.startTime);
  5147. this.update(this.cue.startTime);
  5148. };
  5149. /**
  5150. * Update chapter menu item
  5151. *
  5152. * @method update
  5153. */
  5154. ChaptersTrackMenuItem.prototype.update = function update() {
  5155. var cue = this.cue;
  5156. var currentTime = this.player_.currentTime();
  5157. // vjs.log(currentTime, cue.startTime);
  5158. this.selected(cue['startTime'] <= currentTime && currentTime < cue['endTime']);
  5159. };
  5160. return ChaptersTrackMenuItem;
  5161. })(_menuMenuItemJs2['default']);
  5162. _componentJs2['default'].registerComponent('ChaptersTrackMenuItem', ChaptersTrackMenuItem);
  5163. exports['default'] = ChaptersTrackMenuItem;
  5164. module.exports = exports['default'];
  5165. },{"../../component.js":65,"../../menu/menu-item.js":103,"../../utils/fn.js":130}],84:[function(_dereq_,module,exports){
  5166. /**
  5167. * @file off-text-track-menu-item.js
  5168. */
  5169. 'use strict';
  5170. exports.__esModule = true;
  5171. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5172. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5173. 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; }
  5174. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5175. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5176. var _componentJs = _dereq_('../../component.js');
  5177. var _componentJs2 = _interopRequireDefault(_componentJs);
  5178. /**
  5179. * A special menu item for turning of a specific type of text track
  5180. *
  5181. * @param {Player|Object} player
  5182. * @param {Object=} options
  5183. * @extends TextTrackMenuItem
  5184. * @class OffTextTrackMenuItem
  5185. */
  5186. var OffTextTrackMenuItem = (function (_TextTrackMenuItem) {
  5187. _inherits(OffTextTrackMenuItem, _TextTrackMenuItem);
  5188. function OffTextTrackMenuItem(player, options) {
  5189. _classCallCheck(this, OffTextTrackMenuItem);
  5190. // Create pseudo track info
  5191. // Requires options['kind']
  5192. options['track'] = {
  5193. 'kind': options['kind'],
  5194. 'player': player,
  5195. 'label': options['kind'] + ' off',
  5196. 'default': false,
  5197. 'mode': 'disabled'
  5198. };
  5199. _TextTrackMenuItem.call(this, player, options);
  5200. this.selected(true);
  5201. }
  5202. /**
  5203. * Handle text track change
  5204. *
  5205. * @param {Object} event Event object
  5206. * @method handleTracksChange
  5207. */
  5208. OffTextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  5209. var tracks = this.player().textTracks();
  5210. var selected = true;
  5211. for (var i = 0, l = tracks.length; i < l; i++) {
  5212. var track = tracks[i];
  5213. if (track['kind'] === this.track['kind'] && track['mode'] === 'showing') {
  5214. selected = false;
  5215. break;
  5216. }
  5217. }
  5218. this.selected(selected);
  5219. };
  5220. return OffTextTrackMenuItem;
  5221. })(_textTrackMenuItemJs2['default']);
  5222. _componentJs2['default'].registerComponent('OffTextTrackMenuItem', OffTextTrackMenuItem);
  5223. exports['default'] = OffTextTrackMenuItem;
  5224. module.exports = exports['default'];
  5225. },{"../../component.js":65,"./text-track-menu-item.js":87}],85:[function(_dereq_,module,exports){
  5226. /**
  5227. * @file subtitles-button.js
  5228. */
  5229. 'use strict';
  5230. exports.__esModule = true;
  5231. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5232. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5233. 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; }
  5234. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5235. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5236. var _componentJs = _dereq_('../../component.js');
  5237. var _componentJs2 = _interopRequireDefault(_componentJs);
  5238. /**
  5239. * The button component for toggling and selecting subtitles
  5240. *
  5241. * @param {Object} player Player object
  5242. * @param {Object=} options Object of option names and values
  5243. * @param {Function=} ready Ready callback function
  5244. * @extends TextTrackButton
  5245. * @class SubtitlesButton
  5246. */
  5247. var SubtitlesButton = (function (_TextTrackButton) {
  5248. _inherits(SubtitlesButton, _TextTrackButton);
  5249. function SubtitlesButton(player, options, ready) {
  5250. _classCallCheck(this, SubtitlesButton);
  5251. _TextTrackButton.call(this, player, options, ready);
  5252. this.el_.setAttribute('aria-label', 'Subtitles Menu');
  5253. }
  5254. /**
  5255. * Allow sub components to stack CSS class names
  5256. *
  5257. * @return {String} The constructed class name
  5258. * @method buildCSSClass
  5259. */
  5260. SubtitlesButton.prototype.buildCSSClass = function buildCSSClass() {
  5261. return 'vjs-subtitles-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5262. };
  5263. return SubtitlesButton;
  5264. })(_textTrackButtonJs2['default']);
  5265. SubtitlesButton.prototype.kind_ = 'subtitles';
  5266. SubtitlesButton.prototype.controlText_ = 'Subtitles';
  5267. _componentJs2['default'].registerComponent('SubtitlesButton', SubtitlesButton);
  5268. exports['default'] = SubtitlesButton;
  5269. module.exports = exports['default'];
  5270. },{"../../component.js":65,"./text-track-button.js":86}],86:[function(_dereq_,module,exports){
  5271. /**
  5272. * @file text-track-button.js
  5273. */
  5274. 'use strict';
  5275. exports.__esModule = true;
  5276. 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; } }
  5277. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5278. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5279. 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; }
  5280. var _menuMenuButtonJs = _dereq_('../../menu/menu-button.js');
  5281. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  5282. var _componentJs = _dereq_('../../component.js');
  5283. var _componentJs2 = _interopRequireDefault(_componentJs);
  5284. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5285. var Fn = _interopRequireWildcard(_utilsFnJs);
  5286. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5287. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5288. var _offTextTrackMenuItemJs = _dereq_('./off-text-track-menu-item.js');
  5289. var _offTextTrackMenuItemJs2 = _interopRequireDefault(_offTextTrackMenuItemJs);
  5290. /**
  5291. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  5292. *
  5293. * @param {Player|Object} player
  5294. * @param {Object=} options
  5295. * @extends MenuButton
  5296. * @class TextTrackButton
  5297. */
  5298. var TextTrackButton = (function (_MenuButton) {
  5299. _inherits(TextTrackButton, _MenuButton);
  5300. function TextTrackButton(player, options) {
  5301. _classCallCheck(this, TextTrackButton);
  5302. _MenuButton.call(this, player, options);
  5303. var tracks = this.player_.textTracks();
  5304. if (this.items.length <= 1) {
  5305. this.hide();
  5306. }
  5307. if (!tracks) {
  5308. return;
  5309. }
  5310. var updateHandler = Fn.bind(this, this.update);
  5311. tracks.addEventListener('removetrack', updateHandler);
  5312. tracks.addEventListener('addtrack', updateHandler);
  5313. this.player_.on('dispose', function () {
  5314. tracks.removeEventListener('removetrack', updateHandler);
  5315. tracks.removeEventListener('addtrack', updateHandler);
  5316. });
  5317. }
  5318. // Create a menu item for each text track
  5319. TextTrackButton.prototype.createItems = function createItems() {
  5320. var items = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  5321. // Add an OFF menu item to turn all tracks off
  5322. items.push(new _offTextTrackMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }));
  5323. var tracks = this.player_.textTracks();
  5324. if (!tracks) {
  5325. return items;
  5326. }
  5327. for (var i = 0; i < tracks.length; i++) {
  5328. var track = tracks[i];
  5329. // only add tracks that are of the appropriate kind and have a label
  5330. if (track['kind'] === this.kind_) {
  5331. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5332. 'track': track
  5333. }));
  5334. }
  5335. }
  5336. return items;
  5337. };
  5338. return TextTrackButton;
  5339. })(_menuMenuButtonJs2['default']);
  5340. _componentJs2['default'].registerComponent('TextTrackButton', TextTrackButton);
  5341. exports['default'] = TextTrackButton;
  5342. module.exports = exports['default'];
  5343. },{"../../component.js":65,"../../menu/menu-button.js":102,"../../utils/fn.js":130,"./off-text-track-menu-item.js":84,"./text-track-menu-item.js":87}],87:[function(_dereq_,module,exports){
  5344. /**
  5345. * @file text-track-menu-item.js
  5346. */
  5347. 'use strict';
  5348. exports.__esModule = true;
  5349. 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; } }
  5350. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5351. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5352. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5353. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  5354. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  5355. var _componentJs = _dereq_('../../component.js');
  5356. var _componentJs2 = _interopRequireDefault(_componentJs);
  5357. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5358. var Fn = _interopRequireWildcard(_utilsFnJs);
  5359. var _globalWindow = _dereq_('global/window');
  5360. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  5361. var _globalDocument = _dereq_('global/document');
  5362. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  5363. /**
  5364. * The specific menu item type for selecting a language within a text track kind
  5365. *
  5366. * @param {Player|Object} player
  5367. * @param {Object=} options
  5368. * @extends MenuItem
  5369. * @class TextTrackMenuItem
  5370. */
  5371. var TextTrackMenuItem = (function (_MenuItem) {
  5372. _inherits(TextTrackMenuItem, _MenuItem);
  5373. function TextTrackMenuItem(player, options) {
  5374. var _this = this;
  5375. _classCallCheck(this, TextTrackMenuItem);
  5376. var track = options['track'];
  5377. var tracks = player.textTracks();
  5378. // Modify options for parent MenuItem class's init.
  5379. options['label'] = track['label'] || track['language'] || 'Unknown';
  5380. options['selected'] = track['default'] || track['mode'] === 'showing';
  5381. _MenuItem.call(this, player, options);
  5382. this.track = track;
  5383. if (tracks) {
  5384. (function () {
  5385. var changeHandler = Fn.bind(_this, _this.handleTracksChange);
  5386. tracks.addEventListener('change', changeHandler);
  5387. _this.on('dispose', function () {
  5388. tracks.removeEventListener('change', changeHandler);
  5389. });
  5390. })();
  5391. }
  5392. // iOS7 doesn't dispatch change events to TextTrackLists when an
  5393. // associated track's mode changes. Without something like
  5394. // Object.observe() (also not present on iOS7), it's not
  5395. // possible to detect changes to the mode attribute and polyfill
  5396. // the change event. As a poor substitute, we manually dispatch
  5397. // change events whenever the controls modify the mode.
  5398. if (tracks && tracks.onchange === undefined) {
  5399. (function () {
  5400. var event = undefined;
  5401. _this.on(['tap', 'click'], function () {
  5402. if (typeof _globalWindow2['default'].Event !== 'object') {
  5403. // Android 2.3 throws an Illegal Constructor error for window.Event
  5404. try {
  5405. event = new _globalWindow2['default'].Event('change');
  5406. } catch (err) {}
  5407. }
  5408. if (!event) {
  5409. event = _globalDocument2['default'].createEvent('Event');
  5410. event.initEvent('change', true, true);
  5411. }
  5412. tracks.dispatchEvent(event);
  5413. });
  5414. })();
  5415. }
  5416. }
  5417. /**
  5418. * Handle click on text track
  5419. *
  5420. * @method handleClick
  5421. */
  5422. TextTrackMenuItem.prototype.handleClick = function handleClick(event) {
  5423. var kind = this.track['kind'];
  5424. var tracks = this.player_.textTracks();
  5425. _MenuItem.prototype.handleClick.call(this, event);
  5426. if (!tracks) return;
  5427. for (var i = 0; i < tracks.length; i++) {
  5428. var track = tracks[i];
  5429. if (track['kind'] !== kind) {
  5430. continue;
  5431. }
  5432. if (track === this.track) {
  5433. track['mode'] = 'showing';
  5434. } else {
  5435. track['mode'] = 'disabled';
  5436. }
  5437. }
  5438. };
  5439. /**
  5440. * Handle text track change
  5441. *
  5442. * @method handleTracksChange
  5443. */
  5444. TextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  5445. this.selected(this.track['mode'] === 'showing');
  5446. };
  5447. return TextTrackMenuItem;
  5448. })(_menuMenuItemJs2['default']);
  5449. _componentJs2['default'].registerComponent('TextTrackMenuItem', TextTrackMenuItem);
  5450. exports['default'] = TextTrackMenuItem;
  5451. module.exports = exports['default'];
  5452. },{"../../component.js":65,"../../menu/menu-item.js":103,"../../utils/fn.js":130,"global/document":1,"global/window":2}],88:[function(_dereq_,module,exports){
  5453. /**
  5454. * @file current-time-display.js
  5455. */
  5456. 'use strict';
  5457. exports.__esModule = true;
  5458. 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; } }
  5459. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5460. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5461. 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; }
  5462. var _componentJs = _dereq_('../../component.js');
  5463. var _componentJs2 = _interopRequireDefault(_componentJs);
  5464. var _utilsDomJs = _dereq_('../../utils/dom.js');
  5465. var Dom = _interopRequireWildcard(_utilsDomJs);
  5466. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  5467. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  5468. /**
  5469. * Displays the current time
  5470. *
  5471. * @param {Player|Object} player
  5472. * @param {Object=} options
  5473. * @extends Component
  5474. * @class CurrentTimeDisplay
  5475. */
  5476. var CurrentTimeDisplay = (function (_Component) {
  5477. _inherits(CurrentTimeDisplay, _Component);
  5478. function CurrentTimeDisplay(player, options) {
  5479. _classCallCheck(this, CurrentTimeDisplay);
  5480. _Component.call(this, player, options);
  5481. this.on(player, 'timeupdate', this.updateContent);
  5482. }
  5483. /**
  5484. * Create the component's DOM element
  5485. *
  5486. * @return {Element}
  5487. * @method createEl
  5488. */
  5489. CurrentTimeDisplay.prototype.createEl = function createEl() {
  5490. var el = _Component.prototype.createEl.call(this, 'div', {
  5491. className: 'vjs-current-time vjs-time-control vjs-control'
  5492. });
  5493. this.contentEl_ = Dom.createEl('div', {
  5494. className: 'vjs-current-time-display',
  5495. // label the current time for screen reader users
  5496. innerHTML: '<span class="vjs-control-text">Current Time </span>' + '0:00'
  5497. }, {
  5498. // tell screen readers not to automatically read the time as it changes
  5499. 'aria-live': 'off'
  5500. });
  5501. el.appendChild(this.contentEl_);
  5502. return el;
  5503. };
  5504. /**
  5505. * Update current time display
  5506. *
  5507. * @method updateContent
  5508. */
  5509. CurrentTimeDisplay.prototype.updateContent = function updateContent() {
  5510. // Allows for smooth scrubbing, when player can't keep up.
  5511. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  5512. var localizedText = this.localize('Current Time');
  5513. var formattedTime = _utilsFormatTimeJs2['default'](time, this.player_.duration());
  5514. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime;
  5515. };
  5516. return CurrentTimeDisplay;
  5517. })(_componentJs2['default']);
  5518. _componentJs2['default'].registerComponent('CurrentTimeDisplay', CurrentTimeDisplay);
  5519. exports['default'] = CurrentTimeDisplay;
  5520. module.exports = exports['default'];
  5521. },{"../../component.js":65,"../../utils/dom.js":128,"../../utils/format-time.js":131}],89:[function(_dereq_,module,exports){
  5522. /**
  5523. * @file duration-display.js
  5524. */
  5525. 'use strict';
  5526. exports.__esModule = true;
  5527. 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; } }
  5528. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5529. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5530. 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; }
  5531. var _componentJs = _dereq_('../../component.js');
  5532. var _componentJs2 = _interopRequireDefault(_componentJs);
  5533. var _utilsDomJs = _dereq_('../../utils/dom.js');
  5534. var Dom = _interopRequireWildcard(_utilsDomJs);
  5535. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  5536. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  5537. /**
  5538. * Displays the duration
  5539. *
  5540. * @param {Player|Object} player
  5541. * @param {Object=} options
  5542. * @extends Component
  5543. * @class DurationDisplay
  5544. */
  5545. var DurationDisplay = (function (_Component) {
  5546. _inherits(DurationDisplay, _Component);
  5547. function DurationDisplay(player, options) {
  5548. _classCallCheck(this, DurationDisplay);
  5549. _Component.call(this, player, options);
  5550. // this might need to be changed to 'durationchange' instead of 'timeupdate' eventually,
  5551. // however the durationchange event fires before this.player_.duration() is set,
  5552. // so the value cannot be written out using this method.
  5553. // Once the order of durationchange and this.player_.duration() being set is figured out,
  5554. // this can be updated.
  5555. this.on(player, 'timeupdate', this.updateContent);
  5556. this.on(player, 'loadedmetadata', this.updateContent);
  5557. }
  5558. /**
  5559. * Create the component's DOM element
  5560. *
  5561. * @return {Element}
  5562. * @method createEl
  5563. */
  5564. DurationDisplay.prototype.createEl = function createEl() {
  5565. var el = _Component.prototype.createEl.call(this, 'div', {
  5566. className: 'vjs-duration vjs-time-control vjs-control'
  5567. });
  5568. this.contentEl_ = Dom.createEl('div', {
  5569. className: 'vjs-duration-display',
  5570. // label the duration time for screen reader users
  5571. innerHTML: '<span class="vjs-control-text">' + this.localize('Duration Time') + '</span> 0:00'
  5572. }, {
  5573. // tell screen readers not to automatically read the time as it changes
  5574. 'aria-live': 'off'
  5575. });
  5576. el.appendChild(this.contentEl_);
  5577. return el;
  5578. };
  5579. /**
  5580. * Update duration time display
  5581. *
  5582. * @method updateContent
  5583. */
  5584. DurationDisplay.prototype.updateContent = function updateContent() {
  5585. var duration = this.player_.duration();
  5586. if (duration) {
  5587. var localizedText = this.localize('Duration Time');
  5588. var formattedTime = _utilsFormatTimeJs2['default'](duration);
  5589. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime; // label the duration time for screen reader users
  5590. }
  5591. };
  5592. return DurationDisplay;
  5593. })(_componentJs2['default']);
  5594. _componentJs2['default'].registerComponent('DurationDisplay', DurationDisplay);
  5595. exports['default'] = DurationDisplay;
  5596. module.exports = exports['default'];
  5597. },{"../../component.js":65,"../../utils/dom.js":128,"../../utils/format-time.js":131}],90:[function(_dereq_,module,exports){
  5598. /**
  5599. * @file remaining-time-display.js
  5600. */
  5601. 'use strict';
  5602. exports.__esModule = true;
  5603. 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; } }
  5604. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5605. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5606. 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; }
  5607. var _componentJs = _dereq_('../../component.js');
  5608. var _componentJs2 = _interopRequireDefault(_componentJs);
  5609. var _utilsDomJs = _dereq_('../../utils/dom.js');
  5610. var Dom = _interopRequireWildcard(_utilsDomJs);
  5611. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  5612. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  5613. /**
  5614. * Displays the time left in the video
  5615. *
  5616. * @param {Player|Object} player
  5617. * @param {Object=} options
  5618. * @extends Component
  5619. * @class RemainingTimeDisplay
  5620. */
  5621. var RemainingTimeDisplay = (function (_Component) {
  5622. _inherits(RemainingTimeDisplay, _Component);
  5623. function RemainingTimeDisplay(player, options) {
  5624. _classCallCheck(this, RemainingTimeDisplay);
  5625. _Component.call(this, player, options);
  5626. this.on(player, 'timeupdate', this.updateContent);
  5627. }
  5628. /**
  5629. * Create the component's DOM element
  5630. *
  5631. * @return {Element}
  5632. * @method createEl
  5633. */
  5634. RemainingTimeDisplay.prototype.createEl = function createEl() {
  5635. var el = _Component.prototype.createEl.call(this, 'div', {
  5636. className: 'vjs-remaining-time vjs-time-control vjs-control'
  5637. });
  5638. this.contentEl_ = Dom.createEl('div', {
  5639. className: 'vjs-remaining-time-display',
  5640. // label the remaining time for screen reader users
  5641. innerHTML: '<span class="vjs-control-text">' + this.localize('Remaining Time') + '</span> -0:00'
  5642. }, {
  5643. // tell screen readers not to automatically read the time as it changes
  5644. 'aria-live': 'off'
  5645. });
  5646. el.appendChild(this.contentEl_);
  5647. return el;
  5648. };
  5649. /**
  5650. * Update remaining time display
  5651. *
  5652. * @method updateContent
  5653. */
  5654. RemainingTimeDisplay.prototype.updateContent = function updateContent() {
  5655. if (this.player_.duration()) {
  5656. var localizedText = this.localize('Remaining Time');
  5657. var formattedTime = _utilsFormatTimeJs2['default'](this.player_.remainingTime());
  5658. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> -' + formattedTime;
  5659. }
  5660. // Allows for smooth scrubbing, when player can't keep up.
  5661. // var time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
  5662. // this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
  5663. };
  5664. return RemainingTimeDisplay;
  5665. })(_componentJs2['default']);
  5666. _componentJs2['default'].registerComponent('RemainingTimeDisplay', RemainingTimeDisplay);
  5667. exports['default'] = RemainingTimeDisplay;
  5668. module.exports = exports['default'];
  5669. },{"../../component.js":65,"../../utils/dom.js":128,"../../utils/format-time.js":131}],91:[function(_dereq_,module,exports){
  5670. /**
  5671. * @file time-divider.js
  5672. */
  5673. 'use strict';
  5674. exports.__esModule = true;
  5675. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5676. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5677. 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; }
  5678. var _componentJs = _dereq_('../../component.js');
  5679. var _componentJs2 = _interopRequireDefault(_componentJs);
  5680. /**
  5681. * The separator between the current time and duration.
  5682. * Can be hidden if it's not needed in the design.
  5683. *
  5684. * @param {Player|Object} player
  5685. * @param {Object=} options
  5686. * @extends Component
  5687. * @class TimeDivider
  5688. */
  5689. var TimeDivider = (function (_Component) {
  5690. _inherits(TimeDivider, _Component);
  5691. function TimeDivider() {
  5692. _classCallCheck(this, TimeDivider);
  5693. _Component.apply(this, arguments);
  5694. }
  5695. /**
  5696. * Create the component's DOM element
  5697. *
  5698. * @return {Element}
  5699. * @method createEl
  5700. */
  5701. TimeDivider.prototype.createEl = function createEl() {
  5702. return _Component.prototype.createEl.call(this, 'div', {
  5703. className: 'vjs-time-control vjs-time-divider',
  5704. innerHTML: '<div><span>/</span></div>'
  5705. });
  5706. };
  5707. return TimeDivider;
  5708. })(_componentJs2['default']);
  5709. _componentJs2['default'].registerComponent('TimeDivider', TimeDivider);
  5710. exports['default'] = TimeDivider;
  5711. module.exports = exports['default'];
  5712. },{"../../component.js":65}],92:[function(_dereq_,module,exports){
  5713. /**
  5714. * @file volume-bar.js
  5715. */
  5716. 'use strict';
  5717. exports.__esModule = true;
  5718. 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; } }
  5719. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5720. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5721. 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; }
  5722. var _sliderSliderJs = _dereq_('../../slider/slider.js');
  5723. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs);
  5724. var _componentJs = _dereq_('../../component.js');
  5725. var _componentJs2 = _interopRequireDefault(_componentJs);
  5726. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5727. var Fn = _interopRequireWildcard(_utilsFnJs);
  5728. // Required children
  5729. var _volumeLevelJs = _dereq_('./volume-level.js');
  5730. var _volumeLevelJs2 = _interopRequireDefault(_volumeLevelJs);
  5731. /**
  5732. * The bar that contains the volume level and can be clicked on to adjust the level
  5733. *
  5734. * @param {Player|Object} player
  5735. * @param {Object=} options
  5736. * @extends Slider
  5737. * @class VolumeBar
  5738. */
  5739. var VolumeBar = (function (_Slider) {
  5740. _inherits(VolumeBar, _Slider);
  5741. function VolumeBar(player, options) {
  5742. _classCallCheck(this, VolumeBar);
  5743. _Slider.call(this, player, options);
  5744. this.on(player, 'volumechange', this.updateARIAAttributes);
  5745. player.ready(Fn.bind(this, this.updateARIAAttributes));
  5746. }
  5747. /**
  5748. * Create the component's DOM element
  5749. *
  5750. * @return {Element}
  5751. * @method createEl
  5752. */
  5753. VolumeBar.prototype.createEl = function createEl() {
  5754. return _Slider.prototype.createEl.call(this, 'div', {
  5755. className: 'vjs-volume-bar vjs-slider-bar'
  5756. }, {
  5757. 'aria-label': 'volume level'
  5758. });
  5759. };
  5760. /**
  5761. * Handle mouse move on volume bar
  5762. *
  5763. * @method handleMouseMove
  5764. */
  5765. VolumeBar.prototype.handleMouseMove = function handleMouseMove(event) {
  5766. if (this.player_.muted()) {
  5767. this.player_.muted(false);
  5768. }
  5769. this.player_.volume(this.calculateDistance(event));
  5770. };
  5771. /**
  5772. * Get percent of volume level
  5773. *
  5774. * @retun {Number} Volume level percent
  5775. * @method getPercent
  5776. */
  5777. VolumeBar.prototype.getPercent = function getPercent() {
  5778. if (this.player_.muted()) {
  5779. return 0;
  5780. } else {
  5781. return this.player_.volume();
  5782. }
  5783. };
  5784. /**
  5785. * Increase volume level for keyboard users
  5786. *
  5787. * @method stepForward
  5788. */
  5789. VolumeBar.prototype.stepForward = function stepForward() {
  5790. this.player_.volume(this.player_.volume() + 0.1);
  5791. };
  5792. /**
  5793. * Decrease volume level for keyboard users
  5794. *
  5795. * @method stepBack
  5796. */
  5797. VolumeBar.prototype.stepBack = function stepBack() {
  5798. this.player_.volume(this.player_.volume() - 0.1);
  5799. };
  5800. /**
  5801. * Update ARIA accessibility attributes
  5802. *
  5803. * @method updateARIAAttributes
  5804. */
  5805. VolumeBar.prototype.updateARIAAttributes = function updateARIAAttributes() {
  5806. // Current value of volume bar as a percentage
  5807. var volume = (this.player_.volume() * 100).toFixed(2);
  5808. this.el_.setAttribute('aria-valuenow', volume);
  5809. this.el_.setAttribute('aria-valuetext', volume + '%');
  5810. };
  5811. return VolumeBar;
  5812. })(_sliderSliderJs2['default']);
  5813. VolumeBar.prototype.options_ = {
  5814. children: ['volumeLevel'],
  5815. 'barName': 'volumeLevel'
  5816. };
  5817. VolumeBar.prototype.playerEvent = 'volumechange';
  5818. _componentJs2['default'].registerComponent('VolumeBar', VolumeBar);
  5819. exports['default'] = VolumeBar;
  5820. module.exports = exports['default'];
  5821. },{"../../component.js":65,"../../slider/slider.js":110,"../../utils/fn.js":130,"./volume-level.js":94}],93:[function(_dereq_,module,exports){
  5822. /**
  5823. * @file volume-control.js
  5824. */
  5825. 'use strict';
  5826. exports.__esModule = true;
  5827. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5828. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5829. 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; }
  5830. var _componentJs = _dereq_('../../component.js');
  5831. var _componentJs2 = _interopRequireDefault(_componentJs);
  5832. // Required children
  5833. var _volumeBarJs = _dereq_('./volume-bar.js');
  5834. var _volumeBarJs2 = _interopRequireDefault(_volumeBarJs);
  5835. /**
  5836. * The component for controlling the volume level
  5837. *
  5838. * @param {Player|Object} player
  5839. * @param {Object=} options
  5840. * @extends Component
  5841. * @class VolumeControl
  5842. */
  5843. var VolumeControl = (function (_Component) {
  5844. _inherits(VolumeControl, _Component);
  5845. function VolumeControl(player, options) {
  5846. _classCallCheck(this, VolumeControl);
  5847. _Component.call(this, player, options);
  5848. // hide volume controls when they're not supported by the current tech
  5849. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  5850. this.addClass('vjs-hidden');
  5851. }
  5852. this.on(player, 'loadstart', function () {
  5853. if (player.tech_['featuresVolumeControl'] === false) {
  5854. this.addClass('vjs-hidden');
  5855. } else {
  5856. this.removeClass('vjs-hidden');
  5857. }
  5858. });
  5859. }
  5860. /**
  5861. * Create the component's DOM element
  5862. *
  5863. * @return {Element}
  5864. * @method createEl
  5865. */
  5866. VolumeControl.prototype.createEl = function createEl() {
  5867. return _Component.prototype.createEl.call(this, 'div', {
  5868. className: 'vjs-volume-control vjs-control'
  5869. });
  5870. };
  5871. return VolumeControl;
  5872. })(_componentJs2['default']);
  5873. VolumeControl.prototype.options_ = {
  5874. children: ['volumeBar']
  5875. };
  5876. _componentJs2['default'].registerComponent('VolumeControl', VolumeControl);
  5877. exports['default'] = VolumeControl;
  5878. module.exports = exports['default'];
  5879. },{"../../component.js":65,"./volume-bar.js":92}],94:[function(_dereq_,module,exports){
  5880. /**
  5881. * @file volume-level.js
  5882. */
  5883. 'use strict';
  5884. exports.__esModule = true;
  5885. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5886. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5887. 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; }
  5888. var _componentJs = _dereq_('../../component.js');
  5889. var _componentJs2 = _interopRequireDefault(_componentJs);
  5890. /**
  5891. * Shows volume level
  5892. *
  5893. * @param {Player|Object} player
  5894. * @param {Object=} options
  5895. * @extends Component
  5896. * @class VolumeLevel
  5897. */
  5898. var VolumeLevel = (function (_Component) {
  5899. _inherits(VolumeLevel, _Component);
  5900. function VolumeLevel() {
  5901. _classCallCheck(this, VolumeLevel);
  5902. _Component.apply(this, arguments);
  5903. }
  5904. /**
  5905. * Create the component's DOM element
  5906. *
  5907. * @return {Element}
  5908. * @method createEl
  5909. */
  5910. VolumeLevel.prototype.createEl = function createEl() {
  5911. return _Component.prototype.createEl.call(this, 'div', {
  5912. className: 'vjs-volume-level',
  5913. innerHTML: '<span class="vjs-control-text"></span>'
  5914. });
  5915. };
  5916. return VolumeLevel;
  5917. })(_componentJs2['default']);
  5918. _componentJs2['default'].registerComponent('VolumeLevel', VolumeLevel);
  5919. exports['default'] = VolumeLevel;
  5920. module.exports = exports['default'];
  5921. },{"../../component.js":65}],95:[function(_dereq_,module,exports){
  5922. /**
  5923. * @file volume-menu-button.js
  5924. */
  5925. 'use strict';
  5926. exports.__esModule = true;
  5927. 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; } }
  5928. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5929. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5930. 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; }
  5931. var _buttonJs = _dereq_('../button.js');
  5932. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  5933. var _utilsFnJs = _dereq_('../utils/fn.js');
  5934. var Fn = _interopRequireWildcard(_utilsFnJs);
  5935. var _componentJs = _dereq_('../component.js');
  5936. var _componentJs2 = _interopRequireDefault(_componentJs);
  5937. var _menuMenuJs = _dereq_('../menu/menu.js');
  5938. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  5939. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js');
  5940. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  5941. var _muteToggleJs = _dereq_('./mute-toggle.js');
  5942. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs);
  5943. var _volumeControlVolumeBarJs = _dereq_('./volume-control/volume-bar.js');
  5944. var _volumeControlVolumeBarJs2 = _interopRequireDefault(_volumeControlVolumeBarJs);
  5945. var _globalDocument = _dereq_('global/document');
  5946. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  5947. /**
  5948. * Button for volume menu
  5949. *
  5950. * @param {Player|Object} player
  5951. * @param {Object=} options
  5952. * @extends MenuButton
  5953. * @class VolumeMenuButton
  5954. */
  5955. var VolumeMenuButton = (function (_MenuButton) {
  5956. _inherits(VolumeMenuButton, _MenuButton);
  5957. function VolumeMenuButton(player) {
  5958. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  5959. _classCallCheck(this, VolumeMenuButton);
  5960. // Default to inline
  5961. if (options.inline === undefined) {
  5962. options.inline = true;
  5963. }
  5964. // If the vertical option isn't passed at all, default to true.
  5965. if (options.vertical === undefined) {
  5966. // If an inline volumeMenuButton is used, we should default to using
  5967. // a horizontal slider for obvious reasons.
  5968. if (options.inline) {
  5969. options.vertical = false;
  5970. } else {
  5971. options.vertical = true;
  5972. }
  5973. }
  5974. // The vertical option needs to be set on the volumeBar as well,
  5975. // since that will need to be passed along to the VolumeBar constructor
  5976. options.volumeBar = options.volumeBar || {};
  5977. options.volumeBar.vertical = !!options.vertical;
  5978. _MenuButton.call(this, player, options);
  5979. // Same listeners as MuteToggle
  5980. this.on(player, 'volumechange', this.volumeUpdate);
  5981. this.on(player, 'loadstart', this.volumeUpdate);
  5982. // hide mute toggle if the current tech doesn't support volume control
  5983. function updateVisibility() {
  5984. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  5985. this.addClass('vjs-hidden');
  5986. } else {
  5987. this.removeClass('vjs-hidden');
  5988. }
  5989. }
  5990. updateVisibility.call(this);
  5991. this.on(player, 'loadstart', updateVisibility);
  5992. this.on(this.volumeBar, ['slideractive', 'focus'], function () {
  5993. this.addClass('vjs-slider-active');
  5994. });
  5995. this.on(this.volumeBar, ['sliderinactive', 'blur'], function () {
  5996. this.removeClass('vjs-slider-active');
  5997. });
  5998. }
  5999. /**
  6000. * Allow sub components to stack CSS class names
  6001. *
  6002. * @return {String} The constructed class name
  6003. * @method buildCSSClass
  6004. */
  6005. VolumeMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  6006. var orientationClass = '';
  6007. if (!!this.options_.vertical) {
  6008. orientationClass = 'vjs-volume-menu-button-vertical';
  6009. } else {
  6010. orientationClass = 'vjs-volume-menu-button-horizontal';
  6011. }
  6012. return 'vjs-volume-menu-button ' + _MenuButton.prototype.buildCSSClass.call(this) + ' ' + orientationClass;
  6013. };
  6014. /**
  6015. * Allow sub components to stack CSS class names
  6016. *
  6017. * @return {Menu} The volume menu button
  6018. * @method createMenu
  6019. */
  6020. VolumeMenuButton.prototype.createMenu = function createMenu() {
  6021. var menu = new _menuMenuJs2['default'](this.player_, {
  6022. contentElType: 'div'
  6023. });
  6024. var vb = new _volumeControlVolumeBarJs2['default'](this.player_, this.options_.volumeBar);
  6025. menu.addChild(vb);
  6026. this.volumeBar = vb;
  6027. this.attachVolumeBarEvents();
  6028. return menu;
  6029. };
  6030. /**
  6031. * Handle click on volume menu and calls super
  6032. *
  6033. * @method handleClick
  6034. */
  6035. VolumeMenuButton.prototype.handleClick = function handleClick() {
  6036. _muteToggleJs2['default'].prototype.handleClick.call(this);
  6037. _MenuButton.prototype.handleClick.call(this);
  6038. };
  6039. VolumeMenuButton.prototype.attachVolumeBarEvents = function attachVolumeBarEvents() {
  6040. this.on(['mousedown', 'touchdown'], this.handleMouseDown);
  6041. };
  6042. VolumeMenuButton.prototype.handleMouseDown = function handleMouseDown(event) {
  6043. this.on(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
  6044. this.on(_globalDocument2['default'], ['mouseup', 'touchend'], this.handleMouseUp);
  6045. };
  6046. VolumeMenuButton.prototype.handleMouseUp = function handleMouseUp(event) {
  6047. this.off(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
  6048. };
  6049. return VolumeMenuButton;
  6050. })(_menuMenuButtonJs2['default']);
  6051. VolumeMenuButton.prototype.volumeUpdate = _muteToggleJs2['default'].prototype.update;
  6052. VolumeMenuButton.prototype.controlText_ = 'Mute';
  6053. _componentJs2['default'].registerComponent('VolumeMenuButton', VolumeMenuButton);
  6054. exports['default'] = VolumeMenuButton;
  6055. module.exports = exports['default'];
  6056. },{"../button.js":63,"../component.js":65,"../menu/menu-button.js":102,"../menu/menu.js":104,"../utils/fn.js":130,"./mute-toggle.js":69,"./volume-control/volume-bar.js":92,"global/document":1}],96:[function(_dereq_,module,exports){
  6057. /**
  6058. * @file error-display.js
  6059. */
  6060. 'use strict';
  6061. exports.__esModule = true;
  6062. 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; } }
  6063. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6064. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6065. 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; }
  6066. var _component = _dereq_('./component');
  6067. var _component2 = _interopRequireDefault(_component);
  6068. var _modalDialog = _dereq_('./modal-dialog');
  6069. var _modalDialog2 = _interopRequireDefault(_modalDialog);
  6070. var _utilsDom = _dereq_('./utils/dom');
  6071. var Dom = _interopRequireWildcard(_utilsDom);
  6072. var _utilsMergeOptions = _dereq_('./utils/merge-options');
  6073. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  6074. /**
  6075. * Display that an error has occurred making the video unplayable.
  6076. *
  6077. * @extends ModalDialog
  6078. * @class ErrorDisplay
  6079. */
  6080. var ErrorDisplay = (function (_ModalDialog) {
  6081. _inherits(ErrorDisplay, _ModalDialog);
  6082. /**
  6083. * Constructor for error display modal.
  6084. *
  6085. * @param {Player} player
  6086. * @param {Object} [options]
  6087. */
  6088. function ErrorDisplay(player, options) {
  6089. _classCallCheck(this, ErrorDisplay);
  6090. _ModalDialog.call(this, player, options);
  6091. this.on(player, 'error', this.open);
  6092. }
  6093. /**
  6094. * Include the old class for backward-compatibility.
  6095. *
  6096. * This can be removed in 6.0.
  6097. *
  6098. * @method buildCSSClass
  6099. * @deprecated
  6100. * @return {String}
  6101. */
  6102. ErrorDisplay.prototype.buildCSSClass = function buildCSSClass() {
  6103. return 'vjs-error-display ' + _ModalDialog.prototype.buildCSSClass.call(this);
  6104. };
  6105. /**
  6106. * Generates the modal content based on the player error.
  6107. *
  6108. * @return {String|Null}
  6109. */
  6110. ErrorDisplay.prototype.content = function content() {
  6111. var error = this.player().error();
  6112. return error ? this.localize(error.message) : '';
  6113. };
  6114. return ErrorDisplay;
  6115. })(_modalDialog2['default']);
  6116. ErrorDisplay.prototype.options_ = _utilsMergeOptions2['default'](_modalDialog2['default'].prototype.options_, {
  6117. fillAlways: true,
  6118. temporary: false,
  6119. uncloseable: true
  6120. });
  6121. _component2['default'].registerComponent('ErrorDisplay', ErrorDisplay);
  6122. exports['default'] = ErrorDisplay;
  6123. module.exports = exports['default'];
  6124. },{"./component":65,"./modal-dialog":105,"./utils/dom":128,"./utils/merge-options":134}],97:[function(_dereq_,module,exports){
  6125. /**
  6126. * @file event-target.js
  6127. */
  6128. 'use strict';
  6129. exports.__esModule = true;
  6130. 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; } }
  6131. var _utilsEventsJs = _dereq_('./utils/events.js');
  6132. var Events = _interopRequireWildcard(_utilsEventsJs);
  6133. var EventTarget = function EventTarget() {};
  6134. EventTarget.prototype.allowedEvents_ = {};
  6135. EventTarget.prototype.on = function (type, fn) {
  6136. // Remove the addEventListener alias before calling Events.on
  6137. // so we don't get into an infinite type loop
  6138. var ael = this.addEventListener;
  6139. this.addEventListener = Function.prototype;
  6140. Events.on(this, type, fn);
  6141. this.addEventListener = ael;
  6142. };
  6143. EventTarget.prototype.addEventListener = EventTarget.prototype.on;
  6144. EventTarget.prototype.off = function (type, fn) {
  6145. Events.off(this, type, fn);
  6146. };
  6147. EventTarget.prototype.removeEventListener = EventTarget.prototype.off;
  6148. EventTarget.prototype.one = function (type, fn) {
  6149. Events.one(this, type, fn);
  6150. };
  6151. EventTarget.prototype.trigger = function (event) {
  6152. var type = event.type || event;
  6153. if (typeof event === 'string') {
  6154. event = {
  6155. type: type
  6156. };
  6157. }
  6158. event = Events.fixEvent(event);
  6159. if (this.allowedEvents_[type] && this['on' + type]) {
  6160. this['on' + type](event);
  6161. }
  6162. Events.trigger(this, event);
  6163. };
  6164. // The standard DOM EventTarget.dispatchEvent() is aliased to trigger()
  6165. EventTarget.prototype.dispatchEvent = EventTarget.prototype.trigger;
  6166. exports['default'] = EventTarget;
  6167. module.exports = exports['default'];
  6168. },{"./utils/events.js":129}],98:[function(_dereq_,module,exports){
  6169. 'use strict';
  6170. exports.__esModule = true;
  6171. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6172. var _utilsLog = _dereq_('./utils/log');
  6173. var _utilsLog2 = _interopRequireDefault(_utilsLog);
  6174. /*
  6175. * @file extend.js
  6176. *
  6177. * A combination of node inherits and babel's inherits (after transpile).
  6178. * Both work the same but node adds `super_` to the subClass
  6179. * and Bable adds the superClass as __proto__. Both seem useful.
  6180. */
  6181. var _inherits = function _inherits(subClass, superClass) {
  6182. if (typeof superClass !== 'function' && superClass !== null) {
  6183. throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
  6184. }
  6185. subClass.prototype = Object.create(superClass && superClass.prototype, {
  6186. constructor: {
  6187. value: subClass,
  6188. enumerable: false,
  6189. writable: true,
  6190. configurable: true
  6191. }
  6192. });
  6193. if (superClass) {
  6194. // node
  6195. subClass.super_ = superClass;
  6196. }
  6197. };
  6198. /*
  6199. * Function for subclassing using the same inheritance that
  6200. * videojs uses internally
  6201. * ```js
  6202. * var Button = videojs.getComponent('Button');
  6203. * ```
  6204. * ```js
  6205. * var MyButton = videojs.extend(Button, {
  6206. * constructor: function(player, options) {
  6207. * Button.call(this, player, options);
  6208. * },
  6209. * onClick: function() {
  6210. * // doSomething
  6211. * }
  6212. * });
  6213. * ```
  6214. */
  6215. var extendFn = function extendFn(superClass) {
  6216. var subClassMethods = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  6217. var subClass = function subClass() {
  6218. superClass.apply(this, arguments);
  6219. };
  6220. var methods = {};
  6221. if (typeof subClassMethods === 'object') {
  6222. if (typeof subClassMethods.init === 'function') {
  6223. _utilsLog2['default'].warn('Constructor logic via init() is deprecated; please use constructor() instead.');
  6224. subClassMethods.constructor = subClassMethods.init;
  6225. }
  6226. if (subClassMethods.constructor !== Object.prototype.constructor) {
  6227. subClass = subClassMethods.constructor;
  6228. }
  6229. methods = subClassMethods;
  6230. } else if (typeof subClassMethods === 'function') {
  6231. subClass = subClassMethods;
  6232. }
  6233. _inherits(subClass, superClass);
  6234. // Extend subObj's prototype with functions and other properties from props
  6235. for (var name in methods) {
  6236. if (methods.hasOwnProperty(name)) {
  6237. subClass.prototype[name] = methods[name];
  6238. }
  6239. }
  6240. return subClass;
  6241. };
  6242. exports['default'] = extendFn;
  6243. module.exports = exports['default'];
  6244. },{"./utils/log":133}],99:[function(_dereq_,module,exports){
  6245. /**
  6246. * @file fullscreen-api.js
  6247. */
  6248. 'use strict';
  6249. exports.__esModule = true;
  6250. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6251. var _globalDocument = _dereq_('global/document');
  6252. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  6253. /*
  6254. * Store the browser-specific methods for the fullscreen API
  6255. * @type {Object|undefined}
  6256. * @private
  6257. */
  6258. var FullscreenApi = {};
  6259. // browser API methods
  6260. // map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js
  6261. var apiMap = [
  6262. // Spec: https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
  6263. ['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
  6264. // WebKit
  6265. ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6266. // Old WebKit (Safari 5.1)
  6267. ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6268. // Mozilla
  6269. ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'],
  6270. // Microsoft
  6271. ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];
  6272. var specApi = apiMap[0];
  6273. var browserApi = undefined;
  6274. // determine the supported set of functions
  6275. for (var i = 0; i < apiMap.length; i++) {
  6276. // check for exitFullscreen function
  6277. if (apiMap[i][1] in _globalDocument2['default']) {
  6278. browserApi = apiMap[i];
  6279. break;
  6280. }
  6281. }
  6282. // map the browser API names to the spec API names
  6283. if (browserApi) {
  6284. for (var i = 0; i < browserApi.length; i++) {
  6285. FullscreenApi[specApi[i]] = browserApi[i];
  6286. }
  6287. }
  6288. exports['default'] = FullscreenApi;
  6289. module.exports = exports['default'];
  6290. },{"global/document":1}],100:[function(_dereq_,module,exports){
  6291. /**
  6292. * @file loading-spinner.js
  6293. */
  6294. 'use strict';
  6295. exports.__esModule = true;
  6296. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6297. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6298. 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; }
  6299. var _component = _dereq_('./component');
  6300. var _component2 = _interopRequireDefault(_component);
  6301. /* Loading Spinner
  6302. ================================================================================ */
  6303. /**
  6304. * Loading spinner for waiting events
  6305. *
  6306. * @extends Component
  6307. * @class LoadingSpinner
  6308. */
  6309. var LoadingSpinner = (function (_Component) {
  6310. _inherits(LoadingSpinner, _Component);
  6311. function LoadingSpinner() {
  6312. _classCallCheck(this, LoadingSpinner);
  6313. _Component.apply(this, arguments);
  6314. }
  6315. /**
  6316. * Create the component's DOM element
  6317. *
  6318. * @method createEl
  6319. */
  6320. LoadingSpinner.prototype.createEl = function createEl() {
  6321. return _Component.prototype.createEl.call(this, 'div', {
  6322. className: 'vjs-loading-spinner'
  6323. });
  6324. };
  6325. return LoadingSpinner;
  6326. })(_component2['default']);
  6327. _component2['default'].registerComponent('LoadingSpinner', LoadingSpinner);
  6328. exports['default'] = LoadingSpinner;
  6329. module.exports = exports['default'];
  6330. },{"./component":65}],101:[function(_dereq_,module,exports){
  6331. /**
  6332. * @file media-error.js
  6333. */
  6334. 'use strict';
  6335. exports.__esModule = true;
  6336. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6337. var _objectAssign = _dereq_('object.assign');
  6338. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  6339. /*
  6340. * Custom MediaError to mimic the HTML5 MediaError
  6341. *
  6342. * @param {Number} code The media error code
  6343. */
  6344. var MediaError = function MediaError(code) {
  6345. if (typeof code === 'number') {
  6346. this.code = code;
  6347. } else if (typeof code === 'string') {
  6348. // default code is zero, so this is a custom error
  6349. this.message = code;
  6350. } else if (typeof code === 'object') {
  6351. // object
  6352. _objectAssign2['default'](this, code);
  6353. }
  6354. if (!this.message) {
  6355. this.message = MediaError.defaultMessages[this.code] || '';
  6356. }
  6357. };
  6358. /*
  6359. * The error code that refers two one of the defined
  6360. * MediaError types
  6361. *
  6362. * @type {Number}
  6363. */
  6364. MediaError.prototype.code = 0;
  6365. /*
  6366. * An optional message to be shown with the error.
  6367. * Message is not part of the HTML5 video spec
  6368. * but allows for more informative custom errors.
  6369. *
  6370. * @type {String}
  6371. */
  6372. MediaError.prototype.message = '';
  6373. /*
  6374. * An optional status code that can be set by plugins
  6375. * to allow even more detail about the error.
  6376. * For example the HLS plugin might provide the specific
  6377. * HTTP status code that was returned when the error
  6378. * occurred, then allowing a custom error overlay
  6379. * to display more information.
  6380. *
  6381. * @type {Array}
  6382. */
  6383. MediaError.prototype.status = null;
  6384. MediaError.errorTypes = ['MEDIA_ERR_CUSTOM', // = 0
  6385. 'MEDIA_ERR_ABORTED', // = 1
  6386. 'MEDIA_ERR_NETWORK', // = 2
  6387. 'MEDIA_ERR_DECODE', // = 3
  6388. 'MEDIA_ERR_SRC_NOT_SUPPORTED', // = 4
  6389. 'MEDIA_ERR_ENCRYPTED' // = 5
  6390. ];
  6391. MediaError.defaultMessages = {
  6392. 1: 'You aborted the media playback',
  6393. 2: 'A network error caused the media download to fail part-way.',
  6394. 3: 'The media playback was aborted due to a corruption problem or because the media used features your browser did not support.',
  6395. 4: 'The media could not be loaded, either because the server or network failed or because the format is not supported.',
  6396. 5: 'The media is encrypted and we do not have the keys to decrypt it.'
  6397. };
  6398. // Add types as properties on MediaError
  6399. // e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
  6400. for (var errNum = 0; errNum < MediaError.errorTypes.length; errNum++) {
  6401. MediaError[MediaError.errorTypes[errNum]] = errNum;
  6402. // values should be accessible on both the class and instance
  6403. MediaError.prototype[MediaError.errorTypes[errNum]] = errNum;
  6404. }
  6405. exports['default'] = MediaError;
  6406. module.exports = exports['default'];
  6407. },{"object.assign":45}],102:[function(_dereq_,module,exports){
  6408. /**
  6409. * @file menu-button.js
  6410. */
  6411. 'use strict';
  6412. exports.__esModule = true;
  6413. 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; } }
  6414. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6415. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6416. 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; }
  6417. var _buttonJs = _dereq_('../button.js');
  6418. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  6419. var _componentJs = _dereq_('../component.js');
  6420. var _componentJs2 = _interopRequireDefault(_componentJs);
  6421. var _menuJs = _dereq_('./menu.js');
  6422. var _menuJs2 = _interopRequireDefault(_menuJs);
  6423. var _utilsDomJs = _dereq_('../utils/dom.js');
  6424. var Dom = _interopRequireWildcard(_utilsDomJs);
  6425. var _utilsFnJs = _dereq_('../utils/fn.js');
  6426. var Fn = _interopRequireWildcard(_utilsFnJs);
  6427. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  6428. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  6429. /**
  6430. * A button class with a popup menu
  6431. *
  6432. * @param {Player|Object} player
  6433. * @param {Object=} options
  6434. * @extends Button
  6435. * @class MenuButton
  6436. */
  6437. var MenuButton = (function (_Button) {
  6438. _inherits(MenuButton, _Button);
  6439. function MenuButton(player) {
  6440. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  6441. _classCallCheck(this, MenuButton);
  6442. _Button.call(this, player, options);
  6443. this.update();
  6444. this.on('keydown', this.handleKeyPress);
  6445. this.el_.setAttribute('aria-haspopup', true);
  6446. this.el_.setAttribute('role', 'button');
  6447. }
  6448. /**
  6449. * Update menu
  6450. *
  6451. * @method update
  6452. */
  6453. MenuButton.prototype.update = function update() {
  6454. var menu = this.createMenu();
  6455. if (this.menu) {
  6456. this.removeChild(this.menu);
  6457. }
  6458. this.menu = menu;
  6459. this.addChild(menu);
  6460. /**
  6461. * Track the state of the menu button
  6462. *
  6463. * @type {Boolean}
  6464. * @private
  6465. */
  6466. this.buttonPressed_ = false;
  6467. if (this.items && this.items.length === 0) {
  6468. this.hide();
  6469. } else if (this.items && this.items.length > 1) {
  6470. this.show();
  6471. }
  6472. };
  6473. /**
  6474. * Create menu
  6475. *
  6476. * @return {Menu} The constructed menu
  6477. * @method createMenu
  6478. */
  6479. MenuButton.prototype.createMenu = function createMenu() {
  6480. var menu = new _menuJs2['default'](this.player_);
  6481. // Add a title list item to the top
  6482. if (this.options_.title) {
  6483. menu.contentEl().appendChild(Dom.createEl('li', {
  6484. className: 'vjs-menu-title',
  6485. innerHTML: _utilsToTitleCaseJs2['default'](this.options_.title),
  6486. tabIndex: -1
  6487. }));
  6488. }
  6489. this.items = this['createItems']();
  6490. if (this.items) {
  6491. // Add menu items to the menu
  6492. for (var i = 0; i < this.items.length; i++) {
  6493. menu.addItem(this.items[i]);
  6494. }
  6495. }
  6496. return menu;
  6497. };
  6498. /**
  6499. * Create the list of menu items. Specific to each subclass.
  6500. *
  6501. * @method createItems
  6502. */
  6503. MenuButton.prototype.createItems = function createItems() {};
  6504. /**
  6505. * Create the component's DOM element
  6506. *
  6507. * @return {Element}
  6508. * @method createEl
  6509. */
  6510. MenuButton.prototype.createEl = function createEl() {
  6511. return _Button.prototype.createEl.call(this, 'div', {
  6512. className: this.buildCSSClass()
  6513. });
  6514. };
  6515. /**
  6516. * Allow sub components to stack CSS class names
  6517. *
  6518. * @return {String} The constructed class name
  6519. * @method buildCSSClass
  6520. */
  6521. MenuButton.prototype.buildCSSClass = function buildCSSClass() {
  6522. var menuButtonClass = 'vjs-menu-button';
  6523. // If the inline option is passed, we want to use different styles altogether.
  6524. if (this.options_.inline === true) {
  6525. menuButtonClass += '-inline';
  6526. } else {
  6527. menuButtonClass += '-popup';
  6528. }
  6529. return 'vjs-menu-button ' + menuButtonClass + ' ' + _Button.prototype.buildCSSClass.call(this);
  6530. };
  6531. /**
  6532. * Focus - Add keyboard functionality to element
  6533. * This function is not needed anymore. Instead, the
  6534. * keyboard functionality is handled by
  6535. * treating the button as triggering a submenu.
  6536. * When the button is pressed, the submenu
  6537. * appears. Pressing the button again makes
  6538. * the submenu disappear.
  6539. *
  6540. * @method handleFocus
  6541. */
  6542. MenuButton.prototype.handleFocus = function handleFocus() {};
  6543. /**
  6544. * Can't turn off list display that we turned
  6545. * on with focus, because list would go away.
  6546. *
  6547. * @method handleBlur
  6548. */
  6549. MenuButton.prototype.handleBlur = function handleBlur() {};
  6550. /**
  6551. * When you click the button it adds focus, which
  6552. * will show the menu indefinitely.
  6553. * So we'll remove focus when the mouse leaves the button.
  6554. * Focus is needed for tab navigation.
  6555. * Allow sub components to stack CSS class names
  6556. *
  6557. * @method handleClick
  6558. */
  6559. MenuButton.prototype.handleClick = function handleClick() {
  6560. this.one('mouseout', Fn.bind(this, function () {
  6561. this.menu.unlockShowing();
  6562. this.el_.blur();
  6563. }));
  6564. if (this.buttonPressed_) {
  6565. this.unpressButton();
  6566. } else {
  6567. this.pressButton();
  6568. }
  6569. };
  6570. /**
  6571. * Handle key press on menu
  6572. *
  6573. * @param {Object} Key press event
  6574. * @method handleKeyPress
  6575. */
  6576. MenuButton.prototype.handleKeyPress = function handleKeyPress(event) {
  6577. // Check for space bar (32) or enter (13) keys
  6578. if (event.which === 32 || event.which === 13) {
  6579. if (this.buttonPressed_) {
  6580. this.unpressButton();
  6581. } else {
  6582. this.pressButton();
  6583. }
  6584. event.preventDefault();
  6585. // Check for escape (27) key
  6586. } else if (event.which === 27) {
  6587. if (this.buttonPressed_) {
  6588. this.unpressButton();
  6589. }
  6590. event.preventDefault();
  6591. }
  6592. };
  6593. /**
  6594. * Makes changes based on button pressed
  6595. *
  6596. * @method pressButton
  6597. */
  6598. MenuButton.prototype.pressButton = function pressButton() {
  6599. this.buttonPressed_ = true;
  6600. this.menu.lockShowing();
  6601. this.el_.setAttribute('aria-pressed', true);
  6602. if (this.items && this.items.length > 0) {
  6603. this.items[0].el().focus(); // set the focus to the title of the submenu
  6604. }
  6605. };
  6606. /**
  6607. * Makes changes based on button unpressed
  6608. *
  6609. * @method unpressButton
  6610. */
  6611. MenuButton.prototype.unpressButton = function unpressButton() {
  6612. this.buttonPressed_ = false;
  6613. this.menu.unlockShowing();
  6614. this.el_.setAttribute('aria-pressed', false);
  6615. };
  6616. return MenuButton;
  6617. })(_buttonJs2['default']);
  6618. _componentJs2['default'].registerComponent('MenuButton', MenuButton);
  6619. exports['default'] = MenuButton;
  6620. module.exports = exports['default'];
  6621. },{"../button.js":63,"../component.js":65,"../utils/dom.js":128,"../utils/fn.js":130,"../utils/to-title-case.js":137,"./menu.js":104}],103:[function(_dereq_,module,exports){
  6622. /**
  6623. * @file menu-item.js
  6624. */
  6625. 'use strict';
  6626. exports.__esModule = true;
  6627. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6628. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6629. 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; }
  6630. var _buttonJs = _dereq_('../button.js');
  6631. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  6632. var _componentJs = _dereq_('../component.js');
  6633. var _componentJs2 = _interopRequireDefault(_componentJs);
  6634. var _objectAssign = _dereq_('object.assign');
  6635. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  6636. /**
  6637. * The component for a menu item. `<li>`
  6638. *
  6639. * @param {Player|Object} player
  6640. * @param {Object=} options
  6641. * @extends Button
  6642. * @class MenuItem
  6643. */
  6644. var MenuItem = (function (_Button) {
  6645. _inherits(MenuItem, _Button);
  6646. function MenuItem(player, options) {
  6647. _classCallCheck(this, MenuItem);
  6648. _Button.call(this, player, options);
  6649. this.selected(options['selected']);
  6650. }
  6651. /**
  6652. * Create the component's DOM element
  6653. *
  6654. * @param {String=} type Desc
  6655. * @param {Object=} props Desc
  6656. * @return {Element}
  6657. * @method createEl
  6658. */
  6659. MenuItem.prototype.createEl = function createEl(type, props, attrs) {
  6660. return _Button.prototype.createEl.call(this, 'li', _objectAssign2['default']({
  6661. className: 'vjs-menu-item',
  6662. innerHTML: this.localize(this.options_['label'])
  6663. }, props), attrs);
  6664. };
  6665. /**
  6666. * Handle a click on the menu item, and set it to selected
  6667. *
  6668. * @method handleClick
  6669. */
  6670. MenuItem.prototype.handleClick = function handleClick() {
  6671. this.selected(true);
  6672. };
  6673. /**
  6674. * Set this menu item as selected or not
  6675. *
  6676. * @param {Boolean} selected
  6677. * @method selected
  6678. */
  6679. MenuItem.prototype.selected = function selected(_selected) {
  6680. if (_selected) {
  6681. this.addClass('vjs-selected');
  6682. this.el_.setAttribute('aria-selected', true);
  6683. } else {
  6684. this.removeClass('vjs-selected');
  6685. this.el_.setAttribute('aria-selected', false);
  6686. }
  6687. };
  6688. return MenuItem;
  6689. })(_buttonJs2['default']);
  6690. _componentJs2['default'].registerComponent('MenuItem', MenuItem);
  6691. exports['default'] = MenuItem;
  6692. module.exports = exports['default'];
  6693. },{"../button.js":63,"../component.js":65,"object.assign":45}],104:[function(_dereq_,module,exports){
  6694. /**
  6695. * @file menu.js
  6696. */
  6697. 'use strict';
  6698. exports.__esModule = true;
  6699. 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; } }
  6700. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6701. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6702. 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; }
  6703. var _componentJs = _dereq_('../component.js');
  6704. var _componentJs2 = _interopRequireDefault(_componentJs);
  6705. var _utilsDomJs = _dereq_('../utils/dom.js');
  6706. var Dom = _interopRequireWildcard(_utilsDomJs);
  6707. var _utilsFnJs = _dereq_('../utils/fn.js');
  6708. var Fn = _interopRequireWildcard(_utilsFnJs);
  6709. var _utilsEventsJs = _dereq_('../utils/events.js');
  6710. var Events = _interopRequireWildcard(_utilsEventsJs);
  6711. /**
  6712. * The Menu component is used to build pop up menus, including subtitle and
  6713. * captions selection menus.
  6714. *
  6715. * @extends Component
  6716. * @class Menu
  6717. */
  6718. var Menu = (function (_Component) {
  6719. _inherits(Menu, _Component);
  6720. function Menu() {
  6721. _classCallCheck(this, Menu);
  6722. _Component.apply(this, arguments);
  6723. }
  6724. /**
  6725. * Add a menu item to the menu
  6726. *
  6727. * @param {Object|String} component Component or component type to add
  6728. * @method addItem
  6729. */
  6730. Menu.prototype.addItem = function addItem(component) {
  6731. this.addChild(component);
  6732. component.on('click', Fn.bind(this, function () {
  6733. this.unlockShowing();
  6734. }));
  6735. };
  6736. /**
  6737. * Create the component's DOM element
  6738. *
  6739. * @return {Element}
  6740. * @method createEl
  6741. */
  6742. Menu.prototype.createEl = function createEl() {
  6743. var contentElType = this.options_.contentElType || 'ul';
  6744. this.contentEl_ = Dom.createEl(contentElType, {
  6745. className: 'vjs-menu-content'
  6746. });
  6747. var el = _Component.prototype.createEl.call(this, 'div', {
  6748. append: this.contentEl_,
  6749. className: 'vjs-menu'
  6750. });
  6751. el.appendChild(this.contentEl_);
  6752. // Prevent clicks from bubbling up. Needed for Menu Buttons,
  6753. // where a click on the parent is significant
  6754. Events.on(el, 'click', function (event) {
  6755. event.preventDefault();
  6756. event.stopImmediatePropagation();
  6757. });
  6758. return el;
  6759. };
  6760. return Menu;
  6761. })(_componentJs2['default']);
  6762. _componentJs2['default'].registerComponent('Menu', Menu);
  6763. exports['default'] = Menu;
  6764. module.exports = exports['default'];
  6765. },{"../component.js":65,"../utils/dom.js":128,"../utils/events.js":129,"../utils/fn.js":130}],105:[function(_dereq_,module,exports){
  6766. /**
  6767. * @file modal-dialog.js
  6768. */
  6769. 'use strict';
  6770. exports.__esModule = true;
  6771. 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; } }
  6772. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6773. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6774. 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; }
  6775. var _globalDocument = _dereq_('global/document');
  6776. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  6777. var _utilsDom = _dereq_('./utils/dom');
  6778. var Dom = _interopRequireWildcard(_utilsDom);
  6779. var _utilsFn = _dereq_('./utils/fn');
  6780. var Fn = _interopRequireWildcard(_utilsFn);
  6781. var _utilsLog = _dereq_('./utils/log');
  6782. var _utilsLog2 = _interopRequireDefault(_utilsLog);
  6783. var _component = _dereq_('./component');
  6784. var _component2 = _interopRequireDefault(_component);
  6785. var _closeButton = _dereq_('./close-button');
  6786. var _closeButton2 = _interopRequireDefault(_closeButton);
  6787. var MODAL_CLASS_NAME = 'vjs-modal-dialog';
  6788. var ESC = 27;
  6789. /**
  6790. * The `ModalDialog` displays over the video and its controls, which blocks
  6791. * interaction with the player until it is closed.
  6792. *
  6793. * Modal dialogs include a "Close" button and will close when that button
  6794. * is activated - or when ESC is pressed anywhere.
  6795. *
  6796. * @extends Component
  6797. * @class ModalDialog
  6798. */
  6799. var ModalDialog = (function (_Component) {
  6800. _inherits(ModalDialog, _Component);
  6801. /**
  6802. * Constructor for modals.
  6803. *
  6804. * @param {Player} player
  6805. * @param {Object} [options]
  6806. * @param {Mixed} [options.content=undefined]
  6807. * Provide customized content for this modal.
  6808. *
  6809. * @param {String} [options.description]
  6810. * A text description for the modal, primarily for accessibility.
  6811. *
  6812. * @param {Boolean} [options.fillAlways=false]
  6813. * Normally, modals are automatically filled only the first time
  6814. * they open. This tells the modal to refresh its content
  6815. * every time it opens.
  6816. *
  6817. * @param {String} [options.label]
  6818. * A text label for the modal, primarily for accessibility.
  6819. *
  6820. * @param {Boolean} [options.temporary=true]
  6821. * If `true`, the modal can only be opened once; it will be
  6822. * disposed as soon as it's closed.
  6823. *
  6824. * @param {Boolean} [options.uncloseable=false]
  6825. * If `true`, the user will not be able to close the modal
  6826. * through the UI in the normal ways. Programmatic closing is
  6827. * still possible.
  6828. *
  6829. */
  6830. function ModalDialog(player, options) {
  6831. _classCallCheck(this, ModalDialog);
  6832. _Component.call(this, player, options);
  6833. this.opened_ = this.hasBeenOpened_ = this.hasBeenFilled_ = false;
  6834. this.closeable(!this.options_.uncloseable);
  6835. this.content(this.options_.content);
  6836. // Make sure the contentEl is defined AFTER any children are initialized
  6837. // because we only want the contents of the modal in the contentEl
  6838. // (not the UI elements like the close button).
  6839. this.contentEl_ = Dom.createEl('div', {
  6840. className: MODAL_CLASS_NAME + '-content'
  6841. }, {
  6842. role: 'document'
  6843. });
  6844. this.descEl_ = Dom.createEl('p', {
  6845. className: MODAL_CLASS_NAME + '-description vjs-offscreen',
  6846. id: this.el().getAttribute('aria-describedby')
  6847. });
  6848. Dom.textContent(this.descEl_, this.description());
  6849. this.el_.appendChild(this.descEl_);
  6850. this.el_.appendChild(this.contentEl_);
  6851. }
  6852. /*
  6853. * Modal dialog default options.
  6854. *
  6855. * @type {Object}
  6856. * @private
  6857. */
  6858. /**
  6859. * Create the modal's DOM element
  6860. *
  6861. * @method createEl
  6862. * @return {Element}
  6863. */
  6864. ModalDialog.prototype.createEl = function createEl() {
  6865. return _Component.prototype.createEl.call(this, 'div', {
  6866. className: this.buildCSSClass(),
  6867. tabIndex: -1
  6868. }, {
  6869. 'aria-describedby': this.id() + '_description',
  6870. 'aria-hidden': 'true',
  6871. 'aria-label': this.label(),
  6872. role: 'dialog'
  6873. });
  6874. };
  6875. /**
  6876. * Build the modal's CSS class.
  6877. *
  6878. * @method buildCSSClass
  6879. * @return {String}
  6880. */
  6881. ModalDialog.prototype.buildCSSClass = function buildCSSClass() {
  6882. return MODAL_CLASS_NAME + ' vjs-hidden ' + _Component.prototype.buildCSSClass.call(this);
  6883. };
  6884. /**
  6885. * Handles key presses on the document, looking for ESC, which closes
  6886. * the modal.
  6887. *
  6888. * @method handleKeyPress
  6889. * @param {Event} e
  6890. */
  6891. ModalDialog.prototype.handleKeyPress = function handleKeyPress(e) {
  6892. if (e.which === ESC && this.closeable()) {
  6893. this.close();
  6894. }
  6895. };
  6896. /**
  6897. * Returns the label string for this modal. Primarily used for accessibility.
  6898. *
  6899. * @return {String}
  6900. */
  6901. ModalDialog.prototype.label = function label() {
  6902. return this.options_.label || this.localize('Modal Window');
  6903. };
  6904. /**
  6905. * Returns the description string for this modal. Primarily used for
  6906. * accessibility.
  6907. *
  6908. * @return {String}
  6909. */
  6910. ModalDialog.prototype.description = function description() {
  6911. var desc = this.options_.description || this.localize('This is a modal window.');
  6912. // Append a universal closeability message if the modal is closeable.
  6913. if (this.closeable()) {
  6914. desc += ' ' + this.localize('This modal can be closed by pressing the Escape key or activating the close button.');
  6915. }
  6916. return desc;
  6917. };
  6918. /**
  6919. * Opens the modal.
  6920. *
  6921. * @method open
  6922. * @return {ModalDialog}
  6923. */
  6924. ModalDialog.prototype.open = function open() {
  6925. if (!this.opened_) {
  6926. var player = this.player();
  6927. this.trigger('beforemodalopen');
  6928. this.opened_ = true;
  6929. // Fill content if the modal has never opened before and
  6930. // never been filled.
  6931. if (this.options_.fillAlways || !this.hasBeenOpened_ && !this.hasBeenFilled_) {
  6932. this.fill();
  6933. }
  6934. // If the player was playing, pause it and take note of its previously
  6935. // playing state.
  6936. this.wasPlaying_ = !player.paused();
  6937. if (this.wasPlaying_) {
  6938. player.pause();
  6939. }
  6940. if (this.closeable()) {
  6941. this.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  6942. }
  6943. player.controls(false);
  6944. this.show();
  6945. this.el().setAttribute('aria-hidden', 'false');
  6946. this.trigger('modalopen');
  6947. this.hasBeenOpened_ = true;
  6948. }
  6949. return this;
  6950. };
  6951. /**
  6952. * Whether or not the modal is opened currently.
  6953. *
  6954. * @method opened
  6955. * @param {Boolean} [value]
  6956. * If given, it will open (`true`) or close (`false`) the modal.
  6957. *
  6958. * @return {Boolean}
  6959. */
  6960. ModalDialog.prototype.opened = function opened(value) {
  6961. if (typeof value === 'boolean') {
  6962. this[value ? 'open' : 'close']();
  6963. }
  6964. return this.opened_;
  6965. };
  6966. /**
  6967. * Closes the modal.
  6968. *
  6969. * @method close
  6970. * @return {ModalDialog}
  6971. */
  6972. ModalDialog.prototype.close = function close() {
  6973. if (this.opened_) {
  6974. var player = this.player();
  6975. this.trigger('beforemodalclose');
  6976. this.opened_ = false;
  6977. if (this.wasPlaying_) {
  6978. player.play();
  6979. }
  6980. if (this.closeable()) {
  6981. this.off(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  6982. }
  6983. player.controls(true);
  6984. this.hide();
  6985. this.el().setAttribute('aria-hidden', 'true');
  6986. this.trigger('modalclose');
  6987. if (this.options_.temporary) {
  6988. this.dispose();
  6989. }
  6990. }
  6991. return this;
  6992. };
  6993. /**
  6994. * Whether or not the modal is closeable via the UI.
  6995. *
  6996. * @method closeable
  6997. * @param {Boolean} [value]
  6998. * If given as a Boolean, it will set the `closeable` option.
  6999. *
  7000. * @return {Boolean}
  7001. */
  7002. ModalDialog.prototype.closeable = function closeable(value) {
  7003. if (typeof value === 'boolean') {
  7004. var closeable = this.closeable_ = !!value;
  7005. var _close = this.getChild('closeButton');
  7006. // If this is being made closeable and has no close button, add one.
  7007. if (closeable && !_close) {
  7008. // The close button should be a child of the modal - not its
  7009. // content element, so temporarily change the content element.
  7010. var temp = this.contentEl_;
  7011. this.contentEl_ = this.el_;
  7012. _close = this.addChild('closeButton');
  7013. this.contentEl_ = temp;
  7014. this.on(_close, 'close', this.close);
  7015. }
  7016. // If this is being made uncloseable and has a close button, remove it.
  7017. if (!closeable && _close) {
  7018. this.off(_close, 'close', this.close);
  7019. this.removeChild(_close);
  7020. _close.dispose();
  7021. }
  7022. }
  7023. return this.closeable_;
  7024. };
  7025. /**
  7026. * Fill the modal's content element with the modal's "content" option.
  7027. *
  7028. * The content element will be emptied before this change takes place.
  7029. *
  7030. * @method fill
  7031. * @return {ModalDialog}
  7032. */
  7033. ModalDialog.prototype.fill = function fill() {
  7034. return this.fillWith(this.content());
  7035. };
  7036. /**
  7037. * Fill the modal's content element with arbitrary content.
  7038. *
  7039. * The content element will be emptied before this change takes place.
  7040. *
  7041. * @method fillWith
  7042. * @param {Mixed} [content]
  7043. * The same rules apply to this as apply to the `content` option.
  7044. *
  7045. * @return {ModalDialog}
  7046. */
  7047. ModalDialog.prototype.fillWith = function fillWith(content) {
  7048. var contentEl = this.contentEl();
  7049. var parentEl = contentEl.parentNode;
  7050. var nextSiblingEl = contentEl.nextSibling;
  7051. this.trigger('beforemodalfill');
  7052. this.hasBeenFilled_ = true;
  7053. // Detach the content element from the DOM before performing
  7054. // manipulation to avoid modifying the live DOM multiple times.
  7055. parentEl.removeChild(contentEl);
  7056. this.empty();
  7057. Dom.insertContent(contentEl, content);
  7058. this.trigger('modalfill');
  7059. // Re-inject the re-filled content element.
  7060. if (nextSiblingEl) {
  7061. parentEl.insertBefore(contentEl, nextSiblingEl);
  7062. } else {
  7063. parentEl.appendChild(contentEl);
  7064. }
  7065. return this;
  7066. };
  7067. /**
  7068. * Empties the content element.
  7069. *
  7070. * This happens automatically anytime the modal is filled.
  7071. *
  7072. * @method empty
  7073. * @return {ModalDialog}
  7074. */
  7075. ModalDialog.prototype.empty = function empty() {
  7076. this.trigger('beforemodalempty');
  7077. Dom.emptyEl(this.contentEl());
  7078. this.trigger('modalempty');
  7079. return this;
  7080. };
  7081. /**
  7082. * Gets or sets the modal content, which gets normalized before being
  7083. * rendered into the DOM.
  7084. *
  7085. * This does not update the DOM or fill the modal, but it is called during
  7086. * that process.
  7087. *
  7088. * @method content
  7089. * @param {Mixed} [value]
  7090. * If defined, sets the internal content value to be used on the
  7091. * next call(s) to `fill`. This value is normalized before being
  7092. * inserted. To "clear" the internal content value, pass `null`.
  7093. *
  7094. * @return {Mixed}
  7095. */
  7096. ModalDialog.prototype.content = function content(value) {
  7097. if (typeof value !== 'undefined') {
  7098. this.content_ = value;
  7099. }
  7100. return this.content_;
  7101. };
  7102. return ModalDialog;
  7103. })(_component2['default']);
  7104. ModalDialog.prototype.options_ = {
  7105. temporary: true
  7106. };
  7107. _component2['default'].registerComponent('ModalDialog', ModalDialog);
  7108. exports['default'] = ModalDialog;
  7109. module.exports = exports['default'];
  7110. },{"./close-button":64,"./component":65,"./utils/dom":128,"./utils/fn":130,"./utils/log":133,"global/document":1}],106:[function(_dereq_,module,exports){
  7111. /**
  7112. * @file player.js
  7113. */
  7114. // Subclasses Component
  7115. 'use strict';
  7116. exports.__esModule = true;
  7117. 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; } }
  7118. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7119. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7120. 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; }
  7121. var _componentJs = _dereq_('./component.js');
  7122. var _componentJs2 = _interopRequireDefault(_componentJs);
  7123. var _globalDocument = _dereq_('global/document');
  7124. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  7125. var _globalWindow = _dereq_('global/window');
  7126. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  7127. var _utilsEventsJs = _dereq_('./utils/events.js');
  7128. var Events = _interopRequireWildcard(_utilsEventsJs);
  7129. var _utilsDomJs = _dereq_('./utils/dom.js');
  7130. var Dom = _interopRequireWildcard(_utilsDomJs);
  7131. var _utilsFnJs = _dereq_('./utils/fn.js');
  7132. var Fn = _interopRequireWildcard(_utilsFnJs);
  7133. var _utilsGuidJs = _dereq_('./utils/guid.js');
  7134. var Guid = _interopRequireWildcard(_utilsGuidJs);
  7135. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  7136. var browser = _interopRequireWildcard(_utilsBrowserJs);
  7137. var _utilsLogJs = _dereq_('./utils/log.js');
  7138. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  7139. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
  7140. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  7141. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js');
  7142. var _utilsBufferJs = _dereq_('./utils/buffer.js');
  7143. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js');
  7144. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs);
  7145. var _fullscreenApiJs = _dereq_('./fullscreen-api.js');
  7146. var _fullscreenApiJs2 = _interopRequireDefault(_fullscreenApiJs);
  7147. var _mediaErrorJs = _dereq_('./media-error.js');
  7148. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs);
  7149. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple');
  7150. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple);
  7151. var _objectAssign = _dereq_('object.assign');
  7152. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  7153. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
  7154. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  7155. var _tracksTextTrackListConverterJs = _dereq_('./tracks/text-track-list-converter.js');
  7156. var _tracksTextTrackListConverterJs2 = _interopRequireDefault(_tracksTextTrackListConverterJs);
  7157. // Include required child components (importing also registers them)
  7158. var _techLoaderJs = _dereq_('./tech/loader.js');
  7159. var _techLoaderJs2 = _interopRequireDefault(_techLoaderJs);
  7160. var _posterImageJs = _dereq_('./poster-image.js');
  7161. var _posterImageJs2 = _interopRequireDefault(_posterImageJs);
  7162. var _tracksTextTrackDisplayJs = _dereq_('./tracks/text-track-display.js');
  7163. var _tracksTextTrackDisplayJs2 = _interopRequireDefault(_tracksTextTrackDisplayJs);
  7164. var _loadingSpinnerJs = _dereq_('./loading-spinner.js');
  7165. var _loadingSpinnerJs2 = _interopRequireDefault(_loadingSpinnerJs);
  7166. var _bigPlayButtonJs = _dereq_('./big-play-button.js');
  7167. var _bigPlayButtonJs2 = _interopRequireDefault(_bigPlayButtonJs);
  7168. var _controlBarControlBarJs = _dereq_('./control-bar/control-bar.js');
  7169. var _controlBarControlBarJs2 = _interopRequireDefault(_controlBarControlBarJs);
  7170. var _errorDisplayJs = _dereq_('./error-display.js');
  7171. var _errorDisplayJs2 = _interopRequireDefault(_errorDisplayJs);
  7172. var _tracksTextTrackSettingsJs = _dereq_('./tracks/text-track-settings.js');
  7173. var _tracksTextTrackSettingsJs2 = _interopRequireDefault(_tracksTextTrackSettingsJs);
  7174. var _modalDialog = _dereq_('./modal-dialog');
  7175. var _modalDialog2 = _interopRequireDefault(_modalDialog);
  7176. // Require html5 tech, at least for disposing the original video tag
  7177. var _techTechJs = _dereq_('./tech/tech.js');
  7178. var _techTechJs2 = _interopRequireDefault(_techTechJs);
  7179. var _techHtml5Js = _dereq_('./tech/html5.js');
  7180. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js);
  7181. /**
  7182. * An instance of the `Player` class is created when any of the Video.js setup methods are used to initialize a video.
  7183. * ```js
  7184. * var myPlayer = videojs('example_video_1');
  7185. * ```
  7186. * In the following example, the `data-setup` attribute tells the Video.js library to create a player instance when the library is ready.
  7187. * ```html
  7188. * <video id="example_video_1" data-setup='{}' controls>
  7189. * <source src="my-source.mp4" type="video/mp4">
  7190. * </video>
  7191. * ```
  7192. * After an instance has been created it can be accessed globally using `Video('example_video_1')`.
  7193. *
  7194. * @param {Element} tag The original video tag used for configuring options
  7195. * @param {Object=} options Object of option names and values
  7196. * @param {Function=} ready Ready callback function
  7197. * @extends Component
  7198. * @class Player
  7199. */
  7200. var Player = (function (_Component) {
  7201. _inherits(Player, _Component);
  7202. /**
  7203. * player's constructor function
  7204. *
  7205. * @constructs
  7206. * @method init
  7207. * @param {Element} tag The original video tag used for configuring options
  7208. * @param {Object=} options Player options
  7209. * @param {Function=} ready Ready callback function
  7210. */
  7211. function Player(tag, options, ready) {
  7212. var _this = this;
  7213. _classCallCheck(this, Player);
  7214. // Make sure tag ID exists
  7215. tag.id = tag.id || 'vjs_video_' + Guid.newGUID();
  7216. // Set Options
  7217. // The options argument overrides options set in the video tag
  7218. // which overrides globally set options.
  7219. // This latter part coincides with the load order
  7220. // (tag must exist before Player)
  7221. options = _objectAssign2['default'](Player.getTagSettings(tag), options);
  7222. // Delay the initialization of children because we need to set up
  7223. // player properties first, and can't use `this` before `super()`
  7224. options.initChildren = false;
  7225. // Same with creating the element
  7226. options.createEl = false;
  7227. // we don't want the player to report touch activity on itself
  7228. // see enableTouchActivity in Component
  7229. options.reportTouchActivity = false;
  7230. // Run base component initializing with new options
  7231. _Component.call(this, null, options, ready);
  7232. // if the global option object was accidentally blown away by
  7233. // someone, bail early with an informative error
  7234. if (!this.options_ || !this.options_.techOrder || !this.options_.techOrder.length) {
  7235. throw new Error('No techOrder specified. Did you overwrite ' + 'videojs.options instead of just changing the ' + 'properties you want to override?');
  7236. }
  7237. this.tag = tag; // Store the original tag used to set options
  7238. // Store the tag attributes used to restore html5 element
  7239. this.tagAttributes = tag && Dom.getElAttributes(tag);
  7240. // Update current language
  7241. this.language(this.options_.language);
  7242. // Update Supported Languages
  7243. if (options.languages) {
  7244. (function () {
  7245. // Normalise player option languages to lowercase
  7246. var languagesToLower = {};
  7247. Object.getOwnPropertyNames(options.languages).forEach(function (name) {
  7248. languagesToLower[name.toLowerCase()] = options.languages[name];
  7249. });
  7250. _this.languages_ = languagesToLower;
  7251. })();
  7252. } else {
  7253. this.languages_ = Player.prototype.options_.languages;
  7254. }
  7255. // Cache for video property values.
  7256. this.cache_ = {};
  7257. // Set poster
  7258. this.poster_ = options.poster || '';
  7259. // Set controls
  7260. this.controls_ = !!options.controls;
  7261. // Original tag settings stored in options
  7262. // now remove immediately so native controls don't flash.
  7263. // May be turned back on by HTML5 tech if nativeControlsForTouch is true
  7264. tag.controls = false;
  7265. /*
  7266. * Store the internal state of scrubbing
  7267. *
  7268. * @private
  7269. * @return {Boolean} True if the user is scrubbing
  7270. */
  7271. this.scrubbing_ = false;
  7272. this.el_ = this.createEl();
  7273. // We also want to pass the original player options to each component and plugin
  7274. // as well so they don't need to reach back into the player for options later.
  7275. // We also need to do another copy of this.options_ so we don't end up with
  7276. // an infinite loop.
  7277. var playerOptionsCopy = _utilsMergeOptionsJs2['default'](this.options_);
  7278. // Load plugins
  7279. if (options.plugins) {
  7280. (function () {
  7281. var plugins = options.plugins;
  7282. Object.getOwnPropertyNames(plugins).forEach(function (name) {
  7283. if (typeof this[name] === 'function') {
  7284. this[name](plugins[name]);
  7285. } else {
  7286. _utilsLogJs2['default'].error('Unable to find plugin:', name);
  7287. }
  7288. }, _this);
  7289. })();
  7290. }
  7291. this.options_.playerOptions = playerOptionsCopy;
  7292. this.initChildren();
  7293. // Set isAudio based on whether or not an audio tag was used
  7294. this.isAudio(tag.nodeName.toLowerCase() === 'audio');
  7295. // Update controls className. Can't do this when the controls are initially
  7296. // set because the element doesn't exist yet.
  7297. if (this.controls()) {
  7298. this.addClass('vjs-controls-enabled');
  7299. } else {
  7300. this.addClass('vjs-controls-disabled');
  7301. }
  7302. if (this.isAudio()) {
  7303. this.addClass('vjs-audio');
  7304. }
  7305. if (this.flexNotSupported_()) {
  7306. this.addClass('vjs-no-flex');
  7307. }
  7308. // TODO: Make this smarter. Toggle user state between touching/mousing
  7309. // using events, since devices can have both touch and mouse events.
  7310. // if (browser.TOUCH_ENABLED) {
  7311. // this.addClass('vjs-touch-enabled');
  7312. // }
  7313. // Make player easily findable by ID
  7314. Player.players[this.id_] = this;
  7315. // When the player is first initialized, trigger activity so components
  7316. // like the control bar show themselves if needed
  7317. this.userActive(true);
  7318. this.reportUserActivity();
  7319. this.listenForUserActivity_();
  7320. this.on('fullscreenchange', this.handleFullscreenChange_);
  7321. this.on('stageclick', this.handleStageClick_);
  7322. }
  7323. /*
  7324. * Global player list
  7325. *
  7326. * @type {Object}
  7327. */
  7328. /**
  7329. * Destroys the video player and does any necessary cleanup
  7330. * ```js
  7331. * myPlayer.dispose();
  7332. * ```
  7333. * This is especially helpful if you are dynamically adding and removing videos
  7334. * to/from the DOM.
  7335. *
  7336. * @method dispose
  7337. */
  7338. Player.prototype.dispose = function dispose() {
  7339. this.trigger('dispose');
  7340. // prevent dispose from being called twice
  7341. this.off('dispose');
  7342. if (this.styleEl_ && this.styleEl_.parentNode) {
  7343. this.styleEl_.parentNode.removeChild(this.styleEl_);
  7344. }
  7345. // Kill reference to this player
  7346. Player.players[this.id_] = null;
  7347. if (this.tag && this.tag.player) {
  7348. this.tag.player = null;
  7349. }
  7350. if (this.el_ && this.el_.player) {
  7351. this.el_.player = null;
  7352. }
  7353. if (this.tech_) {
  7354. this.tech_.dispose();
  7355. }
  7356. _Component.prototype.dispose.call(this);
  7357. };
  7358. /**
  7359. * Create the component's DOM element
  7360. *
  7361. * @return {Element}
  7362. * @method createEl
  7363. */
  7364. Player.prototype.createEl = function createEl() {
  7365. var el = this.el_ = _Component.prototype.createEl.call(this, 'div');
  7366. var tag = this.tag;
  7367. // Remove width/height attrs from tag so CSS can make it 100% width/height
  7368. tag.removeAttribute('width');
  7369. tag.removeAttribute('height');
  7370. // Copy over all the attributes from the tag, including ID and class
  7371. // ID will now reference player box, not the video tag
  7372. var attrs = Dom.getElAttributes(tag);
  7373. Object.getOwnPropertyNames(attrs).forEach(function (attr) {
  7374. // workaround so we don't totally break IE7
  7375. // http://stackoverflow.com/questions/3653444/css-styles-not-applied-on-dynamic-elements-in-internet-explorer-7
  7376. if (attr === 'class') {
  7377. el.className = attrs[attr];
  7378. } else {
  7379. el.setAttribute(attr, attrs[attr]);
  7380. }
  7381. });
  7382. // Update tag id/class for use as HTML5 playback tech
  7383. // Might think we should do this after embedding in container so .vjs-tech class
  7384. // doesn't flash 100% width/height, but class only applies with .video-js parent
  7385. tag.playerId = tag.id;
  7386. tag.id += '_html5_api';
  7387. tag.className = 'vjs-tech';
  7388. // Make player findable on elements
  7389. tag.player = el.player = this;
  7390. // Default state of video is paused
  7391. this.addClass('vjs-paused');
  7392. // Add a style element in the player that we'll use to set the width/height
  7393. // of the player in a way that's still overrideable by CSS, just like the
  7394. // video element
  7395. this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions');
  7396. var defaultsStyleEl = Dom.$('.vjs-styles-defaults');
  7397. var head = Dom.$('head');
  7398. head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild);
  7399. // Pass in the width/height/aspectRatio options which will update the style el
  7400. this.width(this.options_.width);
  7401. this.height(this.options_.height);
  7402. this.fluid(this.options_.fluid);
  7403. this.aspectRatio(this.options_.aspectRatio);
  7404. // insertElFirst seems to cause the networkState to flicker from 3 to 2, so
  7405. // keep track of the original for later so we can know if the source originally failed
  7406. tag.initNetworkState_ = tag.networkState;
  7407. // Wrap video tag in div (el/box) container
  7408. if (tag.parentNode) {
  7409. tag.parentNode.insertBefore(el, tag);
  7410. }
  7411. Dom.insertElFirst(tag, el); // Breaks iPhone, fixed in HTML5 setup.
  7412. this.el_ = el;
  7413. return el;
  7414. };
  7415. /**
  7416. * Get/set player width
  7417. *
  7418. * @param {Number=} value Value for width
  7419. * @return {Number} Width when getting
  7420. * @method width
  7421. */
  7422. Player.prototype.width = function width(value) {
  7423. return this.dimension('width', value);
  7424. };
  7425. /**
  7426. * Get/set player height
  7427. *
  7428. * @param {Number=} value Value for height
  7429. * @return {Number} Height when getting
  7430. * @method height
  7431. */
  7432. Player.prototype.height = function height(value) {
  7433. return this.dimension('height', value);
  7434. };
  7435. /**
  7436. * Get/set dimension for player
  7437. *
  7438. * @param {String} dimension Either width or height
  7439. * @param {Number=} value Value for dimension
  7440. * @return {Component}
  7441. * @method dimension
  7442. */
  7443. Player.prototype.dimension = function dimension(_dimension, value) {
  7444. var privDimension = _dimension + '_';
  7445. if (value === undefined) {
  7446. return this[privDimension] || 0;
  7447. }
  7448. if (value === '') {
  7449. // If an empty string is given, reset the dimension to be automatic
  7450. this[privDimension] = undefined;
  7451. } else {
  7452. var parsedVal = parseFloat(value);
  7453. if (isNaN(parsedVal)) {
  7454. _utilsLogJs2['default'].error('Improper value "' + value + '" supplied for for ' + _dimension);
  7455. return this;
  7456. }
  7457. this[privDimension] = parsedVal;
  7458. }
  7459. this.updateStyleEl_();
  7460. return this;
  7461. };
  7462. /**
  7463. * Add/remove the vjs-fluid class
  7464. *
  7465. * @param {Boolean} bool Value of true adds the class, value of false removes the class
  7466. * @method fluid
  7467. */
  7468. Player.prototype.fluid = function fluid(bool) {
  7469. if (bool === undefined) {
  7470. return !!this.fluid_;
  7471. }
  7472. this.fluid_ = !!bool;
  7473. if (bool) {
  7474. this.addClass('vjs-fluid');
  7475. } else {
  7476. this.removeClass('vjs-fluid');
  7477. }
  7478. };
  7479. /**
  7480. * Get/Set the aspect ratio
  7481. *
  7482. * @param {String=} ratio Aspect ratio for player
  7483. * @return aspectRatio
  7484. * @method aspectRatio
  7485. */
  7486. Player.prototype.aspectRatio = function aspectRatio(ratio) {
  7487. if (ratio === undefined) {
  7488. return this.aspectRatio_;
  7489. }
  7490. // Check for width:height format
  7491. if (!/^\d+\:\d+$/.test(ratio)) {
  7492. throw new Error('Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.');
  7493. }
  7494. this.aspectRatio_ = ratio;
  7495. // We're assuming if you set an aspect ratio you want fluid mode,
  7496. // because in fixed mode you could calculate width and height yourself.
  7497. this.fluid(true);
  7498. this.updateStyleEl_();
  7499. };
  7500. /**
  7501. * Update styles of the player element (height, width and aspect ratio)
  7502. *
  7503. * @method updateStyleEl_
  7504. */
  7505. Player.prototype.updateStyleEl_ = function updateStyleEl_() {
  7506. var width = undefined;
  7507. var height = undefined;
  7508. var aspectRatio = undefined;
  7509. var idClass = undefined;
  7510. // The aspect ratio is either used directly or to calculate width and height.
  7511. if (this.aspectRatio_ !== undefined && this.aspectRatio_ !== 'auto') {
  7512. // Use any aspectRatio that's been specifically set
  7513. aspectRatio = this.aspectRatio_;
  7514. } else if (this.videoWidth()) {
  7515. // Otherwise try to get the aspect ratio from the video metadata
  7516. aspectRatio = this.videoWidth() + ':' + this.videoHeight();
  7517. } else {
  7518. // Or use a default. The video element's is 2:1, but 16:9 is more common.
  7519. aspectRatio = '16:9';
  7520. }
  7521. // Get the ratio as a decimal we can use to calculate dimensions
  7522. var ratioParts = aspectRatio.split(':');
  7523. var ratioMultiplier = ratioParts[1] / ratioParts[0];
  7524. if (this.width_ !== undefined) {
  7525. // Use any width that's been specifically set
  7526. width = this.width_;
  7527. } else if (this.height_ !== undefined) {
  7528. // Or calulate the width from the aspect ratio if a height has been set
  7529. width = this.height_ / ratioMultiplier;
  7530. } else {
  7531. // Or use the video's metadata, or use the video el's default of 300
  7532. width = this.videoWidth() || 300;
  7533. }
  7534. if (this.height_ !== undefined) {
  7535. // Use any height that's been specifically set
  7536. height = this.height_;
  7537. } else {
  7538. // Otherwise calculate the height from the ratio and the width
  7539. height = width * ratioMultiplier;
  7540. }
  7541. // Ensure the CSS class is valid by starting with an alpha character
  7542. if (/^[^a-zA-Z]/.test(this.id())) {
  7543. idClass = 'dimensions-' + this.id();
  7544. } else {
  7545. idClass = this.id() + '-dimensions';
  7546. }
  7547. // Ensure the right class is still on the player for the style element
  7548. this.addClass(idClass);
  7549. 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 ');
  7550. };
  7551. /**
  7552. * Load the Media Playback Technology (tech)
  7553. * Load/Create an instance of playback technology including element and API methods
  7554. * And append playback element in player div.
  7555. *
  7556. * @param {String} techName Name of the playback technology
  7557. * @param {String} source Video source
  7558. * @method loadTech_
  7559. * @private
  7560. */
  7561. Player.prototype.loadTech_ = function loadTech_(techName, source) {
  7562. // Pause and remove current playback technology
  7563. if (this.tech_) {
  7564. this.unloadTech_();
  7565. }
  7566. // get rid of the HTML5 video tag as soon as we are using another tech
  7567. if (techName !== 'Html5' && this.tag) {
  7568. _techTechJs2['default'].getTech('Html5').disposeMediaElement(this.tag);
  7569. this.tag.player = null;
  7570. this.tag = null;
  7571. }
  7572. this.techName_ = techName;
  7573. // Turn off API access because we're loading a new tech that might load asynchronously
  7574. this.isReady_ = false;
  7575. // Grab tech-specific options from player options and add source and parent element to use.
  7576. var techOptions = _objectAssign2['default']({
  7577. 'nativeControlsForTouch': this.options_.nativeControlsForTouch,
  7578. 'source': source,
  7579. 'playerId': this.id(),
  7580. 'techId': this.id() + '_' + techName + '_api',
  7581. 'textTracks': this.textTracks_,
  7582. 'autoplay': this.options_.autoplay,
  7583. 'preload': this.options_.preload,
  7584. 'loop': this.options_.loop,
  7585. 'muted': this.options_.muted,
  7586. 'poster': this.poster(),
  7587. 'language': this.language(),
  7588. 'vtt.js': this.options_['vtt.js']
  7589. }, this.options_[techName.toLowerCase()]);
  7590. if (this.tag) {
  7591. techOptions.tag = this.tag;
  7592. }
  7593. if (source) {
  7594. this.currentType_ = source.type;
  7595. if (source.src === this.cache_.src && this.cache_.currentTime > 0) {
  7596. techOptions.startTime = this.cache_.currentTime;
  7597. }
  7598. this.cache_.src = source.src;
  7599. }
  7600. // Initialize tech instance
  7601. var techComponent = _techTechJs2['default'].getTech(techName);
  7602. // Support old behavior of techs being registered as components.
  7603. // Remove once that deprecated behavior is removed.
  7604. if (!techComponent) {
  7605. techComponent = _componentJs2['default'].getComponent(techName);
  7606. }
  7607. this.tech_ = new techComponent(techOptions);
  7608. // player.triggerReady is always async, so don't need this to be async
  7609. this.tech_.ready(Fn.bind(this, this.handleTechReady_), true);
  7610. _tracksTextTrackListConverterJs2['default'].jsonToTextTracks(this.textTracksJson_ || [], this.tech_);
  7611. // Listen to all HTML5-defined events and trigger them on the player
  7612. this.on(this.tech_, 'loadstart', this.handleTechLoadStart_);
  7613. this.on(this.tech_, 'waiting', this.handleTechWaiting_);
  7614. this.on(this.tech_, 'canplay', this.handleTechCanPlay_);
  7615. this.on(this.tech_, 'canplaythrough', this.handleTechCanPlayThrough_);
  7616. this.on(this.tech_, 'playing', this.handleTechPlaying_);
  7617. this.on(this.tech_, 'ended', this.handleTechEnded_);
  7618. this.on(this.tech_, 'seeking', this.handleTechSeeking_);
  7619. this.on(this.tech_, 'seeked', this.handleTechSeeked_);
  7620. this.on(this.tech_, 'play', this.handleTechPlay_);
  7621. this.on(this.tech_, 'firstplay', this.handleTechFirstPlay_);
  7622. this.on(this.tech_, 'pause', this.handleTechPause_);
  7623. this.on(this.tech_, 'progress', this.handleTechProgress_);
  7624. this.on(this.tech_, 'durationchange', this.handleTechDurationChange_);
  7625. this.on(this.tech_, 'fullscreenchange', this.handleTechFullscreenChange_);
  7626. this.on(this.tech_, 'error', this.handleTechError_);
  7627. this.on(this.tech_, 'suspend', this.handleTechSuspend_);
  7628. this.on(this.tech_, 'abort', this.handleTechAbort_);
  7629. this.on(this.tech_, 'emptied', this.handleTechEmptied_);
  7630. this.on(this.tech_, 'stalled', this.handleTechStalled_);
  7631. this.on(this.tech_, 'loadedmetadata', this.handleTechLoadedMetaData_);
  7632. this.on(this.tech_, 'loadeddata', this.handleTechLoadedData_);
  7633. this.on(this.tech_, 'timeupdate', this.handleTechTimeUpdate_);
  7634. this.on(this.tech_, 'ratechange', this.handleTechRateChange_);
  7635. this.on(this.tech_, 'volumechange', this.handleTechVolumeChange_);
  7636. this.on(this.tech_, 'texttrackchange', this.handleTechTextTrackChange_);
  7637. this.on(this.tech_, 'loadedmetadata', this.updateStyleEl_);
  7638. this.on(this.tech_, 'posterchange', this.handleTechPosterChange_);
  7639. this.usingNativeControls(this.techGet_('controls'));
  7640. if (this.controls() && !this.usingNativeControls()) {
  7641. this.addTechControlsListeners_();
  7642. }
  7643. // Add the tech element in the DOM if it was not already there
  7644. // Make sure to not insert the original video element if using Html5
  7645. if (this.tech_.el().parentNode !== this.el() && (techName !== 'Html5' || !this.tag)) {
  7646. Dom.insertElFirst(this.tech_.el(), this.el());
  7647. }
  7648. // Get rid of the original video tag reference after the first tech is loaded
  7649. if (this.tag) {
  7650. this.tag.player = null;
  7651. this.tag = null;
  7652. }
  7653. };
  7654. /**
  7655. * Unload playback technology
  7656. *
  7657. * @method unloadTech_
  7658. * @private
  7659. */
  7660. Player.prototype.unloadTech_ = function unloadTech_() {
  7661. // Save the current text tracks so that we can reuse the same text tracks with the next tech
  7662. this.textTracks_ = this.textTracks();
  7663. this.textTracksJson_ = _tracksTextTrackListConverterJs2['default'].textTracksToJson(this.tech_);
  7664. this.isReady_ = false;
  7665. this.tech_.dispose();
  7666. this.tech_ = false;
  7667. };
  7668. /**
  7669. * Return a reference to the current tech.
  7670. * It will only return a reference to the tech if given an object with the
  7671. * `IWillNotUseThisInPlugins` property on it. This is try and prevent misuse
  7672. * of techs by plugins.
  7673. *
  7674. * @param {Object}
  7675. * @return {Object} The Tech
  7676. * @method tech
  7677. */
  7678. Player.prototype.tech = function tech(safety) {
  7679. if (safety && safety.IWillNotUseThisInPlugins) {
  7680. return this.tech_;
  7681. }
  7682. 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 ';
  7683. _globalWindow2['default'].alert(errorText);
  7684. throw new Error(errorText);
  7685. };
  7686. /**
  7687. * Set up click and touch listeners for the playback element
  7688. *
  7689. * On desktops, a click on the video itself will toggle playback,
  7690. * on a mobile device a click on the video toggles controls.
  7691. * (toggling controls is done by toggling the user state between active and
  7692. * inactive)
  7693. * A tap can signal that a user has become active, or has become inactive
  7694. * e.g. a quick tap on an iPhone movie should reveal the controls. Another
  7695. * quick tap should hide them again (signaling the user is in an inactive
  7696. * viewing state)
  7697. * In addition to this, we still want the user to be considered inactive after
  7698. * a few seconds of inactivity.
  7699. * Note: the only part of iOS interaction we can't mimic with this setup
  7700. * is a touch and hold on the video element counting as activity in order to
  7701. * keep the controls showing, but that shouldn't be an issue. A touch and hold
  7702. * on any controls will still keep the user active
  7703. *
  7704. * @private
  7705. * @method addTechControlsListeners_
  7706. */
  7707. Player.prototype.addTechControlsListeners_ = function addTechControlsListeners_() {
  7708. // Make sure to remove all the previous listeners in case we are called multiple times.
  7709. this.removeTechControlsListeners_();
  7710. // Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
  7711. // trigger mousedown/up.
  7712. // http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
  7713. // Any touch events are set to block the mousedown event from happening
  7714. this.on(this.tech_, 'mousedown', this.handleTechClick_);
  7715. // If the controls were hidden we don't want that to change without a tap event
  7716. // so we'll check if the controls were already showing before reporting user
  7717. // activity
  7718. this.on(this.tech_, 'touchstart', this.handleTechTouchStart_);
  7719. this.on(this.tech_, 'touchmove', this.handleTechTouchMove_);
  7720. this.on(this.tech_, 'touchend', this.handleTechTouchEnd_);
  7721. // The tap listener needs to come after the touchend listener because the tap
  7722. // listener cancels out any reportedUserActivity when setting userActive(false)
  7723. this.on(this.tech_, 'tap', this.handleTechTap_);
  7724. };
  7725. /**
  7726. * Remove the listeners used for click and tap controls. This is needed for
  7727. * toggling to controls disabled, where a tap/touch should do nothing.
  7728. *
  7729. * @method removeTechControlsListeners_
  7730. * @private
  7731. */
  7732. Player.prototype.removeTechControlsListeners_ = function removeTechControlsListeners_() {
  7733. // We don't want to just use `this.off()` because there might be other needed
  7734. // listeners added by techs that extend this.
  7735. this.off(this.tech_, 'tap', this.handleTechTap_);
  7736. this.off(this.tech_, 'touchstart', this.handleTechTouchStart_);
  7737. this.off(this.tech_, 'touchmove', this.handleTechTouchMove_);
  7738. this.off(this.tech_, 'touchend', this.handleTechTouchEnd_);
  7739. this.off(this.tech_, 'mousedown', this.handleTechClick_);
  7740. };
  7741. /**
  7742. * Player waits for the tech to be ready
  7743. *
  7744. * @method handleTechReady_
  7745. * @private
  7746. */
  7747. Player.prototype.handleTechReady_ = function handleTechReady_() {
  7748. this.triggerReady();
  7749. // Keep the same volume as before
  7750. if (this.cache_.volume) {
  7751. this.techCall_('setVolume', this.cache_.volume);
  7752. }
  7753. // Look if the tech found a higher resolution poster while loading
  7754. this.handleTechPosterChange_();
  7755. // Update the duration if available
  7756. this.handleTechDurationChange_();
  7757. // Chrome and Safari both have issues with autoplay.
  7758. // In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
  7759. // In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
  7760. // This fixes both issues. Need to wait for API, so it updates displays correctly
  7761. if (this.src() && this.tag && this.options_.autoplay && this.paused()) {
  7762. delete this.tag.poster; // Chrome Fix. Fixed in Chrome v16.
  7763. this.play();
  7764. }
  7765. };
  7766. /**
  7767. * Fired when the user agent begins looking for media data
  7768. *
  7769. * @private
  7770. * @method handleTechLoadStart_
  7771. */
  7772. Player.prototype.handleTechLoadStart_ = function handleTechLoadStart_() {
  7773. // TODO: Update to use `emptied` event instead. See #1277.
  7774. this.removeClass('vjs-ended');
  7775. // reset the error state
  7776. this.error(null);
  7777. // If it's already playing we want to trigger a firstplay event now.
  7778. // The firstplay event relies on both the play and loadstart events
  7779. // which can happen in any order for a new source
  7780. if (!this.paused()) {
  7781. this.trigger('loadstart');
  7782. this.trigger('firstplay');
  7783. } else {
  7784. // reset the hasStarted state
  7785. this.hasStarted(false);
  7786. this.trigger('loadstart');
  7787. }
  7788. };
  7789. /**
  7790. * Add/remove the vjs-has-started class
  7791. *
  7792. * @param {Boolean} hasStarted The value of true adds the class the value of false remove the class
  7793. * @return {Boolean} Boolean value if has started
  7794. * @private
  7795. * @method hasStarted
  7796. */
  7797. Player.prototype.hasStarted = function hasStarted(_hasStarted) {
  7798. if (_hasStarted !== undefined) {
  7799. // only update if this is a new value
  7800. if (this.hasStarted_ !== _hasStarted) {
  7801. this.hasStarted_ = _hasStarted;
  7802. if (_hasStarted) {
  7803. this.addClass('vjs-has-started');
  7804. // trigger the firstplay event if this newly has played
  7805. this.trigger('firstplay');
  7806. } else {
  7807. this.removeClass('vjs-has-started');
  7808. }
  7809. }
  7810. return this;
  7811. }
  7812. return !!this.hasStarted_;
  7813. };
  7814. /**
  7815. * Fired whenever the media begins or resumes playback
  7816. *
  7817. * @private
  7818. * @method handleTechPlay_
  7819. */
  7820. Player.prototype.handleTechPlay_ = function handleTechPlay_() {
  7821. this.removeClass('vjs-ended');
  7822. this.removeClass('vjs-paused');
  7823. this.addClass('vjs-playing');
  7824. // hide the poster when the user hits play
  7825. // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play
  7826. this.hasStarted(true);
  7827. this.trigger('play');
  7828. };
  7829. /**
  7830. * Fired whenever the media begins waiting
  7831. *
  7832. * @private
  7833. * @method handleTechWaiting_
  7834. */
  7835. Player.prototype.handleTechWaiting_ = function handleTechWaiting_() {
  7836. this.addClass('vjs-waiting');
  7837. this.trigger('waiting');
  7838. };
  7839. /**
  7840. * A handler for events that signal that waiting has ended
  7841. * which is not consistent between browsers. See #1351
  7842. *
  7843. * @private
  7844. * @method handleTechCanPlay_
  7845. */
  7846. Player.prototype.handleTechCanPlay_ = function handleTechCanPlay_() {
  7847. this.removeClass('vjs-waiting');
  7848. this.trigger('canplay');
  7849. };
  7850. /**
  7851. * A handler for events that signal that waiting has ended
  7852. * which is not consistent between browsers. See #1351
  7853. *
  7854. * @private
  7855. * @method handleTechCanPlayThrough_
  7856. */
  7857. Player.prototype.handleTechCanPlayThrough_ = function handleTechCanPlayThrough_() {
  7858. this.removeClass('vjs-waiting');
  7859. this.trigger('canplaythrough');
  7860. };
  7861. /**
  7862. * A handler for events that signal that waiting has ended
  7863. * which is not consistent between browsers. See #1351
  7864. *
  7865. * @private
  7866. * @method handleTechPlaying_
  7867. */
  7868. Player.prototype.handleTechPlaying_ = function handleTechPlaying_() {
  7869. this.removeClass('vjs-waiting');
  7870. this.trigger('playing');
  7871. };
  7872. /**
  7873. * Fired whenever the player is jumping to a new time
  7874. *
  7875. * @private
  7876. * @method handleTechSeeking_
  7877. */
  7878. Player.prototype.handleTechSeeking_ = function handleTechSeeking_() {
  7879. this.addClass('vjs-seeking');
  7880. this.trigger('seeking');
  7881. };
  7882. /**
  7883. * Fired when the player has finished jumping to a new time
  7884. *
  7885. * @private
  7886. * @method handleTechSeeked_
  7887. */
  7888. Player.prototype.handleTechSeeked_ = function handleTechSeeked_() {
  7889. this.removeClass('vjs-seeking');
  7890. this.trigger('seeked');
  7891. };
  7892. /**
  7893. * Fired the first time a video is played
  7894. * Not part of the HLS spec, and we're not sure if this is the best
  7895. * implementation yet, so use sparingly. If you don't have a reason to
  7896. * prevent playback, use `myPlayer.one('play');` instead.
  7897. *
  7898. * @private
  7899. * @method handleTechFirstPlay_
  7900. */
  7901. Player.prototype.handleTechFirstPlay_ = function handleTechFirstPlay_() {
  7902. //If the first starttime attribute is specified
  7903. //then we will start at the given offset in seconds
  7904. if (this.options_.starttime) {
  7905. this.currentTime(this.options_.starttime);
  7906. }
  7907. this.addClass('vjs-has-started');
  7908. this.trigger('firstplay');
  7909. };
  7910. /**
  7911. * Fired whenever the media has been paused
  7912. *
  7913. * @private
  7914. * @method handleTechPause_
  7915. */
  7916. Player.prototype.handleTechPause_ = function handleTechPause_() {
  7917. this.removeClass('vjs-playing');
  7918. this.addClass('vjs-paused');
  7919. this.trigger('pause');
  7920. };
  7921. /**
  7922. * Fired while the user agent is downloading media data
  7923. *
  7924. * @private
  7925. * @method handleTechProgress_
  7926. */
  7927. Player.prototype.handleTechProgress_ = function handleTechProgress_() {
  7928. this.trigger('progress');
  7929. };
  7930. /**
  7931. * Fired when the end of the media resource is reached (currentTime == duration)
  7932. *
  7933. * @private
  7934. * @method handleTechEnded_
  7935. */
  7936. Player.prototype.handleTechEnded_ = function handleTechEnded_() {
  7937. this.addClass('vjs-ended');
  7938. if (this.options_.loop) {
  7939. this.currentTime(0);
  7940. this.play();
  7941. } else if (!this.paused()) {
  7942. this.pause();
  7943. }
  7944. this.trigger('ended');
  7945. };
  7946. /**
  7947. * Fired when the duration of the media resource is first known or changed
  7948. *
  7949. * @private
  7950. * @method handleTechDurationChange_
  7951. */
  7952. Player.prototype.handleTechDurationChange_ = function handleTechDurationChange_() {
  7953. this.duration(this.techGet_('duration'));
  7954. };
  7955. /**
  7956. * Handle a click on the media element to play/pause
  7957. *
  7958. * @param {Object=} event Event object
  7959. * @private
  7960. * @method handleTechClick_
  7961. */
  7962. Player.prototype.handleTechClick_ = function handleTechClick_(event) {
  7963. // We're using mousedown to detect clicks thanks to Flash, but mousedown
  7964. // will also be triggered with right-clicks, so we need to prevent that
  7965. if (event.button !== 0) return;
  7966. // When controls are disabled a click should not toggle playback because
  7967. // the click is considered a control
  7968. if (this.controls()) {
  7969. if (this.paused()) {
  7970. this.play();
  7971. } else {
  7972. this.pause();
  7973. }
  7974. }
  7975. };
  7976. /**
  7977. * Handle a tap on the media element. It will toggle the user
  7978. * activity state, which hides and shows the controls.
  7979. *
  7980. * @private
  7981. * @method handleTechTap_
  7982. */
  7983. Player.prototype.handleTechTap_ = function handleTechTap_() {
  7984. this.userActive(!this.userActive());
  7985. };
  7986. /**
  7987. * Handle touch to start
  7988. *
  7989. * @private
  7990. * @method handleTechTouchStart_
  7991. */
  7992. Player.prototype.handleTechTouchStart_ = function handleTechTouchStart_() {
  7993. this.userWasActive = this.userActive();
  7994. };
  7995. /**
  7996. * Handle touch to move
  7997. *
  7998. * @private
  7999. * @method handleTechTouchMove_
  8000. */
  8001. Player.prototype.handleTechTouchMove_ = function handleTechTouchMove_() {
  8002. if (this.userWasActive) {
  8003. this.reportUserActivity();
  8004. }
  8005. };
  8006. /**
  8007. * Handle touch to end
  8008. *
  8009. * @private
  8010. * @method handleTechTouchEnd_
  8011. */
  8012. Player.prototype.handleTechTouchEnd_ = function handleTechTouchEnd_(event) {
  8013. // Stop the mouse events from also happening
  8014. event.preventDefault();
  8015. };
  8016. /**
  8017. * Fired when the player switches in or out of fullscreen mode
  8018. *
  8019. * @private
  8020. * @method handleFullscreenChange_
  8021. */
  8022. Player.prototype.handleFullscreenChange_ = function handleFullscreenChange_() {
  8023. if (this.isFullscreen()) {
  8024. this.addClass('vjs-fullscreen');
  8025. } else {
  8026. this.removeClass('vjs-fullscreen');
  8027. }
  8028. };
  8029. /**
  8030. * native click events on the SWF aren't triggered on IE11, Win8.1RT
  8031. * use stageclick events triggered from inside the SWF instead
  8032. *
  8033. * @private
  8034. * @method handleStageClick_
  8035. */
  8036. Player.prototype.handleStageClick_ = function handleStageClick_() {
  8037. this.reportUserActivity();
  8038. };
  8039. /**
  8040. * Handle Tech Fullscreen Change
  8041. *
  8042. * @private
  8043. * @method handleTechFullscreenChange_
  8044. */
  8045. Player.prototype.handleTechFullscreenChange_ = function handleTechFullscreenChange_(event, data) {
  8046. if (data) {
  8047. this.isFullscreen(data.isFullscreen);
  8048. }
  8049. this.trigger('fullscreenchange');
  8050. };
  8051. /**
  8052. * Fires when an error occurred during the loading of an audio/video
  8053. *
  8054. * @private
  8055. * @method handleTechError_
  8056. */
  8057. Player.prototype.handleTechError_ = function handleTechError_() {
  8058. var error = this.tech_.error();
  8059. this.error(error && error.code);
  8060. };
  8061. /**
  8062. * Fires when the browser is intentionally not getting media data
  8063. *
  8064. * @private
  8065. * @method handleTechSuspend_
  8066. */
  8067. Player.prototype.handleTechSuspend_ = function handleTechSuspend_() {
  8068. this.trigger('suspend');
  8069. };
  8070. /**
  8071. * Fires when the loading of an audio/video is aborted
  8072. *
  8073. * @private
  8074. * @method handleTechAbort_
  8075. */
  8076. Player.prototype.handleTechAbort_ = function handleTechAbort_() {
  8077. this.trigger('abort');
  8078. };
  8079. /**
  8080. * Fires when the current playlist is empty
  8081. *
  8082. * @private
  8083. * @method handleTechEmptied_
  8084. */
  8085. Player.prototype.handleTechEmptied_ = function handleTechEmptied_() {
  8086. this.trigger('emptied');
  8087. };
  8088. /**
  8089. * Fires when the browser is trying to get media data, but data is not available
  8090. *
  8091. * @private
  8092. * @method handleTechStalled_
  8093. */
  8094. Player.prototype.handleTechStalled_ = function handleTechStalled_() {
  8095. this.trigger('stalled');
  8096. };
  8097. /**
  8098. * Fires when the browser has loaded meta data for the audio/video
  8099. *
  8100. * @private
  8101. * @method handleTechLoadedMetaData_
  8102. */
  8103. Player.prototype.handleTechLoadedMetaData_ = function handleTechLoadedMetaData_() {
  8104. this.trigger('loadedmetadata');
  8105. };
  8106. /**
  8107. * Fires when the browser has loaded the current frame of the audio/video
  8108. *
  8109. * @private
  8110. * @method handleTechLoadedData_
  8111. */
  8112. Player.prototype.handleTechLoadedData_ = function handleTechLoadedData_() {
  8113. this.trigger('loadeddata');
  8114. };
  8115. /**
  8116. * Fires when the current playback position has changed
  8117. *
  8118. * @private
  8119. * @method handleTechTimeUpdate_
  8120. */
  8121. Player.prototype.handleTechTimeUpdate_ = function handleTechTimeUpdate_() {
  8122. this.trigger('timeupdate');
  8123. };
  8124. /**
  8125. * Fires when the playing speed of the audio/video is changed
  8126. *
  8127. * @private
  8128. * @method handleTechRateChange_
  8129. */
  8130. Player.prototype.handleTechRateChange_ = function handleTechRateChange_() {
  8131. this.trigger('ratechange');
  8132. };
  8133. /**
  8134. * Fires when the volume has been changed
  8135. *
  8136. * @private
  8137. * @method handleTechVolumeChange_
  8138. */
  8139. Player.prototype.handleTechVolumeChange_ = function handleTechVolumeChange_() {
  8140. this.trigger('volumechange');
  8141. };
  8142. /**
  8143. * Fires when the text track has been changed
  8144. *
  8145. * @private
  8146. * @method handleTechTextTrackChange_
  8147. */
  8148. Player.prototype.handleTechTextTrackChange_ = function handleTechTextTrackChange_() {
  8149. this.trigger('texttrackchange');
  8150. };
  8151. /**
  8152. * Get object for cached values.
  8153. *
  8154. * @return {Object}
  8155. * @method getCache
  8156. */
  8157. Player.prototype.getCache = function getCache() {
  8158. return this.cache_;
  8159. };
  8160. /**
  8161. * Pass values to the playback tech
  8162. *
  8163. * @param {String=} method Method
  8164. * @param {Object=} arg Argument
  8165. * @private
  8166. * @method techCall_
  8167. */
  8168. Player.prototype.techCall_ = function techCall_(method, arg) {
  8169. // If it's not ready yet, call method when it is
  8170. if (this.tech_ && !this.tech_.isReady_) {
  8171. this.tech_.ready(function () {
  8172. this[method](arg);
  8173. }, true);
  8174. // Otherwise call method now
  8175. } else {
  8176. try {
  8177. this.tech_[method](arg);
  8178. } catch (e) {
  8179. _utilsLogJs2['default'](e);
  8180. throw e;
  8181. }
  8182. }
  8183. };
  8184. /**
  8185. * Get calls can't wait for the tech, and sometimes don't need to.
  8186. *
  8187. * @param {String} method Tech method
  8188. * @return {Method}
  8189. * @private
  8190. * @method techGet_
  8191. */
  8192. Player.prototype.techGet_ = function techGet_(method) {
  8193. if (this.tech_ && this.tech_.isReady_) {
  8194. // Flash likes to die and reload when you hide or reposition it.
  8195. // In these cases the object methods go away and we get errors.
  8196. // When that happens we'll catch the errors and inform tech that it's not ready any more.
  8197. try {
  8198. return this.tech_[method]();
  8199. } catch (e) {
  8200. // When building additional tech libs, an expected method may not be defined yet
  8201. if (this.tech_[method] === undefined) {
  8202. _utilsLogJs2['default']('Video.js: ' + method + ' method not defined for ' + this.techName_ + ' playback technology.', e);
  8203. } else {
  8204. // When a method isn't available on the object it throws a TypeError
  8205. if (e.name === 'TypeError') {
  8206. _utilsLogJs2['default']('Video.js: ' + method + ' unavailable on ' + this.techName_ + ' playback technology element.', e);
  8207. this.tech_.isReady_ = false;
  8208. } else {
  8209. _utilsLogJs2['default'](e);
  8210. }
  8211. }
  8212. throw e;
  8213. }
  8214. }
  8215. return;
  8216. };
  8217. /**
  8218. * start media playback
  8219. * ```js
  8220. * myPlayer.play();
  8221. * ```
  8222. *
  8223. * @return {Player} self
  8224. * @method play
  8225. */
  8226. Player.prototype.play = function play() {
  8227. this.techCall_('play');
  8228. return this;
  8229. };
  8230. /**
  8231. * Pause the video playback
  8232. * ```js
  8233. * myPlayer.pause();
  8234. * ```
  8235. *
  8236. * @return {Player} self
  8237. * @method pause
  8238. */
  8239. Player.prototype.pause = function pause() {
  8240. this.techCall_('pause');
  8241. return this;
  8242. };
  8243. /**
  8244. * Check if the player is paused
  8245. * ```js
  8246. * var isPaused = myPlayer.paused();
  8247. * var isPlaying = !myPlayer.paused();
  8248. * ```
  8249. *
  8250. * @return {Boolean} false if the media is currently playing, or true otherwise
  8251. * @method paused
  8252. */
  8253. Player.prototype.paused = function paused() {
  8254. // The initial state of paused should be true (in Safari it's actually false)
  8255. return this.techGet_('paused') === false ? false : true;
  8256. };
  8257. /**
  8258. * Returns whether or not the user is "scrubbing". Scrubbing is when the user
  8259. * has clicked the progress bar handle and is dragging it along the progress bar.
  8260. *
  8261. * @param {Boolean} isScrubbing True/false the user is scrubbing
  8262. * @return {Boolean} The scrubbing status when getting
  8263. * @return {Object} The player when setting
  8264. * @method scrubbing
  8265. */
  8266. Player.prototype.scrubbing = function scrubbing(isScrubbing) {
  8267. if (isScrubbing !== undefined) {
  8268. this.scrubbing_ = !!isScrubbing;
  8269. if (isScrubbing) {
  8270. this.addClass('vjs-scrubbing');
  8271. } else {
  8272. this.removeClass('vjs-scrubbing');
  8273. }
  8274. return this;
  8275. }
  8276. return this.scrubbing_;
  8277. };
  8278. /**
  8279. * Get or set the current time (in seconds)
  8280. * ```js
  8281. * // get
  8282. * var whereYouAt = myPlayer.currentTime();
  8283. * // set
  8284. * myPlayer.currentTime(120); // 2 minutes into the video
  8285. * ```
  8286. *
  8287. * @param {Number|String=} seconds The time to seek to
  8288. * @return {Number} The time in seconds, when not setting
  8289. * @return {Player} self, when the current time is set
  8290. * @method currentTime
  8291. */
  8292. Player.prototype.currentTime = function currentTime(seconds) {
  8293. if (seconds !== undefined) {
  8294. this.techCall_('setCurrentTime', seconds);
  8295. return this;
  8296. }
  8297. // cache last currentTime and return. default to 0 seconds
  8298. //
  8299. // Caching the currentTime is meant to prevent a massive amount of reads on the tech's
  8300. // currentTime when scrubbing, but may not provide much performance benefit afterall.
  8301. // Should be tested. Also something has to read the actual current time or the cache will
  8302. // never get updated.
  8303. return this.cache_.currentTime = this.techGet_('currentTime') || 0;
  8304. };
  8305. /**
  8306. * Get the length in time of the video in seconds
  8307. * ```js
  8308. * var lengthOfVideo = myPlayer.duration();
  8309. * ```
  8310. * **NOTE**: The video must have started loading before the duration can be
  8311. * known, and in the case of Flash, may not be known until the video starts
  8312. * playing.
  8313. *
  8314. * @param {Number} seconds Duration when setting
  8315. * @return {Number} The duration of the video in seconds when getting
  8316. * @method duration
  8317. */
  8318. Player.prototype.duration = function duration(seconds) {
  8319. if (seconds === undefined) {
  8320. return this.cache_.duration || 0;
  8321. }
  8322. seconds = parseFloat(seconds) || 0;
  8323. // Standardize on Inifity for signaling video is live
  8324. if (seconds < 0) {
  8325. seconds = Infinity;
  8326. }
  8327. if (seconds !== this.cache_.duration) {
  8328. // Cache the last set value for optimized scrubbing (esp. Flash)
  8329. this.cache_.duration = seconds;
  8330. if (seconds === Infinity) {
  8331. this.addClass('vjs-live');
  8332. } else {
  8333. this.removeClass('vjs-live');
  8334. }
  8335. this.trigger('durationchange');
  8336. }
  8337. return this;
  8338. };
  8339. /**
  8340. * Calculates how much time is left.
  8341. * ```js
  8342. * var timeLeft = myPlayer.remainingTime();
  8343. * ```
  8344. * Not a native video element function, but useful
  8345. *
  8346. * @return {Number} The time remaining in seconds
  8347. * @method remainingTime
  8348. */
  8349. Player.prototype.remainingTime = function remainingTime() {
  8350. return this.duration() - this.currentTime();
  8351. };
  8352. // http://dev.w3.org/html5/spec/video.html#dom-media-buffered
  8353. // Buffered returns a timerange object.
  8354. // Kind of like an array of portions of the video that have been downloaded.
  8355. /**
  8356. * Get a TimeRange object with the times of the video that have been downloaded
  8357. * If you just want the percent of the video that's been downloaded,
  8358. * use bufferedPercent.
  8359. * ```js
  8360. * // Number of different ranges of time have been buffered. Usually 1.
  8361. * numberOfRanges = bufferedTimeRange.length,
  8362. * // Time in seconds when the first range starts. Usually 0.
  8363. * firstRangeStart = bufferedTimeRange.start(0),
  8364. * // Time in seconds when the first range ends
  8365. * firstRangeEnd = bufferedTimeRange.end(0),
  8366. * // Length in seconds of the first time range
  8367. * firstRangeLength = firstRangeEnd - firstRangeStart;
  8368. * ```
  8369. *
  8370. * @return {Object} A mock TimeRange object (following HTML spec)
  8371. * @method buffered
  8372. */
  8373. Player.prototype.buffered = function buffered() {
  8374. var buffered = this.techGet_('buffered');
  8375. if (!buffered || !buffered.length) {
  8376. buffered = _utilsTimeRangesJs.createTimeRange(0, 0);
  8377. }
  8378. return buffered;
  8379. };
  8380. /**
  8381. * Get the percent (as a decimal) of the video that's been downloaded
  8382. * ```js
  8383. * var howMuchIsDownloaded = myPlayer.bufferedPercent();
  8384. * ```
  8385. * 0 means none, 1 means all.
  8386. * (This method isn't in the HTML5 spec, but it's very convenient)
  8387. *
  8388. * @return {Number} A decimal between 0 and 1 representing the percent
  8389. * @method bufferedPercent
  8390. */
  8391. Player.prototype.bufferedPercent = function bufferedPercent() {
  8392. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration());
  8393. };
  8394. /**
  8395. * Get the ending time of the last buffered time range
  8396. * This is used in the progress bar to encapsulate all time ranges.
  8397. *
  8398. * @return {Number} The end of the last buffered time range
  8399. * @method bufferedEnd
  8400. */
  8401. Player.prototype.bufferedEnd = function bufferedEnd() {
  8402. var buffered = this.buffered(),
  8403. duration = this.duration(),
  8404. end = buffered.end(buffered.length - 1);
  8405. if (end > duration) {
  8406. end = duration;
  8407. }
  8408. return end;
  8409. };
  8410. /**
  8411. * Get or set the current volume of the media
  8412. * ```js
  8413. * // get
  8414. * var howLoudIsIt = myPlayer.volume();
  8415. * // set
  8416. * myPlayer.volume(0.5); // Set volume to half
  8417. * ```
  8418. * 0 is off (muted), 1.0 is all the way up, 0.5 is half way.
  8419. *
  8420. * @param {Number} percentAsDecimal The new volume as a decimal percent
  8421. * @return {Number} The current volume when getting
  8422. * @return {Player} self when setting
  8423. * @method volume
  8424. */
  8425. Player.prototype.volume = function volume(percentAsDecimal) {
  8426. var vol = undefined;
  8427. if (percentAsDecimal !== undefined) {
  8428. vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); // Force value to between 0 and 1
  8429. this.cache_.volume = vol;
  8430. this.techCall_('setVolume', vol);
  8431. return this;
  8432. }
  8433. // Default to 1 when returning current volume.
  8434. vol = parseFloat(this.techGet_('volume'));
  8435. return isNaN(vol) ? 1 : vol;
  8436. };
  8437. /**
  8438. * Get the current muted state, or turn mute on or off
  8439. * ```js
  8440. * // get
  8441. * var isVolumeMuted = myPlayer.muted();
  8442. * // set
  8443. * myPlayer.muted(true); // mute the volume
  8444. * ```
  8445. *
  8446. * @param {Boolean=} muted True to mute, false to unmute
  8447. * @return {Boolean} True if mute is on, false if not when getting
  8448. * @return {Player} self when setting mute
  8449. * @method muted
  8450. */
  8451. Player.prototype.muted = function muted(_muted) {
  8452. if (_muted !== undefined) {
  8453. this.techCall_('setMuted', _muted);
  8454. return this;
  8455. }
  8456. return this.techGet_('muted') || false; // Default to false
  8457. };
  8458. // Check if current tech can support native fullscreen
  8459. // (e.g. with built in controls like iOS, so not our flash swf)
  8460. /**
  8461. * Check to see if fullscreen is supported
  8462. *
  8463. * @return {Boolean}
  8464. * @method supportsFullScreen
  8465. */
  8466. Player.prototype.supportsFullScreen = function supportsFullScreen() {
  8467. return this.techGet_('supportsFullScreen') || false;
  8468. };
  8469. /**
  8470. * Check if the player is in fullscreen mode
  8471. * ```js
  8472. * // get
  8473. * var fullscreenOrNot = myPlayer.isFullscreen();
  8474. * // set
  8475. * myPlayer.isFullscreen(true); // tell the player it's in fullscreen
  8476. * ```
  8477. * NOTE: As of the latest HTML5 spec, isFullscreen is no longer an official
  8478. * property and instead document.fullscreenElement is used. But isFullscreen is
  8479. * still a valuable property for internal player workings.
  8480. *
  8481. * @param {Boolean=} isFS Update the player's fullscreen state
  8482. * @return {Boolean} true if fullscreen false if not when getting
  8483. * @return {Player} self when setting
  8484. * @method isFullscreen
  8485. */
  8486. Player.prototype.isFullscreen = function isFullscreen(isFS) {
  8487. if (isFS !== undefined) {
  8488. this.isFullscreen_ = !!isFS;
  8489. return this;
  8490. }
  8491. return !!this.isFullscreen_;
  8492. };
  8493. /**
  8494. * Increase the size of the video to full screen
  8495. * ```js
  8496. * myPlayer.requestFullscreen();
  8497. * ```
  8498. * In some browsers, full screen is not supported natively, so it enters
  8499. * "full window mode", where the video fills the browser window.
  8500. * In browsers and devices that support native full screen, sometimes the
  8501. * browser's default controls will be shown, and not the Video.js custom skin.
  8502. * This includes most mobile devices (iOS, Android) and older versions of
  8503. * Safari.
  8504. *
  8505. * @return {Player} self
  8506. * @method requestFullscreen
  8507. */
  8508. Player.prototype.requestFullscreen = function requestFullscreen() {
  8509. var fsApi = _fullscreenApiJs2['default'];
  8510. this.isFullscreen(true);
  8511. if (fsApi.requestFullscreen) {
  8512. // the browser supports going fullscreen at the element level so we can
  8513. // take the controls fullscreen as well as the video
  8514. // Trigger fullscreenchange event after change
  8515. // We have to specifically add this each time, and remove
  8516. // when canceling fullscreen. Otherwise if there's multiple
  8517. // players on a page, they would all be reacting to the same fullscreen
  8518. // events
  8519. Events.on(_globalDocument2['default'], fsApi.fullscreenchange, Fn.bind(this, function documentFullscreenChange(e) {
  8520. this.isFullscreen(_globalDocument2['default'][fsApi.fullscreenElement]);
  8521. // If cancelling fullscreen, remove event listener.
  8522. if (this.isFullscreen() === false) {
  8523. Events.off(_globalDocument2['default'], fsApi.fullscreenchange, documentFullscreenChange);
  8524. }
  8525. this.trigger('fullscreenchange');
  8526. }));
  8527. this.el_[fsApi.requestFullscreen]();
  8528. } else if (this.tech_.supportsFullScreen()) {
  8529. // we can't take the video.js controls fullscreen but we can go fullscreen
  8530. // with native controls
  8531. this.techCall_('enterFullScreen');
  8532. } else {
  8533. // fullscreen isn't supported so we'll just stretch the video element to
  8534. // fill the viewport
  8535. this.enterFullWindow();
  8536. this.trigger('fullscreenchange');
  8537. }
  8538. return this;
  8539. };
  8540. /**
  8541. * Return the video to its normal size after having been in full screen mode
  8542. * ```js
  8543. * myPlayer.exitFullscreen();
  8544. * ```
  8545. *
  8546. * @return {Player} self
  8547. * @method exitFullscreen
  8548. */
  8549. Player.prototype.exitFullscreen = function exitFullscreen() {
  8550. var fsApi = _fullscreenApiJs2['default'];
  8551. this.isFullscreen(false);
  8552. // Check for browser element fullscreen support
  8553. if (fsApi.requestFullscreen) {
  8554. _globalDocument2['default'][fsApi.exitFullscreen]();
  8555. } else if (this.tech_.supportsFullScreen()) {
  8556. this.techCall_('exitFullScreen');
  8557. } else {
  8558. this.exitFullWindow();
  8559. this.trigger('fullscreenchange');
  8560. }
  8561. return this;
  8562. };
  8563. /**
  8564. * When fullscreen isn't supported we can stretch the video container to as wide as the browser will let us.
  8565. *
  8566. * @method enterFullWindow
  8567. */
  8568. Player.prototype.enterFullWindow = function enterFullWindow() {
  8569. this.isFullWindow = true;
  8570. // Storing original doc overflow value to return to when fullscreen is off
  8571. this.docOrigOverflow = _globalDocument2['default'].documentElement.style.overflow;
  8572. // Add listener for esc key to exit fullscreen
  8573. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.fullWindowOnEscKey));
  8574. // Hide any scroll bars
  8575. _globalDocument2['default'].documentElement.style.overflow = 'hidden';
  8576. // Apply fullscreen styles
  8577. Dom.addElClass(_globalDocument2['default'].body, 'vjs-full-window');
  8578. this.trigger('enterFullWindow');
  8579. };
  8580. /**
  8581. * Check for call to either exit full window or full screen on ESC key
  8582. *
  8583. * @param {String} event Event to check for key press
  8584. * @method fullWindowOnEscKey
  8585. */
  8586. Player.prototype.fullWindowOnEscKey = function fullWindowOnEscKey(event) {
  8587. if (event.keyCode === 27) {
  8588. if (this.isFullscreen() === true) {
  8589. this.exitFullscreen();
  8590. } else {
  8591. this.exitFullWindow();
  8592. }
  8593. }
  8594. };
  8595. /**
  8596. * Exit full window
  8597. *
  8598. * @method exitFullWindow
  8599. */
  8600. Player.prototype.exitFullWindow = function exitFullWindow() {
  8601. this.isFullWindow = false;
  8602. Events.off(_globalDocument2['default'], 'keydown', this.fullWindowOnEscKey);
  8603. // Unhide scroll bars.
  8604. _globalDocument2['default'].documentElement.style.overflow = this.docOrigOverflow;
  8605. // Remove fullscreen styles
  8606. Dom.removeElClass(_globalDocument2['default'].body, 'vjs-full-window');
  8607. // Resize the box, controller, and poster to original sizes
  8608. // this.positionAll();
  8609. this.trigger('exitFullWindow');
  8610. };
  8611. /**
  8612. * Check whether the player can play a given mimetype
  8613. *
  8614. * @param {String} type The mimetype to check
  8615. * @return {String} 'probably', 'maybe', or '' (empty string)
  8616. * @method canPlayType
  8617. */
  8618. Player.prototype.canPlayType = function canPlayType(type) {
  8619. var can = undefined;
  8620. // Loop through each playback technology in the options order
  8621. for (var i = 0, j = this.options_.techOrder; i < j.length; i++) {
  8622. var techName = _utilsToTitleCaseJs2['default'](j[i]);
  8623. var tech = _techTechJs2['default'].getTech(techName);
  8624. // Support old behavior of techs being registered as components.
  8625. // Remove once that deprecated behavior is removed.
  8626. if (!tech) {
  8627. tech = _componentJs2['default'].getComponent(techName);
  8628. }
  8629. // Check if the current tech is defined before continuing
  8630. if (!tech) {
  8631. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
  8632. continue;
  8633. }
  8634. // Check if the browser supports this technology
  8635. if (tech.isSupported()) {
  8636. can = tech.canPlayType(type);
  8637. if (can) {
  8638. return can;
  8639. }
  8640. }
  8641. }
  8642. return '';
  8643. };
  8644. /**
  8645. * Select source based on tech-order or source-order
  8646. * Uses source-order selection if `options.sourceOrder` is truthy. Otherwise,
  8647. * defaults to tech-order selection
  8648. *
  8649. * @param {Array} sources The sources for a media asset
  8650. * @return {Object|Boolean} Object of source and tech order, otherwise false
  8651. * @method selectSource
  8652. */
  8653. Player.prototype.selectSource = function selectSource(sources) {
  8654. // Get only the techs specified in `techOrder` that exist and are supported by the
  8655. // current platform
  8656. var techs = this.options_.techOrder.map(_utilsToTitleCaseJs2['default']).map(function (techName) {
  8657. // `Component.getComponent(...)` is for support of old behavior of techs
  8658. // being registered as components.
  8659. // Remove once that deprecated behavior is removed.
  8660. return [techName, _techTechJs2['default'].getTech(techName) || _componentJs2['default'].getComponent(techName)];
  8661. }).filter(function (_ref) {
  8662. var techName = _ref[0];
  8663. var tech = _ref[1];
  8664. // Check if the current tech is defined before continuing
  8665. if (tech) {
  8666. // Check if the browser supports this technology
  8667. return tech.isSupported();
  8668. }
  8669. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
  8670. return false;
  8671. });
  8672. // Iterate over each `innerArray` element once per `outerArray` element and execute
  8673. // `tester` with both. If `tester` returns a non-falsy value, exit early and return
  8674. // that value.
  8675. var findFirstPassingTechSourcePair = function findFirstPassingTechSourcePair(outerArray, innerArray, tester) {
  8676. var found = undefined;
  8677. outerArray.some(function (outerChoice) {
  8678. return innerArray.some(function (innerChoice) {
  8679. found = tester(outerChoice, innerChoice);
  8680. if (found) {
  8681. return true;
  8682. }
  8683. });
  8684. });
  8685. return found;
  8686. };
  8687. var foundSourceAndTech = undefined;
  8688. var flip = function flip(fn) {
  8689. return function (a, b) {
  8690. return fn(b, a);
  8691. };
  8692. };
  8693. var finder = function finder(_ref2, source) {
  8694. var techName = _ref2[0];
  8695. var tech = _ref2[1];
  8696. if (tech.canPlaySource(source)) {
  8697. return { source: source, tech: techName };
  8698. }
  8699. };
  8700. // Depending on the truthiness of `options.sourceOrder`, we swap the order of techs and sources
  8701. // to select from them based on their priority.
  8702. if (this.options_.sourceOrder) {
  8703. // Source-first ordering
  8704. foundSourceAndTech = findFirstPassingTechSourcePair(sources, techs, flip(finder));
  8705. } else {
  8706. // Tech-first ordering
  8707. foundSourceAndTech = findFirstPassingTechSourcePair(techs, sources, finder);
  8708. }
  8709. return foundSourceAndTech || false;
  8710. };
  8711. /**
  8712. * The source function updates the video source
  8713. * There are three types of variables you can pass as the argument.
  8714. * **URL String**: A URL to the the video file. Use this method if you are sure
  8715. * the current playback technology (HTML5/Flash) can support the source you
  8716. * provide. Currently only MP4 files can be used in both HTML5 and Flash.
  8717. * ```js
  8718. * myPlayer.src("http://www.example.com/path/to/video.mp4");
  8719. * ```
  8720. * **Source Object (or element):* * A javascript object containing information
  8721. * about the source file. Use this method if you want the player to determine if
  8722. * it can support the file using the type information.
  8723. * ```js
  8724. * myPlayer.src({ type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" });
  8725. * ```
  8726. * **Array of Source Objects:* * To provide multiple versions of the source so
  8727. * that it can be played using HTML5 across browsers you can use an array of
  8728. * source objects. Video.js will detect which version is supported and load that
  8729. * file.
  8730. * ```js
  8731. * myPlayer.src([
  8732. * { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" },
  8733. * { type: "video/webm", src: "http://www.example.com/path/to/video.webm" },
  8734. * { type: "video/ogg", src: "http://www.example.com/path/to/video.ogv" }
  8735. * ]);
  8736. * ```
  8737. *
  8738. * @param {String|Object|Array=} source The source URL, object, or array of sources
  8739. * @return {String} The current video source when getting
  8740. * @return {String} The player when setting
  8741. * @method src
  8742. */
  8743. Player.prototype.src = function src(source) {
  8744. if (source === undefined) {
  8745. return this.techGet_('src');
  8746. }
  8747. var currentTech = _techTechJs2['default'].getTech(this.techName_);
  8748. // Support old behavior of techs being registered as components.
  8749. // Remove once that deprecated behavior is removed.
  8750. if (!currentTech) {
  8751. currentTech = _componentJs2['default'].getComponent(this.techName_);
  8752. }
  8753. // case: Array of source objects to choose from and pick the best to play
  8754. if (Array.isArray(source)) {
  8755. this.sourceList_(source);
  8756. // case: URL String (http://myvideo...)
  8757. } else if (typeof source === 'string') {
  8758. // create a source object from the string
  8759. this.src({ src: source });
  8760. // case: Source object { src: '', type: '' ... }
  8761. } else if (source instanceof Object) {
  8762. // check if the source has a type and the loaded tech cannot play the source
  8763. // if there's no type we'll just try the current tech
  8764. if (source.type && !currentTech.canPlaySource(source)) {
  8765. // create a source list with the current source and send through
  8766. // the tech loop to check for a compatible technology
  8767. this.sourceList_([source]);
  8768. } else {
  8769. this.cache_.src = source.src;
  8770. this.currentType_ = source.type || '';
  8771. // wait until the tech is ready to set the source
  8772. this.ready(function () {
  8773. // The setSource tech method was added with source handlers
  8774. // so older techs won't support it
  8775. // We need to check the direct prototype for the case where subclasses
  8776. // of the tech do not support source handlers
  8777. if (currentTech.prototype.hasOwnProperty('setSource')) {
  8778. this.techCall_('setSource', source);
  8779. } else {
  8780. this.techCall_('src', source.src);
  8781. }
  8782. if (this.options_.preload === 'auto') {
  8783. this.load();
  8784. }
  8785. if (this.options_.autoplay) {
  8786. this.play();
  8787. }
  8788. // Set the source synchronously if possible (#2326)
  8789. }, true);
  8790. }
  8791. }
  8792. return this;
  8793. };
  8794. /**
  8795. * Handle an array of source objects
  8796. *
  8797. * @param {Array} sources Array of source objects
  8798. * @private
  8799. * @method sourceList_
  8800. */
  8801. Player.prototype.sourceList_ = function sourceList_(sources) {
  8802. var sourceTech = this.selectSource(sources);
  8803. if (sourceTech) {
  8804. if (sourceTech.tech === this.techName_) {
  8805. // if this technology is already loaded, set the source
  8806. this.src(sourceTech.source);
  8807. } else {
  8808. // load this technology with the chosen source
  8809. this.loadTech_(sourceTech.tech, sourceTech.source);
  8810. }
  8811. } else {
  8812. // We need to wrap this in a timeout to give folks a chance to add error event handlers
  8813. this.setTimeout(function () {
  8814. this.error({ code: 4, message: this.localize(this.options_.notSupportedMessage) });
  8815. }, 0);
  8816. // we could not find an appropriate tech, but let's still notify the delegate that this is it
  8817. // this needs a better comment about why this is needed
  8818. this.triggerReady();
  8819. }
  8820. };
  8821. /**
  8822. * Begin loading the src data.
  8823. *
  8824. * @return {Player} Returns the player
  8825. * @method load
  8826. */
  8827. Player.prototype.load = function load() {
  8828. this.techCall_('load');
  8829. return this;
  8830. };
  8831. /**
  8832. * Reset the player. Loads the first tech in the techOrder,
  8833. * and calls `reset` on the tech`.
  8834. *
  8835. * @return {Player} Returns the player
  8836. * @method reset
  8837. */
  8838. Player.prototype.reset = function reset() {
  8839. this.loadTech_(_utilsToTitleCaseJs2['default'](this.options_.techOrder[0]), null);
  8840. this.techCall_('reset');
  8841. return this;
  8842. };
  8843. /**
  8844. * Returns the fully qualified URL of the current source value e.g. http://mysite.com/video.mp4
  8845. * Can be used in conjuction with `currentType` to assist in rebuilding the current source object.
  8846. *
  8847. * @return {String} The current source
  8848. * @method currentSrc
  8849. */
  8850. Player.prototype.currentSrc = function currentSrc() {
  8851. return this.techGet_('currentSrc') || this.cache_.src || '';
  8852. };
  8853. /**
  8854. * Get the current source type e.g. video/mp4
  8855. * This can allow you rebuild the current source object so that you could load the same
  8856. * source and tech later
  8857. *
  8858. * @return {String} The source MIME type
  8859. * @method currentType
  8860. */
  8861. Player.prototype.currentType = function currentType() {
  8862. return this.currentType_ || '';
  8863. };
  8864. /**
  8865. * Get or set the preload attribute
  8866. *
  8867. * @param {Boolean} value Boolean to determine if preload should be used
  8868. * @return {String} The preload attribute value when getting
  8869. * @return {Player} Returns the player when setting
  8870. * @method preload
  8871. */
  8872. Player.prototype.preload = function preload(value) {
  8873. if (value !== undefined) {
  8874. this.techCall_('setPreload', value);
  8875. this.options_.preload = value;
  8876. return this;
  8877. }
  8878. return this.techGet_('preload');
  8879. };
  8880. /**
  8881. * Get or set the autoplay attribute.
  8882. *
  8883. * @param {Boolean} value Boolean to determine if video should autoplay
  8884. * @return {String} The autoplay attribute value when getting
  8885. * @return {Player} Returns the player when setting
  8886. * @method autoplay
  8887. */
  8888. Player.prototype.autoplay = function autoplay(value) {
  8889. if (value !== undefined) {
  8890. this.techCall_('setAutoplay', value);
  8891. this.options_.autoplay = value;
  8892. return this;
  8893. }
  8894. return this.techGet_('autoplay', value);
  8895. };
  8896. /**
  8897. * Get or set the loop attribute on the video element.
  8898. *
  8899. * @param {Boolean} value Boolean to determine if video should loop
  8900. * @return {String} The loop attribute value when getting
  8901. * @return {Player} Returns the player when setting
  8902. * @method loop
  8903. */
  8904. Player.prototype.loop = function loop(value) {
  8905. if (value !== undefined) {
  8906. this.techCall_('setLoop', value);
  8907. this.options_['loop'] = value;
  8908. return this;
  8909. }
  8910. return this.techGet_('loop');
  8911. };
  8912. /**
  8913. * Get or set the poster image source url
  8914. *
  8915. * ##### EXAMPLE:
  8916. * ```js
  8917. * // get
  8918. * var currentPoster = myPlayer.poster();
  8919. * // set
  8920. * myPlayer.poster('http://example.com/myImage.jpg');
  8921. * ```
  8922. *
  8923. * @param {String=} src Poster image source URL
  8924. * @return {String} poster URL when getting
  8925. * @return {Player} self when setting
  8926. * @method poster
  8927. */
  8928. Player.prototype.poster = function poster(src) {
  8929. if (src === undefined) {
  8930. return this.poster_;
  8931. }
  8932. // The correct way to remove a poster is to set as an empty string
  8933. // other falsey values will throw errors
  8934. if (!src) {
  8935. src = '';
  8936. }
  8937. // update the internal poster variable
  8938. this.poster_ = src;
  8939. // update the tech's poster
  8940. this.techCall_('setPoster', src);
  8941. // alert components that the poster has been set
  8942. this.trigger('posterchange');
  8943. return this;
  8944. };
  8945. /**
  8946. * Some techs (e.g. YouTube) can provide a poster source in an
  8947. * asynchronous way. We want the poster component to use this
  8948. * poster source so that it covers up the tech's controls.
  8949. * (YouTube's play button). However we only want to use this
  8950. * soruce if the player user hasn't set a poster through
  8951. * the normal APIs.
  8952. *
  8953. * @private
  8954. * @method handleTechPosterChange_
  8955. */
  8956. Player.prototype.handleTechPosterChange_ = function handleTechPosterChange_() {
  8957. if (!this.poster_ && this.tech_ && this.tech_.poster) {
  8958. this.poster_ = this.tech_.poster() || '';
  8959. // Let components know the poster has changed
  8960. this.trigger('posterchange');
  8961. }
  8962. };
  8963. /**
  8964. * Get or set whether or not the controls are showing.
  8965. *
  8966. * @param {Boolean} bool Set controls to showing or not
  8967. * @return {Boolean} Controls are showing
  8968. * @method controls
  8969. */
  8970. Player.prototype.controls = function controls(bool) {
  8971. if (bool !== undefined) {
  8972. bool = !!bool; // force boolean
  8973. // Don't trigger a change event unless it actually changed
  8974. if (this.controls_ !== bool) {
  8975. this.controls_ = bool;
  8976. if (this.usingNativeControls()) {
  8977. this.techCall_('setControls', bool);
  8978. }
  8979. if (bool) {
  8980. this.removeClass('vjs-controls-disabled');
  8981. this.addClass('vjs-controls-enabled');
  8982. this.trigger('controlsenabled');
  8983. if (!this.usingNativeControls()) {
  8984. this.addTechControlsListeners_();
  8985. }
  8986. } else {
  8987. this.removeClass('vjs-controls-enabled');
  8988. this.addClass('vjs-controls-disabled');
  8989. this.trigger('controlsdisabled');
  8990. if (!this.usingNativeControls()) {
  8991. this.removeTechControlsListeners_();
  8992. }
  8993. }
  8994. }
  8995. return this;
  8996. }
  8997. return !!this.controls_;
  8998. };
  8999. /**
  9000. * Toggle native controls on/off. Native controls are the controls built into
  9001. * devices (e.g. default iPhone controls), Flash, or other techs
  9002. * (e.g. Vimeo Controls)
  9003. * **This should only be set by the current tech, because only the tech knows
  9004. * if it can support native controls**
  9005. *
  9006. * @param {Boolean} bool True signals that native controls are on
  9007. * @return {Player} Returns the player
  9008. * @private
  9009. * @method usingNativeControls
  9010. */
  9011. Player.prototype.usingNativeControls = function usingNativeControls(bool) {
  9012. if (bool !== undefined) {
  9013. bool = !!bool; // force boolean
  9014. // Don't trigger a change event unless it actually changed
  9015. if (this.usingNativeControls_ !== bool) {
  9016. this.usingNativeControls_ = bool;
  9017. if (bool) {
  9018. this.addClass('vjs-using-native-controls');
  9019. /**
  9020. * player is using the native device controls
  9021. *
  9022. * @event usingnativecontrols
  9023. * @memberof Player
  9024. * @instance
  9025. * @private
  9026. */
  9027. this.trigger('usingnativecontrols');
  9028. } else {
  9029. this.removeClass('vjs-using-native-controls');
  9030. /**
  9031. * player is using the custom HTML controls
  9032. *
  9033. * @event usingcustomcontrols
  9034. * @memberof Player
  9035. * @instance
  9036. * @private
  9037. */
  9038. this.trigger('usingcustomcontrols');
  9039. }
  9040. }
  9041. return this;
  9042. }
  9043. return !!this.usingNativeControls_;
  9044. };
  9045. /**
  9046. * Set or get the current MediaError
  9047. *
  9048. * @param {*} err A MediaError or a String/Number to be turned into a MediaError
  9049. * @return {MediaError|null} when getting
  9050. * @return {Player} when setting
  9051. * @method error
  9052. */
  9053. Player.prototype.error = function error(err) {
  9054. if (err === undefined) {
  9055. return this.error_ || null;
  9056. }
  9057. // restoring to default
  9058. if (err === null) {
  9059. this.error_ = err;
  9060. this.removeClass('vjs-error');
  9061. this.errorDisplay.close();
  9062. return this;
  9063. }
  9064. // error instance
  9065. if (err instanceof _mediaErrorJs2['default']) {
  9066. this.error_ = err;
  9067. } else {
  9068. this.error_ = new _mediaErrorJs2['default'](err);
  9069. }
  9070. // add the vjs-error classname to the player
  9071. this.addClass('vjs-error');
  9072. // log the name of the error type and any message
  9073. // ie8 just logs "[object object]" if you just log the error object
  9074. _utilsLogJs2['default'].error('(CODE:' + this.error_.code + ' ' + _mediaErrorJs2['default'].errorTypes[this.error_.code] + ')', this.error_.message, this.error_);
  9075. // fire an error event on the player
  9076. this.trigger('error');
  9077. return this;
  9078. };
  9079. /**
  9080. * Returns whether or not the player is in the "ended" state.
  9081. *
  9082. * @return {Boolean} True if the player is in the ended state, false if not.
  9083. * @method ended
  9084. */
  9085. Player.prototype.ended = function ended() {
  9086. return this.techGet_('ended');
  9087. };
  9088. /**
  9089. * Returns whether or not the player is in the "seeking" state.
  9090. *
  9091. * @return {Boolean} True if the player is in the seeking state, false if not.
  9092. * @method seeking
  9093. */
  9094. Player.prototype.seeking = function seeking() {
  9095. return this.techGet_('seeking');
  9096. };
  9097. /**
  9098. * Returns the TimeRanges of the media that are currently available
  9099. * for seeking to.
  9100. *
  9101. * @return {TimeRanges} the seekable intervals of the media timeline
  9102. * @method seekable
  9103. */
  9104. Player.prototype.seekable = function seekable() {
  9105. return this.techGet_('seekable');
  9106. };
  9107. /**
  9108. * Report user activity
  9109. *
  9110. * @param {Object} event Event object
  9111. * @method reportUserActivity
  9112. */
  9113. Player.prototype.reportUserActivity = function reportUserActivity(event) {
  9114. this.userActivity_ = true;
  9115. };
  9116. /**
  9117. * Get/set if user is active
  9118. *
  9119. * @param {Boolean} bool Value when setting
  9120. * @return {Boolean} Value if user is active user when getting
  9121. * @method userActive
  9122. */
  9123. Player.prototype.userActive = function userActive(bool) {
  9124. if (bool !== undefined) {
  9125. bool = !!bool;
  9126. if (bool !== this.userActive_) {
  9127. this.userActive_ = bool;
  9128. if (bool) {
  9129. // If the user was inactive and is now active we want to reset the
  9130. // inactivity timer
  9131. this.userActivity_ = true;
  9132. this.removeClass('vjs-user-inactive');
  9133. this.addClass('vjs-user-active');
  9134. this.trigger('useractive');
  9135. } else {
  9136. // We're switching the state to inactive manually, so erase any other
  9137. // activity
  9138. this.userActivity_ = false;
  9139. // Chrome/Safari/IE have bugs where when you change the cursor it can
  9140. // trigger a mousemove event. This causes an issue when you're hiding
  9141. // the cursor when the user is inactive, and a mousemove signals user
  9142. // activity. Making it impossible to go into inactive mode. Specifically
  9143. // this happens in fullscreen when we really need to hide the cursor.
  9144. //
  9145. // When this gets resolved in ALL browsers it can be removed
  9146. // https://code.google.com/p/chromium/issues/detail?id=103041
  9147. if (this.tech_) {
  9148. this.tech_.one('mousemove', function (e) {
  9149. e.stopPropagation();
  9150. e.preventDefault();
  9151. });
  9152. }
  9153. this.removeClass('vjs-user-active');
  9154. this.addClass('vjs-user-inactive');
  9155. this.trigger('userinactive');
  9156. }
  9157. }
  9158. return this;
  9159. }
  9160. return this.userActive_;
  9161. };
  9162. /**
  9163. * Listen for user activity based on timeout value
  9164. *
  9165. * @private
  9166. * @method listenForUserActivity_
  9167. */
  9168. Player.prototype.listenForUserActivity_ = function listenForUserActivity_() {
  9169. var mouseInProgress = undefined,
  9170. lastMoveX = undefined,
  9171. lastMoveY = undefined;
  9172. var handleActivity = Fn.bind(this, this.reportUserActivity);
  9173. var handleMouseMove = function handleMouseMove(e) {
  9174. // #1068 - Prevent mousemove spamming
  9175. // Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
  9176. if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) {
  9177. lastMoveX = e.screenX;
  9178. lastMoveY = e.screenY;
  9179. handleActivity();
  9180. }
  9181. };
  9182. var handleMouseDown = function handleMouseDown() {
  9183. handleActivity();
  9184. // For as long as the they are touching the device or have their mouse down,
  9185. // we consider them active even if they're not moving their finger or mouse.
  9186. // So we want to continue to update that they are active
  9187. this.clearInterval(mouseInProgress);
  9188. // Setting userActivity=true now and setting the interval to the same time
  9189. // as the activityCheck interval (250) should ensure we never miss the
  9190. // next activityCheck
  9191. mouseInProgress = this.setInterval(handleActivity, 250);
  9192. };
  9193. var handleMouseUp = function handleMouseUp(event) {
  9194. handleActivity();
  9195. // Stop the interval that maintains activity if the mouse/touch is down
  9196. this.clearInterval(mouseInProgress);
  9197. };
  9198. // Any mouse movement will be considered user activity
  9199. this.on('mousedown', handleMouseDown);
  9200. this.on('mousemove', handleMouseMove);
  9201. this.on('mouseup', handleMouseUp);
  9202. // Listen for keyboard navigation
  9203. // Shouldn't need to use inProgress interval because of key repeat
  9204. this.on('keydown', handleActivity);
  9205. this.on('keyup', handleActivity);
  9206. // Run an interval every 250 milliseconds instead of stuffing everything into
  9207. // the mousemove/touchmove function itself, to prevent performance degradation.
  9208. // `this.reportUserActivity` simply sets this.userActivity_ to true, which
  9209. // then gets picked up by this loop
  9210. // http://ejohn.org/blog/learning-from-twitter/
  9211. var inactivityTimeout = undefined;
  9212. var activityCheck = this.setInterval(function () {
  9213. // Check to see if mouse/touch activity has happened
  9214. if (this.userActivity_) {
  9215. // Reset the activity tracker
  9216. this.userActivity_ = false;
  9217. // If the user state was inactive, set the state to active
  9218. this.userActive(true);
  9219. // Clear any existing inactivity timeout to start the timer over
  9220. this.clearTimeout(inactivityTimeout);
  9221. var timeout = this.options_['inactivityTimeout'];
  9222. if (timeout > 0) {
  9223. // In <timeout> milliseconds, if no more activity has occurred the
  9224. // user will be considered inactive
  9225. inactivityTimeout = this.setTimeout(function () {
  9226. // Protect against the case where the inactivityTimeout can trigger just
  9227. // before the next user activity is picked up by the activityCheck loop
  9228. // causing a flicker
  9229. if (!this.userActivity_) {
  9230. this.userActive(false);
  9231. }
  9232. }, timeout);
  9233. }
  9234. }
  9235. }, 250);
  9236. };
  9237. /**
  9238. * Gets or sets the current playback rate. A playback rate of
  9239. * 1.0 represents normal speed and 0.5 would indicate half-speed
  9240. * playback, for instance.
  9241. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-playbackrate
  9242. *
  9243. * @param {Number} rate New playback rate to set.
  9244. * @return {Number} Returns the new playback rate when setting
  9245. * @return {Number} Returns the current playback rate when getting
  9246. * @method playbackRate
  9247. */
  9248. Player.prototype.playbackRate = function playbackRate(rate) {
  9249. if (rate !== undefined) {
  9250. this.techCall_('setPlaybackRate', rate);
  9251. return this;
  9252. }
  9253. if (this.tech_ && this.tech_['featuresPlaybackRate']) {
  9254. return this.techGet_('playbackRate');
  9255. } else {
  9256. return 1.0;
  9257. }
  9258. };
  9259. /**
  9260. * Gets or sets the audio flag
  9261. *
  9262. * @param {Boolean} bool True signals that this is an audio player.
  9263. * @return {Boolean} Returns true if player is audio, false if not when getting
  9264. * @return {Player} Returns the player if setting
  9265. * @private
  9266. * @method isAudio
  9267. */
  9268. Player.prototype.isAudio = function isAudio(bool) {
  9269. if (bool !== undefined) {
  9270. this.isAudio_ = !!bool;
  9271. return this;
  9272. }
  9273. return !!this.isAudio_;
  9274. };
  9275. /**
  9276. * Returns the current state of network activity for the element, from
  9277. * the codes in the list below.
  9278. * - NETWORK_EMPTY (numeric value 0)
  9279. * The element has not yet been initialised. All attributes are in
  9280. * their initial states.
  9281. * - NETWORK_IDLE (numeric value 1)
  9282. * The element's resource selection algorithm is active and has
  9283. * selected a resource, but it is not actually using the network at
  9284. * this time.
  9285. * - NETWORK_LOADING (numeric value 2)
  9286. * The user agent is actively trying to download data.
  9287. * - NETWORK_NO_SOURCE (numeric value 3)
  9288. * The element's resource selection algorithm is active, but it has
  9289. * not yet found a resource to use.
  9290. *
  9291. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#network-states
  9292. * @return {Number} the current network activity state
  9293. * @method networkState
  9294. */
  9295. Player.prototype.networkState = function networkState() {
  9296. return this.techGet_('networkState');
  9297. };
  9298. /**
  9299. * Returns a value that expresses the current state of the element
  9300. * with respect to rendering the current playback position, from the
  9301. * codes in the list below.
  9302. * - HAVE_NOTHING (numeric value 0)
  9303. * No information regarding the media resource is available.
  9304. * - HAVE_METADATA (numeric value 1)
  9305. * Enough of the resource has been obtained that the duration of the
  9306. * resource is available.
  9307. * - HAVE_CURRENT_DATA (numeric value 2)
  9308. * Data for the immediate current playback position is available.
  9309. * - HAVE_FUTURE_DATA (numeric value 3)
  9310. * Data for the immediate current playback position is available, as
  9311. * well as enough data for the user agent to advance the current
  9312. * playback position in the direction of playback.
  9313. * - HAVE_ENOUGH_DATA (numeric value 4)
  9314. * The user agent estimates that enough data is available for
  9315. * playback to proceed uninterrupted.
  9316. *
  9317. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-readystate
  9318. * @return {Number} the current playback rendering state
  9319. * @method readyState
  9320. */
  9321. Player.prototype.readyState = function readyState() {
  9322. return this.techGet_('readyState');
  9323. };
  9324. /*
  9325. * Text tracks are tracks of timed text events.
  9326. * Captions - text displayed over the video for the hearing impaired
  9327. * Subtitles - text displayed over the video for those who don't understand language in the video
  9328. * Chapters - text displayed in a menu allowing the user to jump to particular points (chapters) in the video
  9329. * Descriptions (not supported yet) - audio descriptions that are read back to the user by a screen reading device
  9330. */
  9331. /**
  9332. * Get an array of associated text tracks. captions, subtitles, chapters, descriptions
  9333. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-texttracks
  9334. *
  9335. * @return {Array} Array of track objects
  9336. * @method textTracks
  9337. */
  9338. Player.prototype.textTracks = function textTracks() {
  9339. // cannot use techGet_ directly because it checks to see whether the tech is ready.
  9340. // Flash is unlikely to be ready in time but textTracks should still work.
  9341. return this.tech_ && this.tech_['textTracks']();
  9342. };
  9343. /**
  9344. * Get an array of remote text tracks
  9345. *
  9346. * @return {Array}
  9347. * @method remoteTextTracks
  9348. */
  9349. Player.prototype.remoteTextTracks = function remoteTextTracks() {
  9350. return this.tech_ && this.tech_['remoteTextTracks']();
  9351. };
  9352. /**
  9353. * Get an array of remote html track elements
  9354. *
  9355. * @return {HTMLTrackElement[]}
  9356. * @method remoteTextTrackEls
  9357. */
  9358. Player.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  9359. return this.tech_ && this.tech_['remoteTextTrackEls']();
  9360. };
  9361. /**
  9362. * Add a text track
  9363. * In addition to the W3C settings we allow adding additional info through options.
  9364. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-addtexttrack
  9365. *
  9366. * @param {String} kind Captions, subtitles, chapters, descriptions, or metadata
  9367. * @param {String=} label Optional label
  9368. * @param {String=} language Optional language
  9369. * @method addTextTrack
  9370. */
  9371. Player.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  9372. return this.tech_ && this.tech_['addTextTrack'](kind, label, language);
  9373. };
  9374. /**
  9375. * Add a remote text track
  9376. *
  9377. * @param {Object} options Options for remote text track
  9378. * @method addRemoteTextTrack
  9379. */
  9380. Player.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  9381. return this.tech_ && this.tech_['addRemoteTextTrack'](options);
  9382. };
  9383. /**
  9384. * Remove a remote text track
  9385. *
  9386. * @param {Object} track Remote text track to remove
  9387. * @method removeRemoteTextTrack
  9388. */
  9389. Player.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  9390. this.tech_ && this.tech_['removeRemoteTextTrack'](track);
  9391. };
  9392. /**
  9393. * Get video width
  9394. *
  9395. * @return {Number} Video width
  9396. * @method videoWidth
  9397. */
  9398. Player.prototype.videoWidth = function videoWidth() {
  9399. return this.tech_ && this.tech_.videoWidth && this.tech_.videoWidth() || 0;
  9400. };
  9401. /**
  9402. * Get video height
  9403. *
  9404. * @return {Number} Video height
  9405. * @method videoHeight
  9406. */
  9407. Player.prototype.videoHeight = function videoHeight() {
  9408. return this.tech_ && this.tech_.videoHeight && this.tech_.videoHeight() || 0;
  9409. };
  9410. // Methods to add support for
  9411. // initialTime: function(){ return this.techCall_('initialTime'); },
  9412. // startOffsetTime: function(){ return this.techCall_('startOffsetTime'); },
  9413. // played: function(){ return this.techCall_('played'); },
  9414. // videoTracks: function(){ return this.techCall_('videoTracks'); },
  9415. // audioTracks: function(){ return this.techCall_('audioTracks'); },
  9416. // defaultPlaybackRate: function(){ return this.techCall_('defaultPlaybackRate'); },
  9417. // defaultMuted: function(){ return this.techCall_('defaultMuted'); }
  9418. /**
  9419. * The player's language code
  9420. * NOTE: The language should be set in the player options if you want the
  9421. * the controls to be built with a specific language. Changing the lanugage
  9422. * later will not update controls text.
  9423. *
  9424. * @param {String} code The locale string
  9425. * @return {String} The locale string when getting
  9426. * @return {Player} self when setting
  9427. * @method language
  9428. */
  9429. Player.prototype.language = function language(code) {
  9430. if (code === undefined) {
  9431. return this.language_;
  9432. }
  9433. this.language_ = ('' + code).toLowerCase();
  9434. return this;
  9435. };
  9436. /**
  9437. * Get the player's language dictionary
  9438. * Merge every time, because a newly added plugin might call videojs.addLanguage() at any time
  9439. * Languages specified directly in the player options have precedence
  9440. *
  9441. * @return {Array} Array of languages
  9442. * @method languages
  9443. */
  9444. Player.prototype.languages = function languages() {
  9445. return _utilsMergeOptionsJs2['default'](Player.prototype.options_.languages, this.languages_);
  9446. };
  9447. /**
  9448. * Converts track info to JSON
  9449. *
  9450. * @return {Object} JSON object of options
  9451. * @method toJSON
  9452. */
  9453. Player.prototype.toJSON = function toJSON() {
  9454. var options = _utilsMergeOptionsJs2['default'](this.options_);
  9455. var tracks = options.tracks;
  9456. options.tracks = [];
  9457. for (var i = 0; i < tracks.length; i++) {
  9458. var track = tracks[i];
  9459. // deep merge tracks and null out player so no circular references
  9460. track = _utilsMergeOptionsJs2['default'](track);
  9461. track.player = undefined;
  9462. options.tracks[i] = track;
  9463. }
  9464. return options;
  9465. };
  9466. /**
  9467. * Creates a simple modal dialog (an instance of the `ModalDialog`
  9468. * component) that immediately overlays the player with arbitrary
  9469. * content and removes itself when closed.
  9470. *
  9471. * @param {String|Function|Element|Array|Null} content
  9472. * Same as `ModalDialog#content`'s param of the same name.
  9473. *
  9474. * The most straight-forward usage is to provide a string or DOM
  9475. * element.
  9476. *
  9477. * @param {Object} [options]
  9478. * Extra options which will be passed on to the `ModalDialog`.
  9479. *
  9480. * @return {ModalDialog}
  9481. */
  9482. Player.prototype.createModal = function createModal(content, options) {
  9483. var player = this;
  9484. options = options || {};
  9485. options.content = content || '';
  9486. var modal = new _modalDialog2['default'](player, options);
  9487. player.addChild(modal);
  9488. modal.on('dispose', function () {
  9489. player.removeChild(modal);
  9490. });
  9491. return modal.open();
  9492. };
  9493. /**
  9494. * Gets tag settings
  9495. *
  9496. * @param {Element} tag The player tag
  9497. * @return {Array} An array of sources and track objects
  9498. * @static
  9499. * @method getTagSettings
  9500. */
  9501. Player.getTagSettings = function getTagSettings(tag) {
  9502. var baseOptions = {
  9503. 'sources': [],
  9504. 'tracks': []
  9505. };
  9506. var tagOptions = Dom.getElAttributes(tag);
  9507. var dataSetup = tagOptions['data-setup'];
  9508. // Check if data-setup attr exists.
  9509. if (dataSetup !== null) {
  9510. // Parse options JSON
  9511. var _safeParseTuple = _safeJsonParseTuple2['default'](dataSetup || '{}');
  9512. var err = _safeParseTuple[0];
  9513. var data = _safeParseTuple[1];
  9514. if (err) {
  9515. _utilsLogJs2['default'].error(err);
  9516. }
  9517. _objectAssign2['default'](tagOptions, data);
  9518. }
  9519. _objectAssign2['default'](baseOptions, tagOptions);
  9520. // Get tag children settings
  9521. if (tag.hasChildNodes()) {
  9522. var children = tag.childNodes;
  9523. for (var i = 0, j = children.length; i < j; i++) {
  9524. var child = children[i];
  9525. // Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
  9526. var childName = child.nodeName.toLowerCase();
  9527. if (childName === 'source') {
  9528. baseOptions.sources.push(Dom.getElAttributes(child));
  9529. } else if (childName === 'track') {
  9530. baseOptions.tracks.push(Dom.getElAttributes(child));
  9531. }
  9532. }
  9533. }
  9534. return baseOptions;
  9535. };
  9536. return Player;
  9537. })(_componentJs2['default']);
  9538. Player.players = {};
  9539. var navigator = _globalWindow2['default'].navigator;
  9540. /*
  9541. * Player instance options, surfaced using options
  9542. * options = Player.prototype.options_
  9543. * Make changes in options, not here.
  9544. *
  9545. * @type {Object}
  9546. * @private
  9547. */
  9548. Player.prototype.options_ = {
  9549. // Default order of fallback technology
  9550. techOrder: ['html5', 'flash'],
  9551. // techOrder: ['flash','html5'],
  9552. html5: {},
  9553. flash: {},
  9554. // defaultVolume: 0.85,
  9555. defaultVolume: 0.00, // The freakin seaguls are driving me crazy!
  9556. // default inactivity timeout
  9557. inactivityTimeout: 2000,
  9558. // default playback rates
  9559. playbackRates: [],
  9560. // Add playback rate selection by adding rates
  9561. // 'playbackRates': [0.5, 1, 1.5, 2],
  9562. // Included control sets
  9563. children: ['mediaLoader', 'posterImage', 'textTrackDisplay', 'loadingSpinner', 'bigPlayButton', 'controlBar', 'errorDisplay', 'textTrackSettings'],
  9564. language: _globalDocument2['default'].getElementsByTagName('html')[0].getAttribute('lang') || navigator.languages && navigator.languages[0] || navigator.userLanguage || navigator.language || 'en',
  9565. // locales and their language translations
  9566. languages: {},
  9567. // Default message to show when a video cannot be played.
  9568. notSupportedMessage: 'No compatible source was found for this video.'
  9569. };
  9570. /**
  9571. * Fired when the player has initial duration and dimension information
  9572. *
  9573. * @event loadedmetadata
  9574. */
  9575. Player.prototype.handleLoadedMetaData_;
  9576. /**
  9577. * Fired when the player has downloaded data at the current playback position
  9578. *
  9579. * @event loadeddata
  9580. */
  9581. Player.prototype.handleLoadedData_;
  9582. /**
  9583. * Fired when the user is active, e.g. moves the mouse over the player
  9584. *
  9585. * @event useractive
  9586. */
  9587. Player.prototype.handleUserActive_;
  9588. /**
  9589. * Fired when the user is inactive, e.g. a short delay after the last mouse move or control interaction
  9590. *
  9591. * @event userinactive
  9592. */
  9593. Player.prototype.handleUserInactive_;
  9594. /**
  9595. * Fired when the current playback position has changed *
  9596. * During playback this is fired every 15-250 milliseconds, depending on the
  9597. * playback technology in use.
  9598. *
  9599. * @event timeupdate
  9600. */
  9601. Player.prototype.handleTimeUpdate_;
  9602. /**
  9603. * Fired when video playback ends
  9604. *
  9605. * @event ended
  9606. */
  9607. Player.prototype.handleTechEnded_;
  9608. /**
  9609. * Fired when the volume changes
  9610. *
  9611. * @event volumechange
  9612. */
  9613. Player.prototype.handleVolumeChange_;
  9614. /**
  9615. * Fired when an error occurs
  9616. *
  9617. * @event error
  9618. */
  9619. Player.prototype.handleError_;
  9620. Player.prototype.flexNotSupported_ = function () {
  9621. var elem = _globalDocument2['default'].createElement('i');
  9622. // Note: We don't actually use flexBasis (or flexOrder), but it's one of the more
  9623. // common flex features that we can rely on when checking for flex support.
  9624. 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) */;
  9625. };
  9626. _componentJs2['default'].registerComponent('Player', Player);
  9627. exports['default'] = Player;
  9628. module.exports = exports['default'];
  9629. // If empty string, make it a parsable json object.
  9630. },{"./big-play-button.js":62,"./component.js":65,"./control-bar/control-bar.js":66,"./error-display.js":96,"./fullscreen-api.js":99,"./loading-spinner.js":100,"./media-error.js":101,"./modal-dialog":105,"./poster-image.js":108,"./tech/html5.js":113,"./tech/loader.js":114,"./tech/tech.js":115,"./tracks/text-track-display.js":119,"./tracks/text-track-list-converter.js":121,"./tracks/text-track-settings.js":123,"./utils/browser.js":125,"./utils/buffer.js":126,"./utils/dom.js":128,"./utils/events.js":129,"./utils/fn.js":130,"./utils/guid.js":132,"./utils/log.js":133,"./utils/merge-options.js":134,"./utils/stylesheet.js":135,"./utils/time-ranges.js":136,"./utils/to-title-case.js":137,"global/document":1,"global/window":2,"object.assign":45,"safe-json-parse/tuple":53}],107:[function(_dereq_,module,exports){
  9631. /**
  9632. * @file plugins.js
  9633. */
  9634. 'use strict';
  9635. exports.__esModule = true;
  9636. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  9637. var _playerJs = _dereq_('./player.js');
  9638. var _playerJs2 = _interopRequireDefault(_playerJs);
  9639. /**
  9640. * The method for registering a video.js plugin
  9641. *
  9642. * @param {String} name The name of the plugin
  9643. * @param {Function} init The function that is run when the player inits
  9644. * @method plugin
  9645. */
  9646. var plugin = function plugin(name, init) {
  9647. _playerJs2['default'].prototype[name] = init;
  9648. };
  9649. exports['default'] = plugin;
  9650. module.exports = exports['default'];
  9651. },{"./player.js":106}],108:[function(_dereq_,module,exports){
  9652. /**
  9653. * @file poster-image.js
  9654. */
  9655. 'use strict';
  9656. exports.__esModule = true;
  9657. 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; } }
  9658. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  9659. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  9660. 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; }
  9661. var _buttonJs = _dereq_('./button.js');
  9662. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  9663. var _componentJs = _dereq_('./component.js');
  9664. var _componentJs2 = _interopRequireDefault(_componentJs);
  9665. var _utilsFnJs = _dereq_('./utils/fn.js');
  9666. var Fn = _interopRequireWildcard(_utilsFnJs);
  9667. var _utilsDomJs = _dereq_('./utils/dom.js');
  9668. var Dom = _interopRequireWildcard(_utilsDomJs);
  9669. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  9670. var browser = _interopRequireWildcard(_utilsBrowserJs);
  9671. /**
  9672. * The component that handles showing the poster image.
  9673. *
  9674. * @param {Player|Object} player
  9675. * @param {Object=} options
  9676. * @extends Button
  9677. * @class PosterImage
  9678. */
  9679. var PosterImage = (function (_Button) {
  9680. _inherits(PosterImage, _Button);
  9681. function PosterImage(player, options) {
  9682. _classCallCheck(this, PosterImage);
  9683. _Button.call(this, player, options);
  9684. this.update();
  9685. player.on('posterchange', Fn.bind(this, this.update));
  9686. }
  9687. /**
  9688. * Clean up the poster image
  9689. *
  9690. * @method dispose
  9691. */
  9692. PosterImage.prototype.dispose = function dispose() {
  9693. this.player().off('posterchange', this.update);
  9694. _Button.prototype.dispose.call(this);
  9695. };
  9696. /**
  9697. * Create the poster's image element
  9698. *
  9699. * @return {Element}
  9700. * @method createEl
  9701. */
  9702. PosterImage.prototype.createEl = function createEl() {
  9703. var el = Dom.createEl('div', {
  9704. className: 'vjs-poster',
  9705. // Don't want poster to be tabbable.
  9706. tabIndex: -1
  9707. });
  9708. // To ensure the poster image resizes while maintaining its original aspect
  9709. // ratio, use a div with `background-size` when available. For browsers that
  9710. // do not support `background-size` (e.g. IE8), fall back on using a regular
  9711. // img element.
  9712. if (!browser.BACKGROUND_SIZE_SUPPORTED) {
  9713. this.fallbackImg_ = Dom.createEl('img');
  9714. el.appendChild(this.fallbackImg_);
  9715. }
  9716. return el;
  9717. };
  9718. /**
  9719. * Event handler for updates to the player's poster source
  9720. *
  9721. * @method update
  9722. */
  9723. PosterImage.prototype.update = function update() {
  9724. var url = this.player().poster();
  9725. this.setSrc(url);
  9726. // If there's no poster source we should display:none on this component
  9727. // so it's not still clickable or right-clickable
  9728. if (url) {
  9729. this.show();
  9730. } else {
  9731. this.hide();
  9732. }
  9733. };
  9734. /**
  9735. * Set the poster source depending on the display method
  9736. *
  9737. * @param {String} url The URL to the poster source
  9738. * @method setSrc
  9739. */
  9740. PosterImage.prototype.setSrc = function setSrc(url) {
  9741. if (this.fallbackImg_) {
  9742. this.fallbackImg_.src = url;
  9743. } else {
  9744. var backgroundImage = '';
  9745. // Any falsey values should stay as an empty string, otherwise
  9746. // this will throw an extra error
  9747. if (url) {
  9748. backgroundImage = 'url("' + url + '")';
  9749. }
  9750. this.el_.style.backgroundImage = backgroundImage;
  9751. }
  9752. };
  9753. /**
  9754. * Event handler for clicks on the poster image
  9755. *
  9756. * @method handleClick
  9757. */
  9758. PosterImage.prototype.handleClick = function handleClick() {
  9759. // We don't want a click to trigger playback when controls are disabled
  9760. // but CSS should be hiding the poster to prevent that from happening
  9761. if (this.player_.paused()) {
  9762. this.player_.play();
  9763. } else {
  9764. this.player_.pause();
  9765. }
  9766. };
  9767. return PosterImage;
  9768. })(_buttonJs2['default']);
  9769. _componentJs2['default'].registerComponent('PosterImage', PosterImage);
  9770. exports['default'] = PosterImage;
  9771. module.exports = exports['default'];
  9772. },{"./button.js":63,"./component.js":65,"./utils/browser.js":125,"./utils/dom.js":128,"./utils/fn.js":130}],109:[function(_dereq_,module,exports){
  9773. /**
  9774. * @file setup.js
  9775. *
  9776. * Functions for automatically setting up a player
  9777. * based on the data-setup attribute of the video tag
  9778. */
  9779. 'use strict';
  9780. exports.__esModule = true;
  9781. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  9782. 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; } }
  9783. var _utilsEventsJs = _dereq_('./utils/events.js');
  9784. var Events = _interopRequireWildcard(_utilsEventsJs);
  9785. var _globalDocument = _dereq_('global/document');
  9786. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  9787. var _globalWindow = _dereq_('global/window');
  9788. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  9789. var _windowLoaded = false;
  9790. var videojs = undefined;
  9791. // Automatically set up any tags that have a data-setup attribute
  9792. var autoSetup = function autoSetup() {
  9793. // One day, when we stop supporting IE8, go back to this, but in the meantime...*hack hack hack*
  9794. // var vids = Array.prototype.slice.call(document.getElementsByTagName('video'));
  9795. // var audios = Array.prototype.slice.call(document.getElementsByTagName('audio'));
  9796. // var mediaEls = vids.concat(audios);
  9797. // Because IE8 doesn't support calling slice on a node list, we need to loop through each list of elements
  9798. // to build up a new, combined list of elements.
  9799. var vids = _globalDocument2['default'].getElementsByTagName('video');
  9800. var audios = _globalDocument2['default'].getElementsByTagName('audio');
  9801. var mediaEls = [];
  9802. if (vids && vids.length > 0) {
  9803. for (var i = 0, e = vids.length; i < e; i++) {
  9804. mediaEls.push(vids[i]);
  9805. }
  9806. }
  9807. if (audios && audios.length > 0) {
  9808. for (var i = 0, e = audios.length; i < e; i++) {
  9809. mediaEls.push(audios[i]);
  9810. }
  9811. }
  9812. // Check if any media elements exist
  9813. if (mediaEls && mediaEls.length > 0) {
  9814. for (var i = 0, e = mediaEls.length; i < e; i++) {
  9815. var mediaEl = mediaEls[i];
  9816. // Check if element exists, has getAttribute func.
  9817. // IE seems to consider typeof el.getAttribute == 'object' instead of 'function' like expected, at least when loading the player immediately.
  9818. if (mediaEl && mediaEl.getAttribute) {
  9819. // Make sure this player hasn't already been set up.
  9820. if (mediaEl['player'] === undefined) {
  9821. var options = mediaEl.getAttribute('data-setup');
  9822. // Check if data-setup attr exists.
  9823. // We only auto-setup if they've added the data-setup attr.
  9824. if (options !== null) {
  9825. // Create new video.js instance.
  9826. var player = videojs(mediaEl);
  9827. }
  9828. }
  9829. // If getAttribute isn't defined, we need to wait for the DOM.
  9830. } else {
  9831. autoSetupTimeout(1);
  9832. break;
  9833. }
  9834. }
  9835. // No videos were found, so keep looping unless page is finished loading.
  9836. } else if (!_windowLoaded) {
  9837. autoSetupTimeout(1);
  9838. }
  9839. };
  9840. // Pause to let the DOM keep processing
  9841. var autoSetupTimeout = function autoSetupTimeout(wait, vjs) {
  9842. videojs = vjs;
  9843. setTimeout(autoSetup, wait);
  9844. };
  9845. if (_globalDocument2['default'].readyState === 'complete') {
  9846. _windowLoaded = true;
  9847. } else {
  9848. Events.one(_globalWindow2['default'], 'load', function () {
  9849. _windowLoaded = true;
  9850. });
  9851. }
  9852. var hasLoaded = function hasLoaded() {
  9853. return _windowLoaded;
  9854. };
  9855. exports.autoSetup = autoSetup;
  9856. exports.autoSetupTimeout = autoSetupTimeout;
  9857. exports.hasLoaded = hasLoaded;
  9858. },{"./utils/events.js":129,"global/document":1,"global/window":2}],110:[function(_dereq_,module,exports){
  9859. /**
  9860. * @file slider.js
  9861. */
  9862. 'use strict';
  9863. exports.__esModule = true;
  9864. 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; } }
  9865. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  9866. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  9867. 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; }
  9868. var _componentJs = _dereq_('../component.js');
  9869. var _componentJs2 = _interopRequireDefault(_componentJs);
  9870. var _utilsDomJs = _dereq_('../utils/dom.js');
  9871. var Dom = _interopRequireWildcard(_utilsDomJs);
  9872. var _globalDocument = _dereq_('global/document');
  9873. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  9874. var _objectAssign = _dereq_('object.assign');
  9875. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  9876. /**
  9877. * The base functionality for sliders like the volume bar and seek bar
  9878. *
  9879. * @param {Player|Object} player
  9880. * @param {Object=} options
  9881. * @extends Component
  9882. * @class Slider
  9883. */
  9884. var Slider = (function (_Component) {
  9885. _inherits(Slider, _Component);
  9886. function Slider(player, options) {
  9887. _classCallCheck(this, Slider);
  9888. _Component.call(this, player, options);
  9889. // Set property names to bar to match with the child Slider class is looking for
  9890. this.bar = this.getChild(this.options_.barName);
  9891. // Set a horizontal or vertical class on the slider depending on the slider type
  9892. this.vertical(!!this.options_.vertical);
  9893. this.on('mousedown', this.handleMouseDown);
  9894. this.on('touchstart', this.handleMouseDown);
  9895. this.on('focus', this.handleFocus);
  9896. this.on('blur', this.handleBlur);
  9897. this.on('click', this.handleClick);
  9898. this.on(player, 'controlsvisible', this.update);
  9899. this.on(player, this.playerEvent, this.update);
  9900. }
  9901. /**
  9902. * Create the component's DOM element
  9903. *
  9904. * @param {String} type Type of element to create
  9905. * @param {Object=} props List of properties in Object form
  9906. * @return {Element}
  9907. * @method createEl
  9908. */
  9909. Slider.prototype.createEl = function createEl(type) {
  9910. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  9911. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  9912. // Add the slider element class to all sub classes
  9913. props.className = props.className + ' vjs-slider';
  9914. props = _objectAssign2['default']({
  9915. tabIndex: 0
  9916. }, props);
  9917. attributes = _objectAssign2['default']({
  9918. 'role': 'slider',
  9919. 'aria-valuenow': 0,
  9920. 'aria-valuemin': 0,
  9921. 'aria-valuemax': 100,
  9922. tabIndex: 0
  9923. }, attributes);
  9924. return _Component.prototype.createEl.call(this, type, props, attributes);
  9925. };
  9926. /**
  9927. * Handle mouse down on slider
  9928. *
  9929. * @param {Object} event Mouse down event object
  9930. * @method handleMouseDown
  9931. */
  9932. Slider.prototype.handleMouseDown = function handleMouseDown(event) {
  9933. event.preventDefault();
  9934. Dom.blockTextSelection();
  9935. this.addClass('vjs-sliding');
  9936. this.trigger('slideractive');
  9937. this.on(_globalDocument2['default'], 'mousemove', this.handleMouseMove);
  9938. this.on(_globalDocument2['default'], 'mouseup', this.handleMouseUp);
  9939. this.on(_globalDocument2['default'], 'touchmove', this.handleMouseMove);
  9940. this.on(_globalDocument2['default'], 'touchend', this.handleMouseUp);
  9941. this.handleMouseMove(event);
  9942. };
  9943. /**
  9944. * To be overridden by a subclass
  9945. *
  9946. * @method handleMouseMove
  9947. */
  9948. Slider.prototype.handleMouseMove = function handleMouseMove() {};
  9949. /**
  9950. * Handle mouse up on Slider
  9951. *
  9952. * @method handleMouseUp
  9953. */
  9954. Slider.prototype.handleMouseUp = function handleMouseUp() {
  9955. Dom.unblockTextSelection();
  9956. this.removeClass('vjs-sliding');
  9957. this.trigger('sliderinactive');
  9958. this.off(_globalDocument2['default'], 'mousemove', this.handleMouseMove);
  9959. this.off(_globalDocument2['default'], 'mouseup', this.handleMouseUp);
  9960. this.off(_globalDocument2['default'], 'touchmove', this.handleMouseMove);
  9961. this.off(_globalDocument2['default'], 'touchend', this.handleMouseUp);
  9962. this.update();
  9963. };
  9964. /**
  9965. * Update slider
  9966. *
  9967. * @method update
  9968. */
  9969. Slider.prototype.update = function update() {
  9970. // In VolumeBar init we have a setTimeout for update that pops and update to the end of the
  9971. // execution stack. The player is destroyed before then update will cause an error
  9972. if (!this.el_) return;
  9973. // If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
  9974. // On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
  9975. // var progress = (this.player_.scrubbing()) ? this.player_.getCache().currentTime / this.player_.duration() : this.player_.currentTime() / this.player_.duration();
  9976. var progress = this.getPercent();
  9977. var bar = this.bar;
  9978. // If there's no bar...
  9979. if (!bar) return;
  9980. // Protect against no duration and other division issues
  9981. if (typeof progress !== 'number' || progress !== progress || progress < 0 || progress === Infinity) {
  9982. progress = 0;
  9983. }
  9984. // Convert to a percentage for setting
  9985. var percentage = (progress * 100).toFixed(2) + '%';
  9986. // Set the new bar width or height
  9987. if (this.vertical()) {
  9988. bar.el().style.height = percentage;
  9989. } else {
  9990. bar.el().style.width = percentage;
  9991. }
  9992. };
  9993. /**
  9994. * Calculate distance for slider
  9995. *
  9996. * @param {Object} event Event object
  9997. * @method calculateDistance
  9998. */
  9999. Slider.prototype.calculateDistance = function calculateDistance(event) {
  10000. var position = Dom.getPointerPosition(this.el_, event);
  10001. if (this.vertical()) {
  10002. return position.y;
  10003. }
  10004. return position.x;
  10005. };
  10006. /**
  10007. * Handle on focus for slider
  10008. *
  10009. * @method handleFocus
  10010. */
  10011. Slider.prototype.handleFocus = function handleFocus() {
  10012. this.on(_globalDocument2['default'], 'keydown', this.handleKeyPress);
  10013. };
  10014. /**
  10015. * Handle key press for slider
  10016. *
  10017. * @param {Object} event Event object
  10018. * @method handleKeyPress
  10019. */
  10020. Slider.prototype.handleKeyPress = function handleKeyPress(event) {
  10021. if (event.which === 37 || event.which === 40) {
  10022. // Left and Down Arrows
  10023. event.preventDefault();
  10024. this.stepBack();
  10025. } else if (event.which === 38 || event.which === 39) {
  10026. // Up and Right Arrows
  10027. event.preventDefault();
  10028. this.stepForward();
  10029. }
  10030. };
  10031. /**
  10032. * Handle on blur for slider
  10033. *
  10034. * @method handleBlur
  10035. */
  10036. Slider.prototype.handleBlur = function handleBlur() {
  10037. this.off(_globalDocument2['default'], 'keydown', this.handleKeyPress);
  10038. };
  10039. /**
  10040. * Listener for click events on slider, used to prevent clicks
  10041. * from bubbling up to parent elements like button menus.
  10042. *
  10043. * @param {Object} event Event object
  10044. * @method handleClick
  10045. */
  10046. Slider.prototype.handleClick = function handleClick(event) {
  10047. event.stopImmediatePropagation();
  10048. event.preventDefault();
  10049. };
  10050. /**
  10051. * Get/set if slider is horizontal for vertical
  10052. *
  10053. * @param {Boolean} bool True if slider is vertical, false is horizontal
  10054. * @return {Boolean} True if slider is vertical, false is horizontal
  10055. * @method vertical
  10056. */
  10057. Slider.prototype.vertical = function vertical(bool) {
  10058. if (bool === undefined) {
  10059. return this.vertical_ || false;
  10060. }
  10061. this.vertical_ = !!bool;
  10062. if (this.vertical_) {
  10063. this.addClass('vjs-slider-vertical');
  10064. } else {
  10065. this.addClass('vjs-slider-horizontal');
  10066. }
  10067. return this;
  10068. };
  10069. return Slider;
  10070. })(_componentJs2['default']);
  10071. _componentJs2['default'].registerComponent('Slider', Slider);
  10072. exports['default'] = Slider;
  10073. module.exports = exports['default'];
  10074. },{"../component.js":65,"../utils/dom.js":128,"global/document":1,"object.assign":45}],111:[function(_dereq_,module,exports){
  10075. /**
  10076. * @file flash-rtmp.js
  10077. */
  10078. 'use strict';
  10079. exports.__esModule = true;
  10080. function FlashRtmpDecorator(Flash) {
  10081. Flash.streamingFormats = {
  10082. 'rtmp/mp4': 'MP4',
  10083. 'rtmp/flv': 'FLV'
  10084. };
  10085. Flash.streamFromParts = function (connection, stream) {
  10086. return connection + '&' + stream;
  10087. };
  10088. Flash.streamToParts = function (src) {
  10089. var parts = {
  10090. connection: '',
  10091. stream: ''
  10092. };
  10093. if (!src) return parts;
  10094. // Look for the normal URL separator we expect, '&'.
  10095. // If found, we split the URL into two pieces around the
  10096. // first '&'.
  10097. var connEnd = src.search(/&(?!\w+=)/);
  10098. var streamBegin = undefined;
  10099. if (connEnd !== -1) {
  10100. streamBegin = connEnd + 1;
  10101. } else {
  10102. // If there's not a '&', we use the last '/' as the delimiter.
  10103. connEnd = streamBegin = src.lastIndexOf('/') + 1;
  10104. if (connEnd === 0) {
  10105. // really, there's not a '/'?
  10106. connEnd = streamBegin = src.length;
  10107. }
  10108. }
  10109. parts.connection = src.substring(0, connEnd);
  10110. parts.stream = src.substring(streamBegin, src.length);
  10111. return parts;
  10112. };
  10113. Flash.isStreamingType = function (srcType) {
  10114. return srcType in Flash.streamingFormats;
  10115. };
  10116. // RTMP has four variations, any string starting
  10117. // with one of these protocols should be valid
  10118. Flash.RTMP_RE = /^rtmp[set]?:\/\//i;
  10119. Flash.isStreamingSrc = function (src) {
  10120. return Flash.RTMP_RE.test(src);
  10121. };
  10122. /**
  10123. * A source handler for RTMP urls
  10124. * @type {Object}
  10125. */
  10126. Flash.rtmpSourceHandler = {};
  10127. /**
  10128. * Check if Flash can play the given videotype
  10129. * @param {String} type The mimetype to check
  10130. * @return {String} 'probably', 'maybe', or '' (empty string)
  10131. */
  10132. Flash.rtmpSourceHandler.canPlayType = function (type) {
  10133. if (Flash.isStreamingType(type)) {
  10134. return 'maybe';
  10135. }
  10136. return '';
  10137. };
  10138. /**
  10139. * Check if Flash can handle the source natively
  10140. * @param {Object} source The source object
  10141. * @return {String} 'probably', 'maybe', or '' (empty string)
  10142. */
  10143. Flash.rtmpSourceHandler.canHandleSource = function (source) {
  10144. var can = Flash.rtmpSourceHandler.canPlayType(source.type);
  10145. if (can) {
  10146. return can;
  10147. }
  10148. if (Flash.isStreamingSrc(source.src)) {
  10149. return 'maybe';
  10150. }
  10151. return '';
  10152. };
  10153. /**
  10154. * Pass the source to the flash object
  10155. * Adaptive source handlers will have more complicated workflows before passing
  10156. * video data to the video element
  10157. * @param {Object} source The source object
  10158. * @param {Flash} tech The instance of the Flash tech
  10159. */
  10160. Flash.rtmpSourceHandler.handleSource = function (source, tech) {
  10161. var srcParts = Flash.streamToParts(source.src);
  10162. tech['setRtmpConnection'](srcParts.connection);
  10163. tech['setRtmpStream'](srcParts.stream);
  10164. };
  10165. // Register the native source handler
  10166. Flash.registerSourceHandler(Flash.rtmpSourceHandler);
  10167. return Flash;
  10168. }
  10169. exports['default'] = FlashRtmpDecorator;
  10170. module.exports = exports['default'];
  10171. },{}],112:[function(_dereq_,module,exports){
  10172. /**
  10173. * @file flash.js
  10174. * VideoJS-SWF - Custom Flash Player with HTML5-ish API
  10175. * https://github.com/zencoder/video-js-swf
  10176. * Not using setupTriggers. Using global onEvent func to distribute events
  10177. */
  10178. 'use strict';
  10179. exports.__esModule = true;
  10180. 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; } }
  10181. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10182. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10183. 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; }
  10184. var _tech = _dereq_('./tech');
  10185. var _tech2 = _interopRequireDefault(_tech);
  10186. var _utilsDomJs = _dereq_('../utils/dom.js');
  10187. var Dom = _interopRequireWildcard(_utilsDomJs);
  10188. var _utilsUrlJs = _dereq_('../utils/url.js');
  10189. var Url = _interopRequireWildcard(_utilsUrlJs);
  10190. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js');
  10191. var _flashRtmp = _dereq_('./flash-rtmp');
  10192. var _flashRtmp2 = _interopRequireDefault(_flashRtmp);
  10193. var _component = _dereq_('../component');
  10194. var _component2 = _interopRequireDefault(_component);
  10195. var _globalWindow = _dereq_('global/window');
  10196. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  10197. var _objectAssign = _dereq_('object.assign');
  10198. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  10199. var navigator = _globalWindow2['default'].navigator;
  10200. /**
  10201. * Flash Media Controller - Wrapper for fallback SWF API
  10202. *
  10203. * @param {Object=} options Object of option names and values
  10204. * @param {Function=} ready Ready callback function
  10205. * @extends Tech
  10206. * @class Flash
  10207. */
  10208. var Flash = (function (_Tech) {
  10209. _inherits(Flash, _Tech);
  10210. function Flash(options, ready) {
  10211. _classCallCheck(this, Flash);
  10212. _Tech.call(this, options, ready);
  10213. // Set the source when ready
  10214. if (options.source) {
  10215. this.ready(function () {
  10216. this.setSource(options.source);
  10217. }, true);
  10218. }
  10219. // Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
  10220. // This allows resetting the playhead when we catch the reload
  10221. if (options.startTime) {
  10222. this.ready(function () {
  10223. this.load();
  10224. this.play();
  10225. this.currentTime(options.startTime);
  10226. }, true);
  10227. }
  10228. // Add global window functions that the swf expects
  10229. // A 4.x workflow we weren't able to solve for in 5.0
  10230. // because of the need to hard code these functions
  10231. // into the swf for security reasons
  10232. _globalWindow2['default'].videojs = _globalWindow2['default'].videojs || {};
  10233. _globalWindow2['default'].videojs.Flash = _globalWindow2['default'].videojs.Flash || {};
  10234. _globalWindow2['default'].videojs.Flash.onReady = Flash.onReady;
  10235. _globalWindow2['default'].videojs.Flash.onEvent = Flash.onEvent;
  10236. _globalWindow2['default'].videojs.Flash.onError = Flash.onError;
  10237. this.on('seeked', function () {
  10238. this.lastSeekTarget_ = undefined;
  10239. });
  10240. }
  10241. // Create setters and getters for attributes
  10242. /**
  10243. * Create the component's DOM element
  10244. *
  10245. * @return {Element}
  10246. * @method createEl
  10247. */
  10248. Flash.prototype.createEl = function createEl() {
  10249. var options = this.options_;
  10250. // If video.js is hosted locally you should also set the location
  10251. // for the hosted swf, which should be relative to the page (not video.js)
  10252. // Otherwise this adds a CDN url.
  10253. // The CDN also auto-adds a swf URL for that specific version.
  10254. if (!options.swf) {
  10255. options.swf = '//vjs.zencdn.net/swf/5.0.1/video-js.swf';
  10256. }
  10257. // Generate ID for swf object
  10258. var objId = options.techId;
  10259. // Merge default flashvars with ones passed in to init
  10260. var flashVars = _objectAssign2['default']({
  10261. // SWF Callback Functions
  10262. 'readyFunction': 'videojs.Flash.onReady',
  10263. 'eventProxyFunction': 'videojs.Flash.onEvent',
  10264. 'errorEventProxyFunction': 'videojs.Flash.onError',
  10265. // Player Settings
  10266. 'autoplay': options.autoplay,
  10267. 'preload': options.preload,
  10268. 'loop': options.loop,
  10269. 'muted': options.muted
  10270. }, options.flashVars);
  10271. // Merge default parames with ones passed in
  10272. var params = _objectAssign2['default']({
  10273. 'wmode': 'opaque', // Opaque is needed to overlay controls, but can affect playback performance
  10274. 'bgcolor': '#000000' // Using bgcolor prevents a white flash when the object is loading
  10275. }, options.params);
  10276. // Merge default attributes with ones passed in
  10277. var attributes = _objectAssign2['default']({
  10278. 'id': objId,
  10279. 'name': objId, // Both ID and Name needed or swf to identify itself
  10280. 'class': 'vjs-tech'
  10281. }, options.attributes);
  10282. this.el_ = Flash.embed(options.swf, flashVars, params, attributes);
  10283. this.el_.tech = this;
  10284. return this.el_;
  10285. };
  10286. /**
  10287. * Play for flash tech
  10288. *
  10289. * @method play
  10290. */
  10291. Flash.prototype.play = function play() {
  10292. if (this.ended()) {
  10293. this.setCurrentTime(0);
  10294. }
  10295. this.el_.vjs_play();
  10296. };
  10297. /**
  10298. * Pause for flash tech
  10299. *
  10300. * @method pause
  10301. */
  10302. Flash.prototype.pause = function pause() {
  10303. this.el_.vjs_pause();
  10304. };
  10305. /**
  10306. * Get/set video
  10307. *
  10308. * @param {Object=} src Source object
  10309. * @return {Object}
  10310. * @method src
  10311. */
  10312. Flash.prototype.src = function src(_src) {
  10313. if (_src === undefined) {
  10314. return this.currentSrc();
  10315. }
  10316. // Setting src through `src` not `setSrc` will be deprecated
  10317. return this.setSrc(_src);
  10318. };
  10319. /**
  10320. * Set video
  10321. *
  10322. * @param {Object=} src Source object
  10323. * @deprecated
  10324. * @method setSrc
  10325. */
  10326. Flash.prototype.setSrc = function setSrc(src) {
  10327. // Make sure source URL is absolute.
  10328. src = Url.getAbsoluteURL(src);
  10329. this.el_.vjs_src(src);
  10330. // Currently the SWF doesn't autoplay if you load a source later.
  10331. // e.g. Load player w/ no source, wait 2s, set src.
  10332. if (this.autoplay()) {
  10333. var tech = this;
  10334. this.setTimeout(function () {
  10335. tech.play();
  10336. }, 0);
  10337. }
  10338. };
  10339. /**
  10340. * Returns true if the tech is currently seeking.
  10341. * @return {boolean} true if seeking
  10342. */
  10343. Flash.prototype.seeking = function seeking() {
  10344. return this.lastSeekTarget_ !== undefined;
  10345. };
  10346. /**
  10347. * Set current time
  10348. *
  10349. * @param {Number} time Current time of video
  10350. * @method setCurrentTime
  10351. */
  10352. Flash.prototype.setCurrentTime = function setCurrentTime(time) {
  10353. var seekable = this.seekable();
  10354. if (seekable.length) {
  10355. // clamp to the current seekable range
  10356. time = time > seekable.start(0) ? time : seekable.start(0);
  10357. time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1);
  10358. this.lastSeekTarget_ = time;
  10359. this.trigger('seeking');
  10360. this.el_.vjs_setProperty('currentTime', time);
  10361. _Tech.prototype.setCurrentTime.call(this);
  10362. }
  10363. };
  10364. /**
  10365. * Get current time
  10366. *
  10367. * @param {Number=} time Current time of video
  10368. * @return {Number} Current time
  10369. * @method currentTime
  10370. */
  10371. Flash.prototype.currentTime = function currentTime(time) {
  10372. // when seeking make the reported time keep up with the requested time
  10373. // by reading the time we're seeking to
  10374. if (this.seeking()) {
  10375. return this.lastSeekTarget_ || 0;
  10376. }
  10377. return this.el_.vjs_getProperty('currentTime');
  10378. };
  10379. /**
  10380. * Get current source
  10381. *
  10382. * @method currentSrc
  10383. */
  10384. Flash.prototype.currentSrc = function currentSrc() {
  10385. if (this.currentSource_) {
  10386. return this.currentSource_.src;
  10387. } else {
  10388. return this.el_.vjs_getProperty('currentSrc');
  10389. }
  10390. };
  10391. /**
  10392. * Load media into player
  10393. *
  10394. * @method load
  10395. */
  10396. Flash.prototype.load = function load() {
  10397. this.el_.vjs_load();
  10398. };
  10399. /**
  10400. * Get poster
  10401. *
  10402. * @method poster
  10403. */
  10404. Flash.prototype.poster = function poster() {
  10405. this.el_.vjs_getProperty('poster');
  10406. };
  10407. /**
  10408. * Poster images are not handled by the Flash tech so make this a no-op
  10409. *
  10410. * @method setPoster
  10411. */
  10412. Flash.prototype.setPoster = function setPoster() {};
  10413. /**
  10414. * Determine if can seek in media
  10415. *
  10416. * @return {TimeRangeObject}
  10417. * @method seekable
  10418. */
  10419. Flash.prototype.seekable = function seekable() {
  10420. var duration = this.duration();
  10421. if (duration === 0) {
  10422. return _utilsTimeRangesJs.createTimeRange();
  10423. }
  10424. return _utilsTimeRangesJs.createTimeRange(0, duration);
  10425. };
  10426. /**
  10427. * Get buffered time range
  10428. *
  10429. * @return {TimeRangeObject}
  10430. * @method buffered
  10431. */
  10432. Flash.prototype.buffered = function buffered() {
  10433. var ranges = this.el_.vjs_getProperty('buffered');
  10434. if (ranges.length === 0) {
  10435. return _utilsTimeRangesJs.createTimeRange();
  10436. }
  10437. return _utilsTimeRangesJs.createTimeRange(ranges[0][0], ranges[0][1]);
  10438. };
  10439. /**
  10440. * Get fullscreen support -
  10441. * Flash does not allow fullscreen through javascript
  10442. * so always returns false
  10443. *
  10444. * @return {Boolean} false
  10445. * @method supportsFullScreen
  10446. */
  10447. Flash.prototype.supportsFullScreen = function supportsFullScreen() {
  10448. return false; // Flash does not allow fullscreen through javascript
  10449. };
  10450. /**
  10451. * Request to enter fullscreen
  10452. * Flash does not allow fullscreen through javascript
  10453. * so always returns false
  10454. *
  10455. * @return {Boolean} false
  10456. * @method enterFullScreen
  10457. */
  10458. Flash.prototype.enterFullScreen = function enterFullScreen() {
  10459. return false;
  10460. };
  10461. return Flash;
  10462. })(_tech2['default']);
  10463. var _api = Flash.prototype;
  10464. var _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
  10465. var _readOnly = 'networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(',');
  10466. function _createSetter(attr) {
  10467. var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
  10468. _api['set' + attrUpper] = function (val) {
  10469. return this.el_.vjs_setProperty(attr, val);
  10470. };
  10471. }
  10472. function _createGetter(attr) {
  10473. _api[attr] = function () {
  10474. return this.el_.vjs_getProperty(attr);
  10475. };
  10476. }
  10477. // Create getter and setters for all read/write attributes
  10478. for (var i = 0; i < _readWrite.length; i++) {
  10479. _createGetter(_readWrite[i]);
  10480. _createSetter(_readWrite[i]);
  10481. }
  10482. // Create getters for read-only attributes
  10483. for (var i = 0; i < _readOnly.length; i++) {
  10484. _createGetter(_readOnly[i]);
  10485. }
  10486. /* Flash Support Testing -------------------------------------------------------- */
  10487. Flash.isSupported = function () {
  10488. return Flash.version()[0] >= 10;
  10489. // return swfobject.hasFlashPlayerVersion('10');
  10490. };
  10491. // Add Source Handler pattern functions to this tech
  10492. _tech2['default'].withSourceHandlers(Flash);
  10493. /*
  10494. * The default native source handler.
  10495. * This simply passes the source to the video element. Nothing fancy.
  10496. *
  10497. * @param {Object} source The source object
  10498. * @param {Flash} tech The instance of the Flash tech
  10499. */
  10500. Flash.nativeSourceHandler = {};
  10501. /**
  10502. * Check if Flash can play the given videotype
  10503. * @param {String} type The mimetype to check
  10504. * @return {String} 'probably', 'maybe', or '' (empty string)
  10505. */
  10506. Flash.nativeSourceHandler.canPlayType = function (type) {
  10507. if (type in Flash.formats) {
  10508. return 'maybe';
  10509. }
  10510. return '';
  10511. };
  10512. /*
  10513. * Check Flash can handle the source natively
  10514. *
  10515. * @param {Object} source The source object
  10516. * @return {String} 'probably', 'maybe', or '' (empty string)
  10517. */
  10518. Flash.nativeSourceHandler.canHandleSource = function (source) {
  10519. var type;
  10520. function guessMimeType(src) {
  10521. var ext = Url.getFileExtension(src);
  10522. if (ext) {
  10523. return 'video/' + ext;
  10524. }
  10525. return '';
  10526. }
  10527. if (!source.type) {
  10528. type = guessMimeType(source.src);
  10529. } else {
  10530. // Strip code information from the type because we don't get that specific
  10531. type = source.type.replace(/;.*/, '').toLowerCase();
  10532. }
  10533. return Flash.nativeSourceHandler.canPlayType(type);
  10534. };
  10535. /*
  10536. * Pass the source to the flash object
  10537. * Adaptive source handlers will have more complicated workflows before passing
  10538. * video data to the video element
  10539. *
  10540. * @param {Object} source The source object
  10541. * @param {Flash} tech The instance of the Flash tech
  10542. */
  10543. Flash.nativeSourceHandler.handleSource = function (source, tech) {
  10544. tech.setSrc(source.src);
  10545. };
  10546. /*
  10547. * Clean up the source handler when disposing the player or switching sources..
  10548. * (no cleanup is needed when supporting the format natively)
  10549. */
  10550. Flash.nativeSourceHandler.dispose = function () {};
  10551. // Register the native source handler
  10552. Flash.registerSourceHandler(Flash.nativeSourceHandler);
  10553. Flash.formats = {
  10554. 'video/flv': 'FLV',
  10555. 'video/x-flv': 'FLV',
  10556. 'video/mp4': 'MP4',
  10557. 'video/m4v': 'MP4'
  10558. };
  10559. Flash.onReady = function (currSwf) {
  10560. var el = Dom.getEl(currSwf);
  10561. var tech = el && el.tech;
  10562. // if there is no el then the tech has been disposed
  10563. // and the tech element was removed from the player div
  10564. if (tech && tech.el()) {
  10565. // check that the flash object is really ready
  10566. Flash.checkReady(tech);
  10567. }
  10568. };
  10569. // The SWF isn't always ready when it says it is. Sometimes the API functions still need to be added to the object.
  10570. // If it's not ready, we set a timeout to check again shortly.
  10571. Flash.checkReady = function (tech) {
  10572. // stop worrying if the tech has been disposed
  10573. if (!tech.el()) {
  10574. return;
  10575. }
  10576. // check if API property exists
  10577. if (tech.el().vjs_getProperty) {
  10578. // tell tech it's ready
  10579. tech.triggerReady();
  10580. } else {
  10581. // wait longer
  10582. this.setTimeout(function () {
  10583. Flash['checkReady'](tech);
  10584. }, 50);
  10585. }
  10586. };
  10587. // Trigger events from the swf on the player
  10588. Flash.onEvent = function (swfID, eventName) {
  10589. var tech = Dom.getEl(swfID).tech;
  10590. tech.trigger(eventName);
  10591. };
  10592. // Log errors from the swf
  10593. Flash.onError = function (swfID, err) {
  10594. var tech = Dom.getEl(swfID).tech;
  10595. // trigger MEDIA_ERR_SRC_NOT_SUPPORTED
  10596. if (err === 'srcnotfound') {
  10597. return tech.error(4);
  10598. }
  10599. // trigger a custom error
  10600. tech.error('FLASH: ' + err);
  10601. };
  10602. // Flash Version Check
  10603. Flash.version = function () {
  10604. var version = '0,0,0';
  10605. // IE
  10606. try {
  10607. version = new _globalWindow2['default'].ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  10608. // other browsers
  10609. } catch (e) {
  10610. try {
  10611. if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
  10612. version = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  10613. }
  10614. } catch (err) {}
  10615. }
  10616. return version.split(',');
  10617. };
  10618. // Flash embedding method. Only used in non-iframe mode
  10619. Flash.embed = function (swf, flashVars, params, attributes) {
  10620. var code = Flash.getEmbedCode(swf, flashVars, params, attributes);
  10621. // Get element by embedding code and retrieving created element
  10622. var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0];
  10623. return obj;
  10624. };
  10625. Flash.getEmbedCode = function (swf, flashVars, params, attributes) {
  10626. var objTag = '<object type="application/x-shockwave-flash" ';
  10627. var flashVarsString = '';
  10628. var paramsString = '';
  10629. var attrsString = '';
  10630. // Convert flash vars to string
  10631. if (flashVars) {
  10632. Object.getOwnPropertyNames(flashVars).forEach(function (key) {
  10633. flashVarsString += key + '=' + flashVars[key] + '&amp;';
  10634. });
  10635. }
  10636. // Add swf, flashVars, and other default params
  10637. params = _objectAssign2['default']({
  10638. 'movie': swf,
  10639. 'flashvars': flashVarsString,
  10640. 'allowScriptAccess': 'always', // Required to talk to swf
  10641. 'allowNetworking': 'all' // All should be default, but having security issues.
  10642. }, params);
  10643. // Create param tags string
  10644. Object.getOwnPropertyNames(params).forEach(function (key) {
  10645. paramsString += '<param name="' + key + '" value="' + params[key] + '" />';
  10646. });
  10647. attributes = _objectAssign2['default']({
  10648. // Add swf to attributes (need both for IE and Others to work)
  10649. 'data': swf,
  10650. // Default to 100% width/height
  10651. 'width': '100%',
  10652. 'height': '100%'
  10653. }, attributes);
  10654. // Create Attributes string
  10655. Object.getOwnPropertyNames(attributes).forEach(function (key) {
  10656. attrsString += key + '="' + attributes[key] + '" ';
  10657. });
  10658. return '' + objTag + attrsString + '>' + paramsString + '</object>';
  10659. };
  10660. // Run Flash through the RTMP decorator
  10661. _flashRtmp2['default'](Flash);
  10662. _component2['default'].registerComponent('Flash', Flash);
  10663. _tech2['default'].registerTech('Flash', Flash);
  10664. exports['default'] = Flash;
  10665. module.exports = exports['default'];
  10666. },{"../component":65,"../utils/dom.js":128,"../utils/time-ranges.js":136,"../utils/url.js":138,"./flash-rtmp":111,"./tech":115,"global/window":2,"object.assign":45}],113:[function(_dereq_,module,exports){
  10667. /**
  10668. * @file html5.js
  10669. * HTML5 Media Controller - Wrapper for HTML5 Media API
  10670. */
  10671. 'use strict';
  10672. exports.__esModule = true;
  10673. 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; } }
  10674. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10675. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10676. 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; }
  10677. var _techJs = _dereq_('./tech.js');
  10678. var _techJs2 = _interopRequireDefault(_techJs);
  10679. var _component = _dereq_('../component');
  10680. var _component2 = _interopRequireDefault(_component);
  10681. var _utilsDomJs = _dereq_('../utils/dom.js');
  10682. var Dom = _interopRequireWildcard(_utilsDomJs);
  10683. var _utilsUrlJs = _dereq_('../utils/url.js');
  10684. var Url = _interopRequireWildcard(_utilsUrlJs);
  10685. var _utilsFnJs = _dereq_('../utils/fn.js');
  10686. var Fn = _interopRequireWildcard(_utilsFnJs);
  10687. var _utilsLogJs = _dereq_('../utils/log.js');
  10688. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  10689. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  10690. var browser = _interopRequireWildcard(_utilsBrowserJs);
  10691. var _globalDocument = _dereq_('global/document');
  10692. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  10693. var _globalWindow = _dereq_('global/window');
  10694. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  10695. var _objectAssign = _dereq_('object.assign');
  10696. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  10697. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js');
  10698. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  10699. /**
  10700. * HTML5 Media Controller - Wrapper for HTML5 Media API
  10701. *
  10702. * @param {Object=} options Object of option names and values
  10703. * @param {Function=} ready Ready callback function
  10704. * @extends Tech
  10705. * @class Html5
  10706. */
  10707. var Html5 = (function (_Tech) {
  10708. _inherits(Html5, _Tech);
  10709. function Html5(options, ready) {
  10710. _classCallCheck(this, Html5);
  10711. _Tech.call(this, options, ready);
  10712. var source = options.source;
  10713. // Set the source if one is provided
  10714. // 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted)
  10715. // 2) Check to see if the network state of the tag was failed at init, and if so, reset the source
  10716. // anyway so the error gets fired.
  10717. if (source && (this.el_.currentSrc !== source.src || options.tag && options.tag.initNetworkState_ === 3)) {
  10718. this.setSource(source);
  10719. } else {
  10720. this.handleLateInit_(this.el_);
  10721. }
  10722. if (this.el_.hasChildNodes()) {
  10723. var nodes = this.el_.childNodes;
  10724. var nodesLength = nodes.length;
  10725. var removeNodes = [];
  10726. while (nodesLength--) {
  10727. var node = nodes[nodesLength];
  10728. var nodeName = node.nodeName.toLowerCase();
  10729. if (nodeName === 'track') {
  10730. if (!this.featuresNativeTextTracks) {
  10731. // Empty video tag tracks so the built-in player doesn't use them also.
  10732. // This may not be fast enough to stop HTML5 browsers from reading the tags
  10733. // so we'll need to turn off any default tracks if we're manually doing
  10734. // captions and subtitles. videoElement.textTracks
  10735. removeNodes.push(node);
  10736. } else {
  10737. // store HTMLTrackElement and TextTrack to remote list
  10738. this.remoteTextTrackEls().addTrackElement_(node);
  10739. this.remoteTextTracks().addTrack_(node.track);
  10740. }
  10741. }
  10742. }
  10743. for (var i = 0; i < removeNodes.length; i++) {
  10744. this.el_.removeChild(removeNodes[i]);
  10745. }
  10746. }
  10747. if (this.featuresNativeTextTracks) {
  10748. this.handleTextTrackChange_ = Fn.bind(this, this.handleTextTrackChange);
  10749. this.handleTextTrackAdd_ = Fn.bind(this, this.handleTextTrackAdd);
  10750. this.handleTextTrackRemove_ = Fn.bind(this, this.handleTextTrackRemove);
  10751. this.proxyNativeTextTracks_();
  10752. }
  10753. // Determine if native controls should be used
  10754. // Our goal should be to get the custom controls on mobile solid everywhere
  10755. // so we can remove this all together. Right now this will block custom
  10756. // controls on touch enabled laptops like the Chrome Pixel
  10757. if (browser.TOUCH_ENABLED && options.nativeControlsForTouch === true || browser.IS_IPHONE || browser.IS_NATIVE_ANDROID) {
  10758. this.setControls(true);
  10759. }
  10760. this.triggerReady();
  10761. }
  10762. /* HTML5 Support Testing ---------------------------------------------------- */
  10763. /*
  10764. * Element for testing browser HTML5 video capabilities
  10765. *
  10766. * @type {Element}
  10767. * @constant
  10768. * @private
  10769. */
  10770. /**
  10771. * Dispose of html5 media element
  10772. *
  10773. * @method dispose
  10774. */
  10775. Html5.prototype.dispose = function dispose() {
  10776. var tt = this.el().textTracks;
  10777. var emulatedTt = this.textTracks();
  10778. // remove native event listeners
  10779. if (tt && tt.removeEventListener) {
  10780. tt.removeEventListener('change', this.handleTextTrackChange_);
  10781. tt.removeEventListener('addtrack', this.handleTextTrackAdd_);
  10782. tt.removeEventListener('removetrack', this.handleTextTrackRemove_);
  10783. }
  10784. // clearout the emulated text track list.
  10785. var i = emulatedTt.length;
  10786. while (i--) {
  10787. emulatedTt.removeTrack_(emulatedTt[i]);
  10788. }
  10789. Html5.disposeMediaElement(this.el_);
  10790. _Tech.prototype.dispose.call(this);
  10791. };
  10792. /**
  10793. * Create the component's DOM element
  10794. *
  10795. * @return {Element}
  10796. * @method createEl
  10797. */
  10798. Html5.prototype.createEl = function createEl() {
  10799. var el = this.options_.tag;
  10800. // Check if this browser supports moving the element into the box.
  10801. // On the iPhone video will break if you move the element,
  10802. // So we have to create a brand new element.
  10803. if (!el || this['movingMediaElementInDOM'] === false) {
  10804. // If the original tag is still there, clone and remove it.
  10805. if (el) {
  10806. var clone = el.cloneNode(true);
  10807. el.parentNode.insertBefore(clone, el);
  10808. Html5.disposeMediaElement(el);
  10809. el = clone;
  10810. } else {
  10811. el = _globalDocument2['default'].createElement('video');
  10812. // determine if native controls should be used
  10813. var tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag);
  10814. var attributes = _utilsMergeOptionsJs2['default']({}, tagAttributes);
  10815. if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
  10816. delete attributes.controls;
  10817. }
  10818. Dom.setElAttributes(el, _objectAssign2['default'](attributes, {
  10819. id: this.options_.techId,
  10820. 'class': 'vjs-tech'
  10821. }));
  10822. }
  10823. }
  10824. // Update specific tag settings, in case they were overridden
  10825. var settingsAttrs = ['autoplay', 'preload', 'loop', 'muted'];
  10826. for (var i = settingsAttrs.length - 1; i >= 0; i--) {
  10827. var attr = settingsAttrs[i];
  10828. var overwriteAttrs = {};
  10829. if (typeof this.options_[attr] !== 'undefined') {
  10830. overwriteAttrs[attr] = this.options_[attr];
  10831. }
  10832. Dom.setElAttributes(el, overwriteAttrs);
  10833. }
  10834. return el;
  10835. // jenniisawesome = true;
  10836. };
  10837. // If we're loading the playback object after it has started loading
  10838. // or playing the video (often with autoplay on) then the loadstart event
  10839. // has already fired and we need to fire it manually because many things
  10840. // rely on it.
  10841. Html5.prototype.handleLateInit_ = function handleLateInit_(el) {
  10842. var _this = this;
  10843. if (el.networkState === 0 || el.networkState === 3) {
  10844. // The video element hasn't started loading the source yet
  10845. // or didn't find a source
  10846. return;
  10847. }
  10848. if (el.readyState === 0) {
  10849. var _ret = (function () {
  10850. // NetworkState is set synchronously BUT loadstart is fired at the
  10851. // end of the current stack, usually before setInterval(fn, 0).
  10852. // So at this point we know loadstart may have already fired or is
  10853. // about to fire, and either way the player hasn't seen it yet.
  10854. // We don't want to fire loadstart prematurely here and cause a
  10855. // double loadstart so we'll wait and see if it happens between now
  10856. // and the next loop, and fire it if not.
  10857. // HOWEVER, we also want to make sure it fires before loadedmetadata
  10858. // which could also happen between now and the next loop, so we'll
  10859. // watch for that also.
  10860. var loadstartFired = false;
  10861. var setLoadstartFired = function setLoadstartFired() {
  10862. loadstartFired = true;
  10863. };
  10864. _this.on('loadstart', setLoadstartFired);
  10865. var triggerLoadstart = function triggerLoadstart() {
  10866. // We did miss the original loadstart. Make sure the player
  10867. // sees loadstart before loadedmetadata
  10868. if (!loadstartFired) {
  10869. this.trigger('loadstart');
  10870. }
  10871. };
  10872. _this.on('loadedmetadata', triggerLoadstart);
  10873. _this.ready(function () {
  10874. this.off('loadstart', setLoadstartFired);
  10875. this.off('loadedmetadata', triggerLoadstart);
  10876. if (!loadstartFired) {
  10877. // We did miss the original native loadstart. Fire it now.
  10878. this.trigger('loadstart');
  10879. }
  10880. });
  10881. return {
  10882. v: undefined
  10883. };
  10884. })();
  10885. if (typeof _ret === 'object') return _ret.v;
  10886. }
  10887. // From here on we know that loadstart already fired and we missed it.
  10888. // The other readyState events aren't as much of a problem if we double
  10889. // them, so not going to go to as much trouble as loadstart to prevent
  10890. // that unless we find reason to.
  10891. var eventsToTrigger = ['loadstart'];
  10892. // loadedmetadata: newly equal to HAVE_METADATA (1) or greater
  10893. eventsToTrigger.push('loadedmetadata');
  10894. // loadeddata: newly increased to HAVE_CURRENT_DATA (2) or greater
  10895. if (el.readyState >= 2) {
  10896. eventsToTrigger.push('loadeddata');
  10897. }
  10898. // canplay: newly increased to HAVE_FUTURE_DATA (3) or greater
  10899. if (el.readyState >= 3) {
  10900. eventsToTrigger.push('canplay');
  10901. }
  10902. // canplaythrough: newly equal to HAVE_ENOUGH_DATA (4)
  10903. if (el.readyState >= 4) {
  10904. eventsToTrigger.push('canplaythrough');
  10905. }
  10906. // We still need to give the player time to add event listeners
  10907. this.ready(function () {
  10908. eventsToTrigger.forEach(function (type) {
  10909. this.trigger(type);
  10910. }, this);
  10911. });
  10912. };
  10913. Html5.prototype.proxyNativeTextTracks_ = function proxyNativeTextTracks_() {
  10914. var tt = this.el().textTracks;
  10915. if (tt && tt.addEventListener) {
  10916. tt.addEventListener('change', this.handleTextTrackChange_);
  10917. tt.addEventListener('addtrack', this.handleTextTrackAdd_);
  10918. tt.addEventListener('removetrack', this.handleTextTrackRemove_);
  10919. }
  10920. };
  10921. Html5.prototype.handleTextTrackChange = function handleTextTrackChange(e) {
  10922. var tt = this.textTracks();
  10923. this.textTracks().trigger({
  10924. type: 'change',
  10925. target: tt,
  10926. currentTarget: tt,
  10927. srcElement: tt
  10928. });
  10929. };
  10930. Html5.prototype.handleTextTrackAdd = function handleTextTrackAdd(e) {
  10931. this.textTracks().addTrack_(e.track);
  10932. };
  10933. Html5.prototype.handleTextTrackRemove = function handleTextTrackRemove(e) {
  10934. this.textTracks().removeTrack_(e.track);
  10935. };
  10936. /**
  10937. * Play for html5 tech
  10938. *
  10939. * @method play
  10940. */
  10941. Html5.prototype.play = function play() {
  10942. this.el_.play();
  10943. };
  10944. /**
  10945. * Pause for html5 tech
  10946. *
  10947. * @method pause
  10948. */
  10949. Html5.prototype.pause = function pause() {
  10950. this.el_.pause();
  10951. };
  10952. /**
  10953. * Paused for html5 tech
  10954. *
  10955. * @return {Boolean}
  10956. * @method paused
  10957. */
  10958. Html5.prototype.paused = function paused() {
  10959. return this.el_.paused;
  10960. };
  10961. /**
  10962. * Get current time
  10963. *
  10964. * @return {Number}
  10965. * @method currentTime
  10966. */
  10967. Html5.prototype.currentTime = function currentTime() {
  10968. return this.el_.currentTime;
  10969. };
  10970. /**
  10971. * Set current time
  10972. *
  10973. * @param {Number} seconds Current time of video
  10974. * @method setCurrentTime
  10975. */
  10976. Html5.prototype.setCurrentTime = function setCurrentTime(seconds) {
  10977. try {
  10978. this.el_.currentTime = seconds;
  10979. } catch (e) {
  10980. _utilsLogJs2['default'](e, 'Video is not ready. (Video.js)');
  10981. // this.warning(VideoJS.warnings.videoNotReady);
  10982. }
  10983. };
  10984. /**
  10985. * Get duration
  10986. *
  10987. * @return {Number}
  10988. * @method duration
  10989. */
  10990. Html5.prototype.duration = function duration() {
  10991. return this.el_.duration || 0;
  10992. };
  10993. /**
  10994. * Get a TimeRange object that represents the intersection
  10995. * of the time ranges for which the user agent has all
  10996. * relevant media
  10997. *
  10998. * @return {TimeRangeObject}
  10999. * @method buffered
  11000. */
  11001. Html5.prototype.buffered = function buffered() {
  11002. return this.el_.buffered;
  11003. };
  11004. /**
  11005. * Get volume level
  11006. *
  11007. * @return {Number}
  11008. * @method volume
  11009. */
  11010. Html5.prototype.volume = function volume() {
  11011. return this.el_.volume;
  11012. };
  11013. /**
  11014. * Set volume level
  11015. *
  11016. * @param {Number} percentAsDecimal Volume percent as a decimal
  11017. * @method setVolume
  11018. */
  11019. Html5.prototype.setVolume = function setVolume(percentAsDecimal) {
  11020. this.el_.volume = percentAsDecimal;
  11021. };
  11022. /**
  11023. * Get if muted
  11024. *
  11025. * @return {Boolean}
  11026. * @method muted
  11027. */
  11028. Html5.prototype.muted = function muted() {
  11029. return this.el_.muted;
  11030. };
  11031. /**
  11032. * Set muted
  11033. *
  11034. * @param {Boolean} If player is to be muted or note
  11035. * @method setMuted
  11036. */
  11037. Html5.prototype.setMuted = function setMuted(muted) {
  11038. this.el_.muted = muted;
  11039. };
  11040. /**
  11041. * Get player width
  11042. *
  11043. * @return {Number}
  11044. * @method width
  11045. */
  11046. Html5.prototype.width = function width() {
  11047. return this.el_.offsetWidth;
  11048. };
  11049. /**
  11050. * Get player height
  11051. *
  11052. * @return {Number}
  11053. * @method height
  11054. */
  11055. Html5.prototype.height = function height() {
  11056. return this.el_.offsetHeight;
  11057. };
  11058. /**
  11059. * Get if there is fullscreen support
  11060. *
  11061. * @return {Boolean}
  11062. * @method supportsFullScreen
  11063. */
  11064. Html5.prototype.supportsFullScreen = function supportsFullScreen() {
  11065. if (typeof this.el_.webkitEnterFullScreen === 'function') {
  11066. var userAgent = _globalWindow2['default'].navigator.userAgent;
  11067. // Seems to be broken in Chromium/Chrome && Safari in Leopard
  11068. if (/Android/.test(userAgent) || !/Chrome|Mac OS X 10.5/.test(userAgent)) {
  11069. return true;
  11070. }
  11071. }
  11072. return false;
  11073. };
  11074. /**
  11075. * Request to enter fullscreen
  11076. *
  11077. * @method enterFullScreen
  11078. */
  11079. Html5.prototype.enterFullScreen = function enterFullScreen() {
  11080. var video = this.el_;
  11081. if ('webkitDisplayingFullscreen' in video) {
  11082. this.one('webkitbeginfullscreen', function () {
  11083. this.one('webkitendfullscreen', function () {
  11084. this.trigger('fullscreenchange', { isFullscreen: false });
  11085. });
  11086. this.trigger('fullscreenchange', { isFullscreen: true });
  11087. });
  11088. }
  11089. if (video.paused && video.networkState <= video.HAVE_METADATA) {
  11090. // attempt to prime the video element for programmatic access
  11091. // this isn't necessary on the desktop but shouldn't hurt
  11092. this.el_.play();
  11093. // playing and pausing synchronously during the transition to fullscreen
  11094. // can get iOS ~6.1 devices into a play/pause loop
  11095. this.setTimeout(function () {
  11096. video.pause();
  11097. video.webkitEnterFullScreen();
  11098. }, 0);
  11099. } else {
  11100. video.webkitEnterFullScreen();
  11101. }
  11102. };
  11103. /**
  11104. * Request to exit fullscreen
  11105. *
  11106. * @method exitFullScreen
  11107. */
  11108. Html5.prototype.exitFullScreen = function exitFullScreen() {
  11109. this.el_.webkitExitFullScreen();
  11110. };
  11111. /**
  11112. * Get/set video
  11113. *
  11114. * @param {Object=} src Source object
  11115. * @return {Object}
  11116. * @method src
  11117. */
  11118. Html5.prototype.src = function src(_src) {
  11119. if (_src === undefined) {
  11120. return this.el_.src;
  11121. } else {
  11122. // Setting src through `src` instead of `setSrc` will be deprecated
  11123. this.setSrc(_src);
  11124. }
  11125. };
  11126. /**
  11127. * Set video
  11128. *
  11129. * @param {Object} src Source object
  11130. * @deprecated
  11131. * @method setSrc
  11132. */
  11133. Html5.prototype.setSrc = function setSrc(src) {
  11134. this.el_.src = src;
  11135. };
  11136. /**
  11137. * Load media into player
  11138. *
  11139. * @method load
  11140. */
  11141. Html5.prototype.load = function load() {
  11142. this.el_.load();
  11143. };
  11144. /**
  11145. * Reset the tech. Removes all sources and calls `load`.
  11146. *
  11147. * @method reset
  11148. */
  11149. Html5.prototype.reset = function reset() {
  11150. Html5.resetMediaElement(this.el_);
  11151. };
  11152. /**
  11153. * Get current source
  11154. *
  11155. * @return {Object}
  11156. * @method currentSrc
  11157. */
  11158. Html5.prototype.currentSrc = function currentSrc() {
  11159. if (this.currentSource_) {
  11160. return this.currentSource_.src;
  11161. } else {
  11162. return this.el_.currentSrc;
  11163. }
  11164. };
  11165. /**
  11166. * Get poster
  11167. *
  11168. * @return {String}
  11169. * @method poster
  11170. */
  11171. Html5.prototype.poster = function poster() {
  11172. return this.el_.poster;
  11173. };
  11174. /**
  11175. * Set poster
  11176. *
  11177. * @param {String} val URL to poster image
  11178. * @method
  11179. */
  11180. Html5.prototype.setPoster = function setPoster(val) {
  11181. this.el_.poster = val;
  11182. };
  11183. /**
  11184. * Get preload attribute
  11185. *
  11186. * @return {String}
  11187. * @method preload
  11188. */
  11189. Html5.prototype.preload = function preload() {
  11190. return this.el_.preload;
  11191. };
  11192. /**
  11193. * Set preload attribute
  11194. *
  11195. * @param {String} val Value for preload attribute
  11196. * @method setPreload
  11197. */
  11198. Html5.prototype.setPreload = function setPreload(val) {
  11199. this.el_.preload = val;
  11200. };
  11201. /**
  11202. * Get autoplay attribute
  11203. *
  11204. * @return {String}
  11205. * @method autoplay
  11206. */
  11207. Html5.prototype.autoplay = function autoplay() {
  11208. return this.el_.autoplay;
  11209. };
  11210. /**
  11211. * Set autoplay attribute
  11212. *
  11213. * @param {String} val Value for preload attribute
  11214. * @method setAutoplay
  11215. */
  11216. Html5.prototype.setAutoplay = function setAutoplay(val) {
  11217. this.el_.autoplay = val;
  11218. };
  11219. /**
  11220. * Get controls attribute
  11221. *
  11222. * @return {String}
  11223. * @method controls
  11224. */
  11225. Html5.prototype.controls = function controls() {
  11226. return this.el_.controls;
  11227. };
  11228. /**
  11229. * Set controls attribute
  11230. *
  11231. * @param {String} val Value for controls attribute
  11232. * @method setControls
  11233. */
  11234. Html5.prototype.setControls = function setControls(val) {
  11235. this.el_.controls = !!val;
  11236. };
  11237. /**
  11238. * Get loop attribute
  11239. *
  11240. * @return {String}
  11241. * @method loop
  11242. */
  11243. Html5.prototype.loop = function loop() {
  11244. return this.el_.loop;
  11245. };
  11246. /**
  11247. * Set loop attribute
  11248. *
  11249. * @param {String} val Value for loop attribute
  11250. * @method setLoop
  11251. */
  11252. Html5.prototype.setLoop = function setLoop(val) {
  11253. this.el_.loop = val;
  11254. };
  11255. /**
  11256. * Get error value
  11257. *
  11258. * @return {String}
  11259. * @method error
  11260. */
  11261. Html5.prototype.error = function error() {
  11262. return this.el_.error;
  11263. };
  11264. /**
  11265. * Get whether or not the player is in the "seeking" state
  11266. *
  11267. * @return {Boolean}
  11268. * @method seeking
  11269. */
  11270. Html5.prototype.seeking = function seeking() {
  11271. return this.el_.seeking;
  11272. };
  11273. /**
  11274. * Get a TimeRanges object that represents the
  11275. * ranges of the media resource to which it is possible
  11276. * for the user agent to seek.
  11277. *
  11278. * @return {TimeRangeObject}
  11279. * @method seekable
  11280. */
  11281. Html5.prototype.seekable = function seekable() {
  11282. return this.el_.seekable;
  11283. };
  11284. /**
  11285. * Get if video ended
  11286. *
  11287. * @return {Boolean}
  11288. * @method ended
  11289. */
  11290. Html5.prototype.ended = function ended() {
  11291. return this.el_.ended;
  11292. };
  11293. /**
  11294. * Get the value of the muted content attribute
  11295. * This attribute has no dynamic effect, it only
  11296. * controls the default state of the element
  11297. *
  11298. * @return {Boolean}
  11299. * @method defaultMuted
  11300. */
  11301. Html5.prototype.defaultMuted = function defaultMuted() {
  11302. return this.el_.defaultMuted;
  11303. };
  11304. /**
  11305. * Get desired speed at which the media resource is to play
  11306. *
  11307. * @return {Number}
  11308. * @method playbackRate
  11309. */
  11310. Html5.prototype.playbackRate = function playbackRate() {
  11311. return this.el_.playbackRate;
  11312. };
  11313. /**
  11314. * Returns a TimeRanges object that represents the ranges of the
  11315. * media resource that the user agent has played.
  11316. * @return {TimeRangeObject} the range of points on the media
  11317. * timeline that has been reached through normal playback
  11318. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-played
  11319. */
  11320. Html5.prototype.played = function played() {
  11321. return this.el_.played;
  11322. };
  11323. /**
  11324. * Set desired speed at which the media resource is to play
  11325. *
  11326. * @param {Number} val Speed at which the media resource is to play
  11327. * @method setPlaybackRate
  11328. */
  11329. Html5.prototype.setPlaybackRate = function setPlaybackRate(val) {
  11330. this.el_.playbackRate = val;
  11331. };
  11332. /**
  11333. * Get the current state of network activity for the element, from
  11334. * the list below
  11335. * NETWORK_EMPTY (numeric value 0)
  11336. * NETWORK_IDLE (numeric value 1)
  11337. * NETWORK_LOADING (numeric value 2)
  11338. * NETWORK_NO_SOURCE (numeric value 3)
  11339. *
  11340. * @return {Number}
  11341. * @method networkState
  11342. */
  11343. Html5.prototype.networkState = function networkState() {
  11344. return this.el_.networkState;
  11345. };
  11346. /**
  11347. * Get a value that expresses the current state of the element
  11348. * with respect to rendering the current playback position, from
  11349. * the codes in the list below
  11350. * HAVE_NOTHING (numeric value 0)
  11351. * HAVE_METADATA (numeric value 1)
  11352. * HAVE_CURRENT_DATA (numeric value 2)
  11353. * HAVE_FUTURE_DATA (numeric value 3)
  11354. * HAVE_ENOUGH_DATA (numeric value 4)
  11355. *
  11356. * @return {Number}
  11357. * @method readyState
  11358. */
  11359. Html5.prototype.readyState = function readyState() {
  11360. return this.el_.readyState;
  11361. };
  11362. /**
  11363. * Get width of video
  11364. *
  11365. * @return {Number}
  11366. * @method videoWidth
  11367. */
  11368. Html5.prototype.videoWidth = function videoWidth() {
  11369. return this.el_.videoWidth;
  11370. };
  11371. /**
  11372. * Get height of video
  11373. *
  11374. * @return {Number}
  11375. * @method videoHeight
  11376. */
  11377. Html5.prototype.videoHeight = function videoHeight() {
  11378. return this.el_.videoHeight;
  11379. };
  11380. /**
  11381. * Get text tracks
  11382. *
  11383. * @return {TextTrackList}
  11384. * @method textTracks
  11385. */
  11386. Html5.prototype.textTracks = function textTracks() {
  11387. return _Tech.prototype.textTracks.call(this);
  11388. };
  11389. /**
  11390. * Creates and returns a text track object
  11391. *
  11392. * @param {String} kind Text track kind (subtitles, captions, descriptions
  11393. * chapters and metadata)
  11394. * @param {String=} label Label to identify the text track
  11395. * @param {String=} language Two letter language abbreviation
  11396. * @return {TextTrackObject}
  11397. * @method addTextTrack
  11398. */
  11399. Html5.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  11400. if (!this['featuresNativeTextTracks']) {
  11401. return _Tech.prototype.addTextTrack.call(this, kind, label, language);
  11402. }
  11403. return this.el_.addTextTrack(kind, label, language);
  11404. };
  11405. /**
  11406. * Creates a remote text track object and returns a html track element
  11407. *
  11408. * @param {Object} options The object should contain values for
  11409. * kind, language, label and src (location of the WebVTT file)
  11410. * @return {HTMLTrackElement}
  11411. * @method addRemoteTextTrack
  11412. */
  11413. Html5.prototype.addRemoteTextTrack = function addRemoteTextTrack() {
  11414. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  11415. if (!this['featuresNativeTextTracks']) {
  11416. return _Tech.prototype.addRemoteTextTrack.call(this, options);
  11417. }
  11418. var htmlTrackElement = _globalDocument2['default'].createElement('track');
  11419. if (options.kind) {
  11420. htmlTrackElement.kind = options.kind;
  11421. }
  11422. if (options.label) {
  11423. htmlTrackElement.label = options.label;
  11424. }
  11425. if (options.language || options.srclang) {
  11426. htmlTrackElement.srclang = options.language || options.srclang;
  11427. }
  11428. if (options['default']) {
  11429. htmlTrackElement['default'] = options['default'];
  11430. }
  11431. if (options.id) {
  11432. htmlTrackElement.id = options.id;
  11433. }
  11434. if (options.src) {
  11435. htmlTrackElement.src = options.src;
  11436. }
  11437. this.el().appendChild(htmlTrackElement);
  11438. // store HTMLTrackElement and TextTrack to remote list
  11439. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
  11440. this.remoteTextTracks().addTrack_(htmlTrackElement.track);
  11441. return htmlTrackElement;
  11442. };
  11443. /**
  11444. * Remove remote text track from TextTrackList object
  11445. *
  11446. * @param {TextTrackObject} track Texttrack object to remove
  11447. * @method removeRemoteTextTrack
  11448. */
  11449. Html5.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  11450. if (!this['featuresNativeTextTracks']) {
  11451. return _Tech.prototype.removeRemoteTextTrack.call(this, track);
  11452. }
  11453. var tracks = undefined,
  11454. i = undefined;
  11455. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
  11456. // remove HTMLTrackElement and TextTrack from remote list
  11457. this.remoteTextTrackEls().removeTrackElement_(trackElement);
  11458. this.remoteTextTracks().removeTrack_(track);
  11459. tracks = this.$$('track');
  11460. i = tracks.length;
  11461. while (i--) {
  11462. if (track === tracks[i] || track === tracks[i].track) {
  11463. this.el().removeChild(tracks[i]);
  11464. }
  11465. }
  11466. };
  11467. return Html5;
  11468. })(_techJs2['default']);
  11469. Html5.TEST_VID = _globalDocument2['default'].createElement('video');
  11470. var track = _globalDocument2['default'].createElement('track');
  11471. track.kind = 'captions';
  11472. track.srclang = 'en';
  11473. track.label = 'English';
  11474. Html5.TEST_VID.appendChild(track);
  11475. /*
  11476. * Check if HTML5 video is supported by this browser/device
  11477. *
  11478. * @return {Boolean}
  11479. */
  11480. Html5.isSupported = function () {
  11481. // IE9 with no Media Player is a LIAR! (#984)
  11482. try {
  11483. Html5.TEST_VID['volume'] = 0.5;
  11484. } catch (e) {
  11485. return false;
  11486. }
  11487. return !!Html5.TEST_VID.canPlayType;
  11488. };
  11489. // Add Source Handler pattern functions to this tech
  11490. _techJs2['default'].withSourceHandlers(Html5);
  11491. /*
  11492. * The default native source handler.
  11493. * This simply passes the source to the video element. Nothing fancy.
  11494. *
  11495. * @param {Object} source The source object
  11496. * @param {Html5} tech The instance of the HTML5 tech
  11497. */
  11498. Html5.nativeSourceHandler = {};
  11499. /*
  11500. * Check if the video element can play the given videotype
  11501. *
  11502. * @param {String} type The mimetype to check
  11503. * @return {String} 'probably', 'maybe', or '' (empty string)
  11504. */
  11505. Html5.nativeSourceHandler.canPlayType = function (type) {
  11506. // IE9 on Windows 7 without MediaPlayer throws an error here
  11507. // https://github.com/videojs/video.js/issues/519
  11508. try {
  11509. return Html5.TEST_VID.canPlayType(type);
  11510. } catch (e) {
  11511. return '';
  11512. }
  11513. };
  11514. /*
  11515. * Check if the video element can handle the source natively
  11516. *
  11517. * @param {Object} source The source object
  11518. * @return {String} 'probably', 'maybe', or '' (empty string)
  11519. */
  11520. Html5.nativeSourceHandler.canHandleSource = function (source) {
  11521. var match, ext;
  11522. // If a type was provided we should rely on that
  11523. if (source.type) {
  11524. return Html5.nativeSourceHandler.canPlayType(source.type);
  11525. } else if (source.src) {
  11526. // If no type, fall back to checking 'video/[EXTENSION]'
  11527. ext = Url.getFileExtension(source.src);
  11528. return Html5.nativeSourceHandler.canPlayType('video/' + ext);
  11529. }
  11530. return '';
  11531. };
  11532. /*
  11533. * Pass the source to the video element
  11534. * Adaptive source handlers will have more complicated workflows before passing
  11535. * video data to the video element
  11536. *
  11537. * @param {Object} source The source object
  11538. * @param {Html5} tech The instance of the Html5 tech
  11539. */
  11540. Html5.nativeSourceHandler.handleSource = function (source, tech) {
  11541. tech.setSrc(source.src);
  11542. };
  11543. /*
  11544. * Clean up the source handler when disposing the player or switching sources..
  11545. * (no cleanup is needed when supporting the format natively)
  11546. */
  11547. Html5.nativeSourceHandler.dispose = function () {};
  11548. // Register the native source handler
  11549. Html5.registerSourceHandler(Html5.nativeSourceHandler);
  11550. /*
  11551. * Check if the volume can be changed in this browser/device.
  11552. * Volume cannot be changed in a lot of mobile devices.
  11553. * Specifically, it can't be changed from 1 on iOS.
  11554. *
  11555. * @return {Boolean}
  11556. */
  11557. Html5.canControlVolume = function () {
  11558. var volume = Html5.TEST_VID.volume;
  11559. Html5.TEST_VID.volume = volume / 2 + 0.1;
  11560. return volume !== Html5.TEST_VID.volume;
  11561. };
  11562. /*
  11563. * Check if playbackRate is supported in this browser/device.
  11564. *
  11565. * @return {Number} [description]
  11566. */
  11567. Html5.canControlPlaybackRate = function () {
  11568. var playbackRate = Html5.TEST_VID.playbackRate;
  11569. Html5.TEST_VID.playbackRate = playbackRate / 2 + 0.1;
  11570. return playbackRate !== Html5.TEST_VID.playbackRate;
  11571. };
  11572. /*
  11573. * Check to see if native text tracks are supported by this browser/device
  11574. *
  11575. * @return {Boolean}
  11576. */
  11577. Html5.supportsNativeTextTracks = function () {
  11578. var supportsTextTracks;
  11579. // Figure out native text track support
  11580. // If mode is a number, we cannot change it because it'll disappear from view.
  11581. // Browsers with numeric modes include IE10 and older (<=2013) samsung android models.
  11582. // Firefox isn't playing nice either with modifying the mode
  11583. // TODO: Investigate firefox: https://github.com/videojs/video.js/issues/1862
  11584. supportsTextTracks = !!Html5.TEST_VID.textTracks;
  11585. if (supportsTextTracks && Html5.TEST_VID.textTracks.length > 0) {
  11586. supportsTextTracks = typeof Html5.TEST_VID.textTracks[0]['mode'] !== 'number';
  11587. }
  11588. if (supportsTextTracks && browser.IS_FIREFOX) {
  11589. supportsTextTracks = false;
  11590. }
  11591. if (supportsTextTracks && !('onremovetrack' in Html5.TEST_VID.textTracks)) {
  11592. supportsTextTracks = false;
  11593. }
  11594. return supportsTextTracks;
  11595. };
  11596. /**
  11597. * An array of events available on the Html5 tech.
  11598. *
  11599. * @private
  11600. * @type {Array}
  11601. */
  11602. Html5.Events = ['loadstart', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', 'playing', 'waiting', 'seeking', 'seeked', 'ended', 'durationchange', 'timeupdate', 'progress', 'play', 'pause', 'ratechange', 'volumechange'];
  11603. /*
  11604. * Set the tech's volume control support status
  11605. *
  11606. * @type {Boolean}
  11607. */
  11608. Html5.prototype['featuresVolumeControl'] = Html5.canControlVolume();
  11609. /*
  11610. * Set the tech's playbackRate support status
  11611. *
  11612. * @type {Boolean}
  11613. */
  11614. Html5.prototype['featuresPlaybackRate'] = Html5.canControlPlaybackRate();
  11615. /*
  11616. * Set the tech's status on moving the video element.
  11617. * In iOS, if you move a video element in the DOM, it breaks video playback.
  11618. *
  11619. * @type {Boolean}
  11620. */
  11621. Html5.prototype['movingMediaElementInDOM'] = !browser.IS_IOS;
  11622. /*
  11623. * Set the the tech's fullscreen resize support status.
  11624. * HTML video is able to automatically resize when going to fullscreen.
  11625. * (No longer appears to be used. Can probably be removed.)
  11626. */
  11627. Html5.prototype['featuresFullscreenResize'] = true;
  11628. /*
  11629. * Set the tech's progress event support status
  11630. * (this disables the manual progress events of the Tech)
  11631. */
  11632. Html5.prototype['featuresProgressEvents'] = true;
  11633. /*
  11634. * Sets the tech's status on native text track support
  11635. *
  11636. * @type {Boolean}
  11637. */
  11638. Html5.prototype['featuresNativeTextTracks'] = Html5.supportsNativeTextTracks();
  11639. // HTML5 Feature detection and Device Fixes --------------------------------- //
  11640. var canPlayType = undefined;
  11641. var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i;
  11642. var mp4RE = /^video\/mp4/i;
  11643. Html5.patchCanPlayType = function () {
  11644. // Android 4.0 and above can play HLS to some extent but it reports being unable to do so
  11645. if (browser.ANDROID_VERSION >= 4.0) {
  11646. if (!canPlayType) {
  11647. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
  11648. }
  11649. Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
  11650. if (type && mpegurlRE.test(type)) {
  11651. return 'maybe';
  11652. }
  11653. return canPlayType.call(this, type);
  11654. };
  11655. }
  11656. // Override Android 2.2 and less canPlayType method which is broken
  11657. if (browser.IS_OLD_ANDROID) {
  11658. if (!canPlayType) {
  11659. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
  11660. }
  11661. Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
  11662. if (type && mp4RE.test(type)) {
  11663. return 'maybe';
  11664. }
  11665. return canPlayType.call(this, type);
  11666. };
  11667. }
  11668. };
  11669. Html5.unpatchCanPlayType = function () {
  11670. var r = Html5.TEST_VID.constructor.prototype.canPlayType;
  11671. Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType;
  11672. canPlayType = null;
  11673. return r;
  11674. };
  11675. // by default, patch the video element
  11676. Html5.patchCanPlayType();
  11677. Html5.disposeMediaElement = function (el) {
  11678. if (!el) {
  11679. return;
  11680. }
  11681. if (el.parentNode) {
  11682. el.parentNode.removeChild(el);
  11683. }
  11684. // remove any child track or source nodes to prevent their loading
  11685. while (el.hasChildNodes()) {
  11686. el.removeChild(el.firstChild);
  11687. }
  11688. // remove any src reference. not setting `src=''` because that causes a warning
  11689. // in firefox
  11690. el.removeAttribute('src');
  11691. // force the media element to update its loading state by calling load()
  11692. // however IE on Windows 7N has a bug that throws an error so need a try/catch (#793)
  11693. if (typeof el.load === 'function') {
  11694. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  11695. (function () {
  11696. try {
  11697. el.load();
  11698. } catch (e) {
  11699. // not supported
  11700. }
  11701. })();
  11702. }
  11703. };
  11704. Html5.resetMediaElement = function (el) {
  11705. if (!el) {
  11706. return;
  11707. }
  11708. var sources = el.querySelectorAll('source');
  11709. var i = sources.length;
  11710. while (i--) {
  11711. el.removeChild(sources[i]);
  11712. }
  11713. // remove any src reference.
  11714. // not setting `src=''` because that throws an error
  11715. el.removeAttribute('src');
  11716. if (typeof el.load === 'function') {
  11717. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  11718. (function () {
  11719. try {
  11720. el.load();
  11721. } catch (e) {}
  11722. })();
  11723. }
  11724. };
  11725. _component2['default'].registerComponent('Html5', Html5);
  11726. _techJs2['default'].registerTech('Html5', Html5);
  11727. exports['default'] = Html5;
  11728. module.exports = exports['default'];
  11729. },{"../component":65,"../utils/browser.js":125,"../utils/dom.js":128,"../utils/fn.js":130,"../utils/log.js":133,"../utils/merge-options.js":134,"../utils/url.js":138,"./tech.js":115,"global/document":1,"global/window":2,"object.assign":45}],114:[function(_dereq_,module,exports){
  11730. /**
  11731. * @file loader.js
  11732. */
  11733. 'use strict';
  11734. exports.__esModule = true;
  11735. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11736. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  11737. 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; }
  11738. var _componentJs = _dereq_('../component.js');
  11739. var _componentJs2 = _interopRequireDefault(_componentJs);
  11740. var _techJs = _dereq_('./tech.js');
  11741. var _techJs2 = _interopRequireDefault(_techJs);
  11742. var _globalWindow = _dereq_('global/window');
  11743. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  11744. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  11745. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  11746. /**
  11747. * The Media Loader is the component that decides which playback technology to load
  11748. * when the player is initialized.
  11749. *
  11750. * @param {Object} player Main Player
  11751. * @param {Object=} options Object of option names and values
  11752. * @param {Function=} ready Ready callback function
  11753. * @extends Component
  11754. * @class MediaLoader
  11755. */
  11756. var MediaLoader = (function (_Component) {
  11757. _inherits(MediaLoader, _Component);
  11758. function MediaLoader(player, options, ready) {
  11759. _classCallCheck(this, MediaLoader);
  11760. _Component.call(this, player, options, ready);
  11761. // If there are no sources when the player is initialized,
  11762. // load the first supported playback technology.
  11763. if (!options.playerOptions['sources'] || options.playerOptions['sources'].length === 0) {
  11764. for (var i = 0, j = options.playerOptions['techOrder']; i < j.length; i++) {
  11765. var techName = _utilsToTitleCaseJs2['default'](j[i]);
  11766. var tech = _techJs2['default'].getTech(techName);
  11767. // Support old behavior of techs being registered as components.
  11768. // Remove once that deprecated behavior is removed.
  11769. if (!techName) {
  11770. tech = _componentJs2['default'].getComponent(techName);
  11771. }
  11772. // Check if the browser supports this technology
  11773. if (tech && tech.isSupported()) {
  11774. player.loadTech_(techName);
  11775. break;
  11776. }
  11777. }
  11778. } else {
  11779. // // Loop through playback technologies (HTML5, Flash) and check for support.
  11780. // // Then load the best source.
  11781. // // A few assumptions here:
  11782. // // All playback technologies respect preload false.
  11783. player.src(options.playerOptions['sources']);
  11784. }
  11785. }
  11786. return MediaLoader;
  11787. })(_componentJs2['default']);
  11788. _componentJs2['default'].registerComponent('MediaLoader', MediaLoader);
  11789. exports['default'] = MediaLoader;
  11790. module.exports = exports['default'];
  11791. },{"../component.js":65,"../utils/to-title-case.js":137,"./tech.js":115,"global/window":2}],115:[function(_dereq_,module,exports){
  11792. /**
  11793. * @file tech.js
  11794. * Media Technology Controller - Base class for media playback
  11795. * technology controllers like Flash and HTML5
  11796. */
  11797. 'use strict';
  11798. exports.__esModule = true;
  11799. 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; } }
  11800. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11801. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  11802. 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; }
  11803. var _component = _dereq_('../component');
  11804. var _component2 = _interopRequireDefault(_component);
  11805. var _tracksHtmlTrackElement = _dereq_('../tracks/html-track-element');
  11806. var _tracksHtmlTrackElement2 = _interopRequireDefault(_tracksHtmlTrackElement);
  11807. var _tracksHtmlTrackElementList = _dereq_('../tracks/html-track-element-list');
  11808. var _tracksHtmlTrackElementList2 = _interopRequireDefault(_tracksHtmlTrackElementList);
  11809. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js');
  11810. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  11811. var _tracksTextTrack = _dereq_('../tracks/text-track');
  11812. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack);
  11813. var _tracksTextTrackList = _dereq_('../tracks/text-track-list');
  11814. var _tracksTextTrackList2 = _interopRequireDefault(_tracksTextTrackList);
  11815. var _utilsFnJs = _dereq_('../utils/fn.js');
  11816. var Fn = _interopRequireWildcard(_utilsFnJs);
  11817. var _utilsLogJs = _dereq_('../utils/log.js');
  11818. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  11819. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js');
  11820. var _utilsBufferJs = _dereq_('../utils/buffer.js');
  11821. var _mediaErrorJs = _dereq_('../media-error.js');
  11822. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs);
  11823. var _globalWindow = _dereq_('global/window');
  11824. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  11825. var _globalDocument = _dereq_('global/document');
  11826. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  11827. /**
  11828. * Base class for media (HTML5 Video, Flash) controllers
  11829. *
  11830. * @param {Object=} options Options object
  11831. * @param {Function=} ready Ready callback function
  11832. * @extends Component
  11833. * @class Tech
  11834. */
  11835. var Tech = (function (_Component) {
  11836. _inherits(Tech, _Component);
  11837. function Tech() {
  11838. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  11839. var ready = arguments.length <= 1 || arguments[1] === undefined ? function () {} : arguments[1];
  11840. _classCallCheck(this, Tech);
  11841. // we don't want the tech to report user activity automatically.
  11842. // This is done manually in addControlsListeners
  11843. options.reportTouchActivity = false;
  11844. _Component.call(this, null, options, ready);
  11845. // keep track of whether the current source has played at all to
  11846. // implement a very limited played()
  11847. this.hasStarted_ = false;
  11848. this.on('playing', function () {
  11849. this.hasStarted_ = true;
  11850. });
  11851. this.on('loadstart', function () {
  11852. this.hasStarted_ = false;
  11853. });
  11854. this.textTracks_ = options.textTracks;
  11855. // Manually track progress in cases where the browser/flash player doesn't report it.
  11856. if (!this.featuresProgressEvents) {
  11857. this.manualProgressOn();
  11858. }
  11859. // Manually track timeupdates in cases where the browser/flash player doesn't report it.
  11860. if (!this.featuresTimeupdateEvents) {
  11861. this.manualTimeUpdatesOn();
  11862. }
  11863. if (options.nativeCaptions === false || options.nativeTextTracks === false) {
  11864. this.featuresNativeTextTracks = false;
  11865. }
  11866. if (!this.featuresNativeTextTracks) {
  11867. this.on('ready', this.emulateTextTracks);
  11868. }
  11869. this.initTextTrackListeners();
  11870. // Turn on component tap events
  11871. this.emitTapEvents();
  11872. }
  11873. /*
  11874. * List of associated text tracks
  11875. *
  11876. * @type {Array}
  11877. * @private
  11878. */
  11879. /* Fallbacks for unsupported event types
  11880. ================================================================================ */
  11881. // Manually trigger progress events based on changes to the buffered amount
  11882. // Many flash players and older HTML5 browsers don't send progress or progress-like events
  11883. /**
  11884. * Turn on progress events
  11885. *
  11886. * @method manualProgressOn
  11887. */
  11888. Tech.prototype.manualProgressOn = function manualProgressOn() {
  11889. this.on('durationchange', this.onDurationChange);
  11890. this.manualProgress = true;
  11891. // Trigger progress watching when a source begins loading
  11892. this.one('ready', this.trackProgress);
  11893. };
  11894. /**
  11895. * Turn off progress events
  11896. *
  11897. * @method manualProgressOff
  11898. */
  11899. Tech.prototype.manualProgressOff = function manualProgressOff() {
  11900. this.manualProgress = false;
  11901. this.stopTrackingProgress();
  11902. this.off('durationchange', this.onDurationChange);
  11903. };
  11904. /**
  11905. * Track progress
  11906. *
  11907. * @method trackProgress
  11908. */
  11909. Tech.prototype.trackProgress = function trackProgress() {
  11910. this.stopTrackingProgress();
  11911. this.progressInterval = this.setInterval(Fn.bind(this, function () {
  11912. // Don't trigger unless buffered amount is greater than last time
  11913. var numBufferedPercent = this.bufferedPercent();
  11914. if (this.bufferedPercent_ !== numBufferedPercent) {
  11915. this.trigger('progress');
  11916. }
  11917. this.bufferedPercent_ = numBufferedPercent;
  11918. if (numBufferedPercent === 1) {
  11919. this.stopTrackingProgress();
  11920. }
  11921. }), 500);
  11922. };
  11923. /**
  11924. * Update duration
  11925. *
  11926. * @method onDurationChange
  11927. */
  11928. Tech.prototype.onDurationChange = function onDurationChange() {
  11929. this.duration_ = this.duration();
  11930. };
  11931. /**
  11932. * Create and get TimeRange object for buffering
  11933. *
  11934. * @return {TimeRangeObject}
  11935. * @method buffered
  11936. */
  11937. Tech.prototype.buffered = function buffered() {
  11938. return _utilsTimeRangesJs.createTimeRange(0, 0);
  11939. };
  11940. /**
  11941. * Get buffered percent
  11942. *
  11943. * @return {Number}
  11944. * @method bufferedPercent
  11945. */
  11946. Tech.prototype.bufferedPercent = function bufferedPercent() {
  11947. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration_);
  11948. };
  11949. /**
  11950. * Stops tracking progress by clearing progress interval
  11951. *
  11952. * @method stopTrackingProgress
  11953. */
  11954. Tech.prototype.stopTrackingProgress = function stopTrackingProgress() {
  11955. this.clearInterval(this.progressInterval);
  11956. };
  11957. /*! Time Tracking -------------------------------------------------------------- */
  11958. /**
  11959. * Set event listeners for on play and pause and tracking current time
  11960. *
  11961. * @method manualTimeUpdatesOn
  11962. */
  11963. Tech.prototype.manualTimeUpdatesOn = function manualTimeUpdatesOn() {
  11964. this.manualTimeUpdates = true;
  11965. this.on('play', this.trackCurrentTime);
  11966. this.on('pause', this.stopTrackingCurrentTime);
  11967. };
  11968. /**
  11969. * Remove event listeners for on play and pause and tracking current time
  11970. *
  11971. * @method manualTimeUpdatesOff
  11972. */
  11973. Tech.prototype.manualTimeUpdatesOff = function manualTimeUpdatesOff() {
  11974. this.manualTimeUpdates = false;
  11975. this.stopTrackingCurrentTime();
  11976. this.off('play', this.trackCurrentTime);
  11977. this.off('pause', this.stopTrackingCurrentTime);
  11978. };
  11979. /**
  11980. * Tracks current time
  11981. *
  11982. * @method trackCurrentTime
  11983. */
  11984. Tech.prototype.trackCurrentTime = function trackCurrentTime() {
  11985. if (this.currentTimeInterval) {
  11986. this.stopTrackingCurrentTime();
  11987. }
  11988. this.currentTimeInterval = this.setInterval(function () {
  11989. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  11990. }, 250); // 42 = 24 fps // 250 is what Webkit uses // FF uses 15
  11991. };
  11992. /**
  11993. * Turn off play progress tracking (when paused or dragging)
  11994. *
  11995. * @method stopTrackingCurrentTime
  11996. */
  11997. Tech.prototype.stopTrackingCurrentTime = function stopTrackingCurrentTime() {
  11998. this.clearInterval(this.currentTimeInterval);
  11999. // #1002 - if the video ends right before the next timeupdate would happen,
  12000. // the progress bar won't make it all the way to the end
  12001. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  12002. };
  12003. /**
  12004. * Turn off any manual progress or timeupdate tracking
  12005. *
  12006. * @method dispose
  12007. */
  12008. Tech.prototype.dispose = function dispose() {
  12009. // clear out text tracks because we can't reuse them between techs
  12010. var textTracks = this.textTracks();
  12011. if (textTracks) {
  12012. var i = textTracks.length;
  12013. while (i--) {
  12014. this.removeRemoteTextTrack(textTracks[i]);
  12015. }
  12016. }
  12017. // Turn off any manual progress or timeupdate tracking
  12018. if (this.manualProgress) {
  12019. this.manualProgressOff();
  12020. }
  12021. if (this.manualTimeUpdates) {
  12022. this.manualTimeUpdatesOff();
  12023. }
  12024. _Component.prototype.dispose.call(this);
  12025. };
  12026. /**
  12027. * Reset the tech. Removes all sources and resets readyState.
  12028. *
  12029. * @method reset
  12030. */
  12031. Tech.prototype.reset = function reset() {};
  12032. /**
  12033. * When invoked without an argument, returns a MediaError object
  12034. * representing the current error state of the player or null if
  12035. * there is no error. When invoked with an argument, set the current
  12036. * error state of the player.
  12037. * @param {MediaError=} err Optional an error object
  12038. * @return {MediaError} the current error object or null
  12039. * @method error
  12040. */
  12041. Tech.prototype.error = function error(err) {
  12042. if (err !== undefined) {
  12043. if (err instanceof _mediaErrorJs2['default']) {
  12044. this.error_ = err;
  12045. } else {
  12046. this.error_ = new _mediaErrorJs2['default'](err);
  12047. }
  12048. this.trigger('error');
  12049. }
  12050. return this.error_;
  12051. };
  12052. /**
  12053. * Return the time ranges that have been played through for the
  12054. * current source. This implementation is incomplete. It does not
  12055. * track the played time ranges, only whether the source has played
  12056. * at all or not.
  12057. * @return {TimeRangeObject} a single time range if this video has
  12058. * played or an empty set of ranges if not.
  12059. * @method played
  12060. */
  12061. Tech.prototype.played = function played() {
  12062. if (this.hasStarted_) {
  12063. return _utilsTimeRangesJs.createTimeRange(0, 0);
  12064. }
  12065. return _utilsTimeRangesJs.createTimeRange();
  12066. };
  12067. /**
  12068. * Set current time
  12069. *
  12070. * @method setCurrentTime
  12071. */
  12072. Tech.prototype.setCurrentTime = function setCurrentTime() {
  12073. // improve the accuracy of manual timeupdates
  12074. if (this.manualTimeUpdates) {
  12075. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  12076. }
  12077. };
  12078. /**
  12079. * Initialize texttrack listeners
  12080. *
  12081. * @method initTextTrackListeners
  12082. */
  12083. Tech.prototype.initTextTrackListeners = function initTextTrackListeners() {
  12084. var textTrackListChanges = Fn.bind(this, function () {
  12085. this.trigger('texttrackchange');
  12086. });
  12087. var tracks = this.textTracks();
  12088. if (!tracks) return;
  12089. tracks.addEventListener('removetrack', textTrackListChanges);
  12090. tracks.addEventListener('addtrack', textTrackListChanges);
  12091. this.on('dispose', Fn.bind(this, function () {
  12092. tracks.removeEventListener('removetrack', textTrackListChanges);
  12093. tracks.removeEventListener('addtrack', textTrackListChanges);
  12094. }));
  12095. };
  12096. /**
  12097. * Emulate texttracks
  12098. *
  12099. * @method emulateTextTracks
  12100. */
  12101. Tech.prototype.emulateTextTracks = function emulateTextTracks() {
  12102. var _this = this;
  12103. var tracks = this.textTracks();
  12104. if (!tracks) {
  12105. return;
  12106. }
  12107. if (!_globalWindow2['default']['WebVTT'] && this.el().parentNode != null) {
  12108. var script = _globalDocument2['default'].createElement('script');
  12109. script.src = this.options_['vtt.js'] || 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.min.js';
  12110. this.el().parentNode.appendChild(script);
  12111. _globalWindow2['default']['WebVTT'] = true;
  12112. }
  12113. var updateDisplay = function updateDisplay() {
  12114. return _this.trigger('texttrackchange');
  12115. };
  12116. var textTracksChanges = function textTracksChanges() {
  12117. updateDisplay();
  12118. for (var i = 0; i < tracks.length; i++) {
  12119. var track = tracks[i];
  12120. track.removeEventListener('cuechange', updateDisplay);
  12121. if (track.mode === 'showing') {
  12122. track.addEventListener('cuechange', updateDisplay);
  12123. }
  12124. }
  12125. };
  12126. textTracksChanges();
  12127. tracks.addEventListener('change', textTracksChanges);
  12128. this.on('dispose', function () {
  12129. tracks.removeEventListener('change', textTracksChanges);
  12130. });
  12131. };
  12132. /*
  12133. * Provide default methods for text tracks.
  12134. *
  12135. * Html5 tech overrides these.
  12136. */
  12137. /**
  12138. * Get texttracks
  12139. *
  12140. * @returns {TextTrackList}
  12141. * @method textTracks
  12142. */
  12143. Tech.prototype.textTracks = function textTracks() {
  12144. this.textTracks_ = this.textTracks_ || new _tracksTextTrackList2['default']();
  12145. return this.textTracks_;
  12146. };
  12147. /**
  12148. * Get remote texttracks
  12149. *
  12150. * @returns {TextTrackList}
  12151. * @method remoteTextTracks
  12152. */
  12153. Tech.prototype.remoteTextTracks = function remoteTextTracks() {
  12154. this.remoteTextTracks_ = this.remoteTextTracks_ || new _tracksTextTrackList2['default']();
  12155. return this.remoteTextTracks_;
  12156. };
  12157. /**
  12158. * Get remote htmltrackelements
  12159. *
  12160. * @returns {HTMLTrackElementList}
  12161. * @method remoteTextTrackEls
  12162. */
  12163. Tech.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  12164. this.remoteTextTrackEls_ = this.remoteTextTrackEls_ || new _tracksHtmlTrackElementList2['default']();
  12165. return this.remoteTextTrackEls_;
  12166. };
  12167. /**
  12168. * Creates and returns a remote text track object
  12169. *
  12170. * @param {String} kind Text track kind (subtitles, captions, descriptions
  12171. * chapters and metadata)
  12172. * @param {String=} label Label to identify the text track
  12173. * @param {String=} language Two letter language abbreviation
  12174. * @return {TextTrackObject}
  12175. * @method addTextTrack
  12176. */
  12177. Tech.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  12178. if (!kind) {
  12179. throw new Error('TextTrack kind is required but was not provided');
  12180. }
  12181. return createTrackHelper(this, kind, label, language);
  12182. };
  12183. /**
  12184. * Creates a remote text track object and returns a emulated html track element
  12185. *
  12186. * @param {Object} options The object should contain values for
  12187. * kind, language, label and src (location of the WebVTT file)
  12188. * @return {HTMLTrackElement}
  12189. * @method addRemoteTextTrack
  12190. */
  12191. Tech.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  12192. var track = _utilsMergeOptionsJs2['default'](options, {
  12193. tech: this
  12194. });
  12195. var htmlTrackElement = new _tracksHtmlTrackElement2['default'](track);
  12196. // store HTMLTrackElement and TextTrack to remote list
  12197. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
  12198. this.remoteTextTracks().addTrack_(htmlTrackElement.track);
  12199. // must come after remoteTextTracks()
  12200. this.textTracks().addTrack_(htmlTrackElement.track);
  12201. return htmlTrackElement;
  12202. };
  12203. /**
  12204. * Remove remote texttrack
  12205. *
  12206. * @param {TextTrackObject} track Texttrack to remove
  12207. * @method removeRemoteTextTrack
  12208. */
  12209. Tech.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  12210. this.textTracks().removeTrack_(track);
  12211. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
  12212. // remove HTMLTrackElement and TextTrack from remote list
  12213. this.remoteTextTrackEls().removeTrackElement_(trackElement);
  12214. this.remoteTextTracks().removeTrack_(track);
  12215. };
  12216. /**
  12217. * Provide a default setPoster method for techs
  12218. * Poster support for techs should be optional, so we don't want techs to
  12219. * break if they don't have a way to set a poster.
  12220. *
  12221. * @method setPoster
  12222. */
  12223. Tech.prototype.setPoster = function setPoster() {};
  12224. /*
  12225. * Check if the tech can support the given type
  12226. *
  12227. * The base tech does not support any type, but source handlers might
  12228. * overwrite this.
  12229. *
  12230. * @param {String} type The mimetype to check
  12231. * @return {String} 'probably', 'maybe', or '' (empty string)
  12232. */
  12233. Tech.prototype.canPlayType = function canPlayType() {
  12234. return '';
  12235. };
  12236. /*
  12237. * Return whether the argument is a Tech or not.
  12238. * Can be passed either a Class like `Html5` or a instance like `player.tech_`
  12239. *
  12240. * @param {Object} component An item to check
  12241. * @return {Boolean} Whether it is a tech or not
  12242. */
  12243. Tech.isTech = function isTech(component) {
  12244. return component.prototype instanceof Tech || component instanceof Tech || component === Tech;
  12245. };
  12246. /**
  12247. * Registers a Tech
  12248. *
  12249. * @param {String} name Name of the Tech to register
  12250. * @param {Object} tech The tech to register
  12251. * @static
  12252. * @method registerComponent
  12253. */
  12254. Tech.registerTech = function registerTech(name, tech) {
  12255. if (!Tech.techs_) {
  12256. Tech.techs_ = {};
  12257. }
  12258. if (!Tech.isTech(tech)) {
  12259. throw new Error('Tech ' + name + ' must be a Tech');
  12260. }
  12261. Tech.techs_[name] = tech;
  12262. return tech;
  12263. };
  12264. /**
  12265. * Gets a component by name
  12266. *
  12267. * @param {String} name Name of the component to get
  12268. * @return {Component}
  12269. * @static
  12270. * @method getComponent
  12271. */
  12272. Tech.getTech = function getTech(name) {
  12273. if (Tech.techs_ && Tech.techs_[name]) {
  12274. return Tech.techs_[name];
  12275. }
  12276. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  12277. _utilsLogJs2['default'].warn('The ' + name + ' tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)');
  12278. return _globalWindow2['default'].videojs[name];
  12279. }
  12280. };
  12281. return Tech;
  12282. })(_component2['default']);
  12283. Tech.prototype.textTracks_;
  12284. var createTrackHelper = function createTrackHelper(self, kind, label, language) {
  12285. var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4];
  12286. var tracks = self.textTracks();
  12287. options.kind = kind;
  12288. if (label) {
  12289. options.label = label;
  12290. }
  12291. if (language) {
  12292. options.language = language;
  12293. }
  12294. options.tech = self;
  12295. var track = new _tracksTextTrack2['default'](options);
  12296. tracks.addTrack_(track);
  12297. return track;
  12298. };
  12299. Tech.prototype.featuresVolumeControl = true;
  12300. // Resizing plugins using request fullscreen reloads the plugin
  12301. Tech.prototype.featuresFullscreenResize = false;
  12302. Tech.prototype.featuresPlaybackRate = false;
  12303. // Optional events that we can manually mimic with timers
  12304. // currently not triggered by video-js-swf
  12305. Tech.prototype.featuresProgressEvents = false;
  12306. Tech.prototype.featuresTimeupdateEvents = false;
  12307. Tech.prototype.featuresNativeTextTracks = false;
  12308. /*
  12309. * A functional mixin for techs that want to use the Source Handler pattern.
  12310. *
  12311. * ##### EXAMPLE:
  12312. *
  12313. * Tech.withSourceHandlers.call(MyTech);
  12314. *
  12315. */
  12316. Tech.withSourceHandlers = function (_Tech) {
  12317. /*
  12318. * Register a source handler
  12319. * Source handlers are scripts for handling specific formats.
  12320. * The source handler pattern is used for adaptive formats (HLS, DASH) that
  12321. * manually load video data and feed it into a Source Buffer (Media Source Extensions)
  12322. * @param {Function} handler The source handler
  12323. * @param {Boolean} first Register it before any existing handlers
  12324. */
  12325. _Tech.registerSourceHandler = function (handler, index) {
  12326. var handlers = _Tech.sourceHandlers;
  12327. if (!handlers) {
  12328. handlers = _Tech.sourceHandlers = [];
  12329. }
  12330. if (index === undefined) {
  12331. // add to the end of the list
  12332. index = handlers.length;
  12333. }
  12334. handlers.splice(index, 0, handler);
  12335. };
  12336. /*
  12337. * Check if the tech can support the given type
  12338. * @param {String} type The mimetype to check
  12339. * @return {String} 'probably', 'maybe', or '' (empty string)
  12340. */
  12341. _Tech.canPlayType = function (type) {
  12342. var handlers = _Tech.sourceHandlers || [];
  12343. var can = undefined;
  12344. for (var i = 0; i < handlers.length; i++) {
  12345. can = handlers[i].canPlayType(type);
  12346. if (can) {
  12347. return can;
  12348. }
  12349. }
  12350. return '';
  12351. };
  12352. /*
  12353. * Return the first source handler that supports the source
  12354. * TODO: Answer question: should 'probably' be prioritized over 'maybe'
  12355. * @param {Object} source The source object
  12356. * @returns {Object} The first source handler that supports the source
  12357. * @returns {null} Null if no source handler is found
  12358. */
  12359. _Tech.selectSourceHandler = function (source) {
  12360. var handlers = _Tech.sourceHandlers || [];
  12361. var can = undefined;
  12362. for (var i = 0; i < handlers.length; i++) {
  12363. can = handlers[i].canHandleSource(source);
  12364. if (can) {
  12365. return handlers[i];
  12366. }
  12367. }
  12368. return null;
  12369. };
  12370. /*
  12371. * Check if the tech can support the given source
  12372. * @param {Object} srcObj The source object
  12373. * @return {String} 'probably', 'maybe', or '' (empty string)
  12374. */
  12375. _Tech.canPlaySource = function (srcObj) {
  12376. var sh = _Tech.selectSourceHandler(srcObj);
  12377. if (sh) {
  12378. return sh.canHandleSource(srcObj);
  12379. }
  12380. return '';
  12381. };
  12382. /*
  12383. * When using a source handler, prefer its implementation of
  12384. * any function normally provided by the tech.
  12385. */
  12386. var deferrable = ['seekable', 'duration'];
  12387. deferrable.forEach(function (fnName) {
  12388. var originalFn = this[fnName];
  12389. if (typeof originalFn !== 'function') {
  12390. return;
  12391. }
  12392. this[fnName] = function () {
  12393. if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
  12394. return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments);
  12395. }
  12396. return originalFn.apply(this, arguments);
  12397. };
  12398. }, _Tech.prototype);
  12399. /*
  12400. * Create a function for setting the source using a source object
  12401. * and source handlers.
  12402. * Should never be called unless a source handler was found.
  12403. * @param {Object} source A source object with src and type keys
  12404. * @return {Tech} self
  12405. */
  12406. _Tech.prototype.setSource = function (source) {
  12407. var sh = _Tech.selectSourceHandler(source);
  12408. if (!sh) {
  12409. // Fall back to a native source hander when unsupported sources are
  12410. // deliberately set
  12411. if (_Tech.nativeSourceHandler) {
  12412. sh = _Tech.nativeSourceHandler;
  12413. } else {
  12414. _utilsLogJs2['default'].error('No source hander found for the current source.');
  12415. }
  12416. }
  12417. // Dispose any existing source handler
  12418. this.disposeSourceHandler();
  12419. this.off('dispose', this.disposeSourceHandler);
  12420. this.currentSource_ = source;
  12421. this.sourceHandler_ = sh.handleSource(source, this);
  12422. this.on('dispose', this.disposeSourceHandler);
  12423. return this;
  12424. };
  12425. /*
  12426. * Clean up any existing source handler
  12427. */
  12428. _Tech.prototype.disposeSourceHandler = function () {
  12429. if (this.sourceHandler_ && this.sourceHandler_.dispose) {
  12430. this.sourceHandler_.dispose();
  12431. }
  12432. };
  12433. };
  12434. _component2['default'].registerComponent('Tech', Tech);
  12435. // Old name for Tech
  12436. _component2['default'].registerComponent('MediaTechController', Tech);
  12437. Tech.registerTech('Tech', Tech);
  12438. exports['default'] = Tech;
  12439. module.exports = exports['default'];
  12440. },{"../component":65,"../media-error.js":101,"../tracks/html-track-element":117,"../tracks/html-track-element-list":116,"../tracks/text-track":124,"../tracks/text-track-list":122,"../utils/buffer.js":126,"../utils/fn.js":130,"../utils/log.js":133,"../utils/merge-options.js":134,"../utils/time-ranges.js":136,"global/document":1,"global/window":2}],116:[function(_dereq_,module,exports){
  12441. /**
  12442. * @file html-track-element-list.js
  12443. */
  12444. 'use strict';
  12445. exports.__esModule = true;
  12446. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  12447. 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; } }
  12448. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  12449. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  12450. var browser = _interopRequireWildcard(_utilsBrowserJs);
  12451. var _globalDocument = _dereq_('global/document');
  12452. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  12453. var HtmlTrackElementList = (function () {
  12454. function HtmlTrackElementList() {
  12455. var trackElements = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  12456. _classCallCheck(this, HtmlTrackElementList);
  12457. var list = this;
  12458. if (browser.IS_IE8) {
  12459. list = _globalDocument2['default'].createElement('custom');
  12460. for (var prop in HtmlTrackElementList.prototype) {
  12461. if (prop !== 'constructor') {
  12462. list[prop] = HtmlTrackElementList.prototype[prop];
  12463. }
  12464. }
  12465. }
  12466. list.trackElements_ = [];
  12467. Object.defineProperty(list, 'length', {
  12468. get: function get() {
  12469. return this.trackElements_.length;
  12470. }
  12471. });
  12472. for (var i = 0, _length = trackElements.length; i < _length; i++) {
  12473. list.addTrackElement_(trackElements[i]);
  12474. }
  12475. if (browser.IS_IE8) {
  12476. return list;
  12477. }
  12478. }
  12479. HtmlTrackElementList.prototype.addTrackElement_ = function addTrackElement_(trackElement) {
  12480. this.trackElements_.push(trackElement);
  12481. };
  12482. HtmlTrackElementList.prototype.getTrackElementByTrack_ = function getTrackElementByTrack_(track) {
  12483. var trackElement_ = undefined;
  12484. for (var i = 0, _length2 = this.trackElements_.length; i < _length2; i++) {
  12485. if (track === this.trackElements_[i].track) {
  12486. trackElement_ = this.trackElements_[i];
  12487. break;
  12488. }
  12489. }
  12490. return trackElement_;
  12491. };
  12492. HtmlTrackElementList.prototype.removeTrackElement_ = function removeTrackElement_(trackElement) {
  12493. for (var i = 0, _length3 = this.trackElements_.length; i < _length3; i++) {
  12494. if (trackElement === this.trackElements_[i]) {
  12495. this.trackElements_.splice(i, 1);
  12496. break;
  12497. }
  12498. }
  12499. };
  12500. return HtmlTrackElementList;
  12501. })();
  12502. exports['default'] = HtmlTrackElementList;
  12503. module.exports = exports['default'];
  12504. },{"../utils/browser.js":125,"global/document":1}],117:[function(_dereq_,module,exports){
  12505. /**
  12506. * @file html-track-element.js
  12507. */
  12508. 'use strict';
  12509. exports.__esModule = true;
  12510. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  12511. 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; } }
  12512. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  12513. 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; }
  12514. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  12515. var browser = _interopRequireWildcard(_utilsBrowserJs);
  12516. var _globalDocument = _dereq_('global/document');
  12517. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  12518. var _eventTarget = _dereq_('../event-target');
  12519. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  12520. var _tracksTextTrack = _dereq_('../tracks/text-track');
  12521. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack);
  12522. var NONE = 0;
  12523. var LOADING = 1;
  12524. var LOADED = 2;
  12525. var ERROR = 3;
  12526. /**
  12527. * https://html.spec.whatwg.org/multipage/embedded-content.html#htmltrackelement
  12528. *
  12529. * interface HTMLTrackElement : HTMLElement {
  12530. * attribute DOMString kind;
  12531. * attribute DOMString src;
  12532. * attribute DOMString srclang;
  12533. * attribute DOMString label;
  12534. * attribute boolean default;
  12535. *
  12536. * const unsigned short NONE = 0;
  12537. * const unsigned short LOADING = 1;
  12538. * const unsigned short LOADED = 2;
  12539. * const unsigned short ERROR = 3;
  12540. * readonly attribute unsigned short readyState;
  12541. *
  12542. * readonly attribute TextTrack track;
  12543. * };
  12544. *
  12545. * @param {Object} options TextTrack configuration
  12546. * @class HTMLTrackElement
  12547. */
  12548. var HTMLTrackElement = (function (_EventTarget) {
  12549. _inherits(HTMLTrackElement, _EventTarget);
  12550. function HTMLTrackElement() {
  12551. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  12552. _classCallCheck(this, HTMLTrackElement);
  12553. _EventTarget.call(this);
  12554. var readyState = undefined,
  12555. trackElement = this;
  12556. if (browser.IS_IE8) {
  12557. trackElement = _globalDocument2['default'].createElement('custom');
  12558. for (var prop in HTMLTrackElement.prototype) {
  12559. if (prop !== 'constructor') {
  12560. trackElement[prop] = HTMLTrackElement.prototype[prop];
  12561. }
  12562. }
  12563. }
  12564. var track = new _tracksTextTrack2['default'](options);
  12565. trackElement.kind = track.kind;
  12566. trackElement.src = track.src;
  12567. trackElement.srclang = track.language;
  12568. trackElement.label = track.label;
  12569. trackElement['default'] = track['default'];
  12570. Object.defineProperty(trackElement, 'readyState', {
  12571. get: function get() {
  12572. return readyState;
  12573. }
  12574. });
  12575. Object.defineProperty(trackElement, 'track', {
  12576. get: function get() {
  12577. return track;
  12578. }
  12579. });
  12580. readyState = NONE;
  12581. track.addEventListener('loadeddata', function () {
  12582. readyState = LOADED;
  12583. trackElement.trigger({
  12584. type: 'load',
  12585. target: trackElement
  12586. });
  12587. });
  12588. if (browser.IS_IE8) {
  12589. return trackElement;
  12590. }
  12591. }
  12592. return HTMLTrackElement;
  12593. })(_eventTarget2['default']);
  12594. HTMLTrackElement.prototype.allowedEvents_ = {
  12595. load: 'load'
  12596. };
  12597. HTMLTrackElement.NONE = NONE;
  12598. HTMLTrackElement.LOADING = LOADING;
  12599. HTMLTrackElement.LOADED = LOADED;
  12600. HTMLTrackElement.ERROR = ERROR;
  12601. exports['default'] = HTMLTrackElement;
  12602. module.exports = exports['default'];
  12603. },{"../event-target":97,"../tracks/text-track":124,"../utils/browser.js":125,"global/document":1}],118:[function(_dereq_,module,exports){
  12604. /**
  12605. * @file text-track-cue-list.js
  12606. */
  12607. 'use strict';
  12608. exports.__esModule = true;
  12609. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  12610. 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; } }
  12611. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  12612. var browser = _interopRequireWildcard(_utilsBrowserJs);
  12613. var _globalDocument = _dereq_('global/document');
  12614. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  12615. /*
  12616. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist
  12617. *
  12618. * interface TextTrackCueList {
  12619. * readonly attribute unsigned long length;
  12620. * getter TextTrackCue (unsigned long index);
  12621. * TextTrackCue? getCueById(DOMString id);
  12622. * };
  12623. */
  12624. var TextTrackCueList = function TextTrackCueList(cues) {
  12625. var list = this;
  12626. if (browser.IS_IE8) {
  12627. list = _globalDocument2['default'].createElement('custom');
  12628. for (var prop in TextTrackCueList.prototype) {
  12629. if (prop !== 'constructor') {
  12630. list[prop] = TextTrackCueList.prototype[prop];
  12631. }
  12632. }
  12633. }
  12634. TextTrackCueList.prototype.setCues_.call(list, cues);
  12635. Object.defineProperty(list, 'length', {
  12636. get: function get() {
  12637. return this.length_;
  12638. }
  12639. });
  12640. if (browser.IS_IE8) {
  12641. return list;
  12642. }
  12643. };
  12644. TextTrackCueList.prototype.setCues_ = function (cues) {
  12645. var oldLength = this.length || 0;
  12646. var i = 0;
  12647. var l = cues.length;
  12648. this.cues_ = cues;
  12649. this.length_ = cues.length;
  12650. var defineProp = function defineProp(i) {
  12651. if (!('' + i in this)) {
  12652. Object.defineProperty(this, '' + i, {
  12653. get: function get() {
  12654. return this.cues_[i];
  12655. }
  12656. });
  12657. }
  12658. };
  12659. if (oldLength < l) {
  12660. i = oldLength;
  12661. for (; i < l; i++) {
  12662. defineProp.call(this, i);
  12663. }
  12664. }
  12665. };
  12666. TextTrackCueList.prototype.getCueById = function (id) {
  12667. var result = null;
  12668. for (var i = 0, l = this.length; i < l; i++) {
  12669. var cue = this[i];
  12670. if (cue.id === id) {
  12671. result = cue;
  12672. break;
  12673. }
  12674. }
  12675. return result;
  12676. };
  12677. exports['default'] = TextTrackCueList;
  12678. module.exports = exports['default'];
  12679. },{"../utils/browser.js":125,"global/document":1}],119:[function(_dereq_,module,exports){
  12680. /**
  12681. * @file text-track-display.js
  12682. */
  12683. 'use strict';
  12684. exports.__esModule = true;
  12685. 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; } }
  12686. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  12687. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  12688. 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; }
  12689. var _component = _dereq_('../component');
  12690. var _component2 = _interopRequireDefault(_component);
  12691. var _menuMenuJs = _dereq_('../menu/menu.js');
  12692. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  12693. var _menuMenuItemJs = _dereq_('../menu/menu-item.js');
  12694. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  12695. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js');
  12696. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  12697. var _utilsFnJs = _dereq_('../utils/fn.js');
  12698. var Fn = _interopRequireWildcard(_utilsFnJs);
  12699. var _globalDocument = _dereq_('global/document');
  12700. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  12701. var _globalWindow = _dereq_('global/window');
  12702. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  12703. var darkGray = '#222';
  12704. var lightGray = '#ccc';
  12705. var fontMap = {
  12706. monospace: 'monospace',
  12707. sansSerif: 'sans-serif',
  12708. serif: 'serif',
  12709. monospaceSansSerif: '"Andale Mono", "Lucida Console", monospace',
  12710. monospaceSerif: '"Courier New", monospace',
  12711. proportionalSansSerif: 'sans-serif',
  12712. proportionalSerif: 'serif',
  12713. casual: '"Comic Sans MS", Impact, fantasy',
  12714. script: '"Monotype Corsiva", cursive',
  12715. smallcaps: '"Andale Mono", "Lucida Console", monospace, sans-serif'
  12716. };
  12717. /**
  12718. * The component for displaying text track cues
  12719. *
  12720. * @param {Object} player Main Player
  12721. * @param {Object=} options Object of option names and values
  12722. * @param {Function=} ready Ready callback function
  12723. * @extends Component
  12724. * @class TextTrackDisplay
  12725. */
  12726. var TextTrackDisplay = (function (_Component) {
  12727. _inherits(TextTrackDisplay, _Component);
  12728. function TextTrackDisplay(player, options, ready) {
  12729. _classCallCheck(this, TextTrackDisplay);
  12730. _Component.call(this, player, options, ready);
  12731. player.on('loadstart', Fn.bind(this, this.toggleDisplay));
  12732. player.on('texttrackchange', Fn.bind(this, this.updateDisplay));
  12733. // This used to be called during player init, but was causing an error
  12734. // if a track should show by default and the display hadn't loaded yet.
  12735. // Should probably be moved to an external track loader when we support
  12736. // tracks that don't need a display.
  12737. player.ready(Fn.bind(this, function () {
  12738. if (player.tech_ && player.tech_['featuresNativeTextTracks']) {
  12739. this.hide();
  12740. return;
  12741. }
  12742. player.on('fullscreenchange', Fn.bind(this, this.updateDisplay));
  12743. var tracks = this.options_.playerOptions['tracks'] || [];
  12744. for (var i = 0; i < tracks.length; i++) {
  12745. var track = tracks[i];
  12746. this.player_.addRemoteTextTrack(track);
  12747. }
  12748. }));
  12749. }
  12750. /**
  12751. * Add cue HTML to display
  12752. *
  12753. * @param {Number} color Hex number for color, like #f0e
  12754. * @param {Number} opacity Value for opacity,0.0 - 1.0
  12755. * @return {RGBAColor} In the form 'rgba(255, 0, 0, 0.3)'
  12756. * @method constructColor
  12757. */
  12758. /**
  12759. * Toggle display texttracks
  12760. *
  12761. * @method toggleDisplay
  12762. */
  12763. TextTrackDisplay.prototype.toggleDisplay = function toggleDisplay() {
  12764. if (this.player_.tech_ && this.player_.tech_['featuresNativeTextTracks']) {
  12765. this.hide();
  12766. } else {
  12767. this.show();
  12768. }
  12769. };
  12770. /**
  12771. * Create the component's DOM element
  12772. *
  12773. * @return {Element}
  12774. * @method createEl
  12775. */
  12776. TextTrackDisplay.prototype.createEl = function createEl() {
  12777. return _Component.prototype.createEl.call(this, 'div', {
  12778. className: 'vjs-text-track-display'
  12779. });
  12780. };
  12781. /**
  12782. * Clear display texttracks
  12783. *
  12784. * @method clearDisplay
  12785. */
  12786. TextTrackDisplay.prototype.clearDisplay = function clearDisplay() {
  12787. if (typeof _globalWindow2['default']['WebVTT'] === 'function') {
  12788. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], [], this.el_);
  12789. }
  12790. };
  12791. /**
  12792. * Update display texttracks
  12793. *
  12794. * @method updateDisplay
  12795. */
  12796. TextTrackDisplay.prototype.updateDisplay = function updateDisplay() {
  12797. var tracks = this.player_.textTracks();
  12798. this.clearDisplay();
  12799. if (!tracks) {
  12800. return;
  12801. }
  12802. for (var i = 0; i < tracks.length; i++) {
  12803. var track = tracks[i];
  12804. if (track['mode'] === 'showing') {
  12805. this.updateForTrack(track);
  12806. }
  12807. }
  12808. };
  12809. /**
  12810. * Add texttrack to texttrack list
  12811. *
  12812. * @param {TextTrackObject} track Texttrack object to be added to list
  12813. * @method updateForTrack
  12814. */
  12815. TextTrackDisplay.prototype.updateForTrack = function updateForTrack(track) {
  12816. if (typeof _globalWindow2['default']['WebVTT'] !== 'function' || !track['activeCues']) {
  12817. return;
  12818. }
  12819. var overrides = this.player_['textTrackSettings'].getValues();
  12820. var cues = [];
  12821. for (var _i = 0; _i < track['activeCues'].length; _i++) {
  12822. cues.push(track['activeCues'][_i]);
  12823. }
  12824. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], track['activeCues'], this.el_);
  12825. var i = cues.length;
  12826. while (i--) {
  12827. var cue = cues[i];
  12828. if (!cue) {
  12829. continue;
  12830. }
  12831. var cueDiv = cue.displayState;
  12832. if (overrides.color) {
  12833. cueDiv.firstChild.style.color = overrides.color;
  12834. }
  12835. if (overrides.textOpacity) {
  12836. tryUpdateStyle(cueDiv.firstChild, 'color', constructColor(overrides.color || '#fff', overrides.textOpacity));
  12837. }
  12838. if (overrides.backgroundColor) {
  12839. cueDiv.firstChild.style.backgroundColor = overrides.backgroundColor;
  12840. }
  12841. if (overrides.backgroundOpacity) {
  12842. tryUpdateStyle(cueDiv.firstChild, 'backgroundColor', constructColor(overrides.backgroundColor || '#000', overrides.backgroundOpacity));
  12843. }
  12844. if (overrides.windowColor) {
  12845. if (overrides.windowOpacity) {
  12846. tryUpdateStyle(cueDiv, 'backgroundColor', constructColor(overrides.windowColor, overrides.windowOpacity));
  12847. } else {
  12848. cueDiv.style.backgroundColor = overrides.windowColor;
  12849. }
  12850. }
  12851. if (overrides.edgeStyle) {
  12852. if (overrides.edgeStyle === 'dropshadow') {
  12853. cueDiv.firstChild.style.textShadow = '2px 2px 3px ' + darkGray + ', 2px 2px 4px ' + darkGray + ', 2px 2px 5px ' + darkGray;
  12854. } else if (overrides.edgeStyle === 'raised') {
  12855. cueDiv.firstChild.style.textShadow = '1px 1px ' + darkGray + ', 2px 2px ' + darkGray + ', 3px 3px ' + darkGray;
  12856. } else if (overrides.edgeStyle === 'depressed') {
  12857. cueDiv.firstChild.style.textShadow = '1px 1px ' + lightGray + ', 0 1px ' + lightGray + ', -1px -1px ' + darkGray + ', 0 -1px ' + darkGray;
  12858. } else if (overrides.edgeStyle === 'uniform') {
  12859. cueDiv.firstChild.style.textShadow = '0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray;
  12860. }
  12861. }
  12862. if (overrides.fontPercent && overrides.fontPercent !== 1) {
  12863. var fontSize = _globalWindow2['default'].parseFloat(cueDiv.style.fontSize);
  12864. cueDiv.style.fontSize = fontSize * overrides.fontPercent + 'px';
  12865. cueDiv.style.height = 'auto';
  12866. cueDiv.style.top = 'auto';
  12867. cueDiv.style.bottom = '2px';
  12868. }
  12869. if (overrides.fontFamily && overrides.fontFamily !== 'default') {
  12870. if (overrides.fontFamily === 'small-caps') {
  12871. cueDiv.firstChild.style.fontVariant = 'small-caps';
  12872. } else {
  12873. cueDiv.firstChild.style.fontFamily = fontMap[overrides.fontFamily];
  12874. }
  12875. }
  12876. }
  12877. };
  12878. return TextTrackDisplay;
  12879. })(_component2['default']);
  12880. function constructColor(color, opacity) {
  12881. return 'rgba(' +
  12882. // color looks like "#f0e"
  12883. parseInt(color[1] + color[1], 16) + ',' + parseInt(color[2] + color[2], 16) + ',' + parseInt(color[3] + color[3], 16) + ',' + opacity + ')';
  12884. }
  12885. /**
  12886. * Try to update style
  12887. * Some style changes will throw an error, particularly in IE8. Those should be noops.
  12888. *
  12889. * @param {Element} el The element to be styles
  12890. * @param {CSSProperty} style The CSS property to be styled
  12891. * @param {CSSStyle} rule The actual style to be applied to the property
  12892. * @method tryUpdateStyle
  12893. */
  12894. function tryUpdateStyle(el, style, rule) {
  12895. //
  12896. try {
  12897. el.style[style] = rule;
  12898. } catch (e) {}
  12899. }
  12900. _component2['default'].registerComponent('TextTrackDisplay', TextTrackDisplay);
  12901. exports['default'] = TextTrackDisplay;
  12902. module.exports = exports['default'];
  12903. },{"../component":65,"../menu/menu-button.js":102,"../menu/menu-item.js":103,"../menu/menu.js":104,"../utils/fn.js":130,"global/document":1,"global/window":2}],120:[function(_dereq_,module,exports){
  12904. /**
  12905. * @file text-track-enums.js
  12906. *
  12907. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackmode
  12908. *
  12909. * enum TextTrackMode { "disabled", "hidden", "showing" };
  12910. */
  12911. 'use strict';
  12912. exports.__esModule = true;
  12913. var TextTrackMode = {
  12914. 'disabled': 'disabled',
  12915. 'hidden': 'hidden',
  12916. 'showing': 'showing'
  12917. };
  12918. /*
  12919. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackkind
  12920. *
  12921. * enum TextTrackKind { "subtitles", "captions", "descriptions", "chapters", "metadata" };
  12922. */
  12923. var TextTrackKind = {
  12924. 'subtitles': 'subtitles',
  12925. 'captions': 'captions',
  12926. 'descriptions': 'descriptions',
  12927. 'chapters': 'chapters',
  12928. 'metadata': 'metadata'
  12929. };
  12930. exports.TextTrackMode = TextTrackMode;
  12931. exports.TextTrackKind = TextTrackKind;
  12932. },{}],121:[function(_dereq_,module,exports){
  12933. /**
  12934. * Utilities for capturing text track state and re-creating tracks
  12935. * based on a capture.
  12936. *
  12937. * @file text-track-list-converter.js
  12938. */
  12939. /**
  12940. * Examine a single text track and return a JSON-compatible javascript
  12941. * object that represents the text track's state.
  12942. * @param track {TextTrackObject} the text track to query
  12943. * @return {Object} a serializable javascript representation of the
  12944. * @private
  12945. */
  12946. 'use strict';
  12947. exports.__esModule = true;
  12948. var trackToJson_ = function trackToJson_(track) {
  12949. var ret = ['kind', 'label', 'language', 'id', 'inBandMetadataTrackDispatchType', 'mode', 'src'].reduce(function (acc, prop, i) {
  12950. if (track[prop]) {
  12951. acc[prop] = track[prop];
  12952. }
  12953. return acc;
  12954. }, {
  12955. cues: track.cues && Array.prototype.map.call(track.cues, function (cue) {
  12956. return {
  12957. startTime: cue.startTime,
  12958. endTime: cue.endTime,
  12959. text: cue.text,
  12960. id: cue.id
  12961. };
  12962. })
  12963. });
  12964. return ret;
  12965. };
  12966. /**
  12967. * Examine a tech and return a JSON-compatible javascript array that
  12968. * represents the state of all text tracks currently configured. The
  12969. * return array is compatible with `jsonToTextTracks`.
  12970. * @param tech {tech} the tech object to query
  12971. * @return {Array} a serializable javascript representation of the
  12972. * @function textTracksToJson
  12973. */
  12974. var textTracksToJson = function textTracksToJson(tech) {
  12975. var trackEls = tech.$$('track');
  12976. var trackObjs = Array.prototype.map.call(trackEls, function (t) {
  12977. return t.track;
  12978. });
  12979. var tracks = Array.prototype.map.call(trackEls, function (trackEl) {
  12980. var json = trackToJson_(trackEl.track);
  12981. if (trackEl.src) {
  12982. json.src = trackEl.src;
  12983. }
  12984. return json;
  12985. });
  12986. return tracks.concat(Array.prototype.filter.call(tech.textTracks(), function (track) {
  12987. return trackObjs.indexOf(track) === -1;
  12988. }).map(trackToJson_));
  12989. };
  12990. /**
  12991. * Creates a set of remote text tracks on a tech based on an array of
  12992. * javascript text track representations.
  12993. * @param json {Array} an array of text track representation objects,
  12994. * like those that would be produced by `textTracksToJson`
  12995. * @param tech {tech} the tech to create text tracks on
  12996. * @function jsonToTextTracks
  12997. */
  12998. var jsonToTextTracks = function jsonToTextTracks(json, tech) {
  12999. json.forEach(function (track) {
  13000. var addedTrack = tech.addRemoteTextTrack(track).track;
  13001. if (!track.src && track.cues) {
  13002. track.cues.forEach(function (cue) {
  13003. return addedTrack.addCue(cue);
  13004. });
  13005. }
  13006. });
  13007. return tech.textTracks();
  13008. };
  13009. exports['default'] = { textTracksToJson: textTracksToJson, jsonToTextTracks: jsonToTextTracks, trackToJson_: trackToJson_ };
  13010. module.exports = exports['default'];
  13011. },{}],122:[function(_dereq_,module,exports){
  13012. /**
  13013. * @file text-track-list.js
  13014. */
  13015. 'use strict';
  13016. exports.__esModule = true;
  13017. 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; } }
  13018. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13019. var _eventTarget = _dereq_('../event-target');
  13020. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  13021. var _utilsFnJs = _dereq_('../utils/fn.js');
  13022. var Fn = _interopRequireWildcard(_utilsFnJs);
  13023. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  13024. var browser = _interopRequireWildcard(_utilsBrowserJs);
  13025. var _globalDocument = _dereq_('global/document');
  13026. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13027. /*
  13028. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttracklist
  13029. *
  13030. * interface TextTrackList : EventTarget {
  13031. * readonly attribute unsigned long length;
  13032. * getter TextTrack (unsigned long index);
  13033. * TextTrack? getTrackById(DOMString id);
  13034. *
  13035. * attribute EventHandler onchange;
  13036. * attribute EventHandler onaddtrack;
  13037. * attribute EventHandler onremovetrack;
  13038. * };
  13039. */
  13040. var TextTrackList = function TextTrackList(tracks) {
  13041. var list = this;
  13042. if (browser.IS_IE8) {
  13043. list = _globalDocument2['default'].createElement('custom');
  13044. for (var prop in TextTrackList.prototype) {
  13045. if (prop !== 'constructor') {
  13046. list[prop] = TextTrackList.prototype[prop];
  13047. }
  13048. }
  13049. }
  13050. tracks = tracks || [];
  13051. list.tracks_ = [];
  13052. Object.defineProperty(list, 'length', {
  13053. get: function get() {
  13054. return this.tracks_.length;
  13055. }
  13056. });
  13057. for (var i = 0; i < tracks.length; i++) {
  13058. list.addTrack_(tracks[i]);
  13059. }
  13060. if (browser.IS_IE8) {
  13061. return list;
  13062. }
  13063. };
  13064. TextTrackList.prototype = Object.create(_eventTarget2['default'].prototype);
  13065. TextTrackList.prototype.constructor = TextTrackList;
  13066. /*
  13067. * change - One or more tracks in the track list have been enabled or disabled.
  13068. * addtrack - A track has been added to the track list.
  13069. * removetrack - A track has been removed from the track list.
  13070. */
  13071. TextTrackList.prototype.allowedEvents_ = {
  13072. 'change': 'change',
  13073. 'addtrack': 'addtrack',
  13074. 'removetrack': 'removetrack'
  13075. };
  13076. // emulate attribute EventHandler support to allow for feature detection
  13077. for (var _event in TextTrackList.prototype.allowedEvents_) {
  13078. TextTrackList.prototype['on' + _event] = null;
  13079. }
  13080. /**
  13081. * Add TextTrack from TextTrackList
  13082. *
  13083. * @param {TextTrack} track
  13084. * @method addTrack_
  13085. * @private
  13086. */
  13087. TextTrackList.prototype.addTrack_ = function (track) {
  13088. var index = this.tracks_.length;
  13089. if (!('' + index in this)) {
  13090. Object.defineProperty(this, index, {
  13091. get: function get() {
  13092. return this.tracks_[index];
  13093. }
  13094. });
  13095. }
  13096. track.addEventListener('modechange', Fn.bind(this, function () {
  13097. this.trigger('change');
  13098. }));
  13099. this.tracks_.push(track);
  13100. this.trigger({
  13101. type: 'addtrack',
  13102. track: track
  13103. });
  13104. };
  13105. /**
  13106. * Remove TextTrack from TextTrackList
  13107. * NOTE: Be mindful of what is passed in as it may be a HTMLTrackElement
  13108. *
  13109. * @param {TextTrack} rtrack
  13110. * @method removeTrack_
  13111. * @private
  13112. */
  13113. TextTrackList.prototype.removeTrack_ = function (rtrack) {
  13114. var track = undefined;
  13115. for (var i = 0, l = this.length; i < l; i++) {
  13116. if (this[i] === rtrack) {
  13117. track = this[i];
  13118. this.tracks_.splice(i, 1);
  13119. break;
  13120. }
  13121. }
  13122. if (!track) {
  13123. return;
  13124. }
  13125. this.trigger({
  13126. type: 'removetrack',
  13127. track: track
  13128. });
  13129. };
  13130. TextTrackList.prototype.getTrackById = function (id) {
  13131. var result = null;
  13132. for (var i = 0, l = this.length; i < l; i++) {
  13133. var track = this[i];
  13134. if (track.id === id) {
  13135. result = track;
  13136. break;
  13137. }
  13138. }
  13139. return result;
  13140. };
  13141. exports['default'] = TextTrackList;
  13142. module.exports = exports['default'];
  13143. },{"../event-target":97,"../utils/browser.js":125,"../utils/fn.js":130,"global/document":1}],123:[function(_dereq_,module,exports){
  13144. /**
  13145. * @file text-track-settings.js
  13146. */
  13147. 'use strict';
  13148. exports.__esModule = true;
  13149. 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; } }
  13150. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13151. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13152. 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; }
  13153. var _component = _dereq_('../component');
  13154. var _component2 = _interopRequireDefault(_component);
  13155. var _utilsEventsJs = _dereq_('../utils/events.js');
  13156. var Events = _interopRequireWildcard(_utilsEventsJs);
  13157. var _utilsFnJs = _dereq_('../utils/fn.js');
  13158. var Fn = _interopRequireWildcard(_utilsFnJs);
  13159. var _utilsLogJs = _dereq_('../utils/log.js');
  13160. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  13161. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple');
  13162. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple);
  13163. var _globalWindow = _dereq_('global/window');
  13164. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  13165. /**
  13166. * Manipulate settings of texttracks
  13167. *
  13168. * @param {Object} player Main Player
  13169. * @param {Object=} options Object of option names and values
  13170. * @extends Component
  13171. * @class TextTrackSettings
  13172. */
  13173. var TextTrackSettings = (function (_Component) {
  13174. _inherits(TextTrackSettings, _Component);
  13175. function TextTrackSettings(player, options) {
  13176. _classCallCheck(this, TextTrackSettings);
  13177. _Component.call(this, player, options);
  13178. this.hide();
  13179. // Grab `persistTextTrackSettings` from the player options if not passed in child options
  13180. if (options.persistTextTrackSettings === undefined) {
  13181. this.options_.persistTextTrackSettings = this.options_.playerOptions.persistTextTrackSettings;
  13182. }
  13183. Events.on(this.$('.vjs-done-button'), 'click', Fn.bind(this, function () {
  13184. this.saveSettings();
  13185. this.hide();
  13186. }));
  13187. Events.on(this.$('.vjs-default-button'), 'click', Fn.bind(this, function () {
  13188. this.$('.vjs-fg-color > select').selectedIndex = 0;
  13189. this.$('.vjs-bg-color > select').selectedIndex = 0;
  13190. this.$('.window-color > select').selectedIndex = 0;
  13191. this.$('.vjs-text-opacity > select').selectedIndex = 0;
  13192. this.$('.vjs-bg-opacity > select').selectedIndex = 0;
  13193. this.$('.vjs-window-opacity > select').selectedIndex = 0;
  13194. this.$('.vjs-edge-style select').selectedIndex = 0;
  13195. this.$('.vjs-font-family select').selectedIndex = 0;
  13196. this.$('.vjs-font-percent select').selectedIndex = 2;
  13197. this.updateDisplay();
  13198. }));
  13199. Events.on(this.$('.vjs-fg-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  13200. Events.on(this.$('.vjs-bg-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  13201. Events.on(this.$('.window-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  13202. Events.on(this.$('.vjs-text-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  13203. Events.on(this.$('.vjs-bg-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  13204. Events.on(this.$('.vjs-window-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  13205. Events.on(this.$('.vjs-font-percent select'), 'change', Fn.bind(this, this.updateDisplay));
  13206. Events.on(this.$('.vjs-edge-style select'), 'change', Fn.bind(this, this.updateDisplay));
  13207. Events.on(this.$('.vjs-font-family select'), 'change', Fn.bind(this, this.updateDisplay));
  13208. if (this.options_.persistTextTrackSettings) {
  13209. this.restoreSettings();
  13210. }
  13211. }
  13212. /**
  13213. * Create the component's DOM element
  13214. *
  13215. * @return {Element}
  13216. * @method createEl
  13217. */
  13218. TextTrackSettings.prototype.createEl = function createEl() {
  13219. return _Component.prototype.createEl.call(this, 'div', {
  13220. className: 'vjs-caption-settings vjs-modal-overlay',
  13221. innerHTML: captionOptionsMenuTemplate()
  13222. });
  13223. };
  13224. /**
  13225. * Get texttrack settings
  13226. * Settings are
  13227. * .vjs-edge-style
  13228. * .vjs-font-family
  13229. * .vjs-fg-color
  13230. * .vjs-text-opacity
  13231. * .vjs-bg-color
  13232. * .vjs-bg-opacity
  13233. * .window-color
  13234. * .vjs-window-opacity
  13235. *
  13236. * @return {Object}
  13237. * @method getValues
  13238. */
  13239. TextTrackSettings.prototype.getValues = function getValues() {
  13240. var textEdge = getSelectedOptionValue(this.$('.vjs-edge-style select'));
  13241. var fontFamily = getSelectedOptionValue(this.$('.vjs-font-family select'));
  13242. var fgColor = getSelectedOptionValue(this.$('.vjs-fg-color > select'));
  13243. var textOpacity = getSelectedOptionValue(this.$('.vjs-text-opacity > select'));
  13244. var bgColor = getSelectedOptionValue(this.$('.vjs-bg-color > select'));
  13245. var bgOpacity = getSelectedOptionValue(this.$('.vjs-bg-opacity > select'));
  13246. var windowColor = getSelectedOptionValue(this.$('.window-color > select'));
  13247. var windowOpacity = getSelectedOptionValue(this.$('.vjs-window-opacity > select'));
  13248. var fontPercent = _globalWindow2['default']['parseFloat'](getSelectedOptionValue(this.$('.vjs-font-percent > select')));
  13249. var result = {
  13250. 'backgroundOpacity': bgOpacity,
  13251. 'textOpacity': textOpacity,
  13252. 'windowOpacity': windowOpacity,
  13253. 'edgeStyle': textEdge,
  13254. 'fontFamily': fontFamily,
  13255. 'color': fgColor,
  13256. 'backgroundColor': bgColor,
  13257. 'windowColor': windowColor,
  13258. 'fontPercent': fontPercent
  13259. };
  13260. for (var _name in result) {
  13261. if (result[_name] === '' || result[_name] === 'none' || _name === 'fontPercent' && result[_name] === 1.00) {
  13262. delete result[_name];
  13263. }
  13264. }
  13265. return result;
  13266. };
  13267. /**
  13268. * Set texttrack settings
  13269. * Settings are
  13270. * .vjs-edge-style
  13271. * .vjs-font-family
  13272. * .vjs-fg-color
  13273. * .vjs-text-opacity
  13274. * .vjs-bg-color
  13275. * .vjs-bg-opacity
  13276. * .window-color
  13277. * .vjs-window-opacity
  13278. *
  13279. * @param {Object} values Object with texttrack setting values
  13280. * @method setValues
  13281. */
  13282. TextTrackSettings.prototype.setValues = function setValues(values) {
  13283. setSelectedOption(this.$('.vjs-edge-style select'), values.edgeStyle);
  13284. setSelectedOption(this.$('.vjs-font-family select'), values.fontFamily);
  13285. setSelectedOption(this.$('.vjs-fg-color > select'), values.color);
  13286. setSelectedOption(this.$('.vjs-text-opacity > select'), values.textOpacity);
  13287. setSelectedOption(this.$('.vjs-bg-color > select'), values.backgroundColor);
  13288. setSelectedOption(this.$('.vjs-bg-opacity > select'), values.backgroundOpacity);
  13289. setSelectedOption(this.$('.window-color > select'), values.windowColor);
  13290. setSelectedOption(this.$('.vjs-window-opacity > select'), values.windowOpacity);
  13291. var fontPercent = values.fontPercent;
  13292. if (fontPercent) {
  13293. fontPercent = fontPercent.toFixed(2);
  13294. }
  13295. setSelectedOption(this.$('.vjs-font-percent > select'), fontPercent);
  13296. };
  13297. /**
  13298. * Restore texttrack settings
  13299. *
  13300. * @method restoreSettings
  13301. */
  13302. TextTrackSettings.prototype.restoreSettings = function restoreSettings() {
  13303. var _safeParseTuple = _safeJsonParseTuple2['default'](_globalWindow2['default'].localStorage.getItem('vjs-text-track-settings'));
  13304. var err = _safeParseTuple[0];
  13305. var values = _safeParseTuple[1];
  13306. if (err) {
  13307. _utilsLogJs2['default'].error(err);
  13308. }
  13309. if (values) {
  13310. this.setValues(values);
  13311. }
  13312. };
  13313. /**
  13314. * Save texttrack settings to local storage
  13315. *
  13316. * @method saveSettings
  13317. */
  13318. TextTrackSettings.prototype.saveSettings = function saveSettings() {
  13319. if (!this.options_.persistTextTrackSettings) {
  13320. return;
  13321. }
  13322. var values = this.getValues();
  13323. try {
  13324. if (Object.getOwnPropertyNames(values).length > 0) {
  13325. _globalWindow2['default'].localStorage.setItem('vjs-text-track-settings', JSON.stringify(values));
  13326. } else {
  13327. _globalWindow2['default'].localStorage.removeItem('vjs-text-track-settings');
  13328. }
  13329. } catch (e) {}
  13330. };
  13331. /**
  13332. * Update display of texttrack settings
  13333. *
  13334. * @method updateDisplay
  13335. */
  13336. TextTrackSettings.prototype.updateDisplay = function updateDisplay() {
  13337. var ttDisplay = this.player_.getChild('textTrackDisplay');
  13338. if (ttDisplay) {
  13339. ttDisplay.updateDisplay();
  13340. }
  13341. };
  13342. return TextTrackSettings;
  13343. })(_component2['default']);
  13344. _component2['default'].registerComponent('TextTrackSettings', TextTrackSettings);
  13345. function getSelectedOptionValue(target) {
  13346. var selectedOption = undefined;
  13347. // not all browsers support selectedOptions, so, fallback to options
  13348. if (target.selectedOptions) {
  13349. selectedOption = target.selectedOptions[0];
  13350. } else if (target.options) {
  13351. selectedOption = target.options[target.options.selectedIndex];
  13352. }
  13353. return selectedOption.value;
  13354. }
  13355. function setSelectedOption(target, value) {
  13356. if (!value) {
  13357. return;
  13358. }
  13359. var i = undefined;
  13360. for (i = 0; i < target.options.length; i++) {
  13361. var option = target.options[i];
  13362. if (option.value === value) {
  13363. break;
  13364. }
  13365. }
  13366. target.selectedIndex = i;
  13367. }
  13368. function captionOptionsMenuTemplate() {
  13369. 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>';
  13370. return template;
  13371. }
  13372. exports['default'] = TextTrackSettings;
  13373. module.exports = exports['default'];
  13374. },{"../component":65,"../utils/events.js":129,"../utils/fn.js":130,"../utils/log.js":133,"global/window":2,"safe-json-parse/tuple":53}],124:[function(_dereq_,module,exports){
  13375. /**
  13376. * @file text-track.js
  13377. */
  13378. 'use strict';
  13379. exports.__esModule = true;
  13380. 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; } }
  13381. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13382. var _textTrackCueList = _dereq_('./text-track-cue-list');
  13383. var _textTrackCueList2 = _interopRequireDefault(_textTrackCueList);
  13384. var _utilsFnJs = _dereq_('../utils/fn.js');
  13385. var Fn = _interopRequireWildcard(_utilsFnJs);
  13386. var _utilsGuidJs = _dereq_('../utils/guid.js');
  13387. var Guid = _interopRequireWildcard(_utilsGuidJs);
  13388. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  13389. var browser = _interopRequireWildcard(_utilsBrowserJs);
  13390. var _textTrackEnums = _dereq_('./text-track-enums');
  13391. var TextTrackEnum = _interopRequireWildcard(_textTrackEnums);
  13392. var _utilsLogJs = _dereq_('../utils/log.js');
  13393. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  13394. var _eventTarget = _dereq_('../event-target');
  13395. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  13396. var _globalDocument = _dereq_('global/document');
  13397. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13398. var _globalWindow = _dereq_('global/window');
  13399. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  13400. var _utilsUrlJs = _dereq_('../utils/url.js');
  13401. var _xhr = _dereq_('xhr');
  13402. var _xhr2 = _interopRequireDefault(_xhr);
  13403. /*
  13404. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrack
  13405. *
  13406. * interface TextTrack : EventTarget {
  13407. * readonly attribute TextTrackKind kind;
  13408. * readonly attribute DOMString label;
  13409. * readonly attribute DOMString language;
  13410. *
  13411. * readonly attribute DOMString id;
  13412. * readonly attribute DOMString inBandMetadataTrackDispatchType;
  13413. *
  13414. * attribute TextTrackMode mode;
  13415. *
  13416. * readonly attribute TextTrackCueList? cues;
  13417. * readonly attribute TextTrackCueList? activeCues;
  13418. *
  13419. * void addCue(TextTrackCue cue);
  13420. * void removeCue(TextTrackCue cue);
  13421. *
  13422. * attribute EventHandler oncuechange;
  13423. * };
  13424. */
  13425. var TextTrack = function TextTrack() {
  13426. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  13427. if (!options.tech) {
  13428. throw new Error('A tech was not provided.');
  13429. }
  13430. var tt = this;
  13431. if (browser.IS_IE8) {
  13432. tt = _globalDocument2['default'].createElement('custom');
  13433. for (var prop in TextTrack.prototype) {
  13434. if (prop !== 'constructor') {
  13435. tt[prop] = TextTrack.prototype[prop];
  13436. }
  13437. }
  13438. }
  13439. tt.tech_ = options.tech;
  13440. var mode = TextTrackEnum.TextTrackMode[options['mode']] || 'disabled';
  13441. var kind = TextTrackEnum.TextTrackKind[options['kind']] || 'subtitles';
  13442. var label = options['label'] || '';
  13443. var language = options['language'] || options['srclang'] || '';
  13444. var id = options['id'] || 'vjs_text_track_' + Guid.newGUID();
  13445. if (kind === 'metadata' || kind === 'chapters') {
  13446. mode = 'hidden';
  13447. }
  13448. tt.cues_ = [];
  13449. tt.activeCues_ = [];
  13450. var cues = new _textTrackCueList2['default'](tt.cues_);
  13451. var activeCues = new _textTrackCueList2['default'](tt.activeCues_);
  13452. var changed = false;
  13453. var timeupdateHandler = Fn.bind(tt, function () {
  13454. this['activeCues'];
  13455. if (changed) {
  13456. this['trigger']('cuechange');
  13457. changed = false;
  13458. }
  13459. });
  13460. if (mode !== 'disabled') {
  13461. tt.tech_.on('timeupdate', timeupdateHandler);
  13462. }
  13463. Object.defineProperty(tt, 'kind', {
  13464. get: function get() {
  13465. return kind;
  13466. },
  13467. set: Function.prototype
  13468. });
  13469. Object.defineProperty(tt, 'label', {
  13470. get: function get() {
  13471. return label;
  13472. },
  13473. set: Function.prototype
  13474. });
  13475. Object.defineProperty(tt, 'language', {
  13476. get: function get() {
  13477. return language;
  13478. },
  13479. set: Function.prototype
  13480. });
  13481. Object.defineProperty(tt, 'id', {
  13482. get: function get() {
  13483. return id;
  13484. },
  13485. set: Function.prototype
  13486. });
  13487. Object.defineProperty(tt, 'mode', {
  13488. get: function get() {
  13489. return mode;
  13490. },
  13491. set: function set(newMode) {
  13492. if (!TextTrackEnum.TextTrackMode[newMode]) {
  13493. return;
  13494. }
  13495. mode = newMode;
  13496. if (mode === 'showing') {
  13497. this.tech_.on('timeupdate', timeupdateHandler);
  13498. }
  13499. this.trigger('modechange');
  13500. }
  13501. });
  13502. Object.defineProperty(tt, 'cues', {
  13503. get: function get() {
  13504. if (!this.loaded_) {
  13505. return null;
  13506. }
  13507. return cues;
  13508. },
  13509. set: Function.prototype
  13510. });
  13511. Object.defineProperty(tt, 'activeCues', {
  13512. get: function get() {
  13513. if (!this.loaded_) {
  13514. return null;
  13515. }
  13516. if (this['cues'].length === 0) {
  13517. return activeCues; // nothing to do
  13518. }
  13519. var ct = this.tech_.currentTime();
  13520. var active = [];
  13521. for (var i = 0, l = this['cues'].length; i < l; i++) {
  13522. var cue = this['cues'][i];
  13523. if (cue['startTime'] <= ct && cue['endTime'] >= ct) {
  13524. active.push(cue);
  13525. } else if (cue['startTime'] === cue['endTime'] && cue['startTime'] <= ct && cue['startTime'] + 0.5 >= ct) {
  13526. active.push(cue);
  13527. }
  13528. }
  13529. changed = false;
  13530. if (active.length !== this.activeCues_.length) {
  13531. changed = true;
  13532. } else {
  13533. for (var i = 0; i < active.length; i++) {
  13534. if (indexOf.call(this.activeCues_, active[i]) === -1) {
  13535. changed = true;
  13536. }
  13537. }
  13538. }
  13539. this.activeCues_ = active;
  13540. activeCues.setCues_(this.activeCues_);
  13541. return activeCues;
  13542. },
  13543. set: Function.prototype
  13544. });
  13545. if (options.src) {
  13546. tt.src = options.src;
  13547. loadTrack(options.src, tt);
  13548. } else {
  13549. tt.loaded_ = true;
  13550. }
  13551. if (browser.IS_IE8) {
  13552. return tt;
  13553. }
  13554. };
  13555. TextTrack.prototype = Object.create(_eventTarget2['default'].prototype);
  13556. TextTrack.prototype.constructor = TextTrack;
  13557. /*
  13558. * cuechange - One or more cues in the track have become active or stopped being active.
  13559. */
  13560. TextTrack.prototype.allowedEvents_ = {
  13561. 'cuechange': 'cuechange'
  13562. };
  13563. TextTrack.prototype.addCue = function (cue) {
  13564. var tracks = this.tech_.textTracks();
  13565. if (tracks) {
  13566. for (var i = 0; i < tracks.length; i++) {
  13567. if (tracks[i] !== this) {
  13568. tracks[i].removeCue(cue);
  13569. }
  13570. }
  13571. }
  13572. this.cues_.push(cue);
  13573. this['cues'].setCues_(this.cues_);
  13574. };
  13575. TextTrack.prototype.removeCue = function (removeCue) {
  13576. var removed = false;
  13577. for (var i = 0, l = this.cues_.length; i < l; i++) {
  13578. var cue = this.cues_[i];
  13579. if (cue === removeCue) {
  13580. this.cues_.splice(i, 1);
  13581. removed = true;
  13582. }
  13583. }
  13584. if (removed) {
  13585. this.cues.setCues_(this.cues_);
  13586. }
  13587. };
  13588. /*
  13589. * Downloading stuff happens below this point
  13590. */
  13591. var parseCues = function parseCues(srcContent, track) {
  13592. var parser = new _globalWindow2['default'].WebVTT.Parser(_globalWindow2['default'], _globalWindow2['default'].vttjs, _globalWindow2['default'].WebVTT.StringDecoder());
  13593. parser.oncue = function (cue) {
  13594. track.addCue(cue);
  13595. };
  13596. parser.onparsingerror = function (error) {
  13597. _utilsLogJs2['default'].error(error);
  13598. };
  13599. parser.onflush = function () {
  13600. track.trigger({
  13601. type: 'loadeddata',
  13602. target: track
  13603. });
  13604. };
  13605. parser.parse(srcContent);
  13606. parser.flush();
  13607. };
  13608. var loadTrack = function loadTrack(src, track) {
  13609. var opts = {
  13610. uri: src
  13611. };
  13612. var crossOrigin = _utilsUrlJs.isCrossOrigin(src);
  13613. if (crossOrigin) {
  13614. opts.cors = crossOrigin;
  13615. }
  13616. _xhr2['default'](opts, Fn.bind(this, function (err, response, responseBody) {
  13617. if (err) {
  13618. return _utilsLogJs2['default'].error(err, response);
  13619. }
  13620. track.loaded_ = true;
  13621. // NOTE: this is only used for the alt/video.novtt.js build
  13622. if (typeof _globalWindow2['default'].WebVTT !== 'function') {
  13623. _globalWindow2['default'].setTimeout(function () {
  13624. parseCues(responseBody, track);
  13625. }, 100);
  13626. } else {
  13627. parseCues(responseBody, track);
  13628. }
  13629. }));
  13630. };
  13631. var indexOf = function indexOf(searchElement, fromIndex) {
  13632. if (this == null) {
  13633. throw new TypeError('"this" is null or not defined');
  13634. }
  13635. var O = Object(this);
  13636. var len = O.length >>> 0;
  13637. if (len === 0) {
  13638. return -1;
  13639. }
  13640. var n = +fromIndex || 0;
  13641. if (Math.abs(n) === Infinity) {
  13642. n = 0;
  13643. }
  13644. if (n >= len) {
  13645. return -1;
  13646. }
  13647. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
  13648. while (k < len) {
  13649. if (k in O && O[k] === searchElement) {
  13650. return k;
  13651. }
  13652. k++;
  13653. }
  13654. return -1;
  13655. };
  13656. exports['default'] = TextTrack;
  13657. module.exports = exports['default'];
  13658. },{"../event-target":97,"../utils/browser.js":125,"../utils/fn.js":130,"../utils/guid.js":132,"../utils/log.js":133,"../utils/url.js":138,"./text-track-cue-list":118,"./text-track-enums":120,"global/document":1,"global/window":2,"xhr":55}],125:[function(_dereq_,module,exports){
  13659. /**
  13660. * @file browser.js
  13661. */
  13662. 'use strict';
  13663. exports.__esModule = true;
  13664. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13665. var _globalDocument = _dereq_('global/document');
  13666. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13667. var _globalWindow = _dereq_('global/window');
  13668. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  13669. var USER_AGENT = _globalWindow2['default'].navigator.userAgent;
  13670. var webkitVersionMap = /AppleWebKit\/([\d.]+)/i.exec(USER_AGENT);
  13671. var appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null;
  13672. /*
  13673. * Device is an iPhone
  13674. *
  13675. * @type {Boolean}
  13676. * @constant
  13677. * @private
  13678. */
  13679. var IS_IPHONE = /iPhone/i.test(USER_AGENT);
  13680. exports.IS_IPHONE = IS_IPHONE;
  13681. var IS_IPAD = /iPad/i.test(USER_AGENT);
  13682. exports.IS_IPAD = IS_IPAD;
  13683. var IS_IPOD = /iPod/i.test(USER_AGENT);
  13684. exports.IS_IPOD = IS_IPOD;
  13685. var IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;
  13686. exports.IS_IOS = IS_IOS;
  13687. var IOS_VERSION = (function () {
  13688. var match = USER_AGENT.match(/OS (\d+)_/i);
  13689. if (match && match[1]) {
  13690. return match[1];
  13691. }
  13692. })();
  13693. exports.IOS_VERSION = IOS_VERSION;
  13694. var IS_ANDROID = /Android/i.test(USER_AGENT);
  13695. exports.IS_ANDROID = IS_ANDROID;
  13696. var ANDROID_VERSION = (function () {
  13697. // This matches Android Major.Minor.Patch versions
  13698. // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
  13699. var match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i),
  13700. major,
  13701. minor;
  13702. if (!match) {
  13703. return null;
  13704. }
  13705. major = match[1] && parseFloat(match[1]);
  13706. minor = match[2] && parseFloat(match[2]);
  13707. if (major && minor) {
  13708. return parseFloat(match[1] + '.' + match[2]);
  13709. } else if (major) {
  13710. return major;
  13711. } else {
  13712. return null;
  13713. }
  13714. })();
  13715. exports.ANDROID_VERSION = ANDROID_VERSION;
  13716. // Old Android is defined as Version older than 2.3, and requiring a webkit version of the android browser
  13717. var IS_OLD_ANDROID = IS_ANDROID && /webkit/i.test(USER_AGENT) && ANDROID_VERSION < 2.3;
  13718. exports.IS_OLD_ANDROID = IS_OLD_ANDROID;
  13719. var IS_NATIVE_ANDROID = IS_ANDROID && ANDROID_VERSION < 5 && appleWebkitVersion < 537;
  13720. exports.IS_NATIVE_ANDROID = IS_NATIVE_ANDROID;
  13721. var IS_FIREFOX = /Firefox/i.test(USER_AGENT);
  13722. exports.IS_FIREFOX = IS_FIREFOX;
  13723. var IS_CHROME = /Chrome/i.test(USER_AGENT);
  13724. exports.IS_CHROME = IS_CHROME;
  13725. var IS_IE8 = /MSIE\s8\.0/.test(USER_AGENT);
  13726. exports.IS_IE8 = IS_IE8;
  13727. var TOUCH_ENABLED = !!('ontouchstart' in _globalWindow2['default'] || _globalWindow2['default'].DocumentTouch && _globalDocument2['default'] instanceof _globalWindow2['default'].DocumentTouch);
  13728. exports.TOUCH_ENABLED = TOUCH_ENABLED;
  13729. var BACKGROUND_SIZE_SUPPORTED = ('backgroundSize' in _globalDocument2['default'].createElement('video').style);
  13730. exports.BACKGROUND_SIZE_SUPPORTED = BACKGROUND_SIZE_SUPPORTED;
  13731. },{"global/document":1,"global/window":2}],126:[function(_dereq_,module,exports){
  13732. /**
  13733. * @file buffer.js
  13734. */
  13735. 'use strict';
  13736. exports.__esModule = true;
  13737. exports.bufferedPercent = bufferedPercent;
  13738. var _timeRangesJs = _dereq_('./time-ranges.js');
  13739. /**
  13740. * Compute how much your video has been buffered
  13741. *
  13742. * @param {Object} Buffered object
  13743. * @param {Number} Total duration
  13744. * @return {Number} Percent buffered of the total duration
  13745. * @private
  13746. * @function bufferedPercent
  13747. */
  13748. function bufferedPercent(buffered, duration) {
  13749. var bufferedDuration = 0,
  13750. start,
  13751. end;
  13752. if (!duration) {
  13753. return 0;
  13754. }
  13755. if (!buffered || !buffered.length) {
  13756. buffered = _timeRangesJs.createTimeRange(0, 0);
  13757. }
  13758. for (var i = 0; i < buffered.length; i++) {
  13759. start = buffered.start(i);
  13760. end = buffered.end(i);
  13761. // buffered end can be bigger than duration by a very small fraction
  13762. if (end > duration) {
  13763. end = duration;
  13764. }
  13765. bufferedDuration += end - start;
  13766. }
  13767. return bufferedDuration / duration;
  13768. }
  13769. },{"./time-ranges.js":136}],127:[function(_dereq_,module,exports){
  13770. 'use strict';
  13771. exports.__esModule = true;
  13772. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13773. var _logJs = _dereq_('./log.js');
  13774. var _logJs2 = _interopRequireDefault(_logJs);
  13775. /**
  13776. * Object containing the default behaviors for available handler methods.
  13777. *
  13778. * @private
  13779. * @type {Object}
  13780. */
  13781. var defaultBehaviors = {
  13782. get: function get(obj, key) {
  13783. return obj[key];
  13784. },
  13785. set: function set(obj, key, value) {
  13786. obj[key] = value;
  13787. return true;
  13788. }
  13789. };
  13790. /**
  13791. * Expose private objects publicly using a Proxy to log deprecation warnings.
  13792. *
  13793. * Browsers that do not support Proxy objects will simply return the `target`
  13794. * object, so it can be directly exposed.
  13795. *
  13796. * @param {Object} target The target object.
  13797. * @param {Object} messages Messages to display from a Proxy. Only operations
  13798. * with an associated message will be proxied.
  13799. * @param {String} [messages.get]
  13800. * @param {String} [messages.set]
  13801. * @return {Object} A Proxy if supported or the `target` argument.
  13802. */
  13803. exports['default'] = function (target) {
  13804. var messages = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  13805. if (typeof Proxy === 'function') {
  13806. var _ret = (function () {
  13807. var handler = {};
  13808. // Build a handler object based on those keys that have both messages
  13809. // and default behaviors.
  13810. Object.keys(messages).forEach(function (key) {
  13811. if (defaultBehaviors.hasOwnProperty(key)) {
  13812. handler[key] = function () {
  13813. _logJs2['default'].warn(messages[key]);
  13814. return defaultBehaviors[key].apply(this, arguments);
  13815. };
  13816. }
  13817. });
  13818. return {
  13819. v: new Proxy(target, handler)
  13820. };
  13821. })();
  13822. if (typeof _ret === 'object') return _ret.v;
  13823. }
  13824. return target;
  13825. };
  13826. module.exports = exports['default'];
  13827. },{"./log.js":133}],128:[function(_dereq_,module,exports){
  13828. /**
  13829. * @file dom.js
  13830. */
  13831. 'use strict';
  13832. exports.__esModule = true;
  13833. exports.getEl = getEl;
  13834. exports.createEl = createEl;
  13835. exports.textContent = textContent;
  13836. exports.insertElFirst = insertElFirst;
  13837. exports.getElData = getElData;
  13838. exports.hasElData = hasElData;
  13839. exports.removeElData = removeElData;
  13840. exports.hasElClass = hasElClass;
  13841. exports.addElClass = addElClass;
  13842. exports.removeElClass = removeElClass;
  13843. exports.toggleElClass = toggleElClass;
  13844. exports.setElAttributes = setElAttributes;
  13845. exports.getElAttributes = getElAttributes;
  13846. exports.blockTextSelection = blockTextSelection;
  13847. exports.unblockTextSelection = unblockTextSelection;
  13848. exports.findElPosition = findElPosition;
  13849. exports.getPointerPosition = getPointerPosition;
  13850. exports.isEl = isEl;
  13851. exports.isTextNode = isTextNode;
  13852. exports.emptyEl = emptyEl;
  13853. exports.normalizeContent = normalizeContent;
  13854. exports.appendContent = appendContent;
  13855. exports.insertContent = insertContent;
  13856. 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 ', '.']);
  13857. 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; } }
  13858. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13859. function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings; }
  13860. var _globalDocument = _dereq_('global/document');
  13861. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13862. var _globalWindow = _dereq_('global/window');
  13863. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  13864. var _guidJs = _dereq_('./guid.js');
  13865. var Guid = _interopRequireWildcard(_guidJs);
  13866. var _logJs = _dereq_('./log.js');
  13867. var _logJs2 = _interopRequireDefault(_logJs);
  13868. var _tsml = _dereq_('tsml');
  13869. var _tsml2 = _interopRequireDefault(_tsml);
  13870. /**
  13871. * Detect if a value is a string with any non-whitespace characters.
  13872. *
  13873. * @param {String} str
  13874. * @return {Boolean}
  13875. */
  13876. function isNonBlankString(str) {
  13877. return typeof str === 'string' && /\S/.test(str);
  13878. }
  13879. /**
  13880. * Throws an error if the passed string has whitespace. This is used by
  13881. * class methods to be relatively consistent with the classList API.
  13882. *
  13883. * @param {String} str
  13884. * @return {Boolean}
  13885. */
  13886. function throwIfWhitespace(str) {
  13887. if (/\s/.test(str)) {
  13888. throw new Error('class has illegal whitespace characters');
  13889. }
  13890. }
  13891. /**
  13892. * Produce a regular expression for matching a class name.
  13893. *
  13894. * @param {String} className
  13895. * @return {RegExp}
  13896. */
  13897. function classRegExp(className) {
  13898. return new RegExp('(^|\\s)' + className + '($|\\s)');
  13899. }
  13900. /**
  13901. * Creates functions to query the DOM using a given method.
  13902. *
  13903. * @function createQuerier
  13904. * @private
  13905. * @param {String} method
  13906. * @return {Function}
  13907. */
  13908. function createQuerier(method) {
  13909. return function (selector, context) {
  13910. if (!isNonBlankString(selector)) {
  13911. return _globalDocument2['default'][method](null);
  13912. }
  13913. if (isNonBlankString(context)) {
  13914. context = _globalDocument2['default'].querySelector(context);
  13915. }
  13916. return (isEl(context) ? context : _globalDocument2['default'])[method](selector);
  13917. };
  13918. }
  13919. /**
  13920. * Shorthand for document.getElementById()
  13921. * Also allows for CSS (jQuery) ID syntax. But nothing other than IDs.
  13922. *
  13923. * @param {String} id Element ID
  13924. * @return {Element} Element with supplied ID
  13925. * @function getEl
  13926. */
  13927. function getEl(id) {
  13928. if (id.indexOf('#') === 0) {
  13929. id = id.slice(1);
  13930. }
  13931. return _globalDocument2['default'].getElementById(id);
  13932. }
  13933. /**
  13934. * Creates an element and applies properties.
  13935. *
  13936. * @param {String} [tagName='div'] Name of tag to be created.
  13937. * @param {Object} [properties={}] Element properties to be applied.
  13938. * @param {Object} [attributes={}] Element attributes to be applied.
  13939. * @return {Element}
  13940. * @function createEl
  13941. */
  13942. function createEl() {
  13943. var tagName = arguments.length <= 0 || arguments[0] === undefined ? 'div' : arguments[0];
  13944. var properties = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  13945. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  13946. var el = _globalDocument2['default'].createElement(tagName);
  13947. Object.getOwnPropertyNames(properties).forEach(function (propName) {
  13948. var val = properties[propName];
  13949. // See #2176
  13950. // We originally were accepting both properties and attributes in the
  13951. // same object, but that doesn't work so well.
  13952. if (propName.indexOf('aria-') !== -1 || propName === 'role' || propName === 'type') {
  13953. _logJs2['default'].warn(_tsml2['default'](_templateObject, propName, val));
  13954. el.setAttribute(propName, val);
  13955. } else {
  13956. el[propName] = val;
  13957. }
  13958. });
  13959. Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
  13960. var val = attributes[attrName];
  13961. el.setAttribute(attrName, attributes[attrName]);
  13962. });
  13963. return el;
  13964. }
  13965. /**
  13966. * Injects text into an element, replacing any existing contents entirely.
  13967. *
  13968. * @param {Element} el
  13969. * @param {String} text
  13970. * @return {Element}
  13971. * @function textContent
  13972. */
  13973. function textContent(el, text) {
  13974. if (typeof el.textContent === 'undefined') {
  13975. el.innerText = text;
  13976. } else {
  13977. el.textContent = text;
  13978. }
  13979. }
  13980. /**
  13981. * Insert an element as the first child node of another
  13982. *
  13983. * @param {Element} child Element to insert
  13984. * @param {Element} parent Element to insert child into
  13985. * @private
  13986. * @function insertElFirst
  13987. */
  13988. function insertElFirst(child, parent) {
  13989. if (parent.firstChild) {
  13990. parent.insertBefore(child, parent.firstChild);
  13991. } else {
  13992. parent.appendChild(child);
  13993. }
  13994. }
  13995. /**
  13996. * Element Data Store. Allows for binding data to an element without putting it directly on the element.
  13997. * Ex. Event listeners are stored here.
  13998. * (also from jsninja.com, slightly modified and updated for closure compiler)
  13999. *
  14000. * @type {Object}
  14001. * @private
  14002. */
  14003. var elData = {};
  14004. /*
  14005. * Unique attribute name to store an element's guid in
  14006. *
  14007. * @type {String}
  14008. * @constant
  14009. * @private
  14010. */
  14011. var elIdAttr = 'vdata' + new Date().getTime();
  14012. /**
  14013. * Returns the cache object where data for an element is stored
  14014. *
  14015. * @param {Element} el Element to store data for.
  14016. * @return {Object}
  14017. * @function getElData
  14018. */
  14019. function getElData(el) {
  14020. var id = el[elIdAttr];
  14021. if (!id) {
  14022. id = el[elIdAttr] = Guid.newGUID();
  14023. }
  14024. if (!elData[id]) {
  14025. elData[id] = {};
  14026. }
  14027. return elData[id];
  14028. }
  14029. /**
  14030. * Returns whether or not an element has cached data
  14031. *
  14032. * @param {Element} el A dom element
  14033. * @return {Boolean}
  14034. * @private
  14035. * @function hasElData
  14036. */
  14037. function hasElData(el) {
  14038. var id = el[elIdAttr];
  14039. if (!id) {
  14040. return false;
  14041. }
  14042. return !!Object.getOwnPropertyNames(elData[id]).length;
  14043. }
  14044. /**
  14045. * Delete data for the element from the cache and the guid attr from getElementById
  14046. *
  14047. * @param {Element} el Remove data for an element
  14048. * @private
  14049. * @function removeElData
  14050. */
  14051. function removeElData(el) {
  14052. var id = el[elIdAttr];
  14053. if (!id) {
  14054. return;
  14055. }
  14056. // Remove all stored data
  14057. delete elData[id];
  14058. // Remove the elIdAttr property from the DOM node
  14059. try {
  14060. delete el[elIdAttr];
  14061. } catch (e) {
  14062. if (el.removeAttribute) {
  14063. el.removeAttribute(elIdAttr);
  14064. } else {
  14065. // IE doesn't appear to support removeAttribute on the document element
  14066. el[elIdAttr] = null;
  14067. }
  14068. }
  14069. }
  14070. /**
  14071. * Check if an element has a CSS class
  14072. *
  14073. * @function hasElClass
  14074. * @param {Element} element Element to check
  14075. * @param {String} classToCheck Classname to check
  14076. */
  14077. function hasElClass(element, classToCheck) {
  14078. if (element.classList) {
  14079. return element.classList.contains(classToCheck);
  14080. } else {
  14081. throwIfWhitespace(classToCheck);
  14082. return classRegExp(classToCheck).test(element.className);
  14083. }
  14084. }
  14085. /**
  14086. * Add a CSS class name to an element
  14087. *
  14088. * @function addElClass
  14089. * @param {Element} element Element to add class name to
  14090. * @param {String} classToAdd Classname to add
  14091. */
  14092. function addElClass(element, classToAdd) {
  14093. if (element.classList) {
  14094. element.classList.add(classToAdd);
  14095. // Don't need to `throwIfWhitespace` here because `hasElClass` will do it
  14096. // in the case of classList not being supported.
  14097. } else if (!hasElClass(element, classToAdd)) {
  14098. element.className = (element.className + ' ' + classToAdd).trim();
  14099. }
  14100. return element;
  14101. }
  14102. /**
  14103. * Remove a CSS class name from an element
  14104. *
  14105. * @function removeElClass
  14106. * @param {Element} element Element to remove from class name
  14107. * @param {String} classToRemove Classname to remove
  14108. */
  14109. function removeElClass(element, classToRemove) {
  14110. if (element.classList) {
  14111. element.classList.remove(classToRemove);
  14112. } else {
  14113. throwIfWhitespace(classToRemove);
  14114. element.className = element.className.split(/\s+/).filter(function (c) {
  14115. return c !== classToRemove;
  14116. }).join(' ');
  14117. }
  14118. return element;
  14119. }
  14120. /**
  14121. * Adds or removes a CSS class name on an element depending on an optional
  14122. * condition or the presence/absence of the class name.
  14123. *
  14124. * @function toggleElClass
  14125. * @param {Element} element
  14126. * @param {String} classToToggle
  14127. * @param {Boolean|Function} [predicate]
  14128. * Can be a function that returns a Boolean. If `true`, the class
  14129. * will be added; if `false`, the class will be removed. If not
  14130. * given, the class will be added if not present and vice versa.
  14131. */
  14132. function toggleElClass(element, classToToggle, predicate) {
  14133. // This CANNOT use `classList` internally because IE does not support the
  14134. // second parameter to the `classList.toggle()` method! Which is fine because
  14135. // `classList` will be used by the add/remove functions.
  14136. var has = hasElClass(element, classToToggle);
  14137. if (typeof predicate === 'function') {
  14138. predicate = predicate(element, classToToggle);
  14139. }
  14140. if (typeof predicate !== 'boolean') {
  14141. predicate = !has;
  14142. }
  14143. // If the necessary class operation matches the current state of the
  14144. // element, no action is required.
  14145. if (predicate === has) {
  14146. return;
  14147. }
  14148. if (predicate) {
  14149. addElClass(element, classToToggle);
  14150. } else {
  14151. removeElClass(element, classToToggle);
  14152. }
  14153. return element;
  14154. }
  14155. /**
  14156. * Apply attributes to an HTML element.
  14157. *
  14158. * @param {Element} el Target element.
  14159. * @param {Object=} attributes Element attributes to be applied.
  14160. * @private
  14161. * @function setElAttributes
  14162. */
  14163. function setElAttributes(el, attributes) {
  14164. Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
  14165. var attrValue = attributes[attrName];
  14166. if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
  14167. el.removeAttribute(attrName);
  14168. } else {
  14169. el.setAttribute(attrName, attrValue === true ? '' : attrValue);
  14170. }
  14171. });
  14172. }
  14173. /**
  14174. * Get an element's attribute values, as defined on the HTML tag
  14175. * Attributes are not the same as properties. They're defined on the tag
  14176. * or with setAttribute (which shouldn't be used with HTML)
  14177. * This will return true or false for boolean attributes.
  14178. *
  14179. * @param {Element} tag Element from which to get tag attributes
  14180. * @return {Object}
  14181. * @private
  14182. * @function getElAttributes
  14183. */
  14184. function getElAttributes(tag) {
  14185. var obj, knownBooleans, attrs, attrName, attrVal;
  14186. obj = {};
  14187. // known boolean attributes
  14188. // we can check for matching boolean properties, but older browsers
  14189. // won't know about HTML5 boolean attributes that we still read from
  14190. knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ',';
  14191. if (tag && tag.attributes && tag.attributes.length > 0) {
  14192. attrs = tag.attributes;
  14193. for (var i = attrs.length - 1; i >= 0; i--) {
  14194. attrName = attrs[i].name;
  14195. attrVal = attrs[i].value;
  14196. // check for known booleans
  14197. // the matching element property will return a value for typeof
  14198. if (typeof tag[attrName] === 'boolean' || knownBooleans.indexOf(',' + attrName + ',') !== -1) {
  14199. // the value of an included boolean attribute is typically an empty
  14200. // string ('') which would equal false if we just check for a false value.
  14201. // we also don't want support bad code like autoplay='false'
  14202. attrVal = attrVal !== null ? true : false;
  14203. }
  14204. obj[attrName] = attrVal;
  14205. }
  14206. }
  14207. return obj;
  14208. }
  14209. /**
  14210. * Attempt to block the ability to select text while dragging controls
  14211. *
  14212. * @return {Boolean}
  14213. * @function blockTextSelection
  14214. */
  14215. function blockTextSelection() {
  14216. _globalDocument2['default'].body.focus();
  14217. _globalDocument2['default'].onselectstart = function () {
  14218. return false;
  14219. };
  14220. }
  14221. /**
  14222. * Turn off text selection blocking
  14223. *
  14224. * @return {Boolean}
  14225. * @function unblockTextSelection
  14226. */
  14227. function unblockTextSelection() {
  14228. _globalDocument2['default'].onselectstart = function () {
  14229. return true;
  14230. };
  14231. }
  14232. /**
  14233. * Offset Left
  14234. * getBoundingClientRect technique from
  14235. * John Resig http://ejohn.org/blog/getboundingclientrect-is-awesome/
  14236. *
  14237. * @function findElPosition
  14238. * @param {Element} el Element from which to get offset
  14239. * @return {Object}
  14240. */
  14241. function findElPosition(el) {
  14242. var box = undefined;
  14243. if (el.getBoundingClientRect && el.parentNode) {
  14244. box = el.getBoundingClientRect();
  14245. }
  14246. if (!box) {
  14247. return {
  14248. left: 0,
  14249. top: 0
  14250. };
  14251. }
  14252. var docEl = _globalDocument2['default'].documentElement;
  14253. var body = _globalDocument2['default'].body;
  14254. var clientLeft = docEl.clientLeft || body.clientLeft || 0;
  14255. var scrollLeft = _globalWindow2['default'].pageXOffset || body.scrollLeft;
  14256. var left = box.left + scrollLeft - clientLeft;
  14257. var clientTop = docEl.clientTop || body.clientTop || 0;
  14258. var scrollTop = _globalWindow2['default'].pageYOffset || body.scrollTop;
  14259. var top = box.top + scrollTop - clientTop;
  14260. // Android sometimes returns slightly off decimal values, so need to round
  14261. return {
  14262. left: Math.round(left),
  14263. top: Math.round(top)
  14264. };
  14265. }
  14266. /**
  14267. * Get pointer position in element
  14268. * Returns an object with x and y coordinates.
  14269. * The base on the coordinates are the bottom left of the element.
  14270. *
  14271. * @function getPointerPosition
  14272. * @param {Element} el Element on which to get the pointer position on
  14273. * @param {Event} event Event object
  14274. * @return {Object} This object will have x and y coordinates corresponding to the mouse position
  14275. */
  14276. function getPointerPosition(el, event) {
  14277. var position = {};
  14278. var box = findElPosition(el);
  14279. var boxW = el.offsetWidth;
  14280. var boxH = el.offsetHeight;
  14281. var boxY = box.top;
  14282. var boxX = box.left;
  14283. var pageY = event.pageY;
  14284. var pageX = event.pageX;
  14285. if (event.changedTouches) {
  14286. pageX = event.changedTouches[0].pageX;
  14287. pageY = event.changedTouches[0].pageY;
  14288. }
  14289. position.y = Math.max(0, Math.min(1, (boxY - pageY + boxH) / boxH));
  14290. position.x = Math.max(0, Math.min(1, (pageX - boxX) / boxW));
  14291. return position;
  14292. }
  14293. /**
  14294. * Determines, via duck typing, whether or not a value is a DOM element.
  14295. *
  14296. * @function isEl
  14297. * @param {Mixed} value
  14298. * @return {Boolean}
  14299. */
  14300. function isEl(value) {
  14301. return !!value && typeof value === 'object' && value.nodeType === 1;
  14302. }
  14303. /**
  14304. * Determines, via duck typing, whether or not a value is a text node.
  14305. *
  14306. * @param {Mixed} value
  14307. * @return {Boolean}
  14308. */
  14309. function isTextNode(value) {
  14310. return !!value && typeof value === 'object' && value.nodeType === 3;
  14311. }
  14312. /**
  14313. * Empties the contents of an element.
  14314. *
  14315. * @function emptyEl
  14316. * @param {Element} el
  14317. * @return {Element}
  14318. */
  14319. function emptyEl(el) {
  14320. while (el.firstChild) {
  14321. el.removeChild(el.firstChild);
  14322. }
  14323. return el;
  14324. }
  14325. /**
  14326. * Normalizes content for eventual insertion into the DOM.
  14327. *
  14328. * This allows a wide range of content definition methods, but protects
  14329. * from falling into the trap of simply writing to `innerHTML`, which is
  14330. * an XSS concern.
  14331. *
  14332. * The content for an element can be passed in multiple types and
  14333. * combinations, whose behavior is as follows:
  14334. *
  14335. * - String
  14336. * Normalized into a text node.
  14337. *
  14338. * - Element, TextNode
  14339. * Passed through.
  14340. *
  14341. * - Array
  14342. * A one-dimensional array of strings, elements, nodes, or functions (which
  14343. * return single strings, elements, or nodes).
  14344. *
  14345. * - Function
  14346. * If the sole argument, is expected to produce a string, element,
  14347. * node, or array.
  14348. *
  14349. * @function normalizeContent
  14350. * @param {String|Element|TextNode|Array|Function} content
  14351. * @return {Array}
  14352. */
  14353. function normalizeContent(content) {
  14354. // First, invoke content if it is a function. If it produces an array,
  14355. // that needs to happen before normalization.
  14356. if (typeof content === 'function') {
  14357. content = content();
  14358. }
  14359. // Next up, normalize to an array, so one or many items can be normalized,
  14360. // filtered, and returned.
  14361. return (Array.isArray(content) ? content : [content]).map(function (value) {
  14362. // First, invoke value if it is a function to produce a new value,
  14363. // which will be subsequently normalized to a Node of some kind.
  14364. if (typeof value === 'function') {
  14365. value = value();
  14366. }
  14367. if (isEl(value) || isTextNode(value)) {
  14368. return value;
  14369. }
  14370. if (typeof value === 'string' && /\S/.test(value)) {
  14371. return _globalDocument2['default'].createTextNode(value);
  14372. }
  14373. }).filter(function (value) {
  14374. return value;
  14375. });
  14376. }
  14377. /**
  14378. * Normalizes and appends content to an element.
  14379. *
  14380. * @function appendContent
  14381. * @param {Element} el
  14382. * @param {String|Element|TextNode|Array|Function} content
  14383. * See: `normalizeContent`
  14384. * @return {Element}
  14385. */
  14386. function appendContent(el, content) {
  14387. normalizeContent(content).forEach(function (node) {
  14388. return el.appendChild(node);
  14389. });
  14390. return el;
  14391. }
  14392. /**
  14393. * Normalizes and inserts content into an element; this is identical to
  14394. * `appendContent()`, except it empties the element first.
  14395. *
  14396. * @function insertContent
  14397. * @param {Element} el
  14398. * @param {String|Element|TextNode|Array|Function} content
  14399. * See: `normalizeContent`
  14400. * @return {Element}
  14401. */
  14402. function insertContent(el, content) {
  14403. return appendContent(emptyEl(el), content);
  14404. }
  14405. /**
  14406. * Finds a single DOM element matching `selector` within the optional
  14407. * `context` of another DOM element (defaulting to `document`).
  14408. *
  14409. * @function $
  14410. * @param {String} selector
  14411. * A valid CSS selector, which will be passed to `querySelector`.
  14412. *
  14413. * @param {Element|String} [context=document]
  14414. * A DOM element within which to query. Can also be a selector
  14415. * string in which case the first matching element will be used
  14416. * as context. If missing (or no element matches selector), falls
  14417. * back to `document`.
  14418. *
  14419. * @return {Element|null}
  14420. */
  14421. var $ = createQuerier('querySelector');
  14422. exports.$ = $;
  14423. /**
  14424. * Finds a all DOM elements matching `selector` within the optional
  14425. * `context` of another DOM element (defaulting to `document`).
  14426. *
  14427. * @function $$
  14428. * @param {String} selector
  14429. * A valid CSS selector, which will be passed to `querySelectorAll`.
  14430. *
  14431. * @param {Element|String} [context=document]
  14432. * A DOM element within which to query. Can also be a selector
  14433. * string in which case the first matching element will be used
  14434. * as context. If missing (or no element matches selector), falls
  14435. * back to `document`.
  14436. *
  14437. * @return {NodeList}
  14438. */
  14439. var $$ = createQuerier('querySelectorAll');
  14440. exports.$$ = $$;
  14441. },{"./guid.js":132,"./log.js":133,"global/document":1,"global/window":2,"tsml":54}],129:[function(_dereq_,module,exports){
  14442. /**
  14443. * @file events.js
  14444. *
  14445. * Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)
  14446. * (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)
  14447. * This should work very similarly to jQuery's events, however it's based off the book version which isn't as
  14448. * robust as jquery's, so there's probably some differences.
  14449. */
  14450. 'use strict';
  14451. exports.__esModule = true;
  14452. exports.on = on;
  14453. exports.off = off;
  14454. exports.trigger = trigger;
  14455. exports.one = one;
  14456. exports.fixEvent = fixEvent;
  14457. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14458. 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; } }
  14459. var _domJs = _dereq_('./dom.js');
  14460. var Dom = _interopRequireWildcard(_domJs);
  14461. var _guidJs = _dereq_('./guid.js');
  14462. var Guid = _interopRequireWildcard(_guidJs);
  14463. var _globalWindow = _dereq_('global/window');
  14464. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  14465. var _globalDocument = _dereq_('global/document');
  14466. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14467. /**
  14468. * Add an event listener to element
  14469. * It stores the handler function in a separate cache object
  14470. * and adds a generic handler to the element's event,
  14471. * along with a unique id (guid) to the element.
  14472. *
  14473. * @param {Element|Object} elem Element or object to bind listeners to
  14474. * @param {String|Array} type Type of event to bind to.
  14475. * @param {Function} fn Event listener.
  14476. * @method on
  14477. */
  14478. function on(elem, type, fn) {
  14479. if (Array.isArray(type)) {
  14480. return _handleMultipleEvents(on, elem, type, fn);
  14481. }
  14482. var data = Dom.getElData(elem);
  14483. // We need a place to store all our handler data
  14484. if (!data.handlers) data.handlers = {};
  14485. if (!data.handlers[type]) data.handlers[type] = [];
  14486. if (!fn.guid) fn.guid = Guid.newGUID();
  14487. data.handlers[type].push(fn);
  14488. if (!data.dispatcher) {
  14489. data.disabled = false;
  14490. data.dispatcher = function (event, hash) {
  14491. if (data.disabled) return;
  14492. event = fixEvent(event);
  14493. var handlers = data.handlers[event.type];
  14494. if (handlers) {
  14495. // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
  14496. var handlersCopy = handlers.slice(0);
  14497. for (var m = 0, n = handlersCopy.length; m < n; m++) {
  14498. if (event.isImmediatePropagationStopped()) {
  14499. break;
  14500. } else {
  14501. handlersCopy[m].call(elem, event, hash);
  14502. }
  14503. }
  14504. }
  14505. };
  14506. }
  14507. if (data.handlers[type].length === 1) {
  14508. if (elem.addEventListener) {
  14509. elem.addEventListener(type, data.dispatcher, false);
  14510. } else if (elem.attachEvent) {
  14511. elem.attachEvent('on' + type, data.dispatcher);
  14512. }
  14513. }
  14514. }
  14515. /**
  14516. * Removes event listeners from an element
  14517. *
  14518. * @param {Element|Object} elem Object to remove listeners from
  14519. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  14520. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  14521. * @method off
  14522. */
  14523. function off(elem, type, fn) {
  14524. // Don't want to add a cache object through getElData if not needed
  14525. if (!Dom.hasElData(elem)) return;
  14526. var data = Dom.getElData(elem);
  14527. // If no events exist, nothing to unbind
  14528. if (!data.handlers) {
  14529. return;
  14530. }
  14531. if (Array.isArray(type)) {
  14532. return _handleMultipleEvents(off, elem, type, fn);
  14533. }
  14534. // Utility function
  14535. var removeType = function removeType(t) {
  14536. data.handlers[t] = [];
  14537. _cleanUpEvents(elem, t);
  14538. };
  14539. // Are we removing all bound events?
  14540. if (!type) {
  14541. for (var t in data.handlers) {
  14542. removeType(t);
  14543. }return;
  14544. }
  14545. var handlers = data.handlers[type];
  14546. // If no handlers exist, nothing to unbind
  14547. if (!handlers) return;
  14548. // If no listener was provided, remove all listeners for type
  14549. if (!fn) {
  14550. removeType(type);
  14551. return;
  14552. }
  14553. // We're only removing a single handler
  14554. if (fn.guid) {
  14555. for (var n = 0; n < handlers.length; n++) {
  14556. if (handlers[n].guid === fn.guid) {
  14557. handlers.splice(n--, 1);
  14558. }
  14559. }
  14560. }
  14561. _cleanUpEvents(elem, type);
  14562. }
  14563. /**
  14564. * Trigger an event for an element
  14565. *
  14566. * @param {Element|Object} elem Element to trigger an event on
  14567. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  14568. * @param {Object} [hash] data hash to pass along with the event
  14569. * @return {Boolean=} Returned only if default was prevented
  14570. * @method trigger
  14571. */
  14572. function trigger(elem, event, hash) {
  14573. // Fetches element data and a reference to the parent (for bubbling).
  14574. // Don't want to add a data object to cache for every parent,
  14575. // so checking hasElData first.
  14576. var elemData = Dom.hasElData(elem) ? Dom.getElData(elem) : {};
  14577. var parent = elem.parentNode || elem.ownerDocument;
  14578. // type = event.type || event,
  14579. // handler;
  14580. // If an event name was passed as a string, creates an event out of it
  14581. if (typeof event === 'string') {
  14582. event = { type: event, target: elem };
  14583. }
  14584. // Normalizes the event properties.
  14585. event = fixEvent(event);
  14586. // If the passed element has a dispatcher, executes the established handlers.
  14587. if (elemData.dispatcher) {
  14588. elemData.dispatcher.call(elem, event, hash);
  14589. }
  14590. // Unless explicitly stopped or the event does not bubble (e.g. media events)
  14591. // recursively calls this function to bubble the event up the DOM.
  14592. if (parent && !event.isPropagationStopped() && event.bubbles === true) {
  14593. trigger.call(null, parent, event, hash);
  14594. // If at the top of the DOM, triggers the default action unless disabled.
  14595. } else if (!parent && !event.defaultPrevented) {
  14596. var targetData = Dom.getElData(event.target);
  14597. // Checks if the target has a default action for this event.
  14598. if (event.target[event.type]) {
  14599. // Temporarily disables event dispatching on the target as we have already executed the handler.
  14600. targetData.disabled = true;
  14601. // Executes the default action.
  14602. if (typeof event.target[event.type] === 'function') {
  14603. event.target[event.type]();
  14604. }
  14605. // Re-enables event dispatching.
  14606. targetData.disabled = false;
  14607. }
  14608. }
  14609. // Inform the triggerer if the default was prevented by returning false
  14610. return !event.defaultPrevented;
  14611. }
  14612. /**
  14613. * Trigger a listener only once for an event
  14614. *
  14615. * @param {Element|Object} elem Element or object to
  14616. * @param {String|Array} type Name/type of event
  14617. * @param {Function} fn Event handler function
  14618. * @method one
  14619. */
  14620. function one(elem, type, fn) {
  14621. if (Array.isArray(type)) {
  14622. return _handleMultipleEvents(one, elem, type, fn);
  14623. }
  14624. var func = function func() {
  14625. off(elem, type, func);
  14626. fn.apply(this, arguments);
  14627. };
  14628. // copy the guid to the new function so it can removed using the original function's ID
  14629. func.guid = fn.guid = fn.guid || Guid.newGUID();
  14630. on(elem, type, func);
  14631. }
  14632. /**
  14633. * Fix a native event to have standard property values
  14634. *
  14635. * @param {Object} event Event object to fix
  14636. * @return {Object}
  14637. * @private
  14638. * @method fixEvent
  14639. */
  14640. function fixEvent(event) {
  14641. function returnTrue() {
  14642. return true;
  14643. }
  14644. function returnFalse() {
  14645. return false;
  14646. }
  14647. // Test if fixing up is needed
  14648. // Used to check if !event.stopPropagation instead of isPropagationStopped
  14649. // But native events return true for stopPropagation, but don't have
  14650. // other expected methods like isPropagationStopped. Seems to be a problem
  14651. // with the Javascript Ninja code. So we're just overriding all events now.
  14652. if (!event || !event.isPropagationStopped) {
  14653. var old = event || _globalWindow2['default'].event;
  14654. event = {};
  14655. // Clone the old object so that we can modify the values event = {};
  14656. // IE8 Doesn't like when you mess with native event properties
  14657. // Firefox returns false for event.hasOwnProperty('type') and other props
  14658. // which makes copying more difficult.
  14659. // TODO: Probably best to create a whitelist of event props
  14660. for (var key in old) {
  14661. // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
  14662. // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
  14663. // and webkitMovementX/Y
  14664. if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation' && key !== 'webkitMovementX' && key !== 'webkitMovementY') {
  14665. // Chrome 32+ warns if you try to copy deprecated returnValue, but
  14666. // we still want to if preventDefault isn't supported (IE8).
  14667. if (!(key === 'returnValue' && old.preventDefault)) {
  14668. event[key] = old[key];
  14669. }
  14670. }
  14671. }
  14672. // The event occurred on this element
  14673. if (!event.target) {
  14674. event.target = event.srcElement || _globalDocument2['default'];
  14675. }
  14676. // Handle which other element the event is related to
  14677. if (!event.relatedTarget) {
  14678. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
  14679. }
  14680. // Stop the default browser action
  14681. event.preventDefault = function () {
  14682. if (old.preventDefault) {
  14683. old.preventDefault();
  14684. }
  14685. event.returnValue = false;
  14686. old.returnValue = false;
  14687. event.defaultPrevented = true;
  14688. };
  14689. event.defaultPrevented = false;
  14690. // Stop the event from bubbling
  14691. event.stopPropagation = function () {
  14692. if (old.stopPropagation) {
  14693. old.stopPropagation();
  14694. }
  14695. event.cancelBubble = true;
  14696. old.cancelBubble = true;
  14697. event.isPropagationStopped = returnTrue;
  14698. };
  14699. event.isPropagationStopped = returnFalse;
  14700. // Stop the event from bubbling and executing other handlers
  14701. event.stopImmediatePropagation = function () {
  14702. if (old.stopImmediatePropagation) {
  14703. old.stopImmediatePropagation();
  14704. }
  14705. event.isImmediatePropagationStopped = returnTrue;
  14706. event.stopPropagation();
  14707. };
  14708. event.isImmediatePropagationStopped = returnFalse;
  14709. // Handle mouse position
  14710. if (event.clientX != null) {
  14711. var doc = _globalDocument2['default'].documentElement,
  14712. body = _globalDocument2['default'].body;
  14713. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  14714. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  14715. }
  14716. // Handle key presses
  14717. event.which = event.charCode || event.keyCode;
  14718. // Fix button for mouse clicks:
  14719. // 0 == left; 1 == middle; 2 == right
  14720. if (event.button != null) {
  14721. event.button = event.button & 1 ? 0 : event.button & 4 ? 1 : event.button & 2 ? 2 : 0;
  14722. }
  14723. }
  14724. // Returns fixed-up instance
  14725. return event;
  14726. }
  14727. /**
  14728. * Clean up the listener cache and dispatchers
  14729. *
  14730. * @param {Element|Object} elem Element to clean up
  14731. * @param {String} type Type of event to clean up
  14732. * @private
  14733. * @method _cleanUpEvents
  14734. */
  14735. function _cleanUpEvents(elem, type) {
  14736. var data = Dom.getElData(elem);
  14737. // Remove the events of a particular type if there are none left
  14738. if (data.handlers[type].length === 0) {
  14739. delete data.handlers[type];
  14740. // data.handlers[type] = null;
  14741. // Setting to null was causing an error with data.handlers
  14742. // Remove the meta-handler from the element
  14743. if (elem.removeEventListener) {
  14744. elem.removeEventListener(type, data.dispatcher, false);
  14745. } else if (elem.detachEvent) {
  14746. elem.detachEvent('on' + type, data.dispatcher);
  14747. }
  14748. }
  14749. // Remove the events object if there are no types left
  14750. if (Object.getOwnPropertyNames(data.handlers).length <= 0) {
  14751. delete data.handlers;
  14752. delete data.dispatcher;
  14753. delete data.disabled;
  14754. }
  14755. // Finally remove the element data if there is no data left
  14756. if (Object.getOwnPropertyNames(data).length === 0) {
  14757. Dom.removeElData(elem);
  14758. }
  14759. }
  14760. /**
  14761. * Loops through an array of event types and calls the requested method for each type.
  14762. *
  14763. * @param {Function} fn The event method we want to use.
  14764. * @param {Element|Object} elem Element or object to bind listeners to
  14765. * @param {String} type Type of event to bind to.
  14766. * @param {Function} callback Event listener.
  14767. * @private
  14768. * @function _handleMultipleEvents
  14769. */
  14770. function _handleMultipleEvents(fn, elem, types, callback) {
  14771. types.forEach(function (type) {
  14772. //Call the event method for each one of the types
  14773. fn(elem, type, callback);
  14774. });
  14775. }
  14776. },{"./dom.js":128,"./guid.js":132,"global/document":1,"global/window":2}],130:[function(_dereq_,module,exports){
  14777. /**
  14778. * @file fn.js
  14779. */
  14780. 'use strict';
  14781. exports.__esModule = true;
  14782. var _guidJs = _dereq_('./guid.js');
  14783. /**
  14784. * Bind (a.k.a proxy or Context). A simple method for changing the context of a function
  14785. * It also stores a unique id on the function so it can be easily removed from events
  14786. *
  14787. * @param {*} context The object to bind as scope
  14788. * @param {Function} fn The function to be bound to a scope
  14789. * @param {Number=} uid An optional unique ID for the function to be set
  14790. * @return {Function}
  14791. * @private
  14792. * @method bind
  14793. */
  14794. var bind = function bind(context, fn, uid) {
  14795. // Make sure the function has a unique ID
  14796. if (!fn.guid) {
  14797. fn.guid = _guidJs.newGUID();
  14798. }
  14799. // Create the new function that changes the context
  14800. var ret = function ret() {
  14801. return fn.apply(context, arguments);
  14802. };
  14803. // Allow for the ability to individualize this function
  14804. // Needed in the case where multiple objects might share the same prototype
  14805. // IF both items add an event listener with the same function, then you try to remove just one
  14806. // it will remove both because they both have the same guid.
  14807. // when using this, you need to use the bind method when you remove the listener as well.
  14808. // currently used in text tracks
  14809. ret.guid = uid ? uid + '_' + fn.guid : fn.guid;
  14810. return ret;
  14811. };
  14812. exports.bind = bind;
  14813. },{"./guid.js":132}],131:[function(_dereq_,module,exports){
  14814. /**
  14815. * @file format-time.js
  14816. *
  14817. * Format seconds as a time string, H:MM:SS or M:SS
  14818. * Supplying a guide (in seconds) will force a number of leading zeros
  14819. * to cover the length of the guide
  14820. *
  14821. * @param {Number} seconds Number of seconds to be turned into a string
  14822. * @param {Number} guide Number (in seconds) to model the string after
  14823. * @return {String} Time formatted as H:MM:SS or M:SS
  14824. * @private
  14825. * @function formatTime
  14826. */
  14827. 'use strict';
  14828. exports.__esModule = true;
  14829. function formatTime(seconds) {
  14830. var guide = arguments.length <= 1 || arguments[1] === undefined ? seconds : arguments[1];
  14831. return (function () {
  14832. seconds = seconds < 0 ? 0 : seconds;
  14833. var s = Math.floor(seconds % 60);
  14834. var m = Math.floor(seconds / 60 % 60);
  14835. var h = Math.floor(seconds / 3600);
  14836. var gm = Math.floor(guide / 60 % 60);
  14837. var gh = Math.floor(guide / 3600);
  14838. // handle invalid times
  14839. if (isNaN(seconds) || seconds === Infinity) {
  14840. // '-' is false for all relational operators (e.g. <, >=) so this setting
  14841. // will add the minimum number of fields specified by the guide
  14842. h = m = s = '-';
  14843. }
  14844. // Check if we need to show hours
  14845. h = h > 0 || gh > 0 ? h + ':' : '';
  14846. // If hours are showing, we may need to add a leading zero.
  14847. // Always show at least one digit of minutes.
  14848. m = ((h || gm >= 10) && m < 10 ? '0' + m : m) + ':';
  14849. // Check if leading zero is need for seconds
  14850. s = s < 10 ? '0' + s : s;
  14851. return h + m + s;
  14852. })();
  14853. }
  14854. exports['default'] = formatTime;
  14855. module.exports = exports['default'];
  14856. },{}],132:[function(_dereq_,module,exports){
  14857. /**
  14858. * @file guid.js
  14859. *
  14860. * Unique ID for an element or function
  14861. * @type {Number}
  14862. * @private
  14863. */
  14864. "use strict";
  14865. exports.__esModule = true;
  14866. exports.newGUID = newGUID;
  14867. var _guid = 1;
  14868. /**
  14869. * Get the next unique ID
  14870. *
  14871. * @return {String}
  14872. * @function newGUID
  14873. */
  14874. function newGUID() {
  14875. return _guid++;
  14876. }
  14877. },{}],133:[function(_dereq_,module,exports){
  14878. /**
  14879. * @file log.js
  14880. */
  14881. 'use strict';
  14882. exports.__esModule = true;
  14883. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14884. var _globalWindow = _dereq_('global/window');
  14885. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  14886. /**
  14887. * Log plain debug messages
  14888. */
  14889. var log = function log() {
  14890. _logType(null, arguments);
  14891. };
  14892. /**
  14893. * Keep a history of log messages
  14894. * @type {Array}
  14895. */
  14896. log.history = [];
  14897. /**
  14898. * Log error messages
  14899. */
  14900. log.error = function () {
  14901. _logType('error', arguments);
  14902. };
  14903. /**
  14904. * Log warning messages
  14905. */
  14906. log.warn = function () {
  14907. _logType('warn', arguments);
  14908. };
  14909. /**
  14910. * Log messages to the console and history based on the type of message
  14911. *
  14912. * @param {String} type The type of message, or `null` for `log`
  14913. * @param {Object} args The args to be passed to the log
  14914. * @private
  14915. * @method _logType
  14916. */
  14917. function _logType(type, args) {
  14918. // convert args to an array to get array functions
  14919. var argsArray = Array.prototype.slice.call(args);
  14920. // if there's no console then don't try to output messages
  14921. // they will still be stored in log.history
  14922. // Was setting these once outside of this function, but containing them
  14923. // in the function makes it easier to test cases where console doesn't exist
  14924. var noop = function noop() {};
  14925. var console = _globalWindow2['default']['console'] || {
  14926. 'log': noop,
  14927. 'warn': noop,
  14928. 'error': noop
  14929. };
  14930. if (type) {
  14931. // add the type to the front of the message
  14932. argsArray.unshift(type.toUpperCase() + ':');
  14933. } else {
  14934. // default to log with no prefix
  14935. type = 'log';
  14936. }
  14937. // add to history
  14938. log.history.push(argsArray);
  14939. // add console prefix after adding to history
  14940. argsArray.unshift('VIDEOJS:');
  14941. // call appropriate log function
  14942. if (console[type].apply) {
  14943. console[type].apply(console, argsArray);
  14944. } else {
  14945. // ie8 doesn't allow error.apply, but it will just join() the array anyway
  14946. console[type](argsArray.join(' '));
  14947. }
  14948. }
  14949. exports['default'] = log;
  14950. module.exports = exports['default'];
  14951. },{"global/window":2}],134:[function(_dereq_,module,exports){
  14952. /**
  14953. * @file merge-options.js
  14954. */
  14955. 'use strict';
  14956. exports.__esModule = true;
  14957. exports['default'] = mergeOptions;
  14958. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14959. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge');
  14960. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge);
  14961. function isPlain(obj) {
  14962. return !!obj && typeof obj === 'object' && obj.toString() === '[object Object]' && obj.constructor === Object;
  14963. }
  14964. /**
  14965. * Merge customizer. video.js simply overwrites non-simple objects
  14966. * (like arrays) instead of attempting to overlay them.
  14967. * @see https://lodash.com/docs#merge
  14968. */
  14969. var customizer = function customizer(destination, source) {
  14970. // If we're not working with a plain object, copy the value as is
  14971. // If source is an array, for instance, it will replace destination
  14972. if (!isPlain(source)) {
  14973. return source;
  14974. }
  14975. // If the new value is a plain object but the first object value is not
  14976. // we need to create a new object for the first object to merge with.
  14977. // This makes it consistent with how merge() works by default
  14978. // and also protects from later changes the to first object affecting
  14979. // the second object's values.
  14980. if (!isPlain(destination)) {
  14981. return mergeOptions(source);
  14982. }
  14983. };
  14984. /**
  14985. * Merge one or more options objects, recursively merging **only**
  14986. * plain object properties. Previously `deepMerge`.
  14987. *
  14988. * @param {...Object} source One or more objects to merge
  14989. * @returns {Object} a new object that is the union of all
  14990. * provided objects
  14991. * @function mergeOptions
  14992. */
  14993. function mergeOptions() {
  14994. // contruct the call dynamically to handle the variable number of
  14995. // objects to merge
  14996. var args = Array.prototype.slice.call(arguments);
  14997. // unshift an empty object into the front of the call as the target
  14998. // of the merge
  14999. args.unshift({});
  15000. // customize conflict resolution to match our historical merge behavior
  15001. args.push(customizer);
  15002. _lodashCompatObjectMerge2['default'].apply(null, args);
  15003. // return the mutated result object
  15004. return args[0];
  15005. }
  15006. module.exports = exports['default'];
  15007. },{"lodash-compat/object/merge":40}],135:[function(_dereq_,module,exports){
  15008. 'use strict';
  15009. exports.__esModule = true;
  15010. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15011. var _globalDocument = _dereq_('global/document');
  15012. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15013. var createStyleElement = function createStyleElement(className) {
  15014. var style = _globalDocument2['default'].createElement('style');
  15015. style.className = className;
  15016. return style;
  15017. };
  15018. exports.createStyleElement = createStyleElement;
  15019. var setTextContent = function setTextContent(el, content) {
  15020. if (el.styleSheet) {
  15021. el.styleSheet.cssText = content;
  15022. } else {
  15023. el.textContent = content;
  15024. }
  15025. };
  15026. exports.setTextContent = setTextContent;
  15027. },{"global/document":1}],136:[function(_dereq_,module,exports){
  15028. 'use strict';
  15029. exports.__esModule = true;
  15030. exports.createTimeRanges = createTimeRanges;
  15031. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15032. var _logJs = _dereq_('./log.js');
  15033. var _logJs2 = _interopRequireDefault(_logJs);
  15034. /**
  15035. * @file time-ranges.js
  15036. *
  15037. * Should create a fake TimeRange object
  15038. * Mimics an HTML5 time range instance, which has functions that
  15039. * return the start and end times for a range
  15040. * TimeRanges are returned by the buffered() method
  15041. *
  15042. * @param {(Number|Array)} Start of a single range or an array of ranges
  15043. * @param {Number} End of a single range
  15044. * @private
  15045. * @method createTimeRanges
  15046. */
  15047. function createTimeRanges(start, end) {
  15048. if (Array.isArray(start)) {
  15049. return createTimeRangesObj(start);
  15050. } else if (start === undefined || end === undefined) {
  15051. return createTimeRangesObj();
  15052. }
  15053. return createTimeRangesObj([[start, end]]);
  15054. }
  15055. exports.createTimeRange = createTimeRanges;
  15056. function createTimeRangesObj(ranges) {
  15057. if (ranges === undefined || ranges.length === 0) {
  15058. return {
  15059. length: 0,
  15060. start: function start() {
  15061. throw new Error('This TimeRanges object is empty');
  15062. },
  15063. end: function end() {
  15064. throw new Error('This TimeRanges object is empty');
  15065. }
  15066. };
  15067. }
  15068. return {
  15069. length: ranges.length,
  15070. start: getRange.bind(null, 'start', 0, ranges),
  15071. end: getRange.bind(null, 'end', 1, ranges)
  15072. };
  15073. }
  15074. function getRange(fnName, valueIndex, ranges, rangeIndex) {
  15075. if (rangeIndex === undefined) {
  15076. _logJs2['default'].warn('DEPRECATED: Function \'' + fnName + '\' on \'TimeRanges\' called without an index argument.');
  15077. rangeIndex = 0;
  15078. }
  15079. rangeCheck(fnName, rangeIndex, ranges.length - 1);
  15080. return ranges[rangeIndex][valueIndex];
  15081. }
  15082. function rangeCheck(fnName, index, maxIndex) {
  15083. if (index < 0 || index > maxIndex) {
  15084. throw new Error('Failed to execute \'' + fnName + '\' on \'TimeRanges\': The index provided (' + index + ') is greater than or equal to the maximum bound (' + maxIndex + ').');
  15085. }
  15086. }
  15087. },{"./log.js":133}],137:[function(_dereq_,module,exports){
  15088. /**
  15089. * @file to-title-case.js
  15090. *
  15091. * Uppercase the first letter of a string
  15092. *
  15093. * @param {String} string String to be uppercased
  15094. * @return {String}
  15095. * @private
  15096. * @method toTitleCase
  15097. */
  15098. "use strict";
  15099. exports.__esModule = true;
  15100. function toTitleCase(string) {
  15101. return string.charAt(0).toUpperCase() + string.slice(1);
  15102. }
  15103. exports["default"] = toTitleCase;
  15104. module.exports = exports["default"];
  15105. },{}],138:[function(_dereq_,module,exports){
  15106. /**
  15107. * @file url.js
  15108. */
  15109. 'use strict';
  15110. exports.__esModule = true;
  15111. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15112. var _globalDocument = _dereq_('global/document');
  15113. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15114. var _globalWindow = _dereq_('global/window');
  15115. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  15116. /**
  15117. * Resolve and parse the elements of a URL
  15118. *
  15119. * @param {String} url The url to parse
  15120. * @return {Object} An object of url details
  15121. * @method parseUrl
  15122. */
  15123. var parseUrl = function parseUrl(url) {
  15124. var props = ['protocol', 'hostname', 'port', 'pathname', 'search', 'hash', 'host'];
  15125. // add the url to an anchor and let the browser parse the URL
  15126. var a = _globalDocument2['default'].createElement('a');
  15127. a.href = url;
  15128. // IE8 (and 9?) Fix
  15129. // ie8 doesn't parse the URL correctly until the anchor is actually
  15130. // added to the body, and an innerHTML is needed to trigger the parsing
  15131. var addToBody = a.host === '' && a.protocol !== 'file:';
  15132. var div = undefined;
  15133. if (addToBody) {
  15134. div = _globalDocument2['default'].createElement('div');
  15135. div.innerHTML = '<a href="' + url + '"></a>';
  15136. a = div.firstChild;
  15137. // prevent the div from affecting layout
  15138. div.setAttribute('style', 'display:none; position:absolute;');
  15139. _globalDocument2['default'].body.appendChild(div);
  15140. }
  15141. // Copy the specific URL properties to a new object
  15142. // This is also needed for IE8 because the anchor loses its
  15143. // properties when it's removed from the dom
  15144. var details = {};
  15145. for (var i = 0; i < props.length; i++) {
  15146. details[props[i]] = a[props[i]];
  15147. }
  15148. // IE9 adds the port to the host property unlike everyone else. If
  15149. // a port identifier is added for standard ports, strip it.
  15150. if (details.protocol === 'http:') {
  15151. details.host = details.host.replace(/:80$/, '');
  15152. }
  15153. if (details.protocol === 'https:') {
  15154. details.host = details.host.replace(/:443$/, '');
  15155. }
  15156. if (addToBody) {
  15157. _globalDocument2['default'].body.removeChild(div);
  15158. }
  15159. return details;
  15160. };
  15161. exports.parseUrl = parseUrl;
  15162. /**
  15163. * Get absolute version of relative URL. Used to tell flash correct URL.
  15164. * http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue
  15165. *
  15166. * @param {String} url URL to make absolute
  15167. * @return {String} Absolute URL
  15168. * @private
  15169. * @method getAbsoluteURL
  15170. */
  15171. var getAbsoluteURL = function getAbsoluteURL(url) {
  15172. // Check if absolute URL
  15173. if (!url.match(/^https?:\/\//)) {
  15174. // Convert to absolute URL. Flash hosted off-site needs an absolute URL.
  15175. var div = _globalDocument2['default'].createElement('div');
  15176. div.innerHTML = '<a href="' + url + '">x</a>';
  15177. url = div.firstChild.href;
  15178. }
  15179. return url;
  15180. };
  15181. exports.getAbsoluteURL = getAbsoluteURL;
  15182. /**
  15183. * Returns the extension of the passed file name. It will return an empty string if you pass an invalid path
  15184. *
  15185. * @param {String} path The fileName path like '/path/to/file.mp4'
  15186. * @returns {String} The extension in lower case or an empty string if no extension could be found.
  15187. * @method getFileExtension
  15188. */
  15189. var getFileExtension = function getFileExtension(path) {
  15190. if (typeof path === 'string') {
  15191. var splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
  15192. var pathParts = splitPathRe.exec(path);
  15193. if (pathParts) {
  15194. return pathParts.pop().toLowerCase();
  15195. }
  15196. }
  15197. return '';
  15198. };
  15199. exports.getFileExtension = getFileExtension;
  15200. /**
  15201. * Returns whether the url passed is a cross domain request or not.
  15202. *
  15203. * @param {String} url The url to check
  15204. * @return {Boolean} Whether it is a cross domain request or not
  15205. * @method isCrossOrigin
  15206. */
  15207. var isCrossOrigin = function isCrossOrigin(url) {
  15208. var winLoc = _globalWindow2['default'].location;
  15209. var urlInfo = parseUrl(url);
  15210. // IE8 protocol relative urls will return ':' for protocol
  15211. var srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol;
  15212. // Check if url is for another domain/origin
  15213. // IE8 doesn't know location.origin, so we won't rely on it here
  15214. var crossOrigin = srcProtocol + urlInfo.host !== winLoc.protocol + winLoc.host;
  15215. return crossOrigin;
  15216. };
  15217. exports.isCrossOrigin = isCrossOrigin;
  15218. },{"global/document":1,"global/window":2}],139:[function(_dereq_,module,exports){
  15219. /**
  15220. * @file video.js
  15221. */
  15222. 'use strict';
  15223. exports.__esModule = true;
  15224. 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; } }
  15225. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15226. var _globalDocument = _dereq_('global/document');
  15227. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15228. var _setup = _dereq_('./setup');
  15229. var setup = _interopRequireWildcard(_setup);
  15230. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js');
  15231. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs);
  15232. var _component = _dereq_('./component');
  15233. var _component2 = _interopRequireDefault(_component);
  15234. var _eventTarget = _dereq_('./event-target');
  15235. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  15236. var _utilsEventsJs = _dereq_('./utils/events.js');
  15237. var Events = _interopRequireWildcard(_utilsEventsJs);
  15238. var _player = _dereq_('./player');
  15239. var _player2 = _interopRequireDefault(_player);
  15240. var _pluginsJs = _dereq_('./plugins.js');
  15241. var _pluginsJs2 = _interopRequireDefault(_pluginsJs);
  15242. var _srcJsUtilsMergeOptionsJs = _dereq_('../../src/js/utils/merge-options.js');
  15243. var _srcJsUtilsMergeOptionsJs2 = _interopRequireDefault(_srcJsUtilsMergeOptionsJs);
  15244. var _utilsFnJs = _dereq_('./utils/fn.js');
  15245. var Fn = _interopRequireWildcard(_utilsFnJs);
  15246. var _tracksTextTrackJs = _dereq_('./tracks/text-track.js');
  15247. var _tracksTextTrackJs2 = _interopRequireDefault(_tracksTextTrackJs);
  15248. var _objectAssign = _dereq_('object.assign');
  15249. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  15250. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js');
  15251. var _utilsFormatTimeJs = _dereq_('./utils/format-time.js');
  15252. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  15253. var _utilsLogJs = _dereq_('./utils/log.js');
  15254. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  15255. var _utilsDomJs = _dereq_('./utils/dom.js');
  15256. var Dom = _interopRequireWildcard(_utilsDomJs);
  15257. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  15258. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15259. var _utilsUrlJs = _dereq_('./utils/url.js');
  15260. var Url = _interopRequireWildcard(_utilsUrlJs);
  15261. var _extendJs = _dereq_('./extend.js');
  15262. var _extendJs2 = _interopRequireDefault(_extendJs);
  15263. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge');
  15264. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge);
  15265. var _utilsCreateDeprecationProxyJs = _dereq_('./utils/create-deprecation-proxy.js');
  15266. var _utilsCreateDeprecationProxyJs2 = _interopRequireDefault(_utilsCreateDeprecationProxyJs);
  15267. var _xhr = _dereq_('xhr');
  15268. var _xhr2 = _interopRequireDefault(_xhr);
  15269. // Include the built-in techs
  15270. var _techTechJs = _dereq_('./tech/tech.js');
  15271. var _techTechJs2 = _interopRequireDefault(_techTechJs);
  15272. var _techHtml5Js = _dereq_('./tech/html5.js');
  15273. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js);
  15274. var _techFlashJs = _dereq_('./tech/flash.js');
  15275. var _techFlashJs2 = _interopRequireDefault(_techFlashJs);
  15276. // HTML5 Element Shim for IE8
  15277. if (typeof HTMLVideoElement === 'undefined') {
  15278. _globalDocument2['default'].createElement('video');
  15279. _globalDocument2['default'].createElement('audio');
  15280. _globalDocument2['default'].createElement('track');
  15281. }
  15282. /**
  15283. * Doubles as the main function for users to create a player instance and also
  15284. * the main library object.
  15285. * The `videojs` function can be used to initialize or retrieve a player.
  15286. * ```js
  15287. * var myPlayer = videojs('my_video_id');
  15288. * ```
  15289. *
  15290. * @param {String|Element} id Video element or video element ID
  15291. * @param {Object=} options Optional options object for config/settings
  15292. * @param {Function=} ready Optional ready callback
  15293. * @return {Player} A player instance
  15294. * @mixes videojs
  15295. * @method videojs
  15296. */
  15297. var videojs = function videojs(id, options, ready) {
  15298. var tag = undefined; // Element of ID
  15299. // Allow for element or ID to be passed in
  15300. // String ID
  15301. if (typeof id === 'string') {
  15302. // Adjust for jQuery ID syntax
  15303. if (id.indexOf('#') === 0) {
  15304. id = id.slice(1);
  15305. }
  15306. // If a player instance has already been created for this ID return it.
  15307. if (videojs.getPlayers()[id]) {
  15308. // If options or ready funtion are passed, warn
  15309. if (options) {
  15310. _utilsLogJs2['default'].warn('Player "' + id + '" is already initialised. Options will not be applied.');
  15311. }
  15312. if (ready) {
  15313. videojs.getPlayers()[id].ready(ready);
  15314. }
  15315. return videojs.getPlayers()[id];
  15316. // Otherwise get element for ID
  15317. } else {
  15318. tag = Dom.getEl(id);
  15319. }
  15320. // ID is a media element
  15321. } else {
  15322. tag = id;
  15323. }
  15324. // Check for a useable element
  15325. if (!tag || !tag.nodeName) {
  15326. // re: nodeName, could be a box div also
  15327. throw new TypeError('The element or ID supplied is not valid. (videojs)'); // Returns
  15328. }
  15329. // Element may have a player attr referring to an already created player instance.
  15330. // If not, set up a new player and return the instance.
  15331. return tag['player'] || _player2['default'].players[tag.playerId] || new _player2['default'](tag, options, ready);
  15332. };
  15333. // Add default styles
  15334. var style = Dom.$('.vjs-styles-defaults');
  15335. if (!style) {
  15336. style = stylesheet.createStyleElement('vjs-styles-defaults');
  15337. var head = Dom.$('head');
  15338. head.insertBefore(style, head.firstChild);
  15339. stylesheet.setTextContent(style, '\n .video-js {\n width: 300px;\n height: 150px;\n }\n\n .vjs-fluid {\n padding-top: 56.25%\n }\n ');
  15340. }
  15341. // Run Auto-load players
  15342. // 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)
  15343. setup.autoSetupTimeout(1, videojs);
  15344. /*
  15345. * Current software version (semver)
  15346. *
  15347. * @type {String}
  15348. */
  15349. videojs.VERSION = '5.5.3';
  15350. /**
  15351. * The global options object. These are the settings that take effect
  15352. * if no overrides are specified when the player is created.
  15353. *
  15354. * ```js
  15355. * videojs.options.autoplay = true
  15356. * // -> all players will autoplay by default
  15357. * ```
  15358. *
  15359. * @type {Object}
  15360. */
  15361. videojs.options = _player2['default'].prototype.options_;
  15362. /**
  15363. * Get an object with the currently created players, keyed by player ID
  15364. *
  15365. * @return {Object} The created players
  15366. * @mixes videojs
  15367. * @method getPlayers
  15368. */
  15369. videojs.getPlayers = function () {
  15370. return _player2['default'].players;
  15371. };
  15372. /**
  15373. * For backward compatibility, expose players object.
  15374. *
  15375. * @deprecated
  15376. * @memberOf videojs
  15377. * @property {Object|Proxy} players
  15378. */
  15379. videojs.players = _utilsCreateDeprecationProxyJs2['default'](_player2['default'].players, {
  15380. get: 'Access to videojs.players is deprecated; use videojs.getPlayers instead',
  15381. set: 'Modification of videojs.players is deprecated'
  15382. });
  15383. /**
  15384. * Get a component class object by name
  15385. * ```js
  15386. * var VjsButton = videojs.getComponent('Button');
  15387. * // Create a new instance of the component
  15388. * var myButton = new VjsButton(myPlayer);
  15389. * ```
  15390. *
  15391. * @return {Component} Component identified by name
  15392. * @mixes videojs
  15393. * @method getComponent
  15394. */
  15395. videojs.getComponent = _component2['default'].getComponent;
  15396. /**
  15397. * Register a component so it can referred to by name
  15398. * Used when adding to other
  15399. * components, either through addChild
  15400. * `component.addChild('myComponent')`
  15401. * or through default children options
  15402. * `{ children: ['myComponent'] }`.
  15403. * ```js
  15404. * // Get a component to subclass
  15405. * var VjsButton = videojs.getComponent('Button');
  15406. * // Subclass the component (see 'extend' doc for more info)
  15407. * var MySpecialButton = videojs.extend(VjsButton, {});
  15408. * // Register the new component
  15409. * VjsButton.registerComponent('MySepcialButton', MySepcialButton);
  15410. * // (optionally) add the new component as a default player child
  15411. * myPlayer.addChild('MySepcialButton');
  15412. * ```
  15413. * NOTE: You could also just initialize the component before adding.
  15414. * `component.addChild(new MyComponent());`
  15415. *
  15416. * @param {String} The class name of the component
  15417. * @param {Component} The component class
  15418. * @return {Component} The newly registered component
  15419. * @mixes videojs
  15420. * @method registerComponent
  15421. */
  15422. videojs.registerComponent = function (name, comp) {
  15423. if (_techTechJs2['default'].isTech(comp)) {
  15424. _utilsLogJs2['default'].warn('The ' + name + ' tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)');
  15425. }
  15426. _component2['default'].registerComponent.call(_component2['default'], name, comp);
  15427. };
  15428. /**
  15429. * Get a Tech class object by name
  15430. * ```js
  15431. * var Html5 = videojs.getTech('Html5');
  15432. * // Create a new instance of the component
  15433. * var html5 = new Html5(options);
  15434. * ```
  15435. *
  15436. * @return {Tech} Tech identified by name
  15437. * @mixes videojs
  15438. * @method getComponent
  15439. */
  15440. videojs.getTech = _techTechJs2['default'].getTech;
  15441. /**
  15442. * Register a Tech so it can referred to by name.
  15443. * This is used in the tech order for the player.
  15444. *
  15445. * ```js
  15446. * // get the Html5 Tech
  15447. * var Html5 = videojs.getTech('Html5');
  15448. * var MyTech = videojs.extend(Html5, {});
  15449. * // Register the new Tech
  15450. * VjsButton.registerTech('Tech', MyTech);
  15451. * var player = videojs('myplayer', {
  15452. * techOrder: ['myTech', 'html5']
  15453. * });
  15454. * ```
  15455. *
  15456. * @param {String} The class name of the tech
  15457. * @param {Tech} The tech class
  15458. * @return {Tech} The newly registered Tech
  15459. * @mixes videojs
  15460. * @method registerTech
  15461. */
  15462. videojs.registerTech = _techTechJs2['default'].registerTech;
  15463. /**
  15464. * A suite of browser and device tests
  15465. *
  15466. * @type {Object}
  15467. * @private
  15468. */
  15469. videojs.browser = browser;
  15470. /**
  15471. * Whether or not the browser supports touch events. Included for backward
  15472. * compatibility with 4.x, but deprecated. Use `videojs.browser.TOUCH_ENABLED`
  15473. * instead going forward.
  15474. *
  15475. * @deprecated
  15476. * @type {Boolean}
  15477. */
  15478. videojs.TOUCH_ENABLED = browser.TOUCH_ENABLED;
  15479. /**
  15480. * Subclass an existing class
  15481. * Mimics ES6 subclassing with the `extend` keyword
  15482. * ```js
  15483. * // Create a basic javascript 'class'
  15484. * function MyClass(name){
  15485. * // Set a property at initialization
  15486. * this.myName = name;
  15487. * }
  15488. * // Create an instance method
  15489. * MyClass.prototype.sayMyName = function(){
  15490. * alert(this.myName);
  15491. * };
  15492. * // Subclass the exisitng class and change the name
  15493. * // when initializing
  15494. * var MySubClass = videojs.extend(MyClass, {
  15495. * constructor: function(name) {
  15496. * // Call the super class constructor for the subclass
  15497. * MyClass.call(this, name)
  15498. * }
  15499. * });
  15500. * // Create an instance of the new sub class
  15501. * var myInstance = new MySubClass('John');
  15502. * myInstance.sayMyName(); // -> should alert "John"
  15503. * ```
  15504. *
  15505. * @param {Function} The Class to subclass
  15506. * @param {Object} An object including instace methods for the new class
  15507. * Optionally including a `constructor` function
  15508. * @return {Function} The newly created subclass
  15509. * @mixes videojs
  15510. * @method extend
  15511. */
  15512. videojs.extend = _extendJs2['default'];
  15513. /**
  15514. * Merge two options objects recursively
  15515. * Performs a deep merge like lodash.merge but **only merges plain objects**
  15516. * (not arrays, elements, anything else)
  15517. * Other values will be copied directly from the second object.
  15518. * ```js
  15519. * var defaultOptions = {
  15520. * foo: true,
  15521. * bar: {
  15522. * a: true,
  15523. * b: [1,2,3]
  15524. * }
  15525. * };
  15526. * var newOptions = {
  15527. * foo: false,
  15528. * bar: {
  15529. * b: [4,5,6]
  15530. * }
  15531. * };
  15532. * var result = videojs.mergeOptions(defaultOptions, newOptions);
  15533. * // result.foo = false;
  15534. * // result.bar.a = true;
  15535. * // result.bar.b = [4,5,6];
  15536. * ```
  15537. *
  15538. * @param {Object} defaults The options object whose values will be overriden
  15539. * @param {Object} overrides The options object with values to override the first
  15540. * @param {Object} etc Any number of additional options objects
  15541. *
  15542. * @return {Object} a new object with the merged values
  15543. * @mixes videojs
  15544. * @method mergeOptions
  15545. */
  15546. videojs.mergeOptions = _srcJsUtilsMergeOptionsJs2['default'];
  15547. /**
  15548. * Change the context (this) of a function
  15549. *
  15550. * videojs.bind(newContext, function(){
  15551. * this === newContext
  15552. * });
  15553. *
  15554. * NOTE: as of v5.0 we require an ES5 shim, so you should use the native
  15555. * `function(){}.bind(newContext);` instead of this.
  15556. *
  15557. * @param {*} context The object to bind as scope
  15558. * @param {Function} fn The function to be bound to a scope
  15559. * @param {Number=} uid An optional unique ID for the function to be set
  15560. * @return {Function}
  15561. */
  15562. videojs.bind = Fn.bind;
  15563. /**
  15564. * Create a Video.js player plugin
  15565. * Plugins are only initialized when options for the plugin are included
  15566. * in the player options, or the plugin function on the player instance is
  15567. * called.
  15568. * **See the plugin guide in the docs for a more detailed example**
  15569. * ```js
  15570. * // Make a plugin that alerts when the player plays
  15571. * videojs.plugin('myPlugin', function(myPluginOptions) {
  15572. * myPluginOptions = myPluginOptions || {};
  15573. *
  15574. * var player = this;
  15575. * var alertText = myPluginOptions.text || 'Player is playing!'
  15576. *
  15577. * player.on('play', function(){
  15578. * alert(alertText);
  15579. * });
  15580. * });
  15581. * // USAGE EXAMPLES
  15582. * // EXAMPLE 1: New player with plugin options, call plugin immediately
  15583. * var player1 = videojs('idOne', {
  15584. * myPlugin: {
  15585. * text: 'Custom text!'
  15586. * }
  15587. * });
  15588. * // Click play
  15589. * // --> Should alert 'Custom text!'
  15590. * // EXAMPLE 3: New player, initialize plugin later
  15591. * var player3 = videojs('idThree');
  15592. * // Click play
  15593. * // --> NO ALERT
  15594. * // Click pause
  15595. * // Initialize plugin using the plugin function on the player instance
  15596. * player3.myPlugin({
  15597. * text: 'Plugin added later!'
  15598. * });
  15599. * // Click play
  15600. * // --> Should alert 'Plugin added later!'
  15601. * ```
  15602. *
  15603. * @param {String} name The plugin name
  15604. * @param {Function} fn The plugin function that will be called with options
  15605. * @mixes videojs
  15606. * @method plugin
  15607. */
  15608. videojs.plugin = _pluginsJs2['default'];
  15609. /**
  15610. * Adding languages so that they're available to all players.
  15611. * ```js
  15612. * videojs.addLanguage('es', { 'Hello': 'Hola' });
  15613. * ```
  15614. *
  15615. * @param {String} code The language code or dictionary property
  15616. * @param {Object} data The data values to be translated
  15617. * @return {Object} The resulting language dictionary object
  15618. * @mixes videojs
  15619. * @method addLanguage
  15620. */
  15621. videojs.addLanguage = function (code, data) {
  15622. var _merge;
  15623. code = ('' + code).toLowerCase();
  15624. return _lodashCompatObjectMerge2['default'](videojs.options.languages, (_merge = {}, _merge[code] = data, _merge))[code];
  15625. };
  15626. /**
  15627. * Log debug messages.
  15628. *
  15629. * @param {...Object} messages One or more messages to log
  15630. */
  15631. videojs.log = _utilsLogJs2['default'];
  15632. /**
  15633. * Creates an emulated TimeRange object.
  15634. *
  15635. * @param {Number|Array} start Start time in seconds or an array of ranges
  15636. * @param {Number} end End time in seconds
  15637. * @return {Object} Fake TimeRange object
  15638. * @method createTimeRange
  15639. */
  15640. videojs.createTimeRange = videojs.createTimeRanges = _utilsTimeRangesJs.createTimeRanges;
  15641. /**
  15642. * Format seconds as a time string, H:MM:SS or M:SS
  15643. * Supplying a guide (in seconds) will force a number of leading zeros
  15644. * to cover the length of the guide
  15645. *
  15646. * @param {Number} seconds Number of seconds to be turned into a string
  15647. * @param {Number} guide Number (in seconds) to model the string after
  15648. * @return {String} Time formatted as H:MM:SS or M:SS
  15649. * @method formatTime
  15650. */
  15651. videojs.formatTime = _utilsFormatTimeJs2['default'];
  15652. /**
  15653. * Resolve and parse the elements of a URL
  15654. *
  15655. * @param {String} url The url to parse
  15656. * @return {Object} An object of url details
  15657. * @method parseUrl
  15658. */
  15659. videojs.parseUrl = Url.parseUrl;
  15660. /**
  15661. * Returns whether the url passed is a cross domain request or not.
  15662. *
  15663. * @param {String} url The url to check
  15664. * @return {Boolean} Whether it is a cross domain request or not
  15665. * @method isCrossOrigin
  15666. */
  15667. videojs.isCrossOrigin = Url.isCrossOrigin;
  15668. /**
  15669. * Event target class.
  15670. *
  15671. * @type {Function}
  15672. */
  15673. videojs.EventTarget = _eventTarget2['default'];
  15674. /**
  15675. * Add an event listener to element
  15676. * It stores the handler function in a separate cache object
  15677. * and adds a generic handler to the element's event,
  15678. * along with a unique id (guid) to the element.
  15679. *
  15680. * @param {Element|Object} elem Element or object to bind listeners to
  15681. * @param {String|Array} type Type of event to bind to.
  15682. * @param {Function} fn Event listener.
  15683. * @method on
  15684. */
  15685. videojs.on = Events.on;
  15686. /**
  15687. * Trigger a listener only once for an event
  15688. *
  15689. * @param {Element|Object} elem Element or object to
  15690. * @param {String|Array} type Name/type of event
  15691. * @param {Function} fn Event handler function
  15692. * @method one
  15693. */
  15694. videojs.one = Events.one;
  15695. /**
  15696. * Removes event listeners from an element
  15697. *
  15698. * @param {Element|Object} elem Object to remove listeners from
  15699. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  15700. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  15701. * @method off
  15702. */
  15703. videojs.off = Events.off;
  15704. /**
  15705. * Trigger an event for an element
  15706. *
  15707. * @param {Element|Object} elem Element to trigger an event on
  15708. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  15709. * @param {Object} [hash] data hash to pass along with the event
  15710. * @return {Boolean=} Returned only if default was prevented
  15711. * @method trigger
  15712. */
  15713. videojs.trigger = Events.trigger;
  15714. /**
  15715. * A cross-browser XMLHttpRequest wrapper. Here's a simple example:
  15716. *
  15717. * videojs.xhr({
  15718. * body: someJSONString,
  15719. * uri: "/foo",
  15720. * headers: {
  15721. * "Content-Type": "application/json"
  15722. * }
  15723. * }, function (err, resp, body) {
  15724. * // check resp.statusCode
  15725. * });
  15726. *
  15727. * Check out the [full
  15728. * documentation](https://github.com/Raynos/xhr/blob/v2.1.0/README.md)
  15729. * for more options.
  15730. *
  15731. * @param {Object} options settings for the request.
  15732. * @return {XMLHttpRequest|XDomainRequest} the request object.
  15733. * @see https://github.com/Raynos/xhr
  15734. */
  15735. videojs.xhr = _xhr2['default'];
  15736. /**
  15737. * TextTrack class
  15738. *
  15739. * @type {Function}
  15740. */
  15741. videojs.TextTrack = _tracksTextTrackJs2['default'];
  15742. /**
  15743. * Determines, via duck typing, whether or not a value is a DOM element.
  15744. *
  15745. * @method isEl
  15746. * @param {Mixed} value
  15747. * @return {Boolean}
  15748. */
  15749. videojs.isEl = Dom.isEl;
  15750. /**
  15751. * Determines, via duck typing, whether or not a value is a text node.
  15752. *
  15753. * @method isTextNode
  15754. * @param {Mixed} value
  15755. * @return {Boolean}
  15756. */
  15757. videojs.isTextNode = Dom.isTextNode;
  15758. /**
  15759. * Creates an element and applies properties.
  15760. *
  15761. * @method createEl
  15762. * @param {String} [tagName='div'] Name of tag to be created.
  15763. * @param {Object} [properties={}] Element properties to be applied.
  15764. * @param {Object} [attributes={}] Element attributes to be applied.
  15765. * @return {Element}
  15766. */
  15767. videojs.createEl = Dom.createEl;
  15768. /**
  15769. * Check if an element has a CSS class
  15770. *
  15771. * @method hasClass
  15772. * @param {Element} element Element to check
  15773. * @param {String} classToCheck Classname to check
  15774. */
  15775. videojs.hasClass = Dom.hasElClass;
  15776. /**
  15777. * Add a CSS class name to an element
  15778. *
  15779. * @method addClass
  15780. * @param {Element} element Element to add class name to
  15781. * @param {String} classToAdd Classname to add
  15782. */
  15783. videojs.addClass = Dom.addElClass;
  15784. /**
  15785. * Remove a CSS class name from an element
  15786. *
  15787. * @method removeClass
  15788. * @param {Element} element Element to remove from class name
  15789. * @param {String} classToRemove Classname to remove
  15790. */
  15791. videojs.removeClass = Dom.removeElClass;
  15792. /**
  15793. * Adds or removes a CSS class name on an element depending on an optional
  15794. * condition or the presence/absence of the class name.
  15795. *
  15796. * @method toggleElClass
  15797. * @param {Element} element
  15798. * @param {String} classToToggle
  15799. * @param {Boolean|Function} [predicate]
  15800. * Can be a function that returns a Boolean. If `true`, the class
  15801. * will be added; if `false`, the class will be removed. If not
  15802. * given, the class will be added if not present and vice versa.
  15803. */
  15804. videojs.toggleClass = Dom.toggleElClass;
  15805. /**
  15806. * Apply attributes to an HTML element.
  15807. *
  15808. * @method setAttributes
  15809. * @param {Element} el Target element.
  15810. * @param {Object=} attributes Element attributes to be applied.
  15811. */
  15812. videojs.setAttributes = Dom.setElAttributes;
  15813. /**
  15814. * Get an element's attribute values, as defined on the HTML tag
  15815. * Attributes are not the same as properties. They're defined on the tag
  15816. * or with setAttribute (which shouldn't be used with HTML)
  15817. * This will return true or false for boolean attributes.
  15818. *
  15819. * @method getAttributes
  15820. * @param {Element} tag Element from which to get tag attributes
  15821. * @return {Object}
  15822. */
  15823. videojs.getAttributes = Dom.getElAttributes;
  15824. /**
  15825. * Empties the contents of an element.
  15826. *
  15827. * @method emptyEl
  15828. * @param {Element} el
  15829. * @return {Element}
  15830. */
  15831. videojs.emptyEl = Dom.emptyEl;
  15832. /**
  15833. * Normalizes and appends content to an element.
  15834. *
  15835. * The content for an element can be passed in multiple types and
  15836. * combinations, whose behavior is as follows:
  15837. *
  15838. * - String
  15839. * Normalized into a text node.
  15840. *
  15841. * - Element, TextNode
  15842. * Passed through.
  15843. *
  15844. * - Array
  15845. * A one-dimensional array of strings, elements, nodes, or functions (which
  15846. * return single strings, elements, or nodes).
  15847. *
  15848. * - Function
  15849. * If the sole argument, is expected to produce a string, element,
  15850. * node, or array.
  15851. *
  15852. * @method appendContent
  15853. * @param {Element} el
  15854. * @param {String|Element|TextNode|Array|Function} content
  15855. * @return {Element}
  15856. */
  15857. videojs.appendContent = Dom.appendContent;
  15858. /**
  15859. * Normalizes and inserts content into an element; this is identical to
  15860. * `appendContent()`, except it empties the element first.
  15861. *
  15862. * The content for an element can be passed in multiple types and
  15863. * combinations, whose behavior is as follows:
  15864. *
  15865. * - String
  15866. * Normalized into a text node.
  15867. *
  15868. * - Element, TextNode
  15869. * Passed through.
  15870. *
  15871. * - Array
  15872. * A one-dimensional array of strings, elements, nodes, or functions (which
  15873. * return single strings, elements, or nodes).
  15874. *
  15875. * - Function
  15876. * If the sole argument, is expected to produce a string, element,
  15877. * node, or array.
  15878. *
  15879. * @method insertContent
  15880. * @param {Element} el
  15881. * @param {String|Element|TextNode|Array|Function} content
  15882. * @return {Element}
  15883. */
  15884. videojs.insertContent = Dom.insertContent;
  15885. /*
  15886. * Custom Universal Module Definition (UMD)
  15887. *
  15888. * Video.js will never be a non-browser lib so we can simplify UMD a bunch and
  15889. * still support requirejs and browserify. This also needs to be closure
  15890. * compiler compatible, so string keys are used.
  15891. */
  15892. if (typeof define === 'function' && define['amd']) {
  15893. define('videojs', [], function () {
  15894. return videojs;
  15895. });
  15896. // checking that module is an object too because of umdjs/umd#35
  15897. } else if (typeof exports === 'object' && typeof module === 'object') {
  15898. module['exports'] = videojs;
  15899. }
  15900. exports['default'] = videojs;
  15901. module.exports = exports['default'];
  15902. },{"../../src/js/utils/merge-options.js":134,"./component":65,"./event-target":97,"./extend.js":98,"./player":106,"./plugins.js":107,"./setup":109,"./tech/flash.js":112,"./tech/html5.js":113,"./tech/tech.js":115,"./tracks/text-track.js":124,"./utils/browser.js":125,"./utils/create-deprecation-proxy.js":127,"./utils/dom.js":128,"./utils/events.js":129,"./utils/fn.js":130,"./utils/format-time.js":131,"./utils/log.js":133,"./utils/stylesheet.js":135,"./utils/time-ranges.js":136,"./utils/url.js":138,"global/document":1,"lodash-compat/object/merge":40,"object.assign":45,"xhr":55}]},{},[139])(139)
  15903. });
  15904. //# sourceMappingURL=video.js.map
  15905. /* vtt.js - v0.12.1 (https://github.com/mozilla/vtt.js) built on 08-07-2015 */
  15906. (function(root) {
  15907. var vttjs = root.vttjs = {};
  15908. var cueShim = vttjs.VTTCue;
  15909. var regionShim = vttjs.VTTRegion;
  15910. var oldVTTCue = root.VTTCue;
  15911. var oldVTTRegion = root.VTTRegion;
  15912. vttjs.shim = function() {
  15913. vttjs.VTTCue = cueShim;
  15914. vttjs.VTTRegion = regionShim;
  15915. };
  15916. vttjs.restore = function() {
  15917. vttjs.VTTCue = oldVTTCue;
  15918. vttjs.VTTRegion = oldVTTRegion;
  15919. };
  15920. }(this));
  15921. /**
  15922. * Copyright 2013 vtt.js Contributors
  15923. *
  15924. * Licensed under the Apache License, Version 2.0 (the "License");
  15925. * you may not use this file except in compliance with the License.
  15926. * You may obtain a copy of the License at
  15927. *
  15928. * http://www.apache.org/licenses/LICENSE-2.0
  15929. *
  15930. * Unless required by applicable law or agreed to in writing, software
  15931. * distributed under the License is distributed on an "AS IS" BASIS,
  15932. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15933. * See the License for the specific language governing permissions and
  15934. * limitations under the License.
  15935. */
  15936. (function(root, vttjs) {
  15937. var autoKeyword = "auto";
  15938. var directionSetting = {
  15939. "": true,
  15940. "lr": true,
  15941. "rl": true
  15942. };
  15943. var alignSetting = {
  15944. "start": true,
  15945. "middle": true,
  15946. "end": true,
  15947. "left": true,
  15948. "right": true
  15949. };
  15950. function findDirectionSetting(value) {
  15951. if (typeof value !== "string") {
  15952. return false;
  15953. }
  15954. var dir = directionSetting[value.toLowerCase()];
  15955. return dir ? value.toLowerCase() : false;
  15956. }
  15957. function findAlignSetting(value) {
  15958. if (typeof value !== "string") {
  15959. return false;
  15960. }
  15961. var align = alignSetting[value.toLowerCase()];
  15962. return align ? value.toLowerCase() : false;
  15963. }
  15964. function extend(obj) {
  15965. var i = 1;
  15966. for (; i < arguments.length; i++) {
  15967. var cobj = arguments[i];
  15968. for (var p in cobj) {
  15969. obj[p] = cobj[p];
  15970. }
  15971. }
  15972. return obj;
  15973. }
  15974. function VTTCue(startTime, endTime, text) {
  15975. var cue = this;
  15976. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  15977. var baseObj = {};
  15978. if (isIE8) {
  15979. cue = document.createElement('custom');
  15980. } else {
  15981. baseObj.enumerable = true;
  15982. }
  15983. /**
  15984. * Shim implementation specific properties. These properties are not in
  15985. * the spec.
  15986. */
  15987. // Lets us know when the VTTCue's data has changed in such a way that we need
  15988. // to recompute its display state. This lets us compute its display state
  15989. // lazily.
  15990. cue.hasBeenReset = false;
  15991. /**
  15992. * VTTCue and TextTrackCue properties
  15993. * http://dev.w3.org/html5/webvtt/#vttcue-interface
  15994. */
  15995. var _id = "";
  15996. var _pauseOnExit = false;
  15997. var _startTime = startTime;
  15998. var _endTime = endTime;
  15999. var _text = text;
  16000. var _region = null;
  16001. var _vertical = "";
  16002. var _snapToLines = true;
  16003. var _line = "auto";
  16004. var _lineAlign = "start";
  16005. var _position = 50;
  16006. var _positionAlign = "middle";
  16007. var _size = 50;
  16008. var _align = "middle";
  16009. Object.defineProperty(cue,
  16010. "id", extend({}, baseObj, {
  16011. get: function() {
  16012. return _id;
  16013. },
  16014. set: function(value) {
  16015. _id = "" + value;
  16016. }
  16017. }));
  16018. Object.defineProperty(cue,
  16019. "pauseOnExit", extend({}, baseObj, {
  16020. get: function() {
  16021. return _pauseOnExit;
  16022. },
  16023. set: function(value) {
  16024. _pauseOnExit = !!value;
  16025. }
  16026. }));
  16027. Object.defineProperty(cue,
  16028. "startTime", extend({}, baseObj, {
  16029. get: function() {
  16030. return _startTime;
  16031. },
  16032. set: function(value) {
  16033. if (typeof value !== "number") {
  16034. throw new TypeError("Start time must be set to a number.");
  16035. }
  16036. _startTime = value;
  16037. this.hasBeenReset = true;
  16038. }
  16039. }));
  16040. Object.defineProperty(cue,
  16041. "endTime", extend({}, baseObj, {
  16042. get: function() {
  16043. return _endTime;
  16044. },
  16045. set: function(value) {
  16046. if (typeof value !== "number") {
  16047. throw new TypeError("End time must be set to a number.");
  16048. }
  16049. _endTime = value;
  16050. this.hasBeenReset = true;
  16051. }
  16052. }));
  16053. Object.defineProperty(cue,
  16054. "text", extend({}, baseObj, {
  16055. get: function() {
  16056. return _text;
  16057. },
  16058. set: function(value) {
  16059. _text = "" + value;
  16060. this.hasBeenReset = true;
  16061. }
  16062. }));
  16063. Object.defineProperty(cue,
  16064. "region", extend({}, baseObj, {
  16065. get: function() {
  16066. return _region;
  16067. },
  16068. set: function(value) {
  16069. _region = value;
  16070. this.hasBeenReset = true;
  16071. }
  16072. }));
  16073. Object.defineProperty(cue,
  16074. "vertical", extend({}, baseObj, {
  16075. get: function() {
  16076. return _vertical;
  16077. },
  16078. set: function(value) {
  16079. var setting = findDirectionSetting(value);
  16080. // Have to check for false because the setting an be an empty string.
  16081. if (setting === false) {
  16082. throw new SyntaxError("An invalid or illegal string was specified.");
  16083. }
  16084. _vertical = setting;
  16085. this.hasBeenReset = true;
  16086. }
  16087. }));
  16088. Object.defineProperty(cue,
  16089. "snapToLines", extend({}, baseObj, {
  16090. get: function() {
  16091. return _snapToLines;
  16092. },
  16093. set: function(value) {
  16094. _snapToLines = !!value;
  16095. this.hasBeenReset = true;
  16096. }
  16097. }));
  16098. Object.defineProperty(cue,
  16099. "line", extend({}, baseObj, {
  16100. get: function() {
  16101. return _line;
  16102. },
  16103. set: function(value) {
  16104. if (typeof value !== "number" && value !== autoKeyword) {
  16105. throw new SyntaxError("An invalid number or illegal string was specified.");
  16106. }
  16107. _line = value;
  16108. this.hasBeenReset = true;
  16109. }
  16110. }));
  16111. Object.defineProperty(cue,
  16112. "lineAlign", extend({}, baseObj, {
  16113. get: function() {
  16114. return _lineAlign;
  16115. },
  16116. set: function(value) {
  16117. var setting = findAlignSetting(value);
  16118. if (!setting) {
  16119. throw new SyntaxError("An invalid or illegal string was specified.");
  16120. }
  16121. _lineAlign = setting;
  16122. this.hasBeenReset = true;
  16123. }
  16124. }));
  16125. Object.defineProperty(cue,
  16126. "position", extend({}, baseObj, {
  16127. get: function() {
  16128. return _position;
  16129. },
  16130. set: function(value) {
  16131. if (value < 0 || value > 100) {
  16132. throw new Error("Position must be between 0 and 100.");
  16133. }
  16134. _position = value;
  16135. this.hasBeenReset = true;
  16136. }
  16137. }));
  16138. Object.defineProperty(cue,
  16139. "positionAlign", extend({}, baseObj, {
  16140. get: function() {
  16141. return _positionAlign;
  16142. },
  16143. set: function(value) {
  16144. var setting = findAlignSetting(value);
  16145. if (!setting) {
  16146. throw new SyntaxError("An invalid or illegal string was specified.");
  16147. }
  16148. _positionAlign = setting;
  16149. this.hasBeenReset = true;
  16150. }
  16151. }));
  16152. Object.defineProperty(cue,
  16153. "size", extend({}, baseObj, {
  16154. get: function() {
  16155. return _size;
  16156. },
  16157. set: function(value) {
  16158. if (value < 0 || value > 100) {
  16159. throw new Error("Size must be between 0 and 100.");
  16160. }
  16161. _size = value;
  16162. this.hasBeenReset = true;
  16163. }
  16164. }));
  16165. Object.defineProperty(cue,
  16166. "align", extend({}, baseObj, {
  16167. get: function() {
  16168. return _align;
  16169. },
  16170. set: function(value) {
  16171. var setting = findAlignSetting(value);
  16172. if (!setting) {
  16173. throw new SyntaxError("An invalid or illegal string was specified.");
  16174. }
  16175. _align = setting;
  16176. this.hasBeenReset = true;
  16177. }
  16178. }));
  16179. /**
  16180. * Other <track> spec defined properties
  16181. */
  16182. // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-display-state
  16183. cue.displayState = undefined;
  16184. if (isIE8) {
  16185. return cue;
  16186. }
  16187. }
  16188. /**
  16189. * VTTCue methods
  16190. */
  16191. VTTCue.prototype.getCueAsHTML = function() {
  16192. // Assume WebVTT.convertCueToDOMTree is on the global.
  16193. return WebVTT.convertCueToDOMTree(window, this.text);
  16194. };
  16195. root.VTTCue = root.VTTCue || VTTCue;
  16196. vttjs.VTTCue = VTTCue;
  16197. }(this, (this.vttjs || {})));
  16198. /**
  16199. * Copyright 2013 vtt.js Contributors
  16200. *
  16201. * Licensed under the Apache License, Version 2.0 (the "License");
  16202. * you may not use this file except in compliance with the License.
  16203. * You may obtain a copy of the License at
  16204. *
  16205. * http://www.apache.org/licenses/LICENSE-2.0
  16206. *
  16207. * Unless required by applicable law or agreed to in writing, software
  16208. * distributed under the License is distributed on an "AS IS" BASIS,
  16209. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16210. * See the License for the specific language governing permissions and
  16211. * limitations under the License.
  16212. */
  16213. (function(root, vttjs) {
  16214. var scrollSetting = {
  16215. "": true,
  16216. "up": true
  16217. };
  16218. function findScrollSetting(value) {
  16219. if (typeof value !== "string") {
  16220. return false;
  16221. }
  16222. var scroll = scrollSetting[value.toLowerCase()];
  16223. return scroll ? value.toLowerCase() : false;
  16224. }
  16225. function isValidPercentValue(value) {
  16226. return typeof value === "number" && (value >= 0 && value <= 100);
  16227. }
  16228. // VTTRegion shim http://dev.w3.org/html5/webvtt/#vttregion-interface
  16229. function VTTRegion() {
  16230. var _width = 100;
  16231. var _lines = 3;
  16232. var _regionAnchorX = 0;
  16233. var _regionAnchorY = 100;
  16234. var _viewportAnchorX = 0;
  16235. var _viewportAnchorY = 100;
  16236. var _scroll = "";
  16237. Object.defineProperties(this, {
  16238. "width": {
  16239. enumerable: true,
  16240. get: function() {
  16241. return _width;
  16242. },
  16243. set: function(value) {
  16244. if (!isValidPercentValue(value)) {
  16245. throw new Error("Width must be between 0 and 100.");
  16246. }
  16247. _width = value;
  16248. }
  16249. },
  16250. "lines": {
  16251. enumerable: true,
  16252. get: function() {
  16253. return _lines;
  16254. },
  16255. set: function(value) {
  16256. if (typeof value !== "number") {
  16257. throw new TypeError("Lines must be set to a number.");
  16258. }
  16259. _lines = value;
  16260. }
  16261. },
  16262. "regionAnchorY": {
  16263. enumerable: true,
  16264. get: function() {
  16265. return _regionAnchorY;
  16266. },
  16267. set: function(value) {
  16268. if (!isValidPercentValue(value)) {
  16269. throw new Error("RegionAnchorX must be between 0 and 100.");
  16270. }
  16271. _regionAnchorY = value;
  16272. }
  16273. },
  16274. "regionAnchorX": {
  16275. enumerable: true,
  16276. get: function() {
  16277. return _regionAnchorX;
  16278. },
  16279. set: function(value) {
  16280. if(!isValidPercentValue(value)) {
  16281. throw new Error("RegionAnchorY must be between 0 and 100.");
  16282. }
  16283. _regionAnchorX = value;
  16284. }
  16285. },
  16286. "viewportAnchorY": {
  16287. enumerable: true,
  16288. get: function() {
  16289. return _viewportAnchorY;
  16290. },
  16291. set: function(value) {
  16292. if (!isValidPercentValue(value)) {
  16293. throw new Error("ViewportAnchorY must be between 0 and 100.");
  16294. }
  16295. _viewportAnchorY = value;
  16296. }
  16297. },
  16298. "viewportAnchorX": {
  16299. enumerable: true,
  16300. get: function() {
  16301. return _viewportAnchorX;
  16302. },
  16303. set: function(value) {
  16304. if (!isValidPercentValue(value)) {
  16305. throw new Error("ViewportAnchorX must be between 0 and 100.");
  16306. }
  16307. _viewportAnchorX = value;
  16308. }
  16309. },
  16310. "scroll": {
  16311. enumerable: true,
  16312. get: function() {
  16313. return _scroll;
  16314. },
  16315. set: function(value) {
  16316. var setting = findScrollSetting(value);
  16317. // Have to check for false as an empty string is a legal value.
  16318. if (setting === false) {
  16319. throw new SyntaxError("An invalid or illegal string was specified.");
  16320. }
  16321. _scroll = setting;
  16322. }
  16323. }
  16324. });
  16325. }
  16326. root.VTTRegion = root.VTTRegion || VTTRegion;
  16327. vttjs.VTTRegion = VTTRegion;
  16328. }(this, (this.vttjs || {})));
  16329. /**
  16330. * Copyright 2013 vtt.js Contributors
  16331. *
  16332. * Licensed under the Apache License, Version 2.0 (the "License");
  16333. * you may not use this file except in compliance with the License.
  16334. * You may obtain a copy of the License at
  16335. *
  16336. * http://www.apache.org/licenses/LICENSE-2.0
  16337. *
  16338. * Unless required by applicable law or agreed to in writing, software
  16339. * distributed under the License is distributed on an "AS IS" BASIS,
  16340. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16341. * See the License for the specific language governing permissions and
  16342. * limitations under the License.
  16343. */
  16344. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  16345. /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
  16346. (function(global) {
  16347. var _objCreate = Object.create || (function() {
  16348. function F() {}
  16349. return function(o) {
  16350. if (arguments.length !== 1) {
  16351. throw new Error('Object.create shim only accepts one parameter.');
  16352. }
  16353. F.prototype = o;
  16354. return new F();
  16355. };
  16356. })();
  16357. // Creates a new ParserError object from an errorData object. The errorData
  16358. // object should have default code and message properties. The default message
  16359. // property can be overriden by passing in a message parameter.
  16360. // See ParsingError.Errors below for acceptable errors.
  16361. function ParsingError(errorData, message) {
  16362. this.name = "ParsingError";
  16363. this.code = errorData.code;
  16364. this.message = message || errorData.message;
  16365. }
  16366. ParsingError.prototype = _objCreate(Error.prototype);
  16367. ParsingError.prototype.constructor = ParsingError;
  16368. // ParsingError metadata for acceptable ParsingErrors.
  16369. ParsingError.Errors = {
  16370. BadSignature: {
  16371. code: 0,
  16372. message: "Malformed WebVTT signature."
  16373. },
  16374. BadTimeStamp: {
  16375. code: 1,
  16376. message: "Malformed time stamp."
  16377. }
  16378. };
  16379. // Try to parse input as a time stamp.
  16380. function parseTimeStamp(input) {
  16381. function computeSeconds(h, m, s, f) {
  16382. return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000;
  16383. }
  16384. var m = input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);
  16385. if (!m) {
  16386. return null;
  16387. }
  16388. if (m[3]) {
  16389. // Timestamp takes the form of [hours]:[minutes]:[seconds].[milliseconds]
  16390. return computeSeconds(m[1], m[2], m[3].replace(":", ""), m[4]);
  16391. } else if (m[1] > 59) {
  16392. // Timestamp takes the form of [hours]:[minutes].[milliseconds]
  16393. // First position is hours as it's over 59.
  16394. return computeSeconds(m[1], m[2], 0, m[4]);
  16395. } else {
  16396. // Timestamp takes the form of [minutes]:[seconds].[milliseconds]
  16397. return computeSeconds(0, m[1], m[2], m[4]);
  16398. }
  16399. }
  16400. // A settings object holds key/value pairs and will ignore anything but the first
  16401. // assignment to a specific key.
  16402. function Settings() {
  16403. this.values = _objCreate(null);
  16404. }
  16405. Settings.prototype = {
  16406. // Only accept the first assignment to any key.
  16407. set: function(k, v) {
  16408. if (!this.get(k) && v !== "") {
  16409. this.values[k] = v;
  16410. }
  16411. },
  16412. // Return the value for a key, or a default value.
  16413. // If 'defaultKey' is passed then 'dflt' is assumed to be an object with
  16414. // a number of possible default values as properties where 'defaultKey' is
  16415. // the key of the property that will be chosen; otherwise it's assumed to be
  16416. // a single value.
  16417. get: function(k, dflt, defaultKey) {
  16418. if (defaultKey) {
  16419. return this.has(k) ? this.values[k] : dflt[defaultKey];
  16420. }
  16421. return this.has(k) ? this.values[k] : dflt;
  16422. },
  16423. // Check whether we have a value for a key.
  16424. has: function(k) {
  16425. return k in this.values;
  16426. },
  16427. // Accept a setting if its one of the given alternatives.
  16428. alt: function(k, v, a) {
  16429. for (var n = 0; n < a.length; ++n) {
  16430. if (v === a[n]) {
  16431. this.set(k, v);
  16432. break;
  16433. }
  16434. }
  16435. },
  16436. // Accept a setting if its a valid (signed) integer.
  16437. integer: function(k, v) {
  16438. if (/^-?\d+$/.test(v)) { // integer
  16439. this.set(k, parseInt(v, 10));
  16440. }
  16441. },
  16442. // Accept a setting if its a valid percentage.
  16443. percent: function(k, v) {
  16444. var m;
  16445. if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) {
  16446. v = parseFloat(v);
  16447. if (v >= 0 && v <= 100) {
  16448. this.set(k, v);
  16449. return true;
  16450. }
  16451. }
  16452. return false;
  16453. }
  16454. };
  16455. // Helper function to parse input into groups separated by 'groupDelim', and
  16456. // interprete each group as a key/value pair separated by 'keyValueDelim'.
  16457. function parseOptions(input, callback, keyValueDelim, groupDelim) {
  16458. var groups = groupDelim ? input.split(groupDelim) : [input];
  16459. for (var i in groups) {
  16460. if (typeof groups[i] !== "string") {
  16461. continue;
  16462. }
  16463. var kv = groups[i].split(keyValueDelim);
  16464. if (kv.length !== 2) {
  16465. continue;
  16466. }
  16467. var k = kv[0];
  16468. var v = kv[1];
  16469. callback(k, v);
  16470. }
  16471. }
  16472. function parseCue(input, cue, regionList) {
  16473. // Remember the original input if we need to throw an error.
  16474. var oInput = input;
  16475. // 4.1 WebVTT timestamp
  16476. function consumeTimeStamp() {
  16477. var ts = parseTimeStamp(input);
  16478. if (ts === null) {
  16479. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  16480. "Malformed timestamp: " + oInput);
  16481. }
  16482. // Remove time stamp from input.
  16483. input = input.replace(/^[^\sa-zA-Z-]+/, "");
  16484. return ts;
  16485. }
  16486. // 4.4.2 WebVTT cue settings
  16487. function consumeCueSettings(input, cue) {
  16488. var settings = new Settings();
  16489. parseOptions(input, function (k, v) {
  16490. switch (k) {
  16491. case "region":
  16492. // Find the last region we parsed with the same region id.
  16493. for (var i = regionList.length - 1; i >= 0; i--) {
  16494. if (regionList[i].id === v) {
  16495. settings.set(k, regionList[i].region);
  16496. break;
  16497. }
  16498. }
  16499. break;
  16500. case "vertical":
  16501. settings.alt(k, v, ["rl", "lr"]);
  16502. break;
  16503. case "line":
  16504. var vals = v.split(","),
  16505. vals0 = vals[0];
  16506. settings.integer(k, vals0);
  16507. settings.percent(k, vals0) ? settings.set("snapToLines", false) : null;
  16508. settings.alt(k, vals0, ["auto"]);
  16509. if (vals.length === 2) {
  16510. settings.alt("lineAlign", vals[1], ["start", "middle", "end"]);
  16511. }
  16512. break;
  16513. case "position":
  16514. vals = v.split(",");
  16515. settings.percent(k, vals[0]);
  16516. if (vals.length === 2) {
  16517. settings.alt("positionAlign", vals[1], ["start", "middle", "end"]);
  16518. }
  16519. break;
  16520. case "size":
  16521. settings.percent(k, v);
  16522. break;
  16523. case "align":
  16524. settings.alt(k, v, ["start", "middle", "end", "left", "right"]);
  16525. break;
  16526. }
  16527. }, /:/, /\s/);
  16528. // Apply default values for any missing fields.
  16529. cue.region = settings.get("region", null);
  16530. cue.vertical = settings.get("vertical", "");
  16531. cue.line = settings.get("line", "auto");
  16532. cue.lineAlign = settings.get("lineAlign", "start");
  16533. cue.snapToLines = settings.get("snapToLines", true);
  16534. cue.size = settings.get("size", 100);
  16535. cue.align = settings.get("align", "middle");
  16536. cue.position = settings.get("position", {
  16537. start: 0,
  16538. left: 0,
  16539. middle: 50,
  16540. end: 100,
  16541. right: 100
  16542. }, cue.align);
  16543. cue.positionAlign = settings.get("positionAlign", {
  16544. start: "start",
  16545. left: "start",
  16546. middle: "middle",
  16547. end: "end",
  16548. right: "end"
  16549. }, cue.align);
  16550. }
  16551. function skipWhitespace() {
  16552. input = input.replace(/^\s+/, "");
  16553. }
  16554. // 4.1 WebVTT cue timings.
  16555. skipWhitespace();
  16556. cue.startTime = consumeTimeStamp(); // (1) collect cue start time
  16557. skipWhitespace();
  16558. if (input.substr(0, 3) !== "-->") { // (3) next characters must match "-->"
  16559. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  16560. "Malformed time stamp (time stamps must be separated by '-->'): " +
  16561. oInput);
  16562. }
  16563. input = input.substr(3);
  16564. skipWhitespace();
  16565. cue.endTime = consumeTimeStamp(); // (5) collect cue end time
  16566. // 4.1 WebVTT cue settings list.
  16567. skipWhitespace();
  16568. consumeCueSettings(input, cue);
  16569. }
  16570. var ESCAPE = {
  16571. "&amp;": "&",
  16572. "&lt;": "<",
  16573. "&gt;": ">",
  16574. "&lrm;": "\u200e",
  16575. "&rlm;": "\u200f",
  16576. "&nbsp;": "\u00a0"
  16577. };
  16578. var TAG_NAME = {
  16579. c: "span",
  16580. i: "i",
  16581. b: "b",
  16582. u: "u",
  16583. ruby: "ruby",
  16584. rt: "rt",
  16585. v: "span",
  16586. lang: "span"
  16587. };
  16588. var TAG_ANNOTATION = {
  16589. v: "title",
  16590. lang: "lang"
  16591. };
  16592. var NEEDS_PARENT = {
  16593. rt: "ruby"
  16594. };
  16595. // Parse content into a document fragment.
  16596. function parseContent(window, input) {
  16597. function nextToken() {
  16598. // Check for end-of-string.
  16599. if (!input) {
  16600. return null;
  16601. }
  16602. // Consume 'n' characters from the input.
  16603. function consume(result) {
  16604. input = input.substr(result.length);
  16605. return result;
  16606. }
  16607. var m = input.match(/^([^<]*)(<[^>]+>?)?/);
  16608. // If there is some text before the next tag, return it, otherwise return
  16609. // the tag.
  16610. return consume(m[1] ? m[1] : m[2]);
  16611. }
  16612. // Unescape a string 's'.
  16613. function unescape1(e) {
  16614. return ESCAPE[e];
  16615. }
  16616. function unescape(s) {
  16617. while ((m = s.match(/&(amp|lt|gt|lrm|rlm|nbsp);/))) {
  16618. s = s.replace(m[0], unescape1);
  16619. }
  16620. return s;
  16621. }
  16622. function shouldAdd(current, element) {
  16623. return !NEEDS_PARENT[element.localName] ||
  16624. NEEDS_PARENT[element.localName] === current.localName;
  16625. }
  16626. // Create an element for this tag.
  16627. function createElement(type, annotation) {
  16628. var tagName = TAG_NAME[type];
  16629. if (!tagName) {
  16630. return null;
  16631. }
  16632. var element = window.document.createElement(tagName);
  16633. element.localName = tagName;
  16634. var name = TAG_ANNOTATION[type];
  16635. if (name && annotation) {
  16636. element[name] = annotation.trim();
  16637. }
  16638. return element;
  16639. }
  16640. var rootDiv = window.document.createElement("div"),
  16641. current = rootDiv,
  16642. t,
  16643. tagStack = [];
  16644. while ((t = nextToken()) !== null) {
  16645. if (t[0] === '<') {
  16646. if (t[1] === "/") {
  16647. // If the closing tag matches, move back up to the parent node.
  16648. if (tagStack.length &&
  16649. tagStack[tagStack.length - 1] === t.substr(2).replace(">", "")) {
  16650. tagStack.pop();
  16651. current = current.parentNode;
  16652. }
  16653. // Otherwise just ignore the end tag.
  16654. continue;
  16655. }
  16656. var ts = parseTimeStamp(t.substr(1, t.length - 2));
  16657. var node;
  16658. if (ts) {
  16659. // Timestamps are lead nodes as well.
  16660. node = window.document.createProcessingInstruction("timestamp", ts);
  16661. current.appendChild(node);
  16662. continue;
  16663. }
  16664. var m = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);
  16665. // If we can't parse the tag, skip to the next tag.
  16666. if (!m) {
  16667. continue;
  16668. }
  16669. // Try to construct an element, and ignore the tag if we couldn't.
  16670. node = createElement(m[1], m[3]);
  16671. if (!node) {
  16672. continue;
  16673. }
  16674. // Determine if the tag should be added based on the context of where it
  16675. // is placed in the cuetext.
  16676. if (!shouldAdd(current, node)) {
  16677. continue;
  16678. }
  16679. // Set the class list (as a list of classes, separated by space).
  16680. if (m[2]) {
  16681. node.className = m[2].substr(1).replace('.', ' ');
  16682. }
  16683. // Append the node to the current node, and enter the scope of the new
  16684. // node.
  16685. tagStack.push(m[1]);
  16686. current.appendChild(node);
  16687. current = node;
  16688. continue;
  16689. }
  16690. // Text nodes are leaf nodes.
  16691. current.appendChild(window.document.createTextNode(unescape(t)));
  16692. }
  16693. return rootDiv;
  16694. }
  16695. // This is a list of all the Unicode characters that have a strong
  16696. // right-to-left category. What this means is that these characters are
  16697. // written right-to-left for sure. It was generated by pulling all the strong
  16698. // right-to-left characters out of the Unicode data table. That table can
  16699. // found at: http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
  16700. var strongRTLChars = [0x05BE, 0x05C0, 0x05C3, 0x05C6, 0x05D0, 0x05D1,
  16701. 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA,
  16702. 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3,
  16703. 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x05F0, 0x05F1,
  16704. 0x05F2, 0x05F3, 0x05F4, 0x0608, 0x060B, 0x060D, 0x061B, 0x061E, 0x061F,
  16705. 0x0620, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628,
  16706. 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631,
  16707. 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063A,
  16708. 0x063B, 0x063C, 0x063D, 0x063E, 0x063F, 0x0640, 0x0641, 0x0642, 0x0643,
  16709. 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, 0x066D, 0x066E,
  16710. 0x066F, 0x0671, 0x0672, 0x0673, 0x0674, 0x0675, 0x0676, 0x0677, 0x0678,
  16711. 0x0679, 0x067A, 0x067B, 0x067C, 0x067D, 0x067E, 0x067F, 0x0680, 0x0681,
  16712. 0x0682, 0x0683, 0x0684, 0x0685, 0x0686, 0x0687, 0x0688, 0x0689, 0x068A,
  16713. 0x068B, 0x068C, 0x068D, 0x068E, 0x068F, 0x0690, 0x0691, 0x0692, 0x0693,
  16714. 0x0694, 0x0695, 0x0696, 0x0697, 0x0698, 0x0699, 0x069A, 0x069B, 0x069C,
  16715. 0x069D, 0x069E, 0x069F, 0x06A0, 0x06A1, 0x06A2, 0x06A3, 0x06A4, 0x06A5,
  16716. 0x06A6, 0x06A7, 0x06A8, 0x06A9, 0x06AA, 0x06AB, 0x06AC, 0x06AD, 0x06AE,
  16717. 0x06AF, 0x06B0, 0x06B1, 0x06B2, 0x06B3, 0x06B4, 0x06B5, 0x06B6, 0x06B7,
  16718. 0x06B8, 0x06B9, 0x06BA, 0x06BB, 0x06BC, 0x06BD, 0x06BE, 0x06BF, 0x06C0,
  16719. 0x06C1, 0x06C2, 0x06C3, 0x06C4, 0x06C5, 0x06C6, 0x06C7, 0x06C8, 0x06C9,
  16720. 0x06CA, 0x06CB, 0x06CC, 0x06CD, 0x06CE, 0x06CF, 0x06D0, 0x06D1, 0x06D2,
  16721. 0x06D3, 0x06D4, 0x06D5, 0x06E5, 0x06E6, 0x06EE, 0x06EF, 0x06FA, 0x06FB,
  16722. 0x06FC, 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702, 0x0703, 0x0704,
  16723. 0x0705, 0x0706, 0x0707, 0x0708, 0x0709, 0x070A, 0x070B, 0x070C, 0x070D,
  16724. 0x070F, 0x0710, 0x0712, 0x0713, 0x0714, 0x0715, 0x0716, 0x0717, 0x0718,
  16725. 0x0719, 0x071A, 0x071B, 0x071C, 0x071D, 0x071E, 0x071F, 0x0720, 0x0721,
  16726. 0x0722, 0x0723, 0x0724, 0x0725, 0x0726, 0x0727, 0x0728, 0x0729, 0x072A,
  16727. 0x072B, 0x072C, 0x072D, 0x072E, 0x072F, 0x074D, 0x074E, 0x074F, 0x0750,
  16728. 0x0751, 0x0752, 0x0753, 0x0754, 0x0755, 0x0756, 0x0757, 0x0758, 0x0759,
  16729. 0x075A, 0x075B, 0x075C, 0x075D, 0x075E, 0x075F, 0x0760, 0x0761, 0x0762,
  16730. 0x0763, 0x0764, 0x0765, 0x0766, 0x0767, 0x0768, 0x0769, 0x076A, 0x076B,
  16731. 0x076C, 0x076D, 0x076E, 0x076F, 0x0770, 0x0771, 0x0772, 0x0773, 0x0774,
  16732. 0x0775, 0x0776, 0x0777, 0x0778, 0x0779, 0x077A, 0x077B, 0x077C, 0x077D,
  16733. 0x077E, 0x077F, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0786,
  16734. 0x0787, 0x0788, 0x0789, 0x078A, 0x078B, 0x078C, 0x078D, 0x078E, 0x078F,
  16735. 0x0790, 0x0791, 0x0792, 0x0793, 0x0794, 0x0795, 0x0796, 0x0797, 0x0798,
  16736. 0x0799, 0x079A, 0x079B, 0x079C, 0x079D, 0x079E, 0x079F, 0x07A0, 0x07A1,
  16737. 0x07A2, 0x07A3, 0x07A4, 0x07A5, 0x07B1, 0x07C0, 0x07C1, 0x07C2, 0x07C3,
  16738. 0x07C4, 0x07C5, 0x07C6, 0x07C7, 0x07C8, 0x07C9, 0x07CA, 0x07CB, 0x07CC,
  16739. 0x07CD, 0x07CE, 0x07CF, 0x07D0, 0x07D1, 0x07D2, 0x07D3, 0x07D4, 0x07D5,
  16740. 0x07D6, 0x07D7, 0x07D8, 0x07D9, 0x07DA, 0x07DB, 0x07DC, 0x07DD, 0x07DE,
  16741. 0x07DF, 0x07E0, 0x07E1, 0x07E2, 0x07E3, 0x07E4, 0x07E5, 0x07E6, 0x07E7,
  16742. 0x07E8, 0x07E9, 0x07EA, 0x07F4, 0x07F5, 0x07FA, 0x0800, 0x0801, 0x0802,
  16743. 0x0803, 0x0804, 0x0805, 0x0806, 0x0807, 0x0808, 0x0809, 0x080A, 0x080B,
  16744. 0x080C, 0x080D, 0x080E, 0x080F, 0x0810, 0x0811, 0x0812, 0x0813, 0x0814,
  16745. 0x0815, 0x081A, 0x0824, 0x0828, 0x0830, 0x0831, 0x0832, 0x0833, 0x0834,
  16746. 0x0835, 0x0836, 0x0837, 0x0838, 0x0839, 0x083A, 0x083B, 0x083C, 0x083D,
  16747. 0x083E, 0x0840, 0x0841, 0x0842, 0x0843, 0x0844, 0x0845, 0x0846, 0x0847,
  16748. 0x0848, 0x0849, 0x084A, 0x084B, 0x084C, 0x084D, 0x084E, 0x084F, 0x0850,
  16749. 0x0851, 0x0852, 0x0853, 0x0854, 0x0855, 0x0856, 0x0857, 0x0858, 0x085E,
  16750. 0x08A0, 0x08A2, 0x08A3, 0x08A4, 0x08A5, 0x08A6, 0x08A7, 0x08A8, 0x08A9,
  16751. 0x08AA, 0x08AB, 0x08AC, 0x200F, 0xFB1D, 0xFB1F, 0xFB20, 0xFB21, 0xFB22,
  16752. 0xFB23, 0xFB24, 0xFB25, 0xFB26, 0xFB27, 0xFB28, 0xFB2A, 0xFB2B, 0xFB2C,
  16753. 0xFB2D, 0xFB2E, 0xFB2F, 0xFB30, 0xFB31, 0xFB32, 0xFB33, 0xFB34, 0xFB35,
  16754. 0xFB36, 0xFB38, 0xFB39, 0xFB3A, 0xFB3B, 0xFB3C, 0xFB3E, 0xFB40, 0xFB41,
  16755. 0xFB43, 0xFB44, 0xFB46, 0xFB47, 0xFB48, 0xFB49, 0xFB4A, 0xFB4B, 0xFB4C,
  16756. 0xFB4D, 0xFB4E, 0xFB4F, 0xFB50, 0xFB51, 0xFB52, 0xFB53, 0xFB54, 0xFB55,
  16757. 0xFB56, 0xFB57, 0xFB58, 0xFB59, 0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D, 0xFB5E,
  16758. 0xFB5F, 0xFB60, 0xFB61, 0xFB62, 0xFB63, 0xFB64, 0xFB65, 0xFB66, 0xFB67,
  16759. 0xFB68, 0xFB69, 0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D, 0xFB6E, 0xFB6F, 0xFB70,
  16760. 0xFB71, 0xFB72, 0xFB73, 0xFB74, 0xFB75, 0xFB76, 0xFB77, 0xFB78, 0xFB79,
  16761. 0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D, 0xFB7E, 0xFB7F, 0xFB80, 0xFB81, 0xFB82,
  16762. 0xFB83, 0xFB84, 0xFB85, 0xFB86, 0xFB87, 0xFB88, 0xFB89, 0xFB8A, 0xFB8B,
  16763. 0xFB8C, 0xFB8D, 0xFB8E, 0xFB8F, 0xFB90, 0xFB91, 0xFB92, 0xFB93, 0xFB94,
  16764. 0xFB95, 0xFB96, 0xFB97, 0xFB98, 0xFB99, 0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D,
  16765. 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3, 0xFBA4, 0xFBA5, 0xFBA6,
  16766. 0xFBA7, 0xFBA8, 0xFBA9, 0xFBAA, 0xFBAB, 0xFBAC, 0xFBAD, 0xFBAE, 0xFBAF,
  16767. 0xFBB0, 0xFBB1, 0xFBB2, 0xFBB3, 0xFBB4, 0xFBB5, 0xFBB6, 0xFBB7, 0xFBB8,
  16768. 0xFBB9, 0xFBBA, 0xFBBB, 0xFBBC, 0xFBBD, 0xFBBE, 0xFBBF, 0xFBC0, 0xFBC1,
  16769. 0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6, 0xFBD7, 0xFBD8, 0xFBD9, 0xFBDA, 0xFBDB,
  16770. 0xFBDC, 0xFBDD, 0xFBDE, 0xFBDF, 0xFBE0, 0xFBE1, 0xFBE2, 0xFBE3, 0xFBE4,
  16771. 0xFBE5, 0xFBE6, 0xFBE7, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEB, 0xFBEC, 0xFBED,
  16772. 0xFBEE, 0xFBEF, 0xFBF0, 0xFBF1, 0xFBF2, 0xFBF3, 0xFBF4, 0xFBF5, 0xFBF6,
  16773. 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF,
  16774. 0xFC00, 0xFC01, 0xFC02, 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
  16775. 0xFC09, 0xFC0A, 0xFC0B, 0xFC0C, 0xFC0D, 0xFC0E, 0xFC0F, 0xFC10, 0xFC11,
  16776. 0xFC12, 0xFC13, 0xFC14, 0xFC15, 0xFC16, 0xFC17, 0xFC18, 0xFC19, 0xFC1A,
  16777. 0xFC1B, 0xFC1C, 0xFC1D, 0xFC1E, 0xFC1F, 0xFC20, 0xFC21, 0xFC22, 0xFC23,
  16778. 0xFC24, 0xFC25, 0xFC26, 0xFC27, 0xFC28, 0xFC29, 0xFC2A, 0xFC2B, 0xFC2C,
  16779. 0xFC2D, 0xFC2E, 0xFC2F, 0xFC30, 0xFC31, 0xFC32, 0xFC33, 0xFC34, 0xFC35,
  16780. 0xFC36, 0xFC37, 0xFC38, 0xFC39, 0xFC3A, 0xFC3B, 0xFC3C, 0xFC3D, 0xFC3E,
  16781. 0xFC3F, 0xFC40, 0xFC41, 0xFC42, 0xFC43, 0xFC44, 0xFC45, 0xFC46, 0xFC47,
  16782. 0xFC48, 0xFC49, 0xFC4A, 0xFC4B, 0xFC4C, 0xFC4D, 0xFC4E, 0xFC4F, 0xFC50,
  16783. 0xFC51, 0xFC52, 0xFC53, 0xFC54, 0xFC55, 0xFC56, 0xFC57, 0xFC58, 0xFC59,
  16784. 0xFC5A, 0xFC5B, 0xFC5C, 0xFC5D, 0xFC5E, 0xFC5F, 0xFC60, 0xFC61, 0xFC62,
  16785. 0xFC63, 0xFC64, 0xFC65, 0xFC66, 0xFC67, 0xFC68, 0xFC69, 0xFC6A, 0xFC6B,
  16786. 0xFC6C, 0xFC6D, 0xFC6E, 0xFC6F, 0xFC70, 0xFC71, 0xFC72, 0xFC73, 0xFC74,
  16787. 0xFC75, 0xFC76, 0xFC77, 0xFC78, 0xFC79, 0xFC7A, 0xFC7B, 0xFC7C, 0xFC7D,
  16788. 0xFC7E, 0xFC7F, 0xFC80, 0xFC81, 0xFC82, 0xFC83, 0xFC84, 0xFC85, 0xFC86,
  16789. 0xFC87, 0xFC88, 0xFC89, 0xFC8A, 0xFC8B, 0xFC8C, 0xFC8D, 0xFC8E, 0xFC8F,
  16790. 0xFC90, 0xFC91, 0xFC92, 0xFC93, 0xFC94, 0xFC95, 0xFC96, 0xFC97, 0xFC98,
  16791. 0xFC99, 0xFC9A, 0xFC9B, 0xFC9C, 0xFC9D, 0xFC9E, 0xFC9F, 0xFCA0, 0xFCA1,
  16792. 0xFCA2, 0xFCA3, 0xFCA4, 0xFCA5, 0xFCA6, 0xFCA7, 0xFCA8, 0xFCA9, 0xFCAA,
  16793. 0xFCAB, 0xFCAC, 0xFCAD, 0xFCAE, 0xFCAF, 0xFCB0, 0xFCB1, 0xFCB2, 0xFCB3,
  16794. 0xFCB4, 0xFCB5, 0xFCB6, 0xFCB7, 0xFCB8, 0xFCB9, 0xFCBA, 0xFCBB, 0xFCBC,
  16795. 0xFCBD, 0xFCBE, 0xFCBF, 0xFCC0, 0xFCC1, 0xFCC2, 0xFCC3, 0xFCC4, 0xFCC5,
  16796. 0xFCC6, 0xFCC7, 0xFCC8, 0xFCC9, 0xFCCA, 0xFCCB, 0xFCCC, 0xFCCD, 0xFCCE,
  16797. 0xFCCF, 0xFCD0, 0xFCD1, 0xFCD2, 0xFCD3, 0xFCD4, 0xFCD5, 0xFCD6, 0xFCD7,
  16798. 0xFCD8, 0xFCD9, 0xFCDA, 0xFCDB, 0xFCDC, 0xFCDD, 0xFCDE, 0xFCDF, 0xFCE0,
  16799. 0xFCE1, 0xFCE2, 0xFCE3, 0xFCE4, 0xFCE5, 0xFCE6, 0xFCE7, 0xFCE8, 0xFCE9,
  16800. 0xFCEA, 0xFCEB, 0xFCEC, 0xFCED, 0xFCEE, 0xFCEF, 0xFCF0, 0xFCF1, 0xFCF2,
  16801. 0xFCF3, 0xFCF4, 0xFCF5, 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9, 0xFCFA, 0xFCFB,
  16802. 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF, 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04,
  16803. 0xFD05, 0xFD06, 0xFD07, 0xFD08, 0xFD09, 0xFD0A, 0xFD0B, 0xFD0C, 0xFD0D,
  16804. 0xFD0E, 0xFD0F, 0xFD10, 0xFD11, 0xFD12, 0xFD13, 0xFD14, 0xFD15, 0xFD16,
  16805. 0xFD17, 0xFD18, 0xFD19, 0xFD1A, 0xFD1B, 0xFD1C, 0xFD1D, 0xFD1E, 0xFD1F,
  16806. 0xFD20, 0xFD21, 0xFD22, 0xFD23, 0xFD24, 0xFD25, 0xFD26, 0xFD27, 0xFD28,
  16807. 0xFD29, 0xFD2A, 0xFD2B, 0xFD2C, 0xFD2D, 0xFD2E, 0xFD2F, 0xFD30, 0xFD31,
  16808. 0xFD32, 0xFD33, 0xFD34, 0xFD35, 0xFD36, 0xFD37, 0xFD38, 0xFD39, 0xFD3A,
  16809. 0xFD3B, 0xFD3C, 0xFD3D, 0xFD50, 0xFD51, 0xFD52, 0xFD53, 0xFD54, 0xFD55,
  16810. 0xFD56, 0xFD57, 0xFD58, 0xFD59, 0xFD5A, 0xFD5B, 0xFD5C, 0xFD5D, 0xFD5E,
  16811. 0xFD5F, 0xFD60, 0xFD61, 0xFD62, 0xFD63, 0xFD64, 0xFD65, 0xFD66, 0xFD67,
  16812. 0xFD68, 0xFD69, 0xFD6A, 0xFD6B, 0xFD6C, 0xFD6D, 0xFD6E, 0xFD6F, 0xFD70,
  16813. 0xFD71, 0xFD72, 0xFD73, 0xFD74, 0xFD75, 0xFD76, 0xFD77, 0xFD78, 0xFD79,
  16814. 0xFD7A, 0xFD7B, 0xFD7C, 0xFD7D, 0xFD7E, 0xFD7F, 0xFD80, 0xFD81, 0xFD82,
  16815. 0xFD83, 0xFD84, 0xFD85, 0xFD86, 0xFD87, 0xFD88, 0xFD89, 0xFD8A, 0xFD8B,
  16816. 0xFD8C, 0xFD8D, 0xFD8E, 0xFD8F, 0xFD92, 0xFD93, 0xFD94, 0xFD95, 0xFD96,
  16817. 0xFD97, 0xFD98, 0xFD99, 0xFD9A, 0xFD9B, 0xFD9C, 0xFD9D, 0xFD9E, 0xFD9F,
  16818. 0xFDA0, 0xFDA1, 0xFDA2, 0xFDA3, 0xFDA4, 0xFDA5, 0xFDA6, 0xFDA7, 0xFDA8,
  16819. 0xFDA9, 0xFDAA, 0xFDAB, 0xFDAC, 0xFDAD, 0xFDAE, 0xFDAF, 0xFDB0, 0xFDB1,
  16820. 0xFDB2, 0xFDB3, 0xFDB4, 0xFDB5, 0xFDB6, 0xFDB7, 0xFDB8, 0xFDB9, 0xFDBA,
  16821. 0xFDBB, 0xFDBC, 0xFDBD, 0xFDBE, 0xFDBF, 0xFDC0, 0xFDC1, 0xFDC2, 0xFDC3,
  16822. 0xFDC4, 0xFDC5, 0xFDC6, 0xFDC7, 0xFDF0, 0xFDF1, 0xFDF2, 0xFDF3, 0xFDF4,
  16823. 0xFDF5, 0xFDF6, 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC, 0xFE70,
  16824. 0xFE71, 0xFE72, 0xFE73, 0xFE74, 0xFE76, 0xFE77, 0xFE78, 0xFE79, 0xFE7A,
  16825. 0xFE7B, 0xFE7C, 0xFE7D, 0xFE7E, 0xFE7F, 0xFE80, 0xFE81, 0xFE82, 0xFE83,
  16826. 0xFE84, 0xFE85, 0xFE86, 0xFE87, 0xFE88, 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C,
  16827. 0xFE8D, 0xFE8E, 0xFE8F, 0xFE90, 0xFE91, 0xFE92, 0xFE93, 0xFE94, 0xFE95,
  16828. 0xFE96, 0xFE97, 0xFE98, 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C, 0xFE9D, 0xFE9E,
  16829. 0xFE9F, 0xFEA0, 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4, 0xFEA5, 0xFEA6, 0xFEA7,
  16830. 0xFEA8, 0xFEA9, 0xFEAA, 0xFEAB, 0xFEAC, 0xFEAD, 0xFEAE, 0xFEAF, 0xFEB0,
  16831. 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4, 0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8, 0xFEB9,
  16832. 0xFEBA, 0xFEBB, 0xFEBC, 0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0, 0xFEC1, 0xFEC2,
  16833. 0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8, 0xFEC9, 0xFECA, 0xFECB,
  16834. 0xFECC, 0xFECD, 0xFECE, 0xFECF, 0xFED0, 0xFED1, 0xFED2, 0xFED3, 0xFED4,
  16835. 0xFED5, 0xFED6, 0xFED7, 0xFED8, 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC, 0xFEDD,
  16836. 0xFEDE, 0xFEDF, 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6,
  16837. 0xFEE7, 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF,
  16838. 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8,
  16839. 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0x10800, 0x10801, 0x10802, 0x10803,
  16840. 0x10804, 0x10805, 0x10808, 0x1080A, 0x1080B, 0x1080C, 0x1080D, 0x1080E,
  16841. 0x1080F, 0x10810, 0x10811, 0x10812, 0x10813, 0x10814, 0x10815, 0x10816,
  16842. 0x10817, 0x10818, 0x10819, 0x1081A, 0x1081B, 0x1081C, 0x1081D, 0x1081E,
  16843. 0x1081F, 0x10820, 0x10821, 0x10822, 0x10823, 0x10824, 0x10825, 0x10826,
  16844. 0x10827, 0x10828, 0x10829, 0x1082A, 0x1082B, 0x1082C, 0x1082D, 0x1082E,
  16845. 0x1082F, 0x10830, 0x10831, 0x10832, 0x10833, 0x10834, 0x10835, 0x10837,
  16846. 0x10838, 0x1083C, 0x1083F, 0x10840, 0x10841, 0x10842, 0x10843, 0x10844,
  16847. 0x10845, 0x10846, 0x10847, 0x10848, 0x10849, 0x1084A, 0x1084B, 0x1084C,
  16848. 0x1084D, 0x1084E, 0x1084F, 0x10850, 0x10851, 0x10852, 0x10853, 0x10854,
  16849. 0x10855, 0x10857, 0x10858, 0x10859, 0x1085A, 0x1085B, 0x1085C, 0x1085D,
  16850. 0x1085E, 0x1085F, 0x10900, 0x10901, 0x10902, 0x10903, 0x10904, 0x10905,
  16851. 0x10906, 0x10907, 0x10908, 0x10909, 0x1090A, 0x1090B, 0x1090C, 0x1090D,
  16852. 0x1090E, 0x1090F, 0x10910, 0x10911, 0x10912, 0x10913, 0x10914, 0x10915,
  16853. 0x10916, 0x10917, 0x10918, 0x10919, 0x1091A, 0x1091B, 0x10920, 0x10921,
  16854. 0x10922, 0x10923, 0x10924, 0x10925, 0x10926, 0x10927, 0x10928, 0x10929,
  16855. 0x1092A, 0x1092B, 0x1092C, 0x1092D, 0x1092E, 0x1092F, 0x10930, 0x10931,
  16856. 0x10932, 0x10933, 0x10934, 0x10935, 0x10936, 0x10937, 0x10938, 0x10939,
  16857. 0x1093F, 0x10980, 0x10981, 0x10982, 0x10983, 0x10984, 0x10985, 0x10986,
  16858. 0x10987, 0x10988, 0x10989, 0x1098A, 0x1098B, 0x1098C, 0x1098D, 0x1098E,
  16859. 0x1098F, 0x10990, 0x10991, 0x10992, 0x10993, 0x10994, 0x10995, 0x10996,
  16860. 0x10997, 0x10998, 0x10999, 0x1099A, 0x1099B, 0x1099C, 0x1099D, 0x1099E,
  16861. 0x1099F, 0x109A0, 0x109A1, 0x109A2, 0x109A3, 0x109A4, 0x109A5, 0x109A6,
  16862. 0x109A7, 0x109A8, 0x109A9, 0x109AA, 0x109AB, 0x109AC, 0x109AD, 0x109AE,
  16863. 0x109AF, 0x109B0, 0x109B1, 0x109B2, 0x109B3, 0x109B4, 0x109B5, 0x109B6,
  16864. 0x109B7, 0x109BE, 0x109BF, 0x10A00, 0x10A10, 0x10A11, 0x10A12, 0x10A13,
  16865. 0x10A15, 0x10A16, 0x10A17, 0x10A19, 0x10A1A, 0x10A1B, 0x10A1C, 0x10A1D,
  16866. 0x10A1E, 0x10A1F, 0x10A20, 0x10A21, 0x10A22, 0x10A23, 0x10A24, 0x10A25,
  16867. 0x10A26, 0x10A27, 0x10A28, 0x10A29, 0x10A2A, 0x10A2B, 0x10A2C, 0x10A2D,
  16868. 0x10A2E, 0x10A2F, 0x10A30, 0x10A31, 0x10A32, 0x10A33, 0x10A40, 0x10A41,
  16869. 0x10A42, 0x10A43, 0x10A44, 0x10A45, 0x10A46, 0x10A47, 0x10A50, 0x10A51,
  16870. 0x10A52, 0x10A53, 0x10A54, 0x10A55, 0x10A56, 0x10A57, 0x10A58, 0x10A60,
  16871. 0x10A61, 0x10A62, 0x10A63, 0x10A64, 0x10A65, 0x10A66, 0x10A67, 0x10A68,
  16872. 0x10A69, 0x10A6A, 0x10A6B, 0x10A6C, 0x10A6D, 0x10A6E, 0x10A6F, 0x10A70,
  16873. 0x10A71, 0x10A72, 0x10A73, 0x10A74, 0x10A75, 0x10A76, 0x10A77, 0x10A78,
  16874. 0x10A79, 0x10A7A, 0x10A7B, 0x10A7C, 0x10A7D, 0x10A7E, 0x10A7F, 0x10B00,
  16875. 0x10B01, 0x10B02, 0x10B03, 0x10B04, 0x10B05, 0x10B06, 0x10B07, 0x10B08,
  16876. 0x10B09, 0x10B0A, 0x10B0B, 0x10B0C, 0x10B0D, 0x10B0E, 0x10B0F, 0x10B10,
  16877. 0x10B11, 0x10B12, 0x10B13, 0x10B14, 0x10B15, 0x10B16, 0x10B17, 0x10B18,
  16878. 0x10B19, 0x10B1A, 0x10B1B, 0x10B1C, 0x10B1D, 0x10B1E, 0x10B1F, 0x10B20,
  16879. 0x10B21, 0x10B22, 0x10B23, 0x10B24, 0x10B25, 0x10B26, 0x10B27, 0x10B28,
  16880. 0x10B29, 0x10B2A, 0x10B2B, 0x10B2C, 0x10B2D, 0x10B2E, 0x10B2F, 0x10B30,
  16881. 0x10B31, 0x10B32, 0x10B33, 0x10B34, 0x10B35, 0x10B40, 0x10B41, 0x10B42,
  16882. 0x10B43, 0x10B44, 0x10B45, 0x10B46, 0x10B47, 0x10B48, 0x10B49, 0x10B4A,
  16883. 0x10B4B, 0x10B4C, 0x10B4D, 0x10B4E, 0x10B4F, 0x10B50, 0x10B51, 0x10B52,
  16884. 0x10B53, 0x10B54, 0x10B55, 0x10B58, 0x10B59, 0x10B5A, 0x10B5B, 0x10B5C,
  16885. 0x10B5D, 0x10B5E, 0x10B5F, 0x10B60, 0x10B61, 0x10B62, 0x10B63, 0x10B64,
  16886. 0x10B65, 0x10B66, 0x10B67, 0x10B68, 0x10B69, 0x10B6A, 0x10B6B, 0x10B6C,
  16887. 0x10B6D, 0x10B6E, 0x10B6F, 0x10B70, 0x10B71, 0x10B72, 0x10B78, 0x10B79,
  16888. 0x10B7A, 0x10B7B, 0x10B7C, 0x10B7D, 0x10B7E, 0x10B7F, 0x10C00, 0x10C01,
  16889. 0x10C02, 0x10C03, 0x10C04, 0x10C05, 0x10C06, 0x10C07, 0x10C08, 0x10C09,
  16890. 0x10C0A, 0x10C0B, 0x10C0C, 0x10C0D, 0x10C0E, 0x10C0F, 0x10C10, 0x10C11,
  16891. 0x10C12, 0x10C13, 0x10C14, 0x10C15, 0x10C16, 0x10C17, 0x10C18, 0x10C19,
  16892. 0x10C1A, 0x10C1B, 0x10C1C, 0x10C1D, 0x10C1E, 0x10C1F, 0x10C20, 0x10C21,
  16893. 0x10C22, 0x10C23, 0x10C24, 0x10C25, 0x10C26, 0x10C27, 0x10C28, 0x10C29,
  16894. 0x10C2A, 0x10C2B, 0x10C2C, 0x10C2D, 0x10C2E, 0x10C2F, 0x10C30, 0x10C31,
  16895. 0x10C32, 0x10C33, 0x10C34, 0x10C35, 0x10C36, 0x10C37, 0x10C38, 0x10C39,
  16896. 0x10C3A, 0x10C3B, 0x10C3C, 0x10C3D, 0x10C3E, 0x10C3F, 0x10C40, 0x10C41,
  16897. 0x10C42, 0x10C43, 0x10C44, 0x10C45, 0x10C46, 0x10C47, 0x10C48, 0x1EE00,
  16898. 0x1EE01, 0x1EE02, 0x1EE03, 0x1EE05, 0x1EE06, 0x1EE07, 0x1EE08, 0x1EE09,
  16899. 0x1EE0A, 0x1EE0B, 0x1EE0C, 0x1EE0D, 0x1EE0E, 0x1EE0F, 0x1EE10, 0x1EE11,
  16900. 0x1EE12, 0x1EE13, 0x1EE14, 0x1EE15, 0x1EE16, 0x1EE17, 0x1EE18, 0x1EE19,
  16901. 0x1EE1A, 0x1EE1B, 0x1EE1C, 0x1EE1D, 0x1EE1E, 0x1EE1F, 0x1EE21, 0x1EE22,
  16902. 0x1EE24, 0x1EE27, 0x1EE29, 0x1EE2A, 0x1EE2B, 0x1EE2C, 0x1EE2D, 0x1EE2E,
  16903. 0x1EE2F, 0x1EE30, 0x1EE31, 0x1EE32, 0x1EE34, 0x1EE35, 0x1EE36, 0x1EE37,
  16904. 0x1EE39, 0x1EE3B, 0x1EE42, 0x1EE47, 0x1EE49, 0x1EE4B, 0x1EE4D, 0x1EE4E,
  16905. 0x1EE4F, 0x1EE51, 0x1EE52, 0x1EE54, 0x1EE57, 0x1EE59, 0x1EE5B, 0x1EE5D,
  16906. 0x1EE5F, 0x1EE61, 0x1EE62, 0x1EE64, 0x1EE67, 0x1EE68, 0x1EE69, 0x1EE6A,
  16907. 0x1EE6C, 0x1EE6D, 0x1EE6E, 0x1EE6F, 0x1EE70, 0x1EE71, 0x1EE72, 0x1EE74,
  16908. 0x1EE75, 0x1EE76, 0x1EE77, 0x1EE79, 0x1EE7A, 0x1EE7B, 0x1EE7C, 0x1EE7E,
  16909. 0x1EE80, 0x1EE81, 0x1EE82, 0x1EE83, 0x1EE84, 0x1EE85, 0x1EE86, 0x1EE87,
  16910. 0x1EE88, 0x1EE89, 0x1EE8B, 0x1EE8C, 0x1EE8D, 0x1EE8E, 0x1EE8F, 0x1EE90,
  16911. 0x1EE91, 0x1EE92, 0x1EE93, 0x1EE94, 0x1EE95, 0x1EE96, 0x1EE97, 0x1EE98,
  16912. 0x1EE99, 0x1EE9A, 0x1EE9B, 0x1EEA1, 0x1EEA2, 0x1EEA3, 0x1EEA5, 0x1EEA6,
  16913. 0x1EEA7, 0x1EEA8, 0x1EEA9, 0x1EEAB, 0x1EEAC, 0x1EEAD, 0x1EEAE, 0x1EEAF,
  16914. 0x1EEB0, 0x1EEB1, 0x1EEB2, 0x1EEB3, 0x1EEB4, 0x1EEB5, 0x1EEB6, 0x1EEB7,
  16915. 0x1EEB8, 0x1EEB9, 0x1EEBA, 0x1EEBB, 0x10FFFD];
  16916. function determineBidi(cueDiv) {
  16917. var nodeStack = [],
  16918. text = "",
  16919. charCode;
  16920. if (!cueDiv || !cueDiv.childNodes) {
  16921. return "ltr";
  16922. }
  16923. function pushNodes(nodeStack, node) {
  16924. for (var i = node.childNodes.length - 1; i >= 0; i--) {
  16925. nodeStack.push(node.childNodes[i]);
  16926. }
  16927. }
  16928. function nextTextNode(nodeStack) {
  16929. if (!nodeStack || !nodeStack.length) {
  16930. return null;
  16931. }
  16932. var node = nodeStack.pop(),
  16933. text = node.textContent || node.innerText;
  16934. if (text) {
  16935. // TODO: This should match all unicode type B characters (paragraph
  16936. // separator characters). See issue #115.
  16937. var m = text.match(/^.*(\n|\r)/);
  16938. if (m) {
  16939. nodeStack.length = 0;
  16940. return m[0];
  16941. }
  16942. return text;
  16943. }
  16944. if (node.tagName === "ruby") {
  16945. return nextTextNode(nodeStack);
  16946. }
  16947. if (node.childNodes) {
  16948. pushNodes(nodeStack, node);
  16949. return nextTextNode(nodeStack);
  16950. }
  16951. }
  16952. pushNodes(nodeStack, cueDiv);
  16953. while ((text = nextTextNode(nodeStack))) {
  16954. for (var i = 0; i < text.length; i++) {
  16955. charCode = text.charCodeAt(i);
  16956. for (var j = 0; j < strongRTLChars.length; j++) {
  16957. if (strongRTLChars[j] === charCode) {
  16958. return "rtl";
  16959. }
  16960. }
  16961. }
  16962. }
  16963. return "ltr";
  16964. }
  16965. function computeLinePos(cue) {
  16966. if (typeof cue.line === "number" &&
  16967. (cue.snapToLines || (cue.line >= 0 && cue.line <= 100))) {
  16968. return cue.line;
  16969. }
  16970. if (!cue.track || !cue.track.textTrackList ||
  16971. !cue.track.textTrackList.mediaElement) {
  16972. return -1;
  16973. }
  16974. var track = cue.track,
  16975. trackList = track.textTrackList,
  16976. count = 0;
  16977. for (var i = 0; i < trackList.length && trackList[i] !== track; i++) {
  16978. if (trackList[i].mode === "showing") {
  16979. count++;
  16980. }
  16981. }
  16982. return ++count * -1;
  16983. }
  16984. function StyleBox() {
  16985. }
  16986. // Apply styles to a div. If there is no div passed then it defaults to the
  16987. // div on 'this'.
  16988. StyleBox.prototype.applyStyles = function(styles, div) {
  16989. div = div || this.div;
  16990. for (var prop in styles) {
  16991. if (styles.hasOwnProperty(prop)) {
  16992. div.style[prop] = styles[prop];
  16993. }
  16994. }
  16995. };
  16996. StyleBox.prototype.formatStyle = function(val, unit) {
  16997. return val === 0 ? 0 : val + unit;
  16998. };
  16999. // Constructs the computed display state of the cue (a div). Places the div
  17000. // into the overlay which should be a block level element (usually a div).
  17001. function CueStyleBox(window, cue, styleOptions) {
  17002. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  17003. var color = "rgba(255, 255, 255, 1)";
  17004. var backgroundColor = "rgba(0, 0, 0, 0.8)";
  17005. if (isIE8) {
  17006. color = "rgb(255, 255, 255)";
  17007. backgroundColor = "rgb(0, 0, 0)";
  17008. }
  17009. StyleBox.call(this);
  17010. this.cue = cue;
  17011. // Parse our cue's text into a DOM tree rooted at 'cueDiv'. This div will
  17012. // have inline positioning and will function as the cue background box.
  17013. this.cueDiv = parseContent(window, cue.text);
  17014. var styles = {
  17015. color: color,
  17016. backgroundColor: backgroundColor,
  17017. position: "relative",
  17018. left: 0,
  17019. right: 0,
  17020. top: 0,
  17021. bottom: 0,
  17022. display: "inline"
  17023. };
  17024. if (!isIE8) {
  17025. styles.writingMode = cue.vertical === "" ? "horizontal-tb"
  17026. : cue.vertical === "lr" ? "vertical-lr"
  17027. : "vertical-rl";
  17028. styles.unicodeBidi = "plaintext";
  17029. }
  17030. this.applyStyles(styles, this.cueDiv);
  17031. // Create an absolutely positioned div that will be used to position the cue
  17032. // div. Note, all WebVTT cue-setting alignments are equivalent to the CSS
  17033. // mirrors of them except "middle" which is "center" in CSS.
  17034. this.div = window.document.createElement("div");
  17035. styles = {
  17036. textAlign: cue.align === "middle" ? "center" : cue.align,
  17037. font: styleOptions.font,
  17038. whiteSpace: "pre-line",
  17039. position: "absolute"
  17040. };
  17041. if (!isIE8) {
  17042. styles.direction = determineBidi(this.cueDiv);
  17043. styles.writingMode = cue.vertical === "" ? "horizontal-tb"
  17044. : cue.vertical === "lr" ? "vertical-lr"
  17045. : "vertical-rl".
  17046. stylesunicodeBidi = "plaintext";
  17047. }
  17048. this.applyStyles(styles);
  17049. this.div.appendChild(this.cueDiv);
  17050. // Calculate the distance from the reference edge of the viewport to the text
  17051. // position of the cue box. The reference edge will be resolved later when
  17052. // the box orientation styles are applied.
  17053. var textPos = 0;
  17054. switch (cue.positionAlign) {
  17055. case "start":
  17056. textPos = cue.position;
  17057. break;
  17058. case "middle":
  17059. textPos = cue.position - (cue.size / 2);
  17060. break;
  17061. case "end":
  17062. textPos = cue.position - cue.size;
  17063. break;
  17064. }
  17065. // Horizontal box orientation; textPos is the distance from the left edge of the
  17066. // area to the left edge of the box and cue.size is the distance extending to
  17067. // the right from there.
  17068. if (cue.vertical === "") {
  17069. this.applyStyles({
  17070. left: this.formatStyle(textPos, "%"),
  17071. width: this.formatStyle(cue.size, "%")
  17072. });
  17073. // Vertical box orientation; textPos is the distance from the top edge of the
  17074. // area to the top edge of the box and cue.size is the height extending
  17075. // downwards from there.
  17076. } else {
  17077. this.applyStyles({
  17078. top: this.formatStyle(textPos, "%"),
  17079. height: this.formatStyle(cue.size, "%")
  17080. });
  17081. }
  17082. this.move = function(box) {
  17083. this.applyStyles({
  17084. top: this.formatStyle(box.top, "px"),
  17085. bottom: this.formatStyle(box.bottom, "px"),
  17086. left: this.formatStyle(box.left, "px"),
  17087. right: this.formatStyle(box.right, "px"),
  17088. height: this.formatStyle(box.height, "px"),
  17089. width: this.formatStyle(box.width, "px")
  17090. });
  17091. };
  17092. }
  17093. CueStyleBox.prototype = _objCreate(StyleBox.prototype);
  17094. CueStyleBox.prototype.constructor = CueStyleBox;
  17095. // Represents the co-ordinates of an Element in a way that we can easily
  17096. // compute things with such as if it overlaps or intersects with another Element.
  17097. // Can initialize it with either a StyleBox or another BoxPosition.
  17098. function BoxPosition(obj) {
  17099. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  17100. // Either a BoxPosition was passed in and we need to copy it, or a StyleBox
  17101. // was passed in and we need to copy the results of 'getBoundingClientRect'
  17102. // as the object returned is readonly. All co-ordinate values are in reference
  17103. // to the viewport origin (top left).
  17104. var lh, height, width, top;
  17105. if (obj.div) {
  17106. height = obj.div.offsetHeight;
  17107. width = obj.div.offsetWidth;
  17108. top = obj.div.offsetTop;
  17109. var rects = (rects = obj.div.childNodes) && (rects = rects[0]) &&
  17110. rects.getClientRects && rects.getClientRects();
  17111. obj = obj.div.getBoundingClientRect();
  17112. // In certain cases the outter div will be slightly larger then the sum of
  17113. // the inner div's lines. This could be due to bold text, etc, on some platforms.
  17114. // In this case we should get the average line height and use that. This will
  17115. // result in the desired behaviour.
  17116. lh = rects ? Math.max((rects[0] && rects[0].height) || 0, obj.height / rects.length)
  17117. : 0;
  17118. }
  17119. this.left = obj.left;
  17120. this.right = obj.right;
  17121. this.top = obj.top || top;
  17122. this.height = obj.height || height;
  17123. this.bottom = obj.bottom || (top + (obj.height || height));
  17124. this.width = obj.width || width;
  17125. this.lineHeight = lh !== undefined ? lh : obj.lineHeight;
  17126. if (isIE8 && !this.lineHeight) {
  17127. this.lineHeight = 13;
  17128. }
  17129. }
  17130. // Move the box along a particular axis. Optionally pass in an amount to move
  17131. // the box. If no amount is passed then the default is the line height of the
  17132. // box.
  17133. BoxPosition.prototype.move = function(axis, toMove) {
  17134. toMove = toMove !== undefined ? toMove : this.lineHeight;
  17135. switch (axis) {
  17136. case "+x":
  17137. this.left += toMove;
  17138. this.right += toMove;
  17139. break;
  17140. case "-x":
  17141. this.left -= toMove;
  17142. this.right -= toMove;
  17143. break;
  17144. case "+y":
  17145. this.top += toMove;
  17146. this.bottom += toMove;
  17147. break;
  17148. case "-y":
  17149. this.top -= toMove;
  17150. this.bottom -= toMove;
  17151. break;
  17152. }
  17153. };
  17154. // Check if this box overlaps another box, b2.
  17155. BoxPosition.prototype.overlaps = function(b2) {
  17156. return this.left < b2.right &&
  17157. this.right > b2.left &&
  17158. this.top < b2.bottom &&
  17159. this.bottom > b2.top;
  17160. };
  17161. // Check if this box overlaps any other boxes in boxes.
  17162. BoxPosition.prototype.overlapsAny = function(boxes) {
  17163. for (var i = 0; i < boxes.length; i++) {
  17164. if (this.overlaps(boxes[i])) {
  17165. return true;
  17166. }
  17167. }
  17168. return false;
  17169. };
  17170. // Check if this box is within another box.
  17171. BoxPosition.prototype.within = function(container) {
  17172. return this.top >= container.top &&
  17173. this.bottom <= container.bottom &&
  17174. this.left >= container.left &&
  17175. this.right <= container.right;
  17176. };
  17177. // Check if this box is entirely within the container or it is overlapping
  17178. // on the edge opposite of the axis direction passed. For example, if "+x" is
  17179. // passed and the box is overlapping on the left edge of the container, then
  17180. // return true.
  17181. BoxPosition.prototype.overlapsOppositeAxis = function(container, axis) {
  17182. switch (axis) {
  17183. case "+x":
  17184. return this.left < container.left;
  17185. case "-x":
  17186. return this.right > container.right;
  17187. case "+y":
  17188. return this.top < container.top;
  17189. case "-y":
  17190. return this.bottom > container.bottom;
  17191. }
  17192. };
  17193. // Find the percentage of the area that this box is overlapping with another
  17194. // box.
  17195. BoxPosition.prototype.intersectPercentage = function(b2) {
  17196. var x = Math.max(0, Math.min(this.right, b2.right) - Math.max(this.left, b2.left)),
  17197. y = Math.max(0, Math.min(this.bottom, b2.bottom) - Math.max(this.top, b2.top)),
  17198. intersectArea = x * y;
  17199. return intersectArea / (this.height * this.width);
  17200. };
  17201. // Convert the positions from this box to CSS compatible positions using
  17202. // the reference container's positions. This has to be done because this
  17203. // box's positions are in reference to the viewport origin, whereas, CSS
  17204. // values are in referecne to their respective edges.
  17205. BoxPosition.prototype.toCSSCompatValues = function(reference) {
  17206. return {
  17207. top: this.top - reference.top,
  17208. bottom: reference.bottom - this.bottom,
  17209. left: this.left - reference.left,
  17210. right: reference.right - this.right,
  17211. height: this.height,
  17212. width: this.width
  17213. };
  17214. };
  17215. // Get an object that represents the box's position without anything extra.
  17216. // Can pass a StyleBox, HTMLElement, or another BoxPositon.
  17217. BoxPosition.getSimpleBoxPosition = function(obj) {
  17218. var height = obj.div ? obj.div.offsetHeight : obj.tagName ? obj.offsetHeight : 0;
  17219. var width = obj.div ? obj.div.offsetWidth : obj.tagName ? obj.offsetWidth : 0;
  17220. var top = obj.div ? obj.div.offsetTop : obj.tagName ? obj.offsetTop : 0;
  17221. obj = obj.div ? obj.div.getBoundingClientRect() :
  17222. obj.tagName ? obj.getBoundingClientRect() : obj;
  17223. var ret = {
  17224. left: obj.left,
  17225. right: obj.right,
  17226. top: obj.top || top,
  17227. height: obj.height || height,
  17228. bottom: obj.bottom || (top + (obj.height || height)),
  17229. width: obj.width || width
  17230. };
  17231. return ret;
  17232. };
  17233. // Move a StyleBox to its specified, or next best, position. The containerBox
  17234. // is the box that contains the StyleBox, such as a div. boxPositions are
  17235. // a list of other boxes that the styleBox can't overlap with.
  17236. function moveBoxToLinePosition(window, styleBox, containerBox, boxPositions) {
  17237. // Find the best position for a cue box, b, on the video. The axis parameter
  17238. // is a list of axis, the order of which, it will move the box along. For example:
  17239. // Passing ["+x", "-x"] will move the box first along the x axis in the positive
  17240. // direction. If it doesn't find a good position for it there it will then move
  17241. // it along the x axis in the negative direction.
  17242. function findBestPosition(b, axis) {
  17243. var bestPosition,
  17244. specifiedPosition = new BoxPosition(b),
  17245. percentage = 1; // Highest possible so the first thing we get is better.
  17246. for (var i = 0; i < axis.length; i++) {
  17247. while (b.overlapsOppositeAxis(containerBox, axis[i]) ||
  17248. (b.within(containerBox) && b.overlapsAny(boxPositions))) {
  17249. b.move(axis[i]);
  17250. }
  17251. // We found a spot where we aren't overlapping anything. This is our
  17252. // best position.
  17253. if (b.within(containerBox)) {
  17254. return b;
  17255. }
  17256. var p = b.intersectPercentage(containerBox);
  17257. // If we're outside the container box less then we were on our last try
  17258. // then remember this position as the best position.
  17259. if (percentage > p) {
  17260. bestPosition = new BoxPosition(b);
  17261. percentage = p;
  17262. }
  17263. // Reset the box position to the specified position.
  17264. b = new BoxPosition(specifiedPosition);
  17265. }
  17266. return bestPosition || specifiedPosition;
  17267. }
  17268. var boxPosition = new BoxPosition(styleBox),
  17269. cue = styleBox.cue,
  17270. linePos = computeLinePos(cue),
  17271. axis = [];
  17272. // If we have a line number to align the cue to.
  17273. if (cue.snapToLines) {
  17274. var size;
  17275. switch (cue.vertical) {
  17276. case "":
  17277. axis = [ "+y", "-y" ];
  17278. size = "height";
  17279. break;
  17280. case "rl":
  17281. axis = [ "+x", "-x" ];
  17282. size = "width";
  17283. break;
  17284. case "lr":
  17285. axis = [ "-x", "+x" ];
  17286. size = "width";
  17287. break;
  17288. }
  17289. var step = boxPosition.lineHeight,
  17290. position = step * Math.round(linePos),
  17291. maxPosition = containerBox[size] + step,
  17292. initialAxis = axis[0];
  17293. // If the specified intial position is greater then the max position then
  17294. // clamp the box to the amount of steps it would take for the box to
  17295. // reach the max position.
  17296. if (Math.abs(position) > maxPosition) {
  17297. position = position < 0 ? -1 : 1;
  17298. position *= Math.ceil(maxPosition / step) * step;
  17299. }
  17300. // If computed line position returns negative then line numbers are
  17301. // relative to the bottom of the video instead of the top. Therefore, we
  17302. // need to increase our initial position by the length or width of the
  17303. // video, depending on the writing direction, and reverse our axis directions.
  17304. if (linePos < 0) {
  17305. position += cue.vertical === "" ? containerBox.height : containerBox.width;
  17306. axis = axis.reverse();
  17307. }
  17308. // Move the box to the specified position. This may not be its best
  17309. // position.
  17310. boxPosition.move(initialAxis, position);
  17311. } else {
  17312. // If we have a percentage line value for the cue.
  17313. var calculatedPercentage = (boxPosition.lineHeight / containerBox.height) * 100;
  17314. switch (cue.lineAlign) {
  17315. case "middle":
  17316. linePos -= (calculatedPercentage / 2);
  17317. break;
  17318. case "end":
  17319. linePos -= calculatedPercentage;
  17320. break;
  17321. }
  17322. // Apply initial line position to the cue box.
  17323. switch (cue.vertical) {
  17324. case "":
  17325. styleBox.applyStyles({
  17326. top: styleBox.formatStyle(linePos, "%")
  17327. });
  17328. break;
  17329. case "rl":
  17330. styleBox.applyStyles({
  17331. left: styleBox.formatStyle(linePos, "%")
  17332. });
  17333. break;
  17334. case "lr":
  17335. styleBox.applyStyles({
  17336. right: styleBox.formatStyle(linePos, "%")
  17337. });
  17338. break;
  17339. }
  17340. axis = [ "+y", "-x", "+x", "-y" ];
  17341. // Get the box position again after we've applied the specified positioning
  17342. // to it.
  17343. boxPosition = new BoxPosition(styleBox);
  17344. }
  17345. var bestPosition = findBestPosition(boxPosition, axis);
  17346. styleBox.move(bestPosition.toCSSCompatValues(containerBox));
  17347. }
  17348. function WebVTT() {
  17349. // Nothing
  17350. }
  17351. // Helper to allow strings to be decoded instead of the default binary utf8 data.
  17352. WebVTT.StringDecoder = function() {
  17353. return {
  17354. decode: function(data) {
  17355. if (!data) {
  17356. return "";
  17357. }
  17358. if (typeof data !== "string") {
  17359. throw new Error("Error - expected string data.");
  17360. }
  17361. return decodeURIComponent(encodeURIComponent(data));
  17362. }
  17363. };
  17364. };
  17365. WebVTT.convertCueToDOMTree = function(window, cuetext) {
  17366. if (!window || !cuetext) {
  17367. return null;
  17368. }
  17369. return parseContent(window, cuetext);
  17370. };
  17371. var FONT_SIZE_PERCENT = 0.05;
  17372. var FONT_STYLE = "sans-serif";
  17373. var CUE_BACKGROUND_PADDING = "1.5%";
  17374. // Runs the processing model over the cues and regions passed to it.
  17375. // @param overlay A block level element (usually a div) that the computed cues
  17376. // and regions will be placed into.
  17377. WebVTT.processCues = function(window, cues, overlay) {
  17378. if (!window || !cues || !overlay) {
  17379. return null;
  17380. }
  17381. // Remove all previous children.
  17382. while (overlay.firstChild) {
  17383. overlay.removeChild(overlay.firstChild);
  17384. }
  17385. var paddedOverlay = window.document.createElement("div");
  17386. paddedOverlay.style.position = "absolute";
  17387. paddedOverlay.style.left = "0";
  17388. paddedOverlay.style.right = "0";
  17389. paddedOverlay.style.top = "0";
  17390. paddedOverlay.style.bottom = "0";
  17391. paddedOverlay.style.margin = CUE_BACKGROUND_PADDING;
  17392. overlay.appendChild(paddedOverlay);
  17393. // Determine if we need to compute the display states of the cues. This could
  17394. // be the case if a cue's state has been changed since the last computation or
  17395. // if it has not been computed yet.
  17396. function shouldCompute(cues) {
  17397. for (var i = 0; i < cues.length; i++) {
  17398. if (cues[i].hasBeenReset || !cues[i].displayState) {
  17399. return true;
  17400. }
  17401. }
  17402. return false;
  17403. }
  17404. // We don't need to recompute the cues' display states. Just reuse them.
  17405. if (!shouldCompute(cues)) {
  17406. for (var i = 0; i < cues.length; i++) {
  17407. paddedOverlay.appendChild(cues[i].displayState);
  17408. }
  17409. return;
  17410. }
  17411. var boxPositions = [],
  17412. containerBox = BoxPosition.getSimpleBoxPosition(paddedOverlay),
  17413. fontSize = Math.round(containerBox.height * FONT_SIZE_PERCENT * 100) / 100;
  17414. var styleOptions = {
  17415. font: fontSize + "px " + FONT_STYLE
  17416. };
  17417. (function() {
  17418. var styleBox, cue;
  17419. for (var i = 0; i < cues.length; i++) {
  17420. cue = cues[i];
  17421. // Compute the intial position and styles of the cue div.
  17422. styleBox = new CueStyleBox(window, cue, styleOptions);
  17423. paddedOverlay.appendChild(styleBox.div);
  17424. // Move the cue div to it's correct line position.
  17425. moveBoxToLinePosition(window, styleBox, containerBox, boxPositions);
  17426. // Remember the computed div so that we don't have to recompute it later
  17427. // if we don't have too.
  17428. cue.displayState = styleBox.div;
  17429. boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox));
  17430. }
  17431. })();
  17432. };
  17433. WebVTT.Parser = function(window, vttjs, decoder) {
  17434. if (!decoder) {
  17435. decoder = vttjs;
  17436. vttjs = {};
  17437. }
  17438. if (!vttjs) {
  17439. vttjs = {};
  17440. }
  17441. this.window = window;
  17442. this.vttjs = vttjs;
  17443. this.state = "INITIAL";
  17444. this.buffer = "";
  17445. this.decoder = decoder || new TextDecoder("utf8");
  17446. this.regionList = [];
  17447. };
  17448. WebVTT.Parser.prototype = {
  17449. // If the error is a ParsingError then report it to the consumer if
  17450. // possible. If it's not a ParsingError then throw it like normal.
  17451. reportOrThrowError: function(e) {
  17452. if (e instanceof ParsingError) {
  17453. this.onparsingerror && this.onparsingerror(e);
  17454. } else {
  17455. throw e;
  17456. }
  17457. },
  17458. parse: function (data) {
  17459. var self = this;
  17460. // If there is no data then we won't decode it, but will just try to parse
  17461. // whatever is in buffer already. This may occur in circumstances, for
  17462. // example when flush() is called.
  17463. if (data) {
  17464. // Try to decode the data that we received.
  17465. self.buffer += self.decoder.decode(data, {stream: true});
  17466. }
  17467. function collectNextLine() {
  17468. var buffer = self.buffer;
  17469. var pos = 0;
  17470. while (pos < buffer.length && buffer[pos] !== '\r' && buffer[pos] !== '\n') {
  17471. ++pos;
  17472. }
  17473. var line = buffer.substr(0, pos);
  17474. // Advance the buffer early in case we fail below.
  17475. if (buffer[pos] === '\r') {
  17476. ++pos;
  17477. }
  17478. if (buffer[pos] === '\n') {
  17479. ++pos;
  17480. }
  17481. self.buffer = buffer.substr(pos);
  17482. return line;
  17483. }
  17484. // 3.4 WebVTT region and WebVTT region settings syntax
  17485. function parseRegion(input) {
  17486. var settings = new Settings();
  17487. parseOptions(input, function (k, v) {
  17488. switch (k) {
  17489. case "id":
  17490. settings.set(k, v);
  17491. break;
  17492. case "width":
  17493. settings.percent(k, v);
  17494. break;
  17495. case "lines":
  17496. settings.integer(k, v);
  17497. break;
  17498. case "regionanchor":
  17499. case "viewportanchor":
  17500. var xy = v.split(',');
  17501. if (xy.length !== 2) {
  17502. break;
  17503. }
  17504. // We have to make sure both x and y parse, so use a temporary
  17505. // settings object here.
  17506. var anchor = new Settings();
  17507. anchor.percent("x", xy[0]);
  17508. anchor.percent("y", xy[1]);
  17509. if (!anchor.has("x") || !anchor.has("y")) {
  17510. break;
  17511. }
  17512. settings.set(k + "X", anchor.get("x"));
  17513. settings.set(k + "Y", anchor.get("y"));
  17514. break;
  17515. case "scroll":
  17516. settings.alt(k, v, ["up"]);
  17517. break;
  17518. }
  17519. }, /=/, /\s/);
  17520. // Create the region, using default values for any values that were not
  17521. // specified.
  17522. if (settings.has("id")) {
  17523. var region = new (self.vttjs.VTTRegion || self.window.VTTRegion)();
  17524. region.width = settings.get("width", 100);
  17525. region.lines = settings.get("lines", 3);
  17526. region.regionAnchorX = settings.get("regionanchorX", 0);
  17527. region.regionAnchorY = settings.get("regionanchorY", 100);
  17528. region.viewportAnchorX = settings.get("viewportanchorX", 0);
  17529. region.viewportAnchorY = settings.get("viewportanchorY", 100);
  17530. region.scroll = settings.get("scroll", "");
  17531. // Register the region.
  17532. self.onregion && self.onregion(region);
  17533. // Remember the VTTRegion for later in case we parse any VTTCues that
  17534. // reference it.
  17535. self.regionList.push({
  17536. id: settings.get("id"),
  17537. region: region
  17538. });
  17539. }
  17540. }
  17541. // 3.2 WebVTT metadata header syntax
  17542. function parseHeader(input) {
  17543. parseOptions(input, function (k, v) {
  17544. switch (k) {
  17545. case "Region":
  17546. // 3.3 WebVTT region metadata header syntax
  17547. parseRegion(v);
  17548. break;
  17549. }
  17550. }, /:/);
  17551. }
  17552. // 5.1 WebVTT file parsing.
  17553. try {
  17554. var line;
  17555. if (self.state === "INITIAL") {
  17556. // We can't start parsing until we have the first line.
  17557. if (!/\r\n|\n/.test(self.buffer)) {
  17558. return this;
  17559. }
  17560. line = collectNextLine();
  17561. var m = line.match(/^WEBVTT([ \t].*)?$/);
  17562. if (!m || !m[0]) {
  17563. throw new ParsingError(ParsingError.Errors.BadSignature);
  17564. }
  17565. self.state = "HEADER";
  17566. }
  17567. var alreadyCollectedLine = false;
  17568. while (self.buffer) {
  17569. // We can't parse a line until we have the full line.
  17570. if (!/\r\n|\n/.test(self.buffer)) {
  17571. return this;
  17572. }
  17573. if (!alreadyCollectedLine) {
  17574. line = collectNextLine();
  17575. } else {
  17576. alreadyCollectedLine = false;
  17577. }
  17578. switch (self.state) {
  17579. case "HEADER":
  17580. // 13-18 - Allow a header (metadata) under the WEBVTT line.
  17581. if (/:/.test(line)) {
  17582. parseHeader(line);
  17583. } else if (!line) {
  17584. // An empty line terminates the header and starts the body (cues).
  17585. self.state = "ID";
  17586. }
  17587. continue;
  17588. case "NOTE":
  17589. // Ignore NOTE blocks.
  17590. if (!line) {
  17591. self.state = "ID";
  17592. }
  17593. continue;
  17594. case "ID":
  17595. // Check for the start of NOTE blocks.
  17596. if (/^NOTE($|[ \t])/.test(line)) {
  17597. self.state = "NOTE";
  17598. break;
  17599. }
  17600. // 19-29 - Allow any number of line terminators, then initialize new cue values.
  17601. if (!line) {
  17602. continue;
  17603. }
  17604. self.cue = new (self.vttjs.VTTCue || self.window.VTTCue)(0, 0, "");
  17605. self.state = "CUE";
  17606. // 30-39 - Check if self line contains an optional identifier or timing data.
  17607. if (line.indexOf("-->") === -1) {
  17608. self.cue.id = line;
  17609. continue;
  17610. }
  17611. // Process line as start of a cue.
  17612. /*falls through*/
  17613. case "CUE":
  17614. // 40 - Collect cue timings and settings.
  17615. try {
  17616. parseCue(line, self.cue, self.regionList);
  17617. } catch (e) {
  17618. self.reportOrThrowError(e);
  17619. // In case of an error ignore rest of the cue.
  17620. self.cue = null;
  17621. self.state = "BADCUE";
  17622. continue;
  17623. }
  17624. self.state = "CUETEXT";
  17625. continue;
  17626. case "CUETEXT":
  17627. var hasSubstring = line.indexOf("-->") !== -1;
  17628. // 34 - If we have an empty line then report the cue.
  17629. // 35 - If we have the special substring '-->' then report the cue,
  17630. // but do not collect the line as we need to process the current
  17631. // one as a new cue.
  17632. if (!line || hasSubstring && (alreadyCollectedLine = true)) {
  17633. // We are done parsing self cue.
  17634. self.oncue && self.oncue(self.cue);
  17635. self.cue = null;
  17636. self.state = "ID";
  17637. continue;
  17638. }
  17639. if (self.cue.text) {
  17640. self.cue.text += "\n";
  17641. }
  17642. self.cue.text += line;
  17643. continue;
  17644. case "BADCUE": // BADCUE
  17645. // 54-62 - Collect and discard the remaining cue.
  17646. if (!line) {
  17647. self.state = "ID";
  17648. }
  17649. continue;
  17650. }
  17651. }
  17652. } catch (e) {
  17653. self.reportOrThrowError(e);
  17654. // If we are currently parsing a cue, report what we have.
  17655. if (self.state === "CUETEXT" && self.cue && self.oncue) {
  17656. self.oncue(self.cue);
  17657. }
  17658. self.cue = null;
  17659. // Enter BADWEBVTT state if header was not parsed correctly otherwise
  17660. // another exception occurred so enter BADCUE state.
  17661. self.state = self.state === "INITIAL" ? "BADWEBVTT" : "BADCUE";
  17662. }
  17663. return this;
  17664. },
  17665. flush: function () {
  17666. var self = this;
  17667. try {
  17668. // Finish decoding the stream.
  17669. self.buffer += self.decoder.decode();
  17670. // Synthesize the end of the current cue or region.
  17671. if (self.cue || self.state === "HEADER") {
  17672. self.buffer += "\n\n";
  17673. self.parse();
  17674. }
  17675. // If we've flushed, parsed, and we're still on the INITIAL state then
  17676. // that means we don't have enough of the stream to parse the first
  17677. // line.
  17678. if (self.state === "INITIAL") {
  17679. throw new ParsingError(ParsingError.Errors.BadSignature);
  17680. }
  17681. } catch(e) {
  17682. self.reportOrThrowError(e);
  17683. }
  17684. self.onflush && self.onflush();
  17685. return this;
  17686. }
  17687. };
  17688. global.WebVTT = WebVTT;
  17689. }(this, (this.vttjs || {})));
  17690. !function(){!function(a){var b=a&&a.videojs;if(b){b.CDN_VERSION="5.5.3";var c="https:"===a.location.protocol?"https://":"http://";b.options.flash.swf=c+"vjs.zencdn.net/swf/5.0.1/video-js.swf"}}(window),function(a,b,c,d,e,f,g){b&&b.HELP_IMPROVE_VIDEOJS!==!1&&(e.random()>.01||(f=b.location,g=b.videojs||{},a.src="//www.google-analytics.com/__utm.gif?utmwv=5.4.2&utmac=UA-16505296-3&utmn=1&utmhn="+d(f.hostname)+"&utmsr="+b.screen.availWidth+"x"+b.screen.availHeight+"&utmul="+(c.language||c.userLanguage||"").toLowerCase()+"&utmr="+d(f.href)+"&utmp="+d(f.hostname+f.pathname)+"&utmcc=__utma%3D1."+e.floor(1e10*e.random())+".1.1.1.1%3B&utme=8(vjsv*cdnv)9("+g.VERSION+"*"+g.CDN_VERSION+")"))}(new Image,window,navigator,encodeURIComponent,Math)}();