@castlabs/prestoplay 6.6.0 → 6.6.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/CHANGELOG.md +17 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +6 -6
- package/cjs/cl.cast.js +110 -110
- package/cjs/cl.conviva.js +33 -33
- package/cjs/cl.core.js +406 -406
- package/cjs/cl.crypto.js +8 -8
- package/cjs/cl.dash.js +71 -71
- package/cjs/cl.externs.js +17 -6
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +49 -48
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +22 -22
- package/cjs/cl.mse.js +256 -257
- package/cjs/cl.muxdata.js +12 -12
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.smooth.js +71 -70
- package/cjs/cl.thumbnails.js +24 -24
- package/cjs/cl.tizen.js +71 -71
- package/cjs/cl.ttml.js +27 -27
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +13 -13
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.youbora.js +20 -20
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +5 -5
- package/cl.cast.js +88 -88
- package/cl.conviva.js +27 -27
- package/cl.core.js +357 -356
- package/cl.crypto.js +8 -8
- package/cl.dash.js +66 -66
- package/cl.externs.js +17 -6
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +40 -40
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +25 -25
- package/cl.ima.js +16 -16
- package/cl.mse.js +199 -200
- package/cl.muxdata.js +8 -8
- package/cl.onboard.js +2 -2
- package/cl.persistent.js +9 -9
- package/cl.playlist.js +4 -4
- package/cl.smooth.js +59 -58
- package/cl.thumbnails.js +16 -16
- package/cl.tizen.js +57 -57
- package/cl.ttml.js +12 -12
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +13 -13
- package/cl.vtt.js +11 -11
- package/cl.youbora.js +15 -15
- package/package.json +5 -1
- package/typings.d.ts +100 -96
package/cl.mse.js
CHANGED
|
@@ -1,233 +1,232 @@
|
|
|
1
1
|
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Gt,Ht,It,Jt,Kt,Lt,Mt,Pt,Qt,St,Tt,Ut,Vt,Wt,Xt,Zt,au,bu,cu,du,eu,hu,iu,ju,ku,lu,qu,ru,su,tu,vu,zu,Au,Bu,Cu,Eu,Gu,Iu,Ju,Ku,Lu,Mu,Nu,Ru,Vu,Xu,Yu,Zu,$u,fv,hv,iv,mv,nv,ov,qv,pv,rv,sv,vv,xv,yv,zv,Av,Bv,Cv,Ev,Fv,Gv,Hv,Iv,Kv,Jv,Dv,Qv,Lv,Mv,Nv,Ov,Pv,Rv,Sv,Vv,Tv,Uv,Wv,Xv,Yv,Zv,aw,bw,cw,dw,ew,fw,gw,hw,jw,iw,kw,sw,rw,tw,uw,vw,xw,yw,Bw,zw,Aw,Cw,Dw,Ew,Fw,Gw,Hw,Iw,Jw,Mw,Nw,Ow,Pw,Kw,Lw,Sw,Vw,Uw,Ww,Tw,Xw,Zw,Yw,ax,bx,cx,dx,ex,fx,kx,lx,nx,ox,hx,ix,jx,px,qx,xx,rx,sx,tx,ux,vx,yx,Cx,gx,Dx,Gx,Hx,Ix,Ex,Fx,
|
|
2
|
-
Ax,Bx,Jx,Kx,Lx,Mx,Nx,Ox,Px,Ux,Qx,Rx,Sx,Tx,Vx,Wx,Xx,lw,mw,nw,ow,pw,qw,iy,ky,ly,qy,oy,ny,py,Fy,Gy,Ky,Oy,bz,sy,Iy,Jy,wy,Ny,Qy,Ry,Ty,gy,Vy,Wy,Zy,$y,az,
|
|
2
|
+
Ax,Bx,Jx,Kx,Lx,Mx,Nx,Ox,Px,Ux,Qx,Rx,Sx,Tx,Vx,Wx,Xx,lw,mw,nw,ow,pw,qw,iy,ky,ly,qy,oy,ny,py,Fy,Gy,Ky,Oy,bz,sy,Iy,Jy,wy,Ny,Qy,Ry,Ty,gy,Vy,Wy,Zy,$y,az,xy,My,Zx,fy,fz,Ey,dy,ey,qz,$x,ay,by,cy,dz,pz,cz,rz,hz,iz,gz,sz,tz,uz,vz,wz,xz,yz,mu,Hy,ev,mz,lz,wv,ty;Gt=" buffer";Ht=" is being or has been set up";It="\x3c/DATA\x3e\x3c/WRMHEADER\x3e";Jt="Choosing new streams after key status change";Kt="IterateSegmentReference";Lt="Jumping forward";Mt="MediaSource threw QuotaExceededError:";_.Nt="No stream with id";
|
|
3
3
|
_.Ot="Player is in ERROR state and can not switch to ";Pt="PrestoPlay TextTrack";Qt="Removing audio from variant - audio not compatible with platform";_.Rt="Updating manifest...";St="bufferBehind\x3d";Tt="bufferedBehind\x3d";Ut="calling onCanSwitch()...";Vt="cannot find segment";Wt="clpp.mse.Player";Xt="currentPeriod.startTime\x3d";_.Yt="getSegmentNextReference";Zt="key-restriction";_.$t="onChooseStreams_";au="presentationTime:";bu="presentationTime\x3d";cu="reference.endTime\x3d";du="reference.position\x3d";
|
|
4
|
-
eu="reference.startTime\x3d";_.fu="subtitle";_.gu="subtitles";hu="switch: Stream ";iu=function(a,b,c){if(null==a&&null==b)return!0;if(null==a||null==b)return!1;a=c?a.map(c):a;b=c?b.map(c):b;return _.
|
|
5
|
-
ku=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&&iu(a.roles,b.roles)&&iu(a.accessibility,b.accessibility,ju)};lu=function(a){for(var b=a.a;_.
|
|
6
|
-
_.nu=function(a){const b=new Uint8Array(mu),c=4+b.byteLength+a.h.byteLength+4+a.f.byteLength,d=new _.
|
|
7
|
-
_.ou=function(a,b,c,d){var e=_.
|
|
4
|
+
eu="reference.startTime\x3d";_.fu="subtitle";_.gu="subtitles";hu="switch: Stream ";iu=function(a,b,c){if(null==a&&null==b)return!0;if(null==a||null==b)return!1;a=c?a.map(c):a;b=c?b.map(c):b;return _.bg(a,b)&&_.bg(b,a)};ju=function(a){return`@@scheme:${a.scheme||""}`+`@@value:${a.value}`+`@@id:${a.id||""}@@type:${a.type||""}`+`@@protocol:${a.protocol||""}`};
|
|
5
|
+
ku=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&&iu(a.roles,b.roles)&&iu(a.accessibility,b.accessibility,ju)};lu=function(a){for(var b=a.a;_.wj(a)&&0!==a.f.getUint8(a.a);)a.a+=1;b=a.f.buffer.slice(b,a.a);a.a+=1;return _.Ig(b)};
|
|
6
|
+
_.nu=function(a){const b=new Uint8Array(mu),c=4+b.byteLength+a.h.byteLength+4+a.f.byteLength,d=new _.Oj(c,!1);_.L(d,c);_.vj(d,b);_.vj(d,a.h);_.L(d,a.f.byteLength);_.vj(d,a.f);return _.H(d.buffer)};
|
|
7
|
+
_.ou=function(a,b,c,d){var e=_.gj(b);if(8!==e.byteLength)e="";else{var f=_.xk(e);e=_.dj(f);b:switch(f=f.byteLength,_.If("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>`:"",It].join("");break b;
|
|
8
8
|
case "4.1.0.0":e=[`<WRMHEADER xmlns="${"http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader"}" version="${a}">`,'\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>`:"",It].join("");break b;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" ',
|
|
9
|
-
c?`CHECKSUM="${c}" `:"",`VALUE="${e}"`,"\x3e\x3c/KID\x3e\x3c/KIDS\x3e\x3c/PROTECTINFO\x3e",d?`<LA_URL>${d}</LA_URL>`:"",It].join("");break b;default:_.B("Cannot create PlayReady header in version",a),e=""}}if(!e)return null;_.
|
|
10
|
-
qu=function(a,b){a:{if(b)for(const c of a.g.keys()){const d=a.g.get(c);for(let e=0;e<d
|
|
11
|
-
tu=function(a,b){const c=b.audio,d=b.video;if(c&&c.encrypted&&!ru(a,_.
|
|
12
|
-
_.xu=function(a,b,c){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:b||[],keyIds:[],periodId:c?c:null}};_.yu=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Wc:b,item:d,
|
|
13
|
-
Au=function(a,b){let c=0;for(const d of a)c+=b(d)?1:0;return c};Bu=function(a,b){a=_.
|
|
14
|
-
_.Du=function(a,b){a=_.
|
|
9
|
+
c?`CHECKSUM="${c}" `:"",`VALUE="${e}"`,"\x3e\x3c/KID\x3e\x3c/KIDS\x3e\x3c/PROTECTINFO\x3e",d?`<LA_URL>${d}</LA_URL>`:"",It].join("");break b;default:_.B("Cannot create PlayReady header in version",a),e=""}}if(!e)return null;_.If("New payload",e);e=_.H(_.Ng(e,!0));return new _.Ak(_.Ek,b,d||null,e,a,c)};_.pu=function(a,b){return b===a.version?a:_.ou(b,a.a,a.j||void 0,a.g||void 0)};
|
|
10
|
+
qu=function(a,b){a:{if(b)for(const c of a.g.keys()){const d=a.g.get(c);for(let e=0;e<d.Za.length;e++)if(d.Za[e]===b){a=d;break a}}a=null}return a?a.xa:null};ru=function(a,b){return _.Wh("Edge/")?!0:a.J.has(b)};su=function(a,b){a=a.j.get(b);return!(!a||a!==_.Nd&&a!==_.fd)};
|
|
11
|
+
tu=function(a,b){const c=b.audio,d=b.video;if(c&&c.encrypted&&!ru(a,_.Ph(c.mimeType,c.codecs))||d&&d.encrypted&&!ru(a,_.Ph(d.mimeType,d.codecs)))return!1;const e=a.keySystem();return 0==b.drmInfos.length||b.drmInfos.some(f=>f.keySystem==e)};_.uu=function(a,b){return a.concat(b)};vu=function(){};_.wu=function(a,b){if(0==b.length)return a;const c=b.map(d=>new _.eg(d));return a.map(d=>new _.eg(d)).map(d=>c.map(d.resolve.bind(d))).reduce(_.uu,[]).map(d=>d.toString())};
|
|
12
|
+
_.xu=function(a,b,c){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:b||[],keyIds:[],periodId:c?c:null}};_.yu=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Wc:b,item:d,If:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{Wc:b,If:c,item:d,next:void 0})};zu=function(a,b){for(const c in b)if(b[c]===a)return c;return""};
|
|
13
|
+
Au=function(a,b){let c=0;for(const d of a)c+=b(d)?1:0;return c};Bu=function(a,b){a=_.Nh(a);b=_.Nh(b);a=a.split("-");b=b.split("-");return a[0]==b[0]&&1==a.length&&2==b.length};Cu=function(a){return a.language?_.Nh(a.language):a.audio&&a.audio.language?_.Nh(a.audio.language):a.video&&a.video.language?_.Nh(a.video.language):_.ye};
|
|
14
|
+
_.Du=function(a,b){a=_.Nh(a);const c=new Set;for(var d of b)c.add(_.Nh(d));for(const e of c)if(e==a)return e;for(const e of c)if(Bu(e,a))return e;for(const e of c)if(d=e,b=a,d=_.Nh(d),b=_.Nh(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(Bu(a,e))return e;return null};Eu=function(a){const b=[a.mimeType];_.Wo.forEach((c,d)=>{(d=a[d])&&b.push(c+'\x3d"'+d+'"')});return b.join(";")};_.Fu=function(a){a=a.split(".");const b=a[0];a.pop();return[b,a.join(".")]};
|
|
15
15
|
Gu=function(a,b="total"){b=new _.$o(void 0,b);for(const c of a)b.a.push(c);b.length=a.length;return b};
|
|
16
16
|
_.Hu=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||[]);const h=[...f.keyIds||[]];d.keyIds&&d.keyIds.length&&d.keyIds.forEach(k=>{h.includes(k)||h.push(k)});c.push({keySystem:f.keySystem,licenseServerUri:f.licenseServerUri||d.licenseServerUri,distinctiveIdentifierRequired:f.distinctiveIdentifierRequired||
|
|
17
|
-
d.distinctiveIdentifierRequired,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};Iu=function(a,b){return a.start-b.start};Ju=function(a){return a
|
|
18
|
-
Ku=function(a){a.a&&a.a.trigger(new _.C(_.
|
|
19
|
-
Mu=function(a,b,c){a
|
|
20
|
-
_.Qu=function(a,b,c,d,e,f,g,h){a=_.
|
|
17
|
+
d.distinctiveIdentifierRequired,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};Iu=function(a,b){return a.start-b.start};Ju=function(a){return a.$.map(b=>({start:b.start,end:b.end,width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b.rendition}))};
|
|
18
|
+
Ku=function(a){a.a&&a.a.trigger(new _.C(_.fc))};Lu=function(a){if(a.a){var b=!1,c={};for(let d=0;d<a.$.length;d++){const e=a.$[d],f=e.width+"x"+e.height,g=c[f];if(g&&g!==e.bandwidth){b=!0;break}c[f]=e.bandwidth}b&&!a.g?(a.log.debug("Tracking timeupdates"),a.a.on(_.ve,a.f,a),a.g=!0):!b&&a.g&&(a.log.debug("Stop tracking timeupdates"),a.a.off(_.ve,a.f),a.g=!1)}};
|
|
19
|
+
Mu=function(a,b,c){a.$=a.$.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 _.C(_.Ke))};Nu=function(a,b){let c=null;for(const d of a)b>=d.startTime&&(c=d);return c};_.Ou=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)};_.Pu=function(a){return a.a/(1-Math.pow(a.g,a.f))};
|
|
20
|
+
_.Qu=function(a,b,c,d,e,f,g,h){a=_.bh(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};Ru=function(a){return a.j?a.g:a.m?a.f:null};_.Su=function(a,b){a.h=null==a.h?b:Math.min(a.h,b)};
|
|
21
21
|
_.Tu=function(a,b,c){if(0!=b.length){var d=b[b.length-1].endTime+c;_.Su(a,b[0].startTime+c);a.a=b.reduce((e,f)=>Math.max(e,f.endTime-f.startTime),a.a);a.f=Math.max(a.f||0,d);null!=a.o&&a.F&&(a.o=(Date.now()+a.A)/1E3-a.f-a.a);a.B.debug("notifySegments: maxSegmentDuration\x3d"+a.a)}};_.Uu=function(a,b){a.a=Math.max(a.a,b);a.B.debug("notifyNewSegmentDuration: maxSegmentDuration\x3d"+a.a)};
|
|
22
|
-
Vu=function(a){if(a.j)a=a.g;else if(a.m)a=a.f||0;else{var b=(Date.now()+a.A)/1E3;b=a.C?Math.max(0,b-(a.a-a.w)-a.o):Math.max(0,b-a.a-a.o);a=Math.min(b,a.g)}return a};_.Wu=function(a){return Infinity==a.
|
|
23
|
-
$u=function(a){let b=a.g.get(a.a);if(!b)return null;0<b.a.length&&b.
|
|
24
|
-
_.cv=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.h.info("Refusing to rewrite original references on update!"):(.1<Math.abs(g.endTime-h.endTime)?c.push(new _.bv(g.position,h.startTime,h.endTime,h.
|
|
25
|
-
c[c.length-1].position+1;f<b.length;)g=b[f++],g=new _.bv(e++,g.startTime,g.endTime,g.
|
|
26
|
-
_.dv=function(a,b){for(let c=0;c<a.a.length;++c)if(a.a[c].endTime>b)
|
|
27
|
-
_.gv=function(a,b){for(;a.a.length;)if(0>=a.a[0].endTime)a.a.shift();else break;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
a
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Dv=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(_.F,3,3017,{type:b})):c.p.reject(new _.H(_.F,3,3015,{mediaError:d})),Jv(a,b)}else a.a.debug("No more scheduled operations for "+b)};
|
|
22
|
+
Vu=function(a){if(a.j)a=a.g;else if(a.m)a=a.f||0;else{var b=(Date.now()+a.A)/1E3;b=a.C?Math.max(0,b-(a.a-a.w)-a.o):Math.max(0,b-a.a-a.o);a=Math.min(b,a.g)}return a};_.Wu=function(a){return Infinity==a.Zb?0:Math.max(0,Vu(a)-a.Zb)};Xu=function(a){return Math.max(0,Vu(a)-(a.j||a.m?0:a.Md))};Yu=function(a,b){const c=Math.max(a.h,0);return Infinity==a.Zb?Math.ceil(1E3*c)/1E3:Math.max(c,Math.min(Vu(a)-a.Zb+b,Xu(a)))};Zu=function(a,b){a.f=b};
|
|
23
|
+
$u=function(a){let b=a.g.get(a.a);if(!b)return null;0<b.a.length&&b.Ca().length&&a.f>=b.a.length&&(a.a+=1,a.f=0,b=a.g.get(a.a));return b&&0<b.a.length?b.a[a.f]||null:b};_.av=function(a){return a.a.length?a.a[a.a.length-1].endTime:0};
|
|
24
|
+
_.cv=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.h.info("Refusing to rewrite original references on update!"):(.1<Math.abs(g.endTime-h.endTime)?c.push(new _.bv(g.position,h.startTime,h.endTime,h.Ca,h.Ta,h.Ja,h.Ea,h.keyInfo,h.ic,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 _.bv(e++,g.startTime,g.endTime,g.Ca,g.Ta,g.Ja,g.Ea,g.keyInfo,g.ic,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 _.bv(f-e--,h.startTime,h.endTime,h.Ca,h.Ta,h.Ja,h.Ea,h.keyInfo,h.ic,h.timescale,h.horizontalTiles,h.verticalTiles,h.durationPerTile));for(const h of c)b.push(h)}a.a=b};
|
|
26
|
+
_.dv=function(a,b){for(let c=0;c<a.a.length;++c)if(a.a[c].endTime>b)return a.a.splice(0,c);b=a.a;a.a=[];return b};fv=function(a,b){let c=a.f(b);c=null===c?-1:c-1;const d=a.get(c+1);let e=-1;if(d&&0<d.a.length)for(let f=d.a.length-1;0<=f;--f){let g=d.a[f];if(b>=g.startTime&&b<g.endTime){for(;f&&!g.g;)--f,g=d.a[f];if(!g.g)break;c+=1;e=f-1;break}}return new ev(a,c,e)};
|
|
27
|
+
_.gv=function(a,b){for(;a.a.length;)if(0>=a.a[0].endTime)a.a.shift();else break;0==a.a.length||a.a[a.a.length-1].startTime>=b||(a.a[a.a.length-1].endTime=b)};hv=function(a,b){for(const c of a.a)c.m(a.f.currentTime,b)};iv=function(a,b,c,d){a.a=b;a.f=c;a.g=d};_.jv=function(a){_.Kn[a]&&delete _.Kn[a]};_.kv=function(a){_.In[a]&&delete _.In[a]};_.lv=function(a){a=a.toLowerCase();return _.io[a]||window.muxjs&&a==_.Tb?!0:!1};
|
|
28
|
+
mv=function(a,b,c,d){return Promise.resolve().then(()=>{if(a.o&&a.g)if(null==c||null==d)a.o.parseInit(_.H(b));else{var e={periodStart:a.w,segmentStart:c,segmentEnd:d};e=a.o.parseMedia(_.H(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)}})};nv=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
|
+
ov=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 _.Co(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))};qv=function(a,b){return!window.muxjs||"mp2t"!=a.toLowerCase().split(";")[0].split("/")[1]&&"aac"!=a.toLowerCase().split(";")[0].split("/")[1]?!1:b?MediaSource.isTypeSupported(pv(b,a))||MediaSource.isTypeSupported(a.replace(/aac/i,_.xd)):MediaSource.isTypeSupported(pv(_.ac,a))||MediaSource.isTypeSupported(a.replace(/aac/i,_.xd))||MediaSource.isTypeSupported(pv(_.u,a))};
|
|
31
|
+
pv=function(a,b){b=b.replace(/mp2t/i,_.xd);a==_.ac&&(b=b.replace(_.u,_.ac));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};rv=function(a,b){a.h=!0;a.f=new _.Xk;a.m=[];a.j=[];a.g=[];b=_.H(b);a.a.push(b);a.a.flush();a.h&&a.f.reject(new _.G(_.F,3,3018));return a.f};
|
|
32
|
+
sv=function(a){const b=_.Ph(a.mimeType,a.codecs),c=Eu(a);return _.lv(b)||MediaSource.isTypeSupported(c)||qv(b,a.type)};vv=function(a,b){const c=new MediaSource,d=uv(c);a.o.one(c,"sourceopen",()=>{URL.revokeObjectURL(d);b.resolve()});a.j.src=d;return c};xv=function(a,b){a.g||(a.g=new wv(a.L,a.B));a=a.g;if(b!=_.Tb){var c=_.io[b];if(!c)throw new _.G(_.F,2,2012,"Text parser is unavailable for "+b);a.o=new c(a.B)}};
|
|
33
|
+
yv=function(a,b){b.forEach((c,d)=>{c=a.m.addSourceBuffer(c);a.o.on(c,_.$c,a.T.bind(a,d));a.o.on(c,"updateend",a.w.bind(a,d));a.f[d]=c;a.h[d]=[];a.F[d]=!1});a.K=b.has(_.ac)&&b.has(_.u)};zv=function(a){return a.m?a.m.readyState==_.Zc:!0};Av=function(a,b){try{return new _.$o(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
|
+
Bv=function(a){const b={};b.total=new _.$o(a.j.buffered,"total");b.audio=Av(a,_.ac);b.video=Av(a,_.u);let c=[];a.g&&(c=[{start:a.g.lb(),end:a.g.va()}]);b.text=Gu(c,_.r);return b};Cv=function(a,b){return a.f[b]?(a=Av(a,b))?a.toString():"":""};Ev=function(a,b,c){if(a.I)return Promise.reject();c={start:c,p:new _.Xk};a.h[b].push(c);1===a.h[b].length&&Dv(a,b);return c.p};
|
|
35
|
+
Fv=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=mv(a.g,c,d,e):a.A[b]?c=rv(a.A[b],c).then(n=>{n.captions&&0<n.captions.length&&(a.g||xv(a,_.te),ov(a.g,n.captions,d,e,a.f.video.timestampOffset));const q=[];0<n.audio.byteLength&&a.f.audio&&q.push(Ev(a,_.ac,a.J.bind(a,_.ac,n.audio.buffer)));0<n.video.byteLength&&a.f.video&&q.push(Ev(a,_.u,a.J.bind(a,_.u,n.video.buffer)));
|
|
36
|
+
return Promise.all(q)}):(f&&window.muxjs&&(a.g||xv(a,_.te),null==d&&null==e?a.G.init(c):a.G.g(c,n=>{n.length&&ov(a.g,n,d,e,a.f.video.timestampOffset)})),c=Ev(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:",Cv(a,b));else if(b===_.ac&&null!==d&&null!==e)Ku(a.C),null!==d&&null!==e&&a.a.debug("Appended audio segment ",d,e,"Buffer:",Cv(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.F[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=Ev(a,b,()=>{a.S(b,t)}),q=Ev(a,b,a.N.bind(a,b,!1)),Promise.all([n,q])}null!==d&&null!==
|
|
38
|
+
e&&(a.F[b]=!0)}).catch(n=>{throw n;})};Gv=function(a,b){const c=a.va(_.u)||0;nv(a.g,b,c)};Hv=function(a,b,c,d,e){return[Ev(a,b,a.U.bind(a,b)),Ev(a,b,a.S.bind(a,b,c)),Ev(a,b,a.W.bind(a,b,d,e))]};Iv=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=Hv(a,b,c,d,e);a.K&&(b=b.concat(Hv(a,_.ac,c,d,e)));return Promise.all(b)};
|
|
39
|
+
Kv=function(a,b){if(a.I)return Promise.reject();const c=[];for(const d in a.f){const e=new _.Xk,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 _.G(_.F,3,3015,{mediaError:e}))}for(const e in a.f)Jv(a,e);return d},()=>{for(const d in a.f)a.h[d].length&&a.h[d].shift();return Promise.reject()})};Jv=function(a,b){a.h[b].shift();Dv(a,b)};
|
|
40
|
+
Dv=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 _.G(_.F,3,3017,{type:b})):c.p.reject(new _.G(_.F,3,3015,{mediaError:d})),Jv(a,b)}else a.a.debug("No more scheduled operations for "+b)};
|
|
42
41
|
Qv=function(a,b,c,d){var e=a.periods.flatMap(h=>h.variants);if(b.length||c.length)e=Lv(e,b,c);e=Mv(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=
|
|
43
|
-
Nv(e);const g=Ov(e);for(const h of a.periods)h.variants=h.variants.filter(k=>{if(Pv(k)===g)return!0;_.
|
|
44
|
-
Mv=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))};Nv=function(a){const b=new _.
|
|
45
|
-
Ov=function(a){let b="",c=Infinity;a.forEach((d,e)=>{e=e.reduce((f,g)=>f+g.bandwidth||0,0)/e.length;_.
|
|
42
|
+
Nv(e);const g=Ov(e);for(const h of a.periods)h.variants=h.variants.filter(k=>{if(Pv(k)===g)return!0;_.If("Dropping Variant (better codec available)",k);return!1})};Lv=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
|
+
Mv=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))};Nv=function(a){const b=new _.qo;for(const c of a)a=Pv(c),b.push(a,c);return b};
|
|
44
|
+
Ov=function(a){let b="",c=Infinity;a.forEach((d,e)=>{e=e.reduce((f,g)=>f+g.bandwidth||0,0)/e.length;_.If(_.Fc,d,"avg bandwidth",e);e<c&&(b=d,c=e)});return b};Pv=function(a){let b="";a.video&&(b=_.Fu(a.video.codecs)[0]);let c="";a.audio&&(c=_.Fu(a.audio.codecs)[0]);return b+"-"+c};
|
|
46
45
|
Rv=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};Sv=function(a,b,c){let d=!1;for(const e of a)a=e.allowedByApplication,e.allowedByApplication=Rv(e,b,c),a!=e.allowedByApplication&&(d=!0);return d};
|
|
47
|
-
Vv=function(a,b,c,d){let e=!1;d.variants=d.variants.filter(f=>{if(a&&a.
|
|
48
|
-
Tv(h)),!1):g&&b&&!Uv(g,b)?(_.
|
|
49
|
-
!1):!0))}d.textStreams=d.textStreams.filter(f=>{const g=_.lv(_.
|
|
50
|
-
Tv=function(a){const b=Eu(a);return a.type===_.
|
|
46
|
+
Vv=function(a,b,c,d){let e=!1;d.variants=d.variants.filter(f=>{if(a&&a.R&&!tu(a,f))return _.If("Dropping variant - not compatible with key system",f),!1;let g=f.audio;const h=f.video;if(g&&!sv(g)){const k=g.codecs;0<=g.codecs.indexOf("ec-3")?(_.If("Trying to use AC-3 for EC-3"),g.codecs=g.codecs.replace("ec-3","ac-3"),sv(g)?_.Hf("Using AC-3 instead of EC-3 for",Tv(g)):(g.codecs=k,_.Hf(Qt,Tv(g)),f.audio=null,e=!0,g=null)):(_.Hf(Qt,Tv(g)),f.audio=null,e=!0,g=null)}return h&&!sv(h)?(_.Hf("Dropping variant - video not compatible with platform",
|
|
47
|
+
Tv(h)),!1):g&&b&&!Uv(g,b)?(_.Hf("Dropping variant - not compatible with active audio","active audio",Tv(b),"variant.audio",Tv(g)),!1):h&&c&&!Uv(h,c)?(_.Hf("Dropping variant - not compatible with active video","active video",Tv(c),"variant.video",Tv(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?(_.Hf("Dropping variant - not compatible with video + audio","variant.video",Tv(h.video)),
|
|
48
|
+
!1):!0))}d.textStreams=d.textStreams.filter(f=>{const g=_.lv(_.Ph(f.mimeType,f.codecs));g||_.If("Dropping text stream. Is not supported by the platform.",f);return g})};
|
|
49
|
+
Tv=function(a){const b=Eu(a);return a.type===_.ac?"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"};
|
|
51
50
|
Uv=function(a,b){return a.mimeType!=b.mimeType||a.codecs.split(".")[0]!=b.codecs.split(".")[0]?!1:!0};
|
|
52
51
|
Wv=function(a){const b=a.audio,c=a.video,d=b?b.codecs:null,e=c?c.codecs:null,f=[];e&&f.push(e);d&&f.push(d);const g=c&&c.mimeType||null,h=b&&b.mimeType||null;var k=[];b&&k.push(b.kind);c&&k.push(c.kind);k=k[0]||null;const l=new Set,m=new Set;if(b)for(var n of b.roles)m.add(n);if(c)for(const q of c.roles)l.add(q);n=[c,b].map(q=>q?q.accessibility||[]:[]).reduce((q,t)=>q.concat(t),[]);a={id:a.id,active:!1,type:"variant",bandwidth:a.bandwidth,language:a.language,label:null,kind:k,width:null,height:null,
|
|
53
52
|
frameRate:null,mimeType:g,audioMimeType:h,codecs:f.join(", "),audioCodec:d,videoCodec:e,primary:a.primary,roles:Array.from(l),audioRoles:Array.from(m),videoId:null,audioId:null,channelsCount:null,audioBandwidth:null,videoBandwidth:null,originalVideoId:null,originalAudioId:null,originalTextId:null,accessibility:n,keyId:c?c.keyId:b?b.keyId:null};c&&(a.videoId=c.id,a.originalVideoId=c.originalId,a.width=c.width||null,a.height=c.height||null,a.frameRate=c.frameRate||null,a.videoBandwidth=c.bandwidth||
|
|
54
53
|
null);b&&(a.audioId=b.id,a.originalAudioId=b.originalId,a.channelsCount=b.channelsCount,a.audioBandwidth=b.bandwidth||null,a.label=b.label,a.audioRoles=b.roles);return a};
|
|
55
54
|
Xv=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,accessibility:a.accessibility,keyId:null}};
|
|
56
55
|
Yv=function(a){return a.allowedByApplication&&a.allowedByKeySystem};
|
|
57
|
-
_.$v=function(a,b,c){b=_
|
|
56
|
+
_.$v=function(a,b,c){b=_.$f(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=_.Du(_.Nh(g),a.map(k=>k.language));return h?(d=a.filter(k=>_.Nh(k.language)===h),!0):!1});if(c){b=Zv(d,c);if(b.length)return b;_.B("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(_.uu,[]);return b.length?Zv(d,b[0]):d};
|
|
58
57
|
Zv=function(a,b){return a.filter(c=>c.roles.includes(b))};aw=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};
|
|
59
|
-
bw=function(a,b){var c=String(_.
|
|
60
|
-
cw=function(a,b,c){const d=new _.
|
|
58
|
+
bw=function(a,b){var c=String(_.oh++);c=new _.ph(c,a);c.mimeType=_.lh(b.mimeType);if(a===_.I||a===_.J)c.label=_.lh(b.label),c.language=_.lh(b.language);a===_.K?(c.frameRate=b.frameRate,c.roles=b.roles):a===_.J?(c.channelsCount=b.channelsCount,c.roles=b.audioRoles||[],c.mimeType=_.lh(b.audioMimeType)):(c.kind=_.lh(b.kind),c.roles=b.roles);c.accessibility=a===_.K||a===_.J?(b.accessibility||[]).filter(d=>d.type===a):b.accessibility||[];return c};
|
|
59
|
+
cw=function(a,b,c){const d=new _.xh(a===_.K?`${b.videoId}`:a===_.J?`${b.audioId}`:`${b.id}`,c);switch(a){case _.K:d.codec=_.lh(b.videoCodec);d.bandwidth=b.videoBandwidth||b.bandwidth;d.width=b.width;d.height=b.height;d.originalId=b.originalVideoId;d.drm={keyId:b.keyId||void 0};break;case _.J:d.codec=_.lh(b.audioCodec);d.bandwidth=b.audioBandwidth||b.bandwidth;d.originalId=b.originalAudioId;d.drm={keyId:b.keyId||void 0};break;default:d.codec=_.lh(b.codecs),d.originalId=b.originalTextId}(a=c.renditions.find(e=>
|
|
61
60
|
_.rf(e,d,null,["id","track"])))||c.renditions.push(d);return a||d};dw=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)};ew=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};
|
|
62
|
-
fw=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};gw=function(a,b){return a.h.filter(c=>c.type===b)};hw=function(a,b){return(a=a.a.get(b)||null)&&a.track};jw=function(a,b,c){c&&hw(a,c.type)===c&&!a.l.
|
|
63
|
-
iw=function(a,b,c,d){d=void 0===d?!1:d;if(a.l&&((a.a.get(b)||null)!==c||a.l.
|
|
64
|
-
${b} with ID: ${c.id}`);if(b===_.I){const f=e.
|
|
65
|
-
l.id).filter(l=>l!==f.id);g=h.find(l=>k.find(m=>m==l.audioId))}}else g=ow(e).find(h=>h.videoId==c.id);g?(a.f.set(b,c),pw(e,g,d)):a.g.warn("Cannot find matching variant")}}else a.g.debug(_.
|
|
66
|
-
kw=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)};sw=function(a){if(a.l){a.g.debug("Track list change detected, updating track list");var b=[];for(var c of Object.values(_.Uo))a.a.set(c,null),a.f.set(c,null);for(var d of a.l.
|
|
67
|
-
rw=function(a,b,c,d){c=dw(c,d);for(const e of c){let f=bw(d,e);f=(c=b.find(h=>ku(f,h)))||f;const g=cw(d,e,f);e.active&&a.a.set(d,g);c||b.push(f)}};tw=function(a,b,c){if(b){a.h.length||sw(a);var d=b.type,e=a.a.get(d)||null,f;for(const g of gw(a,d))if(f=g.renditions.find(h=>h.id==b.id))break;f&&e!==f&&(kw(a,f),d===_.J?a.l.trigger(new _.C(_.
|
|
61
|
+
fw=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};gw=function(a,b){return a.h.filter(c=>c.type===b)};hw=function(a,b){return(a=a.a.get(b)||null)&&a.track};jw=function(a,b,c){c&&hw(a,c.type)===c&&!a.l.ja()||iw(a,b,c&&c.renditions[0])};
|
|
62
|
+
iw=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
|
|
63
|
+
${b} with ID: ${c.id}`);if(b===_.I){const f=e.ha().find(g=>g.id==c.id);f&&(a.f.set(b,c),kw(a,c),e.trigger(new _.C(_.Li)),lw(e,!0).then(()=>{mw(e,f)}).catch(g=>{a.g.warn("Error while activating track",g)}))}else if(b===_.J)a.f.set(b,c),nw(e,parseInt(c.id,10));else if(b===_.K){const f=a.a.get(_.J)||null;let g;if(f){const h=ow(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=>
|
|
64
|
+
l.id).filter(l=>l!==f.id);g=h.find(l=>k.find(m=>m==l.audioId))}}else g=ow(e).find(h=>h.videoId==c.id);g?(a.f.set(b,c),pw(e,g,d)):a.g.warn("Cannot find matching variant")}}else a.g.debug(_.xa+b),hw(a,b)&&(b===_.I?lw(e,!1).then(()=>{a.a.set(b,null);e.trigger(new _.C(_.Li))}).catch(f=>{a.g.warn("Error while de-activating text tracks",f)}):b===_.J?a.g.info("Enabling ABR for audio is not supported"):pw(e,null,d))}};
|
|
65
|
+
kw=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)};sw=function(a){if(a.l){a.g.debug("Track list change detected, updating track list");var b=[];for(var c of Object.values(_.Uo))a.a.set(c,null),a.f.set(c,null);for(var d of a.l.ha()){let e=bw(_.I,d);e=(c=b.find(g=>ku(e,g)))||e;const f=cw(_.I,d,e);d.active&&a.a.set(_.I,f);c||b.push(e)}qw(a.l)||a.a.set(_.I,null);d=ow(a.l);rw(a,b,d,_.K);rw(a,b,d,_.J);a.h=b}};
|
|
66
|
+
rw=function(a,b,c,d){c=dw(c,d);for(const e of c){let f=bw(d,e);f=(c=b.find(h=>ku(f,h)))||f;const g=cw(d,e,f);e.active&&a.a.set(d,g);c||b.push(f)}};tw=function(a,b,c){if(b){a.h.length||sw(a);var d=b.type,e=a.a.get(d)||null,f;for(const g of gw(a,d))if(f=g.renditions.find(h=>h.id==b.id))break;f&&e!==f&&(kw(a,f),d===_.J?a.l.trigger(new _.C(_.Ki)):d===_.K&&a.l.trigger(new _.C(_.Le,{details:{width:f.width||0,height:f.height||0,bandwidth:f.bandwidth,track:f.track,abrSelection:c}})))}};
|
|
68
67
|
uw=function(a,b){return 128E3>a.a?b:Math.min(_.Pu(a.f),_.Pu(a.g))};vw=function(a,b){a&&(b=b.filter(c=>Rv(c,a,{width:Infinity,height:Infinity})));return b.sort((c,d)=>c.bandwidth-d.bandwidth)};xw=function(a,b){a.a.has(b)||a.a.set(b,new ww);return a.a.get(b)};yw=function(a,b,c){xw(a,b).text=c};
|
|
69
68
|
Bw=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&&zw(c,d)&&Aw(c.roles,d.roles))}!c&&(c=a.video&&b.video)&&(a=a.video,b=b.video,c=!(zw(a,b)&&Aw(a.roles,b.roles)));return c?!1:!0};
|
|
70
69
|
zw=function(a,b){if(a.mimeType!=b.mimeType)return!1;a=a.codecs.split(",").map(c=>_.Fu(c)[0]);b=b.codecs.split(",").map(c=>_.Fu(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};Aw=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};
|
|
71
|
-
Cw=function(a,b){let c=null;b.some(d=>{c=_.Du(_.
|
|
70
|
+
Cw=function(a,b){let c=null;b.some(d=>{c=_.Du(_.Nh(d),a.map(e=>Cu(e)));return!!c});return c?a.filter(d=>c===Cu(d)):[]};Dw=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)})};
|
|
72
71
|
Ew=function(a){return 1>=a.a.chasingRate?(a.f.warn("chasingRate must be greater than 1."),!1):a.a.chaseJumpDistance<=a.a.startChasingAt?(a.f.warn("chaseJumpDistance must be greater than startChasingAt."),!1):a.a.startChasingAt<=a.a.stopChasingAt?(a.f.warn("startChasingAt must be greater than stopChasingAt."),!1):0>a.a.stopChasingAt?(a.f.warn("stopChasingAt must be greater than or equal to 0."),!1):!0};Fw=function(a,b){a.f=b};
|
|
73
|
-
Gw=function(a){a.f.stop();const b=a.h?0:a.g;0<=b?a.a.
|
|
72
|
+
Gw=function(a){a.f.stop();const b=a.h?0:a.g;0<=b?a.a.rd()!=b&&a.a.Ie(b):(a.f.Ua(.25),0!=a.a.rd()&&a.a.Ie(0))};Hw=function(a,b){a.f=b};Iw=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};
|
|
74
73
|
Jw=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.G&&(a.h=!1,a.G=a.a.readyState);var b=a.j.smallGapLimit,c=a.a.currentTime,d=a.a.buffered;a:{var e=new _.$o(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=Iw(d);d=d.a.currentTime;b=Date.now()/1E3;if(a.a!=d||a.j!=c)a.h=
|
|
75
|
-
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.F&&(f=d.start(e),!(f>=Xu(a.C)))){g=f-c;b=g<=b;var h=!1;if(!(.001>g)){if(!b&&!a.h){a.h=!0;const k=new _.C("largegap",{detail:{currentTime:c,gapSize:g}});k.cancelable=!0;a.B(k);a.j.jumpLargeGaps&&!k.defaultPrevented?h=!0:_.
|
|
76
|
-
Mw=function(a,b){a.o||(a.o=!0,a.m&&a.m());.001>Math.abs(a.a.currentTime-b)?Kw(a):(a.f.one(a.a,_.fe,()=>{Kw(a)}),Lw(a.g,0==a.a.currentTime?b:a.a.currentTime))};Nw=function(a,b){a.w=b;a.f.off(a.a,_.
|
|
77
|
-
Sw=function(a,b,c){if(!c.stallEnabled)return null;const d=c.gapDetectionThreshold;let e=c.stallSkip;c=new Qw(new Rw(b),c.stallThreshold);Hw(c,(f,g)=>{a.f.warn(`Stall detected at ${f} for ${g} seconds.`);if(e){g=new _.$o(b.buffered);var h;if(h=_.
|
|
74
|
+
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.F&&(f=d.start(e),!(f>=Xu(a.C)))){g=f-c;b=g<=b;var h=!1;if(!(.001>g)){if(!b&&!a.h){a.h=!0;const k=new _.C("largegap",{detail:{currentTime:c,gapSize:g}});k.cancelable=!0;a.B(k);a.j.jumpLargeGaps&&!k.defaultPrevented?h=!0:_.Hf("Ignoring large gap at",c,"size",g)}if(b||h)0==e?_.Hf(Lt,g,"seconds because of gap before start time of",f):_.Hf(Lt,g,"seconds because of gap starting at",d.end(e-1),"and ending at",f),a.a.currentTime=f}}}}};
|
|
75
|
+
Mw=function(a,b){a.o||(a.o=!0,a.m&&a.m());.001>Math.abs(a.a.currentTime-b)?Kw(a):(a.f.one(a.a,_.fe,()=>{Kw(a)}),Lw(a.g,0==a.a.currentTime?b:a.a.currentTime))};Nw=function(a,b){a.w=b;a.f.off(a.a,_.od);a.f.one(a.a,_.od,()=>{Mw(a,b)})};Ow=function(a){return a.j?a.a.currentTime:a.w};Pw=function(a,b){0<a.a.readyState?Lw(a.g,b):Nw(a,b)};Kw=function(a){_.bi()&&!a.j&&a.h();a.j=!0;a.f.on(a.a,_.fe,()=>a.h())};Lw=function(a,b){a.g=a.f.currentTime;a.j=b;a.h=a.m;a.f.currentTime=b;a.a.Ua(.1)};
|
|
76
|
+
Sw=function(a,b,c){if(!c.stallEnabled)return null;const d=c.gapDetectionThreshold;let e=c.stallSkip;c=new Qw(new Rw(b),c.stallThreshold);Hw(c,(f,g)=>{a.f.warn(`Stall detected at ${f} for ${g} seconds.`);if(e){g=new _.$o(b.buffered);var h;if(h=_.Wh("Edge/")||_.Wh("Trident/")||_.Xh()||_.bi())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)&&
|
|
78
77
|
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};Vw=function(a,b){null==b?b=Infinity>a.a.getDuration()?Yu(a.a,0):Xu(a.a):0>b&&(b=Xu(a.a)+b);return Tw(a,Uw(a,b))};Uw=function(a,b){const c=Yu(a.a,0);if(b<c)return c;a=Xu(a.a);return b>a?a:b};Ww=function(a){const b=Ow(a.g);return 0<a.h.readyState&&!a.h.paused?Uw(a,b):b};
|
|
79
78
|
Tw=function(a,b){const c=a.a.getDuration();return b>=c?c-a.m.durationBackoff:b};
|
|
80
|
-
Xw=function(a,b){var c=new _.$o(a.h.buffered);c=c.
|
|
79
|
+
Xw=function(a,b){var c=new _.$o(a.h.buffered);c=c.Wb.bind(c);var d=Math.max(a.B,a.m.rebufferingGoal);const e=a.m.safeSeekOffset;let f=Yu(a.a,0);const g=Xu(a.a),h=a.a.getDuration();3>g-f&&(f=g-3);const k=Yu(a.a,d),l=Yu(a.a,e);d=Yu(a.a,d+e);if(b>=h)return a.f.debug("Playhead past duration."),Tw(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>=
|
|
81
80
|
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};
|
|
82
|
-
Zw=function(a){a=_.
|
|
83
|
-
g.length||!c)throw _.
|
|
84
|
-
Yw=function(a,b,c,d,e){{var f=$w.value(),g=a.subarray(c.start,c.start+c.size);const k=_.
|
|
85
|
-
d=a.getUint32(b);a.setUint32(b,d+1);return h};ax=function(a,b,c){a=_.
|
|
86
|
-
kx=function(a,b,c,d,e){return _.w(function*(){var f=a.D.
|
|
87
|
-
nx=function(a){return _.mx(a,_.
|
|
88
|
-
hx=function(a,b){return _.w(function*(){var c=[];for(const d of b){const e=a.o.get(d.id);e?(a.a.debug("(all) Stream "+d.id+Ht),c.push(e.
|
|
89
|
-
d.id))})};ix=function(a,b,c){return{stream:a,type:a.type,
|
|
90
|
-
px=function(a,b){return _.w(function*(){yield a.D.
|
|
91
|
-
_.wx=function(a,b,c,d){const e=a.f.get(b.type);if(!e&&b.type==_.r&&a.j.ignoreTextStreamFailures)px(a,b);else if(e){var f=rx(a,b);if(c&&f!=e.
|
|
92
|
-
g.
|
|
81
|
+
Zw=function(a){a=_.H(a);let b=!1,c;const d=[],e=h=>{d.push(h);_.N(h)},f=()=>{b=!0},g=[];(new _.Mj).M(_.wd,e).M(_.we,e).M(_.rd,e).M(_.vd,e).M(_.me,e).X(_.oe,h=>{c=h;d.push(h);_.Gj(h)}).X("encv",f).X("enca",f).X("avc1",h=>{g.push({M:h,pc:1701733238})}).X("avc3",h=>{g.push({M:h,pc:1701733238})}).X("ac-3",h=>{g.push({M:h,pc:1701733217})}).X("ec-3",h=>{g.push({M:h,pc:1701733217})}).X("mp4a",h=>{g.push({M:h,pc:1701733217})}).parse(a);if(b)return _.Hf("Init segment already indicates encryption."),a;if(0===
|
|
82
|
+
g.length||!c)throw _.Jf("Failed to find boxes needed to fake encryption!"),_.Jf("Failed init segment (hex):",_.hj(a)),new _.G(_.F,3,14E3);g.reverse();for(const h of g)_.Hf(`Inserting "${_.Fj(h.pc)}" box into init segment.`),a=Yw(a,c,h.M,d,h.pc);return a};
|
|
83
|
+
Yw=function(a,b,c,d,e){{var f=$w.value(),g=a.subarray(c.start,c.start+c.size);const k=_.Fg(g);var h=new Uint8Array(c.size+f.byteLength);h.set(g,0);g=_.Fg(h);g.setUint32(4,e);h.set(f,c.size);e=k.getUint32(4);g.setUint32(c.size+16,e);ax(h,0,h.byteLength);e=h}h=new Uint8Array(a.byteLength+e.byteLength);c=_.Wh("Xbox One")||_.Vh()?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)ax(h,k.start,k.size+e.byteLength);a=_.Fg(h,b.start);b=_.Ij(b);
|
|
84
|
+
d=a.getUint32(b);a.setUint32(b,d+1);return h};ax=function(a,b,c){a=_.Fg(a,b);b=a.getUint32(0);0!=b&&(1==b?(a.setUint32(8,c>>32),a.setUint32(12,c&4294967295)):a.setUint32(0,c))};bx=function(a){return"("+a.type+":"+a.stream.id+")"};cx=function(a){return!a.Pa&&null==a.kb&&!a.zb&&!a.Qb};dx=function(a){null!=a.kb&&(a.kb.stop(),a.kb=null)};ex=function(a){return _.w(function*(){a.wb&&(yield a.wb.abort())})};fx=function(a,b){return(b=Nu(a.g.periods,b+_.No))?a.g.periods.indexOf(b):0};
|
|
85
|
+
kx=function(a,b,c,d,e){return _.w(function*(){var f=a.D.qb();const g=fx(a,f);f=new Map;const h=new Set;b&&(f.set(_.ac,b),h.add(b));c&&(f.set(_.u,c),h.add(c));d&&(f.set(_.r,d),h.add(d));yield a.D.Y.init(f,a.j.forceNativeTS);a.h||(gx(a),yield hx(a,h),a.h||f.forEach((k,l)=>{a.f.has(l)||(k=ix(k,g,e),a.f.set(l,k),jx(a,k,0))}))})};lx=function(a){var b=a.f.get(_.u);return b?a.g.periods[b.tb]:(b=a.f.get(_.ac))?a.g.periods[b.tb]:null};_.mx=function(a,b){return(a=a.f.get(b))?a.Jb||a.stream:null};
|
|
86
|
+
nx=function(a){return _.mx(a,_.ac)};ox=function(a){return _.mx(a,_.u)};
|
|
87
|
+
hx=function(a,b){return _.w(function*(){var c=[];for(const d of b){const e=a.o.get(d.id);e?(a.a.debug("(all) Stream "+d.id+Ht),c.push(e.P)):(a.a.debug("(all) setting up Stream "+d.id),a.o.set(d.id,{P:new _.Xk,rc:!1}),c.push(d.createSegmentIndex()))}try{if(yield Promise.all(c),a.h)return}catch(d){if(a.h)return;for(const e of b)a.o.get(e.id).P.catch(()=>{}),a.o.get(e.id).P.reject(),a.o.delete(e.id);throw d;}for(const d of b)c=a.o.get(d.id),c.rc||(c.P.resolve(),c.rc=!0,a.a.debug("(all) setup Stream "+
|
|
88
|
+
d.id))})};ix=function(a,b,c){return{stream:a,type:a.type,Hb:null,segmentIterator:null,oa:null,Jb:null,Ec:!0,tb:b,endOfStream:!1,Pa:!1,kb:null,zb:!1,Mc:0,cd:!1,Qb:!1,Od:!1,oc:!1,Ge:c||0,wb:null,Oc:!1,se:0}};jx=function(a,b,c){a.a.debug(bx(b),"updating in "+c+" seconds");b.kb=(new _.Xo(()=>_.w(function*(){try{yield a.vb(b)}catch(d){if(a.D)a.D.onError(d)}}))).ba(c)};
|
|
89
|
+
px=function(a,b){return _.w(function*(){yield a.D.Y.clear(_.r);a.G++;a.H=!1;var c=a.G,d=a.D.Y;const e=new Map,f=new Set;e.set(_.r,b);f.add(b);yield d.init(e,!1);a.h||(yield hx(a,f),a.h||(d=d.getTextDisplayer().isTextVisible()||a.j.alwaysStreamText,a.G!=c||a.f.has(_.r)||a.H||!d||(c=a.D.qb(),c=fx(a,c),c=ix(b,c,0),a.f.set(_.r,c),jx(a,c,0))))})};qx=function(a){a.H=!0;const b=a.f.get(_.r);b&&(dx(b),ex(b).catch(()=>{}),a.f.delete(_.r))};
|
|
90
|
+
_.wx=function(a,b,c,d){const e=a.f.get(b.type);if(!e&&b.type==_.r&&a.j.ignoreTextStreamFailures)px(a,b);else if(e){var f=rx(a,b);if(c&&f!=e.tb){a.a.debug("switch: switching to stream in another Period; clearing buffer and changing Periods");for(var g of a.f.values())sx(a,g)}else if(e.Jb&&(a.a.debug("switch during trick play mode",b),b.trickModeVideo?(e.Jb=b,b=b.trickModeVideo,a.a.debug("switch found trick play stream",b)):(e.Jb=null,a.a.debug("switch found no special trick play stream"))),(g=a.m[f])&&
|
|
91
|
+
g.rc&&(g=a.o.get(b.id))&&g.rc)if(e.stream!=b){g=a.g.presentationTimeline.getDuration();var h=a.D.qb();h=tx(a,e,h);!c&&(e.endOfStream||h>=g)?a.a.debug(hu+bx(e)+" already buffered to the end. Not switching."):(b.type==_.r&&xv(a.D.Y,_.Ph(b.mimeType,b.codecs)),e.stream=b,e.stream.segmentIterator=null,e.Ec=!0,a.a.debug("switch: switching to Stream "+bx(e)),ux(a,e,f)&&(a.a.info("Aborting current segment request to switch."),e.wb.abort()),c&&(e.Qb?e.cd=!0:e.Pa?(e.zb=!0,e.Mc=d,e.cd=!0):(dx(e),vx(a,e,!0,d).catch(k=>
|
|
93
92
|
{if(a.D)a.D.onError(k)}))))}else a.a.debug(hu+bx(e)+" already active")}};xx=function(a,b,c,d){b.video&&_.wx(a,b.video,c,d);b.audio&&_.wx(a,b.audio,c,d)};rx=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};
|
|
94
|
-
sx=function(a,b){const c=bx(b);b.
|
|
95
|
-
ux=function(a,b,c){if(!b.
|
|
96
|
-
vx=function(a,b,c,d){return _.w(function*(){const e=bx(b);b.
|
|
97
|
-
yx=function(a,b,c,d,e){if(b.stream.segmentLookupStrategy===_.zx)b.stream.segmentIterator?a=$u(b.stream.segmentIterator):b.
|
|
98
|
-
c),d=b.stream.segmentIterator.next().value),null===d&&a.a.warn(Kt,Vt,"lookupTime:",e,au,c),a=d);else{var f=bx(b);b.
|
|
99
|
-
Math.max(0,c-1))),a=f||Ax(a,b,e,c)))}return a};Cx=function(a){const b=a.D.
|
|
100
|
-
gx=function(a){const b=a.g.presentationTimeline.getDuration();Infinity>b?a.D.
|
|
101
|
-
Dx=function(a,b){let c=a.m[b];if(c)return a.a.debug("(all) Period "+b+Ht),c.
|
|
102
|
-
(a.m[b].
|
|
103
|
-
Gx=function(a,b){if(b.type==_.r&&b.stream.mimeType==_.
|
|
104
|
-
g,bu+d,"timeNeeded\x3d"+e,"currentPeriodIndex\x3d"+f),null;if(h>=k)return a.a.debug(c,"buffering goal met"),a.j.bufferLimitUpdateInterval||.5;g=a.D.
|
|
105
|
-
1;b.
|
|
106
|
-
Ix=function(a,b){const c=bx(b),d=rx(a,b.stream);if(b.
|
|
107
|
-
k.set(_.r,h.text);for(const l of a.f.keys())if(!k.has(l)&&l!=_.r){a.a.error(c,"invalid Streams chosen: missing "+l+" Stream");a.D.onError(new _.
|
|
108
|
-
a.D.
|
|
109
|
-
Fx=function(a,b,c,d,e){return _.w(function*(){const f=bx(b),g=a.g.periods[d];a.a.debug(f,"fetchAndAppend_:",bu+c,Xt+g.startTime,du+e.position,eu+e.startTime,cu+e.endTime);const h=b.stream,k=b.stream.segmentIterator;var l=a.g.presentationTimeline.getDuration();const m=a.g.periods[d+1];l=Jx(a,b,d,Math.max(0,g.startTime-.1),m?m.startTime+.01:l,e);b.
|
|
110
|
-
a.h||a.A?null:Lx(a,b,e,!1,
|
|
111
|
-
a.f.delete(_.r)):7001==
|
|
112
|
-
|
|
113
|
-
Bx=function(a,b,c,d){const e=bx(b);d=a.g.periods[d];a.a.debug(e,"
|
|
114
|
-
Jx=function(a,b,c,d,e,f){c=a.g.periods[c].startTime-f.
|
|
115
|
-
Fv(a.D.
|
|
116
|
-
Kx=function(a,b,c,d,e,f,g,h){h=void 0===h?!1:h;return _.w(function*(){const k=bx(b);if(e&&e.keyId&&a.D.
|
|
117
|
-
Promise.resolve();const m=e.closedCaptions&&0<e.closedCaptions.size;null!=e.emsgSchemeIdUris&&0<e.emsgSchemeIdUris.length&&(new _.
|
|
118
|
-
g,n,q,m,e.id,h)}).then(()=>{a.h||(a.a.debug(k,"appended media segment"),b.
|
|
119
|
-
Lx=function(a,b,c,d,e){d=void 0===d?!1:d;e=void 0===e?null:e;const f=_.Qu(c.
|
|
120
|
-
a.D.
|
|
121
|
-
Mx=function(a,b,c,d,e){if(!a.g.presentationTimeline.isLive()&&b.type!==_.r){const f=bx(b);c=(a.D.
|
|
122
|
-
Nx=function(a,b,c){if(!a.B){b=bx(b);var d=Array.from(a.f.values());1!=d.length||d[0].type!=_.r?a.B=d.every(e=>e.type==_.r||a.C?!0:!e.
|
|
123
|
-
Ox=function(a,b,c){const d=bx(b);if(Array.from(a.f.values()).some(e=>e!=b&&e.
|
|
124
|
-
Px=function(a,b,c,d){return _.w(function*(){let e=!0;1001===d.code&&500<=d.data.status||(e=!a.D.
|
|
125
|
-
Qx=function(a,b,c){return _.w(function*(){if(a.j.patchEdgeWhenMixedContent&&_.
|
|
126
|
-
Sx=function(a,b,c){if(a.h)return Promise.resolve();const d=bx(b);a.a.debug(d,"checking buffer length");const e=Math.max(a.j.bufferBehind,a.g.presentationTimeline.a),f=a.D.
|
|
127
|
-
f,f+h).then(()=>{a.h||a.a.debug(d,"evicted "+h+" seconds")})};Tx=function(a,b,c){(new _.
|
|
128
|
-
Vx=function(a){return _.w(function*(){const b=[];for(const c of a.f.values())dx(c),c.
|
|
129
|
-
Xx=function(a){const b=c=>c.video&&c.audio||c.video&&c.video.codecs.includes(",");if(a.some(c=>c.variants.some(b))){_.
|
|
130
|
-
lw=function(a,b){return _.w(function*(){if(a.
|
|
131
|
-
nw=function(a,b){if(a.a&&(a.f||a.w)){var c=ox(a.a),d=nx(a.a),e=Nu(a.f.periods,Ww(a.w)),f=a.f.periods[e?a.f.periods.indexOf(e):0].variants.filter(h=>h.audio.id==b&&Yv(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().
|
|
132
|
-
a.
|
|
133
|
-
pw=function(a,b,c){var d=void 0===d?0:d;if(a.f&&a.a){const f=Zx(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.
|
|
134
|
-
g.id==b.id);e?(a.
|
|
135
|
-
iy=function(a,b){a.h||(a.m.on(b,_
|
|
93
|
+
sx=function(a,b){const c=bx(b);b.Qb?a.a.debug(c,"clear: already clearing the buffer"):b.zb?a.a.debug(c,"clear: already waiting"):b.Pa?(a.a.debug(c,"clear: currently updating"),b.zb=!0,b.Mc=0):null==a.D.Y.lb(b.type)?(a.a.debug(c,"clear: nothing buffered"),null==b.kb&&jx(a,b,0)):(a.a.debug(c,"clear: handling right now"),dx(b),vx(a,b,!1,0).catch(d=>{if(a.D)a.D.onError(d)}))};tx=function(a,b,c){if(!b.Hb||!b.oa)return Math.max(c,b.Ge);c=rx(a,b.Hb);return a.g.periods[c].startTime+b.oa.endTime};
|
|
94
|
+
ux=function(a,b,c){if(!b.wb)return!1;const d=a.D.qb(),e=a.D.Y.va(b.type);c=(c=yx(a,b,d,e,c))?c.Ja?c.Ja-c.Ta+1:null:null;if(null==c)return!1;var f=b.stream.initSegmentReference;f&&(c+=(f.Ja?f.Ja-f.Ta+1:null)||0);f=a.D.pd().getBandwidthEstimate();if(8*c/f<(null===e?0:e-d)-Math.max(a.g.minBufferTime||0,a.j.rebufferingGoal))return!0;a=b.wb;a=a.h?a.h.bytesRemaining:-1;return 0>a||a>c?!0:!1};
|
|
95
|
+
vx=function(a,b,c,d){return _.w(function*(){const e=bx(b);b.zb=!1;b.cd=!1;b.Mc=0;b.Qb=!0;b.stream.segmentIterator=null;a.a.debug(e,"clearing buffer");if(d){var f=a.D.qb();const g=a.D.Y.getDuration();f=a.D.Y.remove(b.type,f+d,g)}else f=a.D.Y.clear(b.type).then(()=>!a.h&&c?a.D.Y.flush(b.type):null);yield f;a.h||(a.a.debug(e,"cleared buffer"),b.Hb=null,b.oa=null,b.Qb=!1,b.endOfStream=!1,b.Oc=!1,jx(a,b,0))})};
|
|
96
|
+
yx=function(a,b,c,d,e){if(b.stream.segmentLookupStrategy===_.zx)b.stream.segmentIterator?a=$u(b.stream.segmentIterator):b.oa||d?(e=b.oa?b.oa.endTime:d,a.a.info(Kt,"looking up segment from new stream endTime:",e),b.stream.segmentIterator=fv(b.stream.segmentIndex,e),d=b.stream.segmentIterator.next().value,null===d&&(b.stream.segmentIterator=null,a.a.warn(Kt,Vt,"endTime:",e,b.oa)),a=d):(e=Math.max(c,0),a.a.info(Kt,"looking up segment","lookupTime:",e,au,c),d=null,d||(b.stream.segmentIterator=fv(b.stream.segmentIndex,
|
|
97
|
+
c),d=b.stream.segmentIterator.next().value),null===d&&a.a.warn(Kt,Vt,"lookupTime:",e,au,c),a=d);else{var f=bx(b);b.oa&&b.stream==b.Hb?(d=b.oa.position+1,a.a.debug(f,"next position known:","position\x3d"+d),a=Ax(a,b,e,d)):(b.oa?(a.a.debug(f,"next position unknown: another Stream buffered"),c=rx(a,b.Hb),c=Bx(a,b,a.g.periods[c].startTime+b.oa.endTime,e)):(a.a.debug(f,"next position unknown: nothing buffered"),c=Bx(a,b,d||c,e)),null==c?a=null:(f=null,null!=d||null!==a.j&&a.j.ignoreDrift||(f=Ax(a,b,e,
|
|
98
|
+
Math.max(0,c-1))),a=f||Ax(a,b,e,c)))}return a};Cx=function(a){const b=a.D.qb(),c=g=>a.D.Y.Wb(g,b,0);let d=!1;const e=fx(a,b);if(_.sg(a.f.values(),g=>g.tb==e))for(const g of a.f.keys()){var f=a.f.get(g);f.stream.segmentIterator=null;c(g)||(sx(a,f),d=!0)}else if(!_.sg(a.f.keys(),c)){a.a.debug("(all): seeked: unbuffered seek: clearing all buffers");for(f of a.f.values())sx(a,f);d=!0}d||a.a.debug("(all): seeked: buffered seek: presentationTime\x3d"+b)};
|
|
99
|
+
gx=function(a){const b=a.g.presentationTimeline.getDuration();Infinity>b?a.D.Y.Lb(b):a.D.Y.Lb(Math.pow(2,32))};
|
|
100
|
+
Dx=function(a,b){let c=a.m[b];if(c)return a.a.debug("(all) Period "+b+Ht),c.P;a.a.debug("(all) setting up Period "+b);c={P:new _.Xk,rc:!1};a.m[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.F=a.F.then(()=>a.h?null:hx(a,d)).then(()=>{a.h||(a.m[b].P.resolve(),a.m[b].rc=!0,a.a.debug("(all) setup Period "+b))}).catch(e=>{a.h||
|
|
101
|
+
(a.m[b].P.catch(()=>{}),a.m[b].P.reject(),delete a.m[b],a.a.warn("(all) failed to setup Period "+b),a.D.onError(e))});return c.P};
|
|
102
|
+
Gx=function(a,b){if(b.type==_.r&&b.stream.mimeType==_.Tb)return Gv(a.D.Y,b.stream.originalId||""),null;var c=bx(b);const d=a.D.qb(),e=tx(a,b,d);a.a.debug(c,"timeNeeded\x3d"+e);const f=rx(a,b.stream);var g=fx(a,e),h=a.D.Y.za(b.type,d);a.a.debug(c,"update_:",bu+d,"bufferedAhead\x3d"+h);const k=Math.max(a.g.minBufferTime||0,a.j.rebufferingGoal,a.j.bufferingGoal)*a.w,l=Ru(a.g.presentationTimeline);if(null!=l&&e>=l&&!b.Oc)return Ex(a,b),null;b.endOfStream=!1;b.tb=g;if(g!=f)return a.a.debug(c,"need Period "+
|
|
103
|
+
g,bu+d,"timeNeeded\x3d"+e,"currentPeriodIndex\x3d"+f),null;if(h>=k)return a.a.debug(c,"buffering goal met"),a.j.bufferLimitUpdateInterval||.5;g=a.D.Y.va(b.type);g=yx(a,b,d,g,f);if(!g)return a.g.presentationTimeline.isLive()||b.type===_.r?a.j.bufferLimitUpdateInterval||1:(a.a.debug("Media state "+c+": no next segment found. Assuming EOS."),Ex(a,b),null);c=Infinity;for(const m of a.f.values())if(m.type!=_.r||m.stream.mimeType!=_.Tb)h=tx(a,m,d),c=Math.min(c,h);if(e>=c+a.g.presentationTimeline.a)return a.j.bufferLimitUpdateInterval||
|
|
104
|
+
1;b.Ge=0;Fx(a,b,d,f,g).catch(()=>{});return null};Hx=function(a,b){return _.w(function*(){if(!a.h){if(a.D.Je)try{yield a.D.Je(b)}catch(c){c.cause=b,b=c}if(!b.f)a.D.onError(b)}})};
|
|
105
|
+
Ix=function(a,b){const c=bx(b),d=rx(a,b.stream);if(b.tb!=d){var e=b.tb,f=Array.from(a.f.values());f.every(g=>g.tb==e)?f.every(cx)?(a.a.debug(c,"all need Period "+e),Dx(a,e).then(()=>{if(!a.h)if(f.every(l=>{const m=cx(l),n=rx(a,l.stream);return m&&l.tb==e&&n!=e})){var g=a.g.periods[e];a.a.debug(c,"calling onChooseStreams()...");var h=a.D.Hd(g);a.C=!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(_.ac,h.variant.audio);h.text&&
|
|
106
|
+
k.set(_.r,h.text);for(const l of a.f.keys())if(!k.has(l)&&l!=_.r){a.a.error(c,"invalid Streams chosen: missing "+l+" Stream");a.D.onError(new _.G(_.F,5,5005));return}for(const l of Array.from(k.keys()))if(!a.f.has(l))if(l==_.r)kx(a,null,null,k.get(_.r),g.startTime),k.delete(l);else{a.a.error(c,"invalid Streams chosen: unusable "+l+" Stream");a.D.onError(new _.G(_.F,5,5005));return}for(const l of Array.from(a.f.keys()))(g=k.get(l))?(_.wx(a,g,!1,0),jx(a,a.f.get(l),0)):a.f.delete(l);a.a.debug(c,Ut);
|
|
107
|
+
a.D.Gd()}else a.a.debug(c,"ignoring transition to Period",e,"since another is happening")}).catch(vu)):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)}};Ex=function(a,b){a.a.debug(bx(b),"buffered to end of presentation");b.endOfStream=!0;b.type==_.u&&(a=a.f.get(_.r))&&a.stream.mimeType==_.Tb&&(a.endOfStream=!0)};
|
|
108
|
+
Fx=function(a,b,c,d,e){return _.w(function*(){const f=bx(b),g=a.g.periods[d];a.a.debug(f,"fetchAndAppend_:",bu+c,Xt+g.startTime,du+e.position,eu+e.startTime,cu+e.endTime);const h=b.stream,k=b.stream.segmentIterator;var l=a.g.presentationTimeline.getDuration();const m=a.g.periods[d+1];l=Jx(a,b,d,Math.max(0,g.startTime-.1),m?m.startTime+.01:l,e);b.Pa=!0;b.Ec=!1;a.a.debug(f,"fetching segment");let n=!1;const q=(v,y)=>{if(a.h||a.A)return null;n=!0;return Kx(a,b,c,g,h,e,v,y)},t=a.D.Y.va(b.type)||0;l.then(()=>
|
|
109
|
+
a.h||a.A?null:Lx(a,b,e,!1,v=>q(v.data,!0))).then(v=>a.h||a.A?null:n||null===v?(Mx(a,b,t,e,h),null):q(v,!1)).then(()=>{if(!a.h&&!a.A){Mx(a,b,t,e,h);b.Pa=!1;b.Od=!1;b.zb||a.D.Zc();if(k){const v=k.next().value;v&&a.a.debug("New iterated segment",v)}jx(a,b,0);Nx(a,b,h);a.a.debug(f,"finished fetch and append")}}).catch(v=>_.w(function*(){a.h||a.A||(b.Pa=!1,b.type==_.r&&a.j.ignoreTextStreamFailures?(1001==v.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."),
|
|
110
|
+
a.f.delete(_.r)):7001==v.code?(b.Pa=!1,b.kb=null,jx(a,b,0)):3017===v.code?Ox(a,b,v):1001===v.code&&v.data&&404===v.data[1]?(a.a.warn(f,"request for segment failed","segment not available on server",du+e.position,eu+e.startTime,cu+e.endTime,"error\x3d"+v),b.Pa=!1,b.kb=null,jx(a,b,1)):b.type===_.r?(v instanceof _.G&&v.a(1),dx(b),a.D.onError(new _.G(1,2,2010,v))):1001<=v.code&&1003>=v.code?yield Px(a,b,g,v):(a.a.error(f,"failed fetch and append: code\x3d"+v.code),b.oc=!0,v instanceof _.G&&v.a(_.F),yield Hx(a,
|
|
111
|
+
v)))}))})};Ax=function(a,b,c,d){const e=bx(b);c=a.g.periods[c];const f=b.stream.getSegmentReference(d);if(!f)return a.a.debug(e,"segment does not exist:",Xt+c.startTime,"position\x3d"+d),null;var g=a.g.presentationTimeline;d=_.Wu(g);g=Vu(g);return!b.Oc&&(c.startTime+f.endTime<d||c.startTime+f.startTime>g)?(a.a.debug(e,"segment is not available:",Xt+c.startTime,eu+f.startTime,cu+f.endTime,"availabilityStart\x3d"+d,"availabilityEnd\x3d"+g),null):f};
|
|
112
|
+
Bx=function(a,b,c,d){const e=bx(b);d=a.g.periods[d];const f=Math.max(0,c-d.startTime);b=b.stream.findSegmentPosition(f);a.a.debug(e,"Looked up segment:",bu+c,"lookupTime\x3d"+f,Xt+d.startTime,"Result: segment position\x3d"+b);null==b&&a.a.warn(e,"cannot find segment:",Xt+d.startTime,"lookupTime\x3d"+f);return b};
|
|
113
|
+
Jx=function(a,b,c,d,e,f){c=a.g.periods[c].startTime-f.Ea;if(!b.Ec&&c===b.se)return Promise.resolve();b.se=c;const g=bx(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=Iv(a.D.Y,b.type,c,d,e);if(!b.stream.initSegmentReference||!b.Ec)return d;a.a.debug(g,"fetching init segment");e=Lx(a,b,b.stream.initSegmentReference,!0).then(h=>{if(a.h)return null;a.a.debug(g,"appending init segment");return Qx(a,h,b).then(()=>
|
|
114
|
+
Fv(a.D.Y,b.type,h,null,null,!!b.stream.closedCaptions&&0<b.stream.closedCaptions.size))}).catch(h=>{b.Ec=!0;return Promise.reject(h)});return Promise.all([d,e])};
|
|
115
|
+
Kx=function(a,b,c,d,e,f,g,h){h=void 0===h?!1:h;return _.w(function*(){const k=bx(b);if(e&&e.keyId&&a.D.xc){var l=qu(a.D.xc,e.keyId);if(l)try{yield l}catch(n){a.a.warn("DRM session load failed!",n)}else a.a.warn(`Unable to find DRM session for ${e.keyId}`)}if(e.encrypted&&e.keyId&&a.D.xc&&su(a.D.xc,e.keyId))return dx(b),l=rx(a,e),(l=Rx(a,l))&&(yield l),l=a.D.fd(e,d,Zt),a.a.warn(k,`Blocked append for ${f.startTime+d.startTime} - ${f.endTime+d.startTime}: ${l}. `+`Stream with Key ID ${e.keyId} has restrictions.`),
|
|
116
|
+
Promise.resolve();const m=e.closedCaptions&&0<e.closedCaptions.size;null!=e.emsgSchemeIdUris&&0<e.emsgSchemeIdUris.length&&(new _.Mj).X("emsg",a.I.bind(a,d,f,e.emsgSchemeIdUris)).parse(g);return Sx(a,b,c).then(()=>{if(a.h)return null;const n=f.startTime+d.startTime,q=f.endTime+d.startTime;a.a.debug(k,"Appending segment "+`with ${n.toFixed(3)} - ${q.toFixed(3)} `+`KeyID: ${e.keyId} `+`Width: ${e.width} Height: ${e.height} `+`Bitrate: ${_.Vg(e.bandwidth)} `+`Fragment: ${h}`);return Fv(a.D.Y,b.type,
|
|
117
|
+
g,n,q,m,e.id,h)}).then(()=>{a.h||(a.a.debug(k,"appended media segment"),b.Hb=e,b.oa=f)})})};
|
|
118
|
+
Lx=function(a,b,c,d,e){d=void 0===d?!1:d;e=void 0===e?null:e;const f=_.Qu(c.Ca(),c.Ta,c.Ja,a.j.attemptParameters,c.startTime,c.endTime,b.type,c.timescale);f.type=2;f.onFragment=c.ic?null:e;f.disableFragmentSupport=c.ic||a.j.disableFragmentSupport;f.disableMergedFragments=a.j.disableMergedFragments;if(e=c.f())f.keyInfo=e,f.onFragment=null;d&&(f.responseModifiers.push(g=>{Tx(a,b,g.data)}),b.type===_.u&&a.j.overridePasp&&f.responseModifiers.push(a.J.bind(a)));a.a.debug("fetching: reference\x3d",c);c=
|
|
119
|
+
a.D.ub.fetch(f);b.wb=c;return c.P.then(g=>{const h=a.D.pd(),k=g.timeMs,l=g.data.byteLength;k&&l&&!d&&h.segmentDownloaded(k,l);b.wb=null;return g.data})};
|
|
120
|
+
Mx=function(a,b,c,d,e){if(!a.g.presentationTimeline.isLive()&&b.type!==_.r){const f=bx(b);c=(a.D.Y.va(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.Oc=!0,e.adjustSegmentDurations(d.position,h))}};
|
|
121
|
+
Nx=function(a,b,c){if(!a.B){b=bx(b);var d=Array.from(a.f.values());1!=d.length||d[0].type!=_.r?a.B=d.every(e=>e.type==_.r||a.C?!0:!e.zb&&!e.Qb&&e.oa):a.C&&(a.B=!0);a.B&&(a.a.debug(b,"startup complete"),c=rx(a,c),Rx(a,c))}};
|
|
122
|
+
Ox=function(a,b,c){const d=bx(b);if(Array.from(a.f.values()).some(e=>e!=b&&e.Od))a.a.debug(d,Mt,"waiting for another stream to recover...");else{const e=Math.round(100*a.w);if(20<e)a.w-=.2;else if(4<e)a.w-=.04;else{a.a.error(d,"MediaSource threw QuotaExceededError too many times");b.oc=!0;a.A=!0;a.D.onError(c);return}a.a.warn(d,Mt,"reducing buffering goals by "+(100-Math.round(100*a.w))+"%");b.Od=!0}jx(a,b,4)};
|
|
123
|
+
Px=function(a,b,c,d){return _.w(function*(){let e=!0;1001===d.code&&500<=d.data.status||(e=!a.D.fd(b.stream,c));e&&(b.oc=!0,d.a(_.F),yield Hx(a,d))})};Ux=function(a,b){b=void 0===b?!1:b;if(a.h)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.f.values()){const d=bx(c);if(c.oc||b&&cx(c))a.a.info(d,"Retrying after failure..."),c.oc=!1,jx(a,c,.1)}};
|
|
124
|
+
Qx=function(a,b,c){return _.w(function*(){if(a.j.patchEdgeWhenMixedContent&&_.Vh()){const d=Zw(b);yield Fv(a.D.Y,c.type,d.buffer,null,null,!!c.stream.closedCaptions&&0<c.stream.closedCaptions.size)}})};Rx=function(a,b){let c=null;a.m[b]||(c=Dx(a,b).then(()=>{a.h||(a.a.debug(Ut),a.D.Gd())}).catch(vu));for(b=0;b<a.g.periods.length;++b)Dx(a,b).catch(vu);a.D.Gf&&(a.a.debug("calling onStartupComplete()..."),a.D.Gf());return c};
|
|
125
|
+
Sx=function(a,b,c){if(a.h)return Promise.resolve();const d=bx(b);a.a.debug(d,"checking buffer length");const e=Math.max(a.j.bufferBehind,a.g.presentationTimeline.a),f=a.D.Y.lb(b.type);if(null==f)return a.a.debug(d,"buffer behind okay because nothing buffered:",bu+c,St+e),Promise.resolve();const g=c-f,h=g-e;if(.01>=h)return a.a.debug(d,"buffer behind okay:",bu+c,Tt+g,St+e,"underflow\x3d"+Math.abs(h)),Promise.resolve();a.a.debug(d,"buffer behind too large:",bu+c,Tt+g,St+e,"overflow\x3d"+h);return a.D.Y.remove(b.type,
|
|
126
|
+
f,f+h).then(()=>{a.h||a.a.debug(d,"evicted "+h+" seconds")})};Tx=function(a,b,c){(new _.Mj).M(_.wd,_.N).M(_.we,_.N).M(_.rd,_.N).M(_.vd,_.N).M(_.me,_.N).X(_.oe,_.Gj).M("encv",d=>{d.reader.skip(78);_.N(d)}).M(_.he,_.N).M("schi",_.N).M("tenc",d=>{d.reader.skip(6);if(_.yj(d.reader)){d.reader.skip(1);const e=_.hj(_.Dj(d.reader,16));e!==b.stream.keyId&&(a.a.debug(bx(b),"Key id from tenc mismatches with key id from manifest. Switching from "+`${b.stream.keyId} to ${e}.`),b.stream.keyId=e)}d.parser.stop()}).parse(c)};
|
|
127
|
+
Vx=function(a){return _.w(function*(){const b=[];for(const c of a.f.values())dx(c),c.Pa&&c.wb&&(c.Pa=!1,b.push(c.wb.abort())),c.zb&&b.push(vx(a,c,!0,0));yield Promise.all(b)})};Wx=function(a,b,c){(a=a.f.get(b))&&c&&(dx(a),a.stream=c,a.Hb=c,a.oa&&(a.oa=c.getSegmentReference(a.oa.position)),a.oa||(a.Hb=null))};
|
|
128
|
+
Xx=function(a){const b=c=>c.video&&c.audio||c.video&&c.video.codecs.includes(",");if(a.some(c=>c.variants.some(b))){_.If("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)}};
|
|
129
|
+
lw=function(a,b){return _.w(function*(){if(a.wd!=b&&(a.wd=b,a.C===Yx&&(a.H.getTextDisplayer().setTextVisibility(b),!a.configuration.streaming.alwaysStreamText)))if(b){var c=Zx(a);c=_.$v(c.textStreams,a.Z,a.ka);0<c.length&&(yield px(a.a,c[0]))}else qx(a.a)})};mw=function(a,b){if(a.f&&a.a){const c=Zx(a),d=c.textStreams.find(e=>e.id==b.id);d?($x(a,c,d,!1),ay(a,d),a.Z=d.language):a.log.error(_.Nt,b.id)}};
|
|
130
|
+
nw=function(a,b){if(a.a&&(a.f||a.w)){var c=ox(a.a),d=nx(a.a),e=Nu(a.f.periods,Ww(a.w)),f=a.f.periods[e?a.f.periods.indexOf(e):0].variants.filter(h=>h.audio.id==b&&Yv(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().Da();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;
|
|
131
|
+
a.Wa=d.id;a.g.setVariants(f);f=Zx(a);by(a,f,e,!1);g||a.N?cy(a,e,!0,0):_.wx(a.a,d,!0,0);Promise.resolve();return}a.log.warn("Target audio codecs not compatible with active audio codecs.")}}Promise.reject()};ow=function(a){if(a.f&&a.w){const b=dy(a),c=[];for(const d of ey(a))a=Wv(d),a.active=d==b,c.push(a);return c}return[]};
|
|
132
|
+
pw=function(a,b,c){var d=void 0===d?0:d;if(a.f&&a.a){const f=Zx(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=fy(a,f.variants);null!=a.W&&(a.Va=a.W,a.W=null);null==c||a.N||gy(a,c);return}if(b){a.L=b.id;var e=f.variants.find(g=>
|
|
133
|
+
g.id==b.id);e?(a.L=e.video.id,Yv(e)?(by(a,f,e,!1),cy(a,e,c,d),null==a.W&&(a.W=a.Va),a.Va=new hy(e),fy(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.W&&(a.Va=a.W,a.W=null),c=fy(a,f.variants),null==c||a.N||gy(a,c)}};qw=function(a){const b=a.wd;return a.f?a.H.getTextDisplayer().isTextVisible():b};
|
|
134
|
+
iy=function(a,b){a.h||(a.m.on(b,_.$c,()=>{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 _.G(_.F,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()};
|
|
136
135
|
ky=function(a){return new _.jy(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})};
|
|
137
|
-
ly=function(a,b){if(a.
|
|
138
|
-
b===_.
|
|
139
|
-
ny=function(a){return _.w(function*(){a.C!==my&&(a.C=ry);const b=a.h;b&&(a.m.off(b,_.
|
|
140
|
-
null);a.
|
|
141
|
-
Fy=function(a){a.A&&a.A.configure(a.configuration.manifest);a.j&&wy(a);if(a.a){a.a.j=a.configuration.streaming;try{for(var b of a.f.periods)
|
|
142
|
-
Gy=function(a,b){return _.w(function*(){const c=a.getNetworkEngine();a.A=yield _.
|
|
143
|
-
Ky=function(a,b){return _.w(function*(){a.
|
|
144
|
-
a.f.presentationTimeline.
|
|
145
|
-
Oy=function(a){return _.w(function*(){a.j=new _.
|
|
146
|
-
if(k.length){k=a.getPeriods();for(let t=0;t<k.length;t++){const
|
|
147
|
-
(h=!0)}}}if(f=lx(a.a))if(l=nx(a.a),m=ox(a.a),l=aw(l,m,f.variants),!l||l.allowedByKeySystem)a.log.info(Jt),My(a),fy(a,f.variants);h&&f!==g&&(a.log.info(Jt),My(a),fy(a,g.variants))}},onExpirationUpdated:(f,g)=>{if(a.A&&a.A.onExpirationUpdated)a.A.onExpirationUpdated(f,g);a.trigger(new _.C(_.
|
|
148
|
-
f&&(yield f.o(b,e,a.getNetworkEngine()),d=yield f.m(c))}yield _.
|
|
149
|
-
bz=function(a){return _.w(function*(){const b=a.h;var c=e=>{a.h&&a.F&&(e.type===_.fe&&a.Vc?(a.F.a=Py,sy(a)):e.type===_.Pe&&a.getState()===_.
|
|
150
|
-
[],a.configuration.preferredAudioRole,a.configuration.preferredAudioChannelCount);a
|
|
151
|
-
Qv(a.f,_
|
|
152
|
-
fy(a,d.variants);a.m.one(b,_.
|
|
153
|
-
Jy=function(a){return{networkingEngine:a.getNetworkEngine(),filterNewPeriod:b=>
|
|
154
|
-
Ny=function(a,b){var c=a.a?nx(a.a):null;const d=a.a?ox(a.a):null;for(const e of b)Vv(a.j,c,d,e);c=Au(b,e=>e.variants.some(Yv));if(0==c)throw new _.
|
|
155
|
-
Qy=function(a){switch(a.C){case Yx:a:if(a.h.ended||zv(a.
|
|
156
|
-
|
|
157
|
-
Ty=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.
|
|
158
|
-
emsgSchemeIdUris:null,roles:g.roles,channelsCount:null,closedCaptions:null};e.set(h,k)}}for(const f of e.values())d.textStreams.push(f)}};gy=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=gz(a,b);hz(a,e,()=>by(a,e,b,!0));e===Zx(a)&&iz(a);a.a&&xx(a.a,b,c,d)}};Vy=function(a,b){return new jz(a.h,a.f,a.configuration.streaming,b,()=>{a.
|
|
159
|
-
Wy=function(a){const b=new kz(a.f);Fw(b,()=>{My(a)});const c=new lz(a.
|
|
160
|
-
$y=function(a){const b={
|
|
136
|
+
ly=function(a,b){if(a.U!==b)if(a.U===_.Ol&&b!==_.Pl)b=zu(b,_.Nl),a.log.info(_.Ot+`${b}`);else{var c=a.zd;c=0===c?0:Date.now()-c;var d=a.U;a.U=b;a.zd=Date.now();a.G&&_.yl(a.G.a,a.U);b===_.Kl&&(a.xe=a.td?1:2);var e=a.xe,f={currentState:a.U,previousState:d,timeSinceLastStateChangeMS:c,reason:b===_.Kl||d===_.Kl?e:void 0},g=zu(d,_.Nl),h=zu(b,_.Nl),k=b!==_.Kl?"":`[${zu(e,_.Ml)}]`;a.log.info(`Player state change: ${g} -> `+`${h}${k}`);a.trigger(new _.C(_.ke,{detail:f}));(b===_.Hl||b===_.Ol)&&a.aa&&a.aa.stop();
|
|
137
|
+
b===_.Kl?a.trigger(new _.C(_.nc,{detail:{bufferedTimeMS:-1,reason:e}})):d===_.Kl&&a.trigger(new _.C(_.mc,{detail:{bufferedTimeMS:c,reason:e}}))}};qy=function(a){var b=!1;b=void 0===b?!0:b;return _.w(function*(){if(a.C===my)return Promise.reject(new _.G(_.F,7,7E3));yield ny(a);yield oy(a);var c=_.Xh(4)||_.Xh(5);if(b||c)c=a.getSurface().getMedia(),yield iy(a,c),yield py(a,c)})};oy=function(a){a.h&&(a.m.off(a.h,_.$c),a.h=null);return Promise.resolve()};
|
|
138
|
+
ny=function(a){return _.w(function*(){a.C!==my&&(a.C=ry);const b=a.h;b&&(a.m.off(b,_.nd),a.m.off(b,_.Td),a.m.off(b,_.Od),a.m.off(b,_.Zc),a.m.off(b,_.Yd),a.m.off(b,_.Wd));a.Ya&&(a.Ya.release(),a.Ya=null);a.aa&&(a.aa.stop(),a.aa=null);a.A&&(yield a.A.stop(),a.A=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.Qc&&(a.Qc.release(),a.Qc=null);b&&b.src&&(b.removeAttribute("src"),b.load());a.j&&(yield a.j.destroy(),a.j=
|
|
139
|
+
null);a.K.clear();a.F=null;a.Rc.clear();a.f=null;a.G=null;a.N=!0;a.Ab.clear();a.Ob=!1;sy(a)})};py=function(a,b){return _.w(function*(){var c=window.muxjs?new ty:new _.uy;const d=_.xl(a.configuration,["html","single-native"]);a.I=d.create(a);a.Pb=ky(a);a.Pb.track(a);c=new _.vy(b,c,a.I,a.Pb,a.configuration);yield c.H;a.H=c})};
|
|
140
|
+
Fy=function(a){a.A&&a.A.configure(a.configuration.manifest);a.j&&wy(a);if(a.a){a.a.j=a.configuration.streaming;try{for(var b of a.f.periods)xy(a,b)}catch(e){a.onError(e)}var c=nx(a.a);const d=ox(a.a);b=Zx(a)||a.f.periods[0];c=aw(c,d,b.variants);a.g&&c&&c.allowedByApplication&&c.allowedByKeySystem?fy(a,b.variants):(a.log.debug("Choosing new streams after changing configuration"),Ey(a,b))}a.g&&(a.g.configure(a.configuration.abr),a.configuration.abr.enabled&&!a.N?a.g.enable():a.g.disable())};
|
|
141
|
+
Gy=function(a,b){return _.w(function*(){const c=a.getNetworkEngine();a.A=yield _.Hn(b.url,c,a.configuration.manifest.attemptParameters,b.type||null);a.A.configure(a.configuration.manifest)})};
|
|
142
|
+
Ky=function(a,b){return _.w(function*(){a.Ha=new Hy;Zu(a.Ha,c=>{Iy(a,_.Tf,c)});yield(new _.dm(Promise.resolve().then(()=>_.w(function*(){for(;!a.f;)try{a.f=yield a.A.start(b.url,Jy(a))}catch(c){if(a.ca){const d=yield a.ca(b.url,c);if(d)b.url=d;else throw c;}else throw c;}!a.f.presentationTimeline||a.configuration.manifest.hlsLowLatency||_.z(a.configuration.suggestedPresentationDelay)||isNaN(a.configuration.suggestedPresentationDelay)||(a.log.info("Apply suggested presentation delay of: "+a.configuration.suggestedPresentationDelay),
|
|
143
|
+
a.f.presentationTimeline.Md=a.configuration.suggestedPresentationDelay);a.f.presentationTimeline&&(a.f.presentationTimeline.C=!!a.configuration.lowLatencyMode);if(0==a.f.periods.length)throw new _.G(_.F,4,4014);Xx(a.f.periods)})),()=>{a.log.info("Aborting parser step...");return a.A.stop()})).P})};
|
|
144
|
+
Oy=function(a){return _.w(function*(){a.j=new _.am({ub:a.getNetworkEngine(),onError:f=>a.onError(f),Kd:f=>{if(a.a){var g=Zx(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.");
|
|
145
|
+
if(k.length){k=a.getPeriods();for(let t=0;t<k.length;t++){const v=k[t];for(var m of v.variants){var n=m;var q=[];n.audio&&q.push(n.audio);n.video&&q.push(n.video);n=q;for(const y of n)n=m.allowedByKeySystem,y.keyId&&(q=f[l?"00":y.keyId],q=!!q&&!Ly.includes(q),m.allowedByKeySystem=q),n!==m.allowedByKeySystem&&(q=y.type,y.type===_.u&&(q=`video ${y.width}x${y.height}@`+`${_.Vg(y.bandwidth)}`),a.log.warn("DRM Key not available for "+`KID: '${y.keyId}'. Applying restrictions to ${q}`)),v===g&&n!==m.allowedByKeySystem&&
|
|
146
|
+
(h=!0)}}}if(f=lx(a.a))if(l=nx(a.a),m=ox(a.a),l=aw(l,m,f.variants),!l||l.allowedByKeySystem)a.log.info(Jt),My(a),fy(a,f.variants);h&&f!==g&&(a.log.info(Jt),My(a),fy(a,g.variants))}},onExpirationUpdated:(f,g)=>{if(a.A&&a.A.onExpirationUpdated)a.A.onExpirationUpdated(f,g);a.trigger(new _.C(_.Rc,{expirationTime:g}))},onEvent:f=>a.yd(f),getConfiguration:()=>a.getConfiguration(),nc:()=>a.nc()});wy(a);const b=a.configuration.drm,c=b?b.offlineId||"":"";let d=[];const e=_.Fn(a.f.periods);if(c){const f=_.$i(_.Pd);
|
|
147
|
+
f&&(yield f.o(b,e,a.getNetworkEngine()),d=yield f.m(c))}yield _.Wk(a.j,e,d);a.f&&Ny(a,a.f.periods)})};
|
|
148
|
+
bz=function(a){return _.w(function*(){const b=a.h;var c=e=>{a.h&&a.F&&(e.type===_.fe&&a.Vc?(a.F.a=Py,sy(a)):e.type===_.Pe&&a.getState()===_.Sl&&.1>a.getBufferInfo().za(a.getPosition())?(a.F.a=Py,sy(a)):a.F&&Qy(a));Ry(a)};a.m.on(b,_.Td,c);a.m.on(b,_.Od,c);a.m.on(b,_.Zc,c);a.m.on(b,_.fe,c);a.m.on(b,_.ee,c);a.m.on(b,_.Wd,c);a.m.on(b,_.Pe,c);a.m.on(b,_.Yd,()=>{if(a.h){var e=a.h.playbackRate;0!=e&&a.Xa.set(e)}});a.g||(a.g=new _.Sy,a.g.configure(a.configuration.abr));Ty(a,a.f.periods);a.Va=new Uy(a.configuration.preferredAudioLanguage||
|
|
149
|
+
[],a.configuration.preferredAudioRole,a.configuration.preferredAudioChannelCount);a.Z=a.configuration.preferredTextLanguage;a.ka=a.configuration.preferredTextRole;yield _.ml(a.j,b);if(!a.j)throw new _.G(_.F,7,7001);a.g.init((e,f,g)=>{!a.N&&gy(a,e,f,g)});a.w=Vy(a,a.configuration.startTime);a.Ya=Wy(a);a.Xa=new Xy({rd:()=>b.playbackRate,Ie:e=>{b.playbackRate=e},Ef:e=>{b.currentTime+=e}});a.isLive()&&a.configuration.streaming.enableLiveEdgeChasing&&(a.Qc=new Yy(a));Zy(a,Math.max(1E-4,a.configuration.streaming.rebufferingGoal));
|
|
150
|
+
Qv(a.f,_.$f(a.configuration.preferredVideoCodec),_.$f(a.configuration.preferredAudioCodec),a.configuration.preferredAudioChannelCount);a.a=$y(a);a.a.j=a.configuration.streaming;a.C=Yx;yield a.a.start();if(!a.a)throw new _.G(_.F,7,7001);a.configuration.streaming.startAtSegmentBoundary&&(c=az(a,Ww(a.w)),Pw(a.w.g,c));for(var d of a.f.periods)xy(a,d);My(a);d=Zx(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");
|
|
151
|
+
fy(a,d.variants);a.m.one(b,_.nd,()=>{a.G.w=Date.now()/1E3-(null===a.xd?0:a.xd)})})};sy=function(a){if(a.G&&a.F&&a.w){const c=cz(a)===_.Kl;var b=a.Xa;b.h=c;Gw(b);a.w.j.m=c;Ry(a)}};Iy=function(a,b,c){a.trigger(new _.C(b,{detail:{schemeIdUri:c.schemeIdUri,value:c.value,startTime:c.startTime,endTime:c.endTime,id:c.id,eventElement:c.eventElement,type:c.type}}))};
|
|
152
|
+
Jy=function(a){return{networkingEngine:a.getNetworkEngine(),filterNewPeriod:b=>xy(a,b),filterAllPeriods:b=>Ny(a,b),onTimelineCueAdded:b=>{var c=a.Ha;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.yd(b),onError:b=>a.onError(b)}};wy=function(a){const b=_.qj(a.configuration.drm);a.j.h=b};
|
|
153
|
+
Ny=function(a,b){var c=a.a?nx(a.a):null;const d=a.a?ox(a.a):null;for(const e of b)Vv(a.j,c,d,e);c=Au(b,e=>e.variants.some(Yv));if(0==c)throw new _.G(_.F,4,4032);if(c<b.length)throw new _.G(_.F,4,4011);for(const e of b)Sv(e.variants,a.configuration.restrictions,a.He)&&a.a&&Zx(a)==e&&My(a),dz(a,e.variants)};
|
|
154
|
+
Qy=function(a){switch(a.C){case Yx:a:if(a.h.ended||zv(a.H))var b=!0;else{if(a.isLive()){b=Vu(a.f.presentationTimeline);var c=a.getBufferInfo();if(null!==c&&(c=c.va(),null!==c&&c>=b)){b=!0;break a}}b=!1}break;default:b=!1}if(a.H){var d=Bv(a.H);c=d.video;d=d.audio;var e=a.h.currentTime;c&&d?(c=c.za(e),d=d.za(e),c=Math.min(c,d)):c=c?c.za(e):d?d.za(e):0}else c=0;if(d=a.F){{d=a.F;var f=b;const g=d.f.get(d.a);e=d.a;c=f||c>=g?ez:Py;d.a=c;d=e!=c}}c=d;d=fz(a);c||a.getState()===_.Kl&&!d?(a.log.debug("Buffering state changed. Is buffering",
|
|
155
|
+
d,"buffered to end",b,"state",a.getState()),sy(a)):a.Ob&&Ry(a)};Ry=function(a){ly(a,cz(a))};
|
|
156
|
+
Ty=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.Ke++,originalId:h,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:()=>null,getSegmentReference:()=>null,initSegmentReference:null,Ea:0,mimeType:_.Tb,codecs:"",kind:"caption",encrypted:!1,keyId:null,language:g.closedCaptions.get(h),label:null,type:_.r,primary:!1,trickModeVideo:null,
|
|
157
|
+
emsgSchemeIdUris:null,roles:g.roles,channelsCount:null,closedCaptions:null};e.set(h,k)}}for(const f of e.values())d.textStreams.push(f)}};gy=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=gz(a,b);hz(a,e,()=>by(a,e,b,!0));e===Zx(a)&&iz(a);a.a&&xx(a.a,b,c,d)}};Vy=function(a,b){return new jz(a.h,a.f,a.configuration.streaming,b,()=>{a.Ya&&hv(a.Ya,!0);a.a&&Cx(a.a)},c=>a.dispatchEvent(c))};
|
|
158
|
+
Wy=function(a){const b=new kz(a.f);Fw(b,()=>{My(a)});const c=new lz(a.Ha);iv(c,e=>{e.Yc&&e.Yc();Iy(a,_.Vf,e)},e=>{e.Jd&&e.Jd();Iy(a,_.Wf,e)},(e,f)=>{f||(e.Yc&&e.Yc(),Iy(a,_.Vf,e),e.Jd&&e.Jd(),Iy(a,_.Wf,e))});const d=new mz(a.h);d.a.add(b);d.a.add(c);return d};Zy=function(a,b){a.F=new nz(b,Math.min(.5,b/2));a.F.a=Py;sy(a);a.aa=(new _.Th(()=>{Qy(a)})).Ua(.25)};
|
|
159
|
+
$y=function(a){const b={qb:()=>Ww(a.w),Y:a.H,ub:a.getNetworkEngine(),Hd:a.$f.bind(a),Gd:a.Zf.bind(a),onError:a.onError.bind(a),ye:a.Pe.bind(a),onEvent:a.yd.bind(a),Ce:a.ag.bind(a),Zc:a.Qe.bind(a),pd:()=>a.g,fd:a.Yf.bind(a),Je:a.Se.bind(a),xc:a.j};return new _.oz(a.f,b)};
|
|
161
160
|
az=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=nx(a.a);var e=ox(a.a);const f=Zx(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};
|
|
162
|
-
|
|
161
|
+
xy=function(a,b){var c=a.a?nx(a.a):null;const d=a.a?ox(a.a):null;Vv(a.j,c,d,b);c=b.variants;if(!c.some(Yv))throw new _.G(_.F,4,4011);dz(a,b.variants);Sv(c,a.configuration.restrictions,a.He)&&a.a&&Zx(a)==b&&My(a);if(!_.Xh(2)&&(b=a.j?a.j.getDrmInfo():null))for(const e of c)for(const f of e.drmInfos)if(f.keySystem===b.keySystem)for(const g of f.initData||[])_.$k(a.j,g.keyId,g.initData)||_.bl(a.j,g.initDataType,g.initData,g.keyId)};
|
|
163
162
|
My=function(a){const b=a.getTrackManager();b&&a.C!==my&&(b.l&&(sw(b),b.l.trigger(new _.C(_.Zo))),iz(a))};Zx=function(a){const b=Ww(a.w);let c=null;for(const d of a.f.periods)d.startTime<=b&&(c=d);return c};
|
|
164
|
-
fy=function(a,b){try{dz(a,b)}catch(d){return a.onError(d),null}b=b.filter(d=>Yv(d));b=ew(b,a.
|
|
165
|
-
fz=function(a){return a.j&&a.j.B?!0:a.F?a.F.getState()===Py:!1};Ey=function(a,b,c){c=void 0===c?!0:c;const d=fy(a,b.variants);a.
|
|
166
|
-
qz=function(a){const b=Zx(a);if(null==b)return[];pz(a);return b.textStreams.filter(c=>!a.Rc.has(c))};$x=function(a,b,c,d){yw(a.
|
|
167
|
-
by=function(a,b,c,d){var e=a.getTrackManager();a.A.setCurrentVariant(c);if(e){var f=a.G.A;if(c.video){tw(e,c.video,d);var g=e.
|
|
168
|
-
b).variant=c};cy=function(a,b,c,d){c=void 0===c?!1:c;d=void 0===d?0:d;a.
|
|
169
|
-
dz=function(a,b){a=a.j?_.
|
|
170
|
-
pz=function(a){if(a.a&&a.f){var b=lx(a.a),c=Zx(a);null!=b&&b==c&&(nx(a.a),ox(a.a),_.mx(a.a,_.r),xw(a.
|
|
171
|
-
rz=function(a,b){a.
|
|
172
|
-
hz=function(a,b,c){a.
|
|
173
|
-
sz=function(a,b,c){return _.w(function*(){let d;try{d=yield _.
|
|
174
|
-
a.configuration.preferredAudioChannelCount);const k=fw(f,g,h.variants),l=_.$v(h.textStreams,a
|
|
163
|
+
fy=function(a,b){try{dz(a,b)}catch(d){return a.onError(d),null}b=b.filter(d=>Yv(d));b=ew(b,a.Wa);var c=a.Va.create(b);c=Array.from(c.values());a.g.setVariants(c);if(null!==a.L&&null!==a.Wa&&(c=c.find(d=>d.video.id==a.L&&d.audio.id==a.Wa),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())};
|
|
164
|
+
fz=function(a){return a.j&&a.j.B?!0:a.F?a.F.getState()===Py:!1};Ey=function(a,b,c){c=void 0===c?!0:c;const d=fy(a,b.variants);a.Wa=d&&d.audio&&d.audio.id;d&&(by(a,b,d,!0),cy(a,d,c));(c=_.$v(b.textStreams,a.Z,a.ka)[0]||null)&&(a.configuration.streaming.alwaysStreamText||qw(a))&&($x(a,b,c,!0),ay(a,c))};dy=function(a){const b=Zx(a);return b&&xw(a.K,b).variant};ey=function(a){const b=Zx(a);if(null==b)return[];pz(a);return b.variants.filter(c=>Yv(c))};
|
|
165
|
+
qz=function(a){const b=Zx(a);if(null==b)return[];pz(a);return b.textStreams.filter(c=>!a.Rc.has(c))};$x=function(a,b,c,d){yw(a.K,b,c);if(b=a.getTrackManager())tw(b,c,d),c=b.Ba(),a=a.G.A,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}))};ay=function(a,b){a.N?a.S=b:_.wx(a.a,b,!0,0)};
|
|
166
|
+
by=function(a,b,c,d){var e=a.getTrackManager();a.A.setCurrentVariant(c);if(e){var f=a.G.A;if(c.video){tw(e,c.video,d);var g=e.ga(),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&&(tw(e,c.audio,d),e=e.Aa(),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})))}xw(a.K,
|
|
167
|
+
b).variant=c};cy=function(a,b,c,d){c=void 0===c?!1:c;d=void 0===d?0:d;a.N?(a.V=b,a.Fe=c,a.Ee=d):xx(a.a,b,c,d)};
|
|
168
|
+
dz=function(a,b){a=a.j?_.uf(a.j.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])?Ly.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 _.G(_.F,4,4012,{hasAppRestrictions:e,missingKeys:f,restrictedKeyStatuses:g});};
|
|
169
|
+
pz=function(a){if(a.a&&a.f){var b=lx(a.a),c=Zx(a);null!=b&&b==c&&(nx(a.a),ox(a.a),_.mx(a.a,_.r),xw(a.K,c),xw(a.K,c))}};cz=function(a){const b=a.getDuration(),c=a.getPosition();return a.h&&a.h.ended||(a.Ob||a.U===_.Hl)&&1>=Math.abs(b-c)?_.Hl:fz(a)||a.Vc?_.Kl:a.h&&a.h.paused?_.Rl:_.Sl};
|
|
170
|
+
rz=function(a,b){a.N=!0;a.g.disable();a.log.debug("Choosing new streams after period changed");let c=fy(a,b.variants),d=_.$v(b.textStreams,a.Z,a.ka)[0]||null;a.V&&(b.variants.includes(a.V)&&(c=a.V),a.V=null);a.S&&(b.textStreams.includes(a.S)&&(d=a.S),a.S=null);c&&hz(a,b,()=>by(a,b,c,!0));d&&(a.configuration.streaming.alwaysStreamText||qw(a))&&hz(a,b,()=>$x(a,b,d,!0));b===Zx(a)&&iz(a);return a.configuration.streaming.alwaysStreamText||qw(a)?{variant:c,text:d}:{variant:c,text:null}};
|
|
171
|
+
hz=function(a,b,c){a.Ab.has(b)||a.Ab.set(b,[]);a.Ab.get(b).push(c)};iz=function(a){const b=Zx(a);if(b){const c=a.Ab.get(b)||[];for(a.Ab.delete(b);c.length;)c.shift()()}};gz=function(a,b){for(const c of a.f.periods)if(c.variants.includes(b))return c;return null};
|
|
172
|
+
sz=function(a,b,c){return _.w(function*(){let d;try{d=yield _.Hn(b.url,a.getNetworkEngine(),a.configuration.manifest.attemptParameters,b.type||null);d.configure(a.configuration.manifest);var e=yield d.start(b.url,Jy(a));Xx(e.periods);if(!e.periods.length)throw new _.G(_.F,4,4014);yield a.A.stop();a.A=d;const f=c.audio&&c.audio.id,g=c.video&&c.video.id;a.f.periods=e.periods;const h=Nu(e.periods,Ww(a.w))||e.periods[0];Qv(a.f,_.$f(a.configuration.preferredVideoCodec),_.$f(a.configuration.preferredAudioCodec),
|
|
173
|
+
a.configuration.preferredAudioChannelCount);const k=fw(f,g,h.variants),l=_.$v(h.textStreams,a.Z,a.ka)[0]||null;fy(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);Wx(a.a,_.ac,n);Wx(a.a,_.u,m);Wx(a.a,_.r,l);k&&by(a,h,k,!1);a.log.info("Switch CDN successful.")}catch(f){throw d&&(yield d.stop()),f;}})};
|
|
175
174
|
tz=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)}};
|
|
176
175
|
uz=function(){const a=MediaSource.isTypeSupported;MediaSource.isTypeSupported=b=>"mp2t"==b.split(/ *; */)[0].split("/")[1].toLowerCase()?!1:a(b)};vz=function(){const a=MediaSource.prototype.addSourceBuffer;MediaSource.prototype.addSourceBuffer=function(...b){b=a.apply(this,b);b.abort=function(){};return b}};wz=function(){const a=SourceBuffer.prototype.remove;SourceBuffer.prototype.remove=function(b,c){return a.call(this,b,c-.001)}};
|
|
177
|
-
xz=function(){const a=MediaSource.isTypeSupported;MediaSource.isTypeSupported=b=>"opus"!=_.Fu(b)[0]&&a(b)};yz=function(a,b){const c=a.mode;a.mode=c==_.ge?_.ge:_.
|
|
178
|
-
_.jy=class{constructor(a){this.
|
|
179
|
-
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
|
|
180
|
-
Math.min(e.start,c);if(e.start<=a&&e.end>a){a=.1>e.end-a&&d<b-1?this
|
|
181
|
-
_.Az=class{constructor(a,b,c,d,e){this.
|
|
182
|
-
_.Bz=class{constructor(a,b,c,d,e){e=void 0===e?!1:e;this.o=a;this.
|
|
183
|
-
Hy=class{constructor(){this.f=()=>{};this.a=new Set}release(){this.f=()=>{};this.a.clear()}cues(){return this.a}};ev=class{constructor(a,b,c){this.g=a;this.a=b;this.f=c;new _.O("clpp.media.SegmentIterator")}next(){var a=this.g.get(this.a);a&&0<a.a.length?(this.f+=1,a.
|
|
176
|
+
xz=function(){const a=MediaSource.isTypeSupported;MediaSource.isTypeSupported=b=>"opus"!=_.Fu(b)[0]&&a(b)};yz=function(a,b){const c=a.mode;a.mode=c==_.ge?_.ge:_.dd;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};mu=[112,115,115,104,0,0,0,0];
|
|
177
|
+
_.jy=class{constructor(a){this.j=a;this.log=new _.O("clpp.renditions");this.$=[];this.h=this.a=null;this.g=!1}track(a){null!=this.a&&(this.a&&(this.a.off(_.ce,this.f),this.g&&this.a.off(_.ve,this.f)),this.a=null);a&&(this.a=a,this.a.on(_.ce,this.f,this))}append(a,b,c){const d=this.j?this.j(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.$.find(f=>f.start>=a&&f.end<=b);if(e)e.rendition=
|
|
178
|
+
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.$)a>=f.start&&a<f.end?f.end=a:b>=f.start&&b<f.end&&(f.start=b);this.$.push(c);this.$.sort(Iu)}Lu(this);this.f();this.a&&this.a.trigger(new _.C(_.Ke))}clear(){this.$=[];Lu(this);this.a&&(this.a.trigger(new _.C(_.Ke)),this.a.trigger(new _.C(_.fc)))}f(){if(this.a){var a=this.a.getPosition();if(0<=a){a:{var b=this.$.length,c=Number.MAX_SAFE_INTEGER;for(var d=0;d<b;d++){const e=this.$[d];c=
|
|
179
|
+
Math.min(e.start,c);if(e.start<=a&&e.end>a){a=.1>e.end-a&&d<b-1?this.$[d+1].rendition:e.rendition;break a}if(e.start>a)break}a=0<b&&c>a&&.25>c-a?this.$[0].rendition:null}if(a&&this.h!==a&&(this.h=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 _.C(_.hc,{detail:{width:b,height:c,bandwidth:a?a.bandwidth:null,rendition:a}}))}}}}};_.zz=class{constructor(a){this.g=Math.exp(Math.log(.5)/a);this.f=this.a=0}};
|
|
180
|
+
_.Az=class{constructor(a,b,c,d,e){this.Ca=a;this.Ta=b;this.Ja=c;this.keyInfo=d||null;this.ic=_.z(e)?!1:!!e}f(){return this.keyInfo}};_.bv=class{constructor(a,b,c,d,e,f,g,h,k,l=null,m=null,n=null,q=null,t=[]){this.position=a;this.startTime=b;this.endTime=c;this.Ea=g;this.Ca=d;this.Ta=e;this.Ja=f;this.keyInfo=h||null;this.ic=_.z(k)?!1:!!k;this.timescale=l;this.horizontalTiles=m;this.verticalTiles=n;this.durationPerTile=q;this.a=t||[];this.g=!1}getPosition(){return this.position}f(){return this.keyInfo}};
|
|
181
|
+
_.Bz=class{constructor(a,b,c,d,e){e=void 0===e?!1:e;this.o=a;this.Md=b;this.Zb=this.g=Infinity;this.a=1;this.w=0;this.f=this.h=null;this.A=0;this.m=this.j=c;this.F=void 0===d?!0:d;this.B=new _.O("clpp.media.PresentationTimeline");this.C=e}getDuration(){return this.g}Lb(a){this.g=a}getPresentationStartTime(){return this.o}offset(a){null!=this.h&&(this.h+=a);null!=this.f&&(this.f+=a)}isLive(){return Infinity==this.g&&!this.j}};
|
|
182
|
+
Hy=class{constructor(){this.f=()=>{};this.a=new Set}release(){this.f=()=>{};this.a.clear()}cues(){return this.a}};ev=class{constructor(a,b,c){this.g=a;this.a=b;this.f=c;new _.O("clpp.media.SegmentIterator")}next(){var a=this.g.get(this.a);a&&0<a.a.length?(this.f+=1,a.Ca().length&&this.f===a.a.length&&(this.a+=1,this.f=0)):(this.a+=1,this.f=0);a=$u(this);return{value:a,done:!a}}};
|
|
184
183
|
_.Cz=class{constructor(a){this.a=a;this.h=new _.O("clpp.media.SegmentIndex")}destroy(){this.a=[];return Promise.resolve()}f(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.h.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.h.debug("SegmentIndex Ref "+a+" start: "+b.startTime+" end: "+b.endTime+" pos: "+
|
|
185
|
-
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.h.info("Apply offset"+a+" to segment index");for(const b of this.a)b.startTime+=a,b.endTime+=a,b.
|
|
186
|
-
this.a[0].startTime}replace(a){this.a=a}};mz=class{constructor(a){this.f=a;this.a=new Set;this.g=(new _.
|
|
187
|
-
lz=class{constructor(a){this.j=a;this.h=new Map;this.a=()=>{};this.f=()=>{};this.g=()=>{};this.o=[{
|
|
188
|
-
a>c.endTime?3:2;this.h.set(c,e);const f=this.o.find(g=>g.
|
|
189
|
-
wv=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))})}
|
|
190
|
-
this.a&&a<this.f}
|
|
191
|
-
{video:_.
|
|
192
|
-
_.vy=class{constructor(a,b,c,d,e){this.j=a;this.B=c;this.f={};this.
|
|
193
|
-
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.F={};this.G=null;this.
|
|
194
|
-
!b||d.keyInfo)&&qv(f,e)){c.A[e]=new Dz;f="aac"==f.toLowerCase().split(";")[0].split("/")[1]?f.replace(/aac/i,_.
|
|
195
|
-
(a=Av(this,a))?a.va():null}
|
|
196
|
-
a,this.
|
|
197
|
-
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)}}
|
|
198
|
-
Gt);this.w(a)}
|
|
199
|
-
a,b,c),c;}this.a.debug("Done Setting timestamp offset for "+a,b);this.w(a)}
|
|
200
|
-
this.a.debug("Update-End received for "+a),Jv(this,a))}getTextDisplayer(){return this.B}};uv=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}initialize(a){this.l=a}release(){this.h=[];this.a.clear();this.f.clear()}load(){}destroy(){this.release();this.l=null}getVideoTracks(){return gw(this,_.K)}getAudioTracks(){return gw(this,_.J)}
|
|
201
|
-
null}
|
|
202
|
-
T.prototype.addTextTrack=T.prototype.addTextTrack;T.prototype.setTextRendition=T.prototype.
|
|
203
|
-
T.prototype.getLoadingAudioRendition=T.prototype.
|
|
184
|
+
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.h.info("Apply offset"+a+" to segment index");for(const b of this.a)b.startTime+=a,b.endTime+=a,b.Ea-=a}g(a,b){a-=this.a[0].position;if(0<=a&&a<this.a.length)for(this.h.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-
|
|
185
|
+
this.a[0].startTime}replace(a){this.a=a}};mz=class{constructor(a){this.f=a;this.a=new Set;this.g=(new _.Th(()=>{hv(this,!1)})).Ua(.25)}release(){this.g.stop();for(const a of this.a)a.release();this.a.clear()}};
|
|
186
|
+
lz=class{constructor(a){this.j=a;this.h=new Map;this.a=()=>{};this.f=()=>{};this.g=()=>{};this.o=[{ec:null,dc:2,Ub:(b,c)=>this.a(b,c)},{ec:1,dc:2,Ub:(b,c)=>this.a(b,c)},{ec:3,dc:2,Ub:(b,c)=>this.a(b,c)},{ec:2,dc:1,Ub:(b,c)=>this.f(b,c)},{ec:2,dc:3,Ub:(b,c)=>this.f(b,c)},{ec:1,dc:3,Ub:(b,c)=>this.g(b,c)},{ec:3,dc:1,Ub:(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:
|
|
187
|
+
a>c.endTime?3:2;this.h.set(c,e);const f=this.o.find(g=>g.ec===d&&g.dc===e);f&&f.Ub(c,b)}}};
|
|
188
|
+
wv=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))})}lb(){return this.a}va(){return this.f}Wb(a){return null==this.a||null==this.f?!1:a>=
|
|
189
|
+
this.a&&a<this.f}za(a){return null==this.f||this.f<a?0:this.f-Math.max(a,this.a)}};ty=class{constructor(){this.a=new muxjs.mp4.CaptionParser;this.j=[];this.h={}}init(a){const b=muxjs.mp4.probe;a=_.H(a);this.j=b.videoTrackIds(a);this.h=b.timescale(a);this.a.init()}g(a,b){a=_.H(a);(a=this.a.parse(a,this.j,this.h))&&a.captions&&b(a.captions);this.a.clearParsedCaptions()}f(){this.a.resetCaptionStream()}};_.uy=class{init(){}g(){}f(){}};var Dz=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===_.ac&&this.j.push(b)}o(){const a=
|
|
190
|
+
{video:_.jj(...this.m),captions:this.g,audio:_.jj(...this.j)};this.f.resolve(a);this.h=!1}};var uv;
|
|
191
|
+
_.vy=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 _.uo;this.I=!1;this.A={};this.G=b;this.C=d;this.L=e;this.V=this.L.streaming.maxSegmentToMediaOffset||1;this.H=new _.Xk;this.F={};this.m=vv(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(vu));for(b=1;b<d.length;++b)d[b].p.catch(vu),d[b].p.reject()}this.g&&a.push(this.g.destroy());
|
|
192
|
+
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.F={};this.G=null;this.K=!1;for(const c in this.h);this.h={}})}init(a,b){const c=this;return _.w(function*(){yield c.H;a.forEach((d,e)=>{var f=_.Ph(d.mimeType,d.codecs);if(e==_.r)xv(c,f);else{let g=new Map;g.set(e,f);if((!MediaSource.isTypeSupported(f)||
|
|
193
|
+
!b||d.keyInfo)&&qv(f,e)){c.A[e]=new Dz;f="aac"==f.toLowerCase().split(";")[0].split("/")[1]?f.replace(/aac/i,_.xd):pv(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(_.ac,`audio/mp4;codecs="${l}"`);g=0<k.size?k:f}catch(h){g=f}}yv(c,g)}})})}lb(a){return a===_.r?this.g.lb():(a=Av(this,a))?a.lb():null}va(a){return a===_.r?this.g.va():
|
|
194
|
+
(a=Av(this,a))?a.va():null}Wb(a,b,c){return a===_.r?this.g.Wb(b):(a=Av(this,a))?a.Wb(b,!1,c):!1}za(a,b){return a===_.r?this.g.za(b):(a=Av(this,a))?a.za(b):0}remove(a,b,c){return a===_.r?this.g.remove(b,c):Ev(this,a,this.R.bind(this,a,b,c)).then(()=>{if(a===_.u){var d=this.lb(a);const e=this.va(a);null!==d&&null!==e&&Mu(this.C,d,e)}else a===_.ac&&(d=this.C,d.a&&d.a.trigger(new _.C(_.fc)))})}clear(a){if(a==_.r){if(!this.g)return Promise.resolve();this.G.f();return this.g.remove(0,Infinity)}return Ev(this,
|
|
195
|
+
a,this.R.bind(this,a,0,this.m.duration))}flush(a){return a==_.r?Promise.resolve():Ev(this,a,this.N.bind(this,a))}endOfStream(a){return Kv(this,()=>{zv(this)||(a?this.m.endOfStream(a):this.m.endOfStream())})}Lb(a){Kv(this,()=>{this.m.duration=a})}getDuration(){return this.m.duration}J(a,b){this.a.debug("Appending data to "+a+Gt);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+Gt)}R(a,b,c){if(c<=b)this.w(a);else{this.a.debug("Removing data from "+
|
|
196
|
+
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+Gt);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+Gt,b),b;}this.a.debug("Done Aborting operations for "+a+
|
|
197
|
+
Gt);this.w(a)}N(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 "+
|
|
198
|
+
a,b,c),c;}this.a.debug("Done Setting timestamp offset for "+a,b);this.w(a)}W(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 _.G(_.F,3,3014,{mediaError:this.j.error?this.j.error.code:0}))}w(a){const b=this.h[a][0];b&&(b.p.resolve(),
|
|
199
|
+
this.a.debug("Update-End received for "+a),Jv(this,a))}getTextDisplayer(){return this.B}};uv=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}initialize(a){this.l=a}release(){this.h=[];this.a.clear();this.f.clear()}load(){}destroy(){this.release();this.l=null}getVideoTracks(){return gw(this,_.K)}getAudioTracks(){return gw(this,_.J)}ha(){return gw(this,_.I)}ga(){return this.a.get(_.K)||null}Aa(){return this.a.get(_.J)||null}Ba(){return this.a.get(_.I)||null}Na(){return this.f.get(_.K)||null}ab(){return this.f.get(_.J)||
|
|
200
|
+
null}bb(){return this.f.get(_.I)||null}Da(){return hw(this,_.K)}la(){return hw(this,_.J)}ma(){return hw(this,_.I)}Sa(a){jw(this,_.K,a)}qa(a){jw(this,_.J,a)}ya(a){jw(this,_.I,a)}Ra(a,b){iw(this,_.K,a,void 0===b?!1:b)}hb(a,b){iw(this,_.J,a,void 0===b?!1:b)}ib(a,b){iw(this,_.I,a,void 0===b?!1:b)}addTextTrack(a){const b=this;return _.w(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;
|
|
201
|
+
T.prototype.addTextTrack=T.prototype.addTextTrack;T.prototype.setTextRendition=T.prototype.ib;T.prototype.setAudioRendition=T.prototype.hb;T.prototype.setVideoRendition=T.prototype.Ra;T.prototype.setTextTrack=T.prototype.ya;T.prototype.setAudioTrack=T.prototype.qa;T.prototype.setVideoTrack=T.prototype.Sa;T.prototype.getTextTrack=T.prototype.ma;T.prototype.getAudioTrack=T.prototype.la;T.prototype.getVideoTrack=T.prototype.Da;T.prototype.getLoadingTextRendition=T.prototype.bb;
|
|
202
|
+
T.prototype.getLoadingAudioRendition=T.prototype.ab;T.prototype.getLoadingVideoRendition=T.prototype.Na;T.prototype.getTextRendition=T.prototype.Ba;T.prototype.getAudioRendition=T.prototype.Aa;T.prototype.getVideoRendition=T.prototype.ga;T.prototype.getTextTracks=T.prototype.ha;T.prototype.getAudioTracks=T.prototype.getAudioTracks;T.prototype.getVideoTracks=T.prototype.getVideoTracks;var Ez=class{constructor(){this.f=new _.zz(2);this.g=new _.zz(5);this.a=0}};_.Sy=class{constructor(){this.f=new _.O("clpp.abr");this.w=null;this.j=!1;this.g=new Ez;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=vw(!this.B&&this.a.initialRestrictions?this.a.initialRestrictions:this.a.restrictions,this.o);const b=uw(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."),
|
|
204
203
|
a=vw(null,this.o),a=[a[0]]);let c=a[0]||null;for(const {item:e,next:f}of _.yu(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:",
|
|
205
204
|
"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;_.Ou(c.f,a,d);_.Ou(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...");
|
|
206
|
-
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(uw(this.g,this.a.defaultBandwidthEstimate)/1E3)+" kbps");this.w(b)}}playbackRateChanged(a){this.m=a}getBandwidthEstimate(){return uw(this.g,this.a.defaultBandwidthEstimate)}setVariants(a){this.o=a}configure(a){this.a=a}reset(){this.A=!1;this.g=new Ez;const a=this.chooseVariant();a&&this.w(a)}};var Fz=class{constructor(){this.a=new Map}clear(){this.a.clear()}},ww=class{constructor(){this.text=this.variant=null}};var Gz=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(Bw(this.f,a))return this.a.add(a),!0;_.B("Rejecting variant - not compatible with root.");return!1}values(){return this.a.values()}};var hy=class{constructor(a){this.a=a;this.f=new Uy(a.language,"",a.audio&&a.audio.channelsCount?a.audio.channelsCount:0)}create(a){const b=a.filter(c=>Bw(this.a,c));return b.length?new Gz(b[0],b):this.f.create(a)}},Uy=class{constructor(a,b,c){this.g=_
|
|
207
|
-
(a=b));this.f&&(b=Mv(a,this.f),b.length?a=b:_.B("No exact match for the channel count could be found."));b=new Gz(a[0]);for(const c of a)Bw(b.f,c)&&b.add(c);return b}};var nz=class{constructor(a,b){this.a=ez;this.f=(new Map).set(ez,b).set(Py,a)}getState(){return this.a}},Py=0,ez=1;var Yy=class{constructor(a){this.D=a;this.a=a.getConfiguration().streaming;this.g=new _.
|
|
208
|
-
this.D.setPlaybackRate(this.a.chasingRate)):1<d&&b<=e&&(this.f.debug("On live edge, reduce playback rate."),this.D.setPlaybackRate(1))}}))}release(){this.g.release()}};var kz=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=Nu(c,a)||c[0]}b!=a&&this.f(a);this.a=a}};var Xy=class{constructor(a){this.a=a;this.h=!1;this.g=this.a.
|
|
209
|
-
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 jz=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 Hz(a,b.presentationTimeline,c,Sw(this,a,c),f);this.g=new Jz(a,()=>{a:{var g=this.j;g.A=!0;g.w=!1;g.h=!1;g=Ow(this.g);const h=Xw(this,g);if(.001<Math.abs(h-g)){const k=(new Date).getTime()/1E3;if(!this.w||this.w<k-1){this.w=k;Pw(this.g,h);g=void 0;break a}}this.f.debug("Seek to "+g);this.A();g=void 0}return g},Vw(this,d),()=>{this.j.F=!0});this.o=(new _.
|
|
210
|
-
{if(0!=this.h.readyState&&!this.h.paused){var g=Ow(this.g),h=Yu(this.a,0),k=Xu(this.a);3>k-h&&(h=k-3);g<h&&(h=Xw(this,g),this.f.info("Jumping forward "+(h-g)+" seconds to catch up with the seek range."),this.h.currentTime=h)}})).
|
|
211
|
-
if(!c.variant&&!c.text)throw a.a.error("init: no Streams chosen"),new _.
|
|
212
|
-
a,a.
|
|
213
|
-
b.startTime+h/g;c.includes(e)&&("urn:mpeg:dash:event:2012"==e?this.D.
|
|
214
|
-
d.
|
|
215
|
-
this.configuration.preferredAudioChannelCount);this
|
|
216
|
-
a&&a.release();return this.C===my?Promise.resolve():qy(this).then(()=>{this.log.debug(_
|
|
217
|
-
d(g)})}catch(e){a.
|
|
218
|
-
this.f.presentationTimeline.getDuration():Infinity}destroy(){const a=this,b=()=>Object.getPrototypeOf(Object.getPrototypeOf(this)).destroy;return _.w(function*(){yield b().call(a);a.C!==my&&(a.log.debug("Destroying player..."),a.C=my,yield oy(a),a.m&&(a.m.release(),a.m=null),a.g=null)})}load(a){const b=this;return _.w(function*(){if(b.C===my)return Promise.reject(new _.
|
|
219
|
-
if(b.
|
|
220
|
-
d();yield py(b,f);b.
|
|
221
|
-
0),end:Xu(a)}}return{start:0,end:0}}getPlaybackRate(){if(this.
|
|
222
|
-
d),a.
|
|
223
|
-
a.h=c}if(this.C===Yx){if(b=dy(this))this.G.m=b.bandwidth;b&&b.video&&(a=this.G,c=b.video.height||NaN,a.o=b.video.width||NaN,a.g=c);a=this.g.getBandwidthEstimate();this.G.f=a}return this.G.getStats()}getTimelineCues(){return this.
|
|
224
|
-
Error("State error!");const h=Zx(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 _.
|
|
225
|
-
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.Rc.add(k);h.textStreams.push(k);yield px(g.a,k);const n=_.mx(g.a,_.r);n&&yw(g.
|
|
226
|
-
a.textStreams);const b=rz(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}}}
|
|
227
|
-
c?"":c)===Zt)return My(this),this.
|
|
228
|
-
this.
|
|
229
|
-
d=b.
|
|
230
|
-
_.
|
|
231
|
-
_.
|
|
232
|
-
"middle"}d.writingMode===_.Ge?e.vertical="lr":d.writingMode===_.He&&(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;yz(this.a,c=>c.startTime<b&&c.endTime>a);return!0}isTextVisible(){return this.a.mode==_.ge}setTextVisibility(a){null!==this.a&&(this.a.mode=a?_.ge:_.
|
|
233
|
-
yz(this.a,()=>!0);this.a=null;return Promise.resolve()}};_.
|
|
205
|
+
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(uw(this.g,this.a.defaultBandwidthEstimate)/1E3)+" kbps");this.w(b)}}playbackRateChanged(a){this.m=a}getBandwidthEstimate(){return uw(this.g,this.a.defaultBandwidthEstimate)}setVariants(a){this.o=a}configure(a){this.a=a}reset(){this.A=!1;this.g=new Ez;const a=this.chooseVariant();a&&this.w(a)}};var Fz=class{constructor(){this.a=new Map}clear(){this.a.clear()}},ww=class{constructor(){this.text=this.variant=null}};var Gz=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(Bw(this.f,a))return this.a.add(a),!0;_.B("Rejecting variant - not compatible with root.");return!1}values(){return this.a.values()}};var hy=class{constructor(a){this.a=a;this.f=new Uy(a.language,"",a.audio&&a.audio.channelsCount?a.audio.channelsCount:0)}create(a){const b=a.filter(c=>Bw(this.a,c));return b.length?new Gz(b[0],b):this.f.create(a)}},Uy=class{constructor(a,b,c){this.g=_.$f(a);this.a=b;this.f=c}create(a){var b=Cw(a,this.g);0<b.length&&(a=b);b=!1;if(this.a){const c=Dw(a,this.a);0<c.length?(a=c,b=!0):_.B("No exact match for preferred variant role could be "+`found. Role: ${this.a}`)}b||(b=a.filter(c=>c.primary),0<b.length&&
|
|
206
|
+
(a=b));this.f&&(b=Mv(a,this.f),b.length?a=b:_.B("No exact match for the channel count could be found."));b=new Gz(a[0]);for(const c of a)Bw(b.f,c)&&b.add(c);return b}};var nz=class{constructor(a,b){this.a=ez;this.f=(new Map).set(ez,b).set(Py,a)}getState(){return this.a}},Py=0,ez=1;var Yy=class{constructor(a){this.D=a;this.a=a.getConfiguration().streaming;this.g=new _.uo;this.f=new _.O("clpp.mse.media.LiveEdgeObserver");Ew(this)&&(a=this.D.getSurface().getMedia(),this.g.on(a,_.ve,()=>{{var b=this.D.getPosition();const c=this.D.getSeekRange().end;b=c-b;const d=this.D.getPlaybackRate(),e=this.a.stopChasingAt;1<=d&&b>=this.a.chaseJumpDistance?(this.f.debug("Too far from edge, jump to beginning."),this.D.setPlaybackRate(1),this.D.seek(c)):1===d&&b>=this.a.startChasingAt?(this.f.debug("Not on live edge, increase playback rate."),
|
|
207
|
+
this.D.setPlaybackRate(this.a.chasingRate)):1<d&&b<=e&&(this.f.debug("On live edge, reduce playback rate."),this.D.setPlaybackRate(1))}}))}release(){this.g.release()}};var kz=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=Nu(c,a)||c[0]}b!=a&&this.f(a);this.a=a}};var Xy=class{constructor(a){this.a=a;this.h=!1;this.g=this.a.rd();this.f=new _.Th(()=>{this.a.Ef(.25*this.g)})}release(){this.f&&(this.f.stop(),this.f=null);this.a=null}set(a){this.g=a;Gw(this)}};var Qw=class{constructor(a,b){this.g=a;this.j=Iw(a);this.a=a.a.currentTime;this.h=Date.now()/1E3;this.m=b;this.f=()=>{}}release(){this.g=null;this.f=()=>{}}},Rw=class{constructor(a){this.a=a}};var Hz=class{constructor(a,b,c,d,e){this.a=a;this.C=b;this.j=c;this.B=e;this.g=new _.uo;this.A=!1;this.G=a.readyState;this.h=!1;this.f=d;this.m=this.F=this.w=!1;this.g.on(a,_.Pe,()=>Jw(this));this.o=(new _.Th(()=>{Jw(this)})).Ua(.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}Zc(){this.w=!0;Jw(this)}};var Jz=class{constructor(a,b,c,d){this.a=a;this.h=b;this.m=d;this.w=c;this.j=!1;this.f=new _.uo;this.g=new Iz(a,10);this.o=!1;0<a.readyState?Mw(this,c):Nw(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}},Iz=class{constructor(a,b){this.f=a;this.m=b;this.j=this.g=this.h=0;this.a=new _.Th(()=>{0>=this.h?(_.B(["Failed to move playhead from",this.g,"to",this.j].join(" ")),this.a.stop()):this.f.currentTime!=
|
|
208
|
+
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 jz=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 Hz(a,b.presentationTimeline,c,Sw(this,a,c),f);this.g=new Jz(a,()=>{a:{var g=this.j;g.A=!0;g.w=!1;g.h=!1;g=Ow(this.g);const h=Xw(this,g);if(.001<Math.abs(h-g)){const k=(new Date).getTime()/1E3;if(!this.w||this.w<k-1){this.w=k;Pw(this.g,h);g=void 0;break a}}this.f.debug("Seek to "+g);this.A();g=void 0}return g},Vw(this,d),()=>{this.j.F=!0});this.o=(new _.Th(()=>
|
|
209
|
+
{if(0!=this.h.readyState&&!this.h.paused){var g=Ow(this.g),h=Yu(this.a,0),k=Xu(this.a);3>k-h&&(h=k-3);g<h&&(h=Xw(this,g),this.f.info("Jumping forward "+(h-g)+" seconds to catch up with the seek range."),this.h.currentTime=h)}})).Ua(.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 $w=new _.xp(()=>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]));_.oz=class{constructor(a,b){this.D=b;this.g=a;this.j=null;this.w=1;this.F=Promise.resolve();this.m=[];this.o=new Map;this.f=new Map;this.H=this.h=this.A=this.B=!1;this.G=0;this.a=new _.O("clpp.mse.Streaming");this.C=!1}destroy(){const a=this;return _.w(function*(){const b=[];for(const c of a.f.values())dx(c),b.push(ex(c));yield Promise.all(b);a.f.clear();a.o.clear();a.D=null;a.g=null;a.F=null;a.m=null;a.j=null;a.h=!0})}start(){const a=this;return _.w(function*(){const b=a.D.qb();var c=fx(a,b);c=a.D.Hd(a.g.periods[c]);
|
|
210
|
+
if(!c.variant&&!c.text)throw a.a.error("init: no Streams chosen"),new _.G(_.F,5,5005);a.C=!c.variant&&!!c.text;yield kx(a,c.variant?c.variant.audio:null,c.variant?c.variant.video:null,c.text,b);a.h||(a.a.debug("init: completed initial Stream setup"),a.D&&a.D.Ff&&(a.a.debug("init: calling onInitialStreamsSetup()..."),a.D.Ff()))})}vb(a){const b=this;return _.w(function*(){if(!b.h){var c=bx(a);if(!a.Pa&&null!=a.kb&&!a.Qb)if(a.kb=null,a.zb)b.a.debug(c,"skipping update and clearing the buffer"),yield vx(b,
|
|
211
|
+
a,a.cd,a.Mc);else{try{var d=Gx(b,a);null!=d&&(jx(b,a,d),a.oc=!1)}catch(e){yield Hx(b,e);return}d=Array.from(b.f.values());Ix(b,a);b.B&&d.every(e=>e.endOfStream)&&(b.a.debug(c,"calling endOfStream()..."),b.D.Y.endOfStream().then(()=>{if(!b.h){var e=b.D.Y.getDuration();e<b.g.presentationTimeline.getDuration()&&b.g.presentationTimeline.Lb(e)}}).then(()=>{b.D.ye()}))}}})}I(a,b,c,d){const e=lu(d.reader),f=lu(d.reader),g=_.M(d.reader),h=_.M(d.reader),k=_.M(d.reader),l=_.M(d.reader);d=_.Dj(d.reader,d.reader.wa()-
|
|
212
|
+
d.reader.getPosition());a=a.startTime+b.startTime+h/g;c.includes(e)&&("urn:mpeg:dash:event:2012"==e?this.D.Ce():(c=new _.C("emsg",{detail:{startTime:a,endTime:a+k/g,schemeIdUri:e,value:f,timescale:g,presentationTimeDelta:h,eventDuration:k,id:l,messageData:d}}),this.D.onEvent(c)))}J(a){let b=!1,c=0;(new _.Mj).M(_.wd,_.N).M(_.we,_.N).M(_.rd,_.N).M(_.vd,_.N).M(_.me,_.N).X(_.oe,_.Gj).M("encv",d=>{d.reader.skip(78);_.N(d)}).M("pasp",d=>{c=d.start+d.headerSize;const e=_.M(d.reader),f=_.M(d.reader);b=e!==
|
|
213
|
+
f;this.a.debug(`hSpacing=${e}, vSpacing=${f}, updatePASP=${b}`);d.parser.stop()}).parse(a.data);b&&(a=new _.Oj(new DataView(a.data)),a.seek(c),_.L(a,1),_.L(a,1))}};_.zx="iterateSegmentReference";var Kz=class extends _.dp{constructor(a){super(Wt);this.C=ry;this.h=this.pa=this.R=null;this.zd=0;this.xe=2;this.Pb=null;this.wd=!1;this.m=new _.uo;this.aa=this.Qc=this.Xa=this.Ya=this.w=this.H=this.j=null;this.Ob=!1;this.g=this.f=this.A=this.a=this.Ha=this.F=null;this.Ke=1E9;this.Rc=new Set;this.N=!0;this.V=null;this.Fe=!1;this.Ee=0;this.S=null;this.K=new Fz;this.He={width:Infinity,height:Infinity};this.G=null;this.U=_.Pl;this.Va=new Uy(this.configuration.preferredAudioLanguage||[],this.configuration.preferredAudioRole,
|
|
214
|
+
this.configuration.preferredAudioChannelCount);this.Z=this.configuration.preferredTextLanguage;this.L=this.Wa=null;this.Ab=new Map;this.W=null;this.ka=this.configuration.preferredTextRole;a&&a(this);this.xd=null;this.m.on(window,"online",()=>{this.C===Yx&&Ux(this.a)})}init(a,b){const c=a.getMedia();super.init(a,b);iy(this,c)}namespace(){return Wt}De(){return new T}getState(){return this.U}getDrmInfo(){return this.j?this.j.getDrmInfo():null}unload(){lw(this,!1);this.Ob=!1;if(this.o){const a=this.getTrackManager();
|
|
215
|
+
a&&a.release();return this.C===my?Promise.resolve():qy(this).then(()=>{this.log.debug(_.$a,this.o);this.o=null;this.zd=0;this.L=this.Wa=null})}return Promise.resolve()}release(){const a=this,b=()=>Object.getPrototypeOf(Object.getPrototypeOf(this)).release;return _.w(function*(){if(a.R)return a.R;a.R=new Promise((c,d)=>{try{const e=a.pa;a.pa=null;let f=e;e&&(f=e.catch(()=>{}));f?f=f.then(()=>b().call(a)):f=b().call(a);f=f.then(()=>a.unload());f.then(()=>{ly(a,_.Pl);a.R=null;c()}).catch(g=>{a.R=null;
|
|
216
|
+
d(g)})}catch(e){a.R=null,d(e)}});return a.R})}getBufferInfo(a){if(this.H){var b=Bv(this.H);const c=new _.$o(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.Pb?(b=Ju(this.Pb),Gu(b,a)):super.getBufferInfo(a)}getPosition(){return this.w?Ww(this.w):super.getPosition()}getPresentationStartTime(){return this.f?this.f.presentationTimeline.getPresentationStartTime():null}getDuration(){return this.f?
|
|
217
|
+
this.f.presentationTimeline.getDuration():Infinity}destroy(){const a=this,b=()=>Object.getPrototypeOf(Object.getPrototypeOf(this)).destroy;return _.w(function*(){yield b().call(a);a.C!==my&&(a.log.debug("Destroying player..."),a.C=my,yield oy(a),a.m&&(a.m.release(),a.m=null),a.g=null)})}load(a){const b=this;return _.w(function*(){if(b.C===my)return Promise.reject(new _.G(_.F,7,7E3));const c=new _.Xk;var d=()=>{b.log.info("Aborting current load");throw new _.G(_.F,7,7E3);};b.pa=c;try{b.pa!==c&&d();
|
|
218
|
+
if(b.R){try{yield b.R}catch(h){}b.pa!==c&&d()}b.G=new _.wp;b.xd=Date.now()/1E3;ly(b,_.Ql);b.o=_.Vl(a);_.Yi(a)&&(b.configuration=_.Xi(b.hc,a));b.log.info(_.Ja,b.configuration);b.log.info(_.Wa,b.o);const e=b.getTrackManager();e&&e.load();const f=b.getSurface().getMedia();f.loop=!!b.configuration.loop;_.z(b.configuration.volume)||b.setVolume(b.configuration.volume);_.z(b.configuration.muted)||b.setMuted(b.configuration.muted);Fy(b);const g=b.o[b.getSourceIndex()];b.pa!==c&&d();yield iy(b,f);b.pa!==c&&
|
|
219
|
+
d();yield py(b,f);b.pa!==c&&d();yield Gy(b,g);b.pa!==c&&d();yield Ky(b,g);b.pa!==c&&d();yield Oy(b);b.pa!==c&&d();yield bz(b);b.pa!==c&&d();c.resolve()}catch(e){throw d=e,b.pa!==c&&(d=new _.G(_.F,7,7E3)),c.reject(d),b.onError(d),d;}})}isLive(){var a;this.f?(a=this.f.presentationTimeline.isLive())||(a=this.f.presentationTimeline,a=Infinity!=a.g&&!a.j):a=!1;return a}Ne(){this.log.debug("User seeking finished");this.F&&Qy(this);Ry(this)}getSeekRange(){if(this.f){const a=this.f.presentationTimeline;return{start:Yu(a,
|
|
220
|
+
0),end:Xu(a)}}return{start:0,end:0}}getPlaybackRate(){if(this.Xa){var a=this.Xa;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===Yx){this.Xa.set(a);this.g.playbackRateChanged(a);var b=this.a,c=1<Math.abs(a);if(a=b.f.get(_.u)){var d=a.stream;if(d)if(b.a.debug("setTrickPlay",c),c)(c=d.trickModeVideo)&&!a.Jb&&(b.a.debug("Engaging trick mode stream",c),_.wx(b,c,!1,0),a.Jb=d);else if(d=a.Jb)b.a.debug("Restoring non-trick-mode stream",
|
|
221
|
+
d),a.Jb=null,_.wx(b,d,!0,0)}}}ha(){if(this.f&&this.w){var a=Zx(this);if(null==a)a=null;else{if(!xw(this.K,a).text){var b=_.$v(a.textStreams,this.Z,this.ka);b.length&&yw(this.K,a,b[0])}a=xw(this.K,a).text}b=[];for(const c of qz(this)){const d=Xv(c);d.active=c==a;b.push(d)}return b}return[]}getPeriods(){return this.f.periods}getStats(){if(this.C!==Yx)return _.Cl();Ry(this);var a=this.h;if(a.getVideoPlaybackQuality){var b=a.getVideoPlaybackQuality();a=this.G;var c=Number(b.totalVideoFrames);a.j=Number(b.droppedVideoFrames);
|
|
222
|
+
a.h=c}if(this.C===Yx){if(b=dy(this))this.G.m=b.bandwidth;b&&b.video&&(a=this.G,c=b.video.height||NaN,a.o=b.video.width||NaN,a.g=c);a=this.g.getBandwidthEstimate();this.G.f=a}return this.G.getStats()}getTimelineCues(){return this.Ha?[...this.Ha.cues()].map(a=>({schemeIdUri:a.schemeIdUri,value:a.value,startTime:a.startTime,endTime:a.endTime,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 _.w(function*(){if(g.C!==Yx)throw g.log.error("Must call load() and wait for it to resolve before adding text tracks."),
|
|
223
|
+
Error("State error!");const h=Zx(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 _.G(1,4,4040);const m=new _.bv(1,0,l,()=>[a],0,null,0);k={id:g.Ke++,originalId:null,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:()=>1,getSegmentReference:q=>1==q?m:null,adjustSegmentDurations:()=>{},getDuration:()=>l,segmentLookupStrategy:_.Yt,initSegmentReference:null,mimeType:d,
|
|
224
|
+
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.Rc.add(k);h.textStreams.push(k);yield px(g.a,k);const n=_.mx(g.a,_.r);n&&yw(g.K,h,n);g.Rc.delete(k);g.log.debug("Choosing new streams after adding a text stream");Ey(g,h);My(g);return Xv(k)})}$f(a){this.log.debug(_.$t,a);try{this.log.debug("onChooseStreams_, choosing variant from ",a.variants);this.log.debug("onChooseStreams_, choosing text from ",
|
|
225
|
+
a.textStreams);const b=rz(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}}}Zf(){this.log.debug("canSwitch_");this.N=!1;this.configuration.abr.enabled&&this.g.enable();this.V&&(xx(this.a,this.V,this.Fe,this.Ee),this.V=null);this.S&&(_.wx(this.a,this.S,!0,0),this.S=null)}ag(){this.A&&this.A.update&&this.A.update()}Qe(){this.w&&this.w.j.Zc()}Yf(a,b,c){if((void 0===
|
|
226
|
+
c?"":c)===Zt)return My(this),this.ja()||(this.configuration.abr.enabled=!0,this.g.enable()),Ey(this,b,!1),!0;if(c=b.variants.some(d=>{let e=!1;const f=d[a.type];f&&(e=d.allowedByApplication&&f.id!==a.id,a.type===_.ac&&(e=e&&f.language===a.language));return e})&&this.ja()){for(const d of b.variants){const e=d[a.type];e&&e.id===a.id&&(d.allowedByApplication=!1)}My(this);this.ja()||(this.configuration.abr.enabled=!0,this.g.enable());Ey(this,b)}return c}Pe(){this.log.debug("endOfStream called by streaming engine");
|
|
227
|
+
this.Ob=!0}onError(a){if(this.C!==my&&7001!==a.code&&7E3!==a.code){var b=new _.C(_.$c,{detail:a});a.severity===_.F&&ly(this,_.Ol);this.trigger(b);b.defaultPrevented&&(b.a=!0)}}yd(a){a.type===_.Uc?this.dispatchEvent(a):"largegap"!==a.type&&(a.type===_.Qe?sy(this):"emsg"!==a.type&&(a instanceof _.C?this.dispatchEvent(a):this.log.debug(_.ob,a.type)))}ja(){return this.configuration.abr.enabled}Se(a){const b=this;return _.w(function*(){if(b.ca){b.log.info("Attempt to switch CDN.");var c=b.getLoadedSource(),
|
|
228
|
+
d=b.ja();if(c=yield b.ca(c.url,a)){c=_.jf(b.getLoadedSource(),{url:c});d&&b.g.disable();yield Vx(b.a);var e=dy(b);do{var f=!1;try{b.log.info(`Switching CDN to ${c.url}.`),yield sz(b,c,e)}catch(g){if(b.log.info("Switch failed"),f=yield b.ca(c.url,a))c.url=f,f=!0;else throw g;}}while(f);d&&b.g.enable();Ux(b.a,!0);b.o[b.getSourceIndex()]=c;a.f=!0;b.trigger(new _.C(_.sc,{newManifest:c.url}))}}})}},my=0,ry=1,Yx=2,Ly=[_.Nd,_.fd];
|
|
229
|
+
_.Mf(new class{a(){return Wt}canPlay(a,b){if(_.fi())return 0;const c=a.type||"",d=window.MediaSource&&MediaSource.isTypeSupported?!0:!1;a=window.MediaSource&&MediaSource.isTypeSupported?c in _.In||_.Jn(a.url)in _.Kn?!0:!1:!1;if(d&&a){if(_.Xh(2))return 1;if(_.gi()&&c===_.Pi){if(b.streaming.preferNativeHlsOnSafari)return 1;_.B("Support for MSE + FairPlay on Apple is experimental. In case of issues, consider using native HLS.")}return 2}return 0}create(){return new Kz}});_.Am(function(){_.If("MediaSource.install");if(window.MediaSource)if(window.cast&&cast.__platform__&&cast.__platform__.canDisplayType)_.Hf("Patching Chromecast MSE bugs."),tz();else if(_.gi()){var a=navigator.appVersion;a=0<=a.indexOf("Version")?parseInt(a.match(/Version\/(\d+)/)[1],10):13;uz();10>=a?(_.Hf("Blacklisting MSE on Safari \x3c\x3d 10."),window.MediaSource=null):12>=a?(_.Hf("Patching Safari 11 \x26 12 MSE bugs."),vz(),wz()):(_.Hf("Patching Safari 13 MSE bugs."),vz())}else _.Xh(2)||_.Xh(3)||
|
|
230
|
+
_.Xh(4)?xz():_.Hf("Using native MSE as-is.");else _.Hf("No MSE implementation available.")});var Lz=class extends _.iq{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=_.Pc;c.label===Pt&&(this.a=c)}this.a||(this.a=a.addTextTrack(_.gu,Pt));this.a.mode=_.dd}append(a){const b=[],c=d=>{if(d.startTime>=d.endTime)_.B("Invalid cue times: "+d.startTime+" - "+d.endTime),d=null;else{var e=d.payload||"";e=e.replace(/<br\s*\/?>/igm,"\n");e=_.Xg(e);e=new VTTCue(d.startTime,d.endTime,e);e.line=-1;try{e.align=_.uc}catch(f){e.align=
|
|
231
|
+
"middle"}d.writingMode===_.Ge?e.vertical="lr":d.writingMode===_.He&&(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;yz(this.a,c=>c.startTime<b&&c.endTime>a);return!0}isTextVisible(){return this.a.mode==_.ge}setTextVisibility(a){null!==this.a&&(this.a.mode=a?_.ge:_.dd)}destroy(){this.a&&
|
|
232
|
+
yz(this.a,()=>!0);this.a=null;return Promise.resolve()}};_.wl("single-native",new class{da(){return!0}create(a){return new Lz(a)}});};f.call(g, window);
|