index.f15b595a.js 178 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693
  1. var St = Object.defineProperty,
  2. Et = Object.defineProperties
  3. var Pt = Object.getOwnPropertyDescriptors
  4. var he = Object.getOwnPropertySymbols
  5. var De = Object.prototype.hasOwnProperty,
  6. He = Object.prototype.propertyIsEnumerable
  7. var Ve = (e, i, t) =>
  8. i in e
  9. ? St(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t })
  10. : (e[i] = t),
  11. q = (e, i) => {
  12. for (var t in i || (i = {})) De.call(i, t) && Ve(e, t, i[t])
  13. if (he) for (var t of he(i)) He.call(i, t) && Ve(e, t, i[t])
  14. return e
  15. },
  16. ie = (e, i) => Et(e, Pt(i))
  17. var Fe = (e, i) => {
  18. var t = {}
  19. for (var s in e) De.call(e, s) && i.indexOf(s) < 0 && (t[s] = e[s])
  20. if (e != null && he)
  21. for (var s of he(e)) i.indexOf(s) < 0 && He.call(e, s) && (t[s] = e[s])
  22. return t
  23. }
  24. import {
  25. d as Nt,
  26. a as j,
  27. L as Mt,
  28. j as Te,
  29. F as qe,
  30. K as Ue,
  31. B as xt,
  32. T as It
  33. } from './vendor.3506a68e.js'
  34. import { l as Lt, b as Ot, p as $t, s as _t } from './index.9e4b607f.js'
  35. const Rt = '_video_1vz16_1',
  36. jt = '_loadingVideo_1vz16_35',
  37. Dt = '_playOver_1vz16_44',
  38. Ht = '_tips_1vz16_52',
  39. Vt = '_btn_1vz16_56',
  40. Ft = '_freeTxt_1vz16_59',
  41. qt = '_freeRate_1vz16_65'
  42. var U = {
  43. 'video-container': '_video-container_1vz16_1',
  44. video: Rt,
  45. loadingVideo: jt,
  46. playOver: Dt,
  47. tips: Ht,
  48. btn: Vt,
  49. freeTxt: Ft,
  50. freeRate: qt
  51. }
  52. function m(e, i, t) {
  53. return (
  54. i in e
  55. ? Object.defineProperty(e, i, {
  56. value: t,
  57. enumerable: !0,
  58. configurable: !0,
  59. writable: !0
  60. })
  61. : (e[i] = t),
  62. e
  63. )
  64. }
  65. function Ut(e, i) {
  66. if (!(e instanceof i))
  67. throw new TypeError('Cannot call a class as a function')
  68. }
  69. function Be(e, i) {
  70. for (var t = 0; t < i.length; t++) {
  71. var s = i[t]
  72. ;(s.enumerable = s.enumerable || !1),
  73. (s.configurable = !0),
  74. 'value' in s && (s.writable = !0),
  75. Object.defineProperty(e, s.key, s)
  76. }
  77. }
  78. function Bt(e, i, t) {
  79. return i && Be(e.prototype, i), t && Be(e, t), e
  80. }
  81. function zt(e, i, t) {
  82. return (
  83. i in e
  84. ? Object.defineProperty(e, i, {
  85. value: t,
  86. enumerable: !0,
  87. configurable: !0,
  88. writable: !0
  89. })
  90. : (e[i] = t),
  91. e
  92. )
  93. }
  94. function ze(e, i) {
  95. var t = Object.keys(e)
  96. if (Object.getOwnPropertySymbols) {
  97. var s = Object.getOwnPropertySymbols(e)
  98. i &&
  99. (s = s.filter(function (n) {
  100. return Object.getOwnPropertyDescriptor(e, n).enumerable
  101. })),
  102. t.push.apply(t, s)
  103. }
  104. return t
  105. }
  106. function We(e) {
  107. for (var i = 1; i < arguments.length; i++) {
  108. var t = arguments[i] != null ? arguments[i] : {}
  109. i % 2
  110. ? ze(Object(t), !0).forEach(function (s) {
  111. zt(e, s, t[s])
  112. })
  113. : Object.getOwnPropertyDescriptors
  114. ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
  115. : ze(Object(t)).forEach(function (s) {
  116. Object.defineProperty(e, s, Object.getOwnPropertyDescriptor(t, s))
  117. })
  118. }
  119. return e
  120. }
  121. var Ke = { addCSS: !0, thumbWidth: 15, watch: !0 }
  122. function Wt(e, i) {
  123. return function () {
  124. return Array.from(document.querySelectorAll(i)).includes(this)
  125. }.call(e, i)
  126. }
  127. function Kt(e, i) {
  128. if (e && i) {
  129. var t = new Event(i, { bubbles: !0 })
  130. e.dispatchEvent(t)
  131. }
  132. }
  133. var se = function (e) {
  134. return e != null ? e.constructor : null
  135. },
  136. ke = function (e, i) {
  137. return !!(e && i && e instanceof i)
  138. },
  139. Ye = function (e) {
  140. return e == null
  141. },
  142. Je = function (e) {
  143. return se(e) === Object
  144. },
  145. Yt = function (e) {
  146. return se(e) === Number && !Number.isNaN(e)
  147. },
  148. Qe = function (e) {
  149. return se(e) === String
  150. },
  151. Jt = function (e) {
  152. return se(e) === Boolean
  153. },
  154. Qt = function (e) {
  155. return se(e) === Function
  156. },
  157. Xe = function (e) {
  158. return Array.isArray(e)
  159. },
  160. Ge = function (e) {
  161. return ke(e, NodeList)
  162. },
  163. Xt = function (e) {
  164. return ke(e, Element)
  165. },
  166. Gt = function (e) {
  167. return ke(e, Event)
  168. },
  169. Zt = function (e) {
  170. return (
  171. Ye(e) ||
  172. ((Qe(e) || Xe(e) || Ge(e)) && !e.length) ||
  173. (Je(e) && !Object.keys(e).length)
  174. )
  175. },
  176. R = {
  177. nullOrUndefined: Ye,
  178. object: Je,
  179. number: Yt,
  180. string: Qe,
  181. boolean: Jt,
  182. function: Qt,
  183. array: Xe,
  184. nodeList: Ge,
  185. element: Xt,
  186. event: Gt,
  187. empty: Zt
  188. }
  189. function ei(e) {
  190. var i = ''.concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/)
  191. return i ? Math.max(0, (i[1] ? i[1].length : 0) - (i[2] ? +i[2] : 0)) : 0
  192. }
  193. function ti(e, i) {
  194. if (1 > i) {
  195. var t = ei(i)
  196. return parseFloat(e.toFixed(t))
  197. }
  198. return Math.round(e / i) * i
  199. }
  200. var ii = (function () {
  201. function e(i, t) {
  202. Ut(this, e),
  203. R.element(i)
  204. ? (this.element = i)
  205. : R.string(i) && (this.element = document.querySelector(i)),
  206. R.element(this.element) &&
  207. R.empty(this.element.rangeTouch) &&
  208. ((this.config = We({}, Ke, {}, t)), this.init())
  209. }
  210. return (
  211. Bt(
  212. e,
  213. [
  214. {
  215. key: 'init',
  216. value: function () {
  217. e.enabled &&
  218. (this.config.addCSS &&
  219. ((this.element.style.userSelect = 'none'),
  220. (this.element.style.webKitUserSelect = 'none'),
  221. (this.element.style.touchAction = 'manipulation')),
  222. this.listeners(!0),
  223. (this.element.rangeTouch = this))
  224. }
  225. },
  226. {
  227. key: 'destroy',
  228. value: function () {
  229. e.enabled &&
  230. (this.config.addCSS &&
  231. ((this.element.style.userSelect = ''),
  232. (this.element.style.webKitUserSelect = ''),
  233. (this.element.style.touchAction = '')),
  234. this.listeners(!1),
  235. (this.element.rangeTouch = null))
  236. }
  237. },
  238. {
  239. key: 'listeners',
  240. value: function (i) {
  241. var t = this,
  242. s = i ? 'addEventListener' : 'removeEventListener'
  243. ;['touchstart', 'touchmove', 'touchend'].forEach(function (n) {
  244. t.element[s](
  245. n,
  246. function (a) {
  247. return t.set(a)
  248. },
  249. !1
  250. )
  251. })
  252. }
  253. },
  254. {
  255. key: 'get',
  256. value: function (i) {
  257. if (!e.enabled || !R.event(i)) return null
  258. var t,
  259. s = i.target,
  260. n = i.changedTouches[0],
  261. a = parseFloat(s.getAttribute('min')) || 0,
  262. r = parseFloat(s.getAttribute('max')) || 100,
  263. o = parseFloat(s.getAttribute('step')) || 1,
  264. c = s.getBoundingClientRect(),
  265. u = ((100 / c.width) * (this.config.thumbWidth / 2)) / 100
  266. return (
  267. 0 > (t = (100 / c.width) * (n.clientX - c.left))
  268. ? (t = 0)
  269. : 100 < t && (t = 100),
  270. 50 > t
  271. ? (t -= (100 - 2 * t) * u)
  272. : 50 < t && (t += 2 * (t - 50) * u),
  273. a + ti((t / 100) * (r - a), o)
  274. )
  275. }
  276. },
  277. {
  278. key: 'set',
  279. value: function (i) {
  280. e.enabled &&
  281. R.event(i) &&
  282. !i.target.disabled &&
  283. (i.preventDefault(),
  284. (i.target.value = this.get(i)),
  285. Kt(i.target, i.type === 'touchend' ? 'change' : 'input'))
  286. }
  287. }
  288. ],
  289. [
  290. {
  291. key: 'setup',
  292. value: function (i) {
  293. var t =
  294. 1 < arguments.length && arguments[1] !== void 0
  295. ? arguments[1]
  296. : {},
  297. s = null
  298. if (
  299. (R.empty(i) || R.string(i)
  300. ? (s = Array.from(
  301. document.querySelectorAll(
  302. R.string(i) ? i : 'input[type="range"]'
  303. )
  304. ))
  305. : R.element(i)
  306. ? (s = [i])
  307. : R.nodeList(i)
  308. ? (s = Array.from(i))
  309. : R.array(i) && (s = i.filter(R.element)),
  310. R.empty(s))
  311. )
  312. return null
  313. var n = We({}, Ke, {}, t)
  314. if (R.string(i) && n.watch) {
  315. var a = new MutationObserver(function (r) {
  316. Array.from(r).forEach(function (o) {
  317. Array.from(o.addedNodes).forEach(function (c) {
  318. R.element(c) && Wt(c, i) && new e(c, n)
  319. })
  320. })
  321. })
  322. a.observe(document.body, { childList: !0, subtree: !0 })
  323. }
  324. return s.map(function (r) {
  325. return new e(r, t)
  326. })
  327. }
  328. },
  329. {
  330. key: 'enabled',
  331. get: function () {
  332. return 'ontouchstart' in document.documentElement
  333. }
  334. }
  335. ]
  336. ),
  337. e
  338. )
  339. })()
  340. const G = e => (e != null ? e.constructor : null),
  341. B = (e, i) => Boolean(e && i && e instanceof i),
  342. Ae = e => e == null,
  343. Ze = e => G(e) === Object,
  344. si = e => G(e) === Number && !Number.isNaN(e),
  345. de = e => G(e) === String,
  346. ni = e => G(e) === Boolean,
  347. et = e => G(e) === Function,
  348. tt = e => Array.isArray(e),
  349. ai = e => B(e, WeakMap),
  350. it = e => B(e, NodeList),
  351. li = e => G(e) === Text,
  352. ri = e => B(e, Event),
  353. oi = e => B(e, KeyboardEvent),
  354. ci = e => B(e, window.TextTrackCue) || B(e, window.VTTCue),
  355. ui = e => B(e, TextTrack) || (!Ae(e) && de(e.kind)),
  356. hi = e => B(e, Promise) && et(e.then),
  357. di = e =>
  358. e !== null &&
  359. typeof e == 'object' &&
  360. e.nodeType === 1 &&
  361. typeof e.style == 'object' &&
  362. typeof e.ownerDocument == 'object',
  363. st = e =>
  364. Ae(e) ||
  365. ((de(e) || tt(e) || it(e)) && !e.length) ||
  366. (Ze(e) && !Object.keys(e).length),
  367. mi = e => {
  368. if (B(e, window.URL)) return !0
  369. if (!de(e)) return !1
  370. let i = e
  371. ;(e.startsWith('http://') && e.startsWith('https://')) ||
  372. (i = `http://${e}`)
  373. try {
  374. return !st(new URL(i).hostname)
  375. } catch {
  376. return !1
  377. }
  378. }
  379. var l = {
  380. nullOrUndefined: Ae,
  381. object: Ze,
  382. number: si,
  383. string: de,
  384. boolean: ni,
  385. function: et,
  386. array: tt,
  387. weakMap: ai,
  388. nodeList: it,
  389. element: di,
  390. textNode: li,
  391. event: ri,
  392. keyboardEvent: oi,
  393. cue: ci,
  394. track: ui,
  395. promise: hi,
  396. url: mi,
  397. empty: st
  398. }
  399. const Ce = (() => {
  400. const e = document.createElement('span'),
  401. i = {
  402. WebkitTransition: 'webkitTransitionEnd',
  403. MozTransition: 'transitionend',
  404. OTransition: 'oTransitionEnd otransitionend',
  405. transition: 'transitionend'
  406. },
  407. t = Object.keys(i).find(s => e.style[s] !== void 0)
  408. return !!l.string(t) && i[t]
  409. })()
  410. function nt(e, i) {
  411. setTimeout(() => {
  412. try {
  413. ;(e.hidden = !0), e.offsetHeight, (e.hidden = !1)
  414. } catch {}
  415. }, i)
  416. }
  417. const _ = {
  418. isIE: Boolean(window.document.documentMode),
  419. isEdge: window.navigator.userAgent.includes('Edge'),
  420. isWebkit:
  421. 'WebkitAppearance' in document.documentElement.style &&
  422. !/Edge/.test(navigator.userAgent),
  423. isIPhone: /(iPhone|iPod)/gi.test(navigator.platform),
  424. isIos:
  425. (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) ||
  426. /(iPad|iPhone|iPod)/gi.test(navigator.platform)
  427. }
  428. function pi(e) {
  429. return JSON.parse(JSON.stringify(e))
  430. }
  431. function at(e, i) {
  432. return i.split('.').reduce((t, s) => t && t[s], e)
  433. }
  434. function I(e = {}, ...i) {
  435. if (!i.length) return e
  436. const t = i.shift()
  437. return l.object(t)
  438. ? (Object.keys(t).forEach(s => {
  439. l.object(t[s])
  440. ? (Object.keys(e).includes(s) || Object.assign(e, { [s]: {} }),
  441. I(e[s], t[s]))
  442. : Object.assign(e, { [s]: t[s] })
  443. }),
  444. I(e, ...i))
  445. : e
  446. }
  447. function lt(e, i) {
  448. const t = e.length ? e : [e]
  449. Array.from(t)
  450. .reverse()
  451. .forEach((s, n) => {
  452. const a = n > 0 ? i.cloneNode(!0) : i,
  453. r = s.parentNode,
  454. o = s.nextSibling
  455. a.appendChild(s), o ? r.insertBefore(a, o) : r.appendChild(a)
  456. })
  457. }
  458. function Se(e, i) {
  459. l.element(e) &&
  460. !l.empty(i) &&
  461. Object.entries(i)
  462. .filter(([, t]) => !l.nullOrUndefined(t))
  463. .forEach(([t, s]) => e.setAttribute(t, s))
  464. }
  465. function y(e, i, t) {
  466. const s = document.createElement(e)
  467. return l.object(i) && Se(s, i), l.string(t) && (s.innerText = t), s
  468. }
  469. function gi(e, i) {
  470. l.element(e) && l.element(i) && i.parentNode.insertBefore(e, i.nextSibling)
  471. }
  472. function rt(e, i, t, s) {
  473. l.element(i) && i.appendChild(y(e, t, s))
  474. }
  475. function z(e) {
  476. l.nodeList(e) || l.array(e)
  477. ? Array.from(e).forEach(z)
  478. : l.element(e) && l.element(e.parentNode) && e.parentNode.removeChild(e)
  479. }
  480. function me(e) {
  481. if (!l.element(e)) return
  482. let { length: i } = e.childNodes
  483. for (; i > 0; ) e.removeChild(e.lastChild), (i -= 1)
  484. }
  485. function pe(e, i) {
  486. return l.element(i) && l.element(i.parentNode) && l.element(e)
  487. ? (i.parentNode.replaceChild(e, i), e)
  488. : null
  489. }
  490. function H(e, i) {
  491. if (!l.string(e) || l.empty(e)) return {}
  492. const t = {},
  493. s = I({}, i)
  494. return (
  495. e.split(',').forEach(n => {
  496. const a = n.trim(),
  497. r = a.replace('.', ''),
  498. o = a.replace(/[[\]]/g, '').split('='),
  499. [c] = o,
  500. u = o.length > 1 ? o[1].replace(/["']/g, '') : ''
  501. switch (a.charAt(0)) {
  502. case '.':
  503. l.string(s.class) ? (t.class = `${s.class} ${r}`) : (t.class = r)
  504. break
  505. case '#':
  506. t.id = a.replace('#', '')
  507. break
  508. case '[':
  509. t[c] = u
  510. }
  511. }),
  512. I(s, t)
  513. )
  514. }
  515. function J(e, i) {
  516. if (!l.element(e)) return
  517. let t = i
  518. l.boolean(t) || (t = !e.hidden), (e.hidden = t)
  519. }
  520. function A(e, i, t) {
  521. if (l.nodeList(e)) return Array.from(e).map(s => A(s, i, t))
  522. if (l.element(e)) {
  523. let s = 'toggle'
  524. return (
  525. t !== void 0 && (s = t ? 'add' : 'remove'),
  526. e.classList[s](i),
  527. e.classList.contains(i)
  528. )
  529. }
  530. return !1
  531. }
  532. function ge(e, i) {
  533. return l.element(e) && e.classList.contains(i)
  534. }
  535. function Q(e, i) {
  536. const { prototype: t } = Element
  537. return (
  538. t.matches ||
  539. t.webkitMatchesSelector ||
  540. t.mozMatchesSelector ||
  541. t.msMatchesSelector ||
  542. function () {
  543. return Array.from(document.querySelectorAll(i)).includes(this)
  544. }
  545. ).call(e, i)
  546. }
  547. function fi(e, i) {
  548. const { prototype: t } = Element
  549. return (
  550. t.closest ||
  551. function () {
  552. let s = this
  553. do {
  554. if (Q.matches(s, i)) return s
  555. s = s.parentElement || s.parentNode
  556. } while (s !== null && s.nodeType === 1)
  557. return null
  558. }
  559. ).call(e, i)
  560. }
  561. function Z(e) {
  562. return this.elements.container.querySelectorAll(e)
  563. }
  564. function O(e) {
  565. return this.elements.container.querySelector(e)
  566. }
  567. function Ee(e = null, i = !1) {
  568. l.element(e) &&
  569. (e.focus({ preventScroll: !0 }), i && A(e, this.config.classNames.tabFocus))
  570. }
  571. const ot = {
  572. 'audio/ogg': 'vorbis',
  573. 'audio/wav': '1',
  574. 'video/webm': 'vp8, vorbis',
  575. 'video/mp4': 'avc1.42E01E, mp4a.40.2',
  576. 'video/ogg': 'theora'
  577. },
  578. x = {
  579. audio: 'canPlayType' in document.createElement('audio'),
  580. video: 'canPlayType' in document.createElement('video'),
  581. check(e, i, t) {
  582. const s = _.isIPhone && t && x.playsinline,
  583. n = x[e] || i !== 'html5'
  584. return {
  585. api: n,
  586. ui: n && x.rangeInput && (e !== 'video' || !_.isIPhone || s)
  587. }
  588. },
  589. pip: !(
  590. _.isIPhone ||
  591. (!l.function(y('video').webkitSetPresentationMode) &&
  592. (!document.pictureInPictureEnabled ||
  593. y('video').disablePictureInPicture))
  594. ),
  595. airplay: l.function(window.WebKitPlaybackTargetAvailabilityEvent),
  596. playsinline: 'playsInline' in document.createElement('video'),
  597. mime(e) {
  598. if (l.empty(e)) return !1
  599. const [i] = e.split('/')
  600. let t = e
  601. if (!this.isHTML5 || i !== this.type) return !1
  602. Object.keys(ot).includes(t) && (t += `; codecs="${ot[e]}"`)
  603. try {
  604. return Boolean(t && this.media.canPlayType(t).replace(/no/, ''))
  605. } catch {
  606. return !1
  607. }
  608. },
  609. textTracks: 'textTracks' in document.createElement('video'),
  610. rangeInput: (() => {
  611. const e = document.createElement('input')
  612. return (e.type = 'range'), e.type === 'range'
  613. })(),
  614. touch: 'ontouchstart' in document.documentElement,
  615. transitions: Ce !== !1,
  616. reducedMotion:
  617. 'matchMedia' in window &&
  618. window.matchMedia('(prefers-reduced-motion)').matches
  619. },
  620. yi = (() => {
  621. let e = !1
  622. try {
  623. const i = Object.defineProperty({}, 'passive', {
  624. get: () => ((e = !0), null)
  625. })
  626. window.addEventListener('test', null, i),
  627. window.removeEventListener('test', null, i)
  628. } catch {}
  629. return e
  630. })()
  631. function ee(e, i, t, s = !1, n = !0, a = !1) {
  632. if (!e || !('addEventListener' in e) || l.empty(i) || !l.function(t)) return
  633. const r = i.split(' ')
  634. let o = a
  635. yi && (o = { passive: n, capture: a }),
  636. r.forEach(c => {
  637. this &&
  638. this.eventListeners &&
  639. s &&
  640. this.eventListeners.push({
  641. element: e,
  642. type: c,
  643. callback: t,
  644. options: o
  645. }),
  646. e[s ? 'addEventListener' : 'removeEventListener'](c, t, o)
  647. })
  648. }
  649. function C(e, i = '', t, s = !0, n = !1) {
  650. ee.call(this, e, i, t, !0, s, n)
  651. }
  652. function fe(e, i = '', t, s = !0, n = !1) {
  653. ee.call(this, e, i, t, !1, s, n)
  654. }
  655. function Pe(e, i = '', t, s = !0, n = !1) {
  656. const a = (...r) => {
  657. fe(e, i, a, s, n), t.apply(this, r)
  658. }
  659. ee.call(this, e, i, a, !0, s, n)
  660. }
  661. function b(e, i = '', t = !1, s = {}) {
  662. if (!l.element(e) || l.empty(i)) return
  663. const n = new CustomEvent(i, {
  664. bubbles: t,
  665. detail: ie(q({}, s), { plyr: this })
  666. })
  667. e.dispatchEvent(n)
  668. }
  669. function bi() {
  670. this &&
  671. this.eventListeners &&
  672. (this.eventListeners.forEach(e => {
  673. const { element: i, type: t, callback: s, options: n } = e
  674. i.removeEventListener(t, s, n)
  675. }),
  676. (this.eventListeners = []))
  677. }
  678. function vi() {
  679. return new Promise(e =>
  680. this.ready
  681. ? setTimeout(e, 0)
  682. : C.call(this, this.elements.container, 'ready', e)
  683. ).then(() => {})
  684. }
  685. function V(e) {
  686. l.promise(e) && e.then(null, () => {})
  687. }
  688. function Ne(e) {
  689. return l.array(e) ? e.filter((i, t) => e.indexOf(i) === t) : e
  690. }
  691. function ct(e, i) {
  692. return l.array(e) && e.length
  693. ? e.reduce((t, s) => (Math.abs(s - i) < Math.abs(t - i) ? s : t))
  694. : null
  695. }
  696. function ut(e) {
  697. return !(!window || !window.CSS) && window.CSS.supports(e)
  698. }
  699. const ht = [
  700. [1, 1],
  701. [4, 3],
  702. [3, 4],
  703. [5, 4],
  704. [4, 5],
  705. [3, 2],
  706. [2, 3],
  707. [16, 10],
  708. [10, 16],
  709. [16, 9],
  710. [9, 16],
  711. [21, 9],
  712. [9, 21],
  713. [32, 9],
  714. [9, 32]
  715. ].reduce((e, [i, t]) => ie(q({}, e), { [i / t]: [i, t] }), {})
  716. function dt(e) {
  717. return l.array(e) || (l.string(e) && e.includes(':'))
  718. ? (l.array(e) ? e : e.split(':')).map(Number).every(l.number)
  719. : !1
  720. }
  721. function ye(e) {
  722. if (!l.array(e) || !e.every(l.number)) return null
  723. const [i, t] = e,
  724. s = (a, r) => (r === 0 ? a : s(r, a % r)),
  725. n = s(i, t)
  726. return [i / n, t / n]
  727. }
  728. function Me(e) {
  729. const i = s => (dt(s) ? s.split(':').map(Number) : null)
  730. let t = i(e)
  731. if (
  732. (t === null && (t = i(this.config.ratio)),
  733. t === null &&
  734. !l.empty(this.embed) &&
  735. l.array(this.embed.ratio) &&
  736. ({ ratio: t } = this.embed),
  737. t === null && this.isHTML5)
  738. ) {
  739. const { videoWidth: s, videoHeight: n } = this.media
  740. t = [s, n]
  741. }
  742. return ye(t)
  743. }
  744. function te(e) {
  745. if (!this.isVideo) return {}
  746. const { wrapper: i } = this.elements,
  747. t = Me.call(this, e)
  748. if (!l.array(t)) return {}
  749. const [s, n] = ye(t),
  750. a = (100 / s) * n
  751. if (
  752. (ut(`aspect-ratio: ${s}/${n}`)
  753. ? (i.style.aspectRatio = `${s}/${n}`)
  754. : (i.style.paddingBottom = `${a}%`),
  755. this.isVimeo && !this.config.vimeo.premium && this.supported.ui)
  756. ) {
  757. const r =
  758. (100 / this.media.offsetWidth) *
  759. parseInt(window.getComputedStyle(this.media).paddingBottom, 10),
  760. o = (r - a) / (r / 50)
  761. this.fullscreen.active
  762. ? (i.style.paddingBottom = null)
  763. : (this.media.style.transform = `translateY(-${o}%)`)
  764. } else this.isHTML5 && i.classList.add(this.config.classNames.videoFixedRatio)
  765. return { padding: a, ratio: t }
  766. }
  767. function mt(e, i, t = 0.05) {
  768. const s = e / i,
  769. n = ct(Object.keys(ht), s)
  770. return Math.abs(n - s) <= t ? ht[n] : [e, i]
  771. }
  772. function wi() {
  773. return [
  774. Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0),
  775. Math.max(
  776. document.documentElement.clientHeight || 0,
  777. window.innerHeight || 0
  778. )
  779. ]
  780. }
  781. const K = {
  782. getSources() {
  783. return this.isHTML5
  784. ? Array.from(this.media.querySelectorAll('source')).filter(e => {
  785. const i = e.getAttribute('type')
  786. return !!l.empty(i) || x.mime.call(this, i)
  787. })
  788. : []
  789. },
  790. getQualityOptions() {
  791. return this.config.quality.forced
  792. ? this.config.quality.options
  793. : K.getSources
  794. .call(this)
  795. .map(e => Number(e.getAttribute('size')))
  796. .filter(Boolean)
  797. },
  798. setup() {
  799. if (!this.isHTML5) return
  800. const e = this
  801. ;(e.options.speed = e.config.speed.options),
  802. l.empty(this.config.ratio) || te.call(e),
  803. Object.defineProperty(e.media, 'quality', {
  804. get() {
  805. const i = K.getSources
  806. .call(e)
  807. .find(t => t.getAttribute('src') === e.source)
  808. return i && Number(i.getAttribute('size'))
  809. },
  810. set(i) {
  811. if (e.quality !== i) {
  812. if (
  813. e.config.quality.forced &&
  814. l.function(e.config.quality.onChange)
  815. )
  816. e.config.quality.onChange(i)
  817. else {
  818. const t = K.getSources
  819. .call(e)
  820. .find(c => Number(c.getAttribute('size')) === i)
  821. if (!t) return
  822. const {
  823. currentTime: s,
  824. paused: n,
  825. preload: a,
  826. readyState: r,
  827. playbackRate: o
  828. } = e.media
  829. ;(e.media.src = t.getAttribute('src')),
  830. (a !== 'none' || r) &&
  831. (e.once('loadedmetadata', () => {
  832. ;(e.speed = o), (e.currentTime = s), n || V(e.play())
  833. }),
  834. e.media.load())
  835. }
  836. b.call(e, e.media, 'qualitychange', !1, { quality: i })
  837. }
  838. }
  839. })
  840. },
  841. cancelRequests() {
  842. this.isHTML5 &&
  843. (z(K.getSources.call(this)),
  844. this.media.setAttribute('src', this.config.blankVideo),
  845. this.media.load(),
  846. this.debug.log('Cancelled network requests'))
  847. }
  848. }
  849. function Ti(e) {
  850. return `${e}-${Math.floor(1e4 * Math.random())}`
  851. }
  852. function xe(e, ...i) {
  853. return l.empty(e)
  854. ? e
  855. : e.toString().replace(/{(\d+)}/g, (t, s) => i[s].toString())
  856. }
  857. function ki(e, i) {
  858. return e === 0 || i === 0 || Number.isNaN(e) || Number.isNaN(i)
  859. ? 0
  860. : ((e / i) * 100).toFixed(2)
  861. }
  862. const ne = (e = '', i = '', t = '') =>
  863. e.replace(
  864. new RegExp(
  865. i.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'),
  866. 'g'
  867. ),
  868. t.toString()
  869. ),
  870. pt = (e = '') =>
  871. e
  872. .toString()
  873. .replace(
  874. /\w\S*/g,
  875. i => i.charAt(0).toUpperCase() + i.slice(1).toLowerCase()
  876. )
  877. function Ai(e = '') {
  878. let i = e.toString()
  879. return (
  880. (i = ne(i, '-', ' ')), (i = ne(i, '_', ' ')), (i = pt(i)), ne(i, ' ', '')
  881. )
  882. }
  883. function Ci(e = '') {
  884. let i = e.toString()
  885. return (i = Ai(i)), i.charAt(0).toLowerCase() + i.slice(1)
  886. }
  887. function Si(e) {
  888. const i = document.createDocumentFragment(),
  889. t = document.createElement('div')
  890. return i.appendChild(t), (t.innerHTML = e), i.firstChild.innerText
  891. }
  892. function Ei(e) {
  893. const i = document.createElement('div')
  894. return i.appendChild(e), i.innerHTML
  895. }
  896. const gt = {
  897. pip: 'PIP',
  898. airplay: 'AirPlay',
  899. html5: 'HTML5',
  900. vimeo: 'Vimeo',
  901. youtube: 'YouTube'
  902. },
  903. $ = {
  904. get(e = '', i = {}) {
  905. if (l.empty(e) || l.empty(i)) return ''
  906. let t = at(i.i18n, e)
  907. if (l.empty(t)) return Object.keys(gt).includes(e) ? gt[e] : ''
  908. const s = { '{seektime}': i.seekTime, '{title}': i.title }
  909. return (
  910. Object.entries(s).forEach(([n, a]) => {
  911. t = ne(t, n, a)
  912. }),
  913. t
  914. )
  915. }
  916. }
  917. class ae {
  918. constructor(i) {
  919. m(this, 'get', t => {
  920. if (!ae.supported || !this.enabled) return null
  921. const s = window.localStorage.getItem(this.key)
  922. if (l.empty(s)) return null
  923. const n = JSON.parse(s)
  924. return l.string(t) && t.length ? n[t] : n
  925. }),
  926. m(this, 'set', t => {
  927. if (!ae.supported || !this.enabled || !l.object(t)) return
  928. let s = this.get()
  929. l.empty(s) && (s = {}), I(s, t)
  930. try {
  931. window.localStorage.setItem(this.key, JSON.stringify(s))
  932. } catch {}
  933. }),
  934. (this.enabled = i.config.storage.enabled),
  935. (this.key = i.config.storage.key)
  936. }
  937. static get supported() {
  938. try {
  939. if (!('localStorage' in window)) return !1
  940. const i = '___test'
  941. return (
  942. window.localStorage.setItem(i, i), window.localStorage.removeItem(i), !0
  943. )
  944. } catch {
  945. return !1
  946. }
  947. }
  948. }
  949. function le(e, i = 'text') {
  950. return new Promise((t, s) => {
  951. try {
  952. const n = new XMLHttpRequest()
  953. if (!('withCredentials' in n)) return
  954. n.addEventListener('load', () => {
  955. if (i === 'text')
  956. try {
  957. t(JSON.parse(n.responseText))
  958. } catch {
  959. t(n.responseText)
  960. }
  961. else t(n.response)
  962. }),
  963. n.addEventListener('error', () => {
  964. throw new Error(n.status)
  965. }),
  966. n.open('GET', e, !0),
  967. (n.responseType = i),
  968. n.send()
  969. } catch (n) {
  970. s(n)
  971. }
  972. })
  973. }
  974. function ft(e, i) {
  975. if (!l.string(e)) return
  976. const t = l.string(i)
  977. let s = !1
  978. const n = () => document.getElementById(i) !== null,
  979. a = (r, o) => {
  980. ;(r.innerHTML = o),
  981. (t && n()) || document.body.insertAdjacentElement('afterbegin', r)
  982. }
  983. if (!t || !n()) {
  984. const r = ae.supported,
  985. o = document.createElement('div')
  986. if ((o.setAttribute('hidden', ''), t && o.setAttribute('id', i), r)) {
  987. const c = window.localStorage.getItem(`cache-${i}`)
  988. if (((s = c !== null), s)) {
  989. const u = JSON.parse(c)
  990. a(o, u.content)
  991. }
  992. }
  993. le(e)
  994. .then(c => {
  995. if (!l.empty(c)) {
  996. if (r)
  997. try {
  998. window.localStorage.setItem(
  999. `cache-${i}`,
  1000. JSON.stringify({ content: c })
  1001. )
  1002. } catch {}
  1003. a(o, c)
  1004. }
  1005. })
  1006. .catch(() => {})
  1007. }
  1008. }
  1009. const yt = e => Math.trunc((e / 60 / 60) % 60, 10),
  1010. Pi = e => Math.trunc(e % 60, 10)
  1011. function be(e = 0, i = !1, t = !1) {
  1012. if (!l.number(e)) return be(void 0, i, t)
  1013. const s = c => `0${c}`.slice(-2)
  1014. let n = yt(e)
  1015. const a = ((r = e), Math.trunc((r / 60) % 60, 10))
  1016. var r
  1017. const o = Pi(e)
  1018. return (
  1019. (n = i || n > 0 ? `${n}:` : ''),
  1020. `${t && e > 0 ? '-' : ''}${n}${s(a)}:${s(o)}`
  1021. )
  1022. }
  1023. const h = {
  1024. getIconUrl() {
  1025. const e = new URL(this.config.iconUrl, window.location),
  1026. i = window.location.host
  1027. ? window.location.host
  1028. : window.top.location.host,
  1029. t = e.host !== i || (_.isIE && !window.svg4everybody)
  1030. return { url: this.config.iconUrl, cors: t }
  1031. },
  1032. findElements() {
  1033. try {
  1034. return (
  1035. (this.elements.controls = O.call(
  1036. this,
  1037. this.config.selectors.controls.wrapper
  1038. )),
  1039. (this.elements.buttons = {
  1040. play: Z.call(this, this.config.selectors.buttons.play),
  1041. pause: O.call(this, this.config.selectors.buttons.pause),
  1042. restart: O.call(this, this.config.selectors.buttons.restart),
  1043. rewind: O.call(this, this.config.selectors.buttons.rewind),
  1044. fastForward: O.call(this, this.config.selectors.buttons.fastForward),
  1045. mute: O.call(this, this.config.selectors.buttons.mute),
  1046. pip: O.call(this, this.config.selectors.buttons.pip),
  1047. airplay: O.call(this, this.config.selectors.buttons.airplay),
  1048. settings: O.call(this, this.config.selectors.buttons.settings),
  1049. captions: O.call(this, this.config.selectors.buttons.captions),
  1050. fullscreen: O.call(this, this.config.selectors.buttons.fullscreen)
  1051. }),
  1052. (this.elements.progress = O.call(this, this.config.selectors.progress)),
  1053. (this.elements.inputs = {
  1054. seek: O.call(this, this.config.selectors.inputs.seek),
  1055. volume: O.call(this, this.config.selectors.inputs.volume)
  1056. }),
  1057. (this.elements.display = {
  1058. buffer: O.call(this, this.config.selectors.display.buffer),
  1059. currentTime: O.call(this, this.config.selectors.display.currentTime),
  1060. duration: O.call(this, this.config.selectors.display.duration)
  1061. }),
  1062. l.element(this.elements.progress) &&
  1063. (this.elements.display.seekTooltip =
  1064. this.elements.progress.querySelector(
  1065. `.${this.config.classNames.tooltip}`
  1066. )),
  1067. !0
  1068. )
  1069. } catch (e) {
  1070. return (
  1071. this.debug.warn(
  1072. 'It looks like there is a problem with your custom controls HTML',
  1073. e
  1074. ),
  1075. this.toggleNativeControls(!0),
  1076. !1
  1077. )
  1078. }
  1079. },
  1080. createIcon(e, i) {
  1081. const t = 'http://www.w3.org/2000/svg',
  1082. s = h.getIconUrl.call(this),
  1083. n = `${s.cors ? '' : s.url}#${this.config.iconPrefix}`,
  1084. a = document.createElementNS(t, 'svg')
  1085. Se(a, I(i, { 'aria-hidden': 'true', focusable: 'false' }))
  1086. const r = document.createElementNS(t, 'use'),
  1087. o = `${n}-${e}`
  1088. return (
  1089. 'href' in r &&
  1090. r.setAttributeNS('http://www.w3.org/1999/xlink', 'href', o),
  1091. r.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', o),
  1092. a.appendChild(r),
  1093. a
  1094. )
  1095. },
  1096. createLabel(e, i = {}) {
  1097. const t = $.get(e, this.config)
  1098. return y(
  1099. 'span',
  1100. ie(q({}, i), {
  1101. class: [i.class, this.config.classNames.hidden]
  1102. .filter(Boolean)
  1103. .join(' ')
  1104. }),
  1105. t
  1106. )
  1107. },
  1108. createBadge(e) {
  1109. if (l.empty(e)) return null
  1110. const i = y('span', { class: this.config.classNames.menu.value })
  1111. return (
  1112. i.appendChild(y('span', { class: this.config.classNames.menu.badge }, e)),
  1113. i
  1114. )
  1115. },
  1116. createButton(e, i) {
  1117. const t = I({}, i)
  1118. let s = Ci(e)
  1119. const n = {
  1120. element: 'button',
  1121. toggle: !1,
  1122. label: null,
  1123. icon: null,
  1124. labelPressed: null,
  1125. iconPressed: null
  1126. }
  1127. switch (
  1128. (['element', 'icon', 'label'].forEach(r => {
  1129. Object.keys(t).includes(r) && ((n[r] = t[r]), delete t[r])
  1130. }),
  1131. n.element !== 'button' ||
  1132. Object.keys(t).includes('type') ||
  1133. (t.type = 'button'),
  1134. Object.keys(t).includes('class')
  1135. ? t.class.split(' ').some(r => r === this.config.classNames.control) ||
  1136. I(t, { class: `${t.class} ${this.config.classNames.control}` })
  1137. : (t.class = this.config.classNames.control),
  1138. e)
  1139. ) {
  1140. case 'play':
  1141. ;(n.toggle = !0),
  1142. (n.label = 'play'),
  1143. (n.labelPressed = 'pause'),
  1144. (n.icon = 'play'),
  1145. (n.iconPressed = 'pause')
  1146. break
  1147. case 'mute':
  1148. ;(n.toggle = !0),
  1149. (n.label = 'mute'),
  1150. (n.labelPressed = 'unmute'),
  1151. (n.icon = 'volume'),
  1152. (n.iconPressed = 'muted')
  1153. break
  1154. case 'captions':
  1155. ;(n.toggle = !0),
  1156. (n.label = 'enableCaptions'),
  1157. (n.labelPressed = 'disableCaptions'),
  1158. (n.icon = 'captions-off'),
  1159. (n.iconPressed = 'captions-on')
  1160. break
  1161. case 'fullscreen':
  1162. ;(n.toggle = !0),
  1163. (n.label = 'enterFullscreen'),
  1164. (n.labelPressed = 'exitFullscreen'),
  1165. (n.icon = 'enter-fullscreen'),
  1166. (n.iconPressed = 'exit-fullscreen')
  1167. break
  1168. case 'play-large':
  1169. ;(t.class += ` ${this.config.classNames.control}--overlaid`),
  1170. (s = 'play'),
  1171. (n.label = 'play'),
  1172. (n.icon = 'play')
  1173. break
  1174. default:
  1175. l.empty(n.label) && (n.label = s), l.empty(n.icon) && (n.icon = e)
  1176. }
  1177. const a = y(n.element)
  1178. return (
  1179. n.toggle
  1180. ? (a.appendChild(
  1181. h.createIcon.call(this, n.iconPressed, { class: 'icon--pressed' })
  1182. ),
  1183. a.appendChild(
  1184. h.createIcon.call(this, n.icon, { class: 'icon--not-pressed' })
  1185. ),
  1186. a.appendChild(
  1187. h.createLabel.call(this, n.labelPressed, {
  1188. class: 'label--pressed'
  1189. })
  1190. ),
  1191. a.appendChild(
  1192. h.createLabel.call(this, n.label, { class: 'label--not-pressed' })
  1193. ))
  1194. : (a.appendChild(h.createIcon.call(this, n.icon)),
  1195. a.appendChild(h.createLabel.call(this, n.label))),
  1196. I(t, H(this.config.selectors.buttons[s], t)),
  1197. Se(a, t),
  1198. s === 'play'
  1199. ? (l.array(this.elements.buttons[s]) || (this.elements.buttons[s] = []),
  1200. this.elements.buttons[s].push(a))
  1201. : (this.elements.buttons[s] = a),
  1202. a
  1203. )
  1204. },
  1205. createRange(e, i) {
  1206. const t = y(
  1207. 'input',
  1208. I(
  1209. H(this.config.selectors.inputs[e]),
  1210. {
  1211. type: 'range',
  1212. min: 0,
  1213. max: 100,
  1214. step: 0.01,
  1215. value: 0,
  1216. autocomplete: 'off',
  1217. role: 'slider',
  1218. 'aria-label': $.get(e, this.config),
  1219. 'aria-valuemin': 0,
  1220. 'aria-valuemax': 100,
  1221. 'aria-valuenow': 0
  1222. },
  1223. i
  1224. )
  1225. )
  1226. return (
  1227. (this.elements.inputs[e] = t),
  1228. h.updateRangeFill.call(this, t),
  1229. ii.setup(t),
  1230. t
  1231. )
  1232. },
  1233. createProgress(e, i) {
  1234. const t = y(
  1235. 'progress',
  1236. I(
  1237. H(this.config.selectors.display[e]),
  1238. { min: 0, max: 100, value: 0, role: 'progressbar', 'aria-hidden': !0 },
  1239. i
  1240. )
  1241. )
  1242. if (e !== 'volume') {
  1243. t.appendChild(y('span', null, '0'))
  1244. const s = { played: 'played', buffer: 'buffered' }[e],
  1245. n = s ? $.get(s, this.config) : ''
  1246. t.innerText = `% ${n.toLowerCase()}`
  1247. }
  1248. return (this.elements.display[e] = t), t
  1249. },
  1250. createTime(e, i) {
  1251. const t = H(this.config.selectors.display[e], i),
  1252. s = y(
  1253. 'div',
  1254. I(t, {
  1255. class: `${t.class ? t.class : ''} ${
  1256. this.config.classNames.display.time
  1257. } `.trim(),
  1258. 'aria-label': $.get(e, this.config)
  1259. }),
  1260. '00:00'
  1261. )
  1262. return (this.elements.display[e] = s), s
  1263. },
  1264. bindMenuItemShortcuts(e, i) {
  1265. C.call(
  1266. this,
  1267. e,
  1268. 'keydown keyup',
  1269. t => {
  1270. if (
  1271. !['Space', 'ArrowUp', 'ArrowDown', 'ArrowRight'].includes(t.key) ||
  1272. (t.preventDefault(), t.stopPropagation(), t.type === 'keydown')
  1273. )
  1274. return
  1275. const s = Q(e, '[role="menuitemradio"]')
  1276. if (!s && ['Space', 'ArrowRight'].includes(t.key))
  1277. h.showMenuPanel.call(this, i, !0)
  1278. else {
  1279. let n
  1280. t.key !== 'Space' &&
  1281. (t.key === 'ArrowDown' || (s && t.key === 'ArrowRight')
  1282. ? ((n = e.nextElementSibling),
  1283. l.element(n) || (n = e.parentNode.firstElementChild))
  1284. : ((n = e.previousElementSibling),
  1285. l.element(n) || (n = e.parentNode.lastElementChild)),
  1286. Ee.call(this, n, !0))
  1287. }
  1288. },
  1289. !1
  1290. ),
  1291. C.call(this, e, 'keyup', t => {
  1292. t.key === 'Return' && h.focusFirstMenuItem.call(this, null, !0)
  1293. })
  1294. },
  1295. createMenuItem({
  1296. value: e,
  1297. list: i,
  1298. type: t,
  1299. title: s,
  1300. badge: n = null,
  1301. checked: a = !1
  1302. }) {
  1303. const r = H(this.config.selectors.inputs[t]),
  1304. o = y(
  1305. 'button',
  1306. I(r, {
  1307. type: 'button',
  1308. role: 'menuitemradio',
  1309. class: `${this.config.classNames.control} ${
  1310. r.class ? r.class : ''
  1311. }`.trim(),
  1312. 'aria-checked': a,
  1313. value: e
  1314. })
  1315. ),
  1316. c = y('span')
  1317. ;(c.innerHTML = s),
  1318. l.element(n) && c.appendChild(n),
  1319. o.appendChild(c),
  1320. Object.defineProperty(o, 'checked', {
  1321. enumerable: !0,
  1322. get: () => o.getAttribute('aria-checked') === 'true',
  1323. set(u) {
  1324. u &&
  1325. Array.from(o.parentNode.children)
  1326. .filter(p => Q(p, '[role="menuitemradio"]'))
  1327. .forEach(p => p.setAttribute('aria-checked', 'false')),
  1328. o.setAttribute('aria-checked', u ? 'true' : 'false')
  1329. }
  1330. }),
  1331. this.listeners.bind(
  1332. o,
  1333. 'click keyup',
  1334. u => {
  1335. if (!l.keyboardEvent(u) || u.key === 'Space') {
  1336. switch (
  1337. (u.preventDefault(), u.stopPropagation(), (o.checked = !0), t)
  1338. ) {
  1339. case 'language':
  1340. this.currentTrack = Number(e)
  1341. break
  1342. case 'quality':
  1343. this.quality = e
  1344. break
  1345. case 'speed':
  1346. this.speed = parseFloat(e)
  1347. }
  1348. h.showMenuPanel.call(this, 'home', l.keyboardEvent(u))
  1349. }
  1350. },
  1351. t,
  1352. !1
  1353. ),
  1354. h.bindMenuItemShortcuts.call(this, o, t),
  1355. i.appendChild(o)
  1356. },
  1357. formatTime(e = 0, i = !1) {
  1358. return l.number(e) ? be(e, yt(this.duration) > 0, i) : e
  1359. },
  1360. updateTimeDisplay(e = null, i = 0, t = !1) {
  1361. l.element(e) && l.number(i) && (e.innerText = h.formatTime(i, t))
  1362. },
  1363. updateVolume() {
  1364. this.supported.ui &&
  1365. (l.element(this.elements.inputs.volume) &&
  1366. h.setRange.call(
  1367. this,
  1368. this.elements.inputs.volume,
  1369. this.muted ? 0 : this.volume
  1370. ),
  1371. l.element(this.elements.buttons.mute) &&
  1372. (this.elements.buttons.mute.pressed = this.muted || this.volume === 0))
  1373. },
  1374. setRange(e, i = 0) {
  1375. l.element(e) && ((e.value = i), h.updateRangeFill.call(this, e))
  1376. },
  1377. updateProgress(e) {
  1378. if (!this.supported.ui || !l.event(e)) return
  1379. let i = 0
  1380. const t = (s, n) => {
  1381. const a = l.number(n) ? n : 0,
  1382. r = l.element(s) ? s : this.elements.display.buffer
  1383. if (l.element(r)) {
  1384. r.value = a
  1385. const o = r.getElementsByTagName('span')[0]
  1386. l.element(o) && (o.childNodes[0].nodeValue = a)
  1387. }
  1388. }
  1389. if (e)
  1390. switch (e.type) {
  1391. case 'timeupdate':
  1392. case 'seeking':
  1393. case 'seeked':
  1394. ;(i = ki(this.currentTime, this.duration)),
  1395. e.type === 'timeupdate' &&
  1396. h.setRange.call(this, this.elements.inputs.seek, i)
  1397. break
  1398. case 'playing':
  1399. case 'progress':
  1400. t(this.elements.display.buffer, 100 * this.buffered)
  1401. }
  1402. },
  1403. updateRangeFill(e) {
  1404. const i = l.event(e) ? e.target : e
  1405. if (l.element(i) && i.getAttribute('type') === 'range') {
  1406. if (Q(i, this.config.selectors.inputs.seek)) {
  1407. i.setAttribute('aria-valuenow', this.currentTime)
  1408. const t = h.formatTime(this.currentTime),
  1409. s = h.formatTime(this.duration),
  1410. n = $.get('seekLabel', this.config)
  1411. i.setAttribute(
  1412. 'aria-valuetext',
  1413. n.replace('{currentTime}', t).replace('{duration}', s)
  1414. )
  1415. } else if (Q(i, this.config.selectors.inputs.volume)) {
  1416. const t = 100 * i.value
  1417. i.setAttribute('aria-valuenow', t),
  1418. i.setAttribute('aria-valuetext', `${t.toFixed(1)}%`)
  1419. } else i.setAttribute('aria-valuenow', i.value)
  1420. _.isWebkit &&
  1421. i.style.setProperty('--value', (i.value / i.max) * 100 + '%')
  1422. }
  1423. },
  1424. updateSeekTooltip(e) {
  1425. var i, t
  1426. if (
  1427. !this.config.tooltips.seek ||
  1428. !l.element(this.elements.inputs.seek) ||
  1429. !l.element(this.elements.display.seekTooltip) ||
  1430. this.duration === 0
  1431. )
  1432. return
  1433. const s = this.elements.display.seekTooltip,
  1434. n = `${this.config.classNames.tooltip}--visible`,
  1435. a = p => A(s, n, p)
  1436. if (this.touch) return void a(!1)
  1437. let r = 0
  1438. const o = this.elements.progress.getBoundingClientRect()
  1439. if (l.event(e)) r = (100 / o.width) * (e.pageX - o.left)
  1440. else {
  1441. if (!ge(s, n)) return
  1442. r = parseFloat(s.style.left, 10)
  1443. }
  1444. r < 0 ? (r = 0) : r > 100 && (r = 100)
  1445. const c = (this.duration / 100) * r
  1446. s.innerText = h.formatTime(c)
  1447. const u =
  1448. (i = this.config.markers) === null ||
  1449. i === void 0 ||
  1450. (t = i.points) === null ||
  1451. t === void 0
  1452. ? void 0
  1453. : t.find(({ time: p }) => p === Math.round(c))
  1454. u && s.insertAdjacentHTML('afterbegin', `${u.label}<br>`),
  1455. (s.style.left = `${r}%`),
  1456. l.event(e) &&
  1457. ['mouseenter', 'mouseleave'].includes(e.type) &&
  1458. a(e.type === 'mouseenter')
  1459. },
  1460. timeUpdate(e) {
  1461. const i =
  1462. !l.element(this.elements.display.duration) && this.config.invertTime
  1463. h.updateTimeDisplay.call(
  1464. this,
  1465. this.elements.display.currentTime,
  1466. i ? this.duration - this.currentTime : this.currentTime,
  1467. i
  1468. ),
  1469. (e && e.type === 'timeupdate' && this.media.seeking) ||
  1470. h.updateProgress.call(this, e)
  1471. },
  1472. durationUpdate() {
  1473. if (!this.supported.ui || (!this.config.invertTime && this.currentTime))
  1474. return
  1475. if (this.duration >= 2 ** 32)
  1476. return (
  1477. J(this.elements.display.currentTime, !0),
  1478. void J(this.elements.progress, !0)
  1479. )
  1480. l.element(this.elements.inputs.seek) &&
  1481. this.elements.inputs.seek.setAttribute('aria-valuemax', this.duration)
  1482. const e = l.element(this.elements.display.duration)
  1483. !e &&
  1484. this.config.displayDuration &&
  1485. this.paused &&
  1486. h.updateTimeDisplay.call(
  1487. this,
  1488. this.elements.display.currentTime,
  1489. this.duration
  1490. ),
  1491. e &&
  1492. h.updateTimeDisplay.call(
  1493. this,
  1494. this.elements.display.duration,
  1495. this.duration
  1496. ),
  1497. this.config.markers.enabled && h.setMarkers.call(this),
  1498. h.updateSeekTooltip.call(this)
  1499. },
  1500. toggleMenuButton(e, i) {
  1501. J(this.elements.settings.buttons[e], !i)
  1502. },
  1503. updateSetting(e, i, t) {
  1504. const s = this.elements.settings.panels[e]
  1505. let n = null,
  1506. a = i
  1507. if (e === 'captions') n = this.currentTrack
  1508. else {
  1509. if (
  1510. ((n = l.empty(t) ? this[e] : t),
  1511. l.empty(n) && (n = this.config[e].default),
  1512. !l.empty(this.options[e]) && !this.options[e].includes(n))
  1513. )
  1514. return void this.debug.warn(`Unsupported value of '${n}' for ${e}`)
  1515. if (!this.config[e].options.includes(n))
  1516. return void this.debug.warn(`Disabled value of '${n}' for ${e}`)
  1517. }
  1518. if (
  1519. (l.element(a) || (a = s && s.querySelector('[role="menu"]')),
  1520. !l.element(a))
  1521. )
  1522. return
  1523. this.elements.settings.buttons[e].querySelector(
  1524. `.${this.config.classNames.menu.value}`
  1525. ).innerHTML = h.getLabel.call(this, e, n)
  1526. const r = a && a.querySelector(`[value="${n}"]`)
  1527. l.element(r) && (r.checked = !0)
  1528. },
  1529. getLabel(e, i) {
  1530. switch (e) {
  1531. case 'speed':
  1532. return i === 1 ? $.get('normal', this.config) : `${i}&times;`
  1533. case 'quality':
  1534. if (l.number(i)) {
  1535. const t = $.get(`qualityLabel.${i}`, this.config)
  1536. return t.length ? t : `${i}p`
  1537. }
  1538. return pt(i)
  1539. case 'captions':
  1540. return E.getLabel.call(this)
  1541. default:
  1542. return null
  1543. }
  1544. },
  1545. setQualityMenu(e) {
  1546. if (!l.element(this.elements.settings.panels.quality)) return
  1547. const i = 'quality',
  1548. t = this.elements.settings.panels.quality.querySelector('[role="menu"]')
  1549. l.array(e) &&
  1550. (this.options.quality = Ne(e).filter(a =>
  1551. this.config.quality.options.includes(a)
  1552. ))
  1553. const s = !l.empty(this.options.quality) && this.options.quality.length > 1
  1554. if (
  1555. (h.toggleMenuButton.call(this, i, s), me(t), h.checkMenu.call(this), !s)
  1556. )
  1557. return
  1558. const n = a => {
  1559. const r = $.get(`qualityBadge.${a}`, this.config)
  1560. return r.length ? h.createBadge.call(this, r) : null
  1561. }
  1562. this.options.quality
  1563. .sort((a, r) => {
  1564. const o = this.config.quality.options
  1565. return o.indexOf(a) > o.indexOf(r) ? 1 : -1
  1566. })
  1567. .forEach(a => {
  1568. h.createMenuItem.call(this, {
  1569. value: a,
  1570. list: t,
  1571. type: i,
  1572. title: h.getLabel.call(this, 'quality', a),
  1573. badge: n(a)
  1574. })
  1575. }),
  1576. h.updateSetting.call(this, i, t)
  1577. },
  1578. setCaptionsMenu() {
  1579. if (!l.element(this.elements.settings.panels.captions)) return
  1580. const e = 'captions',
  1581. i = this.elements.settings.panels.captions.querySelector('[role="menu"]'),
  1582. t = E.getTracks.call(this),
  1583. s = Boolean(t.length)
  1584. if (
  1585. (h.toggleMenuButton.call(this, e, s), me(i), h.checkMenu.call(this), !s)
  1586. )
  1587. return
  1588. const n = t.map((a, r) => ({
  1589. value: r,
  1590. checked: this.captions.toggled && this.currentTrack === r,
  1591. title: E.getLabel.call(this, a),
  1592. badge: a.language && h.createBadge.call(this, a.language.toUpperCase()),
  1593. list: i,
  1594. type: 'language'
  1595. }))
  1596. n.unshift({
  1597. value: -1,
  1598. checked: !this.captions.toggled,
  1599. title: $.get('disabled', this.config),
  1600. list: i,
  1601. type: 'language'
  1602. }),
  1603. n.forEach(h.createMenuItem.bind(this)),
  1604. h.updateSetting.call(this, e, i)
  1605. },
  1606. setSpeedMenu() {
  1607. if (!l.element(this.elements.settings.panels.speed)) return
  1608. const e = 'speed',
  1609. i = this.elements.settings.panels.speed.querySelector('[role="menu"]')
  1610. this.options.speed = this.options.speed.filter(
  1611. s => s >= this.minimumSpeed && s <= this.maximumSpeed
  1612. )
  1613. const t = !l.empty(this.options.speed) && this.options.speed.length > 1
  1614. h.toggleMenuButton.call(this, e, t),
  1615. me(i),
  1616. h.checkMenu.call(this),
  1617. t &&
  1618. (this.options.speed.forEach(s => {
  1619. h.createMenuItem.call(this, {
  1620. value: s,
  1621. list: i,
  1622. type: e,
  1623. title: h.getLabel.call(this, 'speed', s)
  1624. })
  1625. }),
  1626. h.updateSetting.call(this, e, i))
  1627. },
  1628. checkMenu() {
  1629. const { buttons: e } = this.elements.settings,
  1630. i = !l.empty(e) && Object.values(e).some(t => !t.hidden)
  1631. J(this.elements.settings.menu, !i)
  1632. },
  1633. focusFirstMenuItem(e, i = !1) {
  1634. if (this.elements.settings.popup.hidden) return
  1635. let t = e
  1636. l.element(t) ||
  1637. (t = Object.values(this.elements.settings.panels).find(n => !n.hidden))
  1638. const s = t.querySelector('[role^="menuitem"]')
  1639. Ee.call(this, s, i)
  1640. },
  1641. toggleMenu(e) {
  1642. const { popup: i } = this.elements.settings,
  1643. t = this.elements.buttons.settings
  1644. if (!l.element(i) || !l.element(t)) return
  1645. const { hidden: s } = i
  1646. let n = s
  1647. if (l.boolean(e)) n = e
  1648. else if (l.keyboardEvent(e) && e.key === 'Escape') n = !1
  1649. else if (l.event(e)) {
  1650. const a = l.function(e.composedPath) ? e.composedPath()[0] : e.target,
  1651. r = i.contains(a)
  1652. if (r || (!r && e.target !== t && n)) return
  1653. }
  1654. t.setAttribute('aria-expanded', n),
  1655. J(i, !n),
  1656. A(this.elements.container, this.config.classNames.menu.open, n),
  1657. n && l.keyboardEvent(e)
  1658. ? h.focusFirstMenuItem.call(this, null, !0)
  1659. : n || s || Ee.call(this, t, l.keyboardEvent(e))
  1660. },
  1661. getMenuSize(e) {
  1662. const i = e.cloneNode(!0)
  1663. ;(i.style.position = 'absolute'),
  1664. (i.style.opacity = 0),
  1665. i.removeAttribute('hidden'),
  1666. e.parentNode.appendChild(i)
  1667. const t = i.scrollWidth,
  1668. s = i.scrollHeight
  1669. return z(i), { width: t, height: s }
  1670. },
  1671. showMenuPanel(e = '', i = !1) {
  1672. const t = this.elements.container.querySelector(
  1673. `#plyr-settings-${this.id}-${e}`
  1674. )
  1675. if (!l.element(t)) return
  1676. const s = t.parentNode,
  1677. n = Array.from(s.children).find(a => !a.hidden)
  1678. if (x.transitions && !x.reducedMotion) {
  1679. ;(s.style.width = `${n.scrollWidth}px`),
  1680. (s.style.height = `${n.scrollHeight}px`)
  1681. const a = h.getMenuSize.call(this, t),
  1682. r = o => {
  1683. o.target === s &&
  1684. ['width', 'height'].includes(o.propertyName) &&
  1685. ((s.style.width = ''),
  1686. (s.style.height = ''),
  1687. fe.call(this, s, Ce, r))
  1688. }
  1689. C.call(this, s, Ce, r),
  1690. (s.style.width = `${a.width}px`),
  1691. (s.style.height = `${a.height}px`)
  1692. }
  1693. J(n, !0), J(t, !1), h.focusFirstMenuItem.call(this, t, i)
  1694. },
  1695. setDownloadUrl() {
  1696. const e = this.elements.buttons.download
  1697. l.element(e) && e.setAttribute('href', this.download)
  1698. },
  1699. create(e) {
  1700. const {
  1701. bindMenuItemShortcuts: i,
  1702. createButton: t,
  1703. createProgress: s,
  1704. createRange: n,
  1705. createTime: a,
  1706. setQualityMenu: r,
  1707. setSpeedMenu: o,
  1708. showMenuPanel: c
  1709. } = h
  1710. ;(this.elements.controls = null),
  1711. l.array(this.config.controls) &&
  1712. this.config.controls.includes('play-large') &&
  1713. this.elements.container.appendChild(t.call(this, 'play-large'))
  1714. const u = y('div', H(this.config.selectors.controls.wrapper))
  1715. this.elements.controls = u
  1716. const p = { class: 'plyr__controls__item' }
  1717. return (
  1718. Ne(l.array(this.config.controls) ? this.config.controls : []).forEach(
  1719. f => {
  1720. if (
  1721. (f === 'restart' && u.appendChild(t.call(this, 'restart', p)),
  1722. f === 'rewind' && u.appendChild(t.call(this, 'rewind', p)),
  1723. f === 'play' && u.appendChild(t.call(this, 'play', p)),
  1724. f === 'fast-forward' &&
  1725. u.appendChild(t.call(this, 'fast-forward', p)),
  1726. f === 'progress')
  1727. ) {
  1728. const d = y('div', {
  1729. class: `${p.class} plyr__progress__container`
  1730. }),
  1731. v = y('div', H(this.config.selectors.progress))
  1732. if (
  1733. (v.appendChild(n.call(this, 'seek', { id: `plyr-seek-${e.id}` })),
  1734. v.appendChild(s.call(this, 'buffer')),
  1735. this.config.tooltips.seek)
  1736. ) {
  1737. const T = y(
  1738. 'span',
  1739. { class: this.config.classNames.tooltip },
  1740. '00:00'
  1741. )
  1742. v.appendChild(T), (this.elements.display.seekTooltip = T)
  1743. }
  1744. ;(this.elements.progress = v),
  1745. d.appendChild(this.elements.progress),
  1746. u.appendChild(d)
  1747. }
  1748. if (
  1749. (f === 'current-time' &&
  1750. u.appendChild(a.call(this, 'currentTime', p)),
  1751. f === 'duration' && u.appendChild(a.call(this, 'duration', p)),
  1752. f === 'mute' || f === 'volume')
  1753. ) {
  1754. let { volume: d } = this.elements
  1755. if (
  1756. ((l.element(d) && u.contains(d)) ||
  1757. ((d = y(
  1758. 'div',
  1759. I({}, p, { class: `${p.class} plyr__volume`.trim() })
  1760. )),
  1761. (this.elements.volume = d),
  1762. u.appendChild(d)),
  1763. f === 'mute' && d.appendChild(t.call(this, 'mute')),
  1764. f === 'volume' && !_.isIos)
  1765. ) {
  1766. const v = { max: 1, step: 0.05, value: this.config.volume }
  1767. d.appendChild(
  1768. n.call(this, 'volume', I(v, { id: `plyr-volume-${e.id}` }))
  1769. )
  1770. }
  1771. }
  1772. if (
  1773. (f === 'captions' && u.appendChild(t.call(this, 'captions', p)),
  1774. f === 'settings' && !l.empty(this.config.settings))
  1775. ) {
  1776. const d = y(
  1777. 'div',
  1778. I({}, p, { class: `${p.class} plyr__menu`.trim(), hidden: '' })
  1779. )
  1780. d.appendChild(
  1781. t.call(this, 'settings', {
  1782. 'aria-haspopup': !0,
  1783. 'aria-controls': `plyr-settings-${e.id}`,
  1784. 'aria-expanded': !1
  1785. })
  1786. )
  1787. const v = y('div', {
  1788. class: 'plyr__menu__container',
  1789. id: `plyr-settings-${e.id}`,
  1790. hidden: ''
  1791. }),
  1792. T = y('div'),
  1793. k = y('div', { id: `plyr-settings-${e.id}-home` }),
  1794. N = y('div', { role: 'menu' })
  1795. k.appendChild(N),
  1796. T.appendChild(k),
  1797. (this.elements.settings.panels.home = k),
  1798. this.config.settings.forEach(w => {
  1799. const M = y(
  1800. 'button',
  1801. I(H(this.config.selectors.buttons.settings), {
  1802. type: 'button',
  1803. class: `${this.config.classNames.control} ${this.config.classNames.control}--forward`,
  1804. role: 'menuitem',
  1805. 'aria-haspopup': !0,
  1806. hidden: ''
  1807. })
  1808. )
  1809. i.call(this, M, w),
  1810. C.call(this, M, 'click', () => {
  1811. c.call(this, w, !1)
  1812. })
  1813. const g = y('span', null, $.get(w, this.config)),
  1814. S = y('span', { class: this.config.classNames.menu.value })
  1815. ;(S.innerHTML = e[w]),
  1816. g.appendChild(S),
  1817. M.appendChild(g),
  1818. N.appendChild(M)
  1819. const L = y('div', {
  1820. id: `plyr-settings-${e.id}-${w}`,
  1821. hidden: ''
  1822. }),
  1823. D = y('button', {
  1824. type: 'button',
  1825. class: `${this.config.classNames.control} ${this.config.classNames.control}--back`
  1826. })
  1827. D.appendChild(
  1828. y('span', { 'aria-hidden': !0 }, $.get(w, this.config))
  1829. ),
  1830. D.appendChild(
  1831. y(
  1832. 'span',
  1833. { class: this.config.classNames.hidden },
  1834. $.get('menuBack', this.config)
  1835. )
  1836. ),
  1837. C.call(
  1838. this,
  1839. L,
  1840. 'keydown',
  1841. W => {
  1842. W.key === 'ArrowLeft' &&
  1843. (W.preventDefault(),
  1844. W.stopPropagation(),
  1845. c.call(this, 'home', !0))
  1846. },
  1847. !1
  1848. ),
  1849. C.call(this, D, 'click', () => {
  1850. c.call(this, 'home', !1)
  1851. }),
  1852. L.appendChild(D),
  1853. L.appendChild(y('div', { role: 'menu' })),
  1854. T.appendChild(L),
  1855. (this.elements.settings.buttons[w] = M),
  1856. (this.elements.settings.panels[w] = L)
  1857. }),
  1858. v.appendChild(T),
  1859. d.appendChild(v),
  1860. u.appendChild(d),
  1861. (this.elements.settings.popup = v),
  1862. (this.elements.settings.menu = d)
  1863. }
  1864. if (
  1865. (f === 'pip' && x.pip && u.appendChild(t.call(this, 'pip', p)),
  1866. f === 'airplay' &&
  1867. x.airplay &&
  1868. u.appendChild(t.call(this, 'airplay', p)),
  1869. f === 'download')
  1870. ) {
  1871. const d = I({}, p, {
  1872. element: 'a',
  1873. href: this.download,
  1874. target: '_blank'
  1875. })
  1876. this.isHTML5 && (d.download = '')
  1877. const { download: v } = this.config.urls
  1878. !l.url(v) &&
  1879. this.isEmbed &&
  1880. I(d, { icon: `logo-${this.provider}`, label: this.provider }),
  1881. u.appendChild(t.call(this, 'download', d))
  1882. }
  1883. f === 'fullscreen' && u.appendChild(t.call(this, 'fullscreen', p))
  1884. }
  1885. ),
  1886. this.isHTML5 && r.call(this, K.getQualityOptions.call(this)),
  1887. o.call(this),
  1888. u
  1889. )
  1890. },
  1891. inject() {
  1892. if (this.config.loadSprite) {
  1893. const n = h.getIconUrl.call(this)
  1894. n.cors && ft(n.url, 'sprite-plyr')
  1895. }
  1896. this.id = Math.floor(1e4 * Math.random())
  1897. let e = null
  1898. this.elements.controls = null
  1899. const i = {
  1900. id: this.id,
  1901. seektime: this.config.seekTime,
  1902. title: this.config.title
  1903. }
  1904. let t = !0
  1905. l.function(this.config.controls) &&
  1906. (this.config.controls = this.config.controls.call(this, i)),
  1907. this.config.controls || (this.config.controls = []),
  1908. l.element(this.config.controls) || l.string(this.config.controls)
  1909. ? (e = this.config.controls)
  1910. : ((e = h.create.call(this, {
  1911. id: this.id,
  1912. seektime: this.config.seekTime,
  1913. speed: this.speed,
  1914. quality: this.quality,
  1915. captions: E.getLabel.call(this)
  1916. })),
  1917. (t = !1))
  1918. let s
  1919. if (
  1920. (t &&
  1921. l.string(this.config.controls) &&
  1922. (e = (n => {
  1923. let a = n
  1924. return (
  1925. Object.entries(i).forEach(([r, o]) => {
  1926. a = ne(a, `{${r}}`, o)
  1927. }),
  1928. a
  1929. )
  1930. })(e)),
  1931. l.string(this.config.selectors.controls.container) &&
  1932. (s = document.querySelector(this.config.selectors.controls.container)),
  1933. l.element(s) || (s = this.elements.container),
  1934. s[l.element(e) ? 'insertAdjacentElement' : 'insertAdjacentHTML'](
  1935. 'afterbegin',
  1936. e
  1937. ),
  1938. l.element(this.elements.controls) || h.findElements.call(this),
  1939. !l.empty(this.elements.buttons))
  1940. ) {
  1941. const n = a => {
  1942. const r = this.config.classNames.controlPressed
  1943. Object.defineProperty(a, 'pressed', {
  1944. enumerable: !0,
  1945. get: () => ge(a, r),
  1946. set(o = !1) {
  1947. A(a, r, o)
  1948. }
  1949. })
  1950. }
  1951. Object.values(this.elements.buttons)
  1952. .filter(Boolean)
  1953. .forEach(a => {
  1954. l.array(a) || l.nodeList(a)
  1955. ? Array.from(a).filter(Boolean).forEach(n)
  1956. : n(a)
  1957. })
  1958. }
  1959. if ((_.isEdge && nt(s), this.config.tooltips.controls)) {
  1960. const { classNames: n, selectors: a } = this.config,
  1961. r = `${a.controls.wrapper} ${a.labels} .${n.hidden}`,
  1962. o = Z.call(this, r)
  1963. Array.from(o).forEach(c => {
  1964. A(c, this.config.classNames.hidden, !1),
  1965. A(c, this.config.classNames.tooltip, !0)
  1966. })
  1967. }
  1968. },
  1969. setMediaMetadata() {
  1970. try {
  1971. 'mediaSession' in navigator &&
  1972. (navigator.mediaSession.metadata = new window.MediaMetadata({
  1973. title: this.config.mediaMetadata.title,
  1974. artist: this.config.mediaMetadata.artist,
  1975. album: this.config.mediaMetadata.album,
  1976. artwork: this.config.mediaMetadata.artwork
  1977. }))
  1978. } catch {}
  1979. },
  1980. setMarkers() {
  1981. var e, i
  1982. if (!this.duration || this.elements.markers) return
  1983. const t =
  1984. (e = this.config.markers) === null ||
  1985. e === void 0 ||
  1986. (i = e.points) === null ||
  1987. i === void 0
  1988. ? void 0
  1989. : i.filter(({ time: c }) => c > 0 && c < this.duration)
  1990. if (t == null || !t.length) return
  1991. const s = document.createDocumentFragment(),
  1992. n = document.createDocumentFragment()
  1993. let a = null
  1994. const r = `${this.config.classNames.tooltip}--visible`,
  1995. o = c => A(a, r, c)
  1996. t.forEach(c => {
  1997. const u = y('span', { class: this.config.classNames.marker }, ''),
  1998. p = (c.time / this.duration) * 100 + '%'
  1999. a &&
  2000. (u.addEventListener('mouseenter', () => {
  2001. c.label || ((a.style.left = p), (a.innerHTML = c.label), o(!0))
  2002. }),
  2003. u.addEventListener('mouseleave', () => {
  2004. o(!1)
  2005. })),
  2006. u.addEventListener('click', () => {
  2007. this.currentTime = c.time
  2008. }),
  2009. (u.style.left = p),
  2010. n.appendChild(u)
  2011. }),
  2012. s.appendChild(n),
  2013. this.config.tooltips.seek ||
  2014. ((a = y('span', { class: this.config.classNames.tooltip }, '')),
  2015. s.appendChild(a)),
  2016. (this.elements.markers = { points: n, tip: a }),
  2017. this.elements.progress.appendChild(s)
  2018. }
  2019. }
  2020. function bt(e, i = !0) {
  2021. let t = e
  2022. if (i) {
  2023. const s = document.createElement('a')
  2024. ;(s.href = t), (t = s.href)
  2025. }
  2026. try {
  2027. return new URL(t)
  2028. } catch {
  2029. return null
  2030. }
  2031. }
  2032. function vt(e) {
  2033. const i = new URLSearchParams()
  2034. return (
  2035. l.object(e) &&
  2036. Object.entries(e).forEach(([t, s]) => {
  2037. i.set(t, s)
  2038. }),
  2039. i
  2040. )
  2041. }
  2042. const E = {
  2043. setup() {
  2044. if (!this.supported.ui) return
  2045. if (!this.isVideo || this.isYouTube || (this.isHTML5 && !x.textTracks))
  2046. return void (
  2047. l.array(this.config.controls) &&
  2048. this.config.controls.includes('settings') &&
  2049. this.config.settings.includes('captions') &&
  2050. h.setCaptionsMenu.call(this)
  2051. )
  2052. if (
  2053. (l.element(this.elements.captions) ||
  2054. ((this.elements.captions = y(
  2055. 'div',
  2056. H(this.config.selectors.captions)
  2057. )),
  2058. gi(this.elements.captions, this.elements.wrapper)),
  2059. _.isIE && window.URL)
  2060. ) {
  2061. const s = this.media.querySelectorAll('track')
  2062. Array.from(s).forEach(n => {
  2063. const a = n.getAttribute('src'),
  2064. r = bt(a)
  2065. r !== null &&
  2066. r.hostname !== window.location.href.hostname &&
  2067. ['http:', 'https:'].includes(r.protocol) &&
  2068. le(a, 'blob')
  2069. .then(o => {
  2070. n.setAttribute('src', window.URL.createObjectURL(o))
  2071. })
  2072. .catch(() => {
  2073. z(n)
  2074. })
  2075. })
  2076. }
  2077. const e = Ne(
  2078. (
  2079. navigator.languages || [
  2080. navigator.language || navigator.userLanguage || 'en'
  2081. ]
  2082. ).map(s => s.split('-')[0])
  2083. )
  2084. let i = (
  2085. this.storage.get('language') ||
  2086. this.config.captions.language ||
  2087. 'auto'
  2088. ).toLowerCase()
  2089. i === 'auto' && ([i] = e)
  2090. let t = this.storage.get('captions')
  2091. if (
  2092. (l.boolean(t) || ({ active: t } = this.config.captions),
  2093. Object.assign(this.captions, {
  2094. toggled: !1,
  2095. active: t,
  2096. language: i,
  2097. languages: e
  2098. }),
  2099. this.isHTML5)
  2100. ) {
  2101. const s = this.config.captions.update
  2102. ? 'addtrack removetrack'
  2103. : 'removetrack'
  2104. C.call(this, this.media.textTracks, s, E.update.bind(this))
  2105. }
  2106. setTimeout(E.update.bind(this), 0)
  2107. },
  2108. update() {
  2109. const e = E.getTracks.call(this, !0),
  2110. {
  2111. active: i,
  2112. language: t,
  2113. meta: s,
  2114. currentTrackNode: n
  2115. } = this.captions,
  2116. a = Boolean(e.find(r => r.language === t))
  2117. this.isHTML5 &&
  2118. this.isVideo &&
  2119. e
  2120. .filter(r => !s.get(r))
  2121. .forEach(r => {
  2122. this.debug.log('Track added', r),
  2123. s.set(r, { default: r.mode === 'showing' }),
  2124. r.mode === 'showing' && (r.mode = 'hidden'),
  2125. C.call(this, r, 'cuechange', () => E.updateCues.call(this))
  2126. }),
  2127. ((a && this.language !== t) || !e.includes(n)) &&
  2128. (E.setLanguage.call(this, t), E.toggle.call(this, i && a)),
  2129. this.elements &&
  2130. A(
  2131. this.elements.container,
  2132. this.config.classNames.captions.enabled,
  2133. !l.empty(e)
  2134. ),
  2135. l.array(this.config.controls) &&
  2136. this.config.controls.includes('settings') &&
  2137. this.config.settings.includes('captions') &&
  2138. h.setCaptionsMenu.call(this)
  2139. },
  2140. toggle(e, i = !0) {
  2141. if (!this.supported.ui) return
  2142. const { toggled: t } = this.captions,
  2143. s = this.config.classNames.captions.active,
  2144. n = l.nullOrUndefined(e) ? !t : e
  2145. if (n !== t) {
  2146. if (
  2147. (i || ((this.captions.active = n), this.storage.set({ captions: n })),
  2148. !this.language && n && !i)
  2149. ) {
  2150. const a = E.getTracks.call(this),
  2151. r = E.findTrack.call(
  2152. this,
  2153. [this.captions.language, ...this.captions.languages],
  2154. !0
  2155. )
  2156. return (
  2157. (this.captions.language = r.language),
  2158. void E.set.call(this, a.indexOf(r))
  2159. )
  2160. }
  2161. this.elements.buttons.captions &&
  2162. (this.elements.buttons.captions.pressed = n),
  2163. A(this.elements.container, s, n),
  2164. (this.captions.toggled = n),
  2165. h.updateSetting.call(this, 'captions'),
  2166. b.call(this, this.media, n ? 'captionsenabled' : 'captionsdisabled')
  2167. }
  2168. setTimeout(() => {
  2169. n &&
  2170. this.captions.toggled &&
  2171. (this.captions.currentTrackNode.mode = 'hidden')
  2172. })
  2173. },
  2174. set(e, i = !0) {
  2175. const t = E.getTracks.call(this)
  2176. if (e !== -1)
  2177. if (l.number(e))
  2178. if (e in t) {
  2179. if (this.captions.currentTrack !== e) {
  2180. this.captions.currentTrack = e
  2181. const s = t[e],
  2182. { language: n } = s || {}
  2183. ;(this.captions.currentTrackNode = s),
  2184. h.updateSetting.call(this, 'captions'),
  2185. i ||
  2186. ((this.captions.language = n),
  2187. this.storage.set({ language: n })),
  2188. this.isVimeo && this.embed.enableTextTrack(n),
  2189. b.call(this, this.media, 'languagechange')
  2190. }
  2191. E.toggle.call(this, !0, i),
  2192. this.isHTML5 && this.isVideo && E.updateCues.call(this)
  2193. } else this.debug.warn('Track not found', e)
  2194. else this.debug.warn('Invalid caption argument', e)
  2195. else E.toggle.call(this, !1, i)
  2196. },
  2197. setLanguage(e, i = !0) {
  2198. if (!l.string(e))
  2199. return void this.debug.warn('Invalid language argument', e)
  2200. const t = e.toLowerCase()
  2201. this.captions.language = t
  2202. const s = E.getTracks.call(this),
  2203. n = E.findTrack.call(this, [t])
  2204. E.set.call(this, s.indexOf(n), i)
  2205. },
  2206. getTracks(e = !1) {
  2207. return Array.from((this.media || {}).textTracks || [])
  2208. .filter(i => !this.isHTML5 || e || this.captions.meta.has(i))
  2209. .filter(i => ['captions', 'subtitles'].includes(i.kind))
  2210. },
  2211. findTrack(e, i = !1) {
  2212. const t = E.getTracks.call(this),
  2213. s = r => Number((this.captions.meta.get(r) || {}).default),
  2214. n = Array.from(t).sort((r, o) => s(o) - s(r))
  2215. let a
  2216. return (
  2217. e.every(r => ((a = n.find(o => o.language === r)), !a)),
  2218. a || (i ? n[0] : void 0)
  2219. )
  2220. },
  2221. getCurrentTrack() {
  2222. return E.getTracks.call(this)[this.currentTrack]
  2223. },
  2224. getLabel(e) {
  2225. let i = e
  2226. return (
  2227. !l.track(i) &&
  2228. x.textTracks &&
  2229. this.captions.toggled &&
  2230. (i = E.getCurrentTrack.call(this)),
  2231. l.track(i)
  2232. ? l.empty(i.label)
  2233. ? l.empty(i.language)
  2234. ? $.get('enabled', this.config)
  2235. : e.language.toUpperCase()
  2236. : i.label
  2237. : $.get('disabled', this.config)
  2238. )
  2239. },
  2240. updateCues(e) {
  2241. if (!this.supported.ui) return
  2242. if (!l.element(this.elements.captions))
  2243. return void this.debug.warn('No captions element to render to')
  2244. if (!l.nullOrUndefined(e) && !Array.isArray(e))
  2245. return void this.debug.warn('updateCues: Invalid input', e)
  2246. let i = e
  2247. if (!i) {
  2248. const s = E.getCurrentTrack.call(this)
  2249. i = Array.from((s || {}).activeCues || [])
  2250. .map(n => n.getCueAsHTML())
  2251. .map(Ei)
  2252. }
  2253. const t = i.map(s => s.trim()).join(`
  2254. `)
  2255. if (t !== this.elements.captions.innerHTML) {
  2256. me(this.elements.captions)
  2257. const s = y('span', H(this.config.selectors.caption))
  2258. ;(s.innerHTML = t),
  2259. this.elements.captions.appendChild(s),
  2260. b.call(this, this.media, 'cuechange')
  2261. }
  2262. }
  2263. },
  2264. wt = {
  2265. enabled: !0,
  2266. title: '',
  2267. debug: !1,
  2268. autoplay: !1,
  2269. autopause: !0,
  2270. playsinline: !0,
  2271. seekTime: 10,
  2272. volume: 1,
  2273. muted: !1,
  2274. duration: null,
  2275. displayDuration: !0,
  2276. invertTime: !0,
  2277. toggleInvert: !0,
  2278. ratio: null,
  2279. clickToPlay: !0,
  2280. hideControls: !0,
  2281. resetOnEnd: !1,
  2282. disableContextMenu: !0,
  2283. loadSprite: !0,
  2284. iconPrefix: 'plyr',
  2285. iconUrl: 'https://cdn.plyr.io/3.7.2/plyr.svg',
  2286. blankVideo: 'https://cdn.plyr.io/static/blank.mp4',
  2287. quality: {
  2288. default: 576,
  2289. options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240],
  2290. forced: !1,
  2291. onChange: null
  2292. },
  2293. loop: { active: !1 },
  2294. speed: { selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 4] },
  2295. keyboard: { focused: !0, global: !1 },
  2296. tooltips: { controls: !1, seek: !0 },
  2297. captions: { active: !1, language: 'auto', update: !1 },
  2298. fullscreen: { enabled: !0, fallback: !0, iosNative: !1 },
  2299. storage: { enabled: !0, key: 'plyr' },
  2300. controls: [
  2301. 'play-large',
  2302. 'play',
  2303. 'progress',
  2304. 'current-time',
  2305. 'mute',
  2306. 'volume',
  2307. 'captions',
  2308. 'settings',
  2309. 'pip',
  2310. 'airplay',
  2311. 'fullscreen'
  2312. ],
  2313. settings: ['captions', 'quality', 'speed'],
  2314. i18n: {
  2315. restart: 'Restart',
  2316. rewind: 'Rewind {seektime}s',
  2317. play: 'Play',
  2318. pause: 'Pause',
  2319. fastForward: 'Forward {seektime}s',
  2320. seek: 'Seek',
  2321. seekLabel: '{currentTime} of {duration}',
  2322. played: 'Played',
  2323. buffered: 'Buffered',
  2324. currentTime: 'Current time',
  2325. duration: 'Duration',
  2326. volume: 'Volume',
  2327. mute: 'Mute',
  2328. unmute: 'Unmute',
  2329. enableCaptions: 'Enable captions',
  2330. disableCaptions: 'Disable captions',
  2331. download: 'Download',
  2332. enterFullscreen: 'Enter fullscreen',
  2333. exitFullscreen: 'Exit fullscreen',
  2334. frameTitle: 'Player for {title}',
  2335. captions: 'Captions',
  2336. settings: 'Settings',
  2337. pip: 'PIP',
  2338. menuBack: 'Go back to previous menu',
  2339. speed: 'Speed',
  2340. normal: 'Normal',
  2341. quality: 'Quality',
  2342. loop: 'Loop',
  2343. start: 'Start',
  2344. end: 'End',
  2345. all: 'All',
  2346. reset: 'Reset',
  2347. disabled: 'Disabled',
  2348. enabled: 'Enabled',
  2349. advertisement: 'Ad',
  2350. qualityBadge: {
  2351. 2160: '4K',
  2352. 1440: 'HD',
  2353. 1080: 'HD',
  2354. 720: 'HD',
  2355. 576: 'SD',
  2356. 480: 'SD'
  2357. }
  2358. },
  2359. urls: {
  2360. download: null,
  2361. vimeo: {
  2362. sdk: 'https://player.vimeo.com/api/player.js',
  2363. iframe: 'https://player.vimeo.com/video/{0}?{1}',
  2364. api: 'https://vimeo.com/api/oembed.json?url={0}'
  2365. },
  2366. youtube: {
  2367. sdk: 'https://www.youtube.com/iframe_api',
  2368. api: 'https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}'
  2369. },
  2370. googleIMA: { sdk: 'https://imasdk.googleapis.com/js/sdkloader/ima3.js' }
  2371. },
  2372. listeners: {
  2373. seek: null,
  2374. play: null,
  2375. pause: null,
  2376. restart: null,
  2377. rewind: null,
  2378. fastForward: null,
  2379. mute: null,
  2380. volume: null,
  2381. captions: null,
  2382. download: null,
  2383. fullscreen: null,
  2384. pip: null,
  2385. airplay: null,
  2386. speed: null,
  2387. quality: null,
  2388. loop: null,
  2389. language: null
  2390. },
  2391. events: [
  2392. 'ended',
  2393. 'progress',
  2394. 'stalled',
  2395. 'playing',
  2396. 'waiting',
  2397. 'canplay',
  2398. 'canplaythrough',
  2399. 'loadstart',
  2400. 'loadeddata',
  2401. 'loadedmetadata',
  2402. 'timeupdate',
  2403. 'volumechange',
  2404. 'play',
  2405. 'pause',
  2406. 'error',
  2407. 'seeking',
  2408. 'seeked',
  2409. 'emptied',
  2410. 'ratechange',
  2411. 'cuechange',
  2412. 'download',
  2413. 'enterfullscreen',
  2414. 'exitfullscreen',
  2415. 'captionsenabled',
  2416. 'captionsdisabled',
  2417. 'languagechange',
  2418. 'controlshidden',
  2419. 'controlsshown',
  2420. 'ready',
  2421. 'statechange',
  2422. 'qualitychange',
  2423. 'adsloaded',
  2424. 'adscontentpause',
  2425. 'adscontentresume',
  2426. 'adstarted',
  2427. 'adsmidpoint',
  2428. 'adscomplete',
  2429. 'adsallcomplete',
  2430. 'adsimpression',
  2431. 'adsclick'
  2432. ],
  2433. selectors: {
  2434. editable: 'input, textarea, select, [contenteditable]',
  2435. container: '.plyr',
  2436. controls: { container: null, wrapper: '.plyr__controls' },
  2437. labels: '[data-plyr]',
  2438. buttons: {
  2439. play: '[data-plyr="play"]',
  2440. pause: '[data-plyr="pause"]',
  2441. restart: '[data-plyr="restart"]',
  2442. rewind: '[data-plyr="rewind"]',
  2443. fastForward: '[data-plyr="fast-forward"]',
  2444. mute: '[data-plyr="mute"]',
  2445. captions: '[data-plyr="captions"]',
  2446. download: '[data-plyr="download"]',
  2447. fullscreen: '[data-plyr="fullscreen"]',
  2448. pip: '[data-plyr="pip"]',
  2449. airplay: '[data-plyr="airplay"]',
  2450. settings: '[data-plyr="settings"]',
  2451. loop: '[data-plyr="loop"]'
  2452. },
  2453. inputs: {
  2454. seek: '[data-plyr="seek"]',
  2455. volume: '[data-plyr="volume"]',
  2456. speed: '[data-plyr="speed"]',
  2457. language: '[data-plyr="language"]',
  2458. quality: '[data-plyr="quality"]'
  2459. },
  2460. display: {
  2461. currentTime: '.plyr__time--current',
  2462. duration: '.plyr__time--duration',
  2463. buffer: '.plyr__progress__buffer',
  2464. loop: '.plyr__progress__loop',
  2465. volume: '.plyr__volume--display'
  2466. },
  2467. progress: '.plyr__progress',
  2468. captions: '.plyr__captions',
  2469. caption: '.plyr__caption'
  2470. },
  2471. classNames: {
  2472. type: 'plyr--{0}',
  2473. provider: 'plyr--{0}',
  2474. video: 'plyr__video-wrapper',
  2475. embed: 'plyr__video-embed',
  2476. videoFixedRatio: 'plyr__video-wrapper--fixed-ratio',
  2477. embedContainer: 'plyr__video-embed__container',
  2478. poster: 'plyr__poster',
  2479. posterEnabled: 'plyr__poster-enabled',
  2480. ads: 'plyr__ads',
  2481. control: 'plyr__control',
  2482. controlPressed: 'plyr__control--pressed',
  2483. playing: 'plyr--playing',
  2484. paused: 'plyr--paused',
  2485. stopped: 'plyr--stopped',
  2486. loading: 'plyr--loading',
  2487. hover: 'plyr--hover',
  2488. tooltip: 'plyr__tooltip',
  2489. cues: 'plyr__cues',
  2490. marker: 'plyr__progress__marker',
  2491. hidden: 'plyr__sr-only',
  2492. hideControls: 'plyr--hide-controls',
  2493. isIos: 'plyr--is-ios',
  2494. isTouch: 'plyr--is-touch',
  2495. uiSupported: 'plyr--full-ui',
  2496. noTransition: 'plyr--no-transition',
  2497. display: { time: 'plyr__time' },
  2498. menu: {
  2499. value: 'plyr__menu__value',
  2500. badge: 'plyr__badge',
  2501. open: 'plyr--menu-open'
  2502. },
  2503. captions: {
  2504. enabled: 'plyr--captions-enabled',
  2505. active: 'plyr--captions-active'
  2506. },
  2507. fullscreen: {
  2508. enabled: 'plyr--fullscreen-enabled',
  2509. fallback: 'plyr--fullscreen-fallback'
  2510. },
  2511. pip: { supported: 'plyr--pip-supported', active: 'plyr--pip-active' },
  2512. airplay: {
  2513. supported: 'plyr--airplay-supported',
  2514. active: 'plyr--airplay-active'
  2515. },
  2516. tabFocus: 'plyr__tab-focus',
  2517. previewThumbnails: {
  2518. thumbContainer: 'plyr__preview-thumb',
  2519. thumbContainerShown: 'plyr__preview-thumb--is-shown',
  2520. imageContainer: 'plyr__preview-thumb__image-container',
  2521. timeContainer: 'plyr__preview-thumb__time-container',
  2522. scrubbingContainer: 'plyr__preview-scrubbing',
  2523. scrubbingContainerShown: 'plyr__preview-scrubbing--is-shown'
  2524. }
  2525. },
  2526. attributes: {
  2527. embed: {
  2528. provider: 'data-plyr-provider',
  2529. id: 'data-plyr-embed-id',
  2530. hash: 'data-plyr-embed-hash'
  2531. }
  2532. },
  2533. ads: { enabled: !1, publisherId: '', tagUrl: '' },
  2534. previewThumbnails: { enabled: !1, src: '' },
  2535. vimeo: {
  2536. byline: !1,
  2537. portrait: !1,
  2538. title: !1,
  2539. speed: !0,
  2540. transparent: !1,
  2541. customControls: !0,
  2542. referrerPolicy: null,
  2543. premium: !1
  2544. },
  2545. youtube: {
  2546. rel: 0,
  2547. showinfo: 0,
  2548. iv_load_policy: 3,
  2549. modestbranding: 1,
  2550. customControls: !0,
  2551. noCookie: !1
  2552. },
  2553. mediaMetadata: { title: '', artist: '', album: '', artwork: [] },
  2554. markers: { enabled: !1, points: [] }
  2555. },
  2556. Ie = { active: 'picture-in-picture', inactive: 'inline' },
  2557. Y = { html5: 'html5', youtube: 'youtube', vimeo: 'vimeo' },
  2558. Le = { audio: 'audio', video: 'video' }
  2559. function Ni(e) {
  2560. return /^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(
  2561. e
  2562. )
  2563. ? Y.youtube
  2564. : /^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(e)
  2565. ? Y.vimeo
  2566. : null
  2567. }
  2568. const Oe = () => {}
  2569. class Mi {
  2570. constructor(i = !1) {
  2571. ;(this.enabled = window.console && i),
  2572. this.enabled && this.log('Debugging enabled')
  2573. }
  2574. get log() {
  2575. return this.enabled
  2576. ? Function.prototype.bind.call(console.log, console)
  2577. : Oe
  2578. }
  2579. get warn() {
  2580. return this.enabled
  2581. ? Function.prototype.bind.call(console.warn, console)
  2582. : Oe
  2583. }
  2584. get error() {
  2585. return this.enabled
  2586. ? Function.prototype.bind.call(console.error, console)
  2587. : Oe
  2588. }
  2589. }
  2590. class F {
  2591. constructor(i) {
  2592. m(this, 'onChange', () => {
  2593. if (!this.enabled) return
  2594. const t = this.player.elements.buttons.fullscreen
  2595. l.element(t) && (t.pressed = this.active)
  2596. const s =
  2597. this.target === this.player.media
  2598. ? this.target
  2599. : this.player.elements.container
  2600. b.call(
  2601. this.player,
  2602. s,
  2603. this.active ? 'enterfullscreen' : 'exitfullscreen',
  2604. !0
  2605. )
  2606. }),
  2607. m(this, 'toggleFallback', (t = !1) => {
  2608. if (
  2609. (t
  2610. ? (this.scrollPosition = {
  2611. x: window.scrollX || 0,
  2612. y: window.scrollY || 0
  2613. })
  2614. : window.scrollTo(this.scrollPosition.x, this.scrollPosition.y),
  2615. (document.body.style.overflow = t ? 'hidden' : ''),
  2616. A(this.target, this.player.config.classNames.fullscreen.fallback, t),
  2617. _.isIos)
  2618. ) {
  2619. let s = document.head.querySelector('meta[name="viewport"]')
  2620. const n = 'viewport-fit=cover'
  2621. s ||
  2622. ((s = document.createElement('meta')),
  2623. s.setAttribute('name', 'viewport'))
  2624. const a = l.string(s.content) && s.content.includes(n)
  2625. t
  2626. ? ((this.cleanupViewport = !a), a || (s.content += `,${n}`))
  2627. : this.cleanupViewport &&
  2628. (s.content = s.content
  2629. .split(',')
  2630. .filter(r => r.trim() !== n)
  2631. .join(','))
  2632. }
  2633. this.onChange()
  2634. }),
  2635. m(this, 'trapFocus', t => {
  2636. if (_.isIos || !this.active || t.key !== 'Tab') return
  2637. const s = document.activeElement,
  2638. n = Z.call(
  2639. this.player,
  2640. 'a[href], button:not(:disabled), input:not(:disabled), [tabindex]'
  2641. ),
  2642. [a] = n,
  2643. r = n[n.length - 1]
  2644. s !== r || t.shiftKey
  2645. ? s === a && t.shiftKey && (r.focus(), t.preventDefault())
  2646. : (a.focus(), t.preventDefault())
  2647. }),
  2648. m(this, 'update', () => {
  2649. if (this.enabled) {
  2650. let t
  2651. ;(t = this.forceFallback
  2652. ? 'Fallback (forced)'
  2653. : F.native
  2654. ? 'Native'
  2655. : 'Fallback'),
  2656. this.player.debug.log(`${t} fullscreen enabled`)
  2657. } else
  2658. this.player.debug.log(
  2659. 'Fullscreen not supported and fallback disabled'
  2660. )
  2661. A(
  2662. this.player.elements.container,
  2663. this.player.config.classNames.fullscreen.enabled,
  2664. this.enabled
  2665. )
  2666. }),
  2667. m(this, 'enter', () => {
  2668. this.enabled &&
  2669. (_.isIos && this.player.config.fullscreen.iosNative
  2670. ? this.player.isVimeo
  2671. ? this.player.embed.requestFullscreen()
  2672. : this.target.webkitEnterFullscreen()
  2673. : !F.native || this.forceFallback
  2674. ? this.toggleFallback(!0)
  2675. : this.prefix
  2676. ? l.empty(this.prefix) ||
  2677. this.target[`${this.prefix}Request${this.property}`]()
  2678. : this.target.requestFullscreen({ navigationUI: 'hide' }))
  2679. }),
  2680. m(this, 'exit', () => {
  2681. if (this.enabled)
  2682. if (_.isIos && this.player.config.fullscreen.iosNative)
  2683. this.target.webkitExitFullscreen(), V(this.player.play())
  2684. else if (!F.native || this.forceFallback) this.toggleFallback(!1)
  2685. else if (this.prefix) {
  2686. if (!l.empty(this.prefix)) {
  2687. const t = this.prefix === 'moz' ? 'Cancel' : 'Exit'
  2688. document[`${this.prefix}${t}${this.property}`]()
  2689. }
  2690. } else
  2691. (document.cancelFullScreen || document.exitFullscreen).call(
  2692. document
  2693. )
  2694. }),
  2695. m(this, 'toggle', () => {
  2696. this.active ? this.exit() : this.enter()
  2697. }),
  2698. (this.player = i),
  2699. (this.prefix = F.prefix),
  2700. (this.property = F.property),
  2701. (this.scrollPosition = { x: 0, y: 0 }),
  2702. (this.forceFallback = i.config.fullscreen.fallback === 'force'),
  2703. (this.player.elements.fullscreen =
  2704. i.config.fullscreen.container &&
  2705. fi(this.player.elements.container, i.config.fullscreen.container)),
  2706. C.call(
  2707. this.player,
  2708. document,
  2709. this.prefix === 'ms'
  2710. ? 'MSFullscreenChange'
  2711. : `${this.prefix}fullscreenchange`,
  2712. () => {
  2713. this.onChange()
  2714. }
  2715. ),
  2716. C.call(this.player, this.player.elements.container, 'dblclick', t => {
  2717. ;(l.element(this.player.elements.controls) &&
  2718. this.player.elements.controls.contains(t.target)) ||
  2719. this.player.listeners.proxy(t, this.toggle, 'fullscreen')
  2720. }),
  2721. C.call(this, this.player.elements.container, 'keydown', t =>
  2722. this.trapFocus(t)
  2723. ),
  2724. this.update()
  2725. }
  2726. static get native() {
  2727. return !!(
  2728. document.fullscreenEnabled ||
  2729. document.webkitFullscreenEnabled ||
  2730. document.mozFullScreenEnabled ||
  2731. document.msFullscreenEnabled
  2732. )
  2733. }
  2734. get usingNative() {
  2735. return F.native && !this.forceFallback
  2736. }
  2737. static get prefix() {
  2738. if (l.function(document.exitFullscreen)) return ''
  2739. let i = ''
  2740. return (
  2741. ['webkit', 'moz', 'ms'].some(
  2742. t =>
  2743. !(
  2744. !l.function(document[`${t}ExitFullscreen`]) &&
  2745. !l.function(document[`${t}CancelFullScreen`])
  2746. ) && ((i = t), !0)
  2747. ),
  2748. i
  2749. )
  2750. }
  2751. static get property() {
  2752. return this.prefix === 'moz' ? 'FullScreen' : 'Fullscreen'
  2753. }
  2754. get enabled() {
  2755. return (
  2756. (F.native || this.player.config.fullscreen.fallback) &&
  2757. this.player.config.fullscreen.enabled &&
  2758. this.player.supported.ui &&
  2759. this.player.isVideo
  2760. )
  2761. }
  2762. get active() {
  2763. if (!this.enabled) return !1
  2764. if (!F.native || this.forceFallback)
  2765. return ge(this.target, this.player.config.classNames.fullscreen.fallback)
  2766. const i = this.prefix
  2767. ? this.target.getRootNode()[`${this.prefix}${this.property}Element`]
  2768. : this.target.getRootNode().fullscreenElement
  2769. return i && i.shadowRoot
  2770. ? i === this.target.getRootNode().host
  2771. : i === this.target
  2772. }
  2773. get target() {
  2774. return _.isIos && this.player.config.fullscreen.iosNative
  2775. ? this.player.media
  2776. : this.player.elements.fullscreen || this.player.elements.container
  2777. }
  2778. }
  2779. function ve(e, i = 1) {
  2780. return new Promise((t, s) => {
  2781. const n = new Image(),
  2782. a = () => {
  2783. delete n.onload, delete n.onerror, (n.naturalWidth >= i ? t : s)(n)
  2784. }
  2785. Object.assign(n, { onload: a, onerror: a, src: e })
  2786. })
  2787. }
  2788. const P = {
  2789. addStyleHook() {
  2790. A(
  2791. this.elements.container,
  2792. this.config.selectors.container.replace('.', ''),
  2793. !0
  2794. ),
  2795. A(
  2796. this.elements.container,
  2797. this.config.classNames.uiSupported,
  2798. this.supported.ui
  2799. )
  2800. },
  2801. toggleNativeControls(e = !1) {
  2802. e && this.isHTML5
  2803. ? this.media.setAttribute('controls', '')
  2804. : this.media.removeAttribute('controls')
  2805. },
  2806. build() {
  2807. if ((this.listeners.media(), !this.supported.ui))
  2808. return (
  2809. this.debug.warn(`Basic support only for ${this.provider} ${this.type}`),
  2810. void P.toggleNativeControls.call(this, !0)
  2811. )
  2812. l.element(this.elements.controls) ||
  2813. (h.inject.call(this), this.listeners.controls()),
  2814. P.toggleNativeControls.call(this),
  2815. this.isHTML5 && E.setup.call(this),
  2816. (this.volume = null),
  2817. (this.muted = null),
  2818. (this.loop = null),
  2819. (this.quality = null),
  2820. (this.speed = null),
  2821. h.updateVolume.call(this),
  2822. h.timeUpdate.call(this),
  2823. h.durationUpdate.call(this),
  2824. P.checkPlaying.call(this),
  2825. A(
  2826. this.elements.container,
  2827. this.config.classNames.pip.supported,
  2828. x.pip && this.isHTML5 && this.isVideo
  2829. ),
  2830. A(
  2831. this.elements.container,
  2832. this.config.classNames.airplay.supported,
  2833. x.airplay && this.isHTML5
  2834. ),
  2835. A(this.elements.container, this.config.classNames.isIos, _.isIos),
  2836. A(this.elements.container, this.config.classNames.isTouch, this.touch),
  2837. (this.ready = !0),
  2838. setTimeout(() => {
  2839. b.call(this, this.media, 'ready')
  2840. }, 0),
  2841. P.setTitle.call(this),
  2842. this.poster && P.setPoster.call(this, this.poster, !1).catch(() => {}),
  2843. this.config.duration && h.durationUpdate.call(this),
  2844. this.config.mediaMetadata && h.setMediaMetadata.call(this)
  2845. },
  2846. setTitle() {
  2847. let e = $.get('play', this.config)
  2848. if (
  2849. (l.string(this.config.title) &&
  2850. !l.empty(this.config.title) &&
  2851. (e += `, ${this.config.title}`),
  2852. Array.from(this.elements.buttons.play || []).forEach(i => {
  2853. i.setAttribute('aria-label', e)
  2854. }),
  2855. this.isEmbed)
  2856. ) {
  2857. const i = O.call(this, 'iframe')
  2858. if (!l.element(i)) return
  2859. const t = l.empty(this.config.title) ? 'video' : this.config.title,
  2860. s = $.get('frameTitle', this.config)
  2861. i.setAttribute('title', s.replace('{title}', t))
  2862. }
  2863. },
  2864. togglePoster(e) {
  2865. A(this.elements.container, this.config.classNames.posterEnabled, e)
  2866. },
  2867. setPoster(e, i = !0) {
  2868. return i && this.poster
  2869. ? Promise.reject(new Error('Poster already set'))
  2870. : (this.media.setAttribute('data-poster', e),
  2871. this.elements.poster.removeAttribute('hidden'),
  2872. vi
  2873. .call(this)
  2874. .then(() => ve(e))
  2875. .catch(t => {
  2876. throw (e === this.poster && P.togglePoster.call(this, !1), t)
  2877. })
  2878. .then(() => {
  2879. if (e !== this.poster)
  2880. throw new Error('setPoster cancelled by later call to setPoster')
  2881. })
  2882. .then(
  2883. () => (
  2884. Object.assign(this.elements.poster.style, {
  2885. backgroundImage: `url('${e}')`,
  2886. backgroundSize: ''
  2887. }),
  2888. P.togglePoster.call(this, !0),
  2889. e
  2890. )
  2891. ))
  2892. },
  2893. checkPlaying(e) {
  2894. A(this.elements.container, this.config.classNames.playing, this.playing),
  2895. A(this.elements.container, this.config.classNames.paused, this.paused),
  2896. A(this.elements.container, this.config.classNames.stopped, this.stopped),
  2897. Array.from(this.elements.buttons.play || []).forEach(i => {
  2898. Object.assign(i, { pressed: this.playing }),
  2899. i.setAttribute(
  2900. 'aria-label',
  2901. $.get(this.playing ? 'pause' : 'play', this.config)
  2902. )
  2903. }),
  2904. (l.event(e) && e.type === 'timeupdate') || P.toggleControls.call(this)
  2905. },
  2906. checkLoading(e) {
  2907. ;(this.loading = ['stalled', 'waiting'].includes(e.type)),
  2908. clearTimeout(this.timers.loading),
  2909. (this.timers.loading = setTimeout(
  2910. () => {
  2911. A(
  2912. this.elements.container,
  2913. this.config.classNames.loading,
  2914. this.loading
  2915. ),
  2916. P.toggleControls.call(this)
  2917. },
  2918. this.loading ? 250 : 0
  2919. ))
  2920. },
  2921. toggleControls(e) {
  2922. const { controls: i } = this.elements
  2923. if (i && this.config.hideControls) {
  2924. const t = this.touch && this.lastSeekTime + 2e3 > Date.now()
  2925. this.toggleControls(
  2926. Boolean(e || this.loading || this.paused || i.pressed || i.hover || t)
  2927. )
  2928. }
  2929. },
  2930. migrateStyles() {
  2931. Object.values(q({}, this.media.style))
  2932. .filter(e => !l.empty(e) && l.string(e) && e.startsWith('--plyr'))
  2933. .forEach(e => {
  2934. this.elements.container.style.setProperty(
  2935. e,
  2936. this.media.style.getPropertyValue(e)
  2937. ),
  2938. this.media.style.removeProperty(e)
  2939. }),
  2940. l.empty(this.media.style) && this.media.removeAttribute('style')
  2941. }
  2942. }
  2943. class xi {
  2944. constructor(i) {
  2945. m(this, 'firstTouch', () => {
  2946. const { player: t } = this,
  2947. { elements: s } = t
  2948. ;(t.touch = !0), A(s.container, t.config.classNames.isTouch, !0)
  2949. }),
  2950. m(this, 'setTabFocus', t => {
  2951. const { player: s } = this,
  2952. { elements: n } = s,
  2953. { key: a, type: r, timeStamp: o } = t
  2954. if ((clearTimeout(this.focusTimer), r === 'keydown' && a !== 'Tab'))
  2955. return
  2956. r === 'keydown' && (this.lastKeyDown = o)
  2957. const c = o - this.lastKeyDown <= 20
  2958. ;(r !== 'focus' || c) &&
  2959. ((() => {
  2960. const u = s.config.classNames.tabFocus
  2961. A(Z.call(s, `.${u}`), u, !1)
  2962. })(),
  2963. r !== 'focusout' &&
  2964. (this.focusTimer = setTimeout(() => {
  2965. const u = document.activeElement
  2966. n.container.contains(u) &&
  2967. A(document.activeElement, s.config.classNames.tabFocus, !0)
  2968. }, 10)))
  2969. }),
  2970. m(this, 'global', (t = !0) => {
  2971. const { player: s } = this
  2972. s.config.keyboard.global &&
  2973. ee.call(s, window, 'keydown keyup', this.handleKey, t, !1),
  2974. ee.call(s, document.body, 'click', this.toggleMenu, t),
  2975. Pe.call(s, document.body, 'touchstart', this.firstTouch),
  2976. ee.call(
  2977. s,
  2978. document.body,
  2979. 'keydown focus blur focusout',
  2980. this.setTabFocus,
  2981. t,
  2982. !1,
  2983. !0
  2984. )
  2985. }),
  2986. m(this, 'container', () => {
  2987. const { player: t } = this,
  2988. { config: s, elements: n, timers: a } = t
  2989. !s.keyboard.global &&
  2990. s.keyboard.focused &&
  2991. C.call(t, n.container, 'keydown keyup', this.handleKey, !1),
  2992. C.call(
  2993. t,
  2994. n.container,
  2995. 'mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen',
  2996. c => {
  2997. const { controls: u } = n
  2998. u &&
  2999. c.type === 'enterfullscreen' &&
  3000. ((u.pressed = !1), (u.hover = !1))
  3001. let p = 0
  3002. ;['touchstart', 'touchmove', 'mousemove'].includes(c.type) &&
  3003. (P.toggleControls.call(t, !0), (p = t.touch ? 3e3 : 2e3)),
  3004. clearTimeout(a.controls),
  3005. (a.controls = setTimeout(() => P.toggleControls.call(t, !1), p))
  3006. }
  3007. )
  3008. const r = () => {
  3009. if (!t.isVimeo || t.config.vimeo.premium) return
  3010. const c = n.wrapper,
  3011. { active: u } = t.fullscreen,
  3012. [p, f] = Me.call(t),
  3013. d = ut(`aspect-ratio: ${p} / ${f}`)
  3014. if (!u)
  3015. return void (d
  3016. ? ((c.style.width = null), (c.style.height = null))
  3017. : ((c.style.maxWidth = null), (c.style.margin = null)))
  3018. const [v, T] = wi(),
  3019. k = v / T > p / f
  3020. d
  3021. ? ((c.style.width = k ? 'auto' : '100%'),
  3022. (c.style.height = k ? '100%' : 'auto'))
  3023. : ((c.style.maxWidth = k ? (T / f) * p + 'px' : null),
  3024. (c.style.margin = k ? '0 auto' : null))
  3025. },
  3026. o = () => {
  3027. clearTimeout(a.resized), (a.resized = setTimeout(r, 50))
  3028. }
  3029. C.call(t, n.container, 'enterfullscreen exitfullscreen', c => {
  3030. const { target: u } = t.fullscreen
  3031. u === n.container &&
  3032. ((!t.isEmbed && l.empty(t.config.ratio)) ||
  3033. (r(),
  3034. (c.type === 'enterfullscreen' ? C : fe).call(
  3035. t,
  3036. window,
  3037. 'resize',
  3038. o
  3039. )))
  3040. })
  3041. }),
  3042. m(this, 'media', () => {
  3043. const { player: t } = this,
  3044. { elements: s } = t
  3045. if (
  3046. (C.call(t, t.media, 'timeupdate seeking seeked', a =>
  3047. h.timeUpdate.call(t, a)
  3048. ),
  3049. C.call(t, t.media, 'durationchange loadeddata loadedmetadata', a =>
  3050. h.durationUpdate.call(t, a)
  3051. ),
  3052. C.call(t, t.media, 'ended', () => {
  3053. t.isHTML5 &&
  3054. t.isVideo &&
  3055. t.config.resetOnEnd &&
  3056. (t.restart(), t.pause())
  3057. }),
  3058. C.call(t, t.media, 'progress playing seeking seeked', a =>
  3059. h.updateProgress.call(t, a)
  3060. ),
  3061. C.call(t, t.media, 'volumechange', a => h.updateVolume.call(t, a)),
  3062. C.call(t, t.media, 'playing play pause ended emptied timeupdate', a =>
  3063. P.checkPlaying.call(t, a)
  3064. ),
  3065. C.call(t, t.media, 'waiting canplay seeked playing', a =>
  3066. P.checkLoading.call(t, a)
  3067. ),
  3068. t.supported.ui && t.config.clickToPlay && !t.isAudio)
  3069. ) {
  3070. const a = O.call(t, `.${t.config.classNames.video}`)
  3071. if (!l.element(a)) return
  3072. C.call(t, s.container, 'click', r => {
  3073. ;([s.container, a].includes(r.target) || a.contains(r.target)) &&
  3074. ((t.touch && t.config.hideControls) ||
  3075. (t.ended
  3076. ? (this.proxy(r, t.restart, 'restart'),
  3077. this.proxy(
  3078. r,
  3079. () => {
  3080. V(t.play())
  3081. },
  3082. 'play'
  3083. ))
  3084. : this.proxy(
  3085. r,
  3086. () => {
  3087. V(t.togglePlay())
  3088. },
  3089. 'play'
  3090. )))
  3091. })
  3092. }
  3093. t.supported.ui &&
  3094. t.config.disableContextMenu &&
  3095. C.call(
  3096. t,
  3097. s.wrapper,
  3098. 'contextmenu',
  3099. a => {
  3100. a.preventDefault()
  3101. },
  3102. !1
  3103. ),
  3104. C.call(t, t.media, 'volumechange', () => {
  3105. t.storage.set({ volume: t.volume, muted: t.muted })
  3106. }),
  3107. C.call(t, t.media, 'ratechange', () => {
  3108. h.updateSetting.call(t, 'speed'), t.storage.set({ speed: t.speed })
  3109. }),
  3110. C.call(t, t.media, 'qualitychange', a => {
  3111. h.updateSetting.call(t, 'quality', null, a.detail.quality)
  3112. }),
  3113. C.call(t, t.media, 'ready qualitychange', () => {
  3114. h.setDownloadUrl.call(t)
  3115. })
  3116. const n = t.config.events.concat(['keyup', 'keydown']).join(' ')
  3117. C.call(t, t.media, n, a => {
  3118. let { detail: r = {} } = a
  3119. a.type === 'error' && (r = t.media.error),
  3120. b.call(t, s.container, a.type, !0, r)
  3121. })
  3122. }),
  3123. m(this, 'proxy', (t, s, n) => {
  3124. const { player: a } = this,
  3125. r = a.config.listeners[n]
  3126. let o = !0
  3127. l.function(r) && (o = r.call(a, t)),
  3128. o !== !1 && l.function(s) && s.call(a, t)
  3129. }),
  3130. m(this, 'bind', (t, s, n, a, r = !0) => {
  3131. const { player: o } = this,
  3132. c = o.config.listeners[a],
  3133. u = l.function(c)
  3134. C.call(o, t, s, p => this.proxy(p, n, a), r && !u)
  3135. }),
  3136. m(this, 'controls', () => {
  3137. const { player: t } = this,
  3138. { elements: s } = t,
  3139. n = _.isIE ? 'change' : 'input'
  3140. if (
  3141. (s.buttons.play &&
  3142. Array.from(s.buttons.play).forEach(a => {
  3143. this.bind(
  3144. a,
  3145. 'click',
  3146. () => {
  3147. V(t.togglePlay())
  3148. },
  3149. 'play'
  3150. )
  3151. }),
  3152. this.bind(s.buttons.restart, 'click', t.restart, 'restart'),
  3153. this.bind(
  3154. s.buttons.rewind,
  3155. 'click',
  3156. () => {
  3157. ;(t.lastSeekTime = Date.now()), t.rewind()
  3158. },
  3159. 'rewind'
  3160. ),
  3161. this.bind(
  3162. s.buttons.fastForward,
  3163. 'click',
  3164. () => {
  3165. ;(t.lastSeekTime = Date.now()), t.forward()
  3166. },
  3167. 'fastForward'
  3168. ),
  3169. this.bind(
  3170. s.buttons.mute,
  3171. 'click',
  3172. () => {
  3173. t.muted = !t.muted
  3174. },
  3175. 'mute'
  3176. ),
  3177. this.bind(s.buttons.captions, 'click', () => t.toggleCaptions()),
  3178. this.bind(
  3179. s.buttons.download,
  3180. 'click',
  3181. () => {
  3182. b.call(t, t.media, 'download')
  3183. },
  3184. 'download'
  3185. ),
  3186. this.bind(
  3187. s.buttons.fullscreen,
  3188. 'click',
  3189. () => {
  3190. t.fullscreen.toggle()
  3191. },
  3192. 'fullscreen'
  3193. ),
  3194. this.bind(
  3195. s.buttons.pip,
  3196. 'click',
  3197. () => {
  3198. t.pip = 'toggle'
  3199. },
  3200. 'pip'
  3201. ),
  3202. this.bind(s.buttons.airplay, 'click', t.airplay, 'airplay'),
  3203. this.bind(
  3204. s.buttons.settings,
  3205. 'click',
  3206. a => {
  3207. a.stopPropagation(), a.preventDefault(), h.toggleMenu.call(t, a)
  3208. },
  3209. null,
  3210. !1
  3211. ),
  3212. this.bind(
  3213. s.buttons.settings,
  3214. 'keyup',
  3215. a => {
  3216. ;['Space', 'Enter'].includes(a.key) &&
  3217. (a.key !== 'Enter'
  3218. ? (a.preventDefault(),
  3219. a.stopPropagation(),
  3220. h.toggleMenu.call(t, a))
  3221. : h.focusFirstMenuItem.call(t, null, !0))
  3222. },
  3223. null,
  3224. !1
  3225. ),
  3226. this.bind(s.settings.menu, 'keydown', a => {
  3227. a.key === 'Escape' && h.toggleMenu.call(t, a)
  3228. }),
  3229. this.bind(s.inputs.seek, 'mousedown mousemove', a => {
  3230. const r = s.progress.getBoundingClientRect(),
  3231. o = (100 / r.width) * (a.pageX - r.left)
  3232. a.currentTarget.setAttribute('seek-value', o)
  3233. }),
  3234. this.bind(
  3235. s.inputs.seek,
  3236. 'mousedown mouseup keydown keyup touchstart touchend',
  3237. a => {
  3238. const r = a.currentTarget,
  3239. o = 'play-on-seeked'
  3240. if (
  3241. l.keyboardEvent(a) &&
  3242. !['ArrowLeft', 'ArrowRight'].includes(a.key)
  3243. )
  3244. return
  3245. t.lastSeekTime = Date.now()
  3246. const c = r.hasAttribute(o),
  3247. u = ['mouseup', 'touchend', 'keyup'].includes(a.type)
  3248. c && u
  3249. ? (r.removeAttribute(o), V(t.play()))
  3250. : !u && t.playing && (r.setAttribute(o, ''), t.pause())
  3251. }
  3252. ),
  3253. _.isIos)
  3254. ) {
  3255. const a = Z.call(t, 'input[type="range"]')
  3256. Array.from(a).forEach(r => this.bind(r, n, o => nt(o.target)))
  3257. }
  3258. this.bind(
  3259. s.inputs.seek,
  3260. n,
  3261. a => {
  3262. const r = a.currentTarget
  3263. let o = r.getAttribute('seek-value')
  3264. l.empty(o) && (o = r.value),
  3265. r.removeAttribute('seek-value'),
  3266. (t.currentTime = (o / r.max) * t.duration)
  3267. },
  3268. 'seek'
  3269. ),
  3270. this.bind(s.progress, 'mouseenter mouseleave mousemove', a =>
  3271. h.updateSeekTooltip.call(t, a)
  3272. ),
  3273. this.bind(s.progress, 'mousemove touchmove', a => {
  3274. const { previewThumbnails: r } = t
  3275. r && r.loaded && r.startMove(a)
  3276. }),
  3277. this.bind(s.progress, 'mouseleave touchend click', () => {
  3278. const { previewThumbnails: a } = t
  3279. a && a.loaded && a.endMove(!1, !0)
  3280. }),
  3281. this.bind(s.progress, 'mousedown touchstart', a => {
  3282. const { previewThumbnails: r } = t
  3283. r && r.loaded && r.startScrubbing(a)
  3284. }),
  3285. this.bind(s.progress, 'mouseup touchend', a => {
  3286. const { previewThumbnails: r } = t
  3287. r && r.loaded && r.endScrubbing(a)
  3288. }),
  3289. _.isWebkit &&
  3290. Array.from(Z.call(t, 'input[type="range"]')).forEach(a => {
  3291. this.bind(a, 'input', r => h.updateRangeFill.call(t, r.target))
  3292. }),
  3293. t.config.toggleInvert &&
  3294. !l.element(s.display.duration) &&
  3295. this.bind(s.display.currentTime, 'click', () => {
  3296. t.currentTime !== 0 &&
  3297. ((t.config.invertTime = !t.config.invertTime),
  3298. h.timeUpdate.call(t))
  3299. }),
  3300. this.bind(
  3301. s.inputs.volume,
  3302. n,
  3303. a => {
  3304. t.volume = a.target.value
  3305. },
  3306. 'volume'
  3307. ),
  3308. this.bind(s.controls, 'mouseenter mouseleave', a => {
  3309. s.controls.hover = !t.touch && a.type === 'mouseenter'
  3310. }),
  3311. s.fullscreen &&
  3312. Array.from(s.fullscreen.children)
  3313. .filter(a => !a.contains(s.container))
  3314. .forEach(a => {
  3315. this.bind(a, 'mouseenter mouseleave', r => {
  3316. s.controls &&
  3317. (s.controls.hover = !t.touch && r.type === 'mouseenter')
  3318. })
  3319. }),
  3320. this.bind(
  3321. s.controls,
  3322. 'mousedown mouseup touchstart touchend touchcancel',
  3323. a => {
  3324. s.controls.pressed = ['mousedown', 'touchstart'].includes(a.type)
  3325. }
  3326. ),
  3327. this.bind(s.controls, 'focusin', () => {
  3328. const { config: a, timers: r } = t
  3329. A(s.controls, a.classNames.noTransition, !0),
  3330. P.toggleControls.call(t, !0),
  3331. setTimeout(() => {
  3332. A(s.controls, a.classNames.noTransition, !1)
  3333. }, 0)
  3334. const o = this.touch ? 3e3 : 4e3
  3335. clearTimeout(r.controls),
  3336. (r.controls = setTimeout(() => P.toggleControls.call(t, !1), o))
  3337. }),
  3338. this.bind(
  3339. s.inputs.volume,
  3340. 'wheel',
  3341. a => {
  3342. const r = a.webkitDirectionInvertedFromDevice,
  3343. [o, c] = [a.deltaX, -a.deltaY].map(f => (r ? -f : f)),
  3344. u = Math.sign(Math.abs(o) > Math.abs(c) ? o : c)
  3345. t.increaseVolume(u / 50)
  3346. const { volume: p } = t.media
  3347. ;((u === 1 && p < 1) || (u === -1 && p > 0)) && a.preventDefault()
  3348. },
  3349. 'volume',
  3350. !1
  3351. )
  3352. }),
  3353. (this.player = i),
  3354. (this.lastKey = null),
  3355. (this.focusTimer = null),
  3356. (this.lastKeyDown = null),
  3357. (this.handleKey = this.handleKey.bind(this)),
  3358. (this.toggleMenu = this.toggleMenu.bind(this)),
  3359. (this.setTabFocus = this.setTabFocus.bind(this)),
  3360. (this.firstTouch = this.firstTouch.bind(this))
  3361. }
  3362. handleKey(i) {
  3363. const { player: t } = this,
  3364. { elements: s } = t,
  3365. { key: n, type: a, altKey: r, ctrlKey: o, metaKey: c, shiftKey: u } = i,
  3366. p = a === 'keydown',
  3367. f = p && n === this.lastKey
  3368. if (!(r || o || c || u) && !!n) {
  3369. if (p) {
  3370. const v = document.activeElement
  3371. if (l.element(v)) {
  3372. const { editable: T } = t.config.selectors,
  3373. { seek: k } = s.inputs
  3374. if (
  3375. (v !== k && Q(v, T)) ||
  3376. (i.key === 'Space' && Q(v, 'button, [role^="menuitem"]'))
  3377. )
  3378. return
  3379. }
  3380. switch (
  3381. ([
  3382. 'Space',
  3383. 'ArrowLeft',
  3384. 'ArrowUp',
  3385. 'ArrowRight',
  3386. 'ArrowDown',
  3387. '0',
  3388. '1',
  3389. '2',
  3390. '3',
  3391. '4',
  3392. '5',
  3393. '6',
  3394. '7',
  3395. '8',
  3396. '9',
  3397. 'c',
  3398. 'f',
  3399. 'k',
  3400. 'l',
  3401. 'm'
  3402. ].includes(n) && (i.preventDefault(), i.stopPropagation()),
  3403. n)
  3404. ) {
  3405. case '0':
  3406. case '1':
  3407. case '2':
  3408. case '3':
  3409. case '4':
  3410. case '5':
  3411. case '6':
  3412. case '7':
  3413. case '8':
  3414. case '9':
  3415. f ||
  3416. ((d = parseInt(n, 10)), (t.currentTime = (t.duration / 10) * d))
  3417. break
  3418. case 'Space':
  3419. case 'k':
  3420. f || V(t.togglePlay())
  3421. break
  3422. case 'ArrowUp':
  3423. t.increaseVolume(0.1)
  3424. break
  3425. case 'ArrowDown':
  3426. t.decreaseVolume(0.1)
  3427. break
  3428. case 'm':
  3429. f || (t.muted = !t.muted)
  3430. break
  3431. case 'ArrowRight':
  3432. t.forward()
  3433. break
  3434. case 'ArrowLeft':
  3435. t.rewind()
  3436. break
  3437. case 'f':
  3438. t.fullscreen.toggle()
  3439. break
  3440. case 'c':
  3441. f || t.toggleCaptions()
  3442. break
  3443. case 'l':
  3444. t.loop = !t.loop
  3445. }
  3446. n === 'Escape' &&
  3447. !t.fullscreen.usingNative &&
  3448. t.fullscreen.active &&
  3449. t.fullscreen.toggle(),
  3450. (this.lastKey = n)
  3451. } else this.lastKey = null
  3452. var d
  3453. }
  3454. }
  3455. toggleMenu(i) {
  3456. h.toggleMenu.call(this.player, i)
  3457. }
  3458. }
  3459. function Ii(e, i) {
  3460. return e((i = { exports: {} }), i.exports), i.exports
  3461. }
  3462. var Li = Ii(function (e, i) {
  3463. e.exports = (function () {
  3464. var t = function () {},
  3465. s = {},
  3466. n = {},
  3467. a = {}
  3468. function r(d, v) {
  3469. d = d.push ? d : [d]
  3470. var T,
  3471. k,
  3472. N,
  3473. w = [],
  3474. M = d.length,
  3475. g = M
  3476. for (
  3477. T = function (S, L) {
  3478. L.length && w.push(S), --g || v(w)
  3479. };
  3480. M--;
  3481. )
  3482. (k = d[M]), (N = n[k]) ? T(k, N) : (a[k] = a[k] || []).push(T)
  3483. }
  3484. function o(d, v) {
  3485. if (d) {
  3486. var T = a[d]
  3487. if (((n[d] = v), T)) for (; T.length; ) T[0](d, v), T.splice(0, 1)
  3488. }
  3489. }
  3490. function c(d, v) {
  3491. d.call && (d = { success: d }),
  3492. v.length ? (d.error || t)(v) : (d.success || t)(d)
  3493. }
  3494. function u(d, v, T, k) {
  3495. var N,
  3496. w,
  3497. M = document,
  3498. g = T.async,
  3499. S = (T.numRetries || 0) + 1,
  3500. L = T.before || t,
  3501. D = d.replace(/[\?|#].*$/, ''),
  3502. W = d.replace(/^(css|img)!/, '')
  3503. ;(k = k || 0),
  3504. /(^css!|\.css$)/.test(D)
  3505. ? (((w = M.createElement('link')).rel = 'stylesheet'),
  3506. (w.href = W),
  3507. (N = 'hideFocus' in w) &&
  3508. w.relList &&
  3509. ((N = 0), (w.rel = 'preload'), (w.as = 'style')))
  3510. : /(^img!|\.(png|gif|jpg|svg|webp)$)/.test(D)
  3511. ? ((w = M.createElement('img')).src = W)
  3512. : (((w = M.createElement('script')).src = d),
  3513. (w.async = g === void 0 || g)),
  3514. (w.onload =
  3515. w.onerror =
  3516. w.onbeforeload =
  3517. function (X) {
  3518. var ue = X.type[0]
  3519. if (N)
  3520. try {
  3521. w.sheet.cssText.length || (ue = 'e')
  3522. } catch (Ct) {
  3523. Ct.code != 18 && (ue = 'e')
  3524. }
  3525. if (ue == 'e') {
  3526. if ((k += 1) < S) return u(d, v, T, k)
  3527. } else if (w.rel == 'preload' && w.as == 'style')
  3528. return (w.rel = 'stylesheet')
  3529. v(d, ue, X.defaultPrevented)
  3530. }),
  3531. L(d, w) !== !1 && M.head.appendChild(w)
  3532. }
  3533. function p(d, v, T) {
  3534. var k,
  3535. N,
  3536. w = (d = d.push ? d : [d]).length,
  3537. M = w,
  3538. g = []
  3539. for (
  3540. k = function (S, L, D) {
  3541. if ((L == 'e' && g.push(S), L == 'b')) {
  3542. if (!D) return
  3543. g.push(S)
  3544. }
  3545. --w || v(g)
  3546. },
  3547. N = 0;
  3548. N < M;
  3549. N++
  3550. )
  3551. u(d[N], k, T)
  3552. }
  3553. function f(d, v, T) {
  3554. var k, N
  3555. if ((v && v.trim && (k = v), (N = (k ? T : v) || {}), k)) {
  3556. if (k in s) throw 'LoadJS'
  3557. s[k] = !0
  3558. }
  3559. function w(M, g) {
  3560. p(
  3561. d,
  3562. function (S) {
  3563. c(N, S), M && c({ success: M, error: g }, S), o(k, S)
  3564. },
  3565. N
  3566. )
  3567. }
  3568. if (N.returnPromise) return new Promise(w)
  3569. w()
  3570. }
  3571. return (
  3572. (f.ready = function (d, v) {
  3573. return (
  3574. r(d, function (T) {
  3575. c(v, T)
  3576. }),
  3577. f
  3578. )
  3579. }),
  3580. (f.done = function (d) {
  3581. o(d, [])
  3582. }),
  3583. (f.reset = function () {
  3584. ;(s = {}), (n = {}), (a = {})
  3585. }),
  3586. (f.isDefined = function (d) {
  3587. return d in s
  3588. }),
  3589. f
  3590. )
  3591. })()
  3592. })
  3593. function $e(e) {
  3594. return new Promise((i, t) => {
  3595. Li(e, { success: i, error: t })
  3596. })
  3597. }
  3598. function Oi(e) {
  3599. return l.empty(e)
  3600. ? null
  3601. : l.number(Number(e))
  3602. ? e
  3603. : e.match(/^.*(vimeo.com\/|video\/)(\d+).*/)
  3604. ? RegExp.$2
  3605. : e
  3606. }
  3607. function $i(e) {
  3608. const i = e.match(/^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/)
  3609. return i && i.length === 5 ? i[4] : null
  3610. }
  3611. function re(e) {
  3612. e && !this.embed.hasPlayed && (this.embed.hasPlayed = !0),
  3613. this.media.paused === e &&
  3614. ((this.media.paused = !e), b.call(this, this.media, e ? 'play' : 'pause'))
  3615. }
  3616. const _e = {
  3617. setup() {
  3618. const e = this
  3619. A(e.elements.wrapper, e.config.classNames.embed, !0),
  3620. (e.options.speed = e.config.speed.options),
  3621. te.call(e),
  3622. l.object(window.Vimeo)
  3623. ? _e.ready.call(e)
  3624. : $e(e.config.urls.vimeo.sdk)
  3625. .then(() => {
  3626. _e.ready.call(e)
  3627. })
  3628. .catch(i => {
  3629. e.debug.warn('Vimeo SDK (player.js) failed to load', i)
  3630. })
  3631. },
  3632. ready() {
  3633. const e = this,
  3634. i = e.config.vimeo,
  3635. M = i,
  3636. { premium: t, referrerPolicy: s } = M,
  3637. n = Fe(M, ['premium', 'referrerPolicy'])
  3638. let a = e.media.getAttribute('src'),
  3639. r = ''
  3640. l.empty(a)
  3641. ? ((a = e.media.getAttribute(e.config.attributes.embed.id)),
  3642. (r = e.media.getAttribute(e.config.attributes.embed.hash)))
  3643. : (r = $i(a))
  3644. const o = r ? { h: r } : {}
  3645. t && Object.assign(n, { controls: !1, sidedock: !1 })
  3646. const c = vt(
  3647. q(
  3648. q(
  3649. {
  3650. loop: e.config.loop.active,
  3651. autoplay: e.autoplay,
  3652. muted: e.muted,
  3653. gesture: 'media',
  3654. playsinline: !this.config.fullscreen.iosNative
  3655. },
  3656. o
  3657. ),
  3658. n
  3659. )
  3660. ),
  3661. u = Oi(a),
  3662. p = y('iframe'),
  3663. f = xe(e.config.urls.vimeo.iframe, u, c)
  3664. if (
  3665. (p.setAttribute('src', f),
  3666. p.setAttribute('allowfullscreen', ''),
  3667. p.setAttribute(
  3668. 'allow',
  3669. [
  3670. 'autoplay',
  3671. 'fullscreen',
  3672. 'picture-in-picture',
  3673. 'encrypted-media',
  3674. 'accelerometer',
  3675. 'gyroscope'
  3676. ].join('; ')
  3677. ),
  3678. l.empty(s) || p.setAttribute('referrerPolicy', s),
  3679. t || !i.customControls)
  3680. )
  3681. p.setAttribute('data-poster', e.poster), (e.media = pe(p, e.media))
  3682. else {
  3683. const g = y('div', {
  3684. class: e.config.classNames.embedContainer,
  3685. 'data-poster': e.poster
  3686. })
  3687. g.appendChild(p), (e.media = pe(g, e.media))
  3688. }
  3689. i.customControls ||
  3690. le(xe(e.config.urls.vimeo.api, f)).then(g => {
  3691. !l.empty(g) &&
  3692. g.thumbnail_url &&
  3693. P.setPoster.call(e, g.thumbnail_url).catch(() => {})
  3694. }),
  3695. (e.embed = new window.Vimeo.Player(p, {
  3696. autopause: e.config.autopause,
  3697. muted: e.muted
  3698. })),
  3699. (e.media.paused = !0),
  3700. (e.media.currentTime = 0),
  3701. e.supported.ui && e.embed.disableTextTrack(),
  3702. (e.media.play = () => (re.call(e, !0), e.embed.play())),
  3703. (e.media.pause = () => (re.call(e, !1), e.embed.pause())),
  3704. (e.media.stop = () => {
  3705. e.pause(), (e.currentTime = 0)
  3706. })
  3707. let { currentTime: d } = e.media
  3708. Object.defineProperty(e.media, 'currentTime', {
  3709. get: () => d,
  3710. set(g) {
  3711. const { embed: S, media: L, paused: D, volume: W } = e,
  3712. X = D && !S.hasPlayed
  3713. ;(L.seeking = !0),
  3714. b.call(e, L, 'seeking'),
  3715. Promise.resolve(X && S.setVolume(0))
  3716. .then(() => S.setCurrentTime(g))
  3717. .then(() => X && S.pause())
  3718. .then(() => X && S.setVolume(W))
  3719. .catch(() => {})
  3720. }
  3721. })
  3722. let v = e.config.speed.selected
  3723. Object.defineProperty(e.media, 'playbackRate', {
  3724. get: () => v,
  3725. set(g) {
  3726. e.embed
  3727. .setPlaybackRate(g)
  3728. .then(() => {
  3729. ;(v = g), b.call(e, e.media, 'ratechange')
  3730. })
  3731. .catch(() => {
  3732. e.options.speed = [1]
  3733. })
  3734. }
  3735. })
  3736. let { volume: T } = e.config
  3737. Object.defineProperty(e.media, 'volume', {
  3738. get: () => T,
  3739. set(g) {
  3740. e.embed.setVolume(g).then(() => {
  3741. ;(T = g), b.call(e, e.media, 'volumechange')
  3742. })
  3743. }
  3744. })
  3745. let { muted: k } = e.config
  3746. Object.defineProperty(e.media, 'muted', {
  3747. get: () => k,
  3748. set(g) {
  3749. const S = !!l.boolean(g) && g
  3750. e.embed.setVolume(S ? 0 : e.config.volume).then(() => {
  3751. ;(k = S), b.call(e, e.media, 'volumechange')
  3752. })
  3753. }
  3754. })
  3755. let N,
  3756. { loop: w } = e.config
  3757. Object.defineProperty(e.media, 'loop', {
  3758. get: () => w,
  3759. set(g) {
  3760. const S = l.boolean(g) ? g : e.config.loop.active
  3761. e.embed.setLoop(S).then(() => {
  3762. w = S
  3763. })
  3764. }
  3765. }),
  3766. e.embed
  3767. .getVideoUrl()
  3768. .then(g => {
  3769. ;(N = g), h.setDownloadUrl.call(e)
  3770. })
  3771. .catch(g => {
  3772. this.debug.warn(g)
  3773. }),
  3774. Object.defineProperty(e.media, 'currentSrc', { get: () => N }),
  3775. Object.defineProperty(e.media, 'ended', {
  3776. get: () => e.currentTime === e.duration
  3777. }),
  3778. Promise.all([e.embed.getVideoWidth(), e.embed.getVideoHeight()]).then(
  3779. g => {
  3780. const [S, L] = g
  3781. ;(e.embed.ratio = mt(S, L)), te.call(this)
  3782. }
  3783. ),
  3784. e.embed.setAutopause(e.config.autopause).then(g => {
  3785. e.config.autopause = g
  3786. }),
  3787. e.embed.getVideoTitle().then(g => {
  3788. ;(e.config.title = g), P.setTitle.call(this)
  3789. }),
  3790. e.embed.getCurrentTime().then(g => {
  3791. ;(d = g), b.call(e, e.media, 'timeupdate')
  3792. }),
  3793. e.embed.getDuration().then(g => {
  3794. ;(e.media.duration = g), b.call(e, e.media, 'durationchange')
  3795. }),
  3796. e.embed.getTextTracks().then(g => {
  3797. ;(e.media.textTracks = g), E.setup.call(e)
  3798. }),
  3799. e.embed.on('cuechange', ({ cues: g = [] }) => {
  3800. const S = g.map(L => Si(L.text))
  3801. E.updateCues.call(e, S)
  3802. }),
  3803. e.embed.on('loaded', () => {
  3804. e.embed.getPaused().then(g => {
  3805. re.call(e, !g), g || b.call(e, e.media, 'playing')
  3806. }),
  3807. l.element(e.embed.element) &&
  3808. e.supported.ui &&
  3809. e.embed.element.setAttribute('tabindex', -1)
  3810. }),
  3811. e.embed.on('bufferstart', () => {
  3812. b.call(e, e.media, 'waiting')
  3813. }),
  3814. e.embed.on('bufferend', () => {
  3815. b.call(e, e.media, 'playing')
  3816. }),
  3817. e.embed.on('play', () => {
  3818. re.call(e, !0), b.call(e, e.media, 'playing')
  3819. }),
  3820. e.embed.on('pause', () => {
  3821. re.call(e, !1)
  3822. }),
  3823. e.embed.on('timeupdate', g => {
  3824. ;(e.media.seeking = !1),
  3825. (d = g.seconds),
  3826. b.call(e, e.media, 'timeupdate')
  3827. }),
  3828. e.embed.on('progress', g => {
  3829. ;(e.media.buffered = g.percent),
  3830. b.call(e, e.media, 'progress'),
  3831. parseInt(g.percent, 10) === 1 && b.call(e, e.media, 'canplaythrough'),
  3832. e.embed.getDuration().then(S => {
  3833. S !== e.media.duration &&
  3834. ((e.media.duration = S), b.call(e, e.media, 'durationchange'))
  3835. })
  3836. }),
  3837. e.embed.on('seeked', () => {
  3838. ;(e.media.seeking = !1), b.call(e, e.media, 'seeked')
  3839. }),
  3840. e.embed.on('ended', () => {
  3841. ;(e.media.paused = !0), b.call(e, e.media, 'ended')
  3842. }),
  3843. e.embed.on('error', g => {
  3844. ;(e.media.error = g), b.call(e, e.media, 'error')
  3845. }),
  3846. i.customControls && setTimeout(() => P.build.call(e), 0)
  3847. }
  3848. }
  3849. function _i(e) {
  3850. return l.empty(e)
  3851. ? null
  3852. : e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/)
  3853. ? RegExp.$2
  3854. : e
  3855. }
  3856. function oe(e) {
  3857. e && !this.embed.hasPlayed && (this.embed.hasPlayed = !0),
  3858. this.media.paused === e &&
  3859. ((this.media.paused = !e), b.call(this, this.media, e ? 'play' : 'pause'))
  3860. }
  3861. function Ri(e) {
  3862. return e.noCookie
  3863. ? 'https://www.youtube-nocookie.com'
  3864. : window.location.protocol === 'http:'
  3865. ? 'http://www.youtube.com'
  3866. : void 0
  3867. }
  3868. const we = {
  3869. setup() {
  3870. if (
  3871. (A(this.elements.wrapper, this.config.classNames.embed, !0),
  3872. l.object(window.YT) && l.function(window.YT.Player))
  3873. )
  3874. we.ready.call(this)
  3875. else {
  3876. const e = window.onYouTubeIframeAPIReady
  3877. ;(window.onYouTubeIframeAPIReady = () => {
  3878. l.function(e) && e(), we.ready.call(this)
  3879. }),
  3880. $e(this.config.urls.youtube.sdk).catch(i => {
  3881. this.debug.warn('YouTube API failed to load', i)
  3882. })
  3883. }
  3884. },
  3885. getTitle(e) {
  3886. le(xe(this.config.urls.youtube.api, e))
  3887. .then(i => {
  3888. if (l.object(i)) {
  3889. const { title: t, height: s, width: n } = i
  3890. ;(this.config.title = t),
  3891. P.setTitle.call(this),
  3892. (this.embed.ratio = mt(n, s))
  3893. }
  3894. te.call(this)
  3895. })
  3896. .catch(() => {
  3897. te.call(this)
  3898. })
  3899. },
  3900. ready() {
  3901. const e = this,
  3902. i = e.config.youtube,
  3903. t = e.media && e.media.getAttribute('id')
  3904. if (!l.empty(t) && t.startsWith('youtube-')) return
  3905. let s = e.media.getAttribute('src')
  3906. l.empty(s) && (s = e.media.getAttribute(this.config.attributes.embed.id))
  3907. const n = _i(s),
  3908. a = y('div', {
  3909. id: Ti(e.provider),
  3910. 'data-poster': i.customControls ? e.poster : void 0
  3911. })
  3912. if (((e.media = pe(a, e.media)), i.customControls)) {
  3913. const r = o => `https://i.ytimg.com/vi/${n}/${o}default.jpg`
  3914. ve(r('maxres'), 121)
  3915. .catch(() => ve(r('sd'), 121))
  3916. .catch(() => ve(r('hq')))
  3917. .then(o => P.setPoster.call(e, o.src))
  3918. .then(o => {
  3919. o.includes('maxres') ||
  3920. (e.elements.poster.style.backgroundSize = 'cover')
  3921. })
  3922. .catch(() => {})
  3923. }
  3924. e.embed = new window.YT.Player(e.media, {
  3925. videoId: n,
  3926. host: Ri(i),
  3927. playerVars: I(
  3928. {},
  3929. {
  3930. autoplay: e.config.autoplay ? 1 : 0,
  3931. hl: e.config.hl,
  3932. controls: e.supported.ui && i.customControls ? 0 : 1,
  3933. disablekb: 1,
  3934. playsinline: e.config.fullscreen.iosNative ? 0 : 1,
  3935. cc_load_policy: e.captions.active ? 1 : 0,
  3936. cc_lang_pref: e.config.captions.language,
  3937. widget_referrer: window ? window.location.href : null
  3938. },
  3939. i
  3940. ),
  3941. events: {
  3942. onError(r) {
  3943. if (!e.media.error) {
  3944. const o = r.data,
  3945. c =
  3946. {
  3947. 2: 'The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.',
  3948. 5: 'The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.',
  3949. 100: 'The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.',
  3950. 101: 'The owner of the requested video does not allow it to be played in embedded players.',
  3951. 150: 'The owner of the requested video does not allow it to be played in embedded players.'
  3952. }[o] || 'An unknown error occured'
  3953. ;(e.media.error = { code: o, message: c }),
  3954. b.call(e, e.media, 'error')
  3955. }
  3956. },
  3957. onPlaybackRateChange(r) {
  3958. const o = r.target
  3959. ;(e.media.playbackRate = o.getPlaybackRate()),
  3960. b.call(e, e.media, 'ratechange')
  3961. },
  3962. onReady(r) {
  3963. if (l.function(e.media.play)) return
  3964. const o = r.target
  3965. we.getTitle.call(e, n),
  3966. (e.media.play = () => {
  3967. oe.call(e, !0), o.playVideo()
  3968. }),
  3969. (e.media.pause = () => {
  3970. oe.call(e, !1), o.pauseVideo()
  3971. }),
  3972. (e.media.stop = () => {
  3973. o.stopVideo()
  3974. }),
  3975. (e.media.duration = o.getDuration()),
  3976. (e.media.paused = !0),
  3977. (e.media.currentTime = 0),
  3978. Object.defineProperty(e.media, 'currentTime', {
  3979. get: () => Number(o.getCurrentTime()),
  3980. set(f) {
  3981. e.paused && !e.embed.hasPlayed && e.embed.mute(),
  3982. (e.media.seeking = !0),
  3983. b.call(e, e.media, 'seeking'),
  3984. o.seekTo(f)
  3985. }
  3986. }),
  3987. Object.defineProperty(e.media, 'playbackRate', {
  3988. get: () => o.getPlaybackRate(),
  3989. set(f) {
  3990. o.setPlaybackRate(f)
  3991. }
  3992. })
  3993. let { volume: c } = e.config
  3994. Object.defineProperty(e.media, 'volume', {
  3995. get: () => c,
  3996. set(f) {
  3997. ;(c = f),
  3998. o.setVolume(100 * c),
  3999. b.call(e, e.media, 'volumechange')
  4000. }
  4001. })
  4002. let { muted: u } = e.config
  4003. Object.defineProperty(e.media, 'muted', {
  4004. get: () => u,
  4005. set(f) {
  4006. const d = l.boolean(f) ? f : u
  4007. ;(u = d),
  4008. o[d ? 'mute' : 'unMute'](),
  4009. o.setVolume(100 * c),
  4010. b.call(e, e.media, 'volumechange')
  4011. }
  4012. }),
  4013. Object.defineProperty(e.media, 'currentSrc', {
  4014. get: () => o.getVideoUrl()
  4015. }),
  4016. Object.defineProperty(e.media, 'ended', {
  4017. get: () => e.currentTime === e.duration
  4018. })
  4019. const p = o.getAvailablePlaybackRates()
  4020. ;(e.options.speed = p.filter(f =>
  4021. e.config.speed.options.includes(f)
  4022. )),
  4023. e.supported.ui &&
  4024. i.customControls &&
  4025. e.media.setAttribute('tabindex', -1),
  4026. b.call(e, e.media, 'timeupdate'),
  4027. b.call(e, e.media, 'durationchange'),
  4028. clearInterval(e.timers.buffering),
  4029. (e.timers.buffering = setInterval(() => {
  4030. ;(e.media.buffered = o.getVideoLoadedFraction()),
  4031. (e.media.lastBuffered === null ||
  4032. e.media.lastBuffered < e.media.buffered) &&
  4033. b.call(e, e.media, 'progress'),
  4034. (e.media.lastBuffered = e.media.buffered),
  4035. e.media.buffered === 1 &&
  4036. (clearInterval(e.timers.buffering),
  4037. b.call(e, e.media, 'canplaythrough'))
  4038. }, 200)),
  4039. i.customControls && setTimeout(() => P.build.call(e), 50)
  4040. },
  4041. onStateChange(r) {
  4042. const o = r.target
  4043. switch (
  4044. (clearInterval(e.timers.playing),
  4045. e.media.seeking &&
  4046. [1, 2].includes(r.data) &&
  4047. ((e.media.seeking = !1), b.call(e, e.media, 'seeked')),
  4048. r.data)
  4049. ) {
  4050. case -1:
  4051. b.call(e, e.media, 'timeupdate'),
  4052. (e.media.buffered = o.getVideoLoadedFraction()),
  4053. b.call(e, e.media, 'progress')
  4054. break
  4055. case 0:
  4056. oe.call(e, !1),
  4057. e.media.loop
  4058. ? (o.stopVideo(), o.playVideo())
  4059. : b.call(e, e.media, 'ended')
  4060. break
  4061. case 1:
  4062. i.customControls &&
  4063. !e.config.autoplay &&
  4064. e.media.paused &&
  4065. !e.embed.hasPlayed
  4066. ? e.media.pause()
  4067. : (oe.call(e, !0),
  4068. b.call(e, e.media, 'playing'),
  4069. (e.timers.playing = setInterval(() => {
  4070. b.call(e, e.media, 'timeupdate')
  4071. }, 50)),
  4072. e.media.duration !== o.getDuration() &&
  4073. ((e.media.duration = o.getDuration()),
  4074. b.call(e, e.media, 'durationchange')))
  4075. break
  4076. case 2:
  4077. e.muted || e.embed.unMute(), oe.call(e, !1)
  4078. break
  4079. case 3:
  4080. b.call(e, e.media, 'waiting')
  4081. }
  4082. b.call(e, e.elements.container, 'statechange', !1, { code: r.data })
  4083. }
  4084. }
  4085. })
  4086. }
  4087. },
  4088. Tt = {
  4089. setup() {
  4090. this.media
  4091. ? (A(
  4092. this.elements.container,
  4093. this.config.classNames.type.replace('{0}', this.type),
  4094. !0
  4095. ),
  4096. A(
  4097. this.elements.container,
  4098. this.config.classNames.provider.replace('{0}', this.provider),
  4099. !0
  4100. ),
  4101. this.isEmbed &&
  4102. A(
  4103. this.elements.container,
  4104. this.config.classNames.type.replace('{0}', 'video'),
  4105. !0
  4106. ),
  4107. this.isVideo &&
  4108. ((this.elements.wrapper = y('div', {
  4109. class: this.config.classNames.video
  4110. })),
  4111. lt(this.media, this.elements.wrapper),
  4112. (this.elements.poster = y('div', {
  4113. class: this.config.classNames.poster
  4114. })),
  4115. this.elements.wrapper.appendChild(this.elements.poster)),
  4116. this.isHTML5
  4117. ? K.setup.call(this)
  4118. : this.isYouTube
  4119. ? we.setup.call(this)
  4120. : this.isVimeo && _e.setup.call(this))
  4121. : this.debug.warn('No media element found!')
  4122. }
  4123. }
  4124. class ji {
  4125. constructor(i) {
  4126. m(this, 'load', () => {
  4127. this.enabled &&
  4128. (l.object(window.google) && l.object(window.google.ima)
  4129. ? this.ready()
  4130. : $e(this.player.config.urls.googleIMA.sdk)
  4131. .then(() => {
  4132. this.ready()
  4133. })
  4134. .catch(() => {
  4135. this.trigger(
  4136. 'error',
  4137. new Error('Google IMA SDK failed to load')
  4138. )
  4139. }))
  4140. }),
  4141. m(this, 'ready', () => {
  4142. var t
  4143. this.enabled ||
  4144. ((t = this).manager && t.manager.destroy(),
  4145. t.elements.displayContainer && t.elements.displayContainer.destroy(),
  4146. t.elements.container.remove()),
  4147. this.startSafetyTimer(12e3, 'ready()'),
  4148. this.managerPromise.then(() => {
  4149. this.clearSafetyTimer('onAdsManagerLoaded()')
  4150. }),
  4151. this.listeners(),
  4152. this.setupIMA()
  4153. }),
  4154. m(this, 'setupIMA', () => {
  4155. ;(this.elements.container = y('div', {
  4156. class: this.player.config.classNames.ads
  4157. })),
  4158. this.player.elements.container.appendChild(this.elements.container),
  4159. google.ima.settings.setVpaidMode(
  4160. google.ima.ImaSdkSettings.VpaidMode.ENABLED
  4161. ),
  4162. google.ima.settings.setLocale(this.player.config.ads.language),
  4163. google.ima.settings.setDisableCustomPlaybackForIOS10Plus(
  4164. this.player.config.playsinline
  4165. ),
  4166. (this.elements.displayContainer = new google.ima.AdDisplayContainer(
  4167. this.elements.container,
  4168. this.player.media
  4169. )),
  4170. (this.loader = new google.ima.AdsLoader(
  4171. this.elements.displayContainer
  4172. )),
  4173. this.loader.addEventListener(
  4174. google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
  4175. t => this.onAdsManagerLoaded(t),
  4176. !1
  4177. ),
  4178. this.loader.addEventListener(
  4179. google.ima.AdErrorEvent.Type.AD_ERROR,
  4180. t => this.onAdError(t),
  4181. !1
  4182. ),
  4183. this.requestAds()
  4184. }),
  4185. m(this, 'requestAds', () => {
  4186. const { container: t } = this.player.elements
  4187. try {
  4188. const s = new google.ima.AdsRequest()
  4189. ;(s.adTagUrl = this.tagUrl),
  4190. (s.linearAdSlotWidth = t.offsetWidth),
  4191. (s.linearAdSlotHeight = t.offsetHeight),
  4192. (s.nonLinearAdSlotWidth = t.offsetWidth),
  4193. (s.nonLinearAdSlotHeight = t.offsetHeight),
  4194. (s.forceNonLinearFullSlot = !1),
  4195. s.setAdWillPlayMuted(!this.player.muted),
  4196. this.loader.requestAds(s)
  4197. } catch (s) {
  4198. this.onAdError(s)
  4199. }
  4200. }),
  4201. m(this, 'pollCountdown', (t = !1) => {
  4202. if (!t)
  4203. return (
  4204. clearInterval(this.countdownTimer),
  4205. void this.elements.container.removeAttribute('data-badge-text')
  4206. )
  4207. this.countdownTimer = setInterval(() => {
  4208. const s = be(Math.max(this.manager.getRemainingTime(), 0)),
  4209. n = `${$.get('advertisement', this.player.config)} - ${s}`
  4210. this.elements.container.setAttribute('data-badge-text', n)
  4211. }, 100)
  4212. }),
  4213. m(this, 'onAdsManagerLoaded', t => {
  4214. if (!this.enabled) return
  4215. const s = new google.ima.AdsRenderingSettings()
  4216. ;(s.restoreCustomPlaybackStateOnAdBreakComplete = !0),
  4217. (s.enablePreloading = !0),
  4218. (this.manager = t.getAdsManager(this.player, s)),
  4219. (this.cuePoints = this.manager.getCuePoints()),
  4220. this.manager.addEventListener(
  4221. google.ima.AdErrorEvent.Type.AD_ERROR,
  4222. n => this.onAdError(n)
  4223. ),
  4224. Object.keys(google.ima.AdEvent.Type).forEach(n => {
  4225. this.manager.addEventListener(google.ima.AdEvent.Type[n], a =>
  4226. this.onAdEvent(a)
  4227. )
  4228. }),
  4229. this.trigger('loaded')
  4230. }),
  4231. m(this, 'addCuePoints', () => {
  4232. l.empty(this.cuePoints) ||
  4233. this.cuePoints.forEach(t => {
  4234. if (t !== 0 && t !== -1 && t < this.player.duration) {
  4235. const s = this.player.elements.progress
  4236. if (l.element(s)) {
  4237. const n = (100 / this.player.duration) * t,
  4238. a = y('span', { class: this.player.config.classNames.cues })
  4239. ;(a.style.left = `${n.toString()}%`), s.appendChild(a)
  4240. }
  4241. }
  4242. })
  4243. }),
  4244. m(this, 'onAdEvent', t => {
  4245. const { container: s } = this.player.elements,
  4246. n = t.getAd(),
  4247. a = t.getAdData()
  4248. switch (
  4249. ((r => {
  4250. b.call(
  4251. this.player,
  4252. this.player.media,
  4253. `ads${r.replace(/_/g, '').toLowerCase()}`
  4254. )
  4255. })(t.type),
  4256. t.type)
  4257. ) {
  4258. case google.ima.AdEvent.Type.LOADED:
  4259. this.trigger('loaded'),
  4260. this.pollCountdown(!0),
  4261. n.isLinear() ||
  4262. ((n.width = s.offsetWidth), (n.height = s.offsetHeight))
  4263. break
  4264. case google.ima.AdEvent.Type.STARTED:
  4265. this.manager.setVolume(this.player.volume)
  4266. break
  4267. case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:
  4268. this.player.ended ? this.loadAds() : this.loader.contentComplete()
  4269. break
  4270. case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:
  4271. this.pauseContent()
  4272. break
  4273. case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:
  4274. this.pollCountdown(), this.resumeContent()
  4275. break
  4276. case google.ima.AdEvent.Type.LOG:
  4277. a.adError &&
  4278. this.player.debug.warn(
  4279. `Non-fatal ad error: ${a.adError.getMessage()}`
  4280. )
  4281. }
  4282. }),
  4283. m(this, 'onAdError', t => {
  4284. this.cancel(), this.player.debug.warn('Ads error', t)
  4285. }),
  4286. m(this, 'listeners', () => {
  4287. const { container: t } = this.player.elements
  4288. let s
  4289. this.player.on('canplay', () => {
  4290. this.addCuePoints()
  4291. }),
  4292. this.player.on('ended', () => {
  4293. this.loader.contentComplete()
  4294. }),
  4295. this.player.on('timeupdate', () => {
  4296. s = this.player.currentTime
  4297. }),
  4298. this.player.on('seeked', () => {
  4299. const n = this.player.currentTime
  4300. l.empty(this.cuePoints) ||
  4301. this.cuePoints.forEach((a, r) => {
  4302. s < a &&
  4303. a < n &&
  4304. (this.manager.discardAdBreak(), this.cuePoints.splice(r, 1))
  4305. })
  4306. }),
  4307. window.addEventListener('resize', () => {
  4308. this.manager &&
  4309. this.manager.resize(
  4310. t.offsetWidth,
  4311. t.offsetHeight,
  4312. google.ima.ViewMode.NORMAL
  4313. )
  4314. })
  4315. }),
  4316. m(this, 'play', () => {
  4317. const { container: t } = this.player.elements
  4318. this.managerPromise || this.resumeContent(),
  4319. this.managerPromise
  4320. .then(() => {
  4321. this.manager.setVolume(this.player.volume),
  4322. this.elements.displayContainer.initialize()
  4323. try {
  4324. this.initialized ||
  4325. (this.manager.init(
  4326. t.offsetWidth,
  4327. t.offsetHeight,
  4328. google.ima.ViewMode.NORMAL
  4329. ),
  4330. this.manager.start()),
  4331. (this.initialized = !0)
  4332. } catch (s) {
  4333. this.onAdError(s)
  4334. }
  4335. })
  4336. .catch(() => {})
  4337. }),
  4338. m(this, 'resumeContent', () => {
  4339. ;(this.elements.container.style.zIndex = ''),
  4340. (this.playing = !1),
  4341. V(this.player.media.play())
  4342. }),
  4343. m(this, 'pauseContent', () => {
  4344. ;(this.elements.container.style.zIndex = 3),
  4345. (this.playing = !0),
  4346. this.player.media.pause()
  4347. }),
  4348. m(this, 'cancel', () => {
  4349. this.initialized && this.resumeContent(),
  4350. this.trigger('error'),
  4351. this.loadAds()
  4352. }),
  4353. m(this, 'loadAds', () => {
  4354. this.managerPromise
  4355. .then(() => {
  4356. this.manager && this.manager.destroy(),
  4357. (this.managerPromise = new Promise(t => {
  4358. this.on('loaded', t), this.player.debug.log(this.manager)
  4359. })),
  4360. (this.initialized = !1),
  4361. this.requestAds()
  4362. })
  4363. .catch(() => {})
  4364. }),
  4365. m(this, 'trigger', (t, ...s) => {
  4366. const n = this.events[t]
  4367. l.array(n) &&
  4368. n.forEach(a => {
  4369. l.function(a) && a.apply(this, s)
  4370. })
  4371. }),
  4372. m(
  4373. this,
  4374. 'on',
  4375. (t, s) => (
  4376. l.array(this.events[t]) || (this.events[t] = []),
  4377. this.events[t].push(s),
  4378. this
  4379. )
  4380. ),
  4381. m(this, 'startSafetyTimer', (t, s) => {
  4382. this.player.debug.log(`Safety timer invoked from: ${s}`),
  4383. (this.safetyTimer = setTimeout(() => {
  4384. this.cancel(), this.clearSafetyTimer('startSafetyTimer()')
  4385. }, t))
  4386. }),
  4387. m(this, 'clearSafetyTimer', t => {
  4388. l.nullOrUndefined(this.safetyTimer) ||
  4389. (this.player.debug.log(`Safety timer cleared from: ${t}`),
  4390. clearTimeout(this.safetyTimer),
  4391. (this.safetyTimer = null))
  4392. }),
  4393. (this.player = i),
  4394. (this.config = i.config.ads),
  4395. (this.playing = !1),
  4396. (this.initialized = !1),
  4397. (this.elements = { container: null, displayContainer: null }),
  4398. (this.manager = null),
  4399. (this.loader = null),
  4400. (this.cuePoints = null),
  4401. (this.events = {}),
  4402. (this.safetyTimer = null),
  4403. (this.countdownTimer = null),
  4404. (this.managerPromise = new Promise((t, s) => {
  4405. this.on('loaded', t), this.on('error', s)
  4406. })),
  4407. this.load()
  4408. }
  4409. get enabled() {
  4410. const { config: i } = this
  4411. return (
  4412. this.player.isHTML5 &&
  4413. this.player.isVideo &&
  4414. i.enabled &&
  4415. (!l.empty(i.publisherId) || l.url(i.tagUrl))
  4416. )
  4417. }
  4418. get tagUrl() {
  4419. const { config: i } = this
  4420. return l.url(i.tagUrl)
  4421. ? i.tagUrl
  4422. : `https://go.aniview.com/api/adserver6/vast/?${vt({
  4423. AV_PUBLISHERID: '58c25bb0073ef448b1087ad6',
  4424. AV_CHANNELID: '5a0458dc28a06145e4519d21',
  4425. AV_URL: window.location.hostname,
  4426. cb: Date.now(),
  4427. AV_WIDTH: 640,
  4428. AV_HEIGHT: 480,
  4429. AV_CDIM2: i.publisherId
  4430. })}`
  4431. }
  4432. }
  4433. function kt(e = 0, i = 0, t = 255) {
  4434. return Math.min(Math.max(e, i), t)
  4435. }
  4436. const Di = e => {
  4437. const i = []
  4438. return (
  4439. e.split(/\r\n\r\n|\n\n|\r\r/).forEach(t => {
  4440. const s = {}
  4441. t.split(/\r\n|\n|\r/).forEach(n => {
  4442. if (l.number(s.startTime)) {
  4443. if (!l.empty(n.trim()) && l.empty(s.text)) {
  4444. const a = n.trim().split('#xywh=')
  4445. ;([s.text] = a), a[1] && ([s.x, s.y, s.w, s.h] = a[1].split(','))
  4446. }
  4447. } else {
  4448. const a = n.match(
  4449. /([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})/
  4450. )
  4451. a &&
  4452. ((s.startTime =
  4453. 60 * Number(a[1] || 0) * 60 +
  4454. 60 * Number(a[2]) +
  4455. Number(a[3]) +
  4456. Number(`0.${a[4]}`)),
  4457. (s.endTime =
  4458. 60 * Number(a[6] || 0) * 60 +
  4459. 60 * Number(a[7]) +
  4460. Number(a[8]) +
  4461. Number(`0.${a[9]}`)))
  4462. }
  4463. }),
  4464. s.text && i.push(s)
  4465. }),
  4466. i
  4467. )
  4468. },
  4469. At = (e, i) => {
  4470. const t = {}
  4471. return (
  4472. e > i.width / i.height
  4473. ? ((t.width = i.width), (t.height = (1 / e) * i.width))
  4474. : ((t.height = i.height), (t.width = e * i.height)),
  4475. t
  4476. )
  4477. }
  4478. class Re {
  4479. constructor(i) {
  4480. m(this, 'load', () => {
  4481. this.player.elements.display.seekTooltip &&
  4482. (this.player.elements.display.seekTooltip.hidden = this.enabled),
  4483. this.enabled &&
  4484. this.getThumbnails().then(() => {
  4485. this.enabled &&
  4486. (this.render(),
  4487. this.determineContainerAutoSizing(),
  4488. (this.loaded = !0))
  4489. })
  4490. }),
  4491. m(
  4492. this,
  4493. 'getThumbnails',
  4494. () =>
  4495. new Promise(t => {
  4496. const { src: s } = this.player.config.previewThumbnails
  4497. if (l.empty(s))
  4498. throw new Error('Missing previewThumbnails.src config attribute')
  4499. const n = () => {
  4500. this.thumbnails.sort((a, r) => a.height - r.height),
  4501. this.player.debug.log('Preview thumbnails', this.thumbnails),
  4502. t()
  4503. }
  4504. if (l.function(s))
  4505. s(a => {
  4506. ;(this.thumbnails = a), n()
  4507. })
  4508. else {
  4509. const a = (l.string(s) ? [s] : s).map(r => this.getThumbnail(r))
  4510. Promise.all(a).then(n)
  4511. }
  4512. })
  4513. ),
  4514. m(
  4515. this,
  4516. 'getThumbnail',
  4517. t =>
  4518. new Promise(s => {
  4519. le(t).then(n => {
  4520. const a = { frames: Di(n), height: null, urlPrefix: '' }
  4521. a.frames[0].text.startsWith('/') ||
  4522. a.frames[0].text.startsWith('http://') ||
  4523. a.frames[0].text.startsWith('https://') ||
  4524. (a.urlPrefix = t.substring(0, t.lastIndexOf('/') + 1))
  4525. const r = new Image()
  4526. ;(r.onload = () => {
  4527. ;(a.height = r.naturalHeight),
  4528. (a.width = r.naturalWidth),
  4529. this.thumbnails.push(a),
  4530. s()
  4531. }),
  4532. (r.src = a.urlPrefix + a.frames[0].text)
  4533. })
  4534. })
  4535. ),
  4536. m(this, 'startMove', t => {
  4537. if (
  4538. this.loaded &&
  4539. l.event(t) &&
  4540. ['touchmove', 'mousemove'].includes(t.type) &&
  4541. this.player.media.duration
  4542. ) {
  4543. if (t.type === 'touchmove')
  4544. this.seekTime =
  4545. this.player.media.duration *
  4546. (this.player.elements.inputs.seek.value / 100)
  4547. else {
  4548. var s, n
  4549. const a = this.player.elements.progress.getBoundingClientRect(),
  4550. r = (100 / a.width) * (t.pageX - a.left)
  4551. ;(this.seekTime = this.player.media.duration * (r / 100)),
  4552. this.seekTime < 0 && (this.seekTime = 0),
  4553. this.seekTime > this.player.media.duration - 1 &&
  4554. (this.seekTime = this.player.media.duration - 1),
  4555. (this.mousePosX = t.pageX),
  4556. (this.elements.thumb.time.innerText = be(this.seekTime))
  4557. const o =
  4558. (s = this.player.config.markers) === null ||
  4559. s === void 0 ||
  4560. (n = s.points) === null ||
  4561. n === void 0
  4562. ? void 0
  4563. : n.find(({ time: c }) => c === Math.round(this.seekTime))
  4564. o &&
  4565. this.elements.thumb.time.insertAdjacentHTML(
  4566. 'afterbegin',
  4567. `${o.label}<br>`
  4568. )
  4569. }
  4570. this.showImageAtCurrentTime()
  4571. }
  4572. }),
  4573. m(this, 'endMove', () => {
  4574. this.toggleThumbContainer(!1, !0)
  4575. }),
  4576. m(this, 'startScrubbing', t => {
  4577. ;(l.nullOrUndefined(t.button) || t.button === !1 || t.button === 0) &&
  4578. ((this.mouseDown = !0),
  4579. this.player.media.duration &&
  4580. (this.toggleScrubbingContainer(!0),
  4581. this.toggleThumbContainer(!1, !0),
  4582. this.showImageAtCurrentTime()))
  4583. }),
  4584. m(this, 'endScrubbing', () => {
  4585. ;(this.mouseDown = !1),
  4586. Math.ceil(this.lastTime) === Math.ceil(this.player.media.currentTime)
  4587. ? this.toggleScrubbingContainer(!1)
  4588. : Pe.call(this.player, this.player.media, 'timeupdate', () => {
  4589. this.mouseDown || this.toggleScrubbingContainer(!1)
  4590. })
  4591. }),
  4592. m(this, 'listeners', () => {
  4593. this.player.on('play', () => {
  4594. this.toggleThumbContainer(!1, !0)
  4595. }),
  4596. this.player.on('seeked', () => {
  4597. this.toggleThumbContainer(!1)
  4598. }),
  4599. this.player.on('timeupdate', () => {
  4600. this.lastTime = this.player.media.currentTime
  4601. })
  4602. }),
  4603. m(this, 'render', () => {
  4604. ;(this.elements.thumb.container = y('div', {
  4605. class: this.player.config.classNames.previewThumbnails.thumbContainer
  4606. })),
  4607. (this.elements.thumb.imageContainer = y('div', {
  4608. class:
  4609. this.player.config.classNames.previewThumbnails.imageContainer
  4610. })),
  4611. this.elements.thumb.container.appendChild(
  4612. this.elements.thumb.imageContainer
  4613. )
  4614. const t = y('div', {
  4615. class: this.player.config.classNames.previewThumbnails.timeContainer
  4616. })
  4617. ;(this.elements.thumb.time = y('span', {}, '00:00')),
  4618. t.appendChild(this.elements.thumb.time),
  4619. this.elements.thumb.imageContainer.appendChild(t),
  4620. l.element(this.player.elements.progress) &&
  4621. this.player.elements.progress.appendChild(
  4622. this.elements.thumb.container
  4623. ),
  4624. (this.elements.scrubbing.container = y('div', {
  4625. class:
  4626. this.player.config.classNames.previewThumbnails.scrubbingContainer
  4627. })),
  4628. this.player.elements.wrapper.appendChild(
  4629. this.elements.scrubbing.container
  4630. )
  4631. }),
  4632. m(this, 'destroy', () => {
  4633. this.elements.thumb.container && this.elements.thumb.container.remove(),
  4634. this.elements.scrubbing.container &&
  4635. this.elements.scrubbing.container.remove()
  4636. }),
  4637. m(this, 'showImageAtCurrentTime', () => {
  4638. this.mouseDown
  4639. ? this.setScrubbingContainerSize()
  4640. : this.setThumbContainerSizeAndPos()
  4641. const t = this.thumbnails[0].frames.findIndex(
  4642. a => this.seekTime >= a.startTime && this.seekTime <= a.endTime
  4643. ),
  4644. s = t >= 0
  4645. let n = 0
  4646. this.mouseDown || this.toggleThumbContainer(s),
  4647. s &&
  4648. (this.thumbnails.forEach((a, r) => {
  4649. this.loadedImages.includes(a.frames[t].text) && (n = r)
  4650. }),
  4651. t !== this.showingThumb &&
  4652. ((this.showingThumb = t), this.loadImage(n)))
  4653. }),
  4654. m(this, 'loadImage', (t = 0) => {
  4655. const s = this.showingThumb,
  4656. n = this.thumbnails[t],
  4657. { urlPrefix: a } = n,
  4658. r = n.frames[s],
  4659. o = n.frames[s].text,
  4660. c = a + o
  4661. if (
  4662. this.currentImageElement &&
  4663. this.currentImageElement.dataset.filename === o
  4664. )
  4665. this.showImage(this.currentImageElement, r, t, s, o, !1),
  4666. (this.currentImageElement.dataset.index = s),
  4667. this.removeOldImages(this.currentImageElement)
  4668. else {
  4669. this.loadingImage &&
  4670. this.usingSprites &&
  4671. (this.loadingImage.onload = null)
  4672. const u = new Image()
  4673. ;(u.src = c),
  4674. (u.dataset.index = s),
  4675. (u.dataset.filename = o),
  4676. (this.showingThumbFilename = o),
  4677. this.player.debug.log(`Loading image: ${c}`),
  4678. (u.onload = () => this.showImage(u, r, t, s, o, !0)),
  4679. (this.loadingImage = u),
  4680. this.removeOldImages(u)
  4681. }
  4682. }),
  4683. m(this, 'showImage', (t, s, n, a, r, o = !0) => {
  4684. this.player.debug.log(
  4685. `Showing thumb: ${r}. num: ${a}. qual: ${n}. newimg: ${o}`
  4686. ),
  4687. this.setImageSizeAndOffset(t, s),
  4688. o &&
  4689. (this.currentImageContainer.appendChild(t),
  4690. (this.currentImageElement = t),
  4691. this.loadedImages.includes(r) || this.loadedImages.push(r)),
  4692. this.preloadNearby(a, !0)
  4693. .then(this.preloadNearby(a, !1))
  4694. .then(this.getHigherQuality(n, t, s, r))
  4695. }),
  4696. m(this, 'removeOldImages', t => {
  4697. Array.from(this.currentImageContainer.children).forEach(s => {
  4698. if (s.tagName.toLowerCase() !== 'img') return
  4699. const n = this.usingSprites ? 500 : 1e3
  4700. if (s.dataset.index !== t.dataset.index && !s.dataset.deleting) {
  4701. s.dataset.deleting = !0
  4702. const { currentImageContainer: a } = this
  4703. setTimeout(() => {
  4704. a.removeChild(s),
  4705. this.player.debug.log(`Removing thumb: ${s.dataset.filename}`)
  4706. }, n)
  4707. }
  4708. })
  4709. }),
  4710. m(
  4711. this,
  4712. 'preloadNearby',
  4713. (t, s = !0) =>
  4714. new Promise(n => {
  4715. setTimeout(() => {
  4716. const a = this.thumbnails[0].frames[t].text
  4717. if (this.showingThumbFilename === a) {
  4718. let r
  4719. r = s
  4720. ? this.thumbnails[0].frames.slice(t)
  4721. : this.thumbnails[0].frames.slice(0, t).reverse()
  4722. let o = !1
  4723. r.forEach(c => {
  4724. const u = c.text
  4725. if (u !== a && !this.loadedImages.includes(u)) {
  4726. ;(o = !0),
  4727. this.player.debug.log(`Preloading thumb filename: ${u}`)
  4728. const { urlPrefix: p } = this.thumbnails[0],
  4729. f = p + u,
  4730. d = new Image()
  4731. ;(d.src = f),
  4732. (d.onload = () => {
  4733. this.player.debug.log(`Preloaded thumb filename: ${u}`),
  4734. this.loadedImages.includes(u) ||
  4735. this.loadedImages.push(u),
  4736. n()
  4737. })
  4738. }
  4739. }),
  4740. o || n()
  4741. }
  4742. }, 300)
  4743. })
  4744. ),
  4745. m(this, 'getHigherQuality', (t, s, n, a) => {
  4746. if (t < this.thumbnails.length - 1) {
  4747. let r = s.naturalHeight
  4748. this.usingSprites && (r = n.h),
  4749. r < this.thumbContainerHeight &&
  4750. setTimeout(() => {
  4751. this.showingThumbFilename === a &&
  4752. (this.player.debug.log(
  4753. `Showing higher quality thumb for: ${a}`
  4754. ),
  4755. this.loadImage(t + 1))
  4756. }, 300)
  4757. }
  4758. }),
  4759. m(this, 'toggleThumbContainer', (t = !1, s = !1) => {
  4760. const n =
  4761. this.player.config.classNames.previewThumbnails.thumbContainerShown
  4762. this.elements.thumb.container.classList.toggle(n, t),
  4763. !t &&
  4764. s &&
  4765. ((this.showingThumb = null), (this.showingThumbFilename = null))
  4766. }),
  4767. m(this, 'toggleScrubbingContainer', (t = !1) => {
  4768. const s =
  4769. this.player.config.classNames.previewThumbnails
  4770. .scrubbingContainerShown
  4771. this.elements.scrubbing.container.classList.toggle(s, t),
  4772. t || ((this.showingThumb = null), (this.showingThumbFilename = null))
  4773. }),
  4774. m(this, 'determineContainerAutoSizing', () => {
  4775. ;(this.elements.thumb.imageContainer.clientHeight > 20 ||
  4776. this.elements.thumb.imageContainer.clientWidth > 20) &&
  4777. (this.sizeSpecifiedInCSS = !0)
  4778. }),
  4779. m(this, 'setThumbContainerSizeAndPos', () => {
  4780. const { imageContainer: t } = this.elements.thumb
  4781. if (this.sizeSpecifiedInCSS) {
  4782. if (t.clientHeight > 20 && t.clientWidth < 20) {
  4783. const s = Math.floor(t.clientHeight * this.thumbAspectRatio)
  4784. t.style.width = `${s}px`
  4785. } else if (t.clientHeight < 20 && t.clientWidth > 20) {
  4786. const s = Math.floor(t.clientWidth / this.thumbAspectRatio)
  4787. t.style.height = `${s}px`
  4788. }
  4789. } else {
  4790. const s = Math.floor(
  4791. this.thumbContainerHeight * this.thumbAspectRatio
  4792. )
  4793. ;(t.style.height = `${this.thumbContainerHeight}px`),
  4794. (t.style.width = `${s}px`)
  4795. }
  4796. this.setThumbContainerPos()
  4797. }),
  4798. m(this, 'setThumbContainerPos', () => {
  4799. const t = this.player.elements.progress.getBoundingClientRect(),
  4800. s = this.player.elements.container.getBoundingClientRect(),
  4801. { container: n } = this.elements.thumb,
  4802. a = s.left - t.left + 10,
  4803. r = s.right - t.left - n.clientWidth - 10,
  4804. o = this.mousePosX - t.left - n.clientWidth / 2,
  4805. c = kt(o, a, r)
  4806. ;(n.style.left = `${c}px`),
  4807. n.style.setProperty('--preview-arrow-offset', o - c + 'px')
  4808. }),
  4809. m(this, 'setScrubbingContainerSize', () => {
  4810. const { width: t, height: s } = At(this.thumbAspectRatio, {
  4811. width: this.player.media.clientWidth,
  4812. height: this.player.media.clientHeight
  4813. })
  4814. ;(this.elements.scrubbing.container.style.width = `${t}px`),
  4815. (this.elements.scrubbing.container.style.height = `${s}px`)
  4816. }),
  4817. m(this, 'setImageSizeAndOffset', (t, s) => {
  4818. if (!this.usingSprites) return
  4819. const n = this.thumbContainerHeight / s.h
  4820. ;(t.style.height = t.naturalHeight * n + 'px'),
  4821. (t.style.width = t.naturalWidth * n + 'px'),
  4822. (t.style.left = `-${s.x * n}px`),
  4823. (t.style.top = `-${s.y * n}px`)
  4824. }),
  4825. (this.player = i),
  4826. (this.thumbnails = []),
  4827. (this.loaded = !1),
  4828. (this.lastMouseMoveTime = Date.now()),
  4829. (this.mouseDown = !1),
  4830. (this.loadedImages = []),
  4831. (this.elements = { thumb: {}, scrubbing: {} }),
  4832. this.load()
  4833. }
  4834. get enabled() {
  4835. return (
  4836. this.player.isHTML5 &&
  4837. this.player.isVideo &&
  4838. this.player.config.previewThumbnails.enabled
  4839. )
  4840. }
  4841. get currentImageContainer() {
  4842. return this.mouseDown
  4843. ? this.elements.scrubbing.container
  4844. : this.elements.thumb.imageContainer
  4845. }
  4846. get usingSprites() {
  4847. return Object.keys(this.thumbnails[0].frames[0]).includes('w')
  4848. }
  4849. get thumbAspectRatio() {
  4850. return this.usingSprites
  4851. ? this.thumbnails[0].frames[0].w / this.thumbnails[0].frames[0].h
  4852. : this.thumbnails[0].width / this.thumbnails[0].height
  4853. }
  4854. get thumbContainerHeight() {
  4855. if (this.mouseDown) {
  4856. const { height: i } = At(this.thumbAspectRatio, {
  4857. width: this.player.media.clientWidth,
  4858. height: this.player.media.clientHeight
  4859. })
  4860. return i
  4861. }
  4862. return this.sizeSpecifiedInCSS
  4863. ? this.elements.thumb.imageContainer.clientHeight
  4864. : Math.floor(this.player.media.clientWidth / this.thumbAspectRatio / 4)
  4865. }
  4866. get currentImageElement() {
  4867. return this.mouseDown
  4868. ? this.currentScrubbingImageElement
  4869. : this.currentThumbnailImageElement
  4870. }
  4871. set currentImageElement(i) {
  4872. this.mouseDown
  4873. ? (this.currentScrubbingImageElement = i)
  4874. : (this.currentThumbnailImageElement = i)
  4875. }
  4876. }
  4877. const je = {
  4878. insertElements(e, i) {
  4879. l.string(i)
  4880. ? rt(e, this.media, { src: i })
  4881. : l.array(i) &&
  4882. i.forEach(t => {
  4883. rt(e, this.media, t)
  4884. })
  4885. },
  4886. change(e) {
  4887. at(e, 'sources.length')
  4888. ? (K.cancelRequests.call(this),
  4889. this.destroy.call(
  4890. this,
  4891. () => {
  4892. ;(this.options.quality = []),
  4893. z(this.media),
  4894. (this.media = null),
  4895. l.element(this.elements.container) &&
  4896. this.elements.container.removeAttribute('class')
  4897. const { sources: i, type: t } = e,
  4898. [{ provider: s = Y.html5, src: n }] = i,
  4899. a = s === 'html5' ? t : 'div',
  4900. r = s === 'html5' ? {} : { src: n }
  4901. Object.assign(this, {
  4902. provider: s,
  4903. type: t,
  4904. supported: x.check(t, s, this.config.playsinline),
  4905. media: y(a, r)
  4906. }),
  4907. this.elements.container.appendChild(this.media),
  4908. l.boolean(e.autoplay) && (this.config.autoplay = e.autoplay),
  4909. this.isHTML5 &&
  4910. (this.config.crossorigin &&
  4911. this.media.setAttribute('crossorigin', ''),
  4912. this.config.autoplay && this.media.setAttribute('autoplay', ''),
  4913. l.empty(e.poster) || (this.poster = e.poster),
  4914. this.config.loop.active && this.media.setAttribute('loop', ''),
  4915. this.config.muted && this.media.setAttribute('muted', ''),
  4916. this.config.playsinline &&
  4917. this.media.setAttribute('playsinline', '')),
  4918. P.addStyleHook.call(this),
  4919. this.isHTML5 && je.insertElements.call(this, 'source', i),
  4920. (this.config.title = e.title),
  4921. Tt.setup.call(this),
  4922. this.isHTML5 &&
  4923. Object.keys(e).includes('tracks') &&
  4924. je.insertElements.call(this, 'track', e.tracks),
  4925. (this.isHTML5 || (this.isEmbed && !this.supported.ui)) &&
  4926. P.build.call(this),
  4927. this.isHTML5 && this.media.load(),
  4928. l.empty(e.previewThumbnails) ||
  4929. (Object.assign(
  4930. this.config.previewThumbnails,
  4931. e.previewThumbnails
  4932. ),
  4933. this.previewThumbnails &&
  4934. this.previewThumbnails.loaded &&
  4935. (this.previewThumbnails.destroy(),
  4936. (this.previewThumbnails = null)),
  4937. this.config.previewThumbnails.enabled &&
  4938. (this.previewThumbnails = new Re(this))),
  4939. this.fullscreen.update()
  4940. },
  4941. !0
  4942. ))
  4943. : this.debug.warn('Invalid source format')
  4944. }
  4945. }
  4946. class ce {
  4947. constructor(i, t) {
  4948. if (
  4949. (m(this, 'play', () =>
  4950. l.function(this.media.play)
  4951. ? (this.ads &&
  4952. this.ads.enabled &&
  4953. this.ads.managerPromise
  4954. .then(() => this.ads.play())
  4955. .catch(() => V(this.media.play())),
  4956. this.media.play())
  4957. : null
  4958. ),
  4959. m(this, 'pause', () =>
  4960. this.playing && l.function(this.media.pause) ? this.media.pause() : null
  4961. ),
  4962. m(this, 'togglePlay', o =>
  4963. (l.boolean(o) ? o : !this.playing) ? this.play() : this.pause()
  4964. ),
  4965. m(this, 'stop', () => {
  4966. this.isHTML5
  4967. ? (this.pause(), this.restart())
  4968. : l.function(this.media.stop) && this.media.stop()
  4969. }),
  4970. m(this, 'restart', () => {
  4971. this.currentTime = 0
  4972. }),
  4973. m(this, 'rewind', o => {
  4974. this.currentTime -= l.number(o) ? o : this.config.seekTime
  4975. }),
  4976. m(this, 'forward', o => {
  4977. this.currentTime += l.number(o) ? o : this.config.seekTime
  4978. }),
  4979. m(this, 'increaseVolume', o => {
  4980. const c = this.media.muted ? 0 : this.volume
  4981. this.volume = c + (l.number(o) ? o : 0)
  4982. }),
  4983. m(this, 'decreaseVolume', o => {
  4984. this.increaseVolume(-o)
  4985. }),
  4986. m(this, 'airplay', () => {
  4987. x.airplay && this.media.webkitShowPlaybackTargetPicker()
  4988. }),
  4989. m(this, 'toggleControls', o => {
  4990. if (this.supported.ui && !this.isAudio) {
  4991. const c = ge(
  4992. this.elements.container,
  4993. this.config.classNames.hideControls
  4994. ),
  4995. u = o === void 0 ? void 0 : !o,
  4996. p = A(
  4997. this.elements.container,
  4998. this.config.classNames.hideControls,
  4999. u
  5000. )
  5001. if (
  5002. (p &&
  5003. l.array(this.config.controls) &&
  5004. this.config.controls.includes('settings') &&
  5005. !l.empty(this.config.settings) &&
  5006. h.toggleMenu.call(this, !1),
  5007. p !== c)
  5008. ) {
  5009. const f = p ? 'controlshidden' : 'controlsshown'
  5010. b.call(this, this.media, f)
  5011. }
  5012. return !p
  5013. }
  5014. return !1
  5015. }),
  5016. m(this, 'on', (o, c) => {
  5017. C.call(this, this.elements.container, o, c)
  5018. }),
  5019. m(this, 'once', (o, c) => {
  5020. Pe.call(this, this.elements.container, o, c)
  5021. }),
  5022. m(this, 'off', (o, c) => {
  5023. fe(this.elements.container, o, c)
  5024. }),
  5025. m(this, 'destroy', (o, c = !1) => {
  5026. if (!this.ready) return
  5027. const u = () => {
  5028. ;(document.body.style.overflow = ''),
  5029. (this.embed = null),
  5030. c
  5031. ? (Object.keys(this.elements).length &&
  5032. (z(this.elements.buttons.play),
  5033. z(this.elements.captions),
  5034. z(this.elements.controls),
  5035. z(this.elements.wrapper),
  5036. (this.elements.buttons.play = null),
  5037. (this.elements.captions = null),
  5038. (this.elements.controls = null),
  5039. (this.elements.wrapper = null)),
  5040. l.function(o) && o())
  5041. : (bi.call(this),
  5042. K.cancelRequests.call(this),
  5043. pe(this.elements.original, this.elements.container),
  5044. b.call(this, this.elements.original, 'destroyed', !0),
  5045. l.function(o) && o.call(this.elements.original),
  5046. (this.ready = !1),
  5047. setTimeout(() => {
  5048. ;(this.elements = null), (this.media = null)
  5049. }, 200))
  5050. }
  5051. this.stop(),
  5052. clearTimeout(this.timers.loading),
  5053. clearTimeout(this.timers.controls),
  5054. clearTimeout(this.timers.resized),
  5055. this.isHTML5
  5056. ? (P.toggleNativeControls.call(this, !0), u())
  5057. : this.isYouTube
  5058. ? (clearInterval(this.timers.buffering),
  5059. clearInterval(this.timers.playing),
  5060. this.embed !== null &&
  5061. l.function(this.embed.destroy) &&
  5062. this.embed.destroy(),
  5063. u())
  5064. : this.isVimeo &&
  5065. (this.embed !== null && this.embed.unload().then(u),
  5066. setTimeout(u, 200))
  5067. }),
  5068. m(this, 'supports', o => x.mime.call(this, o)),
  5069. (this.timers = {}),
  5070. (this.ready = !1),
  5071. (this.loading = !1),
  5072. (this.failed = !1),
  5073. (this.touch = x.touch),
  5074. (this.media = i),
  5075. l.string(this.media) &&
  5076. (this.media = document.querySelectorAll(this.media)),
  5077. ((window.jQuery && this.media instanceof jQuery) ||
  5078. l.nodeList(this.media) ||
  5079. l.array(this.media)) &&
  5080. (this.media = this.media[0]),
  5081. (this.config = I(
  5082. {},
  5083. wt,
  5084. ce.defaults,
  5085. t || {},
  5086. (() => {
  5087. try {
  5088. return JSON.parse(this.media.getAttribute('data-plyr-config'))
  5089. } catch {
  5090. return {}
  5091. }
  5092. })()
  5093. )),
  5094. (this.elements = {
  5095. container: null,
  5096. fullscreen: null,
  5097. captions: null,
  5098. buttons: {},
  5099. display: {},
  5100. progress: {},
  5101. inputs: {},
  5102. settings: { popup: null, menu: null, panels: {}, buttons: {} }
  5103. }),
  5104. (this.captions = { active: null, currentTrack: -1, meta: new WeakMap() }),
  5105. (this.fullscreen = { active: !1 }),
  5106. (this.options = { speed: [], quality: [] }),
  5107. (this.debug = new Mi(this.config.debug)),
  5108. this.debug.log('Config', this.config),
  5109. this.debug.log('Support', x),
  5110. l.nullOrUndefined(this.media) || !l.element(this.media))
  5111. )
  5112. return void this.debug.error('Setup failed: no suitable element passed')
  5113. if (this.media.plyr) return void this.debug.warn('Target already setup')
  5114. if (!this.config.enabled)
  5115. return void this.debug.error('Setup failed: disabled by config')
  5116. if (!x.check().api) return void this.debug.error('Setup failed: no support')
  5117. const s = this.media.cloneNode(!0)
  5118. ;(s.autoplay = !1), (this.elements.original = s)
  5119. const n = this.media.tagName.toLowerCase()
  5120. let a = null,
  5121. r = null
  5122. switch (n) {
  5123. case 'div':
  5124. if (((a = this.media.querySelector('iframe')), l.element(a))) {
  5125. if (
  5126. ((r = bt(a.getAttribute('src'))),
  5127. (this.provider = Ni(r.toString())),
  5128. (this.elements.container = this.media),
  5129. (this.media = a),
  5130. (this.elements.container.className = ''),
  5131. r.search.length)
  5132. ) {
  5133. const o = ['1', 'true']
  5134. o.includes(r.searchParams.get('autoplay')) &&
  5135. (this.config.autoplay = !0),
  5136. o.includes(r.searchParams.get('loop')) &&
  5137. (this.config.loop.active = !0),
  5138. this.isYouTube
  5139. ? ((this.config.playsinline = o.includes(
  5140. r.searchParams.get('playsinline')
  5141. )),
  5142. (this.config.youtube.hl = r.searchParams.get('hl')))
  5143. : (this.config.playsinline = !0)
  5144. }
  5145. } else
  5146. (this.provider = this.media.getAttribute(
  5147. this.config.attributes.embed.provider
  5148. )),
  5149. this.media.removeAttribute(this.config.attributes.embed.provider)
  5150. if (l.empty(this.provider) || !Object.values(Y).includes(this.provider))
  5151. return void this.debug.error('Setup failed: Invalid provider')
  5152. this.type = Le.video
  5153. break
  5154. case 'video':
  5155. case 'audio':
  5156. ;(this.type = n),
  5157. (this.provider = Y.html5),
  5158. this.media.hasAttribute('crossorigin') &&
  5159. (this.config.crossorigin = !0),
  5160. this.media.hasAttribute('autoplay') && (this.config.autoplay = !0),
  5161. (this.media.hasAttribute('playsinline') ||
  5162. this.media.hasAttribute('webkit-playsinline')) &&
  5163. (this.config.playsinline = !0),
  5164. this.media.hasAttribute('muted') && (this.config.muted = !0),
  5165. this.media.hasAttribute('loop') && (this.config.loop.active = !0)
  5166. break
  5167. default:
  5168. return void this.debug.error('Setup failed: unsupported type')
  5169. }
  5170. ;(this.supported = x.check(
  5171. this.type,
  5172. this.provider,
  5173. this.config.playsinline
  5174. )),
  5175. this.supported.api
  5176. ? ((this.eventListeners = []),
  5177. (this.listeners = new xi(this)),
  5178. (this.storage = new ae(this)),
  5179. (this.media.plyr = this),
  5180. l.element(this.elements.container) ||
  5181. ((this.elements.container = y('div', { tabindex: 0 })),
  5182. lt(this.media, this.elements.container)),
  5183. P.migrateStyles.call(this),
  5184. P.addStyleHook.call(this),
  5185. Tt.setup.call(this),
  5186. this.config.debug &&
  5187. C.call(
  5188. this,
  5189. this.elements.container,
  5190. this.config.events.join(' '),
  5191. o => {
  5192. this.debug.log(`event: ${o.type}`)
  5193. }
  5194. ),
  5195. (this.fullscreen = new F(this)),
  5196. (this.isHTML5 || (this.isEmbed && !this.supported.ui)) &&
  5197. P.build.call(this),
  5198. this.listeners.container(),
  5199. this.listeners.global(),
  5200. this.config.ads.enabled && (this.ads = new ji(this)),
  5201. this.isHTML5 &&
  5202. this.config.autoplay &&
  5203. this.once('canplay', () => V(this.play())),
  5204. (this.lastSeekTime = 0),
  5205. this.config.previewThumbnails.enabled &&
  5206. (this.previewThumbnails = new Re(this)))
  5207. : this.debug.error('Setup failed: no support')
  5208. }
  5209. get isHTML5() {
  5210. return this.provider === Y.html5
  5211. }
  5212. get isEmbed() {
  5213. return this.isYouTube || this.isVimeo
  5214. }
  5215. get isYouTube() {
  5216. return this.provider === Y.youtube
  5217. }
  5218. get isVimeo() {
  5219. return this.provider === Y.vimeo
  5220. }
  5221. get isVideo() {
  5222. return this.type === Le.video
  5223. }
  5224. get isAudio() {
  5225. return this.type === Le.audio
  5226. }
  5227. get playing() {
  5228. return Boolean(this.ready && !this.paused && !this.ended)
  5229. }
  5230. get paused() {
  5231. return Boolean(this.media.paused)
  5232. }
  5233. get stopped() {
  5234. return Boolean(this.paused && this.currentTime === 0)
  5235. }
  5236. get ended() {
  5237. return Boolean(this.media.ended)
  5238. }
  5239. set currentTime(i) {
  5240. if (!this.duration) return
  5241. const t = l.number(i) && i > 0
  5242. ;(this.media.currentTime = t ? Math.min(i, this.duration) : 0),
  5243. this.debug.log(`Seeking to ${this.currentTime} seconds`)
  5244. }
  5245. get currentTime() {
  5246. return Number(this.media.currentTime)
  5247. }
  5248. get buffered() {
  5249. const { buffered: i } = this.media
  5250. return l.number(i)
  5251. ? i
  5252. : i && i.length && this.duration > 0
  5253. ? i.end(0) / this.duration
  5254. : 0
  5255. }
  5256. get seeking() {
  5257. return Boolean(this.media.seeking)
  5258. }
  5259. get duration() {
  5260. const i = parseFloat(this.config.duration),
  5261. t = (this.media || {}).duration,
  5262. s = l.number(t) && t !== 1 / 0 ? t : 0
  5263. return i || s
  5264. }
  5265. set volume(i) {
  5266. let t = i
  5267. l.string(t) && (t = Number(t)),
  5268. l.number(t) || (t = this.storage.get('volume')),
  5269. l.number(t) || ({ volume: t } = this.config),
  5270. t > 1 && (t = 1),
  5271. t < 0 && (t = 0),
  5272. (this.config.volume = t),
  5273. (this.media.volume = t),
  5274. !l.empty(i) && this.muted && t > 0 && (this.muted = !1)
  5275. }
  5276. get volume() {
  5277. return Number(this.media.volume)
  5278. }
  5279. set muted(i) {
  5280. let t = i
  5281. l.boolean(t) || (t = this.storage.get('muted')),
  5282. l.boolean(t) || (t = this.config.muted),
  5283. (this.config.muted = t),
  5284. (this.media.muted = t)
  5285. }
  5286. get muted() {
  5287. return Boolean(this.media.muted)
  5288. }
  5289. get hasAudio() {
  5290. return (
  5291. !this.isHTML5 ||
  5292. !!this.isAudio ||
  5293. Boolean(this.media.mozHasAudio) ||
  5294. Boolean(this.media.webkitAudioDecodedByteCount) ||
  5295. Boolean(this.media.audioTracks && this.media.audioTracks.length)
  5296. )
  5297. }
  5298. set speed(i) {
  5299. let t = null
  5300. l.number(i) && (t = i),
  5301. l.number(t) || (t = this.storage.get('speed')),
  5302. l.number(t) || (t = this.config.speed.selected)
  5303. const { minimumSpeed: s, maximumSpeed: n } = this
  5304. ;(t = kt(t, s, n)),
  5305. (this.config.speed.selected = t),
  5306. setTimeout(() => {
  5307. this.media && (this.media.playbackRate = t)
  5308. }, 0)
  5309. }
  5310. get speed() {
  5311. return Number(this.media.playbackRate)
  5312. }
  5313. get minimumSpeed() {
  5314. return this.isYouTube
  5315. ? Math.min(...this.options.speed)
  5316. : this.isVimeo
  5317. ? 0.5
  5318. : 0.0625
  5319. }
  5320. get maximumSpeed() {
  5321. return this.isYouTube
  5322. ? Math.max(...this.options.speed)
  5323. : this.isVimeo
  5324. ? 2
  5325. : 16
  5326. }
  5327. set quality(i) {
  5328. const t = this.config.quality,
  5329. s = this.options.quality
  5330. if (!s.length) return
  5331. let n = [
  5332. !l.empty(i) && Number(i),
  5333. this.storage.get('quality'),
  5334. t.selected,
  5335. t.default
  5336. ].find(l.number),
  5337. a = !0
  5338. if (!s.includes(n)) {
  5339. const r = ct(s, n)
  5340. this.debug.warn(`Unsupported quality option: ${n}, using ${r} instead`),
  5341. (n = r),
  5342. (a = !1)
  5343. }
  5344. ;(t.selected = n),
  5345. (this.media.quality = n),
  5346. a && this.storage.set({ quality: n })
  5347. }
  5348. get quality() {
  5349. return this.media.quality
  5350. }
  5351. set loop(i) {
  5352. const t = l.boolean(i) ? i : this.config.loop.active
  5353. ;(this.config.loop.active = t), (this.media.loop = t)
  5354. }
  5355. get loop() {
  5356. return Boolean(this.media.loop)
  5357. }
  5358. set source(i) {
  5359. je.change.call(this, i)
  5360. }
  5361. get source() {
  5362. return this.media.currentSrc
  5363. }
  5364. get download() {
  5365. const { download: i } = this.config.urls
  5366. return l.url(i) ? i : this.source
  5367. }
  5368. set download(i) {
  5369. l.url(i) && ((this.config.urls.download = i), h.setDownloadUrl.call(this))
  5370. }
  5371. set poster(i) {
  5372. this.isVideo
  5373. ? P.setPoster.call(this, i, !1).catch(() => {})
  5374. : this.debug.warn('Poster can only be set for video')
  5375. }
  5376. get poster() {
  5377. return this.isVideo
  5378. ? this.media.getAttribute('poster') ||
  5379. this.media.getAttribute('data-poster')
  5380. : null
  5381. }
  5382. get ratio() {
  5383. if (!this.isVideo) return null
  5384. const i = ye(Me.call(this))
  5385. return l.array(i) ? i.join(':') : i
  5386. }
  5387. set ratio(i) {
  5388. this.isVideo
  5389. ? l.string(i) && dt(i)
  5390. ? ((this.config.ratio = ye(i)), te.call(this))
  5391. : this.debug.error(`Invalid aspect ratio specified (${i})`)
  5392. : this.debug.warn('Aspect ratio can only be set for video')
  5393. }
  5394. set autoplay(i) {
  5395. this.config.autoplay = l.boolean(i) ? i : this.config.autoplay
  5396. }
  5397. get autoplay() {
  5398. return Boolean(this.config.autoplay)
  5399. }
  5400. toggleCaptions(i) {
  5401. E.toggle.call(this, i, !1)
  5402. }
  5403. set currentTrack(i) {
  5404. E.set.call(this, i, !1), E.setup.call(this)
  5405. }
  5406. get currentTrack() {
  5407. const { toggled: i, currentTrack: t } = this.captions
  5408. return i ? t : -1
  5409. }
  5410. set language(i) {
  5411. E.setLanguage.call(this, i, !1)
  5412. }
  5413. get language() {
  5414. return (E.getCurrentTrack.call(this) || {}).language
  5415. }
  5416. set pip(i) {
  5417. if (!x.pip) return
  5418. const t = l.boolean(i) ? i : !this.pip
  5419. l.function(this.media.webkitSetPresentationMode) &&
  5420. this.media.webkitSetPresentationMode(t ? Ie.active : Ie.inactive),
  5421. l.function(this.media.requestPictureInPicture) &&
  5422. (!this.pip && t
  5423. ? this.media.requestPictureInPicture()
  5424. : this.pip && !t && document.exitPictureInPicture())
  5425. }
  5426. get pip() {
  5427. return x.pip
  5428. ? l.empty(this.media.webkitPresentationMode)
  5429. ? this.media === document.pictureInPictureElement
  5430. : this.media.webkitPresentationMode === Ie.active
  5431. : null
  5432. }
  5433. setPreviewThumbnails(i) {
  5434. this.previewThumbnails &&
  5435. this.previewThumbnails.loaded &&
  5436. (this.previewThumbnails.destroy(), (this.previewThumbnails = null)),
  5437. Object.assign(this.config.previewThumbnails, i),
  5438. this.config.previewThumbnails.enabled &&
  5439. (this.previewThumbnails = new Re(this))
  5440. }
  5441. static supported(i, t, s) {
  5442. return x.check(i, t, s)
  5443. }
  5444. static loadSprite(i, t) {
  5445. return ft(i, t)
  5446. }
  5447. static setup(i, t = {}) {
  5448. let s = null
  5449. return (
  5450. l.string(i)
  5451. ? (s = Array.from(document.querySelectorAll(i)))
  5452. : l.nodeList(i)
  5453. ? (s = Array.from(i))
  5454. : l.array(i) && (s = i.filter(l.element)),
  5455. l.empty(s) ? null : s.map(n => new ce(n, t))
  5456. )
  5457. }
  5458. }
  5459. ce.defaults = pi(wt)
  5460. var Hi =
  5461. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFIAAABSCAMAAADw8nOpAAAAAXNSR0IArs4c6QAAAapQTFRFAAAA////////////2NjY2dnZ9vb2////9vb23Nzc3d3d3t7e39/f////4+Pj4+Pj6+vr7Ozs5+fn6Ojo7u7u6enp6enp7+/v8fHx7Ozs8fHx7e3t7+/v8/Pz8PDw8/Pz9PT0+/v78PDw8PDw9PT09PT0////9fX1/Pz89fX19fX19fX18vLy/Pz89vb29vb2/Pz8+fn59/f3////9/f3+vr69/f3+vr6////+Pj4+/v7////+/v7+/v7+Pj4+fn5/////f39+/v7+/v7+/v7+fn5+/v7+/v7/f39////+/v7////+/v7/f39/Pz8/Pz8/////Pz8/////Pz8/f39/f39/Pz8/f39/v7+/Pz8/v7+/////Pz8/v7+/v7+/v7+/v7+/Pz8/v7+/////v7+/v7+/v7+/v7+/v7+/v7+/////v7+/v7+/v7+/////v7+/////v7+/v7+/////v7+/////v7+/////////////////v7+/////v7+/////////////v7+/////////////////////v7+////////////////////////lZ+FUgAAAI10Uk5TAAYSFRobGxscHR4fICMkJScpKywsLi8vNTY2OD5BQkJDQ0RGRkhISktMTlBRUlNVWFlbXF1gY29wcXJyc3R1d3p7fH+AgoSFhoaHj5CTlJWXmJifn6WoqKusr6+0tLi5ury/v8LDyMvMzdTV1tjY2trb3ODh4eLj5ejs7e3u7u/w8vT19vj5+vr7/P3+n1NMJwAAA5RJREFUWMO1metfEkEUhg86lrZZRBeVitJSsVIkKym7KFqYqJGXLiplCWUYBKllRiaQa7Lz/s998Bqyu7ML+37eeX47t3Pec4ZIR9VuX2gutpSW5fRSbC7kc1dTKaroHEtyFIgnxzorzPFs7VMbADLRCb/X5XRIksPp8vonohkAG1PtNsPAysFVIB8JtNawAtW0BiJ5YHWw0hDwaDALxAbqmIrqBmJANnhEfMq9OfDZNqaptlmOXK/g9Bvj4DNNTFdNMxzxRpFfHOFIeZiQPCnwEd0frZ2HPCQxQUlDMuZrtYkt61hsZgbUvIj1Fi1i1ybCdmZI9jA2u9SJPQpGmWGNQulRJULpZybUr0CF2aUo3cyUuhWl6NxbNtHPTKofm0X2qHbdzDrur+f6obNkm0eYlaAw5gvP/AgW7aUg7YsYKbjXXG5mJalZ5v/dd1sCQ6xEDSFxcOp9SEmlIqUU+g5E3Bz3sJLl4bn9mBzEDCuDZhDcyzNZrhpxT104Loxs4tndfDSIWbX1mdzCr8fHRJmzGNzZ7lWo5ZlhAMDna4LINqxub3o7YmrffN12A8qkQ4wZQzsREU1jQO2TH7sW4+ddIeQApomIKuR8nS4S+HBRAFmX36ggok5EmAASf5+d0GdG0ElEYwgIIYHvt3WRAYwRURKtgkjgbb0OshVJomqeqRFGIhfQPqQ1GV5Nbo2lPIwEEjd0FtNNPowbQoK/PKOBHIePQvAbQwJrD6pUR/gRojl4jSKBj5fVRngxRwtwGUdi6/nJ4iNcWKBlNJhAAis3i45owDKl4TCFRL6j2AgH0iRDMocsnvclyCUg36shTU8c99QmvgSnKWR+uOgIJ5YoZuoQ4dOV4iMuIWbuqP9+VKVx1E1cSP7qrOaFNBw28KVDI2xMwEduRA0h/2hXRVG4DYZgvDuvH4INJYqVOyKJwkA6Uw0/helMNOlqBMnCpCtoDdbuVwlbAyEDw1+cFjMwU3o269sOMX7dmM3SMIOvt5P3E0GHuWcGNSzruTiAN/VMUHuWVctYS7ceXjVjrC2w/1YUKdRbnlKq92DBFy9HwRe3WVuWWlE8W1HiW9CIsKJdYkVTx4rWkxUNMivaeFY0G61oiVrRuCWixoR4eznRKNgE7xNtgveJvwEcKXernoio8mmZHxS2nz2mZQCZyLjf62pwSJKjweX1j0cyAORpE88eljzOHHxCWlhOy3J6eUHoCekfdmynrwwsFL4AAAAASUVORK5CYII=',
  5462. Ui = Nt({
  5463. name: 'col-video',
  5464. props: {
  5465. trySee: { type: Boolean, default: !1 },
  5466. freeTitleStatus: { type: Boolean, default: !0 },
  5467. freeRate: { type: Number, default: 100 },
  5468. setting: { type: Object, default: () => {} },
  5469. controls: Boolean,
  5470. height: String,
  5471. src: { type: String, default: '' },
  5472. poster: { type: String, default: '' },
  5473. styleValue: { type: Object, default: () => ({}) },
  5474. preload: { type: String, default: 'auto' },
  5475. currentTime: { type: Boolean, default: !0 },
  5476. playsinline: { type: Boolean, default: !0 },
  5477. onPlay: { type: Function, default: () => {} }
  5478. },
  5479. data() {
  5480. return { player: null, loading: !0, trySeeOver: !1, showSeeStatus: !0 }
  5481. },
  5482. mounted() {
  5483. this._init(),
  5484. Lt('setVideoPlayer', e => {
  5485. ;(e == null ? void 0 : e.content).status === 'pause' &&
  5486. this.player.pause()
  5487. })
  5488. },
  5489. computed: {
  5490. computedSeeStatus() {
  5491. return (
  5492. console.log(
  5493. this.showSeeStatus,
  5494. this.trySee,
  5495. this.trySeeOver,
  5496. 'this.showSeeStatus, this.trySee'
  5497. ),
  5498. this.showSeeStatus && this.trySee
  5499. )
  5500. },
  5501. playTime() {
  5502. return (this.player.duration * this.freeRate) / 100 || 0
  5503. }
  5504. },
  5505. methods: {
  5506. _init() {
  5507. const e = ['play-large', 'play', 'progress', 'captions', 'fullscreen']
  5508. this.currentTime && e.push('current-time')
  5509. const i = ie(q({ controls: e }, this.setting), { invertTime: !1 })
  5510. Ot().iPhone &&
  5511. (i.fullscreen = { enabled: !0, fallback: 'force', iosNative: !0 }),
  5512. (this.player = new ce(this.$refs.video, i)),
  5513. this.player.elements.container &&
  5514. (this.player.elements.container.style.height =
  5515. this.height || '210px'),
  5516. this.preload === 'none' && (this.loading = !1),
  5517. this.player.on('loadedmetadata', () => {
  5518. ;(this.loading = !1),
  5519. console.log('loading 1111'),
  5520. this.trySee
  5521. ? this.domPlayVisibility()
  5522. : this.domPlayVisibility(!1)
  5523. const t = this
  5524. this.player.on('timeupdate', () => {
  5525. const s = t.player
  5526. s.currentTime >= this.playTime &&
  5527. t.trySee &&
  5528. (s.pause(),
  5529. (t.trySeeOver = !0),
  5530. (t.showSeeStatus = !0),
  5531. t.domPlayVisibility())
  5532. })
  5533. }),
  5534. this.player.on('play', () => {
  5535. $t({ api: 'getDeviceStatus', content: { type: 'video' } }, t => {
  5536. t.content.status == '1' &&
  5537. (It(
  5538. '\u4E3A\u4E86\u4FDD\u8BC1\u6570\u636E\u5B89\u5168\uFF0C\u8BF7\u4E0D\u8981\u5F55\u5C4F'
  5539. ),
  5540. this.player.pause())
  5541. }),
  5542. this.onPlay && this.onPlay()
  5543. }),
  5544. this.player.on('enterfullscreen', () => {
  5545. console.log('fullscreen')
  5546. const t = document.createElement('i')
  5547. ;(t.id = 'fullscreen-back'),
  5548. (t.className = 'van-icon van-icon-arrow-left video-back'),
  5549. t.addEventListener('click', () => {
  5550. this.player.fullscreen.exit()
  5551. }),
  5552. console.log(document.getElementsByClassName('plyr')),
  5553. document.getElementsByClassName('plyr')[0].appendChild(t)
  5554. }),
  5555. this.player.on('exitfullscreen', () => {
  5556. console.log('exitfullscreen')
  5557. const t = document.getElementById('fullscreen-back')
  5558. t && t.remove()
  5559. })
  5560. },
  5561. domPlayVisibility(e = !0) {
  5562. const i = document.querySelector('.plyr__controls'),
  5563. t = document.querySelector('.plyr__control--overlaid')
  5564. e
  5565. ? (i == null || i.setAttribute('style', 'display:none'),
  5566. t == null || t.setAttribute('style', 'display:none'))
  5567. : (i == null || i.removeAttribute('style'),
  5568. setTimeout(() => {
  5569. t == null || t.removeAttribute('style')
  5570. }, 200))
  5571. },
  5572. onClickPlay() {
  5573. this.player.play(),
  5574. this.domPlayVisibility(!1),
  5575. (this.showSeeStatus = !1)
  5576. },
  5577. onBuy() {
  5578. this.$router.back()
  5579. },
  5580. onReplay() {
  5581. this.player.restart(),
  5582. this.player.play(),
  5583. this.domPlayVisibility(!1),
  5584. (this.trySeeOver = !1),
  5585. (this.showSeeStatus = !1)
  5586. }
  5587. },
  5588. unmounted() {
  5589. var e
  5590. ;(e = this.player) == null || e.destroy()
  5591. },
  5592. render() {
  5593. return j('div', { class: U['video-container'] }, [
  5594. j(
  5595. 'video',
  5596. {
  5597. ref: 'video',
  5598. class: U.video,
  5599. src: this.src,
  5600. playsinline: this.playsinline,
  5601. poster: this.poster,
  5602. preload: this.preload,
  5603. style: q({}, this.styleValue)
  5604. },
  5605. null
  5606. ),
  5607. this.loading &&
  5608. j(
  5609. 'div',
  5610. {
  5611. class: U.loadingVideo,
  5612. style: { height: this.height || '210px' }
  5613. },
  5614. [
  5615. j(
  5616. Mt,
  5617. {
  5618. size: 36,
  5619. color: '#01C1B5',
  5620. vertical: !0,
  5621. style: { height: '100%', justifyContent: 'center' }
  5622. },
  5623. { default: () => [Te('\u52A0\u8F7D\u4E2D...')] }
  5624. )
  5625. ]
  5626. ),
  5627. this.trySee &&
  5628. this.computedSeeStatus &&
  5629. !this.loading &&
  5630. j(
  5631. 'div',
  5632. {
  5633. class: [U.loadingVideo, U.playOver],
  5634. style: { height: this.height || '210px' }
  5635. },
  5636. [
  5637. this.trySeeOver
  5638. ? j(qe, null, [
  5639. j('p', { class: U.tips }, [
  5640. this.freeTitleStatus
  5641. ? '\u514D\u8D39\u8BD5\u770B\u7ED3\u675F\uFF0C\u8D2D\u4E70\u5B8C\u6574\u8BFE\u7A0B\u540E\u7EE7\u7EED\u5B66\u4E60'
  5642. : '\u8BD5\u770B\u7ED3\u675F\uFF0C\u9886\u53D6\u8BFE\u7A0B\u540E\u7EE7\u7EED\u5B66\u4E60'
  5643. ]),
  5644. j(
  5645. xt,
  5646. {
  5647. class: U.btn,
  5648. type: 'primary',
  5649. round: !0,
  5650. size: 'small',
  5651. onClick: this.onBuy
  5652. },
  5653. {
  5654. default: () => [
  5655. _t.platformType === 'STUDENT'
  5656. ? this.freeTitleStatus
  5657. ? '\u7ACB\u5373\u8D2D\u4E70'
  5658. : '\u514D\u8D39\u9886\u53D6'
  5659. : '\u8FD4\u56DE'
  5660. ]
  5661. }
  5662. ),
  5663. j('div', { class: U.replay, onClick: this.onReplay }, [
  5664. j(
  5665. Ue,
  5666. {
  5667. name: 'replay',
  5668. style: { marginRight: '5px' },
  5669. size: 16
  5670. },
  5671. null
  5672. ),
  5673. Te('\u91CD\u64AD')
  5674. ])
  5675. ])
  5676. : j(qe, null, [
  5677. j(
  5678. Ue,
  5679. { name: Hi, size: 50, onClick: this.onClickPlay },
  5680. null
  5681. ),
  5682. j('p', { class: U.freeTxt }, [
  5683. Te('\u514D\u8D39'),
  5684. this.freeTitleStatus ? '\u8BD5\u770B' : '\u9886\u53D6'
  5685. ])
  5686. ])
  5687. ]
  5688. )
  5689. ])
  5690. }
  5691. })
  5692. export { Ui as C }