@castlabs/prestoplay 6.6.1-beta.2 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +6 -6
  5. package/cjs/cl.cast.js +110 -110
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +403 -403
  8. package/cjs/cl.crypto.js +10 -10
  9. package/cjs/cl.dash.js +71 -71
  10. package/cjs/cl.externs.js +47 -41
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +68 -49
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -31
  15. package/cjs/cl.ima.js +24 -23
  16. package/cjs/cl.mse.js +263 -260
  17. package/cjs/cl.muxdata.js +11 -12
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.smooth.js +70 -69
  22. package/cjs/cl.thumbnails.js +24 -24
  23. package/cjs/cl.tizen.js +71 -71
  24. package/cjs/cl.ttml.js +27 -27
  25. package/cjs/cl.verimatrix.js +5 -5
  26. package/cjs/cl.vimond.js +13 -13
  27. package/cjs/cl.vr.js +13 -13
  28. package/cjs/cl.vtt.js +11 -11
  29. package/cjs/cl.youbora.js +19 -19
  30. package/cl.adobe.js +3 -3
  31. package/cl.airplay.js +3 -3
  32. package/cl.broadpeak.js +5 -5
  33. package/cl.cast.js +88 -88
  34. package/cl.conviva.js +27 -27
  35. package/cl.core.js +345 -343
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +67 -67
  38. package/cl.externs.js +47 -41
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +57 -40
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +17 -16
  44. package/cl.mse.js +227 -227
  45. package/cl.muxdata.js +9 -8
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +10 -10
  48. package/cl.playlist.js +5 -5
  49. package/cl.smooth.js +58 -58
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +22 -22
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +15 -15
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +14 -14
  58. package/package.json +1 -1
  59. package/typings.d.ts +118 -12
@@ -1,28 +1,28 @@
1
1
  (function(){var g={}; var _ = _ || {}
2
- var f=function(window){var Ot="No thumbnail duration or URL specified",Pt="No thumbnail found for position ",Qt="Position is out of range: ",Rt="Thumbnail URL is mandatory",St="Wrong gridSize format",Tt="clpp.thumbnails",Ut=function(){this.log=new _.H(Tt);this.g=null;this.a=[];this.w=!1},Wt=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Ld&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return Vt(a,0,e,!!f)})},Promise.resolve())},Vt=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();
3
- var e=b+c;return Xt(a,d).then(function(){return a.a[b].load()}).then(function(){return Vt(a,e,c,d)})},Xt=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.cn)c();else a.g.one(_.uc,function(){c()})})},Yt=function(a,b){return b>=a.time&&b<a.time+a.duration},Zt=function(a,b,c,d,e,f,g,h,l,m,n,p){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;l=void 0===l?1:l;m=void 0===m?0:m;n=void 0===n?0:n;p=void 0===p?new Image:p;this.time=b;this.src=a;this.duration=
4
- c;this.x=d;this.y=e;this.width=f;this.height=g;this.ia=p;this.Th=h;this.Gj=l;this.ni=m;this.oi=n;this.Ob=null},$t=function(){Ut.call(this);this.f=null;this.o=this.h=1;this.j=0},au=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Sf=new _.Th},bu=function(){this.g=new _.H(Tt);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Th},cu=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.Sf.resolve()})},eu=function(a,b){return du(a,b).then(function(c){return new Zt(c,
5
- b.time,b.duration)})},du=function(a,b){return b.load().then(function(){var c=_.N(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.kk(c)})},fu=function(){Ut.call(this);this.f=null},gu=function(a){a=a.split(/\.|:/).map(parseFloat);var b=0,c,d={3:.001,2:1,1:60,0:3600};for(c=a.length-1;0<=c;c--)b+=a[c]*d[c];return b},hu=function(){Ut.apply(this,arguments)},iu=function(a,b){for(var c=null,d=_.u(a),e=d.next();!e.done;e=d.next())e=e.value,e.startTime<=b&&(c=e);return c},ju=function(a,b){var c=a.horizontalTiles||
6
- b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{cd:c,ef:d,Lf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},ku=function(){this.f=new _.H(Tt);this.a=this.l=null},lu=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},mu=function(a){if(!a)return null;a=new _.qi(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},nu=function(){};Ut.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.ge,function(){c.w=!0});a.isLive()||this.m().then(function(){b&&b.preload&&Wt(c,b.preload)})};Zt.prototype.raw=function(){return this.ia.cloneNode(!1)};
7
- Zt.prototype.element=function(a,b){var c=this.width,d=this.height,e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));e=document.createElement(_.Yc);e.style.width=c+_.de;e.style.height=d+_.de;e.style.backgroundColor="#000";e.style.backgroundRepeat="no-repeat";e.style.backgroundImage='url("'+this.src+'")';e.style.backgroundSize=Math.ceil(c/this.width*(this.ia.naturalWidth||this.ia.width))+"px "+Math.ceil(d/
8
- this.height*(this.ia.naturalHeight||this.ia.height))+_.de;var f=this.y/this.height;e.style.backgroundPositionX="-"+this.x/this.width*c+_.de;e.style.backgroundPositionY="-"+f*d+_.de;return e};
9
- Zt.prototype.load=function(){var a=this;this.Ob||(this.Ob=new Promise(function(b,c){function d(){a.width||(a.width=(a.ia.naturalWidth||a.ia.width)/a.Th);a.height||(a.height=(a.ia.naturalHeight||a.ia.height)/a.Gj);a.x||(a.x=a.width*a.ni);a.y||(a.y=a.height*a.oi)}if(a.ia.src&&a.ia.complete)d(),b(a);else{var e=null,f=function(){d();a.ia.removeEventListener("load",f);a.ia.removeEventListener(_.jd,e);b(a)};e=function(){a.ia.removeEventListener("load",f);a.ia.removeEventListener(_.jd,e);c()};a.ia.addEventListener("load",
10
- f);a.ia.addEventListener(_.jd,e);a.ia.src=a.src}}));return this.Ob};_.C("clpp.thumbnails.Thumbnail",Zt);Zt.prototype.load=Zt.prototype.load;Zt.prototype.element=Zt.prototype.element;Zt.prototype.raw=Zt.prototype.raw;_.v($t,Ut);
11
- $t.prototype.init=function(a,b){if(!b||!b.url)throw new _.L(_.M,7,7100,Rt);if("GRID"===b.mode&&!b.gridSize)throw new _.L(_.M,7,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.L(_.M,7,7100,"Duration is mandatory");this.f=b;var c=this.f.duration,d=this.f.url;if(!c||!d)throw this.log.error(Ot,c,d),new _.L(_.M,7,7100,Ot);this.j=c;if(this.f.gridSize)try{var e=this.f.gridSize.split(/x/).map(function(f){return parseInt(f,10)}).filter(function(f){return 0<f});if(2===e.length)this.h=e[0],
12
- this.o=e[1];else throw new _.L(_.M,7,7100,St);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.L(_.M,7,7100,St);}Ut.prototype.init.call(this,a,b)};$t.prototype.get=function(a){var b=this.g.getDuration();if(void 0===this.f.duration)return Promise.reject("Duration configuration not defined");var c=Math.floor(a/this.f.duration);if(0>a||a>b)return Promise.reject(Qt+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Pt+a+" at index "+c)};
13
- $t.prototype.m=function(){if(0<this.a.length)return Promise.resolve();var a=this.g.getDuration(),b=this.h*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);for(var c=this.f.templateKey||"$index$",d=0;d<a;d++)for(var e=this.f.url.replace(c,String(d+1)),f=new Image,g=0;g<b;g++)this.a.push(new Zt(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()};au.prototype.load=function(){return this.Sf};
14
- bu.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Rt);var d=b.url,e=_.Oh(d);e.type=_.Nh;a.getNetworkEngine().fetch(e).O.then(function(f){f=f.data;var g=_.N(c.f);f=_.N(f);for(var h=g.byteLength+f.byteLength,l=new ArrayBuffer(h),m=new DataView(l),n=0,p=0,q=g.byteLength;p<q;p++)m.setUint8(n,g[p]),n+=1;g=0;for(p=f.byteLength;g<p;g++)m.setUint8(n,f[g]),n+=1;c.f=l;c.g.info("Appended "+f.byteLength+" bytes.Total data now "+(h+" bytes."))}).then(function(){var f=c.f,g=_.N(f),
15
- h=String.fromCharCode.apply(null,ou),l=Array.prototype.slice.call(g,0,8);g=64;var m=0;var n=!1;if(h===String.fromCharCode.apply(null,l))for(f=new DataView(f,16,20),f=f.getUint32(0,!0),0===f&&(f=1E3);!n;){m+=1;l=f;h=new DataView(c.f,g);n=h.getUint32(0,!0);l=n*l/1E3;h=h.getUint32(4,!0);h=new au(l,h);if(l=c.a.length)l=c.a[l-1],l.length=h.offset-l.offset,l.duration=h.time-l.time;c.a.push(h);g+=8;(n=4294967295===n)&&c.h.resolve();if(1E5<m)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");
16
- }).then(function(){cu(c)})["catch"](function(f){c.g.error("[BIF] Error while loading thumbnails '\n + 'URL: "+d,f);a.onError(new _.L(1,7,2013,"Error while loading and parsing BIF thumbnails.",f))})};bu.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Qt+a):this.h.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(Yt(d,a))return eu(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Pt+a)})};var ou=[137,66,73,70,13,10,26,10];_.v(fu,Ut);
17
- fu.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Rt);var d=b.url,e=_.Oh(d);e.type=_.Nh;this.f=a.getNetworkEngine().fetch(e).O.then(function(f){if(f=f.data){f=_.wh(f).split(/\n/);for(var g=0;g<f.length;g++){var h=f[g],l=h.split(" --\x3e ");if(2===l.length){h=f[++g];var m=h.indexOf("\x3d"),n=0>m?[]:h.substr(m+1).split(/,/).map(parseFloat);m=n[0];var p=n[1],q=n[2];n=n[3];var r=h.indexOf("#");h=0>r?h:h.substr(0,r);h.match(/^http|^\/\//)||(h=d.substr(0,d.lastIndexOf("/"))+"/"+
18
- h);r=gu(l[0]);l=gu(l[1])-r;c.a.push(new Zt(h,r,l,m,p,q,n,0,0))}}}})["catch"](function(f){c.log.error("[VTT] Error while loading thumbnails URL: "+d,f);a.onError(new _.L(1,7,2013,"Error while loading VTT thumbnails.",f))});Ut.prototype.init.call(this,a,b)};
19
- fu.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Qt+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Nc:c.Nc},d++)if(c.Nc=b.a[d],Yt(c.Nc,a))return c.Nc.load().then(function(e){return function(){return e.Nc}}(c));return Promise.reject(Pt+a)})};fu.prototype.m=function(){return this.f};_.v(hu,Ut);
20
- hu.prototype.get=function(a){if(0>a)return this.log.error("Position must be greater than 0 but is "+a),Promise.reject();var b=this.g.getPeriods();b=iu(b,a);if(!b)return this.log.error("Could not find period for specified position",a),Promise.reject();var c=b.thumbStreams.sort(this.f)[0];if(!c)return this.log.error("Could not find thumb stream for specified position",a),Promise.reject();b=c.findSegmentPosition(a-b.startTime);if(null===b||void 0===b)return this.log.error("Could not find segment index for specified position",a),
21
- Promise.reject();var d=c.getSegmentReference(b);if(d){var e=ju(d,c);a=Math.floor((a-d.startTime)/e.durationPerTile);var f;if(0<this.a.length)d=c.findSegmentPosition(0),null!==d&&(f=this.a[(b-d)*e.Lf+a]);else if((c=d.Oa())&&0<c.length){var g=0,h=0;d=d.startTime;1<e.Lf&&(g=a%e.cd,h=Math.floor(a/e.cd),d+=a*e.durationPerTile);f=new Zt(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.cd,e.ef,g,h)}if(f)return f.load().then(function(){return f})}this.log.error("segment reference for specified segment index does not exist",
22
- b);return Promise.reject()};hu.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
23
- hu.prototype.m=function(){if(0<this.a.length)return Promise.resolve();var a=this.g.getPeriods();a=_.u(a);for(var b=a.next();!b.done;b=a.next())if(b=b.value.thumbStreams.sort(this.f)[0])for(var c=b.findSegmentPosition(0),d=void 0;null!==c&&!_.K.R(d=b.getSegmentReference(c++));)for(var e=ju(d,b),f=d.Oa()[0],g=new Image,h=d.startTime,l=0;l<e.ef;++l)for(var m=0;m<e.cd;++m)this.a.push(new Zt(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.cd,e.ef,m,l,g)),h+=e.durationPerTile;return Promise.resolve()};_.t=ku.prototype;_.t.onPlayerCreated=function(a){this.l=a};_.t.onPlayerWillDestroy=function(){this.l=null};_.t.onPlayerWillRelease=function(){this.a=null};
24
- _.t.onContentWillLoad=function(a){var b=this,c=a.getConfiguration();if(c.thumbnails){var d=c.thumbnails;d&&(void 0===d.enabled||d.enabled)&&((c=d.mode)||(c=mu(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new $t:"WEBVTT"===c?this.a=new fu:"BIF"===c&&(this.a=new bu)),this.a&&(this.f.info("Loading thumbs configuration",d),this.l.one(_.xd,function(){b.f.info("Initialize thumbnails provider");b.a.init(a,d)})))}else this.a=null};
25
- _.t.onContentLoaded=function(a,b){for(var c=1;c<arguments.length;++c);if(!this.a&&(c=(c=a.getConfiguration())&&c.thumbnails,!c||void 0===c.enabled||c.enabled)){var d=a.getPeriods();lu(d)&&(this.a=new hu,this.a.init(a,c))}};_.t.get=function(a){return this.a?this.a.get(a):Promise.reject()};_.t.id=function(){return"thumbnails"};_.C("clpp.thumbnails.ThumbnailsPlugin",ku);ku.prototype.get=ku.prototype.get;ku.Id="thumbnails";nu.prototype.create=function(){return new ku};_.Fo(new nu);};
2
+ var f=function(window){var Pt="No thumbnail duration or URL specified",Qt="No thumbnail found for position ",Rt="Position is out of range: ",St="Thumbnail URL is mandatory",Tt="Wrong gridSize format",Ut="clpp.thumbnails",Vt=function(){this.log=new _.H(Ut);this.g=null;this.a=[];this.A=!1},Xt=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Ld&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return Wt(a,0,e,!!f)})},Promise.resolve())},Wt=function(a,b,c,d){if(a.A||b>=a.a.length)return Promise.resolve();
3
+ var e=b+c;return Yt(a,d).then(function(){return a.a[b].load()}).then(function(){return Wt(a,e,c,d)})},Yt=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.cn)c();else a.g.one(_.wc,function(){c()})})},Zt=function(a,b){return b>=a.time&&b<a.time+a.duration},$t=function(a,b,c,d,e,f,g,h,l,m,n,p){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;l=void 0===l?1:l;m=void 0===m?0:m;n=void 0===n?0:n;p=void 0===p?new Image:p;this.time=b;this.src=a;this.duration=
4
+ c;this.x=d;this.y=e;this.width=f;this.height=g;this.ja=p;this.Gi=h;this.Rk=l;this.mj=m;this.nj=n;this.Sb=null},au=function(){Vt.call(this);this.f=null;this.w=this.j=1;this.m=0},bu=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.pg=new _.di},cu=function(){this.h=new _.H(Ut);this.f=new ArrayBuffer(0);this.a=[];this.g=new _.di},du=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.pg.resolve()})},fu=function(a,b){return eu(a,b).then(function(c){return new $t(c,
5
+ b.time,b.duration)})},eu=function(a,b){return b.load().then(function(){var c=_.N(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.Lh(c)})},gu=function(){Vt.call(this);this.f=null},hu=function(a){a=a.split(/\.|:/).map(parseFloat);var b=0,c,d={3:.001,2:1,1:60,0:3600};for(c=a.length-1;0<=c;c--)b+=a[c]*d[c];return b},iu=function(){Vt.apply(this,arguments)},ju=function(a,b){for(var c=null,d=_.u(a),e=d.next();!e.done;e=d.next())e=e.value,e.startTime<=b&&(c=e);return c},ku=function(a,b){var c=a.horizontalTiles||
6
+ b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{kd:c,yf:d,hg:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},lu=function(){this.h=new _.H(Ut);this.a=this.l=null},mu=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},nu=function(a){if(!a)return null;a=new _.Bi(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},ou=function(){};Vt.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.ge,function(){c.A=!0});a.isLive()||this.o().then(function(){b&&b.preload&&Xt(c,b.preload)})};$t.prototype.raw=function(){return this.ja.cloneNode(!1)};
7
+ $t.prototype.element=function(a,b){var c=this.width,d=this.height,e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));e=document.createElement(_.$c);e.style.width=c+_.de;e.style.height=d+_.de;e.style.backgroundColor="#000";e.style.backgroundRepeat="no-repeat";e.style.backgroundImage='url("'+this.src+'")';e.style.backgroundSize=Math.ceil(c/this.width*(this.ja.naturalWidth||this.ja.width))+"px "+Math.ceil(d/
8
+ this.height*(this.ja.naturalHeight||this.ja.height))+_.de;var f=this.y/this.height;e.style.backgroundPositionX="-"+this.x/this.width*c+_.de;e.style.backgroundPositionY="-"+f*d+_.de;return e};
9
+ $t.prototype.load=function(){var a=this;this.Sb||(this.Sb=new Promise(function(b,c){function d(){a.width||(a.width=(a.ja.naturalWidth||a.ja.width)/a.Gi);a.height||(a.height=(a.ja.naturalHeight||a.ja.height)/a.Rk);a.x||(a.x=a.width*a.mj);a.y||(a.y=a.height*a.nj)}if(a.ja.src&&a.ja.complete)d(),b(a);else{var e=null,f=function(){d();a.ja.removeEventListener("load",f);a.ja.removeEventListener(_.jd,e);b(a)};e=function(){a.ja.removeEventListener("load",f);a.ja.removeEventListener(_.jd,e);c()};a.ja.addEventListener("load",
10
+ f);a.ja.addEventListener(_.jd,e);a.ja.src=a.src}}));return this.Sb};_.C("clpp.thumbnails.Thumbnail",$t);$t.prototype.load=$t.prototype.load;$t.prototype.element=$t.prototype.element;$t.prototype.raw=$t.prototype.raw;_.w(au,Vt);
11
+ au.prototype.init=function(a,b){if(!b||!b.url)throw new _.L(_.M,7,7100,St);if("GRID"===b.mode&&!b.gridSize)throw new _.L(_.M,7,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.L(_.M,7,7100,"Duration is mandatory");this.f=b;var c=this.f.duration,d=this.f.url;if(!c||!d)throw this.log.error(Pt,c,d),new _.L(_.M,7,7100,Pt);this.m=c;if(this.f.gridSize)try{var e=this.f.gridSize.split(/x/).map(function(f){return parseInt(f,10)}).filter(function(f){return 0<f});if(2===e.length)this.j=e[0],
12
+ this.w=e[1];else throw new _.L(_.M,7,7100,Tt);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.L(_.M,7,7100,Tt);}Vt.prototype.init.call(this,a,b)};au.prototype.get=function(a){var b=this.g.getDuration();if(void 0===this.f.duration)return Promise.reject("Duration configuration not defined");var c=Math.floor(a/this.f.duration);if(0>a||a>b)return Promise.reject(Rt+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Qt+a+" at index "+c)};
13
+ au.prototype.o=function(){if(0<this.a.length)return Promise.resolve();var a=this.g.getDuration(),b=this.j*this.w;a=Math.ceil(Math.ceil(a/this.m)/b);for(var c=this.f.templateKey||"$index$",d=0;d<a;d++)for(var e=this.f.url.replace(c,String(d+1)),f=new Image,g=0;g<b;g++)this.a.push(new $t(e,this.m*(d*b+g),this.m,0,0,0,0,this.j,this.w,g%this.j,Math.floor(g/this.j),f));return Promise.resolve()};bu.prototype.load=function(){return this.pg};
14
+ cu.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,St);var d=b.url,e=_.Zh(d);e.type=_.Yh;a.getNetworkEngine().fetch(e).O.then(function(f){f=f.data;var g=_.N(c.f);f=_.N(f);for(var h=g.byteLength+f.byteLength,l=new ArrayBuffer(h),m=new DataView(l),n=0,p=0,q=g.byteLength;p<q;p++)m.setUint8(n,g[p]),n+=1;g=0;for(p=f.byteLength;g<p;g++)m.setUint8(n,f[g]),n+=1;c.f=l;c.h.info("Appended "+f.byteLength+" bytes.Total data now "+(h+" bytes."))}).then(function(){var f=c.f,g=_.N(f),
15
+ h=String.fromCharCode.apply(null,pu),l=Array.prototype.slice.call(g,0,8);g=64;var m=0;var n=!1;if(h===String.fromCharCode.apply(null,l))for(f=new DataView(f,16,20),f=f.getUint32(0,!0),0===f&&(f=1E3);!n;){m+=1;l=f;h=new DataView(c.f,g);n=h.getUint32(0,!0);l=n*l/1E3;h=h.getUint32(4,!0);h=new bu(l,h);if(l=c.a.length)l=c.a[l-1],l.length=h.offset-l.offset,l.duration=h.time-l.time;c.a.push(h);g+=8;(n=4294967295===n)&&c.g.resolve();if(1E5<m)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");
16
+ }).then(function(){du(c)})["catch"](function(f){c.h.error("[BIF] Error while loading thumbnails '\n + 'URL: "+d,f);a.onError(new _.L(1,7,2013,"Error while loading and parsing BIF thumbnails.",f))})};cu.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Rt+a):this.g.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(Zt(d,a))return fu(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Qt+a)})};var pu=[137,66,73,70,13,10,26,10];_.w(gu,Vt);
17
+ gu.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,St);var d=b.url,e=_.Zh(d);e.type=_.Yh;this.f=a.getNetworkEngine().fetch(e).O.then(function(f){if(f=f.data){f=_.wh(f).split(/\n/);for(var g=0;g<f.length;g++){var h=f[g],l=h.split(" --\x3e ");if(2===l.length){h=f[++g];var m=h.indexOf("\x3d"),n=0>m?[]:h.substr(m+1).split(/,/).map(parseFloat);m=n[0];var p=n[1],q=n[2];n=n[3];var r=h.indexOf("#");h=0>r?h:h.substr(0,r);h.match(/^http|^\/\//)||(h=d.substr(0,d.lastIndexOf("/"))+"/"+
18
+ h);r=hu(l[0]);l=hu(l[1])-r;c.a.push(new $t(h,r,l,m,p,q,n,0,0))}}}})["catch"](function(f){c.log.error("[VTT] Error while loading thumbnails URL: "+d,f);a.onError(new _.L(1,7,2013,"Error while loading VTT thumbnails.",f))});Vt.prototype.init.call(this,a,b)};
19
+ gu.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Rt+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Uc:c.Uc},d++)if(c.Uc=b.a[d],Zt(c.Uc,a))return c.Uc.load().then(function(e){return function(){return e.Uc}}(c));return Promise.reject(Qt+a)})};gu.prototype.o=function(){return this.f};_.w(iu,Vt);
20
+ iu.prototype.get=function(a){if(0>a)return this.log.error("Position must be greater than 0 but is "+a),Promise.reject();var b=this.g.getPeriods();b=ju(b,a);if(!b)return this.log.error("Could not find period for specified position",a),Promise.reject();var c=b.thumbStreams.sort(this.f)[0];if(!c)return this.log.error("Could not find thumb stream for specified position",a),Promise.reject();b=c.findSegmentPosition(a-b.startTime);if(null===b||void 0===b)return this.log.error("Could not find segment index for specified position",a),
21
+ Promise.reject();var d=c.getSegmentReference(b);if(d){var e=ku(d,c);a=Math.floor((a-d.startTime)/e.durationPerTile);var f;if(0<this.a.length)d=c.findSegmentPosition(0),null!==d&&(f=this.a[(b-d)*e.hg+a]);else if((c=d.Ka())&&0<c.length){var g=0,h=0;d=d.startTime;1<e.hg&&(g=a%e.kd,h=Math.floor(a/e.kd),d+=a*e.durationPerTile);f=new $t(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.kd,e.yf,g,h)}if(f)return f.load().then(function(){return f})}this.log.error("segment reference for specified segment index does not exist",
22
+ b);return Promise.reject()};iu.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
23
+ iu.prototype.o=function(){if(0<this.a.length)return Promise.resolve();var a=this.g.getPeriods();a=_.u(a);for(var b=a.next();!b.done;b=a.next())if(b=b.value.thumbStreams.sort(this.f)[0])for(var c=b.findSegmentPosition(0),d=void 0;null!==c&&!_.K.R(d=b.getSegmentReference(c++));)for(var e=ku(d,b),f=d.Ka()[0],g=new Image,h=d.startTime,l=0;l<e.yf;++l)for(var m=0;m<e.kd;++m)this.a.push(new $t(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.kd,e.yf,m,l,g)),h+=e.durationPerTile;return Promise.resolve()};_.t=lu.prototype;_.t.onPlayerCreated=function(a){this.l=a};_.t.onPlayerWillDestroy=function(){this.l=null};_.t.onPlayerWillRelease=function(){this.a=null};
24
+ _.t.onContentWillLoad=function(a){var b=this,c=a.getConfiguration();if(c.thumbnails){var d=c.thumbnails;d&&(void 0===d.enabled||d.enabled)&&((c=d.mode)||(c=nu(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new au:"WEBVTT"===c?this.a=new gu:"BIF"===c&&(this.a=new cu)),this.a&&(this.h.info("Loading thumbs configuration",d),this.l.one(_.xd,function(){b.h.info("Initialize thumbnails provider");b.a.init(a,d)})))}else this.a=null};
25
+ _.t.onContentLoaded=function(a,b){for(var c=1;c<arguments.length;++c);if(!this.a&&(c=(c=a.getConfiguration())&&c.thumbnails,!c||void 0===c.enabled||c.enabled)){var d=a.getPeriods();mu(d)&&(this.a=new iu,this.a.init(a,c))}};_.t.get=function(a){return this.a?this.a.get(a):Promise.reject()};_.t.id=function(){return"thumbnails"};_.C("clpp.thumbnails.ThumbnailsPlugin",lu);lu.prototype.get=lu.prototype.get;lu.Id="thumbnails";ou.prototype.create=function(){return new lu};_.Fo(new ou);};
26
26
  if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
