@castlabs/prestoplay 6.6.1 → 6.8.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 +36 -1
- 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 +418 -419
- package/cjs/cl.crypto.js +10 -10
- package/cjs/cl.dash.js +72 -72
- package/cjs/cl.externs.js +48 -42
- package/cjs/cl.freewheel.js +24 -24
- package/cjs/cl.hls.js +68 -49
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +31 -31
- package/cjs/cl.ima.js +24 -23
- package/cjs/cl.mse.js +275 -261
- package/cjs/cl.muxdata.js +15 -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 -71
- 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 +362 -365
- package/cl.crypto.js +8 -8
- package/cl.dash.js +67 -67
- package/cl.externs.js +48 -42
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +58 -40
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +25 -25
- package/cl.ima.js +17 -16
- package/cl.mse.js +238 -228
- package/cl.muxdata.js +12 -8
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +10 -10
- package/cl.playlist.js +5 -5
- package/cl.smooth.js +58 -59
- package/cl.thumbnails.js +17 -17
- package/cl.tizen.js +57 -57
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +15 -15
- package/cl.vtt.js +12 -12
- package/cl.youbora.js +15 -15
- package/package.json +1 -1
- package/typings.d.ts +147 -19
package/cl.freewheel.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
if(b.length)throw new _.
|
|
3
|
-
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.g.on(a.l,_.
|
|
4
|
-
a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},
|
|
5
|
-
!0),a.getSurface().hide(this.a);else a.onError(new _.
|
|
6
|
-
0}getSkipTimeOffset(){return 0}
|
|
7
|
-
case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_.
|
|
13
|
-
if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);
|
|
14
|
-
a.h&&(a.h.stop(),a.h=null);
|
|
15
|
-
9,10003,{errorType:0},void 0));this.j.resolve()}J(a){
|
|
16
|
-
_.
|
|
17
|
-
_.
|
|
18
|
-
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.m.findIndex(c=>c===this.f);this.m.splice(b,1);this.l.pause();
|
|
19
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var eK="clpp-freewheel",fK="clpp.freewheel.AdsManagerFactory",gK="freewheel",hK=function(a){switch(a){case 0:return tv.freewheel.SDK.ADUNIT_PREROLL;case 1:return tv.freewheel.SDK.ADUNIT_MIDROLL;case 2:return tv.freewheel.SDK.ADUNIT_POSTROLL;default:return""}},iK=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.me&&b.push("serverUrl");typeof a.profileId!==_.me&&b.push("profileId");typeof a.videoAssetId!==_.me&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
|
|
2
|
+
if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},jK=function(){return _.y(function*(){var a=new _.Vp;let b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_NONE;const c=yield a.canPlay(!1);a=yield a.canPlay(!0);c?b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED:a&&(b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED);return b})},kK=function(a){a.g.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.H.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.J.bind(a));a.g.on(a.a,
|
|
3
|
+
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.g.on(a.l,_.ue,a.F.bind(a));a.g.on(a.l,_.je,a.C.bind(a))},nK=function(a){return _.y(function*(){a.A.length?(lK(a),a.f=a.A.shift(),a.f.play()):(mK(a),yield a.l.a.play())})},mK=function(a){const b=a.l.Ub(gK).qc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},lK=function(a){const b=a.l.Ub(gK).qc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(eK),
|
|
4
|
+
a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},oK=function(a){a.w.length?(lK(a),a.f=a.w.shift(),a.f.play()):mK(a)},pK=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.l.trigger(new _.F(b,d))},qK=class extends _.aq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.am(_.Qc,{id:eK}),this.f=_.am(_.w,{"class":_.xc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
|
|
5
|
+
!0),a.getSurface().hide(this.a);else a.onError(new _.H(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return gK}qc(){return this.a}Bf(){return this.f}};_.A("clpp.freewheel.FreeWheelPlugin",qK);qK.prototype.getAdVideo=qK.prototype.Bf;qK.prototype.getAdContainer=qK.prototype.qc;qK.Id=gK;qK.AD_CONTAINER_ID=eK;_.Hm(new class{create(){return new qK}});var X=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}nb(){return"FreeWheel AdManager SDK"}ob(){return tv.freewheel.SDK.version}tb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.me?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
|
|
6
|
+
0}getSkipTimeOffset(){return 0}Yb(){return!1}Fb(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}qb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}pb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}eb(){return 0}Qa(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
|
|
7
|
+
case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Qa()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Gb(){switch(this.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Hb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}sb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
|
|
8
|
+
X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.sb;X.prototype.getPositionInSequence=X.prototype.Hb;X.prototype.getPodTimeOffset=X.prototype.Gb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Qa;X.prototype.getMediaBitrate=X.prototype.eb;X.prototype.getMediaHeight=X.prototype.pb;
|
|
9
|
+
X.prototype.getMediaWidth=X.prototype.qb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Fb;X.prototype.isBumper=X.prototype.Yb;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;
|
|
10
|
+
X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.tb;X.prototype.getAdManagerVersion=X.prototype.ob;X.prototype.getAdManagerName=X.prototype.nb;var rK=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Ib(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}fb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
|
|
11
|
+
rK.prototype.hasPostroll=rK.prototype.fb;rK.prototype.hasPreroll=rK.prototype.Ib;rK.prototype.getCuePoints=rK.prototype.getCuePoints;var sK=class{constructor(a){this.B=new _.P("clpp.freewheel.AdsManager");this.l=a;this.g=new _.jo;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Mk;this.h=null}load(){const a=this;return _.y(function*(){const b=a.l.getConfiguration().freewheel||{};try{iK(b)}catch(d){return a.l.onError(d),a.j.resolve(),a.j}a.o.setNetwork(b.networkId);a.o.setServer(b.serverUrl);a.a=a.o.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.me&&typeof b.siteSectionId!==
|
|
12
|
+
_.r||a.a.setSiteSection(b.siteSectionId);const c=yield jK();a.a.setVideoAsset(b.videoAssetId,a.l.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,hK(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Bd&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);
|
|
13
|
+
if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);kK(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.y(function*(){yield nK(a)})}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}dispose(){const a=this;return _.y(function*(){a.g.release();
|
|
14
|
+
a.h&&(a.h.stop(),a.h=null);mK(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.m=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.w=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.l.trigger(new _.F(_.Nb,{adsTimeline:new rK(this.a)})),this.h=new _.Tp(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Ub(gK).f);else this.l.onError(new _.H(1,
|
|
15
|
+
9,10003,{errorType:0},void 0));this.j.resolve()}J(a){pK(this,_.wb,a);this.h.start()}I(a){this.f=null;a=a.slot;pK(this,_.xb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:nK(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:mK(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:oK(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:pK(this,_.Jb,a);pK(this,
|
|
16
|
+
_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:pK(this,_.Kb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:pK(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:pK(this,_.Eb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:pK(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:pK(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:pK(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:pK(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:pK(this,
|
|
17
|
+
_.Hb,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:pK(this,_.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:pK(this,_.yb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:pK(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.l.onError(new _.H(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}F(){if(!this.f){var a=this.l.getPosition();if(this.f=this.m.find(b=>
|
|
18
|
+
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.m.findIndex(c=>c===this.f);this.m.splice(b,1);this.l.pause();lK(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Hl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Gl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.wl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);oK(this);break;case _.El:case _.Dl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
|
|
19
|
+
sK.prototype.getPosition=sK.prototype.getPosition;sK.prototype.setVolume=sK.prototype.setVolume;sK.prototype.getVolume=sK.prototype.getVolume;sK.prototype.skip=sK.prototype.skip;sK.prototype.pause=sK.prototype.pause;sK.prototype.resume=sK.prototype.resume;sK.prototype.start=sK.prototype.start;var tK=class{constructor(){this.a=new _.P(fK)}name(){return fK}da(a,b){return a.namespace()===_.zc?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new sK(a)}};tK.prototype.create=tK.prototype.create;tK.prototype.isSupported=tK.prototype.da;tK.prototype.name=tK.prototype.name;_.Yl(new tK);};f.call(g, window);
|
package/cl.hls.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
a
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
b,c,d
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
a.
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
e
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
_.
|
|
40
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var eA="CLOSED-CAPTIONS",fA="Could not parse MP4 segment start time.",gA="EXT-X-BYTERANGE",hA="EXT-X-DISCONTINUITY",iA="EXT-X-DISCONTINUITY-SEQUENCE",jA="EXT-X-ENDLIST",kA="EXT-X-KEY",lA="EXT-X-MAP",mA="EXT-X-MEDIA-SEQUENCE",nA="EXT-X-PART-INF",oA="EXT-X-PLAYLIST-TYPE",pA="EXT-X-PRELOAD-HINT",qA="EXT-X-SERVER-CONTROL",rA="EXT-X-STREAM-INF",sA="EXT-X-TARGETDURATION",tA="Failed to infer discontinuity number",uA="Guessing audio-only",vA="METHOD",wA="SAMPLE-AES-CTR",xA="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",
|
|
2
|
+
yA="application/vnd.apple.mpegurl",zA="sample",AA="whole-segment",BA=function(a,b){return _.pg(a,b,void 0,{required:!0})},CA=function(a){if(1>a.a)throw _.vj();--a.a},DA=function(a){if(null!==a&&void 0!==a)return Number(a)},EA=function(a,b){return a.filter(c=>c.name===b)},FA=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=BA(d,"TYPE");return c.includes(d)})},GA=function(a,b){return a.some(c=>c.name===b)},HA=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.G,
|
|
3
|
+
4,4024,{missingTag:b});return a},IA=function(a){var b=HA(a,"EXT-X-TILES");if(!b)return{we:1,Xe:1,durationPerTile:null};a=_.pg(b,"LAYOUT")||"1x1";b=(b=_.pg(b,"DURATION"))?Number(b):null;const [c,d]=a.split("x").map(e=>parseInt(e,10));return{we:c,Xe:d,durationPerTile:b}},JA=function(a,b){return _.uu([a],[b])[0]},KA=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)},
|
|
4
|
+
LA=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of KA(c))b(d,c)})},MA=function(a){return a.type===_.p||a.type===_.w},NA=function(a){const b=HA(a,oA);if(HA(a,jA))return _.Rt;if(!b)return"LIVE";if(b.value===_.Rt)return _.Rt;if("EVENT"===b.value)return"EVENT";throw new _.H(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${b.value}`);},OA=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.H(_.G,4,4044,"Byte range length must be positive.");
|
|
5
|
+
if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.G,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ta:d,ha:e}},PA=function(a,b){a=HA(a,gA);return OA(a?a.value:null,b)},QA=function(a){a=HA(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||
|
|
6
|
+
null}},RA=function(a,b){b=void 0===b?{}:b;const c={Rc:!1,lf:!1,mf:null,Kf:null,Ke:null};a=HA(a,qA,{required:b.Oe});if(!a)return c;const d=e=>null==e?null:Number(e);c.Rc="YES"===_.pg(a,"CAN-BLOCK-RELOAD");c.lf="YES"===_.pg(a,"CAN-SKIP-DATERANGES");c.mf=d(_.pg(a,"CAN-SKIP-UNTIL"));c.Kf=d(_.pg(a,"HOLD-BACK"));c.Ke=d(_.pg(a,"PART-HOLD-BACK",void 0,{required:b.Oe}));return c},SA=function(a,b,c){c=void 0===c?!1:c;a=_.pg(a,"BYTERANGE");return OA(a,b,c)},UA=function(a,b){const c=PA(a.$,null);return new TA(0,
|
|
7
|
+
0,0,()=>[a.a],c.ta,c.ha,0,b)},VA=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.$g(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},WA=function(a){let b=Infinity,c=Infinity;KA(a).filter(MA).forEach(d=>{{d=d.V;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{$b:b,duration:c}},XA=function(a){return a.map(b=>{({duration:b}=WA(b));return b}).reduce((b,c)=>b+c,0)},YA=function(a,b,c){if(b===
|
|
8
|
+
_.Rt)return{delay:0,Oc:0};b=HA(a,nA);if(c&&b)return c=Number(BA(b,"PART-TARGET")),{Ke:a}=RA(a,{Oe:!0}),{delay:a,Oc:c};a=HA(a,sA,{required:!0});a=Number(a.value);return{delay:3*a,Oc:a}},ZA=function(a){const b=[];LA(a,c=>{b.push(c.Sf)});return{delay:Math.max(...b.map(c=>c.delay)),Oc:Math.min(...b.map(c=>c.Oc))}},$A=function(a){const b=new Map;a.forEach(c=>{var d=c.ea[0].groupId;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},aB=function(a){a=_.pg(a,"LANGUAGE")||_.xe;return _.rg(a)},
|
|
9
|
+
cB=function(a){a=a.audio.concat(a.video);for(const b of a)a=b.ea[0].codecs.split(",").filter(c=>"mp4a.40.34"!==c),bB(b,a)},gB=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.eh(a.a++,h),dB.includes(h.name)?d.push(h):eB.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===pA&&"PART"===_.pg(h,"TYPE")&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=JA(b,h.trim()),e.push(new fB(h,f,g)),f=[],g=[])});0<g.length&&e.push(new fB(null,f,g));return{V:e,$:d}},hB=function(a){return 0>
|
|
10
|
+
a?[]:Array.from({length:a},(b,c)=>c)},iB=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},jB=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 _.H(_.G,4,4030);}iB(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],
|
|
11
|
+
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}}iB(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},kB=function(a,b){let c=null,d=0;try{(new _.Lj).M(_.wd,_.Ej).M(_.ve,_.Ej).M(_.rd,_.Ej).Z("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,
|
|
12
|
+
!0)}catch(g){c=g}if(c||!d)throw _.Wp.error("Unable to find timescale in init segment!"),new _.H(_.G,4,4030,fA,c);let e=0,f=!1;try{(new _.Lj).M("moof",_.Ej).M("traf",_.Ej).Z("tfdt",g=>{e=(0==g.version?_.N(g.reader):_.Aj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.H(_.G,4,4030,fA,c);return e},lB=function(a){for(;a.getPosition()<a.za()-1;){const b=a.getPosition();if(71===_.wj(a))return CA(a),b}return-1},mB=function(a){function b(){d.seek(e+188);f=_.wj(d);71!=f&&
|
|
13
|
+
(d.seek(e+192),f=_.wj(d));71!=f&&(d.seek(e+204),f=_.wj(d));71!=f&&c();CA(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.qk(new DataView(a),!1);let e=0,f=0;e=lB(d);0>e&&(_.Wp.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.wj(d);71!=f&&c();a=_.xj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.wj(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.wj(d),d.skip(a));if(1!=_.N(d)>>8){b();continue}d.skip(3);a=_.wj(d)>>6;0!=a&&1!=a||c();0==_.wj(d)&&
|
|
14
|
+
c();a=_.wj(d);const g=_.xj(d),h=_.xj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},pB=function(a){var b=BA(a,vA);if(!nB.includes(b))return oB.error("PlayReady in HLS is only supported with [",nB.join(", "),"], not",b),null;a=BA(a,_.lb);b=_.Vn(a);a=null;b=_.I(b.data);try{a=_.nu(_.Xu(b))}catch(c){a=b}return _.vu(_.Ic,[{initDataType:_.sc,initData:a}],"")},rB=function(a){if(0===a.length)return qB();if(a.some(c=>c.type===AA)||a.every(c=>c.type===_.Ad))return a[0];a=a.filter(c=>c.type===
|
|
15
|
+
zA);const b=Array.from((new Set(a.flatMap(c=>c.drmInfos))).values());return{keyInfo:null,keyId:a[a.length-1].keyId,type:zA,drmInfos:b}},uB=function(a){a=sB(a);if(a.some(b=>tB(b))&&1<a.length)throw new _.H(_.G,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");},tB=function(a){return EA(a.$,kA).some(b=>"AES-128"===_.pg(b,vA))},wB=function(a,b,c){return sB(a).map(d=>vB(d.$,b,c))},xB=function(a){return a.filter(b=>GA(b.$,kA)).length},sB=function(a){return a.filter(b=>
|
|
16
|
+
GA(b.$,kA))},vB=function(a,b,c){a=EA(a,kA);if(0===a.length)return null;var d=BA(a[0],vA);if(1===a.length){if("NONE"===d)return qB();if("AES-128"===d)return a=a[0],d=_.pg(a,"IV",""),{type:AA,keyInfo:{method:"AES-128",url:JA(b,BA(a,_.lb)),iv:d?_.Vg((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>BA(e,vA));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===wA))throw yB.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");
|
|
17
|
+
b=a.map(e=>{const f=_.pg(e,"KEYFORMAT","identity");{const g=zB[f]||null;e=g?g(e,c):null}e||yB.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.G,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:zA,drmInfos:b}},qB=function(){return{type:_.Ad,keyInfo:null,drmInfos:[],keyId:null}},AB=function(a,b,c){return _.y(function*(){const d=b.f(),e=_.jv(b.Fa(),b.ta,b.ta+2048-1,a.a.attemptParameters);e.type=2;
|
|
18
|
+
const f=_.jv(b.Fa(),b.ta,b.ha,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;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 _.H(_.G,4,4030,"Failed to fetch the media segment.");
|
|
19
|
+
}}})},BB=function(a,b,c,d,e,f){return _.y(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.cc||d===_.bc)return 0;if(d===_.ac){var g=yield AB(a,c,f);const h=_.I(g.data);return iB(h)?jB(h):mB(g.data)}if(d===_.Je||d===_.dc)return g=[AB(a,c,f)],b&&g.push(AB(a,b,!0)),g=yield Promise.all(g),kB(g[0].data,(g[1]||g[0]).data);if(d===_.He)return g=yield AB(a,c,f),mB(g.data);if(!_.Eu(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.G,4,4030);})},CB=function(a,
|
|
20
|
+
b){a=a.map(c=>c.ea[b]);return a.some(c=>null==c)?null:a},bB=function(a,b){a.ea.forEach(c=>{c.codecs=b.join(",")})},DB=function(a,b){a=a.ea.find(c=>{c=c.V;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.V.find(c=>c.position===b)||null},EB=function(a,b){a.ea.forEach(c=>{c.width=b})},FB=function(a,b){a.ea.forEach(c=>{c.height=b})},GB=function(a,b){a.ea.forEach(c=>{c.frameRate=b})},HB=function(a,b){a.ea.forEach(c=>{c.bandwidth=b})},IB=function(a,b){return a.ea.some(c=>c.id===
|
|
21
|
+
b)},JB=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},MB=function(a,b,c,d){var e=a[0].length();e=hB(e).map(f=>{const g=JB(a,f)||[],h=CB(b,f)||[],k=CB(c,f)||[];return KB({variants:g,textStreams:h,thumbStreams:k,Qf:d&&0===f})});LB(e);return e},OB=function(a){if(1===a.length)return a[0];const b=a[0],c=a.reduce((e,f)=>e+f.duration,0),d=new Map;a.forEach((e,f)=>{const g=KA(e);0<f&&NB(g,e.startTime);g.forEach(h=>{const k=h.ec;d.has(k)?d.get(k).push(h):d.set(k,[h])})});LA(b,e=>{var f=
|
|
22
|
+
d.get(e.ec);const g=f.flatMap(h=>h.V);f=f.map(h=>({keyInfo:h.keyInfo,type:h.re,drmInfos:h.drmInfos,keyId:h.keyId}));f=rB(f);e.keyInfo=f.keyInfo;e.re=f.type;e.encrypted=f.type===zA;e.drmInfos=f.drmInfos;e.keyId=f.keyId;e.V=g;e.segmentIndex.replace(g)});return Object.assign({},b,{duration:c,endTime:a[0].startTime+c})},KB=function(a){const b=a.variants,c=a.textStreams,d=a.thumbStreams;var e=a.Qf;a=[...b.flatMap(l=>[l.video,l.audio]),...c,...d].filter(Boolean);const f=a[0].$b;e=e?f:0;PB(a,e);const {Db:g,
|
|
23
|
+
cd:h,duration:k}=a[0];return{variants:b,textStreams:c,thumbStreams:d,startTime:0,id:`P${g}`,endTime:h,duration:k+e,Db:g}},LB=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:0;c.endTime=c.startTime+c.duration}},PB=function(a,b){NB(a,0);QB(a);0<b&&NB(a,b)},NB=function(a,b){a.forEach(c=>{const d=-c.$b+b;c.segmentIndex.offset(d);c.cd+=d;c.$b=b})},QB=function(a){const b=RB(a);a.forEach(c=>{_.fv(c.segmentIndex,b);c.duration=b;c.cd=c.$b+b})},RB=function(a){let b=Infinity;
|
|
24
|
+
a.filter(MA).forEach(c=>{b=Math.min(b,c.duration)});return b},SB=function(a,b){return _.y(function*(){var c=_.jh([b],a.f.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.Eg(c.data)}catch(e){throw new _.H(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},YB=function(a,b){return _.y(function*(){var c=TB(a,b,a.h,"");if(1===c.type){a.w.set(a.h,c);c=_.Fo(c.V[0].a)||"";c=null!=_.Eo.video[c]?_.w:null!=_.Eo.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":
|
|
25
|
+
c===_.p&&(d="mp4a.40.2");{c=a.K;var e=a.h;d=a.f.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.ch(_.ja,"0"));k.push(new _.ch(_.lb,e));d.length&&k.push(new _.ch(_.ka,d));h.push(new _.dh(c.a++,rA,k));c=new UB(e,0,h)}}d=c.$;c=EA(d,"EXT-X-MEDIA");e=EA(d,rA);d=EA(d,"EXT-X-IMAGE-STREAM-INF");c={tc:{gf:FA(c,["AUDIO",_.sb]),closedCaptions:FA(c,eA),kg:FA(c,"SUBTITLES")},Ze:e,Lf:d};c=yield VB(a,c);if(!a.D)throw new _.H(_.G,7,7001);d=ZA(c[0]);e=WB(a,d.delay,c);if(!XB(a)){a.H=d.Oc;d=0;for(var f of a.g.values())d=
|
|
26
|
+
Math.max(d,f.ea[0].$b);for(f=0;95443.7176888889<=d;)f+=95443.7176888889,d-=95443.7176888889;if(f){a.a.debug("Offsetting live streams by",f,"to compensate for rollover");for(var g of a.g.values())d=g.ea[0],95443.7176888889>d.$b?(a.a.debug("Offset applied to",d.type),d.segmentIndex.offset(f)):a.a.debug("Offset NOT applied to",d.type)}}g=XA(c);"LIVE"===a.m||"EVENT"===a.m?(g=Math.max(g,e.F),isNaN(a.f.availabilityWindowOverride)||(g=a.f.availabilityWindowOverride),e.j=g):a.m===_.Rt&&(e.f=g);g={presentationTimeline:e,
|
|
27
|
+
periods:c,offlineSessionIds:[],minBufferTime:0};a.a.debug("HLS playlist parsed",g);return g})},cC=function(a,b,c,d){return _.y(function*(){var e=b.ea[0],f=ZB(a,e);const {response:g,text:h}=yield SB(a,f.toString());f=TB(a,h,g.uri,e.ec);$B(f,e.codecs,e.type);if(1!==f.type)throw new _.H(_.G,4,4017);const k=(yield aC(a,f,e.type,e.codecs)).flatMap(l=>l.V);e.V=k;e.segmentIndex.replace(k);_.nv(c,k,d);e=k[k.length-1];HA(f.$,jA)&&(bC(a,_.Rt),_.kv(c,!0),c.f=e.endTime)})},ZB=function(a,b){const c=new _.cg(b.ef);
|
|
28
|
+
if(a.f.hlsLowLatency){a=c.a;if(b.Rc){b=b.segmentIndex;if(b=b.a[b.a.length-1]){var d=b.a,e=d.length-1;b={Tf:b.position,Zf:d&&0<d.length?e:null}}else b=null;const {Tf:f,Zf:g}=b;null!==f&&(a.add("_HLS_msn",f),null!==g&&a.add("_HLS_part",g))}b=a;_.ng(b);b.g&&_.fg(c,a)}return c},TB=function(a,b,c,d){a:{a=a.K;b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.H(_.G,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||/^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.eh(0,h),
|
|
29
|
+
dB.includes(e.name)){f=1;break}else e.name===rA&&(g=!0)}h=f;f=[];g=!0;for(var k of _.zu(b)){let {yd:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||g)g=!1;else{e=m;e=_.eh(a.a++,e);if(dC.includes(e.name)){if(1!==h)throw new _.H(_.G,4,4017);k=b.splice(l,b.length-l);a=gB(a,c,k);c=new UB(c,h,f.concat(a.$),a.V);break a}f.push(e);e.name===rA&&(e.attributes.push(new _.ch(_.lb,n)),g=!0)}}c=new UB(c,h,f)}c.a=d;eC(c);return c},$B=function(a,b,c){if(1===a.type&&(a=a.V.map(d=>d.a?d.a:d.f.map(e=>
|
|
30
|
+
_.pg(e,_.lb))||null).map(d=>_.Go(d,c,b)),1<(new Set(a)).size))throw new _.H(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},aC=function(a,b,c,d){return _.y(function*(){const e=b.a;var f=b.V;var g=void 0===g?0:g;var h=(h=HA(b.$,mA))?Number(h.value):g;g=[];a:{var k=a.g.get(b.a),l=!XB(a),m=HA(b.$,iA);if(m)var n=Number(m.value);else{k?(m=k.ea[k.ea.length-1].V,m=m[m.length-1].Db):m=0;if(l&&0<m)try{var q=HA(b.$,mA);if(!q)throw fC.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),
|
|
31
|
+
Error(tA);var t=Number(q.value),u=DB(k,t);if(!u)throw fC.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${t})`),Error(tA);n=u.Db;break a}catch(z){throw new _.H(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}n=0}}!XB(a)&&uB(f);q=yield gC(a,b.f,e,f,h,c,d);t=h;if(0===f.length)f=[];else{u=[];h=[];for(var x of f)GA(x.$,hA)&&0<h.length&&(u.push(h),h=[]),h.push(x);u.push(h);
|
|
32
|
+
f=u}for(x=0;x<f.length;x++)u=f[x],q=yield hC(a,e,b.f,u,n+x,t,q,c,d,g[g.length-1]||null,f.length),g.push(q),q=q.endTime,t+=u.length;return g})},bC=function(a,b){a.m=b;XB(a)&&a.j.stop()},VB=function(a,b){return _.y(function*(){var c=b.tc.closedCaptions;var d=new Map;for(var e of c){c=aB(e);var f=BA(e,_.Ba),g=BA(e,"INSTREAM-ID");d.has(f)||d.set(f,new Map);d.get(f).set(g,c)}c=b.Ze;e=new Map;for(k of c){f=_.pg(k,"AUDIO");c=_.pg(k,_.sb);var h=_.pg(k,"SUBTITLES");g=iC(a,k);if(h){const l=_.Nh(_.v,g);e.set(h,
|
|
33
|
+
l);h=g.indexOf(l);-1<h&&g.splice(h,1)}f&&(h=jC(_.p,g),e.set(f,h));c&&(f=jC(_.w,g),e.set(c,f))}var k=e;e=yield kC(a,b.tc.gf,k);d=yield lC(a,b.Ze,e,d);k=yield mC(a,b.tc.kg,k);e=yield nC(a,b.Lf);k=MB(d,k,e,!XB(a));!XB(a)&&(k=[OB(k)]);a.D.filterAllPeriods(k);return k})},WB=function(a,b,c){let d=!0,e=null,f=0;XB(a)||(d=!1,e=0,f=b);const g=new _.Vz(e,f,!0);_.kv(g,d);LA(c,(h,k)=>{_.nv(g,h.V,k.startTime)});return g},kC=function(a,b,c){return _.y(function*(){var d=b.filter(f=>""!==(_.pg(f,_.lb)||""));if(0===
|
|
34
|
+
d.length)return new Map;let e=[oC(a,d[0],c)];yield e[0];e=e.concat(d.slice(1).map(f=>oC(a,f,c)));d=yield Promise.all(e);return $A(d)})},lC=function(a,b,c,d){return _.y(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(BA(f[k],_.ja));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield pC(a,h,c,d,e);f=f.map(k=>pC(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.su,[])})},mC=function(a,b,c){return Promise.all(b.map(d=>oC(a,d,c)))},
|
|
35
|
+
nC=function(a,b){return Promise.all(b.map(c=>qC(a,c)))},iC=function(a,b){var c=_.pg(b,_.ka,a.f.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.Ku(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},jC=function(a,b){if(1===b.length)return b[0];a=_.Nh(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},oC=function(a,b,c){return _.y(function*(){const d=BA(b,_.lb);return rC(a,d,()=>_.y(function*(){const e=
|
|
36
|
+
BA(b,_.Ba);var f={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.v,"CLOSED-CAPTIONS":_.v}[BA(b,"TYPE").toUpperCase()];if(!f)throw new _.H(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");const g=c.get(e)||"",h=aB(b),k=_.pg(b,"NAME"),l=b.getAttribute("DEFAULT"),m=b.getAttribute("AUTOSELECT"),n=_.pg(b,"CHANNELS");return yield sC(a,{uri:d,codecs:g,type:f,language:h,primary:!!l&&!!m,name:k,channelsCount:f===_.p?n?parseInt(n.split("/")[0],10):null:null,groupId:e,closedCaptions:null,ee:null})}))})},qC=function(a,
|
|
37
|
+
b){return _.y(function*(){const c=BA(b,_.lb);return rC(a,c,()=>_.y(function*(){var d=_.pg(b,_.ka)||"jpg",e=aB(b);const f=_.pg(b,"NAME");d=yield sC(a,{uri:c,codecs:d,type:_.ed,language:e,name:f,primary:!1,channelsCount:null,closedCaptions:null,groupId:null,ee:null});(e=_.pg(b,_.ja))&&HB(d,Number(e));return d}))})},pC=function(a,b,c,d,e){return _.y(function*(){var f=Number(BA(b,_.ja));if(null!=b.getAttribute("FRAME-RATE")||null!=b.getAttribute(_.Ya)){var g=_.pg(b,"FRAME-RATE");var h=_.pg(b,_.Ya),[k,
|
|
38
|
+
l]=h?h.split("x"):[null,null];g={frameRate:DA(g),width:DA(k),height:DA(l)}}else g=null;if(h=yield tC(a,b,g,c,d)){g=h.video;h=h.audio;var m=0<h.length?h:[null];g=0<g.length?g:[null];h=[];for(const O of m)for(const pa of g)if(m=(pa?pa.ea[0].ec:"")+" - "+(O?O.ea[0].ec:""),e.has(m))a.a.debug("Skipping variant which only differs in text streams.");else{a:{var n=a;var q=O,t=pa,u=f;const pb=[],Nc=(t||q).length();for(let Qb=0;Qb<Nc;Qb++){var x=q?q.ea[Qb]||null:null,z=t?t.ea[Qb]||null:null,E=x,D=z;E=E&&D?
|
|
39
|
+
_.Cu(E.drmInfos,D.drmInfos)?_.Bu(E.drmInfos,D.drmInfos):null:E?E.drmInfos:D?D.drmInfos:null;if(!E){n=null;break a}D=u;x={id:n.I++,language:x?x.language:_.xe,primary:!!x&&x.primary||!!z&&z.primary,audio:x,video:z,bandwidth:D,drmInfos:E,allowedByApplication:!0,allowedByKeySystem:!0};pb.push(x)}n=new uC(pb)}null==n?a.a.warn("Incompatible DRM info in HLS variant. Skipping."):(h.push(n),e.add(m))}f=h}else f=[];return f})},tC=function(a,b,c,d,e){return _.y(function*(){let f=iC(a,b);var g=_.pg(b,"AUDIO"),
|
|
40
|
+
h=_.pg(b,_.sb),k=g||h;k=k&&d.has(k)?d.get(k):[];g={audio:g?k:[],video:h?k:[]};a.a.debug("Guessing stream type for",b.toString());h=!1;const l=BA(b,_.lb);var m=g.audio.find(q=>q.ec===l);var n=_.Nh(_.w,f);n=c||n;1!==f.length||n?!k.length&&1<f.length?(a.a.debug("Guessing multiplexed audio+video"),m=_.w,f=[f.join(",")]):g.audio.length&&m?(a.a.debug(uA),m=_.p,h=!0):g.video.length?(a.a.debug(uA),m=_.p):(a.a.debug("Guessing video-only"),m=_.w):(m=_.p,a.a.debug(uA));n=null;h||(n=yield vC(a,b,f,m,e,c));if(null==
|
|
41
|
+
n)return null;g[m]=[n];m===_.p&&c&&k.forEach(q=>{EB(q,c.width);FB(q,c.height);GB(q,c.frameRate)});cB(g);return g})},vC=function(a,b,c,d,e,f){return _.y(function*(){const g=BA(b,_.lb);return rC(a,g,()=>_.y(function*(){var h=_.pg(b,eA);let k=null;d===_.w&&h&&"NONE"!==h&&(k=e.get(h));h=jC(d,c);return yield sC(a,{uri:g,codecs:h,type:d,closedCaptions:k,primary:!1,language:null,name:null,channelsCount:null,groupId:null,ee:f})}))})},rC=function(a,b,c){if(a.g.has(b))return a=a.g.get(b),Promise.resolve(a);
|
|
42
|
+
if(a.g.a.has(b))return a.g.a.get(b)||null;c=c();a.g.set(b,c);return c},sC=function(a,b){return _.y(function*(){const c=b.uri,d=b.codecs,e=b.type,f=b.language,g=b.groupId,h=b.primary,k=b.name,l=b.channelsCount,m=b.closedCaptions,n=b.ee;let q=JA(a.h,c);if(XB(a)&&a.w.has(q)){var t=a.w.get(q);a.w.delete(q)}else{const {response:O,text:pa}=yield SB(a,q);q=O.uri;t=TB(a,pa,q,c);$B(t,d,e)}if(1!==t.type)throw new _.H(_.G,4,4017);var u=NA(t.$);bC(a,u);const x=YA(t.$,u,a.f.hlsLowLatency||!1);u=yield aC(a,t,e,
|
|
43
|
+
d);const z=a.f.hlsLowLatency?_.Wx:_.Yt;let E=void 0;e===_.v&&(E=_.fu);const {Rc:D}=RA(t.$);t=u.map(O=>{const pa=O.V,pb=O.sf,Nc=O.mimeType;O=O.Db;const Qb=pa[0].startTime,Qa=pa[pa.length-1].endTime,Ge=Qa-Qb,bb=new _.Wz(pa),qa=pa[0].initSegment||null;return{id:a.I++,originalId:k,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:bb.f.bind(bb),getSegmentReference:bb.get.bind(bb),adjustSegmentDurations:bb.g.bind(bb),getDuration:bb.getDuration.bind(bb),segmentIndex:bb,segmentLookupStrategy:z,
|
|
44
|
+
initSegmentReference:qa,mimeType:Nc,codecs:d,kind:E,re:pb.type,encrypted:pb.type===zA,keyId:pb.keyId,language:f||_.xe,label:k,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:n?n.frameRate:void 0,width:n?n.width:void 0,height:n?n.height:void 0,bandwidth:void 0,roles:[],channelsCount:l,closedCaptions:m,keyInfo:pb.keyInfo,V:pa,drmInfos:pb.drmInfos,Db:O,ec:c,ef:q,$b:Qb,cd:Qa,duration:Ge,Rc:D,groupId:g,Sf:x}});return new wC(t)})},eC=function(a){1===a.type&&a.V.forEach((b,c)=>{if(GA(b.$,
|
|
45
|
+
lA)&&!GA(b.$,hA)&&0<c)throw new _.H(_.G,4,4046,"Media playlist contains an EXT-X-MAP tag not accompanied by an EXT-X-DISCONTINUITY tag.");})},xC=function(a,b,c){a=EA(a.$,lA);if(1<a.length)throw new _.H(_.G,4,4020);a=a[0];if(!a)return null;const d=BA(a,_.lb),e=JA(b,d);b=SA(a,null,!0);return new _.Sz(()=>[e],b.ta,b.ha,c)},yC=function(a,b,c,d,e,f,g){const h=[];for(const q of _.zu(b.f)){b=q.yd;const t=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.pg(t,"DURATION"));n=m+n;k=SA(t,k?
|
|
46
|
+
null:l.ha,k);l=_.pg(t,_.lb);const u=(l=JA(g,l))?[l]:[];m=new TA(c,m,n,()=>u,k.ta,k.ha,e,f,!1,null,null,null,null);if("YES"===_.pg(t,"INDEPENDENT")||0===b)m.g=!0;h.push(m)}}return h},zC=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.$;var q=c.a;const t=null!=q,u=q?[q]:[];if(!t&&!a.f.hlsLowLatency)return null;a=0;q={ta:0,ha:null};let x=null;t?({duration:c}=QA(n),a=e+c,q=PA(n,b?b.ha:null)):(b=yC(b,c,d,e,f,g,k),a=b[b.length-1].endTime,x=b);h=h===_.ed?IA(n):null;d=new TA(d,e,a,()=>u,q.ta,q.ha,f,g,!1,null,h?
|
|
47
|
+
h.we:null,h?h.Xe:null,h?h.durationPerTile:null,x);d.Db=l;d.initSegment=m||void 0;return d},gC=function(a,b,c,d,e,f,g){return _.y(function*(){var h=d[0];if(null!=a.B)return a.B;const k=yield AC(a,f,g,h);var l=vB(h.$,a.h,k)||qB();const m=xC(h,b,l.keyInfo);l=VA(l.keyInfo,e);h=yield BC(a,c,m,h,e,l,k,g);a.a.debug(`Setting playlist start time to ${h}.`);return a.B=h})},hC=function(a,b,c,d,e,f,g,h,k,l,m){return _.y(function*(){var n=d[0],q=null==l;const t=yield AC(a,h,k,n);var u=a.h,x=l?l.Rf:null;var z=
|
|
48
|
+
1===m;if(d.slice(1).some(tB))throw new _.H(_.G,4,4046,z?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");if(GA(d[0].$,kA)||null===x)if((x=vB(d[0].$,u,t))&&x.type===AA){if(1<xB(d))throw new _.H(_.G,4,4046,xA+`${z?"playlist":"discontinuity"}.`);z=[x]}else z=wB(d,u,t),z=0===z.length?
|
|
49
|
+
[qB()]:z;else if(u=wB(d,u,t),x.type===_.Ad||x.type===zA)z=[x,...u];else{if(0<xB(d))throw new _.H(_.G,4,4046,xA+`${z?"playlist":"discontinuity"}.`);z=[x]}u=z;z=u[u.length-1];u=rB(u);x=xC(n,c,u.keyInfo)||(l?l.Mf:null);var E=VA(u.keyInfo,f);n=q&&XB(a)?0:yield CC(a,e,b,x,n,f,E,t,k,g);q=[];for(E=0;E<d.length;E++){var D=d[E];const O=q[q.length-1]||null,pa=0===E?g:O.endTime,pb=f+E,Nc=VA(u.keyInfo,pb);(D=zC(a,O,D,pb,pa,n,Nc,h,c,e,x))&&q.push(D)}return{V:q,sf:u,Rf:z,mimeType:t,endTime:q[q.length-1].endTime,
|
|
50
|
+
Db:e,Mf:x}})},AC=function(a,b,c,d){return _.y(function*(){const e=d.a;var f=HA(d.$,lA);f=f?BA(f,_.lb):null;return DC(a,b,c,e,f)})},BC=function(a,b,c,d,e,f,g,h){return _.y(function*(){if(null==d.a)return 0;var k;k=(k=a.g.get(b))?(k=DB(k,e))?k.startTime:null:null;if(null!=k)return a.a.debug("Found segment start time in previous manifest"),k;a.a.debug("Unable to find segment start time in previous manifest!");k=UA(d,f);return BB(a.L,c,k,g,h,null!=f)})},XB=function(a){return a.m===_.Rt},CC=function(a,
|
|
51
|
+
b,c,d,e,f,g,h,k,l){return _.y(function*(){let m;a.G.has(b)?m=a.G.get(b):(m=(yield BC(a,c,d,e,f,g,h,k))-l,a.a.debug(`Segment #${f} has `+`timestamp offset ${m} s`),a.G.set(b,m));return m})},DC=function(a,b,c,d,e){return _.y(function*(){const f=[d,e].filter(Boolean);var g=_.Qh(f,b,c);if(g)return g;g=_.jh([d],a.f.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.F(g)).headers["content-type"];if(!g)throw new _.H(_.G,4,4021,f.join(", "));return g.split(";")[0]})},UB=class{constructor(a,b,c,d){if(1===
|
|
52
|
+
b){if(!d||0===d.length)throw new _.H(_.G,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.G,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.$=c;this.V=1===b?d:null}},fB=class{constructor(a,b,c){c=void 0===c?[]:c;this.$=b;this.a=a;this.f=c}},TA=class extends _.xv{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,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:
|
|
53
|
+
m,void 0===n?null:n,void 0===q?null:q,t);this.initSegment=void 0;this.Db=0}},dB=[iA,jA,"EXT-X-I-FRAMES-ONLY",mA,nA,oA,qA,sA],dC=["EXTINF",gA,"EXT-X-DATERANGE",hA,kA,lA,"EXT-X-PROGRAM-DATE-TIME"],eB=["EXT-X-PART",pA],EC=class{constructor(){this.a=0}},FC=class{constructor(){this.f=new Map;this.a=new Map}set(a,b){this.a.set(a,b);return b.then(c=>this.f.set(a,c)).catch(()=>{}).then(()=>this.a.delete(a))}has(a){return this.f.has(a)}get(a){return this.f.get(a)||null}values(){return Array.from(this.f.values())}clear(){this.a.clear();
|
|
54
|
+
this.f.clear()}},fC=new _.P("clpp.hls.DiscontinuityUtils");var zB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.He)throw new _.H(_.G,4,4041);if(BA(a,vA)===wA)throw new _.H(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.vu(_.Hc,[{initDataType:_.ge,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":pB,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":pB,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=BA(a,vA);if(!nB.includes(b))return oB.error("Widevine in HLS is only supported with [",
|
|
55
|
+
nB.join(", "),"], not",b),null;b=BA(a,_.lb);b=_.Vn(b);b=_.I(b.data);b=_.vu(_.Jc,[{initDataType:_.sc,initData:b}],"");if(a=_.pg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},nB=["SAMPLE-AES",wA],oB=new _.P("clpp.hls.DrmParser");var yB=new _.P("clpp.hls.EncryptionUtils");var GC=class{constructor(a){this.f=new _.P("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.gh()}}};var wC=class{constructor(a){this.ea=a}length(){return this.ea.length}};var uC=class{constructor(a){this.a=a}length(){return this.a.length}};var HC=class{constructor(){this.f=this.D=null;this.I=1;this.g=new FC;this.h="";this.K=new EC;this.H=0;this.A=new Map;this.j=new _.Yh(()=>{this.wb()});this.m=_.Rt;this.C=null;this.o=new _.Jo;this.B=null;this.a=new _.P("clpp.hls.HlsParser");this.w=new Map;this.G=new Map;this.L=new GC(this.F.bind(this));this.J=!1}configure(a){this.f=a;this.L.a=a}setCurrentVariant(a){const b=a.video?a.video.id:null;a=a.audio?a.audio.id:null;this.A.clear();for(const c of this.g.values())(null!=b&&IB(c,b)||null!=a&&IB(c,
|
|
56
|
+
a))&&this.A.set(c.ea[0].ec,c)}start(a,b){const c=this;return _.y(function*(){if(c.J)throw Error("start() may be called only once!");c.J=!0;c.D=b;const {response:d,text:e}=yield SB(c,a);c.h=d.uri;const f=yield YB(c,e);c.C=f;const g=c.H;0<g&&c.j.ca(g);return f})}stop(){this.j&&(this.j.stop(),this.j=null);const a=[];this.o&&(a.push(this.o.destroy()),this.o=null);this.g.clear();this.A.clear();this.f=this.D=null;this.w.clear();this.C=null;return Promise.all(a)}onExpirationUpdated(){}update(){const a=this;
|
|
57
|
+
return _.y(function*(){var b=a.C;if(!XB(a)&&b){var c=b.presentationTimeline;b=b.periods[0].startTime;var d=[];"LIVE"===a.m&&(a.B=null);var e=Array.from(a.g.values()),f=Array.from(a.A.values());e=a.f.hlsLowLatency&&0<f.length?f:e;yield cC(a,e[0],c,b);for(f=1;f<e.length;f++)d.push(cC(a,e[f],c,b));yield Promise.all(d)}})}wb(){const a=this;return _.y(function*(){a.a.debug(_.Qt);if(a.D)try{yield a.update(),a.j.ca(a.H)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.j.ca(.1))}})}F(a){if(!this.o)throw new _.H(_.G,
|
|
58
|
+
7,7001);a=this.D.networkingEngine.fetch(a);_.qh(this.o,a);return a.P}};_.A("clpp.hls.HlsComponent",class extends _.Ap{constructor(){super()}f(){_.zn.m3u8=HC;_.xn[_.Ui]=HC;_.xn[yA]=HC}a(){_.Ev("m3u8");_.Fv(_.Ui);_.Fv(yA)}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 WJ=function(a){a.a.one(a.l,_.nd,()=>VJ(a))},VJ=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Mb,d=>XJ(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{XJ(a,{track:d})});!YJ(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."),ZJ(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.")},XJ=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,_.Mc,c=>$J(a,c)))},YJ=function(a){return a.some(b=>b.kind===_.td)},ZJ=function(a,b){const c=a.l.getTrackManager(),d=c.na(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.sa(d);a.a.on(b.textTracks,_.Mb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Mb,f),c.sa(d))});c.sa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
$J=function(a,b){const c=aK(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 bK(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Ig(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)}}})},aK=function(a){return(a=a.l.getTrackManager().oa())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
bK=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(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 cK=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.jo;this.h=(a=_.Xn[_.Yb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.P("clpp.hlssmpte.ImageCueHandler");this.g=null;WJ(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var dK=class extends _.aq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.li()){var b=a.getConfiguration();b=_.kf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.hc&&(b.patchMetadataTrack=!1);_.qf(b.timestampOffset)||(b.timestampOffset=0);this.a=new cK(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.A("clpp.hlssmpte.HlsSmptePlugin",dK);
|
|
5
|
+
dK.Id="hlssmpte";_.Hm(new class{create(){return new dK}});};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 _.
|
|
6
|
-
case _.
|
|
7
|
-
["+y","-y"];break;case _.
|
|
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
|
-
_.
|
|
21
|
-
b=c;f*=b;break a;default:throw Error(
|
|
22
|
-
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.
|
|
23
|
-
new _.
|
|
24
|
-
this;return _.
|
|
25
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var OI="Unsupported unit",PI="clpp-text-plain",QI="clpp-text-ttml",RI="clpp.htmlcue.HtmlTextDisplayer",SI="initial",TI=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},UI=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},WI=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>VI[c]);return a},YI=
|
|
2
|
+
function(a,b){XI(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{XI(a,c)})},XI=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},ZI=function(a,b){return 0===a?"0":a+b},$I=function(a,b){return 1>Math.abs(a-b)||a<b},aJ=function(a,b){return a<b&&1<Math.abs(a-b)},bJ=function(a,b){return a>b&&1<Math.abs(a-b)},cJ=function(a,b){return 1>Math.abs(a-b)||a>b},eJ=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 dJ(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},fJ=function(a){return new dJ(a.f,a.g,a.h,a.a,a.height,a.width)},gJ=function(a,b){return b.some(c=>aJ(a.f,c.g)&&bJ(a.g,c.f)&&aJ(a.h,c.a)&&bJ(a.a,c.h))},hJ=function(a,b){return cJ(a.h,
|
|
4
|
+
b.h)&&$I(a.a,b.a)&&cJ(a.f,b.f)&&$I(a.g,b.g)},iJ=function(a,b,c){switch(c){case "+x":return aJ(a.f,b.f);case "-x":return bJ(a.g,b.g);case "+y":return aJ(a.h,b.h);case "-y":return bJ(a.a,b.a);default:throw Error("Unknown axis");}},jJ=function(a){return a.f.writingMode===_.no},kJ=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 jJ(a)?b:c},lJ=function(a){switch(a.f.writingMode){case _.no:return"horizontal-tb";case _.Ee:return _.Ee;
|
|
5
|
+
case _.Fe:return _.Fe;default:throw Error("Unknown writing mode");}},mJ=function(a){switch(a.f.positionAlign){case _.ld:return _.hd;case "auto":case _.tc:return _.mo;case _.md:return _.ce}return a.f.textAlign},nJ=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===_.r)switch(b){case _.ld:return a.f.position;case "auto":case _.tc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},oJ=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.hd:case _.hd:return _.ld;
|
|
6
|
+
case _.mo:return _.tc;case _.ce:case _.ce:return _.md}return a.f.positionAlign},rJ=function(a,b,c){return(pJ(a)||qJ(a))&&_.qf(c)?ZI(c,_.Wd):pJ(a)&&_.B(c)?ZI(0,_.Wd):jJ(a)&&_.qf(b)?ZI(b,"%"):SI},sJ=function(a,b,c){return jJ(a)&&_.qf(c)?ZI(c,_.Wd):(pJ(a)||qJ(a))&&_.qf(b)?ZI(b,"%"):SI},qJ=function(a){return a.f.writingMode===_.Fe},pJ=function(a){return a.f.writingMode===_.Ee},tJ=function(a,b){if(a.h)switch(b.writingMode){case _.no:return["-y"];case _.Ee:return["+x"];case _.Fe:return["-x"]}a=[];switch(b.writingMode){case _.no:a=
|
|
7
|
+
["+y","-y"];break;case _.Ee:a=["+x","-x"];break;case _.Fe:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},uJ=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=eJ(a.j.a)},vJ=function(a,b){uJ(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},wJ=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.uo)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(OI);},yJ=function(a,b,c,d){const e=document.createElement(_.oe),
|
|
8
|
+
f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);xJ(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},zJ=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)},AJ=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},BJ=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},xJ=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())},CJ=function(a){a=_.kf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},IJ=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Hl)if(a.I=c,c=DJ(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,EJ(a),c)){b={color:a.getFontColor()||void 0,
|
|
11
|
+
backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.co(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 _.we:g=QI;break;case _.lo:g=PI}g&&!f.classList.contains(g)&&_.bm(f,g);f=eJ(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{XI({fontSize:FJ(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Oe;var h=d.payloadType===_.we;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new GJ(d.region,{}),c.A.set(d.region.id,f),vJ(c.a,f)));d=new HJ(d,c.K,e);f?vJ(f,d):vJ(c.a,d)}}}}},JJ=function(a){EJ(a);a.I=null;a.m=null;a.f=[]},KJ=function(a,b){return a.startTime<=b&&a.endTime>b},DJ=function(a,b){var c=TI(a.f,d=>KJ(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&&KJ(a.f[d-1],b);)d--;for(;c+1<a.f.length&&KJ(a.f[c+1],b);)c++;return{start:d,end:c}}},EJ=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(QI);b.classList.remove(PI);a=a.a;uJ(a.g);a.j=[]}},FJ=function(a,b){const c=eJ(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===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*
|
|
14
|
+
a)}px`},OJ=class{parse(a){a={input:a};const b=_.dm(_.Qc),c=[];let d=b;for(var e;null!==(e=UI(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=LJ[f];h?(h=_.dm(h),(f=MJ[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||NJ[g.localName]&&NJ[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(WI(e)));return b}},LJ={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},MJ={v:"voice",lang:"lang"},NJ={rt:"ruby"},VI={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var dJ=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 PJ=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 HJ=class extends PJ{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)_.bm(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===_.we){var c=_.dm(_.Qc);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
16
|
+
_.Oe?b=(new OJ).parse(b.payload):(c=_.dm(_.Qc),c.textContent=b.payload,b=c);_.bm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.bm(b,d);XI({writingMode:lJ(this)},b);var d=b;this.a.appendChild(d);_.bm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.bm(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.oo,this.f.line=jJ(this)?-1:0);e=lJ(this);XI({writingMode:e,webkitWritingMode:e,direction:SI,textAlign:mJ(this)},this.a);if(!this.f.region||
|
|
17
|
+
!this.f.region.displayAlign){e=nJ(this,oJ(this));XI({position:"absolute",left:rJ(this,e,null),right:qJ(this)&&_.B(null)?ZI(0,_.Wd):SI,top:sJ(this,e,null),width:jJ(this)?ZI(this.f.size,"%"):SI,height:pJ(this)||qJ(this)?ZI(this.f.size,"%"):SI},this.a);b=this.f;a=jJ(this)?a.height:a.width;c=kJ(this);if(b.lineInterpretation===_.oo){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 _.tc:g-=f/2;break;case _.Yc:g-=f}f=Math.round(g/
|
|
18
|
+
100*a)}qJ(this)&&(f=a-f-c);a=f;XI({left:rJ(this,e,a),right:qJ(this)&&_.B(a)?ZI(0,_.Wd):SI,top:sJ(this,e,a)},this.a)}YI(this.B,d)}}m(){return _.dm(_.Qc)}};var QJ=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=eJ(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=eJ(a.a);var d=tJ(this,a.f),e=kJ(a);const g=fJ(c);let h=null,k=0;for(const l of d){for(;iJ(c,this.a,l)||hJ(c,this.a)&&gJ(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||hJ(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=fJ(c),k=d);c=fJ(g)}c=h||g}XI({top:ZI(c.h-this.a.h,_.Wd),bottom:ZI(this.a.a-c.a,_.Wd),left:ZI(c.f-this.a.f,_.Wd),right:ZI(this.a.g-c.g,_.Wd),height:ZI(c.height,_.Wd),width:ZI(c.width,_.Wd)},a.a)}b.style.visibility="visible";this.g.push(eJ(a.a))}};var RJ=class extends PJ{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new QJ(this);this.h=!0}m(){const a=_.dm(_.Qc);_.bm(a,this.o);this.id&&(a.id=this.id);return a}};var GJ=class extends RJ{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 _.uo:b=b.width/100*a.width;break a;default:throw Error(OI);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.uo)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(OI);d=a.height;const e=wJ(this,d,a.height);XI(this.A,this.a);XI({left:ZI(c,_.Wd),top:ZI(e,_.Wd),width:ZI(b,
|
|
20
|
+
_.Wd),height:ZI(d,_.Wd)},this.a);this.f.writingMode&&XI({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&XI({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.bm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.uo:f=f.height/100*a.height;break a;case 2:f=f.height;c=new HJ(new _.ro(0,1,"Lorem ipsum",_.lo),{},{});b=c.a;this.a.appendChild(b);c.init(eJ(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
21
|
+
b=c;f*=b;break a;default:throw Error(OI);}a=wJ(this,f,a.height);XI({top:ZI(a,_.Wd),height:ZI(f,_.Wd)},this.a);this.g=new QJ(this,!0);this.h=!0}getId(){return this.f.id}};var SJ=class{constructor(a,b){this.f=new _.P("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=yJ(this,this.h,this.j);this.g=yJ(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=zJ(this,a);if(AJ(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 _.y(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],BJ(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 TJ=class extends _.Yp{constructor(a){super(a);this.L=new _.P(RI);this.l=a;this.K=CJ(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new SJ(a,"CLPP Subtitle Styles");this.a=new RJ(null,"clpp-text-container",{});this.w=new _.Tp(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 _.Yh(()=>{IJ(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;IJ(this,!1)}}g(){null==this.h||IJ(this,!0)}destroy(){const a=
|
|
24
|
+
this;return _.y(function*(){null!=a.h&&(JJ(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;IJ(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Va(.25),this.K.enableResizeObserver&&this.w.start(),IJ(this,!0)):(this.F.stop(),this.w.stop(),JJ(this)))}U(){IJ(this,!0)}};_.A(RI,TJ);
|
|
25
|
+
TJ.prototype.setTextVisibility=TJ.prototype.setTextVisibility;TJ.prototype.isTextVisible=TJ.prototype.isTextVisible;TJ.prototype.remove=TJ.prototype.remove;TJ.prototype.destroy=TJ.prototype.destroy;TJ.prototype.append=TJ.prototype.append;var UJ=class{da(a){return!!a.enableHtmlCue&&!_.ni()}create(a){return new TJ(a)}};_.A("clpp.htmlcue.HtmlCueComponent",class extends _.Ap{f(){_.ll("html",new UJ)}a(){}id(){return _.pe}});};f.call(g, window);
|