@castlabs/prestoplay 6.32.0-beta.2 → 6.32.0
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 +5 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +18 -18
- package/cjs/cl.cast.js +126 -126
- package/cjs/cl.conviva.js +32 -32
- package/cjs/cl.core.js +604 -604
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +101 -101
- package/cjs/cl.externs.js +1 -29
- package/cjs/cl.freewheel.js +26 -26
- package/cjs/cl.hls.js +77 -77
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +26 -26
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +352 -352
- package/cjs/cl.muxdata.js +14 -14
- package/cjs/cl.onboard.js +4 -4
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.simid.js +16 -16
- package/cjs/cl.smooth.js +71 -71
- package/cjs/cl.thumbnails.js +25 -25
- package/cjs/cl.tizen.js +71 -71
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +12 -12
- package/cjs/cl.vr.js +18 -18
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.yospace.js +4 -4
- package/cjs/cl.youbora.js +38 -38
- package/cjs/polyfill.min.js +2 -2
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +14 -14
- package/cl.cast.js +100 -100
- package/cl.conviva.js +27 -27
- package/cl.core.js +488 -487
- package/cl.crypto.js +8 -8
- package/cl.dash.js +75 -75
- package/cl.externs.js +1 -25
- package/cl.freewheel.js +20 -20
- package/cl.hls.js +65 -65
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +19 -19
- package/cl.mediatailor.js +2 -2
- package/cl.mse.js +200 -200
- package/cl.muxdata.js +12 -12
- package/cl.onboard.js +3 -3
- package/cl.persistent.js +8 -8
- package/cl.playlist.js +4 -4
- package/cl.simid.js +2 -2
- package/cl.smooth.js +47 -47
- package/cl.thumbnails.js +12 -12
- package/cl.tizen.js +41 -41
- package/cl.ttml.js +10 -10
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +3 -3
- package/cl.vtt.js +11 -11
- package/cl.yospace.js +3 -3
- package/cl.youbora.js +27 -27
- package/package.json +1 -1
- package/typings.d.ts +6 -22
- package/cjs/cl.cdn.js +0 -13
- package/cl.cdn.js +0 -7
package/cl.hls.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
1
|
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var JI="CLOSED-CAPTIONS",KI="Could not parse MP4 segment start time.",LI="DURATION",MI="EXT-X-DATERANGE",NI="EXT-X-DISCONTINUITY",OI="EXT-X-KEY",PI="EXT-X-MAP",QI="EXT-X-MEDIA",RI="EXT-X-MEDIA-SEQUENCE",SI="EXT-X-PROGRAM-DATE-TIME",TI="EXT-X-STREAM-INF",UI="Failed to infer discontinuity number",VI="Guessing audio-only",WI="METHOD",XI="SAMPLE-AES-CTR",YI="SUBTITLES",ZI="_HLS_part",$I="application/vnd.apple.mpegurl",aJ="manifestloaded",bJ="sample",cJ=function(a,b){return _.L(a,b,void 0,
|
|
2
|
-
{required:!0})},dJ=function(a){if(1>a.a)throw _.
|
|
2
|
+
{required:!0})},dJ=function(a){if(1>a.a)throw _.To();--a.a},eJ=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ie&&e&&typeof e===_.Ie){if(!eJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},fJ=function(a,b){if(!eJ(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Ie&&e&&typeof e===_.Ie&&fJ(d,e))return!0}return!1},gJ=function(a,b){if(a===b||_.z(a)||_.z(b))return!1;const c=Object.keys(a);
|
|
3
3
|
for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.Ie&&typeof d===_.Ie){if(gJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},hJ=function(a){if(null!==a&&void 0!==a)return Number(a)},iJ=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},jJ=function(a){return new Uint8Array([a>>
|
|
4
4
|
24&255,a>>16&255,a>>8&255,a&255])},kJ=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},lJ=function(a,b){return a.filter(c=>c.name===b)},mJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.L(d,"VALUE"),f=_.L(d,_.Ta),g=_.L(d,"IMPORT"),h=_.L(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.D,4,4044,{message:"Invalid tag.",text:d.toString()});
|
|
5
5
|
d=f||g||h;if(c.has(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},nJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=cJ(d,_.tb);return c.includes(d)})},oJ=function(a,b){return a.some(c=>c.name===b)},pJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.D,4,4024,{missingTag:b});return a},qJ=function(a){var b=pJ(a,
|
|
6
|
-
"EXT-X-TILES");if(!b)return{Ld:1,
|
|
6
|
+
"EXT-X-TILES");if(!b)return{Ld:1,ce:1,durationPerTile:null};a=_.L(b,"LAYOUT")||"1x1";b=_.L(b,LI);a=_.DB(a);return{Ld:a.Ld,ce:a.ce,durationPerTile:b?Number(b):null}},rJ=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},sJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of rJ(c))b(d,c)})},tJ=function(a){return a.some(b=>oJ(b.ba,"EXT-X-ENDLIST"))},
|
|
7
7
|
uJ=function(a){return a.type===_.q||a.type===_.t},vJ=function(a){if(pJ(a,"EXT-X-ENDLIST"))return _.Fb;a=pJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Fb)return _.Fb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.D,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},wJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.K,"CLOSED-CAPTIONS":_.K}[a.toUpperCase()];if(!a)throw new _.I(_.D,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},xJ=function(a,b,c){c=void 0===
|
|
8
8
|
c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.D,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.D,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.D,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.D,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{na:d,ja:e}},yJ=function(a,b){a=pJ(a,"EXT-X-BYTERANGE");
|
|
9
|
-
return xJ(a?a.value:null,b)},zJ=function(a){a=pJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},AJ=function(a,b){b=void 0===b?{}:b;const c={
|
|
10
|
-
c.
|
|
11
|
-
const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{nd:b,duration:c}},GJ=function(a){return a.map(b=>{({duration:b}=FJ(b));return b}).reduce((b,c)=>b+c,0)},HJ=function(a){return(a.video?a.video.
|
|
12
|
-
a=Number(a.value);e=e||a;return null!=d?{delay:d,
|
|
13
|
-
e.schemeIdUri,h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.lv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d
|
|
14
|
-
null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.
|
|
15
|
-
case _.Rb:d[_.Rb]=l.value.split(",")}l=_.
|
|
16
|
-
m;h.type=_.
|
|
9
|
+
return xJ(a?a.value:null,b)},zJ=function(a){a=pJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},AJ=function(a,b){b=void 0===b?{}:b;const c={eg:!1,Gh:!1,Hh:null,ji:null,Pg:null};a=pJ(a,"EXT-X-SERVER-CONTROL",{required:b.Yg});if(!a)return c;const d=e=>null==e?null:Number(e);c.eg="YES"===_.L(a,"CAN-BLOCK-RELOAD");c.Gh="YES"===_.L(a,"CAN-SKIP-DATERANGES");c.Hh=d(_.L(a,"CAN-SKIP-UNTIL"));
|
|
10
|
+
c.ji=d(_.L(a,"HOLD-BACK"));c.Pg=d(_.L(a,"PART-HOLD-BACK",void 0,{required:b.Yg}));return c},BJ=function(a,b,c){c=void 0===c?!1:c;a=_.L(a,"BYTERANGE");return xJ(a,b,c)},CJ=function(a){const b=lJ(a,QI),c=lJ(a,TI);a=lJ(a,"EXT-X-IMAGE-STREAM-INF");return{Oc:{Zf:nJ(b,[_.pA,_.Eb]),closedCaptions:nJ(b,JI),dj:nJ(b,YI)},de:c,$e:a}},EJ=function(a,b){const c=yJ(a.ba,null);return new DJ(0,0,0,()=>[a.a],c.na,c.ja,0,b)},FJ=function(a){let b=Infinity,c=Infinity;rJ(a).filter(uJ).forEach(d=>{{d=d.T;var e=d[0].startTime;
|
|
11
|
+
const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{nd:b,duration:c}},GJ=function(a){return a.map(b=>{({duration:b}=FJ(b));return b}).reduce((b,c)=>b+c,0)},HJ=function(a){return(a.video?a.video.ab:"")+" - "+(a.audio?a.audio.ab:"")},IJ=function(a,b,c,d,e){if(b===_.Fb)return{delay:0,be:0};b=pJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(cJ(b,"PART-TARGET"));if(null!=d)return{delay:d,be:e};({Pg:d}=AJ(a,{Yg:!0}));return{delay:d,be:e}}a=pJ(a,"EXT-X-TARGETDURATION",{required:!0});
|
|
12
|
+
a=Number(a.value);e=e||a;return null!=d?{delay:d,be:e}:{delay:3*a,be:e}},JJ=function(a){const b=new Map;a.forEach(c=>{var d=`${c.Hc()}:${c.streams[0].groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},KJ=function(a){const b=new Map;for(const c of a){a=_.L(c,_.La);a=_.Gn(a||_.lg);const d=cJ(c,_.Fa),e=cJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},LJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},MJ=function(a,b,c,d,e){var f=e&&e.$d,g=e&&
|
|
13
|
+
e.schemeIdUri,h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.lv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,$d:f};f=hJ(_.L(a,LI));void 0!==f&&0<=f&&(h.duration=f);f=hJ(_.L(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.L(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.L(a,"END-DATE"))?new Date(f):
|
|
14
|
+
null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.gh(d)?d:null}k=k||{};(d=_.L(a,"CUE"))&&(k.CUE=d.split(","));if(_.fk(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Ob:d[_.Ob]=l.value;break;case _.Nb:d[_.Nb]=l.value;break;case _.Sb:d[_.Sb]=hJ(l.value);break;case _.Qb:d[_.Qb]=hJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;
|
|
15
|
+
case _.Rb:d[_.Rb]=l.value.split(",")}l=_.gh(d)?d:null}l&&(k=Object.assign(k,l))}_.gh(k)&&(h.customAttributes=k);if(gJ(e,h))return _.lv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.dh(e,h);if(_.fk(g)&&!_.gk(h.customAttributes))return _.lv.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=
|
|
16
|
+
m;h.type=_.ee;return h},NJ=function(a,b){if(!a)return null;const c=a.ab;return b.find(d=>d.streams[0].ab===c)||null},OJ=function(a){return(a=_.L(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},PJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},QJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.L(e,_.Ta),g=_.L(e,"QUERYPARAM");if(f)g=cJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.D,4,4044,`Query param '${g}' missing in playlist URI.`);
|
|
17
17
|
if(!f)throw new _.I(_.D,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},RJ=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.D,4,4044,`Undefined variable '${d}'`);return c})},SJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=RJ(d.value,b)})})},VJ=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=TJ(a,b[e]);d.push(f);if(f.name===TI){const g=b[e+1];if(!g)throw new _.I(_.D,
|
|
18
|
-
4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.
|
|
19
|
-
c):ZJ(a,b,c)},WJ=function(a){const b=[],c=[],d=[];for(const e of a)aK.test(e)?d.push(e):bK.test(e)?c.push(e):b.push(e);return{
|
|
20
|
-
[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=TJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.tb)?g.push(h):f.push(h)):(oJ(f,"EXT-X-GAP")||(h=RJ(h,d),h=_.
|
|
18
|
+
4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.mr(_.wb,g));e++}}b=lJ(d,"EXT-X-DEFINE");mJ(b);b=QJ(b,c);a.a=b;SJ(d,a.a);return new UJ(c,0,d)},ZJ=function(a,b,c){const {Si:d,ii:e,pj:f}=WJ(b),g=XJ(a,f,c);b=e.map(k=>TJ(a,k,g));const h=YJ(a,c,d,g);return new UJ(c,1,b,h)},$J=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.D,4,4015);b=b.slice(1);return 0===PJ(b)?VJ(a,b,
|
|
19
|
+
c):ZJ(a,b,c)},WJ=function(a){const b=[],c=[],d=[];for(const e of a)aK.test(e)?d.push(e):bK.test(e)?c.push(e):b.push(e);return{Si:b,ii:c,pj:d}},XJ=function(a,b,c){b=b.map(e=>TJ(a,e));mJ(b);const d=QJ(b,c);b.map(e=>_.L(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.D,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},TJ=function(a,b,c){a=_.or(a.h++,b);c&&SJ([a],c);return a},YJ=function(a,b,c,d){const e=
|
|
20
|
+
[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=TJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.tb)?g.push(h):f.push(h)):(oJ(f,"EXT-X-GAP")||(h=RJ(h,d),h=_.Pm(h,b),e.push(new cK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new cK(null,f,g));return e},dK=function(a,b,c){const d=[],e=[];e.push(new _.mr(_.ma,"0"));e.push(new _.mr(_.wb,b));c.length&&e.push(new _.mr(_.pa,c));d.push(new _.nr(a.h++,TI,e));return new UJ(b,0,d)},eK=function(a){function b(h,k,l){let m="";for(;k<
|
|
21
21
|
l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.I(_.D,4,4030);}kJ(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<
|
|
22
|
-
22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}kJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},fK=function(a,b){let c=null,d=0;try{(new _.
|
|
23
|
-
g.version)h=_.N(g.reader)/h;else{{const k=_.N(g.reader),l=_.N(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.D,4,4030,KI,c);return e},gK=function(a){for(;a.getPosition()<a.
|
|
24
|
-
71!==f&&(d.seek(e+192),f=_.
|
|
25
|
-
a||c();0===_.
|
|
26
|
-
lK.join(", "),"], not",b),null;a=cJ(a,_.wb);b=_.
|
|
22
|
+
22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}kJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},fK=function(a,b){let c=null,d=0;try{(new _.ip).N(_.Ee,_.bp).N(_.ig,_.bp).N(_.ze,_.bp).fa("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Sv.error("Unable to find timescale in init segment!"),new _.I(_.D,4,4030,KI,c);let e=0,f=!1;try{(new _.ip).N("moof",_.bp).N("traf",_.bp).fa("tfdt",g=>{var h=d;if(0===
|
|
23
|
+
g.version)h=_.N(g.reader)/h;else{{const k=_.N(g.reader),l=_.N(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.D,4,4030,KI,c);return e},gK=function(a){for(;a.getPosition()<a.Sa()-1;){const b=a.getPosition();if(71===_.Uo(a))return dJ(a),b}return-1},hK=function(a){function b(){d.seek(e+188);f=_.Uo(d);
|
|
24
|
+
71!==f&&(d.seek(e+192),f=_.Uo(d));71!==f&&(d.seek(e+204),f=_.Uo(d));71!==f&&c();dJ(d)}function c(){throw new _.I(_.D,4,4030);}const d=new _.aq(new DataView(a),!1);let e=0,f=0;e=gK(d);0>e&&(_.Sv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Uo(d);71!==f&&c();a=_.Vo(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Uo(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Uo(d),d.skip(a));if(1!==_.N(d)>>8){b();continue}d.skip(3);a=_.Uo(d)>>6;0!==a&&1!==
|
|
25
|
+
a||c();0===_.Uo(d)&&c();a=_.Uo(d);const g=_.Vo(d),h=_.Vo(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},kK=function(a){const b=iK(a),c=jK(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.ma===b);let g=e.findIndex(h=>h.ma===c+1);-1===g&&(g=e.length);d.T=e.slice(f,g)})},jK=function(a){a=a.map(b=>b.T[b.T.length-1].ma);return Math.min(...a)},iK=function(a){a=a.map(b=>b.T[0].ma);return Math.max(...a)},nK=function(a){var b=cJ(a,WI);if(!lK.includes(b))return mK.error("PlayReady in HLS is only supported with [",
|
|
26
|
+
lK.join(", "),"], not",b),null;a=cJ(a,_.wb);b=_.fm(a);a=null;b=_.G(b.data);try{a=_.dB(_.hq(b))}catch(c){a=b}return _.rB(_.vd,[{initDataType:_.Xc,initData:a}],"")},pK=function(a){if(0===a.length)return oK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.He))return a[0];a=a.filter(c=>c.type===bJ);const b=_.ci(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:bJ,drmInfos:b}},sK=function(a,b){return qK(a).map(c=>rK(c.ba,b)).filter(Boolean)},qK=function(a){return a.filter(b=>
|
|
27
27
|
oJ(b.ba,OI))},rK=function(a,b){a=lJ(a,OI).filter(d=>"AES-128"!==cJ(d,WI));if(0===a.length)return null;var c=cJ(a[0],WI);if(1===a.length&&"NONE"===c)return oK();c=a.map(d=>cJ(d,WI));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===XI))throw tK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.D,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.L(d,"KEYFORMAT","identity");{const f=uK[e]||null;d=f?f(d,b):null}d||tK.warn("Unsupported HLS KEYFORMAT",
|
|
28
|
-
e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.D,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:bJ,drmInfos:a}},oK=function(){return{type:_.He,drmInfos:[],keyId:null}},vK=function(a,b,c){a=lJ(a,OI)[0];if(!a||"AES-128"!==cJ(a,WI))return null;var d=_.L(a,"IV","");d?c={iv:_.
|
|
29
|
-
generatedIv:f}=c;return{method:"AES-128",url:_.
|
|
30
|
-
e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.D,4,4030,"Failed to fetch the media segment.");}}})},xK=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.
|
|
31
|
-
_.
|
|
32
|
-
{c.
|
|
28
|
+
e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.D,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:bJ,drmInfos:a}},oK=function(){return{type:_.He,drmInfos:[],keyId:null}},vK=function(a,b,c){a=lJ(a,OI)[0];if(!a||"AES-128"!==cJ(a,WI))return null;var d=_.L(a,"IV","");d?c={iv:_.bm((d||"0x").slice(2)),generatedIv:!1}:(d=_.L(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.em(new Uint8Array(12),jJ(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
|
|
29
|
+
generatedIv:f}=c;return{method:"AES-128",url:_.Pm(cJ(a,_.wb),b),iv:e,generatedIv:f}},wK=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.ZB(b.Da(),b.na,b.na+2048-1,a.a.attemptParameters);e.type=2;const f=_.ZB(b.Da(),b.na,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
|
|
30
|
+
e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.D,4,4030,"Failed to fetch the media segment.");}}})},xK=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Hc||d===_.Gc)return 0;if(d===_.Fc){var g=yield wK(a,c,f);g=_.G(g.data);if(!kJ(g))throw new _.I(_.D,4,4030,"AAC segment does not contain an ID3 tag.");return eK(g)}if(d===_.Ag||d===
|
|
31
|
+
_.Ic)return g=[wK(a,c,f)],b&&g.push(wK(a,b,!0)),g=yield Promise.all(g),fK(g[0].data,(g[1]||g[0]).data);if(d===_.zg)return g=yield wK(a,c,f),hK(g.data);if(!_.mt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.D,4,4030);})},yK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},zK=function(a,b){a=a.streams.find(c=>{c=c.T;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.T.find(c=>c.position===b)||null},AK=function(a,b){a.streams.forEach(c=>
|
|
32
|
+
{c.Ne=b})},BK=function(a,b){a.streams.forEach(c=>{c.width=b})},CK=function(a,b){a.streams.forEach(c=>{c.height=b})},DK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},EK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},FK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},GK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},IK=function(a,b){for(;a[0].ma<b[0].ma;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||
|
|
33
33
|
HK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&HK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},MK=function(a,b,c,d,e){var f=b[0].length();f=iJ(f).map(g=>{var h=FK(b,g)||[];const k=yK(c,g)||[];g=yK(d,g)||[];{const l=[...JK(h),...k,...g].filter(Boolean);KK(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});f[0].startTime+=e;f[0].endTime+=e;LK(f);return f},
|
|
34
34
|
JK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},LK=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},HK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;NK(a.variants,b.variants);OK(rJ(a),rJ(b))},NK=function(a,b){const c=new Map(a.map(d=>[HJ(d),d]));b.forEach(d=>{c.get(HJ(d)).drmInfos=d.drmInfos})},OK=function(a,b){const c=new Map(a.map(d=>
|
|
35
|
-
[d.
|
|
36
|
-
|
|
37
|
-
!!RK(b.T[0]))},SK=function(a,b){a&&b&&[PI,OI].forEach(c=>{if(!oJ(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},UK=function(a,b){sJ(b,(c,d)=>{_.lC(a,c.T,d.startTime)});_.dC(a.a,b[0].startTime,b[b.length-1].endTime)},VK=function(a,b){return _.w(function*(){var c=_.
|
|
38
|
-
fL=function(a,b){return _.w(function*(){var c=WK(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=XK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=dK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=CJ(c.ba);c=YK(d.Oc.
|
|
39
|
-
$K(a,g);h=aL(a,f.delay,g,h);bL(a)||(a.G=f.
|
|
35
|
+
[d.ab,d]));b.forEach(d=>{const e=c.get(d.ab);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);e.nd=d.nd;e.df=d.df;e.duration=d.duration;e.ng=d.ng;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},KK=function(a){const b=PK(a);a.forEach(c=>{_.VB(c.segmentIndex,b);c.duration=b;c.df=c.nd+b})},PK=function(a){let b=Infinity;a.filter(uJ).forEach(c=>{b=Math.min(b,c.duration)});return b},TK=function(a){if(!(2>a.length)&&QK(a)){a=a.map(e=>({playlist:e,
|
|
36
|
+
jg:RK(e.T[0])}));var b=a.map(e=>e.jg),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.jg;0<f.T.length&&1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;SK(g,h);h=RK(h);null!=h?e=h:({duration:h}=zJ(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.T.length))throw new _.I(_.D,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>e.T.length));a.forEach(e=>{for(;e.T.length>d;)e.T.pop()})}}},QK=function(a){return a.every(b=>
|
|
37
|
+
!!RK(b.T[0]))},SK=function(a,b){a&&b&&[PI,OI].forEach(c=>{if(!oJ(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},UK=function(a,b){sJ(b,(c,d)=>{_.lC(a,c.T,d.startTime)});_.dC(a.a,b[0].startTime,b[b.length-1].endTime)},VK=function(a,b){return _.w(function*(){var c=_.vk([b],a.a.attemptParameters);c.type=1;c=yield a.I(c);let d="";try{d=_.ni(c.data)}catch(e){throw new _.I(_.D,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},
|
|
38
|
+
fL=function(a,b){return _.w(function*(){var c=WK(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=XK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=dK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=CJ(c.ba);c=YK(d.Oc.Zf);c.forEach(m=>{a.K.add(m.groupId)});var e=yield ZK(a,d);var f=e.vi;const g=e.periods;var h=e.Mi;const k=e.fj;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.D,7,7001);
|
|
39
|
+
$K(a,g);h=aL(a,f.delay,g,h);bL(a)||(a.G=f.be,a.g.info(`Update playlist each ${a.G} s`),cL(a));dL(a,h,g);f=eL(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},hL=function(a,b){return Promise.all(b.map(c=>gL(a,c)))},jL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!bL(a),f=pJ(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");
|
|
40
40
|
if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=pJ(c.ba,RI);if(!k)throw iL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(UI);const l=Number(k.value),m=zK(d,l);if(!m)throw iL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(UI);var h=m.ma}g=h;break a}catch(k){throw new _.I(_.D,4,4024,
|
|
41
|
-
"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)oJ(k.ba,NI)&&g++,k.ma=g});kK(b)},mL=function(a,b){return _.w(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,thumbStreams:d,
|
|
42
|
-
h.streams[0].
|
|
43
|
-
"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===MI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=MJ(e,c,a.B,!bL(a),d))&&b.set(d.id,d);return Array.from(b.values())},eL=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b
|
|
44
|
-
schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime
|
|
45
|
-
label:cJ(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},ZK=function(a,b){return _.w(function*(){var c=KJ(b.Oc.closedCaptions),d=qL(a,b.
|
|
46
|
-
c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.
|
|
41
|
+
"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)oJ(k.ba,NI)&&g++,k.ma=g});kK(b)},mL=function(a,b){return _.w(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,thumbStreams:d,Bh:e}=yield kL(a,b),f=a.f.periods[0].variants.map(g=>{const h=NJ(g.audio,e),k=NJ(g.video,e);g=lL(a,h,k,g.bandwidth);if(!g)throw new _.I(_.D,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Sj:k?k.streams[0].ab:void 0,audio:h?
|
|
42
|
+
h.streams[0].ab:void 0});return g});return MK(a.D.configurationId,f,c,d,a.B)})},$K=function(a,b){bL(a)||2!==a.a.timeline.version||(a.J||(a.J=b[0].startTime),_.hD(b,-a.J))},nL=function(a,b){b=b.flatMap(d=>d.T[0].ba);b=pJ(b,SI);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},oL=function(a,b,c){b=b.find(e=>null!==pJ(e.ba,MI));if(!b)return[];if(null===c)throw new _.I(_.D,4,4024,
|
|
43
|
+
"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===MI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=MJ(e,c,a.B,!bL(a),d))&&b.set(d.id,d);return Array.from(b.values())},eL=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b.$d!==d.$d)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,
|
|
44
|
+
schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,$d:d.$d,endTime:d.endTime,id:d.id,type:_.ee,eventElement:null};b&&!fJ(b,e)||a.A.set(d.id,e)}return Array.from(a.A.values())},pL=function(a,b,c){a.w=_.Fb;_.hC(b,!0);b.f=c[c.length-1].endTime},WK=function(a,b,c,d){a=$J(a.S,b,c);a.verbatimUri=d;return a},YK=function(a){return a.filter(b=>b.name===QI&&_.L(b,_.tb)===_.pA&&!_.L(b,_.wb)).map(b=>{const c=OJ(b),d=_.L(b,_.La)||_.lg;return{groupId:cJ(b,_.Fa),id:_.pI++,
|
|
45
|
+
label:cJ(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},ZK=function(a,b){return _.w(function*(){var c=KJ(b.Oc.closedCaptions),d=qL(a,b.de),e=yield rL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=vJ(g.ba);a.w=h;h!==_.Fb&&(a.H=!0);jL(a,f);!bL(a)&&TK(f);a.L=AJ(g.ba);f=IJ(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield sL(a,e.$f,d);c=yield tL(a,e.de,g,c);d=yield uL(a,e.cj,d);g=yield vL(a,e.$e);d=MK(a.D.configurationId,
|
|
46
|
+
c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.de,...e.$f].map(k=>k.playlist);e=nL(a,c);c=oL(a,c,e);return{periods:d,Mi:e,fj:c,vi:f}})},aL=function(a,b,c,d){let e=!0,f=null,g=0;bL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.uI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.hC(a,e);UK(a,c);d&&_.gC(a,d);return a},cL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].nd);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",
|
|
47
47
|
c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.nd?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},dL=function(a,b,c){c=GJ(c);"LIVE"===a.w||"EVENT"===a.w?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.w===_.Fb&&(b.f=c)},kL=function(a,b){return _.w(function*(){const c=h=>h.stream.Hc()===_.t||h.stream.Hc()===_.q;var d=b.filter(c),e=b.filter(h=>
|
|
48
|
-
!c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.
|
|
49
|
-
h.Hc()===_.VA);f=d.filter(h=>h.Hc()===_.he);return{textStreams:e,thumbStreams:f,
|
|
50
|
-
f.push(h)}return new yL(f)},wL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.kd,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.
|
|
51
|
-
1].endTime,
|
|
52
|
-
label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,T:Xa,drmInfos:
|
|
53
|
-
_.L(f,YI);const g=BL(a,f);if(e){const h=_.
|
|
48
|
+
!c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.ab,ee:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist,hc:null},k);return wL(a,h)};const g=[];for(const h of d)g.push(yield f(h));d=[];for(const h of e)d.push(yield f(h));xL(a,g.concat(d));e=d.filter(h=>
|
|
49
|
+
h.Hc()===_.VA);f=d.filter(h=>h.Hc()===_.he);return{textStreams:e,thumbStreams:f,Bh:g}})},lL=function(a,b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||null:null,l=h,m=k;l=l&&m?_.KB(l.drmInfos,m.drmInfos)?_.JB(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.lg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};
|
|
50
|
+
f.push(h)}return new yL(f)},wL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.kd,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.ee,A=_.Gn(f||_.lg);if(1!==c.type)throw new _.I(_.D,4,4017);const E=yield zL(a,c,e,d),F=a.a.lowLatencyMode?_.MA:_.LA;let C=m;e!==_.K||m||(C=_.VA);const ja=vJ(c.ba);m=E.map(Ca=>{const Xa=Ca.T,Ib=Ca.Mh,ub=Ca.mimeType,fc=Ca.ma,gc=Xa[0].startTime,Jb=Xa[Xa.length-
|
|
51
|
+
1].endTime,jb=Jb-gc,xa=new _.vI(Xa),xb=Xa[0].initSegment||null;return{id:null==g?_.pI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:xa.f.bind(xa),getSegmentReference:xa.get.bind(xa),adjustSegmentDurations:xa.h.bind(xa),getDuration:xa.getDuration.bind(xa),segmentIndex:xa,segmentLookupStrategy:F,initSegmentReference:xb,mimeType:ub,codecs:d,kind:C,ng:Ib.type,encrypted:Ib.type===bJ,aesEncrypted:Ca.aesEncrypted,keyId:Ib.keyId,language:A,originalLanguage:f||_.lg,
|
|
52
|
+
label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,T:Xa,drmInfos:Ib.drmInfos,ma:fc,ab:c.verbatimUri,Ne:c.a,nd:gc,df:Jb,duration:jb,groupId:h,Jj:ja,muxedAudioId:k}});return new AL(m)})},xL=function(a,b){b.forEach(c=>{a.j.a.set(c.streams[0].ab,c)})},qL=function(a,b){const c=new Map;for(const f of b){var d=_.L(f,_.pA);b=_.L(f,_.Eb);var e=
|
|
53
|
+
_.L(f,YI);const g=BL(a,f);if(e){const h=_.Fr(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=CL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=CL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},rL=function(a,b){return _.w(function*(){const c=yield Promise.all([DL(a,b.Oc.Zf),DL(a,b.Oc.dj),DL(a,b.de),DL(a,b.$e)]),[d,e,f,g]=c;return{$f:d,cj:e,de:f,$e:g}})},sL=function(a,b,c){return _.w(function*(){if(0===b.length)return new Map;var d=[EL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>
|
|
54
54
|
EL(a,e,c)));d=yield Promise.all(d);return JJ(d)})},tL=function(a,b,c,d){return _.w(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(cJ(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield FL(a,h,c,d,e);f=f.map(k=>FL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.oB,[])})},uL=function(a,b,c){return Promise.all(b.map(d=>EL(a,d,c)))},vL=function(a,b){return Promise.all(b.map(c=>GL(a,c)))},HL=function(a,b){return _.w(function*(){const c=
|
|
55
|
-
_.
|
|
56
|
-
_.Fb},DL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield JL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gL=function(a,b){return _.w(function*(){var c=new URL(b.streams[0].
|
|
57
|
-
f&&d.get(ZI)&&d.delete(ZI),null!==f&&d.set(ZI,f.toString())}const {response:g,text:h}=yield VK(a,c.toString());c=b.streams[0].
|
|
58
|
-
b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},EL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return KL(a,e.verbatimUri,()=>_.w(function*(){const f=cJ(d,_.Fa),g=wJ(cJ(d,_.tb));var h=cJ(d,_.tb).toUpperCase();if(wJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.VA;h===JI&&(l=_.GA);k&&(l=_
|
|
59
|
-
g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wL(a,{playlist:e,codecs:k,type:g,kd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,
|
|
60
|
-
closedCaptions:null,hc:null,groupId:null,
|
|
61
|
-
(p?p.streams[0].
|
|
62
|
-
f?(a.g.debug(VI),c=_.q,b=!0):e?(a.g.debug(VI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(VI));return{type:c,
|
|
63
|
-
u.streams[0].
|
|
64
|
-
CL(_.q,c);m+=`,${n}`}return yield wL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,kd:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,
|
|
65
|
-
(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield PL(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;QL(g);return g})},JL=function(a,b){return _.w(function*(){var c=b.name!==QI?!0:_.L(b,_.tb)===YI;c=_.L(b,_.wb,void 0,{required:c});if(!c)return null;const d=_.
|
|
66
|
-
4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},RL=function(a,b,c){a=lJ(a.ba,PI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=cJ(a,_.wb),e=_.
|
|
67
|
-
const v=(l=_.
|
|
68
|
-
null;d=new DJ(d,e,y,()=>v,A.na,A.ja,f,g,!1,null,a?a.Ld:null,a?a.
|
|
69
|
-
uri:c});}k=yield VL(a,f,g,h);const l=vK(h.ba,a.o,e),m=RL(h,b,l);h=yield WL(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},PL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0];const l=yield VL(a,e,f,k);var m=g?g.
|
|
70
|
-
[];let A=!1;for(let F=0;F<c.length;F++){var E=c[F];const C=u[u.length-1]||null,ja=0===F?0:C.endTime,Ca=d+F,Xa=XL(p,E.ba,a.o,Ca);(p=Xa)&&(A=!0);if(E=TL(a,C,E,Ca,ja,k,Xa,e,b,y,v))v=E.initSegment,u.push(E)}return{T:u,
|
|
71
|
-
d.a;var f=pJ(d.ba,PI);f=f?cJ(f,_.wb):null;return $L(a,b,c,e,f)})},WL=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=EJ(c,d);return xK(a.U,b,g,e,f,null!=d)})},XL=function(a,b,c,d){return b.some(e=>e.name===OI&&"NONE"===_.L(e,WI))?null:(b=vK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.
|
|
72
|
-
u)=>p+u,0);m=k-m;const n=a.C.get(b);a.C.set(b,n+m);a.M=!1}if(a.C.has(b))return a.C.get(b);m=yield WL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,m);return m})},ZL=function(a,b,c){return(a=a.j.get(b))?zK(a,c)||null:null},$L=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.
|
|
73
|
-
f.join(", "));return g.toLowerCase().split(";")[0]})},XK=a=>{a=_.
|
|
55
|
+
_.Pm(b.verbatimUri,a.o),{response:d,text:e}=yield VK(a,c);return WK(a,e,d.uri,b.verbatimUri)})},IL=function(a,b,c){return _.w(function*(){const d=yield wL(a,{playlist:c,codecs:b.codecs,type:b.type,kd:b.originalLanguage,hc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,ee:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&EK(d,b.bandwidth);return d})},bL=function(a){return a.w===
|
|
56
|
+
_.Fb},DL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield JL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gL=function(a,b){return _.w(function*(){var c=new URL(b.streams[0].Ne);if(a.a.lowLatencyMode&&a.L&&a.L.eg){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={wi:d.position,Hi:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Hi,d.set("_HLS_msn",e.wi.toString()),null===
|
|
57
|
+
f&&d.get(ZI)&&d.delete(ZI),null!==f&&d.set(ZI,f.toString())}const {response:g,text:h}=yield VK(a,c.toString());c=b.streams[0].ab;d=b.streams[0].Ne;e=g.uri;d!==e&&(d=e,AK(b,d));c=WK(a,h,d,c);return{stream:b,playlist:c}})},BL=function(a,b){var c=_.L(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=LJ(c);b=new Set;const d=[];for(const e of c)c=_.uB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},CL=function(a,b){if(1===b.length)return b[0];a=_.Fr(a,
|
|
58
|
+
b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},EL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return KL(a,e.verbatimUri,()=>_.w(function*(){const f=cJ(d,_.Fa),g=wJ(cJ(d,_.tb));var h=cJ(d,_.tb).toUpperCase();if(wJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.VA;h===JI&&(l=_.GA);k&&(l=_.$d);h=l}k=c.get(`${g}:${f}`)||"";l=_.L(d,_.La);const m=_.L(d,_.Ta),n=_.L(d,"DEFAULT"),p=g===_.q?OJ(d):null;var u=
|
|
59
|
+
g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wL(a,{playlist:e,codecs:k,type:g,kd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,ee:null})}))})},GL=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return KL(a,d.verbatimUri,()=>_.w(function*(){var e=_.L(c,_.pa)||"jpg",f=_.L(c,_.La);const g=_.L(c,_.Ta);e=yield wL(a,{playlist:d,codecs:e,type:_.he,kd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,
|
|
60
|
+
closedCaptions:null,hc:null,groupId:null,ee:null});(f=_.L(c,_.ma))&&EK(e,Number(f));return e}))})},FL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(cJ(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.mb)){var h=_.L(f,"FRAME-RATE");f=_.L(f,_.mb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:hJ(h),width:hJ(k),height:hJ(l)}}else h=null;if(f=yield LL(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=
|
|
61
|
+
(p?p.streams[0].ab:"")+" - "+(n?n.streams[0].ab:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=lL(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},ML=function(a,b,c,d,e,f){let g=BL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Fr(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&
|
|
62
|
+
f?(a.g.debug(VI),c=_.q,b=!0):e?(a.g.debug(VI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(VI));return{type:c,zh:g,ki:b}},KL=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||null;c=c();a.j.set(b,c);return c},LL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.L(f,_.pA),k=_.L(f,_.Eb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>
|
|
63
|
+
u.streams[0].ab===l);const {type:m,zh:n,ki:p}=ML(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield NL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{BK(u,c.width);CK(u,c.height);DK(u,c.frameRate)});return k})},NL=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return KL(a,h.verbatimUri,()=>_.w(function*(){var k=_.L(g,JI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.L(g,_.pA)||void 0)&&a.K.has(k)?k:void 0;var m=CL(d,c);if(k){const n=
|
|
64
|
+
CL(_.q,c);m+=`,${n}`}return yield wL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,kd:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,ee:f})}))})},zL=function(a,b,c,d){return _.w(function*(){var e=b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=pJ(b.ba,RI);var k=h?Number(h.value):g;g=[];h=null;if(a.H){a.H=!1;var l=a.B;a.B=yield OL(a,b.a,e,f,k,c,d);null!=l&&(h=a.B-l)}e=k;if(0===f.length)f=[];else{k=[];l=[];for(var m of f)oJ(m.ba,NI)&&0<l.length&&
|
|
65
|
+
(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield PL(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;QL(g);return g})},JL=function(a,b){return _.w(function*(){var c=b.name!==QI?!0:_.L(b,_.tb)===YI;c=_.L(b,_.wb,void 0,{required:c});if(!c)return null;const d=_.Pm(c,a.o),e=Date.now(),{response:f,text:g}=yield VK(a,d);a.D.onEvent(new _.H(aJ,{detail:{duration:Date.now()-e,type:"media"}}));return WK(a,g,f.uri,c)})},QL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.D,
|
|
66
|
+
4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},RL=function(a,b,c){a=lJ(a.ba,PI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=cJ(a,_.wb),e=_.Pm(d,b);b=BJ(a,null,!0);return new _.qI(()=>[e],b.na,b.ja,c)},SL=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.L(u,LI));n=m+n;k=BJ(u,k?null:l.ja,k);l=String(_.L(u,_.wb));
|
|
67
|
+
const v=(l=_.Pm(l,g))?[l]:[];m=new DJ(c,m,n,()=>v,k.na,k.ja,e,f,!1,null,null,null,null);if("YES"===_.L(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},TL=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<lJ(n,PI).length&&(m=RL(c,k,g));var u=null!=p;const v=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;let y=0,A={na:0,ja:null};p=null;u&&({duration:u}=zJ(n),y=e+u,A=yJ(n,b?b.ja:null));a.a.lowLatencyMode&&0<c.f.length&&(p=SL(b,c,d,e,f,g,k),0===y&&(y=p[p.length-1].endTime));a=h===_.he?qJ(n):
|
|
68
|
+
null;d=new DJ(d,e,y,()=>v,A.na,A.ja,f,g,!1,null,a?a.Ld:null,a?a.ce:null,a?a.durationPerTile:null,p,m);d.ma=l;return d},OL=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(!bL(a)&&a.f)try{return UL(a,c,e)}catch(n){if(h=a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.I(_.D,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
|
|
69
|
+
uri:c});}k=yield VL(a,f,g,h);const l=vK(h.ba,a.o,e),m=RL(h,b,l);h=yield WL(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},PL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0];const l=yield VL(a,e,f,k);var m=g?g.ri:null;if(oJ(c[0].ba,OI)||null===m)m=sK(c,l),m=0===m.length?[oK()]:m;else{var n=sK(c,l);m=[m,...n]}n=m;m=n[n.length-1];n=pK(n);let p=g?g.si:null;var u=XL(p,k.ba,a.o,d);let v=RL(k,b,u)||(g?g.li:null);const y=k.ma;k=yield YL(a,y,v,k,d,u,l,f,h,null==g);u=
|
|
70
|
+
[];let A=!1;for(let F=0;F<c.length;F++){var E=c[F];const C=u[u.length-1]||null,ja=0===F?0:C.endTime,Ca=d+F,Xa=XL(p,E.ba,a.o,Ca);(p=Xa)&&(A=!0);if(E=TL(a,C,E,Ca,ja,k,Xa,e,b,y,v))v=E.initSegment,u.push(E)}return{T:u,Mh:n,ri:m,aesEncrypted:A,mimeType:l,endTime:u[u.length-1].endTime,ma:y,li:v,si:p}})},UL=function(a,b,c){const d=ZL(a,b,c);if(!d)throw new _.I(_.D,4,4030,"Segment not found in previous playlist update.");return a.f.periods.find(e=>e.ma===d.ma).startTime+d.startTime},VL=function(a,b,c,d){return _.w(function*(){const e=
|
|
71
|
+
d.a;var f=pJ(d.ba,PI);f=f?cJ(f,_.wb):null;return $L(a,b,c,e,f)})},WL=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=EJ(c,d);return xK(a.U,b,g,e,f,null!=d)})},XL=function(a,b,c,d){return b.some(e=>e.name===OI&&"NONE"===_.L(e,WI))?null:(b=vK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.em(new Uint8Array(12),jJ(d))}):a},YL=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){if(a.C.has(b)&&l&&a.M&&null!=k){var m=a.f.periods.filter(p=>p.ma<b).map(p=>p.duration).reduce((p,
|
|
72
|
+
u)=>p+u,0);m=k-m;const n=a.C.get(b);a.C.set(b,n+m);a.M=!1}if(a.C.has(b))return a.C.get(b);m=yield WL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,m);return m})},ZL=function(a,b,c){return(a=a.j.get(b))?zK(a,c)||null:null},$L=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Ir(f,b,c);if(g)return g;g=_.vk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.I(g)).headers["content-type"];if(!g)throw new _.I(_.D,4,4021,"Unknown MIME type of: "+
|
|
73
|
+
f.join(", "));return g.toLowerCase().split(";")[0]})},XK=a=>{a=_.Qm(a)||"";return null!=_.Cu.video[a]?_.t:null!=_.Cu.audio[a]?_.q:null},UJ=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.D,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.D,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.T=1===b?d:null}},cK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=
|
|
74
74
|
a;this.f=c;this.ma=-1}},DJ=class extends _.rI{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===v?null:v);this.ma=0}},aK=/^#EXT-X-DEFINE/,bK=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,aM=class{constructor(){this.h=
|
|
75
|
-
0;this.a=new Map}},bM=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},iL=new _.T("clpp.hls.DiscontinuityUtils");var uK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.zg)throw new _.I(_.D,4,4041);if(cJ(a,WI)===XI)throw new _.I(_.D,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.rB(_.
|
|
76
|
-
lK.join(", "),"], not",b),null;b=cJ(a,_.wb);b=_.
|
|
75
|
+
0;this.a=new Map}},bM=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},iL=new _.T("clpp.hls.DiscontinuityUtils");var uK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.zg)throw new _.I(_.D,4,4041);if(cJ(a,WI)===XI)throw new _.I(_.D,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.rB(_.td,[{initDataType:_.Nf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":nK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":nK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=cJ(a,WI);if(!lK.includes(b))return mK.error("Widevine in HLS is only supported with [",
|
|
76
|
+
lK.join(", "),"], not",b),null;b=cJ(a,_.wb);b=_.fm(b);b=_.G(b.data);b=_.rB(_.xd,[{initDataType:_.Xc,initData:b}],"");if(a=_.L(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},lK=["SAMPLE-AES",XI],mK=new _.T("clpp.hls.DrmParser");var tK=new _.T("clpp.hls.EncryptionUtils");var cM=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.rk()}}};var AL=class{constructor(a){this.streams=a}length(){return this.streams.length}Hc(){return this.streams[0].type}};var yL=class{constructor(a){this.a=a}length(){return this.a.length}};var RK=a=>{if(!a)return null;a=pJ(a.ba,SI);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var dM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new bM;this.o="";this.S=new aM;this.G=0;this.l=new _.Li(()=>{this.dc()});this.w=_.Fb;this.f=null;this.F=new _.eu;this.B=0;this.L=null;this.g=new _.T("clpp.hls.HlsParser");this.C=new Map;this.H=this.M=!1;this.U=new cM(this.I.bind(this));this.P=!1;this.J=null;this.R=!1;this.A=new Map;this.K=new Set}configure(a){this.a=a;this.U.a=a}setCurrentVariant(){}start(a,b){const c=this;return _.w(function*(){if(c.P)throw Error("start() may be called only once!");
|
|
77
77
|
c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield VK(c,a);c.D.onEvent(new _.H(aJ,{detail:{duration:Date.now()-d,type:"master"}}));c.o=e.uri;d=yield fL(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.R=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=null;this.A.clear();this.K.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){const b=a.f;if(!bL(a)&&
|
|
78
78
|
b){var c=b.presentationTimeline,d=Array.from(a.j.values()),e=yield hL(a,d);d=e.map(g=>g.playlist);jL(a,d);e=yield mL(a,e);GK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});$K(a,e);var f=nL(a,d);f=oL(a,d,f);b.cues=eL(a,f);IK(b.periods,e);UK(c,e);if(d=tJ(d))!0!==a.a.keepTimelineLive&&pL(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.R&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.w(function*(){const d=a.id;var e=c.f.periods.find(k=>
|
|
79
|
-
k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.
|
|
80
|
-
e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.
|
|
81
|
-
f.verbatimUri,()=>_.w(function*(){const h=yield HL(c,f);jL(c,[h]);return IL(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.
|
|
82
|
-
7,7001);a=this.D.networkingEngine.fetch(a);_.
|
|
79
|
+
k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.pl(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=KL(c,k.verbatimUri,()=>_.w(function*(){const l=yield HL(c,k);return IL(c,k,l)}))}if(e.video){const k=e.video;g=KL(c,k.verbatimUri,()=>_.w(function*(){const l=yield HL(c,k);return IL(c,k,l)}))}f=yield f;g=yield g;e=lL(c,f,g,e.bandwidth,e.id);let h;e&&(e=MK(c.D.configurationId,[e],[],[],0),c.D.filterAllPeriods(e),
|
|
80
|
+
e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.pl(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.w(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.pl(`Could not load text stream with id: ${a}`);const g=yield KL(c,
|
|
81
|
+
f.verbatimUri,()=>_.w(function*(){const h=yield HL(c,f);jL(c,[h]);return IL(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.pl(`Could not load text stream with id: ${a}`);return d})}dc(){const a=this;return _.w(function*(){a.g.debug(_.BA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}I(a){if(!this.F)throw new _.I(_.D,
|
|
82
|
+
7,7001);a=this.D.networkingEngine.fetch(a);_.Fl(this.F,a);return a.V}};_.x("clpp.hls.HlsComponent",class extends _.Ev{install(){_.Kt.m3u8=dM;_.Jt[_.tl]=dM;_.Jt[$I]=dM}uninstall(){_.QC("m3u8");_.RC(_.tl);_.RC($I)}id(){return"hls"}});};f.call(g, window);
|
package/cl.hlssmpte.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
else a.g.warn("A video element is not available. Skipping.")},
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var UT=function(a){a.a.one(a.m,_.re,()=>TT(a))},TT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.pc,d=>VT(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Be).forEach(d=>{VT(a,{track:d})});!WT(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),XT(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
|
|
2
|
+
else a.g.warn("A video element is not available. Skipping.")},VT=function(a,b){b=b.track;b.kind===_.Be&&(a.g.info("The metadata track has been added."),b.mode=_.de,a.a.on(b,_.Cd,c=>YT(a,c)))},WT=function(a){return a.some(b=>b.kind===_.Be)},XT=function(a,b){const c=a.m.getTrackManager(),d=c.ra(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.za(d);a.a.on(b.textTracks,_.pc,g=>{g.track.kind===_.Be&&(a.a.off(b.textTracks,_.pc,f),c.za(d))});c.za(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
YT=function(a,b){const c=ZT(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new $T(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.ri(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},ZT=function(a){return(a=a.m.getTrackManager().ua())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
$T=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.kh(b)&&(b=b.toLowerCase().match(/lang:(\w+)/))&&b[1]){b=b[1].toLowerCase();break a}b=null}this.f=b;a=a.data;this.a=a=_.kh(a)?a:null}}};var aU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Qt;this.h=(a=_.At(_.Cc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;UT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var bU=class extends _.Uv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Yi()){var b=a.getConfiguration();b=_.eh(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Oc&&(b.patchMetadataTrack=!1);_.lh(b.timestampOffset)||(b.timestampOffset=0);this.a=new aU(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",bU);
|
|
5
|
+
bU.Id="hlssmpte";_.Pn(new class{create(){return new bU}});};f.call(g, window);
|
package/cl.htmlcue.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},
|
|
3
|
-
function(a,b){return 1>Math.abs(a-b)||a>b},
|
|
4
|
-
d-e)},
|
|
5
|
-
function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return
|
|
6
|
-
_.r)switch(b){case _.ne:return a.f.position;case "auto":case _.
|
|
7
|
-
|
|
8
|
-
a.viewportAnchorUnits;if(d===_.
|
|
9
|
-
`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},
|
|
10
|
-
a.o=[]}},
|
|
11
|
-
if(b||a.J!==c&&3===a.m.getState())if(a.J=c,c=
|
|
12
|
-
_.
|
|
13
|
-
c.a.appendChild(d)}}}}},
|
|
14
|
-
b){const c=
|
|
15
|
-
e[1];var g=e[3];var h=
|
|
16
|
-
"\x26nbsp;":"\u00a0"};var
|
|
17
|
-
_.Fg?b=(new
|
|
18
|
-
!this.f.region.displayAlign){e=
|
|
19
|
-
100*a)}
|
|
20
|
-
d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=
|
|
21
|
-
_.vf),height:
|
|
22
|
-
b=c;f*=b;break a;default:throw Error(
|
|
23
|
-
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.w(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],
|
|
24
|
-
this.G=new _.
|
|
25
|
-
this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;
|
|
26
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var LS="Unsupported unit",MS="clpp-text-plain",NS="clpp-text-ttml",OS="clpp.htmlcue.HtmlTextDisplayer",PS="initial",QS=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},RS=function(a){return _.ci(a,{ig:(b,c)=>b.Zc(c)})},SS=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},TS=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
|
|
2
|
+
b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},VS=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>US[c]);return a},XS=function(a,b){WS(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{WS(a,c)})},WS=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},YS=function(a,b){return 0===a?"0":a+b},ZS=function(a,b){return 1>Math.abs(a-b)||a<b},$S=function(a,b){return a<b&&1<Math.abs(a-b)},aT=function(a,b){return a>b&&1<Math.abs(a-b)},bT=
|
|
3
|
+
function(a,b){return 1>Math.abs(a-b)||a>b},dT=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new cT(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
|
+
d-e)},eT=function(a){return new cT(a.left,a.f,a.top,a.a,a.height,a.width)},fT=function(a,b){return b.some(c=>$S(a.left,c.f)&&aT(a.f,c.left)&&$S(a.top,c.a)&&aT(a.a,c.top))},gT=function(a,b){return bT(a.top,b.top)&&ZS(a.a,b.a)&&bT(a.left,b.left)&&ZS(a.f,b.f)},hT=function(a,b,c){switch(c){case "+x":return $S(a.left,b.left);case "-x":return aT(a.f,b.f);case "+y":return $S(a.top,b.top);case "-y":return aT(a.a,b.a);default:throw Error("Unknown axis");}},iT=function(a){return a.f.writingMode===_.qu},jT=
|
|
5
|
+
function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return iT(a)?b:c},kT=function(a){switch(a.f.writingMode){case _.qu:return"horizontal-tb";case _.xg:return _.xg;case _.yg:return _.yg;default:throw Error("Unknown writing mode");}},lT=function(a){switch(a.f.positionAlign){case _.ne:return _.ke;case "auto":case _.Yc:return _.pu;case _.oe:return _.Cf}return a.f.textAlign},mT=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===
|
|
6
|
+
_.r)switch(b){case _.ne:return a.f.position;case "auto":case _.Yc:return a.f.position-a.f.size/2;case _.oe:return a.f.position-a.f.size}return 0},nT=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.Qf:case _.ke:return _.ne;case _.pu:return _.Yc;case _.Wd:case _.Cf:return _.oe}return a.f.positionAlign},qT=function(a,b,c){return(oT(a)||pT(a))&&_.lh(c)?YS(c,_.vf):oT(a)&&_.z(c)?YS(0,_.vf):iT(a)&&_.lh(b)?YS(b,"%"):PS},rT=function(a,b,c){return iT(a)&&_.lh(c)?YS(c,_.vf):(oT(a)||pT(a))&&_.lh(b)?
|
|
7
|
+
YS(b,"%"):PS},pT=function(a){return a.f.writingMode===_.yg},oT=function(a){return a.f.writingMode===_.xg},sT=function(a,b){if(a.j)switch(b.writingMode){case _.qu:return["-y"];case _.xg:return["+x"];case _.yg:return["-x"]}a=[];switch(b.writingMode){case _.qu:a=["+y","-y"];break;case _.xg:a=["+x","-x"];break;case _.yg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},tT=function(a){for(a.h=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=dT(a.l.a)},uT=function(a,b,c){a=a.f;const d=
|
|
8
|
+
a.viewportAnchorUnits;if(d===_.xu)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(LS);},wT=function(a,b,c,d){const e=document.createElement(_.Wf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);vT(a,c,b);a.g.debug(`Created HTML style element #${b}.`);return e.sheet},xT=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,
|
|
9
|
+
`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},yT=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);return c},zT=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
|
|
10
|
+
a.o=[]}},vT=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.g.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.l.push(()=>d.disconnect())},AT=function(a){a=_.eh(a.htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},GT=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();
|
|
11
|
+
if(b||a.J!==c&&3===a.m.getState())if(a.J=c,c=BT(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,CT(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.Gt(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.Fg:g="clpp-text-vtt";break;case _.jg:g=NS;break;case _.ou:g=MS}g&&!f.classList.contains(g)&&
|
|
12
|
+
_.Ci(f,g);f=dT(c.a.a);if(0===f.width||0===f.height)c.g.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");else{WS({fontSize:DT(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Fg;var h=d.payloadType===_.jg;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new ET(d.region,{}),c.B.set(d.region.id,f),c.a.appendChild(f)));d=new FT(d,c.L,e);f?f.appendChild(d):
|
|
13
|
+
c.a.appendChild(d)}}}}},HT=function(a){CT(a);a.J=null;a.o=null;a.f=[]},IT=function(a,b){return a.startTime<=b&&a.endTime>b},BT=function(a,b){var c=QS(a.f,d=>IT(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&IT(a.f[d-1],b);)d--;for(;c+1<a.f.length&&IT(a.f[c+1],b);)c++;return{start:d,end:c}}},CT=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(NS);b.classList.remove(MS);a=a.a;tT(a.h);a.l=[]}},DT=function(a,
|
|
14
|
+
b){const c=dT(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.C)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},MT=class{parse(a){a={input:a};const b=_.Ei(_.Gd),c=[];let d=b;for(var e;null!==(e=TS(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=
|
|
15
|
+
e[1];var g=e[3];var h=JT[f];h?(h=_.Ei(h),(f=KT[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||LT[g.localName]&<[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(VS(e)));return b}},JT={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},KT={v:"voice",lang:"lang"},LT={rt:"ruby"},US={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
|
|
16
|
+
"\x26nbsp;":"\u00a0"};var cT=class{constructor(a,b,c,d,e,f){this.left=a;this.f=b;this.top=c;this.a=d;this.height=e;this.width=f}};var NT=class{constructor(a,b,c){this.id=a;this.w=b;this.B=c;this.a=this.o();this.j=!1}init(){this.j=!0}A(){return!1}};var FT=class extends NT{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.h=!!this.f.backgroundImage;this.C=c}A(){return!this.h&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.h)_.Ci(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.l.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.jg){var c=_.Ei(_.Gd);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
17
|
+
_.Fg?b=(new MT).parse(b.payload):(c=_.Ei(_.Gd),c.textContent=b.payload,b=c);_.Ci(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.Ci(b,d);WS({writingMode:kT(this)},b);var d=b;this.a.appendChild(d);_.Ci(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.Ci(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.ru,this.f.line=iT(this)?-1:0);e=kT(this);WS({writingMode:e,webkitWritingMode:e,direction:PS,textAlign:lT(this)},this.a);if(!this.f.region||
|
|
18
|
+
!this.f.region.displayAlign){e=mT(this,nT(this));WS({position:"absolute",left:qT(this,e,null),right:pT(this)&&_.z(null)?YS(0,_.vf):PS,top:rT(this,e,null),width:iT(this)?YS(this.f.size,"%"):PS,height:oT(this)||pT(this)?YS(this.f.size,"%"):PS},this.a);b=this.f;a=iT(this)?a.height:a.width;c=jT(this);if(b.lineInterpretation===_.ru){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.Yc:g-=f/2;break;case _.Wd:g-=f}f=Math.round(g/
|
|
19
|
+
100*a)}pT(this)&&(f=a-f-c);a=f;WS({left:qT(this,e,a),right:pT(this)&&_.z(a)?YS(0,_.vf):PS,top:rT(this,e,a)},this.a)}XS(this.C,d)}}o(){return _.Ei(_.Gd)}};var OT=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=dT(a.a);this.h=[]}append(a){const b=a.a;b.style.visibility=_.de;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=dT(a.a);var d=sT(this,a.f),e=jT(a);const g=eT(c);let h=null,k=0;for(const l of d){for(;hT(c,this.a,l)||gT(c,this.a)&&fT(c,this.h);){d=c;var f=e;switch(l){case "+x":d.left+=f;d.f+=f;break;case "-x":d.left-=f;d.f-=f;break;case "+y":d.top+=f;d.a+=f;break;case "-y":d.top-=f,d.a-=f}}if(this.j||gT(c,this.a))break a;
|
|
20
|
+
d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=eT(c),k=d);c=eT(g)}c=h||g}WS({top:YS(c.top-this.a.top,_.vf),bottom:YS(this.a.a-c.a,_.vf),left:YS(c.left-this.a.left,_.vf),right:YS(this.a.f-c.f,_.vf),height:YS(c.height,_.vf),width:YS(c.width,_.vf)},a.a)}b.style.visibility="visible";this.h.push(dT(a.a))}};var PT=class extends NT{constructor(a,b,c){super(a,b,c);this.h=null;this.l=[]}init(){this.h=new OT(this);this.j=!0}o(){const a=_.Ei(_.Gd);_.Ci(a,this.w);this.id&&(a.id=this.id);return a}appendChild(a){tT(this.h);this.l.unshift(a);for(const b of this.l)this.h.append(b)}};var ET=class extends PT{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.xu:b=b.width/100*a.width;break a;default:throw Error(LS);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.xu)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(LS);d=a.height;const e=uT(this,d,a.height);WS(this.B,this.a);WS({left:YS(c,_.vf),top:YS(e,_.vf),width:YS(b,
|
|
21
|
+
_.vf),height:YS(d,_.vf)},this.a);this.f.writingMode&&WS({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&WS({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.Ci(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.xu:f=f.height/100*a.height;break a;case 2:f=f.height;c=new FT(new _.uu(0,1,"Lorem ipsum",_.ou),{},{});b=c.a;this.a.appendChild(b);c.init(dT(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
22
|
+
b=c;f*=b;break a;default:throw Error(LS);}a=uT(this,f,a.height);WS({top:YS(a,_.vf),height:YS(f,_.vf)},this.a);this.h=new OT(this,!0);this.j=!0}getId(){return this.f.id}};var QT=class{constructor(a,b){this.g=new _.T("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.h=b;this.o=[];this.a=wT(this,this.h,this.j);this.f=wT(this,this.h,this.j,!0);this.f.disabled=!0;this.g.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=xT(this,a);if(yT(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.g.debug(`Added CSS rule ${b}`)}catch(c){this.g.error(`An error occurred when adding a CSS rule: ${b}`)}this.o.push(a)}else this.g.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
|
|
23
|
+
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.w(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],zT(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.g.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var RT=class extends _.Mv{constructor(a){super(a);this.g=new _.T(OS);this.m=a;this.L=AT(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new QT(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new PT(null,"clpp-text-container",{});this.A=new _.Iv(a.getSurface(),this.S.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.g.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
|
|
24
|
+
this.G=new _.Li(()=>{GT(this)});this.B=new Map;this.o=null}append(a,b){if(null!=this.j&&0!==a.length){for(const c of b)this.j.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=SS(this.f,RS(a));this.o=null;GT(this,!1)}}h(){null==this.j||GT(this,!0)}destroy(){const a=this;return _.w(function*(){null!=a.j&&(HT(a),a.G.stop(),yield a.j.destroy(),a.j=null,a.F.removeChild(a.a.a),a.a=null,a.A.stop(),a.A=null,a.l=!1)})}remove(a,b){if(null==this.j)return!1;
|
|
25
|
+
this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;GT(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.Hb(.25),this.L.enableResizeObserver&&this.A.start(),GT(this,!0)):(this.G.stop(),this.A.stop(),HT(this)))}S(){GT(this,!0)}};_.x(OS,RT);RT.prototype.setTextVisibility=RT.prototype.setTextVisibility;RT.prototype.isTextVisible=RT.prototype.isTextVisible;RT.prototype.remove=RT.prototype.remove;RT.prototype.destroy=RT.prototype.destroy;
|
|
26
|
+
RT.prototype.append=RT.prototype.append;var ST=class{a(a){return!!a.enableHtmlCue&&!_.$i()}create(a){return new RT(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Ev{install(){_.ms(_.fe,new ST)}uninstall(){_.ks.has(_.fe)&&(_.ks.delete(_.fe),_.ls.info("Removed factory: 'html'"))}id(){return _.Xf}});};f.call(g, window);
|
package/cl.ima.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var sS="clpp.ima.AdsManagerFactory",tS=function(){return!window.google||!google.ima||!google.ima.AdsLoader},uS=function(a){a=a.H;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.r&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.
|
|
2
|
-
_.r&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===_.
|
|
3
|
-
c.on(b,d.AD_PROGRESS,a.Ib.bind(a));c.on(b,d.AD_BUFFERING,a.Ac.bind(a));c.on(b,d.FIRST_QUARTILE,a.
|
|
4
|
-
10003,{errorType:c},b))},yS=function(a){return vS(a)&&a.a.isCustomPlaybackUsed()},zS=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new W(c,a.J,a.I)});a.m.trigger(new _.H(b,d))},
|
|
5
|
-
clearTimeout(e),c())},200)})})},
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
W.prototype.getSequenceLength=W.prototype.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var sS="clpp.ima.AdsManagerFactory",tS=function(){return!window.google||!google.ima||!google.ima.AdsLoader},uS=function(a){a=a.H;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.r&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.Oc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.r&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===
|
|
2
|
+
_.r&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===_.Oc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},vS=function(a){const b=_.Pi()||_.Si()||_.$i();return!1===a.H.disableCustomPlayback&&b},wS=function(a){const b=a.a,c=a.S,d=google.ima.AdEvent.Type;c.on(b,d.AD_BREAK_READY,a.yc.bind(a));c.on(b,d.LOADED,a.lb.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.md.bind(a));c.on(b,d.STARTED,a.Tb.bind(a));c.on(b,d.LOG,a.Dc.bind(a));
|
|
3
|
+
c.on(b,d.AD_PROGRESS,a.Ib.bind(a));c.on(b,d.AD_BUFFERING,a.Ac.bind(a));c.on(b,d.FIRST_QUARTILE,a.La.bind(a));c.on(b,d.MIDPOINT,a.Fc.bind(a));c.on(b,d.THIRD_QUARTILE,a.Ub.bind(a));c.on(b,d.PAUSED,a.Ic.bind(a));c.on(b,d.RESUMED,a.Jc.bind(a));c.on(b,d.CLICK,a.Aa.bind(a));c.on(b,d.SKIPPED,a.Jb.bind(a));c.on(b,d.IMPRESSION,a.bb.bind(a));c.on(b,d.COMPLETE,a.Bc.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.od.bind(a))},xS=function(a,b){const c=b?a.xc.create(b.getErrorCode()):null;a.m.onError(new _.I(1,9,
|
|
4
|
+
10003,{errorType:c},b))},yS=function(a){return vS(a)&&a.a.isCustomPlaybackUsed()},zS=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new W(c,a.J,a.I)});a.m.trigger(new _.H(b,d))},BS=function(a){_.w(function*(){a.M=a.m.getPosition();yield AS(a,3);yield a.m.pause();yield a.m.detach();a.a.start()})},AS=function(a,b){return _.w(function*(){return new Promise((c,d)=>{const e=setTimeout(()=>{clearInterval(f);d(Error("Timeout waiting for player state"))},1E4),f=setInterval(()=>{a.m.getState()>=b&&(clearInterval(f),
|
|
5
|
+
clearTimeout(e),c())},200)})})},CS=function(a){a.U=!1;a.G=null;zS(a,_.nc);a.m.getSurface().hide(a.da)},DS=function(a){_.Di(a.F,{visibility:"visible"})},FS=function(a){_.w(function*(){a.ia.initialize();const b=!!a.m.getConfiguration().muted;(yield a.X.canPlay(b))||yS(a)?ES(a):(zS(a,_.Mc),a.g.warn(_.ka))})},ES=function(a){a.a.init(a.F.offsetWidth,a.F.offsetHeight,google.ima.ViewMode.NORMAL);yS(a)?a.H.isVast&&BS(a):a.a.start();a.ca=!0},W=class{constructor(a,b,c){this.a=a;this.f=a.getAdPodInfo();this.j=
|
|
6
|
+
b;this.h=c}cb(){return"Google IMA SDK"}eb(){return google.ima.VERSION}gb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}zb(){return""}getApiFramework(){return this.a.getApiFramework()}getAdSystem(){return this.a.getAdSystem()}getAdvertiserName(){return this.a.getAdvertiserName()}getTitle(){return this.a.getTitle()}getDuration(){return this.a.getDuration()}getPosition(){return 0}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}Bb(){return this.f?this.f.getIsBumper():
|
|
7
|
+
!1}Qa(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Ie&&typeof b[d].clickThroughUrl===_.Uf);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}Ua(){return this.a.getVastMediaWidth()}Ta(){return this.a.getVastMediaHeight()}Ba(){return this.a.getVastMediaBitrate()}Ca(){return this.h?2:this.j?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}pb(){return this.f?this.f.getTimeOffset():0}fb(){return this.f?this.f.getAdPosition():1}Va(){return this.f?
|
|
8
|
+
this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}canSeek(){return!1}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}Ab(){return null}};W.prototype.getVideoElement=W.prototype.Ab;W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.canSeek=W.prototype.canSeek;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;
|
|
9
|
+
W.prototype.getSequenceLength=W.prototype.Va;W.prototype.getPositionInSequence=W.prototype.fb;W.prototype.getPodTimeOffset=W.prototype.pb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Ca;W.prototype.getMediaBitrate=W.prototype.Ba;W.prototype.getMediaHeight=W.prototype.Ta;W.prototype.getMediaWidth=W.prototype.Ua;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Qa;W.prototype.isBumper=W.prototype.Bb;
|
|
10
10
|
W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getPosition=W.prototype.getPosition;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;W.prototype.getSourceId=W.prototype.zb;W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;
|
|
11
|
-
W.prototype.getTechnology=W.prototype.
|
|
12
|
-
(this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}
|
|
13
|
-
this.xc=new
|
|
14
|
-
9,10002)),this.o()):(this.setMuted(this.C),this.h(this.L),this.l=new _.Iv(this.m.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.R=new
|
|
15
|
-
zS(this,_.dc,a):(this.a.discardAdBreak(),this.J||(this.J=!0,this.m.play()))}Tb(a){this.U=!0;this.K=!1;this.G=a.getAd().getDuration();zS(this,_.mc,a);this.m.getSurface().show(this.da)}Dc(a){a=a.getAdData();xS(this,a?a.adError:null);
|
|
16
|
-
_.Yb,a);
|
|
17
|
-
a.m;const c=a.H;try{if(typeof c.adTagUrl!==_.Uf)throw new _.I(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),a.f;b=yield a.X.canPlay(!1);const d=yield a.X.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.B.getSettings().setAutoPlayAdBreaks(!1);a.B.requestAds(e);return a.f})}j(){if(this.W||!this.a||this.W)return!0;if(!this.ca){if(this.R.Qb())return
|
|
18
|
-
|
|
19
|
-
null===this.G)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.G-a}o(){this.a&&(this.a.destroy(),this.a=null);this.W=!0;
|
|
20
|
-
|
|
11
|
+
W.prototype.getTechnology=W.prototype.gb;W.prototype.getAdManagerVersion=W.prototype.eb;W.prototype.getAdManagerName=W.prototype.cb;var GS=class{create(a){const b=google.ima.AdError.ErrorCode;switch(a){case b.VAST_LOAD_TIMEOUT:case b.VAST_MEDIA_LOAD_TIMEOUT:case b.FAILED_TO_REQUEST_ADS:return 0;case b.VIDEO_PLAY_ERROR:return 1;default:return 2}}};var HS=class{constructor(a){this.a=a}getCuePoints(){return this.a}Qb(){return 0<=this.a.indexOf(0)||0===this.a.length}Pb(){return 0<=this.a.indexOf(-1)}};HS.prototype.hasPostroll=HS.prototype.Pb;HS.prototype.hasPreroll=HS.prototype.Qb;HS.prototype.getCuePoints=HS.prototype.getCuePoints;var IS=class extends _.Uv{constructor(){super();this.a=this.h=this.f=null}onPlayerCreated(a){if(tS())return a.onError(new _.I(1,9,1E4));this.f=_.Bi(_.Gd,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.h=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.h);this.a.getSettings().setPlayerType(_.ra);this.a.getSettings().setPlayerVersion(_.ea);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
|
|
12
|
+
(this.a.destroy(),this.a=null);this.h&&(this.h.destroy(),this.h=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}Xh(){return this.a}Vh(){return this.h}$c(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",IS);IS.prototype.getAdContainer=IS.prototype.$c;IS.prototype.getAdDisplayContainer=IS.prototype.Vh;IS.prototype.getAdsLoader=IS.prototype.Xh;IS.Id="ima";IS.isSdkMissing=tS;var JS=class{create(){return new IS}};var KS=class{constructor(a){var b=a.Gd("ima");if(!b)throw Error("IMA plugin not created.");var c=b.$c(),d=b.h;b=b.a;if(!c||!d||!b)throw Error("IMA plugin not initialized.");const e=a.getSurface().getMedia();if(!e)throw Error("Missing media element.");this.m=a;this.F=e;a=this.m.getConfiguration();a=_.eh(a.ima||{});this.H=a=_.dh({disableCustomPlayback:!1},a);this.da=c;this.ia=d;this.B=b;this.X=new _.Kv;this.g=new _.T("clpp.ima");this.a=null;this.W=!1;this.l=null;this.f=new _.Gl;this.ca=!1;this.S=new _.Qt;
|
|
13
|
+
this.xc=new GS;this.G=null;this.C=this.U=!1;this.L=1;this.P=this.I=this.J=!1;this.M=this.R=null;this.K=!0;c=this.S;d=google.ima.AdErrorEvent.Type.AD_ERROR;c.one(this.B,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.hd.bind(this));c.on(this.B,d,this.Lc.bind(this));c.on(this.m,_.Xd,this.jd.bind(this))}hd(a){this.a=a.getAdsManager(this.F,uS(this));this.a.isCustomPlaybackUsed()&&!vS(this)?(this.g.warn("IMA plugin is disabled for this platform with single video element. Disposing."),this.m.onError(new _.I(1,
|
|
14
|
+
9,10002)),this.o()):(this.setMuted(this.C),this.h(this.L),this.l=new _.Iv(this.m.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.R=new HS(a),this.m.trigger(new _.H(_.qc,{adsTimeline:this.R})),wS(this));this.f.resolve()}Lc(a){xS(this,a.getError());this.f.resolve()}md(a){this.P=!0;yS(this)||(this.m.pause(),_.Di(this.F,{visibility:_.de}));zS(this,_.Ub,a);this.l.start()}yc(){yS(this)?BS(this):this.a.start()}lb(a){a.getAd().isLinear()?
|
|
15
|
+
zS(this,_.dc,a):(this.a.discardAdBreak(),this.J||(this.J=!0,this.m.play()))}Tb(a){this.U=!0;this.K=!1;this.G=a.getAd().getDuration();zS(this,_.mc,a);this.m.getSurface().show(this.da)}Dc(a){a=a.getAdData();xS(this,a?a.adError:null);CS(this)}Ib(a){zS(this,_.jc,a)}Ac(a){zS(this,_.Wb,a)}La(a){zS(this,_.Zb,a)}Fc(a){zS(this,_.ec,a)}Ub(a){zS(this,_.oc,a)}Ic(a){this.K=!0;zS(this,_.hc,a)}Jc(a){this.K=!1;zS(this,_.kc,a)}Aa(a){this.pause();zS(this,_.Xb,a)}Jb(a){zS(this,_.lc,a);CS(this)}bb(a){zS(this,_.cc,a)}Bc(a){zS(this,
|
|
16
|
+
_.Yb,a);CS(this)}od(){const a=this;return _.w(function*(){a.J=!0;if(yS(a)&&null!==a.M){const c=a.m.getVolume(),d=a.m.isMuted();var b=a.m;b.a&&b.a.forwardEventsTo(b);b=a.m;b.f=_.dh(b.f,{volume:c,muted:d});yield _.jo(a.m);!a.I&&a.M&&(yield AS(a,2),yield a.m.play(),yield a.m.pause(),yield AS(a,4),yield a.m.setPosition(a.M))}else{if(!a.P)return a.m.play();DS(a)}a.P=!1;a.l&&a.l.stop();a.I||(yield a.m.play());zS(a,_.Vb)})}jd(){this.I=!0;this.B.contentComplete()}load(){const a=this;return _.w(function*(){var b=
|
|
17
|
+
a.m;const c=a.H;try{if(typeof c.adTagUrl!==_.Uf)throw new _.I(1,9,10001,{missingKeys:"adTagUrl"});}catch(f){return b.onError(f),a.f.resolve(),a.f}if(!c.adTagUrl)return a.f.resolve(),a.f;b=yield a.X.canPlay(!1);const d=yield a.X.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.B.getSettings().setAutoPlayAdBreaks(!1);a.B.requestAds(e);return a.f})}j(){if(this.W||!this.a||this.W)return!0;if(!this.ca){if(this.R.Qb())return FS(this),!1;this.ia.initialize();
|
|
18
|
+
ES(this);return!0}return this.qb()&&this.a?(this.a.resume(),!1):!0}A(){}w(){return!0}ib(){this.a&&this.a.pause()}isPaused(){return this.K}skip(){this.a&&this.a.skip()}getAdVolume(){return this.a?this.C?this.L:this.a.getVolume():1}h(a){this.L=a;this.a&&(this.C||this.a.setVolume(a))}setVolume(a){this.h(a)}getVolume(){return this.getAdVolume()}pause(){this.ib()}resume(){this.j()}setMuted(a){this.C=a;this.a&&(a?this.a.setVolume(0):this.a.setVolume(this.L))}isMuted(){return this.C}qb(){return this.U}getPosition(){if(!this.a||
|
|
19
|
+
null===this.G)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.G-a}o(){this.a&&(this.a.destroy(),this.a=null);this.W=!0;DS(this);this.S.release();this.l&&(this.l.stop(),this.l=null);return Promise.resolve()}};KS.prototype.getPosition=KS.prototype.getPosition;KS.prototype.resume=KS.prototype.resume;KS.prototype.pause=KS.prototype.pause;KS.prototype.getVolume=KS.prototype.getVolume;KS.prototype.setVolume=KS.prototype.setVolume;KS.prototype.getAdVolume=KS.prototype.getAdVolume;
|
|
20
|
+
KS.prototype.skip=KS.prototype.skip;KS.prototype.pauseAd=KS.prototype.ib;_.Gh(new class{constructor(){this.Xa=new _.T(sS)}name(){return sS}a(a,b){return a.namespace()===_.id?!1:tS()?(this.Xa.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new KS(a)}});_.Pn(new JS);};f.call(g, window);
|
package/cl.mediatailor.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qS=function(a,b,c){return _.w(function*(){var d=yield(yield fetch(b,{method:_.eb,body:JSON.stringify(c.sessionConfig)})).json();const e=d.trackingUrl;d={
|
|
2
|
-
- manifest URI: ${d.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qS=function(a,b,c){return _.w(function*(){var d=yield(yield fetch(b,{method:_.eb,body:JSON.stringify(c.sessionConfig)})).json();const e=d.trackingUrl;d={Rg:_.Pm(d.manifestUrl,b),Pj:e?_.Pm(e,b):null};a.g.info(`Media Tailor session initialized.
|
|
2
|
+
- manifest URI: ${d.Rg}`);return d})},rS=class extends _.Uv{constructor(){super();this.g=new _.T("clpp.mediatailor.MediaTailorPlugin")}onContentWillLoad(a,b){const c=this;return _.w(function*(){const d=a.getConfiguration().mediatailor;if(d.enabled){c.g.info("MediaTailor plugin is enabled");try{const e=yield qS(c,b.url,d);a.trigger(new _.H("mt-session-started"));b.url=e.Rg}catch(e){throw c.g.error("Failed to start session",e),new _.I(_.D,9,7003,"Media Tailor session failed to initialize.");}}})}id(){return"mediatailor"}};_.Pn(new class{create(){return new rS}});};f.call(g, window);
|