@castlabs/prestoplay 6.28.0 → 6.30.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 +37 -0
- 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 +128 -116
- package/cjs/cl.conviva.js +32 -32
- package/cjs/cl.core.js +619 -614
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +92 -89
- package/cjs/cl.externs.js +154 -60
- package/cjs/cl.freewheel.js +25 -25
- package/cjs/cl.hls.js +77 -77
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +25 -23
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +350 -349
- package/cjs/cl.muxdata.js +14 -14
- package/cjs/cl.onboard.js +4 -4
- package/cjs/cl.persistent.js +15 -15
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.simid.js +16 -16
- package/cjs/cl.smooth.js +57 -58
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +60 -60
- 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 +38 -38
- package/cjs/polyfill.min.js +2 -2
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +6 -6
- package/cl.cast.js +101 -92
- package/cl.conviva.js +27 -27
- package/cl.core.js +500 -496
- package/cl.crypto.js +9 -9
- package/cl.dash.js +84 -83
- package/cl.externs.js +150 -60
- package/cl.freewheel.js +19 -19
- package/cl.hls.js +82 -80
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +19 -17
- package/cl.mediatailor.js +2 -2
- package/cl.mse.js +304 -305
- 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.simid.js +14 -14
- package/cl.smooth.js +60 -60
- package/cl.thumbnails.js +19 -19
- package/cl.tizen.js +56 -56
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +14 -14
- package/cl.vtt.js +12 -12
- package/cl.yospace.js +3 -3
- package/cl.youbora.js +31 -31
- package/package.json +1 -1
- package/typings.d.ts +198 -88
package/cl.thumbnails.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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.
|
|
6
|
-
c+_.
|
|
7
|
-
e);this.a.removeEventListener(_.
|
|
8
|
-
c),new _.
|
|
9
|
-
for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new
|
|
10
|
-
d[l]),k+=1;for(let l=0,m=e.byteLength;l<m;l++)h.setUint8(k,e[l]),k+=1;this.a=g;this.g.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`);f=this.a;d=_.
|
|
11
|
-
h.offset-k.offset,k.duration=h.time-k.time;this.f.push(h);d+=8;(g=4294967295===g)&&this.h.resolve();if(1E5<e)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");
|
|
12
|
-
+ 'URL: ${c}`,d);a.onError(new _.
|
|
13
|
-
l);f.match(/^http|^\/\//)||(f=c.substr(0,c.lastIndexOf("/"))+"/"+f);l=
|
|
14
|
-
yield c.load();return c})}l(){return this.f}};var
|
|
15
|
-
e.findSegmentPosition(a-d.startTime);if(null===d||void 0===d)throw b.log.error("Could not find segment index for specified position",a),c();var f=e.getSegmentReference(d);if(f){const h=
|
|
16
|
-
h.
|
|
17
|
-
0;k<e.
|
|
18
|
-
this.g.warn("Unknown thumbnail mode",c)}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();if(
|
|
19
|
-
var
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Ly="Thumbnail URL is mandatory",My="Wrong gridSize format",Ny="clpp.thumbnails",Py=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.He&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Oy(a,0,e,!!f))},Promise.resolve())},Oy=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Qy(a,d).then(()=>a.a[b].load()).then(()=>Oy(a,e,c,d))},Qy=function(a,b){return new Promise(c=>{if(b||2!==a.player.getState())c();else a.player.one(_.Oc,()=>{c()})})},
|
|
2
|
+
Ry=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.Vc.resolve()})},Uy=function(a,b){return Sy(a,b).then(c=>new Ty(c,b.time,b.duration))},Sy=function(a,b){return b.load().then(()=>{const c=_.G(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.$l(c)})},Vy=function(a){a=a.split(/\.|:/).map(parseFloat);let b=0,c;const d={3:.001,2:1,1:60,0:3600};for(c=a.length-1;0<=c;c--)b+=a[c]*d[c];return b},Wy=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
|
|
3
|
+
Xy=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{ud:c,Gf:d,sg:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Yy=function(a){return a.some(b=>0<b.thumbStreams.length)},fz=function(a){return a?a===Zy||a===$y?new az:a===bz?new cz:a===dz?new ez:null:null},gz=function(a){if(!a)return null;a=new _.gp(a);return a.path.match(/.*\.vtt$/i)?bz:a.path.match(/.*\.bif$/i)?dz:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
|
|
4
|
+
Zy:null};var hz=class{constructor(){this.log=new _.T(Ny);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.xf,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Py(this,b.preload)})}};var Ty=class{constructor(a,b,c,d,e,f,g,h,k,l,m,n){d=void 0===d?0:d;e=void 0===e?0:e;f=void 0===f?0:f;g=void 0===g?0:g;h=void 0===h?1:h;k=void 0===k?1:k;l=void 0===l?0:l;m=void 0===m?0:m;n=void 0===n?new Image:n;this.time=b;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.a=n;this.h=h;this.o=k;this.j=l;this.l=m;this.f=null}raw(){return this.a.cloneNode(!1)}element(a,b){let c=this.width,d=this.height;const e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==a&&
|
|
5
|
+
void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.Fd);a.style.width=c+_.uf;a.style.height=d+_.uf;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.a.naturalWidth||this.a.width))}px ${Math.ceil(d/this.height*(this.a.naturalHeight||this.a.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/this.width*
|
|
6
|
+
c+_.uf;a.style.backgroundPositionY="-"+b*d+_.uf;return a}load(){this.f||(this.f=new Promise((a,b)=>{const c=()=>{this.width||(this.width=(this.a.naturalWidth||this.a.width)/this.h);this.height||(this.height=(this.a.naturalHeight||this.a.height)/this.o);this.x||(this.x=this.width*this.j);this.y||(this.y=this.height*this.l)};if(this.a.src&&this.a.complete)c(),a(this);else{var d=null,e=()=>{c();this.a.removeEventListener(_.pe,e);this.a.removeEventListener(_.Xd,d);a(this)};d=f=>{this.a.removeEventListener(_.pe,
|
|
7
|
+
e);this.a.removeEventListener(_.Xd,d);b(new _.I(1,9,2014,"Failed to load thumbnail.",f))};this.a.addEventListener(_.pe,e);this.a.addEventListener(_.Xd,d);this.a.src=this.src}}));return this.f}};_.x("clpp.thumbnails.Thumbnail",Ty);Ty.prototype.load=Ty.prototype.load;Ty.prototype.element=Ty.prototype.element;Ty.prototype.raw=Ty.prototype.raw;var az=class extends hz{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Ly);if("GRID"===b.mode&&!b.gridSize)throw new _.I(1,9,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.I(1,9,7100,"Duration is mandatory");this.f=b;this.j=this.f.duration;if(this.f.gridSize)try{const c=this.f.gridSize.split(/x/).map(d=>parseInt(d,10)).filter(d=>0<d);if(2===c.length)this.h=c[0],this.o=c[1];else throw new _.I(1,9,7100,My);}catch(c){throw this.log.error("Error during parsing gridSize",
|
|
8
|
+
c),new _.I(1,9,7100,My);}super.init(a,b)}get(a){const b=this;return _.w(function*(){var c=b.player.getDuration();if(0>a||a>c)throw new _.I(1,9,2014,`Position is out of range: ${a}`);c=Math.floor(a/b.f.duration);const d=b.a[c];if(!d)throw new _.I(1,9,2014,"No thumbnail found for position "+a+" at index "+c);yield d.load();return d})}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getDuration();const b=this.h*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);const c=this.f.templateKey||"$index$";
|
|
9
|
+
for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new Ty(e,this.j*(d*b+g),this.j,0,0,0,0,this.h,this.o,g%this.h,Math.floor(g/this.h),f))}return Promise.resolve()}};var iz=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Vc=new _.Hl}load(){return this.Vc}},ez=class{constructor(){this.g=new _.T(Ny);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.Hl}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Ly);const c=b.url;b=_.wk(c);b.type=_.vk;a.getNetworkEngine().fetch(b).U.then(d=>{var e=d.data;d=_.G(this.a);e=_.G(e);var f=d.byteLength+e.byteLength,g=new ArrayBuffer(f),h=new DataView(g),k=0;for(let l=0,m=d.byteLength;l<m;l++)h.setUint8(k,
|
|
10
|
+
d[l]),k+=1;for(let l=0,m=e.byteLength;l<m;l++)h.setUint8(k,e[l]),k+=1;this.a=g;this.g.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`);f=this.a;d=_.G(f);h=String.fromCharCode.apply(null,jz);k=Array.prototype.slice.call(d,0,8);d=64;e=0;g=!1;if(h===String.fromCharCode.apply(null,k))for(f=new DataView(f,16,20),f=f.getUint32(0,!0),0===f&&(f=1E3);!g;){e+=1;k=f;h=new DataView(this.a,d);g=h.getUint32(0,!0);k=g*k/1E3;h=h.getUint32(4,!0);h=new iz(k,h);if(k=this.f.length)k=this.f[k-1],k.length=
|
|
11
|
+
h.offset-k.offset,k.duration=h.time-k.time;this.f.push(h);d+=8;(g=4294967295===g)&&this.h.resolve();if(1E5<e)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");Ry(this)}).catch(d=>{this.g.error(`[BIF] Error while loading thumbnails '
|
|
12
|
+
+ 'URL: ${c}`,d);a.onError(new _.I(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.w(function*(){if(0>a)throw new _.I(1,9,2014,`Position is out of range: ${a}`);yield b.h;var c=b.f.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.I(1,9,2014,`No thumbnail found for position: ${a}`);c=yield Uy(b,c);yield c.load();return c})}},jz=[137,66,73,70,13,10,26,10];var cz=class extends hz{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Ly);const c=b.url,d=_.wk(c);d.type=_.vk;this.f=a.getNetworkEngine().fetch(d).U.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.ni(e).split(/\n/);for(let m=0;m<e.length;m++){var f=e[m],g=f.split(" --\x3e ");if(2===g.length){f=e[++m];var h=f.indexOf("\x3d");var k=h=0>h?[]:f.substr(h+1).split(/,/).map(parseFloat);h=k[0];const n=k[1],p=k[2];k=k[3];var l=f.indexOf("#");f=0>l?f:f.substr(0,
|
|
13
|
+
l);f.match(/^http|^\/\//)||(f=c.substr(0,c.lastIndexOf("/"))+"/"+f);l=Vy(g[0]);g=Vy(g[1])-l;this.a.push(new Ty(f,l,g,h,n,p,k,0,0))}}}).catch(e=>{this.log.error("[VTT] Error while loading thumbnails "+`URL: ${c}`,e);a.onError(new _.I(1,9,2013,"Error while loading VTT thumbnails.",e))});super.init(a,b)}get(a){const b=this;return _.w(function*(){if(0>a)throw new _.I(1,9,2014,`Position is out of range: ${a}`);yield b.f;const c=b.a.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.I(1,9,2014,`No thumbnail found for position: ${a}`);
|
|
14
|
+
yield c.load();return c})}l(){return this.f}};var kz=class extends hz{get(a){const b=this;return _.w(function*(){function c(){return new _.I(1,9,2014,`No thumbnail found for position: ${a}`)}if(0>a)throw b.log.error("Position must be greater than 0 but is "+a),new _.I(1,9,2014,`Position is out of range: ${a}`);var d=b.player.getPeriods();d=Wy(d,a);if(!d)throw b.log.error("Could not find period for specified position",a),c();var e=d.thumbStreams.sort(b.f)[0];if(!e)throw b.log.error("Could not find thumb stream for specified position",a),c();d=
|
|
15
|
+
e.findSegmentPosition(a-d.startTime);if(null===d||void 0===d)throw b.log.error("Could not find segment index for specified position",a),c();var f=e.getSegmentReference(d);if(f){const h=Xy(f,e),k=Math.floor((a-f.startTime)/h.durationPerTile);var g;if(0<b.a.length)f=e.findSegmentPosition(0),null!==f&&(g=b.a[(d-f)*h.sg+k]);else if((e=f.Ea())&&0<e.length){let l=g=0;f=f.startTime;1<h.sg&&(g=k%h.ud,l=Math.floor(k/h.ud),f+=k*h.durationPerTile);g=new Ty(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
|
|
16
|
+
h.ud,h.Gf,g,l)}if(g)return yield g.load(),g}b.log.error("segment reference for specified segment index does not exist",d);throw c();})}f(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getPeriods();for(const b of a)if(a=b.thumbStreams.sort(this.f)[0]){let c=a.findSegmentPosition(0),d;for(;null!==c&&!_.z(d=a.getSegmentReference(c++));){const e=Xy(d,a),f=d.Ea()[0],g=new Image;let h=d.startTime;for(let k=
|
|
17
|
+
0;k<e.Gf;++k)for(let l=0;l<e.ud;++l)this.a.push(new Ty(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.ud,e.Gf,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var lz=class{constructor(){this.g=new _.T(Ny);this.a=this.m=null}onPlayerCreated(a){this.m=a}onPlayerWillDestroy(){this.m=null}onPlayerWillRelease(){this.a=null}onContentWillLoad(a){const b=a.getConfiguration().thumbnails;if(b)if(!1===b.enabled)this.g.info("Thumbnails disabled.");else{var c=b.mode||null;c||(c=gz(b.url||null));(this.a=fz(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.ue,()=>{this.g.info("Initialize thumbnails provider");try{this.a.init(a,b)}catch(d){this.m.onError(d)}})):
|
|
18
|
+
this.g.warn("Unknown thumbnail mode",c)}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();if(Yy(c)){this.a=new kz;try{this.a.init(a,b)}catch(d){this.m.onError(d)}}}}}get(a){return this.a?this.a.get(a):Promise.reject(new _.I(1,9,2014,"Thumbnail format is not supported"))}id(){return"thumbnails"}};_.x("clpp.thumbnails.ThumbnailsPlugin",lz);lz.prototype.get=lz.prototype.get;lz.Id="thumbnails";
|
|
19
|
+
var Zy="SINGLE",$y="GRID",bz="WEBVTT",dz="BIF";_.Qn(new class{create(){return new lz}});};f.call(g, window);
|
package/cl.tizen.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
d)};a.addEventListener(b,d)}
|
|
3
|
-
keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.
|
|
4
|
-
_.
|
|
5
|
-
url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},
|
|
6
|
-
c);try{webapis.avplay.setDrm(
|
|
7
|
-
|
|
8
|
-
!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},
|
|
9
|
-
a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},
|
|
10
|
-
_.
|
|
11
|
-
var c=
|
|
12
|
-
abrSelection:a.a.o}}))},
|
|
13
|
-
d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",e);a.
|
|
14
|
-
var e=b.filter(l=>l.type===
|
|
15
|
-
|
|
16
|
-
c===
|
|
17
|
-
b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):null;a.codec=b.fourCC||null;return a},
|
|
18
|
-
c.push(f)}return c},
|
|
19
|
-
a.a=
|
|
20
|
-
return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===l?!1:l;try{webapis.avplay.setSelectTrack(h,k),a.j[h]=null,e()}catch(m){a.g.debug(`Could not set ${h} track. Trying again...`+`AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),!1===l&&(a.j[h]={type:h,index:k,
|
|
21
|
-
a.a.
|
|
22
|
-
onsubtitlechange:a.P.bind(a),ondrmevent:a.K.bind(a),onerror:a.B.bind(a)})}catch(b){a.g.error(b)}},
|
|
23
|
-
"|BITRATES\x3d"+b+
|
|
24
|
-
|
|
25
|
-
return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.g.debug("AVPlay is ready!");
|
|
26
|
-
currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.
|
|
27
|
-
a.h=new
|
|
28
|
-
a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},
|
|
29
|
-
this.j=!1;this.f=new Map;this.D=b;this.g=new _.
|
|
30
|
-
b[_.
|
|
31
|
-
this.a.off(
|
|
32
|
-
this.a.getState());this.a.getState()===
|
|
33
|
-
yield b.j.start(a.url.replace(_.
|
|
34
|
-
a.id);this.w=!0;let b=_.
|
|
35
|
-
a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.w(function*(){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.w(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var
|
|
36
|
-
b+" data: "+a)}}A(a){3===a.detail.currentState&&this.m.off(_.
|
|
37
|
-
a);const b=this.f[_.
|
|
38
|
-
null}
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.
|
|
43
|
-
d)=>{webapis.avplay.prepareAsync(()=>{
|
|
44
|
-
this.F=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.F)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.F}load(a,b){const c=this;return _.w(function*(){c.g.debug("configure()",b||"");try{yield
|
|
45
|
-
1E3*a;return new Promise((c,d)=>{this.C=!0;this.m.trigger(new _.
|
|
46
|
-
this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.
|
|
47
|
-
"The passed value value should be in the range of 0 to 1.");break;case
|
|
48
|
-
a}getSourceIndex(){return this.G}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},
|
|
49
|
-
{currentTime:a.currentTime/1E3}))}J(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.
|
|
50
|
-
b){this.configuration=this.B=b;this.w=a;this.a.on(
|
|
51
|
-
_.
|
|
52
|
-
this;return _.w(function*(){yield a.release();a.a.off(
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var IO="An unknown error occurred while trying to get volume",JO="Cannot get loading rendition due to platform limitations",KO="SecurityError",LO="The require privilege is: http://tizen.org/privilege/tv.audio",MO="onbufferingcomplete",NO="onbufferingprogress",OO="onbufferingstart",PO="oncurrentplaytime",QO="ondrmevent",RO="onerror",SO="onstreamcompleted",TO="onsubtitlechange",UO="preparingend",VO="preparingstart",WO="|STARTBITRATE\x3d",XO=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,
|
|
2
|
+
d)};a.addEventListener(b,d)},$O=function(a){return _.w(function*(){if(a.a!==_.wd&&a.a!==_.ud)throw new _.I(_.D,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");const b=a.f.get(a.a);if(!b.Bd)throw new _.I(_.D,6,6012,`No license server given for ${a.a}`);try{a.a===_.wd?yield YO(a):yield ZO(a,b),a.o={keySystem:a.a,licenseServerUri:b.Bd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.df,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
|
|
3
|
+
keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.I(_.D,6,6005,{message:JSON.stringify(c)});}})},bP=function(a,b){_.w(function*(){var c=a.f.get(a.a);a.g.debug("DRM Challenge data: ",b.challenge);const d=atob(b.challenge);var e=new Uint8Array(d.length);for(let h=0;h<d.length;++h)e[h]=d.charCodeAt(h);c=_.wk([b.serverurl&&""!==b.serverurl?b.serverurl:c.Bd],_.sk());c.type=3;c.body=e.buffer;c.method=_.eb;try{var f=yield a.D.vb.fetch(c).U;if(a.j){var g=
|
|
4
|
+
_.G(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.g.debug("Widevine license params",k);try{webapis.avplay.setDrm(aP,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.I(_.D,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.I(_.D,6,6007,{message:"Error while fetching license!",
|
|
5
|
+
url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},YO=function(a){return _.w(function*(){try{webapis.avplay.setDrm(aP,"Initialize",""),webapis.avplay.setDrm(aP,"widevine_app_session",a.l.id),webapis.avplay.setDrm(aP,"widevine_data_type",a.l.type)}catch(b){throw b;}})},ZO=function(a,b){return _.w(function*(){var c={};c[cP]=!b.df;c[dP]=b.Bd;""!==b.customData&&(c[eP]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",
|
|
6
|
+
c);try{webapis.avplay.setDrm(fP,"SetProperties",c)}catch(d){throw d;}})},hP=function(a,b){if(a.f!==b)if(a.f===_.ps&&b!==_.zs)a.g.debug(_.sA+`${gP(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;2===a.f?(a.o=(new Date).getTime(),a.m.trigger(new _.H(_.Pc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):2===a.j&&a.m.trigger(new _.H(_.Oc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.H(_.Qf,{detail:b}));a.g.debug("State changed:",
|
|
7
|
+
gP(a.j),"-\x3e",gP(a.f))}},gP=function(a){return Object.keys(_.vs)[a]},kP=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case iP:c=3;break;case jP:c=4;break;default:a.m.isEnded()?c=5:a.g.debug("Inconsistent AVPlay playback state:",b)}hP(a,c)}},lP=function(a){return _.w(function*(){const b=a.m.getConfiguration();let c;(c=yield _.Ct(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},mP=function(a){if(!a)return!1;a=a.periods;let b=
|
|
8
|
+
!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},nP=function(a){const b=document.createElement(_.t),c=new _.wH,d=new _.BG,e=a.m.getTextDisplayer();return new _.xH(b,c,e,d,a.m.getConfiguration())},oP=function(a){const b={configuration:{},sb:()=>a.m.getPosition(),Z:a.h,vb:a.m.getNetworkEngine(),Lc:null,Ye:a.G.bind(a),Cg:a.F.bind(a),onError:a.H.bind(a),Dg:()=>{},onEvent:()=>{},Hg:a.I.bind(a),qe:()=>{},ld:()=>new _.zI,Ge:()=>!1,jd:null};return new _.TH(a.a,b)},pP=function(a){const b=
|
|
9
|
+
a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},qP=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.tr(String(c++),_.P);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||
|
|
10
|
+
_.SA;const f=new _.xr(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},rP=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.gF(a.f,_.K);let c=null;if(b){a=qP(a);for(let d=0;d<a.length;d++)if(a[d].renditions[0].id===String(b.id)){c=a[d].renditions[0];break}}return c}return null},sP=function(a,b){_.w(function*(){a.g.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.Zd,a.a&&a.f)){a.setTextVisibility(!0);
|
|
11
|
+
var c=pP(a);const d=b.renditions[0];(c=c.textStreams.find(e=>String(e.id)===d.id))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=c):(yield _.xF(a.f,c),a.m.trigger(new _.H(_.ag))),a.o=c.language):a.g.error("No stream with id",d.id)}})},tP=function(a){const b=a.ra();b&&a.m.trigger(new _.H(_.Mc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},uP=function(a,b){a.m.trigger(new _.H(_.Bg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,
|
|
12
|
+
abrSelection:a.a.o}}))},vP=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},wP=function(a,b){a=a.f[_.R]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.lh(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},xP=function(a){const b=a.m.getConfiguration();var c=_.Zh(b.preferredAudioLanguage||[]);const d=a.f[_.Q]||[];if(d.length){var e=null;c.some(g=>{e=_.yB(g,
|
|
13
|
+
d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",e);a.za(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},DP=function(a,b){var c=(l,m)=>{for(let n=0;n<l.length;n++)if(l[n].language===m)return l[n];return null};const d={};if(0>=b.length)return d;
|
|
14
|
+
var e=b.filter(l=>l.type===yP),f=b.filter(l=>l.type===zP);const g=[];for(var h=0;h<f.length;h++){const l=vP(a,f[h].extra_info);if(l){var k=_.Hn(l.language||_.kg);k=_.pr(k);k=c(g,k);k||(k=new _.tr(String(a.h++),_.Q),g.push(k));k.renditions.push(AP(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.tr(String(a.h++),_.R);for(f=0;f<e.length;f++)(h=vP(a,e[f].extra_info))?c.renditions.push(BP(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?
|
|
15
|
+
qP(a.j):CP(a,b);d[_.R]=[c];d[_.Q]=g;d[_.P]=e;return d},GP=function(a,b){if(b===_.P&&a.j)return rP(a.j);var c=EP(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.R&&(d=vP(a,c.extra_info),d=wP(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=FP(a,c,_.Q),a.l=d):d=a.l);b===_.P&&(c?(d=FP(a,c,_.P),a.o=d):d=a.o);return d},JP=function(a,b){if(b){const c=b.track.type.toUpperCase();HP(a.a,c,Number(b.id)).then(()=>{c===zP&&(a.l=b,a.m.trigger(new _.H(_.Kc)));
|
|
16
|
+
c===IP&&(a.o=b,a.m.trigger(new _.H(_.ag)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},AP=function(a,b,c){const d=_.Hn(b.language||_.kg);c.language=_.pr(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Hc;a=new _.xr(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},BP=function(a,b,c){c.mimeType=_.zg;a=new _.xr(String(a),c);a.track=c;a.width=b.Width||null;a.height=
|
|
17
|
+
b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):null;a.codec=b.fourCC||null;return a},KP=function(a,b,c){b=_.Hn(b.track_lang||_.kg);c.mimeType="text/ttml";c.language=_.pr(b);c.originalLanguage=b;c.kind=_.SA;return new _.xr(String(a),c)},CP=function(a,b){b=b.filter(d=>d.type===IP);const c=[];for(let d=0;d<b.length;d++){const e=vP(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.tr(String(a.h++),_.P);f.renditions.push(KP(b[d].index,e,f));
|
|
18
|
+
c.push(f)}return c},FP=function(a,b,c){a=a.f[c]||[];b=String(b.index);c=null;for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===b){c=a[d].renditions[e];break}return c},LP=function(a){return a.f&&a.a?a.a.bj:webapis.avplay.getTotalTrackInfo()},NP=function(a,b,c){a.g.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};
|
|
19
|
+
a.a=MP(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Sf;a.f=!1;a.a=null;return e===jP?a.pause():a.play()})}catch(d){return Promise.reject(d)}},OP=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);c=a.m.h;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.g.debug("Could not set text track visibility",d)}},HP=function(a,b,c){b=b.toUpperCase();b===IP&&OP(a,!0);const d=a.j[b];d&&(d.ye.stop(),a.j[b]=null,a.g.debug(`Cancelled pending track switch for ${b}`));
|
|
20
|
+
return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===l?!1:l;try{webapis.avplay.setSelectTrack(h,k),a.j[h]=null,e()}catch(m){a.g.debug(`Could not set ${h} track. Trying again...`+`AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),!1===l&&(a.j[h]={type:h,index:k,Of:0,ye:new _.Li(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Of?(a.w||++k.Of,k.ye.la(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.ye.stop(),a.j[h]=null,f())}};g(b,c)})},EP=function(a){return a.f&&a.a?
|
|
21
|
+
a.a.Eh:webapis.avplay.getCurrentStreamInfo()},PP=function(a){return _.w(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",a.A)},b=>{a.g.debug("Could not load DISPLAY property");throw b;})})},QP=function(a){try{webapis.avplay.setListener({onbufferingstart:a.J.bind(a),onbufferingprogress:a.I.bind(a),onbufferingcomplete:a.H.bind(a),onstreamcompleted:a.M.bind(a),oncurrentplaytime:b=>{a.trigger(new _.H(PO,{currentTime:b}))},onevent:a.L.bind(a),
|
|
22
|
+
onsubtitlechange:a.P.bind(a),ondrmevent:a.K.bind(a),onerror:a.B.bind(a)})}catch(b){a.g.error(b)}},RP=function(a){const b=!!a.m.getTrackManager().Ra();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},SP=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,sj:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",WO+d)}catch(c){a.g.debug(c)}},TP=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
|
|
23
|
+
"|BITRATES\x3d"+b+WO+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},UP=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case KO:a.g.warn("The application doesn't have the privilege to get the mute state.",LO);break;default:a.g.warn(IO,c)}}return!!b},MP=function(a){return{position:a.getPosition(),state:a.m.getState(),Sf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:UP(a),volume:a.getVolume(),bj:LP(a),
|
|
24
|
+
Eh:EP(a)}},VP=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");XO(c,_.pe,d=>a(d));XO(c,_.Xd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},WP=function(a){return _.w(function*(){yield VP();const b=new Promise(c=>{(new _.Li(c)).la(5)});if(!(yield Promise.race([PP(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},XP=function(a){return _.w(function*(){a.g.debug("avplay.prepare()");
|
|
25
|
+
return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.g.debug("AVPlay is ready!");RP(a);b()},d=>{a.g.debug("prepareAsync failed",d);c(d)})}catch(d){a.g.debug("Failed to prepare media player for playback"),c(d)}})})},YP=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case KO:a.g.warn("The application does not have the privilege to set mute.",LO);break;default:a.g.warn(IO,c)}}},$P=function(a,b,c){return _.w(function*(){a.l=_.fn(b);const d=a.G,e=c||{estimatedBandwidth:0,
|
|
26
|
+
currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.H(OO)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.xc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(TP(a,e.nextBandwidth),a.o=!1):(a.o||SP(a,e),a.o=!0);QP(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),vb:a.m.getNetworkEngine()};
|
|
27
|
+
a.h=new ZP(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.H(VO));yield XP(a);a.f||a.trigger(new _.H(UO));f&&typeof f===_.r&&0<f&&a.seek(f).catch(h=>{a.g.debug("Couldn't set start position",h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&YP(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.g.debug("Autoplay failed",h)}))}catch(g){throw a.g.debug("Error while attempting to load source."),g;}})},aQ=function(a){if("NONE"!==a.a.getState()){var b=
|
|
28
|
+
a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},ZP=class{constructor(a,b){this.h=a;this.o=null;this.a=_.Ge;this.l=null;
|
|
29
|
+
this.j=!1;this.f=new Map;this.D=b;this.g=new _.T("clpp.tizen.DrmEngine")}init(){const a=this;return _.w(function*(){var b=_.jn[a.h.env]||null;if(!b)throw a.g.debug(_.ua,_.jb+a.h.env+_.aa),new _.I(_.D,6,6015,`DRM environment '${a.h.env}' is missing.`);a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";b=_.ln(b,a.h.customData);const d=b[_.ud];d&&a.f.set(_.ud,{Bd:d.licenseUrl||"",customData:c,df:!1});(b=
|
|
30
|
+
b[_.wd])&&a.f.set(_.wd,{Bd:b.licenseUrl||"",customData:c,df:!1});if(0===a.f.size)throw new _.I(_.D,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.ud))a.a=_.ud;else if(a.f.get(_.wd))a.a=_.wd;else throw new _.I(_.D,6,6001,"Configuration for the target system is missing.");yield $O(a);a.j=!0})}release(){const a=this;return _.w(function*(){a.j=!1;a.o=null;a.a=_.Ge;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},cP="DeleteLicenseAfterUse",dP="LicenseServer",eP="CustomData";var dQ=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.zs;this.j=7;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.T("clpp.tizen.StateManager")}initialize(){this.a.on(OO,this.C,this);this.a.on(NO,this.B,this);this.a.on(MO,this.A,this);this.a.on(VO,this.H,this);this.a.on(UO,this.G,this);this.a.on(SO,this.F,this)}release(){hP(this,_.zs);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(OO,this.C);this.a.off(NO,this.B);this.a.off(MO,this.A);this.a.off(VO,this.H);
|
|
31
|
+
this.a.off(UO,this.G);this.a.off(SO,this.F);this.m=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.C?1:2;hP(this,2)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",gP(this.f))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.l){this.l=!0;var a=this.m.getConfiguration().autoplay;const b=this.a.getState()===bQ;if(!a&&b){hP(this,4);return}}if(a=1!==this.f)a=this.a.getState(),a=a===iP||a===jP;a&&kP(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",
|
|
32
|
+
this.a.getState());this.a.getState()===cQ?hP(this,1):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){hP(this,5)}getState(){return this.f}};var eQ=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.T("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.w(function*(){if(b.m)if(b.B=a,b.j=yield lP(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),onContentSteeringInfoFound:()=>null,filterNewPeriod:()=>{},filterAllPeriods:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.g.warn(d);try{b.a=
|
|
33
|
+
yield b.j.start(a.url.replace(_.fe,"http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&mP(b.a)){b.h=nP(b);try{yield b.h.open();b.f=oP(b);const d=b.m.getConfiguration();b.f.h=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.C=d.preferForcedSubtitles}catch(d){b.g.debug("Could not setup media source..."),b.h=null,b.f=null,b.j=null,b.a=null}}}else b.g.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.g.debug("Text streamer is not initialized. Will not load()")})}G(a){this.g.debug(_.LA,
|
|
34
|
+
a.id);this.w=!0;let b=_.xE(a.textStreams,this.o||"",this.A||"",this.C)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{video:null,audio:null,text:b,Xa:null}}F(){const a=this;return _.w(function*(){a.g.debug("canSwitch_");a.w=!1;a.l&&(yield _.xF(a.f,a.l),a.l=null)})}H(){this.g.debug("onError_")}I(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.w(function*(){if(a.f)try{a.f.start()}catch(b){a.g.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.g.debug("Set text visibility",
|
|
35
|
+
a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.w(function*(){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.w(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var hQ=class extends _.V{constructor(){super();this.j=this.a=this.m=null;this.f={};this.g=new _.T("clpp.tizen.TrackManager");this.w=this.o=this.l=null;this.B=!1;this.h=1}C(a){var b=a.eventid;a=a.data;switch(b){case fQ:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+vP(this,b[0].extra_info).Bit_rate,b=wP(this,{bandwidth:b}))&&(this.w=b,uP(this,b));break;case gQ:tP(this);break;default:this.g.debug("Event type: "+
|
|
36
|
+
b+" data: "+a)}}A(a){3===a.detail.currentState&&this.m.off(_.Qf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Qf,b=>{this.B||(b=b.detail,3===b.currentState&&(this.g.debug("Current state",b.currentState),this.B=!0,xP(this)))});this.a.on("onevent",this.C,this)}release(){this.f={};this.j=this.w=this.o=this.l=null;this.B=!1;this.h=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.j=this.m.h;this.m.off(_.Qf,this.A);this.m.on(_.Qf,this.A,this);try{const a=LP(this.a);this.f=DP(this,
|
|
37
|
+
a);const b=this.f[_.Q]||[];b.length&&(this.l=b[0].renditions[0]||null);tP(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off("onevent",this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.R]||[]}getAudioTracks(){return this.f[_.Q]||[]}qa(){return this.f[_.P]||[]}ra(){return GP(this,_.R)}Na(){return GP(this,_.Q)}Ra(){return GP(this,_.P)}qb(){return this.w}Fb(){this.g.info(JO);return null}Gb(){this.g.info(JO);return null}Fa(){const a=this.ra();return a?a.track:
|
|
38
|
+
null}pa(){const a=this.Na();return a?a.track:null}va(){const a=this.Ra();return a?a.track:null}zb(a){null===a?(a=this.ra(),NP(this.a,a.bandwidth,null).then(()=>{tP(this)})):0<a.renditions.length&&this.ib(a.renditions[0])}za(a){a?JP(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ta(a){a?(a=a.renditions[0],this.j?sP(this.j,a.track):JP(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,OP(this.a,!1),this.m.trigger(new _.H(_.ag)))}ib(a){const b=
|
|
39
|
+
this.ra();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,uP(this,a),NP(this.a,b.bandwidth,a.bandwidth).then(()=>{tP(this)}).catch(c=>{const d=new _.I(_.D,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}xb(a){JP(this,a)}yb(a){this.j?sP(this.j,a.track):JP(this,a)}addTextTrack(){}wa(){return this.a.o}};hQ.prototype.isAbrEnabled=hQ.prototype.wa;
|
|
40
|
+
hQ.prototype.addTextTrack=hQ.prototype.addTextTrack;hQ.prototype.setTextRendition=hQ.prototype.yb;hQ.prototype.setAudioRendition=hQ.prototype.xb;hQ.prototype.setVideoRendition=hQ.prototype.ib;hQ.prototype.setTextTrack=hQ.prototype.Ta;hQ.prototype.setAudioTrack=hQ.prototype.za;hQ.prototype.setVideoTrack=hQ.prototype.zb;hQ.prototype.getTextTrack=hQ.prototype.va;hQ.prototype.getAudioTrack=hQ.prototype.pa;hQ.prototype.getVideoTrack=hQ.prototype.Fa;hQ.prototype.getLoadingTextRendition=hQ.prototype.Gb;
|
|
41
|
+
hQ.prototype.getLoadingAudioRendition=hQ.prototype.Fb;hQ.prototype.getLoadingVideoRendition=hQ.prototype.qb;hQ.prototype.getTextRendition=hQ.prototype.Ra;hQ.prototype.getAudioRendition=hQ.prototype.Na;hQ.prototype.getVideoRendition=hQ.prototype.ra;hQ.prototype.getTextTracks=hQ.prototype.qa;hQ.prototype.getAudioTracks=hQ.prototype.getAudioTracks;hQ.prototype.getVideoTracks=hQ.prototype.getVideoTracks;var iQ=class extends _.Nt{constructor(a){super();this.m=a;this.h=null;this.g=new _.T("clpp.tizen.Middleware");this.F=1;this.C=!1;this.l=null;this.G=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}J(){this.w=!0;this.f||this.trigger(new _.H(OO))}I(a){this.w=!0;this.trigger(new _.H(NO,{percent:a}))}H(){this.w=!1;this.trigger(new _.H(MO))}M(){this.trigger(new _.H(SO))}L(a,b){this.trigger(new _.H("onevent",{eventid:a,data:b}))}P(a,b,c,d,e){this.trigger(new _.H(TO,{duration:a,text:b,subtitleType:c,
|
|
42
|
+
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.H(QO,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.wd&&"Challenge"===b.name?bP(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.I(_.D,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}B(a){this.trigger(new _.H(RO,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(PO,f,this);e=setTimeout(()=>{this.off(PO,f);d("Timeout")},3E4)});if(a===cQ)return(new Promise((c,
|
|
43
|
+
d)=>{webapis.avplay.prepareAsync(()=>{RP(this);c(webapis.avplay.play())},e=>{this.trigger(new _.H(RO));d(e)})})).then(()=>b());if(a===jP||a===bQ)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===iP?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===jP?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===bQ||b===iP||b===jP){try{webapis.avplay.setSpeed(a),
|
|
44
|
+
this.F=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.F)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.F}load(a,b){const c=this;return _.w(function*(){c.g.debug("configure()",b||"");try{yield WP(c),yield $P(c,a,b)}catch(d){throw new _.I(_.D,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Sf;try{return webapis.avplay.getState()}catch(a){this.B(JSON.stringify(a))}}seek(a){const b=
|
|
45
|
+
1E3*a;return new Promise((c,d)=>{this.C=!0;this.m.trigger(new _.H(_.tg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.H(_.sg));c()},()=>{this.C=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.B(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.B(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.h&&(this.h.release(),
|
|
46
|
+
this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.ye.stop()}this.j={};this.F=1;this.C=!1;this.a=this.l=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case KO:this.g.debug("The application does not have the privilege to get the volume.",LO);break;default:this.g.debug(IO,b)}}return a}setVolume(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.g.warn("Invalid value passed for setVolume.",
|
|
47
|
+
"The passed value value should be in the range of 0 to 1.");break;case KO:this.g.warn("The application does not have the privilege to set the volume.",LO);break;default:this.g.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.B(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.g.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.G=
|
|
48
|
+
a}getSourceIndex(){return this.G}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},cQ="IDLE",bQ="READY",iP="PLAYING",jP="PAUSED",yP=_.Db,zP=_.lA,IP="TEXT",gQ="PLAYER_MSG_RESOLUTION_CHANGED",fQ="PLAYER_MSG_BITRATE_CHANGE",fP="PLAYREADY",aP="WIDEVINE_CDM";var mQ=class extends _.Nt{constructor(){super();this.a=new iQ(this);this.f=new dQ(this);this.configuration=this.B=_.$m();this.w=null;this.g=new _.T("clpp.tizen.Player");this.j=null;this.l=new hQ;this.C=new _.En;this.o=this.h=null;this.A=!1}I(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.H(_.Wd));this.configuration.loop?this.seek(this.configuration.startTime||0).catch(()=>{this.g.debug("Could not loop playback")}):this.a.stop()}F(a){this.trigger(new _.H(_.fg,
|
|
49
|
+
{currentTime:a.currentTime/1E3}))}J(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.Ai(d))&&this.o.append([new _.ou(b,c,d)],[])}G(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)}K(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)}H(a){this.g.debug(`Error: TYPE: ${a.eventType}`);hP(this.f,_.ps);a=new _.I(_.D,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.H(_.Xd,{detail:a}))}init(a,
|
|
50
|
+
b){this.configuration=this.B=b;this.w=a;this.a.on(SO,this.I,this);this.a.on(PO,this.F,this);this.a.on(TO,this.J,this);this.a.on(QO,this.G,this);this.a.on(RO,this.H,this);this.a.on(MO,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=jQ;jQ+=1;a="__clpp_tizen_player_"+a;this.j=_.Bi(_.He,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Mg,_.be,"position",
|
|
51
|
+
_.je,"top"];const e={};c=null!==c.parentElement?window.getComputedStyle(c,null):c.style;if(!b||0===b.length)for(d in b||(b=[]),c)b.push(d);for(const f of b)e[f]=c[f];var d=e}_.Di(a,d);aQ(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.$a)}appendLoad(){return Promise.reject(_.$a)}seekWith(){return Promise.reject(_.$a)}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}destroy(){const a=
|
|
52
|
+
this;return _.w(function*(){yield a.release();a.a.off(SO,a.I);a.a.off(PO,a.F);a.a.off(TO,a.J);a.a.off(QO,a.G);a.a.off(RO,a.H);a.a.off(MO,a.K);a.h&&(yield a.h.destroy(),a.h=null);a.j&&(a.j.parentElement.removeChild(a.j),a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return kQ}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<
|
|
53
53
|
(this.configuration.startTime||0)&&!this.A?0:5===this.f.getState()?this.getDuration():this.a.getPosition()||0}seek(a){return typeof a===_.r&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()}getPresentationStartTime(){return null}getSeekRange(){return{start:0,end:0}}getVolume(){const a=this.a.getVolume();return typeof a===_.r?a/100:null}setVolume(a){this.a.setVolume(a)}getDuration(){return this.getMediaDuration()}getMediaDuration(){return this.a.getDuration()}getBufferInfo(){this.g.warn(_.qa);
|
|
54
|
-
return new _.
|
|
55
|
-
new
|
|
56
|
-
this.f.getState()}isPaused(){return this.a.getState()===
|
|
57
|
-
|
|
54
|
+
return new _.Ht}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.w(function*(){a.h&&(yield a.h.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.l.release();a.f.release();a.A=!1})}load(a){const b=this;return _.w(function*(){b.configuration=_.bn([b.B,a]);var c=_.hs(b.configuration,[_.ee,"native"]);b.o=c.create(b);c=_.fn(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
|
|
55
|
+
new eQ;b.h.initialize(b);try{yield b.h.load(c),b.h.start()}catch(d){b.g.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),d;}b.l.load()})}play(){this.trigger(new _.H(_.We));aQ(this);return this.a.play().then(()=>{kP(this.f)})}pause(){return this.a.pause().then(()=>{kP(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.H(_.Xd,{detail:a});a.severity===_.D&&(hP(this.f,_.ps),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return 5===
|
|
56
|
+
this.f.getState()}isPaused(){return this.a.getState()===jP}isMuted(){return UP(this.a)}setMuted(a){YP(this.a,a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}setCmsdManager(){}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,b){return(new lQ).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
|
|
57
|
+
kQ="clpp.tizen",jQ=0,lQ=class{a(){return kQ}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.xc||a===_.ul||a===_.Cc)&&b){if(_.Pi(2))return 2;if(_.Pi(3)||_.Pi(4)||_.Pi(5)||_.Pi(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.na}create(){return new mQ}};_.x("clpp.tizen.TizenComponent",class extends _.yv{install(){_.Bh(new lQ)}uninstall(){var a=kQ;a&&_.zh[a]&&(delete _.zh[a],_.Ah.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});};f.call(g, window);
|
package/cl.ttml.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
let e=Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else
|
|
3
|
-
"$1em")},
|
|
4
|
-
e);for(const e of a.j)d.appendChild(
|
|
5
|
-
|
|
6
|
-
-1===[_.da,"span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},
|
|
7
|
-
60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},
|
|
8
|
-
"lineHeight","opacity","padding",
|
|
9
|
-
f.get(this.o))){g.region=f.build(a,e);g.textAlign=
|
|
10
|
-
a.getAttribute("imagetype"),a=a.j.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var
|
|
11
|
-
d,1,100);c.widthUnits=
|
|
12
|
-
this.a){d=this.a.textOutline.split(" ");e="black";let g=".4em";const h=d[0]&&d[0].trim(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!
|
|
13
|
-
"monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(
|
|
14
|
-
|
|
15
|
-
["color","color"],[
|
|
16
|
-
_.
|
|
17
|
-
new
|
|
18
|
-
g=new
|
|
19
|
-
c.getId()),c=d,g=a,
|
|
20
|
-
c.f.set(b,g),c.o.push(g),c=g):c=null,c&&a.l.push(c.getId());e=
|
|
21
|
-
e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.
|
|
22
|
-
_.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Ax='application/mp4; codecs\x3d"stpp.ttml"',Bx='application/mp4; codecs\x3d"stpp.ttml.im1i"',Cx='application/mp4; codecs\x3d"stpp.ttml.im1t"',Dx="backgroundColor",Ex="direction",Fx="displayAlign",Gx="region",Hx="textAlign",Ix="textDecoration",Jx="writingMode",Kx=function(a,b,c){a=a.f;for(let d=a.length-1;0<=d;d--){const e=b.get(a[d]);if(e.hasAttribute(c))return e.getAttribute(c)}return null},Sx=function(a,b){var c=null;if(Lx.test(a)){{a=Lx.exec(a);c=Number(a[1]);const d=Number(a[2]);
|
|
2
|
+
let e=Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else Mx.test(a)?c=Nx(Mx,a):Ox.test(a)?c=Nx(Ox,a):Px.test(a)?(a=Px.exec(a),c=Number(a[1])/b.frameRate):Qx.test(a)?(a=Qx.exec(a),c=Number(a[1])/b.a):Rx.test(a)&&(c=Nx(Rx,a));return c},Nx=function(a,b){a=a.exec(b);return null==a||""===a[0]?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+60*(Number(a[2])||0)+3600*(Number(a[1])||0)},Tx=function(a){return a.split(":").pop()},Ux=function(a){return a.replace(/(\d*\.?\d+)c/g,
|
|
3
|
+
"$1em")},Wx=function(a,b){for(;Vx.test(a);){const c=Vx.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Xx=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},Yx=function(a,b,c){a=Kx(a,b,Hx);if(!a&&c&&(a=Kx(c,b,Hx),!a&&"rltb"===Kx(c,b,Jx)))return _.Vd;switch(a){case _.Xc:return _.ju;case _.Bf:case _.Vd:return _.Vd;default:return _.Pf}},Zx=function(a,b,c){if(_.wi(a.w))return document.createTextNode(_.Ai(a.w||""));if(a.A)return _.Bi("br");const d=_.Bi("span");for(const e of a.f)_.Ci(d,
|
|
4
|
+
e);for(const e of a.j)d.appendChild(Zx(c.get(e),b,c));return d},by=function(a,b,c,d){const e=$x.exec(a);a=ay.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},cy=function(a,b){return typeof b===_.r&&0<b?_.ru:ay.test(a)?0:_.ru},dy=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},ey=function(a,b){a=a.getAttribute("extent");return(a=ay.exec(a))?Number(a[b]):null},gy=function(a){a=a.getAttribute("cellResolution");return(a=fy.exec(a))?Number(a[2]):null},
|
|
5
|
+
iy=function(){return`${"inline-"}${hy++}`},ky=function(a){return jy.some(b=>b in a.attributes)},ly=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...ly(a,a.a.get(d).f),d);return c},my=function(a){return a.o.map(b=>b.build(a.l,a.w,a.A,a.h,a.a,a.j,a.f)).filter(b=>null!=b)},ny=function(a){return Tx(a.h.nodeName)},qy=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null;let e=[],f=[],g={};const h=b.parentNode;if(h&&a.a.has(h)){const k=a.a.get(h);e=[...k.l];
|
|
6
|
+
-1===[_.da,"span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},oy.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Gx)&&(c=b.getAttribute(Gx));b.hasAttribute(_.Vf)&&f.push(...b.getAttribute(_.Vf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Tx(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new py(b,c,d,e,f,g);a.a.set(b,c);return c},ry=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/
|
|
7
|
+
60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},sy=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}getId(){return this.h}hasAttribute(a){return a in this.a}getAttribute(a){return this.a[a]}};var ty=class extends sy{constructor(a,b,c){super(a,[],c);this.j=b||""}};var uy=class extends sy{constructor(a,b,c){super(a,b,c)}};var Lx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Mx=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Ox=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Px=/^(\d*(?:\.\d*)?)f$/,Qx=/^(\d*(?:\.\d*)?)t$/,Rx=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,$x=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,ay=/^(\d+)px (\d+)px$/,fy=/^(\d+) (\d+)$/,Vx=/(\d+)px/,vy=/^(\d+px|\d+em|\d*\.?\d+c)$/,jy=[Dx,"color",Ex,Fx,"fontFamily","fontSize","fontStyle","fontWeight",
|
|
8
|
+
"lineHeight","opacity","padding",Hx,Ix,"textOutline",Jx,"zIndex"],oy=["begin",_.Vd];var wy=class extends uy{constructor(a,b,c,d,e,f,g){super(a,f,g);this.w=b;this.A=c;this.o=d;this.l=e;this.j=[]}build(a,b,c,d,e,f,g){let h=Sx(this.a.begin,b);b=Sx(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Bi(_.Fd);for(const k of this.j)c.appendChild(Zx(g.get(k),e,g));g=new _.ou(h,b,c.innerHTML.trim(),_.ig);g.cssClassList=[...this.f];g.textAlign=Yx(this,e,null);g.writingMode=_.ku;g.line=-1;g.lineInterpretation=_.lu;g.lineAlign=_.mu;g.containerRows=dy(null,gy(a),15);if(this.o&&(f=
|
|
9
|
+
f.get(this.o))){g.region=f.build(a,e);g.textAlign=Yx(this,e,f);a:switch(Kx(f,e,Jx)){case "tb":case "tblr":a=_.wg;break a;case "tbrl":a=_.xg;break a;default:a=_.ku}g.writingMode=a;a:switch(Kx(f,e,Fx)){case _.Xc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Kx(f,e,Fx)){case _.Xc:a=1;break a;default:a=_.lu}g.lineInterpretation=a;a:switch(Kx(f,e,Fx)){case _.Xc:e=_.Xc;break a;default:e=_.mu}g.lineAlign=e}this.l&&(d=d.get(this.l))&&(a=d,d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||
|
|
10
|
+
a.getAttribute("imagetype"),a=a.j.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var xy=class{constructor(a,b,c,d){this.frameRate=Number(a)||30;this.f=Number(b)||1;this.a=Number(d);0===this.a&&(this.a=a?this.frameRate*this.f:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=Number(a[1])/Number(a[2]))}};var yy=class extends uy{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.tu;c.id=this.getId();const d=dy(a.j.containerWidth,ey(a,1),720);a=dy(a.j.containerHeight,ey(a,2),480);a:switch(Kx(this,b,Fx)){case "after":var e="flex-start";break a;case _.Xc:e=_.Xc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Kx(this,b,Jx)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.qd}c.writingMode=e;e=this.getAttribute("extent")||Kx(this,b,"extent");c.width=by(e,
|
|
11
|
+
d,1,100);c.widthUnits=cy(e,d);c.height=by(e,a,2,100);c.heightUnits=cy(e,a);b=this.getAttribute("origin")||Kx(this,b,"origin");c.viewportAnchorX=by(b,d,1,0);c.viewportAnchorY=by(b,a,2,0);c.viewportAnchorUnits=cy(b,d);c.cssClassList=[...this.f];return c}};var zy=class extends sy{constructor(a,b){super("root-container",[],b);this.j=a}};var By=class extends sy{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=gy(a);c&&(b=dy(a.j.containerHeight,ey(a,2),480)/c);b=dy(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Ay.entries())g in this.a&&(c+=`${h}:${Ux(this.a[g])};`);a:{if("unicodeBidi"in this.a){var d=this.a.unicodeBidi;var e="";switch(d){case "normal":case "embed":e=d;break;case "bidiOverride":e="bidi-override"}if(0<e.length){d=`unicode-bidi:${e};`;break a}}d=""}c+=d;a:{if("textOutline"in
|
|
12
|
+
this.a){d=this.a.textOutline.split(" ");e="black";let g=".4em";const h=d[0]&&d[0].trim(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!vy.test(h)&&vy.test(k)&&vy.test(l)?(e=h,g=k):2===d.length&&!vy.test(h)&&vy.test(k)?(e=h,g=k):2===d.length&&vy.test(h)&&vy.test(k)&&(g=h);if(""!==g){g=Ux(g);d="text-shadow:"+`0 0 ${g} ${e},`+`0 0 ${g} ${e},`+`0 0 ${g} ${e};`;break a}}d=""}c+=d;"textShadow"in this.a?(d=Xx(this.a.textShadow),d=Ux(d),d=`text-shadow:${d};`):d="";c=c+d+("fontFamily"in this.a?`font-family:${this.a.fontFamily.replace("monospaceSansSerif",
|
|
13
|
+
"monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(Ix in this.a){d=this.a.textDecoration.split(" ");e=[];for(f of d)switch(f){case "underline":case "overline":e.push(f);break;case "lineThrough":e.push("line-through")}if(0<e.length){var f=`text-decoration:${e.join(" ")};`;break a}}f=""}"padding"in this.a?(d="border: solid transparent;border-width:"+
|
|
14
|
+
Ux(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Ux(d),d=Wx(d,b),c+="line-height:",c+=d,c+=";"):c="";a.push(f+c+"}");a:{if("fontSize"in this.a&&(f=this.a.fontSize.split(" "),c=null,1===f.length&&(c=f[0]),2===f.length&&(c=f[1]),c)){c=c.trim();c=Ux(c);c=Wx(c,b);b=`font-size:${c};`;break a}b=null}b&&(f=`::ttml .${this.h} .clpp-text-wrapper {`,f+=b,f+="}",a.push(f),f=`::ttml .clpp-text-wrapper__${this.h} {`,f+=b,f+="}",a.push(f));return a}},Ay=new Map([[Dx,"background-color"],
|
|
15
|
+
["color","color"],[Ex,Ex],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Cy=class{constructor(a){this.B=a;this.w=this.l=null;this.A=0;this.h=new Map;this.a=new Map;this.j=new Map;this.f=new Map;this.o=[]}},hy=0;var Fy=class{constructor(a){this.a=a.firstChild;this.f=new Set}td(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Dy.has(Tx(a.nodeName))||Ey.has(Tx(a.nodeName))||!a.firstChild||this.f.has(a.firstChild)?a.nextSibling?a=a.nextSibling:a=a.parentNode:a=a.firstChild;while(a&&(this.f.has(a)||a.nodeType!==Node.TEXT_NODE&&!Dy.has(Tx(a.nodeName))));const b=this.a;this.a=a;return b}},Dy=new Set(["tt","head","layout",_.Ae,_.ge,Gx,"styling",_.Vf,"body",
|
|
16
|
+
_.Fd,"p","span","br"]),Ey=new Set([_.Vf,_.ge]);var py=class{constructor(a,b,c,d,e,f){this.h=a;this.a=b;this.j=c;this.l=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var Gy=class{constructor(){this.a=new Map}};var Hy=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.dh(this.a.ttml||{}),e=_.G(a,0,c[0]);e=_.ni(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.$f)}catch(m){throw new _.I(_.D,2,2005,"Failed to parse TTML.");}d=new Cy(d);e=new Gy;f=new Fy(f);b=b.periodStart;typeof b===_.r&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.G(a,b,h);k=_.$l(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
|
|
17
|
+
new ty(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.td();)a=f.next(),a=qy(e,a),c=d,b=a,"tt"===ny(b)&&(c.l=new zy(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===ny(b)&&(c.w=new xy(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,ny(b)!==_.ge||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new ty(g,b.h.textContent,b.attributes))),c=d,g=a,ny(g)===_.ge&&g.attributes.begin&&g.attributes.end?(b=`#${iy()}`,
|
|
18
|
+
g=new ty(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,ny(b)===_.Vf&&(g=b.getId()||iy(),h=new By(g,b.f,Object.assign({},b.attributes)),c.a.set(g,h),b.a&&c.j.get(b.a).f.push(g)),c=d,g=a,ny(g)!==_.Vf&&ky(g)?(b=iy(),g=new By(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,ny(g)!==_.Fd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=iy(),g=new yy(b,ly(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
|
|
19
|
+
c.getId()),c=d,g=a,ny(g)!==Gx?c=null:(b=g.getId(),g=new yy(b,ly(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.l,-1===[_.da,"span","br"].indexOf(ny(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=iy(),g=new wy(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===ny(g),g.a,g.j,ly(c,g.f),g.attributes),c.f.set(b,g),(c=c.f.get(h))&&c.j.push(b),c=g):c=null),c&&a.l.push(c.getId()),c=d,g=a,"p"===ny(g)||g.j?(b=iy(),g=new wy(b,null,!1,g.a,g.j,ly(c,g.f),g.attributes),
|
|
20
|
+
c.f.set(b,g),c.o.push(g),c=g):c=null,c&&a.l.push(c.getId());e=my(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Iy=class{constructor(a){this.f=a}a(a){var b=new Hy(this.f);({cues:a}=b.parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}));b="WEBVTT\n\n";for(const d of a){a=b;b=ry(d.startTime)+" --\x3e "+ry(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.je:e.push("align:left");break;case _.Bf:e.push("align:right");break;case _.ju:e.push("align:middle");break;case _.Pf:e.push("align:start");break;case _.Vd:e.push("align:end")}switch(c.writingMode){case _.wg:e.push("vertical:lr");break;case _.xg:e.push("vertical:rl")}c=
|
|
21
|
+
e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.ri(b)}},Jy=class{probe(a,b){return a===_.Bc&&b===_.Zf}create(a){return new Iy(a)}};var Ky=class{constructor(a){this.a=new Hy(a);this.g=new _.T("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.ip).N(_.De,_.bp).N(_.hg,_.bp).N(_.ye,_.bp).N(_.Ce,_.bp).N(_.Sf,_.bp).ea(_.Uf,_.cp).N("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.I(_.D,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.ip).N("moof",_.bp).N("traf",_.bp).ea("subs",g=>{const h=_.N(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.Vo(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
|
|
22
|
+
_.N(g.reader):_.Vo(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.xe,_.dp(g=>{c=!0;g=this.a.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.g.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.x("clpp.ttml.TtmlComponent",class extends _.yv{constructor(){super();this.a=new Jy}install(){_.tt(_.Bc,Hy);_.tt(_.zc,Ky);_.tt(Ax,Ky);_.tt(Cx,Ky);_.tt(Bx,Ky);_.Jr.push(this.a)}uninstall(){_.vt(_.Bc);_.vt(_.zc);_.vt(Ax);_.vt(Cx);_.vt(Bx);_.Lr(this.a)}id(){return"subtitles-ttml"}});};f.call(g, window);
|
package/cl.verimatrix.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
|
|
3
|
-
modifiers:{licenseRequest:this.h.bind(this)}});_.
|
|
4
|
-
b);_.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var px="VerimatrixVCAS",qx="clpp.verimatrix.Vcas",rx="clpp.verimatrix.VcasComponent",tx=function(a,b){return a.C===sx?(a=Object.assign({},{deviceId:_.am(_.ti(a.A))},a.a&&{authenticator:_.am(_.ti(a.a))}),b+_.Om(a)):b},zx=class extends _.yu{constructor(a){super(px);const b={};b[ux]=ux;b[vx]=vx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=sx,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
|
|
2
|
+
wx}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=tx(this,g);this.o=tx(this,h);this.l=tx(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.T(qx);_.xi(this.w)?this.g.warn(_.Ib):this.Ya(_.wd,{licenseUrl:this.w,videoRobustness:[_.pb,void 0],audioRobustness:[_.ob,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.xi(this.o)?this.g.warn(_.fb):this.Ya(_.ud,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
|
|
3
|
+
modifiers:{licenseRequest:this.h.bind(this)}});_.xi(this.l)?this.g.warn(_.Da):_.xi(this.j)?this.g.warn(_.Ca):this.Ya(_.sd,{licenseUrl:this.l,certificateUrl:this.j,modifiers:{licenseRequest:this.J.bind(this),licenseResponse:this.K.bind(this),extractContentId:this.H.bind(this)}})}h(a,b){if(this.C===xx){a=this.B[vx];const c={};c[this.B[ux]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.hp(b);switch(this.F){case yx:a=_.Om({r:a,Ej:this.G},!0)}return a}J(a,b){this.h(a,
|
|
4
|
+
b);_.mp(b)}K(a,b){_.np(b)}};_.x(qx,zx);zx.prototype.constructor=zx.prototype.constructor;zx.NAME=px;var sx="query-string",xx="http-header";zx.LicenseRequestVuidLocation={QUERY_STRING:sx,HTTP_HEADER:xx};var ux="DeviceId",vx="Authenticator";zx.LicenseRequestHttpHeader={DEVICE_ID_HEADER:ux,AUTHENTICATOR_HEADER:vx};var wx="keyid",yx="contentid-siteid";zx.FairPlayAssetIdStrategy={KEYID:wx,CONTENTID_SITEID:yx};_.x(rx,class extends _.yv{constructor(){super();this.g=new _.T(rx)}uninstall(){delete _.jn.VerimatrixVCAS}beforeLoad(a){a=a.getConfiguration();if(a.drm&&a.drm.env===px){({customData:a}=a.drm);if(!a)throw new _.I(_.D,7,7100,_.xd);a=new zx(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.kn(a)}}id(){return"verimatrix-vcas"}});};f.call(g, window);
|
package/cl.vimond.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
new _.
|
|
3
|
-
this.h=!1}H(a){const b=this;return _.w(function*(){const c=a.detail,d=c.currentState;b.g.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.A||b.h||(d!==b.B||b.fa?b.j&&3!==d||(b.fa&&[4,2].includes(d)?b.g.debug("Seeking"):(b.fa&&3===d&&(b.g.debug("Seeked"),b.fa=!1),[3,4,_.
|
|
4
|
-
a.l=b;a.f.stop();a.f.la(a.j?10:a.J);a.j=!1;try{var c=yield a.C.fireEvent();
|
|
5
|
-
c=((new _.
|
|
6
|
-
!0)}a.progress.eventNumber=this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.
|
|
7
|
-
a.onError(new _.
|
|
8
|
-
this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var gx="Registering listeners",hx="clpp.vimond.VimondPlugin",ix=function(a,b){a.m.trigger(new _.H(_.Cg,{detail:b}))},jx=function(a,b,c){b&&(a.A=!0,a.f.stop());a.m.onError(new _.I(b?_.D:1,9,9201,c))},kx=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.gf];if(a.h)return[_.Vd,_.Se];if(5===c)return[_.Vd,null];if(c===_.ps)return[_.Xd,_.Se];b=_.Se;if(2===c||3===c||a.f)b=_.gf;return["period",b]},lx=class{constructor(a,b,c,d,e){this.J=a;this.K=b;this.L=c;this.m=d;this.C=e;this.a=
|
|
2
|
+
new _.Kt;this.j=!0;this.fa=this.h=this.A=!1;this.B=null;this.f=new _.Li(this.w.bind(this));this.g=new _.T("clpp.vimond.VimondDispatcher");this.l=this.o=0;this.m&&this.a&&(this.g.debug(gx),this.a.on(this.m,_.Qf,this.H.bind(this)),this.a.on(this.m,_.fg,this.I.bind(this)),this.a.on(this.m,_.Tb,this.F.bind(this)),this.a.on(this.m,_.Ub,this.G.bind(this)))}I(){this.fa||(this.fa=1<Math.abs(this.o-this.m.getPosition()));this.o=this.m.getPosition()}F(){this.g.debug("Ad break started");this.h=!0}G(){this.g.debug("Ad break stopped");
|
|
3
|
+
this.h=!1}H(a){const b=this;return _.w(function*(){const c=a.detail,d=c.currentState;b.g.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.A||b.h||(d!==b.B||b.fa?b.j&&3!==d||(b.fa&&[4,2].includes(d)?b.g.debug("Seeking"):(b.fa&&3===d&&(b.g.debug("Seeked"),b.fa=!1),[3,4,_.ps,5].includes(d)&&(b.B=d,yield b.w(),5===d&&b.f.stop()))):b.g.debug("Ignore transition"))})}w(){const a=this;return _.w(function*(){var b=Math.floor(Date.now()/1E3);0<a.l&&a.g.debug(`Last event was ${b-a.l} seconds ago`);
|
|
4
|
+
a.l=b;a.f.stop();a.f.la(a.j?10:a.J);a.j=!1;try{var c=yield a.C.fireEvent();ix(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),ix(a,c),jx(a,a.K,c)):1001===b?(a.g.debug("Generic service error"),ix(a,c),jx(a,a.L,c)):a.g.error(d.toString())}})}};var mx=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.h=b;this.a=d;this.j=e;this.g=new _.T("clpp.vimond.VimondService");this.f=0}fireEvent(){this.f++;const a=_.ch(this.o);a.client.buildName=_.ra;a.client.buildVersion=_.ea;var b=a.client;var c=(c=this.a.m.getDrmInfo())?c.keySystem:"";b.drm=c;a.client.pageUrl=document.location.href;a.client.streamUrl=this.a.m.getLoadedSource().url;a.client.userAgent=navigator.userAgent;a.client.videoFormat=this.a.m.getLoadedSource().type||"";b=a.client;c=this.a.m.getLoadedSource();
|
|
5
|
+
c=((new _.gp(c.url)).scheme||"").replace(":","");b.videoProtocol=c;b=kx(this.a,this.f);a.client.playerEvent=b[0]||"";a.client.playerState=b[1]||"";a.progress.vod&&(a.progress.vod.position=this.a.getPosition());if(b=a.progress.live){c=this.a;var d=c.m.getPresentationStartTime()||0;c=Math.floor(d+c.m.getPosition());c=(new Date(1E3*c)).toISOString();b.position=c;d=this.a;c=d.m.getPosition();d=d.m.getSeekRange().end;c=30>Math.abs(d-c);b.onLiveEdge=c;typeof b.liveResumePossible!==_.Nc&&(b.liveResumePossible=
|
|
6
|
+
!0)}a.progress.eventNumber=this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.wk(this.l);b.method=_.eb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.ti(JSON.stringify(a));return this.j.fetch(b).U}Df(a){this.h=a}};var nx=class{constructor(a){this.m=a;this.a=new _.Kt;this.g=new _.T("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(gx),this.a.on(this.m,_.xf,this.o.bind(this)),this.a.on(this.m,_.Tb,this.j.bind(this)),this.a.on(this.m,_.Ub,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}};var ox=class extends _.Ov{constructor(){super();this.a=!1;this.g=new _.T(hx);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.z(b.vimond)&&typeof b.vimond===_.He)?a.namespace()===_.hd&&(this.a=!1,this.g.info("Vimond does not report when casting.")):this.g.debug("Vimond plugin is loaded but not configured. Will do nothing.");if(this.a){b=a.getConfiguration().vimond;for(var c of["authToken","playerEventRequest"])if(!b[c]){this.g.warn(`${c} key is missing`);
|
|
7
|
+
a.onError(new _.I(1,9,9200));return}this.g.debug("Configuration is valid");c=b.failIfUnreachable;typeof c!==_.Nc&&(c=!0);var d=b.failOnError;typeof d!==_.Nc&&(d=!0);this.f=new nx(a);this.h=new mx(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new lx(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.zb);_.Xh(a.a)}this.j&&(a=this.j,a.g.debug(_.zb),_.Xh(a.a),a.f.stop());this.j=this.h=
|
|
8
|
+
this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}Df(a){this.a&&this.h&&this.h.Df(a)}};_.x(hx,ox);ox.prototype.updateAuthToken=ox.prototype.Df;ox.Id="vimond";_.Qn(new class{create(){return new ox}});};f.call(g, window);
|