27
27
  else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
28
28
  else{_=this.clpp._;(f.call(g,this));}
package/cjs/cl.tizen.js CHANGED
@@ -1,75 +1,75 @@
1
1
  (function(){var g={}; var _ = _ || {}
2
- var f=function(window){var $E="An unknown error occurred while trying to get volume",aF="Cannot get loading rendition due to platform limitations",bF="PARAM_START_POSITION",cF="SecurityError",dF="The require privilege is: http://tizen.org/privilege/tv.audio",eF="|STARTBITRATE\x3d",fF=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},gF=function(a,b){this.h=a;this.o=null;this.a=_.Kd;this.m=null;this.j=!1;this.f=new Map;this.C=b;this.g=new _.H("clpp.tizen.DrmEngine")},jF=function(a){var b,
3
- c,d;return _.A(function(e){if(1==e.a){b=a.a===_.Sc||a.a===_.Rc;if(!b)throw new _.L(_.M,6,6001,"The key system "+a.a+" is not supported by the player or the platform");c=a.f.get(a.a);if(!c.gd)throw new _.L(_.M,6,6012,"No license server given for "+a.a);_.zf(e,2);return a.a===_.Sc?_.x(e,hF(a),5):_.x(e,iF(a,c),5)}if(2!=e.a)return a.o={keySystem:a.a,licenseServerUri:c.gd,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Oe,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
4
- keyIds:[],periodId:null},_.Af(e,0);d=_.Bf(e);a.g.error("Error while configuring CDM for "+a.a,d);throw new _.L(_.M,6,6005,{message:JSON.stringify(d)});})},iF=function(a,b){var c,d,e,f;return _.A(function(g){c=kF;d=lF;e={};e[d.yg]=!b.Oe;e[d.zg]=b.gd;""!==b.customData&&(e[d.xg]=b.customData);f=JSON.stringify(e);a.g.debug("PlayReady properties: ",f);try{webapis.avplay.setDrm(c.PLAYREADY,"SetProperties",f)}catch(h){throw h;}_.z(g)})},hF=function(a){var b;return _.A(function(c){b=kF;try{webapis.avplay.setDrm(b.rd,
5
- "Initialize",""),webapis.avplay.setDrm(b.rd,"widevine_app_session",a.m.id),webapis.avplay.setDrm(b.rd,"widevine_data_type",a.m.type)}catch(d){throw d;}_.z(c)})},mF=function(a,b){var c,d,e,f,g,h,l,m,n,p,q,r,w,y,B,E,F;_.A(function(D){if(1==D.a){c=kF;d=a.f.get(a.a);a.g.debug("DRM Challenge data: ",b.challenge);e=atob(b.challenge);f=new Uint8Array(e.length);for(g=0;g<e.length;++g)f[g]=e.charCodeAt(g);h=b.serverurl&&""!==b.serverurl?b.serverurl:d.gd;l=_.Oh([h],_.Lh());l.type=3;l.body=f.buffer;l.method=
6
- "POST";_.zf(D,2);return _.x(D,a.C.zb.fetch(l).O,4)}if(2!=D.a){m=D.f;if(a.j){n=_.N(m.data);p=n.byteLength;q="";for(r=0;r<p;r++)q+=String.fromCharCode(n[r]);w=btoa(q);y=b.session_id+bF+(w+bF);a.g.debug("Widevine license params",y);try{webapis.avplay.setDrm(c.rd,"widevine_license_data",y)}catch(J){a.g.error("License response rejected by CDM"),B=new _.L(_.M,6,6008,{browserError:JSON.stringify(J)}),a.C.onError(B)}}return _.Af(D,0)}E=_.Bf(D);a.g.error("License request failed.",JSON.stringify(E));F=new _.L(_.M,
7
- 6,6007,{message:_.Ha,url:E.data.url,status:E.data.status||NaN,response:E.data.response||"",headers:E.data.headers||{}},E);a.C.onError(F);_.z(D)})},nF=function(a){this.l=a;this.a=this.l.a;this.f=_.Ym;this.j=_.Zm;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.H("clpp.tizen.StateManager")},pF=function(a,b){if(a.f!==b)if(a.f===_.jn&&b!==_.Ym)a.g.debug(_.ev+oF(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.cn?(a.o=(new Date).getTime(),a.l.trigger(new _.I(_.vc,{detail:{bufferedTimeMS:-1,
8
- reason:a.h}}))):a.j===_.cn&&a.l.trigger(new _.I(_.uc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));var d={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.l.trigger(new _.I(_.se,{detail:d}));a.g.debug("State changed:",oF(a.j),"-\x3e",oF(a.f))}},oF=function(a){return Object.keys(_.gn)[a]},sF=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case qF:c=_.mn;break;case rF:c=_.ln;break;default:a.l.isEnded()?c=_.en:a.g.debug("Inconsistent AVPlay playback state:",b)}pF(a,
9
- c)}},tF=function(){this.o=this.A=this.g=this.h=this.B=this.l=this.j=this.f=null;this.w=!0;this.m=null;this.a=new _.H("clpp.tizen.TextStreamer")},uF=function(a){if(!a)return!1;a=a.periods;for(var b=!1,c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},vF=function(a){var b,c;return _.A(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.x(d,_.Ep(a.B.url,a.l.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null),2);(c=d.f)&&c.configure(b.manifest);return d["return"](c)})},
10
- wF=function(a){var b=document.createElement(_.Re),c=new _.Mw,d=new _.Xv(function(){return null}),e=a.l.getTextDisplayer();return new _.Sw(b,c,e,d,a.l.getConfiguration())},xF=function(a){var b={vb:function(){return a.l.getPosition()},W:a.h,zb:a.l.getNetworkEngine(),He:a.Lh.bind(a),Ge:a.Kh.bind(a),onError:a.T.bind(a),ag:function(){},onEvent:function(){},fg:a.Mh.bind(a),Od:function(){},qe:function(){return new _.Vx},ee:function(){return!1},$c:null};return new _.Oy(a.f,b)},yF=function(a){var b=a.l.getPosition(),
11
- c=null;a=_.u(a.f.periods);for(var d=a.next();!d.done;d=a.next())d=d.value,d.startTime<=b&&(c=d);return c},zF=function(a){a.a.debug("getTextStreams()",a.f);if(a.f){var b=[],c=a.f.periods;a.a.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.a.debug(c[d].startTime,a.l.getPosition()),c[d].startTime<=a.l.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];for(d=c=0;d<a.length;d++){var e=new _.hi(String(c++),_.P);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=
12
- a[d].kind||_.xv;var f=new _.pi(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},AF=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.Qy(a.g,_.Ce),c=null;if(b){a=zF(a);for(var 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},BF=function(a,b){a.a.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.f&&a.g)){a.setTextVisibility(!0);var c=yF(a),
13
- d=b.renditions[0];(c=c.textStreams.find(function(e){return String(e.id)==d.id}))?(a.w?(a.a.debug("Switching period defer text selection"),a.m=c):(_.az(a.g,c,!0,0),a.l.trigger(new _.I(_.Nj))),a.o=c.language):a.a.error(_.dv,d.id)}},CF=function(){this.h=this.f=this.l=null;this.g={};this.a=new _.H("clpp.tizen.TrackManager");this.w=this.m=this.j=null;this.A=!1;this.o=1},DF=function(a,b){a.l.trigger(new _.I(_.Ve,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},
14
- EF=function(a){var b=a.ga();b&&a.l.trigger(new _.I(_.sc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},FF=function(a){var b=a.l.getConfiguration(),c=_.Fg(b.preferredAudioLanguage||[]),d=a.g[_.Q]||[];if(d.length){var e=null;c.some(function(g){e=_.Rv(g,d.map(function(h){return h.language}));return!!e});if(e){var f=d.filter(function(g){return g.language===e});c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(function(g){return 0<=g.roles.indexOf(b.preferredAudioRole)}),
15
- 0<f.length&&(c=f[0]));a.a.debug("Setting audio track with preferred language:",e);a.sa(c)}else a.a.debug("Preferred language(s) not available")}else a.a.debug("Could not set preferred audio language")},JF=function(a,b){if(b){var c=b.track.type.toUpperCase();GF(a.f,c,Number(b.id)).then(function(){c===HF&&(a.j=b,a.l.trigger(new _.I(_.Mj)));c===IF&&(a.m=b,a.l.trigger(new _.I(_.Nj)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},KF=
16
- function(a,b,c){var d=_.Ki(b.language||_.Ie);c.language=_.ii(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.pc;a=new _.pi(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},LF=function(a,b,c){c.mimeType=_.Te;a=new _.pi(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):null;a.codec=b.fourCC||null;return a},MF=function(a,b,c){b=_.Ki(b.track_lang||_.Ie);c.mimeType="text/ttml";c.language=
17
- _.ii(b);c.kind=_.xv;return new _.pi(String(a),c)},NF=function(a,b){var c=null;try{c=JSON.parse(b)}catch(d){a.a.warn("Couldn't retrieve extra infos from stream."),c=null}return c},QF=function(a,b){function c(n,p){for(var q=0;q<n.length;q++)if(n[q].language===p)return n[q];return null}var d={};if(0>=b.length)return d;for(var e=b.filter(function(n){return n.type===OF}),f=b.filter(function(n){return n.type===HF}),g=[],h=0;h<f.length;h++){var l=NF(a,f[h].extra_info);if(l){var m=_.Ki(l.language||_.Ie);
18
- m=_.ii(m);m=c(g,m);m||(m=new _.hi(String(a.o++),_.Q),g.push(m));m.renditions.push(KF(f[h].index,l,m))}else a.a.warn("Skipping audio stream with no extra info")}f=new _.hi(String(a.o++),_.ji);for(h=0;h<e.length;h++)(l=NF(a,e[h].extra_info))?f.renditions.push(LF(e[h].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?zF(a.h):PF(a,b);d[_.ji]=[f];d[_.Q]=g;d[_.P]=e;return d},PF=function(a,b){for(var c=b.filter(function(h){return h.type===IF}),d=[],e=0;e<c.length;e++){var f=NF(a,
19
- c[e].extra_info);if(f){var g=new _.hi(String(a.o++),_.P);g.renditions.push(MF(c[e].index,f,g));d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},RF=function(a,b){for(var c=a.g[_.ji]||[],d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].renditions.length;f++)_.K.ua(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},SF=function(a,b,c){a=a.g[c]||[];b=String(b.index);c=null;for(var d=0;d<a.length;d++)for(var e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===
20
- b){c=a[d].renditions[e];break}return c},UF=function(a,b){if(b===_.P&&a.h)return AF(a.h);var c=TF(a.f)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.ji&&(d=NF(a,c.extra_info),d=RF(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=SF(a,c,_.Q),a.j=d):d=a.j);b===_.P&&(c?(d=SF(a,c,_.P),a.m=d):d=a.m);return d},VF=function(a){_.Tj.call(this);this.l=a;this.h=null;this.a=new _.H("clpp.tizen.Middleware");this.D=1;this.B=!1;this.m=null;this.F=0;
21
- this.o=!0;this.g=!1;this.f=null;this.A=1;this.w=!1;this.j={}},WF=function(a){return _.A(function(b){tizen.systeminfo.getPropertyValue("DISPLAY",function(c){a.A=c.resolutionWidth/1920;a.a.debug("Display resolution ratio: ",a.A)},function(c){a.a.debug("Could not load DISPLAY property");throw c;});_.z(b)})},YF=function(a){try{webapis.avplay.setListener({onbufferingstart:a.Fh.bind(a),onbufferingprogress:a.Eh.bind(a),onbufferingcomplete:a.Dh.bind(a),onstreamcompleted:a.Ih.bind(a),oncurrentplaytime:function(b){a.trigger(new _.I(XF,
22
- {currentTime:b}))},onevent:a.Hh.bind(a),onsubtitlechange:a.Jh.bind(a),ondrmevent:a.Gh.bind(a),onerror:a.T.bind(a)})}catch(b){a.a.error(b)}},ZF=function(a){var b=!!a.l.getTrackManager().Ea();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.a.debug("Could not set AVPlay subtitle config",c)}},$F=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,mk:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",eF+d)}catch(e){a.a.debug(e)}},
23
- aG=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+eF+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},dG=function(a){return{position:a.getPosition(),state:a.l.getState(),lf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:bG(a),volume:a.getVolume(),Oj:cG(a),Wh:TF(a)}},fG=function(a){var b,c;return _.A(function(d){if(1==d.a)return _.x(d,eG(),2);if(3!=d.a)return b=new Promise(function(e){(new _.Ti(e)).Y(5)}),
24
- _.x(d,Promise.race([WF(a).then(function(){return!0}),b.then(function(){return!1})]),3);c=d.f;if(!c)return a.a.debug("Took to long for the SDK to be ready"),d["return"](Promise.reject("SDK Timeout"));_.z(d)})},lG=function(a,b,c){var d,e,f,g,h,l,m,n;return _.A(function(p){switch(p.a){case 1:a.m=_.qn(b);d=a.F;e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.a.debug("Loading manifest URL: "+a.m[d].url);f=b.startTime||void 0;a.g&&(a.trigger(new _.I(gG)),f=c.currentPosition);
25
- _.zf(p,2);g=a.m[d].url;h=a.m[d].type;h!==_.dc||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);e.nextBandwidth?(aG(a,e.nextBandwidth),a.o=!1):(a.o||$F(a,e),a.o=!0);YF(a);if(!b.drm||!b.drm.env){a.a.debug("No DRM configuration was provided. Assuming clear content");p.G(4);break}m={onError:function(q){return a.l.onError(q)},zb:a.l.getNetworkEngine()};a.h=new gF(b.drm,m);return _.x(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.I(hG)),
26
- _.x(p,iG(a),6);case 6:a.g||a.trigger(new _.I(jG));f&&typeof f===_.k&&0<f&&a.seek(f)["catch"](function(q){a.a.debug("Couldn't set start position",q)});a.g||(b.volume&&a.setVolume(b.volume),b.muted&&kG(a,b.muted),b.autoplay&&a.l.play()["catch"](function(q){a.a.debug("Autoplay failed",q)}));_.Af(p,0);break;case 2:throw n=_.Bf(p),a.a.debug("Error while attempting to load source."),n;}})},iG=function(a){return _.A(function(b){a.a.debug("avplay.prepare()");return b["return"](new Promise(function(c,d){try{webapis.avplay.prepareAsync(function(){a.a.debug("AVPlay is ready!");
27
- ZF(a);c()},function(e){a.a.debug("prepareAsync failed",e);d(e)})}catch(e){a.a.debug("Failed to prepare media player for playback"),d(e)}}))})},mG=function(a,b,c){a.a.debug("switchVideoTrack()");try{var d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.f=dG(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.f.lf;a.g=!1;a.f=
28
- null;return e===rF?a.pause():a.play()})}catch(e){return Promise.reject(e)}},cG=function(a){return a.g&&a.f?a.f.Oj:webapis.avplay.getTotalTrackInfo()},TF=function(a){return a.g&&a.f?a.f.Wh:webapis.avplay.getCurrentStreamInfo()},GF=function(a,b,c){b=b.toUpperCase();b===IF&&nG(a,!0);var d=a.j[b];d&&(d.Qd.stop(),a.j[b]=null,a.a.debug("Cancelled pending track switch for "+b));return new Promise(function(e,f){function g(h,l,m){m=void 0===m?!1:m;try{webapis.avplay.setSelectTrack(h,l),a.j[h]=null,e()}catch(n){a.a.debug("Could not set "+
29
- h+" track. Trying again...AVPlay state: "+(a.getState()+", buffering: ")+a.w,n),!1===m&&(a.j[h]={type:h,index:l,jf:0,Qd:new _.Ti(function(){return g(h,c,!0)})}),(l=a.j[h])&&3>l.jf?(!a.w&&++l.jf,l.Qd.Y(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Qd.stop(),a.j[h]=null,f())}}g(b,c)})},nG=function(a,b){var c=a.l.getTextDisplayer();c&&c.setTextVisibility(b);c=a.l.g;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.a.debug("Could not set text track visibility",
30
- d)}},kG=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case cF:a.a.warn("The application does not have the privilege to set mute.",dF);break;default:a.a.warn($E,c)}}},bG=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case cF:a.a.warn("The application doesn't have the privilege to get the mute state.",dF);break;default:a.a.warn($E,c)}}return!!b},eG=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
31
- fF(c,"load",function(d){return a(d)});fF(c,_.jd,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},oG=function(){_.Tj.call(this);this.a=new VF(this);this.f=new nF(this);this.configuration=this.B=_.Zj();this.w=null;this.h=new _.H("clpp.tizen.Player");this.j=null;this.m=new CF;this.D=new _.ei;this.o=this.g=null;this.A=!1},pG=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();a=a.a;var c=Math.floor(b.left*a.A),d=Math.floor(b.top*
32
- a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.a.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.h.debug("Could not apply dimension. Player state "+a.a.getState())},qG=function(){},rG=function(){this.a=null};
33
- gF.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.A(function(h){if(1==h.a){b=_.vk[a.h.env]||null;if(!b)throw a.g.debug(_.xa,_.gb+a.h.env+_.aa),new _.L(_.M,6,6015,_.ya+a.h.env+"' is missing.");a.m={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";d=_.xk(b,a.h.customData);(e=d[_.Rc])&&a.f.set(_.Rc,{gd:e.licenseUrl||"",customData:c,Oe:!1});(f=d[_.Sc])&&a.f.set(_.Sc,{gd:f.licenseUrl||"",customData:c,
34
- Oe:!1});if(0===a.f.size)throw new _.L(_.M,6,6E3);if((g=a.h.preferredDrmSystem)&&a.f.get(g))a.a=g;else if(a.f.get(_.Rc))a.a=_.Rc;else if(a.f.get(_.Sc))a.a=_.Sc;else throw new _.L(_.M,6,6001,"Configuration for the target system is missing.");return _.x(h,jF(a),2)}a.j=!0;_.z(h)})};gF.prototype.release=function(){var a=this;return _.A(function(b){a.j=!1;a.o=null;a.a=_.Kd;a.m=null;a.f=new Map;_.z(b)})};gF.prototype.getDrmInfo=function(){return this.o};
35
- var lF={yg:"DeleteLicenseAfterUse",zg:"LicenseServer",$j:"GetChallenge",ak:"HttpHeader",dk:"UserAgent",Wj:"Cookie",xg:"CustomData"};_.t=nF.prototype;_.t.initialize=function(){this.a.on(gG,this.zf,this);this.a.on(sG,this.yf,this);this.a.on(tG,this.xf,this);this.a.on(hG,this.hg,this);this.a.on(jG,this.gg,this);this.a.on(uG,this.Af,this)};_.t.release=function(){pF(this,_.Ym);this.m=!1;this.o=-1;this.h=2};_.t.destroy=function(){this.release();this.a.off(gG,this.zf);this.a.off(sG,this.yf);this.a.off(tG,this.xf);this.a.off(hG,this.hg);this.a.off(jG,this.gg);this.a.off(uG,this.Af);this.l=this.a=null};
36
- _.t.zf=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;pF(this,_.cn)};_.t.yf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",oF(this.f))};_.t.xf=function(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.m){this.m=!0;var a=this.l.getConfiguration().autoplay,b=this.a.getState()===vG;if(!a&&b){pF(this,_.ln);return}}if(a=this.f!==_.kn)a=this.a.getState(),a=a===qF||a===rF;a&&sF(this)};
37
- _.t.hg=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===wG?pF(this,_.kn):this.g.error("AVPlay prepares while state is not IDLE")};_.t.gg=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.Af=function(){pF(this,_.en)};_.t.getState=function(){return this.f};_.t=tF.prototype;_.t.initialize=function(a){this.l=a};
38
- _.t.load=function(a){var b=this,c,d,e,f,g,h,l;return _.A(function(m){switch(m.a){case 1:if(!b.l)return b.a.debug("Text streamer is not initialized. Will not load()"),m["return"]();b.B=a;c=b;return _.x(m,vF(b),2);case 2:c.j=m.f;if(!b.j)return b.a.debug("Could not find manifest parser for source. Make sure parsers are registered."),m["return"]();d={networkingEngine:b.l.getNetworkEngine(),filterNewPeriod:function(){},filterAllPeriods:function(){},onTimelineCueAdded:function(){},onEvent:function(){},
39
- onError:function(){}};_.zf(m,3);e=b;return _.x(m,b.j.start(a.url,d),5);case 5:e.f=m.f;_.Af(m,4);break;case 3:return f=_.Bf(m),b.a.warn(f),_.zf(m,6),g=b,_.x(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.f=m.f;_.Af(m,4);break;case 6:h=_.Bf(m),b.a.error(h),b.f=null;case 4:if(!b.f||!uF(b.f)){m.G(0);break}b.h=wF(b);_.zf(m,10);return _.x(m,b.h.H,12);case 12:b.g=xF(b);l=b.l.getConfiguration();b.g.j=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;_.Af(m,0);break;case 10:_.Bf(m),
40
- b.a.debug("Could not setup media source..."),b.h=null,b.g=null,b.j=null,b.f=null,_.z(m)}})};_.t.Lh=function(a){this.a.debug(_.qv,a);this.w=!0;var b=_.xx(a.textStreams,this.o||"",this.A||"")[0]||null;this.m&&(a.textStreams.includes(this.m)&&(b=this.m),this.m=null);return{variant:null,text:b}};_.t.Kh=function(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.az(this.g,this.m,!0,0),this.m=null)};_.t.T=function(){this.a.debug("onError_")};_.t.Mh=function(){this.j&&this.j.update&&this.j.update()};
41
- _.t.start=function(){var a=this;return _.A(function(b){if(!a.g)return b["return"]();try{a.g.start()}catch(c){a.a.error("Error while starting streaming engine",c)}_.z(b)})};_.t.setTextVisibility=function(a){this.a.debug("Set text visibility",a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)};_.t.release=function(){var a=this;return _.A(function(b){a.l=null;a.f=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.m=null;_.z(b)})};
42
- _.t.destroy=function(){var a=this;return _.A(function(b){switch(b.a){case 1:if(!a.j){b.G(2);break}return _.x(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.g){b.G(4);break}return _.x(b,a.g.destroy(),5);case 5:a.g=null,a.w=!0;case 4:if(!a.h){b.G(0);break}return _.x(b,a.h.destroy(),7);case 7:a.h=null,_.z(b)}})};_.v(CF,_.R);_.t=CF.prototype;_.t.Yf=function(a){var b=a.eventid;a=a.data;switch(b){case xG:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+NF(this,b[0].extra_info).Bit_rate,b=RF(this,{bandwidth:b}))&&(this.w=b,DF(this,b));break;case yG:EF(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.t.Ke=function(a){a.detail.currentState===_.mn&&this.l.off(_.se,this.Ke)};
43
- _.t.initialize=function(a){var b=this;this.l=a;this.f=this.l.a;this.l.on(_.se,function(c){b.A||(c=c.detail,c.currentState===_.mn&&(b.a.debug("Current state",c.currentState),b.A=!0,FF(b)))});this.f.on(zG,this.Yf,this)};_.t.release=function(){this.g={};this.h=this.w=this.m=this.j=null;this.A=!1;this.o=1};
44
- _.t.load=function(){if(this.f&&!(0<Object.keys(this.g).length)){this.h=this.l.g;this.l.off(_.se,this.Ke);this.l.on(_.se,this.Ke,this);try{var a=cG(this.f);this.g=QF(this,a);var b=this.g[_.Q]||[];b.length&&(this.j=b[0].renditions[0]||null);EF(this)}catch(c){this.a.debug("Could not load track manager")}}};_.t.destroy=function(){this.f.off(zG,this.Yf);this.f=this.l=null};_.t.getVideoTracks=function(){return this.g[_.ji]||[]};_.t.getAudioTracks=function(){return this.g[_.Q]||[]};
45
- _.t.ha=function(){return this.g[_.P]||[]};_.t.ga=function(){return UF(this,_.ji)};_.t.Da=function(){return UF(this,_.Q)};_.t.Ea=function(){return UF(this,_.P)};_.t.Ta=function(){return this.w};_.t.eb=function(){this.a.info(aF);return null};_.t.fb=function(){this.a.info(aF);return null};_.t.Fa=function(){var a=this.ga();return a?a.track:null};_.t.ma=function(){var a=this.Da();return a?a.track:null};_.t.na=function(){var a=this.Ea();return a?a.track:null};
46
- _.t.Za=function(a){var b=this;null===a?(a=this.ga(),mG(this.f,a.bandwidth,null).then(function(){EF(b)})):0<a.renditions.length&&this.Ya(a.renditions[0])};_.t.sa=function(a){a?JF(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.t.Aa=function(a){a?(a=a.renditions[0],this.h?BF(this.h,a.track):JF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,nG(this.f,!1),this.l.trigger(new _.I(_.Nj)))};
47
- _.t.Ya=function(a){var b=this,c=this.ga();this.f.o||a.width!==c.width||a.height!==c.height||a.bandwidth!==c.bandwidth?(this.w=a,DF(this,a),mG(this.f,c.bandwidth,a.bandwidth).then(function(){EF(b)})["catch"](function(d){var e=new _.L(_.M,7,7200,{tizenerror:d});b.a.debug("Error while switching video track",d);b.l.onError(e)})):this.a.debug("Trying to switch to already active rendition. Doing nothing...")};_.t.lb=function(a){JF(this,a)};_.t.mb=function(a){this.h?BF(this.h,a.track):JF(this,a)};
48
- _.t.addTextTrack=function(){};_.t.ja=function(){return this.f.o};CF.prototype.isAbrEnabled=CF.prototype.ja;CF.prototype.addTextTrack=CF.prototype.addTextTrack;CF.prototype.setTextRendition=CF.prototype.mb;CF.prototype.setAudioRendition=CF.prototype.lb;CF.prototype.setVideoRendition=CF.prototype.Ya;CF.prototype.setTextTrack=CF.prototype.Aa;CF.prototype.setAudioTrack=CF.prototype.sa;CF.prototype.setVideoTrack=CF.prototype.Za;CF.prototype.getTextTrack=CF.prototype.na;CF.prototype.getAudioTrack=CF.prototype.ma;
49
- CF.prototype.getVideoTrack=CF.prototype.Fa;CF.prototype.getLoadingTextRendition=CF.prototype.fb;CF.prototype.getLoadingAudioRendition=CF.prototype.eb;CF.prototype.getLoadingVideoRendition=CF.prototype.Ta;CF.prototype.getTextRendition=CF.prototype.Ea;CF.prototype.getAudioRendition=CF.prototype.Da;CF.prototype.getVideoRendition=CF.prototype.ga;CF.prototype.getTextTracks=CF.prototype.ha;CF.prototype.getAudioTracks=CF.prototype.getAudioTracks;CF.prototype.getVideoTracks=CF.prototype.getVideoTracks;_.v(VF,_.Tj);_.t=VF.prototype;_.t.Fh=function(){this.w=!0;this.g||this.trigger(new _.I(gG))};_.t.Eh=function(a){this.w=!0;this.trigger(new _.I(sG,{percent:a}))};_.t.Dh=function(){this.w=!1;this.trigger(new _.I(tG))};_.t.Ih=function(){this.trigger(new _.I(uG))};_.t.Hh=function(a,b){this.trigger(new _.I(zG,{eventid:a,data:b}))};_.t.Jh=function(a,b,c,d,e){this.trigger(new _.I(AG,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
- _.t.Gh=function(a,b){this.trigger(new _.I(BG,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Sc&&"Challenge"===b.name)mF(c,b);else if("DrmError"===b.name){c.g.debug("DrmError event",b);var d=new _.L(_.M,6,6005,{message:JSON.stringify(b)});c.C.onError(d)}}};_.t.T=function(a){this.trigger(new _.I(CG,{eventType:a}))};
51
- _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(XF,f,b);g=setTimeout(function(){b.off(XF,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===wG)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){ZF(b);d(webapis.avplay.play())},function(f){b.trigger(new _.I(CG));e(f)})})).then(function(){return a()});if(c===rF||c===vG)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===qF?
52
- Promise.resolve():Promise.reject("Player is in invalid state")};_.t.pause=function(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===rF?Promise.resolve():Promise.reject()};
53
- _.t.setPlaybackRate=function(a){var b=this.getState();if(b===vG||b===qF||b===rF){try{webapis.avplay.setSpeed(a),this.D=a}catch(c){return this.a.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.D)}return!0}this.a.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1};_.t.getPlaybackRate=function(){return this.D};
54
- _.t.load=function(a,b){var c=this,d;return _.A(function(e){switch(e.a){case 1:return c.a.debug("configure()",b||""),_.zf(e,2),_.x(e,fG(c),4);case 4:return _.x(e,lG(c,a,b),5);case 5:_.Af(e,0);break;case 2:throw d=_.Bf(e),new _.L(_.M,7,7003,null,d);}})};_.t.getState=function(){if(this.g&&this.f)return this.f.lf;try{return webapis.avplay.getState()}catch(a){this.T(JSON.stringify(a))}};
55
- _.t.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.l.trigger(new _.I(_.Ne));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.I(_.Me));d()},function(){b.B=!1;e()})})};_.t.getPosition=function(){if(this.g&&this.f)return this.f.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.T(JSON.stringify(a))}};_.t.getDuration=function(){if(this.g&&this.f)return this.f.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.T(JSON.stringify(a))}};
56
- _.t.release=function(){var a=this;return new Promise(function(b,c){try{a.h&&(a.h.release(),a.h=null);webapis.avplay.stop();webapis.avplay.close();for(var d in a.j){var e=a.j[d];e&&e.Qd.stop()}a.j={};a.D=1;a.B=!1;a.m=null;a.f=null;return b()}catch(f){return c(f)}})};_.t.getVolume=function(){var a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case cF:this.a.debug("The application does not have the privilege to get the volume.",dF);break;default:this.a.debug($E,b)}}return a};
57
- _.t.setVolume=function(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.a.warn("Invalid value passed for setVolume.","The passed value value should be in the range of 0 to 1.");break;case cF:this.a.warn("The application does not have the privilege to set the volume.",dF);break;default:this.a.warn("An unknown error occurred while trying to set volume",b)}}};
58
- _.t.isLive=function(){if(this.g&&this.f)return this.f.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.T(JSON.stringify(a))}};_.t.stop=function(){try{webapis.avplay.stop()}catch(a){this.a.debug(a)}};_.t.getDrmInfo=function(){this.h&&this.h.getDrmInfo();return null};_.t.setSourceIndex=function(a){this.F=a};_.t.getSourceIndex=function(){return this.F};_.t.getLoadedSource=function(){return this.m&&this.m[this.getSourceIndex()]};
59
- var wG="IDLE",vG="READY",qF="PLAYING",rF="PAUSED",OF="VIDEO",HF="AUDIO",IF="TEXT",yG="PLAYER_MSG_RESOLUTION_CHANGED",xG="PLAYER_MSG_BITRATE_CHANGE",kF={PLAYREADY:"PLAYREADY",Xj:"EME_PLAYREADY",ek:"VERIMATRIX",rd:"WIDEVINE_CDM",Yj:"EME_WIDEVINE_CDM",fk:"WIDEVINE_CLASSIC"};_.v(oG,_.Tj);_.t=oG.prototype;_.t.vf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.I(_.id));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.t.tf=function(a){this.trigger(new _.I(_.Fe,{currentTime:a.currentTime/1E3}))};
60
- _.t.wf=function(a){var b=this.a.getPosition(),c=b+a.duration/1E3,d=a.text||"";this.h.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.Jh(d))&&this.o.append([new _.zg(b,c,d)],[])};_.t.uf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.$f=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
- _.t.T=function(a){this.h.debug("Error: TYPE: "+a.eventType);pF(this.f,_.jn);a=new _.L(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.I(_.jd,{detail:a}))};
62
- _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(uG,this.vf,this);this.a.on(XF,this.tf,this);this.a.on(AG,this.wf,this);this.a.on(BG,this.uf,this);this.a.on(CG,this.T,this);this.a.on(tG,this.$f,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=DG;DG+=1;this.j=_.In(_.Ld,{id:"__clpp_tizen_player_"+c,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var d=this.w.getMedia();if(d){c=this.j;
63
- var e=[_.ff,_.md,"position",_.rd,"top"],f={};d=null!==d.parentElement?window.getComputedStyle(d,null):d.style;if(!e||0===e.length){e||(e=[]);for(var g in d)e.push(g)}g=_.u(e);for(e=g.next();!e.done;e=g.next())e=e.value,f[e]=d[e];_.Kn(c,f);pG(this)}};_.t.getSurface=function(){return this.w};_.t.getConfiguration=function(){return this.configuration};
64
- _.t.destroy=function(){var a=this;return _.A(function(b){switch(b.a){case 1:return _.x(b,a.release(),2);case 2:a.a.off(uG,a.vf);a.a.off(XF,a.tf);a.a.off(AG,a.wf);a.a.off(BG,a.uf);a.a.off(CG,a.T);a.a.off(tG,a.$f);if(!a.g){b.G(3);break}return _.x(b,a.g.destroy(),4);case 4:a.g=null;case 3:a.j&&(a.j.parentElement.removeChild(a.j),a.j=null),a.m.destroy(),a.f.destroy(),a.m=null,a.f=null,_.z(b)}})};_.t.namespace=function(){return EG};_.t.getPlaybackRate=function(){return this.a.getPlaybackRate()};
65
- _.t.setDrmCustomDataModifier=function(){};_.t.setCdnErrorCallback=function(){};_.t.setPlaybackRate=function(a){this.a.setPlaybackRate(a)};_.t.getPosition=function(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.en?this.getDuration():this.a.getPosition()||0};_.t.seek=function(a){return typeof a===_.k&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()};_.t.getPresentationStartTime=function(){return null};
66
- _.t.getSeekRange=function(){return{start:0,end:0}};_.t.getVolume=function(){var a=this.a.getVolume();return typeof a===_.k?a/100:null};_.t.setVolume=function(a){this.a.setVolume(a)};_.t.getDuration=function(){return this.a.getDuration()};_.t.getBufferInfo=function(){this.h.warn(_.ra);return new _.Sj};_.t.getTrackManager=function(){return this.m};_.t.unload=function(){var a=this;return this.a.release().then(function(){a.m.release()})};
67
- _.t.release=function(){var a=this;return _.A(function(b){switch(b.a){case 1:if(!a.g){b.G(2);break}return _.x(b,a.g.release(),2);case 2:if(!a.o){b.G(4);break}return _.x(b,a.o.destroy(),5);case 5:a.o=null;case 4:return _.x(b,a.a.release(),6);case 6:a.m.release(),a.f.release(),a.A=!1,_.z(b)}})};
68
- _.t.load=function(a){var b=this,c,d,e,f,g;return _.A(function(h){switch(h.a){case 1:_.ck(a)&&(b.configuration=_.bk(b.B,a));c=_.Mm(b.configuration,["html","native"]);b.o=c.create(b);d=_.qn(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.G(2);break}b.g=new tF;b.g.initialize(b);_.zf(h,3);return _.x(h,b.g.load(d),5);case 5:b.g.start();_.Af(h,2);break;case 3:f=_.Bf(h),b.h.error(f);case 2:return _.zf(h,6),_.x(h,b.a.load(b.configuration),8);case 8:_.Af(h,7);break;
69
- case 6:throw g=_.Bf(h),b.onError(g),g;case 7:b.m.load(),_.z(h)}})};_.t.play=function(){var a=this;this.trigger(new _.I(_.Zd));pG(this);return this.a.play().then(function(){sF(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){sF(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.I(_.jd,{detail:a});a.severity===_.M&&(pF(this.f,_.jn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)};
70
- _.t.getDrmInfo=function(){return this.a.getDrmInfo()};_.t.isEnded=function(){return this.f.getState()===_.en};_.t.isPaused=function(){return this.a.getState()===rF};_.t.isMuted=function(){return bG(this.a)};_.t.setMuted=function(a){kG(this.a,a)};_.t.getNetworkEngine=function(){return this.D};_.t.setNetworkEngine=function(a){this.D=a};_.t.isLive=function(){return this.a.isLive()};_.t.getStats=function(){return null};_.t.setSourceIndex=function(a){this.a.setSourceIndex(a)};_.t.getSourceIndex=function(){return this.a.getSourceIndex()};
71
- _.t.getLoadedSource=function(){return this.a.getLoadedSource()};_.t.canPlay=function(a,b){return(new qG).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};oG.prototype.getTextDisplayer=oG.prototype.getTextDisplayer;oG.prototype.setNetworkEngine=oG.prototype.setNetworkEngine;oG.prototype.getNetworkEngine=oG.prototype.getNetworkEngine;var EG="clpp.tizen",DG=0;qG.prototype.a=function(){return EG};
72
- qG.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.dc||a===_.Dj||a===_.ic)&&b){if(_.$h(2))return 2;if(_.$h(3)||_.$h(4)||_.$h(5)||_.$h(6))return _.G("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};qG.prototype.create=function(){return new oG};_.v(rG,_.Ko);rG.prototype.Ga=function(){this.a=new qG;_.ag(this.a)};rG.prototype.Ba=function(){if(this.a){var a=this.a.a();a&&_.Xf[a]&&(delete _.Xf[a],_.$f.info("Removed Player factory: '"+a+"'"));this.a=null}};rG.prototype.id=function(){return"tizen"};_.C("clpp.tizen.TizenComponent",rG);var gG="onbufferingstart",sG="onbufferingprogress",tG="onbufferingcomplete",uG="onstreamcompleted",XF="oncurrentplaytime",zG="onevent",AG="onsubtitlechange",BG="ondrmevent",CG="onerror",hG="preparingstart",jG="preparingend";};
2
+ var f=function(window){var HF="An unknown error occurred while trying to get volume",IF="Cannot get loading rendition due to platform limitations",JF="PARAM_START_POSITION",KF="SecurityError",LF="The require privilege is: http://tizen.org/privilege/tv.audio",MF="|STARTBITRATE\x3d",NF=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},OF=function(a,b){this.g=a;this.o=null;this.a=_.Kd;this.m=null;this.j=!1;this.f=new Map;this.C=b;this.h=new _.H("clpp.tizen.DrmEngine")},RF=function(a){var b,
3
+ c,d;return _.B(function(e){if(1==e.a){b=a.a===_.Uc||a.a===_.Tc;if(!b)throw new _.L(_.M,6,6001,"The key system "+a.a+" is not supported by the player or the platform");c=a.f.get(a.a);if(!c.od)throw new _.L(_.M,6,6012,"No license server given for "+a.a);_.Af(e,2);return a.a===_.Uc?_.x(e,PF(a),5):_.x(e,QF(a,c),5)}if(2!=e.a)return a.o={keySystem:a.a,licenseServerUri:c.od,distinctiveIdentifierRequired:!1,persistentStateRequired:c.ef,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
4
+ keyIds:[],periodId:null},_.Bf(e,0);d=_.Cf(e);a.h.error("Error while configuring CDM for "+a.a,d);throw new _.L(_.M,6,6005,{message:JSON.stringify(d)});})},QF=function(a,b){var c,d,e,f;return _.B(function(g){c=SF;d=TF;e={};e[d.eh]=!b.ef;e[d.fh]=b.od;""!==b.customData&&(e[d.dh]=b.customData);f=JSON.stringify(e);a.h.debug("PlayReady properties: ",f);try{webapis.avplay.setDrm(c.PLAYREADY,"SetProperties",f)}catch(h){throw h;}_.z(g)})},PF=function(a){var b;return _.B(function(c){b=SF;try{webapis.avplay.setDrm(b.Bd,
5
+ "Initialize",""),webapis.avplay.setDrm(b.Bd,"widevine_app_session",a.m.id),webapis.avplay.setDrm(b.Bd,"widevine_data_type",a.m.type)}catch(d){throw d;}_.z(c)})},UF=function(a,b){var c,d,e,f,g,h,l,m,n,p,q,r,v,y,A,E,F;_.B(function(D){if(1==D.a){c=SF;d=a.f.get(a.a);a.h.debug("DRM Challenge data: ",b.challenge);e=atob(b.challenge);f=new Uint8Array(e.length);for(g=0;g<e.length;++g)f[g]=e.charCodeAt(g);h=b.serverurl&&""!==b.serverurl?b.serverurl:d.od;l=_.Zh([h],_.Wh());l.type=3;l.body=f.buffer;l.method=
6
+ "POST";_.Af(D,2);return _.x(D,a.C.Cb.fetch(l).O,4)}if(2!=D.a){m=D.f;if(a.j){n=_.N(m.data);p=n.byteLength;q="";for(r=0;r<p;r++)q+=String.fromCharCode(n[r]);v=btoa(q);y=b.session_id+JF+(v+JF);a.h.debug("Widevine license params",y);try{webapis.avplay.setDrm(c.Bd,"widevine_license_data",y)}catch(J){a.h.error("License response rejected by CDM"),A=new _.L(_.M,6,6008,{browserError:JSON.stringify(J)}),a.C.onError(A)}}return _.Bf(D,0)}E=_.Cf(D);a.h.error("License request failed.",JSON.stringify(E));F=new _.L(_.M,
7
+ 6,6007,{message:_.Ha,url:E.data.url,status:E.data.status||NaN,response:E.data.response||"",headers:E.data.headers||{}},E);a.C.onError(F);_.z(D)})},VF=function(a){this.l=a;this.a=this.l.a;this.f=_.Ym;this.j=_.Zm;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.g=2;this.h=new _.H("clpp.tizen.StateManager")},XF=function(a,b){if(a.f!==b)if(a.f===_.jn&&b!==_.Ym)a.h.debug(_.fv+WF(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.cn?(a.o=(new Date).getTime(),a.l.trigger(new _.I(_.xc,{detail:{bufferedTimeMS:-1,
8
+ reason:a.g}}))):a.j===_.cn&&a.l.trigger(new _.I(_.wc,{detail:{bufferedTimeMS:c-a.o,reason:a.g}}));var d={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.l.trigger(new _.I(_.se,{detail:d}));a.h.debug("State changed:",WF(a.j),"-\x3e",WF(a.f))}},WF=function(a){return Object.keys(_.gn)[a]},$F=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case YF:c=_.mn;break;case ZF:c=_.ln;break;default:a.l.isEnded()?c=_.en:a.h.debug("Inconsistent AVPlay playback state:",b)}XF(a,
9
+ c)}},aG=function(){this.o=this.A=this.f=this.g=this.B=this.l=this.j=this.a=null;this.w=!0;this.m=null;this.h=new _.H("clpp.tizen.TextStreamer")},bG=function(a){if(!a)return!1;a=a.periods;for(var b=!1,c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},cG=function(a){var b,c;return _.B(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.x(d,_.Ep(a.B.url,a.l.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null),2);(c=d.f)&&c.configure(b.manifest);return d["return"](c)})},
10
+ dG=function(a){var b=document.createElement(_.Re),c=new _.Qw,d=new _.bw(function(){return null}),e=a.l.getTextDisplayer();return new _.Ww(b,c,e,d,a.l.getConfiguration())},eG=function(a){var b={yb:function(){return a.l.getPosition()},X:a.g,Cb:a.l.getNetworkEngine(),Xe:a.yi.bind(a),We:a.xi.bind(a),onError:a.S.bind(a),xg:function(){},onEvent:function(){},Cg:a.zi.bind(a),Zd:function(){},Ce:function(){return new _.$x},pe:function(){return!1},hd:null};return new _.Uy(a.a,b)},fG=function(a){var b=a.l.getPosition(),
11
+ c=null;a=_.u(a.a.periods);for(var d=a.next();!d.done;d=a.next())d=d.value,d.startTime<=b&&(c=d);return c},gG=function(a){a.h.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.h.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.h.debug(c[d].startTime,a.l.getPosition()),c[d].startTime<=a.l.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];for(d=c=0;d<a.length;d++){var e=new _.si(String(c++),_.O);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=
12
+ a[d].kind||_.zv;var f=new _.Ai(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},hG=function(a){if(a.g&&!a.g.getTextDisplayer().isTextVisible())return null;if(a.f){var b=_.Wy(a.f,_.Ce),c=null;if(b){a=gG(a);for(var 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},iG=function(a,b){a.h.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.a&&a.f)){a.setTextVisibility(!0);var c=fG(a),
13
+ d=b.renditions[0];(c=c.textStreams.find(function(e){return String(e.id)==d.id}))?(a.w?(a.h.debug("Switching period defer text selection"),a.m=c):(_.gz(a.f,c,!0,0),a.l.trigger(new _.I(_.Vj))),a.o=c.language):a.h.error(_.ev,d.id)}},jG=function(){this.g=this.a=this.l=null;this.f={};this.h=new _.H("clpp.tizen.TrackManager");this.w=this.m=this.j=null;this.A=!1;this.o=1},kG=function(a,b){a.l.trigger(new _.I(_.Ve,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},
14
+ lG=function(a){var b=a.fa();b&&a.l.trigger(new _.I(_.uc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},mG=function(a){var b=a.l.getConfiguration(),c=_.Fg(b.preferredAudioLanguage||[]),d=a.f[_.Q]||[];if(d.length){var e=null;c.some(function(g){e=_.Tv(g,d.map(function(h){return h.language}));return!!e});if(e){var f=d.filter(function(g){return g.language===e});c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(function(g){return 0<=g.roles.indexOf(b.preferredAudioRole)}),
15
+ 0<f.length&&(c=f[0]));a.h.debug("Setting audio track with preferred language:",e);a.va(c)}else a.h.debug("Preferred language(s) not available")}else a.h.debug("Could not set preferred audio language")},qG=function(a,b){if(b){var c=b.track.type.toUpperCase();nG(a.a,c,Number(b.id)).then(function(){c===oG&&(a.j=b,a.l.trigger(new _.I(_.Uj)));c===pG&&(a.m=b,a.l.trigger(new _.I(_.Vj)))})["catch"](function(){a.h.error("Could not select "+c+" track.")})}else a.h.debug("Must provide valid rendition")},rG=
16
+ function(a,b,c){var d=_.gh(b.language||_.Ie);c.language=_.ti(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.rc;a=new _.Ai(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},sG=function(a,b,c){c.mimeType=_.Te;a=new _.Ai(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):null;a.codec=b.fourCC||null;return a},tG=function(a,b,c){b=_.gh(b.track_lang||_.Ie);c.mimeType="text/ttml";c.language=
17
+ _.ti(b);c.kind=_.zv;return new _.Ai(String(a),c)},uG=function(a,b){var c=null;try{c=JSON.parse(b)}catch(d){a.h.warn("Couldn't retrieve extra infos from stream."),c=null}return c},xG=function(a,b){function c(n,p){for(var q=0;q<n.length;q++)if(n[q].language===p)return n[q];return null}var d={};if(0>=b.length)return d;for(var e=b.filter(function(n){return n.type===vG}),f=b.filter(function(n){return n.type===oG}),g=[],h=0;h<f.length;h++){var l=uG(a,f[h].extra_info);if(l){var m=_.gh(l.language||_.Ie);
18
+ m=_.ti(m);m=c(g,m);m||(m=new _.si(String(a.o++),_.Q),g.push(m));m.renditions.push(rG(f[h].index,l,m))}else a.h.warn("Skipping audio stream with no extra info")}f=new _.si(String(a.o++),_.ui);for(h=0;h<e.length;h++)(l=uG(a,e[h].extra_info))?f.renditions.push(sG(e[h].index,l,f)):a.h.warn("Skipping video stream with no extra info");e=[];e=a.g?gG(a.g):wG(a,b);d[_.ui]=[f];d[_.Q]=g;d[_.O]=e;return d},wG=function(a,b){for(var c=b.filter(function(h){return h.type===pG}),d=[],e=0;e<c.length;e++){var f=uG(a,
19
+ c[e].extra_info);if(f){var g=new _.si(String(a.o++),_.O);g.renditions.push(tG(c[e].index,f,g));d.push(g)}else a.h.warn("Skipping text stream with no extra info")}return d},yG=function(a,b){for(var c=a.f[_.ui]||[],d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].renditions.length;f++)_.K.xa(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},zG=function(a,b,c){a=a.f[c]||[];b=String(b.index);c=null;for(var d=0;d<a.length;d++)for(var e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===
20
+ b){c=a[d].renditions[e];break}return c},BG=function(a,b){if(b===_.O&&a.g)return hG(a.g);var c=AG(a.a)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.ui&&(d=uG(a,c.extra_info),d=yG(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=zG(a,c,_.Q),a.j=d):d=a.j);b===_.O&&(c?(d=zG(a,c,_.O),a.m=d):d=a.m);return d},CG=function(a){_.bk.call(this);this.l=a;this.g=null;this.h=new _.H("clpp.tizen.Middleware");this.D=1;this.B=!1;this.m=null;this.F=0;
21
+ this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}},DG=function(a){return _.B(function(b){tizen.systeminfo.getPropertyValue("DISPLAY",function(c){a.A=c.resolutionWidth/1920;a.h.debug("Display resolution ratio: ",a.A)},function(c){a.h.debug("Could not load DISPLAY property");throw c;});_.z(b)})},FG=function(a){try{webapis.avplay.setListener({onbufferingstart:a.pi.bind(a),onbufferingprogress:a.oi.bind(a),onbufferingcomplete:a.ni.bind(a),onstreamcompleted:a.vi.bind(a),oncurrentplaytime:function(b){a.trigger(new _.I(EG,
22
+ {currentTime:b}))},onevent:a.si.bind(a),onsubtitlechange:a.wi.bind(a),ondrmevent:a.ri.bind(a),onerror:a.S.bind(a)})}catch(b){a.h.error(b)}},GG=function(a){var b=!!a.l.getTrackManager().Ja();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.h.debug("Could not set AVPlay subtitle config",c)}},HG=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.h.debug({estimatedBandwidth:c,Dl:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",MF+d)}catch(e){a.h.debug(e)}},
23
+ IG=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+MF+b)}catch(c){throw a.h.debug("Could not set fixed bandwidth",c),c;}},LG=function(a){return{position:a.getPosition(),state:a.l.getState(),Ef:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:JG(a),volume:a.getVolume(),bl:KG(a),Mi:AG(a)}},NG=function(a){var b,c;return _.B(function(d){if(1==d.a)return _.x(d,MG(),2);if(3!=d.a)return b=new Promise(function(e){(new _.aj(e)).Z(5)}),
24
+ _.x(d,Promise.race([DG(a).then(function(){return!0}),b.then(function(){return!1})]),3);c=d.f;if(!c)return a.h.debug("Took to long for the SDK to be ready"),d["return"](Promise.reject("SDK Timeout"));_.z(d)})},TG=function(a,b,c){var d,e,f,g,h,l,m,n;return _.B(function(p){switch(p.a){case 1:a.m=_.qn(b);d=a.F;e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.h.debug("Loading manifest URL: "+a.m[d].url);f=b.startTime||void 0;a.f&&(a.trigger(new _.I(OG)),f=c.currentPosition);
25
+ _.Af(p,2);g=a.m[d].url;h=a.m[d].type;h!==_.ec||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);e.nextBandwidth?(IG(a,e.nextBandwidth),a.o=!1):(a.o||HG(a,e),a.o=!0);FG(a);if(!b.drm||!b.drm.env){a.h.debug("No DRM configuration was provided. Assuming clear content");p.G(4);break}m={onError:function(q){return a.l.onError(q)},Cb:a.l.getNetworkEngine()};a.g=new OF(b.drm,m);return _.x(p,a.g.init(),4);case 4:return a.f||a.trigger(new _.I(PG)),
26
+ _.x(p,QG(a),6);case 6:a.f||a.trigger(new _.I(RG));f&&typeof f===_.k&&0<f&&a.seek(f)["catch"](function(q){a.h.debug("Couldn't set start position",q)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&SG(a,b.muted),b.autoplay&&a.l.play()["catch"](function(q){a.h.debug("Autoplay failed",q)}));_.Bf(p,0);break;case 2:throw n=_.Cf(p),a.h.debug("Error while attempting to load source."),n;}})},QG=function(a){return _.B(function(b){a.h.debug("avplay.prepare()");return b["return"](new Promise(function(c,d){try{webapis.avplay.prepareAsync(function(){a.h.debug("AVPlay is ready!");
27
+ GG(a);c()},function(e){a.h.debug("prepareAsync failed",e);d(e)})}catch(e){a.h.debug("Failed to prepare media player for playback"),d(e)}}))})},UG=function(a,b,c){a.h.debug("switchVideoTrack()");try{var d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=LG(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.a.Ef;a.f=!1;a.a=
28
+ null;return e===ZF?a.pause():a.play()})}catch(e){return Promise.reject(e)}},KG=function(a){return a.f&&a.a?a.a.bl:webapis.avplay.getTotalTrackInfo()},AG=function(a){return a.f&&a.a?a.a.Mi:webapis.avplay.getCurrentStreamInfo()},nG=function(a,b,c){b=b.toUpperCase();b===pG&&VG(a,!0);var d=a.j[b];d&&(d.ae.stop(),a.j[b]=null,a.h.debug("Cancelled pending track switch for "+b));return new Promise(function(e,f){function g(h,l,m){m=void 0===m?!1:m;try{webapis.avplay.setSelectTrack(h,l),a.j[h]=null,e()}catch(n){a.h.debug("Could not set "+
29
+ h+" track. Trying again...AVPlay state: "+(a.getState()+", buffering: ")+a.w,n),!1===m&&(a.j[h]={type:h,index:l,Cf:0,ae:new _.aj(function(){return g(h,c,!0)})}),(l=a.j[h])&&3>l.Cf?(!a.w&&++l.Cf,l.ae.Z(a.w?.5:.25)):(a.h.debug("Could not set track after multiple attempts.Giving up..."),l&&l.ae.stop(),a.j[h]=null,f())}}g(b,c)})},VG=function(a,b){var c=a.l.getTextDisplayer();c&&c.setTextVisibility(b);c=a.l.g;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.h.debug("Could not set text track visibility",
30
+ d)}},SG=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case KF:a.h.warn("The application does not have the privilege to set mute.",LF);break;default:a.h.warn(HF,c)}}},JG=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case KF:a.h.warn("The application doesn't have the privilege to get the mute state.",LF);break;default:a.h.warn(HF,c)}}return!!b},MG=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
31
+ NF(c,"load",function(d){return a(d)});NF(c,_.jd,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},WG=function(){_.bk.call(this);this.a=new CG(this);this.f=new VF(this);this.configuration=this.B=_.hk();this.w=null;this.h=new _.H("clpp.tizen.Player");this.j=null;this.m=new jG;this.D=new _.pi;this.o=this.g=null;this.A=!1},XG=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();a=a.a;var c=Math.floor(b.left*a.A),d=Math.floor(b.top*
32
+ a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.h.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.h.debug("Could not apply dimension. Player state "+a.a.getState())},YG=function(){},ZG=function(){this.a=null};
33
+ OF.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.B(function(h){if(1==h.a){b=_.vk[a.g.env]||null;if(!b)throw a.h.debug(_.va,_.hb+a.g.env+_.aa),new _.L(_.M,6,6015,_.xa+a.g.env+"' is missing.");a.m={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};c=Object.keys(a.g.customData||{}).length?btoa(JSON.stringify(a.g.customData)):"";d=_.xk(b,a.g.customData);(e=d[_.Tc])&&a.f.set(_.Tc,{od:e.licenseUrl||"",customData:c,ef:!1});(f=d[_.Uc])&&a.f.set(_.Uc,{od:f.licenseUrl||"",customData:c,
34
+ ef:!1});if(0===a.f.size)throw new _.L(_.M,6,6E3);if((g=a.g.preferredDrmSystem)&&a.f.get(g))a.a=g;else if(a.f.get(_.Tc))a.a=_.Tc;else if(a.f.get(_.Uc))a.a=_.Uc;else throw new _.L(_.M,6,6001,"Configuration for the target system is missing.");return _.x(h,RF(a),2)}a.j=!0;_.z(h)})};OF.prototype.release=function(){var a=this;return _.B(function(b){a.j=!1;a.o=null;a.a=_.Kd;a.m=null;a.f=new Map;_.z(b)})};OF.prototype.getDrmInfo=function(){return this.o};
35
+ var TF={eh:"DeleteLicenseAfterUse",fh:"LicenseServer",nl:"GetChallenge",ol:"HttpHeader",tl:"UserAgent",jl:"Cookie",dh:"CustomData"};_.t=VF.prototype;_.t.initialize=function(){this.a.on(OG,this.Rf,this);this.a.on($G,this.Qf,this);this.a.on(aH,this.Pf,this);this.a.on(PG,this.Eg,this);this.a.on(RG,this.Dg,this);this.a.on(bH,this.Sf,this)};_.t.release=function(){XF(this,_.Ym);this.m=!1;this.o=-1;this.g=2};_.t.destroy=function(){this.release();this.a.off(OG,this.Rf);this.a.off($G,this.Qf);this.a.off(aH,this.Pf);this.a.off(PG,this.Eg);this.a.off(RG,this.Dg);this.a.off(bH,this.Sf);this.l=this.a=null};
36
+ _.t.Rf=function(){this.h.debug("Buffering start. Player state: ",this.a.getState());this.g=this.a.B?1:2;XF(this,_.cn)};_.t.Qf=function(a){this.h.debug("Buffering progress: "+a.percent+" %. Player state: ",WF(this.f))};_.t.Pf=function(){this.h.debug("Buffering complete. Player state: ",this.a.getState());if(!this.m){this.m=!0;var a=this.l.getConfiguration().autoplay,b=this.a.getState()===cH;if(!a&&b){XF(this,_.ln);return}}if(a=this.f!==_.kn)a=this.a.getState(),a=a===YF||a===ZF;a&&$F(this)};
37
+ _.t.Eg=function(){this.h.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===dH?XF(this,_.kn):this.h.error("AVPlay prepares while state is not IDLE")};_.t.Dg=function(){this.h.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.Sf=function(){XF(this,_.en)};_.t.getState=function(){return this.f};_.t=aG.prototype;_.t.initialize=function(a){this.l=a};
38
+ _.t.load=function(a){var b=this,c,d,e,f,g,h,l;return _.B(function(m){switch(m.a){case 1:if(!b.l)return b.h.debug("Text streamer is not initialized. Will not load()"),m["return"]();b.B=a;c=b;return _.x(m,cG(b),2);case 2:c.j=m.f;if(!b.j)return b.h.debug("Could not find manifest parser for source. Make sure parsers are registered."),m["return"]();d={networkingEngine:b.l.getNetworkEngine(),filterNewPeriod:function(){},filterAllPeriods:function(){},onTimelineCueAdded:function(){},onEvent:function(){},
39
+ onError:function(){}};_.Af(m,3);e=b;return _.x(m,b.j.start(a.url,d),5);case 5:e.a=m.f;_.Bf(m,4);break;case 3:return f=_.Cf(m),b.h.warn(f),_.Af(m,6),g=b,_.x(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.a=m.f;_.Bf(m,4);break;case 6:h=_.Cf(m),b.h.error(h),b.a=null;case 4:if(!b.a||!bG(b.a)){m.G(0);break}b.g=dG(b);_.Af(m,10);return _.x(m,b.g.H,12);case 12:b.f=eG(b);l=b.l.getConfiguration();b.f.j=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;_.Bf(m,0);break;case 10:_.Cf(m),
40
+ b.h.debug("Could not setup media source..."),b.g=null,b.f=null,b.j=null,b.a=null,_.z(m)}})};_.t.yi=function(a){this.h.debug(_.sv,a);this.w=!0;var b=_.Cx(a.textStreams,this.o||"",this.A||"")[0]||null;this.m&&(a.textStreams.includes(this.m)&&(b=this.m),this.m=null);return{variant:null,text:b}};_.t.xi=function(){this.h.debug("canSwitch_");this.w=!1;this.m&&(_.gz(this.f,this.m,!0,0),this.m=null)};_.t.S=function(){this.h.debug("onError_")};_.t.zi=function(){this.j&&this.j.update&&this.j.update()};
41
+ _.t.start=function(){var a=this;return _.B(function(b){if(!a.f)return b["return"]();try{a.f.start()}catch(c){a.h.error("Error while starting streaming engine",c)}_.z(b)})};_.t.setTextVisibility=function(a){this.h.debug("Set text visibility",a);this.g&&this.g.getTextDisplayer().setTextVisibility(a)};_.t.release=function(){var a=this;return _.B(function(b){a.l=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.m=null;_.z(b)})};
42
+ _.t.destroy=function(){var a=this;return _.B(function(b){switch(b.a){case 1:if(!a.j){b.G(2);break}return _.x(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.f){b.G(4);break}return _.x(b,a.f.destroy(),5);case 5:a.f=null,a.w=!0;case 4:if(!a.g){b.G(0);break}return _.x(b,a.g.destroy(),7);case 7:a.g=null,_.z(b)}})};_.w(jG,_.R);_.t=jG.prototype;_.t.ug=function(a){var b=a.eventid;a=a.data;switch(b){case eH:0<Object.keys(this.f).length||(this.h.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+uG(this,b[0].extra_info).Bit_rate,b=yG(this,{bandwidth:b}))&&(this.w=b,kG(this,b));break;case fH:lG(this);break;default:this.h.debug("Event type: "+b+" data: "+a)}};_.t.$e=function(a){a.detail.currentState===_.mn&&this.l.off(_.se,this.$e)};
43
+ _.t.initialize=function(a){var b=this;this.l=a;this.a=this.l.a;this.l.on(_.se,function(c){b.A||(c=c.detail,c.currentState===_.mn&&(b.h.debug("Current state",c.currentState),b.A=!0,mG(b)))});this.a.on(gH,this.ug,this)};_.t.release=function(){this.f={};this.g=this.w=this.m=this.j=null;this.A=!1;this.o=1};
44
+ _.t.load=function(){if(this.a&&!(0<Object.keys(this.f).length)){this.g=this.l.g;this.l.off(_.se,this.$e);this.l.on(_.se,this.$e,this);try{var a=KG(this.a);this.f=xG(this,a);var b=this.f[_.Q]||[];b.length&&(this.j=b[0].renditions[0]||null);lG(this)}catch(c){this.h.debug("Could not load track manager")}}};_.t.destroy=function(){this.a.off(gH,this.ug);this.a=this.l=null};_.t.getVideoTracks=function(){return this.f[_.ui]||[]};_.t.getAudioTracks=function(){return this.f[_.Q]||[]};
45
+ _.t.ia=function(){return this.f[_.O]||[]};_.t.fa=function(){return BG(this,_.ui)};_.t.Ia=function(){return BG(this,_.Q)};_.t.Ja=function(){return BG(this,_.O)};_.t.Xa=function(){return this.w};_.t.hb=function(){this.h.info(IF);return null};_.t.ib=function(){this.h.info(IF);return null};_.t.La=function(){var a=this.fa();return a?a.track:null};_.t.pa=function(){var a=this.Ia();return a?a.track:null};_.t.qa=function(){var a=this.Ja();return a?a.track:null};
46
+ _.t.cb=function(a){var b=this;null===a?(a=this.fa(),UG(this.a,a.bandwidth,null).then(function(){lG(b)})):0<a.renditions.length&&this.bb(a.renditions[0])};_.t.va=function(a){a?qG(this,a.renditions[0]):this.h.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.t.Ea=function(a){a?(a=a.renditions[0],this.g?iG(this.g,a.track):qG(this,a)):(this.h.debug("Disabling text tracks"),this.m=null,VG(this.a,!1),this.l.trigger(new _.I(_.Vj)))};
47
+ _.t.bb=function(a){var b=this,c=this.fa();this.a.o||a.width!==c.width||a.height!==c.height||a.bandwidth!==c.bandwidth?(this.w=a,kG(this,a),UG(this.a,c.bandwidth,a.bandwidth).then(function(){lG(b)})["catch"](function(d){var e=new _.L(_.M,7,7200,{tizenerror:d});b.h.debug("Error while switching video track",d);b.l.onError(e)})):this.h.debug("Trying to switch to already active rendition. Doing nothing...")};_.t.ob=function(a){qG(this,a)};_.t.pb=function(a){this.g?iG(this.g,a.track):qG(this,a)};
48
+ _.t.addTextTrack=function(){};_.t.ka=function(){return this.a.o};jG.prototype.isAbrEnabled=jG.prototype.ka;jG.prototype.addTextTrack=jG.prototype.addTextTrack;jG.prototype.setTextRendition=jG.prototype.pb;jG.prototype.setAudioRendition=jG.prototype.ob;jG.prototype.setVideoRendition=jG.prototype.bb;jG.prototype.setTextTrack=jG.prototype.Ea;jG.prototype.setAudioTrack=jG.prototype.va;jG.prototype.setVideoTrack=jG.prototype.cb;jG.prototype.getTextTrack=jG.prototype.qa;jG.prototype.getAudioTrack=jG.prototype.pa;
49
+ jG.prototype.getVideoTrack=jG.prototype.La;jG.prototype.getLoadingTextRendition=jG.prototype.ib;jG.prototype.getLoadingAudioRendition=jG.prototype.hb;jG.prototype.getLoadingVideoRendition=jG.prototype.Xa;jG.prototype.getTextRendition=jG.prototype.Ja;jG.prototype.getAudioRendition=jG.prototype.Ia;jG.prototype.getVideoRendition=jG.prototype.fa;jG.prototype.getTextTracks=jG.prototype.ia;jG.prototype.getAudioTracks=jG.prototype.getAudioTracks;jG.prototype.getVideoTracks=jG.prototype.getVideoTracks;_.w(CG,_.bk);_.t=CG.prototype;_.t.pi=function(){this.w=!0;this.f||this.trigger(new _.I(OG))};_.t.oi=function(a){this.w=!0;this.trigger(new _.I($G,{percent:a}))};_.t.ni=function(){this.w=!1;this.trigger(new _.I(aH))};_.t.vi=function(){this.trigger(new _.I(bH))};_.t.si=function(a,b){this.trigger(new _.I(gH,{eventid:a,data:b}))};_.t.wi=function(a,b,c,d,e){this.trigger(new _.I(hH,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
+ _.t.ri=function(a,b){this.trigger(new _.I(iH,{drmType:a,drmData:b}));if(this.g){var c=this.g;if(c.j)if(c.a===_.Uc&&"Challenge"===b.name)UF(c,b);else if("DrmError"===b.name){c.h.debug("DrmError event",b);var d=new _.L(_.M,6,6005,{message:JSON.stringify(b)});c.C.onError(d)}}};_.t.S=function(a){this.trigger(new _.I(jH,{eventType:a}))};
51
+ _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(EG,f,b);g=setTimeout(function(){b.off(EG,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===dH)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){GG(b);d(webapis.avplay.play())},function(f){b.trigger(new _.I(jH));e(f)})})).then(function(){return a()});if(c===ZF||c===cH)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===YF?
52
+ Promise.resolve():Promise.reject("Player is in invalid state")};_.t.pause=function(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===ZF?Promise.resolve():Promise.reject()};
53
+ _.t.setPlaybackRate=function(a){var b=this.getState();if(b===cH||b===YF||b===ZF){try{webapis.avplay.setSpeed(a),this.D=a}catch(c){return this.h.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.D)}return!0}this.h.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1};_.t.getPlaybackRate=function(){return this.D};
54
+ _.t.load=function(a,b){var c=this,d;return _.B(function(e){switch(e.a){case 1:return c.h.debug("configure()",b||""),_.Af(e,2),_.x(e,NG(c),4);case 4:return _.x(e,TG(c,a,b),5);case 5:_.Bf(e,0);break;case 2:throw d=_.Cf(e),new _.L(_.M,7,7003,null,d);}})};_.t.getState=function(){if(this.f&&this.a)return this.a.Ef;try{return webapis.avplay.getState()}catch(a){this.S(JSON.stringify(a))}};
55
+ _.t.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.l.trigger(new _.I(_.Ne));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.I(_.Me));d()},function(){b.B=!1;e()})})};_.t.getPosition=function(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.S(JSON.stringify(a))}};_.t.getDuration=function(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.S(JSON.stringify(a))}};
56
+ _.t.release=function(){var a=this;return new Promise(function(b,c){try{a.g&&(a.g.release(),a.g=null);webapis.avplay.stop();webapis.avplay.close();for(var d in a.j){var e=a.j[d];e&&e.ae.stop()}a.j={};a.D=1;a.B=!1;a.m=null;a.a=null;return b()}catch(f){return c(f)}})};_.t.getVolume=function(){var a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case KF:this.h.debug("The application does not have the privilege to get the volume.",LF);break;default:this.h.debug(HF,b)}}return a};
57
+ _.t.setVolume=function(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.h.warn("Invalid value passed for setVolume.","The passed value value should be in the range of 0 to 1.");break;case KF:this.h.warn("The application does not have the privilege to set the volume.",LF);break;default:this.h.warn("An unknown error occurred while trying to set volume",b)}}};
58
+ _.t.isLive=function(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.S(JSON.stringify(a))}};_.t.stop=function(){try{webapis.avplay.stop()}catch(a){this.h.debug(a)}};_.t.getDrmInfo=function(){this.g&&this.g.getDrmInfo();return null};_.t.setSourceIndex=function(a){this.F=a};_.t.getSourceIndex=function(){return this.F};_.t.getLoadedSource=function(){return this.m&&this.m[this.getSourceIndex()]};
59
+ var dH="IDLE",cH="READY",YF="PLAYING",ZF="PAUSED",vG=_.Db,oG="AUDIO",pG="TEXT",fH="PLAYER_MSG_RESOLUTION_CHANGED",eH="PLAYER_MSG_BITRATE_CHANGE",SF={PLAYREADY:"PLAYREADY",kl:"EME_PLAYREADY",ul:"VERIMATRIX",Bd:"WIDEVINE_CDM",ll:"EME_WIDEVINE_CDM",wl:"WIDEVINE_CLASSIC"};_.w(WG,_.bk);_.t=WG.prototype;_.t.Nf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.I(_.id));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.t.Lf=function(a){this.trigger(new _.I(_.Fe,{currentTime:a.currentTime/1E3}))};
60
+ _.t.Of=function(a){var b=this.a.getPosition(),c=b+a.duration/1E3,d=a.text||"";this.h.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.Jh(d))&&this.o.append([new _.zg(b,c,d)],[])};_.t.Mf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.wg=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
+ _.t.S=function(a){this.h.debug("Error: TYPE: "+a.eventType);XF(this.f,_.jn);a=new _.L(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.I(_.jd,{detail:a}))};
62
+ _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(bH,this.Nf,this);this.a.on(EG,this.Lf,this);this.a.on(hH,this.Of,this);this.a.on(iH,this.Mf,this);this.a.on(jH,this.S,this);this.a.on(aH,this.wg,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=kH;kH+=1;this.j=_.In(_.Ld,{id:"__clpp_tizen_player_"+c,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var d=this.w.getMedia();if(d){c=this.j;
63
+ var e=[_.gf,_.md,"position",_.rd,"top"],f={};d=null!==d.parentElement?window.getComputedStyle(d,null):d.style;if(!e||0===e.length){e||(e=[]);for(var g in d)e.push(g)}g=_.u(e);for(e=g.next();!e.done;e=g.next())e=e.value,f[e]=d[e];_.Kn(c,f);XG(this)}};_.t.getSurface=function(){return this.w};_.t.getConfiguration=function(){return this.configuration};
64
+ _.t.destroy=function(){var a=this;return _.B(function(b){switch(b.a){case 1:return _.x(b,a.release(),2);case 2:a.a.off(bH,a.Nf);a.a.off(EG,a.Lf);a.a.off(hH,a.Of);a.a.off(iH,a.Mf);a.a.off(jH,a.S);a.a.off(aH,a.wg);if(!a.g){b.G(3);break}return _.x(b,a.g.destroy(),4);case 4:a.g=null;case 3:a.j&&(a.j.parentElement.removeChild(a.j),a.j=null),a.m.destroy(),a.f.destroy(),a.m=null,a.f=null,_.z(b)}})};_.t.namespace=function(){return lH};_.t.getPlaybackRate=function(){return this.a.getPlaybackRate()};
65
+ _.t.setDrmCustomDataModifier=function(){};_.t.setCdnErrorCallback=function(){};_.t.detach=function(){};_.t.setPlaybackRate=function(a){this.a.setPlaybackRate(a)};_.t.getPosition=function(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.en?this.getDuration():this.a.getPosition()||0};_.t.seek=function(a){return typeof a===_.k&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()};_.t.getPresentationStartTime=function(){return null};
66
+ _.t.getSeekRange=function(){return{start:0,end:0}};_.t.getVolume=function(){var a=this.a.getVolume();return typeof a===_.k?a/100:null};_.t.setVolume=function(a){this.a.setVolume(a)};_.t.getDuration=function(){return this.a.getDuration()};_.t.getBufferInfo=function(){this.h.warn(_.qa);return new _.ak};_.t.getTrackManager=function(){return this.m};_.t.unload=function(){var a=this;return this.a.release().then(function(){a.m.release()})};
67
+ _.t.release=function(){var a=this;return _.B(function(b){switch(b.a){case 1:if(!a.g){b.G(2);break}return _.x(b,a.g.release(),2);case 2:if(!a.o){b.G(4);break}return _.x(b,a.o.destroy(),5);case 5:a.o=null;case 4:return _.x(b,a.a.release(),6);case 6:a.m.release(),a.f.release(),a.A=!1,_.z(b)}})};
68
+ _.t.load=function(a){var b=this,c,d,e,f,g;return _.B(function(h){switch(h.a){case 1:_.kk(a)&&(b.configuration=_.jk(b.B,a));c=_.Mm(b.configuration,["html","native"]);b.o=c.create(b);d=_.qn(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.G(2);break}b.g=new aG;b.g.initialize(b);_.Af(h,3);return _.x(h,b.g.load(d),5);case 5:b.g.start();_.Bf(h,2);break;case 3:f=_.Cf(h),b.h.error(f);case 2:return _.Af(h,6),_.x(h,b.a.load(b.configuration),8);case 8:_.Bf(h,7);break;
69
+ case 6:throw g=_.Cf(h),b.onError(g),g;case 7:b.m.load(),_.z(h)}})};_.t.play=function(){var a=this;this.trigger(new _.I(_.Zd));XG(this);return this.a.play().then(function(){$F(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){$F(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.I(_.jd,{detail:a});a.severity===_.M&&(XF(this.f,_.jn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)};
70
+ _.t.getDrmInfo=function(){return this.a.getDrmInfo()};_.t.isEnded=function(){return this.f.getState()===_.en};_.t.isPaused=function(){return this.a.getState()===ZF};_.t.isMuted=function(){return JG(this.a)};_.t.setMuted=function(a){SG(this.a,a)};_.t.getNetworkEngine=function(){return this.D};_.t.setNetworkEngine=function(a){this.D=a};_.t.isLive=function(){return this.a.isLive()};_.t.getStats=function(){return null};_.t.setSourceIndex=function(a){this.a.setSourceIndex(a)};_.t.getSourceIndex=function(){return this.a.getSourceIndex()};
71
+ _.t.getLoadedSource=function(){return this.a.getLoadedSource()};_.t.canPlay=function(a,b){return(new YG).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};WG.prototype.getTextDisplayer=WG.prototype.getTextDisplayer;WG.prototype.setNetworkEngine=WG.prototype.setNetworkEngine;WG.prototype.getNetworkEngine=WG.prototype.getNetworkEngine;var lH="clpp.tizen",kH=0;YG.prototype.a=function(){return lH};
72
+ YG.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.ec||a===_.Lj||a===_.jc)&&b){if(_.ki(2))return 2;if(_.ki(3)||_.ki(4)||_.ki(5)||_.ki(6))return _.G("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};YG.prototype.create=function(){return new WG};_.w(ZG,_.Ko);ZG.prototype.Ma=function(){this.a=new YG;_.Zf(this.a)};ZG.prototype.Fa=function(){if(this.a){var a=this.a.a();a&&_.Xf[a]&&(delete _.Xf[a],_.Yf.info("Removed Player factory: '"+a+"'"));this.a=null}};ZG.prototype.id=function(){return"tizen"};_.C("clpp.tizen.TizenComponent",ZG);var OG="onbufferingstart",$G="onbufferingprogress",aH="onbufferingcomplete",bH="onstreamcompleted",EG="oncurrentplaytime",gH="onevent",hH="onsubtitlechange",iH="ondrmevent",jH="onerror",PG="preparingstart",RG="preparingend";};
73
73
  if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
74
74
  else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
75
75
  else{_=this.clpp._;(f.call(g,this));}
package/cjs/cl.ttml.js CHANGED
@@ -1,31 +1,31 @@
1
1
  (function(){var g={}; var _ = _ || {}
2
- var f=function(window){var Cs='application/mp4; codecs\x3d"stpp.ttml"',Ds='application/mp4; codecs\x3d"stpp.ttml.im1i"',Es='application/mp4; codecs\x3d"stpp.ttml.im1t"',Fs="backgroundColor",Gs="direction",Hs="displayAlign",Is="region",Js="sans-serif",Ks="textAlign",Ls="textDecoration",Ms="writingMode",Ns=function(a,b,c){this.g=a;this.f=b;this.a=c},Os=function(a,b,c){Ns.call(this,a,[],c);this.h=b||""},Ps=function(a,b,c){Ns.call(this,a,b,c)},Qs=function(a,b,c){a=a.f;for(var d=a.length-1;0<=d;d--){var e=b.get(a[d]);if(c in
3
- e.a)return e.getAttribute(c)}return null},Ys=function(a,b){var c=null;if(Rs.test(a)){c=Rs.exec(a);var d=Number(c[1]),e=Number(c[2]),f=Number(c[3]),g=Number(c[4]);g+=(Number(c[5])||0)/b.f;f+=g/b.frameRate;c=f+60*e+3600*d}else Ss.test(a)?c=Ts(Ss,a):Us.test(a)?c=Ts(Us,a):Vs.test(a)?(c=Vs.exec(a),c=Number(c[1])/b.frameRate):Ws.test(a)?(c=Ws.exec(a),c=Number(c[1])/b.a):Xs.test(a)&&(c=Ts(Xs,a));return c},Ts=function(a,b){var c=a.exec(b);return null==c||""===c[0]?null:(Number(c[4])||0)/1E3+(Number(c[3])||
4
- 0)+60*(Number(c[2])||0)+3600*(Number(c[1])||0)},Zs=function(a){return a.split(":").pop()},$s=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},bt=function(a,b){for(;at.test(a);){var c=at.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},ct=function(a,b,c,d,e,f,g){Ns.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},dt=function(a,b,c){a=Qs(a,b,Ks);if(!a&&c&&(a=Qs(c,b,Ks),!a&&"rltb"===Qs(c,b,Ms)))return _.ke;switch(a){case _.Cc:return _.ug;case _.ke:case _.hd:return _.ke;default:return _.rd}},
5
- et=function(a,b,c){if(_.Fh(a.o))return document.createTextNode(_.Jh(a.o||""));if(a.w)return _.In("br");for(var d=_.In("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.Jn(d,f.value);a=_.u(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(et(c.get(e.value),b,c));return d},ft=function(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]))},gt=function(a,
6
- b,c){Ns.call(this,a,b,c)},jt=function(a,b,c,d){var e=ht.exec(a);a=it.exec(a);return typeof b===_.k&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},kt=function(a,b){return typeof b===_.k&&0<b?_.Ag:it.test(a)?0:_.Ag},lt=function(a,b){Ns.call(this,"root-container",[],b);this.h=a},mt=function(a,b,c){return typeof a===_.k?a:typeof b===_.k?b:c},nt=function(a,b){var c=a.getAttribute("extent");return(c=it.exec(c))?Number(c[b]):null},pt=function(a){a=a.getAttribute("cellResolution");return(a=ot.exec(a))?
7
- Number(a[2]):null},qt=function(a,b,c){Ns.call(this,a,b,c)},rt=function(a){this.A=a;this.o=this.j=null;this.w=0;this.g=new Map;this.a=new Map;this.h=new Map;this.f=new Map;this.m=[]},tt=function(a){return st.some(function(b){return b in a.attributes})},ut=function(a,b){if(0===b.length)return[];for(var c=[],d=_.u(b),e=d.next();!e.done;e=d.next())e=e.value,a.a.has(e)&&c.push.apply(c,_.mf(ut(a,a.a.get(e).f)).concat([e]));return c},wt=function(){return"inline-"+vt++},xt=function(a){return a.m.map(function(b){return b.build(a.j,
8
- a.o,a.w,a.g,a.a,a.h,a.f)}).filter(function(b){return null!=b})},yt=function(a){this.a=a.firstChild;this.f=new Set},zt=function(a,b,c,d,e,f){this.g=a;this.a=b;this.h=c;this.j=d;this.f=e;this.attributes=f},At=function(a){return Zs(a.g.nodeName)},Bt=function(){this.a=new Map},Dt=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null,e=[],f=[],g={},h=b.parentNode;if(h&&a.a.has(h)){var l=a.a.get(h);e=_.mf(l.j).concat();-1===["#text","span","br"].indexOf(b.nodeName)&&(c=l.a,d=l.h,f=_.mf(l.f).concat(),
9
- g={},Ct.forEach(function(n){n in l.attributes&&(g[n]=l.attributes[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Is)&&(c=b.getAttribute(Is));b.hasAttribute(_.xe)&&f.push.apply(f,_.mf(b.getAttribute(_.xe).split(" ")));d=Array.from(b.attributes).map(function(n){return n.name});d=_.u(d);for(h=d.next();!h.done;h=d.next()){h=h.value;var m=Zs(h);g[m]=b.getAttribute(h)}d=g.backgroundImage}c=new zt(b,c,d,e,f,g);a.a.set(b,c);return c},Et=function(a){this.a=a;this.f=new DOMParser},Ft=function(a){this.f=
10
- a},Gt=function(a){return String(Math.floor(a/3600)).padStart(2,"0")+":"+String(Math.floor(a/60%60)).padStart(2,"0")+":"+String(Math.floor(a%60)).padStart(2,"0")+"."+String(Math.floor(1E3*a%1E3)).padStart(3,"0")},Ht=function(){},It=function(a){this.f=new Et(a);this.a=new _.H("clpp.ttml.Mp4TtmlParser")},Jt=function(){this.a=new Ht};Ns.prototype.getId=function(){return this.g};Ns.prototype.getAttribute=function(a){return this.a[a]};_.v(Os,Ns);_.v(Ps,Ns);var Rs=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ss=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Us=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Vs=/^(\d*(?:\.\d*)?)f$/,Ws=/^(\d*(?:\.\d*)?)t$/,Xs=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,ht=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,it=/^(\d+)px (\d+)px$/,ot=/^(\d+) (\d+)$/,at=/(\d+)px/,Kt=/^(\d+px|\d+em|\d*\.?\d+c)$/,st=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
- "color",Fs,"opacity","padding","zIndex",Ks,Hs,Ms,Gs,Ls,"textOutline"],Ct=["begin",_.hd];_.v(ct,Ps);
12
- ct.prototype.build=function(a,b,c,d,e,f,g){var h=Ys(this.a.begin,b);b=Ys(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.In(_.Yc);for(var l=_.u(this.h),m=l.next();!m.done;m=l.next())c.appendChild(et(g.get(m.value),e,g));g=new _.zg(h,b,c.innerHTML.trim(),_.He);g.cssClassList=_.mf(this.f).concat();g.textAlign=dt(this,e,null);g.writingMode=_.vg;g.line=-1;g.lineInterpretation=_.wg;g.lineAlign=_.xg;g.containerRows=mt(null,pt(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
- dt(this,e,f);a:switch(Qs(f,e,Ms)){case "tb":case "tblr":a=_.Pe;break a;case "tbrl":a=_.Qe;break a;default:a=_.vg}g.writingMode=a;a:switch(Qs(f,e,Hs)){case _.Cc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Qs(f,e,Hs)){case _.Cc:a=1;break a;default:a=_.wg}g.lineInterpretation=a;a:switch(Qs(f,e,Hs)){case _.Cc:e=_.Cc;break a;default:e=_.xg}g.lineAlign=e}this.j&&(a=d.get(this.j))&&(d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||a.getAttribute("imagetype"),a=a.h.trim(),
14
- g.backgroundImage=("PNG"===e&&"Base64"===d&&0<a.length?"data:image/png;base64,"+a:null)||"");return g};_.v(gt,Ps);
15
- gt.prototype.build=function(a,b){var c=new _.Cg;c.id=this.getId();var d=mt(a.h.containerWidth,nt(a,1),720),e=mt(a.h.containerHeight,nt(a,2),480);a:switch(Qs(this,b,Hs)){case "after":var f="flex-start";break a;case _.Cc:f=_.Cc;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Qs(this,b,Ms)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Oc}c.writingMode=f;f=this.getAttribute("extent")||Qs(this,b,"extent");c.width=jt(f,d,1,100);c.widthUnits=kt(f,d);c.height=
16
- jt(f,e,2,100);c.heightUnits=kt(f,e);f=this.getAttribute("origin")||Qs(this,b,"origin");c.viewportAnchorX=jt(f,d,1,0);c.viewportAnchorY=jt(f,e,2,0);c.viewportAnchorUnits=kt(f,d);c.cssClassList=_.mf(this.f).concat();return c};_.v(lt,Ns);_.v(qt,Ns);
17
- qt.prototype.build=function(a){var b=null;var c=pt(a);c&&(b=mt(a.h.containerHeight,nt(a,2),480)/c);b=mt(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.u(Lt.entries()),e=d.next();!e.done;e=d.next()){var f=_.u(e.value);e=f.next().value;f=f.next().value;e in this.a&&(c+=f+":"+$s(this.a[e])+";")}a:{if("unicodeBidi"in this.a){d=this.a.unicodeBidi;e="";switch(d){case "normal":case "embed":e=d;break;case "bidiOverride":e="bidi-override"}if(0<e.length){d="unicode-bidi:"+
18
- e+";";break a}}d=""}c+=d;a:{if("textOutline"in this.a){d=this.a.textOutline.split(" ");e="black";f=".4em";var g=d[0]&&d[0].trim(),h=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!Kt.test(g)&&Kt.test(h)&&Kt.test(l)?(e=g,f=h):2===d.length&&!Kt.test(g)&&Kt.test(h)?(e=g,f=h):2===d.length&&Kt.test(g)&&Kt.test(h)&&(f=g);if(""!==f){f=$s(f);d="text-shadow:0 0 "+(f+" "+e+",0 0 ")+(f+" "+e+",0 0 ")+(f+" "+e+";");break a}}d=""}c=c+d+("fontFamily"in this.a?"font-family:"+this.a.fontFamily.replace("monospaceSansSerif",
19
- "monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif",Js).replace("proportionalSerif",Js).replace("sansSerif",Js).replace("default",Js)+";":"");a:{if(Ls in this.a){d=[];e=_.u(this.a.textDecoration.split(" "));for(f=e.next();!f.done;f=e.next())switch(f=f.value,f){case "underline":case "overline":d.push(f);break;case "lineThrough":d.push("line-through")}if(0<d.length){d="text-decoration:"+d.join(" ")+";";break a}}d=""}e="padding"in this.a?"border: solid transparent;border-width:"+
20
- $s(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=$s(e),e=bt(e,b),d=d+"line-height:"+e+";"):d="";a.push(c+d+"}");a:{if("fontSize"in this.a&&(c=this.a.fontSize.split(" "),d=null,1===c.length&&(d=c[0]),2===c.length&&(d=c[1]),d)){d=d.trim();d=$s(d);d=bt(d,b);b="font-size:"+d+";";break a}b=null}b&&(c="::ttml ."+this.g+" .clpp-text-wrapper {",a.push(c+b+"}"),c="::ttml .clpp-text-wrapper__"+this.g+" {",a.push(c+b+"}"));return a};
21
- var Lt=new Map([["color","color"],[Fs,"background-color"],[Gs,Gs],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var vt=0;yt.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Mt.has(Zs(a.nodeName))||Nt.has(Zs(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&&!Mt.has(Zs(a.nodeName))));var b=this.a;this.a=a;return b};var Mt=new Set(["tt","head","layout",_.Cd,_.od,Is,"styling",_.xe,"body",_.Yc,"p","span","br"]),Nt=new Set([_.xe,_.od]);zt.prototype.getId=function(){return this.attributes.id};Et.prototype.parseInit=function(){};
22
- Et.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.K.La(this.a.ttml||{}),e=_.N(a,0,c[0]);e=_.wh(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Ee)}catch(n){throw new _.L(_.M,2,2005,"Failed to parse TTML.");}d=new rt(d);e=new Bt;f=new yt(f);b=b.periodStart;typeof b===_.k&&(d.w=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],l=_.N(a,b,h);l=_.kk(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Os(m,l,{imageType:"PNG",encoding:"Base64"}));
23
- b+=h}for(;f.a;)a=f.next(),a=Dt(e,a),"tt"===At(a)&&(d.j=new lt(d.A,Object.assign({},a.attributes))),"tt"===At(a)&&(d.o=new ft(a.attributes.frameRate,a.attributes.subFrameRate,a.attributes.frameRateMultiplier,a.attributes.tickRate)),At(a)!==_.od||a.attributes.begin||a.attributes.end||(c="#"+a.getId(),d.g.set(c,new Os(c,a.g.textContent,a.attributes))),At(a)===_.od&&a.attributes.begin&&a.attributes.end?(c="#"+wt(),b=new Os(c,a.g.textContent,a.attributes),d.g.set(c,b),c=b):c=null,c&&(a.h=c.getId()),At(a)===
24
- _.xe&&(c=a.getId()||wt(),b=new qt(c,a.f,Object.assign({},a.attributes)),d.a.set(c,b),a.a&&d.h.get(a.a).f.push(c)),At(a)!==_.xe&&tt(a)?(c=wt(),b=new qt(c,[],Object.assign({},a.attributes)),d.a.set(c,b),c=b):c=null,c&&a.f.push(c.getId()),At(a)!==_.Yc||!a.attributes.extent&&!a.attributes.origin?c=null:(c=wt(),b=new gt(c,ut(d,a.f),Object.assign({},a.attributes)),d.h.set(c,b),c=b),c&&(a.a=c.getId()),At(a)!==Is?c=null:(c=a.getId(),b=new gt(c,ut(d,a.f),Object.assign({},a.attributes)),d.h.set(c,b),c=b),c&&
25
- (a.a=c.getId()),c=a.j,-1===["#text","span","br"].indexOf(At(a))||0===c.length?c=null:(g=c[c.length-1],d.f.has(g)?(c=wt(),b=new ct(c,"#text"===a.g.nodeName?a.g.textContent:null,"br"===At(a),a.a,a.h,ut(d,a.f),a.attributes),d.f.set(c,b),(g=d.f.get(g))&&g.h.push(c),c=b):c=null),c&&a.j.push(c.getId()),"p"===At(a)||a.h?(c=wt(),b=new ct(c,null,!1,a.a,a.h,ut(d,a.f),a.attributes),d.f.set(c,b),d.m.push(b),c=b):c=null,c&&a.j.push(c.getId());e=xt(d);f=[];a=_.u(d.a.values());for(c=a.next();!c.done;c=a.next())f.push.apply(f,
26
- _.mf(c.value.build(d.j)));return{cues:e,styles:f}};Ft.prototype.a=function(a){a=(new Et(this.f)).parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}).cues;var b="WEBVTT\n\n";a=_.u(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=Gt(c.startTime)+" --\x3e "+Gt(c.endTime),e=[];switch(c.textAlign){case _.rd:e.push("align:left");break;case _.ke:e.push("align:right");break;case _.ug:e.push("align:middle");break;case _.rd:e.push("align:start");break;case _.ke:e.push("align:end")}switch(c.writingMode){case _.Pe:e.push("vertical:lr");break;
27
- case _.Qe:e.push("vertical:rl")}b+=d+(e.length?" "+e.join(" "):"")+"\n";b+=c.payload+"\n\n"}return _.Ah(b)};Ht.prototype.probe=function(a,b){return a===_.hc&&b===_.De};Ht.prototype.create=function(a){return new Ft(a)};It.prototype.parseInit=function(a){var b=!1;(new _.Pk).L(_.Fd,_.Qk).L(_.Ge,_.Qk).L(_.Ad,_.Qk).L(_.Ed,_.Qk).L(_.ue,_.Qk).V(_.we,_.Rk).L("stpp",function(c){b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.L(_.M,2,2007);};
28
- It.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Pk).L("moof",_.Qk).L("traf",_.Qk).V("subs",function(h){for(var l=_.U(h.reader),m=0;m<l;++m){h.reader.skip(4);for(var n=_.Kk(h.reader),p=0;p<n;++p){var q=1===h.version?_.U(h.reader):_.Kk(h.reader);g.push(q);h.reader.skip(6)}}}).L(_.zd,_.Sk(function(h){d=!0;h=c.f.parseMedia(h,b,g);e=e.concat(h.cues);f=f.concat(h.styles)})).parse(a);d||this.a.warn("Couldn't find the mdat box");return{cues:e,styles:f}};_.v(Jt,_.Ko);Jt.prototype.Ga=function(){_.bq[_.hc]=Et;_.bq[_.fc]=It;_.bq[Cs]=It;_.bq[Es]=It;_.bq[Ds]=It;_.Hi.push(this.a)};Jt.prototype.Ba=function(){_.cq(_.hc);_.cq(_.fc);_.cq(Cs);_.cq(Es);_.cq(Ds);_.Ji(this.a)};Jt.prototype.id=function(){return _.Ae};_.C("clpp.ttml.TtmlComponent",Jt);};
2
+ var f=function(window){var Ds='application/mp4; codecs\x3d"stpp.ttml"',Es='application/mp4; codecs\x3d"stpp.ttml.im1i"',Fs='application/mp4; codecs\x3d"stpp.ttml.im1t"',Gs="backgroundColor",Hs="direction",Is="displayAlign",Js="region",Ks="sans-serif",Ls="textAlign",Ms="textDecoration",Ns="writingMode",Os=function(a,b,c){this.g=a;this.f=b;this.a=c},Ps=function(a,b,c){Os.call(this,a,[],c);this.j=b||""},Qs=function(a,b,c){Os.call(this,a,b,c)},Rs=function(a,b,c){a=a.f;for(var d=a.length-1;0<=d;d--){var e=b.get(a[d]);if(c in
3
+ e.a)return e.getAttribute(c)}return null},Zs=function(a,b){var c=null;if(Ss.test(a)){c=Ss.exec(a);var d=Number(c[1]),e=Number(c[2]),f=Number(c[3]),g=Number(c[4]);g+=(Number(c[5])||0)/b.f;f+=g/b.frameRate;c=f+60*e+3600*d}else Ts.test(a)?c=Us(Ts,a):Vs.test(a)?c=Us(Vs,a):Ws.test(a)?(c=Ws.exec(a),c=Number(c[1])/b.frameRate):Xs.test(a)?(c=Xs.exec(a),c=Number(c[1])/b.a):Ys.test(a)&&(c=Us(Ys,a));return c},Us=function(a,b){var c=a.exec(b);return null==c||""===c[0]?null:(Number(c[4])||0)/1E3+(Number(c[3])||
4
+ 0)+60*(Number(c[2])||0)+3600*(Number(c[1])||0)},$s=function(a){return a.split(":").pop()},at=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},ct=function(a,b){for(;bt.test(a);){var c=bt.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},dt=function(a,b,c,d,e,f,g){Os.call(this,a,f,g);this.w=b;this.A=c;this.o=d;this.m=e;this.j=[]},et=function(a,b,c){a=Rs(a,b,Ls);if(!a&&c&&(a=Rs(c,b,Ls),!a&&"rltb"===Rs(c,b,Ns)))return _.ke;switch(a){case _.Ec:return _.ug;case _.ke:case _.hd:return _.ke;default:return _.rd}},
5
+ ft=function(a,b,c){if(_.Fh(a.w))return document.createTextNode(_.Jh(a.w||""));if(a.A)return _.In("br");for(var d=_.In("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.Jn(d,f.value);a=_.u(a.j);for(e=a.next();!e.done;e=a.next())d.appendChild(ft(c.get(e.value),b,c));return d},gt=function(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]))},ht=function(a,
6
+ b,c){Os.call(this,a,b,c)},kt=function(a,b,c,d){var e=it.exec(a);a=jt.exec(a);return typeof b===_.k&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},lt=function(a,b){return typeof b===_.k&&0<b?_.Ag:jt.test(a)?0:_.Ag},mt=function(a,b){Os.call(this,"root-container",[],b);this.j=a},nt=function(a,b,c){return typeof a===_.k?a:typeof b===_.k?b:c},ot=function(a,b){var c=a.getAttribute("extent");return(c=jt.exec(c))?Number(c[b]):null},qt=function(a){a=a.getAttribute("cellResolution");return(a=pt.exec(a))?
7
+ Number(a[2]):null},rt=function(a,b,c){Os.call(this,a,b,c)},st=function(a){this.B=a;this.w=this.m=null;this.A=0;this.g=new Map;this.a=new Map;this.j=new Map;this.f=new Map;this.o=[]},ut=function(a){return tt.some(function(b){return b in a.attributes})},vt=function(a,b){if(0===b.length)return[];for(var c=[],d=_.u(b),e=d.next();!e.done;e=d.next())e=e.value,a.a.has(e)&&c.push.apply(c,_.nf(vt(a,a.a.get(e).f)).concat([e]));return c},xt=function(){return"inline-"+wt++},yt=function(a){return a.o.map(function(b){return b.build(a.m,
8
+ a.w,a.A,a.g,a.a,a.j,a.f)}).filter(function(b){return null!=b})},zt=function(a){this.a=a.firstChild;this.f=new Set},At=function(a,b,c,d,e,f){this.g=a;this.a=b;this.j=c;this.m=d;this.f=e;this.attributes=f},Bt=function(a){return $s(a.g.nodeName)},Ct=function(){this.a=new Map},Et=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null,e=[],f=[],g={},h=b.parentNode;if(h&&a.a.has(h)){var l=a.a.get(h);e=_.nf(l.m).concat();-1===["#text","span","br"].indexOf(b.nodeName)&&(c=l.a,d=l.j,f=_.nf(l.f).concat(),
9
+ g={},Dt.forEach(function(n){n in l.attributes&&(g[n]=l.attributes[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Js)&&(c=b.getAttribute(Js));b.hasAttribute(_.xe)&&f.push.apply(f,_.nf(b.getAttribute(_.xe).split(" ")));d=Array.from(b.attributes).map(function(n){return n.name});d=_.u(d);for(h=d.next();!h.done;h=d.next()){h=h.value;var m=$s(h);g[m]=b.getAttribute(h)}d=g.backgroundImage}c=new At(b,c,d,e,f,g);a.a.set(b,c);return c},Ft=function(a){this.a=a;this.f=new DOMParser},Gt=function(a){this.f=
10
+ a},Ht=function(a){return String(Math.floor(a/3600)).padStart(2,"0")+":"+String(Math.floor(a/60%60)).padStart(2,"0")+":"+String(Math.floor(a%60)).padStart(2,"0")+"."+String(Math.floor(1E3*a%1E3)).padStart(3,"0")},It=function(){},Jt=function(a){this.a=new Ft(a);this.h=new _.H("clpp.ttml.Mp4TtmlParser")},Kt=function(){this.a=new It};Os.prototype.getId=function(){return this.g};Os.prototype.getAttribute=function(a){return this.a[a]};_.w(Ps,Os);_.w(Qs,Os);var Ss=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ts=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Vs=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Ws=/^(\d*(?:\.\d*)?)f$/,Xs=/^(\d*(?:\.\d*)?)t$/,Ys=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,it=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,jt=/^(\d+)px (\d+)px$/,pt=/^(\d+) (\d+)$/,bt=/(\d+)px/,Lt=/^(\d+px|\d+em|\d*\.?\d+c)$/,tt=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
+ "color",Gs,"opacity","padding","zIndex",Ls,Is,Ns,Hs,Ms,"textOutline"],Dt=["begin",_.hd];_.w(dt,Qs);
12
+ dt.prototype.build=function(a,b,c,d,e,f,g){var h=Zs(this.a.begin,b);b=Zs(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.In(_.$c);for(var l=_.u(this.j),m=l.next();!m.done;m=l.next())c.appendChild(ft(g.get(m.value),e,g));g=new _.zg(h,b,c.innerHTML.trim(),_.He);g.cssClassList=_.nf(this.f).concat();g.textAlign=et(this,e,null);g.writingMode=_.vg;g.line=-1;g.lineInterpretation=_.wg;g.lineAlign=_.xg;g.containerRows=nt(null,qt(a),15);if(this.o&&(f=f.get(this.o))){g.region=f.build(a,e);g.textAlign=
13
+ et(this,e,f);a:switch(Rs(f,e,Ns)){case "tb":case "tblr":a=_.Pe;break a;case "tbrl":a=_.Qe;break a;default:a=_.vg}g.writingMode=a;a:switch(Rs(f,e,Is)){case _.Ec:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Rs(f,e,Is)){case _.Ec:a=1;break a;default:a=_.wg}g.lineInterpretation=a;a:switch(Rs(f,e,Is)){case _.Ec:e=_.Ec;break a;default:e=_.xg}g.lineAlign=e}this.m&&(a=d.get(this.m))&&(d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||a.getAttribute("imagetype"),a=a.j.trim(),
14
+ g.backgroundImage=("PNG"===e&&"Base64"===d&&0<a.length?"data:image/png;base64,"+a:null)||"");return g};_.w(ht,Qs);
15
+ ht.prototype.build=function(a,b){var c=new _.Cg;c.id=this.getId();var d=nt(a.j.containerWidth,ot(a,1),720),e=nt(a.j.containerHeight,ot(a,2),480);a:switch(Rs(this,b,Is)){case "after":var f="flex-start";break a;case _.Ec:f=_.Ec;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Rs(this,b,Ns)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Qc}c.writingMode=f;f=this.getAttribute("extent")||Rs(this,b,"extent");c.width=kt(f,d,1,100);c.widthUnits=lt(f,d);c.height=
16
+ kt(f,e,2,100);c.heightUnits=lt(f,e);f=this.getAttribute("origin")||Rs(this,b,"origin");c.viewportAnchorX=kt(f,d,1,0);c.viewportAnchorY=kt(f,e,2,0);c.viewportAnchorUnits=lt(f,d);c.cssClassList=_.nf(this.f).concat();return c};_.w(mt,Os);_.w(rt,Os);
17
+ rt.prototype.build=function(a){var b=null;var c=qt(a);c&&(b=nt(a.j.containerHeight,ot(a,2),480)/c);b=nt(a.j.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.u(Mt.entries()),e=d.next();!e.done;e=d.next()){var f=_.u(e.value);e=f.next().value;f=f.next().value;e in this.a&&(c+=f+":"+at(this.a[e])+";")}a:{if("unicodeBidi"in this.a){d=this.a.unicodeBidi;e="";switch(d){case "normal":case "embed":e=d;break;case "bidiOverride":e="bidi-override"}if(0<e.length){d="unicode-bidi:"+
18
+ e+";";break a}}d=""}c+=d;a:{if("textOutline"in this.a){d=this.a.textOutline.split(" ");e="black";f=".4em";var g=d[0]&&d[0].trim(),h=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!Lt.test(g)&&Lt.test(h)&&Lt.test(l)?(e=g,f=h):2===d.length&&!Lt.test(g)&&Lt.test(h)?(e=g,f=h):2===d.length&&Lt.test(g)&&Lt.test(h)&&(f=g);if(""!==f){f=at(f);d="text-shadow:0 0 "+(f+" "+e+",0 0 ")+(f+" "+e+",0 0 ")+(f+" "+e+";");break a}}d=""}c=c+d+("fontFamily"in this.a?"font-family:"+this.a.fontFamily.replace("monospaceSansSerif",
19
+ "monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif",Ks).replace("proportionalSerif",Ks).replace("sansSerif",Ks).replace("default",Ks)+";":"");a:{if(Ms in this.a){d=[];e=_.u(this.a.textDecoration.split(" "));for(f=e.next();!f.done;f=e.next())switch(f=f.value,f){case "underline":case "overline":d.push(f);break;case "lineThrough":d.push("line-through")}if(0<d.length){d="text-decoration:"+d.join(" ")+";";break a}}d=""}e="padding"in this.a?"border: solid transparent;border-width:"+
20
+ at(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=at(e),e=ct(e,b),d=d+"line-height:"+e+";"):d="";a.push(c+d+"}");a:{if("fontSize"in this.a&&(c=this.a.fontSize.split(" "),d=null,1===c.length&&(d=c[0]),2===c.length&&(d=c[1]),d)){d=d.trim();d=at(d);d=ct(d,b);b="font-size:"+d+";";break a}b=null}b&&(c="::ttml ."+this.g+" .clpp-text-wrapper {",a.push(c+b+"}"),c="::ttml .clpp-text-wrapper__"+this.g+" {",a.push(c+b+"}"));return a};
21
+ var Mt=new Map([["color","color"],[Gs,"background-color"],[Hs,Hs],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var wt=0;zt.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Nt.has($s(a.nodeName))||Ot.has($s(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&&!Nt.has($s(a.nodeName))));var b=this.a;this.a=a;return b};var Nt=new Set(["tt","head","layout",_.Cd,_.od,Js,"styling",_.xe,"body",_.$c,"p","span","br"]),Ot=new Set([_.xe,_.od]);At.prototype.getId=function(){return this.attributes.id};Ft.prototype.parseInit=function(){};
22
+ Ft.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.K.Qa(this.a.ttml||{}),e=_.N(a,0,c[0]);e=_.wh(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Ee)}catch(n){throw new _.L(_.M,2,2005,"Failed to parse TTML.");}d=new st(d);e=new Ct;f=new zt(f);b=b.periodStart;typeof b===_.k&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],l=_.N(a,b,h);l=_.Lh(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Ps(m,l,{imageType:"PNG",encoding:"Base64"}));
23
+ b+=h}for(;f.a;)a=f.next(),a=Et(e,a),"tt"===Bt(a)&&(d.m=new mt(d.B,Object.assign({},a.attributes))),"tt"===Bt(a)&&(d.w=new gt(a.attributes.frameRate,a.attributes.subFrameRate,a.attributes.frameRateMultiplier,a.attributes.tickRate)),Bt(a)!==_.od||a.attributes.begin||a.attributes.end||(c="#"+a.getId(),d.g.set(c,new Ps(c,a.g.textContent,a.attributes))),Bt(a)===_.od&&a.attributes.begin&&a.attributes.end?(c="#"+xt(),b=new Ps(c,a.g.textContent,a.attributes),d.g.set(c,b),c=b):c=null,c&&(a.j=c.getId()),Bt(a)===
24
+ _.xe&&(c=a.getId()||xt(),b=new rt(c,a.f,Object.assign({},a.attributes)),d.a.set(c,b),a.a&&d.j.get(a.a).f.push(c)),Bt(a)!==_.xe&&ut(a)?(c=xt(),b=new rt(c,[],Object.assign({},a.attributes)),d.a.set(c,b),c=b):c=null,c&&a.f.push(c.getId()),Bt(a)!==_.$c||!a.attributes.extent&&!a.attributes.origin?c=null:(c=xt(),b=new ht(c,vt(d,a.f),Object.assign({},a.attributes)),d.j.set(c,b),c=b),c&&(a.a=c.getId()),Bt(a)!==Js?c=null:(c=a.getId(),b=new ht(c,vt(d,a.f),Object.assign({},a.attributes)),d.j.set(c,b),c=b),c&&
25
+ (a.a=c.getId()),c=a.m,-1===["#text","span","br"].indexOf(Bt(a))||0===c.length?c=null:(g=c[c.length-1],d.f.has(g)?(c=xt(),b=new dt(c,"#text"===a.g.nodeName?a.g.textContent:null,"br"===Bt(a),a.a,a.j,vt(d,a.f),a.attributes),d.f.set(c,b),(g=d.f.get(g))&&g.j.push(c),c=b):c=null),c&&a.m.push(c.getId()),"p"===Bt(a)||a.j?(c=xt(),b=new dt(c,null,!1,a.a,a.j,vt(d,a.f),a.attributes),d.f.set(c,b),d.o.push(b),c=b):c=null,c&&a.m.push(c.getId());e=yt(d);f=[];a=_.u(d.a.values());for(c=a.next();!c.done;c=a.next())f.push.apply(f,
26
+ _.nf(c.value.build(d.m)));return{cues:e,styles:f}};Gt.prototype.a=function(a){a=(new Ft(this.f)).parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}).cues;var b="WEBVTT\n\n";a=_.u(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=Ht(c.startTime)+" --\x3e "+Ht(c.endTime),e=[];switch(c.textAlign){case _.rd:e.push("align:left");break;case _.ke:e.push("align:right");break;case _.ug:e.push("align:middle");break;case _.rd:e.push("align:start");break;case _.ke:e.push("align:end")}switch(c.writingMode){case _.Pe:e.push("vertical:lr");break;
27
+ case _.Qe:e.push("vertical:rl")}b+=d+(e.length?" "+e.join(" "):"")+"\n";b+=c.payload+"\n\n"}return _.Ah(b)};It.prototype.probe=function(a,b){return a===_.ic&&b===_.De};It.prototype.create=function(a){return new Gt(a)};Jt.prototype.parseInit=function(a){var b=!1;(new _.Pk).L(_.Gd,_.Qk).L(_.Ge,_.Qk).L(_.Ad,_.Qk).L(_.Ed,_.Qk).L(_.ue,_.Qk).W(_.we,_.Rk).L("stpp",function(c){b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.L(_.M,2,2007);};
28
+ Jt.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Pk).L("moof",_.Qk).L("traf",_.Qk).W("subs",function(h){for(var l=_.T(h.reader),m=0;m<l;++m){h.reader.skip(4);for(var n=_.Kk(h.reader),p=0;p<n;++p){var q=1===h.version?_.T(h.reader):_.Kk(h.reader);g.push(q);h.reader.skip(6)}}}).L(_.zd,_.Sk(function(h){d=!0;h=c.a.parseMedia(h,b,g);e=e.concat(h.cues);f=f.concat(h.styles)})).parse(a);d||this.h.warn("Couldn't find the mdat box");return{cues:e,styles:f}};_.w(Kt,_.Ko);Kt.prototype.Ma=function(){_.bq[_.ic]=Ft;_.bq[_.gc]=Jt;_.bq[Ds]=Jt;_.bq[Fs]=Jt;_.bq[Es]=Jt;_.Vi.push(this.a)};Kt.prototype.Fa=function(){_.cq(_.ic);_.cq(_.gc);_.cq(Ds);_.cq(Fs);_.cq(Es);_.Xi(this.a)};Kt.prototype.id=function(){return _.Ae};_.C("clpp.ttml.TtmlComponent",Kt);};
29
29
  if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
30
30
  else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
31
31
  else{_=this.clpp._;(f.call(g,this));}