@castlabs/prestoplay 6.2.6-rc-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README +48 -0
- package/cjs/cl.adobe.js +8 -0
- package/cjs/cl.airplay.js +8 -0
- package/cjs/cl.broadpeak.js +11 -0
- package/cjs/cl.cast.js +111 -0
- package/cjs/cl.conviva.js +37 -0
- package/cjs/cl.core.js +420 -0
- package/cjs/cl.crypto.js +15 -0
- package/cjs/cl.dash.js +73 -0
- package/cjs/cl.externs.js +3870 -0
- package/cjs/cl.freewheel.js +29 -0
- package/cjs/cl.hls.js +48 -0
- package/cjs/cl.hlssmpte.js +11 -0
- package/cjs/cl.htmlcue.js +35 -0
- package/cjs/cl.ima.js +28 -0
- package/cjs/cl.mse.js +263 -0
- package/cjs/cl.muxdata.js +16 -0
- package/cjs/cl.onboard.js +8 -0
- package/cjs/cl.persistent.js +19 -0
- package/cjs/cl.playlist.js +10 -0
- package/cjs/cl.smooth.js +75 -0
- package/cjs/cl.thumbnails.js +28 -0
- package/cjs/cl.tizen.js +76 -0
- package/cjs/cl.ttml.js +31 -0
- package/cjs/cl.verimatrix.js +10 -0
- package/cjs/cl.vimond.js +18 -0
- package/cjs/cl.vtt.js +19 -0
- package/cjs/cl.youbora.js +23 -0
- package/cjs/polyfill.min.js +47 -0
- package/cl.adobe.js +3 -0
- package/cl.airplay.js +3 -0
- package/cl.broadpeak.js +5 -0
- package/cl.cast.js +83 -0
- package/cl.conviva.js +27 -0
- package/cl.core.js +364 -0
- package/cl.crypto.js +9 -0
- package/cl.dash.js +62 -0
- package/cl.externs.js +3798 -0
- package/cl.freewheel.js +19 -0
- package/cl.hls.js +36 -0
- package/cl.hlssmpte.js +5 -0
- package/cl.htmlcue.js +24 -0
- package/cl.ima.js +16 -0
- package/cl.mse.js +224 -0
- package/cl.muxdata.js +9 -0
- package/cl.onboard.js +4 -0
- package/cl.persistent.js +11 -0
- package/cl.playlist.js +4 -0
- package/cl.smooth.js +58 -0
- package/cl.thumbnails.js +17 -0
- package/cl.tizen.js +57 -0
- package/cl.ttml.js +21 -0
- package/cl.verimatrix.js +4 -0
- package/cl.vimond.js +8 -0
- package/cl.vtt.js +12 -0
- package/cl.youbora.js +15 -0
- package/clpp.styles.css +147 -0
- package/package.json +43 -0
package/cl.mse.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Yr,Zr,$r,as,bs,es,fs,hs,is,js,ks,ls,ns,os,ps,ss,vs,ws,xs,zs,As,Bs,Ds,Fs,Gs,Hs,Ks,Ns,Os,Ps,Qs,Rs,at,gt,nt,pt,qt,rt,wt,xt,Bt,Ct,Dt,Ft,Et,Gt,Ht,Jt,Lt,Mt,Nt,Ot,Pt,Qt,St,Tt,Ut,Vt,Xt,Wt,Rt,cu,Yt,Zt,$t,au,bu,du,eu,hu,fu,gu,iu,ju,ku,mu,nu,ou,pu,qu,ru,su,tu,vu,uu,wu,Fu,Cu,Eu,Gu,Hu,Iu,Ku,Lu,Ou,Mu,Nu,Pu,Qu,Ru,Su,Tu,Uu,Vu,Wu,Zu,$u,av,bv,Xu,Yu,ev,hv,gv,iv,fv,jv,lv,kv,nv,ov,pv,qv,rv,xv,zv,Av,uv,vv,wv,Cv,Jv,Dv,Ev,Fv,Hv,Gv,Mv,sv,Nv,Qv,Rv,Sv,Bv,Ov,Pv,Kv,Lv,Tv,Uv,Vv,Wv,Xv,Yv,bw,Zv,$v,aw,cw,dw,ew,xu,
|
|
2
|
+
yu,zu,Au,Bu,Du,qw,sw,tw,yw,ww,vw,xw,Ew,Iw,Ow,cx,Aw,Gw,Hw,Mw,Nw,Qw,Rw,Tw,ow,Vw,Ww,Zw,$w,ax,bx,Lw,gw,nw,gx,Kw,lw,mw,xx,hw,iw,jw,kw,ex,wx,dx,yx,ix,jx,hx,zx,Ax,Bx,Cx,Dx,Ex,Fx,ct,Zs,Ws,Gx,Ys,bt,Fw,nx,mx,Kt,Bw;Yr=" buffer";Zr=" is being or has been set up";$r="\x3c/DATA\x3e\x3c/WRMHEADER\x3e";as="Jumping forward";bs="MediaSource threw QuotaExceededError:";_.cs="No stream with id";_.ds="Player is in ERROR state and can not switch to ";es="PrestoPlay TextTrack";fs="Removing audio from variant - audio not compatible with platform";
|
|
3
|
+
_.gs="Updating manifest...";hs="bufferBehind\x3d";is="bufferedBehind\x3d";js="calling onCanSwitch()...";ks="clpp.mse.Player";ls="currentPeriod.startTime\x3d";_.ms="onChooseStreams_";ns="presentationTime\x3d";os="reference.endTime\x3d";ps="reference.startTime\x3d";_.qs="subtitle";_.rs="subtitles";ss="switch: Stream ";_.ts=function(a){try{const b=a.f.getUint8(a.a);a.a+=1;return b}catch(b){_.Ai()}};_.us=function(a){if(1>a.a)throw _.Ai();--a.a};
|
|
4
|
+
vs=function(a){for(var b=a.a;_.zi(a)&&0!==a.f.getUint8(a.a);)a.a+=1;b=a.f.buffer.slice(b,a.a);a.a+=1;return _.gg(b)};ws=function(a,b){return _.uh("Edge/")?!0:a.J.has(b)};xs=function(a,b){const c=b.audio,d=b.video;if(c&&c.encrypted&&!ws(a,_.Ig(c.mimeType,c.codecs))||d&&d.encrypted&&!ws(a,_.Ig(d.mimeType,d.codecs)))return!1;const e=a.keySystem();return 0==b.drmInfos.length||b.drmInfos.some(f=>f.keySystem==e)};
|
|
5
|
+
_.ys=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{kd:b,item:d,kf:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{kd:b,kf:c,item:d,next:void 0})};zs=function(a,b){for(const c in b)if(b[c]===a)return c;return""};As=function(a,b){a=_.Gg(a);b=_.Gg(b);a=a.split("-");b=b.split("-");return a[0]==b[0]&&1==a.length&&2==b.length};Bs=function(a){return a.language?_.Gg(a.language):a.audio&&a.audio.language?_.Gg(a.audio.language):a.video&&a.video.language?_.Gg(a.video.language):_.pe};
|
|
6
|
+
_.Cs=function(a,b){a=_.Gg(a);const c=new Set;for(var d of b)c.add(_.Gg(d));for(const e of c)if(e==a)return e;for(const e of c)if(As(e,a))return e;for(const e of c)if(d=e,b=a,d=_.Gg(d),b=_.Gg(b),d=d.split("-"),b=b.split("-"),b=2==d.length&&2==b.length&&d[0]==b[0])return e;for(const e of c)if(As(a,e))return e;return null};Ds=function(a){const b=[a.mimeType];_.wn.forEach((c,d)=>{(d=a[d])&&b.push(c+'\x3d"'+d+'"')});return b.join(";")};_.Es=function(a){a=a.split(".");const b=a[0];a.pop();return[b,a.join(".")]};
|
|
7
|
+
Fs=function(a,b){if(a===b)return!0;if(!a||!b||a.length!==b.length)return!1;for(let c=0;c<a.length;++c)if(a[c]!==b[c])return!1;return!0};Gs=function(a,b="total"){b=new _.yn(void 0,b);for(const c of a)b.a.push(c);b.length=a.length;return b};Hs=function(a,b){let c=0;for(const d of a)c+=b(d)?1:0;return c};
|
|
8
|
+
_.Is=function(a,b){if(!a.length)return b;if(!b.length)return a;const c=[];for(let e=0;e<a.length;e++)for(var d=0;d<b.length;d++)if(a[e].keySystem===b[d].keySystem&&a[e].periodId===b[d].periodId){const f=a[e];d=b[d];let g=[];g=g.concat(f.initData||[]);g=g.concat(d.initData||[]);let h=[];h=h.concat(f.keyIds);h=h.concat(d.keyIds);c.push({keySystem:f.keySystem,licenseServerUri:f.licenseServerUri||d.licenseServerUri,distinctiveIdentifierRequired:f.distinctiveIdentifierRequired||d.distinctiveIdentifierRequired,
|
|
9
|
+
persistentStateRequired:f.persistentStateRequired||d.persistentStateRequired,videoRobustness:f.videoRobustness||d.videoRobustness,audioRobustness:f.audioRobustness||d.audioRobustness,serverCertificate:f.serverCertificate||d.serverCertificate,initData:g,keyIds:h,periodId:f.periodId});break}return c};_.Js=function(a,b){return a.concat(b)};Ks=function(){};
|
|
10
|
+
_.Ls=function(a,b){if(0==b.length)return a;const c=b.map(d=>new _.dh(d));return a.map(d=>new _.dh(d)).map(d=>c.map(d.resolve.bind(d))).reduce(_.Js,[]).map(d=>d.toString())};_.Ms=function(a,b,c){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:b||[],keyIds:[],periodId:c?c:null}};Ns=function(a,b){return a.start-b.start};
|
|
11
|
+
Os=function(a){return a.f.map(b=>({start:b.start,end:b.end,width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b.rendition}))};Ps=function(a){a.a&&a.a.trigger(new _.F(_.Wb))};Qs=function(a){if(a.a){var b=!1,c={};for(let d=0;d<a.f.length;d++){const e=a.f[d],f=e.width+"x"+e.height,g=c[f];if(g&&g!==e.bandwidth){b=!0;break}c[f]=e.bandwidth}b&&!a.h?(a.log.debug("Tracking timeupdates"),a.a.on(_.me,a.g,a),a.h=!0):!b&&a.h&&(a.log.debug("Stop tracking timeupdates"),a.a.off(_.me,a.g),a.h=!1)}};
|
|
12
|
+
Rs=function(a,b,c){a.f=a.f.filter(d=>{if(d.end<=b||d.start>=c)return!1;d.start=Math.max(d.start,b);d.end=Math.min(d.end,c);return!0});a.a&&a.a.trigger(new _.F(_.Ce))};_.Ss=function(a,b){return Array.prototype.filter.call(a.childNodes,c=>c instanceof Element&&c.tagName==b)};_.Ts=function(a,b){a=_.Ss(a,b);return 1!=a.length?null:a[0]};_.Us=function(a){return Array.prototype.every.call(a.childNodes,b=>b.nodeType==Node.TEXT_NODE||b.nodeType==Node.CDATA_SECTION_NODE)?a.textContent.trim():null};
|
|
13
|
+
_.Vs=function(a,b){const c=new DOMParser;let d=null,e=null;try{e=c.parseFromString(a,_.le)}catch(f){}e&&e.documentElement.tagName==b&&(d=e.documentElement);return d&&0<d.getElementsByTagName("parsererror").length?null:d};_.Xs=function(a){const b=new Uint8Array(Ws),c=4+b.byteLength+a.h.byteLength+4+a.f.byteLength,d=new _.Li(c,!1);_.M(d,c);_.yi(d,b);_.yi(d,a.h);_.M(d,a.f.byteLength);_.yi(d,a.f);return _.L(d.buffer)};
|
|
14
|
+
_.$s=function(a){var b=_.ji(a);b=parseInt(b.byteLength,10).toString(16);b=_.ji("12"+b+a);return new Ys(Zs,a,b)};at=function(a){const b=[];b.push(a[3]);b.push(a[2]);b.push(a[1]);b.push(a[0]);b.push(a[5]);b.push(a[4]);b.push(a[7]);b.push(a[6]);a=_.L(a);a.set(b,0);return a};
|
|
15
|
+
_.dt=function(a,b,c,d){var e=_.ji(b);var f=at(e);a:switch(e=_.gi(f),f=f.byteLength,_.C("Trying to create PlayReady header in version",a),a){case "4.0.0.0":e=[`<WRMHEADER xmlns="${"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader"}" version="${a}">`,"\x3cDATA\x3e\x3cPROTECTINFO\x3e",`<KEYLEN>${f}</KEYLEN>`,"\x3cALGID\x3eAESCTR\x3c/ALGID\x3e\x3c/PROTECTINFO\x3e",`<KID>${e}</KID>`,c?`<CHECKSUM>${c}</CHECKSUM>`:"",d?`<LA_URL>${d}</LA_URL>`:"",$r].join("");break a;case "4.1.0.0":e=[`<WRMHEADER xmlns="${"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader"}" version="${a}">`,
|
|
16
|
+
'\x3cDATA\x3e\x3cPROTECTINFO\x3e\x3cKID ALGID\x3d"AESCTR" ',c?`CHECKSUM="${c}" `:"",`VALUE="${e}"`,"\x3e\x3c/KID\x3e\x3c/PROTECTINFO\x3e",d?`<LA_URL>${d}</LA_URL>`:"",$r].join("");break a;case "4.2.0.0":case "4.3.0.0":e=[`<WRMHEADER xmlns="${"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader"}" version="${a}">`,'\x3cDATA\x3e\x3cPROTECTINFO\x3e\x3cKIDS\x3e\x3cKID ALGID\x3d"AESCTR" ',c?`CHECKSUM="${c}" `:"",`VALUE="${e}"`,"\x3e\x3c/KID\x3e\x3c/KIDS\x3e\x3c/PROTECTINFO\x3e",d?`<LA_URL>${d}</LA_URL>`:
|
|
17
|
+
"",$r].join("");break a;default:_.z("Cannot create PlayReady header in version",a),e=""}_.C("New payload",e);e=_.L(_.lg(e,!0));return new bt(ct,b,d||null,e,a,c)};_.et=function(a,b){return b===a.version?a:_.dt(b,a.a,a.j||void 0,a.g||void 0)};
|
|
18
|
+
_.ft=function(a){a:{a=new _.On(new DataView(a.buffer),!0);_.N(a);for(_.Bi(a);_.zi(a);)if(1===_.Bi(a)){var b=_.Bi(a);a=_.Ei(a,b);break a}a=null}b=_.ig(a,!0);var c=_.Vs(b,"WRMHEADER");b=c.getAttribute("version");var d=_.Ts(c,"DATA");c=(c=_.Ts(d,"LA_URL"))?_.Us(c):"";let e="",f;var g=_.Ts(d,"KID");if(g)e=_.Us(g)||"",f=g.getAttribute("CHECKSUM");else if((g=_.Ts(d,"PROTECTINFO"))&&(g=_.Ts(g,"KIDS"))&&(e=_.Ts(g,"KID").getAttribute("VALUE")||""),d=_.Ts(d,"CHECKSUM"))f=d.textContent;d=_.ii(e);d=at(d);d=_.ki(d);
|
|
19
|
+
return new bt(ct,d,c,a,b,f)};gt=function(a,b){let c=null;for(const d of a)b>=d.startTime&&(c=d);return c};_.ht=function(a,b,c){const d=Math.pow(a.g,b);c=c*(1-d)+d*a.a;isNaN(c)||(a.a=c,a.f+=b)};_.it=function(a){return a.a/(1-Math.pow(a.g,a.f))};
|
|
20
|
+
_.jt=function(a,b,c,d,e,f,g,h){a=_.wg(a);a.timeout=d.timeout;a.maxAttempts=d.maxAttempts;a.baseDelay=d.baseDelay;a.fuzzFactor=d.fuzzFactor;a.backoffFactor=d.backoffFactor;if(0!=b||null!=c)a.headers.Range=c?"bytes\x3d"+b+"-"+c:"bytes\x3d"+b+"-";e&&(a.startTime=e);f&&(a.endTime=f);g&&(a.contentType=g);h&&(a.timescale=h);return a};_.kt=function(a,b){a.j=null==a.j?b:Math.min(a.j,b)};
|
|
21
|
+
_.lt=function(a,b,c){if(0!=b.length){var d=b[b.length-1].endTime+c;_.kt(a,b[0].startTime+c);a.a=b.reduce((e,f)=>Math.max(e,f.endTime-f.startTime),a.a);a.g=Math.max(a.g,d);null!=a.m&&a.D&&(a.m=(Date.now()+a.w)/1E3-a.g-a.a);a.A.debug("notifySegments: maxSegmentDuration\x3d"+a.a)}};_.mt=function(a,b){a.a=Math.max(a.a,b);a.A.debug("notifyNewSegmentDuration: maxSegmentDuration\x3d"+a.a)};
|
|
22
|
+
nt=function(a){if(a.Sb())a=a.g;else if(a.isLive()||Infinity!=a.h&&!a.f){var b=(Date.now()+a.w)/1E3;b=a.C?Math.max(0,b-(a.a-a.o)-a.m):Math.max(0,b-a.a-a.m);a=Math.min(b,a.h)}else a=a.h;return a};_.ot=function(a){if(Infinity==a.Vb)return 0;a=nt(a)-a.Vb;return Math.max(0,a)};pt=function(a){const b=a.Sb()||!a.isLive()&&(Infinity==a.h||a.f)?0:a.Cd;return Math.max(0,nt(a)-b)};
|
|
23
|
+
qt=function(a,b){const c=Math.max(a.j,0);if(Infinity==a.Vb)return Math.ceil(1E3*c)/1E3;const d=nt(a)-a.Vb;a=Math.min(d+b,pt(a));return Math.max(c,a)};rt=function(a,b){a.f=b};
|
|
24
|
+
_.tt=function(a,b){let c=[];const d=[];for(var e=0,f=0;e<a.a.length&&f<b.length;){var g=a.a[e];const h=b[f];g.startTime<h.startTime?(c.push(g),e++):(g.startTime>h.startTime?0===e?d.push(h):a.g.warn("Refusing to rewrite original references on update!"):(.1<Math.abs(g.endTime-h.endTime)?c.push(new _.st(g.position,h.startTime,h.endTime,h.Ka,h.Fa,h.wa,h.qb,h.keyInfo,h.Kb,h.timescale,h.horizontalTiles,h.verticalTiles,h.durationPerTile)):c.push(g),e++),f++)}for(;e<a.a.length;)c.push(a.a[e++]);if(c.length)for(e=
|
|
25
|
+
c[c.length-1].position+1;f<b.length;)g=b[f++],g=new _.st(e++,g.startTime,g.endTime,g.Ka,g.Fa,g.wa,g.qb,g.keyInfo,g.Kb,g.timescale,g.horizontalTiles,g.verticalTiles,g.durationPerTile),c.push(g);else c=b;b=c;if(d.length&&c.length){b=[];f=c[0].position;e=d.length;for(const h of d)b.push(new _.st(f-e--,h.startTime,h.endTime,h.Ka,h.Fa,h.wa,h.qb,h.keyInfo,h.Kb,h.timescale,h.horizontalTiles,h.verticalTiles,h.durationPerTile));for(const h of c)b.push(h)}a.a=b};
|
|
26
|
+
_.ut=function(a,b){for(let c=0;c<a.a.length;++c)if(a.a[c].endTime>b){a.a.splice(0,c);return}a.a=[]};_.vt=function(a,b){for(;a.a.length;)if(0>=a.a[0].endTime)a.a.shift();else break;if(0!=a.a.length){var c=a.a[a.a.length-1];c.startTime>=b||(a.a[a.a.length-1]=new _.st(c.position,c.startTime,b,c.Ka,c.Fa,c.wa,c.qb,c.keyInfo,c.Kb,c.timescale,c.horizontalTiles,c.verticalTiles,c.durationPerTile))}};wt=function(a,b){for(const c of a.a)c.m(a.f.currentTime,b)};xt=function(a,b,c,d){a.a=b;a.f=c;a.g=d};
|
|
27
|
+
_.yt=function(a){_.tm[a]&&delete _.tm[a]};_.zt=function(a){_.rm[a]&&delete _.rm[a]};_.At=function(a){a=a.toLowerCase();return _.Rm[a]||window.muxjs&&a==_.Hb?!0:!1};Bt=function(a,b,c,d){return Promise.resolve().then(()=>{if(a.o&&a.g)if(null==c||null==d)a.o.parseInit(_.L(b));else{var e={periodStart:a.w,segmentStart:c,segmentEnd:d};e=a.o.parseMedia(_.L(b),e);var f=e.cues.filter(g=>g.startTime>=a.h&&g.startTime<a.j);a.g.append(f,e.styles);null==a.a&&(a.a=Math.max(c,a.h));a.f=Math.min(d,a.j)}})};
|
|
28
|
+
Ct=function(a,b,c){a.A=b;if(b=a.m.get(b))for(const d of b.keys()){let e=b.get(d);e&&(e=e.filter(f=>f.endTime<=c),a.g.append(e,[]))}};
|
|
29
|
+
Dt=function(a,b,c,d,e){const f=c+" "+d,g=new Map;for(const h of b){b=h.stream;g.has(b)||g.set(b,new Map);g.get(b).has(f)||g.get(b).set(f,[]);h.startTime+=e;h.endTime+=e;if(!(h.startTime>=a.h&&h.startTime<a.j))continue;const k=new _.ln(h.startTime,h.endTime,h.text);g.get(b).get(f).push(k);b==a.A&&a.g.append([k],[])}for(const h of g.keys()){a.m.has(h)||a.m.set(h,new Map);for(const k of g.get(h).keys())e=g.get(h).get(k),a.m.get(h).set(k,e)}a.a=null==a.a?Math.max(c,a.h):Math.min(a.a,Math.max(c,a.h));
|
|
30
|
+
a.f=Math.max(a.f,Math.min(d,a.j))};Ft=function(a,b){return!window.muxjs||"mp2t"!=a.toLowerCase().split(";")[0].split("/")[1]&&"aac"!=a.toLowerCase().split(";")[0].split("/")[1]?!1:b?MediaSource.isTypeSupported(Et(b,a))||MediaSource.isTypeSupported(a.replace(/aac/i,_.md)):MediaSource.isTypeSupported(Et(_.Rb,a))||MediaSource.isTypeSupported(a.replace(/aac/i,_.md))||MediaSource.isTypeSupported(Et(_.u,a))};
|
|
31
|
+
Et=function(a,b){b=b.replace(/mp2t/i,_.md);a==_.Rb&&(b=b.replace(_.u,_.Rb));if(a=/avc1\.(66|77|100)\.(\d+)/.exec(b)){let d="avc1.";var c=a[1];d="66"==c?d+"4200":"77"==c?d+"4d00":d+"6400";c=Number(a[2]);d+=(c>>4).toString(16);d+=(c&15).toString(16);b=b.replace(a[0],d)}return b};Gt=function(a,b){a.h=!0;a.f=new _.Hj;a.m=[];a.j=[];a.g=[];b=_.L(b);a.a.push(b);a.a.flush();a.h&&a.f.reject(new _.H(_.G,3,3018));return a.f};
|
|
32
|
+
Ht=function(a){const b=_.Ig(a.mimeType,a.codecs),c=Ds(a);return _.At(b)||MediaSource.isTypeSupported(c)||Ft(b,a.type)};Jt=function(a,b){const c=new MediaSource,d=It(c);a.o.one(c,"sourceopen",()=>{URL.revokeObjectURL(d);b.resolve()});a.j.src=d;return c};Lt=function(a,b){a.g||(a.g=new Kt(a.L,a.B));a=a.g;if(b!=_.Hb){b=_.Rm[b];if(!b)throw new _.H(_.G,2,2012,"Text parser is unavailable");a.o=new b(a.B)}};
|
|
33
|
+
Mt=function(a,b){b.forEach((c,d)=>{c=a.m.addSourceBuffer(c);a.o.on(c,_.Oc,a.T.bind(a,d));a.o.on(c,"updateend",a.w.bind(a,d));a.f[d]=c;a.h[d]=[];a.D[d]=!1});a.K=b.has(_.Rb)&&b.has(_.u)};Nt=function(a){return a.m?a.m.readyState==_.Nc:!0};Ot=function(a,b){try{return new _.yn(a.f[b].buffered,b)}catch(c){return b in a.f&&a.a.error("failed to get buffered range for "+b,c),null}};
|
|
34
|
+
Pt=function(a){const b={};b.total=new _.yn(a.j.buffered,"total");b.audio=Ot(a,_.Rb);b.video=Ot(a,_.u);let c=[];a.g&&(c=[{start:a.g.fb(),end:a.g.pa()}]);b.text=Gs(c,_.r);return b};Qt=function(a,b){if(!a.f[b])return"";a=Ot(a,b);if(null===a)return"";b="";for(let c=0;c<a.length;c++)0<c&&(b+=" "),b+=`${a.start(c).toFixed(3)}-${a.end(c).toFixed(3)}`;return b};St=function(a,b,c){if(a.I)return Promise.reject();c={start:c,p:new _.Hj};a.h[b].push(c);1===a.h[b].length&&Rt(a,b);return c.p};
|
|
35
|
+
Tt=function(a,b,c,d,e,f,g,h){h=void 0===h?!1:h;const k=a.f[b];let l=-1,m=0;k&&k.buffered&&(m=k.buffered.length);b===_.u&&null!==d&&null!==e&&h&&(l=0<m?k.buffered.end(m-1):-1);b==_.r?c=Bt(a.g,c,d,e):a.A[b]?c=Gt(a.A[b],c).then(n=>{a.g||Lt(a,_.ke);n.captions&&n.captions.length&&Dt(a.g,n.captions,d,e,a.f.video.timestampOffset);const q=[];0<n.audio.byteLength&&a.f.audio&&q.push(St(a,_.Rb,a.J.bind(a,_.Rb,n.audio.buffer)));0<n.video.byteLength&&a.f.video&&q.push(St(a,_.u,a.J.bind(a,_.u,n.video.buffer)));
|
|
36
|
+
return Promise.all(q)}):(f&&window.muxjs&&(a.g||Lt(a,_.ke),null==d&&null==e?a.F.init(c):a.F.g(c,n=>{n.length&&Dt(a.g,n,d,e,a.f.video.timestampOffset)})),c=St(a,b,a.J.bind(a,b,c)));return c.then(()=>{if(b===_.u&&null!==d&&null!==e&&!h)a.C.append(d,e,g),null!==d&&null!==e&&a.a.debug("Appended video segment ",d,e,"Buffer:",Qt(a,b));else if(b===_.Rb&&null!==d&&null!==e)Ps(a.C),null!==d&&null!==e&&a.a.debug("Appended audio segment ",d,e,"Buffer:",Qt(a,b));else if(b===_.u&&null!==d&&null!==e&&h){var n=
|
|
37
|
+
k.buffered.length,q=0<n?k.buffered.end(n-1):-1;0>l&&0<n&&(l=k.buffered.start(0));0<=l&&0<q&&a.C.append(l,q,g)}if(!a.D[b]&&k&&1===k.buffered.length){n=k.buffered.start(0);const t=d-n;if(Math.abs(t)>a.V&&0===k.timestampOffset)return a.a.warn(`Detected a delta of ${t} between `+`media times and segment times for ${b}. `+`The segment start time is ${d} and the media start time `+`is ${n}. Adjusting timestampOffset.`),n=St(a,b,()=>{a.S(b,t)}),q=St(a,b,a.P.bind(a,b,!1)),Promise.all([n,q])}null!==d&&null!==
|
|
38
|
+
e&&(a.D[b]=!0)}).catch(n=>{throw n;})};Ut=function(a,b,c,d,e){return[St(a,b,a.U.bind(a,b)),St(a,b,a.S.bind(a,b,c)),St(a,b,a.Z.bind(a,b,d,e))]};Vt=function(a,b,c,d,e){if(b==_.r)return a.g.w=c,a=a.g,a.h=d,a.j=e,Promise.resolve();b=Ut(a,b,c,d,e);a.K&&(b=b.concat(Ut(a,_.Rb,c,d,e)));return Promise.all(b)};
|
|
39
|
+
Xt=function(a,b){if(a.I)return Promise.reject();const c=[];for(const d in a.f){const e=new _.Hj,f={start:function(g){g.resolve()}.bind(null,e),p:e};a.h[d].push(f);c.push(e);1==a.h[d].length&&f.start()}return Promise.all(c).then(()=>{for(const e in a.f);let d;try{b()}catch(e){d=Promise.reject(new _.H(_.G,3,3015,{mediaError:e}))}for(const e in a.f)Wt(a,e);return d},()=>{for(const d in a.f)a.h[d].length&&a.h[d].shift();return Promise.reject()})};Wt=function(a,b){a.h[b].shift();Rt(a,b)};
|
|
40
|
+
Rt=function(a,b){const c=a.h[b][0];if(c)try{a.a.debug("Starting next operation for "+b),c.start()}catch(d){"QuotaExceededError"==d.name?c.p.reject(new _.H(_.G,3,3017,{type:b})):c.p.reject(new _.H(_.G,3,3015,{mediaError:d})),Wt(a,b)}else a.a.debug("No more scheduled operations for "+b)};
|
|
41
|
+
cu=function(a,b,c,d){var e=a.periods.flatMap(h=>h.variants);if(b.length||c.length)e=Yt(e,b,c);e=Zt(e,d);if(1<a.periods.length){const h=l=>{l=l.split(".");let m=l[0];1<l.length&&(m+="."+l[1]);return m.toLowerCase()};b=[];for(var f of a.periods){c=new Set;for(const l of f.variants)null!==l.audio&&c.add(h(l.audio.codecs));b.push(c)}let k=b[0];for(f=1;f<b.length;f++){const l=b[f];k=new Set([...k].filter(m=>l.has(m)))}e=e.filter(l=>0===k.size&&null===l.audio?!0:0<k.size&&null===l.audio?!1:k.has(h(l.audio.codecs)))}e=
|
|
42
|
+
$t(e);const g=au(e);for(const h of a.periods)h.variants=h.variants.filter(k=>{if(bu(k)===g)return!0;_.C("Dropping Variant (better codec available)",k);return!1})};Yt=function(a,b,c){for(const d of b)if(b=a.filter(e=>e.video&&e.video.codecs.startsWith(d)),b.length){a=b;break}for(const d of c)if(c=a.filter(e=>e.audio&&e.audio.codecs.startsWith(d)),c.length){a=c;break}return a};
|
|
43
|
+
Zt=function(a,b){var c=a.filter(f=>f.audio&&f.audio.channelsCount);const d=new Map;for(var e of c)c=e.audio.channelsCount,d.has(c)||d.set(c,[]),d.get(c).push(e);e=Array.from(d.keys());if(0===e.length)return a;a=e.filter(f=>f<=b);return a.length?d.get(Math.max.apply(null,a)):d.get(Math.min.apply(null,e))};$t=function(a){const b=new _.Zm;for(const c of a)a=bu(c),b.push(a,c);return b};
|
|
44
|
+
au=function(a){let b="",c=Infinity;a.forEach((d,e)=>{e=e.reduce((f,g)=>f+g.bandwidth||0,0)/e.length;_.C(_.tc,d,"avg bandwidth",e);e<c&&(b=d,c=e)});return b};bu=function(a){let b="";a.video&&(b=_.Es(a.video.codecs)[0]);let c="";a.audio&&(c=_.Es(a.audio.codecs)[0]);return b+"-"+c};
|
|
45
|
+
du=function(a,b,c){var d=a.video,e;if(e=d&&d.width&&d.height){e=d.width;if(e=e>=b.minWidth&&e<=Math.min(b.maxWidth,c.width))e=d.height,e=e>=b.minHeight&&e<=Math.min(b.maxHeight,c.height);if(c=e)d=d.width*d.height,c=d>=b.minPixels&&d<=b.maxPixels;e=!c}(d=e)||(a=a.bandwidth,d=!(a>=b.minBandwidth&&a<=b.maxBandwidth));return d?!1:!0};eu=function(a,b,c){let d=!1;for(const e of a)a=e.allowedByApplication,e.allowedByApplication=du(e,b,c),a!=e.allowedByApplication&&(d=!0);return d};
|
|
46
|
+
hu=function(a,b,c,d){let e=!1;d.variants=d.variants.filter(f=>{if(a&&a.R&&!xs(a,f))return _.C("Dropping variant - not compatible with key system",f),!1;let g=f.audio;const h=f.video;if(g&&!Ht(g)){const k=g.codecs;0<=g.codecs.indexOf("ec-3")?(_.C("Trying to use AC-3 for EC-3"),g.codecs=g.codecs.replace("ec-3","ac-3"),Ht(g)?_.xf("Using AC-3 instead of EC-3 for",fu(g)):(g.codecs=k,_.xf(fs,fu(g)),f.audio=null,e=!0,g=null)):(_.xf(fs,fu(g)),f.audio=null,e=!0,g=null)}return h&&!Ht(h)?(_.xf("Dropping variant - video not compatible with platform",
|
|
47
|
+
fu(h)),!1):g&&b&&!gu(g,b)?(_.xf("Dropping variant - not compatible with active audio","active audio",fu(b),"variant.audio",fu(g)),!1):h&&c&&!gu(h,c)?(_.xf("Dropping variant - not compatible with active video","active video",fu(c),"variant.video",fu(h)),!1):!0});if(e){let f=!1,g=!1;for(const h of d.variants)!f&&h.video&&h.audio&&(f=!0),g||h.audio||!h.video||(g=!0);f&&g&&(d.variants=d.variants.filter(h=>h.video&&!h.audio?(_.xf("Dropping variant - not compatible with video + audio","variant.video",fu(h.video)),
|
|
48
|
+
!1):!0))}d.textStreams=d.textStreams.filter(f=>{const g=_.At(_.Ig(f.mimeType,f.codecs));g||_.C("Dropping text stream. Is not supported by the platform.",f);return g})};
|
|
49
|
+
fu=function(a){const b=Ds(a);return a.type===_.Rb?"type\x3daudio mimeType\x3d"+a.mimeType+" codecs\x3d"+a.codecs+" codecInfo\x3d"+b+" bandwidth\x3d"+a.bandwidth+" channelsCount\x3d"+a.channelsCount:a.type===_.u?"type\x3dvideo mimeType\x3d"+a.mimeType+" codecs\x3d"+a.codecs+" codecInfo\x3d"+b+" bandwidth\x3d"+a.bandwidth+" frameRate\x3d"+a.frameRate+" width\x3d"+a.width+" height\x3d"+a.height:"unexpected stream type"};
|
|
50
|
+
gu=function(a,b){return a.mimeType!=b.mimeType||a.codecs.split(".")[0]!=b.codecs.split(".")[0]?!1:!0};
|
|
51
|
+
iu=function(a){return{id:a.id,active:!1,type:_.r,bandwidth:0,language:a.language,label:a.label,kind:a.kind||null,width:null,height:null,frameRate:null,mimeType:a.mimeType,audioMimeType:null,codecs:a.codecs||null,audioCodec:null,videoCodec:null,primary:a.primary,roles:a.roles,audioRoles:null,videoId:null,audioId:null,channelsCount:null,audioBandwidth:null,videoBandwidth:null,originalVideoId:null,originalAudioId:null,originalTextId:a.originalId}};ju=function(a){return a.allowedByApplication&&a.allowedByKeySystem};
|
|
52
|
+
_.lu=function(a,b,c){b=_.Jg(b);let d=a;const e=a.filter(g=>g.primary);e.length&&(d=e);const f=d.length?d[0].language:"";d=d.filter(g=>g.language===f);b.some(g=>{const h=_.Cs(_.Gg(g),a.map(k=>k.language));return h?(d=a.filter(k=>_.Gg(k.language)===h),!0):!1});if(c){b=ku(d,c);if(b.length)return b;_.z("No exact match for the text role could be found.")}else if(b=d.filter(g=>0===g.roles.length),b.length)return b;b=d.map(g=>g.roles).reduce(_.Js,[]);return b.length?ku(d,b[0]):d};
|
|
53
|
+
ku=function(a,b){return a.filter(c=>c.roles.includes(b))};mu=function(a,b,c){for(let d=0;d<c.length;d++)if(c[d].audio===a&&c[d].video===b)return c[d];return null};
|
|
54
|
+
nu=function(a,b){var c=String(_.Tf++);c=new _.Uf(c,a);c.mimeType=_.Qf(b.mimeType);if(a===_.I||a===_.J)c.label=_.Qf(b.label),c.language=_.Qf(b.language);a===_.K?(c.frameRate=b.frameRate,c.roles=b.roles):a===_.J?(c.channelsCount=b.channelsCount,c.roles=b.audioRoles||[],c.mimeType=_.Qf(b.audioMimeType)):(c.kind=_.Qf(b.kind),c.roles=b.roles);return c};
|
|
55
|
+
ou=function(a,b,c){const d=new _.sn(a===_.K?`${b.videoId}`:a===_.J?`${b.audioId}`:`${b.id}`,c);switch(a){case _.K:d.codec=_.Qf(b.videoCodec);d.bandwidth=b.videoBandwidth||b.bandwidth;d.width=b.width;d.height=b.height;d.originalId=b.originalVideoId;break;case _.J:d.codec=_.Qf(b.audioCodec);d.bandwidth=b.audioBandwidth||b.bandwidth;d.originalId=b.originalAudioId;break;default:d.codec=_.Qf(b.codecs),d.originalId=b.originalTextId}(a=c.renditions.find(e=>_.hf(e,d,null,["id","track"])))||c.renditions.push(d);
|
|
56
|
+
return a||d};pu=function(a,b){a=a.reduce((c,d)=>{b===_.K?null===d.videoId||c[d.videoId]&&!d.active||(c[d.videoId]=d):b===_.J&&(null===d.audioId||c[d.audioId]&&!d.active||(c[d.audioId]=d));return c},{});return Object.values(a)};qu=function(a,b){if(void 0!==b&&null!==b){const c=a.filter(d=>d.audio&&d.audio.id===b);if(0<c.length)return c}return a};ru=function(a,b,c){function d(e,f){return null==e?null==f:f.id==e}for(let e=0;e<c.length;e++)if(d(a,c[e].audio)&&d(b,c[e].video))return c[e];return null};
|
|
57
|
+
su=function(a,b){return a.h.filter(c=>c.type===b)};tu=function(a,b){return(a=a.a.get(b)||null)&&a.track};vu=function(a,b,c){c&&tu(a,c.type)===c&&!a.l.ja()||uu(a,b,c&&c.renditions[0])};uu=function(a,b,c,d){d=void 0===d?!1:d;if(a.l&&((a.a.get(b)||null)!==c||a.l.ja())){var e=a.l;if(c){if(0>a.h.indexOf(c.track))throw Error(`Unknown rendition with ID ${c.id}`);if(b!==c.track.type)throw Error("Types mismatch");a.g.debug(`Activate rendition type
|
|
58
|
+
${b} with ID: ${c.id}`);if(b===_.I){const f=e.ea().find(g=>g.id==c.id);f&&(a.f.set(b,c),wu(a,c),e.trigger(new _.F(_.Wg)),xu(e,!0).then(()=>{yu(e,f)}).catch(g=>{a.g.warn("Error while activating track",g)}))}else if(b===_.J)a.f.set(b,c),zu(e,parseInt(c.id,10));else if(b===_.K){const f=a.a.get(_.J)||null;let g;if(f){const h=Au(e).filter(k=>k.videoId==c.id);g=h.find(k=>k.audioId==f.id);if(!g){a.g.debug("Unable to find exact variant. Searching for equivalent");const k=f.track.renditions.map(l=>
|
|
59
|
+
l.id).filter(l=>l!==f.id);g=h.find(l=>k.find(m=>m==l.audioId))}}else g=Au(e).find(h=>h.videoId==c.id);g?(a.f.set(b,c),Bu(e,g,d)):a.g.warn("Cannot find matching variant")}}else a.g.debug(_.ua+b),tu(a,b)&&(b===_.I?xu(e,!1).then(()=>{a.a.set(b,null);e.trigger(new _.F(_.Wg))}).catch(f=>{a.g.warn("Error while de-activating text tracks",f)}):b===_.J?a.g.info("Enabling ABR for audio is not supported"):Bu(e,null,d))}};
|
|
60
|
+
wu=function(a,b){a.a.set(b.track.type,b);b===(a.f.get(b.track.type)||null)&&a.f.set(b.track.type,null)};Fu=function(a){if(a.l){a.g.debug("Track list change detected, updating track list");var b=[];for(var c of Object.values(_.tn))a.a.set(c,null),a.f.set(c,null);for(var d of a.l.ea()){let e=nu(_.I,d);e=(c=b.find(g=>Cu(g,e)))||e;const f=ou(_.I,d,e);d.active&&a.a.set(_.I,f);c||b.push(e)}Du(a.l)||a.a.set(_.I,null);d=Au(a.l);Eu(a,b,d,_.K);Eu(a,b,d,_.J);a.h=b}};
|
|
61
|
+
Cu=function(a,b){return a.type===b.type&&a.channelsCount===b.channelsCount&&a.frameRate===b.frameRate&&a.kind===b.kind&&a.label===b.label&&a.language===b.language&&a.mimeType===b.mimeType&&Fs(a.roles,b.roles)};Eu=function(a,b,c,d){c=pu(c,d);for(const e of c){let f=nu(d,e);f=(c=b.find(h=>Cu(h,f)))||f;const g=ou(d,e,f);e.active&&a.a.set(d,g);c||b.push(f)}};
|
|
62
|
+
Gu=function(a,b,c){if(b){a.h.length||Fu(a);var d=b.type,e=a.a.get(d)||null,f;for(const g of su(a,d))if(f=g.renditions.find(h=>h.id==b.id))break;f&&e!==f&&(wu(a,f),d===_.J?a.l.trigger(new _.F(_.Vg)):d===_.K&&a.l.trigger(new _.F(_.De,{details:{width:f.width||0,height:f.height||0,bandwidth:f.bandwidth,track:f.track,abrSelection:c}})))}};Hu=function(a,b){return 128E3>a.a?b:Math.min(_.it(a.f),_.it(a.g))};
|
|
63
|
+
Iu=function(a,b){a&&(b=b.filter(c=>du(c,a,{width:Infinity,height:Infinity})));return b.sort((c,d)=>c.bandwidth-d.bandwidth)};Ku=function(a,b){a.a.has(b)||a.a.set(b,new Ju);return a.a.get(b)};Lu=function(a,b,c){Ku(a,b).text=c};
|
|
64
|
+
Ou=function(a,b){var c;if(!(c=!!a.audio!=!!b.audio||!!a.video!=!!b.video||a.language!=b.language)&&(c=a.audio&&b.audio)){c=a.audio;var d=b.audio;c=!(c.channelsCount==d.channelsCount&&Mu(c,d)&&Nu(c.roles,d.roles))}!c&&(c=a.video&&b.video)&&(a=a.video,b=b.video,c=!(Mu(a,b)&&Nu(a.roles,b.roles)));return c?!1:!0};
|
|
65
|
+
Mu=function(a,b){if(a.mimeType!=b.mimeType)return!1;a=a.codecs.split(",").map(c=>_.Es(c)[0]);b=b.codecs.split(",").map(c=>_.Es(c)[0]);if(a.length!=b.length)return!1;a.sort();b.sort();for(let c=0;c<a.length;c++)if(a[c]!=b[c])return!1;return!0};Nu=function(a,b){a=new Set(a);b=new Set(b);a.delete("main");b.delete("main");if(a.size!=b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0};
|
|
66
|
+
Pu=function(a,b){b=_.Jg(b);let c=null;b.some(d=>{c=_.Cs(_.Gg(d),a.map(e=>Bs(e)));return!!c});return c?a.filter(d=>c===Bs(d)):[]};Qu=function(a,b){return a.filter(c=>{const d=c.audio;c=c.video;return d&&0<=d.roles.indexOf(b)||c&&0<=c.roles.indexOf(b)})};
|
|
67
|
+
Ru=function(a){return 1>=a.a.chasingRate?(a.g.warn("chasingRate must be greater than 1."),!1):a.a.chaseJumpDistance<=a.a.startChasingAt?(a.g.warn("chaseJumpDistance must be greater than startChasingAt."),!1):a.a.startChasingAt<=a.a.stopChasingAt?(a.g.warn("startChasingAt must be greater than stopChasingAt."),!1):0>a.a.stopChasingAt?(a.g.warn("stopChasingAt must be greater than or equal to 0."),!1):!0};Su=function(a,b){a.f=b};
|
|
68
|
+
Tu=function(a){a.f.stop();const b=a.h?0:a.g;0<=b?a.a.fd()!=b&&a.a.xe(b):(a.f.Pa(.25),0!=a.a.fd()&&a.a.xe(0))};Uu=function(a,b){a.f=b};Vu=function(a){if(a.a.paused||0==a.a.playbackRate||0===a.a.buffered.length)var b=!1;else a:{b=a.a.buffered;a=a.a.currentTime;for(let c=0;c<b.length;c++){const d=b.start(c),e=b.end(c);if(!(a<d-.1||a>e-(c+1===b.length?.5:.1))){b=!0;break a}}b=!1}return b};
|
|
69
|
+
Wu=function(a){if(0!=a.a.readyState){if(a.a.seeking){if(!a.A)return}else a.A=!1;if(!a.a.paused&&!a.m){a.a.readyState!=a.F&&(a.h=!1,a.F=a.a.readyState);var b=a.j.smallGapLimit,c=a.a.currentTime,d=a.a.buffered;a:{var e=new _.yn(d);var f=a.j.gapDetectionThreshold;if(e.length&&!(1===e.length&&1E-6>e.end(0)-e.start(0)))for(var g=0;g<e.length;g++)if(e.start(g)>c&&(0===g||e.end(g-1)-c<=f)){e=g;break a}e=null}if(null==e){if(a.f){a=a.f;d=a.g;c=Vu(d);d=d.a.currentTime;b=Date.now()/1E3;if(a.a!=d||a.j!=c)a.h=
|
|
70
|
+
b,a.a=d,a.j=c;d=b-a.h;d>=a.m&&c&&a.f(a.a,d)}}else if((0!=e||a.w)&&a.D&&(f=d.start(e),g=pt(a.C),!(f>=g))){g=f-c;b=g<=b;var h=!1;if(!(.001>g)){if(!b&&!a.h){a.h=!0;const k=new _.F("largegap",{detail:{currentTime:c,gapSize:g}});k.cancelable=!0;a.B(k);a.j.jumpLargeGaps&&!k.defaultPrevented?h=!0:_.xf("Ignoring large gap at",c,"size",g)}if(b||h)0==e?_.xf(as,g,"seconds because of gap before start time of",f):_.xf(as,g,"seconds because of gap starting at",d.end(e-1),"and ending at",f),a.a.currentTime=f}}}}};
|
|
71
|
+
Zu=function(a,b){a.o||(a.o=!0,a.m&&a.m());.001>Math.abs(a.a.currentTime-b)?Xu(a):(a.f.one(a.a,_.Xd,()=>{Xu(a)}),Yu(a.g,0==a.a.currentTime?b:a.a.currentTime))};$u=function(a,b){a.w=b;a.f.off(a.a,_.dd);a.f.one(a.a,_.dd,()=>{Zu(a,b)})};av=function(a){return a.j?a.a.currentTime:a.w};bv=function(a,b){0<a.a.readyState?Yu(a.g,b):$u(a,b)};Xu=function(a){_.Ah()&&!a.j&&a.h();a.j=!0;a.f.on(a.a,_.Xd,()=>a.h())};Yu=function(a,b){a.g=a.f.currentTime;a.j=b;a.h=a.m;a.f.currentTime=b;a.a.Pa(.1)};
|
|
72
|
+
ev=function(a,b,c){if(!c.stallEnabled)return null;const d=c.gapDetectionThreshold;let e=c.stallSkip;c=new cv(new dv(b),c.stallThreshold);Uu(c,(f,g)=>{a.f.warn(`Stall detected at ${f} for ${g} seconds.`);if(e){g=new _.yn(b.buffered);var h;if(h=_.uh("Edge/")||_.uh("Trident/")||_.vh()||_.Ah())a:{h=g;if(h.length&&!(1>=h.length))for(let k=0;k<h.length-1;k++)if(f>h.start(k)&&f<h.end(k)){h=h.start(k+1)-h.end(k)>=d;break a}h=!1}if(h){a:{if(g.length&&!(1>=g.length))for(h=0;h<g.length-1;h++)if(f>g.start(h)&&
|
|
73
|
+
f<g.end(h)){f=g.start(h+1)-f;break a}f=null}f&&(e=Math.min(f+.1,e))}a.f.warn(`Seeking forward ${e} seconds to break stall.`);b.currentTime+=e}else a.f.warn("Pausing and unpausing to break stall."),b.pause(),b.play()});return c};hv=function(a,b){null==b?b=Infinity>a.a.getDuration()?qt(a.a,0):pt(a.a):0>b&&(b=pt(a.a)+b);return fv(a,gv(a,b))};gv=function(a,b){const c=qt(a.a,0);if(b<c)return c;a=pt(a.a);return b>a?a:b};iv=function(a){const b=av(a.g);return 0<a.h.readyState&&!a.h.paused?gv(a,b):b};
|
|
74
|
+
fv=function(a,b){const c=a.a.getDuration();return b>=c?c-a.m.durationBackoff:b};
|
|
75
|
+
jv=function(a,b){var c=new _.yn(a.h.buffered);c=c.Qb.bind(c);var d=Math.max(a.B,a.m.rebufferingGoal);const e=a.m.safeSeekOffset;let f=qt(a.a,0);const g=pt(a.a),h=a.a.getDuration();3>g-f&&(f=g-3);const k=qt(a.a,d),l=qt(a.a,e);d=qt(a.a,d+e);if(b>=h)return a.f.debug("Playhead past duration."),fv(a,b);if(b>g)return a.f.debug("Playhead past end."),g;if(b<f){if(c(l))return a.f.debug("Playhead before start \x26 start is buffered"),l;a.f.debug("Playhead before start \x26 start is unbuffered");return d}if(b>=
|
|
76
|
+
k||c(b))return a.f.debug("Playhead in safe region or in buffered region."),b;a.f.debug("Playhead outside safe region \x26 in unbuffered region.");return d};
|
|
77
|
+
lv=function(a){a=_.L(a);let b=!1,c;const d=[],e=h=>{d.push(h);_.mj(h)},f=()=>{b=!0},g=[];(new _.Yn).M(_.ld,e).M(_.ne,e).M(_.gd,e).M(_.kd,e).M(_.de,e).W(_.fe,h=>{c=h;d.push(h);_.nj(h)}).W("encv",f).W("enca",f).W("avc1",h=>{g.push({M:h,lc:1701733238})}).W("avc3",h=>{g.push({M:h,lc:1701733238})}).W("ac-3",h=>{g.push({M:h,lc:1701733217})}).W("ec-3",h=>{g.push({M:h,lc:1701733217})}).W("mp4a",h=>{g.push({M:h,lc:1701733217})}).parse(a);if(b)return _.xf("Init segment already indicates encryption."),a;if(0===
|
|
78
|
+
g.length||!c)throw _.yf("Failed to find boxes needed to fake encryption!"),_.yf("Failed init segment (hex):",_.ki(a)),new _.H(_.G,3,14E3);g.reverse();for(const h of g)_.xf(`Inserting "${_.lj(h.lc)}" box into init segment.`),a=kv(a,c,h.M,d,h.lc);return a};
|
|
79
|
+
kv=function(a,b,c,d,e){{var f=mv.value(),g=a.subarray(c.start,c.start+c.size);const k=_.dg(g);var h=new Uint8Array(c.size+f.byteLength);h.set(g,0);g=_.dg(h);g.setUint32(4,e);h.set(f,c.size);e=k.getUint32(4);g.setUint32(c.size+16,e);nv(h,0,h.byteLength);e=h}h=new Uint8Array(a.byteLength+e.byteLength);c=_.uh("Xbox One")||_.th()?c.start:c.start+c.size;f=a.subarray(c);h.set(a.subarray(0,c));h.set(e,c);h.set(f,c+e.byteLength);for(const k of d)nv(h,k.start,k.size+e.byteLength);a=_.dg(h,b.start);b=_.pj(b);
|
|
80
|
+
d=a.getUint32(b);a.setUint32(b,d+1);return h};nv=function(a,b,c){a=_.dg(a,b);b=a.getUint32(0);0!=b&&(1==b?(a.setUint32(8,c>>32),a.setUint32(12,c&4294967295)):a.setUint32(0,c))};ov=function(a){return"("+a.type+":"+a.stream.id+")"};pv=function(a){return!a.$a&&null==a.sb&&!a.ub&&!a.Jb};qv=function(a){null!=a.sb&&(a.sb.stop(),a.sb=null)};rv=function(a,b){return(b=gt(a.g.periods,b+_.ao))?a.g.periods.indexOf(b):0};
|
|
81
|
+
xv=function(a,b,c,d,e){return _.v(function*(){var f=a.f.kb();const g=rv(a,f);f=new Map;const h=new Set;b&&(f.set(_.Rb,b),h.add(b));c&&(f.set(_.u,c),h.add(c));d&&(f.set(_.r,d),h.add(d));yield a.f.Y.init(f,a.m.forceNativeTS);a.j||(sv(a),yield uv(a,h),a.j||f.forEach((k,l)=>{a.h.has(l)||(k=vv(k,g,e),a.h.set(l,k),wv(a,k,0))}))})};_.yv=function(a,b){return(a=a.h.get(b))?a.Cb||a.stream:null};zv=function(a){return _.yv(a,_.Rb)};Av=function(a){return _.yv(a,_.u)};
|
|
82
|
+
uv=function(a,b){return _.v(function*(){var c=[];for(const d of b){const e=a.w.get(d.id);e?(a.a.debug("(all) Stream "+d.id+Zr),c.push(e.N)):(a.a.debug("(all) setting up Stream "+d.id),a.w.set(d.id,{N:new _.Hj,nc:!1}),c.push(d.createSegmentIndex()))}try{if(yield Promise.all(c),a.j)return}catch(d){if(a.j)return;for(const e of b)a.w.get(e.id).N.catch(()=>{}),a.w.get(e.id).N.reject(),a.w.delete(e.id);throw d;}for(const d of b)c=a.w.get(d.id),c.nc||(c.N.resolve(),c.nc=!0,a.a.debug("(all) setup Stream "+
|
|
83
|
+
d.id))})};vv=function(a,b,c){return{stream:a,type:a.type,nb:null,qa:null,Cb:null,wc:!0,ob:b,endOfStream:!1,$a:!1,sb:null,ub:!1,Dc:0,Sc:!1,Jb:!1,Dd:!1,kc:!1,ve:c||0,Ub:null,Fc:!1,ge:0}};wv=function(a,b,c){a.a.debug(ov(b),"updating in "+c+" seconds");b.sb=(new _.vn(()=>{Bv(a,b)})).$(c)};
|
|
84
|
+
Cv=function(a,b){return _.v(function*(){yield a.f.Y.clear(_.r);a.I++;a.J=!1;var c=a.I,d=a.f.Y;const e=new Map,f=new Set;e.set(_.r,b);f.add(b);yield d.init(e,!1);a.j||(yield uv(a,f),a.j||(d=d.getTextDisplayer().isTextVisible()||a.m.alwaysStreamText,a.I!=c||a.h.has(_.r)||a.J||!d||(c=a.f.kb(),c=rv(a,c),c=vv(b,c,0),a.h.set(_.r,c),wv(a,c,0))))})};
|
|
85
|
+
_.Iv=function(a,b,c,d){const e=a.h.get(b.type);if(!e&&b.type==_.r&&a.m.ignoreTextStreamFailures)Cv(a,b);else if(e){var f=Dv(a,b);if(c&&f!=e.ob){a.a.debug("switch: switching to stream in another Period; clearing buffer and changing Periods");for(var g of a.h.values())Ev(a,g)}else if(e.Cb&&(a.a.debug("switch during trick play mode",b),b.trickModeVideo?(e.Cb=b,b=b.trickModeVideo,a.a.debug("switch found trick play stream",b)):(e.Cb=null,a.a.debug("switch found no special trick play stream"))),(g=a.o[f])&&
|
|
86
|
+
g.nc&&(g=a.w.get(b.id))&&g.nc)if(e.stream!=b){g=a.g.presentationTimeline.getDuration();var h=a.f.kb();h=Fv(a,e,h);!c&&(e.endOfStream||h>=g)?a.a.debug(ss+ov(e)+" already buffered to the end. Not switching."):(b.type==_.r&&Lt(a.f.Y,_.Ig(b.mimeType,b.codecs)),e.stream=b,e.wc=!0,a.a.debug("switch: switching to Stream "+ov(e)),e.Ub?(b=a.f.kb(),g=a.f.Y.pa(e.type),f=(f=Gv(a,e,b,g,f))?f.wa?f.wa-f.Fa:null:null,null==f?f=!1:((h=e.stream.initSegmentReference)&&(f+=(h.wa?h.wa-h.Fa:null)||0),h=a.f.cd().getBandwidthEstimate(),
|
|
87
|
+
8*f/h<(null===g?0:g-b)-Math.max(a.g.minBufferTime||0,a.m.rebufferingGoal)?f=!0:(b=e.Ub,b=b.h?b.h.bytesRemaining:-1,f=0>b||b>f?!0:!1))):f=!1,f&&(a.a.info("Aborting current segment request to switch."),e.Ub.abort()),c&&(e.Jb?e.Sc=!0:e.$a?(e.ub=!0,e.Dc=d,e.Sc=!0):(qv(e),Hv(a,e,!0,d))))}else a.a.debug(ss+ov(e)+" already active")}};Jv=function(a,b,c,d){b.video&&_.Iv(a,b.video,c,d);b.audio&&_.Iv(a,b.audio,c,d)};
|
|
88
|
+
Dv=function(a,b){a=a.g.periods;for(let c=0;c<a.length;c++){const d=a[c],e=new Set;for(const f of d.variants)f.audio&&e.add(f.audio),f.video&&e.add(f.video),f.video&&f.video.trickModeVideo&&e.add(f.video.trickModeVideo);for(const f of d.textStreams)e.add(f);if(e.has(b))return c}return-1};
|
|
89
|
+
Ev=function(a,b){const c=ov(b);b.Jb?a.a.debug(c,"clear: already clearing the buffer"):b.ub?a.a.debug(c,"clear: already waiting"):b.$a?(a.a.debug(c,"clear: currently updating"),b.ub=!0,b.Dc=0):null==a.f.Y.fb(b.type)?(a.a.debug(c,"clear: nothing buffered"),null==b.sb&&wv(a,b,0)):(a.a.debug(c,"clear: handling right now"),qv(b),Hv(a,b,!1,0))};Fv=function(a,b,c){if(!b.nb||!b.qa)return Math.max(c,b.ve);c=Dv(a,b.nb);return a.g.periods[c].startTime+b.qa.endTime};
|
|
90
|
+
Hv=function(a,b,c,d){return _.v(function*(){const e=ov(b);b.ub=!1;b.Sc=!1;b.Dc=0;b.Jb=!0;a.a.debug(e,"clearing buffer");if(d){var f=a.f.kb();const g=a.f.Y.getDuration();f=a.f.Y.remove(b.type,f+d,g)}else f=a.f.Y.clear(b.type).then(()=>!a.j&&c?a.f.Y.flush(b.type):null);yield f;a.j||(a.a.debug(e,"cleared buffer"),b.nb=null,b.qa=null,b.Jb=!1,b.endOfStream=!1,b.Fc=!1,wv(a,b,0))})};
|
|
91
|
+
Gv=function(a,b,c,d,e){var f=ov(b);if(b.qa&&b.stream==b.nb)return d=b.qa.position+1,a.a.debug(f,"next position known:","position\x3d"+d),Kv(a,b,e,d);b.qa?(a.a.debug(f,"next position unknown: another Stream buffered"),f=Dv(a,b.nb),f=Lv(a,b,a.g.periods[f].startTime+b.qa.endTime,e)):(a.a.debug(f,"next position unknown: nothing buffered"),f=Lv(a,b,d||c,e));if(null==f)return null;c=null;null!=d||null!==a.m&&a.m.ignoreDrift||(c=Kv(a,b,e,Math.max(0,f-1)));return c||Kv(a,b,e,f)};
|
|
92
|
+
Mv=function(a){const b=a.f.kb(),c=f=>a.f.Y.Qb(f,b,0);let d=!1;const e=rv(a,b);if(_.Wf(a.h.values(),f=>f.ob==e))for(const f of a.h.keys())c(f)||(Ev(a,a.h.get(f)),d=!0);else if(!_.Wf(a.h.keys(),c)){a.a.debug("(all): seeked: unbuffered seek: clearing all buffers");for(const f of a.h.values())Ev(a,f);d=!0}d||a.a.debug("(all): seeked: buffered seek: presentationTime\x3d"+b)};sv=function(a){const b=a.g.presentationTimeline.getDuration();Infinity>b?a.f.Y.Fb(b):a.f.Y.Fb(Math.pow(2,32))};
|
|
93
|
+
Nv=function(a,b){let c=a.o[b];if(c)return a.a.debug("(all) Period "+b+Zr),c.N;a.a.debug("(all) setting up Period "+b);c={N:new _.Hj,nc:!1};a.o[b]=c;const d=new Set;for(const e of a.g.periods[b].variants)e.video&&d.add(e.video),e.video&&e.video.trickModeVideo&&d.add(e.video.trickModeVideo),e.audio&&d.add(e.audio);for(const e of a.g.periods[b].textStreams)d.add(e);a.H=a.H.then(()=>a.j?null:uv(a,d)).then(()=>{a.j||(a.o[b].N.resolve(),a.o[b].nc=!0,a.a.debug("(all) setup Period "+b))}).catch(e=>{a.j||
|
|
94
|
+
(a.o[b].N.catch(()=>{}),a.o[b].N.reject(),delete a.o[b],a.a.warn("(all) failed to setup Period "+b),a.f.onError(e))});return c.N};
|
|
95
|
+
Qv=function(a,b){if(b.type==_.r&&b.stream.mimeType==_.Hb){a=a.f.Y;b=b.stream.originalId||"";var c=a.pa(_.u)||0;Ct(a.g,b,c);return null}var d=ov(b);c=a.f.kb();const e=Fv(a,b,c);a.a.debug(d,"timeNeeded\x3d"+e);const f=Dv(a,b.stream);var g=rv(a,e),h=a.f.Y.va(b.type,c);a.a.debug(d,"update_:",ns+c,"bufferedAhead\x3d"+h);const k=Math.max(a.g.minBufferTime||0,a.m.rebufferingGoal,a.m.bufferingGoal)*a.B,l=a.g.presentationTimeline.Sb()?nt(a.g.presentationTimeline):a.g.presentationTimeline.getDuration();if(e>=
|
|
96
|
+
l&&!b.Fc)return Ov(a,b),null;b.endOfStream=!1;b.ob=g;if(g!=f)return a.a.debug(d,"need Period "+g,ns+c,"timeNeeded\x3d"+e,"currentPeriodIndex\x3d"+f),null;if(h>=k)return a.a.debug(d,"buffering goal met"),a.m.bufferLimitUpdateInterval||.5;g=a.f.Y.pa(b.type);g=Gv(a,b,c,g,f);if(!g)return a.g.presentationTimeline.isLive()||b.type===_.r?a.m.bufferLimitUpdateInterval||1:(a.a.debug("Media state "+d+": no next segment found. Assuming EOS."),Ov(a,b),null);d=Infinity;for(const m of a.h.values())if(m.type!=_.r||
|
|
97
|
+
m.stream.mimeType!=_.Hb)h=Fv(a,m,c),d=Math.min(d,h);if(e>=d+a.g.presentationTimeline.a)return a.m.bufferLimitUpdateInterval||1;b.ve=0;Pv(a,b,c,f,g);return null};Rv=function(a,b){_.v(function*(){if(!a.j){if(a.f.ye)try{yield a.f.ye(b)}catch(c){c.cause=b,b=c}if(!b.f)a.f.onError(b)}})};
|
|
98
|
+
Sv=function(a,b){const c=ov(b),d=Dv(a,b.stream);if(b.ob!=d){var e=b.ob,f=Array.from(a.h.values());f.every(g=>g.ob==e)?f.every(pv)?(a.a.debug(c,"all need Period "+e),Nv(a,e).then(()=>{if(!a.j)if(f.every(l=>{const m=pv(l),n=Dv(a,l.stream);return m&&l.ob==e&&n!=e})){var g=a.g.periods[e];a.a.debug(c,"calling onChooseStreams()...");var h=a.f.xd(g);a.F=!h.variant&&!!h.text;var k=new Map;h.variant&&h.variant.video&&k.set(_.u,h.variant.video);h.variant&&h.variant.audio&&k.set(_.Rb,h.variant.audio);h.text&&
|
|
99
|
+
k.set(_.r,h.text);for(const l of a.h.keys())if(!k.has(l)&&l!=_.r){a.a.error(c,"invalid Streams chosen: missing "+l+" Stream");a.f.onError(new _.H(_.G,5,5005));return}for(const l of Array.from(k.keys()))if(!a.h.has(l))if(l==_.r)xv(a,null,null,k.get(_.r),g.startTime),k.delete(l);else{a.a.error(c,"invalid Streams chosen: unusable "+l+" Stream");a.f.onError(new _.H(_.G,5,5005));return}for(const l of Array.from(a.h.keys()))(g=k.get(l))?(_.Iv(a,g,!1,0),wv(a,a.h.get(l),0)):a.h.delete(l);a.a.debug(c,js);
|
|
100
|
+
a.f.wd()}else a.a.debug(c,"ignoring transition to Period",e,"since another is happening")}).catch(Ks)):a.a.debug(c,"all MediaStates need Period "+e+", but not all MediaStates are idle"):a.a.debug(c,"not all MediaStates need Period "+e)}};
|
|
101
|
+
Bv=function(a,b){if(!a.j){var c=ov(b);if(!b.$a&&null!=b.sb&&!b.Jb)if(b.sb=null,b.ub)a.a.debug(c,"skipping update and clearing the buffer"),Hv(a,b,b.Sc,b.Dc);else{try{var d=Qv(a,b);null!=d&&(wv(a,b,d),b.kc=!1)}catch(e){Rv(a,e);return}d=Array.from(a.h.values());Sv(a,b);a.C&&d.every(e=>e.endOfStream)&&(a.a.debug(c,"calling endOfStream()..."),a.f.Y.endOfStream().then(()=>{if(!a.j&&!a.g.presentationTimeline.Sb()){var e=a.f.Y.getDuration();e<a.g.presentationTimeline.getDuration()&&a.g.presentationTimeline.Fb(e)}}).then(()=>
|
|
102
|
+
{a.f.me()}))}}};Ov=function(a,b){a.a.debug(ov(b),"buffered to end of presentation");b.endOfStream=!0;b.type==_.u&&(a=a.h.get(_.r))&&a.stream.mimeType==_.Hb&&(a.endOfStream=!0)};
|
|
103
|
+
Pv=function(a,b,c,d,e){const f=ov(b),g=a.g.periods[d];a.a.debug(f,"fetchAndAppend_:",ns+c,ls+g.startTime,"reference.position\x3d"+e.position,ps+e.startTime,os+e.endTime);const h=b.stream,k=a.g.presentationTimeline.getDuration(),l=a.g.periods[d+1];d=Tv(a,b,d,Math.max(0,g.startTime-.1),l?l.startTime+.01:k,e);b.$a=!0;b.wc=!1;a.a.debug(f,"fetching segment");let m=!1;const n=(t,w)=>{if(a.j||a.A)return null;m=!0;return Uv(a,b,c,g,h,e,t,w)},q=a.f.Y.pa(b.type)||0;d.then(()=>a.j||a.A?null:Vv(a,b,e,!1,t=>n(t.data,
|
|
104
|
+
!0))).then(t=>m||a.j||a.A||null===t?(a.j||a.A||Wv(a,b,q,e,h),null):n(t,!1)).then(()=>{a.j||a.A||(Wv(a,b,q,e,h),b.$a=!1,b.Dd=!1,b.ub||a.f.Nc(),wv(a,b,0),Xv(a,b,h),a.a.debug(f,"finished fetch and append"))}).catch(t=>{if(!a.j&&!a.A)if(b.$a=!1,b.type==_.r&&a.m.ignoreTextStreamFailures)1001==t.code?a.a.warn(f,"Text stream failed to download. Proceeding without it."):a.a.warn(f,"Text stream failed to parse. Proceeding without it."),a.h.delete(_.r);else if(7001==t.code)b.$a=!1,b.sb=null,wv(a,b,0);else if(3017==
|
|
105
|
+
t.code)Yv(a,b,t);else if(b.type===_.r)t instanceof _.H&&t.a(1),qv(b),a.f.onError(new _.H(1,2,2010,t));else if(1001<=t.code&&1003>=t.code){{let w=!0;1001===t.code&&500<=t.data.status||(w=typeof a.f.Vc===_.Qc&&!a.f.Vc(b.stream));w&&(b.kc=!0,t.a(_.G),Rv(a,t))}}else a.a.error(f,"failed fetch and append: code\x3d"+t.code),b.kc=!0,t instanceof _.H&&t.a(_.G),Rv(a,t)})};
|
|
106
|
+
Kv=function(a,b,c,d){const e=ov(b);c=a.g.periods[c];const f=b.stream.getSegmentReference(d);if(!f)return a.a.debug(e,"segment does not exist:",ls+c.startTime,"position\x3d"+d),null;var g=a.g.presentationTimeline;d=_.ot(g);g=nt(g);return!b.Fc&&(c.startTime+f.endTime<d||c.startTime+f.startTime>g)?(a.a.debug(e,"segment is not available:",ls+c.startTime,ps+f.startTime,os+f.endTime,"availabilityStart\x3d"+d,"availabilityEnd\x3d"+g),null):f};
|
|
107
|
+
Lv=function(a,b,c,d){const e=ov(b);d=a.g.periods[d];a.a.debug(e,"looking up segment:","lastSegment.endTime\x3d"+c,ls+d.startTime);c=Math.max(0,c-d.startTime);b=b.stream.findSegmentPosition(c);null==b&&a.a.warn(e,"cannot find segment:",ls+d.startTime,"lookupTime\x3d"+c);return b};
|
|
108
|
+
Tv=function(a,b,c,d,e,f){c=a.g.periods[c].startTime-f.qb;if(!b.wc&&c===b.ge)return Promise.resolve();b.ge=c;const g=ov(b);a.a.debug(g,"setting timestamp offset to "+c);a.a.debug(g,"setting append window start to "+d);a.a.debug(g,"setting append window end to "+e);d=Vt(a.f.Y,b.type,c,d,e);if(!b.stream.initSegmentReference||!b.wc)return d;a.a.debug(g,"fetching init segment");e=Vv(a,b,b.stream.initSegmentReference,!0).then(h=>{if(a.j)return null;a.a.debug(g,"appending init segment");return Zv(a,h,b).then(()=>
|
|
109
|
+
Tt(a.f.Y,b.type,h,null,null,!!b.stream.closedCaptions&&0<b.stream.closedCaptions.size))}).catch(h=>{b.wc=!0;return Promise.reject(h)});return Promise.all([d,e])};
|
|
110
|
+
Uv=function(a,b,c,d,e,f,g,h){h=void 0===h?!1:h;const k=ov(b);if(e.encrypted&&e.keyId&&a.D.length&&!a.D.includes(e.keyId))return a.a.warn(k,"Stream has key restrictions. Blocking."),qv(b),b.nb=e,b.qa=f,a.f.Vc(e,!0),Promise.resolve();const l=e.closedCaptions&&0<e.closedCaptions.size;null!=e.emsgSchemeIdUris&&0<e.emsgSchemeIdUris.length&&(new _.Yn).W("emsg",a.K.bind(a,d,f,e.emsgSchemeIdUris)).parse(g);return $v(a,b,c).then(()=>{if(a.j)return null;a.a.debug(k,"appending media segment");return Tt(a.f.Y,
|
|
111
|
+
b.type,g,f.startTime+d.startTime,f.endTime+d.startTime,l,e.id,h)}).then(()=>{a.j||(a.a.debug(k,"appended media segment"),b.nb=e,b.qa=f)})};
|
|
112
|
+
Vv=function(a,b,c,d,e){d=void 0===d?!1:d;e=void 0===e?null:e;const f=_.jt(c.Ka(),c.Fa,c.wa,a.m.attemptParameters,c.startTime,c.endTime,b.type,c.timescale);f.type=2;f.onFragment=c.Kb?null:e;f.disableFragmentSupport=c.Kb||a.m.disableFragmentSupport;f.disableMergedFragments=a.m.disableMergedFragments;if(e=c.a())f.keyInfo=e,f.onFragment=null;d&&(f.responseModifiers.push(g=>{aw(a,b,g.data)}),b.type===_.u&&a.m.overridePasp&&f.responseModifiers.push(a.L.bind(a)));a.a.debug("fetching: reference\x3d",c);c=
|
|
113
|
+
a.f.pb.fetch(f);b.Ub=c;return c.N.then(g=>{const h=a.f.cd(),k=g.timeMs,l=g.data.byteLength;k&&l&&!d&&h.segmentDownloaded(k,l);b.Ub=null;return g.data})};
|
|
114
|
+
Wv=function(a,b,c,d,e){if(!a.g.presentationTimeline.isLive()&&b.type!==_.r){const f=ov(b);c=(a.f.Y.pa(b.type)||0)-c;const g=d.endTime-d.startTime,h=c-g;Math.abs(h)>=Math.min(.01,g)&&Math.abs(h)<=Math.min(1,g)&&(a.a.debug(f,"Adjusted segment",d.position,"with real duration",c,"and accounted for",h,"delta between segment duration and real duration"),b.Fc=!0,e.adjustSegmentDurations(d.position,h))}};
|
|
115
|
+
Xv=function(a,b,c){if(!a.C){var d=ov(b);b=Array.from(a.h.values());1!=b.length||b[0].type!=_.r?a.C=b.every(e=>e.type==_.r||a.F?!0:!e.ub&&!e.Jb&&e.qa):a.F&&(a.C=!0);if(a.C){a.a.debug(d,"startup complete");c=Dv(a,c);a.o[c]||Nv(a,c).then(()=>{a.j||(a.a.debug(d,js),a.f.wd())}).catch(Ks);for(c=0;c<a.g.periods.length;++c)Nv(a,c).catch(Ks);a.f.jf&&(a.a.debug(d,"calling onStartupComplete()..."),a.f.jf())}}};
|
|
116
|
+
Yv=function(a,b,c){const d=ov(b);if(Array.from(a.h.values()).some(e=>e!=b&&e.Dd))a.a.debug(d,bs,"waiting for another stream to recover...");else{const e=Math.round(100*a.B);if(20<e)a.B-=.2;else if(4<e)a.B-=.04;else{a.a.error(d,"MediaSource threw QuotaExceededError too many times");b.kc=!0;a.A=!0;a.f.onError(c);return}a.a.warn(d,bs,"reducing buffering goals by "+(100-Math.round(100*a.B))+"%");b.Dd=!0}wv(a,b,4)};
|
|
117
|
+
bw=function(a,b){b=void 0===b?!1:b;if(a.j)a.a.error("Unable to retry after StreamingEngine is destroyed!");else if(a.A)a.a.error("Unable to retry after StreamingEngine encountered a fatal error!");else for(const c of a.h.values()){const d=ov(c);if(c.kc||b&&pv(c))a.a.info(d,"Retrying after failure..."),c.kc=!1,wv(a,c,.1)}};Zv=function(a,b,c){return _.v(function*(){if(a.m.patchEdgeWhenMixedContent&&_.th()){const d=lv(b);yield Tt(a.f.Y,c.type,d.buffer,null,null,!!c.stream.closedCaptions&&0<c.stream.closedCaptions.size)}})};
|
|
118
|
+
$v=function(a,b,c){if(a.j)return Promise.resolve();const d=ov(b);a.a.debug(d,"checking buffer length");const e=Math.max(a.m.bufferBehind,a.g.presentationTimeline.a),f=a.f.Y.fb(b.type);if(null==f)return a.a.debug(d,"buffer behind okay because nothing buffered:",ns+c,hs+e),Promise.resolve();const g=c-f,h=g-e;if(.01>=h)return a.a.debug(d,"buffer behind okay:",ns+c,is+g,hs+e,"underflow\x3d"+Math.abs(h)),Promise.resolve();a.a.debug(d,"buffer behind too large:",ns+c,is+g,hs+e,"overflow\x3d"+h);return a.f.Y.remove(b.type,
|
|
119
|
+
f,f+h).then(()=>{a.j||a.a.debug(d,"evicted "+h+" seconds")})};aw=function(a,b,c){(new _.Yn).M(_.ld,_.mj).M(_.ne,_.mj).M(_.gd,_.mj).M(_.kd,_.mj).M(_.de,_.mj).W(_.fe,_.nj).M("encv",d=>{d.G.skip(78);_.mj(d)}).M("sinf",_.mj).M("schi",_.mj).M("tenc",d=>{d.G.skip(6);if(_.ts(d.G)){d.G.skip(1);const e=_.ki(_.Ei(d.G,16));e!==b.stream.keyId&&(a.a.debug(ov(b),"Key id from tenc mismatches with key id from manifest. Switching from "+`${b.stream.keyId} to ${e}.`),b.stream.keyId=e)}d.Za.stop()}).parse(c)};
|
|
120
|
+
cw=function(a){return _.v(function*(){const b=[];for(const c of a.h.values())qv(c),c.$a&&c.Ub&&(c.$a=!1,b.push(c.Ub.abort())),c.ub&&b.push(Hv(a,c,!0,0));yield Promise.all(b)})};dw=function(a,b,c){(a=a.h.get(b))&&c&&(qv(a),a.stream=c,a.nb=c,a.qa&&(a.qa=c.getSegmentReference(a.qa.position)),a.qa||(a.nb=null))};
|
|
121
|
+
ew=function(a){const b=c=>c.video&&c.audio||c.video&&c.video.codecs.includes(",");if(a.some(c=>c.variants.some(b))){_.C("Found variant with audio and video content, so filtering out audio-only content in all periods.");for(const c of a)c.variants=c.variants.filter(b)}};
|
|
122
|
+
xu=function(a,b){return _.v(function*(){if(a.ld!=b&&(a.ld=b,a.C==fw&&(a.H.getTextDisplayer().setTextVisibility(b),!a.configuration.streaming.alwaysStreamText)))if(b){var c=gw(a);c=_.lu(c.textStreams,a.Z,a.ga);0<c.length&&(yield Cv(a.a,c[0]))}else{{c=a.a;c.J=!0;const d=c.h.get(_.r);d&&(qv(d),c.h.delete(_.r))}}})};yu=function(a,b){if(a.f&&a.a){const c=gw(a),d=c.textStreams.find(e=>e.id==b.id);d?(hw(a,c,d,!1),iw(a,d),a.Z=d.language):a.log.error(_.cs,b.id)}};
|
|
123
|
+
zu=function(a,b){if(a.a&&(a.f||a.w)){var c=Av(a.a),d=zv(a.a),e=gt(a.f.periods,iv(a.w)),f=a.f.periods[e?a.f.periods.indexOf(e):0].variants.filter(h=>h.audio.id==b&&ju(h));e=f.find(h=>h.video.id==c.id);var g=!1;if(!e){a.log.debug("Cannot find exact variant, looking for anything else that matches with given audioId");g=!0;const h=a.getTrackManager().Aa();if(h){const k=h.renditions.map(l=>l.id);e=f.find(l=>k.find(m=>m==l.video.id))}}if(e){if(d.codecs.split(".")[0]===e.audio.codecs.split(".")[0]){d=e.audio;
|
|
124
|
+
a.Qa=d.id;a.g.setVariants(f);f=gw(a);jw(a,f,e,!1);g||a.P?kw(a,e,!0,0):_.Iv(a.a,d,!0,0);Promise.resolve();return}a.log.warn("Target audio codecs not compatible with active audio codecs.")}}Promise.reject()};
|
|
125
|
+
Au=function(a){if(a.f&&a.w){const d=lw(a),e=[];for(const f of mw(a)){{var b=f;a=b.audio;const g=b.video,h=a?a.codecs:null,k=g?g.codecs:null,l=[];k&&l.push(k);h&&l.push(h);const m=g&&g.mimeType||null,n=a&&a.mimeType||null;var c=[];a&&c.push(a.kind);g&&c.push(g.kind);c=c[0]||null;const q=new Set,t=new Set;if(a)for(const w of a.roles)t.add(w);if(g)for(const w of g.roles)q.add(w);b={id:b.id,active:!1,type:"variant",bandwidth:b.bandwidth,language:b.language,label:null,kind:c,width:null,height:null,frameRate:null,
|
|
126
|
+
mimeType:m,audioMimeType:n,codecs:l.join(", "),audioCodec:h,videoCodec:k,primary:b.primary,roles:Array.from(q),audioRoles:Array.from(t),videoId:null,audioId:null,channelsCount:null,audioBandwidth:null,videoBandwidth:null,originalVideoId:null,originalAudioId:null,originalTextId:null};g&&(b.videoId=g.id,b.originalVideoId=g.originalId,b.width=g.width||null,b.height=g.height||null,b.frameRate=g.frameRate||null,b.videoBandwidth=g.bandwidth||null);a&&(b.audioId=a.id,b.originalAudioId=a.originalId,b.channelsCount=
|
|
127
|
+
a.channelsCount,b.audioBandwidth=a.bandwidth||null,b.label=a.label,b.audioRoles=a.roles);a=b}a.active=f==d;e.push(a)}return e}return[]};
|
|
128
|
+
Bu=function(a,b,c){var d=void 0===d?0:d;if(a.f&&a.a){const f=gw(a);if(a.configuration.abr.enabled&&b)a.log.info("Disable ABR and enable manual track selection to "+`select ${b.width}x${b.height}@${b.bandwidth}`),a.configuration.abr.enabled=!1,a.g.disable();else if(!a.configuration.abr.enabled&&!b){a.log.info("Enable ABR Selection");a.configuration.abr.enabled=!0;a.g.enable();a.L=null;c=nw(a,f.variants);null!=a.V&&(a.ua=a.V,a.V=null);null==c||a.P||ow(a,c);return}if(b){a.L=b.id;var e=f.variants.find(g=>
|
|
129
|
+
g.id==b.id);e?(a.L=e.video.id,ju(e)?(jw(a,f,e,!1),kw(a,e,c,d),null==a.V&&(a.V=a.ua),a.ua=new pw(e),nw(a,f.variants)):a.log.error("Unable to switch to restricted track",b.id)):a.log.error("No variant with id",b.id)}else a.L=null,null!=a.V&&(a.ua=a.V,a.V=null),c=nw(a,f.variants),null==c||a.P||ow(a,c)}};Du=function(a){const b=a.ld;return a.f?a.H.getTextDisplayer().isTextVisible():b};
|
|
130
|
+
qw=function(a,b){a.h||(a.j.on(b,_.Oc,()=>{if(a.h.error){var c=a.h.error.code;if(1==c)c=null;else{var d=a.h.error.msExtendedCode;d&&(0>d&&(d+=Math.pow(2,32)),d=d.toString(16));c=new _.H(_.G,3,3016,{code:c,extendedError:d,message:a.h.error.message})}}else c=null;if(c)a.onError(c)}),a.h=b);return Promise.resolve()};
|
|
131
|
+
sw=function(a){return new _.rw(b=>{if(void 0===b||null===b)return null;const c=a.getTrackManager(),d=[];if(c)for(const e of c.getVideoTracks())d.push(...e.renditions);return d.find(e=>e.id==b)||null})};
|
|
132
|
+
tw=function(a,b){if(a.S!==b)if(a.S===_.yk&&b!==_.zk)b=zs(b,_.xk),a.log.info(_.ds+`${b}`);else{var c=a.qd;c=0===c?0:Date.now()-c;var d=a.S;a.S=b;a.qd=Date.now();a.F&&_.fk(a.F.a,a.S);b===_.uk&&(a.ke=a.hd?1:2);var e=a.ke,f={currentState:a.S,previousState:d,timeSinceLastStateChangeMS:c,reason:b===_.uk||d===_.uk?e:void 0},g=zs(d,_.xk),h=zs(b,_.xk),k=b!==_.uk?"":`[${zs(e,_.wk)}]`;a.log.info(`Player state change: ${g} -> `+`${h}${k}`);a.trigger(new _.F(_.be,{detail:f}));(b===_.rk||b===_.yk)&&a.ca&&a.ca.stop();
|
|
133
|
+
b===_.uk?a.trigger(new _.F(_.ac,{detail:{bufferedTimeMS:-1,reason:e}})):d===_.uk&&a.trigger(new _.F(_.$b,{detail:{bufferedTimeMS:c,reason:e}}))}};yw=function(a){var b=!1;b=void 0===b?!0:b;return _.v(function*(){if(a.C==uw)return Promise.reject(new _.H(_.G,7,7E3));yield vw(a);yield ww(a);var c=_.vh(4)||_.vh(5);if(b||c)c=a.getSurface().getMedia(),yield qw(a,c),yield xw(a,c)})};ww=function(a){a.h&&(a.j.off(a.h,_.Oc),a.h=null);return Promise.resolve()};
|
|
134
|
+
vw=function(a){return _.v(function*(){a.C!=uw&&(a.C=zw);const b=a.h;b&&(a.j.off(b,_.cd),a.j.off(b,_.Kd),a.j.off(b,_.Fd),a.j.off(b,_.Nc),a.j.off(b,_.Pd),a.j.off(b,_.Nd));a.Sa&&(a.Sa.release(),a.Sa=null);a.ca&&(a.ca.stop(),a.ca=null);a.B&&(yield a.B.stop(),a.B=null);a.g&&(yield a.g.stop());a.a&&(yield a.a.destroy(),a.a=null);a.w&&(a.w.release(),a.w=null);a.H&&(yield a.H.destroy(),a.H=null);a.hc&&(a.hc.release(),a.hc=null);b&&b.src&&(b.removeAttribute("src"),b.load());a.m&&(yield a.m.destroy(),a.m=null);
|
|
135
|
+
a.K.clear();a.D=null;a.Hc.clear();a.f=null;a.F=null;a.P=!0;a.Ta.clear();a.Hb=!1;Aw(a)})};xw=function(a,b){return _.v(function*(){var c=window.muxjs?new Bw:new _.Cw;const d=_.dk(a.configuration,["html",_.Zd]);a.I=d.create(a);a.Ib=sw(a);a.Ib.track(a);c=new _.Dw(b,c,a.I,a.Ib,a.configuration);yield c.H;a.H=c})};Ew=function(a,b){return _.v(function*(){const c=a.getNetworkEngine();a.B=yield _.qm(b.url,c,a.configuration.manifest.attemptParameters,b.type);a.B.configure(a.configuration.manifest)})};
|
|
136
|
+
Iw=function(a,b){return _.v(function*(){a.ma=new Fw;rt(a.ma,c=>{Gw(a,_.If,c)});yield(new _.Ok(Promise.resolve().then(()=>_.v(function*(){for(;!a.f;)try{a.f=yield a.B.start(b.url,Hw(a))}catch(c){if(a.da){const d=yield a.da(b.url,c);if(d)b.url=d;else throw c;}else throw c;}!a.f.presentationTimeline||_.y(a.configuration.suggestedPresentationDelay)||isNaN(a.configuration.suggestedPresentationDelay)||(a.log.info("Apply suggested presentation delay of: "+a.configuration.suggestedPresentationDelay),a.f.presentationTimeline.Cd=
|
|
137
|
+
a.configuration.suggestedPresentationDelay);a.f.presentationTimeline&&(a.f.presentationTimeline.C=!!a.configuration.lowLatencyMode);if(0==a.f.periods.length)throw new _.H(_.G,4,4014);ew(a.f.periods)})),()=>{a.log.info("Aborting parser step...");return a.B.stop()})).N})};
|
|
138
|
+
Ow=function(a){return _.v(function*(){a.m=new _.Lk({pb:a.getNetworkEngine(),onError:f=>a.onError(f),zd:f=>{if(a.a){var g=gw(a),h=!1,k=Object.keys(f);0==k.length&&a.log.warn("Got a key status event without any key statuses, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");var l=1==k.length&&"00"==k[0];l&&a.log.warn("Got a synthetic key status event, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");
|
|
139
|
+
if(k.length)for(var m of g.variants){k=m;var n=[];k.audio&&n.push(k.audio);k.video&&n.push(k.video);k=n;for(const q of k)k=m.allowedByKeySystem,q.keyId&&(n=f[l?"00":q.keyId],m.allowedByKeySystem=!!n&&!Jw.includes(n)),k!=m.allowedByKeySystem&&(h=!0)}m=[];if(!l)for(const q in f)Jw.includes(f[q])||m.push(q);a.log.debug("allowedKeyIds",m);a.a.D=m;f=zv(a.a);l=Av(a.a);(f=mu(f,l,g.variants))&&!f.allowedByKeySystem&&(a.log.debug("Choosing new streams after key status changed"),Kw(a,g));h&&(Lw(a),nw(a,g.variants))}},
|
|
140
|
+
onExpirationUpdated:(f,g)=>{if(a.B&&a.B.onExpirationUpdated)a.B.onExpirationUpdated(f,g);a.trigger(new _.F(_.Fc,{expirationTime:g}))},onEvent:f=>a.pd(f),getConfiguration:()=>a.getConfiguration(),jc:()=>a.jc()});Mw(a);const b=a.configuration.drm,c=b?b.offlineId||"":"";let d=[];const e=_.om(a.f.periods);if(c){const f=_.ai(_.Gd);f&&(yield f.o(b,e,a.getNetworkEngine()),d=yield f.m(c))}yield _.Gj(a.m,e,d);Nw(a,a.f.periods)})};
|
|
141
|
+
cx=function(a){return _.v(function*(){const b=a.h;var c=e=>{a.h&&a.D&&(e.type===_.Xd&&a.Ic?(a.D.a=Pw,Aw(a)):e.type===_.He&&a.getState()===_.Ck&&.1>a.getBufferInfo().va(a.getPosition())?(a.D.a=Pw,Aw(a)):a.D&&Qw(a));Rw(a)};a.j.on(b,_.Kd,c);a.j.on(b,_.Fd,c);a.j.on(b,_.Nc,c);a.j.on(b,_.Xd,c);a.j.on(b,_.Wd,c);a.j.on(b,_.Nd,c);a.j.on(b,_.He,c);a.j.on(b,_.Pd,()=>{if(a.h){var e=a.h.playbackRate;0!=e&&a.Ra.set(e)}});a.g||(a.g=new _.Sw,a.g.configure(a.configuration.abr));Tw(a,a.f.periods);a.ua=new Uw(a.configuration.preferredAudioLanguage,
|
|
142
|
+
a.configuration.preferredAudioRole,a.configuration.preferredAudioChannelCount);a.Z=a.configuration.preferredTextLanguage;a.ga=a.configuration.preferredTextRole;yield _.Vj(a.m,b);if(!a.m)throw new _.H(_.G,7,7001);a.g.init((e,f,g)=>{!a.P&&ow(a,e,f,g)});a.w=Vw(a,a.configuration.startTime);a.Sa=Ww(a);a.Ra=new Xw({fd:()=>b.playbackRate,xe:e=>{b.playbackRate=e},gf:e=>{b.currentTime+=e}});a.isLive()&&a.configuration.streaming.enableLiveEdgeChasing&&(a.hc=new Yw(a));Zw(a,Math.max(1E-4,a.configuration.streaming.rebufferingGoal));
|
|
143
|
+
cu(a.f,_.Jg(a.configuration.preferredVideoCodec),_.Jg(a.configuration.preferredAudioCodec),a.configuration.preferredAudioChannelCount);a.a=$w(a);a.a.m=a.configuration.streaming;a.C=fw;yield a.a.start();if(!a.a)throw new _.H(_.G,7,7001);a.configuration.streaming.startAtSegmentBoundary&&(c=iv(a.w),c=ax(a,c),bv(a.w.g,c));for(var d of a.f.periods)bx(a,d);Lw(a);d=gw(a)||a.f.periods[0];c=d.variants.some(e=>e.primary);a.configuration.preferredAudioLanguage||c||a.log.warn("No preferred audio language set. We will choose an arbitrary language initially");
|
|
144
|
+
nw(a,d.variants);a.j.one(b,_.cd,()=>{a.F.o=Date.now()/1E3-(null===a.od?0:a.od)})})};Aw=function(a){if(a.F&&a.D&&a.w){const c=dx(a)===_.uk;var b=a.Ra;b.h=c;Tu(b);a.w.j.m=c;Rw(a)}};Gw=function(a,b,c){a.trigger(new _.F(b,{detail:{schemeIdUri:c.schemeIdUri,value:c.value,startTime:c.startTime,endTime:c.endTime,id:c.id,eventElement:c.eventElement,type:c.type}}))};
|
|
145
|
+
Hw=function(a){return{networkingEngine:a.getNetworkEngine(),filterNewPeriod:b=>bx(a,b),filterAllPeriods:b=>Nw(a,b),onTimelineCueAdded:b=>{var c=a.ma;a:{for(d of c.a)if(d.schemeIdUri===b.schemeIdUri&&d.startTime===b.startTime&&d.endTime===b.endTime)break a;var d=null}null==d&&(c.a.add(b),c.f(b))},onEvent:b=>a.pd(b),onError:b=>a.onError(b)}};Mw=function(a){const b=_.ti(a.configuration.drm);a.m.h=b};
|
|
146
|
+
Nw=function(a,b){var c=a.a?zv(a.a):null;const d=a.a?Av(a.a):null;for(const e of b)hu(a.m,c,d,e);c=Hs(b,e=>e.variants.some(ju));if(0==c)throw new _.H(_.G,4,4032);if(c<b.length)throw new _.H(_.G,4,4011);for(const e of b)eu(e.variants,a.configuration.restrictions,a.ue)&&a.a&&gw(a)==e&&Lw(a),ex(a,e.variants)};
|
|
147
|
+
Qw=function(a){switch(a.C){case fw:a:if(a.h.ended||Nt(a.H))var b=!0;else{if(a.f.presentationTimeline.isLive()){b=nt(a.f.presentationTimeline);var c=a.getBufferInfo();if(null!==c&&(c=c.pa(),null!==c&&c>=b)){b=!0;break a}}b=!1}break;default:b=!1}c=0;if(a.H){var d=Pt(a.H),e=d.video;d=d.audio;var f=a.h.currentTime;if(e||d)c=e&&d?Math.min(e.va(f),d.va(f)):e?e.va(f):d.va(f)}if(e=a.D){{e=a.D;d=c;f=b;const g=e.f.get(e.a);c=e.a;d=f||d>=g?fx:Pw;e.a=d;e=c!=d}}c=e;e=gx(a);c||a.getState()===_.uk&&!e?(a.log.debug("Buffering state changed. Is buffering",
|
|
148
|
+
e,"buffered to end",b,"state",a.getState()),Aw(a)):a.Hb&&Rw(a)};Rw=function(a){tw(a,dx(a))};
|
|
149
|
+
Tw=function(a,b){for(let c=0;c<b.length;c++){const d=b[c],e=new Map;for(const f of d.variants)if(f.video&&f.video.closedCaptions){const g=f.video;for(const h of g.closedCaptions.keys())if(!e.has(h)){const k={id:a.we++,originalId:h,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:()=>null,getSegmentReference:()=>null,initSegmentReference:null,qb:0,mimeType:_.Hb,codecs:"",kind:"caption",encrypted:!1,keyId:null,language:g.closedCaptions.get(h),label:null,type:_.r,primary:!1,trickModeVideo:null,
|
|
150
|
+
emsgSchemeIdUris:null,roles:g.roles,channelsCount:null,closedCaptions:null};e.set(h,k)}}for(const f of e.values())d.textStreams.push(f)}};ow=function(a,b,c,d){c=void 0===c?!1:c;d=void 0===d?0:d;if(a.configuration.abr.enabled){a.log.debug("switch_");var e=hx(a,b);ix(a,e,()=>jw(a,e,b,!0));e===gw(a)&&jx(a);a.a&&Jv(a.a,b,c,d)}};Vw=function(a,b){return new kx(a.h,a.f,a.configuration.streaming,b,()=>{a.Sa&&wt(a.Sa,!0);a.a&&Mv(a.a)},c=>a.dispatchEvent(c))};
|
|
151
|
+
Ww=function(a){const b=new lx(a.f);Su(b,()=>{Lw(a)});const c=new mx(a.ma);xt(c,e=>{e.Mc&&e.Mc();Gw(a,_.Kf,e)},e=>{e.yd&&e.yd();Gw(a,_.Lf,e)},(e,f)=>{f||(e.Mc&&e.Mc(),Gw(a,_.Kf,e),e.yd&&e.yd(),Gw(a,_.Lf,e))});const d=new nx(a.h);d.a.add(b);d.a.add(c);return d};Zw=function(a,b){a.D=new ux(b,Math.min(.5,b/2));a.D.a=Pw;Aw(a);a.ca=(new _.rh(()=>{Qw(a)})).Pa(.25)};
|
|
152
|
+
$w=function(a){const b={kb:()=>iv(a.w),Y:a.H,pb:a.getNetworkEngine(),xd:a.Bf.bind(a),wd:a.Af.bind(a),onError:a.onError.bind(a),me:a.Df.bind(a),onEvent:a.pd.bind(a),qe:a.Cf.bind(a),Nc:a.De.bind(a),cd:()=>a.g,Vc:a.zf.bind(a),ye:a.Fe.bind(a)};return new _.vx(a.f,b)};
|
|
153
|
+
ax=function(a,b){function c(g,h){if(!g)return null;h=g.findSegmentPosition(h-f.startTime);return null==h?null:(g=g.getSegmentReference(h))?g.startTime+f.startTime:null}const d=zv(a.a);var e=Av(a.a);const f=gw(a);a=c(d,b);e=c(e,b);return null!=e&&null!=a?Math.max(e,a):null!=e?e:null!=a?a:b};
|
|
154
|
+
bx=function(a,b){var c=a.a?zv(a.a):null;const d=a.a?Av(a.a):null;hu(a.m,c,d,b);c=b.variants;if(!c.some(ju))throw new _.H(_.G,4,4011);ex(a,b.variants);eu(c,a.configuration.restrictions,a.ue)&&a.a&&gw(a)==b&&Lw(a);if(!_.vh(2)&&(b=a.m?a.m.getDrmInfo():null))for(const e of c)for(const f of e.drmInfos)if(f.keySystem==b.keySystem)for(const g of f.initData||[])_.Mj(a.m,g.initDataType,g.initData)};Lw=function(a){const b=a.getTrackManager();b&&a.C!=uw&&(b.l&&(Fu(b),b.l.trigger(new _.F(_.xn))),jx(a))};
|
|
155
|
+
gw=function(a){const b=iv(a.w);let c=null;for(const d of a.f.periods)d.startTime<=b&&(c=d);return c};
|
|
156
|
+
nw=function(a,b){try{ex(a,b)}catch(d){return a.onError(d),null}b=b.filter(d=>ju(d));b=qu(b,a.Qa);var c=a.ua.create(b);c=Array.from(c.values());a.g.setVariants(c);if(null!==a.L&&null!==a.Qa&&(c=c.find(d=>d.video.id==a.L&&d.audio.id==a.Qa),a.L=null,c))return c;if(a.configuration.abr.enabled||null===a.L)return a.g.chooseVariant();b=b.find(d=>null!==d.video&&d.video.id===a.L);return b?b:(a.log.warn("Selected video track not found. Falling back to ABR selection"),a.g.chooseVariant())};
|
|
157
|
+
gx=function(a){return a.m&&a.m.B?!0:a.D?a.D.getState()===Pw:!1};Kw=function(a,b){var c=nw(a,b.variants);a.Qa=c&&c.audio&&c.audio.id;c&&(jw(a,b,c,!0),kw(a,c,!0));(c=_.lu(b.textStreams,a.Z,a.ga)[0]||null)&&(a.configuration.streaming.alwaysStreamText||Du(a))&&(hw(a,b,c,!0),iw(a,c))};lw=function(a){const b=gw(a);return b&&Ku(a.K,b).variant};mw=function(a){const b=gw(a);if(null==b)return[];wx(a);return b.variants.filter(c=>ju(c))};
|
|
158
|
+
xx=function(a){const b=gw(a);if(null==b)return[];wx(a);return b.textStreams.filter(c=>!a.Hc.has(c))};hw=function(a,b,c,d){Lu(a.K,b,c);if(b=a.getTrackManager())Gu(b,c,d),c=b.za(),a=a.F.w,a.g!==c&&(a.g=c,a.a.push({timestamp:Date.now()/1E3,id:c.id,trackId:c.track.id,type:c.track.type,fromAdaptation:d,width:null,height:null,bandwidth:null}))};iw=function(a,b){a.P?a.R=b:_.Iv(a.a,b,!0,0)};
|
|
159
|
+
jw=function(a,b,c,d){var e=a.getTrackManager();if(e){var f=a.F.w;if(c.video){Gu(e,c.video,d);var g=e.fa(),h=f;h.h!==g&&(h.h=g,h.a.push({timestamp:Date.now()/1E3,id:g.id,trackId:g.track.id,type:g.track.type,fromAdaptation:d,width:g.width,height:g.height,bandwidth:g.bandwidth}))}c.audio&&(Gu(e,c.audio,d),e=e.xa(),f.f!==e&&(f.f=e,f.a.push({timestamp:Date.now()/1E3,id:e.id,trackId:e.track.id,type:e.track.type,fromAdaptation:d,width:null,height:null,bandwidth:e.bandwidth})))}Ku(a.K,b).variant=c};
|
|
160
|
+
kw=function(a,b,c,d){c=void 0===c?!1:c;d=void 0===d?0:d;a.P?(a.U=b,a.te=c,a.re=d):Jv(a.a,b,c,d)};
|
|
161
|
+
ex=function(a,b){a=a.m?_.lf(a.m.V):{};var c=Object.keys(a);c=c.length&&"00"==c[0];let d=!1,e=!1;const f=[],g=[];for(const h of b){b=[];h.audio&&b.push(h.audio);h.video&&b.push(h.video);for(const k of b)k.keyId&&((b=a[c?"00":k.keyId])?Jw.includes(b)&&(g.includes(b)||g.push(b)):f.includes(k.keyId)||f.push(k.keyId));h.allowedByApplication?h.allowedByKeySystem&&(d=!0):e=!0}if(!d)throw new _.H(_.G,4,4012,{hasAppRestrictions:e,missingKeys:f,restrictedKeyStatuses:g});};
|
|
162
|
+
wx=function(a){if(a.a&&a.f){var b=a.a;var c=b.h.get(_.u);b=c?b.g.periods[c.ob]:(c=b.h.get(_.Rb))?b.g.periods[c.ob]:null;c=gw(a);null!=b&&b==c&&(zv(a.a),Av(a.a),_.yv(a.a,_.r),Ku(a.K,c),Ku(a.K,c))}};dx=function(a){const b=a.getDuration(),c=a.getPosition();return a.h&&a.h.ended||(a.Hb||a.S===_.rk)&&1>=Math.abs(b-c)?_.rk:gx(a)||a.Ic?_.uk:a.h&&a.h.paused?_.Bk:_.Ck};
|
|
163
|
+
yx=function(a,b){a.P=!0;a.g.disable();a.log.debug("Choosing new streams after period changed");let c=nw(a,b.variants),d=_.lu(b.textStreams,a.Z,a.ga)[0]||null;a.U&&(b.variants.includes(a.U)&&(c=a.U),a.U=null);a.R&&(b.textStreams.includes(a.R)&&(d=a.R),a.R=null);c&&ix(a,b,()=>jw(a,b,c,!0));d&&(a.configuration.streaming.alwaysStreamText||Du(a))&&ix(a,b,()=>hw(a,b,d,!0));b===gw(a)&&jx(a);return a.configuration.streaming.alwaysStreamText||Du(a)?{variant:c,text:d}:{variant:c,text:null}};
|
|
164
|
+
ix=function(a,b,c){a.Ta.has(b)||a.Ta.set(b,[]);a.Ta.get(b).push(c)};jx=function(a){const b=gw(a);if(b){const c=a.Ta.get(b)||[];for(a.Ta.delete(b);c.length;)c.shift()()}};hx=function(a,b){for(const c of a.f.periods)if(c.variants.includes(b))return c;return null};
|
|
165
|
+
zx=function(a,b,c){return _.v(function*(){let d;try{d=yield _.qm(b.url,a.getNetworkEngine(),a.configuration.manifest.attemptParameters,b.type);d.configure(a.configuration.manifest);var e=yield d.start(b.url,Hw(a));ew(e.periods);if(!e.periods.length)throw new _.H(_.G,4,4014);yield a.B.stop();a.B=d;const f=c.audio&&c.audio.id,g=c.video&&c.video.id;a.f.periods=e.periods;const h=gt(e.periods,iv(a.w))||e.periods[0];cu(a.f,_.Jg(a.configuration.preferredVideoCodec),_.Jg(a.configuration.preferredAudioCodec),
|
|
166
|
+
a.configuration.preferredAudioChannelCount);const k=ru(f,g,h.variants),l=_.lu(h.textStreams,a.Z,a.ga)[0]||null;nw(a,h.variants);const m=k&&k.video,n=k&&k.audio;e=[];const q=new Set;for(const t of h.variants)t.video&&q.add(t.video),t.audio&&q.add(t.audio);for(const t of[...q,...h.textStreams])e.push(t.createSegmentIndex());yield Promise.all(e);dw(a.a,_.Rb,n);dw(a.a,_.u,m);dw(a.a,_.r,l);k&&jw(a,h,k,!1);a.log.info("Switch CDN successful.")}catch(f){throw d&&(yield d.stop()),f;}})};
|
|
167
|
+
Ax=function(){const a=MediaSource.isTypeSupported,b=/^dv(?:h[e1]|a[v1])\./;MediaSource.isTypeSupported=c=>{var d=c.split(/ *; */),e=d.shift();const f={};for(var g of d)d=g.split("\x3d"),f[d[0]]=d[1].replace(/"(.*)"/,"$1");g=f.codecs;if(!g)return a(c);let h=!1,k=!1;c=g.split(",").filter(l=>{b.test(l)&&(k=!0);/^(hev|hvc)1\.2/.test(l)&&(h=!0);return!0});k&&(h=!1);f.codecs=c.join(",");h&&(f.eotf="smpte2084");for(const l in f)e+="; "+l+'\x3d"'+f[l]+'"';return cast.__platform__.canDisplayType(e)}};
|
|
168
|
+
Bx=function(){const a=MediaSource.isTypeSupported;MediaSource.isTypeSupported=b=>"mp2t"==b.split(/ *; */)[0].split("/")[1].toLowerCase()?!1:a(b)};Cx=function(){const a=MediaSource.prototype.addSourceBuffer;MediaSource.prototype.addSourceBuffer=function(...b){b=a.apply(this,b);b.abort=function(){};return b}};Dx=function(){const a=SourceBuffer.prototype.remove;SourceBuffer.prototype.remove=function(b,c){return a.call(this,b,c-.001)}};
|
|
169
|
+
Ex=function(){const a=MediaSource.isTypeSupported;MediaSource.isTypeSupported=b=>"opus"!=_.Es(b)[0]&&a(b)};Fx=function(a,b){const c=a.mode;a.mode=c==_.Yd?_.Yd:_.Sc;const d=a.cues;for(let e=d.length-1;0<=e;e--){const f=d[e];f&&b(f)&&a.removeCue(f)}a.mode=c};
|
|
170
|
+
_.rw=class{constructor(a){this.m=a;this.log=new _.O("clpp.renditions");this.f=[];this.j=this.a=null;this.h=!1}track(a){null!=this.a&&(this.a&&(this.a.off(_.Ud,this.g),this.h&&this.a.off(_.me,this.g)),this.a=null);a&&(this.a=a,this.a.on(_.Ud,this.g,this))}append(a,b,c){const d=this.m?this.m(c):null;d||this.log.debug("Unable to resolve rendition for id",c);c={start:a,end:b,rendition:d,width:d?d.width:0,height:d?d.height:0,bandwidth:d?d.bandwidth:0};const e=this.f.find(f=>f.start>=a&&f.end<=b);if(e)e.rendition=
|
|
171
|
+
d,e.width=c.width,e.height=c.height,e.bandwidth=c.bandwidth,e.start=c.start,e.end=c.end;else{for(const f of this.f)a>=f.start&&a<f.end?f.end=a:b>=f.start&&b<f.end&&(f.start=b);this.f.push(c);this.f.sort(Ns)}Qs(this);this.g();this.a&&this.a.trigger(new _.F(_.Ce))}clear(){this.f=[];Qs(this);this.a&&(this.a.trigger(new _.F(_.Ce)),this.a.trigger(new _.F(_.Wb)))}g(){if(this.a){var a=this.a.getPosition();if(0<=a){a:{var b=this.f.length,c=Number.MAX_SAFE_INTEGER;for(var d=0;d<b;d++){const e=this.f[d];c=
|
|
172
|
+
Math.min(e.start,c);if(e.start<=a&&e.end>a){a=.1>e.end-a&&d<b-1?this.f[d+1].rendition:e.rendition;break a}if(e.start>a)break}a=0<b&&c>a&&.25>c-a?this.f[0].rendition:null}if(a&&this.j!==a&&(this.j=a,this.a)){c=b=-1;if(a)b=a.width||-1,c=a.height||-1;else if(d=this.a.getSurface().getMedia())b=d.videoWidth,c=d.videoHeight;this.a.trigger(new _.F(_.Yb,{detail:{width:b,height:c,bandwidth:a?a.bandwidth:null,rendition:a}}))}}}}};ct=[154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149];
|
|
173
|
+
Zs=[237,239,139,169,121,214,74,206,163,200,39,220,213,29,33,237];Ws=[112,115,115,104,0,0,0,0];Gx=class{constructor(a,b,c){this.h=new Uint8Array(a);this.a=b;this.f=c}};Ys=class extends Gx{};bt=class extends Gx{constructor(a,b,c,d,e,f){f=void 0===f?null:f;super(a,b,d);this.version=e;this.g=c;this.j=f}};_.Hx=class{constructor(a){this.g=Math.exp(Math.log(.5)/a);this.f=this.a=0}};_.Ix=class{constructor(a,b,c,d,e){this.Ka=a;this.Fa=b;this.wa=c;this.keyInfo=d||null;this.Kb=_.y(e)?!1:!!e}a(){return this.keyInfo}};
|
|
174
|
+
_.st=class{constructor(a,b,c,d,e,f,g,h,k,l=null,m=null,n=null,q=null){this.position=a;this.startTime=b;this.endTime=c;this.qb=g;this.Ka=d;this.Fa=e;this.wa=f;this.keyInfo=h||null;this.Kb=_.y(k)?!1:!!k;this.timescale=l;this.horizontalTiles=m;this.verticalTiles=n;this.durationPerTile=q}getPosition(){return this.position}a(){return this.keyInfo}};
|
|
175
|
+
_.Jx=class{constructor(a,b,c,d){d=void 0===d?!1:d;this.m=a;this.Cd=b;this.Vb=this.h=Infinity;this.a=1;this.o=0;this.g=this.j=null;this.w=0;this.f=!0;this.B=!1;this.D=void 0===c?!0:c;this.A=new _.O("clpp.media.PresentationTimeline");this.C=d}getDuration(){return this.h}Fb(a){this.h=a}getPresentationStartTime(){return this.m}Sb(){return this.B}offset(a){null!=this.j&&(this.j+=a);null!=this.g&&(this.g+=a)}isLive(){return Infinity==this.h&&!this.f}};
|
|
176
|
+
Fw=class{constructor(){this.f=()=>{};this.a=new Set}release(){this.f=()=>{};this.a.clear()}cues(){return this.a}};
|
|
177
|
+
_.Kx=class{constructor(a){this.a=a;this.g=new _.O("clpp.media.SegmentIndex")}destroy(){this.a=[];return Promise.resolve()}h(a){for(var b=this.a.length-1;0<=b;--b){const c=this.a[b];if(a>=c.startTime&&a<c.endTime)return c.position}if(this.a.length&&a<this.a[0].startTime)return this.a[0].position;this.g.warn("No Segment found for "+a+". We have "+this.a.length+" references");for(a=0;a<this.a.length;a++)b=this.a[a],this.g.debug("SegmentIndex Ref "+a+" start: "+b.startTime+" end: "+b.endTime+" pos: "+
|
|
178
|
+
b.position);return null}get(a){if(0==this.a.length)return null;a-=this.a[0].position;return 0>a||a>=this.a.length?null:this.a[a]}offset(a){this.g.info("Apply offset"+a+" to segment index");for(const b of this.a)b.startTime+=a,b.endTime+=a,b.qb-=a}f(a,b){a-=this.a[0].position;if(0<=a&&a<this.a.length)for(this.g.warn("Accounting for segment duration drift",b,"at",a),this.a[a].endTime+=b,a+=1;a<this.a.length;++a)this.a[a].startTime+=b,this.a[a].endTime+=b}getDuration(){return this.a[this.a.length-1].endTime-
|
|
179
|
+
this.a[0].startTime}replace(a){this.a=a}};nx=class{constructor(a){this.f=a;this.a=new Set;this.g=(new _.rh(()=>{wt(this,!1)})).Pa(.25)}release(){this.g.stop();for(const a of this.a)a.release();this.a.clear()}};
|
|
180
|
+
mx=class{constructor(a){this.j=a;this.h=new Map;this.a=()=>{};this.f=()=>{};this.g=()=>{};this.o=[{$b:null,Zb:2,Ob:(b,c)=>this.a(b,c)},{$b:1,Zb:2,Ob:(b,c)=>this.a(b,c)},{$b:3,Zb:2,Ob:(b,c)=>this.a(b,c)},{$b:2,Zb:1,Ob:(b,c)=>this.f(b,c)},{$b:2,Zb:3,Ob:(b,c)=>this.f(b,c)},{$b:1,Zb:3,Ob:(b,c)=>this.g(b,c)},{$b:3,Zb:1,Ob:(b,c)=>this.g(b,c)}]}release(){this.j=null;this.h.clear();this.a=()=>{};this.f=()=>{};this.g=()=>{}}m(a,b){for(const c of this.j.cues()){const d=this.h.get(c)||null,e=a<c.startTime?1:
|
|
181
|
+
a>c.endTime?3:2;this.h.set(c,e);const f=this.o.find(g=>g.$b===d&&g.Zb===e);f&&f.Ob(c,b)}}};
|
|
182
|
+
Kt=class{constructor(a,b){this.o=null;this.B=a;this.g=b;this.h=this.w=0;this.j=Infinity;this.f=this.a=null;this.A="";this.m=new Map}destroy(){this.g=this.o=null;this.m.clear();return Promise.resolve()}remove(a,b){return Promise.resolve().then(()=>{!this.g||!this.g.remove(a,b)||null==this.a||b<=this.a||a>=this.f||(a<=this.a&&b>=this.f?this.a=this.f=null:a<=this.a&&b<this.f?this.a=b:a>this.a&&b>=this.f&&(this.f=a))})}fb(){return this.a}pa(){return this.f}Qb(a){return null==this.a||null==this.f?!1:a>=
|
|
183
|
+
this.a&&a<this.f}va(a){return null==this.f||this.f<a?0:this.f-Math.max(a,this.a)}};Bw=class{constructor(){this.a=new muxjs.mp4.CaptionParser;this.j=[];this.h={}}init(a){const b=muxjs.mp4.probe;a=_.L(a);this.j=b.videoTrackIds(a);this.h=b.timescale(a);this.a.init()}g(a,b){a=_.L(a);(a=this.a.parse(a,this.j,this.h))&&a.captions&&b(a.captions);this.a.clearParsedCaptions()}f(){this.a.resetCaptionStream()}};_.Cw=class{init(){}g(){}f(){}};var Lx=class{constructor(){this.a=new muxjs.mp4.Transmuxer({keepOriginalTimestamps:!0,remux:!1});this.f=null;this.m=[];this.j=[];this.g=[];this.h=!1;this.a.on("data",this.w.bind(this));this.a.on("done",this.o.bind(this))}destroy(){this.a&&(this.a.dispose(),this.a=null);return Promise.resolve()}w(a){this.g=a.captions;const b=new Uint8Array(a.data.byteLength+a.initSegment.byteLength);b.set(a.initSegment,0);b.set(a.data,a.initSegment.byteLength);a.type===_.u?this.m.push(b):a.type===_.Rb&&this.j.push(b)}o(){const a=
|
|
184
|
+
{video:_.mi(...this.m),captions:this.g,audio:_.mi(...this.j)};this.f.resolve(a);this.h=!1}};var It;
|
|
185
|
+
_.Dw=class{constructor(a,b,c,d,e){this.j=a;this.B=c;this.f={};this.K=!1;this.g=null;this.h={};this.o=new _.cn;this.I=!1;this.A={};this.F=b;this.C=d;this.L=e;this.V=this.L.streaming.maxSegmentToMediaOffset||1;this.H=new _.Hj;this.D={};this.m=Jt(this,this.H);this.a=new _.O("clpp.mse.MediaSourceEngine")}destroy(){this.I=!0;const a=[];for(const c in this.h){const d=this.h[c];var b=d[0];this.h[c]=d.slice(0,1);b&&a.push(b.p.catch(Ks));for(b=1;b<d.length;++b)d[b].p.catch(Ks),d[b].p.reject()}this.g&&a.push(this.g.destroy());
|
|
186
|
+
this.B&&a.push(this.B.destroy());for(const c in this.A)a.push(this.A[c].destroy());return Promise.all(a).then(()=>{this.o&&(this.o.release(),this.o=null);this.j&&(this.j.removeAttribute("src"),this.j.load(),this.j=null);this.B=this.g=this.m=null;this.f={};this.A={};this.D={};this.F=null;this.K=!1;for(const c in this.h);this.h={}})}init(a,b){const c=this;return _.v(function*(){yield c.H;a.forEach((d,e)=>{var f=_.Ig(d.mimeType,d.codecs);if(e==_.r)Lt(c,f);else{let g=new Map;g.set(e,f);if((!MediaSource.isTypeSupported(f)||
|
|
187
|
+
!b||d.keyInfo)&&Ft(f,e)){c.A[e]=new Lx;f="aac"==f.toLowerCase().split(";")[0].split("/")[1]?f.replace(/aac/i,_.md):Et(e,f);d=f;f=new Map;f.set(e,d);try{const h=d.match(/"(.*?)"/)[0].replace(/"/g,"").split(","),k=new Map;if(1<h.length)for(const l of h)l.startsWith("avc")?k.set(_.u,`video/mp4;codecs="${l}"`):l.startsWith("mp4a")&&k.set(_.Rb,`audio/mp4;codecs="${l}"`);g=0<k.size?k:f}catch(h){g=f}}Mt(c,g)}})})}fb(a){return a===_.r?this.g.fb():(a=Ot(this,a))?a.fb():null}pa(a){return a===_.r?this.g.pa():
|
|
188
|
+
(a=Ot(this,a))?a.pa():null}Qb(a,b,c){return a===_.r?this.g.Qb(b):(a=Ot(this,a))?a.Qb(b,!1,c):!1}va(a,b){return a===_.r?this.g.va(b):(a=Ot(this,a))?a.va(b):0}remove(a,b,c){return a===_.r?this.g.remove(b,c):St(this,a,this.R.bind(this,a,b,c)).then(()=>{if(a===_.u){var d=this.fb(a);const e=this.pa(a);null!==d&&null!==e&&Rs(this.C,d,e)}else a===_.Rb&&(d=this.C,d.a&&d.a.trigger(new _.F(_.Wb)))})}clear(a){if(a==_.r){if(!this.g)return Promise.resolve();this.F.f();return this.g.remove(0,Infinity)}return St(this,
|
|
189
|
+
a,this.R.bind(this,a,0,this.m.duration))}flush(a){return a==_.r?Promise.resolve():St(this,a,this.P.bind(this,a))}endOfStream(a){return Xt(this,()=>{Nt(this)||(a?this.m.endOfStream(a):this.m.endOfStream())})}Fb(a){Xt(this,()=>{this.m.duration=a})}getDuration(){return this.m.duration}J(a,b){this.a.debug("Appending data to "+a+Yr);try{this.f[a].appendBuffer(b)}catch(c){throw this.a.warn("Failed to append data for "+a,c),c;}this.a.debug("Done Appending data to "+a+Yr)}R(a,b,c){if(c<=b)this.w(a);else{this.a.debug("Removing data from "+
|
|
190
|
+
a+" range:",b,c);try{this.f[a].remove(b,c)}catch(d){throw this.a.warn("Failed to remove data from "+a+" buffer. Range:",b,c,d),d;}this.a.debug("Done Removing data from "+a+" range:",b,c)}}U(a){try{this.a.debug("Aborting operations for "+a+Yr);const b=this.f[a].appendWindowStart,c=this.f[a].appendWindowEnd;this.f[a].abort();this.f[a].appendWindowStart=b;this.f[a].appendWindowEnd=c}catch(b){throw this.a.warn("Failed to abort operations for "+a+Yr,b),b;}this.a.debug("Done Aborting operations for "+a+
|
|
191
|
+
Yr);this.w(a)}P(a){try{this.j.readyState>HTMLMediaElement.HAVE_NOTHING?(this.a.debug("Flushing buffer for "+a),this.j.currentTime-=.001):this.a.warn("Skip buffer flush for "+a+" with element state: "+this.j.readyState)}catch(b){throw this.a.warn("Failed to flush buffer for "+a,b),b;}this.a.debug("Done Flushing buffer for "+a);this.w(a)}S(a,b){0>b&&(b+=.001);try{this.a.debug("Setting timestamp offset for "+a,b),this.f[a].timestampOffset=b}catch(c){throw this.a.warn("Failed to set timestamp offset for "+
|
|
192
|
+
a,b,c),c;}this.a.debug("Done Setting timestamp offset for "+a,b);this.w(a)}Z(a,b,c){try{this.a.debug("Setting append window for "+a,b,c),this.f[a].appendWindowStart=0,this.f[a].appendWindowEnd=c,this.f[a].appendWindowStart=b}catch(d){throw this.a.warn("Failed to set append window for "+a,b,c,d),d;}this.a.debug("Done Setting append window for "+a,b,c);this.w(a)}T(a){this.h[a][0].p.reject(new _.H(_.G,3,3014,{mediaError:this.j.error?this.j.error.code:0}))}w(a){const b=this.h[a][0];b&&(b.p.resolve(),
|
|
193
|
+
this.a.debug("Update-End received for "+a),Wt(this,a))}getTextDisplayer(){return this.B}};It=window.URL.createObjectURL;var T=class extends _.P{constructor(){super();this.g=new _.O("cl.api.mse.TrackManager");this.l=null;this.h=[];this.a=new Map;this.f=new Map}j(a){this.l=a}release(){this.h=[];this.a.clear();this.f.clear()}load(){}destroy(){this.release();this.l=null}getVideoTracks(){return su(this,_.K)}getAudioTracks(){return su(this,_.J)}ea(){return su(this,_.I)}fa(){return this.a.get(_.K)||null}xa(){return this.a.get(_.J)||null}za(){return this.a.get(_.I)||null}Ia(){return this.f.get(_.K)||null}Ua(){return this.f.get(_.J)||
|
|
194
|
+
null}Va(){return this.f.get(_.I)||null}Aa(){return tu(this,_.K)}ha(){return tu(this,_.J)}ia(){return tu(this,_.I)}Na(a){vu(this,_.K,a)}ka(a){vu(this,_.J,a)}ta(a){vu(this,_.I,a)}Ma(a,b){uu(this,_.K,a,void 0===b?!1:b)}bb(a,b){uu(this,_.J,a,void 0===b?!1:b)}cb(a,b){uu(this,_.I,a,void 0===b?!1:b)}addTextTrack(a){const b=this;return _.v(function*(){b.l&&(yield b.l.addTextTrack(a.url,a.language,a.kind,a.mimeType,a.codec,a.label))})}ja(){return!!this.l&&this.l.ja()}};T.prototype.isAbrEnabled=T.prototype.ja;
|
|
195
|
+
T.prototype.addTextTrack=T.prototype.addTextTrack;T.prototype.setTextRendition=T.prototype.cb;T.prototype.setAudioRendition=T.prototype.bb;T.prototype.setVideoRendition=T.prototype.Ma;T.prototype.setTextTrack=T.prototype.ta;T.prototype.setAudioTrack=T.prototype.ka;T.prototype.setVideoTrack=T.prototype.Na;T.prototype.getTextTrack=T.prototype.ia;T.prototype.getAudioTrack=T.prototype.ha;T.prototype.getVideoTrack=T.prototype.Aa;T.prototype.getLoadingTextRendition=T.prototype.Va;
|
|
196
|
+
T.prototype.getLoadingAudioRendition=T.prototype.Ua;T.prototype.getLoadingVideoRendition=T.prototype.Ia;T.prototype.getTextRendition=T.prototype.za;T.prototype.getAudioRendition=T.prototype.xa;T.prototype.getVideoRendition=T.prototype.fa;T.prototype.getTextTracks=T.prototype.ea;T.prototype.getAudioTracks=T.prototype.getAudioTracks;T.prototype.getVideoTracks=T.prototype.getVideoTracks;var Mx=class{constructor(){this.f=new _.Hx(2);this.g=new _.Hx(5);this.a=0}};_.Sw=class{constructor(){this.f=new _.O("clpp.abr");this.w=null;this.j=!1;this.g=new Mx;this.o=[];this.m=1;this.B=this.A=!1;this.a=this.h=null}stop(){this.w=null;this.j=!1;this.o=[];this.m=1;this.h=null;this.B=!1}init(a){this.w=a}chooseVariant(){var a=Iu(!this.B&&this.a.initialRestrictions?this.a.initialRestrictions:this.a.restrictions,this.o);const b=Hu(this.g,this.a.defaultBandwidthEstimate);this.o.length&&!a.length&&(this.f.warn("No variants met the ABR restrictions. Choosing a variant by lowest bandwidth."),
|
|
197
|
+
a=Iu(null,this.o),a=[a[0]]);let c=a[0]||null;for(const {item:e,next:f}of _.ys(a)){var d=isNaN(this.m)||0===this.m?1:Math.abs(this.m);a=d*e.bandwidth;const g=a/this.a.bandwidthDowngradeTarget;d=d*(f||{bandwidth:Infinity}).bandwidth/this.a.bandwidthUpgradeTarget;this.f.debug("Bandwidth ranges:",(a/1E6).toFixed(3),(g/1E6).toFixed(3),(d/1E6).toFixed(3));b>=g&&b<=d&&(c=e)}this.h=Date.now();this.B=!0;return c}enable(){this.j=!0}disable(){this.j=!1}segmentDownloaded(a,b){this.f.debug("Segment downloaded:",
|
|
198
|
+
"deltaTimeMs\x3d"+a,"numBytes\x3d"+b,"lastTimeChosenMs\x3d"+this.h,"enabled\x3d"+this.j);var c=this.g;if(!(16E3>b)){var d=8E3*b/a;a/=1E3;c.a+=b;_.ht(c.f,a,d);_.ht(c.g,a,d)}if(null!=this.h&&this.j)a:{this.f.debug("Suggesting Streams...");if(!this.A){if(!(128E3<=this.g.a)){this.f.debug("Still waiting for a good estimate...");break a}this.A=!0;if(this.a.useSwitchIntervalForInitialSwitch&&Date.now()-this.h<1E3*this.a.switchInterval){this.f.debug("Skipping initial estimation switch due to switch interval...");
|
|
199
|
+
break a}}else if(Date.now()-this.h<1E3*this.a.switchInterval){this.f.debug("Still within switch interval...");break a}b=this.chooseVariant();this.f.debug("Calling switch_(), bandwidth\x3d"+Math.round(Hu(this.g,this.a.defaultBandwidthEstimate)/1E3)+" kbps");this.w(b)}}playbackRateChanged(a){this.m=a}getBandwidthEstimate(){return Hu(this.g,this.a.defaultBandwidthEstimate)}setVariants(a){this.o=a}configure(a){this.a=a}reset(){this.A=!1;this.g=new Mx;const a=this.chooseVariant();a&&this.w(a)}};var Nx=class{constructor(){this.a=new Map}clear(){this.a.clear()}},Ju=class{constructor(){this.text=this.variant=null}};var Ox=class{constructor(a,b){this.f=a;this.a=new Set([a]);b=b||[];for(const c of b)this.add(c)}add(a){if(Ou(this.f,a))return this.a.add(a),!0;_.z("Rejecting variant - not compatible with root.");return!1}values(){return this.a.values()}};var pw=class{constructor(a){this.a=a;this.f=new Uw(a.language,"",a.audio&&a.audio.channelsCount?a.audio.channelsCount:0)}create(a){const b=a.filter(c=>Ou(this.a,c));return b.length?new Ox(b[0],b):this.f.create(a)}},Uw=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}create(a){var b=[];b=Pu(a,this.g);const c=a.filter(d=>d.primary);b=b.length?b:c.length?c:a;this.f&&(a=Qu(b,this.f),a.length?b=a:_.z("No exact match for variant role could be found."));this.a&&(a=Zt(b,this.a),a.length?b=a:_.z("No exact match for the channel count could be found."));
|
|
200
|
+
a=new Ox(b[0]);for(const d of b)Ou(a.f,d)&&a.add(d);return a}};var ux=class{constructor(a,b){this.a=fx;this.f=(new Map).set(fx,b).set(Pw,a)}getState(){return this.a}},Pw=0,fx=1;var Yw=class{constructor(a){this.f=a;this.a=a.getConfiguration().streaming;this.h=new _.cn;this.g=new _.O("clpp.mse.media.LiveEdgeObserver");Ru(this)&&(a=this.f.getSurface().getMedia(),this.h.on(a,_.me,()=>{{var b=this.f.getPosition();const c=this.f.getSeekRange().end;b=c-b;const d=this.f.getPlaybackRate(),e=this.a.stopChasingAt;1<=d&&b>=this.a.chaseJumpDistance?(this.g.debug("Too far from edge, jump to beginning."),this.f.setPlaybackRate(1),this.f.seek(c)):1===d&&b>=this.a.startChasingAt?(this.g.debug("Not on live edge, increase playback rate."),
|
|
201
|
+
this.f.setPlaybackRate(this.a.chasingRate)):1<d&&b<=e&&(this.g.debug("On live edge, reduce playback rate."),this.f.setPlaybackRate(1))}}))}release(){this.h.release()}};var lx=class{constructor(a){this.g=a;this.a=null;this.f=()=>{}}release(){this.a=this.g=null;this.f=()=>{}}m(a){const b=this.a;{const c=this.g.periods;a=gt(c,a)||c[0]}b!=a&&this.f(a);this.a=a}};var Xw=class{constructor(a){this.a=a;this.h=!1;this.g=this.a.fd();this.f=new _.rh(()=>{this.a.gf(.25*this.g)})}release(){this.f&&(this.f.stop(),this.f=null);this.a=null}set(a){this.g=a;Tu(this)}};var cv=class{constructor(a,b){this.g=a;this.j=Vu(a);this.a=a.a.currentTime;this.h=Date.now()/1E3;this.m=b;this.f=()=>{}}release(){this.g=null;this.f=()=>{}}},dv=class{constructor(a){this.a=a}};var Px=class{constructor(a,b,c,d,e){this.a=a;this.C=b;this.j=c;this.B=e;this.g=new _.cn;this.A=!1;this.F=a.readyState;this.h=!1;this.f=d;this.m=this.D=this.w=!1;this.g.on(a,_.He,()=>Wu(this));this.o=(new _.rh(()=>{Wu(this)})).Pa(.25)}release(){this.g&&(this.g.release(),this.g=null);null!=this.o&&(this.o.stop(),this.o=null);this.f&&(this.f.release(),this.f=null);this.a=this.C=this.B=null;this.m=!1}Nc(){this.w=!0;Wu(this)}};var Rx=class{constructor(a,b,c,d){this.a=a;this.h=b;this.m=d;this.w=c;this.j=!1;this.f=new _.cn;this.g=new Qx(a,10);this.o=!1;0<a.readyState?Zu(this,c):$u(this,c)}release(){this.f&&(this.f.release(),this.f=null);null!=this.g&&(this.g.release(),this.g=null);this.h=()=>{};this.a=null;this.m=()=>{};this.o=!1}},Qx=class{constructor(a,b){this.f=a;this.m=b;this.j=this.g=this.h=0;this.a=new _.rh(()=>{0>=this.h?(_.z(["Failed to move playhead from",this.g,"to",this.j].join(" ")),this.a.stop()):this.f.currentTime!=
|
|
202
|
+
this.g?this.a.stop():(this.f.currentTime=this.j,this.h--)})}release(){this.a&&(this.a.stop(),this.a=null);this.f=null}};var kx=class{constructor(a,b,c,d,e,f){this.h=a;this.a=b.presentationTimeline;this.B=b.minBufferTime||0;this.m=c;this.A=e;this.w=null;this.j=new Px(a,b.presentationTimeline,c,ev(this,a,c),f);this.g=new Rx(a,()=>{a:{var g=this.j;g.A=!0;g.w=!1;g.h=!1;g=av(this.g);const h=jv(this,g);if(.001<Math.abs(h-g)){const k=(new Date).getTime()/1E3;if(!this.w||this.w<k-1){this.w=k;bv(this.g,h);g=void 0;break a}}this.f.debug("Seek to "+g);this.A();g=void 0}return g},hv(this,d),()=>{this.j.D=!0});this.o=(new _.rh(()=>
|
|
203
|
+
{if(0!=this.h.readyState&&!this.h.paused){var g=av(this.g),h=qt(this.a,0),k=pt(this.a);3>k-h&&(h=k-3);g<h&&(h=jv(this,g),this.f.info("Jumping forward "+(h-g)+" seconds to catch up with the seek range."),this.h.currentTime=h)}})).Pa(.25);this.f=new _.O("clpp.mse.Playhead")}release(){this.g&&(this.g.release(),this.g=null);this.j&&(this.j.release(),this.j=null);this.o&&(this.o.stop(),this.o=null);this.h=this.g=this.a=this.m=null;this.A=()=>{}}};var mv=new _.fo(()=>new Uint8Array([0,0,0,80,115,105,110,102,0,0,0,12,102,114,109,97,0,0,0,0,0,0,0,20,115,99,104,109,0,0,0,0,99,101,110,99,0,1,0,0,0,0,0,40,115,99,104,105,0,0,0,32,116,101,110,99,0,0,0,0,0,0,1,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));_.vx=class{constructor(a,b){this.f=b;this.g=a;this.m=null;this.B=1;this.H=Promise.resolve();this.o=[];this.w=new Map;this.h=new Map;this.J=this.j=this.A=this.C=!1;this.I=0;this.a=new _.O("clpp.mse.Streaming");this.F=!1;this.D=[]}destroy(){for(const a of this.h.values())qv(a);this.h.clear();this.w.clear();this.m=this.o=this.H=this.g=this.f=null;this.D=[];this.j=!0;return Promise.resolve()}start(){const a=this;return _.v(function*(){const b=a.f.kb();var c=rv(a,b);c=a.f.xd(a.g.periods[c]);if(!c.variant&&
|
|
204
|
+
!c.text)throw a.a.error("init: no Streams chosen"),new _.H(_.G,5,5005);a.F=!c.variant&&!!c.text;yield xv(a,c.variant?c.variant.audio:null,c.variant?c.variant.video:null,c.text,b);a.j||(a.a.debug("init: completed initial Stream setup"),a.f&&a.f.hf&&(a.a.debug("init: calling onInitialStreamsSetup()..."),a.f.hf()))})}K(a,b,c,d){const e=vs(d.G),f=vs(d.G),g=_.N(d.G),h=_.N(d.G),k=_.N(d.G),l=_.N(d.G);d=_.Ei(d.G,d.G.ya()-d.G.getPosition());a=a.startTime+b.startTime+h/g;c.includes(e)&&("urn:mpeg:dash:event:2012"==
|
|
205
|
+
e?this.f.qe():(c=new _.F("emsg",{detail:{startTime:a,endTime:a+k/g,schemeIdUri:e,value:f,timescale:g,presentationTimeDelta:h,eventDuration:k,id:l,messageData:d}}),this.f.onEvent(c)))}L(a){let b=!1,c=0;(new _.Yn).M(_.ld,_.mj).M(_.ne,_.mj).M(_.gd,_.mj).M(_.kd,_.mj).M(_.de,_.mj).W(_.fe,_.nj).M("encv",d=>{d.G.skip(78);_.mj(d)}).M("pasp",d=>{c=d.start+d.jd;const e=_.N(d.G),f=_.N(d.G);b=e!==f;this.a.debug(`hSpacing=${e}, vSpacing=${f}, updatePASP=${b}`);d.Za.stop()}).parse(a.data);b&&(a=new _.Li(new DataView(a.data)),
|
|
206
|
+
a.seek(c),_.M(a,1),_.M(a,1))}};var Sx=class extends _.Jn{constructor(a){super(ks);this.C=zw;this.h=null;this.qd=0;this.ke=2;this.Ib=null;this.ld=!1;this.j=new _.cn;this.ca=this.hc=this.Ra=this.Sa=this.w=this.H=this.m=null;this.Hb=!1;this.g=this.f=this.B=this.a=this.ma=this.D=null;this.we=1E9;this.Hc=new Set;this.P=!0;this.U=null;this.te=!1;this.re=0;this.R=null;this.K=new Nx;this.ue={width:Infinity,height:Infinity};this.F=null;this.S=_.zk;this.ua=new Uw(this.configuration.preferredAudioLanguage,this.configuration.preferredAudioRole,
|
|
207
|
+
this.configuration.preferredAudioChannelCount);this.Z=this.configuration.preferredTextLanguage;this.L=this.Qa=null;this.Ta=new Map;this.V=null;this.ga=this.configuration.preferredTextRole;a&&a(this);this.od=null;this.j.on(window,"online",()=>{this.C==fw&&bw(this.a)})}init(a,b){const c=a.getMedia();super.init(a,b);qw(this,c)}namespace(){return ks}le(){return new T}getState(){return this.S}getDrmInfo(){return this.m?this.m.getDrmInfo():null}unload(){xu(this,!1);this.Hb=!1;if(this.o){const a=this.getTrackManager();
|
|
208
|
+
a&&a.release();return this.C==uw?Promise.resolve():yw(this).then(()=>{this.log.debug(_.Ua,this.o);this.o=null;this.qd=0;this.L=this.Qa=null})}return Promise.resolve()}release(){return super.release().then(()=>this.unload()).then(()=>tw(this,_.zk))}getBufferInfo(a){if(this.H){var b=Pt(this.H);const c=new _.yn(void 0,a);switch(a){case _.K:return b.video?b.video:c;case _.J:return b.audio?b.audio:c;case _.I:return b.text?b.text:c}return b.total?b.total:c}return this.Ib?(b=Os(this.Ib),Gs(b,a)):super.getBufferInfo(a)}getPosition(){return this.w?
|
|
209
|
+
iv(this.w):super.getPosition()}getPresentationStartTime(){return this.f?this.f.presentationTimeline.getPresentationStartTime()||0:0}getDuration(){return this.f?this.f.presentationTimeline.getDuration():Infinity}destroy(){const a=this,b=()=>Object.getPrototypeOf(Object.getPrototypeOf(this)).destroy;return _.v(function*(){yield b().call(a);a.C!=uw&&(a.log.debug("Destroying player..."),a.C=uw,yield ww(a),a.j&&(a.j.release(),a.j=null),a.g=null)})}load(a){const b=this;return _.v(function*(){if(b.C==uw)return Promise.reject(new _.H(_.G,
|
|
210
|
+
7,7E3));b.F=new _.eo;b.od=Date.now()/1E3;tw(b,_.Ak);b.o=_.Fk(a);_.Zh(a)&&(b.configuration=_.Yh(b.ac,a));b.log.info(_.Fa,b.configuration);b.log.info(_.Ra,b.o);var c=b.getTrackManager();c&&c.load();c=b.getSurface().getMedia();c.loop=!!b.configuration.loop;_.y(b.configuration.volume)||b.setVolume(b.configuration.volume);_.y(b.configuration.muted)||b.setMuted(b.configuration.muted);b.B&&b.B.configure(b.configuration.manifest);b.m&&Mw(b);if(b.a){b.a.m=b.configuration.streaming;try{for(var d of b.f.periods)bx(b,
|
|
211
|
+
d)}catch(g){b.onError(g)}var e=zv(b.a);const f=Av(b.a);d=gw(b)||b.f.periods[0];e=mu(e,f,d.variants);b.g&&e&&e.allowedByApplication&&e.allowedByKeySystem?nw(b,d.variants):(b.log.debug("Choosing new streams after changing configuration"),Kw(b,d))}b.g&&(b.g.configure(b.configuration.abr),b.configuration.abr.enabled&&!b.P?b.g.enable():b.g.disable());d=b.o[b.getSourceIndex()];try{yield qw(b,c),yield xw(b,c),yield Ew(b,d),yield Iw(b,d),yield Ow(b),yield cx(b)}catch(f){throw b.onError(f),f;}})}isLive(){return this.f?
|
|
212
|
+
this.f.presentationTimeline.isLive():!1}ze(){this.log.debug("User seeking finished");this.D&&Qw(this);Rw(this)}getSeekRange(){if(this.f){const a=this.f.presentationTimeline;return{start:qt(a,0),end:pt(a)}}return{start:0,end:0}}getPlaybackRate(){if(this.Ra){var a=this.Ra;a=a.h?0:a.g}else a=0;return a}setPlaybackRate(a){if(0==a)this.log.warn("A trick play rate of 0 is unsupported!");else if(this.C==fw){this.Ra.set(a);this.g.playbackRateChanged(a);var b=this.a,c=1<Math.abs(a);if(a=b.h.get(_.u)){var d=
|
|
213
|
+
a.stream;if(d)if(b.a.debug("setTrickPlay",c),c)(c=d.trickModeVideo)&&!a.Cb&&(b.a.debug("Engaging trick mode stream",c),_.Iv(b,c,!1,0),a.Cb=d);else if(d=a.Cb)b.a.debug("Restoring non-trick-mode stream",d),a.Cb=null,_.Iv(b,d,!0,0)}}}ea(){if(this.f&&this.w){var a=gw(this);if(null==a)a=null;else{if(!Ku(this.K,a).text){var b=_.lu(a.textStreams,this.Z,this.ga);b.length&&Lu(this.K,a,b[0])}a=Ku(this.K,a).text}b=[];for(const c of xx(this)){const d=iu(c);d.active=c==a;b.push(d)}return b}return[]}getPeriods(){return this.f.periods}getStats(){if(this.C!=
|
|
214
|
+
fw)return _.jk();Rw(this);var a=this.h;if(a.getVideoPlaybackQuality){var b=a.getVideoPlaybackQuality();a=this.F;var c=Number(b.totalVideoFrames);a.h=Number(b.droppedVideoFrames);a.g=c}if(this.C==fw){if(b=lw(this))this.F.A=b.bandwidth;b&&b.video&&(a=this.F,c=b.video.height||NaN,a.j=b.video.width||NaN,a.f=c);a=this.g.getBandwidthEstimate();this.F.m=a}return this.F.getStats()}getTimelineCues(){return this.ma?[...this.ma.cues()].map(a=>({schemeIdUri:a.schemeIdUri,value:a.value,startTime:a.startTime,endTime:a.endTime,
|
|
215
|
+
id:a.id,eventElement:a.eventElement,type:a.type})):[]}resetAbr(){this.g&&this.g.reset()}addTextTrack(a,b,c,d,e,f){const g=this;return _.v(function*(){if(g.C!=fw)throw g.log.error("Must call load() and wait for it to resolve before adding text tracks."),Error("State error!");const h=gw(g);var k=g.f.periods.indexOf(h)+1;const l=(k>=g.f.periods.length?g.f.presentationTimeline.getDuration():g.f.periods[k].startTime)-h.startTime;if(Infinity==l)throw new _.H(1,4,4040);const m=new _.st(1,0,l,()=>[a],0,null,
|
|
216
|
+
0);k={id:g.we++,originalId:null,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:()=>1,getSegmentReference:q=>1==q?m:null,adjustSegmentDurations:()=>{},getDuration:()=>l,initSegmentReference:null,mimeType:d,codecs:e||"",kind:c,encrypted:!1,keyId:null,language:b,label:f||null,type:_.r,primary:!1,trickModeVideo:null,emsgSchemeIdUris:null,roles:[],channelsCount:null,closedCaptions:null};g.Hc.add(k);h.textStreams.push(k);yield Cv(g.a,k);const n=_.yv(g.a,_.r);n&&Lu(g.K,h,n);g.Hc.delete(k);
|
|
217
|
+
g.log.debug("Choosing new streams after adding a text stream");Kw(g,h);Lw(g);return iu(k)})}Bf(a){this.log.debug(_.ms,a);try{this.log.debug("onChooseStreams_, choosing variant from ",a.variants);this.log.debug("onChooseStreams_, choosing text from ",a.textStreams);const b=yx(this,a);this.log.debug("onChooseStreams_, chose variant ",b.variant);this.log.debug("onChooseStreams_, chose text ",b.text);return b}catch(b){return this.onError(b),{variant:null,text:null}}}Af(){this.log.debug("canSwitch_");
|
|
218
|
+
this.P=!1;this.configuration.abr.enabled&&this.g.enable();this.U&&(Jv(this.a,this.U,this.te,this.re),this.U=null);this.R&&(_.Iv(this.a,this.R,!0,0),this.R=null)}Cf(){this.B&&this.B.update&&this.B.update()}De(){this.w&&this.w.j.Nc()}zf(a,b){b=void 0===b?!1:b;const c=gw(this),d=c.variants.some(e=>{let f=!1;const g=e[a.type];g&&(f=e.allowedByApplication&&g.id!==a.id,a.type===_.Rb&&(f=f&&g.language===a.language));return f})&&(this.ja()||b);if(d){for(const e of c.variants){const f=e[a.type];f&&f.id===
|
|
219
|
+
a.id&&(e.allowedByApplication=!1)}Lw(this);!this.ja()&&b&&(this.configuration.abr.enabled=!0,this.g.enable());Kw(this,c)}return d}Df(){this.log.debug("endOfStream called by streaming engine");this.Hb=!0}onError(a){if(this.C!==uw&&7001!==a.code){var b=new _.F(_.Oc,{detail:a});a.severity===_.G&&tw(this,_.yk);this.trigger(b);b.defaultPrevented&&(b.a=!0)}}pd(a){a.type===_.Ic?this.dispatchEvent(a):"largegap"!==a.type&&(a.type===_.Ie?Aw(this):"emsg"!==a.type&&(a instanceof _.F?this.dispatchEvent(a):this.log.debug("Unhandled/ignored event",
|
|
220
|
+
a.type)))}ja(){return this.configuration.abr.enabled}Fe(a){const b=this;return _.v(function*(){if(b.da){b.log.info("Attempt to switch CDN.");var c=b.getLoadedSource(),d=b.ja();if(c=yield b.da(c.url,a)){c=_.af(b.getLoadedSource(),{url:c});d&&b.g.disable();yield cw(b.a);var e=lw(b);do{var f=!1;try{b.log.info(`Switching CDN to ${c.url}.`),yield zx(b,c,e)}catch(g){if(b.log.info("Switch failed"),f=yield b.da(c.url,a))c.url=f,f=!0;else throw g;}}while(f);d&&b.g.enable();bw(b.a,!0);b.o[b.getSourceIndex()]=
|
|
221
|
+
c;a.f=!0;b.trigger(new _.F(_.ic,{newManifest:c.url}))}}})}},uw=0,zw=1,fw=2,Jw=[_.Cd,_.Wc];_.Bf(new class{a(){return ks}canPlay(a,b){if(_.Eh())return 0;const c=a.type||"",d=window.MediaSource&&MediaSource.isTypeSupported?!0:!1;a=window.MediaSource&&MediaSource.isTypeSupported?c in _.rm||_.sm(a.url)in _.tm?!0:!1:!1;if(d&&a){if(_.vh(2))return 1;if(_.Fh()&&c===_.Pb){if(b.streaming.preferNativeHlsOnSafari)return 1;_.z("Support for MSE + FairPlay on Apple is experimental. In case of issues, consider using native HLS.")}return 2}return 0}create(){return new Sx}});_.kl(function(){_.C("MediaSource.install");if(window.MediaSource)if(window.cast&&cast.__platform__&&cast.__platform__.canDisplayType)_.xf("Patching Chromecast MSE bugs."),Ax();else if(_.Fh()){var a=navigator.appVersion;a=0<=a.indexOf("Version")?parseInt(a.match(/Version\/(\d+)/)[1],10):13;Bx();10>=a?(_.xf("Blacklisting MSE on Safari \x3c\x3d 10."),window.MediaSource=null):12>=a?(_.xf("Patching Safari 11 \x26 12 MSE bugs."),Cx(),Dx()):(_.xf("Patching Safari 13 MSE bugs."),Cx())}else _.vh(2)||_.vh(3)||
|
|
222
|
+
_.vh(4)?Ex():_.xf("Using native MSE as-is.");else _.xf("No MSE implementation available.")});var Tx=class extends _.So{constructor(a){super(a);a=a.getSurface().getMedia();this.a=null;for(let b=0;b<a.textTracks.length;++b){const c=a.textTracks[b];c.mode=_.Dc;c.label===es&&(this.a=c)}this.a||(this.a=a.addTextTrack(_.rs,es));this.a.mode=_.Sc}append(a){const b=[],c=d=>{if(d.startTime>=d.endTime)_.z("Invalid cue times: "+d.startTime+" - "+d.endTime),d=null;else{var e=d.payload||"";e=e.replace(/<br\s*\/?>/igm,"\n");e=_.sg(e);e=new VTTCue(d.startTime,d.endTime,e);e.line=-1;try{e.align=_.kc}catch(f){e.align=
|
|
223
|
+
"middle"}d.writingMode===_.ye?e.vertical="lr":d.writingMode===_.ze&&(e.vertical="rl");d=e}d&&b.push(d)};for(const d of a)c(d);a=b.slice().sort((d,e)=>d.startTime!==e.startTime?d.startTime-e.startTime:d.endTime!==e.endTime?d.endTime-e.startTime:b.indexOf(e)-b.indexOf(d));for(const d of a)this.a.addCue(d)}remove(a,b){if(!this.a)return!1;Fx(this.a,c=>c.startTime<b&&c.endTime>a);return!0}isTextVisible(){return this.a.mode==_.Yd}setTextVisibility(a){null!==this.a&&(this.a.mode=a?_.Yd:_.Sc)}destroy(){this.a&&
|
|
224
|
+
Fx(this.a,()=>!0);this.a=null;return Promise.resolve()}};var Ux=class{X(){return!0}create(a){return new Tx(a)}};Ux.prototype.create=Ux.prototype.create;Ux.prototype.isSupported=Ux.prototype.X;_.ck(_.Zd,new Ux);};f.call(g, window);
|
package/cl.muxdata.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Tr=function(a){let b={debug:!0,data:Sr(a)};a.g&&a.g.muxOptionsOverride&&_.df(a.g.muxOptionsOverride)&&(b=_.af(b,a.g.muxOptionsOverride,{getPlayheadTime:()=>1E3*a.l.getPosition(),getStateData:()=>{{a.f.debug("getStateData()");var c=a.l.getLoadedSource(),d=a.l.getTrackManager();const f=a.l.getSurface(),g=d.fa();var e={player_is_paused:a.l.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.l.getDuration(),player_autoplay_on:!!a.l.getConfiguration().autoplay};
|
|
2
|
+
if(c){const h=new _.Ji(c.url);e.video_source_url=_.Fi(h);e.video_source_mime_type=c.type;c.name&&(e.video_title=c.name)}if(c=f.getContainer())e.player_width=c.offsetWidth,e.player_height=c.offsetHeight;g&&g.height&&g.width&&(e.video_source_height=g.height,e.video_source_width=g.width);(d=d.ha())&&d.language&&(e.player_language_code=d.language)}return e}}));a.f.debug("Mux SDK options",b);return b},Ur=function(a,b,c){a.f.debug(`Event: ${b}`);mux.emit(a.A,b,c)},Sr=function(a){const b={env_key:a.g.envKey,
|
|
3
|
+
video_title:a.m&&a.m.name||"",player_software_name:_.la,player_software_version:_.da,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",player_mux_plugin_version:_.da};(a=a.l.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},Vr=function(a){a.a.on(a.l,_.me,()=>{Ur(a,_.me,{player_playhead_time:1E3*a.l.getPosition()})});a.a.on(a.l,_.Jd,()=>Ur(a,_.Jd));a.a.on(a.l,_.Yb,a.B.bind(a));a.a.on(a.l,_.be,a.D.bind(a));a.a.on(a.l,_.ve,()=>Ur(a,_.Xd));a.a.on(a.l,_.te,()=>Ur(a,_.Wd));a.a.on(a.l,
|
|
4
|
+
_.Oc,a.C.bind(a));a.a.on(a.l,_.mb,()=>Ur(a,"adbreakstart"));a.a.on(a.l,_.nb,()=>Ur(a,"adbreakend"));a.a.on(a.l,_.zb,()=>{Ur(a,"adplay");Ur(a,"adplaying")});a.a.on(a.l,_.vb,()=>Ur(a,"adpause"));a.a.on(a.l,_.xb,()=>{Ur(a,"adplay");Ur(a,"adplaying")});a.a.on(a.l,_.Ab,()=>Ur(a,"adended"));a.a.on(a.l,_.rb,()=>Ur(a,"adfirstquartile"));a.a.on(a.l,_.ub,()=>Ur(a,"admidpoint"));a.a.on(a.l,_.Bb,()=>Ur(a,"adthirdquartile"))},Wr=class{constructor(a,b){this.l=a;this.m=this.g=null;this.A=("000000"+(Math.random()*
|
|
5
|
+
Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.cn;this.f=b;this.o=this.j=this.h=this.w=!1}release(){this.f.debug("release()");this.j?this.f.debug(_.ha):(_.Df(this.a),this.j=!0,this.m=this.g=null)}destroy(){this.f.debug(_.Cc);this.o?this.f.debug(_.fa):(this.o=!0,this.h&&this.w&&Ur(this,"viewend"),Ur(this,"destroy"))}B(a){this.f.debug(_.sd);var b=a.detail;a=this.l.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.xa())&&a.bandwidth&&(b+=a.bandwidth),Ur(this,"renditionchange",{video_source_bitrate:b}))}D(a){this.f.debug(_.xd);
|
|
6
|
+
switch(a.detail.currentState){case _.Ak:this.l.getConfiguration().autoplay&&Ur(this,_.Jd);break;case _.Ck:Ur(this,_.Kd);break;case _.Bk:Ur(this,_.Fd);break;case _.rk:this.w=!0,Ur(this,_.Nc)}}C(a){this.f.debug(_.ud);if(this.h&&(a=a.detail||null))if(10003===a.code)Ur(this,"aderror");else if(a.severity===_.G){var b=a.message||"Player error";if(1===a.category||6100===a.code||6007===a.code)b="Download error",6100===a.code?b="Certificate request error":6007===a.code&&(b="License request error"),b=`${b} castlabs-error-data:${JSON.stringify(a.data)}`;
|
|
7
|
+
Ur(this,_.Oc,{player_error_code:a.code,player_error_message:b})}}};var Xr=class extends _.Uo{constructor(){super();this.f=null;this.a=!1;this.g=new _.O("clpp.muxdata")}onPlayerCreated(a){this.f=new Wr(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();if(this.a=!_.y(c.muxdata)&&typeof c.muxdata===_.rd){var d=c.muxdata;if(c="undefined"===typeof window.mux)c=d.muxLib,d="undefined"!==typeof c&&typeof c.init===_.Qc&&typeof c.emit===_.Qc,window.mux=c,c=d,c=!c;c&&(this.g.warn("Mux SDK is not loaded. Will do nothing."),this.a=!1,c=new _.H(1,9,9301),this.T(a,c))}else this.g.warn("Mux plugin is loaded but not configured. Will do nothing.");
|
|
8
|
+
if(this.a){c=a.getConfiguration();c=_.bf(c.muxdata||{});try{d=[];typeof c===_.rd&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.H(1,9,9300,{missingKeys:d});var e=this.f;e.g=c;e.m=b;e.w=!1;if(!e.h){try{e.h=!0,mux.init(e.A,Tr(e))}catch(f){throw e.h=!1,_.Df(e.a),new _.H(1,9,9302,null,f);}Ur(e,"playerready")}e.j&&!e.o&&(Ur(e,"videochange",Sr(e)),e.j=!1);Vr(e)}catch(f){this.a=!1,this.T(a,f)}}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.f=null)}onPlayerWillRelease(){this.a&&
|
|
9
|
+
this.f.release()}id(){return"mux"}T(a,b){a.trigger(new _.F(_.Oc,{detail:b}))}};_.x("clpp.muxdata.MuxDataPlugin",Xr);Xr.Id="mux";_.Cl(new class{create(){return new Xr}});};f.call(g, window);
|
package/cl.onboard.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Rr=function(a,b){let c=b.baseUrl;_.og(c,"/")||(c+="/");const d=g=>g&&(_.ng(g,"https://")||_.ng(g,"http://")||_.ng(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.Nn(a);a.Ba(_.yc,{licenseUrl:e,videoRobustness:[_.Ya,void 0],audioRobustness:[_.Xa,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.Vi,licenseResponse:_.Wi}});a.Ba(_.wc,{licenseUrl:b,
|
|
2
|
+
certificateUrl:b,modifiers:{licenseRequest:_.Yi,licenseResponse:_.Zi,extractContentId:_.$i,certificateRequest:_.aj}});a.Ba(_.xc,{licenseUrl:f,modifiers:{licenseRequest:_.Vi}});_.ri(a)};
|
|
3
|
+
_.x("clpp.onboard.OnboardComponent",class extends _.ro{constructor(){super();this.l=null;this.h=new _.O("clpp.onboard")}f(a){this.l=a}a(){this.l=null}g(){var a=this.l.getConfiguration().drm,b;if(b=!(!a||!a.env))b=a&&a.customData,b=!(!b||!b.baseUrl);b&&(b=a.env,a=a.customData,a={baseUrl:a.baseUrl,widevineUrl:a.widevineUrl,playreadyUrl:a.playreadyUrl,fairplayUrl:a.fairplayUrl},this.h.info(`Registering the DRMtoday Onboard environment, name='${b}'`),Rr(b,a))}release(){}id(){return"onboard"}});
|
|
4
|
+
_.x("clpp.onboard.register",Rr);};f.call(g, window);
|
package/cl.persistent.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Cr="A persistent DRM session already exists for: ",Dr="No DRM configuration.",Er="clpp.persistent",Fr=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},Hr=function(a,b){a.I=Gr;a.H=[];a.C=!0;return _.Ej(a,b)},Jr=function(a,b,c,d,e,f){a.I=Ir;const g=new Map,h=_.sj(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Ad,persistentState:_.Td,sessionTypes:[_.Hd],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,distinctiveIdentifierRequired:!1,persistentStateRequired:!0,
|
|
2
|
+
audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.Dj(a,g)},Kr=function(a,b){return _.v(function*(){const c=yield _.Tj(a,b);if(c){var d=[],e=a.g.get(c);e&&a.A&&(e.eb=new _.Hj,d.push(e.eb));a.a.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.a.debug("Ignoring attempt to remove missing session",b)})},Lr=function(a){a=a.g.keys();a=Fr(a,b=>b.sessionId);return Array.from(a)},Mr=function(a,b){const c=_.ti(a),d=_.Yh({drm:a});
|
|
3
|
+
d.drm=a;a=new _.Lk({pb:b,onError:()=>{},zd:()=>{},onExpirationUpdated:()=>{},onEvent:()=>{},getConfiguration:()=>d,jc:()=>null});a.h=c;return a},Pr=function(a,b,c){return _.v(function*(){const d=Nr;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)Or.debug(Cr,e);else{var g=Mr(a,c);try{yield Hr(g,b);yield _.Sj(g);yield _.Uj(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.Ig(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:Lr(g),keySystem:h.keySystem,
|
|
4
|
+
licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw Or.error("Error while persisting DRM session"),new _.H(1,6,6200,null,h);}finally{yield g.destroy()}}}}else Or.debug(Dr)})},Gr=1,Ir=2,Qr=class{store(a,b){return _.v(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);const e=JSON.stringify(b.audioCapabilities),
|
|
5
|
+
f=JSON.stringify(b.videoCapabilities);c=JSON.stringify({sessionIds:c,keySystem:b.keySystem,licenseServerUri:encodeURIComponent(b.licenseServerUri),serverCertificate:d,audioCapabilities:e,videoCapabilities:f,drmConfig:JSON.stringify(b.drmConfig)})}window.localStorage.setItem(encodeURIComponent(a),btoa(c))})}get(a){return _.v(function*(){var b=window.localStorage.getItem(encodeURIComponent(a));if(b){{b=JSON.parse(atob(b));const c=JSON.parse(b.sessionIds),d=JSON.parse(b.audioCapabilities),e=JSON.parse(b.videoCapabilities),
|
|
6
|
+
f=JSON.parse(b.serverCertificate),g=JSON.parse(b.drmConfig);b={sessionIds:c,keySystem:b.keySystem,licenseServerUri:decodeURIComponent(b.licenseServerUri),serverCertificate:f?new Uint8Array(f):null,audioCapabilities:d,videoCapabilities:e,drmConfig:g}}}else b=null;return b})}delete(a){return _.v(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.v(function*(){window.localStorage.clear()})}getName(){return"clpp.persistent.SimpleSessionStorage"}};_.x("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.y(a)||(_.ef(a.store)||c.push("store"),_.ef(a.get)||c.push("get"),_.ef(a.delete)||c.push("delete"),_.ef(a.clear)||c.push("clear"),_.ef(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw Or.warn("Invalid session storage implementation"),new _.H(1,6,6202,{missingMethods:b});Nr=a});
|
|
7
|
+
_.x("clpp.persistent.fetchLicense",function(a,b,...c){return _.v(function*(){var d=Nr,e=(l,m)=>new _.H(1,6,6200,l,m);const f=_.Fk(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(Dr);var g=b.offlineId;if(typeof g!==_.ee||!g.length)throw e("Missing offline id.");if(yield d.get(g))Or.debug(Cr,g);else{var h=_.Yh();d=new _.zl;g=[];for(var k of c){const l=new k;_.ai(l.id())||(l.f(null),_.ei(l),g.push(l))}k=null;try{k=yield _.qm(f.url,d,h.manifest.attemptParameters,f.type);k.configure(h.manifest);
|
|
8
|
+
const l=yield k.start(f.url,{networkingEngine:d,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.H(_.G,4,4014));const m=_.om(l.periods);yield Pr(b,m,d)}catch(l){if(l instanceof _.H&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.$h.delete(e.id());e=[];k&&e.push(k.stop());e.push(d.destroy());yield Promise.all(e)}}})});
|
|
9
|
+
_.x("clpp.persistent.removeLicense",function(a){return _.v(function*(){var b=Nr;if(_.ff(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.zl,c=Mr(e.drmConfig,d),yield Jr(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.Sj(c),yield Promise.all(e.sessionIds.map(f=>_.v(function*(){yield Kr(c,f);Or.debug("sucessfully removed session with id",f)}))),yield b.delete(a)):Or.debug("No persistent DRM session found")}catch(e){throw Or.error("Failed to remove session"),
|
|
10
|
+
new _.H(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else Or.warn("Invalid offlineId")})});var Nr=new Qr,Or=new _.O(Er);_.x("clpp.persistent.PersistentLicenseComponent",class extends _.ro{constructor(){super();this.l=null;this.j=Nr;this.h=new _.O(Er)}f(a){this.l=a}a(){this.l=null}release(){}g(){this.j=Nr}id(){return _.Gd}o(a,b,c){const d=this;return _.v(function*(){if(a)try{yield Pr(a,b,c),d.l.trigger(new _.F(_.Hc,{offlineId:a.offlineId}))}catch(e){d.l.onError(e)}else d.h.debug("No DRM configuration found for loaded source.")})}m(a){const b=this;return _.v(function*(){try{const c=yield b.j.get(a);if(c)return c.sessionIds;
|
|
11
|
+
b.h.debug(`No offline session found for ${a}`);return[]}catch(c){return b.h.warn("Error while loading session info from storage"),[]}})}});};f.call(g, window);
|
package/cl.playlist.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var zr=function(a,b){return 0<=b&&b<a.a.length},Ar=function(a){a.trigger(new _.F(_.Md))},Br=class extends _.zn{constructor(a,b){b=void 0===b?()=>Promise.resolve():b;super();this.l=a;this.j=b;this.f=0;this.a=[];this.g=!1;this.h=this.ne.bind(this)}getPosition(){return this.f}af(){return this.a}dd(){return 0<this.a.length&&zr(this,this.f)?this.a[this.f]:null}bf(){const a=this.f+1;return 0<this.a.length&&zr(this,a)?this.a[a]:null}ef(){return this.g}start(){this.g||(this.g=!0,this.l.on(_.Nc,
|
|
2
|
+
this.h),this.Kc(this.f,!0))}stop(){this.g=!1;this.l.off(_.Nc,this.h)}ne(){this.next()}next(){const a=this;return _.v(function*(){yield a.Kc(Math.min(a.a.length-1,a.f+1))})}lf(){const a=this;return _.v(function*(){yield a.Kc(Math.max(0,a.f-1))})}Kc(a,b){b=void 0===b?!1:b;const c=this;return _.v(function*(){if(0<c.a.length&&zr(c,a)&&(b||c.f!==a)){c.f=a;var d=c.dd();d&&(yield c.j(d),yield c.l.load(d.configuration),c.trigger(new _.F(_.Ld,{item:d})))}})}append(a){this.a.push(a);Ar(this)}df(a,b){if(0<=
|
|
3
|
+
b&&b<=this.a.length){const c=this.dd();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));Ar(this)}}remove(a){if(0<this.a.length&&zr(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);Ar(this)}}clear(){this.stop();this.f=0;this.a=[];this.g=!1;Ar(this)}};_.x("clpp.Playlist",Br);Br.prototype.clear=Br.prototype.clear;Br.prototype.remove=Br.prototype.remove;Br.prototype.insert=Br.prototype.df;Br.prototype.append=Br.prototype.append;Br.prototype.goTo=Br.prototype.Kc;
|
|
4
|
+
Br.prototype.previous=Br.prototype.lf;Br.prototype.next=Br.prototype.next;Br.prototype.onEnded=Br.prototype.ne;Br.prototype.stop=Br.prototype.stop;Br.prototype.start=Br.prototype.start;Br.prototype.isStarted=Br.prototype.ef;Br.prototype.getUpcoming=Br.prototype.bf;Br.prototype.getCurrent=Br.prototype.dd;Br.prototype.getQueue=Br.prototype.af;Br.prototype.getPosition=Br.prototype.getPosition;};f.call(g, window);
|