@castlabs/prestoplay 6.28.0 → 6.29.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 +15 -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 +123 -113
- package/cjs/cl.conviva.js +28 -28
- package/cjs/cl.core.js +616 -609
- package/cjs/cl.crypto.js +7 -7
- package/cjs/cl.dash.js +89 -89
- package/cjs/cl.externs.js +127 -34
- package/cjs/cl.freewheel.js +25 -25
- package/cjs/cl.hls.js +79 -78
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +24 -24
- package/cjs/cl.ima.js +24 -23
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +350 -350
- package/cjs/cl.muxdata.js +14 -14
- package/cjs/cl.onboard.js +4 -4
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.simid.js +16 -16
- package/cjs/cl.smooth.js +71 -72
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +70 -70
- 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 +37 -37
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +6 -6
- package/cl.cast.js +98 -91
- package/cl.conviva.js +27 -27
- package/cl.core.js +492 -488
- package/cl.crypto.js +8 -8
- package/cl.dash.js +82 -82
- package/cl.externs.js +123 -34
- 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 +16 -15
- package/cl.mediatailor.js +2 -2
- package/cl.mse.js +303 -304
- package/cl.muxdata.js +13 -13
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +10 -10
- 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 +187 -87
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 _.H(1,9,7100,
|
|
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=_.F(f);h=String.fromCharCode.apply(null,
|
|
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 _.H(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.w(function*(){if(0>a)throw new _.H(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 _.H(1,9,2014,`No thumbnail found for position: ${a}`);c=yield
|
|
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 Ry="Thumbnail URL is mandatory",Sy="Wrong gridSize format",Ty="clpp.thumbnails",Vy=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.He&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Uy(a,0,e,!!f))},Promise.resolve())},Uy=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Wy(a,d).then(()=>a.a[b].load()).then(()=>Uy(a,e,c,d))},Wy=function(a,b){return new Promise(c=>{if(b||2!==a.player.getState())c();else a.player.one(_.Nc,()=>{c()})})},
|
|
2
|
+
Xy=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.Sc.resolve()})},$y=function(a,b){return Yy(a,b).then(c=>new Zy(c,b.time,b.duration))},Yy=function(a,b){return b.load().then(()=>{const c=_.F(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.fm(c)})},az=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},bz=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
|
|
3
|
+
cz=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{sd:c,yf:d,lg:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},dz=function(a){return a.some(b=>0<b.thumbStreams.length)},lz=function(a){return a?a===ez||a===fz?new gz:a===hz?new iz:a===jz?new kz:null:null},mz=function(a){if(!a)return null;a=new _.mp(a);return a.path.match(/.*\.vtt$/i)?hz:a.path.match(/.*\.bif$/i)?jz:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
|
|
4
|
+
ez:null};var nz=class{constructor(){this.log=new _.S(Ty);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&&Vy(this,b.preload)})}};var Zy=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(_.Ed);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(_.se,e);this.a.removeEventListener(_.Xd,d);a(this)};d=f=>{this.a.removeEventListener(_.se,
|
|
7
|
+
e);this.a.removeEventListener(_.Xd,d);b(new _.H(1,9,2014,"Failed to load thumbnail.",f))};this.a.addEventListener(_.se,e);this.a.addEventListener(_.Xd,d);this.a.src=this.src}}));return this.f}};_.x("clpp.thumbnails.Thumbnail",Zy);Zy.prototype.load=Zy.prototype.load;Zy.prototype.element=Zy.prototype.element;Zy.prototype.raw=Zy.prototype.raw;var gz=class extends nz{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Ry);if("GRID"===b.mode&&!b.gridSize)throw new _.H(1,9,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.H(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 _.H(1,9,7100,Sy);}catch(c){throw this.log.error("Error during parsing gridSize",
|
|
8
|
+
c),new _.H(1,9,7100,Sy);}super.init(a,b)}get(a){const b=this;return _.w(function*(){var c=b.player.getDuration();if(0>a||a>c)throw new _.H(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 _.H(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 Zy(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 oz=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Sc=new _.Jl}load(){return this.Sc}},kz=class{constructor(){this.g=new _.S(Ty);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.Jl}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Ry);const c=b.url;b=_.yk(c);b.type=_.xk;a.getNetworkEngine().fetch(b).U.then(d=>{var e=d.data;d=_.F(this.a);e=_.F(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=_.F(f);h=String.fromCharCode.apply(null,pz);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 oz(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");Xy(this)}).catch(d=>{this.g.error(`[BIF] Error while loading thumbnails '
|
|
12
|
+
+ 'URL: ${c}`,d);a.onError(new _.H(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.w(function*(){if(0>a)throw new _.H(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 _.H(1,9,2014,`No thumbnail found for position: ${a}`);c=yield $y(b,c);yield c.load();return c})}},pz=[137,66,73,70,13,10,26,10];var iz=class extends nz{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Ry);const c=b.url,d=_.yk(c);d.type=_.xk;this.f=a.getNetworkEngine().fetch(d).U.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.pi(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=az(g[0]);g=az(g[1])-l;this.a.push(new Zy(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 _.H(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 _.H(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 _.H(1,9,2014,`No thumbnail found for position: ${a}`);
|
|
14
|
+
yield c.load();return c})}l(){return this.f}};var qz=class extends nz{get(a){const b=this;return _.w(function*(){function c(){return new _.H(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 _.H(1,9,2014,`Position is out of range: ${a}`);var d=b.player.getPeriods();d=bz(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=cz(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.lg+k]);else if((e=f.Ea())&&0<e.length){let l=g=0;f=f.startTime;1<h.lg&&(g=k%h.sd,l=Math.floor(k/h.sd),f+=k*h.durationPerTile);g=new Zy(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
|
|
16
|
+
h.sd,h.yf,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=cz(d,a),f=d.Ea()[0],g=new Image;let h=d.startTime;for(let k=
|
|
17
|
+
0;k<e.yf;++k)for(let l=0;l<e.sd;++l)this.a.push(new Zy(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.sd,e.yf,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var rz=class{constructor(){this.g=new _.S(Ty);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=mz(b.url||null));(this.a=lz(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(dz(c)){this.a=new qz;try{this.a.init(a,b)}catch(d){this.m.onError(d)}}}}}get(a){return this.a?this.a.get(a):Promise.reject(new _.H(1,9,2014,"Thumbnail format is not supported"))}id(){return"thumbnails"}};_.x("clpp.thumbnails.ThumbnailsPlugin",rz);rz.prototype.get=rz.prototype.get;rz.Id="thumbnails";
|
|
19
|
+
var ez="SINGLE",fz="GRID",hz="WEBVTT",jz="BIF";_.Wn(new class{create(){return new rz}});};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 _.H(_.C,6,6005,{message:JSON.stringify(c)});}})},
|
|
4
|
-
_.F(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(
|
|
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 _.G(
|
|
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 _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.w(function*(){var b=_.
|
|
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[_.P]||[];b.length&&(this.l=b[0].renditions[0]||null);
|
|
38
|
-
null}
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.G(
|
|
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 _.G(_.
|
|
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 PO="An unknown error occurred while trying to get volume",QO="Cannot get loading rendition due to platform limitations",RO="SecurityError",SO="The require privilege is: http://tizen.org/privilege/tv.audio",TO="onbufferingcomplete",UO="onbufferingprogress",VO="onbufferingstart",WO="oncurrentplaytime",XO="ondrmevent",YO="onerror",ZO="onstreamcompleted",$O="onsubtitlechange",aP="preparingend",bP="preparingstart",cP="|STARTBITRATE\x3d",dP=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,
|
|
2
|
+
d)};a.addEventListener(b,d)},gP=function(a){return _.w(function*(){if(a.a!==_.vd&&a.a!==_.td)throw new _.H(_.C,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.zd)throw new _.H(_.C,6,6012,`No license server given for ${a.a}`);try{a.a===_.vd?yield eP(a):yield fP(a,b),a.o={keySystem:a.a,licenseServerUri:b.zd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.Xe,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
|
|
3
|
+
keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.H(_.C,6,6005,{message:JSON.stringify(c)});}})},iP=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=_.yk([b.serverurl&&""!==b.serverurl?b.serverurl:c.zd],_.uk());c.type=3;c.body=e.buffer;c.method=_.cb;try{var f=yield a.D.ub.fetch(c).U;if(a.j){var g=
|
|
4
|
+
_.F(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(hP,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.H(_.C,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.H(_.C,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)}})},eP=function(a){return _.w(function*(){try{webapis.avplay.setDrm(hP,"Initialize",""),webapis.avplay.setDrm(hP,"widevine_app_session",a.l.id),webapis.avplay.setDrm(hP,"widevine_data_type",a.l.type)}catch(b){throw b;}})},fP=function(a,b){return _.w(function*(){var c={};c[jP]=!b.Xe;c[kP]=b.zd;""!==b.customData&&(c[lP]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",
|
|
6
|
+
c);try{webapis.avplay.setDrm(mP,"SetProperties",c)}catch(d){throw d;}})},oP=function(a,b){if(a.f!==b)if(a.f===_.ys&&b!==_.Fs)a.g.debug(_.zA+`${nP(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 _.G(_.Oc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):2===a.j&&a.m.trigger(new _.G(_.Nc,{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 _.G(_.Qf,{detail:b}));a.g.debug("State changed:",
|
|
7
|
+
nP(a.j),"-\x3e",nP(a.f))}},nP=function(a){return Object.keys(_.Es)[a]},rP=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case pP:c=3;break;case qP:c=4;break;default:a.m.isEnded()?c=5:a.g.debug("Inconsistent AVPlay playback state:",b)}oP(a,c)}},sP=function(a){return _.w(function*(){const b=a.m.getConfiguration();let c;(c=yield _.It(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},tP=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},uP=function(a){const b=document.createElement(_.t),c=new _.DH,d=new _.IG,e=a.m.getTextDisplayer();return new _.EH(b,c,e,d,a.m.getConfiguration())},vP=function(a){const b={configuration:{},rb:()=>a.m.getPosition(),$:a.h,ub:a.m.getNetworkEngine(),Ic:null,Re:a.G.bind(a),vg:a.F.bind(a),onError:a.H.bind(a),wg:()=>{},onEvent:()=>{},Ag:a.I.bind(a),me:()=>{},hd:()=>new _.GI,Ce:()=>!1,fd:null};return new _.$H(a.a,b)},wP=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},xP=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 _.zr(String(c++),_.O);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||
|
|
10
|
+
_.ZA;const f=new _.Dr(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},yP=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.nF(a.f,_.J);let c=null;if(b){a=xP(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},zP=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=wP(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 _.KF(a.f,c),a.m.trigger(new _.G(_.ag))),a.o=c.language):a.g.error("No stream with id",d.id)}})},AP=function(a){const b=a.ra();b&&a.m.trigger(new _.G(_.Lc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},BP=function(a,b){a.m.trigger(new _.G(_.Bg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,
|
|
12
|
+
abrSelection:a.a.o}}))},CP=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},DP=function(a,b){a=a.f[_.Q]||[];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},EP=function(a){const b=a.m.getConfiguration();var c=_.Zh(b.preferredAudioLanguage||[]);const d=a.f[_.P]||[];if(d.length){var e=null;c.some(g=>{e=_.FB(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.ya(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},KP=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===FP),f=b.filter(l=>l.type===GP);const g=[];for(var h=0;h<f.length;h++){const l=CP(a,f[h].extra_info);if(l){var k=_.Nn(l.language||_.kg);k=_.vr(k);k=c(g,k);k||(k=new _.zr(String(a.h++),_.P),g.push(k));k.renditions.push(HP(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.zr(String(a.h++),_.Q);for(f=0;f<e.length;f++)(h=CP(a,e[f].extra_info))?c.renditions.push(IP(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?
|
|
15
|
+
xP(a.j):JP(a,b);d[_.Q]=[c];d[_.P]=g;d[_.O]=e;return d},NP=function(a,b){if(b===_.O&&a.j)return yP(a.j);var c=LP(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.Q&&(d=CP(a,c.extra_info),d=DP(a,{width:d.Width,height:d.Height}));b===_.P&&(c?(d=MP(a,c,_.P),a.l=d):d=a.l);b===_.O&&(c?(d=MP(a,c,_.O),a.o=d):d=a.o);return d},QP=function(a,b){if(b){const c=b.track.type.toUpperCase();OP(a.a,c,Number(b.id)).then(()=>{c===GP&&(a.l=b,a.m.trigger(new _.G(_.Jc)));
|
|
16
|
+
c===PP&&(a.o=b,a.m.trigger(new _.G(_.ag)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},HP=function(a,b,c){const d=_.Nn(b.language||_.kg);c.language=_.vr(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Gc;a=new _.Dr(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},IP=function(a,b,c){c.mimeType=_.zg;a=new _.Dr(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},RP=function(a,b,c){b=_.Nn(b.track_lang||_.kg);c.mimeType="text/ttml";c.language=_.vr(b);c.originalLanguage=b;c.kind=_.ZA;return new _.Dr(String(a),c)},JP=function(a,b){b=b.filter(d=>d.type===PP);const c=[];for(let d=0;d<b.length;d++){const e=CP(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.zr(String(a.h++),_.O);f.renditions.push(RP(b[d].index,e,f));
|
|
18
|
+
c.push(f)}return c},MP=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},SP=function(a){return a.f&&a.a?a.a.Wi:webapis.avplay.getTotalTrackInfo()},UP=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=TP(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Kf;a.f=!1;a.a=null;return e===qP?a.pause():a.play()})}catch(d){return Promise.reject(d)}},VP=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)}},OP=function(a,b,c){b=b.toUpperCase();b===PP&&VP(a,!0);const d=a.j[b];d&&(d.ue.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,Gf:0,ue:new _.Ni(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Gf?(a.w||++k.Gf,k.ue.la(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.ue.stop(),a.j[h]=null,f())}};g(b,c)})},LP=function(a){return a.f&&a.a?
|
|
21
|
+
a.a.xh:webapis.avplay.getCurrentStreamInfo()},WP=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;})})},XP=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 _.G(WO,{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)}},YP=function(a){const b=!!a.m.getTrackManager().Qa();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},ZP=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,lj:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",cP+d)}catch(c){a.g.debug(c)}},$P=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
|
|
23
|
+
"|BITRATES\x3d"+b+cP+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},aQ=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case RO:a.g.warn("The application doesn't have the privilege to get the mute state.",SO);break;default:a.g.warn(PO,c)}}return!!b},TP=function(a){return{position:a.getPosition(),state:a.m.getState(),Kf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:aQ(a),volume:a.getVolume(),Wi:SP(a),
|
|
24
|
+
xh:LP(a)}},bQ=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");dP(c,_.se,d=>a(d));dP(c,_.Xd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},cQ=function(a){return _.w(function*(){yield bQ();const b=new Promise(c=>{(new _.Ni(c)).la(5)});if(!(yield Promise.race([WP(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},dQ=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!");YP(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)}})})},eQ=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case RO:a.g.warn("The application does not have the privilege to set mute.",SO);break;default:a.g.warn(PO,c)}}},gQ=function(a,b,c){return _.w(function*(){a.l=_.mn(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 _.G(VO)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.wc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?($P(a,e.nextBandwidth),a.o=!1):(a.o||ZP(a,e),a.o=!0);XP(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),ub:a.m.getNetworkEngine()};
|
|
27
|
+
a.h=new fQ(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.G(bP));yield dQ(a);a.f||a.trigger(new _.G(aP));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&&eQ(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;}})},hQ=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())},fQ=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 _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.w(function*(){var b=_.pn[a.h.env]||null;if(!b)throw a.g.debug(_.va,_.hb+a.h.env+_.aa),new _.H(_.C,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=_.rn(b,a.h.customData);const d=b[_.td];d&&a.f.set(_.td,{zd:d.licenseUrl||"",customData:c,Xe:!1});(b=
|
|
30
|
+
b[_.vd])&&a.f.set(_.vd,{zd:b.licenseUrl||"",customData:c,Xe:!1});if(0===a.f.size)throw new _.H(_.C,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.td))a.a=_.td;else if(a.f.get(_.vd))a.a=_.vd;else throw new _.H(_.C,6,6001,"Configuration for the target system is missing.");yield gP(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}},jP="DeleteLicenseAfterUse",kP="LicenseServer",lP="CustomData";var kQ=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Fs;this.j=7;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.S("clpp.tizen.StateManager")}initialize(){this.a.on(VO,this.C,this);this.a.on(UO,this.B,this);this.a.on(TO,this.A,this);this.a.on(bP,this.H,this);this.a.on(aP,this.G,this);this.a.on(ZO,this.F,this)}release(){oP(this,_.Fs);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(VO,this.C);this.a.off(UO,this.B);this.a.off(TO,this.A);this.a.off(bP,this.H);
|
|
31
|
+
this.a.off(aP,this.G);this.a.off(ZO,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;oP(this,2)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",nP(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()===iQ;if(!a&&b){oP(this,4);return}}if(a=1!==this.f)a=this.a.getState(),a=a===pP||a===qP;a&&rP(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",
|
|
32
|
+
this.a.getState());this.a.getState()===jQ?oP(this,1):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){oP(this,5)}getState(){return this.f}};var lQ=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 _.S("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 sP(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&&tP(b.a)){b.h=uP(b);try{yield b.h.open();b.f=vP(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(_.SA,
|
|
34
|
+
a.id);this.w=!0;let b=_.EE(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,Wa:null}}F(){const a=this;return _.w(function*(){a.g.debug("canSwitch_");a.w=!1;a.l&&(yield _.KF(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 oQ=class extends _.U{constructor(){super();this.j=this.a=this.m=null;this.f={};this.g=new _.S("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 mQ:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+CP(this,b[0].extra_info).Bit_rate,b=DP(this,{bandwidth:b}))&&(this.w=b,BP(this,b));break;case nQ:AP(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,EP(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=SP(this.a);this.f=KP(this,
|
|
37
|
+
a);const b=this.f[_.P]||[];b.length&&(this.l=b[0].renditions[0]||null);AP(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[_.Q]||[]}getAudioTracks(){return this.f[_.P]||[]}qa(){return this.f[_.O]||[]}ra(){return NP(this,_.Q)}Ma(){return NP(this,_.P)}Qa(){return NP(this,_.O)}pb(){return this.w}Eb(){this.g.info(QO);return null}Fb(){this.g.info(QO);return null}Fa(){const a=this.ra();return a?a.track:
|
|
38
|
+
null}pa(){const a=this.Ma();return a?a.track:null}ua(){const a=this.Qa();return a?a.track:null}yb(a){null===a?(a=this.ra(),UP(this.a,a.bandwidth,null).then(()=>{AP(this)})):0<a.renditions.length&&this.hb(a.renditions[0])}ya(a){a?QP(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Sa(a){a?(a=a.renditions[0],this.j?zP(this.j,a.track):QP(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,VP(this.a,!1),this.m.trigger(new _.G(_.ag)))}hb(a){const b=
|
|
39
|
+
this.ra();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,BP(this,a),UP(this.a,b.bandwidth,a.bandwidth).then(()=>{AP(this)}).catch(c=>{const d=new _.H(_.C,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...")}wb(a){QP(this,a)}xb(a){this.j?zP(this.j,a.track):QP(this,a)}addTextTrack(){}va(){return this.a.o}};oQ.prototype.isAbrEnabled=oQ.prototype.va;
|
|
40
|
+
oQ.prototype.addTextTrack=oQ.prototype.addTextTrack;oQ.prototype.setTextRendition=oQ.prototype.xb;oQ.prototype.setAudioRendition=oQ.prototype.wb;oQ.prototype.setVideoRendition=oQ.prototype.hb;oQ.prototype.setTextTrack=oQ.prototype.Sa;oQ.prototype.setAudioTrack=oQ.prototype.ya;oQ.prototype.setVideoTrack=oQ.prototype.yb;oQ.prototype.getTextTrack=oQ.prototype.ua;oQ.prototype.getAudioTrack=oQ.prototype.pa;oQ.prototype.getVideoTrack=oQ.prototype.Fa;oQ.prototype.getLoadingTextRendition=oQ.prototype.Fb;
|
|
41
|
+
oQ.prototype.getLoadingAudioRendition=oQ.prototype.Eb;oQ.prototype.getLoadingVideoRendition=oQ.prototype.pb;oQ.prototype.getTextRendition=oQ.prototype.Qa;oQ.prototype.getAudioRendition=oQ.prototype.Ma;oQ.prototype.getVideoRendition=oQ.prototype.ra;oQ.prototype.getTextTracks=oQ.prototype.qa;oQ.prototype.getAudioTracks=oQ.prototype.getAudioTracks;oQ.prototype.getVideoTracks=oQ.prototype.getVideoTracks;var pQ=class extends _.Tt{constructor(a){super();this.m=a;this.h=null;this.g=new _.S("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 _.G(VO))}I(a){this.w=!0;this.trigger(new _.G(UO,{percent:a}))}H(){this.w=!1;this.trigger(new _.G(TO))}M(){this.trigger(new _.G(ZO))}L(a,b){this.trigger(new _.G("onevent",{eventid:a,data:b}))}P(a,b,c,d,e){this.trigger(new _.G($O,{duration:a,text:b,subtitleType:c,
|
|
42
|
+
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.G(XO,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.vd&&"Challenge"===b.name?iP(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.H(_.C,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}B(a){this.trigger(new _.G(YO,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(WO,f,this);e=setTimeout(()=>{this.off(WO,f);d("Timeout")},3E4)});if(a===jQ)return(new Promise((c,
|
|
43
|
+
d)=>{webapis.avplay.prepareAsync(()=>{YP(this);c(webapis.avplay.play())},e=>{this.trigger(new _.G(YO));d(e)})})).then(()=>b());if(a===qP||a===iQ)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===pP?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===qP?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===iQ||b===pP||b===qP){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 cQ(c),yield gQ(c,a,b)}catch(d){throw new _.H(_.C,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Kf;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 _.G(_.tg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.G(_.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.ue.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 RO:this.g.debug("The application does not have the privilege to get the volume.",SO);break;default:this.g.debug(PO,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 RO:this.g.warn("The application does not have the privilege to set the volume.",SO);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()]}},jQ="IDLE",iQ="READY",pP="PLAYING",qP="PAUSED",FP=_.Cb,GP=_.sA,PP="TEXT",nQ="PLAYER_MSG_RESOLUTION_CHANGED",mQ="PLAYER_MSG_BITRATE_CHANGE",mP="PLAYREADY",hP="WIDEVINE_CDM";var tQ=class extends _.Tt{constructor(){super();this.a=new pQ(this);this.f=new kQ(this);this.configuration=this.B=_.fn();this.w=null;this.g=new _.S("clpp.tizen.Player");this.j=null;this.l=new oQ;this.C=new _.Kn;this.o=this.h=null;this.A=!1}I(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.G(_.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 _.G(_.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=_.Ci(d))&&this.o.append([new _.vu(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}`);oP(this.f,_.ys);a=new _.H(_.C,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.G(_.Xd,{detail:a}))}init(a,
|
|
50
|
+
b){this.configuration=this.B=b;this.w=a;this.a.on(ZO,this.I,this);this.a.on(WO,this.F,this);this.a.on($O,this.J,this);this.a.on(XO,this.G,this);this.a.on(YO,this.H,this);this.a.on(TO,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=qQ;qQ+=1;a="__clpp_tizen_player_"+a;this.j=_.Di(_.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}_.Fi(a,d);hQ(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.Za)}appendLoad(){return Promise.reject(_.Za)}seekWith(){return Promise.reject(_.Za)}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}destroy(){const a=
|
|
52
|
+
this;return _.w(function*(){yield a.release();a.a.off(ZO,a.I);a.a.off(WO,a.F);a.a.off($O,a.J);a.a.off(XO,a.G);a.a.off(YO,a.H);a.a.off(TO,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 rQ}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 _.Nt}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=_.hn([b.B,a]);var c=_.ns(b.configuration,[_.ee,"native"]);b.o=c.create(b);c=_.mn(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
|
|
55
|
+
new lQ;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 _.G(_.We));hQ(this);return this.a.play().then(()=>{rP(this.f)})}pause(){return this.a.pause().then(()=>{rP(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.G(_.Xd,{detail:a});a.severity===_.C&&(oP(this.f,_.ys),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()===qP}isMuted(){return aQ(this.a)}setMuted(a){eQ(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 sQ).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
|
|
57
|
+
rQ="clpp.tizen",qQ=0,sQ=class{a(){return rQ}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.wc||a===_.wl||a===_.Bc)&&b){if(_.Ri(2))return 2;if(_.Ri(3)||_.Ri(4)||_.Ri(5)||_.Ri(6))return _.B("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 tQ}};_.x("clpp.tizen.TizenComponent",class extends _.Ev{install(){_.Bh(new sQ)}uninstall(){var a=rQ;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
|
-
_.M(g.reader):_.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Gx='application/mp4; codecs\x3d"stpp.ttml"',Hx='application/mp4; codecs\x3d"stpp.ttml.im1i"',Ix='application/mp4; codecs\x3d"stpp.ttml.im1t"',Jx="backgroundColor",Kx="direction",Lx="displayAlign",Mx="region",Nx="textAlign",Ox="textDecoration",Px="writingMode",Qx=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},Yx=function(a,b){var c=null;if(Rx.test(a)){{a=Rx.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 Sx.test(a)?c=Tx(Sx,a):Ux.test(a)?c=Tx(Ux,a):Vx.test(a)?(a=Vx.exec(a),c=Number(a[1])/b.frameRate):Wx.test(a)?(a=Wx.exec(a),c=Number(a[1])/b.a):Xx.test(a)&&(c=Tx(Xx,a));return c},Tx=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)},Zx=function(a){return a.split(":").pop()},$x=function(a){return a.replace(/(\d*\.?\d+)c/g,
|
|
3
|
+
"$1em")},by=function(a,b){for(;ay.test(a);){const c=ay.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},cy=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},dy=function(a,b,c){a=Qx(a,b,Nx);if(!a&&c&&(a=Qx(c,b,Nx),!a&&"rltb"===Qx(c,b,Px)))return _.Vd;switch(a){case _.Wc:return _.qu;case _.Bf:case _.Vd:return _.Vd;default:return _.Pf}},ey=function(a,b,c){if(_.yi(a.w))return document.createTextNode(_.Ci(a.w||""));if(a.A)return _.Di("br");const d=_.Di("span");for(const e of a.f)_.Ei(d,
|
|
4
|
+
e);for(const e of a.j)d.appendChild(ey(c.get(e),b,c));return d},hy=function(a,b,c,d){const e=fy.exec(a);a=gy.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},iy=function(a,b){return typeof b===_.r&&0<b?_.yu:gy.test(a)?0:_.yu},jy=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},ky=function(a,b){a=a.getAttribute("extent");return(a=gy.exec(a))?Number(a[b]):null},my=function(a){a=a.getAttribute("cellResolution");return(a=ly.exec(a))?Number(a[2]):null},
|
|
5
|
+
oy=function(){return`${"inline-"}${ny++}`},qy=function(a){return py.some(b=>b in a.attributes)},ry=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...ry(a,a.a.get(d).f),d);return c},sy=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)},ty=function(a){return Zx(a.h.nodeName)},wy=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={},uy.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Mx)&&(c=b.getAttribute(Mx));b.hasAttribute(_.Vf)&&f.push(...b.getAttribute(_.Vf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Zx(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new vy(b,c,d,e,f,g);a.a.set(b,c);return c},xy=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")}`},yy=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 zy=class extends yy{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Ay=class extends yy{constructor(a,b,c){super(a,b,c)}};var Rx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Sx=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Ux=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Vx=/^(\d*(?:\.\d*)?)f$/,Wx=/^(\d*(?:\.\d*)?)t$/,Xx=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,fy=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,gy=/^(\d+)px (\d+)px$/,ly=/^(\d+) (\d+)$/,ay=/(\d+)px/,By=/^(\d+px|\d+em|\d*\.?\d+c)$/,py=[Jx,"color",Kx,Lx,"fontFamily","fontSize","fontStyle","fontWeight",
|
|
8
|
+
"lineHeight","opacity","padding",Nx,Ox,"textOutline",Px,"zIndex"],uy=["begin",_.Vd];var Cy=class extends Ay{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=Yx(this.a.begin,b);b=Yx(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Di(_.Ed);for(const k of this.j)c.appendChild(ey(g.get(k),e,g));g=new _.vu(h,b,c.innerHTML.trim(),_.ig);g.cssClassList=[...this.f];g.textAlign=dy(this,e,null);g.writingMode=_.ru;g.line=-1;g.lineInterpretation=_.su;g.lineAlign=_.tu;g.containerRows=jy(null,my(a),15);if(this.o&&(f=
|
|
9
|
+
f.get(this.o))){g.region=f.build(a,e);g.textAlign=dy(this,e,f);a:switch(Qx(f,e,Px)){case "tb":case "tblr":a=_.wg;break a;case "tbrl":a=_.xg;break a;default:a=_.ru}g.writingMode=a;a:switch(Qx(f,e,Lx)){case _.Wc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Qx(f,e,Lx)){case _.Wc:a=1;break a;default:a=_.su}g.lineInterpretation=a;a:switch(Qx(f,e,Lx)){case _.Wc:e=_.Wc;break a;default:e=_.tu}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 Dy=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 Ey=class extends Ay{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.Au;c.id=this.getId();const d=jy(a.j.containerWidth,ky(a,1),720);a=jy(a.j.containerHeight,ky(a,2),480);a:switch(Qx(this,b,Lx)){case "after":var e="flex-start";break a;case _.Wc:e=_.Wc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Qx(this,b,Px)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.pd}c.writingMode=e;e=this.getAttribute("extent")||Qx(this,b,"extent");c.width=hy(e,
|
|
11
|
+
d,1,100);c.widthUnits=iy(e,d);c.height=hy(e,a,2,100);c.heightUnits=iy(e,a);b=this.getAttribute("origin")||Qx(this,b,"origin");c.viewportAnchorX=hy(b,d,1,0);c.viewportAnchorY=hy(b,a,2,0);c.viewportAnchorUnits=iy(b,d);c.cssClassList=[...this.f];return c}};var Fy=class extends yy{constructor(a,b){super("root-container",[],b);this.j=a}};var Hy=class extends yy{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=my(a);c&&(b=jy(a.j.containerHeight,ky(a,2),480)/c);b=jy(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Gy.entries())g in this.a&&(c+=`${h}:${$x(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&&!By.test(h)&&By.test(k)&&By.test(l)?(e=h,g=k):2===d.length&&!By.test(h)&&By.test(k)?(e=h,g=k):2===d.length&&By.test(h)&&By.test(k)&&(g=h);if(""!==g){g=$x(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=cy(this.a.textShadow),d=$x(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(Ox 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
|
+
$x(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=$x(d),d=by(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=$x(c);c=by(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}},Gy=new Map([[Jx,"background-color"],
|
|
15
|
+
["color","color"],[Kx,Kx],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Iy=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=[]}},ny=0;var Ly=class{constructor(a){this.a=a.firstChild;this.f=new Set}qd(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Jy.has(Zx(a.nodeName))||Ky.has(Zx(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&&!Jy.has(Zx(a.nodeName))));const b=this.a;this.a=a;return b}},Jy=new Set(["tt","head","layout",_.Ae,_.ge,Mx,"styling",_.Vf,"body",
|
|
16
|
+
_.Ed,"p","span","br"]),Ky=new Set([_.Vf,_.ge]);var vy=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 My=class{constructor(){this.a=new Map}};var Ny=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=_.F(a,0,c[0]);e=_.pi(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.$f)}catch(m){throw new _.H(_.C,2,2005,"Failed to parse TTML.");}d=new Iy(d);e=new My;f=new Ly(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=_.F(a,b,h);k=_.fm(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
|
|
17
|
+
new zy(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.qd();)a=f.next(),a=wy(e,a),c=d,b=a,"tt"===ty(b)&&(c.l=new Fy(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===ty(b)&&(c.w=new Dy(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,ty(b)!==_.ge||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new zy(g,b.h.textContent,b.attributes))),c=d,g=a,ty(g)===_.ge&&g.attributes.begin&&g.attributes.end?(b=`#${oy()}`,
|
|
18
|
+
g=new zy(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,ty(b)===_.Vf&&(g=b.getId()||oy(),h=new Hy(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,ty(g)!==_.Vf&&qy(g)?(b=oy(),g=new Hy(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,ty(g)!==_.Ed||!g.attributes.extent&&!g.attributes.origin?c=null:(b=oy(),g=new Ey(b,ry(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
|
|
19
|
+
c.getId()),c=d,g=a,ty(g)!==Mx?c=null:(b=g.getId(),g=new Ey(b,ry(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(ty(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=oy(),g=new Cy(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===ty(g),g.a,g.j,ry(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"===ty(g)||g.j?(b=oy(),g=new Cy(b,null,!1,g.a,g.j,ry(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=sy(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Oy=class{constructor(a){this.f=a}a(a){var b=new Ny(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=xy(d.startTime)+" --\x3e "+xy(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 _.qu: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 _.ti(b)}},Py=class{probe(a,b){return a===_.Ac&&b===_.Zf}create(a){return new Oy(a)}};var Qy=class{constructor(a){this.a=new Ny(a);this.g=new _.S("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.op).N(_.De,_.hp).N(_.hg,_.hp).N(_.ye,_.hp).N(_.Ce,_.hp).N(_.Sf,_.hp).ea(_.Uf,_.ip).N("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.H(_.C,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.op).N("moof",_.hp).N("traf",_.hp).ea("subs",g=>{const h=_.M(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.ap(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
|
|
22
|
+
_.M(g.reader):_.ap(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.xe,_.jp(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 _.Ev{constructor(){super();this.a=new Py}install(){_.zt(_.Ac,Ny);_.zt(_.yc,Qy);_.zt(Gx,Qy);_.zt(Ix,Qy);_.zt(Hx,Qy);_.Pr.push(this.a)}uninstall(){_.Bt(_.Ac);_.Bt(_.yc);_.Bt(Gx);_.Bt(Ix);_.Bt(Hx);_.Rr(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 vx="VerimatrixVCAS",wx="clpp.verimatrix.Vcas",xx="clpp.verimatrix.VcasComponent",zx=function(a,b){return a.C===yx?(a=Object.assign({},{deviceId:_.gm(_.vi(a.A))},a.a&&{authenticator:_.gm(_.vi(a.a))}),b+_.Um(a)):b},Fx=class extends _.Fu{constructor(a){super(vx);const b={};b[Ax]=Ax;b[Bx]=Bx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=yx,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
|
|
2
|
+
Cx}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=zx(this,g);this.o=zx(this,h);this.l=zx(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.S(wx);_.zi(this.w)?this.g.warn(_.Gb):this.Xa(_.vd,{licenseUrl:this.w,videoRobustness:[_.nb,void 0],audioRobustness:[_.mb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.zi(this.o)?this.g.warn(_.db):this.Xa(_.td,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
|
|
3
|
+
modifiers:{licenseRequest:this.h.bind(this)}});_.zi(this.l)?this.g.warn(_.Da):_.zi(this.j)?this.g.warn(_.Ca):this.Xa(_.rd,{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===Dx){a=this.B[Bx];const c={};c[this.B[Ax]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.np(b);switch(this.F){case Ex:a=_.Um({r:a,xj:this.G},!0)}return a}J(a,b){this.h(a,
|
|
4
|
+
b);_.sp(b)}K(a,b){_.tp(b)}};_.x(wx,Fx);Fx.prototype.constructor=Fx.prototype.constructor;Fx.NAME=vx;var yx="query-string",Dx="http-header";Fx.LicenseRequestVuidLocation={QUERY_STRING:yx,HTTP_HEADER:Dx};var Ax="DeviceId",Bx="Authenticator";Fx.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Ax,AUTHENTICATOR_HEADER:Bx};var Cx="keyid",Ex="contentid-siteid";Fx.FairPlayAssetIdStrategy={KEYID:Cx,CONTENTID_SITEID:Ex};_.x(xx,class extends _.Ev{constructor(){super();this.g=new _.S(xx)}uninstall(){delete _.pn.VerimatrixVCAS}beforeLoad(a){a=a.getConfiguration();if(a.drm&&a.drm.env===vx){({customData:a}=a.drm);if(!a)throw new _.H(_.C,7,7100,_.wd);a=new Fx(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.qn(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 _.H(1,9,9200));return}this.g.debug("Configuration is valid");c=b.failIfUnreachable;typeof c!==_.
|
|
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 mx="Registering listeners",nx="clpp.vimond.VimondPlugin",ox=function(a,b){a.m.trigger(new _.G(_.Cg,{detail:b}))},px=function(a,b,c){b&&(a.A=!0,a.f.stop());a.m.onError(new _.H(b?_.C:1,9,9201,c))},qx=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===_.ys)return[_.Xd,_.Se];b=_.Se;if(2===c||3===c||a.f)b=_.gf;return["period",b]},rx=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 _.Qt;this.j=!0;this.fa=this.h=this.A=!1;this.B=null;this.f=new _.Ni(this.w.bind(this));this.g=new _.S("clpp.vimond.VimondDispatcher");this.l=this.o=0;this.m&&this.a&&(this.g.debug(mx),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,_.Sb,this.F.bind(this)),this.a.on(this.m,_.Tb,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,_.ys,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();ox(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),ox(a,c),px(a,a.K,c)):1001===b?(a.g.debug("Generic service error"),ox(a,c),px(a,a.L,c)):a.g.error(d.toString())}})}};var sx=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 _.S("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 _.mp(c.url)).scheme||"").replace(":","");b.videoProtocol=c;b=qx(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!==_.Mc&&(b.liveResumePossible=
|
|
6
|
+
!0)}a.progress.eventNumber=this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.yk(this.l);b.method=_.cb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.vi(JSON.stringify(a));return this.j.fetch(b).U}vf(a){this.h=a}};var tx=class{constructor(a){this.m=a;this.a=new _.Qt;this.g=new _.S("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(mx),this.a.on(this.m,_.xf,this.o.bind(this)),this.a.on(this.m,_.Sb,this.j.bind(this)),this.a.on(this.m,_.Tb,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}};var ux=class extends _.Uv{constructor(){super();this.a=!1;this.g=new _.S(nx);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()===_.gd&&(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 _.H(1,9,9200));return}this.g.debug("Configuration is valid");c=b.failIfUnreachable;typeof c!==_.Mc&&(c=!0);var d=b.failOnError;typeof d!==_.Mc&&(d=!0);this.f=new tx(a);this.h=new sx(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new rx(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.xb);_.Xh(a.a)}this.j&&(a=this.j,a.g.debug(_.xb),_.Xh(a.a),a.f.stop());this.j=this.h=
|
|
8
|
+
this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}vf(a){this.a&&this.h&&this.h.vf(a)}};_.x(nx,ux);ux.prototype.updateAuthToken=ux.prototype.vf;ux.Id="vimond";_.Wn(new class{create(){return new ux}});};f.call(g, window);
|