@castlabs/prestoplay 6.32.0 → 6.33.0-beta.1
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 +29 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +19 -19
- package/cjs/cl.cast.js +129 -127
- package/cjs/cl.conviva.js +32 -32
- package/cjs/cl.core.js +620 -625
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +101 -101
- package/cjs/cl.externs.js +45 -41
- package/cjs/cl.freewheel.js +25 -25
- package/cjs/cl.hls.js +76 -76
- 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 +359 -352
- 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 +72 -72
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +12 -12
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.yospace.js +4 -4
- package/cjs/cl.youbora.js +35 -35
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +14 -14
- package/cl.cast.js +101 -102
- package/cl.conviva.js +27 -27
- package/cl.core.js +497 -503
- package/cl.crypto.js +9 -9
- package/cl.dash.js +89 -89
- package/cl.externs.js +50 -42
- 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 +305 -303
- package/cl.muxdata.js +13 -13
- package/cl.onboard.js +5 -4
- package/cl.persistent.js +11 -11
- 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 +57 -57
- 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 +30 -30
- package/package.json +1 -1
- package/typings.d.ts +32 -24
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 _.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 _.
|
|
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 zy="Thumbnail URL is mandatory",Ay="Wrong gridSize format",By="clpp.thumbnails",Dy=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.Ce&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Cy(a,0,e,!!f))},Promise.resolve())},Cy=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Ey(a,d).then(()=>a.a[b].load()).then(()=>Cy(a,e,c,d))},Ey=function(a,b){return new Promise(c=>{if(b||2!==a.player.getState())c();else a.player.one(_.Nc,()=>{c()})})},
|
|
2
|
+
Fy=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.jd.resolve()})},Iy=function(a,b){return Gy(a,b).then(c=>new Hy(c,b.time,b.duration))},Gy=function(a,b){return b.load().then(()=>{const c=_.G(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.Ml(c)})},Jy=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},Ky=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
|
|
3
|
+
Ly=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Ld:c,Nf:d,wg:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},My=function(a){return a.some(b=>0<b.thumbStreams.length)},Uy=function(a){return a?a===Ny||a===Oy?new Py:a===Qy?new Ry:a===Sy?new Ty:null:null},Vy=function(a){if(!a)return null;a=new _.Zp(a);return a.path.match(/.*\.vtt$/i)?Qy:a.path.match(/.*\.bif$/i)?Sy:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
|
|
4
|
+
Ny:null};var Wy=class{constructor(){this.log=new _.T(By);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.sf,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Dy(this,b.preload)})}};var Hy=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(_.Ad);a.style.width=c+_.pf;a.style.height=d+_.pf;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+_.pf;a.style.backgroundPositionY="-"+b*d+_.pf;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(_.ke,e);this.a.removeEventListener(_.Sd,d);a(this)};d=f=>{this.a.removeEventListener(_.ke,
|
|
7
|
+
e);this.a.removeEventListener(_.Sd,d);b(new _.I(1,9,2014,"Failed to load thumbnail.",f))};this.a.addEventListener(_.ke,e);this.a.addEventListener(_.Sd,d);this.a.src=this.src}}));return this.f}};_.w("clpp.thumbnails.Thumbnail",Hy);Hy.prototype.load=Hy.prototype.load;Hy.prototype.element=Hy.prototype.element;Hy.prototype.raw=Hy.prototype.raw;var Py=class extends Wy{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,zy);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,Ay);}catch(c){throw this.log.error("Error during parsing gridSize",
|
|
8
|
+
c),new _.I(1,9,7100,Ay);}super.init(a,b)}get(a){const b=this;return _.v(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 Hy(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 Xy=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.jd=new _.wl}load(){return this.jd}},Ty=class{constructor(){this.g=new _.T(By);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.wl}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,zy);const c=b.url;b=_.rk(c);b.type=_.qk;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,Yy);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 Xy(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");Fy(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 _.v(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 Iy(b,c);yield c.load();return c})}},Yy=[137,66,73,70,13,10,26,10];var Ry=class extends Wy{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.I(1,9,7100,zy);const c=b.url,d=_.rk(c);d.type=_.qk;this.f=a.getNetworkEngine().fetch(d).V.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.ii(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=Jy(g[0]);g=Jy(g[1])-l;this.a.push(new Hy(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 _.v(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 Zy=class extends Wy{get(a){const b=this;return _.v(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=Ky(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=Ly(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.wg+k]);else if((e=f.Da())&&0<e.length){let l=g=0;f=f.startTime;1<h.wg&&(g=k%h.Ld,l=Math.floor(k/h.Ld),f+=k*h.durationPerTile);g=new Hy(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
|
|
16
|
+
h.Ld,h.Nf,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=Ly(d,a),f=d.Da()[0],g=new Image;let h=d.startTime;for(let k=
|
|
17
|
+
0;k<e.Nf;++k)for(let l=0;l<e.Ld;++l)this.a.push(new Hy(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.Ld,e.Nf,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var $y=class{constructor(){this.g=new _.T(By);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=Vy(b.url||null));(this.a=Uy(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.me,()=>{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(My(c)){this.a=new Zy;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"}};_.w("clpp.thumbnails.ThumbnailsPlugin",$y);$y.prototype.get=$y.prototype.get;$y.Id="thumbnails";
|
|
19
|
+
var Ny="SINGLE",Oy="GRID",Qy="WEBVTT",Sy="BIF";_.En(new class{create(){return new $y}});};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
|
-
|
|
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.za(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},
|
|
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 _.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
|
-
|
|
30
|
-
|
|
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 _.
|
|
36
|
-
b+" data: "+a)}}A(a){3===a.detail.currentState&&this.m.off(_.
|
|
37
|
-
a);const b=this.f[_.
|
|
38
|
-
null}ra(){const a=this.
|
|
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 _.
|
|
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 _.
|
|
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(_.
|
|
54
|
-
return new _.
|
|
55
|
-
new
|
|
56
|
-
this.f.getState()}isPaused(){return this.a.getState()===
|
|
57
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var JO="An unknown error occurred while trying to get volume",KO="Cannot get loading rendition due to platform limitations",LO="SecurityError",MO="The require privilege is: http://tizen.org/privilege/tv.audio",NO="WIDEVINE_CDM",OO="onbufferingcomplete",PO="onbufferingprogress",QO="onbufferingstart",RO="oncurrentplaytime",SO="ondrmevent",TO="onerror",UO="onstreamcompleted",VO="onsubtitlechange",WO="preparingend",XO="preparingstart",YO="|STARTBITRATE\x3d",ZO=function(a,b,c){const d=e=>
|
|
2
|
+
{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},bP=function(a){return _.v(function*(){if(a.a!==_.td&&a.a!==_.rd)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.Qd)throw new _.I(_.D,6,6012,`No license server given for ${a.a}`);try{a.a===_.td?yield $O(a):yield aP(a,b),a.o={keySystem:a.a,licenseServerUri:b.Qd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.mf,audioRobustness:"",videoRobustness:"",
|
|
3
|
+
serverCertificate:null,initData:[],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)});}})},cP=function(a,b){_.v(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=_.rk([b.serverurl&&""!==b.serverurl?b.serverurl:c.Qd],_.mk());c.type=3;c.body=e.buffer;c.method=_.bb;try{var f=yield a.D.Bb.fetch(c).V;
|
|
4
|
+
if(a.j){var g=_.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(NO,"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)}})},$O=function(a){return _.v(function*(){try{webapis.avplay.setDrm(NO,"Initialize",""),webapis.avplay.setDrm(NO,"widevine_app_session",a.l.id),webapis.avplay.setDrm(NO,"widevine_data_type",a.l.type)}catch(b){throw b;}})},aP=function(a,b){return _.v(function*(){var c={};c[dP]=!b.mf;c[eP]=b.Qd;""!==b.customData&&(c[fP]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",
|
|
6
|
+
c);try{webapis.avplay.setDrm("PLAYREADY","SetProperties",c)}catch(d){throw d;}})},hP=function(a,b){if(a.f!==b)if(a.f===_.ko&&b!==_.qo)a.g.debug(_.hA+`${gP(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;2===a.f?(a.o=(new Date).getTime(),a.m.trigger(new _.H(_.Oc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):2===a.j&&a.m.trigger(new _.H(_.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 _.H(_.Lf,{detail:b}));
|
|
7
|
+
a.g.debug("State changed:",gP(a.j),"-\x3e",gP(a.f))}},gP=function(a){return Object.keys(_.no)[a]},kP=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case iP:c=3;break;case jP:c=4;break;default:a.m.isEnded()?c=5:a.g.debug("Inconsistent AVPlay playback state:",b)}hP(a,c)}},lP=function(a){return _.v(function*(){const b=a.m.getConfiguration();let c;(c=yield _.tt(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},mP=function(a){if(!a)return!1;
|
|
8
|
+
a=a.periods;let b=!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},nP=function(a){const b=document.createElement(_.t),c=new _.oH,d=new _.uG,e=a.m.getTextDisplayer();return new _.pH(b,c,e,d,a.m.getConfiguration())},oP=function(a){const b={configuration:{},xb:()=>a.m.getPosition(),$:a.h,Bb:a.m.getNetworkEngine(),Tc:null,ff:a.G.bind(a),Fg:a.F.bind(a),onError:a.H.bind(a),Gg:()=>{},onEvent:()=>{},Jg:a.I.bind(a),Ae:()=>{},Dd:()=>new _.tI,Qe:()=>!1,zd:null};return new _.MH(a.a,b)},
|
|
9
|
+
pP=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},qP=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.So(String(c++),_.M);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;
|
|
10
|
+
e.kind=a[d].kind||_.JA;const f=new _.Wo(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},rP=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.ZE(a.f,_.K);let c=null;if(b){a=qP(a);for(let d=0;d<a.length;d++)if(a[d].renditions[0].id===String(b.id)){c=a[d].renditions[0];break}}return c}return null},sP=function(a,b){_.v(function*(){a.g.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.Ud,
|
|
11
|
+
a.a&&a.f)){a.setTextVisibility(!0);var c=pP(a);const d=b.renditions[0];(c=c.textStreams.find(e=>String(e.id)===d.id))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=c):(yield _.pF(a.f,c),a.m.trigger(new _.H(_.Wf))),a.o=c.language):a.g.error("No stream with id",d.id)}})},tP=function(a){const b=a.ta();b&&a.m.trigger(new _.H(_.Lc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},uP=function(a,b){a.m.trigger(new _.H(_.tg,{details:{width:b.width,height:b.height,
|
|
12
|
+
bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},vP=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},wP=function(a,b){a=a.f[_.O]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.gh(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},xP=function(a){const b=a.m.getConfiguration();var c=_.Uh(b.preferredAudioLanguage||[]);const d=a.f[_.N]||[];if(d.length){var e=
|
|
13
|
+
null;c.some(g=>{e=_.qB(g,d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",e);a.za(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},DP=function(a,b){var c=(l,m)=>{for(let n=0;n<l.length;n++)if(l[n].language===m)return l[n];return null};
|
|
14
|
+
const d={};if(0>=b.length)return d;var e=b.filter(l=>l.type===yP),f=b.filter(l=>l.type===zP);const g=[];for(var h=0;h<f.length;h++){const l=vP(a,f[h].extra_info);if(l){var k=_.vn(l.language||_.fg);k=_.Po(k);k=c(g,k);k||(k=new _.So(String(a.h++),_.N),g.push(k));k.renditions.push(AP(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.So(String(a.h++),_.O);for(f=0;f<e.length;f++)(h=vP(a,e[f].extra_info))?c.renditions.push(BP(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");
|
|
15
|
+
e=[];e=a.j?qP(a.j):CP(a,b);d[_.O]=[c];d[_.N]=g;d[_.M]=e;return d},GP=function(a,b){if(b===_.M&&a.j)return rP(a.j);var c=EP(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.O&&(d=vP(a,c.extra_info),d=wP(a,{width:d.Width,height:d.Height}));b===_.N&&(c?(d=FP(a,c,_.N),a.l=d):d=a.l);b===_.M&&(c?(d=FP(a,c,_.M),a.o=d):d=a.o);return d},JP=function(a,b){if(b){const c=b.track.type.toUpperCase();HP(a.a,c,Number(b.id)).then(()=>{c===zP&&(a.l=b,a.m.trigger(new _.H(_.Jc)));
|
|
16
|
+
c===IP&&(a.o=b,a.m.trigger(new _.H(_.Wf)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},AP=function(a,b,c){const d=_.vn(b.language||_.fg);c.language=_.Po(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Gc;a=new _.Wo(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},BP=function(a,b,c){c.mimeType=_.rg;a=new _.Wo(String(a),c);a.track=c;a.width=b.Width||null;a.height=
|
|
17
|
+
b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):null;a.codec=b.fourCC||null;return a},KP=function(a,b,c){b=_.vn(b.track_lang||_.fg);c.mimeType="text/ttml";c.language=_.Po(b);c.originalLanguage=b;c.kind=_.JA;return new _.Wo(String(a),c)},CP=function(a,b){b=b.filter(d=>d.type===IP);const c=[];for(let d=0;d<b.length;d++){const e=vP(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.So(String(a.h++),_.M);f.renditions.push(KP(b[d].index,e,f));
|
|
18
|
+
c.push(f)}return c},FP=function(a,b,c){a=a.f[c]||[];b=String(b.index);c=null;for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===b){c=a[d].renditions[e];break}return c},LP=function(a){return a.f&&a.a?a.a.hj:webapis.avplay.getTotalTrackInfo()},NP=function(a,b,c){a.g.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};
|
|
19
|
+
a.a=MP(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Xf;a.f=!1;a.a=null;return e===jP?a.pause():a.play()})}catch(d){return Promise.reject(d)}},OP=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);c=a.m.h;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.g.debug("Could not set text track visibility",d)}},HP=function(a,b,c){b=b.toUpperCase();b===IP&&OP(a,!0);const d=a.j[b];d&&(d.Ie.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,Tf:0,Ie:new _.Ii(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Tf?(a.w||++k.Tf,k.Ie.la(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.Ie.stop(),a.j[h]=null,f())}};g(b,c)})},EP=function(a){return a.f&&a.a?
|
|
21
|
+
a.a.Hh:webapis.avplay.getCurrentStreamInfo()},PP=function(a){return _.v(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",a.A)},b=>{a.g.debug("Could not load DISPLAY property");throw b;})})},QP=function(a){try{webapis.avplay.setListener({onbufferingstart:a.J.bind(a),onbufferingprogress:a.I.bind(a),onbufferingcomplete:a.H.bind(a),onstreamcompleted:a.M.bind(a),oncurrentplaytime:b=>{a.trigger(new _.H(RO,{currentTime:b}))},onevent:a.L.bind(a),
|
|
22
|
+
onsubtitlechange:a.P.bind(a),ondrmevent:a.K.bind(a),onerror:a.B.bind(a)})}catch(b){a.g.error(b)}},RP=function(a){const b=!!a.m.getTrackManager().Va();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},SP=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,zj:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",YO+d)}catch(c){a.g.debug(c)}},TP=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
|
|
23
|
+
"|BITRATES\x3d"+b+YO+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},UP=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case LO:a.g.warn("The application doesn't have the privilege to get the mute state.",MO);break;default:a.g.warn(JO,c)}}return!!b},MP=function(a){return{position:a.getPosition(),state:a.m.getState(),Xf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:UP(a),volume:a.getVolume(),hj:LP(a),
|
|
24
|
+
Hh:EP(a)}},VP=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");ZO(c,_.ke,d=>a(d));ZO(c,_.Sd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},WP=function(a){return _.v(function*(){yield VP();const b=new Promise(c=>{(new _.Ii(c)).la(5)});if(!(yield Promise.race([PP(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},XP=function(a){return _.v(function*(){a.g.debug("avplay.prepare()");
|
|
25
|
+
return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.g.debug("AVPlay is ready!");RP(a);b()},d=>{a.g.debug("prepareAsync failed",d);c(d)})}catch(d){a.g.debug("Failed to prepare media player for playback"),c(d)}})})},YP=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case LO:a.g.warn("The application does not have the privilege to set mute.",MO);break;default:a.g.warn(JO,c)}}},$P=function(a,b,c){return _.v(function*(){a.l=_.Um(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(QO)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.tc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(TP(a,e.nextBandwidth),a.o=!1):(a.o||SP(a,e),a.o=!0);QP(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),Bb:a.m.getNetworkEngine()};
|
|
27
|
+
a.h=new ZP(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.H(XO));yield XP(a);a.f||a.trigger(new _.H(WO));f&&typeof f===_.r&&0<f&&a.seek(f).catch(h=>{a.g.debug("Couldn't set start position",h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&YP(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.g.debug("Autoplay failed",h)}))}catch(g){throw a.g.debug("Error while attempting to load source."),g;}})},aQ=function(a){if("NONE"!==a.a.getState()){var b=
|
|
28
|
+
a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())};var ZP=class{constructor(a,b){this.h=a;this.o=null;this.a=_.Be;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.T("clpp.tizen.DrmEngine")}init(){const a=this;return _.v(function*(){var b=_.Xm[a.h.env]||null;if(!b)throw a.g.debug(_.va,_.fb+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=_.Zm(b,a.h.customData);const d=
|
|
29
|
+
b[_.rd];d&&a.f.set(_.rd,{Qd:d.licenseUrl||"",customData:c,mf:!1});(b=b[_.td])&&a.f.set(_.td,{Qd:b.licenseUrl||"",customData:c,mf:!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(_.rd))a.a=_.rd;else if(a.f.get(_.td))a.a=_.td;else throw new _.I(_.D,6,6001,"Configuration for the target system is missing.");yield bP(a);a.j=!0})}release(){const a=this;return _.v(function*(){a.j=!1;a.o=null;a.a=_.Be;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},
|
|
30
|
+
dP="DeleteLicenseAfterUse",eP="LicenseServer",fP="CustomData";var dQ=class{constructor(a){this.m=a;this.a=this.m.a;this.j=this.f=_.qo;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(QO,this.C,this);this.a.on(PO,this.B,this);this.a.on(OO,this.A,this);this.a.on(XO,this.H,this);this.a.on(WO,this.G,this);this.a.on(UO,this.F,this)}release(){hP(this,_.qo);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(QO,this.C);this.a.off(PO,this.B);this.a.off(OO,this.A);this.a.off(XO,this.H);
|
|
31
|
+
this.a.off(WO,this.G);this.a.off(UO,this.F);this.m=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.a.isSeeking()?this.h=1:this.h=2;hP(this,2)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",gP(this.f))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.l){this.l=!0;var a=this.m.getConfiguration().autoplay;const b=this.a.getState()===bQ;if(!a&&b){hP(this,4);return}}if(a=1!==this.f)a=this.a.getState(),a=a===
|
|
32
|
+
iP||a===jP;a&&kP(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===cQ?hP(this,1):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){hP(this,5)}getState(){return this.f}};var eQ=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.T("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.v(function*(){if(b.m)if(b.B=a,b.j=yield lP(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),onContentSteeringInfoFound:()=>null,filterNewPeriod:()=>{},filterAllPeriods:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.g.warn(d);try{b.a=
|
|
33
|
+
yield b.j.start(a.url.replace(_.ae,"http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&mP(b.a)){b.h=nP(b);try{yield b.h.open();b.f=oP(b);const d=b.m.getConfiguration();b.f.h=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.C=d.preferForcedSubtitles}catch(d){b.g.debug("Could not setup media source..."),b.h=null,b.f=null,b.j=null,b.a=null}}}else b.g.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.g.debug("Text streamer is not initialized. Will not load()")})}G(a){this.g.debug(_.CA,
|
|
34
|
+
a.id);this.w=!0;let b=_.lE(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,hb:null}}F(){const a=this;return _.v(function*(){a.g.debug("canSwitch_");a.w=!1;a.l&&(yield _.pF(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 _.v(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 _.v(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 _.v(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var hQ=class extends _.V{constructor(){super();this.j=this.a=this.m=null;this.f={};this.g=new _.T("clpp.tizen.TrackManager");this.w=this.o=this.l=null;this.B=!1;this.h=1}C(a){var b=a.eventid;a=a.data;switch(b){case fQ:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+vP(this,b[0].extra_info).Bit_rate,b=wP(this,{bandwidth:b}))&&(this.w=b,uP(this,b));break;case gQ:tP(this);break;default:this.g.debug("Event type: "+
|
|
36
|
+
b+" data: "+a)}}A(a){3===a.detail.currentState&&this.m.off(_.Lf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Lf,b=>{this.B||(b=b.detail,3===b.currentState&&(this.g.debug("Current state",b.currentState),this.B=!0,xP(this)))});this.a.on("onevent",this.C,this)}release(){this.f={};this.j=this.w=this.o=this.l=null;this.B=!1;this.h=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.j=this.m.h;this.m.off(_.Lf,this.A);this.m.on(_.Lf,this.A,this);try{const a=LP(this.a);this.f=DP(this,
|
|
37
|
+
a);const b=this.f[_.N]||[];b.length&&(this.l=b[0].renditions[0]||null);tP(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off("onevent",this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.O]||[]}getAudioTracks(){return this.f[_.N]||[]}sa(){return this.f[_.M]||[]}ta(){return GP(this,_.O)}Oa(){return GP(this,_.N)}Va(){return GP(this,_.M)}wb(){return this.w}Nb(){this.g.info(KO);return null}Ob(){this.g.info(KO);return null}Ha(){const a=this.ta();return a?a.track:
|
|
38
|
+
null}ra(){const a=this.Oa();return a?a.track:null}ua(){const a=this.Va();return a?a.track:null}Fb(a){null===a?(a=this.ta(),NP(this.a,a.bandwidth,null).then(()=>{tP(this)})):0<a.renditions.length&&this.rb(a.renditions[0])}za(a){a?JP(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Za(a){a?(a=a.renditions[0],this.j?sP(this.j,a.track):JP(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,OP(this.a,!1),this.m.trigger(new _.H(_.Wf)))}rb(a){const b=
|
|
39
|
+
this.ta();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,uP(this,a),NP(this.a,b.bandwidth,a.bandwidth).then(()=>{tP(this)}).catch(c=>{const d=new _.I(_.D,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}Db(a){JP(this,a)}Eb(a){this.j?sP(this.j,a.track):JP(this,a)}addTextTrack(){}va(){return this.a.o}};hQ.prototype.isAbrEnabled=hQ.prototype.va;
|
|
40
|
+
hQ.prototype.addTextTrack=hQ.prototype.addTextTrack;hQ.prototype.setTextRendition=hQ.prototype.Eb;hQ.prototype.setAudioRendition=hQ.prototype.Db;hQ.prototype.setVideoRendition=hQ.prototype.rb;hQ.prototype.setTextTrack=hQ.prototype.Za;hQ.prototype.setAudioTrack=hQ.prototype.za;hQ.prototype.setVideoTrack=hQ.prototype.Fb;hQ.prototype.getTextTrack=hQ.prototype.ua;hQ.prototype.getAudioTrack=hQ.prototype.ra;hQ.prototype.getVideoTrack=hQ.prototype.Ha;hQ.prototype.getLoadingTextRendition=hQ.prototype.Ob;
|
|
41
|
+
hQ.prototype.getLoadingAudioRendition=hQ.prototype.Nb;hQ.prototype.getLoadingVideoRendition=hQ.prototype.wb;hQ.prototype.getTextRendition=hQ.prototype.Va;hQ.prototype.getAudioRendition=hQ.prototype.Oa;hQ.prototype.getVideoRendition=hQ.prototype.ta;hQ.prototype.getTextTracks=hQ.prototype.sa;hQ.prototype.getAudioTracks=hQ.prototype.getAudioTracks;hQ.prototype.getVideoTracks=hQ.prototype.getVideoTracks;var iQ=class extends _.Et{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(QO))}I(a){this.w=!0;this.trigger(new _.H(PO,{percent:a}))}H(){this.w=!1;this.trigger(new _.H(OO))}M(){this.trigger(new _.H(UO))}L(a,b){this.trigger(new _.H("onevent",{eventid:a,data:b}))}P(a,b,c,d,e){this.trigger(new _.H(VO,{duration:a,text:b,subtitleType:c,
|
|
42
|
+
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.H(SO,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.td&&"Challenge"===b.name?cP(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(TO,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(RO,f,this);e=setTimeout(()=>{this.off(RO,f);d("Timeout")},3E4)});if(a===cQ)return(new Promise((c,
|
|
43
|
+
d)=>{webapis.avplay.prepareAsync(()=>{RP(this);c(webapis.avplay.play())},e=>{this.trigger(new _.H(TO));d(e)})})).then(()=>b());if(a===jP||a===bQ)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===iP?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===jP?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===bQ||b===iP||b===jP){try{webapis.avplay.setSpeed(a),
|
|
44
|
+
this.F=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.F)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.F}load(a,b){const c=this;return _.v(function*(){c.g.debug("configure()",b||"");try{yield WP(c),yield $P(c,a,b)}catch(d){throw new _.I(_.D,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Xf;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(_.lg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.H(_.kg));c()},()=>{this.C=!1;d()})})}isSeeking(){return this.C}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,
|
|
46
|
+
b)=>{try{this.h&&(this.h.release(),this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.Ie.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 LO:this.g.debug("The application does not have the privilege to get the volume.",MO);break;default:this.g.debug(JO,b)}}return a}setVolume(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,
|
|
47
|
+
Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.g.warn("Invalid value passed for setVolume.","The passed value value should be in the range of 0 to 1.");break;case LO:this.g.warn("The application does not have the privilege to set the volume.",MO);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&&
|
|
48
|
+
this.h.getDrmInfo();return null}setSourceIndex(a){this.G=a}getSourceIndex(){return this.G}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},cQ="IDLE",bQ="READY",iP="PLAYING",jP="PAUSED",yP=_.Cb,zP=_.aA,IP="TEXT",gQ="PLAYER_MSG_RESOLUTION_CHANGED",fQ="PLAYER_MSG_BITRATE_CHANGE";var mQ=class extends _.Et{constructor(){super();this.a=new iQ(this);this.f=new dQ(this);this.configuration=this.B=_.Om();this.w=null;this.g=new _.T("clpp.tizen.Player");this.j=null;this.l=new hQ;this.C=new _.sn;this.o=this.h=null;this.A=!1}I(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.H(_.Rd));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(_.ag,
|
|
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=_.wi(d))&&this.o.append([new _.hu(b,c,d)],[])}G(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)}K(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)}H(a){this.g.debug(`Error: TYPE: ${a.eventType}`);hP(this.f,_.ko);a=new _.I(_.D,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.H(_.Sd,{detail:a}))}init(a,
|
|
50
|
+
b){this.configuration=this.B=b;this.w=a;this.a.on(UO,this.I,this);this.a.on(RO,this.F,this);this.a.on(VO,this.J,this);this.a.on(SO,this.G,this);this.a.on(TO,this.H,this);this.a.on(OO,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=jQ;jQ+=1;a="__clpp_tizen_player_"+a;this.j=_.yi(_.Ce,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Hg,_.Xd,"position",
|
|
51
|
+
_.ee,"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}_.Ai(a,d);aQ(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.Ya)}appendLoad(){return Promise.reject(_.Ya)}seekWith(){return Promise.reject(_.Ya)}setSeekInterceptor(){}setPlaybackSessionId(){}getBandwidthEstimate(){return null}destroy(){const a=
|
|
52
|
+
this;return _.v(function*(){yield a.release();a.a.off(UO,a.I);a.a.off(RO,a.F);a.a.off(VO,a.J);a.a.off(SO,a.G);a.a.off(TO,a.H);a.a.off(OO,a.K);a.h&&(yield a.h.destroy(),a.h=null);a.j&&(a.j.parentElement.removeChild(a.j),a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return kQ}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<
|
|
53
|
+
(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(_.ra);
|
|
54
|
+
return new _.yt}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.v(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 _.v(function*(){b.configuration=_.Qm([b.B,a]);var c=_.Rr(b.configuration,[_.$d,"native"]);b.o=c.create(b);c=_.Um(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
|
|
55
|
+
new eQ;b.h.initialize(b);try{yield b.h.load(c),b.h.start()}catch(d){b.g.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),d;}b.l.load()})}play(){this.trigger(new _.H(_.Re));aQ(this);return this.a.play().then(()=>{kP(this.f)})}pause(){return this.a.pause().then(()=>{kP(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.H(_.Sd,{detail:a});a.severity===_.D&&(hP(this.f,_.ko),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return 5===
|
|
56
|
+
this.f.getState()}isPaused(){return this.a.getState()===jP}isMuted(){return UP(this.a)}setMuted(a){YP(this.a,a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}setCmsdManager(){}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,b){return(new lQ).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
|
|
57
|
+
kQ="clpp.tizen",jQ=0,lQ=class{a(){return kQ}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.tc||a===_.kl||a===_.Bc)&&b){if(_.Mi(2))return 2;if(_.Mi(3)||_.Mi(4)||_.Mi(5)||_.Mi(6))return _.B("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.oa}create(){return new mQ}};_.w("clpp.tizen.TizenComponent",class extends _.jv{install(){_.wh(new lQ)}uninstall(){var a=kQ;a&&_.uh[a]&&(delete _.uh[a],_.vh.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});};f.call(g, window);
|
package/cl.ttml.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
let e=Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else
|
|
3
|
-
"$1em")}
|
|
4
|
-
e);for(const e of a.j)d.appendChild(
|
|
5
|
-
|
|
6
|
-
-1===[_.da,"span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},
|
|
7
|
-
60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},
|
|
8
|
-
"lineHeight","opacity","padding",
|
|
9
|
-
f.get(this.o))){g.region=f.build(a,e);g.textAlign=
|
|
10
|
-
a.getAttribute("imagetype"),a=a.j.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var
|
|
11
|
-
d,1,100);c.widthUnits=
|
|
12
|
-
this.a){d=this.a.textOutline.split(" ");e="black";let g=".4em";const h=d[0]&&d[0].trim(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!
|
|
13
|
-
"monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(
|
|
14
|
-
|
|
15
|
-
["color","color"],[
|
|
16
|
-
_.
|
|
17
|
-
new
|
|
18
|
-
g=new
|
|
19
|
-
c.getId()),c=d,g=a,
|
|
20
|
-
c.f.set(b,g),c.o.push(g),c=g):c=null,c&&a.l.push(c.getId());e=
|
|
21
|
-
e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.
|
|
22
|
-
_.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var ox='application/mp4; codecs\x3d"stpp.ttml"',px='application/mp4; codecs\x3d"stpp.ttml.im1i"',qx='application/mp4; codecs\x3d"stpp.ttml.im1t"',rx="backgroundColor",sx="direction",tx="displayAlign",ux="region",vx="textAlign",wx="textDecoration",xx="writingMode",yx=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},Gx=function(a,b){var c=null;if(zx.test(a)){{a=zx.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 Ax.test(a)?c=Bx(Ax,a):Cx.test(a)?c=Bx(Cx,a):Dx.test(a)?(a=Dx.exec(a),c=Number(a[1])/b.frameRate):Ex.test(a)?(a=Ex.exec(a),c=Number(a[1])/b.a):Fx.test(a)&&(c=Bx(Fx,a));return c},Bx=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)},Hx=function(a){return a.split(":").pop()},Ix=function(a){return a.replace(/(\d*\.?\d+)c/g,
|
|
3
|
+
"$1em")},Kx=function(a,b){for(;Jx.test(a);){const c=Jx.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Lx=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},Mx=function(a,b,c){a=yx(a,b,vx);if(!a&&c&&(a=yx(c,b,vx),!a&&"rltb"===yx(c,b,xx)))return _.Qd;switch(a){case _.Wc:return _.cu;case _.wf:case _.Qd:return _.Qd;default:return _.Kf}},Nx=function(a,b,c){if(_.ri(a.w))return document.createTextNode(_.wi(a.w||""));if(a.A)return _.yi("br");const d=_.yi("span");for(const e of a.f)_.zi(d,
|
|
4
|
+
e);for(const e of a.j)d.appendChild(Nx(c.get(e),b,c));return d},Qx=function(a,b,c,d){const e=Ox.exec(a);a=Px.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},Rx=function(a,b){return typeof b===_.r&&0<b?_.ku:Px.test(a)?0:_.ku},Sx=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},Tx=function(a,b){a=a.getAttribute("extent");return(a=Px.exec(a))?Number(a[b]):null},Vx=function(a){a=a.getAttribute("cellResolution");return(a=Ux.exec(a))?Number(a[2]):null},
|
|
5
|
+
Xx=function(){return`${"inline-"}${Wx++}`},Zx=function(a){return Yx.some(b=>b in a.attributes)},$x=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...$x(a,a.a.get(d).f),d);return c},ay=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)},by=function(a){return Hx(a.h.nodeName)},ey=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={},cy.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(ux)&&(c=b.getAttribute(ux));b.hasAttribute(_.Qf)&&f.push(...b.getAttribute(_.Qf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Hx(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new dy(b,c,d,e,f,g);a.a.set(b,c);return c},fy=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")}`},gy=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 hy=class extends gy{constructor(a,b,c){super(a,[],c);this.j=b||""}};var iy=class extends gy{constructor(a,b,c){super(a,b,c)}};var zx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ax=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Cx=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Dx=/^(\d*(?:\.\d*)?)f$/,Ex=/^(\d*(?:\.\d*)?)t$/,Fx=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Ox=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Px=/^(\d+)px (\d+)px$/,Ux=/^(\d+) (\d+)$/,Jx=/(\d+)px/,jy=/^(\d+px|\d+em|\d*\.?\d+c)$/,Yx=[rx,"color",sx,tx,"fontFamily","fontSize","fontStyle","fontWeight",
|
|
8
|
+
"lineHeight","opacity","padding",vx,wx,"textOutline",xx,"zIndex"],cy=["begin",_.Qd];var ky=class extends iy{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=Gx(this.a.begin,b);b=Gx(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.yi(_.Ad);for(const k of this.j)c.appendChild(Nx(g.get(k),e,g));g=new _.hu(h,b,c.innerHTML.trim(),_.dg);g.cssClassList=[...this.f];g.textAlign=Mx(this,e,null);g.writingMode=_.du;g.line=-1;g.lineInterpretation=_.eu;g.lineAlign=_.fu;g.containerRows=Sx(null,Vx(a),15);if(this.o&&(f=
|
|
9
|
+
f.get(this.o))){g.region=f.build(a,e);g.textAlign=Mx(this,e,f);a:switch(yx(f,e,xx)){case "tb":case "tblr":a=_.og;break a;case "tbrl":a=_.pg;break a;default:a=_.du}g.writingMode=a;a:switch(yx(f,e,tx)){case _.Wc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(yx(f,e,tx)){case _.Wc:a=1;break a;default:a=_.eu}g.lineInterpretation=a;a:switch(yx(f,e,tx)){case _.Wc:e=_.Wc;break a;default:e=_.fu}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 ly=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 my=class extends iy{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.mu;c.id=this.getId();const d=Sx(a.j.containerWidth,Tx(a,1),720);a=Sx(a.j.containerHeight,Tx(a,2),480);a:switch(yx(this,b,tx)){case "after":var e="flex-start";break a;case _.Wc:e=_.Wc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(yx(this,b,xx)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.nd}c.writingMode=e;e=this.getAttribute("extent")||yx(this,b,"extent");c.width=Qx(e,
|
|
11
|
+
d,1,100);c.widthUnits=Rx(e,d);c.height=Qx(e,a,2,100);c.heightUnits=Rx(e,a);b=this.getAttribute("origin")||yx(this,b,"origin");c.viewportAnchorX=Qx(b,d,1,0);c.viewportAnchorY=Qx(b,a,2,0);c.viewportAnchorUnits=Rx(b,d);c.cssClassList=[...this.f];return c}};var ny=class extends gy{constructor(a,b){super("root-container",[],b);this.j=a}};var py=class extends gy{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=Vx(a);c&&(b=Sx(a.j.containerHeight,Tx(a,2),480)/c);b=Sx(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of oy.entries())g in this.a&&(c+=`${h}:${Ix(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&&!jy.test(h)&&jy.test(k)&&jy.test(l)?(e=h,g=k):2===d.length&&!jy.test(h)&&jy.test(k)?(e=h,g=k):2===d.length&&jy.test(h)&&jy.test(k)&&(g=h);if(""!==g){g=Ix(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=Lx(this.a.textShadow),d=Ix(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(wx 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
|
+
Ix(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Ix(d),d=Kx(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=Ix(c);c=Kx(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}},oy=new Map([[rx,"background-color"],
|
|
15
|
+
["color","color"],[sx,sx],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var qy=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=[]}},Wx=0;var ty=class{constructor(a){this.a=a.firstChild;this.f=new Set}Kd(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!ry.has(Hx(a.nodeName))||sy.has(Hx(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&&!ry.has(Hx(a.nodeName))));const b=this.a;this.a=a;return b}},ry=new Set(["tt","head","layout",_.se,_.be,ux,"styling",_.Qf,"body",
|
|
16
|
+
_.Ad,"p","span","br"]),sy=new Set([_.Qf,_.be]);var dy=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 uy=class{constructor(){this.a=new Map}};var vy=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.Zg(this.a.ttml||{}),e=_.G(a,0,c[0]);e=_.ii(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Vf)}catch(m){throw new _.I(_.D,2,2005,"Failed to parse TTML.");}d=new qy(d);e=new uy;f=new ty(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=_.Ml(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
|
|
17
|
+
new hy(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Kd();)a=f.next(),a=ey(e,a),c=d,b=a,"tt"===by(b)&&(c.l=new ny(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===by(b)&&(c.w=new ly(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,by(b)!==_.be||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new hy(g,b.h.textContent,b.attributes))),c=d,g=a,by(g)===_.be&&g.attributes.begin&&g.attributes.end?(b=`#${Xx()}`,
|
|
18
|
+
g=new hy(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,by(b)===_.Qf&&(g=b.getId()||Xx(),h=new py(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,by(g)!==_.Qf&&Zx(g)?(b=Xx(),g=new py(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,by(g)!==_.Ad||!g.attributes.extent&&!g.attributes.origin?c=null:(b=Xx(),g=new my(b,$x(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
|
|
19
|
+
c.getId()),c=d,g=a,by(g)!==ux?c=null:(b=g.getId(),g=new my(b,$x(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(by(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=Xx(),g=new ky(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===by(g),g.a,g.j,$x(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"===by(g)||g.j?(b=Xx(),g=new ky(b,null,!1,g.a,g.j,$x(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=ay(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var wy=class{constructor(a){this.f=a}a(a){var b=new vy(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=fy(d.startTime)+" --\x3e "+fy(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.ee:e.push("align:left");break;case _.wf:e.push("align:right");break;case _.cu:e.push("align:middle");break;case _.Kf:e.push("align:start");break;case _.Qd:e.push("align:end")}switch(c.writingMode){case _.og:e.push("vertical:lr");break;case _.pg:e.push("vertical:rl")}c=
|
|
21
|
+
e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.mi(b)}},xy=class{probe(a,b){return a===_.Ac&&b===_.Uf}create(a){return new wy(a)}};var yy=class{constructor(a){this.a=new vy(a);this.g=new _.T("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.aq).N(_.ve,_.Up).N(_.cg,_.Up).N(_.qe,_.Up).N(_.ue,_.Up).N(_.Nf,_.Up).fa(_.Pf,_.Vp).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 _.aq).N("moof",_.Up).N("traf",_.Up).fa("subs",g=>{const h=_.Q(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.Np(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
|
|
22
|
+
_.Q(g.reader):_.Np(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.pe,_.Wp(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}}};_.w("clpp.ttml.TtmlComponent",class extends _.jv{constructor(){super();this.a=new xy}install(){_.kt(_.Ac,vy);_.kt(_.xc,yy);_.kt(ox,yy);_.kt(qx,yy);_.kt(px,yy);_.hp.push(this.a)}uninstall(){_.mt(_.Ac);_.mt(_.xc);_.mt(ox);_.mt(qx);_.mt(px);_.jp(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 dx="VerimatrixVCAS",ex="clpp.verimatrix.Vcas",fx="clpp.verimatrix.VcasComponent",hx=function(a,b){return a.C===gx?(a=Object.assign({},{deviceId:_.Nl(_.oi(a.A))},a.a&&{authenticator:_.Nl(_.oi(a.a))}),b+_.zm(a)):b},nx=class extends _.kv{constructor(a){super(dx);const b={};b[ix]=ix;b[jx]=jx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=gx,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
|
|
2
|
+
kx}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=hx(this,g);this.o=hx(this,h);this.l=hx(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.T(ex);_.si(this.w)?this.g.warn(_.Gb):this.jb(_.td,{licenseUrl:this.w,videoRobustness:[_.nb,void 0],audioRobustness:[_.mb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.si(this.o)?this.g.warn(_.cb):this.jb(_.rd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
|
|
3
|
+
modifiers:{licenseRequest:this.h.bind(this)}});_.si(this.l)?this.g.warn(_.Da):_.si(this.j)?this.g.warn(_.Ba):this.jb(_.pd,{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===lx){a=this.B[jx];const c={};c[this.B[ix]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.$p(b);switch(this.F){case mx:a=_.zm({r:a,Kj:this.G},!0)}return a}J(a,b){this.h(a,
|
|
4
|
+
b);_.eq(b)}K(a,b){_.fq(b)}};_.w(ex,nx);nx.prototype.constructor=nx.prototype.constructor;nx.NAME=dx;var gx="query-string",lx="http-header";nx.LicenseRequestVuidLocation={QUERY_STRING:gx,HTTP_HEADER:lx};var ix="DeviceId",jx="Authenticator";nx.LicenseRequestHttpHeader={DEVICE_ID_HEADER:ix,AUTHENTICATOR_HEADER:jx};var kx="keyid",mx="contentid-siteid";nx.FairPlayAssetIdStrategy={KEYID:kx,CONTENTID_SITEID:mx};_.w(fx,class extends _.jv{constructor(){super();this.g=new _.T(fx)}uninstall(){delete _.Xm.VerimatrixVCAS}drmConfigurationResolved(a){if(a&&a.env===dx){({customData:a}=a);if(!a)throw new _.I(_.D,7,7100,_.ud);a=new nx(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.Ym(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 _.
|
|
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
|
-
"").replace(":","");b.videoProtocol=c;b=
|
|
6
|
-
this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.
|
|
7
|
-
a.onError(new _.I(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 Vw="Registering listeners",Ww="clpp.vimond.VimondPlugin",Xw=function(a,b){a.m.trigger(new _.H(_.xg,{detail:b}))},Yw=function(a,b,c){b&&(a.A=!0,a.f.stop());a.m.onError(new _.I(b?_.D:1,9,9201,c))},Zw=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.bf];if(a.h)return[_.Qd,_.Ne];if(5===c)return[_.Qd,null];if(c===_.ko)return[_.Sd,_.Ne];b=_.Ne;if(2===c||3===c||a.f)b=_.bf;return["period",b]},$w=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 _.Bt;this.j=!0;this.ga=this.h=this.A=!1;this.B=null;this.f=new _.Ii(this.w.bind(this));this.g=new _.T("clpp.vimond.VimondDispatcher");this.l=this.o=0;this.m&&this.a&&(this.g.debug(Vw),this.a.on(this.m,_.Lf,this.H.bind(this)),this.a.on(this.m,_.ag,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.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 _.v(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,_.ko,5].includes(d)&&(b.B=d,yield b.w(),5===d&&b.f.stop()))):b.g.debug("Ignore transition"))})}w(){const a=this;return _.v(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();Xw(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),Xw(a,c),Yw(a,a.K,c)):1001===b?(a.g.debug("Generic service error"),Xw(a,c),Yw(a,a.L,c)):a.g.error(d.toString())}})}};var ax=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=_.Yg(this.o);a.client.buildName=_.sa;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.Qa().url;a.client.userAgent=navigator.userAgent;a.client.videoFormat=this.a.m.Qa().type||"";b=a.client;c=this.a.m.Qa();c=((new _.Zp(c.url)).scheme||
|
|
5
|
+
"").replace(":","");b.videoProtocol=c;b=Zw(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=!0)}a.progress.eventNumber=
|
|
6
|
+
this.f;a.timestamp=(new Date).toISOString();this.g.debug("Fire an event");b=_.rk(this.l);b.method=_.bb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.oi(JSON.stringify(a));return this.j.fetch(b).V}Lf(a){this.h=a}};var bx=class{constructor(a){this.m=a;this.a=new _.Bt;this.g=new _.T("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(Vw),this.a.on(this.m,_.sf,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 cx=class extends _.Ev{constructor(){super();this.a=!1;this.g=new _.T(Ww);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.z(b.vimond)&&typeof b.vimond===_.Ce)?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 _.I(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 bx(a);this.h=new ax(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new $w(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.yb);_.Sh(a.a)}this.j&&(a=this.j,a.g.debug(_.yb),_.Sh(a.a),a.f.stop());this.j=this.h=
|
|
8
|
+
this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}Lf(a){this.a&&this.h&&this.h.Lf(a)}};_.w(Ww,cx);cx.prototype.updateAuthToken=cx.prototype.Lf;cx.Id="vimond";_.En(new class{create(){return new cx}});};f.call(g, window);
|