@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.hls.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Mz="CLOSED-CAPTIONS",Nz="Could not parse MP4 segment start time.",Oz="EXT-X-BYTERANGE",Pz="EXT-X-DISCONTINUITY",Qz="EXT-X-DISCONTINUITY-SEQUENCE",Rz="EXT-X-ENDLIST",Sz="EXT-X-MEDIA-SEQUENCE",
|
|
2
|
-
4,4023,b);return a.value},
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
_.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
e)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
d
|
|
36
|
-
this.
|
|
37
|
-
return _.w(function*(){c.D=b;
|
|
38
|
-
d:c;yield
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Mz="CLOSED-CAPTIONS",Nz="Could not parse MP4 segment start time.",Oz="EXT-X-BYTERANGE",Pz="EXT-X-DISCONTINUITY",Qz="EXT-X-DISCONTINUITY-SEQUENCE",Rz="EXT-X-ENDLIST",Sz="EXT-X-MAP",Tz="EXT-X-MEDIA-SEQUENCE",Uz="EXT-X-PART-INF",Vz="EXT-X-PLAYLIST-TYPE",Wz="EXT-X-PRELOAD-HINT",Xz="EXT-X-SERVER-CONTROL",Yz="EXT-X-STREAM-INF",Zz="EXT-X-TARGETDURATION",$z="EXTINF",aA="Guessing audio-only",bA="SAMPLE-AES-CTR",cA="SUBTITLES",dA="application/vnd.apple.mpegurl",eA=function(a,b){a=a.getAttribute(b);
|
|
2
|
+
if(!a)throw new _.G(_.F,4,4023,b);return a.value},fA=function(a){if(1>a.a)throw _.xj();--a.a},gA=function(a,b){return a.filter(c=>c.name==b)},hA=function(a,b){return a.filter(c=>eA(c,"TYPE")===b)},iA=function(a,b){a=gA(a,b);return a.length?a[0]:null},jA=function(a,b){return _.wu([a],[b])[0]},nA=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.yg(a.a++,h),kA.includes(h.name)?d.push(h):lA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===Wz&&"PART"===_.rg(h,
|
|
3
|
+
"TYPE")&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=jA(b,h.trim()),e.push(new mA(h,f,g)),f=[],g=[])});0<g.length&&e.push(new mA(null,f,g));return{$:e,fa:d}},oA=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},pA=function(a){function b(h,k,l){let m="";for(;k<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 _.G(_.F,
|
|
4
|
+
4,4030);}oA(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|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}oA(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},qA=function(a,
|
|
5
|
+
b){let c=null,d=0;try{(new _.Mj).M(_.wd,_.N).M(_.we,_.N).M(_.rd,_.N).X("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.M(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.eq.error("Unable to find timescale in init segment!"),new _.G(_.F,4,4030,Nz,c);let e=0,f=!1;try{(new _.Mj).M("moof",_.N).M("traf",_.N).X("tfdt",g=>{e=(0==g.version?_.M(g.reader):_.Cj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.G(_.F,4,4030,Nz,c);return e},rA=function(a){for(;a.getPosition()<
|
|
6
|
+
a.wa()-1;){const b=a.getPosition();if(71===_.yj(a))return fA(a),b}return-1},sA=function(a){function b(){d.seek(e+188);f=_.yj(d);71!=f&&(d.seek(e+192),f=_.yj(d));71!=f&&(d.seek(e+204),f=_.yj(d));71!=f&&c();fA(d)}function c(){throw new _.G(_.F,4,4030);}const d=new _.vk(new DataView(a),!1);let e=0,f=0;e=rA(d);0>e&&(_.eq.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.yj(d);71!=f&&c();a=_.zj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.yj(d)&
|
|
7
|
+
48)>>4;0!=a&&2!=a||c();3==a&&(a=_.yj(d),d.skip(a));if(1!=_.M(d)>>8){b();continue}d.skip(3);a=_.yj(d)>>6;0!=a&&1!=a||c();0==_.yj(d)&&c();a=_.yj(d);const g=_.zj(d),h=_.zj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},tA=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.Qu(b.Ca(),b.Ta,b.Ta+2048-1,a.a.attemptParameters);e.type=2;const f=_.Qu(b.Ca(),b.Ta,b.Ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.g(c?f:e)}catch(g){if(7001===g.code||c)throw g;
|
|
8
|
+
a.f.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.",e.uris[0]);try{return yield a.g(f)}catch(h){throw a.f.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.G(_.F,4,4030,"Failed to fetch the media segment.");}}})},uA=function(a,b,c,d,e,f){return _.w(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.dc||d===
|
|
9
|
+
_.cc)return 0;if(d===_.bc){var g=yield tA(a,c,f);const h=_.H(g.data);return oA(h)?pA(h):sA(g.data)}if(d===_.Je||d===_.ec)return g=[tA(a,c,f)],b&&g.push(tA(a,b,!0)),g=yield Promise.all(g),qA(g[0].data,(g[1]||g[0]).data);if(d===_.Ie)return g=yield tA(a,c,f),sA(g.data);if(!MediaSource.isTypeSupported(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.G(_.F,4,4030);})},vA=function(a){var b=eA(a,"METHOD");const c=["SAMPLE-AES",bA];if(!c.includes(b))return _.Jf("PlayReady in HLS is only supported with [",
|
|
10
|
+
c.join(", "),"], not",b),null;a=eA(a,_.mb);b=_.go(a);a=null;b=_.H(b.data);try{a=_.nu(_.Fk(b))}catch(d){a=b}return _.xu(_.Jc,[{initDataType:_.tc,initData:a}],"")},wA=function(a,b){return _.w(function*(){var c=_.bh([b],a.g.attemptParameters);c.type=1;c=yield a.R(c);let d="";try{d=_.Ig(c.data)}catch(e){throw new _.G(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},DA=function(a,b){return _.w(function*(){var c=xA(a,b,a.w,"");if(1===c.type){a.G.set(a.w,c);c=
|
|
11
|
+
_.Qo(c.$[0].a)||"";c=null!=_.Po.video[c]?_.u:null!=_.Po.audio[c]?_.ac:null;var d="";c===_.u?d="avc1.42E01E":c===_.ac&&(d="mp4a.40.2");{c=a.aa;var e=a.w;d=a.g.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.wg(_.ka,"0"));k.push(new _.wg(_.mb,e));d.length&&k.push(new _.wg(_.ma,d));h.push(new _.xg(c.a++,Yz,k));c=new yA(e,0,h)}}c=yield zA(a,c.fa);if(!a.D)throw new _.G(_.F,7,7001);a.D.filterAllPeriods([c]);d=e=Infinity;for(var f of a.a.values())e=Math.min(e,f.Dd),f.type!==_.r&&(d=Math.min(d,f.duration));
|
|
12
|
+
a.j===AA?a.h=new _.Bz(null,0,!0):(a.h=new _.Bz(0,a.S,!1),_.Uu(a.h,1));BA(a);if(a.j===AA){a.h.Lb(d);a.h.offset(-e);for(const h of a.a.values())h.segmentIndex.offset(-e),_.gv(h.segmentIndex,d)}else{a.V=a.F;a.j===CA&&(f=Math.max(d,a.h.Md),isNaN(a.g.availabilityWindowOverride)||(f=a.g.availabilityWindowOverride),a.h.Zb=f);f=0;for(var g of a.a.values())f=Math.max(f,g.Dd);for(g=0;95443.7176888889<=f;)g+=95443.7176888889,f-=95443.7176888889;if(g){a.f.debug("Offsetting live streams by",g,"to compensate for rollover");
|
|
13
|
+
for(const h of a.a.values())95443.7176888889>h.Dd?(a.f.debug("Offset applied to",h.type),h.segmentIndex.offset(g)):a.f.debug("Offset NOT applied to",h.type)}}return{presentationTimeline:a.h,periods:[c],offlineSessionIds:[],minBufferTime:0}})},GA=function(a,b){return _.w(function*(){var c=new _.eg(b.Ue);if(a.g.hlsLowLatency){var d=c.a;if(b.$e){var e=b.segmentIndex;if(e=e.a[e.a.length-1]){var f=e.a,g=f.length-1;e={Bf:e.position,Hf:f&&0<f.length?g:null}}else e=null;const {Bf:l,Hf:m}=e;null!==l&&(d.add("_HLS_msn",
|
|
14
|
+
l),null!==m&&d.add("_HLS_part",m))}e=d;_.pg(e);e.g&&_.hg(c,d)}const {response:h,text:k}=yield wA(a,c.toString());c=xA(a,k,h.uri,b.Jc);if(1!==c.type)throw new _.G(_.F,4,4017);d=yield EA(a,b.Jc,c,b.type,b.mimeType,b.codecs,b.keyInfo||null,b.ef);b.$=d;b.segmentIndex.replace(d);d=d[d.length-1];iA(c.fa,Rz)&&(FA(a,AA),a.h.Lb(d.endTime))})},xA=function(a,b,c,d){a:{a=a.aa;b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.G(_.F,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||
|
|
15
|
+
/^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.yg(0,h),kA.includes(e.name)){f=1;break}else e.name===Yz&&(g=!0)}h=f;f=[];g=!0;for(var k of _.yu(b)){let {Wc:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||g)g=!1;else{e=m;e=_.yg(a.a++,e);if(HA.includes(e.name)){if(1!==h)throw new _.G(_.F,4,4017);k=b.splice(l,b.length-l);a=nA(a,c,k);c=new yA(c,h,f.concat(a.fa),a.$);break a}f.push(e);e.name===Yz&&(e.attributes.push(new _.wg(_.mb,n)),g=!0)}}c=new yA(c,h,f)}c.f=d;return c},EA=function(a,b,c,
|
|
16
|
+
d,e,f,g,h){return _.w(function*(){var k=c.$;const l=IA(c,g);var m=(m=iA(c.fa,Tz))?Number(m.value):0;null===a.J&&(a.J=yield JA(a,b,l,k[0],m,g,e,f,d));const n=a.J;a.f.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=iA(c.fa,Qz);let t=q?Number(q.value):0;h.has(t)||h.set(t,m);if(!q)for(;h.has(t+1)&&h.get(t+1)<m;)t++;q=a.H.get(t)||0;const v=[];for(const E of _.yu(k)){var y=E.Wc;k=E.item;{var A=v[v.length-1];const D=0==y?n:A.endTime;y=m+y;iA(k.fa,Pz)&&(t++,h.set(t,y),q=yield KA(a,t,b,
|
|
17
|
+
l,k,y,g,e,f,D,d));A=LA(a,A,k,y,D,q,g,d,c.a);k=iA(k.fa,$z);A&&(a.g.hlsLowLatency||k)&&v.push(A)}}a.U.push(v);BA(a);return v})},FA=function(a,b){a.j=b;if(a.h){b=a.h;var c=a.j===AA;b.j=c;b.m=c}a.j===AA&&a.o.stop()},zA=function(a,b){return _.w(function*(){var c=gA(b,"EXT-X-MEDIA"),d=gA(b,Yz),e=gA(b,"EXT-X-IMAGE-STREAM-INF");var f=new Map;for(var g of d){var h=_.rg(g,"AUDIO"),k=_.rg(g,"VIDEO"),l=_.rg(g,cA);const m=MA(a,g);if(l){const n=_.Fh(_.r,m);f.set(l,n);l=m.indexOf(n);-1<l&&m.splice(l,1)}h&&(l=NA(_.ac,
|
|
18
|
+
m),f.set(h,l));k&&(h=NA(_.u,m),f.set(k,h))}a.B=f;yield OA(a,c);f=hA(c,Mz);for(const m of f)f=PA(m),g=eA(m,_.Ca),k=eA(m,"INSTREAM-ID"),a.I.get(g)||a.I.set(g,new Map),a.I.get(g).set(k,f);d=yield QA(a,d);c=yield RA(a,c);e=yield SA(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},OA=function(a,b){return _.w(function*(){b=b.filter(d=>{const e=_.rg(d,_.mb)||"";return _.rg(d,"TYPE")!==cA&&""!==e});b.length&&(yield TA(a,b[0]));const c=b.slice(1).map(d=>TA(a,d));yield Promise.all(c)})},
|
|
19
|
+
QA=function(a,b){return _.w(function*(){var c=f=>_.w(function*(){const g=_.rg(f,"FRAME-RATE"),h=Number(eA(f,_.ka));var k=_.rg(f,_.Za);const [l,m]=k?k.split("x"):[null,null];return(k=yield UA(a,f,k,g))?VA(a,k.audio,k.video,h,l,m,g):[]});let d=0;var e=Infinity;for(let f=0;f<b.length;++f){const g=Number(eA(b[f],_.ka));g<e&&(e=g,d=f)}e=b.splice(d,1).pop();e=yield c(e);c=b.map(c);c=yield Promise.all(c);c.splice(d,0,e);return c.reduce(_.uu,[]).filter(_.dg)})},RA=function(a,b){return _.w(function*(){var c=
|
|
20
|
+
hA(b,cA),d=c.map(f=>_.w(function*(){try{return yield TA(a,f)}catch(g){throw g;}}));d=yield Promise.all(d);for(const f of c){var e=eA(f,_.Ca);if(c=a.B.get(e))if(e=a.m.get(e))for(const g of e)g.codecs=c}return d.filter(f=>f)})},SA=function(a,b){return _.w(function*(){const c=b.map(d=>_.w(function*(){return WA(a,d)}));return(yield Promise.all(c)).filter(d=>d)})},MA=function(a,b){var c=_.rg(b,_.ma,a.g.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=
|
|
21
|
+
_.Fu(e)[0],b.has(c)?a.f.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},NA=function(a,b){if(1===b.length)return b[0];a=_.Fh(a,b);if(null!=a)return a;throw new _.G(_.F,4,4025,{codecList:b});},TA=function(a,b){return _.w(function*(){const c=eA(b,_.Ca);var d="";let e=eA(b,"TYPE").toLowerCase();e===_.gu&&(e=_.r);e!==_.r&&c&&a.B.has(c)&&(d=a.B.get(c));const f=eA(b,_.mb);if(a.a.has(f))return a.a.get(f);const g=PA(b),h=_.rg(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),
|
|
22
|
+
m=_.rg(b,"CHANNELS");d=yield XA(a,f,d,e,g,!!k&&!!l,h,e==_.ac?m?parseInt(m.split("/")[0],10):null:null,null);a.m.has(c)?a.m.get(c).push(d):a.m.set(c,[d]);if(a.a.has(f))return a.a.get(f);a.a.set(f,d);return d})},WA=function(a,b){return _.w(function*(){const c=eA(b,_.mb);if(a.a.has(c))return a.a.get(c);var d=_.rg(b,_.ma)||"jpg",e=PA(b);const f=_.rg(b,"NAME");d=yield XA(a,c,d,_.ed,e,!1,f,null,null);if(a.a.has(c))return a.a.get(c);if(e=_.rg(b,_.ka))d.bandwidth=Number(e);a.a.set(c,d);return d})},UA=function(a,
|
|
23
|
+
b,c,d){return _.w(function*(){let e=MA(a,b);var f=_.rg(b,"AUDIO"),g=_.rg(b,"VIDEO"),h=f||g;h=h&&a.m.has(h)?a.m.get(h):[];f={audio:f?h:[],video:g?h:[]};a.f.debug("Guessing stream type for",b.toString());g=!1;const k=eA(b,_.mb);var l=f.audio.find(n=>n.Jc===k),m=_.Fh(_.u,e);m=c||d||m;1!==e.length||m?!h.length&&1<e.length?(a.f.debug("Guessing multiplexed audio+video"),h=_.u,e=[e.join(",")]):f.audio.length&&l?(a.f.debug(aA),h=_.ac,g=!0):f.video.length?(a.f.debug(aA),h=_.ac):(a.f.debug("Guessing video-only"),
|
|
24
|
+
h=_.u):(h=_.ac,a.f.debug(aA));l=null;g||(l=yield YA(a,b,e,h));if(l)f[l.type]=[l];else if(null===l)return a.f.debug("stream is null"),null;ZA(f);return f})},VA=function(a,b,c,d,e,f,g){c.forEach(l=>{l&&(l.width=Number(e)||void 0,l.height=Number(f)||void 0,l.frameRate=Number(g)||void 0)});b.length||(b=[null]);c.length||(c=[null]);const h=[];for(const l of b)for(const m of c){var k=l?l.drmInfos:null;const n=m?m.drmInfos:null;b=(m?m.Jc:"")+" - "+(l?l.Jc:"");let q;if(l&&m)if(k.length&&n.length?0<_.Hu(k,
|
|
25
|
+
n).length:1)q=_.Hu(k,n);else{a.f.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else l?q=k:m&&(q=n);a.W.has(b)?a.f.debug("Skipping variant which only differs in text streams."):(k=$A(a,l,m,d,q),h.push(k),a.W.add(b))}return h},YA=function(a,b,c,d){return _.w(function*(){const e=eA(b,_.mb);if(a.a.has(e))return a.a.get(e);var f=_.rg(b,Mz),g=null;d==_.u&&f&&"NONE"!==f&&(g=a.I.get(f));f=NA(d,c);g=yield XA(a,e,f,d,_.ye,!1,null,null,g);if(a.a.has(e))return a.a.get(e);a.a.set(e,g);return g})},
|
|
26
|
+
ZA=function(a){for(const b of a.audio.concat(a.video))a=b.codecs.split(","),a=a.filter(c=>"mp4a.40.34"!==c),b.codecs=a.join(",")},$A=function(a,b,c,d,e){return{id:a.Z++,language:b?b.language:_.ye,primary:!!b&&b.primary||!!c&&c.primary,audio:b,video:c,bandwidth:d,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0}},PA=function(a){a=_.rg(a,"LANGUAGE")||_.ye;return _.Nh(a)},XA=function(a,b,c,d,e,f,g,h,k){return _.w(function*(){let l=jA(a.w,b);var m=null;if(a.j===AA&&a.G.has(l)){var n=a.G.get(l);
|
|
27
|
+
a.G.delete(l)}else{const {response:rb,text:pa}=yield wA(a,l);l=rb.uri;n=xA(a,pa,l,b)}if(1!==n.type)throw new _.G(_.F,4,4017);aB(a,n);const q=yield bB(a,d,c,n),t=[];n.$.forEach(rb=>{rb=gA(rb.fa,"EXT-X-KEY");t.push.apply(t,rb)});let v=!1;const y=[];let A=null;for(var E of t){var D=eA(E,"METHOD"),ha=_.rg(E,"KEYFORMAT","identity");"NONE"!==D&&("AES-128"===D?(m=_.rg(E,"IV",""),m={method:"AES-128",url:jA(a.w,eA(E,_.mb)),iv:m?_.gj((m||"0x").slice(2)):null},a.L=!0):(v=!0,(D=(D=cB[ha])?D(E,q):null)?(D.keyIds.length&&
|
|
28
|
+
(A=D.keyIds[0]),y.push(D)):a.f.warn("Unsupported HLS KEYFORMAT",ha)))}if(v&&!y.length&&!a.L)throw new _.G(_.F,4,4026);E=new Map;ha=yield EA(a,b,n,d,q,c,m,E);D=ha[0].startTime;const gb=ha[ha.length-1].endTime,vf=gb-D,yb=new _.Cz(ha),wf=a.g.hlsLowLatency?_.zx:_.Yt,Ta=IA(n,m);let Hd=void 0;d==_.r&&(Hd=_.fu);n=(n=iA(n.fa,Xz))?"YES"===_.rg(n,"CAN-BLOCK-RELOAD"):!1;return{id:a.Z++,originalId:g,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:yb.f.bind(yb),getSegmentReference:yb.get.bind(yb),
|
|
29
|
+
adjustSegmentDurations:yb.g.bind(yb),getDuration:yb.getDuration.bind(yb),segmentIndex:yb,segmentLookupStrategy:wf,initSegmentReference:Ta,mimeType:q,codecs:c,kind:Hd,encrypted:v,keyId:A,language:e,label:g,type:d,primary:f,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:void 0,width:void 0,height:void 0,bandwidth:void 0,roles:[],channelsCount:h,closedCaptions:k,keyInfo:m,$:ha,drmInfos:y,Jc:b,Ue:l,Dd:D,qg:gb,duration:vf,ef:E,$e:n}})},aB=function(a,b){var c=iA(b.fa,Vz),d=iA(b.fa,Rz);d=c&&"VOD"===
|
|
30
|
+
c.value||d;c=c&&"EVENT"===c.value&&!d;c=!d&&!c;if(d)FA(a,AA);else{c?FA(a,CA):FA(a,dB);d=iA(b.fa,Zz);if(!d)throw new _.G(_.F,4,4024,{missingTag:Zz});d=Number(d.value);c=iA(b.fa,Uz);a.g.hlsLowLatency&&c?(d=Number(eA(c,"PART-TARGET")),a.F=Math.min(d,a.F),a.C=Math.max(d,a.C),b=iA(b.fa,Xz),a.S=b?Number(eA(b,"PART-HOLD-BACK")):0):(a.C=Math.max(d,a.C),a.F=Math.min(d,a.F),a.S=3*a.C)}},bB=function(a,b,c,d){return _.w(function*(){var e=d.$[0];const f=e.a;e=(e=iA(e.fa,Sz))?eA(e,_.mb):null;return eB(a,b,c,f,
|
|
31
|
+
e)})},IA=function(a,b){var c=gA(a.$[0].fa,Sz);if(!c.length)return null;if(1<a.$.map(f=>gA(f.fa,Sz)).reduce((f,g)=>f.concat(g),[]).length)throw new _.G(_.F,4,4020);c=c[0];var d=eA(c,_.mb);const e=jA(a.a,d);a=0;d=null;if(c=_.rg(c,"BYTERANGE"))a=c.split("@"),c=Number(a[0]),a=Number(a[1]),d=a+c-1;return new _.Az(()=>[e],a,d,b)},BA=function(a){a.h&&(a.U.forEach(b=>{_.Tu(a.h,b,0)}),a.U=[])},fB=function(a,b){var c=0;let d=null;b&&(c=b.split("@"),b=Number(c[0]),c=c[1]?Number(c[1]):a.Ja+1,d=c+b-1);return[c,
|
|
32
|
+
d]},hB=function(a,b,c,d,e,f,g){const h=[];for(const n of _.yu(b.f)){b=n.Wc;const q=n.item;{var k=0==b?a:h[h.length-1],l=0==b?d:k.endTime,m=Number(_.rg(q,"DURATION"));m=l+m;const t=_.rg(q,"BYTERANGE"),[v,y]=fB(k,t);k=_.rg(q,_.mb);const A=(k=jA(g,k))?[k]:[];l=new gB(c,l,m,()=>A,v,y,e,f,!1,null,null,null,null);if("YES"===_.rg(q,"INDEPENDENT")||0===b)l.g=!0;h.push(l)}}return h},LA=function(a,b,c,d,e,f,g,h,k){var l=c.fa,m=c.a;const n=m?[m]:[];m=iA(l,$z);(g=g?Object.assign({},g):null)&&!g.iv&&(g.iv=_.jj(new Uint8Array(12),
|
|
33
|
+
new Uint8Array([d>>24&255,d>>16&255,d>>8&255,d&255])));var q=null,t=null,v=null;h===_.ed&&(t=iA(l,"EXT-X-TILES"),q="1x1",t&&(q=_.rg(t,"LAYOUT")||"1x1",v=(v=_.rg(t,"DURATION"))?Number(v):null),[q,t]=q.split("x").map(y=>parseInt(y,10)));if(0===c.f.length&&!m)throw new _.G(_.F,4,4024,{missingTag:$z});h=null;if(0<c.f.length)if(a.g.hlsLowLatency)h=hB(b,c,d,e,f,g,k);else return null;c=a=0;k=null;m?(a=e+Number(m.value.split(",")[0]),l=iA(l,Oz),[c,k]=fB(b,l?l.value:null)):a=h[h.length-1].endTime;return new gB(d,
|
|
34
|
+
e,a,()=>n,c,k,f,g,!1,null,q,t,v,h)},JA=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){const m=LA(a,null,d,e,0,0,f,k,"");if(!m)return 0;if(a.N&&!l){{var n=m.position;const q=a.a.get(b);n=q?(n=q.segmentIndex.get(n))?n.startTime:null:null}if(null!=n)return a.f.debug("Found segment start time in previous manifest"),n;a.f.debug("Unable to find segment start time in previous manifest!")}return uA(a.ca,c,m,g,h,a.L)})},KA=function(a,b,c,d,e,f,g,h,k,l,m){return _.w(function*(){let n;a.H.has(b)?n=a.H.get(b):
|
|
35
|
+
(n=(yield JA(a,c,d,e,f,g,h,k,m,!0))-l,a.f.debug("Discontinuity segment offset",n),a.H.set(b,n));return n})},eB=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Ih(f,b,c);if(g)return g;g=_.bh([d],a.g.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.R(g)).headers["content-type"];if(!g)throw new _.G(_.F,4,4021,f.join(", "));return g.split(";")[0]})},yA=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.G(_.F,4,4043,"Media playlist must have at least one segment!");
|
|
36
|
+
if(null==d[0].a)throw new _.G(_.F,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.f="";this.type=b;this.fa=c;this.$=1===b?d:null}},mA=class{constructor(a,b,c){c=void 0===c?[]:c;this.fa=b;this.a=a;this.f=c}},kA=[Qz,Rz,"EXT-X-I-FRAMES-ONLY",Tz,Uz,Vz,Xz,Zz],HA=[$z,Oz,"EXT-X-DATERANGE",Pz,"EXT-X-KEY",Sz,"EXT-X-PROGRAM-DATE-TIME"],lA=["EXT-X-PART",Wz],iB=class{constructor(){this.a=0}},jB=class{constructor(a){this.f=new _.O("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.Zg()}}};var gB=class extends _.bv{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;super(a,b,c,d,e,f,g,h,k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:q,t);this.initSegment=void 0}};var kB=class{constructor(){this.g=this.D=null;this.Z=1;this.S=0;this.m=new Map;this.W=new Set;this.a=new Map;this.h=null;this.w="";this.aa=new iB;this.V=0;this.K=new Map;this.o=new _.Th(()=>{this.vb()});this.j=AA;this.N=null;this.C=0;this.F=Infinity;this.A=new _.So;this.U=[];this.I=new Map;this.L=!1;this.B=new Map;this.J=null;this.f=new _.O("clpp.hls.HlsParser");this.G=new Map;this.H=new Map;this.ca=new jB(this.R.bind(this))}configure(a){this.g=a;this.ca.a=a}setCurrentVariant(a){const b=a.video?a.video.id:
|
|
37
|
+
null;a=a.audio?a.audio.id:null;this.K.clear();for(const c of this.a.keys()){const d=this.a.get(c);d.id!==b&&d.id!==a||this.K.set(c,d)}}start(a,b){const c=this;return _.w(function*(){c.D=b;const {response:d,text:e}=yield wA(c,a);c.w=d.uri;const f=yield DA(c,e);c.N=f;const g=c.V;0<g&&c.o.ba(g);return f})}stop(){this.o&&(this.o.stop(),this.o=null);const a=[];this.A&&(a.push(this.A.destroy()),this.A=null);this.g=this.D=null;this.W.clear();this.a.clear();this.G.clear();this.N=null;this.m.clear();this.B.clear();
|
|
38
|
+
return Promise.all(a)}update(){const a=this;return _.w(function*(){if(a.j!==AA){var b=[];a.J=null;var c=Array.from(a.a.values()),d=Array.from(a.K.values());c=a.g.hlsLowLatency&&0<d.length?d:c;yield GA(a,c[0]);for(d=1;d<c.length;d++)b.push(GA(a,c[d]));yield Promise.all(b)}})}onExpirationUpdated(){}vb(){const a=this;return _.w(function*(){a.f.debug(_.Rt);if(a.D)try{yield a.update(),a.o.ba(a.V)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.o.ba(.1))}})}R(a){if(!this.A)throw new _.G(_.F,7,7001);a=this.D.networkingEngine.fetch(a);
|
|
39
|
+
_.ih(this.A,a);return a.P}},cB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Ie)throw new _.G(_.F,4,4041);return _.xu(_.Ic,[{initDataType:_.he,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":vA,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":vA,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=eA(a,"METHOD");const c=["SAMPLE-AES",bA];if(!c.includes(b))return _.Jf("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=eA(a,_.mb);b=_.go(b);
|
|
40
|
+
b=_.H(b.data);b=_.xu(_.Kc,[{initDataType:_.tc,initData:b}],"");if(a=_.rg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},AA="VOD",dB="EVENT",CA="LIVE";_.x("clpp.hls.HlsComponent",class extends _.Lp{constructor(){super()}f(){_.Kn.m3u8=kB;_.In[_.Pi]=kB;_.In[dA]=kB}a(){_.jv("m3u8");_.kv(_.Pi);_.kv(dA)}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.f.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 yI=function(a){a.a.one(a.l,_.nd,()=>xI(a))},xI=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Nb,d=>zI(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{zI(a,{track:d})});!AI(c)&&a.m&&(a.f.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),BI(a,b))}else a.f.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
|
|
2
|
+
else a.f.warn("A video element is not available. Skipping.")},zI=function(a,b){b=b.track;b.kind===_.td&&(a.f.info("The metadata track has been added."),b.mode=_.dd,a.a.on(b,_.Nc,c=>CI(a,c)))},AI=function(a){return a.some(b=>b.kind===_.td)},BI=function(a,b){const c=a.l.getTrackManager(),d=c.la(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.qa(d);a.a.on(b.textTracks,_.Nb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Nb,f),c.qa(d))});c.qa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
CI=function(a,b){const c=DI(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.g&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new EI(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Mg(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.l.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},DI=function(a){return(a=a.l.getTrackManager().ma())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
EI=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(_.pf(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=_.pf(a)?a:null}}};var FI=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.uo;this.h=(a=_.io[_.Yb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;yI(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var GI=class extends _.jq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.gi()){var b=a.getConfiguration();b=_.kf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.lc&&(b.patchMetadataTrack=!1);_.qf(b.timestampOffset)||(b.timestampOffset=0);this.a=new FI(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",GI);
|
|
5
|
+
GI.Id="hlssmpte";_.Sm(new class{create(){return new GI}});};f.call(g, window);
|
package/cl.htmlcue.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
function(a,b){
|
|
3
|
-
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
|
|
4
|
-
b.h)&&
|
|
5
|
-
case _.He:return _.He;default:throw Error("Unknown writing mode");}},
|
|
6
|
-
case _.
|
|
7
|
-
["+y","-y"];break;case _.Ge:a=["+x","-x"];break;case _.He:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},
|
|
8
|
-
f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e)
|
|
9
|
-
a)},
|
|
10
|
-
d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},
|
|
11
|
-
backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.
|
|
12
|
-
else{
|
|
13
|
-
c;for(;0<=d-1&&
|
|
14
|
-
a)}px`},
|
|
15
|
-
d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(
|
|
16
|
-
_.Oe?b=(new
|
|
17
|
-
!this.f.region.displayAlign){e=
|
|
18
|
-
100*a)}
|
|
19
|
-
d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.h,d.h))/(c.height*c.width);d>k&&(h=
|
|
20
|
-
_.Xd),height:
|
|
21
|
-
b=c;f*=b;break a;default:throw Error(
|
|
22
|
-
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.w(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],
|
|
23
|
-
new _.
|
|
24
|
-
this;return _.w(function*(){null!=a.h&&(
|
|
25
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qH="Unsupported unit",rH="clpp-text-plain",sH="clpp-text-ttml",tH="clpp.htmlcue.HtmlTextDisplayer",uH="initial",vH=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},wH=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},yH=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>xH[c]);return a},AH=
|
|
2
|
+
function(a,b){zH(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{zH(a,c)})},zH=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},BH=function(a,b){return 0===a?"0":a+b},CH=function(a,b){return 1>Math.abs(a-b)||a<b},DH=function(a,b){return a<b&&1<Math.abs(a-b)},EH=function(a,b){return a>b&&1<Math.abs(a-b)},FH=function(a,b){return 1>Math.abs(a-b)||a>b},HH=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||
|
|
3
|
+
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 GH(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},IH=function(a){return new GH(a.f,a.g,a.h,a.a,a.height,a.width)},JH=function(a,b){return b.some(c=>DH(a.f,c.g)&&EH(a.g,c.f)&&DH(a.h,c.a)&&EH(a.a,c.h))},KH=function(a,b){return FH(a.h,
|
|
4
|
+
b.h)&&CH(a.a,b.a)&&FH(a.f,b.f)&&CH(a.g,b.g)},LH=function(a,b,c){switch(c){case "+x":return DH(a.f,b.f);case "-x":return EH(a.g,b.g);case "+y":return DH(a.h,b.h);case "-y":return EH(a.a,b.a);default:throw Error("Unknown axis");}},MH=function(a){return a.f.writingMode===_.yo},NH=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 MH(a)?b:c},OH=function(a){switch(a.f.writingMode){case _.yo:return"horizontal-tb";case _.Ge:return _.Ge;
|
|
5
|
+
case _.He:return _.He;default:throw Error("Unknown writing mode");}},PH=function(a){switch(a.f.positionAlign){case _.ld:return _.id;case "auto":case _.uc:return _.xo;case _.md:return _.de}return a.f.textAlign},QH=function(a,b){if(typeof a.f.position===_.p&&typeof a.f.size===_.p)switch(b){case _.ld:return a.f.position;case "auto":case _.uc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},RH=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.id:case _.id:return _.ld;
|
|
6
|
+
case _.xo:return _.uc;case _.de:case _.de:return _.md}return a.f.positionAlign},UH=function(a,b,c){return(SH(a)||TH(a))&&_.qf(c)?BH(c,_.Xd):SH(a)&&_.z(c)?BH(0,_.Xd):MH(a)&&_.qf(b)?BH(b,"%"):uH},VH=function(a,b,c){return MH(a)&&_.qf(c)?BH(c,_.Xd):(SH(a)||TH(a))&&_.qf(b)?BH(b,"%"):uH},TH=function(a){return a.f.writingMode===_.He},SH=function(a){return a.f.writingMode===_.Ge},WH=function(a,b){if(a.h)switch(b.writingMode){case _.yo:return["-y"];case _.Ge:return["+x"];case _.He:return["-x"]}a=[];switch(b.writingMode){case _.yo:a=
|
|
7
|
+
["+y","-y"];break;case _.Ge:a=["+x","-x"];break;case _.He:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},XH=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=HH(a.j.a)},YH=function(a,b){XH(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},ZH=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Fo)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(qH);},aI=function(a,b,c,d){const e=document.createElement(_.pe),
|
|
8
|
+
f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);$H(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},bI=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${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,
|
|
9
|
+
a)},cI=function(a,b){let c=!1;try{a.g.insertRule(b,0);const d=a.g.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},dI=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},$H=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.f.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});
|
|
10
|
+
d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},eI=function(a){a=_.kf(a.getConfiguration().htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},kI=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Sl)if(a.I=c,c=fI(a,c),b||(b=a.m,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.m=c,gI(a),c)){b={color:a.getFontColor()||void 0,
|
|
11
|
+
backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.oo(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 _.Oe:g="clpp-text-vtt";break;case _.xe:g=sH;break;case _.wo:g=rH}g&&!f.classList.contains(g)&&_.mm(f,g);f=HH(c.a.a);if(0===f.width||0===f.height)c.L.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.");
|
|
12
|
+
else{zH({fontSize:hI(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Oe;var h=d.payloadType===_.xe;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new iI(d.region,{}),c.A.set(d.region.id,f),YH(c.a,f)));d=new jI(d,c.K,e);f?YH(f,d):YH(c.a,d)}}}}},lI=function(a){gI(a);a.I=null;a.m=null;a.f=[]},mI=function(a,b){return a.startTime<=b&&a.endTime>b},fI=function(a,b){var c=vH(a.f,d=>mI(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=
|
|
13
|
+
c;for(;0<=d-1&&mI(a.f[d-1],b);)d--;for(;c+1<a.f.length&&mI(a.f[c+1],b);)c++;return{start:d,end:c}}},gI=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(sH);b.classList.remove(rH);a=a.a;XH(a.g);a.j=[]}},hI=function(a,b){const c=HH(a.a.a).height;if(null!==a.H)return a.getFontSize();if(null!==a.B)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.p&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*
|
|
14
|
+
a)}px`},qI=class{parse(a){a={input:a};const b=_.om(_.Qc),c=[];let d=b;for(var e;null!==(e=wH(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=e[1];var g=e[3];var h=nI[f];h?(h=_.om(h),(f=oI[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||pI[g.localName]&&pI[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),
|
|
15
|
+
d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(yH(e)));return b}},nI={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},oI={v:"voice",lang:"lang"},pI={rt:"ruby"},xH={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var GH=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.h=c;this.a=d;this.height=e;this.width=f}};var rI=class{constructor(a,b,c){this.id=a;this.o=b;this.A=c;this.a=this.m();this.h=!1}init(){this.h=!0}w(){return!1}};var jI=class extends rI{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.j=b;this.f=a;this.g=!!this.f.backgroundImage;this.B=c}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.mm(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.xe){var c=_.om(_.Qc);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
16
|
+
_.Oe?b=(new qI).parse(b.payload):(c=_.om(_.Qc),c.textContent=b.payload,b=c);_.mm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.mm(b,d);zH({writingMode:OH(this)},b);var d=b;this.a.appendChild(d);_.mm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.mm(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.zo,this.f.line=MH(this)?-1:0);e=OH(this);zH({writingMode:e,webkitWritingMode:e,direction:uH,textAlign:PH(this)},this.a);if(!this.f.region||
|
|
17
|
+
!this.f.region.displayAlign){e=QH(this,RH(this));zH({position:"absolute",left:UH(this,e,null),right:TH(this)&&_.z(null)?BH(0,_.Xd):uH,top:VH(this,e,null),width:MH(this)?BH(this.f.size,"%"):uH,height:SH(this)||TH(this)?BH(this.f.size,"%"):uH},this.a);b=this.f;a=MH(this)?a.height:a.width;c=NH(this);if(b.lineInterpretation===_.zo){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 _.uc:g-=f/2;break;case _.Yc:g-=f}f=Math.round(g/
|
|
18
|
+
100*a)}TH(this)&&(f=a-f-c);a=f;zH({left:UH(this,e,a),right:TH(this)&&_.z(a)?BH(0,_.Xd):uH,top:VH(this,e,a)},this.a)}AH(this.B,d)}}m(){return _.om(_.Qc)}};var sI=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=HH(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.dd;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=HH(a.a);var d=WH(this,a.f),e=NH(a);const g=IH(c);let h=null,k=0;for(const l of d){for(;LH(c,this.a,l)||KH(c,this.a)&&JH(c,this.g);){d=c;var f=e;switch(l){case "+x":d.f+=f;d.g+=f;break;case "-x":d.f-=f;d.g-=f;break;case "+y":d.h+=f;d.a+=f;break;case "-y":d.h-=f,d.a-=f}}if(this.h||KH(c,this.a))break a;
|
|
19
|
+
d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.h,d.h))/(c.height*c.width);d>k&&(h=IH(c),k=d);c=IH(g)}c=h||g}zH({top:BH(c.h-this.a.h,_.Xd),bottom:BH(this.a.a-c.a,_.Xd),left:BH(c.f-this.a.f,_.Xd),right:BH(this.a.g-c.g,_.Xd),height:BH(c.height,_.Xd),width:BH(c.width,_.Xd)},a.a)}b.style.visibility="visible";this.g.push(HH(a.a))}};var tI=class extends rI{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new sI(this);this.h=!0}m(){const a=_.om(_.Qc);_.mm(a,this.o);this.id&&(a.id=this.id);return a}};var iI=class extends tI{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 _.Fo:b=b.width/100*a.width;break a;default:throw Error(qH);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Fo)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(qH);d=a.height;const e=ZH(this,d,a.height);zH(this.A,this.a);zH({left:BH(c,_.Xd),top:BH(e,_.Xd),width:BH(b,
|
|
20
|
+
_.Xd),height:BH(d,_.Xd)},this.a);this.f.writingMode&&zH({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&zH({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.mm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Fo:f=f.height/100*a.height;break a;case 2:f=f.height;c=new jI(new _.Co(0,1,"Lorem ipsum",_.wo),{},{});b=c.a;this.a.appendChild(b);c.init(HH(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
21
|
+
b=c;f*=b;break a;default:throw Error(qH);}a=ZH(this,f,a.height);zH({top:BH(a,_.Xd),height:BH(f,_.Xd)},this.a);this.g=new sI(this,!0);this.h=!0}getId(){return this.f.id}};var uI=class{constructor(a,b){this.f=new _.O("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=aI(this,this.h,this.j);this.g=aI(this,this.h,this.j,!0);this.g.disabled=!0;this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.m.some(b=>b===a)){const b=bI(this,a);if(cI(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.f.debug(`Added CSS rule ${b}`)}catch(c){this.f.error(`An error occurred when adding a CSS rule: ${b}`)}this.m.push(a)}else this.f.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
|
|
22
|
+
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.w(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],dI(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var vI=class extends _.gq{constructor(a){super(a);this.L=new _.O(tH);this.l=a;this.K=eI(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new uI(a,"CLPP Subtitle Styles");this.a=new tI(null,"clpp-text-container",{});this.w=new _.bq(a.getSurface(),this.U.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.L.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
|
|
23
|
+
new _.Th(()=>{kI(this)});this.A=new Map;this.m=null}append(a,b){if(null!=this.h&&0!==a.length){for(const c of b)this.h.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);b=this.f.findIndex(c=>c.startTime>=a[0].startTime);0===b?this.f=[]:0<b&&this.f.splice(0,b);for(const c of a)this.f.some(d=>d.payload!==c.payload?!1:d.startTime!==c.startTime?!1:d.endTime!==c.endTime?!1:!0)||this.f.push(c);this.m=null;kI(this,!1)}}g(){null==this.h||kI(this,!0)}destroy(){const a=
|
|
24
|
+
this;return _.w(function*(){null!=a.h&&(lI(a),a.F.stop(),yield a.h.destroy(),a.h=null,a.C.removeChild(a.a.a),a.a=null,a.w.stop(),a.w=null,a.j=!1)})}remove(a,b){if(null==this.h)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.m=null;kI(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Ua(.25),this.K.enableResizeObserver&&this.w.start(),kI(this,!0)):(this.F.stop(),this.w.stop(),lI(this)))}U(){kI(this,!0)}};_.x(tH,vI);
|
|
25
|
+
vI.prototype.setTextVisibility=vI.prototype.setTextVisibility;vI.prototype.isTextVisible=vI.prototype.isTextVisible;vI.prototype.remove=vI.prototype.remove;vI.prototype.destroy=vI.prototype.destroy;vI.prototype.append=vI.prototype.append;var wI=class{da(a){return!!a.enableHtmlCue&&!_.ii()}create(a){return new vI(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Lp{f(){_.wl("html",new wI)}a(){}id(){return _.qe}});};f.call(g, window);
|
package/cl.ima.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
_.
|
|
3
|
-
a.
|
|
4
|
-
a.m&&a.l.getSurface().hide(a.m)},
|
|
5
|
-
b,c){this.a=a;this.f=a.getAdPodInfo();this.h=b;this.g=c}
|
|
6
|
-
this.f.getIsBumper():!1}
|
|
7
|
-
1}
|
|
8
|
-
V.prototype.getPodTimeOffset=V.prototype.
|
|
9
|
-
V.prototype.getTitle=V.prototype.getTitle;V.prototype.getAdvertiserName=V.prototype.getAdvertiserName;V.prototype.getAdSystem=V.prototype.getAdSystem;V.prototype.getApiFramework=V.prototype.getApiFramework;V.prototype.getCreativeId=V.prototype.getCreativeId;V.prototype.getId=V.prototype.getId;V.prototype.getTechnology=V.prototype.
|
|
10
|
-
this.
|
|
11
|
-
this.l.trigger(new _.C(_.
|
|
12
|
-
_.
|
|
13
|
-
_.ne)throw new _.
|
|
14
|
-
this.a.skip()}getVolume(){return this.a?this.a.getVolume():1}setVolume(a){this.a&&this.a.setVolume(a)}getPosition(){if(!this.a||null===this.A)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.A-a}dispose(){return(new Promise(a=>{this.F&&this.g&&this.g.
|
|
15
|
-
a();this.a.discardAdBreak();this.o.contentComplete()})).then(()=>{
|
|
16
|
-
(this.a.destroy(),this.a=null);this.g&&(this.g.destroy(),this.g=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var aH="clpp.ima.AdsManagerFactory",bH=function(a){a=a.J;const b=new google.ima.AdsRenderingSettings;b.restoreCustomPlaybackStateOnAdBreakComplete=!1;typeof a.bitrate===_.p&&(b.bitrate=a.bitrate);b.enablePreloading=typeof a.enablePreloading===_.lc?a.enablePreloading:!0;typeof a.loadVideoTimeout===_.p&&(b.loadVideoTimeout=a.loadVideoTimeout);Array.isArray(a.mimeTypes)&&(b.mimeTypes=a.mimeTypes);typeof a.playAdsAfterTime===_.p&&(b.playAdsAfterTime=a.playAdsAfterTime);typeof a.useStyledLinearAds===
|
|
2
|
+
_.lc&&(b.useStyledLinearAds=a.useStyledLinearAds);b.uiElements=Array.isArray(a.uiElements)?a.uiElements:[];return b},cH=function(a){const b=a.a,c=a.w,d=google.ima.AdEvent.Type;c.on(b,d.LOADED,a.U.bind(a));c.on(b,d.CONTENT_PAUSE_REQUESTED,a.hc.bind(a));c.on(b,d.STARTED,a.W.bind(a));c.on(b,d.LOG,a.Ha.bind(a));c.on(b,d.AD_PROGRESS,a.Xa.bind(a));c.on(b,d.AD_BUFFERING,a.ca.bind(a));c.on(b,d.FIRST_QUARTILE,a.R.bind(a));c.on(b,d.MIDPOINT,a.Va.bind(a));c.on(b,d.THIRD_QUARTILE,a.Z.bind(a));c.on(b,d.PAUSED,
|
|
3
|
+
a.Wa.bind(a));c.on(b,d.RESUMED,a.Ya.bind(a));c.on(b,d.CLICK,a.N.bind(a));c.on(b,d.SKIPPED,a.V.bind(a));c.on(b,d.IMPRESSION,a.S.bind(a));c.on(b,d.COMPLETE,a.ka.bind(a));c.on(b,d.CONTENT_RESUME_REQUESTED,a.lc.bind(a));c.on(b,d.ALL_ADS_COMPLETED,a.Ob.bind(a))},dH=function(a,b){const c=b?a.aa.create(b.getErrorCode()):null;a.l.onError(new _.G(1,9,10003,{errorType:c},b))},eH=function(a,b,c){c=c&&c.getAd();let d=null;c&&(d={ad:new V(c,a.B,a.K)});a.l.trigger(new _.C(b,d))},fH=function(a){a.A=null;eH(a,_.Lb);
|
|
4
|
+
a.m&&a.l.getSurface().hide(a.m)},gH=function(a){_.nm(a.j,{visibility:"visible"})},iH=function(a){return _.w(function*(){a.I.initialize();const b=!!a.l.getConfiguration().muted;(yield a.G.canPlay(b))?hH(a):(eH(a,_.gc),a.L.warn(_.ja))})},jH=function(a,b){return _.w(function*(){a.I.initialize();yield b.play();hH(a)})},hH=function(a){a.a.init(a.j.offsetWidth,a.j.offsetHeight,google.ima.ViewMode.NORMAL);a.a.start();a.F=!0},kH=function(){return!window.google||!google.ima||!google.ima.AdsLoader},V=class{constructor(a,
|
|
5
|
+
b,c){this.a=a;this.f=a.getAdPodInfo();this.h=b;this.g=c}mb(){return"Google IMA SDK"}nb(){return google.ima.VERSION}sb(){return 0}getId(){return this.a.getAdId()}getCreativeId(){return this.a.getCreativeId()}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()}getSkipTimeOffset(){return this.a.getSkipTimeOffset()}Xb(){return this.f?
|
|
6
|
+
this.f.getIsBumper():!1}Db(){let a=null;const b=this.a,c=Object.keys(b).find(d=>typeof b[d]===_.Bd&&typeof b[d].clickThroughUrl===_.ne);c&&(a=b[c].clickThroughUrl);return a}getMediaUrl(){return this.a.getMediaUrl()}pb(){return this.a.getVastMediaWidth()}ob(){return this.a.getVastMediaHeight()}cb(){return this.a.getVastMediaBitrate()}Oa(){return this.g?2:this.h?1:0}getPodIndex(){return this.f?this.f.getPodIndex():0}Eb(){return this.f?this.f.getTimeOffset():0}Fb(){return this.f?this.f.getAdPosition():
|
|
7
|
+
1}rb(){return this.f?this.f.getTotalAds():1}getWrapperAdIds(){return this.a.getWrapperAdIds()}getWrapperAdSystems(){return this.a.getWrapperAdSystems()}getWrapperCreativeIds(){return this.a.getWrapperCreativeIds()}};V.prototype.getWrapperCreativeIds=V.prototype.getWrapperCreativeIds;V.prototype.getWrapperAdSystems=V.prototype.getWrapperAdSystems;V.prototype.getWrapperAdIds=V.prototype.getWrapperAdIds;V.prototype.getSequenceLength=V.prototype.rb;V.prototype.getPositionInSequence=V.prototype.Fb;
|
|
8
|
+
V.prototype.getPodTimeOffset=V.prototype.Eb;V.prototype.getPodIndex=V.prototype.getPodIndex;V.prototype.getPodType=V.prototype.Oa;V.prototype.getMediaBitrate=V.prototype.cb;V.prototype.getMediaHeight=V.prototype.ob;V.prototype.getMediaWidth=V.prototype.pb;V.prototype.getMediaUrl=V.prototype.getMediaUrl;V.prototype.getClickThroughUrl=V.prototype.Db;V.prototype.isBumper=V.prototype.Xb;V.prototype.getSkipTimeOffset=V.prototype.getSkipTimeOffset;V.prototype.getDuration=V.prototype.getDuration;
|
|
9
|
+
V.prototype.getTitle=V.prototype.getTitle;V.prototype.getAdvertiserName=V.prototype.getAdvertiserName;V.prototype.getAdSystem=V.prototype.getAdSystem;V.prototype.getApiFramework=V.prototype.getApiFramework;V.prototype.getCreativeId=V.prototype.getCreativeId;V.prototype.getId=V.prototype.getId;V.prototype.getTechnology=V.prototype.sb;V.prototype.getAdManagerVersion=V.prototype.nb;V.prototype.getAdManagerName=V.prototype.mb;var lH=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 mH=class{constructor(a){this.a=a}getCuePoints(){return this.a}Gb(){return 0<=this.a.indexOf(0)||0===this.a.length}eb(){return 0<=this.a.indexOf(-1)}};mH.prototype.hasPostroll=mH.prototype.eb;mH.prototype.hasPreroll=mH.prototype.Gb;mH.prototype.getCuePoints=mH.prototype.getCuePoints;var nH=class{constructor(a){this.l=a;this.j=a.getSurface().getMedia();a=this.l.getConfiguration();this.J=a=_.kf(a.ima||{});this.m=this.l.Tb("ima").mc();this.I=this.l.Tb("ima").g;this.o=this.l.Tb("ima").a;this.G=new _.dq;this.L=new _.O("clpp.ima");this.h=this.a=null;this.f=new _.Xk;this.F=!1;this.w=new _.uo;this.aa=new lH;this.A=null;this.H=this.C=this.K=this.B=!1;this.g=null;{a=this.w;const b=google.ima.AdErrorEvent.Type.AD_ERROR;a.one(this.o,google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
|
|
10
|
+
this.Nb.bind(this));a.on(this.o,b,this.Ab.bind(this));a.one(this.j,_.Zc,this.Pb.bind(this))}}Nb(a){this.a=a.getAdsManager(this.j,bH(this));this.a.isCustomPlaybackUsed()?(this.L.warn("IMA plugin does not work correctly right now on platforms with single video element. Disposing."),this.l.onError(new _.G(1,9,10002)),this.dispose()):(this.h=new _.bq(this.l.getSurface(),(b,c,d)=>{this.a.resize(b,c,d?google.ima.ViewMode.FULLSCREEN:google.ima.ViewMode.NORMAL)}),a=this.a.getCuePoints(),this.g=new mH(a),
|
|
11
|
+
this.l.trigger(new _.C(_.Ob,{adsTimeline:this.g})),cH(this));this.f.resolve()}Ab(a){dH(this,a.getError());this.f.resolve()}hc(a){const b=this;return _.w(function*(){b.C=!0;yield b.l.pause();_.nm(b.j,{visibility:_.dd});eH(b,_.wb,a);b.h.start()})}U(a){a.getAd().isLinear()?eH(this,_.Eb,a):(this.a.discardAdBreak(),this.B||(this.B=!0,this.l.play()))}W(a){this.A=a.getAd().getDuration();eH(this,_.Kb,a);this.l.getSurface().show(this.m)}Ha(a){a=a.getAdData();dH(this,a?a.adError:null);fH(this)}Xa(a){eH(this,
|
|
12
|
+
_.Hb,a)}ca(a){eH(this,_.zb,a)}R(a){eH(this,_.Cb,a)}Va(a){eH(this,_.Fb,a)}Z(a){eH(this,_.Mb,a)}Wa(a){eH(this,_.Gb,a)}Ya(a){eH(this,_.Ib,a)}N(a){this.pause();eH(this,_.Ab,a)}V(a){eH(this,_.Jb,a);fH(this)}S(a){eH(this,_.Db,a)}ka(a){eH(this,_.Bb,a);fH(this)}lc(){this.B=!0;if(!this.C)return this.l.play();this.C=!1;this.h.stop();this.l.isEnded()||this.l.play();eH(this,_.xb);gH(this)}Ob(){this.H=!0}Pb(){this.K=!0;this.o.contentComplete()}load(){const a=this;return _.w(function*(){var b=a.l;const c=a.J;try{if(typeof c.adTagUrl!==
|
|
13
|
+
_.ne)throw new _.G(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.G.canPlay(!1);const d=yield a.G.canPlay(!0),e=new google.ima.AdsRequest;e.adTagUrl=c.adTagUrl;e.setAdWillAutoPlay(b);e.setAdWillPlayMuted(d);a.o.requestAds(e);return a.f})}start(a){const b=this;return _.w(function*(){b.a&&b.g&&!b.F?b.g.Gb()?yield iH(b):yield jH(b,a):yield a.play()})}resume(){this.a&&this.a.resume()}pause(){this.a&&this.a.pause()}skip(){this.a&&
|
|
14
|
+
this.a.skip()}getVolume(){return this.a?this.a.getVolume():1}setVolume(a){this.a&&this.a.setVolume(a)}getPosition(){if(!this.a||null===this.A)return-1;const a=this.a.getRemainingTime();return 0>a?0:this.A-a}dispose(){return(new Promise(a=>{this.F&&this.g&&this.g.eb()&&!this.H?(this.w.one(this.a,google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{a();this.m&&this.l.getSurface().hide(this.m)}),_.Pf(this.w,this.a,[google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.STARTED],()=>{this.a&&this.a.discardAdBreak()})):
|
|
15
|
+
a();this.a.discardAdBreak();this.o.contentComplete()})).then(()=>{gH(this);this.w.release();this.h&&(this.h.stop(),this.h=null);this.a&&(this.a.destroy(),this.a=null)})}};nH.prototype.getPosition=nH.prototype.getPosition;nH.prototype.setVolume=nH.prototype.setVolume;nH.prototype.getVolume=nH.prototype.getVolume;nH.prototype.skip=nH.prototype.skip;nH.prototype.pause=nH.prototype.pause;nH.prototype.resume=nH.prototype.resume;var oH=class extends _.jq{constructor(){super();this.a=this.g=this.f=null}onPlayerCreated(a){if(kH())return a.onError(new _.G(1,9,1E4));this.f=_.lm(_.Qc,{"class":"clpp-ima clpp-hidden"});a.getSurface().addElementToContainer(this.f);this.g=new google.ima.AdDisplayContainer(this.f,a.getSurface().getMedia());this.a=new google.ima.AdsLoader(this.g);this.a.getSettings().setPlayerType(_.oa);this.a.getSettings().setPlayerVersion(_.da);this.a.getSettings().setAutoPlayAdBreaks(!0)}onPlayerWillDestroy(a){this.a&&
|
|
16
|
+
(this.a.destroy(),this.a=null);this.g&&(this.g.destroy(),this.g=null);this.f&&(a.getSurface().removeElementFromContainer(this.f),this.f=null)}qf(){return this.a}nf(){return this.g}mc(){return this.f}id(){return"ima"}};_.x("clpp.ima.ImaPlugin",oH);oH.prototype.getAdContainer=oH.prototype.mc;oH.prototype.getAdDisplayContainer=oH.prototype.nf;oH.prototype.getAdsLoader=oH.prototype.qf;oH.Id="ima";oH.isSdkMissing=kH;_.Sm(new class{create(){return new oH}});var pH=class{constructor(){this.a=new _.O(aH)}name(){return aH}da(a,b){return a.namespace()===_.Ac?!1:kH()?(this.a.warn("IMA SDK is not loaded."),!1):!(!b||!b.ima)}create(a){return new nH(a)}};pH.prototype.create=pH.prototype.create;pH.prototype.isSupported=pH.prototype.da;pH.prototype.name=pH.prototype.name;_.im(new pH);};f.call(g, window);
|