@castlabs/prestoplay 6.31.1 → 6.32.0-beta.3
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 +32 -0
- package/README.md +2 -2
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +18 -18
- package/cjs/cl.cast.js +127 -125
- package/cjs/cl.cdn.js +13 -0
- package/cjs/cl.conviva.js +32 -32
- package/cjs/cl.core.js +615 -610
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +101 -95
- package/cjs/cl.externs.js +113 -44
- package/cjs/cl.freewheel.js +26 -26
- package/cjs/cl.hls.js +78 -78
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +26 -26
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +351 -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 -71
- package/cjs/cl.thumbnails.js +26 -26
- package/cjs/cl.tizen.js +71 -71
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +11 -11
- 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 +40 -40
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +14 -14
- package/cl.cast.js +102 -101
- package/cl.cdn.js +7 -0
- package/cl.conviva.js +27 -27
- package/cl.core.js +498 -495
- package/cl.crypto.js +9 -9
- package/cl.dash.js +91 -87
- package/cl.externs.js +109 -44
- package/cl.freewheel.js +20 -20
- package/cl.hls.js +82 -82
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +20 -20
- package/cl.mediatailor.js +2 -2
- package/cl.mse.js +301 -300
- 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 +61 -61
- 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 +7 -1
- package/typings.d.ts +328 -114
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(_.Fd);a.style.width=c+_.
|
|
6
|
-
c+_.
|
|
7
|
-
e);this.a.removeEventListener(_.Xd,d);b(new _.I(1,9,2014,"Failed to load thumbnail.",f))};this.a.addEventListener(_.
|
|
8
|
-
c),new _.I(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=_.G(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 _.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
|
|
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 Py="Thumbnail URL is mandatory",Qy="Wrong gridSize format",Ry="clpp.thumbnails",Ty=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.Ie&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Sy(a,0,e,!!f))},Promise.resolve())},Sy=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Uy(a,d).then(()=>a.a[b].load()).then(()=>Sy(a,e,c,d))},Uy=function(a,b){return new Promise(c=>{if(b||2!==a.player.getState())c();else a.player.one(_.Oc,()=>{c()})})},
|
|
2
|
+
Vy=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.ld.resolve()})},Yy=function(a,b){return Wy(a,b).then(c=>new Xy(c,b.time,b.duration))},Wy=function(a,b){return b.load().then(()=>{const c=_.G(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.cm(c)})},Zy=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},$y=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
|
|
3
|
+
az=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Nd:c,Vf:d,Fg:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},bz=function(a){return a.some(b=>0<b.thumbStreams.length)},jz=function(a){return a?a===cz||a===dz?new ez:a===fz?new gz:a===hz?new iz:null:null},kz=function(a){if(!a)return null;a=new _.lp(a);return a.path.match(/.*\.vtt$/i)?fz:a.path.match(/.*\.bif$/i)?hz:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
|
|
4
|
+
cz:null};var lz=class{constructor(){this.log=new _.T(Ry);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.yf,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Ty(this,b.preload)})}};var Xy=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+_.vf;a.style.height=d+_.vf;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+_.vf;a.style.backgroundPositionY="-"+b*d+_.vf;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(_.qe,e);this.a.removeEventListener(_.Xd,d);a(this)};d=f=>{this.a.removeEventListener(_.qe,
|
|
7
|
+
e);this.a.removeEventListener(_.Xd,d);b(new _.I(1,9,2014,"Failed to load thumbnail.",f))};this.a.addEventListener(_.qe,e);this.a.addEventListener(_.Xd,d);this.a.src=this.src}}));return this.f}};_.x("clpp.thumbnails.Thumbnail",Xy);Xy.prototype.load=Xy.prototype.load;Xy.prototype.element=Xy.prototype.element;Xy.prototype.raw=Xy.prototype.raw;var ez=class extends lz{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,Py);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,Qy);}catch(c){throw this.log.error("Error during parsing gridSize",
|
|
8
|
+
c),new _.I(1,9,7100,Qy);}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 Xy(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 mz=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.ld=new _.Kl}load(){return this.ld}},iz=class{constructor(){this.g=new _.T(Ry);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.Kl}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Py);const c=b.url;b=_.zk(c);b.type=_.yk;a.getNetworkEngine().fetch(b).V.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,nz);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 mz(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");Vy(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 Yy(b,c);yield c.load();return c})}},nz=[137,66,73,70,13,10,26,10];var gz=class extends lz{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,Py);const c=b.url,d=_.zk(c);d.type=_.yk;this.f=a.getNetworkEngine().fetch(d).V.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.ri(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=Zy(g[0]);g=Zy(g[1])-l;this.a.push(new Xy(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 oz=class extends lz{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=$y(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=az(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.Fg+k]);else if((e=f.Da())&&0<e.length){let l=g=0;f=f.startTime;1<h.Fg&&(g=k%h.Nd,l=Math.floor(k/h.Nd),f+=k*h.durationPerTile);g=new Xy(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
|
|
16
|
+
h.Nd,h.Vf,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=az(d,a),f=d.Da()[0],g=new Image;let h=d.startTime;for(let k=
|
|
17
|
+
0;k<e.Vf;++k)for(let l=0;l<e.Nd;++l)this.a.push(new Xy(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.Nd,e.Vf,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var pz=class{constructor(){this.g=new _.T(Ry);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=kz(b.url||null));(this.a=jz(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.se,()=>{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(bz(c)){this.a=new oz;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",pz);pz.prototype.get=pz.prototype.get;pz.Id="thumbnails";
|
|
19
|
+
var cz="SINGLE",dz="GRID",fz="WEBVTT",hz="BIF";_.Tn(new class{create(){return new pz}});};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 _.I(_.D,6,6005,{message:JSON.stringify(c)});}})}
|
|
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(
|
|
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.
|
|
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 _.H(
|
|
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 _.T("clpp.tizen.DrmEngine")}init(){const a=this;return _.w(function*(){var b=_.
|
|
30
|
-
b[_.wd])&&a.f.set(_.wd,{
|
|
31
|
-
this.a.off(
|
|
32
|
-
this.a.getState());this.a.getState()===
|
|
33
|
-
yield b.j.start(a.url.replace(_.fe
|
|
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[_.Q]||[];b.length&&(this.l=b[0].renditions[0]||null);
|
|
38
|
-
null}ra(){const a=this.Qa();return a?a.track:null}
|
|
39
|
-
this.ta();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.H(
|
|
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 _.H(_.
|
|
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 RO="An unknown error occurred while trying to get volume",SO="Cannot get loading rendition due to platform limitations",TO="SecurityError",UO="The require privilege is: http://tizen.org/privilege/tv.audio",VO="onbufferingcomplete",WO="onbufferingprogress",XO="onbufferingstart",YO="oncurrentplaytime",ZO="ondrmevent",$O="onerror",aP="onstreamcompleted",bP="onsubtitlechange",cP="preparingend",dP="preparingstart",eP="|STARTBITRATE\x3d",fP=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,
|
|
2
|
+
d)};a.addEventListener(b,d)},iP=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.Sd)throw new _.I(_.D,6,6012,`No license server given for ${a.a}`);try{a.a===_.wd?yield gP(a):yield hP(a,b),a.o={keySystem:a.a,licenseServerUri:b.Sd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.vf,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)});}})},kP=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=_.zk([b.serverurl&&""!==b.serverurl?b.serverurl:c.Sd],_.vk());c.type=3;c.body=e.buffer;c.method=_.eb;try{var f=yield a.D.Cb.fetch(c).V;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(jP,"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)}})},gP=function(a){return _.w(function*(){try{webapis.avplay.setDrm(jP,"Initialize",""),webapis.avplay.setDrm(jP,"widevine_app_session",a.l.id),webapis.avplay.setDrm(jP,"widevine_data_type",a.l.type)}catch(b){throw b;}})},hP=function(a,b){return _.w(function*(){var c={};c[lP]=!b.vf;c[mP]=b.Sd;""!==b.customData&&(c[nP]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",
|
|
6
|
+
c);try{webapis.avplay.setDrm(oP,"SetProperties",c)}catch(d){throw d;}})},qP=function(a,b){if(a.f!==b)if(a.f===_.As&&b!==_.Hs)a.g.debug(_.wA+`${pP(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(_.Rf,{detail:b}));a.g.debug("State changed:",
|
|
7
|
+
pP(a.j),"-\x3e",pP(a.f))}},pP=function(a){return Object.keys(_.Gs)[a]},tP=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case rP:c=3;break;case sP:c=4;break;default:a.m.isEnded()?c=5:a.g.debug("Inconsistent AVPlay playback state:",b)}qP(a,c)}},uP=function(a){return _.w(function*(){const b=a.m.getConfiguration();let c;(c=yield _.Nt(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},vP=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},wP=function(a){const b=document.createElement(_.t),c=new _.xH,d=new _.CG,e=a.m.getTextDisplayer();return new _.yH(b,c,e,d,a.m.getConfiguration())},xP=function(a){const b={configuration:{},yb:()=>a.m.getPosition(),$:a.h,Cb:a.m.getNetworkEngine(),Wc:null,nf:a.G.bind(a),Og:a.F.bind(a),onError:a.H.bind(a),Pg:()=>{},onEvent:()=>{},Sg:a.I.bind(a),Fe:()=>{},Fd:()=>new _.BI,Xe:()=>!1,Cd:null};return new _.UH(a.a,b)},yP=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},zP=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 _.Cr(String(c++),_.P);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||
|
|
10
|
+
_.WA;const f=new _.Gr(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},AP=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=zP(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},BP=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=yP(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(_.bg))),a.o=c.language):a.g.error("No stream with id",d.id)}})},CP=function(a){const b=a.ta();b&&a.m.trigger(new _.H(_.Mc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},DP=function(a,b){a.m.trigger(new _.H(_.Cg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,
|
|
12
|
+
abrSelection:a.a.o}}))},EP=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},FP=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++)_.qh(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},GP=function(a){const b=a.m.getConfiguration();var c=_.ci(b.preferredAudioLanguage||[]);const d=a.f[_.Q]||[];if(d.length){var e=null;c.some(g=>{e=_.CB(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")},MP=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===HP),f=b.filter(l=>l.type===IP);const g=[];for(var h=0;h<f.length;h++){const l=EP(a,f[h].extra_info);if(l){var k=_.Kn(l.language||_.lg);k=_.zr(k);k=c(g,k);k||(k=new _.Cr(String(a.h++),_.Q),g.push(k));k.renditions.push(JP(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.Cr(String(a.h++),_.R);for(f=0;f<e.length;f++)(h=EP(a,e[f].extra_info))?c.renditions.push(KP(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?
|
|
15
|
+
zP(a.j):LP(a,b);d[_.R]=[c];d[_.Q]=g;d[_.P]=e;return d},PP=function(a,b){if(b===_.P&&a.j)return AP(a.j);var c=NP(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.R&&(d=EP(a,c.extra_info),d=FP(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=OP(a,c,_.Q),a.l=d):d=a.l);b===_.P&&(c?(d=OP(a,c,_.P),a.o=d):d=a.o);return d},SP=function(a,b){if(b){const c=b.track.type.toUpperCase();QP(a.a,c,Number(b.id)).then(()=>{c===IP&&(a.l=b,a.m.trigger(new _.H(_.Kc)));
|
|
16
|
+
c===RP&&(a.o=b,a.m.trigger(new _.H(_.bg)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},JP=function(a,b,c){const d=_.Kn(b.language||_.lg);c.language=_.zr(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Hc;a=new _.Gr(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},KP=function(a,b,c){c.mimeType=_.Ag;a=new _.Gr(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},TP=function(a,b,c){b=_.Kn(b.track_lang||_.lg);c.mimeType="text/ttml";c.language=_.zr(b);c.originalLanguage=b;c.kind=_.WA;return new _.Gr(String(a),c)},LP=function(a,b){b=b.filter(d=>d.type===RP);const c=[];for(let d=0;d<b.length;d++){const e=EP(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.Cr(String(a.h++),_.P);f.renditions.push(TP(b[d].index,e,f));
|
|
18
|
+
c.push(f)}return c},OP=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},UP=function(a){return a.f&&a.a?a.a.mj:webapis.avplay.getTotalTrackInfo()},WP=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=VP(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.fg;a.f=!1;a.a=null;return e===sP?a.pause():a.play()})}catch(d){return Promise.reject(d)}},XP=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)}},QP=function(a,b,c){b=b.toUpperCase();b===RP&&XP(a,!0);const d=a.j[b];d&&(d.Oe.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,bg:0,Oe:new _.Pi(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.bg?(a.w||++k.bg,k.Oe.la(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.Oe.stop(),a.j[h]=null,f())}};g(b,c)})},NP=function(a){return a.f&&a.a?
|
|
21
|
+
a.a.Ph:webapis.avplay.getCurrentStreamInfo()},YP=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;})})},ZP=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(YO,{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)}},$P=function(a){const b=!!a.m.getTrackManager().Xa();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},aQ=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,Dj:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",eP+d)}catch(c){a.g.debug(c)}},bQ=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
|
|
23
|
+
"|BITRATES\x3d"+b+eP+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},cQ=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case TO:a.g.warn("The application doesn't have the privilege to get the mute state.",UO);break;default:a.g.warn(RO,c)}}return!!b},VP=function(a){return{position:a.getPosition(),state:a.m.getState(),fg:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:cQ(a),volume:a.getVolume(),mj:UP(a),
|
|
24
|
+
Ph:NP(a)}},dQ=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");fP(c,_.qe,d=>a(d));fP(c,_.Xd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},eQ=function(a){return _.w(function*(){yield dQ();const b=new Promise(c=>{(new _.Pi(c)).la(5)});if(!(yield Promise.race([YP(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},fQ=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!");$P(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)}})})},gQ=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case TO:a.g.warn("The application does not have the privilege to set mute.",UO);break;default:a.g.warn(RO,c)}}},iQ=function(a,b,c){return _.w(function*(){a.l=_.jn(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(XO)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.vc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(bQ(a,e.nextBandwidth),a.o=!1):(a.o||aQ(a,e),a.o=!0);ZP(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),Cb:a.m.getNetworkEngine()};
|
|
27
|
+
a.h=new hQ(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(dP));yield fQ(a);a.f||a.trigger(new _.H(cP));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&&gQ(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;}})},jQ=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())},hQ=class{constructor(a,b){this.h=a;this.o=null;this.a=_.He;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=_.mn[a.h.env]||null;if(!b)throw a.g.debug(_.ua,_.ib+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=_.on(b,a.h.customData);const d=b[_.ud];d&&a.f.set(_.ud,{Sd:d.licenseUrl||"",customData:c,vf:!1});(b=
|
|
30
|
+
b[_.wd])&&a.f.set(_.wd,{Sd:b.licenseUrl||"",customData:c,vf:!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 iP(a);a.j=!0})}release(){const a=this;return _.w(function*(){a.j=!1;a.o=null;a.a=_.He;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},lP="DeleteLicenseAfterUse",mP="LicenseServer",nP="CustomData";var mQ=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Hs;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(XO,this.C,this);this.a.on(WO,this.B,this);this.a.on(VO,this.A,this);this.a.on(dP,this.H,this);this.a.on(cP,this.G,this);this.a.on(aP,this.F,this)}release(){qP(this,_.Hs);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(XO,this.C);this.a.off(WO,this.B);this.a.off(VO,this.A);this.a.off(dP,this.H);
|
|
31
|
+
this.a.off(cP,this.G);this.a.off(aP,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;qP(this,2)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",pP(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()===kQ;if(!a&&b){qP(this,4);return}}if(a=1!==this.f)a=this.a.getState(),a=a===rP||a===sP;a&&tP(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",
|
|
32
|
+
this.a.getState());this.a.getState()===lQ?qP(this,1):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){qP(this,5)}getState(){return this.f}};var nQ=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 uP(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(_.ge,_.fe),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&vP(b.a)){b.h=wP(b);try{yield b.h.open();b.f=xP(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(_.PA,
|
|
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,ib: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 qQ=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 oQ:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+EP(this,b[0].extra_info).Bit_rate,b=FP(this,{bandwidth:b}))&&(this.w=b,DP(this,b));break;case pQ:CP(this);break;default:this.g.debug("Event type: "+
|
|
36
|
+
b+" data: "+a)}}A(a){3===a.detail.currentState&&this.m.off(_.Rf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Rf,b=>{this.B||(b=b.detail,3===b.currentState&&(this.g.debug("Current state",b.currentState),this.B=!0,GP(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(_.Rf,this.A);this.m.on(_.Rf,this.A,this);try{const a=UP(this.a);this.f=MP(this,
|
|
37
|
+
a);const b=this.f[_.Q]||[];b.length&&(this.l=b[0].renditions[0]||null);CP(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]||[]}sa(){return this.f[_.P]||[]}ta(){return PP(this,_.R)}Qa(){return PP(this,_.Q)}Xa(){return PP(this,_.P)}xb(){return this.w}Nb(){this.g.info(SO);return null}Ob(){this.g.info(SO);return null}Ia(){const a=this.ta();return a?a.track:
|
|
38
|
+
null}ra(){const a=this.Qa();return a?a.track:null}ua(){const a=this.Xa();return a?a.track:null}Gb(a){null===a?(a=this.ta(),WP(this.a,a.bandwidth,null).then(()=>{CP(this)})):0<a.renditions.length&&this.sb(a.renditions[0])}za(a){a?SP(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}ab(a){a?(a=a.renditions[0],this.j?BP(this.j,a.track):SP(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,XP(this.a,!1),this.m.trigger(new _.H(_.bg)))}sb(a){const b=
|
|
39
|
+
this.ta();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,DP(this,a),WP(this.a,b.bandwidth,a.bandwidth).then(()=>{CP(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...")}Eb(a){SP(this,a)}Fb(a){this.j?BP(this.j,a.track):SP(this,a)}addTextTrack(){}va(){return this.a.o}};qQ.prototype.isAbrEnabled=qQ.prototype.va;
|
|
40
|
+
qQ.prototype.addTextTrack=qQ.prototype.addTextTrack;qQ.prototype.setTextRendition=qQ.prototype.Fb;qQ.prototype.setAudioRendition=qQ.prototype.Eb;qQ.prototype.setVideoRendition=qQ.prototype.sb;qQ.prototype.setTextTrack=qQ.prototype.ab;qQ.prototype.setAudioTrack=qQ.prototype.za;qQ.prototype.setVideoTrack=qQ.prototype.Gb;qQ.prototype.getTextTrack=qQ.prototype.ua;qQ.prototype.getAudioTrack=qQ.prototype.ra;qQ.prototype.getVideoTrack=qQ.prototype.Ia;qQ.prototype.getLoadingTextRendition=qQ.prototype.Ob;
|
|
41
|
+
qQ.prototype.getLoadingAudioRendition=qQ.prototype.Nb;qQ.prototype.getLoadingVideoRendition=qQ.prototype.xb;qQ.prototype.getTextRendition=qQ.prototype.Xa;qQ.prototype.getAudioRendition=qQ.prototype.Qa;qQ.prototype.getVideoRendition=qQ.prototype.ta;qQ.prototype.getTextTracks=qQ.prototype.sa;qQ.prototype.getAudioTracks=qQ.prototype.getAudioTracks;qQ.prototype.getVideoTracks=qQ.prototype.getVideoTracks;var rQ=class extends _.Yt{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(XO))}I(a){this.w=!0;this.trigger(new _.H(WO,{percent:a}))}H(){this.w=!1;this.trigger(new _.H(VO))}M(){this.trigger(new _.H(aP))}L(a,b){this.trigger(new _.H("onevent",{eventid:a,data:b}))}P(a,b,c,d,e){this.trigger(new _.H(bP,{duration:a,text:b,subtitleType:c,
|
|
42
|
+
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.H(ZO,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.wd&&"Challenge"===b.name?kP(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($O,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(YO,f,this);e=setTimeout(()=>{this.off(YO,f);d("Timeout")},3E4)});if(a===lQ)return(new Promise((c,
|
|
43
|
+
d)=>{webapis.avplay.prepareAsync(()=>{$P(this);c(webapis.avplay.play())},e=>{this.trigger(new _.H($O));d(e)})})).then(()=>b());if(a===sP||a===kQ)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===rP?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===sP?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===kQ||b===rP||b===sP){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 eQ(c),yield iQ(c,a,b)}catch(d){throw new _.I(_.D,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.fg;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(_.ug));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.H(_.qg));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.Oe.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 TO:this.g.debug("The application does not have the privilege to get the volume.",UO);break;default:this.g.debug(RO,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 TO:this.g.warn("The application does not have the privilege to set the volume.",UO);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()]}},lQ="IDLE",kQ="READY",rP="PLAYING",sP="PAUSED",HP=_.Eb,IP=_.pA,RP="TEXT",pQ="PLAYER_MSG_RESOLUTION_CHANGED",oQ="PLAYER_MSG_BITRATE_CHANGE",oP="PLAYREADY",jP="WIDEVINE_CDM";var vQ=class extends _.Yt{constructor(){super();this.a=new rQ(this);this.f=new mQ(this);this.configuration=this.B=_.cn();this.w=null;this.g=new _.T("clpp.tizen.Player");this.j=null;this.l=new qQ;this.C=new _.Hn;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(_.gg,
|
|
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=_.Ei(d))&&this.o.append([new _.zu(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}`);qP(this.f,_.As);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(aP,this.I,this);this.a.on(YO,this.F,this);this.a.on(bP,this.J,this);this.a.on(ZO,this.G,this);this.a.on($O,this.H,this);this.a.on(VO,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=sQ;sQ+=1;a="__clpp_tizen_player_"+a;this.j=_.Fi(_.Ie,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Ng,_.be,"position",
|
|
51
|
+
_.ke,"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}_.Hi(a,d);jQ(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.ab)}appendLoad(){return Promise.reject(_.ab)}seekWith(){return Promise.reject(_.ab)}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}destroy(){const a=
|
|
52
|
+
this;return _.w(function*(){yield a.release();a.a.off(aP,a.I);a.a.off(YO,a.F);a.a.off(bP,a.J);a.a.off(ZO,a.G);a.a.off($O,a.H);a.a.off(VO,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 tQ}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 _.St}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=_.en([b.B,a]);var c=_.ss(b.configuration,[_.ee,"native"]);b.o=c.create(b);c=_.jn(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
|
|
55
|
+
new nQ;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(_.Xe));jQ(this);return this.a.play().then(()=>{tP(this.f)})}pause(){return this.a.pause().then(()=>{tP(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.H(_.Xd,{detail:a});a.severity===_.D&&(qP(this.f,_.As),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()===sP}isMuted(){return cQ(this.a)}setMuted(a){gQ(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 uQ).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
|
|
57
|
+
tQ="clpp.tizen",sQ=0,uQ=class{a(){return tQ}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.vc||a===_.xl||a===_.Cc)&&b){if(_.Ti(2))return 2;if(_.Ti(3)||_.Ti(4)||_.Ti(5)||_.Ti(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 vQ}};_.x("clpp.tizen.TizenComponent",class extends _.Ev{install(){_.Gh(new uQ)}uninstall(){var a=tQ;a&&_.Eh[a]&&(delete _.Eh[a],_.Fh.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
|
-
_.Fd,"p","span","br"]),
|
|
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
|
-
_.N(g.reader):_
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Ex='application/mp4; codecs\x3d"stpp.ttml"',Fx='application/mp4; codecs\x3d"stpp.ttml.im1i"',Gx='application/mp4; codecs\x3d"stpp.ttml.im1t"',Hx="backgroundColor",Ix="direction",Jx="displayAlign",Kx="region",Lx="textAlign",Mx="textDecoration",Nx="writingMode",Ox=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},Wx=function(a,b){var c=null;if(Px.test(a)){{a=Px.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 Qx.test(a)?c=Rx(Qx,a):Sx.test(a)?c=Rx(Sx,a):Tx.test(a)?(a=Tx.exec(a),c=Number(a[1])/b.frameRate):Ux.test(a)?(a=Ux.exec(a),c=Number(a[1])/b.a):Vx.test(a)&&(c=Rx(Vx,a));return c},Rx=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)},Xx=function(a){return a.split(":").pop()},Yx=function(a){return a.replace(/(\d*\.?\d+)c/g,
|
|
3
|
+
"$1em")},$x=function(a,b){for(;Zx.test(a);){const c=Zx.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},ay=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},by=function(a,b,c){a=Ox(a,b,Lx);if(!a&&c&&(a=Ox(c,b,Lx),!a&&"rltb"===Ox(c,b,Nx)))return _.Vd;switch(a){case _.Xc:return _.uu;case _.Cf:case _.Vd:return _.Vd;default:return _.Qf}},cy=function(a,b,c){if(_.Ai(a.w))return document.createTextNode(_.Ei(a.w||""));if(a.A)return _.Fi("br");const d=_.Fi("span");for(const e of a.f)_.Gi(d,
|
|
4
|
+
e);for(const e of a.j)d.appendChild(cy(c.get(e),b,c));return d},fy=function(a,b,c,d){const e=dy.exec(a);a=ey.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},gy=function(a,b){return typeof b===_.r&&0<b?_.Cu:ey.test(a)?0:_.Cu},hy=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},iy=function(a,b){a=a.getAttribute("extent");return(a=ey.exec(a))?Number(a[b]):null},ky=function(a){a=a.getAttribute("cellResolution");return(a=jy.exec(a))?Number(a[2]):null},
|
|
5
|
+
my=function(){return`${"inline-"}${ly++}`},oy=function(a){return ny.some(b=>b in a.attributes)},py=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...py(a,a.a.get(d).f),d);return c},qy=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)},ry=function(a){return Xx(a.h.nodeName)},uy=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={},sy.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Kx)&&(c=b.getAttribute(Kx));b.hasAttribute(_.Wf)&&f.push(...b.getAttribute(_.Wf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Xx(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new ty(b,c,d,e,f,g);a.a.set(b,c);return c},vy=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")}`},wy=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 xy=class extends wy{constructor(a,b,c){super(a,[],c);this.j=b||""}};var yy=class extends wy{constructor(a,b,c){super(a,b,c)}};var Px=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Qx=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Sx=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Tx=/^(\d*(?:\.\d*)?)f$/,Ux=/^(\d*(?:\.\d*)?)t$/,Vx=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,dy=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,ey=/^(\d+)px (\d+)px$/,jy=/^(\d+) (\d+)$/,Zx=/(\d+)px/,zy=/^(\d+px|\d+em|\d*\.?\d+c)$/,ny=[Hx,"color",Ix,Jx,"fontFamily","fontSize","fontStyle","fontWeight",
|
|
8
|
+
"lineHeight","opacity","padding",Lx,Mx,"textOutline",Nx,"zIndex"],sy=["begin",_.Vd];var Ay=class extends yy{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=Wx(this.a.begin,b);b=Wx(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Fi(_.Fd);for(const k of this.j)c.appendChild(cy(g.get(k),e,g));g=new _.zu(h,b,c.innerHTML.trim(),_.jg);g.cssClassList=[...this.f];g.textAlign=by(this,e,null);g.writingMode=_.vu;g.line=-1;g.lineInterpretation=_.wu;g.lineAlign=_.xu;g.containerRows=hy(null,ky(a),15);if(this.o&&(f=
|
|
9
|
+
f.get(this.o))){g.region=f.build(a,e);g.textAlign=by(this,e,f);a:switch(Ox(f,e,Nx)){case "tb":case "tblr":a=_.xg;break a;case "tbrl":a=_.yg;break a;default:a=_.vu}g.writingMode=a;a:switch(Ox(f,e,Jx)){case _.Xc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Ox(f,e,Jx)){case _.Xc:a=1;break a;default:a=_.wu}g.lineInterpretation=a;a:switch(Ox(f,e,Jx)){case _.Xc:e=_.Xc;break a;default:e=_.xu}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 By=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 Cy=class extends yy{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.Eu;c.id=this.getId();const d=hy(a.j.containerWidth,iy(a,1),720);a=hy(a.j.containerHeight,iy(a,2),480);a:switch(Ox(this,b,Jx)){case "after":var e="flex-start";break a;case _.Xc:e=_.Xc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Ox(this,b,Nx)){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")||Ox(this,b,"extent");c.width=fy(e,
|
|
11
|
+
d,1,100);c.widthUnits=gy(e,d);c.height=fy(e,a,2,100);c.heightUnits=gy(e,a);b=this.getAttribute("origin")||Ox(this,b,"origin");c.viewportAnchorX=fy(b,d,1,0);c.viewportAnchorY=fy(b,a,2,0);c.viewportAnchorUnits=gy(b,d);c.cssClassList=[...this.f];return c}};var Dy=class extends wy{constructor(a,b){super("root-container",[],b);this.j=a}};var Fy=class extends wy{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=ky(a);c&&(b=hy(a.j.containerHeight,iy(a,2),480)/c);b=hy(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Ey.entries())g in this.a&&(c+=`${h}:${Yx(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&&!zy.test(h)&&zy.test(k)&&zy.test(l)?(e=h,g=k):2===d.length&&!zy.test(h)&&zy.test(k)?(e=h,g=k):2===d.length&&zy.test(h)&&zy.test(k)&&(g=h);if(""!==g){g=Yx(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=ay(this.a.textShadow),d=Yx(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(Mx 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
|
+
Yx(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Yx(d),d=$x(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=Yx(c);c=$x(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}},Ey=new Map([[Hx,"background-color"],
|
|
15
|
+
["color","color"],[Ix,Ix],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Gy=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=[]}},ly=0;var Jy=class{constructor(a){this.a=a.firstChild;this.f=new Set}Md(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Hy.has(Xx(a.nodeName))||Iy.has(Xx(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&&!Hy.has(Xx(a.nodeName))));const b=this.a;this.a=a;return b}},Hy=new Set(["tt","head","layout",_.Be,_.he,Kx,"styling",_.Wf,"body",
|
|
16
|
+
_.Fd,"p","span","br"]),Iy=new Set([_.Wf,_.he]);var ty=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 Ky=class{constructor(){this.a=new Map}};var Ly=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.ih(this.a.ttml||{}),e=_.G(a,0,c[0]);e=_.ri(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.ag)}catch(m){throw new _.I(_.D,2,2005,"Failed to parse TTML.");}d=new Gy(d);e=new Ky;f=new Jy(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=_.cm(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
|
|
17
|
+
new xy(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Md();)a=f.next(),a=uy(e,a),c=d,b=a,"tt"===ry(b)&&(c.l=new Dy(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===ry(b)&&(c.w=new By(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,ry(b)!==_.he||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new xy(g,b.h.textContent,b.attributes))),c=d,g=a,ry(g)===_.he&&g.attributes.begin&&g.attributes.end?(b=`#${my()}`,
|
|
18
|
+
g=new xy(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,ry(b)===_.Wf&&(g=b.getId()||my(),h=new Fy(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,ry(g)!==_.Wf&&oy(g)?(b=my(),g=new Fy(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,ry(g)!==_.Fd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=my(),g=new Cy(b,py(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
|
|
19
|
+
c.getId()),c=d,g=a,ry(g)!==Kx?c=null:(b=g.getId(),g=new Cy(b,py(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(ry(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=my(),g=new Ay(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===ry(g),g.a,g.j,py(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"===ry(g)||g.j?(b=my(),g=new Ay(b,null,!1,g.a,g.j,py(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=qy(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var My=class{constructor(a){this.f=a}a(a){var b=new Ly(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=vy(d.startTime)+" --\x3e "+vy(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.ke:e.push("align:left");break;case _.Cf:e.push("align:right");break;case _.uu:e.push("align:middle");break;case _.Qf:e.push("align:start");break;case _.Vd:e.push("align:end")}switch(c.writingMode){case _.xg:e.push("vertical:lr");break;case _.yg:e.push("vertical:rl")}c=
|
|
21
|
+
e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.vi(b)}},Ny=class{probe(a,b){return a===_.Bc&&b===_.$f}create(a){return new My(a)}};var Oy=class{constructor(a){this.a=new Ly(a);this.g=new _.T("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.np).N(_.Ee,_.gp).N(_.ig,_.gp).N(_.ze,_.gp).N(_.De,_.gp).N(_.Tf,_.gp).fa(_.Vf,_.hp).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 _.np).N("moof",_.gp).N("traf",_.gp).fa("subs",g=>{const h=_.N(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.$o(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
|
|
22
|
+
_.N(g.reader):_.$o(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.ve,_.ip(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 Ny}install(){_.Et(_.Bc,Ly);_.Et(_.zc,Oy);_.Et(Ex,Oy);_.Et(Gx,Oy);_.Et(Fx,Oy);_.Sr.push(this.a)}uninstall(){_.Gt(_.Bc);_.Gt(_.zc);_.Gt(Ex);_.Gt(Gx);_.Gt(Fx);_.Ur(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 tx="VerimatrixVCAS",ux="clpp.verimatrix.Vcas",vx="clpp.verimatrix.VcasComponent",xx=function(a,b){return a.C===wx?(a=Object.assign({},{deviceId:_.dm(_.xi(a.A))},a.a&&{authenticator:_.dm(_.xi(a.a))}),b+_.Rm(a)):b},Dx=class extends _.Op{constructor(a){super(tx);const b={};b[yx]=yx;b[zx]=zx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=wx,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
|
|
2
|
+
Ax}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=xx(this,g);this.o=xx(this,h);this.l=xx(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.T(ux);_.Bi(this.w)?this.g.warn(_.Ib):this.Ga(_.wd,{licenseUrl:this.w,videoRobustness:[_.pb,void 0],audioRobustness:[_.ob,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.Bi(this.o)?this.g.warn(_.fb):this.Ga(_.ud,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
|
|
3
|
+
modifiers:{licenseRequest:this.h.bind(this)}});_.Bi(this.l)?this.g.warn(_.Ea):_.Bi(this.j)?this.g.warn(_.Da):this.Ga(_.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===Bx){a=this.B[zx];const c={};c[this.B[yx]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.mp(b);switch(this.F){case Cx:a=_.Rm({r:a,Pj:this.G},!0)}return a}J(a,b){this.h(a,
|
|
4
|
+
b);_.rp(b)}K(a,b){_.sp(b)}};_.x(ux,Dx);Dx.prototype.constructor=Dx.prototype.constructor;Dx.NAME=tx;var wx="query-string",Bx="http-header";Dx.LicenseRequestVuidLocation={QUERY_STRING:wx,HTTP_HEADER:Bx};var yx="DeviceId",zx="Authenticator";Dx.LicenseRequestHttpHeader={DEVICE_ID_HEADER:yx,AUTHENTICATOR_HEADER:zx};var Ax="keyid",Cx="contentid-siteid";Dx.FairPlayAssetIdStrategy={KEYID:Ax,CONTENTID_SITEID:Cx};_.x(vx,class extends _.Ev{constructor(){super();this.g=new _.T(vx)}uninstall(){delete _.mn.VerimatrixVCAS}beforeLoad(a){a=a.getConfiguration();if(a.drm&&a.drm.env===tx){({customData:a}=a.drm);if(!a)throw new _.I(_.D,7,7100,_.xd);a=new Dx(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.nn(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.ga?b.j&&3!==d||(b.ga&&[4,2].includes(d)?b.g.debug("Seeking"):(b.ga&&3===d&&(b.g.debug("Seeked"),b.ga=!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
|
-
|
|
6
|
-
|
|
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
|
|
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 kx="Registering listeners",lx="clpp.vimond.VimondPlugin",mx=function(a,b){a.m.trigger(new _.H(_.Dg,{detail:b}))},nx=function(a,b,c){b&&(a.A=!0,a.f.stop());a.m.onError(new _.I(b?_.D:1,9,9201,c))},ox=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.hf];if(a.h)return[_.Vd,_.Te];if(5===c)return[_.Vd,null];if(c===_.As)return[_.Xd,_.Te];b=_.Te;if(2===c||3===c||a.f)b=_.hf;return["period",b]},px=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 _.Vt;this.j=!0;this.ga=this.h=this.A=!1;this.B=null;this.f=new _.Pi(this.w.bind(this));this.g=new _.T("clpp.vimond.VimondDispatcher");this.l=this.o=0;this.m&&this.a&&(this.g.debug(kx),this.a.on(this.m,_.Rf,this.H.bind(this)),this.a.on(this.m,_.gg,this.I.bind(this)),this.a.on(this.m,_.Ub,this.F.bind(this)),this.a.on(this.m,_.Vb,this.G.bind(this)))}I(){this.ga||(this.ga=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.ga?b.j&&3!==d||(b.ga&&[4,2].includes(d)?b.g.debug("Seeking"):(b.ga&&3===d&&(b.g.debug("Seeked"),b.ga=!1),[3,4,_.As,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();mx(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),mx(a,c),nx(a,a.K,c)):1001===b?(a.g.debug("Generic service error"),mx(a,c),nx(a,a.L,c)):a.g.error(d.toString())}})}};var qx=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=_.hh(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.Sa().url;a.client.userAgent=navigator.userAgent;a.client.videoFormat=this.a.m.Sa().type||"";b=a.client;c=this.a.m.Sa();c=((new _.lp(c.url)).scheme||
|
|
5
|
+
"").replace(":","");b.videoProtocol=c;b=ox(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=!0)}a.progress.eventNumber=
|
|
6
|
+
this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.zk(this.l);b.method=_.eb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.xi(JSON.stringify(a));return this.j.fetch(b).V}Sf(a){this.h=a}};var rx=class{constructor(a){this.m=a;this.a=new _.Vt;this.g=new _.T("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(kx),this.a.on(this.m,_.yf,this.o.bind(this)),this.a.on(this.m,_.Ub,this.j.bind(this)),this.a.on(this.m,_.Vb,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}};var sx=class extends _.Uv{constructor(){super();this.a=!1;this.g=new _.T(lx);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.z(b.vimond)&&typeof b.vimond===_.Ie)?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 rx(a);this.h=new qx(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new px(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.Ab);_.ai(a.a)}this.j&&(a=this.j,a.g.debug(_.Ab),_.ai(a.a),a.f.stop());this.j=this.h=
|
|
8
|
+
this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}Sf(a){this.a&&this.h&&this.h.Sf(a)}};_.x(lx,sx);sx.prototype.updateAuthToken=sx.prototype.Sf;sx.Id="vimond";_.Tn(new class{create(){return new sx}});};f.call(g, window);
|