@castlabs/prestoplay 6.34.0 → 6.35.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/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 +125 -125
- package/cjs/cl.conviva.js +31 -31
- package/cjs/cl.core.js +579 -577
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +100 -100
- package/cjs/cl.freewheel.js +26 -26
- 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 +25 -25
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +345 -345
- package/cjs/cl.muxdata.js +13 -13
- package/cjs/cl.onboard.js +4 -4
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +5 -5
- package/cjs/cl.simid.js +16 -16
- package/cjs/cl.smooth.js +70 -70
- package/cjs/cl.thumbnails.js +25 -25
- package/cjs/cl.tizen.js +67 -67
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +8 -8
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.yospace.js +3 -3
- package/cjs/cl.youbora.js +38 -38
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +14 -14
- package/cl.cast.js +97 -97
- package/cl.conviva.js +28 -27
- package/cl.core.js +463 -462
- package/cl.crypto.js +8 -8
- package/cl.dash.js +89 -89
- 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 +19 -19
- package/cl.mediatailor.js +2 -2
- package/cl.mse.js +299 -299
- package/cl.muxdata.js +11 -11
- package/cl.onboard.js +5 -5
- package/cl.persistent.js +10 -10
- package/cl.playlist.js +5 -5
- package/cl.simid.js +14 -14
- package/cl.smooth.js +60 -60
- package/cl.thumbnails.js +17 -17
- package/cl.tizen.js +55 -55
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +7 -7
- package/cl.vr.js +14 -14
- package/cl.vtt.js +12 -12
- package/cl.yospace.js +3 -3
- package/cl.youbora.js +31 -31
- package/package.json +1 -1
package/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
|
-
{c()})})}
|
|
3
|
-
return c},
|
|
4
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Vy="Thumbnail URL is mandatory",Wy="Wrong gridSize format",Xy="clpp.thumbnails",Zy=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.Ce&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Yy(a,0,e,!!f))},Promise.resolve())},Yy=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return $y(a,d).then(()=>a.a[b].load()).then(()=>Yy(a,e,c,d))},$y=function(a,b){return new Promise(c=>{if(b||6!==a.player.getPlayerState())c();else a.player.one(_.Nc,()=>
|
|
2
|
+
{c()})})},az=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.jd.resolve()})},dz=function(a,b){return bz(a,b).then(c=>new cz(c,b.time,b.duration))},bz=function(a,b){return b.load().then(()=>{const c=_.E(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.Nk(c)})},ez=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},fz=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);
|
|
3
|
+
return c},gz=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Ld:c,Mf:d,vg:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},hz=function(a){return a.some(b=>0<b.thumbStreams.length)},pz=function(a){return a?a===iz||a===jz?new kz:a===lz?new mz:a===nz?new oz:null:null},qz=function(a){if(!a)return null;a=new _.Um(a);return a.path.match(/.*\.vtt$/i)?lz:a.path.match(/.*\.bif$/i)?nz:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
|
|
4
|
+
iz:null};var rz=class{constructor(){this.log=new _.S(Xy);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.tf,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Zy(this,b.preload)})}};var cz=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
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
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(_.je,e);this.a.removeEventListener(_.Sd,d);a(this)};d=f=>{this.a.removeEventListener(_.je,
|
|
7
|
-
e);this.a.removeEventListener(_.Sd,d);b(new _.J(1,9,2014,"Failed to load thumbnail.",f))};this.a.addEventListener(_.je,e);this.a.addEventListener(_.Sd,d);this.a.src=this.src}}));return this.f}};_.w("clpp.thumbnails.Thumbnail",
|
|
8
|
-
c),new _.J(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=_.E(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 _.J(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.v(function*(){if(0>a)throw new _.J(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 _.J(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.Ld,h.Mf,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=
|
|
17
|
-
0;k<e.Mf;++k)for(let l=0;l<e.Ld;++l)this.a.push(new
|
|
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
|
|
7
|
+
e);this.a.removeEventListener(_.Sd,d);b(new _.J(1,9,2014,"Failed to load thumbnail.",f))};this.a.addEventListener(_.je,e);this.a.addEventListener(_.Sd,d);this.a.src=this.src}}));return this.f}};_.w("clpp.thumbnails.Thumbnail",cz);cz.prototype.load=cz.prototype.load;cz.prototype.element=cz.prototype.element;cz.prototype.raw=cz.prototype.raw;var kz=class extends rz{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.J(1,9,7100,Vy);if("GRID"===b.mode&&!b.gridSize)throw new _.J(1,9,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.J(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 _.J(1,9,7100,Wy);}catch(c){throw this.log.error("Error during parsing gridSize",
|
|
8
|
+
c),new _.J(1,9,7100,Wy);}super.init(a,b)}get(a){const b=this;return _.v(function*(){var c=b.player.getDuration();if(0>a||a>c)throw new _.J(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 _.J(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 cz(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 sz=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.jd=new _.xk}load(){return this.jd}},oz=class{constructor(){this.g=new _.S(Xy);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.xk}init(a,b){if(!b||!b.url)throw new _.J(1,9,7100,Vy);const c=b.url;b=_.fk(c);b.type=_.ek;a.getNetworkEngine().fetch(b).V.then(d=>{var e=d.data;d=_.E(this.a);e=_.E(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=_.E(f);h=String.fromCharCode.apply(null,tz);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 sz(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");az(this)}).catch(d=>{this.g.error(`[BIF] Error while loading thumbnails '
|
|
12
|
+
+ 'URL: ${c}`,d);a.onError(new _.J(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.v(function*(){if(0>a)throw new _.J(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 _.J(1,9,2014,`No thumbnail found for position: ${a}`);c=yield dz(b,c);yield c.load();return c})}},tz=[137,66,73,70,13,10,26,10];var mz=class extends rz{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.J(1,9,7100,Vy);const c=b.url,d=_.fk(c);d.type=_.ek;this.f=a.getNetworkEngine().fetch(d).V.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.wi(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=ez(g[0]);g=ez(g[1])-l;this.a.push(new cz(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 _.J(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 _.J(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 _.J(1,9,2014,`No thumbnail found for position: ${a}`);
|
|
14
|
+
yield c.load();return c})}l(){return this.f}};var uz=class extends rz{get(a){const b=this;return _.v(function*(){function c(){return new _.J(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 _.J(1,9,2014,`Position is out of range: ${a}`);var d=b.player.getPeriods();d=fz(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=gz(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.vg+k]);else if((e=f.Da())&&0<e.length){let l=g=0;f=f.startTime;1<h.vg&&(g=k%h.Ld,l=Math.floor(k/h.Ld),f+=k*h.durationPerTile);g=new cz(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
|
|
16
|
+
h.Ld,h.Mf,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=gz(d,a),f=d.Da()[0],g=new Image;let h=d.startTime;for(let k=
|
|
17
|
+
0;k<e.Mf;++k)for(let l=0;l<e.Ld;++l)this.a.push(new cz(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.Ld,e.Mf,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var vz=class{constructor(){this.g=new _.S(Xy);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=qz(b.url||null));(this.a=pz(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.le,()=>{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(hz(c)){this.a=new uz;try{this.a.init(a,b)}catch(d){this.m.onError(d)}}}}}get(a){return this.a?this.a.get(a):Promise.reject(new _.J(1,9,2014,"Thumbnail format is not supported"))}id(){return"thumbnails"}};_.w("clpp.thumbnails.ThumbnailsPlugin",vz);vz.prototype.get=vz.prototype.get;vz.Id="thumbnails";
|
|
19
|
+
var iz="SINGLE",jz="GRID",lz="WEBVTT",nz="BIF";_.Tr(new class{create(){return new vz}});};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
|
-
{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},
|
|
3
|
-
serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.J(_.C,6,6005,{message:JSON.stringify(c)});}})},
|
|
4
|
-
if(a.j){var g=_.E(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("PLAYREADY","SetProperties",c)}catch(d){throw d;}})},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
b&&(c=d);return c},
|
|
10
|
-
null;e.renditions.push(f);b.push(e)}return b},
|
|
11
|
-
String(e.id)===d.id))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=c):(yield _.
|
|
12
|
-
JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},
|
|
13
|
-
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
|
-
|
|
15
|
-
|
|
16
|
-
{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},
|
|
17
|
-
null;a.codec=b.fourCC||null;return a},
|
|
18
|
-
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},
|
|
19
|
-
d).then(()=>{const e=a.a.Wf;a.f=!1;a.a=null;return e===
|
|
20
|
-
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,Sf:0,He:new _.
|
|
21
|
-
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;})})},
|
|
22
|
-
!!a.m.getTrackManager().
|
|
23
|
-
c),c;}},
|
|
24
|
-
|
|
25
|
-
{a.g.debug("AVPlay is ready!");
|
|
26
|
-
a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.H(
|
|
27
|
-
a.f||a.trigger(new _.H(
|
|
28
|
-
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
|
|
29
|
-
b[_.rd];d&&a.f.set(_.rd,{Qd:d.licenseUrl||"",customData:c,lf:!1});(b=b[_.td])&&a.f.set(_.td,{Qd:b.licenseUrl||"",customData:c,lf:!1});if(0===a.f.size)throw new _.J(_.C,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 _.J(_.C,6,6001,"Configuration for the target system is missing.");yield
|
|
30
|
-
|
|
31
|
-
this.G);this.a.off(
|
|
32
|
-
a===
|
|
33
|
-
yield b.j.start(a.url.replace(_.$d,"http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&
|
|
34
|
-
a.id);this.w=!0;let b=_.
|
|
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
|
|
36
|
-
b+" data: "+a)}}A(a){8===a.detail.currentState&&this.m.off(_.bf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.bf,b=>{this.B||(b=b.detail,8===b.currentState&&(this.g.debug("Current state",b.currentState),this.B=!0,
|
|
37
|
-
a);const b=this.f[_.M]||[];b.length&&(this.l=b[0].renditions[0]||null);
|
|
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 _.v(function*(){c.g.debug("configure()",b||"");try{yield
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var dP="An unknown error occurred while trying to get volume",eP="Cannot get loading rendition due to platform limitations",fP="SecurityError",gP="The require privilege is: http://tizen.org/privilege/tv.audio",hP="WIDEVINE_CDM",iP="onbufferingcomplete",jP="onbufferingprogress",kP="onbufferingstart",lP="oncurrentplaytime",mP="ondrmevent",nP="onerror",oP="onstreamcompleted",pP="onsubtitlechange",qP="preparingend",rP="preparingstart",sP="|STARTBITRATE\x3d",tP=function(a,b,c){const d=e=>
|
|
2
|
+
{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},wP=function(a){return _.v(function*(){if(a.a!==_.td&&a.a!==_.rd)throw new _.J(_.C,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");const b=a.f.get(a.a);if(!b.Qd)throw new _.J(_.C,6,6012,`No license server given for ${a.a}`);try{a.a===_.td?yield uP(a):yield vP(a,b),a.o={keySystem:a.a,licenseServerUri:b.Qd,distinctiveIdentifierRequired:!1,persistentStateRequired:b.lf,audioRobustness:"",videoRobustness:"",
|
|
3
|
+
serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.J(_.C,6,6005,{message:JSON.stringify(c)});}})},xP=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=_.fk([b.serverurl&&""!==b.serverurl?b.serverurl:c.Qd],_.ak());c.type=3;c.body=e.buffer;c.method=_.bb;try{var f=yield a.D.Cb.fetch(c).V;
|
|
4
|
+
if(a.j){var g=_.E(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.g.debug("Widevine license params",k);try{webapis.avplay.setDrm(hP,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.J(_.C,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.J(_.C,6,6007,{message:"Error while fetching license!",
|
|
5
|
+
url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},uP=function(a){return _.v(function*(){try{webapis.avplay.setDrm(hP,"Initialize",""),webapis.avplay.setDrm(hP,"widevine_app_session",a.l.id),webapis.avplay.setDrm(hP,"widevine_data_type",a.l.type)}catch(b){throw b;}})},vP=function(a,b){return _.v(function*(){var c={};c[yP]=!b.lf;c[zP]=b.Qd;""!==b.customData&&(c[AP]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",
|
|
6
|
+
c);try{webapis.avplay.setDrm("PLAYREADY","SetProperties",c)}catch(d){throw d;}})},BP=function(a,b){if(a.f!==b)if(3===a.f&&0!==b)a.g.debug(_.DA+`${_.Ii(b,_.Si)}`);else{var c=(new Date).getTime();a.o=a.f;a.f=b;6===a.f?(a.l=(new Date).getTime(),a.m.trigger(new _.H(_.Oc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):6===a.o&&a.m.trigger(new _.H(_.Nc,{detail:{bufferedTimeMS:c-a.l,reason:a.h}}));b={currentState:a.f,previousState:a.o,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.H(_.bf,{detail:b}))}},
|
|
7
|
+
EP=function(a){if(a.j){var b=a.a.getState(),c=a.f;switch(b){case CP:c=8;break;case DP:c=10;break;default:a.m.isEnded()?c=11:a.g.debug("Inconsistent AVPlay playback state:",b)}BP(a,c)}},FP=function(a){return _.v(function*(){const b=a.m.getConfiguration();let c;(c=yield _.Lt(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},GP=function(a){if(!a)return!1;a=a.periods;let b=!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},
|
|
8
|
+
HP=function(a){const b=document.createElement(_.t),c=new _.JH,d=new _.PG,e=a.m.getTextDisplayer();return new _.KH(b,c,e,d,a.m.getConfiguration())},IP=function(a){const b={configuration:{},xb:()=>a.m.getPosition(),$:a.h,Cb:a.m.getNetworkEngine(),Tc:null,ef:a.G.bind(a),Eg:a.F.bind(a),onError:a.H.bind(a),Fg:()=>{},onEvent:()=>{},Ig:a.I.bind(a),ze:()=>{},Dd:()=>new _.OI,Pe:()=>!1,zd:null};return new _.gI(a.a,b)},JP=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=
|
|
9
|
+
b&&(c=d);return c},KP=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 _.nl(String(c++),_.L);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.fB;const f=new _.rl(String(a[d].id),e);f.bandwidth=a[d].bandwidth||
|
|
10
|
+
null;e.renditions.push(f);b.push(e)}return b},LP=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.tF(a.f,_.I);let c=null;if(b){a=KP(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},MP=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,a.a&&a.f)){a.setTextVisibility(!0);var c=JP(a);const d=b.renditions[0];(c=c.textStreams.find(e=>
|
|
11
|
+
String(e.id)===d.id))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=c):(yield _.KF(a.f,c),a.m.trigger(new _.H(_.Vf))),a.o=c.language):a.g.error("No stream with id",d.id)}})},NP=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}}))},OP=function(a,b){a.m.trigger(new _.H(_.sg,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},PP=function(a,b){let c=null;try{c=
|
|
12
|
+
JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},QP=function(a,b){a=a.f[_.N]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.fh(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||null},RP=function(a){const b=a.m.getConfiguration();var c=_.lj(b.preferredAudioLanguage||[]);const d=a.f[_.M]||[];if(d.length){var e=null;c.some(g=>{e=_.Xj(g,d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>
|
|
13
|
+
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")},XP=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;var e=b.filter(l=>l.type===SP),f=b.filter(l=>l.type===
|
|
14
|
+
TP);const g=[];for(var h=0;h<f.length;h++){const l=PP(a,f[h].extra_info);if(l){var k=_.Uj(l.language||_.eg);k=_.kl(k);k=c(g,k);k||(k=new _.nl(String(a.h++),_.M),g.push(k));k.renditions.push(UP(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.nl(String(a.h++),_.N);for(f=0;f<e.length;f++)(h=PP(a,e[f].extra_info))?c.renditions.push(VP(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?KP(a.j):WP(a,b);d[_.N]=[c];d[_.M]=g;d[_.L]=e;return d},
|
|
15
|
+
$P=function(a,b){if(b===_.L&&a.j)return LP(a.j);var c=YP(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.N&&(d=PP(a,c.extra_info),d=QP(a,{width:d.Width,height:d.Height}));b===_.M&&(c?(d=ZP(a,c,_.M),a.l=d):d=a.l);b===_.L&&(c?(d=ZP(a,c,_.L),a.o=d):d=a.o);return d},cQ=function(a,b){if(b){const c=b.track.type.toUpperCase();aQ(a.a,c,Number(b.id)).then(()=>{c===TP&&(a.l=b,a.m.trigger(new _.H(_.Jc)));c===bQ&&(a.o=b,a.m.trigger(new _.H(_.Vf)))}).catch(()=>
|
|
16
|
+
{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},UP=function(a,b,c){const d=_.Uj(b.language||_.eg);c.language=_.kl(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Gc;a=new _.rl(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},VP=function(a,b,c){c.mimeType=_.qg;a=new _.rl(String(a),c);a.track=c;a.width=b.Width||null;a.height=b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):
|
|
17
|
+
null;a.codec=b.fourCC||null;return a},dQ=function(a,b,c){b=_.Uj(b.track_lang||_.eg);c.mimeType="text/ttml";c.language=_.kl(b);c.originalLanguage=b;c.kind=_.fB;return new _.rl(String(a),c)},WP=function(a,b){b=b.filter(d=>d.type===bQ);const c=[];for(let d=0;d<b.length;d++){const e=PP(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");continue}const f=new _.nl(String(a.h++),_.L);f.renditions.push(dQ(b[d].index,e,f));c.push(f)}return c},ZP=function(a,b,c){a=a.f[c]||[];b=String(b.index);
|
|
18
|
+
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},eQ=function(a){return a.f&&a.a?a.a.gj:webapis.avplay.getTotalTrackInfo()},gQ=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()};a.a=fQ(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),
|
|
19
|
+
d).then(()=>{const e=a.a.Wf;a.f=!1;a.a=null;return e===DP?a.pause():a.play()})}catch(d){return Promise.reject(d)}},hQ=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)}},aQ=function(a,b,c){b=b.toUpperCase();b===bQ&&hQ(a,!0);const d=a.j[b];d&&(d.He.stop(),a.j[b]=null,a.g.debug(`Cancelled pending track switch for ${b}`));return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===
|
|
20
|
+
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,Sf:0,He:new _.Kh(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Sf?(a.w||++k.Sf,k.He.la(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),k&&k.He.stop(),a.j[h]=null,f())}};g(b,c)})},YP=function(a){return a.f&&a.a?a.a.Gh:webapis.avplay.getCurrentStreamInfo()},iQ=function(a){return _.v(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",
|
|
21
|
+
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;})})},jQ=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(lP,{currentTime:b}))},onevent:a.L.bind(a),onsubtitlechange:a.P.bind(a),ondrmevent:a.K.bind(a),onerror:a.B.bind(a)})}catch(b){a.g.error(b)}},kQ=function(a){const b=
|
|
22
|
+
!!a.m.getTrackManager().Za();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},lQ=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,Aj:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",sP+d)}catch(c){a.g.debug(c)}},mQ=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+sP+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",
|
|
23
|
+
c),c;}},nQ=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case fP:a.g.warn("The application doesn't have the privilege to get the mute state.",gP);break;default:a.g.warn(dP,c)}}return!!b},fQ=function(a){return{position:a.getPosition(),Wf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:nQ(a),volume:a.getVolume(),gj:eQ(a),Gh:YP(a)}},oQ=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");
|
|
24
|
+
tP(c,_.je,d=>a(d));tP(c,_.Sd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},pQ=function(a){return _.v(function*(){yield oQ();const b=new Promise(c=>{(new _.Kh(c)).la(5)});if(!(yield Promise.race([iQ(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),Promise.reject("SDK Timeout")})},qQ=function(a){return _.v(function*(){a.g.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>
|
|
25
|
+
{a.g.debug("AVPlay is ready!");kQ(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)}})})},rQ=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case fP:a.g.warn("The application does not have the privilege to set mute.",gP);break;default:a.g.warn(dP,c)}}},tQ=function(a,b,c){return _.v(function*(){a.l=_.cp(b);const d=a.G,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};
|
|
26
|
+
a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.H(kP)),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?(mQ(a,e.nextBandwidth),a.o=!1):(a.o||lQ(a,e),a.o=!0);jQ(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),Cb:a.m.getNetworkEngine()};a.h=new sQ(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");
|
|
27
|
+
a.f||a.trigger(new _.H(rP));yield qQ(a);a.f||a.trigger(new _.H(qP));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&&rQ(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;}})},uQ=function(a){if("NONE"!==a.a.getState()){var b=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*
|
|
28
|
+
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 sQ=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 _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.v(function*(){var b=_.mk[a.h.env]||null;if(!b)throw a.g.debug(_.va,_.fb+a.h.env+_.aa),new _.J(_.C,6,6015,`DRM environment '${a.h.env}' is missing.`);a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";b=_.ok(b,a.h.customData);const d=
|
|
29
|
+
b[_.rd];d&&a.f.set(_.rd,{Qd:d.licenseUrl||"",customData:c,lf:!1});(b=b[_.td])&&a.f.set(_.td,{Qd:b.licenseUrl||"",customData:c,lf:!1});if(0===a.f.size)throw new _.J(_.C,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 _.J(_.C,6,6001,"Configuration for the target system is missing.");yield wP(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
|
+
yP="DeleteLicenseAfterUse",zP="LicenseServer",AP="CustomData";var xQ=class{constructor(a){this.m=a;this.a=this.m.a;this.o=this.f=0;this.w=(new Date).getTime();this.j=!1;this.l=-1;this.h=2;this.g=new _.S("clpp.tizen.StateManager")}initialize(){this.a.on(kP,this.C,this);this.a.on(jP,this.B,this);this.a.on(iP,this.A,this);this.a.on(rP,this.H,this);this.a.on(qP,this.G,this);this.a.on(oP,this.F,this)}release(){BP(this,0);this.j=!1;this.l=-1;this.h=2}destroy(){this.release();this.a.off(kP,this.C);this.a.off(jP,this.B);this.a.off(iP,this.A);this.a.off(rP,this.H);this.a.off(qP,
|
|
31
|
+
this.G);this.a.off(oP,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;BP(this,6)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",_.Ii(this.f,_.Si))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.j){this.j=!0;var a=this.m.getConfiguration().autoplay;const b=this.a.getState()===vQ;if(!a&&b){BP(this,10);return}}if(a=2!==this.f)a=this.a.getState(),a=a===CP||
|
|
32
|
+
a===DP;a&&EP(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===wQ?BP(this,2):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){BP(this,11)}getState(){return this.f}};var yQ=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.S("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.v(function*(){if(b.m)if(b.B=a,b.j=yield FP(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(_.$d,"http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&GP(b.a)){b.h=HP(b);try{yield b.h.open();b.f=IP(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(_.YA,
|
|
34
|
+
a.id);this.w=!0;let b=_.GE(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,kb:null}}F(){const a=this;return _.v(function*(){a.g.debug("canSwitch_");a.w=!1;a.l&&(yield _.KF(a.f,a.l),a.l=null)})}H(){this.g.debug("onError_")}I(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.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 BQ=class extends _.U{constructor(){super();this.j=this.a=this.m=null;this.f={};this.g=new _.S("clpp.tizen.TrackManager");this.w=this.o=this.l=null;this.B=!1;this.h=1}C(a){var b=a.eventid;a=a.data;switch(b){case zQ:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+PP(this,b[0].extra_info).Bit_rate,b=QP(this,{bandwidth:b}))&&(this.w=b,OP(this,b));break;case AQ:NP(this);break;default:this.g.debug("Event type: "+
|
|
36
|
+
b+" data: "+a)}}A(a){8===a.detail.currentState&&this.m.off(_.bf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.bf,b=>{this.B||(b=b.detail,8===b.currentState&&(this.g.debug("Current state",b.currentState),this.B=!0,RP(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(_.bf,this.A);this.m.on(_.bf,this.A,this);try{const a=eQ(this.a);this.f=XP(this,
|
|
37
|
+
a);const b=this.f[_.M]||[];b.length&&(this.l=b[0].renditions[0]||null);NP(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[_.N]||[]}getAudioTracks(){return this.f[_.M]||[]}sa(){return this.f[_.L]||[]}ta(){return $P(this,_.N)}Sa(){return $P(this,_.M)}Za(){return $P(this,_.L)}wb(){return this.w}Ob(){this.g.info(eP);return null}Pb(){this.g.info(eP);return null}Ja(){const a=this.ta();return a?a.track:
|
|
38
|
+
null}ra(){const a=this.Sa();return a?a.track:null}ua(){const a=this.Za();return a?a.track:null}Gb(a){null===a?(a=this.ta(),gQ(this.a,a.bandwidth,null).then(()=>{NP(this)})):0<a.renditions.length&&this.rb(a.renditions[0])}za(a){a?cQ(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}bb(a){a?(a=a.renditions[0],this.j?MP(this.j,a.track):cQ(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,hQ(this.a,!1),this.m.trigger(new _.H(_.Vf)))}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,OP(this,a),gQ(this.a,b.bandwidth,a.bandwidth).then(()=>{NP(this)}).catch(c=>{const d=new _.J(_.C,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}Eb(a){cQ(this,a)}Fb(a){this.j?MP(this.j,a.track):cQ(this,a)}addTextTrack(){}va(){return this.a.o}};BQ.prototype.isAbrEnabled=BQ.prototype.va;
|
|
40
|
+
BQ.prototype.addTextTrack=BQ.prototype.addTextTrack;BQ.prototype.setTextRendition=BQ.prototype.Fb;BQ.prototype.setAudioRendition=BQ.prototype.Eb;BQ.prototype.setVideoRendition=BQ.prototype.rb;BQ.prototype.setTextTrack=BQ.prototype.bb;BQ.prototype.setAudioTrack=BQ.prototype.za;BQ.prototype.setVideoTrack=BQ.prototype.Gb;BQ.prototype.getTextTrack=BQ.prototype.ua;BQ.prototype.getAudioTrack=BQ.prototype.ra;BQ.prototype.getVideoTrack=BQ.prototype.Ja;BQ.prototype.getLoadingTextRendition=BQ.prototype.Pb;
|
|
41
|
+
BQ.prototype.getLoadingAudioRendition=BQ.prototype.Ob;BQ.prototype.getLoadingVideoRendition=BQ.prototype.wb;BQ.prototype.getTextRendition=BQ.prototype.Za;BQ.prototype.getAudioRendition=BQ.prototype.Sa;BQ.prototype.getVideoRendition=BQ.prototype.ta;BQ.prototype.getTextTracks=BQ.prototype.sa;BQ.prototype.getAudioTracks=BQ.prototype.getAudioTracks;BQ.prototype.getVideoTracks=BQ.prototype.getVideoTracks;var CQ=class extends _.Du{constructor(a){super();this.m=a;this.h=null;this.g=new _.S("clpp.tizen.Middleware");this.F=1;this.C=!1;this.l=null;this.G=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}J(){this.w=!0;this.f||this.trigger(new _.H(kP))}I(a){this.w=!0;this.trigger(new _.H(jP,{percent:a}))}H(){this.w=!1;this.trigger(new _.H(iP))}M(){this.trigger(new _.H(oP))}L(a,b){this.trigger(new _.H("onevent",{eventid:a,data:b}))}P(a,b,c,d,e){this.trigger(new _.H(pP,{duration:a,text:b,subtitleType:c,
|
|
42
|
+
attriCount:d,attributes:e}))}K(a,b){this.trigger(new _.H(mP,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.td&&"Challenge"===b.name?xP(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.J(_.C,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}B(a){this.trigger(new _.H(nP,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(lP,f,this);e=setTimeout(()=>{this.off(lP,f);d("Timeout")},3E4)});if(a===wQ)return(new Promise((c,
|
|
43
|
+
d)=>{webapis.avplay.prepareAsync(()=>{kQ(this);c(webapis.avplay.play())},e=>{this.trigger(new _.H(nP));d(e)})})).then(()=>b());if(a===DP||a===vQ)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===CP?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===DP?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===vQ||b===CP||b===DP){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 pQ(c),yield tQ(c,a,b)}catch(d){throw new _.J(_.C,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Wf;try{return webapis.avplay.getState()}catch(a){this.B(JSON.stringify(a))}}seek(a){const b=
|
|
45
45
|
1E3*a;return new Promise((c,d)=>{this.C=!0;this.m.trigger(new _.H(_.kg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.H(_.jg));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.He.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
|
|
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
|
|
48
|
-
this.h.getDrmInfo();return null}setSourceIndex(a){this.G=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
|
-
_.de,"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}_.
|
|
52
|
-
this;return _.v(function*(){yield a.release();a.a.off(
|
|
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.He.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 fP:this.g.debug("The application does not have the privilege to get the volume.",gP);break;default:this.g.debug(dP,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 fP:this.g.warn("The application does not have the privilege to set the volume.",gP);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()]}},wQ="IDLE",vQ="READY",CP="PLAYING",DP="PAUSED",SP=_.Cb,TP=_.wA,bQ="TEXT",AQ="PLAYER_MSG_RESOLUTION_CHANGED",zQ="PLAYER_MSG_BITRATE_CHANGE";var GQ=class extends _.Du{constructor(){super();this.a=new CQ(this);this.f=new xQ(this);this.configuration=this.B=_.sm();this.w=null;this.g=new _.S("clpp.tizen.Player");this.j=null;this.l=new BQ;this.C=new _.Kr;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(_.$f,
|
|
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=_.Ki(d))&&this.o.append([new _.fu(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}`);BP(this.f,3);a=new _.J(_.C,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(oP,this.I,this);this.a.on(lP,this.F,this);this.a.on(pP,this.J,this);this.a.on(mP,this.G,this);this.a.on(nP,this.H,this);this.a.on(iP,this.K,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=DQ;DQ+=1;a="__clpp_tizen_player_"+a;this.j=_.Ep(_.Ce,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Gg,_.Xd,"position",
|
|
51
|
+
_.de,"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}_.Gp(a,d);uQ(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(oP,a.I);a.a.off(lP,a.F);a.a.off(pP,a.J);a.a.off(mP,a.G);a.a.off(nP,a.H);a.a.off(iP,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 EQ}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:11===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 _.
|
|
55
|
-
new
|
|
56
|
-
this.f.getState()}isPaused(){return this.a.getState()===
|
|
57
|
-
|
|
54
|
+
return new _.Au}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=_.um([b.B,a]);var c=_.Uo(b.configuration,[_.Zd,_.xe]);b.o=c.create(b);c=_.cp(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=
|
|
55
|
+
new yQ;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));uQ(this);return this.a.play().then(()=>{EP(this.f)})}pause(){return this.a.pause().then(()=>{EP(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.H(_.Sd,{detail:a});a.severity===_.C&&(BP(this.f,3),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return 11===
|
|
56
|
+
this.f.getState()}isPaused(){return this.a.getState()===DP}isMuted(){return nQ(this.a)}setMuted(a){rQ(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 FQ).canPlay(a,b)}getTimelineCues(){return[]}getCueTimeline(){return null}getTextDisplayer(){return this.o}resetAbr(){}},
|
|
57
|
+
EQ="clpp.tizen",DQ=0,FQ=class{a(){return EQ}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.tc||a===_.lm||a===_.Bc)&&b){if(_.Qh(2))return 2;if(_.Qh(3)||_.Qh(4)||_.Qh(5)||_.Qh(6))return _.A("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 GQ}};_.w("clpp.tizen.TizenComponent",class extends _.Fv{install(){_.vh(new FQ)}uninstall(){var a=EQ;a&&_.th[a]&&(delete _.th[a],_.uh.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
|
-
_.Ad,"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
|
-
_.P(g.reader):_.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Kx='application/mp4; codecs\x3d"stpp.ttml"',Lx='application/mp4; codecs\x3d"stpp.ttml.im1i"',Mx='application/mp4; codecs\x3d"stpp.ttml.im1t"',Nx="backgroundColor",Ox="direction",Px="displayAlign",Qx="region",Rx="textAlign",Sx="textDecoration",Tx="writingMode",Ux=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},by=function(a,b){var c=null;if(Vx.test(a)){{a=Vx.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 Wx.test(a)?c=Xx(Wx,a):Yx.test(a)?c=Xx(Yx,a):Zx.test(a)?(a=Zx.exec(a),c=Number(a[1])/b.frameRate):$x.test(a)?(a=$x.exec(a),c=Number(a[1])/b.a):ay.test(a)&&(c=Xx(ay,a));return c},Xx=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)},cy=function(a){return a.split(":").pop()},dy=function(a){return a.replace(/(\d*\.?\d+)c/g,
|
|
3
|
+
"$1em")},fy=function(a,b){for(;ey.test(a);){const c=ey.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},gy=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},hy=function(a,b,c){a=Ux(a,b,Rx);if(!a&&c&&(a=Ux(c,b,Rx),!a&&"rltb"===Ux(c,b,Tx)))return _.Qd;switch(a){case _.Wc:return _.au;case _.xf:case _.Qd:return _.Qd;default:return _.Kf}},iy=function(a,b,c){if(_.Fi(a.w))return document.createTextNode(_.Ki(a.w||""));if(a.A)return _.Ep("br");const d=_.Ep("span");for(const e of a.f)_.Fp(d,
|
|
4
|
+
e);for(const e of a.j)d.appendChild(iy(c.get(e),b,c));return d},ly=function(a,b,c,d){const e=jy.exec(a);a=ky.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},my=function(a,b){return typeof b===_.r&&0<b?_.iu:ky.test(a)?0:_.iu},ny=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},oy=function(a,b){a=a.getAttribute("extent");return(a=ky.exec(a))?Number(a[b]):null},qy=function(a){a=a.getAttribute("cellResolution");return(a=py.exec(a))?Number(a[2]):null},
|
|
5
|
+
sy=function(){return`${"inline-"}${ry++}`},uy=function(a){return ty.some(b=>b in a.attributes)},vy=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...vy(a,a.a.get(d).f),d);return c},wy=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)},xy=function(a){return cy(a.h.nodeName)},Ay=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={},yy.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Qx)&&(c=b.getAttribute(Qx));b.hasAttribute(_.Qf)&&f.push(...b.getAttribute(_.Qf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=cy(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new zy(b,c,d,e,f,g);a.a.set(b,c);return c},By=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")}`},Cy=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 Dy=class extends Cy{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Ey=class extends Cy{constructor(a,b,c){super(a,b,c)}};var Vx=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Wx=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Yx=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Zx=/^(\d*(?:\.\d*)?)f$/,$x=/^(\d*(?:\.\d*)?)t$/,ay=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,jy=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,ky=/^(\d+)px (\d+)px$/,py=/^(\d+) (\d+)$/,ey=/(\d+)px/,Fy=/^(\d+px|\d+em|\d*\.?\d+c)$/,ty=[Nx,"color",Ox,Px,"fontFamily","fontSize","fontStyle","fontWeight",
|
|
8
|
+
"lineHeight","opacity","padding",Rx,Sx,"textOutline",Tx,"zIndex"],yy=["begin",_.Qd];var Gy=class extends Ey{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=by(this.a.begin,b);b=by(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Ep(_.Ad);for(const k of this.j)c.appendChild(iy(g.get(k),e,g));g=new _.fu(h,b,c.innerHTML.trim(),_.cg);g.cssClassList=[...this.f];g.textAlign=hy(this,e,null);g.writingMode=_.bu;g.line=-1;g.lineInterpretation=_.cu;g.lineAlign=_.du;g.containerRows=ny(null,qy(a),15);if(this.o&&(f=
|
|
9
|
+
f.get(this.o))){g.region=f.build(a,e);g.textAlign=hy(this,e,f);a:switch(Ux(f,e,Tx)){case "tb":case "tblr":a=_.ng;break a;case "tbrl":a=_.og;break a;default:a=_.bu}g.writingMode=a;a:switch(Ux(f,e,Px)){case _.Wc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Ux(f,e,Px)){case _.Wc:a=1;break a;default:a=_.cu}g.lineInterpretation=a;a:switch(Ux(f,e,Px)){case _.Wc:e=_.Wc;break a;default:e=_.du}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 Hy=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 Iy=class extends Ey{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.ku;c.id=this.getId();const d=ny(a.j.containerWidth,oy(a,1),720);a=ny(a.j.containerHeight,oy(a,2),480);a:switch(Ux(this,b,Px)){case "after":var e="flex-start";break a;case _.Wc:e=_.Wc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Ux(this,b,Tx)){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")||Ux(this,b,"extent");c.width=ly(e,
|
|
11
|
+
d,1,100);c.widthUnits=my(e,d);c.height=ly(e,a,2,100);c.heightUnits=my(e,a);b=this.getAttribute("origin")||Ux(this,b,"origin");c.viewportAnchorX=ly(b,d,1,0);c.viewportAnchorY=ly(b,a,2,0);c.viewportAnchorUnits=my(b,d);c.cssClassList=[...this.f];return c}};var Jy=class extends Cy{constructor(a,b){super("root-container",[],b);this.j=a}};var Ly=class extends Cy{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=qy(a);c&&(b=ny(a.j.containerHeight,oy(a,2),480)/c);b=ny(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of Ky.entries())g in this.a&&(c+=`${h}:${dy(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&&!Fy.test(h)&&Fy.test(k)&&Fy.test(l)?(e=h,g=k):2===d.length&&!Fy.test(h)&&Fy.test(k)?(e=h,g=k):2===d.length&&Fy.test(h)&&Fy.test(k)&&(g=h);if(""!==g){g=dy(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=gy(this.a.textShadow),d=dy(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(Sx 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
|
+
dy(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=dy(d),d=fy(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=dy(c);c=fy(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}},Ky=new Map([[Nx,"background-color"],
|
|
15
|
+
["color","color"],[Ox,Ox],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var My=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=[]}},ry=0;var Py=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&&!Ny.has(cy(a.nodeName))||Oy.has(cy(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&&!Ny.has(cy(a.nodeName))));const b=this.a;this.a=a;return b}},Ny=new Set(["tt","head","layout",_.re,_.ae,Qx,"styling",_.Qf,"body",
|
|
16
|
+
_.Ad,"p","span","br"]),Oy=new Set([_.Qf,_.ae]);var zy=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 Qy=class{constructor(){this.a=new Map}};var Ry=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.Yg(this.a.ttml||{}),e=_.E(a,0,c[0]);e=_.wi(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Uf)}catch(m){throw new _.J(_.C,2,2005,"Failed to parse TTML.");}d=new My(d);e=new Qy;f=new Py(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=_.E(a,b,h);k=_.Nk(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
|
|
17
|
+
new Dy(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Kd();)a=f.next(),a=Ay(e,a),c=d,b=a,"tt"===xy(b)&&(c.l=new Jy(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===xy(b)&&(c.w=new Hy(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,xy(b)!==_.ae||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new Dy(g,b.h.textContent,b.attributes))),c=d,g=a,xy(g)===_.ae&&g.attributes.begin&&g.attributes.end?(b=`#${sy()}`,
|
|
18
|
+
g=new Dy(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,xy(b)===_.Qf&&(g=b.getId()||sy(),h=new Ly(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,xy(g)!==_.Qf&&uy(g)?(b=sy(),g=new Ly(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,xy(g)!==_.Ad||!g.attributes.extent&&!g.attributes.origin?c=null:(b=sy(),g=new Iy(b,vy(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
|
|
19
|
+
c.getId()),c=d,g=a,xy(g)!==Qx?c=null:(b=g.getId(),g=new Iy(b,vy(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(xy(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=sy(),g=new Gy(b,g.h.nodeName===_.da?g.h.textContent:null,"br"===xy(g),g.a,g.j,vy(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"===xy(g)||g.j?(b=sy(),g=new Gy(b,null,!1,g.a,g.j,vy(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=wy(d);f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Sy=class{constructor(a){this.f=a}a(a){var b=new Ry(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=By(d.startTime)+" --\x3e "+By(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.de:e.push("align:left");break;case _.xf:e.push("align:right");break;case _.au:e.push("align:middle");break;case _.Kf:e.push("align:start");break;case _.Qd:e.push("align:end")}switch(c.writingMode){case _.ng:e.push("vertical:lr");break;case _.og:e.push("vertical:rl")}c=
|
|
21
|
+
e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.Ai(b)}},Ty=class{probe(a,b){return a===_.Ac&&b===_.Tf}create(a){return new Sy(a)}};var Uy=class{constructor(a){this.a=new Ry(a);this.g=new _.S("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Wm).N(_.ue,_.Pm).N(_.bg,_.Pm).N(_.pe,_.Pm).N(_.te,_.Pm).N(_.Nf,_.Pm).fa(_.Pf,_.Qm).N("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.J(_.C,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.Wm).N("moof",_.Pm).N("traf",_.Pm).fa("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.Fm(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
|
|
22
|
+
_.P(g.reader):_.Fm(g.reader);f.push(n);g.reader.skip(6)}}}).N(_.oe,_.Rm(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 _.Fv{constructor(){super();this.a=new Ty}install(){_.Ct(_.Ac,Ry);_.Ct(_.vc,Uy);_.Ct(Kx,Uy);_.Ct(Mx,Uy);_.Ct(Lx,Uy);_.Nl.push(this.a)}uninstall(){_.Et(_.Ac);_.Et(_.vc);_.Et(Kx);_.Et(Mx);_.Et(Lx);_.Pl(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.j.bind(this)}});_.
|
|
4
|
-
b);_
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var zx="VerimatrixVCAS",Ax="clpp.verimatrix.Vcas",Bx="clpp.verimatrix.VcasComponent",Dx=function(a,b){return a.F===Cx?(a=Object.assign({},{deviceId:_.Ok(_.Ci(a.B))},a.a&&{authenticator:_.Ok(_.Ci(a.a))}),b+_.Bj(a)):b},Jx=class extends _.Gv{constructor(a){super(zx);const b={};b[Ex]=Ex;b[Fx]=Fx;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=Cx,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
|
|
2
|
+
Gx}=a;this.B=c;this.a=d;this.F=e;this.C=f;this.A=Dx(this,g);this.w=Dx(this,h);this.o=Dx(this,k);this.l=l;this.I=m;this.H=n;this.g=new _.S(Ax);_.Gi(this.A)?this.g.warn(_.Gb):this.Ha(_.td,{licenseUrl:this.A,videoRobustness:[_.nb,void 0],audioRobustness:[_.mb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.j.bind(this)}});_.Gi(this.w)?this.g.warn(_.cb):this.Ha(_.rd,{licenseUrl:this.w,videoRobustness:["3000"],audioRobustness:["2000"],
|
|
3
|
+
modifiers:{licenseRequest:this.j.bind(this)}});_.Gi(this.o)?this.g.warn(_.Ca):_.Gi(this.l)?this.g.warn(_.Ba):this.Ha(_.pd,{licenseUrl:this.o,certificateUrl:this.l,modifiers:{licenseRequest:this.L.bind(this),licenseResponse:this.M.bind(this),extractContentId:this.J.bind(this)}})}j(a,b){if(this.F===Hx){a=this.C[Fx];const c={};c[this.C[Ex]]=this.B;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}J(a,b){a=_.Vm(b);switch(this.H){case Ix:a=_.Bj({r:a,Mj:this.I},!0)}return a}L(a,b){this.j(a,
|
|
4
|
+
b);_.$m(b)}M(a,b){_.an(b)}};_.w(Ax,Jx);Jx.prototype.constructor=Jx.prototype.constructor;Jx.NAME=zx;var Cx="query-string",Hx="http-header";Jx.LicenseRequestVuidLocation={QUERY_STRING:Cx,HTTP_HEADER:Hx};var Ex="DeviceId",Fx="Authenticator";Jx.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Ex,AUTHENTICATOR_HEADER:Fx};var Gx="keyid",Ix="contentid-siteid";Jx.FairPlayAssetIdStrategy={KEYID:Gx,CONTENTID_SITEID:Ix};_.w(Bx,class extends _.Fv{constructor(){super();this.g=new _.S(Bx)}uninstall(){delete _.mk.VerimatrixVCAS}drmConfigurationResolved(a){if(a&&a.env===zx){({customData:a}=a);if(!a)throw new _.J(_.C,7,7100,_.ud);a=new Jx(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.nk(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
|
-
e;this.a=new _.Ut;this.j=!0;this.ga=this.h=this.A=!1;this.B=null;this.f=new _.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qx="Registering listeners",rx="clpp.vimond.VimondPlugin",sx=function(a,b){a.m.trigger(new _.H(_.tg,{detail:b}))},tx=function(a,b,c){b&&(a.A=!0,a.f.stop());a.m.onError(new _.J(b?_.C:1,9,9201,c))},ux=function(a,b){const c=a.m.getPlayerState();if(1===b)return["str-start",_.cf];if(a.h)return[_.Qd,_.Ne];if(11===c)return[_.Qd,null];if(3===c)return[_.Sd,_.Ne];b=_.Ne;if(6===c||8===c||a.f)b=_.cf;return["period",b]},vx=class{constructor(a,b,c,d,e){this.J=a;this.K=b;this.L=c;this.m=d;this.C=
|
|
2
|
+
e;this.a=new _.Ut;this.j=!0;this.ga=this.h=this.A=!1;this.B=null;this.f=new _.Kh(this.w.bind(this));this.g=new _.S("clpp.vimond.VimondDispatcher");this.l=this.o=0;this.m&&this.a&&(this.g.debug(qx),this.a.on(this.m,_.bf,this.H.bind(this)),this.a.on(this.m,_.$f,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
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&&8!==d||(b.ga&&[10,6].includes(d)?b.g.debug("Seeking"):(b.ga&&8===d&&(b.g.debug("Seeked"),b.ga=!1),[8,10,3,11].includes(d)&&(b.B=d,yield b.w(),11===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();
|
|
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 _.J(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
|
|
8
|
-
this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}Kf(a){this.a&&this.h&&this.h.Kf(a)}};
|
|
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();sx(a,c)}catch(d){b=d.code,c=d.data,[1002,1003].includes(b)?(a.g.debug("Unreachable service"),sx(a,c),tx(a,a.K,c)):1001===b?(a.g.debug("Generic service error"),sx(a,c),tx(a,a.L,c)):a.g.error(d.toString())}})}};var wx=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.h=b;this.a=d;this.j=e;this.g=new _.S("clpp.vimond.VimondService");this.f=0}fireEvent(){this.f++;const a=_.Xg(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.Ua().url;a.client.userAgent=navigator.userAgent;a.client.videoFormat=this.a.m.Ua().type||"";b=a.client;c=this.a.m.Ua();c=((new _.Um(c.url)).scheme||
|
|
5
|
+
"").replace(":","");b.videoProtocol=c;b=ux(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=_.fk(this.l);b.method=_.bb;b.contentType="application/json";b.headers.Authorization=`Bearer ${this.h}`;b.body=_.Ci(JSON.stringify(a));return this.j.fetch(b).V}Kf(a){this.h=a}};var xx=class{constructor(a){this.m=a;this.a=new _.Ut;this.g=new _.S("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(qx),this.a.on(this.m,_.tf,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 yx=class extends _.$v{constructor(){super();this.a=!1;this.g=new _.S(rx);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 _.J(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 xx(a);this.h=new wx(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new vx(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){if(this.a){if(this.f){var a=this.f;a.g.debug(_.yb);_.Eh(a.a)}this.j&&(a=this.j,a.g.debug(_.yb),_.Eh(a.a),a.f.stop());this.j=this.h=
|
|
8
|
+
this.f=null}}onPlayerWillDestroy(){}id(){return"vimond"}Kf(a){this.a&&this.h&&this.h.Kf(a)}};yx.prototype.updateAuthToken=yx.prototype.Kf;_.w(rx,yx);yx.Id="vimond";_.Tr(new class{create(){return new yx}});};f.call(g, window);
|