@castlabs/prestoplay 6.6.0 → 6.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +17 -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 +406 -406
  8. package/cjs/cl.crypto.js +8 -8
  9. package/cjs/cl.dash.js +71 -71
  10. package/cjs/cl.externs.js +17 -6
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +49 -48
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -30
  15. package/cjs/cl.ima.js +22 -22
  16. package/cjs/cl.mse.js +256 -257
  17. package/cjs/cl.muxdata.js +12 -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 +71 -70
  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 +19 -19
  28. package/cjs/cl.vtt.js +14 -14
  29. package/cjs/cl.youbora.js +20 -20
  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 +357 -356
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +66 -66
  38. package/cl.externs.js +17 -6
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +40 -40
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +16 -16
  44. package/cl.mse.js +199 -200
  45. package/cl.muxdata.js +8 -8
  46. package/cl.onboard.js +2 -2
  47. package/cl.persistent.js +9 -9
  48. package/cl.playlist.js +4 -4
  49. package/cl.smooth.js +59 -58
  50. package/cl.thumbnails.js +16 -16
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +12 -12
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +13 -13
  56. package/cl.vtt.js +11 -11
  57. package/cl.youbora.js +15 -15
  58. package/package.json +5 -1
  59. package/typings.d.ts +100 -96
@@ -1,28 +1,28 @@
1
1
  (function(){var g={}; var _ = _ || {}
2
- var f=function(window){var Mt="No thumbnail duration or URL specified",Nt="No thumbnail found for position ",Ot="Position is out of range: ",Pt="Thumbnail URL is mandatory",Qt="Wrong gridSize format",Rt="clpp.thumbnails",St=function(){this.log=new _.H(Rt);this.g=null;this.a=[];this.w=!1},Ut=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Kd&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return Tt(a,0,e,!!f)})},Promise.resolve())},Tt=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();
3
- var e=b+c;return Vt(a,d).then(function(){return a.a[b].load()}).then(function(){return Tt(a,e,c,d)})},Vt=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.an)c();else a.g.one(_.tc,function(){c()})})},Wt=function(a,b){return b>=a.time&&b<a.time+a.duration},Xt=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.Wh=h;this.Kj=l;this.ri=m;this.si=n;this.Pb=null},Yt=function(){St.call(this);this.f=null;this.o=this.h=1;this.j=0},Zt=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Uf=new _.Th},$t=function(){this.g=new _.H(Rt);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Th},au=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.Uf.resolve()})},cu=function(a,b){return bu(a,b).then(function(c){return new Xt(c,
5
- b.time,b.duration)})},bu=function(a,b){return b.load().then(function(){var c=_.N(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.ik(c)})},du=function(){St.call(this);this.f=null},eu=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},fu=function(){St.apply(this,arguments)},gu=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},hu=function(a,b){var c=a.horizontalTiles||
6
- b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{dd:c,gf:d,Nf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},iu=function(){this.f=new _.H(Rt);this.a=this.l=null},ju=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},ku=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},lu=function(){};St.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.fe,function(){c.w=!0});a.isLive()||this.m().then(function(){b&&b.preload&&Ut(c,b.preload)})};Xt.prototype.raw=function(){return this.ia.cloneNode(!1)};
7
- Xt.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(_.Xc);e.style.width=c+_.ce;e.style.height=d+_.ce;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))+_.ce;var f=this.y/this.height;e.style.backgroundPositionX="-"+this.x/this.width*c+_.ce;e.style.backgroundPositionY="-"+f*d+_.ce;return e};
9
- Xt.prototype.load=function(){var a=this;this.Pb||(this.Pb=new Promise(function(b,c){function d(){a.width||(a.width=(a.ia.naturalWidth||a.ia.width)/a.Wh);a.height||(a.height=(a.ia.naturalHeight||a.ia.height)/a.Kj);a.x||(a.x=a.width*a.ri);a.y||(a.y=a.height*a.si)}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(_.hd,e);b(a)};e=function(){a.ia.removeEventListener("load",f);a.ia.removeEventListener(_.hd,e);c()};a.ia.addEventListener("load",
10
- f);a.ia.addEventListener(_.hd,e);a.ia.src=a.src}}));return this.Pb};_.C("clpp.thumbnails.Thumbnail",Xt);Xt.prototype.load=Xt.prototype.load;Xt.prototype.element=Xt.prototype.element;Xt.prototype.raw=Xt.prototype.raw;_.v(Yt,St);
11
- Yt.prototype.init=function(a,b){if(!b||!b.url)throw new _.L(_.M,7,7100,Pt);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(Mt,c,d),new _.L(_.M,7,7100,Mt);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,Qt);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.L(_.M,7,7100,Qt);}St.prototype.init.call(this,a,b)};Yt.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(Ot+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Nt+a+" at index "+c)};
13
- Yt.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 Xt(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()};Zt.prototype.load=function(){return this.Uf};
14
- $t.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Pt);var d=b.url,e=_.Oh(d);e.type=_.Nh;a.getNetworkEngine().fetch(e).P.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,mu),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 Zt(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(){au(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))})};$t.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ot+a):this.h.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(Wt(d,a))return cu(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Nt+a)})};var mu=[137,66,73,70,13,10,26,10];_.v(du,St);
17
- du.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Pt);var d=b.url,e=_.Oh(d);e.type=_.Nh;this.f=a.getNetworkEngine().fetch(e).P.then(function(f){if(f=f.data){f=_.vh(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=eu(l[0]);l=eu(l[1])-r;c.a.push(new Xt(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))});St.prototype.init.call(this,a,b)};
19
- du.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ot+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Pc:c.Pc},d++)if(c.Pc=b.a[d],Wt(c.Pc,a))return c.Pc.load().then(function(e){return function(){return e.Pc}}(c));return Promise.reject(Nt+a)})};du.prototype.m=function(){return this.f};_.v(fu,St);
20
- fu.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=gu(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=hu(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.Nf+a]);else if((c=d.Ha())&&0<c.length){var g=0,h=0;d=d.startTime;1<e.Nf&&(g=a%e.dd,h=Math.floor(a/e.dd),d+=a*e.durationPerTile);f=new Xt(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.dd,e.gf,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()};fu.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
23
- fu.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.S(d=b.getSegmentReference(c++));)for(var e=hu(d,b),f=d.Ha()[0],g=new Image,h=d.startTime,l=0;l<e.gf;++l)for(var m=0;m<e.dd;++m)this.a.push(new Xt(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.dd,e.gf,m,l,g)),h+=e.durationPerTile;return Promise.resolve()};_.t=iu.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=ku(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new Yt:"WEBVTT"===c?this.a=new du:"BIF"===c&&(this.a=new $t)),this.a&&(this.f.info("Loading thumbs configuration",d),this.l.one(_.wd,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();ju(d)&&(this.a=new fu,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",iu);iu.prototype.get=iu.prototype.get;iu.Id="thumbnails";lu.prototype.create=function(){return new iu};_.Do(new lu);};
2
+ var f=function(window){var Nt="No thumbnail duration or URL specified",Ot="No thumbnail found for position ",Pt="Position is out of range: ",Qt="Thumbnail URL is mandatory",Rt="Wrong gridSize format",St="clpp.thumbnails",Tt=function(){this.log=new _.H(St);this.g=null;this.a=[];this.w=!1},Vt=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 Ut(a,0,e,!!f)})},Promise.resolve())},Ut=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();
3
+ var e=b+c;return Wt(a,d).then(function(){return a.a[b].load()}).then(function(){return Ut(a,e,c,d)})},Wt=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.bn)c();else a.g.one(_.vc,function(){c()})})},Xt=function(a,b){return b>=a.time&&b<a.time+a.duration},Yt=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.Th=h;this.Gj=l;this.ni=m;this.oi=n;this.Ob=null},Zt=function(){Tt.call(this);this.f=null;this.o=this.h=1;this.j=0},$t=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Tf=new _.Sh},au=function(){this.g=new _.H(St);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Sh},bu=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.Tf.resolve()})},du=function(a,b){return cu(a,b).then(function(c){return new Yt(c,
5
+ b.time,b.duration)})},cu=function(a,b){return b.load().then(function(){var c=_.N(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.jk(c)})},eu=function(){Tt.call(this);this.f=null},fu=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},gu=function(){Tt.apply(this,arguments)},hu=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},iu=function(a,b){var c=a.horizontalTiles||
6
+ b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{cd:c,ff:d,Mf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},ju=function(){this.f=new _.H(St);this.a=this.l=null},ku=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},lu=function(a){if(!a)return null;a=new _.pi(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},mu=function(){};Tt.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&&Vt(c,b.preload)})};Yt.prototype.raw=function(){return this.ja.cloneNode(!1)};
7
+ Yt.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(_.Zc);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
+ Yt.prototype.load=function(){var a=this;this.Ob||(this.Ob=new Promise(function(b,c){function d(){a.width||(a.width=(a.ja.naturalWidth||a.ja.width)/a.Th);a.height||(a.height=(a.ja.naturalHeight||a.ja.height)/a.Gj);a.x||(a.x=a.width*a.ni);a.y||(a.y=a.height*a.oi)}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.Ob};_.D("clpp.thumbnails.Thumbnail",Yt);Yt.prototype.load=Yt.prototype.load;Yt.prototype.element=Yt.prototype.element;Yt.prototype.raw=Yt.prototype.raw;_.v(Zt,Tt);
11
+ Zt.prototype.init=function(a,b){if(!b||!b.url)throw new _.L(_.M,7,7100,Qt);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(Nt,c,d),new _.L(_.M,7,7100,Nt);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,Rt);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.L(_.M,7,7100,Rt);}Tt.prototype.init.call(this,a,b)};Zt.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(Pt+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Ot+a+" at index "+c)};
13
+ Zt.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 Yt(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()};$t.prototype.load=function(){return this.Tf};
14
+ au.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Qt);var d=b.url,e=_.Nh(d);e.type=_.Mh;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,nu),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 $t(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(){bu(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))})};au.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Pt+a):this.h.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(Xt(d,a))return du(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Ot+a)})};var nu=[137,66,73,70,13,10,26,10];_.v(eu,Tt);
17
+ eu.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Qt);var d=b.url,e=_.Nh(d);e.type=_.Mh;this.f=a.getNetworkEngine().fetch(e).O.then(function(f){if(f=f.data){f=_.vh(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=fu(l[0]);l=fu(l[1])-r;c.a.push(new Yt(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))});Tt.prototype.init.call(this,a,b)};
19
+ eu.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Pt+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Oc:c.Oc},d++)if(c.Oc=b.a[d],Xt(c.Oc,a))return c.Oc.load().then(function(e){return function(){return e.Oc}}(c));return Promise.reject(Ot+a)})};eu.prototype.m=function(){return this.f};_.v(gu,Tt);
20
+ gu.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=hu(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=iu(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.Mf+a]);else if((c=d.Ga())&&0<c.length){var g=0,h=0;d=d.startTime;1<e.Mf&&(g=a%e.cd,h=Math.floor(a/e.cd),d+=a*e.durationPerTile);f=new Yt(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.cd,e.ff,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()};gu.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
23
+ gu.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=iu(d,b),f=d.Ga()[0],g=new Image,h=d.startTime,l=0;l<e.ff;++l)for(var m=0;m<e.cd;++m)this.a.push(new Yt(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.cd,e.ff,m,l,g)),h+=e.durationPerTile;return Promise.resolve()};_.t=ju.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=lu(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new Zt:"WEBVTT"===c?this.a=new eu:"BIF"===c&&(this.a=new au)),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();ku(d)&&(this.a=new gu,this.a.init(a,c))}};_.t.get=function(a){return this.a?this.a.get(a):Promise.reject()};_.t.id=function(){return"thumbnails"};_.D("clpp.thumbnails.ThumbnailsPlugin",ju);ju.prototype.get=ju.prototype.get;ju.Id="thumbnails";mu.prototype.create=function(){return new ju};_.Eo(new mu);};
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 YE="An unknown error occurred while trying to get volume",ZE="Cannot get loading rendition due to platform limitations",$E="PARAM_START_POSITION",aF="SecurityError",bF="The require privilege is: http://tizen.org/privilege/tv.audio",cF="|STARTBITRATE\x3d",dF=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},eF=function(a,b){this.h=a;this.o=null;this.a=_.Jd;this.m=null;this.j=!1;this.f=new Map;this.C=b;this.g=new _.H("clpp.tizen.DrmEngine")},hF=function(a){var b,
3
- c,d;return _.B(function(e){if(1==e.a){b=a.a===_.Rc||a.a===_.Qc;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.hd)throw new _.L(_.M,6,6012,"No license server given for "+a.a);_.zf(e,2);return a.a===_.Rc?_.x(e,fF(a),5):_.x(e,gF(a,c),5)}if(2!=e.a)return a.o={keySystem:a.a,licenseServerUri:c.hd,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Qe,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)});})},gF=function(a,b){var c,d,e,f;return _.B(function(g){c=iF;d=jF;e={};e[d.Bg]=!b.Qe;e[d.Cg]=b.hd;""!==b.customData&&(e[d.Ag]=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)})},fF=function(a){var b;return _.B(function(c){b=iF;try{webapis.avplay.setDrm(b.sd,
5
- "Initialize",""),webapis.avplay.setDrm(b.sd,"widevine_app_session",a.m.id),webapis.avplay.setDrm(b.sd,"widevine_data_type",a.m.type)}catch(d){throw d;}_.z(c)})},kF=function(a,b){var c,d,e,f,g,h,l,m,n,p,q,r,w,y,A,E,F;_.B(function(D){if(1==D.a){c=iF;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.hd;l=_.Oh([h],_.Lh());l.type=3;l.body=f.buffer;l.method=
6
- "POST";_.zf(D,2);return _.x(D,a.C.Ab.fetch(l).P,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+$E+(w+$E);a.g.debug("Widevine license params",y);try{webapis.avplay.setDrm(c.sd,"widevine_license_data",y)}catch(I){a.g.error("License response rejected by CDM"),A=new _.L(_.M,6,6008,{browserError:JSON.stringify(I)}),a.C.onError(A)}}return _.Af(D,0)}E=_.Bf(D);a.g.error("License request failed.",JSON.stringify(E));F=new _.L(_.M,
7
- 6,6007,{message:_.Ia,url:E.data.url,status:E.data.status||NaN,response:E.data.response||"",headers:E.data.headers||{}},E);a.C.onError(F);_.z(D)})},lF=function(a){this.l=a;this.a=this.l.a;this.f=_.Wm;this.j=_.Xm;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.H("clpp.tizen.StateManager")},nF=function(a,b){if(a.f!==b)if(a.f===_.gn&&b!==_.Wm)a.g.debug(_.cv+mF(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.an?(a.o=(new Date).getTime(),a.l.trigger(new _.J(_.uc,{detail:{bufferedTimeMS:-1,
8
- reason:a.h}}))):a.j===_.an&&a.l.trigger(new _.J(_.tc,{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 _.J(_.se,{detail:d}));a.g.debug("State changed:",mF(a.j),"-\x3e",mF(a.f))}},mF=function(a){return Object.keys(_.en)[a]},qF=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case oF:c=_.kn;break;case pF:c=_.jn;break;default:a.l.isEnded()?c=_.cn:a.g.debug("Inconsistent AVPlay playback state:",b)}nF(a,
9
- c)}},rF=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")},sF=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},tF=function(a){var b,c;return _.B(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.x(d,_.Cp(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
- uF=function(a){var b=document.createElement(_.Re),c=new _.Kw,d=new _.Vv(function(){return null}),e=a.l.getTextDisplayer();return new _.Qw(b,c,e,d,a.l.getConfiguration())},vF=function(a){var b={wb:function(){return a.l.getPosition()},X:a.h,Ab:a.l.getNetworkEngine(),Je:a.Oh.bind(a),Ie:a.Nh.bind(a),onError:a.U.bind(a),cg:function(){},onEvent:function(){},hg:a.Ph.bind(a),Pd:function(){},re:function(){return new _.Tx},fe:function(){return!1},bd:null};return new _.Ny(a.f,b)},wF=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},xF=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||_.vv;var f=new _.pi(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},yF=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.Py(a.g,_.Ce),c=null;if(b){a=xF(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},zF=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=wF(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):(_.$y(a.g,c,!0,0),a.l.trigger(new _.J(_.Lj))),a.o=c.language):a.a.error(_.bv,d.id)}},AF=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},BF=function(a,b){a.l.trigger(new _.J(_.Ve,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},
14
- CF=function(a){var b=a.ga();b&&a.l.trigger(new _.J(_.rc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},DF=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=_.Pv(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")},HF=function(a,b){if(b){var c=b.track.type.toUpperCase();EF(a.f,c,Number(b.id)).then(function(){c===FF&&(a.j=b,a.l.trigger(new _.J(_.Kj)));c===GF&&(a.m=b,a.l.trigger(new _.J(_.Lj)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},IF=
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=_.oc;a=new _.pi(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},JF=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},KF=function(a,b,c){b=_.Ki(b.track_lang||_.Ie);c.mimeType="text/ttml";c.language=
17
- _.ii(b);c.kind=_.vv;return new _.pi(String(a),c)},LF=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},OF=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===MF}),f=b.filter(function(n){return n.type===FF}),g=[],h=0;h<f.length;h++){var l=LF(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(IF(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=LF(a,e[h].extra_info))?f.renditions.push(JF(e[h].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?xF(a.h):NF(a,b);d[_.ji]=[f];d[_.Q]=g;d[_.P]=e;return d},NF=function(a,b){for(var c=b.filter(function(h){return h.type===GF}),d=[],e=0;e<c.length;e++){var f=LF(a,
19
- c[e].extra_info);if(f){var g=new _.hi(String(a.o++),_.P);g.renditions.push(KF(c[e].index,f,g));d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},PF=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.va(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},QF=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},SF=function(a,b){if(b===_.P&&a.h)return yF(a.h);var c=RF(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=LF(a,c.extra_info),d=PF(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=QF(a,c,_.Q),a.j=d):d=a.j);b===_.P&&(c?(d=QF(a,c,_.P),a.m=d):d=a.m);return d},TF=function(a){_.Rj.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={}},UF=function(a){return _.B(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)})},WF=function(a){try{webapis.avplay.setListener({onbufferingstart:a.Ih.bind(a),onbufferingprogress:a.Hh.bind(a),onbufferingcomplete:a.Gh.bind(a),onstreamcompleted:a.Lh.bind(a),oncurrentplaytime:function(b){a.trigger(new _.J(VF,
22
- {currentTime:b}))},onevent:a.Kh.bind(a),onsubtitlechange:a.Mh.bind(a),ondrmevent:a.Jh.bind(a),onerror:a.U.bind(a)})}catch(b){a.a.error(b)}},XF=function(a){var b=!!a.l.getTrackManager().Ga();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.a.debug("Could not set AVPlay subtitle config",c)}},YF=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,rk:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",cF+d)}catch(e){a.a.debug(e)}},
23
- ZF=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+cF+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},bG=function(a){return{position:a.getPosition(),state:a.l.getState(),nf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:$F(a),volume:a.getVolume(),Sj:aG(a),Zh:RF(a)}},dG=function(a){var b,c;return _.B(function(d){if(1==d.a)return _.x(d,cG(),2);if(3!=d.a)return b=new Promise(function(e){(new _.Ri(e)).Z(5)}),
24
- _.x(d,Promise.race([UF(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)})},jG=function(a,b,c){var d,e,f,g,h,l,m,n;return _.B(function(p){switch(p.a){case 1:a.m=_.on(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 _.J(eG)),f=c.currentPosition);
25
- _.zf(p,2);g=a.m[d].url;h=a.m[d].type;h!==_.cc||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);e.nextBandwidth?(ZF(a,e.nextBandwidth),a.o=!1):(a.o||YF(a,e),a.o=!0);WF(a);if(!b.drm||!b.drm.env){a.a.debug("No DRM configuration was provided. Assuming clear content");p.H(4);break}m={onError:function(q){return a.l.onError(q)},Ab:a.l.getNetworkEngine()};a.h=new eF(b.drm,m);return _.x(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.J(fG)),
26
- _.x(p,gG(a),6);case 6:a.g||a.trigger(new _.J(hG));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&&iG(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;}})},gG=function(a){return _.B(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
- XF(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)}}))})},kG=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=bG(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.f.nf;a.g=!1;a.f=
28
- null;return e===pF?a.pause():a.play()})}catch(e){return Promise.reject(e)}},aG=function(a){return a.g&&a.f?a.f.Sj:webapis.avplay.getTotalTrackInfo()},RF=function(a){return a.g&&a.f?a.f.Zh:webapis.avplay.getCurrentStreamInfo()},EF=function(a,b,c){b=b.toUpperCase();b===GF&&lG(a,!0);var d=a.j[b];d&&(d.Rd.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,lf:0,Rd:new _.Ri(function(){return g(h,c,!0)})}),(l=a.j[h])&&3>l.lf?(!a.w&&++l.lf,l.Rd.Z(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Rd.stop(),a.j[h]=null,f())}}g(b,c)})},lG=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)}},iG=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case aF:a.a.warn("The application does not have the privilege to set mute.",bF);break;default:a.a.warn(YE,c)}}},$F=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case aF:a.a.warn("The application doesn't have the privilege to get the mute state.",bF);break;default:a.a.warn(YE,c)}}return!!b},cG=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
31
- dF(c,"load",function(d){return a(d)});dF(c,_.hd,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},mG=function(){_.Rj.call(this);this.a=new TF(this);this.f=new lF(this);this.configuration=this.B=_.Xj();this.w=null;this.h=new _.H("clpp.tizen.Player");this.j=null;this.m=new AF;this.D=new _.ei;this.o=this.g=null;this.A=!1},nG=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())},oG=function(){},pG=function(){this.a=null};
33
- eF.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.B(function(h){if(1==h.a){b=_.tk[a.h.env]||null;if(!b)throw a.g.debug(_.xa,_.hb+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=_.vk(b,a.h.customData);(e=d[_.Qc])&&a.f.set(_.Qc,{hd:e.licenseUrl||"",customData:c,Qe:!1});(f=d[_.Rc])&&a.f.set(_.Rc,{hd:f.licenseUrl||"",customData:c,
34
- Qe:!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(_.Qc))a.a=_.Qc;else if(a.f.get(_.Rc))a.a=_.Rc;else throw new _.L(_.M,6,6001,"Configuration for the target system is missing.");return _.x(h,hF(a),2)}a.j=!0;_.z(h)})};eF.prototype.release=function(){var a=this;return _.B(function(b){a.j=!1;a.o=null;a.a=_.Jd;a.m=null;a.f=new Map;_.z(b)})};eF.prototype.getDrmInfo=function(){return this.o};
35
- var jF={Bg:"DeleteLicenseAfterUse",Cg:"LicenseServer",dk:"GetChallenge",ek:"HttpHeader",hk:"UserAgent",$j:"Cookie",Ag:"CustomData"};_.t=lF.prototype;_.t.initialize=function(){this.a.on(eG,this.Bf,this);this.a.on(qG,this.Af,this);this.a.on(rG,this.zf,this);this.a.on(fG,this.jg,this);this.a.on(hG,this.ig,this);this.a.on(sG,this.Cf,this)};_.t.release=function(){nF(this,_.Wm);this.m=!1;this.o=-1;this.h=2};_.t.destroy=function(){this.release();this.a.off(eG,this.Bf);this.a.off(qG,this.Af);this.a.off(rG,this.zf);this.a.off(fG,this.jg);this.a.off(hG,this.ig);this.a.off(sG,this.Cf);this.l=this.a=null};
36
- _.t.Bf=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;nF(this,_.an)};_.t.Af=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",mF(this.f))};_.t.zf=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()===tG;if(!a&&b){nF(this,_.jn);return}}if(a=this.f!==_.hn)a=this.a.getState(),a=a===oF||a===pF;a&&qF(this)};
37
- _.t.jg=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===uG?nF(this,_.hn):this.g.error("AVPlay prepares while state is not IDLE")};_.t.ig=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.Cf=function(){nF(this,_.cn)};_.t.getState=function(){return this.f};_.t=rF.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.a.debug("Text streamer is not initialized. Will not load()"),m["return"]();b.B=a;c=b;return _.x(m,tF(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||!sF(b.f)){m.H(0);break}b.h=uF(b);_.zf(m,10);return _.x(m,b.h.I,12);case 12:b.g=vF(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.Oh=function(a){this.a.debug(_.ov,a);this.w=!0;var b=_.vx(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.Nh=function(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.$y(this.g,this.m,!0,0),this.m=null)};_.t.U=function(){this.a.debug("onError_")};_.t.Ph=function(){this.j&&this.j.update&&this.j.update()};
41
- _.t.start=function(){var a=this;return _.B(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 _.B(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 _.B(function(b){switch(b.a){case 1:if(!a.j){b.H(2);break}return _.x(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.g){b.H(4);break}return _.x(b,a.g.destroy(),5);case 5:a.g=null,a.w=!0;case 4:if(!a.h){b.H(0);break}return _.x(b,a.h.destroy(),7);case 7:a.h=null,_.z(b)}})};_.v(AF,_.R);_.t=AF.prototype;_.t.$f=function(a){var b=a.eventid;a=a.data;switch(b){case vG:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+LF(this,b[0].extra_info).Bit_rate,b=PF(this,{bandwidth:b}))&&(this.w=b,BF(this,b));break;case wG:CF(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.t.Me=function(a){a.detail.currentState===_.kn&&this.l.off(_.se,this.Me)};
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===_.kn&&(b.a.debug("Current state",c.currentState),b.A=!0,DF(b)))});this.f.on(xG,this.$f,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.Me);this.l.on(_.se,this.Me,this);try{var a=aG(this.f);this.g=OF(this,a);var b=this.g[_.Q]||[];b.length&&(this.j=b[0].renditions[0]||null);CF(this)}catch(c){this.a.debug("Could not load track manager")}}};_.t.destroy=function(){this.f.off(xG,this.$f);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 SF(this,_.ji)};_.t.Fa=function(){return SF(this,_.Q)};_.t.Ga=function(){return SF(this,_.P)};_.t.Ua=function(){return this.w};_.t.fb=function(){this.a.info(ZE);return null};_.t.gb=function(){this.a.info(ZE);return null};_.t.Ia=function(){var a=this.ga();return a?a.track:null};_.t.ma=function(){var a=this.Fa();return a?a.track:null};_.t.na=function(){var a=this.Ga();return a?a.track:null};
46
- _.t.ab=function(a){var b=this;null===a?(a=this.ga(),kG(this.f,a.bandwidth,null).then(function(){CF(b)})):0<a.renditions.length&&this.$a(a.renditions[0])};_.t.sa=function(a){a?HF(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.t.Ba=function(a){a?(a=a.renditions[0],this.h?zF(this.h,a.track):HF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,lG(this.f,!1),this.l.trigger(new _.J(_.Lj)))};
47
- _.t.$a=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,BF(this,a),kG(this.f,c.bandwidth,a.bandwidth).then(function(){CF(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.mb=function(a){HF(this,a)};_.t.nb=function(a){this.h?zF(this.h,a.track):HF(this,a)};
48
- _.t.addTextTrack=function(){};_.t.ja=function(){return this.f.o};AF.prototype.isAbrEnabled=AF.prototype.ja;AF.prototype.addTextTrack=AF.prototype.addTextTrack;AF.prototype.setTextRendition=AF.prototype.nb;AF.prototype.setAudioRendition=AF.prototype.mb;AF.prototype.setVideoRendition=AF.prototype.$a;AF.prototype.setTextTrack=AF.prototype.Ba;AF.prototype.setAudioTrack=AF.prototype.sa;AF.prototype.setVideoTrack=AF.prototype.ab;AF.prototype.getTextTrack=AF.prototype.na;AF.prototype.getAudioTrack=AF.prototype.ma;
49
- AF.prototype.getVideoTrack=AF.prototype.Ia;AF.prototype.getLoadingTextRendition=AF.prototype.gb;AF.prototype.getLoadingAudioRendition=AF.prototype.fb;AF.prototype.getLoadingVideoRendition=AF.prototype.Ua;AF.prototype.getTextRendition=AF.prototype.Ga;AF.prototype.getAudioRendition=AF.prototype.Fa;AF.prototype.getVideoRendition=AF.prototype.ga;AF.prototype.getTextTracks=AF.prototype.ha;AF.prototype.getAudioTracks=AF.prototype.getAudioTracks;AF.prototype.getVideoTracks=AF.prototype.getVideoTracks;_.v(TF,_.Rj);_.t=TF.prototype;_.t.Ih=function(){this.w=!0;this.g||this.trigger(new _.J(eG))};_.t.Hh=function(a){this.w=!0;this.trigger(new _.J(qG,{percent:a}))};_.t.Gh=function(){this.w=!1;this.trigger(new _.J(rG))};_.t.Lh=function(){this.trigger(new _.J(sG))};_.t.Kh=function(a,b){this.trigger(new _.J(xG,{eventid:a,data:b}))};_.t.Mh=function(a,b,c,d,e){this.trigger(new _.J(yG,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
- _.t.Jh=function(a,b){this.trigger(new _.J(zG,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Rc&&"Challenge"===b.name)kF(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.U=function(a){this.trigger(new _.J(AG,{eventType:a}))};
51
- _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(VF,f,b);g=setTimeout(function(){b.off(VF,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===uG)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){XF(b);d(webapis.avplay.play())},function(f){b.trigger(new _.J(AG));e(f)})})).then(function(){return a()});if(c===pF||c===tG)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===oF?
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()===pF?Promise.resolve():Promise.reject()};
53
- _.t.setPlaybackRate=function(a){var b=this.getState();if(b===tG||b===oF||b===pF){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 _.B(function(e){switch(e.a){case 1:return c.a.debug("configure()",b||""),_.zf(e,2),_.x(e,dG(c),4);case 4:return _.x(e,jG(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.nf;try{return webapis.avplay.getState()}catch(a){this.U(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 _.J(_.Ne));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.J(_.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.U(JSON.stringify(a))}};_.t.getDuration=function(){if(this.g&&this.f)return this.f.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.U(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.Rd.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 aF:this.a.debug("The application does not have the privilege to get the volume.",bF);break;default:this.a.debug(YE,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 aF:this.a.warn("The application does not have the privilege to set the volume.",bF);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.U(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 uG="IDLE",tG="READY",oF="PLAYING",pF="PAUSED",MF="VIDEO",FF="AUDIO",GF="TEXT",wG="PLAYER_MSG_RESOLUTION_CHANGED",vG="PLAYER_MSG_BITRATE_CHANGE",iF={PLAYREADY:"PLAYREADY",ak:"EME_PLAYREADY",ik:"VERIMATRIX",sd:"WIDEVINE_CDM",bk:"EME_WIDEVINE_CDM",jk:"WIDEVINE_CLASSIC"};_.v(mG,_.Rj);_.t=mG.prototype;_.t.xf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.J(_.gd));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.t.vf=function(a){this.trigger(new _.J(_.Fe,{currentTime:a.currentTime/1E3}))};
60
- _.t.yf=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=_.Ih(d))&&this.o.append([new _.zg(b,c,d)],[])};_.t.wf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.bg=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
- _.t.U=function(a){this.h.debug("Error: TYPE: "+a.eventType);nF(this.f,_.gn);a=new _.L(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.J(_.hd,{detail:a}))};
62
- _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(sG,this.xf,this);this.a.on(VF,this.vf,this);this.a.on(yG,this.yf,this);this.a.on(zG,this.wf,this);this.a.on(AG,this.U,this);this.a.on(rG,this.bg,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=BG;BG+=1;this.j=_.Gn(_.Kd,{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,_.kd,"position",_.qd,"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];_.In(c,f);nG(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(sG,a.xf);a.a.off(VF,a.vf);a.a.off(yG,a.yf);a.a.off(zG,a.wf);a.a.off(AG,a.U);a.a.off(rG,a.bg);if(!a.g){b.H(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 CG};_.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()===_.cn?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(_.sa);return new _.Qj};_.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.H(2);break}return _.x(b,a.g.release(),2);case 2:if(!a.o){b.H(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:_.ak(a)&&(b.configuration=_.Zj(b.B,a));c=_.Km(b.configuration,["html","native"]);b.o=c.create(b);d=_.on(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.H(2);break}b.g=new rF;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 _.J(_.Yd));nG(this);return this.a.play().then(function(){qF(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){qF(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.J(_.hd,{detail:a});a.severity===_.M&&(nF(this.f,_.gn),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()===_.cn};_.t.isPaused=function(){return this.a.getState()===pF};_.t.isMuted=function(){return $F(this.a)};_.t.setMuted=function(a){iG(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 oG).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};mG.prototype.getTextDisplayer=mG.prototype.getTextDisplayer;mG.prototype.setNetworkEngine=mG.prototype.setNetworkEngine;mG.prototype.getNetworkEngine=mG.prototype.getNetworkEngine;var CG="clpp.tizen",BG=0;oG.prototype.a=function(){return CG};
72
- oG.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.cc||a===_.Bj||a===_.hc)&&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};oG.prototype.create=function(){return new mG};_.v(pG,_.Io);pG.prototype.Ja=function(){this.a=new oG;_.ag(this.a)};pG.prototype.Ca=function(){if(this.a){var a=this.a.a();a&&_.Xf[a]&&(delete _.Xf[a],_.$f.info("Removed Player factory: '"+a+"'"));this.a=null}};pG.prototype.id=function(){return"tizen"};_.C("clpp.tizen.TizenComponent",pG);var eG="onbufferingstart",qG="onbufferingprogress",rG="onbufferingcomplete",sG="onstreamcompleted",VF="oncurrentplaytime",xG="onevent",yG="onsubtitlechange",zG="ondrmevent",AG="onerror",fG="preparingstart",hG="preparingend";};
2
+ var f=function(window){var aF="An unknown error occurred while trying to get volume",bF="Cannot get loading rendition due to platform limitations",cF="PARAM_START_POSITION",dF="SecurityError",eF="The require privilege is: http://tizen.org/privilege/tv.audio",fF="|STARTBITRATE\x3d",gF=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},hF=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")},kF=function(a){var b,
3
+ c,d;return _.A(function(e){if(1==e.a){b=a.a===_.Tc||a.a===_.Sc;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===_.Tc?_.x(e,iF(a),5):_.x(e,jF(a,c),5)}if(2!=e.a)return a.o={keySystem:a.a,licenseServerUri:c.gd,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Pe,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)});})},jF=function(a,b){var c,d,e,f;return _.A(function(g){c=lF;d=mF;e={};e[d.zg]=!b.Pe;e[d.Ag]=b.gd;""!==b.customData&&(e[d.yg]=b.customData);f=JSON.stringify(e);a.g.debug("PlayReady properties: ",f);try{webapis.avplay.setDrm(c.PLAYREADY,"SetProperties",f)}catch(h){throw h;}_.y(g)})},iF=function(a){var b;return _.A(function(c){b=lF;try{webapis.avplay.setDrm(b.sd,
5
+ "Initialize",""),webapis.avplay.setDrm(b.sd,"widevine_app_session",a.m.id),webapis.avplay.setDrm(b.sd,"widevine_data_type",a.m.type)}catch(d){throw d;}_.y(c)})},nF=function(a,b){var c,d,e,f,g,h,l,m,n,p,q,r,w,z,C,E,F;_.A(function(B){if(1==B.a){c=lF;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=_.Nh([h],_.Kh());l.type=3;l.body=f.buffer;l.method=
6
+ "POST";_.zf(B,2);return _.x(B,a.C.zb.fetch(l).O,4)}if(2!=B.a){m=B.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);z=b.session_id+cF+(w+cF);a.g.debug("Widevine license params",z);try{webapis.avplay.setDrm(c.sd,"widevine_license_data",z)}catch(I){a.g.error("License response rejected by CDM"),C=new _.L(_.M,6,6008,{browserError:JSON.stringify(I)}),a.C.onError(C)}}return _.Af(B,0)}E=_.Bf(B);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);_.y(B)})},oF=function(a){this.l=a;this.a=this.l.a;this.f=_.Xm;this.j=_.Ym;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.H("clpp.tizen.StateManager")},qF=function(a,b){if(a.f!==b)if(a.f===_.hn&&b!==_.Xm)a.g.debug(_.dv+pF(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.bn?(a.o=(new Date).getTime(),a.l.trigger(new _.J(_.wc,{detail:{bufferedTimeMS:-1,
8
+ reason:a.h}}))):a.j===_.bn&&a.l.trigger(new _.J(_.vc,{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 _.J(_.se,{detail:d}));a.g.debug("State changed:",pF(a.j),"-\x3e",pF(a.f))}},pF=function(a){return Object.keys(_.fn)[a]},tF=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case rF:c=_.ln;break;case sF:c=_.kn;break;default:a.l.isEnded()?c=_.dn:a.g.debug("Inconsistent AVPlay playback state:",b)}qF(a,
9
+ c)}},uF=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")},vF=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},wF=function(a){var b,c;return _.A(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.x(d,_.Dp(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
+ xF=function(a){var b=document.createElement(_.Re),c=new _.Lw,d=new _.Wv(function(){return null}),e=a.l.getTextDisplayer();return new _.Rw(b,c,e,d,a.l.getConfiguration())},yF=function(a){var b={vb:function(){return a.l.getPosition()},W:a.h,zb:a.l.getNetworkEngine(),Ie:a.Lh.bind(a),He:a.Kh.bind(a),onError:a.T.bind(a),bg:function(){},onEvent:function(){},gg:a.Mh.bind(a),Pd:function(){},re:function(){return new _.Ux},ee:function(){return!1},$c:null};return new _.Oy(a.f,b)},zF=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},AF=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 _.gi(String(c++),_.P);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=
12
+ a[d].kind||_.wv;var f=new _.oi(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},BF=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=AF(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},CF=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=zF(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 _.J(_.Mj))),a.o=c.language):a.a.error(_.cv,d.id)}},DF=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},EF=function(a,b){a.l.trigger(new _.J(_.Ve,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},
14
+ FF=function(a){var b=a.ha();b&&a.l.trigger(new _.J(_.tc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},GF=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=_.Qv(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")},KF=function(a,b){if(b){var c=b.track.type.toUpperCase();HF(a.f,c,Number(b.id)).then(function(){c===IF&&(a.j=b,a.l.trigger(new _.J(_.Lj)));c===JF&&(a.m=b,a.l.trigger(new _.J(_.Mj)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},LF=
16
+ function(a,b,c){var d=_.Ji(b.language||_.Ie);c.language=_.hi(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.qc;a=new _.oi(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},MF=function(a,b,c){c.mimeType=_.Te;a=new _.oi(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},NF=function(a,b,c){b=_.Ji(b.track_lang||_.Ie);c.mimeType="text/ttml";c.language=
17
+ _.hi(b);c.kind=_.wv;return new _.oi(String(a),c)},OF=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},RF=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===PF}),f=b.filter(function(n){return n.type===IF}),g=[],h=0;h<f.length;h++){var l=OF(a,f[h].extra_info);if(l){var m=_.Ji(l.language||_.Ie);
18
+ m=_.hi(m);m=c(g,m);m||(m=new _.gi(String(a.o++),_.Q),g.push(m));m.renditions.push(LF(f[h].index,l,m))}else a.a.warn("Skipping audio stream with no extra info")}f=new _.gi(String(a.o++),_.ii);for(h=0;h<e.length;h++)(l=OF(a,e[h].extra_info))?f.renditions.push(MF(e[h].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?AF(a.h):QF(a,b);d[_.ii]=[f];d[_.Q]=g;d[_.P]=e;return d},QF=function(a,b){for(var c=b.filter(function(h){return h.type===JF}),d=[],e=0;e<c.length;e++){var f=OF(a,
19
+ c[e].extra_info);if(f){var g=new _.gi(String(a.o++),_.P);g.renditions.push(NF(c[e].index,f,g));d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},SF=function(a,b){for(var c=a.g[_.ii]||[],d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].renditions.length;f++)_.K.va(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},TF=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},VF=function(a,b){if(b===_.P&&a.h)return BF(a.h);var c=UF(a.f)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.ii&&(d=OF(a,c.extra_info),d=SF(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=TF(a,c,_.Q),a.j=d):d=a.j);b===_.P&&(c?(d=TF(a,c,_.P),a.m=d):d=a.m);return d},WF=function(a){_.Sj.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={}},XF=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;});_.y(b)})},ZF=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 _.J(YF,
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)}},$F=function(a){var b=!!a.l.getTrackManager().Fa();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.a.debug("Could not set AVPlay subtitle config",c)}},aG=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",fF+d)}catch(e){a.a.debug(e)}},
23
+ bG=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+fF+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},eG=function(a){return{position:a.getPosition(),state:a.l.getState(),mf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:cG(a),volume:a.getVolume(),Oj:dG(a),Wh:UF(a)}},gG=function(a){var b,c;return _.A(function(d){if(1==d.a)return _.x(d,fG(),2);if(3!=d.a)return b=new Promise(function(e){(new _.Si(e)).Z(5)}),
24
+ _.x(d,Promise.race([XF(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"));_.y(d)})},mG=function(a,b,c){var d,e,f,g,h,l,m,n;return _.A(function(p){switch(p.a){case 1:a.m=_.pn(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 _.J(hG)),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?(bG(a,e.nextBandwidth),a.o=!1):(a.o||aG(a,e),a.o=!0);ZF(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 hF(b.drm,m);return _.x(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.J(iG)),
26
+ _.x(p,jG(a),6);case 6:a.g||a.trigger(new _.J(kG));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&&lG(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;}})},jG=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
+ $F(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)}}))})},nG=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=eG(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.f.mf;a.g=!1;a.f=
28
+ null;return e===sF?a.pause():a.play()})}catch(e){return Promise.reject(e)}},dG=function(a){return a.g&&a.f?a.f.Oj:webapis.avplay.getTotalTrackInfo()},UF=function(a){return a.g&&a.f?a.f.Wh:webapis.avplay.getCurrentStreamInfo()},HF=function(a,b,c){b=b.toUpperCase();b===JF&&oG(a,!0);var d=a.j[b];d&&(d.Rd.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,kf:0,Rd:new _.Si(function(){return g(h,c,!0)})}),(l=a.j[h])&&3>l.kf?(!a.w&&++l.kf,l.Rd.Z(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Rd.stop(),a.j[h]=null,f())}}g(b,c)})},oG=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)}},lG=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case dF:a.a.warn("The application does not have the privilege to set mute.",eF);break;default:a.a.warn(aF,c)}}},cG=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case dF:a.a.warn("The application doesn't have the privilege to get the mute state.",eF);break;default:a.a.warn(aF,c)}}return!!b},fG=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
31
+ gF(c,"load",function(d){return a(d)});gF(c,_.jd,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},pG=function(){_.Sj.call(this);this.a=new WF(this);this.f=new oF(this);this.configuration=this.B=_.Yj();this.w=null;this.h=new _.H("clpp.tizen.Player");this.j=null;this.m=new DF;this.D=new _.di;this.o=this.g=null;this.A=!1},qG=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())},rG=function(){},sG=function(){this.a=null};
33
+ hF.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.A(function(h){if(1==h.a){b=_.uk[a.h.env]||null;if(!b)throw a.g.debug(_.wa,_.gb+a.h.env+_.aa),new _.L(_.M,6,6015,_.xa+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=_.wk(b,a.h.customData);(e=d[_.Sc])&&a.f.set(_.Sc,{gd:e.licenseUrl||"",customData:c,Pe:!1});(f=d[_.Tc])&&a.f.set(_.Tc,{gd:f.licenseUrl||"",customData:c,
34
+ Pe:!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(_.Sc))a.a=_.Sc;else if(a.f.get(_.Tc))a.a=_.Tc;else throw new _.L(_.M,6,6001,"Configuration for the target system is missing.");return _.x(h,kF(a),2)}a.j=!0;_.y(h)})};hF.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;_.y(b)})};hF.prototype.getDrmInfo=function(){return this.o};
35
+ var mF={zg:"DeleteLicenseAfterUse",Ag:"LicenseServer",$j:"GetChallenge",ak:"HttpHeader",dk:"UserAgent",Wj:"Cookie",yg:"CustomData"};_.t=oF.prototype;_.t.initialize=function(){this.a.on(hG,this.Af,this);this.a.on(tG,this.zf,this);this.a.on(uG,this.yf,this);this.a.on(iG,this.ig,this);this.a.on(kG,this.hg,this);this.a.on(vG,this.Bf,this)};_.t.release=function(){qF(this,_.Xm);this.m=!1;this.o=-1;this.h=2};_.t.destroy=function(){this.release();this.a.off(hG,this.Af);this.a.off(tG,this.zf);this.a.off(uG,this.yf);this.a.off(iG,this.ig);this.a.off(kG,this.hg);this.a.off(vG,this.Bf);this.l=this.a=null};
36
+ _.t.Af=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;qF(this,_.bn)};_.t.zf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",pF(this.f))};_.t.yf=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()===wG;if(!a&&b){qF(this,_.kn);return}}if(a=this.f!==_.jn)a=this.a.getState(),a=a===rF||a===sF;a&&tF(this)};
37
+ _.t.ig=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===xG?qF(this,_.jn):this.g.error("AVPlay prepares while state is not IDLE")};_.t.hg=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.Bf=function(){qF(this,_.dn)};_.t.getState=function(){return this.f};_.t=uF.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,wF(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||!vF(b.f)){m.G(0);break}b.h=xF(b);_.zf(m,10);return _.x(m,b.h.H,12);case 12:b.g=yF(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,_.y(m)}})};_.t.Lh=function(a){this.a.debug(_.pv,a);this.w=!0;var b=_.wx(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)}_.y(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;_.y(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,_.y(b)}})};_.v(DF,_.R);_.t=DF.prototype;_.t.Zf=function(a){var b=a.eventid;a=a.data;switch(b){case yG:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+OF(this,b[0].extra_info).Bit_rate,b=SF(this,{bandwidth:b}))&&(this.w=b,EF(this,b));break;case zG:FF(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.t.Le=function(a){a.detail.currentState===_.ln&&this.l.off(_.se,this.Le)};
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===_.ln&&(b.a.debug("Current state",c.currentState),b.A=!0,GF(b)))});this.f.on(AG,this.Zf,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.Le);this.l.on(_.se,this.Le,this);try{var a=dG(this.f);this.g=RF(this,a);var b=this.g[_.Q]||[];b.length&&(this.j=b[0].renditions[0]||null);FF(this)}catch(c){this.a.debug("Could not load track manager")}}};_.t.destroy=function(){this.f.off(AG,this.Zf);this.f=this.l=null};_.t.getVideoTracks=function(){return this.g[_.ii]||[]};_.t.getAudioTracks=function(){return this.g[_.Q]||[]};
45
+ _.t.ia=function(){return this.g[_.P]||[]};_.t.ha=function(){return VF(this,_.ii)};_.t.Ea=function(){return VF(this,_.Q)};_.t.Fa=function(){return VF(this,_.P)};_.t.Ta=function(){return this.w};_.t.eb=function(){this.a.info(bF);return null};_.t.fb=function(){this.a.info(bF);return null};_.t.Ha=function(){var a=this.ha();return a?a.track:null};_.t.na=function(){var a=this.Ea();return a?a.track:null};_.t.oa=function(){var a=this.Fa();return a?a.track:null};
46
+ _.t.Za=function(a){var b=this;null===a?(a=this.ha(),nG(this.f,a.bandwidth,null).then(function(){FF(b)})):0<a.renditions.length&&this.Ya(a.renditions[0])};_.t.sa=function(a){a?KF(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.t.Ba=function(a){a?(a=a.renditions[0],this.h?CF(this.h,a.track):KF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,oG(this.f,!1),this.l.trigger(new _.J(_.Mj)))};
47
+ _.t.Ya=function(a){var b=this,c=this.ha();this.f.o||a.width!==c.width||a.height!==c.height||a.bandwidth!==c.bandwidth?(this.w=a,EF(this,a),nG(this.f,c.bandwidth,a.bandwidth).then(function(){FF(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){KF(this,a)};_.t.mb=function(a){this.h?CF(this.h,a.track):KF(this,a)};
48
+ _.t.addTextTrack=function(){};_.t.ka=function(){return this.f.o};DF.prototype.isAbrEnabled=DF.prototype.ka;DF.prototype.addTextTrack=DF.prototype.addTextTrack;DF.prototype.setTextRendition=DF.prototype.mb;DF.prototype.setAudioRendition=DF.prototype.lb;DF.prototype.setVideoRendition=DF.prototype.Ya;DF.prototype.setTextTrack=DF.prototype.Ba;DF.prototype.setAudioTrack=DF.prototype.sa;DF.prototype.setVideoTrack=DF.prototype.Za;DF.prototype.getTextTrack=DF.prototype.oa;DF.prototype.getAudioTrack=DF.prototype.na;
49
+ DF.prototype.getVideoTrack=DF.prototype.Ha;DF.prototype.getLoadingTextRendition=DF.prototype.fb;DF.prototype.getLoadingAudioRendition=DF.prototype.eb;DF.prototype.getLoadingVideoRendition=DF.prototype.Ta;DF.prototype.getTextRendition=DF.prototype.Fa;DF.prototype.getAudioRendition=DF.prototype.Ea;DF.prototype.getVideoRendition=DF.prototype.ha;DF.prototype.getTextTracks=DF.prototype.ia;DF.prototype.getAudioTracks=DF.prototype.getAudioTracks;DF.prototype.getVideoTracks=DF.prototype.getVideoTracks;_.v(WF,_.Sj);_.t=WF.prototype;_.t.Fh=function(){this.w=!0;this.g||this.trigger(new _.J(hG))};_.t.Eh=function(a){this.w=!0;this.trigger(new _.J(tG,{percent:a}))};_.t.Dh=function(){this.w=!1;this.trigger(new _.J(uG))};_.t.Ih=function(){this.trigger(new _.J(vG))};_.t.Hh=function(a,b){this.trigger(new _.J(AG,{eventid:a,data:b}))};_.t.Jh=function(a,b,c,d,e){this.trigger(new _.J(BG,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
+ _.t.Gh=function(a,b){this.trigger(new _.J(CG,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Tc&&"Challenge"===b.name)nF(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 _.J(DG,{eventType:a}))};
51
+ _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(YF,f,b);g=setTimeout(function(){b.off(YF,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===xG)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){$F(b);d(webapis.avplay.play())},function(f){b.trigger(new _.J(DG));e(f)})})).then(function(){return a()});if(c===sF||c===wG)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===rF?
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()===sF?Promise.resolve():Promise.reject()};
53
+ _.t.setPlaybackRate=function(a){var b=this.getState();if(b===wG||b===rF||b===sF){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,gG(c),4);case 4:return _.x(e,mG(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.mf;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 _.J(_.Ne));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.J(_.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.Rd.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 dF:this.a.debug("The application does not have the privilege to get the volume.",eF);break;default:this.a.debug(aF,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 dF:this.a.warn("The application does not have the privilege to set the volume.",eF);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 xG="IDLE",wG="READY",rF="PLAYING",sF="PAUSED",PF="VIDEO",IF="AUDIO",JF="TEXT",zG="PLAYER_MSG_RESOLUTION_CHANGED",yG="PLAYER_MSG_BITRATE_CHANGE",lF={PLAYREADY:"PLAYREADY",Xj:"EME_PLAYREADY",ek:"VERIMATRIX",sd:"WIDEVINE_CDM",Yj:"EME_WIDEVINE_CDM",fk:"WIDEVINE_CLASSIC"};_.v(pG,_.Sj);_.t=pG.prototype;_.t.wf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.J(_.id));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.t.uf=function(a){this.trigger(new _.J(_.Fe,{currentTime:a.currentTime/1E3}))};
60
+ _.t.xf=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=_.Ih(d))&&this.o.append([new _.zg(b,c,d)],[])};_.t.vf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.ag=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
+ _.t.T=function(a){this.h.debug("Error: TYPE: "+a.eventType);qF(this.f,_.hn);a=new _.L(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.J(_.jd,{detail:a}))};
62
+ _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(vG,this.wf,this);this.a.on(YF,this.uf,this);this.a.on(BG,this.xf,this);this.a.on(CG,this.vf,this);this.a.on(DG,this.T,this);this.a.on(uG,this.ag,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=EG;EG+=1;this.j=_.Hn(_.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];_.Jn(c,f);qG(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(vG,a.wf);a.a.off(YF,a.uf);a.a.off(BG,a.xf);a.a.off(CG,a.vf);a.a.off(DG,a.T);a.a.off(uG,a.ag);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,_.y(b)}})};_.t.namespace=function(){return FG};_.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()===_.dn?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 _.Rj};_.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,_.y(b)}})};
68
+ _.t.load=function(a){var b=this,c,d,e,f,g;return _.A(function(h){switch(h.a){case 1:_.bk(a)&&(b.configuration=_.ak(b.B,a));c=_.Lm(b.configuration,["html","native"]);b.o=c.create(b);d=_.pn(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.G(2);break}b.g=new uF;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(),_.y(h)}})};_.t.play=function(){var a=this;this.trigger(new _.J(_.Zd));qG(this);return this.a.play().then(function(){tF(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){tF(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.J(_.jd,{detail:a});a.severity===_.M&&(qF(this.f,_.hn),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()===_.dn};_.t.isPaused=function(){return this.a.getState()===sF};_.t.isMuted=function(){return cG(this.a)};_.t.setMuted=function(a){lG(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 rG).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};pG.prototype.getTextDisplayer=pG.prototype.getTextDisplayer;pG.prototype.setNetworkEngine=pG.prototype.setNetworkEngine;pG.prototype.getNetworkEngine=pG.prototype.getNetworkEngine;var FG="clpp.tizen",EG=0;rG.prototype.a=function(){return FG};
72
+ rG.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.dc||a===_.Cj||a===_.ic)&&b){if(_.Zh(2))return 2;if(_.Zh(3)||_.Zh(4)||_.Zh(5)||_.Zh(6))return _.G("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};rG.prototype.create=function(){return new pG};_.v(sG,_.Jo);sG.prototype.Ia=function(){this.a=new rG;_.ag(this.a)};sG.prototype.Ca=function(){if(this.a){var a=this.a.a();a&&_.Xf[a]&&(delete _.Xf[a],_.Yf.info("Removed Player factory: '"+a+"'"));this.a=null}};sG.prototype.id=function(){return"tizen"};_.D("clpp.tizen.TizenComponent",sG);var hG="onbufferingstart",tG="onbufferingprogress",uG="onbufferingcomplete",vG="onstreamcompleted",YF="oncurrentplaytime",AG="onevent",BG="onsubtitlechange",CG="ondrmevent",DG="onerror",iG="preparingstart",kG="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 As='application/mp4; codecs\x3d"stpp.ttml"',Bs='application/mp4; codecs\x3d"stpp.ttml.im1i"',Cs='application/mp4; codecs\x3d"stpp.ttml.im1t"',Ds="backgroundColor",Es="direction",Fs="displayAlign",Gs="region",Hs="sans-serif",Is="textAlign",Js="textDecoration",Ks="writingMode",Ls=function(a,b,c){this.g=a;this.f=b;this.a=c},Ms=function(a,b,c){Ls.call(this,a,[],c);this.h=b||""},Ns=function(a,b,c){Ls.call(this,a,b,c)},Os=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},Ws=function(a,b){var c=null;if(Ps.test(a)){c=Ps.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 Qs.test(a)?c=Rs(Qs,a):Ss.test(a)?c=Rs(Ss,a):Ts.test(a)?(c=Ts.exec(a),c=Number(c[1])/b.frameRate):Us.test(a)?(c=Us.exec(a),c=Number(c[1])/b.a):Vs.test(a)&&(c=Rs(Vs,a));return c},Rs=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)},Xs=function(a){return a.split(":").pop()},Ys=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},$s=function(a,b){for(;Zs.test(a);){var c=Zs.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},at=function(a,b,c,d,e,f,g){Ls.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},bt=function(a,b,c){a=Os(a,b,Is);if(!a&&c&&(a=Os(c,b,Is),!a&&"rltb"===Os(c,b,Ks)))return _.je;switch(a){case _.Bc:return _.ug;case _.je:case _.fd:return _.je;default:return _.qd}},
5
- ct=function(a,b,c){if(_.Eh(a.o))return document.createTextNode(_.Ih(a.o||""));if(a.w)return _.Gn("br");for(var d=_.Gn("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.Hn(d,f.value);a=_.u(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(ct(c.get(e.value),b,c));return d},dt=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]))},et=function(a,
6
- b,c){Ls.call(this,a,b,c)},ht=function(a,b,c,d){var e=ft.exec(a);a=gt.exec(a);return typeof b===_.k&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},it=function(a,b){return typeof b===_.k&&0<b?_.Ag:gt.test(a)?0:_.Ag},jt=function(a,b){Ls.call(this,"root-container",[],b);this.h=a},kt=function(a,b,c){return typeof a===_.k?a:typeof b===_.k?b:c},lt=function(a,b){var c=a.getAttribute("extent");return(c=gt.exec(c))?Number(c[b]):null},nt=function(a){a=a.getAttribute("cellResolution");return(a=mt.exec(a))?
7
- Number(a[2]):null},ot=function(a,b,c){Ls.call(this,a,b,c)},pt=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=[]},rt=function(a){return qt.some(function(b){return b in a.attributes})},st=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(st(a,a.a.get(e).f)).concat([e]));return c},ut=function(){return"inline-"+tt++},vt=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})},wt=function(a){this.a=a.firstChild;this.f=new Set},xt=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},yt=function(a){return Xs(a.g.nodeName)},zt=function(){this.a=new Map},Bt=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={},At.forEach(function(n){n in l.attributes&&(g[n]=l.attributes[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Gs)&&(c=b.getAttribute(Gs));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=Xs(h);g[m]=b.getAttribute(h)}d=g.backgroundImage}c=new xt(b,c,d,e,f,g);a.a.set(b,c);return c},Ct=function(a){this.a=a;this.f=new DOMParser},Dt=function(a){this.f=
10
- a},Et=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")},Ft=function(){},Gt=function(a){this.f=new Ct(a);this.a=new _.H("clpp.ttml.Mp4TtmlParser")},Ht=function(){this.a=new Ft};Ls.prototype.getId=function(){return this.g};Ls.prototype.getAttribute=function(a){return this.a[a]};_.v(Ms,Ls);_.v(Ns,Ls);var Ps=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Qs=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Ss=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Ts=/^(\d*(?:\.\d*)?)f$/,Us=/^(\d*(?:\.\d*)?)t$/,Vs=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,ft=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,gt=/^(\d+)px (\d+)px$/,mt=/^(\d+) (\d+)$/,Zs=/(\d+)px/,It=/^(\d+px|\d+em|\d*\.?\d+c)$/,qt=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
- "color",Ds,"opacity","padding","zIndex",Is,Fs,Ks,Es,Js,"textOutline"],At=["begin",_.fd];_.v(at,Ns);
12
- at.prototype.build=function(a,b,c,d,e,f,g){var h=Ws(this.a.begin,b);b=Ws(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Gn(_.Xc);for(var l=_.u(this.h),m=l.next();!m.done;m=l.next())c.appendChild(ct(g.get(m.value),e,g));g=new _.zg(h,b,c.innerHTML.trim(),_.He);g.cssClassList=_.mf(this.f).concat();g.textAlign=bt(this,e,null);g.writingMode=_.vg;g.line=-1;g.lineInterpretation=_.wg;g.lineAlign=_.xg;g.containerRows=kt(null,nt(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
- bt(this,e,f);a:switch(Os(f,e,Ks)){case "tb":case "tblr":a=_.Pe;break a;case "tbrl":a=_.Qe;break a;default:a=_.vg}g.writingMode=a;a:switch(Os(f,e,Fs)){case _.Bc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Os(f,e,Fs)){case _.Bc:a=1;break a;default:a=_.wg}g.lineInterpretation=a;a:switch(Os(f,e,Fs)){case _.Bc:e=_.Bc;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(et,Ns);
15
- et.prototype.build=function(a,b){var c=new _.Cg;c.id=this.getId();var d=kt(a.h.containerWidth,lt(a,1),720),e=kt(a.h.containerHeight,lt(a,2),480);a:switch(Os(this,b,Fs)){case "after":var f="flex-start";break a;case _.Bc:f=_.Bc;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Os(this,b,Ks)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Nc}c.writingMode=f;f=this.getAttribute("extent")||Os(this,b,"extent");c.width=ht(f,d,1,100);c.widthUnits=it(f,d);c.height=
16
- ht(f,e,2,100);c.heightUnits=it(f,e);f=this.getAttribute("origin")||Os(this,b,"origin");c.viewportAnchorX=ht(f,d,1,0);c.viewportAnchorY=ht(f,e,2,0);c.viewportAnchorUnits=it(f,d);c.cssClassList=_.mf(this.f).concat();return c};_.v(jt,Ls);_.v(ot,Ls);
17
- ot.prototype.build=function(a){var b=null;var c=nt(a);c&&(b=kt(a.h.containerHeight,lt(a,2),480)/c);b=kt(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.u(Jt.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+":"+Ys(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&&!It.test(g)&&It.test(h)&&It.test(l)?(e=g,f=h):2===d.length&&!It.test(g)&&It.test(h)?(e=g,f=h):2===d.length&&It.test(g)&&It.test(h)&&(f=g);if(""!==f){f=Ys(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",Hs).replace("proportionalSerif",Hs).replace("sansSerif",Hs).replace("default",Hs)+";":"");a:{if(Js 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
- Ys(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=Ys(e),e=$s(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=Ys(d);d=$s(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 Jt=new Map([["color","color"],[Ds,"background-color"],[Es,Es],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var tt=0;wt.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Kt.has(Xs(a.nodeName))||Lt.has(Xs(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&&!Kt.has(Xs(a.nodeName))));var b=this.a;this.a=a;return b};var Kt=new Set(["tt","head","layout",_.Bd,_.md,Gs,"styling",_.xe,"body",_.Xc,"p","span","br"]),Lt=new Set([_.xe,_.md]);xt.prototype.getId=function(){return this.attributes.id};Ct.prototype.parseInit=function(){};
22
- Ct.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.K.Na(this.a.ttml||{}),e=_.N(a,0,c[0]);e=_.vh(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 pt(d);e=new zt;f=new wt(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=_.ik(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Ms(m,l,{imageType:"PNG",encoding:"Base64"}));
23
- b+=h}for(;f.a;)a=f.next(),a=Bt(e,a),"tt"===yt(a)&&(d.j=new jt(d.A,Object.assign({},a.attributes))),"tt"===yt(a)&&(d.o=new dt(a.attributes.frameRate,a.attributes.subFrameRate,a.attributes.frameRateMultiplier,a.attributes.tickRate)),yt(a)!==_.md||a.attributes.begin||a.attributes.end||(c="#"+a.getId(),d.g.set(c,new Ms(c,a.g.textContent,a.attributes))),yt(a)===_.md&&a.attributes.begin&&a.attributes.end?(c="#"+ut(),b=new Ms(c,a.g.textContent,a.attributes),d.g.set(c,b),c=b):c=null,c&&(a.h=c.getId()),yt(a)===
24
- _.xe&&(c=a.getId()||ut(),b=new ot(c,a.f,Object.assign({},a.attributes)),d.a.set(c,b),a.a&&d.h.get(a.a).f.push(c)),yt(a)!==_.xe&&rt(a)?(c=ut(),b=new ot(c,[],Object.assign({},a.attributes)),d.a.set(c,b),c=b):c=null,c&&a.f.push(c.getId()),yt(a)!==_.Xc||!a.attributes.extent&&!a.attributes.origin?c=null:(c=ut(),b=new et(c,st(d,a.f),Object.assign({},a.attributes)),d.h.set(c,b),c=b),c&&(a.a=c.getId()),yt(a)!==Gs?c=null:(c=a.getId(),b=new et(c,st(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(yt(a))||0===c.length?c=null:(g=c[c.length-1],d.f.has(g)?(c=ut(),b=new at(c,"#text"===a.g.nodeName?a.g.textContent:null,"br"===yt(a),a.a,a.h,st(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"===yt(a)||a.h?(c=ut(),b=new at(c,null,!1,a.a,a.h,st(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=vt(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}};Dt.prototype.a=function(a){a=(new Ct(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=Et(c.startTime)+" --\x3e "+Et(c.endTime),e=[];switch(c.textAlign){case _.qd:e.push("align:left");break;case _.je:e.push("align:right");break;case _.ug:e.push("align:middle");break;case _.qd:e.push("align:start");break;case _.je: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 _.zh(b)};Ft.prototype.probe=function(a,b){return a===_.gc&&b===_.De};Ft.prototype.create=function(a){return new Dt(a)};Gt.prototype.parseInit=function(a){var b=!1;(new _.Nk).M(_.Ed,_.Ok).M(_.Ge,_.Ok).M(_.zd,_.Ok).M(_.Dd,_.Ok).M(_.ue,_.Ok).W(_.we,_.Pk).M("stpp",function(c){b=!0;c.Xa.stop()}).parse(a);if(!b)throw new _.L(_.M,2,2007);};
28
- Gt.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Nk).M("moof",_.Ok).M("traf",_.Ok).W("subs",function(h){for(var l=_.U(h.G),m=0;m<l;++m){h.G.skip(4);for(var n=_.Ik(h.G),p=0;p<n;++p){var q=1===h.version?_.U(h.G):_.Ik(h.G);g.push(q);h.G.skip(6)}}}).M(_.yd,_.Qk(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(Ht,_.Io);Ht.prototype.Ja=function(){_.$p[_.gc]=Ct;_.$p[_.ec]=Gt;_.$p[As]=Gt;_.$p[Cs]=Gt;_.$p[Bs]=Gt;_.Hi.push(this.a)};Ht.prototype.Ca=function(){_.aq(_.gc);_.aq(_.ec);_.aq(As);_.aq(Cs);_.aq(Bs);_.Ji(this.a)};Ht.prototype.id=function(){return _.Ae};_.C("clpp.ttml.TtmlComponent",Ht);};
2
+ var f=function(window){var Bs='application/mp4; codecs\x3d"stpp.ttml"',Cs='application/mp4; codecs\x3d"stpp.ttml.im1i"',Ds='application/mp4; codecs\x3d"stpp.ttml.im1t"',Es="backgroundColor",Fs="direction",Gs="displayAlign",Hs="region",Is="sans-serif",Js="textAlign",Ks="textDecoration",Ls="writingMode",Ms=function(a,b,c){this.g=a;this.f=b;this.a=c},Ns=function(a,b,c){Ms.call(this,a,[],c);this.h=b||""},Os=function(a,b,c){Ms.call(this,a,b,c)},Ps=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},Xs=function(a,b){var c=null;if(Qs.test(a)){c=Qs.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 Rs.test(a)?c=Ss(Rs,a):Ts.test(a)?c=Ss(Ts,a):Us.test(a)?(c=Us.exec(a),c=Number(c[1])/b.frameRate):Vs.test(a)?(c=Vs.exec(a),c=Number(c[1])/b.a):Ws.test(a)&&(c=Ss(Ws,a));return c},Ss=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)},Ys=function(a){return a.split(":").pop()},Zs=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},at=function(a,b){for(;$s.test(a);){var c=$s.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},bt=function(a,b,c,d,e,f,g){Ms.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},ct=function(a,b,c){a=Ps(a,b,Js);if(!a&&c&&(a=Ps(c,b,Js),!a&&"rltb"===Ps(c,b,Ls)))return _.ke;switch(a){case _.Dc:return _.ug;case _.ke:case _.hd:return _.ke;default:return _.rd}},
5
+ dt=function(a,b,c){if(_.Eh(a.o))return document.createTextNode(_.Ih(a.o||""));if(a.w)return _.Hn("br");for(var d=_.Hn("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.In(d,f.value);a=_.u(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(dt(c.get(e.value),b,c));return d},et=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]))},ft=function(a,
6
+ b,c){Ms.call(this,a,b,c)},it=function(a,b,c,d){var e=gt.exec(a);a=ht.exec(a);return typeof b===_.k&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},jt=function(a,b){return typeof b===_.k&&0<b?_.Ag:ht.test(a)?0:_.Ag},kt=function(a,b){Ms.call(this,"root-container",[],b);this.h=a},lt=function(a,b,c){return typeof a===_.k?a:typeof b===_.k?b:c},mt=function(a,b){var c=a.getAttribute("extent");return(c=ht.exec(c))?Number(c[b]):null},ot=function(a){a=a.getAttribute("cellResolution");return(a=nt.exec(a))?
7
+ Number(a[2]):null},pt=function(a,b,c){Ms.call(this,a,b,c)},qt=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=[]},st=function(a){return rt.some(function(b){return b in a.attributes})},tt=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(tt(a,a.a.get(e).f)).concat([e]));return c},vt=function(){return"inline-"+ut++},wt=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})},xt=function(a){this.a=a.firstChild;this.f=new Set},yt=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},zt=function(a){return Ys(a.g.nodeName)},At=function(){this.a=new Map},Ct=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={},Bt.forEach(function(n){n in l.attributes&&(g[n]=l.attributes[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Hs)&&(c=b.getAttribute(Hs));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=Ys(h);g[m]=b.getAttribute(h)}d=g.backgroundImage}c=new yt(b,c,d,e,f,g);a.a.set(b,c);return c},Dt=function(a){this.a=a;this.f=new DOMParser},Et=function(a){this.f=
10
+ a},Ft=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")},Gt=function(){},Ht=function(a){this.f=new Dt(a);this.a=new _.H("clpp.ttml.Mp4TtmlParser")},It=function(){this.a=new Gt};Ms.prototype.getId=function(){return this.g};Ms.prototype.getAttribute=function(a){return this.a[a]};_.v(Ns,Ms);_.v(Os,Ms);var Qs=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Rs=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Ts=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Us=/^(\d*(?:\.\d*)?)f$/,Vs=/^(\d*(?:\.\d*)?)t$/,Ws=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,gt=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,ht=/^(\d+)px (\d+)px$/,nt=/^(\d+) (\d+)$/,$s=/(\d+)px/,Jt=/^(\d+px|\d+em|\d*\.?\d+c)$/,rt=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
+ "color",Es,"opacity","padding","zIndex",Js,Gs,Ls,Fs,Ks,"textOutline"],Bt=["begin",_.hd];_.v(bt,Os);
12
+ bt.prototype.build=function(a,b,c,d,e,f,g){var h=Xs(this.a.begin,b);b=Xs(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Hn(_.Zc);for(var l=_.u(this.h),m=l.next();!m.done;m=l.next())c.appendChild(dt(g.get(m.value),e,g));g=new _.zg(h,b,c.innerHTML.trim(),_.He);g.cssClassList=_.mf(this.f).concat();g.textAlign=ct(this,e,null);g.writingMode=_.vg;g.line=-1;g.lineInterpretation=_.wg;g.lineAlign=_.xg;g.containerRows=lt(null,ot(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
+ ct(this,e,f);a:switch(Ps(f,e,Ls)){case "tb":case "tblr":a=_.Pe;break a;case "tbrl":a=_.Qe;break a;default:a=_.vg}g.writingMode=a;a:switch(Ps(f,e,Gs)){case _.Dc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Ps(f,e,Gs)){case _.Dc:a=1;break a;default:a=_.wg}g.lineInterpretation=a;a:switch(Ps(f,e,Gs)){case _.Dc:e=_.Dc;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(ft,Os);
15
+ ft.prototype.build=function(a,b){var c=new _.Cg;c.id=this.getId();var d=lt(a.h.containerWidth,mt(a,1),720),e=lt(a.h.containerHeight,mt(a,2),480);a:switch(Ps(this,b,Gs)){case "after":var f="flex-start";break a;case _.Dc:f=_.Dc;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Ps(this,b,Ls)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Pc}c.writingMode=f;f=this.getAttribute("extent")||Ps(this,b,"extent");c.width=it(f,d,1,100);c.widthUnits=jt(f,d);c.height=
16
+ it(f,e,2,100);c.heightUnits=jt(f,e);f=this.getAttribute("origin")||Ps(this,b,"origin");c.viewportAnchorX=it(f,d,1,0);c.viewportAnchorY=it(f,e,2,0);c.viewportAnchorUnits=jt(f,d);c.cssClassList=_.mf(this.f).concat();return c};_.v(kt,Ms);_.v(pt,Ms);
17
+ pt.prototype.build=function(a){var b=null;var c=ot(a);c&&(b=lt(a.h.containerHeight,mt(a,2),480)/c);b=lt(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.u(Kt.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+":"+Zs(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&&!Jt.test(g)&&Jt.test(h)&&Jt.test(l)?(e=g,f=h):2===d.length&&!Jt.test(g)&&Jt.test(h)?(e=g,f=h):2===d.length&&Jt.test(g)&&Jt.test(h)&&(f=g);if(""!==f){f=Zs(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",Is).replace("proportionalSerif",Is).replace("sansSerif",Is).replace("default",Is)+";":"");a:{if(Ks 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
+ Zs(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=Zs(e),e=at(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=Zs(d);d=at(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 Kt=new Map([["color","color"],[Es,"background-color"],[Fs,Fs],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var ut=0;xt.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Lt.has(Ys(a.nodeName))||Mt.has(Ys(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&&!Lt.has(Ys(a.nodeName))));var b=this.a;this.a=a;return b};var Lt=new Set(["tt","head","layout",_.Cd,_.od,Hs,"styling",_.xe,"body",_.Zc,"p","span","br"]),Mt=new Set([_.xe,_.od]);yt.prototype.getId=function(){return this.attributes.id};Dt.prototype.parseInit=function(){};
22
+ Dt.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.K.Ma(this.a.ttml||{}),e=_.N(a,0,c[0]);e=_.vh(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 qt(d);e=new At;f=new xt(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=_.jk(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Ns(m,l,{imageType:"PNG",encoding:"Base64"}));
23
+ b+=h}for(;f.a;)a=f.next(),a=Ct(e,a),"tt"===zt(a)&&(d.j=new kt(d.A,Object.assign({},a.attributes))),"tt"===zt(a)&&(d.o=new et(a.attributes.frameRate,a.attributes.subFrameRate,a.attributes.frameRateMultiplier,a.attributes.tickRate)),zt(a)!==_.od||a.attributes.begin||a.attributes.end||(c="#"+a.getId(),d.g.set(c,new Ns(c,a.g.textContent,a.attributes))),zt(a)===_.od&&a.attributes.begin&&a.attributes.end?(c="#"+vt(),b=new Ns(c,a.g.textContent,a.attributes),d.g.set(c,b),c=b):c=null,c&&(a.h=c.getId()),zt(a)===
24
+ _.xe&&(c=a.getId()||vt(),b=new pt(c,a.f,Object.assign({},a.attributes)),d.a.set(c,b),a.a&&d.h.get(a.a).f.push(c)),zt(a)!==_.xe&&st(a)?(c=vt(),b=new pt(c,[],Object.assign({},a.attributes)),d.a.set(c,b),c=b):c=null,c&&a.f.push(c.getId()),zt(a)!==_.Zc||!a.attributes.extent&&!a.attributes.origin?c=null:(c=vt(),b=new ft(c,tt(d,a.f),Object.assign({},a.attributes)),d.h.set(c,b),c=b),c&&(a.a=c.getId()),zt(a)!==Hs?c=null:(c=a.getId(),b=new ft(c,tt(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(zt(a))||0===c.length?c=null:(g=c[c.length-1],d.f.has(g)?(c=vt(),b=new bt(c,"#text"===a.g.nodeName?a.g.textContent:null,"br"===zt(a),a.a,a.h,tt(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"===zt(a)||a.h?(c=vt(),b=new bt(c,null,!1,a.a,a.h,tt(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=wt(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}};Et.prototype.a=function(a){a=(new Dt(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=Ft(c.startTime)+" --\x3e "+Ft(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 _.zh(b)};Gt.prototype.probe=function(a,b){return a===_.hc&&b===_.De};Gt.prototype.create=function(a){return new Et(a)};Ht.prototype.parseInit=function(a){var b=!1;(new _.Ok).L(_.Fd,_.Pk).L(_.Ge,_.Pk).L(_.Ad,_.Pk).L(_.Ed,_.Pk).L(_.ue,_.Pk).V(_.we,_.Qk).L("stpp",function(c){b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.L(_.M,2,2007);};
28
+ Ht.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Ok).L("moof",_.Pk).L("traf",_.Pk).V("subs",function(h){for(var l=_.U(h.reader),m=0;m<l;++m){h.reader.skip(4);for(var n=_.Jk(h.reader),p=0;p<n;++p){var q=1===h.version?_.U(h.reader):_.Jk(h.reader);g.push(q);h.reader.skip(6)}}}).L(_.zd,_.Rk(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(It,_.Jo);It.prototype.Ia=function(){_.aq[_.hc]=Dt;_.aq[_.fc]=Ht;_.aq[Bs]=Ht;_.aq[Ds]=Ht;_.aq[Cs]=Ht;_.Gi.push(this.a)};It.prototype.Ca=function(){_.bq(_.hc);_.bq(_.fc);_.bq(Bs);_.bq(Ds);_.bq(Cs);_.Ii(this.a)};It.prototype.id=function(){return _.Ae};_.D("clpp.ttml.TtmlComponent",It);};
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));}