@castlabs/prestoplay 6.6.1 → 6.7.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 +13 -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 +423 -423
- package/cjs/cl.crypto.js +10 -10
- package/cjs/cl.dash.js +71 -71
- package/cjs/cl.externs.js +47 -41
- 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 +263 -260
- package/cjs/cl.muxdata.js +11 -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 +23 -23
- 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 +19 -19
- 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 +346 -344
- package/cl.crypto.js +8 -8
- package/cl.dash.js +67 -67
- package/cl.externs.js +47 -41
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +57 -40
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +25 -25
- package/cl.ima.js +17 -16
- package/cl.mse.js +228 -228
- package/cl.muxdata.js +9 -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 +14 -14
- package/package.json +1 -1
- package/typings.d.ts +108 -7
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,_.ve,a.F.bind(a));a.g.on(a.l,_.ke,a.C.bind(a))}
|
|
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
|
-
W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.
|
|
9
|
-
W.prototype.getMediaWidth=W.prototype.
|
|
10
|
-
W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;W.prototype.getTechnology=W.prototype.
|
|
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
|
-
_.Db,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:
|
|
17
|
-
_.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:
|
|
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 RJ="clpp-freewheel",SJ="clpp.freewheel.AdsManagerFactory",TJ="freewheel",UJ=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""}},VJ=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.ne&&b.push("serverUrl");typeof a.profileId!==_.ne&&b.push("profileId");typeof a.videoAssetId!==_.ne&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
|
|
2
|
+
if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},WJ=function(){return _.y(function*(){var a=new _.eq;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})},XJ=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,_.ve,a.F.bind(a));a.g.on(a.l,_.ke,a.C.bind(a))},$J=function(a){return _.y(function*(){a.A.length?(YJ(a),a.f=a.A.shift(),a.f.play()):(ZJ(a),yield a.l.a.play())})},ZJ=function(a){const b=a.l.Vb(TJ).qc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},YJ=function(a){const b=a.l.Vb(TJ).qc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(RJ),
|
|
4
|
+
a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},aK=function(a){a.w.length?(YJ(a),a.f=a.w.shift(),a.f.play()):ZJ(a)},bK=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 W(a.a,c,d)});a.l.trigger(new _.F(b,d))},cK=class extends _.kq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.lm(_.Qc,{id:RJ}),this.f=_.lm(_.w,{"class":_.yc}),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 TJ}qc(){return this.a}Af(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",cK);cK.prototype.getAdVideo=cK.prototype.Af;cK.prototype.getAdContainer=cK.prototype.qc;cK.Id=TJ;cK.AD_CONTAINER_ID=RJ;_.Sm(new class{create(){return new cK}});var W=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===_.ne?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}Zb(){return!1}Gb(){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}Hb(){switch(this.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Ib(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}sb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
|
|
8
|
+
W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.sb;W.prototype.getPositionInSequence=W.prototype.Ib;W.prototype.getPodTimeOffset=W.prototype.Hb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Qa;W.prototype.getMediaBitrate=W.prototype.eb;W.prototype.getMediaHeight=W.prototype.pb;
|
|
9
|
+
W.prototype.getMediaWidth=W.prototype.qb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Gb;W.prototype.isBumper=W.prototype.Zb;W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;
|
|
10
|
+
W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;W.prototype.getTechnology=W.prototype.tb;W.prototype.getAdManagerVersion=W.prototype.ob;W.prototype.getAdManagerName=W.prototype.nb;var dK=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()}})}Jb(){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
|
+
dK.prototype.hasPostroll=dK.prototype.fb;dK.prototype.hasPreroll=dK.prototype.Jb;dK.prototype.getCuePoints=dK.prototype.getCuePoints;var eK=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.uo;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Xk;this.h=null}load(){const a=this;return _.y(function*(){const b=a.l.getConfiguration().freewheel||{};try{VJ(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!==_.ne&&typeof b.siteSectionId!==
|
|
12
|
+
_.r||a.a.setSiteSection(b.siteSectionId);const c=yield WJ();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,UJ(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);XJ(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.y(function*(){yield $J(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);ZJ(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(_.Ob,{adsTimeline:new dK(this.a)})),this.h=new _.cq(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Vb(TJ).f);else this.l.onError(new _.H(1,
|
|
15
|
+
9,10003,{errorType:0},void 0));this.j.resolve()}J(a){bK(this,_.xb,a);this.h.start()}I(a){this.f=null;a=a.slot;bK(this,_.yb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:$J(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:ZJ(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:aK(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:bK(this,_.Kb,a);bK(this,
|
|
16
|
+
_.Db,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:bK(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:bK(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:bK(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:bK(this,_.Mb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:bK(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:bK(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:bK(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:bK(this,
|
|
17
|
+
_.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:bK(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:bK(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:bK(this,_.Hb,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();YJ(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Sl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Rl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Hl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);aK(this);break;case _.Pl:case _.Ol:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
|
|
19
|
+
eK.prototype.getPosition=eK.prototype.getPosition;eK.prototype.setVolume=eK.prototype.setVolume;eK.prototype.getVolume=eK.prototype.getVolume;eK.prototype.skip=eK.prototype.skip;eK.prototype.pause=eK.prototype.pause;eK.prototype.resume=eK.prototype.resume;eK.prototype.start=eK.prototype.start;var fK=class{constructor(){this.a=new _.O(SJ)}name(){return SJ}ba(a,b){return a.namespace()===_.Ac?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new eK(a)}};fK.prototype.create=fK.prototype.create;fK.prototype.isSupported=fK.prototype.ba;fK.prototype.name=fK.prototype.name;_.im(new fK);};f.call(g, window);
|
package/cl.hls.js
CHANGED
|
@@ -1,40 +1,57 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
|
|
3
|
-
"TYPE")
|
|
4
|
-
|
|
5
|
-
b){
|
|
6
|
-
a
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
a.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
a.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
new
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Rz="CLOSED-CAPTIONS",Sz="Could not parse MP4 segment start time.",Tz="EXT-X-BYTERANGE",Uz="EXT-X-DISCONTINUITY",Vz="EXT-X-DISCONTINUITY-SEQUENCE",Wz="EXT-X-ENDLIST",Xz="EXT-X-KEY",Yz="EXT-X-MAP",Zz="EXT-X-MEDIA-SEQUENCE",$z="EXT-X-PART-INF",aA="EXT-X-PLAYLIST-TYPE",bA="EXT-X-PRELOAD-HINT",cA="EXT-X-SERVER-CONTROL",dA="EXT-X-STREAM-INF",eA="EXT-X-TARGETDURATION",fA="Failed to infer discontinuity number",gA="Guessing audio-only",hA="METHOD",iA="Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 in combination with another EXT-X-KEY tag, which is not supported.",
|
|
2
|
+
jA="Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist , which is not supported.",kA="SAMPLE-AES-CTR",lA="application/vnd.apple.mpegurl",mA="sample",nA="whole-segment",oA=function(a,b){return _.qg(a,b,void 0,{required:!0})},pA=function(a){if(1>a.a)throw _.wj();--a.a},qA=function(a){if(null!==a&&void 0!==a)return Number(a)},rA=function(a,b){return a.filter(c=>c.name===b)},sA=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=
|
|
3
|
+
oA(d,"TYPE");return c.includes(d)})},tA=function(a,b){return a.some(c=>c.name===b)},uA=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,4,4024,{missingTag:b});return a},vA=function(a){var b=uA(a,"EXT-X-TILES");if(!b)return{ve:1,Ve:1,durationPerTile:null};a=_.qg(b,"LAYOUT")||"1x1";b=(b=_.qg(b,"DURATION"))?Number(b):null;const [c,d]=a.split("x").map(e=>parseInt(e,10));return{ve:c,Ve:d,durationPerTile:b}},wA=function(a,b){return _.yu([a],[b])[0]},xA=
|
|
4
|
+
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)},yA=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of xA(c))b(d,c)})},zA=function(a){return a.type===_.p||a.type===_.w},AA=function(a){const b=uA(a,aA);if(uA(a,Wz))return _.Tt;if(!b)return"LIVE";if(b.value===_.Tt)return _.Tt;if("EVENT"===b.value)return"EVENT";throw new _.H(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${b.value}`);
|
|
5
|
+
},BA=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.");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}},
|
|
6
|
+
CA=function(a,b){a=uA(a,Tz);return BA(a?a.value:null,b)},DA=function(a){a=uA(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},EA=function(a,b){b=void 0===b?{}:b;const c={Qc:!1,kf:!1,lf:null,Jf:null,Je:null};a=uA(a,cA,{required:b.Me});if(!a)return c;const d=e=>null==e?null:Number(e);c.Qc="YES"===_.qg(a,"CAN-BLOCK-RELOAD");c.kf="YES"===_.qg(a,"CAN-SKIP-DATERANGES");c.lf=d(_.qg(a,"CAN-SKIP-UNTIL"));c.Jf=d(_.qg(a,"HOLD-BACK"));c.Je=d(_.qg(a,"PART-HOLD-BACK",void 0,
|
|
7
|
+
{required:b.Me}));return c},FA=function(a,b,c){c=void 0===c?!1:c;a=_.qg(a,"BYTERANGE");return BA(a,b,c)},HA=function(a,b){const c=CA(a.ca,null);return new GA(0,0,0,()=>[a.a],c.ta,c.ha,0,b)},IA=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.ah(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},JA=function(a){let b=Infinity,c=Infinity;xA(a).filter(zA).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,
|
|
8
|
+
d);c=Math.min(c,e)});return{ub:b,duration:c}},KA=function(a){return a.map(b=>{({duration:b}=JA(b));return b}).reduce((b,c)=>b+c,0)},LA=function(a,b,c){if(b===_.Tt)return{delay:0,Oc:0};b=uA(a,$z);if(c&&b)return c=Number(oA(b,"PART-TARGET")),{Je:a}=EA(a,{Me:!0}),{delay:a,Oc:c};a=uA(a,eA,{required:!0});a=Number(a.value);return{delay:3*a,Oc:a}},MA=function(a){const b=[];yA(a,c=>{b.push(c.Rf)});return{delay:Math.max(...b.map(c=>c.delay)),Oc:Math.min(...b.map(c=>c.Oc))}},NA=function(a){const b=new Map;
|
|
9
|
+
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},OA=function(a){a=_.qg(a,"LANGUAGE")||_.ye;return _.sg(a)},QA=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),PA(b,a)},UA=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.fh(a.a++,h),RA.includes(h.name)?d.push(h):SA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===bA&&"PART"===_.qg(h,"TYPE")&&
|
|
10
|
+
g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=wA(b,h.trim()),e.push(new TA(h,f,g)),f=[],g=[])});0<g.length&&e.push(new TA(null,f,g));return{V:e,ca:d}},VA=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},WA=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},XA=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]<<
|
|
11
|
+
21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.G,4,4030);}WA(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}}WA(a,e)||d();
|
|
12
|
+
e+=10;e+=f}while(e<a.byteLength);return d()},YA=function(a,b){let c=null,d=0;try{(new _.Mj).L(_.wd,_.Fj).L(_.we,_.Fj).L(_.rd,_.Fj).Y("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.fq.error("Unable to find timescale in init segment!"),new _.H(_.G,4,4030,Sz,c);let e=0,f=!1;try{(new _.Mj).L("moof",_.Fj).L("traf",_.Fj).Y("tfdt",g=>{e=(0==g.version?_.N(g.reader):_.Bj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||
|
|
13
|
+
!f)throw new _.H(_.G,4,4030,Sz,c);return e},ZA=function(a){for(;a.getPosition()<a.za()-1;){const b=a.getPosition();if(71===_.xj(a))return pA(a),b}return-1},$A=function(a){function b(){d.seek(e+188);f=_.xj(d);71!=f&&(d.seek(e+192),f=_.xj(d));71!=f&&(d.seek(e+204),f=_.xj(d));71!=f&&c();pA(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.vk(new DataView(a),!1);let e=0,f=0;e=ZA(d);0>e&&(_.fq.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.xj(d);71!=f&&
|
|
14
|
+
c();a=_.yj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.xj(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.xj(d),d.skip(a));if(1!=_.N(d)>>8){b();continue}d.skip(3);a=_.xj(d)>>6;0!=a&&1!=a||c();0==_.xj(d)&&c();a=_.xj(d);const g=_.yj(d),h=_.yj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},cB=function(a){var b=oA(a,hA);if(!aB.includes(b))return bB.error("PlayReady in HLS is only supported with [",aB.join(", "),"], not",b),null;a=oA(a,_.mb);b=_.go(a);a=null;b=_.I(b.data);
|
|
15
|
+
try{a=_.pu(_.Ck(b))}catch(c){a=b}return _.zu(_.Jc,[{initDataType:_.tc,initData:a}],"")},hB=function(a,b,c,d){if(null===d){if(a.slice(1).some(dB))throw new _.H(_.G,4,4046,jA);if((d=eB(a[0].ca,b,c))&&d.type===nA){if(0<fB(a.slice(1)).length)throw new _.H(_.G,4,4046,iA);return[d]}a=fB(a).map(e=>eB(e.ca,b,c));return 0===a.length?[gB()]:a}if(a.some(dB))throw new _.H(_.G,4,4046,jA);if(d.type===nA){if(0<fB(a).length)throw new _.H(_.G,4,4046,iA);return[d]}d=d.type===mA?[d]:[];a=fB(a).map(e=>eB(e.ca,b,c));
|
|
16
|
+
return d.concat(a)},iB=function(a){if(0===a.length)return gB();if(a.some(c=>c.type===nA)||a.every(c=>c.type===_.Ad))return a[0];a=a.filter(c=>c.type===mA);const b=Array.from((new Set(a.flatMap(c=>c.drmInfos))).values());return{keyInfo:null,keyId:a[a.length-1].keyId,type:mA,drmInfos:b}},dB=function(a){return rA(a.ca,Xz).some(b=>"AES-128"===_.qg(b,hA))},fB=function(a){return a.filter(b=>tA(b.ca,Xz))},eB=function(a,b,c){a=rA(a,Xz);if(0===a.length)return null;var d=oA(a[0],hA);if(1===a.length){if("NONE"===
|
|
17
|
+
d)return gB();if("AES-128"===d)return a=a[0],d=_.qg(a,"IV",""),{type:nA,keyInfo:{method:"AES-128",url:wA(b,oA(a,_.mb)),iv:d?_.Yg((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>oA(e,hA));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===kA))throw jB.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.qg(e,"KEYFORMAT","identity");{const g=kB[f]||null;e=g?g(e,c):null}e||jB.warn("Unsupported HLS KEYFORMAT",
|
|
18
|
+
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:mA,drmInfos:b}},gB=function(){return{type:_.Ad,keyInfo:null,drmInfos:[],keyId:null}},lB=function(a,b,c){return _.y(function*(){const d=b.f(),e=_.Tu(b.Fa(),b.ta,b.ta+2048-1,a.a.attemptParameters);e.type=2;const f=_.Tu(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===
|
|
19
|
+
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.");}}})},mB=function(a,b,c,d,e,f){return _.y(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===
|
|
20
|
+
d||d===_.dc||d===_.cc)return 0;if(d===_.bc){var g=yield lB(a,c,f);const h=_.I(g.data);return WA(h)?XA(h):$A(g.data)}if(d===_.Ke||d===_.ec)return g=[lB(a,c,f)],b&&g.push(lB(a,b,!0)),g=yield Promise.all(g),YA(g[0].data,(g[1]||g[0]).data);if(d===_.Je)return g=yield lB(a,c,f),$A(g.data);if(!MediaSource.isTypeSupported(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.G,4,4030);})},nB=function(a,b){a=a.map(c=>c.ea[b]);return a.some(c=>null==c)?null:a},PA=function(a,b){a.ea.forEach(c=>
|
|
21
|
+
{c.codecs=b.join(",")})},oB=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},pB=function(a,b){a.ea.forEach(c=>{c.width=b})},qB=function(a,b){a.ea.forEach(c=>{c.height=b})},rB=function(a,b){a.ea.forEach(c=>{c.frameRate=b})},sB=function(a,b){a.ea.forEach(c=>{c.bandwidth=b})},tB=function(a,b){return a.ea.some(c=>c.id===b)},uB=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},xB=function(a,
|
|
22
|
+
b,c,d){var e=a[0].length();e=VA(e).map(f=>{const g=uB(a,f)||[],h=nB(b,f)||[],k=nB(c,f)||[];return vB({variants:g,textStreams:h,thumbStreams:k,Pf:d&&0===f})});wB(e);return e},zB=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=xA(e);0<f&&yB(g,e.startTime);g.forEach(h=>{const k=h.ec;d.has(k)?d.get(k).push(h):d.set(k,[h])})});yA(b,e=>{var f=d.get(e.ec);const g=f.flatMap(h=>h.V);f=f.map(h=>({keyInfo:h.keyInfo,type:h.qe,drmInfos:h.drmInfos,
|
|
23
|
+
keyId:h.keyId}));f=iB(f);e.keyInfo=f.keyInfo;e.qe=f.type;e.encrypted=f.type===mA;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})},vB=function(a){const b=a.variants,c=a.textStreams,d=a.thumbStreams;var e=a.Pf;a=[...b.flatMap(l=>[l.video,l.audio]),...c,...d].filter(Boolean);const f=a[0].ub;e=e?f:0;AB(a,e);const {Eb:g,bd:h,duration:k}=a[0];return{variants:b,textStreams:c,thumbStreams:d,startTime:0,id:`P${g}`,endTime:h,
|
|
24
|
+
duration:k+e,Eb:g}},wB=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}},AB=function(a,b){yB(a,0);BB(a);0<b&&yB(a,b)},yB=function(a,b){a.forEach(c=>{const d=-c.ub+b;c.segmentIndex.offset(d);c.bd+=d;c.ub=b})},BB=function(a){const b=CB(a);a.forEach(c=>{_.kv(c.segmentIndex,b);c.duration=b;c.bd=c.ub+b})},CB=function(a){let b=Infinity;a.filter(zA).forEach(c=>{b=Math.min(b,c.duration)});return b},DB=function(a,b){return _.y(function*(){var c=
|
|
25
|
+
_.kh([b],a.f.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.Fg(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}})},KB=function(a,b){return _.y(function*(){var c=EB(a,b,a.h,"");if(1===c.type){a.w.set(a.h,c);c=_.Qo(c.V[0].a)||"";c=null!=_.Po.video[c]?_.w:null!=_.Po.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.K;var e=a.h;d=a.f.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.dh(_.ja,
|
|
26
|
+
"0"));k.push(new _.dh(_.mb,e));d.length&&k.push(new _.dh(_.la,d));h.push(new _.eh(c.a++,dA,k));c=new FB(e,0,h)}}d=c.ca;c=rA(d,"EXT-X-MEDIA");e=rA(d,dA);d=rA(d,"EXT-X-IMAGE-STREAM-INF");c={tc:{ff:sA(c,["AUDIO",_.sb]),closedCaptions:sA(c,Rz),kg:sA(c,"SUBTITLES")},Xe:e,Kf:d};c=yield GB(a,c);if(!a.D)throw new _.H(_.G,7,7001);d=MA(c[0]);e=HB(a,d.delay,c);if(!IB(a)){a.H=d.Oc;d=0;for(var f of a.g.values())d=Math.max(d,f.ea[0].ub);for(f=0;95443.7176888889<=d;)f+=95443.7176888889,d-=95443.7176888889;if(f){a.a.debug("Offsetting live streams by",
|
|
27
|
+
f,"to compensate for rollover");for(var g of a.g.values())d=g.ea[0],95443.7176888889>d.ub?(a.a.debug("Offset applied to",d.type),d.segmentIndex.offset(f)):a.a.debug("Offset NOT applied to",d.type)}}g=KA(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===_.Tt&&JB(e,g,c);g={presentationTimeline:e,periods:c,offlineSessionIds:[],minBufferTime:0};a.a.debug("HLS playlist parsed",g);return g})},PB=function(a,b,c,d){return _.y(function*(){var e=
|
|
28
|
+
b.ea[0],f=LB(a,e);const {response:g,text:h}=yield DB(a,f.toString());f=EB(a,h,g.uri,e.ec);MB(f,e.codecs,e.type);if(1!==f.type)throw new _.H(_.G,4,4017);const k=(yield NB(a,f,e.type,e.codecs)).flatMap(l=>l.V);e.V=k;e.segmentIndex.replace(k);_.Xu(c,k,d);e=k[k.length-1];uA(f.ca,Wz)&&(OB(a,_.Tt),_.Uu(c,!0),c.f=e.endTime)})},LB=function(a,b){const c=new _.dg(b.cf);if(a.f.hlsLowLatency){a=c.a;if(b.Qc){b=b.segmentIndex;if(b=b.a[b.a.length-1]){var d=b.a,e=d.length-1;b={Sf:b.position,Yf:d&&0<d.length?e:null}}else b=
|
|
29
|
+
null;const {Sf:f,Yf:g}=b;null!==f&&(a.add("_HLS_msn",f),null!==g&&a.add("_HLS_part",g))}b=a;_.og(b);b.g&&_.gg(c,a)}return c},EB=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=_.fh(0,h),RA.includes(e.name)){f=1;break}else e.name===dA&&(g=!0)}h=f;f=[];g=!0;for(var k of _.Du(b)){let {xd:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||
|
|
30
|
+
g)g=!1;else{e=m;e=_.fh(a.a++,e);if(QB.includes(e.name)){if(1!==h)throw new _.H(_.G,4,4017);k=b.splice(l,b.length-l);a=UA(a,c,k);c=new FB(c,h,f.concat(a.ca),a.V);break a}f.push(e);e.name===dA&&(e.attributes.push(new _.dh(_.mb,n)),g=!0)}}c=new FB(c,h,f)}c.a=d;RB(c);return c},MB=function(a,b,c){if(1===a.type&&(a=a.V.map(d=>d.a?d.a:d.f.map(e=>_.qg(e,_.mb))||null).map(d=>_.Ro(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.");
|
|
31
|
+
},NB=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=uA(b.ca,Zz))?Number(h.value):g;g=[];a:{var k=a.g.get(b.a),l=!IB(a),m=uA(b.ca,Vz);if(m)var n=Number(m.value);else{k?(m=k.ea[k.ea.length-1].V,m=m[m.length-1].Eb):m=0;if(l&&0<m)try{var q=uA(b.ca,Zz);if(!q)throw SB.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(fA);var t=Number(q.value),u=oB(k,t);if(!u)throw SB.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
|
|
32
|
+
` (segment position = ${t})`),Error(fA);n=u.Eb;break a}catch(A){throw new _.H(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}n=0}}q=yield TB(a,b.f,e,f,h,c,d);t=h;if(0===f.length)f=[];else{u=[];h=[];for(var x of f)tA(x.ca,Uz)&&0<h.length&&(u.push(h),h=[]),h.push(x);u.push(h);f=u}for(x=0;x<f.length;x++)u=f[x],q=yield UB(a,e,b.f,u,n+x,t,q,c,d,g[g.length-1]||null),g.push(q),q=q.endTime,t+=u.length;return g})},OB=function(a,b){a.m=b;IB(a)&&a.j.stop()},GB=
|
|
33
|
+
function(a,b){return _.y(function*(){var c=b.tc.closedCaptions;var d=new Map;for(var e of c){c=OA(e);var f=oA(e,_.Ca),g=oA(e,"INSTREAM-ID");d.has(f)||d.set(f,new Map);d.get(f).set(g,c)}c=b.Xe;e=new Map;for(k of c){f=_.qg(k,"AUDIO");c=_.qg(k,_.sb);var h=_.qg(k,"SUBTITLES");g=VB(a,k);if(h){const l=_.Oh(_.v,g);e.set(h,l);h=g.indexOf(l);-1<h&&g.splice(h,1)}f&&(h=WB(_.p,g),e.set(f,h));c&&(f=WB(_.w,g),e.set(c,f))}var k=e;e=yield XB(a,b.tc.ff,k);d=yield YB(a,b.Xe,e,d);k=yield ZB(a,b.tc.kg,k);e=yield $B(a,
|
|
34
|
+
b.Kf);k=xB(d,k,e,!IB(a));k=[zB(k)];a.D.filterAllPeriods(k);return k})},HB=function(a,b,c){let d=!0,e=null,f=0;IB(a)||(d=!1,e=0,f=b);const g=new _.Gz(e,f,!0);_.Uu(g,d);yA(c,(h,k)=>{_.Xu(g,h.V,k.startTime)});return g},XB=function(a,b,c){return _.y(function*(){var d=b.filter(f=>""!==(_.qg(f,_.mb)||""));if(0===d.length)return new Map;let e=[aC(a,d[0],c)];yield e[0];e=e.concat(d.slice(1).map(f=>aC(a,f,c)));d=yield Promise.all(e);return NA(d)})},YB=function(a,b,c,d){return _.y(function*(){const e=new Set;
|
|
35
|
+
var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(oA(f[k],_.ja));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield bC(a,h,c,d,e);f=f.map(k=>bC(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.wu,[])})},ZB=function(a,b,c){return Promise.all(b.map(d=>aC(a,d,c)))},$B=function(a,b){return Promise.all(b.map(c=>cC(a,c)))},VB=function(a,b){var c=_.qg(b,_.la,a.f.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=
|
|
36
|
+
_.Ju(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},WB=function(a,b){if(1===b.length)return b[0];a=_.Oh(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},aC=function(a,b,c){return _.y(function*(){const d=oA(b,_.mb);return dC(a,d,()=>_.y(function*(){const e=oA(b,_.Ca);var f={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.v,"CLOSED-CAPTIONS":_.v}[oA(b,"TYPE").toUpperCase()];if(!f)throw new _.H(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");const g=
|
|
37
|
+
c.get(e)||"",h=OA(b),k=_.qg(b,"NAME"),l=b.getAttribute("DEFAULT"),m=b.getAttribute("AUTOSELECT"),n=_.qg(b,"CHANNELS");return yield eC(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})}))})},cC=function(a,b){return _.y(function*(){const c=oA(b,_.mb);return dC(a,c,()=>_.y(function*(){var d=_.qg(b,_.la)||"jpg",e=OA(b);const f=_.qg(b,"NAME");d=yield eC(a,{uri:c,codecs:d,type:_.ed,language:e,
|
|
38
|
+
name:f,primary:!1,channelsCount:null,closedCaptions:null,groupId:null,ee:null});(e=_.qg(b,_.ja))&&sB(d,Number(e));return d}))})},bC=function(a,b,c,d,e){return _.y(function*(){var f=Number(oA(b,_.ja));if(null!=b.getAttribute("FRAME-RATE")||null!=b.getAttribute(_.Za)){var g=_.qg(b,"FRAME-RATE");var h=_.qg(b,_.Za),[k,l]=h?h.split("x"):[null,null];g={frameRate:qA(g),width:qA(k),height:qA(l)}}else g=null;if(h=yield fC(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=[];
|
|
39
|
+
for(const X of m)for(const na of g)if(m=(na?na.ea[0].ec:"")+" - "+(X?X.ea[0].ec:""),e.has(m))a.a.debug("Skipping variant which only differs in text streams.");else{a:{var n=a;var q=X,t=na,u=f;const tb=[],Jd=(t||q).length();for(let Pb=0;Pb<Jd;Pb++){var x=q?q.ea[Pb]||null:null,A=t?t.ea[Pb]||null:null,E=x,D=A;E=E&&D?_.Gu(E.drmInfos,D.drmInfos)?_.Fu(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:_.ye,primary:!!x&&x.primary||!!A&&
|
|
40
|
+
A.primary,audio:x,video:A,bandwidth:D,drmInfos:E,allowedByApplication:!0,allowedByKeySystem:!0};tb.push(x)}n=new gC(tb)}null==n?a.a.warn("Incompatible DRM info in HLS variant. Skipping."):(h.push(n),e.add(m))}f=h}else f=[];return f})},fC=function(a,b,c,d,e){return _.y(function*(){let f=VB(a,b);var g=_.qg(b,"AUDIO"),h=_.qg(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=oA(b,_.mb);var m=g.audio.find(q=>q.ec===l);
|
|
41
|
+
var n=_.Oh(_.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(gA),m=_.p,h=!0):g.video.length?(a.a.debug(gA),m=_.p):(a.a.debug("Guessing video-only"),m=_.w):(m=_.p,a.a.debug(gA));n=null;h||(n=yield hC(a,b,f,m,e,c));if(null==n)return null;g[m]=[n];m===_.p&&c&&k.forEach(q=>{pB(q,c.width);qB(q,c.height);rB(q,c.frameRate)});QA(g);return g})},hC=function(a,b,c,d,e,f){return _.y(function*(){const g=oA(b,_.mb);
|
|
42
|
+
return dC(a,g,()=>_.y(function*(){var h=_.qg(b,Rz);let k=null;d===_.w&&h&&"NONE"!==h&&(k=e.get(h));h=WB(d,c);return yield eC(a,{uri:g,codecs:h,type:d,closedCaptions:k,primary:!1,language:null,name:null,channelsCount:null,groupId:null,ee:f})}))})},dC=function(a,b,c){if(a.g.has(b))return a=a.g.get(b),Promise.resolve(a);if(a.g.a.has(b))return a.g.a.get(b)||null;c=c();a.g.set(b,c);return c},eC=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,
|
|
43
|
+
k=b.name,l=b.channelsCount,m=b.closedCaptions,n=b.ee;let q=wA(a.h,c);if(IB(a)&&a.w.has(q)){var t=a.w.get(q);a.w.delete(q)}else{const {response:X,text:na}=yield DB(a,q);q=X.uri;t=EB(a,na,q,c);MB(t,d,e)}if(1!==t.type)throw new _.H(_.G,4,4017);var u=AA(t.ca);OB(a,u);const x=LA(t.ca,u,a.f.hlsLowLatency||!1);u=yield NB(a,t,e,d);const A=a.f.hlsLowLatency?_.Ex:_.$t;let E=void 0;e===_.v&&(E=_.hu);const {Qc:D}=EA(t.ca);t=u.map(X=>{const na=X.V,tb=X.rf,Jd=X.mimeType;X=X.Eb;const Pb=na[0].startTime,Qa=na[na.length-
|
|
44
|
+
1].endTime,Fe=Qa-Pb,bb=new _.Hz(na),qa=na[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:A,initSegmentReference:qa,mimeType:Jd,codecs:d,kind:E,qe:tb.type,encrypted:tb.type===mA,keyId:tb.keyId,language:f||_.ye,label:k,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,
|
|
45
|
+
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:tb.keyInfo,V:na,drmInfos:tb.drmInfos,Eb:X,ec:c,cf:q,ub:Pb,bd:Qa,duration:Fe,Qc:D,groupId:g,Rf:x}});return new iC(t)})},RB=function(a){1===a.type&&a.V.slice(1).forEach(b=>{if(tA(b.ca,Yz))throw new _.H(_.G,4,4045,"Media playlist contains one or more EXT-X-MAP tags that are not located at the beginning of the playlist. This is valid, but not yet supported.");
|
|
46
|
+
})},jC=function(a,b,c){a=rA(a.ca,Yz);if(1<a.length)throw new _.H(_.G,4,4020);a=a[0];if(!a)return null;const d=oA(a,_.mb),e=wA(b,d);b=FA(a,null,!0);return new _.Ez(()=>[e],b.ta,b.ha,c)},kC=function(a,b,c,d,e,f,g){const h=[];for(const q of _.Du(b.f)){b=q.xd;const t=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.qg(t,"DURATION"));n=m+n;k=FA(t,k?null:l.ha,k);l=_.qg(t,_.mb);const u=(l=wA(g,l))?[l]:[];m=new GA(c,m,n,()=>u,k.ta,k.ha,e,f,!1,null,null,null,null);if("YES"===_.qg(t,"INDEPENDENT")||
|
|
47
|
+
0===b)m.g=!0;h.push(m)}}return h},lC=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ca;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}=DA(n),a=e+c,q=CA(n,b?b.ha:null)):(b=kC(b,c,d,e,f,g,k),a=b[b.length-1].endTime,x=b);h=h===_.ed?vA(n):null;d=new GA(d,e,a,()=>u,q.ta,q.ha,f,g,!1,null,h?h.ve:null,h?h.Ve:null,h?h.durationPerTile:null,x);d.Eb=l;d.initSegment=m||void 0;return d},TB=function(a,b,c,d,e,f,g){return _.y(function*(){var h=
|
|
48
|
+
d[0];if(null!=a.B)return a.B;const k=yield mC(a,f,g,h);var l=hB([h],a.h,k,null)[0];const m=jC(h,b,l.keyInfo);l=IA(l.keyInfo,e);h=yield nC(a,c,m,h,e,l,k,g);a.a.debug(`Setting playlist start time to ${h}.`);return a.B=h})},UB=function(a,b,c,d,e,f,g,h,k,l){return _.y(function*(){var m=d[0],n=null==l;const q=yield mC(a,h,k,m);var t=hB(d,a.h,q,l?l.Qf:null);const u=t[t.length-1];t=iB(t);const x=jC(m,c,t.keyInfo)||(l?l.Lf:null);var A=IA(t.keyInfo,f);m=n&&IB(a)?0:yield oC(a,e,b,x,m,f,A,q,k,g);n=[];for(A=
|
|
49
|
+
0;A<d.length;A++){var E=d[A];const D=n[n.length-1]||null,X=0===A?g:D.endTime,na=f+A,tb=IA(t.keyInfo,na);(E=lC(a,D,E,na,X,m,tb,h,c,e,x))&&n.push(E)}return{V:n,rf:t,Qf:u,mimeType:q,endTime:n[n.length-1].endTime,Eb:e,Lf:x}})},mC=function(a,b,c,d){return _.y(function*(){const e=d.a;var f=uA(d.ca,Yz);f=f?oA(f,_.mb):null;return pC(a,b,c,e,f)})},nC=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=oB(k,e))?k.startTime:null:null;if(null!=k)return a.a.debug("Found segment start time in previous manifest"),
|
|
50
|
+
k;a.a.debug("Unable to find segment start time in previous manifest!");k=HA(d,f);return mB(a.M,c,k,g,h,null!=f)})},IB=function(a){return a.m===_.Tt},oC=function(a,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 nC(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})},pC=function(a,b,c,d,e){return _.y(function*(){const f=[d,e].filter(Boolean);var g=_.Rh(f,b,c);if(g)return g;g=_.kh([d],a.f.attemptParameters);g.method=
|
|
51
|
+
"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]})},JB=function(a,b,c){a.f=b;b=c[0];const d=JA(b);a.offset(-d.ub);yA(b,e=>{e.segmentIndex.offset(-d.ub);_.kv(e.segmentIndex,d.duration)})},FB=class{constructor(a,b,c,d){if(1===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=
|
|
52
|
+
a;this.a="";this.type=b;this.ca=c;this.V=1===b?d:null}},TA=class{constructor(a,b,c){c=void 0===c?[]:c;this.ca=b;this.a=a;this.f=c}},GA=class extends _.fv{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:m,void 0===n?null:n,void 0===q?null:q,t);this.initSegment=void 0;this.Eb=0}},RA=[Vz,Wz,"EXT-X-I-FRAMES-ONLY",Zz,$z,aA,cA,eA],QB=["EXTINF",Tz,"EXT-X-DATERANGE",Uz,Xz,Yz,"EXT-X-PROGRAM-DATE-TIME"],SA=["EXT-X-PART",
|
|
53
|
+
bA],qC=class{constructor(){this.a=0}},rC=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();this.f.clear()}},SB=new _.O("clpp.hls.DiscontinuityUtils");var kB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Je)throw new _.H(_.G,4,4041);if(oA(a,hA)===kA)throw new _.H(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.zu(_.Ic,[{initDataType:_.he,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":cB,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":cB,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=oA(a,hA);if(!aB.includes(b))return bB.error("Widevine in HLS is only supported with [",
|
|
54
|
+
aB.join(", "),"], not",b),null;b=oA(a,_.mb);b=_.go(b);b=_.I(b.data);b=_.zu(_.Kc,[{initDataType:_.tc,initData:b}],"");if(a=_.qg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},aB=["SAMPLE-AES",kA],bB=new _.O("clpp.hls.DrmParser");var jB=new _.O("clpp.hls.EncryptionUtils");var sC=class{constructor(a){this.f=new _.O("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.hh()}}};var iC=class{constructor(a){this.ea=a}length(){return this.ea.length}};var gC=class{constructor(a){this.a=a}length(){return this.a.length}};var tC=class{constructor(){this.f=this.D=null;this.I=1;this.g=new rC;this.h="";this.K=new qC;this.H=0;this.A=new Map;this.j=new _.Zh(()=>{this.xb()});this.m=_.Tt;this.C=null;this.o=new _.Uo;this.B=null;this.a=new _.O("clpp.hls.HlsParser");this.w=new Map;this.G=new Map;this.M=new sC(this.F.bind(this));this.J=!1}configure(a){this.f=a;this.M.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&&tB(c,b)||null!=a&&tB(c,
|
|
55
|
+
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 DB(c,a);c.h=d.uri;const f=yield KB(c,e);c.C=f;const g=c.H;0<g&&c.j.$(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;
|
|
56
|
+
return _.y(function*(){var b=a.C;if(!IB(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 PB(a,e[0],c,b);for(f=1;f<e.length;f++)d.push(PB(a,e[f],c,b));yield Promise.all(d)}})}xb(){const a=this;return _.y(function*(){a.a.debug(_.St);if(a.D)try{yield a.update(),a.j.$(a.H)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.j.$(.1))}})}F(a){if(!this.o)throw new _.H(_.G,
|
|
57
|
+
7,7001);a=this.D.networkingEngine.fetch(a);_.rh(this.o,a);return a.P}};_.z("clpp.hls.HlsComponent",class extends _.Mp{constructor(){super()}f(){_.Kn.m3u8=tC;_.In[_.Vi]=tC;_.In[lA]=tC}a(){_.nv("m3u8");_.ov(_.Vi);_.ov(lA)}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 IJ=function(a){a.a.one(a.l,_.nd,()=>HJ(a))},HJ=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Nb,d=>JJ(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{JJ(a,{track:d})});!KJ(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."),LJ(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.")},JJ=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=>MJ(a,c)))},KJ=function(a){return a.some(b=>b.kind===_.td)},LJ=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,_.Nb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Nb,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
|
+
MJ=function(a,b){const c=NJ(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 OJ(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Jg(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)}}})},NJ=function(a){return(a=a.l.getTrackManager().oa())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
OJ=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(_.qf(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=_.qf(a)?a:null}}};var PJ=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.uo;this.h=(a=_.io[_.Zb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;IJ(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var QJ=class extends _.kq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.mi()){var b=a.getConfiguration();b=_.lf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.ic&&(b.patchMetadataTrack=!1);_.rf(b.timestampOffset)||(b.timestampOffset=0);this.a=new PJ(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",QJ);
|
|
5
|
+
QJ.Id="hlssmpte";_.Sm(new class{create(){return new QJ}});};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 _.xo:return _.uc;case _.de:case _.de:return _.md}return a.f.positionAlign},
|
|
7
|
-
["+y","-y"];break;case _.Ge:a=["+x","-x"];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:_.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 _.
|
|
12
|
-
else{
|
|
13
|
-
c;for(;0<=d-1&&
|
|
14
|
-
a)}px`},
|
|
15
|
-
d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(
|
|
16
|
-
_.
|
|
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 _.
|
|
23
|
-
new _.
|
|
24
|
-
this;return _.
|
|
25
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var AI="Unsupported unit",BI="clpp-text-plain",CI="clpp-text-ttml",DI="clpp.htmlcue.HtmlTextDisplayer",EI="initial",FI=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},GI=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},II=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>HI[c]);return a},KI=
|
|
2
|
+
function(a,b){JI(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{JI(a,c)})},JI=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},LI=function(a,b){return 0===a?"0":a+b},MI=function(a,b){return 1>Math.abs(a-b)||a<b},NI=function(a,b){return a<b&&1<Math.abs(a-b)},OI=function(a,b){return a>b&&1<Math.abs(a-b)},PI=function(a,b){return 1>Math.abs(a-b)||a>b},RI=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 QI(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},SI=function(a){return new QI(a.f,a.g,a.h,a.a,a.height,a.width)},TI=function(a,b){return b.some(c=>NI(a.f,c.g)&&OI(a.g,c.f)&&NI(a.h,c.a)&&OI(a.a,c.h))},UI=function(a,b){return PI(a.h,
|
|
4
|
+
b.h)&&MI(a.a,b.a)&&PI(a.f,b.f)&&MI(a.g,b.g)},VI=function(a,b,c){switch(c){case "+x":return NI(a.f,b.f);case "-x":return OI(a.g,b.g);case "+y":return NI(a.h,b.h);case "-y":return OI(a.a,b.a);default:throw Error("Unknown axis");}},WI=function(a){return a.f.writingMode===_.yo},XI=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 WI(a)?b:c},YI=function(a){switch(a.f.writingMode){case _.yo:return"horizontal-tb";case _.Ge:return _.Ge;
|
|
5
|
+
case _.Ie:return _.Ie;default:throw Error("Unknown writing mode");}},ZI=function(a){switch(a.f.positionAlign){case _.ld:return _.id;case "auto":case _.uc:return _.xo;case _.md:return _.de}return a.f.textAlign},$I=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 _.uc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},aJ=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},dJ=function(a,b,c){return(bJ(a)||cJ(a))&&_.rf(c)?LI(c,_.Xd):bJ(a)&&_.B(c)?LI(0,_.Xd):WI(a)&&_.rf(b)?LI(b,"%"):EI},eJ=function(a,b,c){return WI(a)&&_.rf(c)?LI(c,_.Xd):(bJ(a)||cJ(a))&&_.rf(b)?LI(b,"%"):EI},cJ=function(a){return a.f.writingMode===_.Ie},bJ=function(a){return a.f.writingMode===_.Ge},fJ=function(a,b){if(a.h)switch(b.writingMode){case _.yo:return["-y"];case _.Ge:return["+x"];case _.Ie:return["-x"]}a=[];switch(b.writingMode){case _.yo:a=
|
|
7
|
+
["+y","-y"];break;case _.Ge:a=["+x","-x"];break;case _.Ie:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},gJ=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=RI(a.j.a)},hJ=function(a,b){gJ(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},iJ=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(AI);},kJ=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);jJ(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},lJ=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)},mJ=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},nJ=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},jJ=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())},oJ=function(a){a=_.lf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},uJ=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=pJ(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,qJ(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 _.Pe:g="clpp-text-vtt";break;case _.xe:g=CI;break;case _.wo:g=BI}g&&!f.classList.contains(g)&&_.mm(f,g);f=RI(c.a.a);if(0===f.width||0===f.height)c.M.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{JI({fontSize:rJ(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Pe;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 sJ(d.region,{}),c.A.set(d.region.id,f),hJ(c.a,f)));d=new tJ(d,c.K,e);f?hJ(f,d):hJ(c.a,d)}}}}},vJ=function(a){qJ(a);a.I=null;a.m=null;a.f=[]},wJ=function(a,b){return a.startTime<=b&&a.endTime>b},pJ=function(a,b){var c=FI(a.f,d=>wJ(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&&wJ(a.f[d-1],b);)d--;for(;c+1<a.f.length&&wJ(a.f[c+1],b);)c++;return{start:d,end:c}}},qJ=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(CI);b.classList.remove(BI);a=a.a;gJ(a.g);a.j=[]}},rJ=function(a,b){const c=RI(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`},AJ=class{parse(a){a={input:a};const b=_.om(_.Qc),c=[];let d=b;for(var e;null!==(e=GI(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=xJ[f];h?(h=_.om(h),(f=yJ[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||zJ[g.localName]&&zJ[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(II(e)));return b}},xJ={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},yJ={v:"voice",lang:"lang"},zJ={rt:"ruby"},HI={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var QI=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 BJ=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 tJ=class extends BJ{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
|
+
_.Pe?b=(new AJ).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);JI({writingMode:YI(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}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.zo,this.f.line=WI(this)?-1:0);e=YI(this);JI({writingMode:e,webkitWritingMode:e,direction:EI,textAlign:ZI(this)},this.a);if(!this.f.region||
|
|
17
|
+
!this.f.region.displayAlign){e=$I(this,aJ(this));JI({position:"absolute",left:dJ(this,e,null),right:cJ(this)&&_.B(null)?LI(0,_.Xd):EI,top:eJ(this,e,null),width:WI(this)?LI(this.f.size,"%"):EI,height:bJ(this)||cJ(this)?LI(this.f.size,"%"):EI},this.a);b=this.f;a=WI(this)?a.height:a.width;c=XI(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)}cJ(this)&&(f=a-f-c);a=f;JI({left:dJ(this,e,a),right:cJ(this)&&_.B(a)?LI(0,_.Xd):EI,top:eJ(this,e,a)},this.a)}KI(this.B,d)}}m(){return _.om(_.Qc)}};var CJ=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=RI(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=RI(a.a);var d=fJ(this,a.f),e=XI(a);const g=SI(c);let h=null,k=0;for(const l of d){for(;VI(c,this.a,l)||UI(c,this.a)&&TI(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||UI(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=SI(c),k=d);c=SI(g)}c=h||g}JI({top:LI(c.h-this.a.h,_.Xd),bottom:LI(this.a.a-c.a,_.Xd),left:LI(c.f-this.a.f,_.Xd),right:LI(this.a.g-c.g,_.Xd),height:LI(c.height,_.Xd),width:LI(c.width,_.Xd)},a.a)}b.style.visibility="visible";this.g.push(RI(a.a))}};var DJ=class extends BJ{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new CJ(this);this.h=!0}m(){const a=_.om(_.Qc);_.mm(a,this.o);this.id&&(a.id=this.id);return a}};var sJ=class extends DJ{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(AI);}}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(AI);d=a.height;const e=iJ(this,d,a.height);JI(this.A,this.a);JI({left:LI(c,_.Xd),top:LI(e,_.Xd),width:LI(b,
|
|
20
|
+
_.Xd),height:LI(d,_.Xd)},this.a);this.f.writingMode&&JI({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&JI({"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 tJ(new _.Co(0,1,"Lorem ipsum",_.wo),{},{});b=c.a;this.a.appendChild(b);c.init(RI(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
21
|
+
b=c;f*=b;break a;default:throw Error(AI);}a=iJ(this,f,a.height);JI({top:LI(a,_.Xd),height:LI(f,_.Xd)},this.a);this.g=new CJ(this,!0);this.h=!0}getId(){return this.f.id}};var EJ=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=kJ(this,this.h,this.j);this.g=kJ(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=lJ(this,a);if(mJ(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=[],nJ(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 FJ=class extends _.hq{constructor(a){super(a);this.M=new _.O(DI);this.l=a;this.K=oJ(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new EJ(a,"CLPP Subtitle Styles");this.a=new DJ(null,"clpp-text-container",{});this.w=new _.cq(a.getSurface(),this.U.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.M.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
|
|
23
|
+
new _.Zh(()=>{uJ(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;uJ(this,!1)}}g(){null==this.h||uJ(this,!0)}destroy(){const a=
|
|
24
|
+
this;return _.y(function*(){null!=a.h&&(vJ(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;uJ(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(),uJ(this,!0)):(this.F.stop(),this.w.stop(),vJ(this)))}U(){uJ(this,!0)}};_.z(DI,FJ);
|
|
25
|
+
FJ.prototype.setTextVisibility=FJ.prototype.setTextVisibility;FJ.prototype.isTextVisible=FJ.prototype.isTextVisible;FJ.prototype.remove=FJ.prototype.remove;FJ.prototype.destroy=FJ.prototype.destroy;FJ.prototype.append=FJ.prototype.append;var GJ=class{ba(a){return!!a.enableHtmlCue&&!_.oi()}create(a){return new FJ(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Mp{f(){_.wl("html",new GJ)}a(){}id(){return _.qe}});};f.call(g, window);
|