@castlabs/prestoplay 6.25.2 → 6.27.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 +38 -0
- package/README.md +5 -5
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +7 -7
- package/cjs/cl.cast.js +115 -114
- package/cjs/cl.conviva.js +32 -32
- package/cjs/cl.core.js +620 -620
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +89 -88
- package/cjs/cl.externs.js +89 -51
- package/cjs/cl.freewheel.js +25 -25
- package/cjs/cl.hls.js +79 -77
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +24 -24
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +351 -336
- package/cjs/cl.muxdata.js +15 -15
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +15 -15
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.sessions.js +16 -16
- package/cjs/cl.simid.js +17 -17
- package/cjs/cl.smooth.js +72 -72
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +73 -72
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +12 -12
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.yospace.js +4 -4
- package/cjs/cl.youbora.js +39 -37
- package/cjs/polyfill.min.js +15 -3
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +5 -5
- package/cl.cast.js +92 -90
- package/cl.conviva.js +27 -27
- package/cl.core.js +496 -500
- package/cl.crypto.js +9 -9
- package/cl.dash.js +82 -82
- package/cl.externs.js +89 -51
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +80 -80
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +17 -17
- package/cl.mediatailor.js +3 -3
- package/cl.mse.js +305 -294
- package/cl.muxdata.js +13 -13
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +11 -11
- package/cl.playlist.js +5 -5
- package/cl.sessions.js +10 -10
- package/cl.simid.js +14 -14
- package/cl.smooth.js +60 -60
- package/cl.thumbnails.js +19 -19
- 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.yospace.js +3 -3
- package/cl.youbora.js +29 -28
- package/package.json +3 -3
- package/typings.d.ts +124 -3
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 _.I(1,9,12001,{missingKeys:b.join(", ")});},
|
|
3
|
-
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.
|
|
4
|
-
a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},
|
|
5
|
-
!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return
|
|
6
|
-
0}getPosition(){return 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.w&&(a.w.stop(),a.w=null);
|
|
15
|
-
9,10003,{errorType:0},void 0));this.A.resolve()}M(a){
|
|
16
|
-
_
|
|
17
|
-
_.
|
|
18
|
-
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();
|
|
19
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var bV="clpp-freewheel",cV="clpp.freewheel.AdsManagerFactory",dV="freewheel",eV=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""}},fV=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Qf&&b.push("serverUrl");typeof a.profileId!==_.Qf&&b.push("profileId");typeof a.videoAssetId!==_.Qf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
|
|
2
|
+
if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},gV=function(){return _.w(function*(){var a=new _.Av;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})},hV=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
|
|
3
|
+
tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.cg,a.I.bind(a));a.j.on(a.m,_.Nf,a.H.bind(a))},kV=function(a){return _.w(function*(){a.G.length?(iV(a),a.f=a.G.shift(),a.f.play()):(jV(a),yield a.m.a.play())})},jV=function(a){const b=a.m.cd(dV).Ic();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},iV=function(a){const b=a.m.cd(dV).Ic();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(bV),
|
|
4
|
+
a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},lV=function(a){a.F.length?(iV(a),a.f=a.F.shift(),a.f.play()):jV(a)},mV=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.m.trigger(new _.C(b,d))},nV=class extends _.Iv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Lp(_.Dd,{id:bV}),this.f=_.Lp(_.t,{"class":_.Zc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
|
|
5
|
+
!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return dV}Ic(){return this.a}oh(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",nV);nV.prototype.getAdVideo=nV.prototype.oh;nV.prototype.getAdContainer=nV.prototype.Ic;nV.Id=dV;nV.AD_CONTAINER_ID=bV;_.fs(new class{create(){return new nV}});var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}kb(){return"FreeWheel AdManager SDK"}lb(){return tv.freewheel.SDK.version}rb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Qf?a:""}Mb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
|
|
6
|
+
0}getPosition(){return 0}getSkipTimeOffset(){return 0}Pb(){return!1}nb(){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():""}bb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ab(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Na(){return 0}Oa(){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.Oa()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Eb(){switch(this.Oa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}pb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}cb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Ob(){return null}};
|
|
8
|
+
X.prototype.getVideoElement=X.prototype.Ob;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.cb;X.prototype.getPositionInSequence=X.prototype.pb;X.prototype.getPodTimeOffset=X.prototype.Eb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Oa;
|
|
9
|
+
X.prototype.getMediaBitrate=X.prototype.Na;X.prototype.getMediaHeight=X.prototype.ab;X.prototype.getMediaWidth=X.prototype.bb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.nb;X.prototype.isBumper=X.prototype.Pb;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getPosition=X.prototype.getPosition;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;
|
|
10
|
+
X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getSourceId=X.prototype.Mb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.rb;X.prototype.getAdManagerVersion=X.prototype.lb;X.prototype.getAdManagerName=X.prototype.kb;var oV=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()}})}Gb(){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
|
+
oV.prototype.hasPostroll=oV.prototype.Fb;oV.prototype.hasPreroll=oV.prototype.Gb;oV.prototype.getCuePoints=oV.prototype.getCuePoints;var pV=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.Kt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.xk;this.w=null}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{fV(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Qf&&typeof b.siteSectionId!==
|
|
12
|
+
_.r||a.a.setSiteSection(b.siteSectionId);const c=yield gV();a.a.setVideoAsset(b.videoAssetId,a.m.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,eV(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Fe&&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);hV(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.w(function*(){yield kV(a)})}o(){}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}l(){return!0}h(){const a=this;return _.w(function*(){a.j.release();
|
|
14
|
+
a.w&&(a.w.stop(),a.w=null);jV(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.C(_.pc,{adsTimeline:new oV(this.a)})),this.w=new _.yv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.cd(dV).f);else this.m.onError(new _.I(1,
|
|
15
|
+
9,10003,{errorType:0},void 0));this.A.resolve()}M(a){mV(this,_.Sb,a);this.w.start()}L(a){this.f=null;a=a.slot;mV(this,_.Tb);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:kV(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:jV(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:lV(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:mV(this,_.kc,a);mV(this,
|
|
16
|
+
_.ac,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:mV(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:mV(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:mV(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:mV(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:mV(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:mV(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:mV(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:mV(this,
|
|
17
|
+
_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:mV(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:mV(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:mV(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(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]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
|
|
18
|
+
.5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();iV(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.sp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.rp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.hp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);lV(this);break;case _.pp:case _.ip:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
|
|
19
|
+
pV.prototype.getPosition=pV.prototype.getPosition;pV.prototype.setVolume=pV.prototype.setVolume;pV.prototype.getVolume=pV.prototype.getVolume;pV.prototype.skip=pV.prototype.skip;pV.prototype.pause=pV.prototype.pause;pV.prototype.resume=pV.prototype.resume;_.Jp(new class{constructor(){this.Qa=new _.S(cV)}name(){return cV}a(a,b){return a.namespace()!==_.ed&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Qa.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new pV(a)}});};f.call(g, window);
|
package/cl.hls.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
_.
|
|
5
|
-
b
|
|
6
|
-
if(a.value===_.
|
|
7
|
-
Number(d[1]),0>d)throw new _.I(_.
|
|
8
|
-
null}},
|
|
9
|
-
|
|
10
|
-
a.video.
|
|
11
|
-
return b},
|
|
12
|
-
new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,_.
|
|
13
|
-
return c})},
|
|
14
|
-
c,d,g);return new
|
|
15
|
-
a.a.get(e);if(null==f)throw new _.I(_.
|
|
16
|
-
f,g));return e},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
g
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
d)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
_.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if(
|
|
62
|
-
|
|
63
|
-
b){return _.
|
|
64
|
-
b
|
|
65
|
-
|
|
66
|
-
g,!1,null,h?h.
|
|
67
|
-
|
|
68
|
-
m);n=[n,...
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
n,void 0===
|
|
73
|
-
null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},
|
|
74
|
-
|
|
75
|
-
c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield
|
|
76
|
-
b){var c=b.presentationTimeline;"LIVE"===a.A&&(a.C=null);var d=Array.from(a.j.values());if(a.a.lowLatencyMode&&null!==a.o){const g=
|
|
77
|
-
a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.
|
|
78
|
-
k);return
|
|
79
|
-
c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.
|
|
80
|
-
_.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var JJ="CLOSED-CAPTIONS",KJ="Could not parse MP4 segment start time.",LJ="DURATION",MJ="EXT-X-DATERANGE",NJ="EXT-X-DISCONTINUITY",OJ="EXT-X-KEY",PJ="EXT-X-MAP",QJ="EXT-X-MEDIA",RJ="EXT-X-MEDIA-SEQUENCE",SJ="EXT-X-PROGRAM-DATE-TIME",TJ="EXT-X-STREAM-INF",UJ="Failed to infer discontinuity number",VJ="Guessing audio-only",WJ="METHOD",XJ="SAMPLE-AES-CTR",YJ="SUBTITLES",ZJ="_HLS_part",$J="application/vnd.apple.mpegurl",aK="manifestloaded",bK="sample",cK=function(a,b){return _.J(a,b,void 0,
|
|
2
|
+
{required:!0})},dK=function(a){if(1>a.a)throw _.xm();--a.a},eK=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Fe&&e&&typeof e===_.Fe){if(!eK(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},fK=function(a,b){if(!eK(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Fe&&e&&typeof e===_.Fe&&fK(d,e))return!0}return!1},gK=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Wf:b,
|
|
3
|
+
item:d,Zh:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{Wf:b,Zh:c,item:d,next:void 0})},hK=function(a){if(null!==a&&void 0!==a)return Number(a)},iK=function(a,b){return a.filter(c=>c.name===b)},jK=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.Ta),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);
|
|
4
|
+
if(!b.test(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},kK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=cK(d,_.sb);return c.includes(d)})},lK=function(a,b){return a.some(c=>c.name===b)},mK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.F,4,4024,{missingTag:b});return a},nK=function(a){var b=mK(a,"EXT-X-TILES");if(!b)return{fd:1,Bd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,
|
|
5
|
+
LJ);a=_.nC(a);return{fd:a.fd,Bd:a.Bd,durationPerTile:b?Number(b):null}},oK=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)},pK=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of oK(c))b(d,c)})},qK=function(a){return a.some(b=>lK(b.ba,"EXT-X-ENDLIST"))},rK=function(a){return a.type===_.q||a.type===_.t},sK=function(a){if(mK(a,"EXT-X-ENDLIST"))return _.Db;
|
|
6
|
+
a=mK(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.I(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},tK=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.H,"CLOSED-CAPTIONS":_.H}[a.toUpperCase()];if(!a)throw new _.I(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},uK=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 _.I(_.F,4,4044,"Byte range length must be positive.");
|
|
7
|
+
if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ma:d,ja:e}},vK=function(a,b){a=mK(a,"EXT-X-BYTERANGE");return uK(a?a.value:null,b)},wK=function(a){a=mK(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.F,
|
|
8
|
+
4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},xK=function(a,b){b=void 0===b?{}:b;const c={Af:!1,Yg:!1,Zg:null,Ch:null,lg:null};a=mK(a,"EXT-X-SERVER-CONTROL",{required:b.rg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Af="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.Yg="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.Zg=d(_.J(a,"CAN-SKIP-UNTIL"));c.Ch=d(_.J(a,"HOLD-BACK"));c.lg=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.rg}));return c},yK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");
|
|
9
|
+
return uK(a,b,c)},zK=function(a){const b=iK(a,QJ),c=iK(a,TJ);a=iK(a,"EXT-X-IMAGE-STREAM-INF");return{wc:{vf:kK(b,[_.kB,_.Cb]),closedCaptions:kK(b,JJ),yi:kK(b,YJ)},Cd:c,ze:a}},BK=function(a,b){const c=vK(a.ba,null);return new AK(0,0,0,()=>[a.a],c.ma,c.ja,0,b)},CK=function(a){let b=Infinity,c=Infinity;oK(a).filter(rK).forEach(d=>{{d=d.S;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{Oc:b,duration:c}},DK=function(a){return a.map(b=>{({duration:b}=
|
|
10
|
+
CK(b));return b}).reduce((b,c)=>b+c,0)},EK=function(a){return(a.video?a.video.Ca:"")+" - "+(a.audio?a.audio.Ca:"")},FK=function(a,b,c,d,e){if(b===_.Db)return{delay:0,zd:0};b=mK(a,"EXT-X-PART-INF");if(c&&b){e=Number(cK(b,"PART-TARGET"));if(null!=d)return{delay:d,zd:e};({lg:d}=xK(a,{rg:!0}));return{delay:d,zd:e}}a=mK(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,zd:e}:{delay:3*a,zd:e}},HK=function(a){const b=new Map;a.forEach(c=>{var d=`${GK(c).type}:${GK(c).groupId}`;
|
|
11
|
+
b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},IK=function(a){const b=new Map;for(const c of a){a=_.J(c,_.La);a=_.$i(a||_.hg);const d=cK(c,_.Fa),e=cK(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},JK=function(a){return a.filter(b=>"mp4a.40.34"!==b)},KK=function(a,b){if(!a)return null;const c=a.Ca;return b.find(d=>GK(d).Ca===c)||null},LK=function(a){return(a=_.J(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},MK=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?
|
|
12
|
+
1:0},NK=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,_.Ta),g=_.J(e,"QUERYPARAM");if(f)g=cK(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.I(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},OK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.F,
|
|
13
|
+
4,4044,`Undefined variable '${d}'`);return c})},PK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=OK(d.value,b)})})},SK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=QK(a,b[e]);d.push(f);if(f.name===TJ){const g=b[e+1];if(!g)throw new _.I(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.ej(_.ub,g));e++}}b=iK(d,"EXT-X-DEFINE");jK(b);b=NK(b,c);a.a=b;PK(d,a.a);return new RK(c,0,d)},WK=function(a,b,c){const {ji:d,Bh:e,Hi:f}=TK(b),g=UK(a,f,
|
|
14
|
+
c);b=e.map(k=>QK(a,k,g));const h=VK(a,c,d,g);return new RK(c,1,b,h)},XK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.F,4,4015);b=b.slice(1);return 0===MK(b)?SK(a,b,c):WK(a,b,c)},TK=function(a){const b=[],c=[],d=[];for(const e of a)YK.test(e)?d.push(e):ZK.test(e)?c.push(e):b.push(e);return{ji:b,Bh:c,Hi:d}},UK=function(a,b,c){b=b.map(e=>QK(a,e));jK(b);const d=NK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>
|
|
15
|
+
{const f=a.a.get(e);if(null==f)throw new _.I(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},QK=function(a,b,c){a=_.gj(a.h++,b);c&&PK([a],c);return a},VK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=QK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.J(h,_.sb)?g.push(h):f.push(h)):(lK(f,"EXT-X-GAP")||(h=OK(h,d),h=_.Ti(h,b),e.push(new $K(h,f,g))),f=[],g=[])});0<g.length&&e.push(new $K(null,
|
|
16
|
+
f,g));return e},aL=function(a,b,c){const d=[],e=[];e.push(new _.ej(_.ma,"0"));e.push(new _.ej(_.ub,b));c.length&&e.push(new _.ej(_.pa,c));d.push(new _.fj(a.h++,TJ,e));return new RK(b,0,d)},bL=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},cL=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},dL=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},eL=function(a){function b(h,
|
|
17
|
+
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 _.I(_.F,4,4030);}dL(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),
|
|
18
|
+
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}}dL(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},fL=function(a,b){let c=null,d=0;try{(new _.Nm).N(_.Be,_.Gm).N(_.eg,_.Gm).N(_.te,_.Gm).fa("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.O(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Cv.error("Unable to find timescale in init segment!"),new _.I(_.F,4,4030,KJ,c);let e=0,f=!1;try{(new _.Nm).N("moof",_.Gm).N("traf",_.Gm).fa("tfdt",
|
|
19
|
+
g=>{var h=d;if(0===g.version)h=_.O(g.reader)/h;else{{const k=_.O(g.reader),l=_.O(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.F,4,4030,KJ,c);return e},gL=function(a){for(;a.getPosition()<a.Ma()-1;){const b=a.getPosition();if(71===_.ym(a))return dK(a),b}return-1},hL=function(a){function b(){d.seek(e+
|
|
20
|
+
188);f=_.ym(d);71!==f&&(d.seek(e+192),f=_.ym(d));71!==f&&(d.seek(e+204),f=_.ym(d));71!==f&&c();dK(d)}function c(){throw new _.I(_.F,4,4030);}const d=new _.Jn(new DataView(a),!1);let e=0,f=0;e=gL(d);0>e&&(_.Cv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.ym(d);71!==f&&c();a=_.zm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.ym(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.ym(d),d.skip(a));if(1!==_.O(d)>>8){b();continue}d.skip(3);a=_.ym(d)>>
|
|
21
|
+
6;0!==a&&1!==a||c();0===_.ym(d)&&c();a=_.ym(d);const g=_.zm(d),h=_.zm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},kL=function(a){const b=iL(a),c=jL(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.ra===b);let g=e.findIndex(h=>h.ra===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},jL=function(a){a=a.map(b=>b.S[b.S.length-1].ra);return Math.min(...a)},iL=function(a){a=a.map(b=>b.S[0].ra);return Math.max(...a)},nL=function(a){var b=cK(a,WJ);if(!lL.includes(b))return mL.error("PlayReady in HLS is only supported with [",
|
|
22
|
+
lL.join(", "),"], not",b),null;a=cK(a,_.ub);b=_.Gk(a);a=null;b=_.G(b.data);try{a=_.XB(_.Qn(b))}catch(c){a=b}return _.jC(_.sd,[{initDataType:_.Uc,initData:a}],"")},pL=function(a){if(0===a.length)return oL();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Ee))return a[0];a=a.filter(c=>c.type===bK);const b=_.hi(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:bK,drmInfos:b}},sL=function(a,b){return qL(a).map(c=>rL(c.ba,b)).filter(Boolean)},qL=function(a){return a.filter(b=>
|
|
23
|
+
lK(b.ba,OJ))},rL=function(a,b){a=iK(a,OJ).filter(d=>"AES-128"!==cK(d,WJ));if(0===a.length)return null;var c=cK(a[0],WJ);if(1===a.length&&"NONE"===c)return oL();c=a.map(d=>cK(d,WJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===XJ))throw tL.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.F,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.J(d,"KEYFORMAT","identity");{const f=uL[e]||null;d=f?f(d,b):null}d||tL.warn("Unsupported HLS KEYFORMAT",
|
|
24
|
+
e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.F,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:bK,drmInfos:a}},oL=function(){return{type:_.Ee,drmInfos:[],keyId:null}},vL=function(a,b,c){a=iK(a,OJ)[0];if(!a||"AES-128"!==cK(a,WJ))return null;var d=_.J(a,"IV","");d?c={iv:_.Ck((d||"0x").slice(2)),generatedIv:!1}:(d=_.J(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Fk(new Uint8Array(12),cL(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
|
|
25
|
+
generatedIv:f}=c;return{method:"AES-128",url:_.Ti(cK(a,_.ub),b),iv:e,generatedIv:f}},wL=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.UC(b.Da(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.UC(b.Da(),b.ma,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
|
|
26
|
+
e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.F,4,4030,"Failed to fetch the media segment.");}}})},xL=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Fc||d===_.Ec)return 0;if(d===_.Dc){var g=yield wL(a,c,f);g=_.G(g.data);if(!dL(g))throw new _.I(_.F,4,4030,"AAC segment does not contain an ID3 tag.");return eL(g)}if(d===_.tg||d===
|
|
27
|
+
_.Gc)return g=[wL(a,c,f)],b&&g.push(wL(a,b,!0)),g=yield Promise.all(g),fL(g[0].data,(g[1]||g[0]).data);if(d===_.sg)return g=yield wL(a,c,f),hL(g.data);if(!_.dt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.F,4,4030);})},yL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},zL=function(a,b){a=a.streams.find(c=>{c=c.S;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.S.find(c=>c.position===b)||null},GK=function(a){return a.streams[0]},
|
|
28
|
+
AL=function(a,b){a.streams.forEach(c=>{c.ke=b})},BL=function(a,b){a.streams.forEach(c=>{c.width=b})},CL=function(a,b){a.streams.forEach(c=>{c.height=b})},DL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},EL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},FL=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},GL=function(a,b){const c=new Set(a.map(d=>d.ra));return b.filter(d=>!c.has(d.ra))},IL=function(a,b){for(;a[0].ra<b[0].ra;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
|
|
29
|
+
d.startTime&&c.endTime===d.endTime||HL(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&HL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},NL=function(a,b,c,d,e){var f=b[0].length();f=bL(f).map(g=>{var h=FL(b,g)||[];const k=yL(c,g)||[];g=yL(d,g)||[];{const l=[...JL(h),...k,...g].filter(Boolean);KL(l);const {ra:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ra:m}}return h});e&&LL(f[0]);
|
|
30
|
+
ML(f);return f},JL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},LL=function(a){const b=JL(a.variants)[0].S[0].Ba;a.startTime+=b;a.endTime+=b},ML=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},HL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;OL(a.variants,b.variants);PL(oK(a),oK(b))},OL=function(a,b){const c=new Map(a.map(d=>[EK(d),
|
|
31
|
+
d]));b.forEach(d=>{c.get(EK(d)).drmInfos=d.drmInfos})},PL=function(a,b){const c=new Map(a.map(d=>[d.Ca,d]));b.forEach(d=>{const e=c.get(d.Ca);e.S=d.S;d.S.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.S);e.Oc=d.Oc;e.Ce=d.Ce;e.duration=d.duration;e.Jf=d.Jf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},KL=function(a){const b=QL(a);a.forEach(c=>{_.QC(c.segmentIndex,b);c.duration=b;c.Ce=c.Oc+b})},QL=function(a){let b=Infinity;a.filter(rK).forEach(c=>{b=
|
|
32
|
+
Math.min(b,c.duration)});return b},UL=function(a){if(!(2>a.length)&&RL(a)){a=a.map(e=>({playlist:e,Ff:SL(e.S[0])}));var b=a.map(e=>e.Ff),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.Ff;0<f.S.length&&1E3<c-e;){var g=f.S.shift(),h=f.S[0];if(!h)break;TL(g,h);h=SL(h);null!=h?e=h:({duration:h}=wK(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.S.length))throw new _.I(_.F,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>
|
|
33
|
+
e.S.length));a.forEach(e=>{for(;e.S.length>d;)e.S.pop()})}}},RL=function(a){return a.every(b=>!!SL(b.S[0]))},TL=function(a,b){a&&b&&[PJ,OJ].forEach(c=>{if(!lK(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},VL=function(a,b){pK(b,(c,d)=>{_.cD(a,c.S,d.startTime)});_.VC(a.a,b[0].startTime,b[b.length-1].endTime)},WL=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Ca)},XL=function(a,b){return _.w(function*(){var c=_.mj([b],a.a.attemptParameters);
|
|
34
|
+
c.type=1;c=yield a.H(c);let d="";try{d=_.Bi(c.data)}catch(e){throw new _.I(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},hM=function(a,b){return _.w(function*(){var c=YL(a,b,a.w,"");if(1===c.type){var d=c.S[0].a;c=ZL(d);if(!c)throw new _.I(_.F,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=aL(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=zK(c.ba);c=$L(d.wc.vf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield aM(a,d);
|
|
35
|
+
var f=e.Mh;const g=e.periods;var h=e.ai;const k=e.Ai;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.F,7,7001);bM(a,g);h=cM(a,f.delay,g,h);dM(a)||(a.G=f.zd,eM(a));fM(a,h,g);f=gM(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},jM=function(a,b){return Promise.all(b.map(c=>
|
|
36
|
+
iM(a,c)))},lM=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!dM(a),f=mK(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].S,f=f[f.length-1].ra):f=0;if(e&&0<f)try{{const k=mK(c.ba,RJ);if(!k)throw kM.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(UJ);const l=Number(k.value),m=zL(d,l);if(!m)throw kM.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
|
|
37
|
+
` (segment position = ${l})`),Error(UJ);var h=m.ra}g=h;break a}catch(k){throw new _.I(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.S||[];for(const k of c)lK(k.ba,NJ)&&g++,k.ra=g});kL(b)},oM=function(a,b){return _.w(function*(){const {textStreams:c,thumbStreams:d,Tg:e}=yield mM(a,b);var f=a.f.periods[0].variants;a.a.lowLatencyMode&&null!==a.o&&(f=f.filter(g=>g.id===a.o.id));f=f.map(g=>{const h=KK(g.audio,e),k=KK(g.video,e);g=nM(a,h,k,g.bandwidth);
|
|
38
|
+
if(!g)throw new _.I(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",jj:k?GK(k).Ca:void 0,audio:h?GK(h).Ca:void 0});return g});return NL(a.D.configurationId,f,c,d,!0)})},bM=function(a,b){dM(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.lE(b,-a.I))},pM=function(a,b){b=b.flatMap(d=>d.S[0].ba);b=mK(b,SJ);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),
|
|
39
|
+
null):c/1E3},qM=function(a,b,c){b=b.find(d=>null!==mK(d.ba,MJ));if(!b)return[];if(null===c)throw new _.I(_.F,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");return b.ba.filter(d=>d.name===MJ).map(d=>{a:{var e=a.C,f=!dM(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.du.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);f=k.getTime()/1E3+e;
|
|
40
|
+
g={id:g,startTime:f,startDate:k,ge:h};h=hK(_.J(d,LJ));void 0!==h&&0<=h&&(g.duration=h);var l=hK(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=m);var n=_.J(d,"END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var p=null;else{k={};for(p of v)p.name.trim().startsWith("X-")&&(k[p.name]=p.value);p=_.ch(k)?k:null}}p=p||{};(k=_.J(d,"CUE"))&&(p.CUE=k.split(","));if(_.Yi(m)){k=
|
|
41
|
+
d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Lb:m[_.Lb]=u.value;break;case _.Kb:m[_.Kb]=u.value;break;case _.Ob:m[_.Ob]=hK(u.value);break;case _.Mb:m[_.Mb]=hK(u.value);break;case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case _.Nb:m[_.Nb]=u.value.split(",")}m[_.Lb]&&m[_.Kb]||!m[_.Lb]&&!m[_.Kb]?(_.du.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.ch(m)?m:null}if(null===u){_.du.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",
|
|
42
|
+
d);d=null;break a}p=Object.assign(p,u)}_.ch(p)&&(g.customAttributes=p);g.endTime=n?n.getTime()/1E3+e:h?f+h:l?f+l:f;g.type=_.Uh;d=g}}return d}).filter(Boolean)},gM=function(a,b){const c=new Set(b.map(d=>d.id));a.B.forEach((d,e)=>{c.has(e)||a.B.delete(e)});for(const d of b){if((b=a.B.get(d.id))&&b.ge!==d.ge)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,
|
|
43
|
+
value:"",startTime:d.startTime,ge:d.ge,endTime:d.endTime,id:d.id,type:_.Uh,eventElement:null};b&&!fK(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},rM=function(a,b,c){a.A=_.Db;_.ZC(b,!0);b.f=c[c.length-1].endTime},YL=function(a,b,c,d){a=XK(a.R,b,c);a.verbatimUri=d;return a},$L=function(a){return a.filter(b=>b.name===QJ&&_.J(b,_.sb)===_.kB&&!_.J(b,_.ub)).map(b=>{const c=LK(b),d=_.J(b,_.La)||_.hg;return{groupId:cK(b,_.Fa),id:_.tJ++,label:cK(b,_.Ta),language:d,channelsCount:c,primary:"YES"===
|
|
44
|
+
_.J(b,"DEFAULT")}})},aM=function(a,b){return _.w(function*(){var c=IK(b.wc.closedCaptions),d=sM(a,b.Cd),e=yield tM(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=sK(g.ba);a.A=h;lM(a,f);!dM(a)&&UL(f);a.K=xK(g.ba);f=FK(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield uM(a,e.wf,d);c=yield vM(a,e.Cd,g,c);d=yield wM(a,e.xi,d);g=yield xM(a,e.ze);d=NL(a.D.configurationId,c,d,g,!dM(a));a.D.filterAllPeriods(d);c=[...e.Cd,...e.wf].map(k=>k.playlist);
|
|
45
|
+
e=pM(a,c);c=qM(a,c,e);return{periods:d,ai:e,Ai:c,Mh:f}})},cM=function(a,b,c,d){let e=!0,f=null,g=0;dM(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.wJ(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.ZC(a,e);VL(a,c);d&&_.YC(a,d);return a},eM=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Oc);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],
|
|
46
|
+
95443.7176888889>b.Oc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},fM=function(a,b,c){c=DK(c);"LIVE"===a.A||"EVENT"===a.A?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.A===_.Db&&(b.f=c)},mM=function(a,b){return _.w(function*(){const c=g=>GK(g.stream).type===_.t||GK(g.stream).type===_.q;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=GK(h.stream);k={language:k.language,
|
|
47
|
+
channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.Ca,Dd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return yM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);zM(a,d.concat(f));e=f.filter(g=>GK(g).type===_.QB);f=f.filter(g=>GK(g).type===_.ee);return{textStreams:e,thumbStreams:f,Tg:d}})},nM=function(a,
|
|
48
|
+
b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||null:null,l=h,m=k;l=l&&m?_.pC(l.drmInfos,m.drmInfos)?_.oC(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.hg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new AM(f)},yM=function(a,b){return _.w(function*(){const c=b.playlist,
|
|
49
|
+
d=b.codecs,e=b.type,f=b.Mc,g=b.dc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Dd,A=_.$i(f||_.hg);if(1!==c.type)throw new _.I(_.F,4,4017);const D=yield BM(a,c,e,d),E=a.a.lowLatencyMode?_.HB:_.GB;let ha=m;e!==_.H||m||(ha=_.QB);const ad=sK(c.ba);m=D.map(hc=>{const Qb=hc.S,Xd=hc.eh,Rb=hc.mimeType,ic=hc.ra,jc=Qb[0].startTime,Fb=Qb[Qb.length-1].endTime,hb=Fb-jc,va=new _.xJ(Qb),yb=Qb[0].initSegment||null;return{id:null===
|
|
50
|
+
g?_.tJ++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:va.f.bind(va),getSegmentReference:va.get.bind(va),adjustSegmentDurations:va.h.bind(va),getDuration:va.getDuration.bind(va),segmentIndex:va,segmentLookupStrategy:E,initSegmentReference:yb,mimeType:Rb,codecs:d,kind:ha,Jf:Xd.type,encrypted:Xd.type===bK,aesEncrypted:hc.aesEncrypted,keyId:Xd.keyId,language:A,originalLanguage:f||_.hg,label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?
|
|
51
|
+
y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,S:Qb,drmInfos:Xd.drmInfos,ra:ic,Ca:c.verbatimUri,ke:c.a,Oc:jc,Ce:Fb,duration:hb,groupId:h,aj:ad,muxedAudioId:k}});return new CM(m)})},zM=function(a,b){b.forEach(c=>{a.j.a.set(GK(c).Ca,c)})},sM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,_.kB);b=_.J(f,_.Cb);var e=_.J(f,YJ);const g=DM(a,f);if(e){const h=_.jl(_.H,g);c.set(`${_.H}:${e}`,h);e=g.indexOf(h);
|
|
52
|
+
-1<e&&g.splice(e,1)}d&&(e=EM(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=EM(_.t,g),c.set(`${"video"}:${b}`,d))}return c},tM=function(a,b){return _.w(function*(){const c=yield Promise.all([FM(a,b.wc.vf),FM(a,b.wc.yi),FM(a,b.Cd),FM(a,b.ze)]),[d,e,f,g]=c;return{wf:d,xi:e,Cd:f,ze:g}})},uM=function(a,b,c){return _.w(function*(){if(0===b.length)return new Map;var d=[GM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>GM(a,e,c)));d=yield Promise.all(d);return HK(d)})},vM=function(a,b,c,d){return _.w(function*(){const e=
|
|
53
|
+
new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(cK(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield HM(a,h,c,d,e);f=f.map(k=>HM(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.fC,[])})},wM=function(a,b,c){return Promise.all(b.map(d=>GM(a,d,c)))},xM=function(a,b){return Promise.all(b.map(c=>IM(a,c)))},JM=function(a,b){return _.w(function*(){const c=_.Ti(b.verbatimUri,a.w),{response:d,text:e}=yield XL(a,c);return YL(a,e,d.uri,b.verbatimUri)})},
|
|
54
|
+
KM=function(a,b,c){return _.w(function*(){const d=yield yM(a,{playlist:c,codecs:b.codecs,type:b.type,Mc:b.originalLanguage,dc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Dd:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&EL(d,b.bandwidth);return d})},dM=function(a){return a.A===_.Db},FM=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>
|
|
55
|
+
_.w(function*(){const d=yield LM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},iM=function(a,b){return _.w(function*(){var c=new URL(GK(b).ke);if(a.a.lowLatencyMode&&a.K&&a.K.Af){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Nh:d.position,Uh:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Uh,d.set("_HLS_msn",e.Nh.toString()),null===f&&d.get(ZJ)&&d.delete(ZJ),null!==f&&d.set(ZJ,f.toString())}const {response:g,text:h}=
|
|
56
|
+
yield XL(a,c.toString());c=GK(b).Ca;d=GK(b).ke;e=g.uri;d!==e&&(d=e,AL(b,d));c=YL(a,h,d,c);return{stream:b,playlist:c}})},DM=function(a,b){var c=_.J(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=JK(c);b=new Set;const d=[];for(const e of c)c=_.uC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},EM=function(a,b){if(1===b.length)return b[0];a=_.jl(a,b);if(null!=a)return a;throw new _.I(_.F,4,4025,{codecList:b});},GM=function(a,b,c){return _.w(function*(){const d=
|
|
57
|
+
b.tag,e=b.playlist;return MM(a,e.verbatimUri,()=>_.w(function*(){const f=cK(d,_.Fa),g=tK(cK(d,_.sb));var h=cK(d,_.sb).toUpperCase();if(tK(h)!==_.H)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.QB;h===JJ&&(l=_.BB);k&&(l=_.Wd);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.La);const m=_.J(d,_.Ta),n=_.J(d,"DEFAULT"),p=g===_.q?LK(d):null;var u=g===_.q?(u=_.J(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield yM(a,{playlist:e,codecs:k,type:g,Mc:l,primary:"YES"===
|
|
58
|
+
n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,dc:null,closedCaptions:null,Dd:null})}))})},IM=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return MM(a,d.verbatimUri,()=>_.w(function*(){var e=_.J(c,_.pa)||"jpg",f=_.J(c,_.La);const g=_.J(c,_.Ta);e=yield yM(a,{playlist:d,codecs:e,type:_.ee,Mc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,dc:null,groupId:null,Dd:null});(f=_.J(c,_.ma))&&EL(e,Number(f));return e}))})},HM=function(a,b,c,
|
|
59
|
+
d,e){return _.w(function*(){var f=b.tag,g=Number(cK(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.lb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,_.lb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:hK(h),width:hK(k),height:hK(l)}}else h=null;if(f=yield NM(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=(p?GK(p).Ca:"")+" - "+(n?GK(n).Ca:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");
|
|
60
|
+
continue}const u=nM(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},OM=function(a,b,c,d,e,f){let g=DM(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.jl(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&f?(a.g.debug(VJ),c=_.q,b=!0):e?(a.g.debug(VJ),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(VJ));return{type:c,
|
|
61
|
+
Rg:g,Dh:b}},MM=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||null;c=c();a.j.set(b,c);return c},NM=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.J(f,_.kB),k=_.J(f,_.Cb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>GK(u).Ca===l);const {type:m,Rg:n,Dh:p}=OM(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield PM(a,b,n,m,e,c));
|
|
62
|
+
if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{BL(u,c.width);CL(u,c.height);DL(u,c.frameRate)});return k})},PM=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return MM(a,h.verbatimUri,()=>_.w(function*(){var k=_.J(g,JJ);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.J(g,_.kB)||void 0)&&a.J.has(k)?k:void 0;var m=EM(d,c);if(k){const n=EM(_.q,c);m+=`,${n}`}return yield yM(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Mc:null,name:null,
|
|
63
|
+
channelsCount:null,spatialAudio:!1,dc:null,groupId:null,muxedAudioId:k,Dd:f})}))})},BM=function(a,b,c,d){return _.w(function*(){var e=b.verbatimUri,f=b.S;var g=void 0===g?0:g;var h=(h=mK(b.ba,RJ))?Number(h.value):g;g=[];e=yield QM(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)lK(m.ba,NJ)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield RM(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;SM(g);return g})},LM=function(a,
|
|
64
|
+
b){return _.w(function*(){var c=b.name!==QJ?!0:_.J(b,_.sb)===YJ;c=_.J(b,_.ub,void 0,{required:c});if(!c)return null;const d=_.Ti(c,a.w),e=Date.now(),{response:f,text:g}=yield XL(a,d);a.D.onEvent(new _.C(aK,{detail:{duration:Date.now()-e,type:"media"}}));return YL(a,g,f.uri,c)})},SM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},TM=function(a,b,c){a=iK(a.ba,
|
|
65
|
+
PJ);if(1<a.length)throw new _.I(_.F,4,4020);a=a[0];if(!a)return null;const d=cK(a,_.ub),e=_.Ti(d,b);b=yK(a,null,!0);return new _.sJ(()=>[e],b.ma,b.ja,c)},UM=function(a,b,c,d,e,f,g){const h=[];for(const p of gK(b.f)){b=p.Wf;const u=p.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,LJ));n=m+n;k=yK(u,k?null:l.ja,k);l=_.J(u,_.ub);const v=(l=_.Ti(l,g))?[l]:[];m=new AK(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},
|
|
66
|
+
VM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<iK(n,PJ).length&&(m=TM(c,k,g));const u=null!=p,v=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;p={ma:0,ja:null};let y=null;u?({duration:c}=wK(n),a=e+c,p=vK(n,b?b.ja:null)):(b=UM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ee?nK(n):null;d=new AK(d,e,a,()=>v,p.ma,p.ja,f,g,!1,null,h?h.fd:null,h?h.Bd:null,h?h.durationPerTile:null,y,m);d.ra=l;return d},QM=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(null!=a.C)return a.C;
|
|
67
|
+
if(!dM(a)&&a.f)try{var k=a.j.get(c);var l=k?zL(k,e)||null:null;if(!l)throw new _.I(_.F,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Ba;a.g.debug(`Setting playlist start time to ${m}.`);return a.C=m}catch(n){if(h=a.j.get(c))m=h.streams[h.streams.length-1].S,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].S[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
|
|
68
|
+
uri:c});}m=yield WM(a,f,g,h);l=vL(h.ba,a.w,e);k=TM(h,b,l);h=yield XM(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},RM=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0],l=null==h;const m=yield WM(a,f,g,k);var n=h?h.Kh:null;if(lK(c[0].ba,OJ)||null===n)n=sL(c,m),n=0===n.length?[oL()]:n;else{var p=sL(c,m);n=[n,...p]}p=n;n=p[p.length-1];p=pL(p);let u=h?h.Lh:null;var v=YM(u,k.ba,a.w,d);let y=TM(k,b,v)||(h?h.Eh:null);const A=k.ra;k=l?e:yield ZM(a,A,y,k,d,v,m,g);
|
|
69
|
+
l=[];v=!1;for(let E=0;E<c.length;E++){var D=c[E];const ha=l[l.length-1]||null,ad=0===E?0:ha.endTime,hc=d+E,Qb=YM(u,D.ba,a.w,hc);(u=Qb)&&(v=!0);if(D=VM(a,ha,D,hc,ad,k,Qb,f,b,A,y))y=D.initSegment,l.push(D)}return{S:l,eh:p,Kh:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,ra:A,Eh:y,Lh:u}})},WM=function(a,b,c,d){return _.w(function*(){const e=d.a;var f=mK(d.ba,PJ);f=f?cK(f,_.ub):null;return $M(a,b,c,e,f)})},XM=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=BK(c,
|
|
70
|
+
d);return xL(a.T,b,g,e,f,null!=d)})},YM=function(a,b,c,d){return b.some(e=>e.name===OJ&&"NONE"===_.J(e,WJ))?null:(b=vL(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Fk(new Uint8Array(12),cL(d))}):a},ZM=function(a,b,c,d,e,f,g,h){return _.w(function*(){if(a.L.has(b))return a.L.get(b);const k=yield XM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.L.set(b,k);return k})},$M=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.ml(f,b,c);if(g)return g;
|
|
71
|
+
g=_.mj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},ZL=a=>{a=_.Vi(a)||"";return null!=_.cu.video[a]?_.t:null!=_.cu.audio[a]?_.q:null},RK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.F,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.F,4,4043,"Media playlist must have at least one full segment!");
|
|
72
|
+
}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.S=1===b?d:null}},$K=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=a;this.f=c;this.ra=-1}},AK=class extends _.pD{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===v?null:v);this.ra=0}},YK=/^#EXT-X-DEFINE/,ZK=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,
|
|
73
|
+
aN=class{constructor(){this.h=0;this.a=new Map}},bN=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},kM=new _.S("clpp.hls.DiscontinuityUtils");var uL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.sg)throw new _.I(_.F,4,4041);if(cK(a,WJ)===XJ)throw new _.I(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.jC(_.qd,[{initDataType:_.Jf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":nL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":nL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=cK(a,WJ);if(!lL.includes(b))return mL.error("Widevine in HLS is only supported with [",
|
|
74
|
+
lL.join(", "),"], not",b),null;b=cK(a,_.ub);b=_.Gk(b);b=_.G(b.data);b=_.jC(_.ud,[{initDataType:_.Uc,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},lL=["SAMPLE-AES",XJ],mL=new _.S("clpp.hls.DrmParser");var tL=new _.S("clpp.hls.EncryptionUtils");var cN=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.ij()}}};var CM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var AM=class{constructor(a){this.a=a}length(){return this.a.length}};var SL=a=>{if(!a)return null;a=mK(a.ba,SJ);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var dN=class{constructor(){this.a=this.D=null;this.h=1;this.j=new bN;this.w="";this.R=new aN;this.G=0;this.o=null;this.l=new _.Mj(()=>{this.Rb()});this.A=_.Db;this.f=null;this.F=new _.eu;this.K=this.C=null;this.g=new _.S("clpp.hls.HlsParser");this.L=new Map;this.T=new cN(this.H.bind(this));this.P=!1;this.I=null;this.M=!1;this.B=new Map;this.J=new Set}configure(a){this.a=a;this.T.a=a}setCurrentVariant(a){this.o=a}start(a,b){const c=this;return _.w(function*(){if(c.P)throw Error("start() may be called only once!");
|
|
75
|
+
c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield XL(c,a);c.D.onEvent(new _.C(aK,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield hM(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.M=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=this.o=null;this.B.clear();this.J.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){const b=a.f;if(!dM(a)&&
|
|
76
|
+
b){var c=b.presentationTimeline;"LIVE"===a.A&&(a.C=null);var d=Array.from(a.j.values());if(a.a.lowLatencyMode&&null!==a.o){const g=WL(a);d=d.filter(h=>g.includes(GK(h).Ca))}var e=yield jM(a,d);d=e.map(g=>g.playlist);lM(a,d);e=yield oM(a,e);GL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});bM(a,e);var f=pM(a,d);f=qM(a,d,f);b.cues=gM(a,f);IL(b.periods,e);VL(c,e);if(d=qK(d))!0!==a.a.keepTimelineLive&&rM(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();
|
|
77
|
+
a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.w(function*(){const d=a.id;var e=c.f.periods.find(k=>k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.ni(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=MM(c,k.verbatimUri,()=>_.w(function*(){const l=yield JM(c,k);return KM(c,k,l)}))}if(e.video){const k=e.video;g=MM(c,k.verbatimUri,()=>_.w(function*(){const l=yield JM(c,
|
|
78
|
+
k);return KM(c,k,l)}))}f=yield f;g=yield g;e=nM(c,f,g,e.bandwidth,e.id);let h;e&&(e=NL(c.D.configurationId,[e],[],[],!dM(c)),c.D.filterAllPeriods(e),e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.ni(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.w(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=
|
|
79
|
+
c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.ni(`Could not load text stream with id: ${a}`);const g=yield MM(c,f.verbatimUri,()=>_.w(function*(){const h=yield JM(c,f);return KM(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.ni(`Could not load text stream with id: ${a}`);return d})}Rb(){const a=this;return _.w(function*(){a.g.debug(_.wB);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
|
|
80
|
+
_.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}H(a){if(!this.F)throw new _.I(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.vj(this.F,a);return a.U}};_.x("clpp.hls.HlsComponent",class extends _.uv{f(){_.st.m3u8=dN;_.rt[_.Ql]=dN;_.rt[$J]=dN}a(){_.ND("m3u8");_.OD(_.Ql);_.OD($J)}id(){return"hls"}});};f.call(g, window);
|
package/cl.hlssmpte.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
else a.g.warn("A video element is not available. Skipping.")},
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var TU=function(a){a.a.one(a.m,_.oe,()=>SU(a))},SU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.oc,d=>UU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.ye).forEach(d=>{UU(a,{track:d})});!VU(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),WU(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
|
|
2
|
+
else a.g.warn("A video element is not available. Skipping.")},UU=function(a,b){b=b.track;b.kind===_.ye&&(a.g.info("The metadata track has been added."),b.mode=_.be,a.a.on(b,_.zd,c=>XU(a,c)))},VU=function(a){return a.some(b=>b.kind===_.ye)},WU=function(a,b){const c=a.m.getTrackManager(),d=c.oa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.xa(d);a.a.on(b.textTracks,_.oc,g=>{g.track.kind===_.ye&&(a.a.off(b.textTracks,_.oc,f),c.xa(d))});c.xa(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
XU=function(a,b){const c=YU(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new ZU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Fi(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},YU=function(a){return(a=a.m.getTrackManager().ta())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
ZU=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.gh(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=_.gh(a)?a:null}}};var $U=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Kt;this.h=(a=_.wt(_.yc))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;TU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var aV=class extends _.Iv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.ak()){var b=a.getConfiguration();b=_.ah(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Mc&&(b.patchMetadataTrack=!1);_.hh(b.timestampOffset)||(b.timestampOffset=0);this.a=new $U(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",aV);
|
|
5
|
+
aV.Id="hlssmpte";_.fs(new class{create(){return new aV}});};f.call(g, window);
|