@castlabs/prestoplay 6.4.1 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +35 -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 +419 -416
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +72 -72
  10. package/cjs/cl.externs.js +26 -26
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +47 -47
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -31
  15. package/cjs/cl.ima.js +22 -22
  16. package/cjs/cl.mse.js +258 -255
  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 +69 -69
  22. package/cjs/cl.thumbnails.js +24 -24
  23. package/cjs/cl.tizen.js +71 -71
  24. package/cjs/cl.ttml.js +27 -27
  25. package/cjs/cl.verimatrix.js +5 -5
  26. package/cjs/cl.vimond.js +13 -13
  27. package/cjs/cl.vr.js +19 -18
  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 +354 -351
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +66 -66
  38. package/cl.externs.js +26 -26
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +40 -39
  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 +230 -231
  45. package/cl.muxdata.js +8 -8
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +9 -9
  48. package/cl.playlist.js +5 -5
  49. package/cl.smooth.js +58 -58
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +22 -22
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +15 -14
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +15 -16
  58. package/package.json +6 -2
@@ -1,28 +1,28 @@
1
1
  (function(){var g={}; var _ = _ || {}
2
- var f=function(window){var At="No thumbnail duration or URL specified",Bt="No thumbnail found for position ",Ct="Position is out of range: ",Dt="Thumbnail URL is mandatory",Et="Wrong gridSize format",Ft="clpp.thumbnails",Gt=function(){this.log=new _.H(Ft);this.g=null;this.a=[];this.w=!1},It=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Id&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return Ht(a,0,e,!!f)})},Promise.resolve())},Ht=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();
3
- var e=b+c;return Jt(a,d).then(function(){return a.a[b].load()}).then(function(){return Ht(a,e,c,d)})},Jt=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.Tm)c();else a.g.one(_.sc,function(){c()})})},Kt=function(a,b){return b>=a.time&&b<a.time+a.duration},Lt=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.ga=p;this.Rh=h;this.Fj=l;this.li=m;this.mi=n;this.Nb=null},Mt=function(){Gt.call(this);this.f=null;this.o=this.h=1;this.j=0},Nt=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Qf=new _.Mh},Ot=function(){this.g=new _.H(Ft);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Mh},Pt=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.Qf.resolve()})},Rt=function(a,b){return Qt(a,b).then(function(c){return new Lt(c,
5
- b.time,b.duration)})},Qt=function(a,b){return b.load().then(function(){var c=_.N(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.ak(c)})},St=function(){Gt.call(this);this.f=null},Tt=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},Ut=function(){Gt.apply(this,arguments)},Vt=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},Wt=function(a,b){var c=a.horizontalTiles||
6
- b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{bd:c,ef:d,Kf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Xt=function(){this.f=new _.H(Ft);this.a=this.l=null},Yt=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},Zt=function(a){if(!a)return null;a=new _.mi(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},$t=function(){};Gt.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.de,function(){c.w=!0});a.isLive()||this.m().then(function(){b&&b.preload&&It(c,b.preload)})};Lt.prototype.raw=function(){return this.ga.cloneNode(!1)};
7
- Lt.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(_.Vc);e.style.width=c+_.ae;e.style.height=d+_.ae;e.style.backgroundColor="#000";e.style.backgroundRepeat="no-repeat";e.style.backgroundImage='url("'+this.src+'")';e.style.backgroundSize=Math.ceil(c/this.width*(this.ga.naturalWidth||this.ga.width))+"px "+Math.ceil(d/
8
- this.height*(this.ga.naturalHeight||this.ga.height))+_.ae;var f=this.y/this.height;e.style.backgroundPositionX="-"+this.x/this.width*c+_.ae;e.style.backgroundPositionY="-"+f*d+_.ae;return e};
9
- Lt.prototype.load=function(){var a=this;this.Nb||(this.Nb=new Promise(function(b,c){function d(){a.width||(a.width=(a.ga.naturalWidth||a.ga.width)/a.Rh);a.height||(a.height=(a.ga.naturalHeight||a.ga.height)/a.Fj);a.x||(a.x=a.width*a.li);a.y||(a.y=a.height*a.mi)}if(a.ga.src&&a.ga.complete)d(),b(a);else{var e=null,f=function(){d();a.ga.removeEventListener("load",f);a.ga.removeEventListener(_.fd,e);b(a)};e=function(){a.ga.removeEventListener("load",f);a.ga.removeEventListener(_.fd,e);c()};a.ga.addEventListener("load",
10
- f);a.ga.addEventListener(_.fd,e);a.ga.src=a.src}}));return this.Nb};_.B("clpp.thumbnails.Thumbnail",Lt);Lt.prototype.load=Lt.prototype.load;Lt.prototype.element=Lt.prototype.element;Lt.prototype.raw=Lt.prototype.raw;_.v(Mt,Gt);
11
- Mt.prototype.init=function(a,b){if(!b||!b.url)throw new _.L(_.M,7,7100,Dt);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(At,c,d),new _.L(_.M,7,7100,At);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,Et);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.L(_.M,7,7100,Et);}Gt.prototype.init.call(this,a,b)};Mt.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(Ct+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Bt+a+" at index "+c)};
13
- Mt.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 Lt(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()};Nt.prototype.load=function(){return this.Qf};
14
- Ot.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Dt);var d=b.url,e=_.Hh(d);e.type=_.Gh;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,au),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 Nt(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(){Pt(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))})};Ot.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ct+a):this.h.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(Kt(d,a))return Rt(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Bt+a)})};var au=[137,66,73,70,13,10,26,10];_.v(St,Gt);
17
- St.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Dt);var d=b.url,e=_.Hh(d);e.type=_.Gh;this.f=a.getNetworkEngine().fetch(e).P.then(function(f){if(f=f.data){f=_.oh(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=Tt(l[0]);l=Tt(l[1])-r;c.a.push(new Lt(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))});Gt.prototype.init.call(this,a,b)};
19
- St.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ct+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Nc:c.Nc},d++)if(c.Nc=b.a[d],Kt(c.Nc,a))return c.Nc.load().then(function(e){return function(){return e.Nc}}(c));return Promise.reject(Bt+a)})};St.prototype.m=function(){return this.f};_.v(Ut,Gt);
20
- Ut.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=Vt(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=Wt(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.Kf+a]);else if((c=d.Ha())&&0<c.length){var g=0,h=0;d=d.startTime;1<e.Kf&&(g=a%e.bd,h=Math.floor(a/e.bd),d+=a*e.durationPerTile);f=new Lt(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.bd,e.ef,g,h)}if(f)return f.load().then(function(){return f})}this.log.error("segment reference for specified segment index does not exist",
22
- b);return Promise.reject()};Ut.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
23
- Ut.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&&!_.J.R(d=b.getSegmentReference(c++));)for(var e=Wt(d,b),f=d.Ha()[0],g=new Image,h=d.startTime,l=0;l<e.ef;++l)for(var m=0;m<e.bd;++m)this.a.push(new Lt(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.bd,e.ef,m,l,g)),h+=e.durationPerTile;return Promise.resolve()};_.t=Xt.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=Zt(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new Mt:"WEBVTT"===c?this.a=new St:"BIF"===c&&(this.a=new Ot)),this.a&&(this.f.info("Loading thumbs configuration",d),this.l.one(_.ud,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();Yt(d)&&(this.a=new Ut,this.a.init(a,c))}};_.t.get=function(a){return this.a?this.a.get(a):Promise.reject()};_.t.id=function(){return"thumbnails"};_.B("clpp.thumbnails.ThumbnailsPlugin",Xt);Xt.prototype.get=Xt.prototype.get;Xt.Id="thumbnails";$t.prototype.create=function(){return new Xt};_.uo(new $t);};
2
+ var f=function(window){var Et="No thumbnail duration or URL specified",Ft="No thumbnail found for position ",Gt="Position is out of range: ",Ht="Thumbnail URL is mandatory",It="Wrong gridSize format",Jt="clpp.thumbnails",Kt=function(){this.log=new _.H(Jt);this.g=null;this.a=[];this.w=!1},Mt=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Jd&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return Lt(a,0,e,!!f)})},Promise.resolve())},Lt=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();
3
+ var e=b+c;return Nt(a,d).then(function(){return a.a[b].load()}).then(function(){return Lt(a,e,c,d)})},Nt=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.Um)c();else a.g.one(_.sc,function(){c()})})},Ot=function(a,b){return b>=a.time&&b<a.time+a.duration},Pt=function(a,b,c,d,e,f,g,h,l,m,n,p){d=void 0===d?0:d;e=void 0===e?0:e;f=void 0===f?0:f;g=void 0===g?0:g;h=void 0===h?1:h;l=void 0===l?1:l;m=void 0===m?0:m;n=void 0===n?0:n;p=void 0===p?new Image:p;this.time=b;this.src=a;this.duration=
4
+ c;this.x=d;this.y=e;this.width=f;this.height=g;this.ia=p;this.Th=h;this.Hj=l;this.ni=m;this.oi=n;this.Pb=null},Qt=function(){Kt.call(this);this.f=null;this.o=this.h=1;this.j=0},Rt=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Tf=new _.Nh},St=function(){this.g=new _.H(Jt);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Nh},Tt=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.Tf.resolve()})},Vt=function(a,b){return Ut(a,b).then(function(c){return new Pt(c,
5
+ b.time,b.duration)})},Ut=function(a,b){return b.load().then(function(){var c=_.N(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.bk(c)})},Wt=function(){Kt.call(this);this.f=null},Xt=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},Yt=function(){Kt.apply(this,arguments)},Zt=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},$t=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,Mf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},au=function(){this.f=new _.H(Jt);this.a=this.l=null},bu=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},cu=function(a){if(!a)return null;a=new _.ni(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},du=function(){};Kt.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.ee,function(){c.w=!0});a.isLive()||this.m().then(function(){b&&b.preload&&Mt(c,b.preload)})};Pt.prototype.raw=function(){return this.ia.cloneNode(!1)};
7
+ Pt.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(_.Wc);e.style.width=c+_.be;e.style.height=d+_.be;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))+_.be;var f=this.y/this.height;e.style.backgroundPositionX="-"+this.x/this.width*c+_.be;e.style.backgroundPositionY="-"+f*d+_.be;return e};
9
+ Pt.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.Th);a.height||(a.height=(a.ia.naturalHeight||a.ia.height)/a.Hj);a.x||(a.x=a.width*a.ni);a.y||(a.y=a.height*a.oi)}if(a.ia.src&&a.ia.complete)d(),b(a);else{var e=null,f=function(){d();a.ia.removeEventListener("load",f);a.ia.removeEventListener(_.gd,e);b(a)};e=function(){a.ia.removeEventListener("load",f);a.ia.removeEventListener(_.gd,e);c()};a.ia.addEventListener("load",
10
+ f);a.ia.addEventListener(_.gd,e);a.ia.src=a.src}}));return this.Pb};_.C("clpp.thumbnails.Thumbnail",Pt);Pt.prototype.load=Pt.prototype.load;Pt.prototype.element=Pt.prototype.element;Pt.prototype.raw=Pt.prototype.raw;_.v(Qt,Kt);
11
+ Qt.prototype.init=function(a,b){if(!b||!b.url)throw new _.L(_.M,7,7100,Ht);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(Et,c,d),new _.L(_.M,7,7100,Et);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,It);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.L(_.M,7,7100,It);}Kt.prototype.init.call(this,a,b)};Qt.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(Gt+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Ft+a+" at index "+c)};
13
+ Qt.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 Pt(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()};Rt.prototype.load=function(){return this.Tf};
14
+ St.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Ht);var d=b.url,e=_.Ih(d);e.type=_.Hh;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,eu),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 Rt(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(){Tt(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))})};St.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Gt+a):this.h.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(Ot(d,a))return Vt(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Ft+a)})};var eu=[137,66,73,70,13,10,26,10];_.v(Wt,Kt);
17
+ Wt.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.L(_.M,7,7100,Ht);var d=b.url,e=_.Ih(d);e.type=_.Hh;this.f=a.getNetworkEngine().fetch(e).P.then(function(f){if(f=f.data){f=_.ph(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=Xt(l[0]);l=Xt(l[1])-r;c.a.push(new Pt(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))});Kt.prototype.init.call(this,a,b)};
19
+ Wt.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Gt+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],Ot(c.Pc,a))return c.Pc.load().then(function(e){return function(){return e.Pc}}(c));return Promise.reject(Ft+a)})};Wt.prototype.m=function(){return this.f};_.v(Yt,Kt);
20
+ Yt.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=Zt(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=$t(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.Ha())&&0<c.length){var g=0,h=0;d=d.startTime;1<e.Mf&&(g=a%e.dd,h=Math.floor(a/e.dd),d+=a*e.durationPerTile);f=new Pt(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()};Yt.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
23
+ Yt.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=$t(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 Pt(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=au.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=cu(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new Qt:"WEBVTT"===c?this.a=new Wt:"BIF"===c&&(this.a=new St)),this.a&&(this.f.info("Loading thumbs configuration",d),this.l.one(_.vd,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();bu(d)&&(this.a=new Yt,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",au);au.prototype.get=au.prototype.get;au.Id="thumbnails";du.prototype.create=function(){return new au};_.wo(new du);};
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 LE="An unknown error occurred while trying to get volume",ME="Cannot get loading rendition due to platform limitations",NE="PARAM_START_POSITION",OE="SecurityError",PE="The require privilege is: http://tizen.org/privilege/tv.audio",QE="|STARTBITRATE\x3d",RE=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},SE=function(a,b){this.h=a;this.w=null;this.a=_.Hd;this.o=null;this.j=!1;this.f=new Map;this.m=b;this.g=new _.H("clpp.tizen.DrmEngine")},VE=function(a){var b,
3
- c,d;return _.A(function(e){if(1==e.a){b=a.a===_.Pc||a.a===_.Oc;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.fd)throw new _.L(_.M,6,6012,"No license server given for "+a.a);_.xf(e,2);return a.a===_.Pc?_.y(e,TE(a),5):_.y(e,UE(a,c),5)}if(2!=e.a)return a.w={keySystem:a.a,licenseServerUri:c.fd,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Oe,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
4
- keyIds:[],periodId:null},_.yf(e,0);d=_.zf(e);a.g.error("Error while configuring CDM for "+a.a,d);throw new _.L(_.M,6,6005,{message:JSON.stringify(d)});})},UE=function(a,b){var c,d,e,f;return _.A(function(g){c=WE;d=XE;e={};e[d.wg]=!b.Oe;e[d.xg]=b.fd;""!==b.customData&&(e[d.vg]=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)})},TE=function(a){var b;return _.A(function(c){b=WE;try{webapis.avplay.setDrm(b.qd,
5
- "Initialize",""),webapis.avplay.setDrm(b.qd,"widevine_app_session",a.o.id),webapis.avplay.setDrm(b.qd,"widevine_data_type",a.o.type)}catch(d){throw d;}_.z(c)})},YE=function(a,b){var c,d,e,f,g,h,l,m,n,p,q,r,w,x,C,D,E;_.A(function(G){if(1==G.a){c=WE;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.fd;l=_.Hh([h],_.Eh());l.type=3;l.body=f.buffer;l.method=
6
- "POST";_.xf(G,2);return _.y(G,a.m.Ab.fetch(l).P,4)}if(2!=G.a){m=G.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);x=b.session_id+NE+(w+NE);a.g.debug("Widevine license params",x);try{webapis.avplay.setDrm(c.qd,"widevine_license_data",x)}catch(K){a.g.error("License response rejected by CDM"),C=new _.L(_.M,6,6008,{browserError:JSON.stringify(K)}),a.m.onError(C)}}return _.yf(G,0)}D=_.zf(G);a.g.error("License request failed.",JSON.stringify(D));E=new _.L(_.M,
7
- 6,6007,{message:_.Ha,url:D.data.url,status:D.data.status||NaN,response:D.data.response||"",headers:D.data.headers||{}},D);a.m.onError(E);_.z(G)})},ZE=function(a){this.l=a;this.a=this.l.a;this.f=_.Om;this.j=_.Pm;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.H("clpp.tizen.StateManager")},aF=function(a,b){if(a.f!==b)if(a.f===_.Zm&&b!==_.Om)a.g.debug(_.Ru+$E(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.Tm?(a.o=(new Date).getTime(),a.l.trigger(new _.I(_.tc,{detail:{bufferedTimeMS:-1,
8
- reason:a.h}}))):a.j===_.Tm&&a.l.trigger(new _.I(_.sc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));var d={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.l.trigger(new _.I(_.pe,{detail:d}));a.g.debug("State changed:",$E(a.j),"-\x3e",$E(a.f))}},$E=function(a){return Object.keys(_.Xm)[a]},dF=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case bF:c=_.bn;break;case cF:c=_.an;break;default:a.l.isEnded()?c=_.Vm:a.g.debug("Inconsistent AVPlay playback state:",b)}aF(a,
9
- c)}},eF=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")},fF=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},gF=function(a){var b,c;return _.A(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.y(d,_.tp(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
- hF=function(a){var b=document.createElement(_.Pe),c=new _.yw,d=new _.Jv(function(){return null}),e=a.l.getTextDisplayer();return new _.Ew(b,c,e,d,a.l.getConfiguration())},iF=function(a){var b={wb:function(){return a.l.getPosition()},W:a.h,Ab:a.l.getNetworkEngine(),He:a.Jh.bind(a),Ge:a.Ih.bind(a),onError:a.T.bind(a),Yf:function(){},onEvent:function(){},cg:a.Kh.bind(a),Nd:function(){},pe:function(){return new _.Hx},de:function(){return!1},Zc:null};return new _.By(a.f,b)},jF=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},kF=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 _.di(String(c++),_.P);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=
12
- a[d].kind||_.iv;var f=new _.li(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},lF=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.Dy(a.g,_.Ae),c=null;if(b){a=kF(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},mF=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=jF(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):(_.Ly(a.g,c,!0,0),a.l.trigger(new _.I(_.Dj))),a.o=c.language):a.a.error(_.Qu,d.id)}},nF=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},oF=function(a,b){a.l.trigger(new _.I(_.Te,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},
14
- pF=function(a){var b=a.ea();b&&a.l.trigger(new _.I(_.qc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},qF=function(a){var b=a.l.getConfiguration(),c=_.ai(b.preferredAudioLanguage||[]),d=a.g[_.Q]||[];if(d.length){var e=null;c.some(function(g){e=_.Dv(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.ra(c)}else a.a.debug("Preferred language(s) not available")}else a.a.debug("Could not set preferred audio language")},uF=function(a,b){if(b){var c=b.track.type.toUpperCase();rF(a.f,c,Number(b.id)).then(function(){c===sF&&(a.j=b,a.l.trigger(new _.I(_.Cj)));c===tF&&(a.m=b,a.l.trigger(new _.I(_.Dj)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},vF=
16
- function(a,b,c){var d=_.Fi(b.language||_.Ge);c.language=_.ei(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.nc;a=new _.li(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},wF=function(a,b,c){c.mimeType=_.Re;a=new _.li(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},xF=function(a,b,c){b=_.Fi(b.track_lang||_.Ge);c.mimeType="text/ttml";c.language=
17
- _.ei(b);c.kind=_.iv;return new _.li(String(a),c)},yF=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},BF=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===zF}),f=b.filter(function(n){return n.type===sF}),g=[],h=0;h<f.length;h++){var l=yF(a,f[h].extra_info);if(l){var m=_.Fi(l.language||_.Ge);
18
- m=_.ei(m);m=c(g,m);m||(m=new _.di(String(a.o++),_.Q),g.push(m));m.renditions.push(vF(f[h].index,l,m))}else a.a.warn("Skipping audio stream with no extra info")}f=new _.di(String(a.o++),_.fi);for(h=0;h<e.length;h++)(l=yF(a,e[h].extra_info))?f.renditions.push(wF(e[h].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?kF(a.h):AF(a,b);d[_.fi]=[f];d[_.Q]=g;d[_.P]=e;return d},AF=function(a,b){for(var c=b.filter(function(h){return h.type===tF}),d=[],e=0;e<c.length;e++){var f=yF(a,
19
- c[e].extra_info);if(f){var g=new _.di(String(a.o++),_.P);g.renditions.push(xF(c[e].index,f,g));d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},CF=function(a,b){for(var c=a.g[_.fi]||[],d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].renditions.length;f++)_.J.va(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},DF=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},FF=function(a,b){if(b===_.P&&a.h)return lF(a.h);var c=EF(a.f)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.fi&&(d=yF(a,c.extra_info),d=CF(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=DF(a,c,_.Q),a.j=d):d=a.j);b===_.P&&(c?(d=DF(a,c,_.P),a.m=d):d=a.m);return d},GF=function(a){_.Jj.call(this);this.l=a;this.h=null;this.a=new _.H("clpp.tizen.Middleware");this.C=1;this.B=!1;this.m=null;this.D=0;
21
- this.o=!0;this.g=!1;this.f=null;this.A=1;this.w=!1;this.j={}},HF=function(a){return _.A(function(b){tizen.systeminfo.getPropertyValue("DISPLAY",function(c){a.A=c.resolutionWidth/1920;a.a.debug("Display resolution ratio: ",a.A)},function(c){a.a.debug("Could not load DISPLAY property");throw c;});_.z(b)})},JF=function(a){try{webapis.avplay.setListener({onbufferingstart:a.Dh.bind(a),onbufferingprogress:a.Ch.bind(a),onbufferingcomplete:a.Bh.bind(a),onstreamcompleted:a.Gh.bind(a),oncurrentplaytime:function(b){a.trigger(new _.I(IF,
22
- {currentTime:b}))},onevent:a.Fh.bind(a),onsubtitlechange:a.Hh.bind(a),ondrmevent:a.Eh.bind(a),onerror:a.T.bind(a)})}catch(b){a.a.error(b)}},KF=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)}},LF=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,jk:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",QE+d)}catch(e){a.a.debug(e)}},
23
- MF=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+QE+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},PF=function(a){return{position:a.getPosition(),state:a.l.getState(),lf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:NF(a),volume:a.getVolume(),Nj:OF(a),Uh:EF(a)}},RF=function(a){var b,c;return _.A(function(d){if(1==d.a)return _.y(d,QF(),2);if(3!=d.a)return b=new Promise(function(e){(new _.Li(e)).Z(5)}),
24
- _.y(d,Promise.race([HF(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)})},XF=function(a,b,c){var d,e,f,g,h,l,m,n;return _.A(function(p){switch(p.a){case 1:a.m=_.fn(b);d=a.D;e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.a.debug("Loading manifest URL: "+a.m[d].url);f=b.startTime||void 0;a.g&&(a.trigger(new _.I(SF)),f=c.currentPosition);
25
- _.xf(p,2);g=a.m[d].url;h=a.m[d].type;h!==_.bc||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);e.nextBandwidth?(MF(a,e.nextBandwidth),a.o=!1):(a.o||LF(a,e),a.o=!0);JF(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 SE(b.drm,m);return _.y(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.I(TF)),
26
- _.y(p,UF(a),6);case 6:a.g||a.trigger(new _.I(VF));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&&WF(a,b.muted),b.autoplay&&a.l.play()["catch"](function(q){a.a.debug("Autoplay failed",q)}));_.yf(p,0);break;case 2:throw n=_.zf(p),a.a.debug("Error while attempting to load source."),n;}})},UF=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
- KF(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)}}))})},YF=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=PF(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.f.lf;a.g=!1;a.f=
28
- null;return e===cF?a.pause():a.play()})}catch(e){return Promise.reject(e)}},OF=function(a){return a.g&&a.f?a.f.Nj:webapis.avplay.getTotalTrackInfo()},EF=function(a){return a.g&&a.f?a.f.Uh:webapis.avplay.getCurrentStreamInfo()},rF=function(a,b,c){b=b.toUpperCase();b===tF&&ZF(a,!0);var d=a.j[b];d&&(d.Pd.stop(),a.j[b]=null,a.a.debug("Cancelled pending track switch for "+b));return new Promise(function(e,f){function g(h,l,m){m=void 0===m?!1:m;try{webapis.avplay.setSelectTrack(h,l),a.j[h]=null,e()}catch(n){a.a.debug("Could not set "+
29
- h+" track. Trying again...AVPlay state: "+(a.getState()+", buffering: ")+a.w,n),!1===m&&(a.j[h]={type:h,index:l,jf:0,Pd:new _.Li(function(){return g(h,c,!0)})}),(l=a.j[h])&&3>l.jf?(!a.w&&++l.jf,l.Pd.Z(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Pd.stop(),a.j[h]=null,f())}}g(b,c)})},ZF=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)}},WF=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case OE:a.a.warn("The application does not have the privilege to set mute.",PE);break;default:a.a.warn(LE,c)}}},NF=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case OE:a.a.warn("The application doesn't have the privilege to get the mute state.",PE);break;default:a.a.warn(LE,c)}}return!!b},QF=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
31
- RE(c,"load",function(d){return a(d)});RE(c,_.fd,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},$F=function(){_.Jj.call(this);this.a=new GF(this);this.f=new ZE(this);this.configuration=this.B=_.Pj();this.w=null;this.h=new _.H("clpp.tizen.Player");this.j=null;this.m=new nF;this.C=new _.Yh;this.o=this.g=null;this.A=!1},aG=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())},bG=function(){},cG=function(){this.a=null};
33
- SE.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.A(function(h){if(1==h.a){b=_.lk[a.h.env]||null;if(!b)throw a.g.debug(_.wa,_.gb+a.h.env+_.aa),new _.L(_.M,6,6015,_.ya+a.h.env+"' is missing.");a.o={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";d=_.nk(b,a.h.customData);(e=d[_.Oc])&&a.f.set(_.Oc,{fd:e.licenseUrl||"",customData:c,Oe:!1});(f=d[_.Pc])&&a.f.set(_.Pc,{fd:f.licenseUrl||"",customData:c,
34
- Oe:!1});if(0===a.f.size)throw new _.L(_.M,6,6E3);if((g=a.h.preferredDrmSystem)&&a.f.get(g))a.a=g;else if(a.f.get(_.Oc))a.a=_.Oc;else if(a.f.get(_.Pc))a.a=_.Pc;else throw new _.L(_.M,6,6001,"Configuration for the target system is missing.");return _.y(h,VE(a),2)}a.j=!0;_.z(h)})};SE.prototype.release=function(){var a=this;return _.A(function(b){a.j=!1;a.w=null;a.a=_.Hd;a.o=null;a.f=new Map;_.z(b)})};SE.prototype.getDrmInfo=function(){return this.w};
35
- var XE={wg:"DeleteLicenseAfterUse",xg:"LicenseServer",Yj:"GetChallenge",Zj:"HttpHeader",bk:"UserAgent",Uj:"Cookie",vg:"CustomData"};_.t=ZE.prototype;_.t.initialize=function(){this.a.on(SF,this.yf,this);this.a.on(dG,this.xf,this);this.a.on(eG,this.wf,this);this.a.on(TF,this.eg,this);this.a.on(VF,this.dg,this);this.a.on(fG,this.zf,this)};_.t.release=function(){aF(this,_.Om);this.m=!1;this.o=-1;this.h=2};_.t.destroy=function(){this.release();this.a.off(SF,this.yf);this.a.off(dG,this.xf);this.a.off(eG,this.wf);this.a.off(TF,this.eg);this.a.off(VF,this.dg);this.a.off(fG,this.zf);this.l=this.a=null};
36
- _.t.yf=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;aF(this,_.Tm)};_.t.xf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",$E(this.f))};_.t.wf=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()===gG;if(!a&&b){aF(this,_.an);return}}if(a=this.f!==_.$m)a=this.a.getState(),a=a===bF||a===cF;a&&dF(this)};
37
- _.t.eg=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===hG?aF(this,_.$m):this.g.error("AVPlay prepares while state is not IDLE")};_.t.dg=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.zf=function(){aF(this,_.Vm)};_.t.getState=function(){return this.f};_.t=eF.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 _.y(m,gF(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(){}};_.xf(m,3);e=b;return _.y(m,b.j.start(a.url,d),5);case 5:e.f=m.f;_.yf(m,4);break;case 3:return f=_.zf(m),b.a.warn(f),_.xf(m,6),g=b,_.y(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.f=m.f;_.yf(m,4);break;case 6:h=_.zf(m),b.a.error(h),b.f=null;case 4:if(!b.f||!fF(b.f)){m.H(0);break}b.h=hF(b);_.xf(m,10);return _.y(m,b.h.G,12);case 12:b.g=iF(b);l=b.l.getConfiguration();b.g.m=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;_.yf(m,0);break;case 10:_.zf(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.Jh=function(a){this.a.debug(_.cv,a);this.w=!0;var b=_.jx(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.Ih=function(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.Ly(this.g,this.m,!0,0),this.m=null)};_.t.T=function(){this.a.debug("onError_")};_.t.Kh=function(){this.j&&this.j.update&&this.j.update()};
41
- _.t.start=function(){var a=this;return _.A(function(b){if(!a.g)return b["return"]();try{a.g.start()}catch(c){a.a.error("Error while starting streaming engine",c)}_.z(b)})};_.t.setTextVisibility=function(a){this.a.debug("Set text visibility",a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)};_.t.release=function(){var a=this;return _.A(function(b){a.l=null;a.f=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.m=null;_.z(b)})};
42
- _.t.destroy=function(){var a=this;return _.A(function(b){switch(b.a){case 1:if(!a.j){b.H(2);break}return _.y(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.g){b.H(4);break}return _.y(b,a.g.destroy(),5);case 5:a.g=null,a.w=!0;case 4:if(!a.h){b.H(0);break}return _.y(b,a.h.destroy(),7);case 7:a.h=null,_.z(b)}})};_.v(nF,_.R);_.t=nF.prototype;_.t.Vf=function(a){var b=a.eventid;a=a.data;switch(b){case iG:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+yF(this,b[0].extra_info).Bit_rate,b=CF(this,{bandwidth:b}))&&(this.w=b,oF(this,b));break;case jG:pF(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.t.Ke=function(a){a.detail.currentState===_.bn&&this.l.off(_.pe,this.Ke)};
43
- _.t.initialize=function(a){var b=this;this.l=a;this.f=this.l.a;this.l.on(_.pe,function(c){b.A||(c=c.detail,c.currentState===_.bn&&(b.a.debug("Current state",c.currentState),b.A=!0,qF(b)))});this.f.on(kG,this.Vf,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(_.pe,this.Ke);this.l.on(_.pe,this.Ke,this);try{var a=OF(this.f);this.g=BF(this,a);var b=this.g[_.Q]||[];b.length&&(this.j=b[0].renditions[0]||null);pF(this)}catch(c){this.a.debug("Could not load track manager")}}};_.t.destroy=function(){this.f.off(kG,this.Vf);this.f=this.l=null};_.t.getVideoTracks=function(){return this.g[_.fi]||[]};_.t.getAudioTracks=function(){return this.g[_.Q]||[]};
45
- _.t.fa=function(){return this.g[_.P]||[]};_.t.ea=function(){return FF(this,_.fi)};_.t.Fa=function(){return FF(this,_.Q)};_.t.Ga=function(){return FF(this,_.P)};_.t.Ta=function(){return this.w};_.t.eb=function(){this.a.info(ME);return null};_.t.fb=function(){this.a.info(ME);return null};_.t.Ia=function(){var a=this.ea();return a?a.track:null};_.t.ka=function(){var a=this.Fa();return a?a.track:null};_.t.la=function(){var a=this.Ga();return a?a.track:null};
46
- _.t.$a=function(a){var b=this;null===a?(a=this.ea(),YF(this.f,a.bandwidth,null).then(function(){pF(b)})):0<a.renditions.length&&this.Za(a.renditions[0])};_.t.ra=function(a){a?uF(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?mF(this.h,a.track):uF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,ZF(this.f,!1),this.l.trigger(new _.I(_.Dj)))};
47
- _.t.Za=function(a){var b=this,c=this.ea();this.f.o||a.width!==c.width||a.height!==c.height||a.bandwidth!==c.bandwidth?(this.w=a,oF(this,a),YF(this.f,c.bandwidth,a.bandwidth).then(function(){pF(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){uF(this,a)};_.t.mb=function(a){this.h?mF(this.h,a.track):uF(this,a)};
48
- _.t.addTextTrack=function(){};_.t.ha=function(){return this.f.o};nF.prototype.isAbrEnabled=nF.prototype.ha;nF.prototype.addTextTrack=nF.prototype.addTextTrack;nF.prototype.setTextRendition=nF.prototype.mb;nF.prototype.setAudioRendition=nF.prototype.lb;nF.prototype.setVideoRendition=nF.prototype.Za;nF.prototype.setTextTrack=nF.prototype.Ba;nF.prototype.setAudioTrack=nF.prototype.ra;nF.prototype.setVideoTrack=nF.prototype.$a;nF.prototype.getTextTrack=nF.prototype.la;nF.prototype.getAudioTrack=nF.prototype.ka;
49
- nF.prototype.getVideoTrack=nF.prototype.Ia;nF.prototype.getLoadingTextRendition=nF.prototype.fb;nF.prototype.getLoadingAudioRendition=nF.prototype.eb;nF.prototype.getLoadingVideoRendition=nF.prototype.Ta;nF.prototype.getTextRendition=nF.prototype.Ga;nF.prototype.getAudioRendition=nF.prototype.Fa;nF.prototype.getVideoRendition=nF.prototype.ea;nF.prototype.getTextTracks=nF.prototype.fa;nF.prototype.getAudioTracks=nF.prototype.getAudioTracks;nF.prototype.getVideoTracks=nF.prototype.getVideoTracks;_.v(GF,_.Jj);_.t=GF.prototype;_.t.Dh=function(){this.w=!0;this.g||this.trigger(new _.I(SF))};_.t.Ch=function(a){this.w=!0;this.trigger(new _.I(dG,{percent:a}))};_.t.Bh=function(){this.w=!1;this.trigger(new _.I(eG))};_.t.Gh=function(){this.trigger(new _.I(fG))};_.t.Fh=function(a,b){this.trigger(new _.I(kG,{eventid:a,data:b}))};_.t.Hh=function(a,b,c,d,e){this.trigger(new _.I(lG,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
- _.t.Eh=function(a,b){this.trigger(new _.I(mG,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Pc&&"Challenge"===b.name)YE(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.m.onError(d)}}};_.t.T=function(a){this.trigger(new _.I(nG,{eventType:a}))};
51
- _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(IF,f,b);g=setTimeout(function(){b.off(IF,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===hG)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){KF(b);d(webapis.avplay.play())},function(f){b.trigger(new _.I(nG));e(f)})})).then(function(){return a()});if(c===cF||c===gG)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===bF?
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()===cF?Promise.resolve():Promise.reject()};
53
- _.t.setPlaybackRate=function(a){var b=this.getState();if(b===gG||b===bF||b===cF){try{webapis.avplay.setSpeed(a),this.C=a}catch(c){return this.a.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.a.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1};_.t.getPlaybackRate=function(){return this.C};
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||""),_.xf(e,2),_.y(e,RF(c),4);case 4:return _.y(e,XF(c,a,b),5);case 5:_.yf(e,0);break;case 2:throw d=_.zf(e),new _.L(_.M,7,7003,null,d);}})};_.t.getState=function(){if(this.g&&this.f)return this.f.lf;try{return webapis.avplay.getState()}catch(a){this.T(JSON.stringify(a))}};
55
- _.t.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.l.trigger(new _.I(_.Le));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.I(_.Ke));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.Pd.stop()}a.j={};a.C=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 OE:this.a.debug("The application does not have the privilege to get the volume.",PE);break;default:this.a.debug(LE,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 OE:this.a.warn("The application does not have the privilege to set the volume.",PE);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.D=a};_.t.getSourceIndex=function(){return this.D};_.t.getLoadedSource=function(){return this.m&&this.m[this.getSourceIndex()]};
59
- var hG="IDLE",gG="READY",bF="PLAYING",cF="PAUSED",zF="VIDEO",sF="AUDIO",tF="TEXT",jG="PLAYER_MSG_RESOLUTION_CHANGED",iG="PLAYER_MSG_BITRATE_CHANGE",WE={PLAYREADY:"PLAYREADY",Vj:"EME_PLAYREADY",ck:"VERIMATRIX",qd:"WIDEVINE_CDM",Wj:"EME_WIDEVINE_CDM",dk:"WIDEVINE_CLASSIC"};_.v($F,_.Jj);_.t=$F.prototype;_.t.uf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.I(_.ed));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.t.sf=function(a){this.trigger(new _.I(_.De,{currentTime:a.currentTime/1E3}))};
60
- _.t.vf=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=_.Bh(d))&&this.o.append([new _.xg(b,c,d)],[])};_.t.tf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.Xf=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
- _.t.T=function(a){this.h.debug("Error: TYPE: "+a.eventType);aF(this.f,_.Zm);a=new _.L(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.I(_.fd,{detail:a}))};
62
- _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(fG,this.uf,this);this.a.on(IF,this.sf,this);this.a.on(lG,this.vf,this);this.a.on(mG,this.tf,this);this.a.on(nG,this.T,this);this.a.on(eG,this.Xf,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=oG;oG+=1;this.j=_.xn(_.Id,{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=[_.df,_.id,"position",_.od,"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];_.zn(c,f);aG(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 _.y(b,a.release(),2);case 2:a.a.off(fG,a.uf);a.a.off(IF,a.sf);a.a.off(lG,a.vf);a.a.off(mG,a.tf);a.a.off(nG,a.T);a.a.off(eG,a.Xf);if(!a.g){b.H(3);break}return _.y(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 pG};_.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()===_.Vm?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 _.Ij};_.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.H(2);break}return _.y(b,a.g.release(),2);case 2:if(!a.o){b.H(4);break}return _.y(b,a.o.destroy(),5);case 5:a.o=null;case 4:return _.y(b,a.a.release(),6);case 6:a.m.release(),a.f.release(),a.A=!1,_.z(b)}})};
68
- _.t.load=function(a){var b=this,c,d,e,f,g;return _.A(function(h){switch(h.a){case 1:_.Sj(a)&&(b.configuration=_.Rj(b.B,a));c=_.xm(b.configuration,["html","native"]);b.o=c.create(b);d=_.fn(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.H(2);break}b.g=new eF;b.g.initialize(b);_.xf(h,3);return _.y(h,b.g.load(d),5);case 5:b.g.start();_.yf(h,2);break;case 3:f=_.zf(h),b.h.error(f);case 2:return _.xf(h,6),_.y(h,b.a.load(b.configuration),8);case 8:_.yf(h,7);break;
69
- case 6:throw g=_.zf(h),b.onError(g),g;case 7:b.m.load(),_.z(h)}})};_.t.play=function(){var a=this;this.trigger(new _.I(_.Wd));aG(this);return this.a.play().then(function(){dF(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){dF(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.I(_.fd,{detail:a});a.severity===_.M&&(aF(this.f,_.Zm),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()===_.Vm};_.t.isPaused=function(){return this.a.getState()===cF};_.t.isMuted=function(){return NF(this.a)};_.t.setMuted=function(a){WF(this.a,a)};_.t.getNetworkEngine=function(){return this.C};_.t.setNetworkEngine=function(a){this.C=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 bG).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};$F.prototype.getTextDisplayer=$F.prototype.getTextDisplayer;$F.prototype.setNetworkEngine=$F.prototype.setNetworkEngine;$F.prototype.getNetworkEngine=$F.prototype.getNetworkEngine;var pG="clpp.tizen",oG=0;bG.prototype.a=function(){return pG};
72
- bG.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.bc||a===_.tj||a===_.gc)&&b){if(_.Th(2))return 2;if(_.Th(3)||_.Th(4)||_.Th(5)||_.Th(6))return _.F("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};bG.prototype.create=function(){return new $F};_.v(cG,_.zo);cG.prototype.Ja=function(){this.a=new bG;_.Xf(this.a)};cG.prototype.Ca=function(){if(this.a){var a=this.a.a();a&&_.Uf[a]&&(delete _.Uf[a],_.Wf.info("Removed Player factory: '"+a+"'"));this.a=null}};cG.prototype.id=function(){return"tizen"};_.B("clpp.tizen.TizenComponent",cG);var SF="onbufferingstart",dG="onbufferingprogress",eG="onbufferingcomplete",fG="onstreamcompleted",IF="oncurrentplaytime",kG="onevent",lG="onsubtitlechange",mG="ondrmevent",nG="onerror",TF="preparingstart",VF="preparingend";};
2
+ var f=function(window){var QE="An unknown error occurred while trying to get volume",RE="Cannot get loading rendition due to platform limitations",SE="PARAM_START_POSITION",TE="SecurityError",UE="The require privilege is: http://tizen.org/privilege/tv.audio",VE="|STARTBITRATE\x3d",WE=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},XE=function(a,b){this.h=a;this.o=null;this.a=_.Id;this.m=null;this.j=!1;this.f=new Map;this.C=b;this.g=new _.H("clpp.tizen.DrmEngine")},$E=function(a){var b,
3
+ c,d;return _.B(function(e){if(1==e.a){b=a.a===_.Qc||a.a===_.Pc;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);_.yf(e,2);return a.a===_.Qc?_.x(e,YE(a),5):_.x(e,ZE(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},_.zf(e,0);d=_.Af(e);a.g.error("Error while configuring CDM for "+a.a,d);throw new _.L(_.M,6,6005,{message:JSON.stringify(d)});})},ZE=function(a,b){var c,d,e,f;return _.B(function(g){c=aF;d=bF;e={};e[d.zg]=!b.Qe;e[d.Ag]=b.hd;""!==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;}_.z(g)})},YE=function(a){var b;return _.B(function(c){b=aF;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)})},cF=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=aF;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=_.Ih([h],_.Fh());l.type=3;l.body=f.buffer;l.method=
6
+ "POST";_.yf(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+SE+(w+SE);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 _.zf(D,0)}E=_.Af(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)})},dF=function(a){this.l=a;this.a=this.l.a;this.f=_.Pm;this.j=_.Qm;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.H("clpp.tizen.StateManager")},fF=function(a,b){if(a.f!==b)if(a.f===_.$m&&b!==_.Pm)a.g.debug(_.Vu+eF(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.Um?(a.o=(new Date).getTime(),a.l.trigger(new _.J(_.tc,{detail:{bufferedTimeMS:-1,
8
+ reason:a.h}}))):a.j===_.Um&&a.l.trigger(new _.J(_.sc,{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(_.re,{detail:d}));a.g.debug("State changed:",eF(a.j),"-\x3e",eF(a.f))}},eF=function(a){return Object.keys(_.Ym)[a]},iF=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case gF:c=_.cn;break;case hF:c=_.bn;break;default:a.l.isEnded()?c=_.Wm:a.g.debug("Inconsistent AVPlay playback state:",b)}fF(a,
9
+ c)}},jF=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")},kF=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},lF=function(a){var b,c;return _.B(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.x(d,_.vp(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
+ mF=function(a){var b=document.createElement(_.Qe),c=new _.Cw,d=new _.Nv(function(){return null}),e=a.l.getTextDisplayer();return new _.Iw(b,c,e,d,a.l.getConfiguration())},nF=function(a){var b={wb:function(){return a.l.getPosition()},X:a.h,Ab:a.l.getNetworkEngine(),Je:a.Lh.bind(a),Ie:a.Kh.bind(a),onError:a.U.bind(a),ag:function(){},onEvent:function(){},fg:a.Mh.bind(a),Pd:function(){},re:function(){return new _.Lx},fe:function(){return!1},bd:null};return new _.Fy(a.f,b)},oF=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},pF=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 _.ei(String(c++),_.P);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=
12
+ a[d].kind||_.mv;var f=new _.mi(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},qF=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.Hy(a.g,_.Be),c=null;if(b){a=pF(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},rF=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=oF(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):(_.Sy(a.g,c,!0,0),a.l.trigger(new _.J(_.Ej))),a.o=c.language):a.a.error(_.Uu,d.id)}},sF=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},tF=function(a,b){a.l.trigger(new _.J(_.Ue,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},
14
+ uF=function(a){var b=a.ga();b&&a.l.trigger(new _.J(_.qc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},vF=function(a){var b=a.l.getConfiguration(),c=_.bi(b.preferredAudioLanguage||[]),d=a.g[_.Q]||[];if(d.length){var e=null;c.some(function(g){e=_.Hv(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")},zF=function(a,b){if(b){var c=b.track.type.toUpperCase();wF(a.f,c,Number(b.id)).then(function(){c===xF&&(a.j=b,a.l.trigger(new _.J(_.Dj)));c===yF&&(a.m=b,a.l.trigger(new _.J(_.Ej)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},AF=
16
+ function(a,b,c){var d=_.Gi(b.language||_.He);c.language=_.fi(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.nc;a=new _.mi(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},BF=function(a,b,c){c.mimeType=_.Se;a=new _.mi(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},CF=function(a,b,c){b=_.Gi(b.track_lang||_.He);c.mimeType="text/ttml";c.language=
17
+ _.fi(b);c.kind=_.mv;return new _.mi(String(a),c)},DF=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},GF=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===EF}),f=b.filter(function(n){return n.type===xF}),g=[],h=0;h<f.length;h++){var l=DF(a,f[h].extra_info);if(l){var m=_.Gi(l.language||_.He);
18
+ m=_.fi(m);m=c(g,m);m||(m=new _.ei(String(a.o++),_.Q),g.push(m));m.renditions.push(AF(f[h].index,l,m))}else a.a.warn("Skipping audio stream with no extra info")}f=new _.ei(String(a.o++),_.gi);for(h=0;h<e.length;h++)(l=DF(a,e[h].extra_info))?f.renditions.push(BF(e[h].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?pF(a.h):FF(a,b);d[_.gi]=[f];d[_.Q]=g;d[_.P]=e;return d},FF=function(a,b){for(var c=b.filter(function(h){return h.type===yF}),d=[],e=0;e<c.length;e++){var f=DF(a,
19
+ c[e].extra_info);if(f){var g=new _.ei(String(a.o++),_.P);g.renditions.push(CF(c[e].index,f,g));d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},HF=function(a,b){for(var c=a.g[_.gi]||[],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},IF=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},KF=function(a,b){if(b===_.P&&a.h)return qF(a.h);var c=JF(a.f)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.gi&&(d=DF(a,c.extra_info),d=HF(a,{width:d.Width,height:d.Height}));b===_.Q&&(c?(d=IF(a,c,_.Q),a.j=d):d=a.j);b===_.P&&(c?(d=IF(a,c,_.P),a.m=d):d=a.m);return d},LF=function(a){_.Kj.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={}},MF=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)})},OF=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(NF,
22
+ {currentTime:b}))},onevent:a.Hh.bind(a),onsubtitlechange:a.Jh.bind(a),ondrmevent:a.Gh.bind(a),onerror:a.U.bind(a)})}catch(b){a.a.error(b)}},PF=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)}},QF=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",VE+d)}catch(e){a.a.debug(e)}},
23
+ RF=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+VE+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},UF=function(a){return{position:a.getPosition(),state:a.l.getState(),nf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:SF(a),volume:a.getVolume(),Pj:TF(a),Wh:JF(a)}},WF=function(a){var b,c;return _.B(function(d){if(1==d.a)return _.x(d,VF(),2);if(3!=d.a)return b=new Promise(function(e){(new _.Ni(e)).Z(5)}),
24
+ _.x(d,Promise.race([MF(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)})},bG=function(a,b,c){var d,e,f,g,h,l,m,n;return _.B(function(p){switch(p.a){case 1:a.m=_.gn(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(XF)),f=c.currentPosition);
25
+ _.yf(p,2);g=a.m[d].url;h=a.m[d].type;h!==_.bc||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);e.nextBandwidth?(RF(a,e.nextBandwidth),a.o=!1):(a.o||QF(a,e),a.o=!0);OF(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 XE(b.drm,m);return _.x(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.J(YF)),
26
+ _.x(p,ZF(a),6);case 6:a.g||a.trigger(new _.J($F));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&&aG(a,b.muted),b.autoplay&&a.l.play()["catch"](function(q){a.a.debug("Autoplay failed",q)}));_.zf(p,0);break;case 2:throw n=_.Af(p),a.a.debug("Error while attempting to load source."),n;}})},ZF=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
+ PF(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)}}))})},cG=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=UF(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===hF?a.pause():a.play()})}catch(e){return Promise.reject(e)}},TF=function(a){return a.g&&a.f?a.f.Pj:webapis.avplay.getTotalTrackInfo()},JF=function(a){return a.g&&a.f?a.f.Wh:webapis.avplay.getCurrentStreamInfo()},wF=function(a,b,c){b=b.toUpperCase();b===yF&&dG(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 _.Ni(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)})},dG=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)}},aG=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case TE:a.a.warn("The application does not have the privilege to set mute.",UE);break;default:a.a.warn(QE,c)}}},SF=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case TE:a.a.warn("The application doesn't have the privilege to get the mute state.",UE);break;default:a.a.warn(QE,c)}}return!!b},VF=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
31
+ WE(c,"load",function(d){return a(d)});WE(c,_.gd,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},eG=function(){_.Kj.call(this);this.a=new LF(this);this.f=new dF(this);this.configuration=this.B=_.Qj();this.w=null;this.h=new _.H("clpp.tizen.Player");this.j=null;this.m=new sF;this.D=new _.Zh;this.o=this.g=null;this.A=!1},fG=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())},gG=function(){},hG=function(){this.a=null};
33
+ XE.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.B(function(h){if(1==h.a){b=_.mk[a.h.env]||null;if(!b)throw a.g.debug(_.xa,_.gb+a.h.env+_.aa),new _.L(_.M,6,6015,_.ya+a.h.env+"' is missing.");a.m={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";d=_.ok(b,a.h.customData);(e=d[_.Pc])&&a.f.set(_.Pc,{hd:e.licenseUrl||"",customData:c,Qe:!1});(f=d[_.Qc])&&a.f.set(_.Qc,{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(_.Pc))a.a=_.Pc;else if(a.f.get(_.Qc))a.a=_.Qc;else throw new _.L(_.M,6,6001,"Configuration for the target system is missing.");return _.x(h,$E(a),2)}a.j=!0;_.z(h)})};XE.prototype.release=function(){var a=this;return _.B(function(b){a.j=!1;a.o=null;a.a=_.Id;a.m=null;a.f=new Map;_.z(b)})};XE.prototype.getDrmInfo=function(){return this.o};
35
+ var bF={zg:"DeleteLicenseAfterUse",Ag:"LicenseServer",ak:"GetChallenge",bk:"HttpHeader",ek:"UserAgent",Xj:"Cookie",yg:"CustomData"};_.t=dF.prototype;_.t.initialize=function(){this.a.on(XF,this.Af,this);this.a.on(iG,this.zf,this);this.a.on(jG,this.yf,this);this.a.on(YF,this.hg,this);this.a.on($F,this.gg,this);this.a.on(kG,this.Bf,this)};_.t.release=function(){fF(this,_.Pm);this.m=!1;this.o=-1;this.h=2};_.t.destroy=function(){this.release();this.a.off(XF,this.Af);this.a.off(iG,this.zf);this.a.off(jG,this.yf);this.a.off(YF,this.hg);this.a.off($F,this.gg);this.a.off(kG,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;fF(this,_.Um)};_.t.zf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",eF(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()===lG;if(!a&&b){fF(this,_.bn);return}}if(a=this.f!==_.an)a=this.a.getState(),a=a===gF||a===hF;a&&iF(this)};
37
+ _.t.hg=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===mG?fF(this,_.an):this.g.error("AVPlay prepares while state is not IDLE")};_.t.gg=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.Bf=function(){fF(this,_.Wm)};_.t.getState=function(){return this.f};_.t=jF.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,lF(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(){}};_.yf(m,3);e=b;return _.x(m,b.j.start(a.url,d),5);case 5:e.f=m.f;_.zf(m,4);break;case 3:return f=_.Af(m),b.a.warn(f),_.yf(m,6),g=b,_.x(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.f=m.f;_.zf(m,4);break;case 6:h=_.Af(m),b.a.error(h),b.f=null;case 4:if(!b.f||!kF(b.f)){m.H(0);break}b.h=mF(b);_.yf(m,10);return _.x(m,b.h.I,12);case 12:b.g=nF(b);l=b.l.getConfiguration();b.g.j=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;_.zf(m,0);break;case 10:_.Af(m),
40
+ b.a.debug("Could not setup media source..."),b.h=null,b.g=null,b.j=null,b.f=null,_.z(m)}})};_.t.Lh=function(a){this.a.debug(_.gv,a);this.w=!0;var b=_.nx(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&&(_.Sy(this.g,this.m,!0,0),this.m=null)};_.t.U=function(){this.a.debug("onError_")};_.t.Mh=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(sF,_.R);_.t=sF.prototype;_.t.Yf=function(a){var b=a.eventid;a=a.data;switch(b){case nG:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+DF(this,b[0].extra_info).Bit_rate,b=HF(this,{bandwidth:b}))&&(this.w=b,tF(this,b));break;case oG:uF(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.t.Me=function(a){a.detail.currentState===_.cn&&this.l.off(_.re,this.Me)};
43
+ _.t.initialize=function(a){var b=this;this.l=a;this.f=this.l.a;this.l.on(_.re,function(c){b.A||(c=c.detail,c.currentState===_.cn&&(b.a.debug("Current state",c.currentState),b.A=!0,vF(b)))});this.f.on(pG,this.Yf,this)};_.t.release=function(){this.g={};this.h=this.w=this.m=this.j=null;this.A=!1;this.o=1};
44
+ _.t.load=function(){if(this.f&&!(0<Object.keys(this.g).length)){this.h=this.l.g;this.l.off(_.re,this.Me);this.l.on(_.re,this.Me,this);try{var a=TF(this.f);this.g=GF(this,a);var b=this.g[_.Q]||[];b.length&&(this.j=b[0].renditions[0]||null);uF(this)}catch(c){this.a.debug("Could not load track manager")}}};_.t.destroy=function(){this.f.off(pG,this.Yf);this.f=this.l=null};_.t.getVideoTracks=function(){return this.g[_.gi]||[]};_.t.getAudioTracks=function(){return this.g[_.Q]||[]};
45
+ _.t.ha=function(){return this.g[_.P]||[]};_.t.ga=function(){return KF(this,_.gi)};_.t.Fa=function(){return KF(this,_.Q)};_.t.Ga=function(){return KF(this,_.P)};_.t.Ua=function(){return this.w};_.t.fb=function(){this.a.info(RE);return null};_.t.gb=function(){this.a.info(RE);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(),cG(this.f,a.bandwidth,null).then(function(){uF(b)})):0<a.renditions.length&&this.$a(a.renditions[0])};_.t.sa=function(a){a?zF(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?rF(this.h,a.track):zF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,dG(this.f,!1),this.l.trigger(new _.J(_.Ej)))};
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,tF(this,a),cG(this.f,c.bandwidth,a.bandwidth).then(function(){uF(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){zF(this,a)};_.t.nb=function(a){this.h?rF(this.h,a.track):zF(this,a)};
48
+ _.t.addTextTrack=function(){};_.t.ja=function(){return this.f.o};sF.prototype.isAbrEnabled=sF.prototype.ja;sF.prototype.addTextTrack=sF.prototype.addTextTrack;sF.prototype.setTextRendition=sF.prototype.nb;sF.prototype.setAudioRendition=sF.prototype.mb;sF.prototype.setVideoRendition=sF.prototype.$a;sF.prototype.setTextTrack=sF.prototype.Ba;sF.prototype.setAudioTrack=sF.prototype.sa;sF.prototype.setVideoTrack=sF.prototype.ab;sF.prototype.getTextTrack=sF.prototype.na;sF.prototype.getAudioTrack=sF.prototype.ma;
49
+ sF.prototype.getVideoTrack=sF.prototype.Ia;sF.prototype.getLoadingTextRendition=sF.prototype.gb;sF.prototype.getLoadingAudioRendition=sF.prototype.fb;sF.prototype.getLoadingVideoRendition=sF.prototype.Ua;sF.prototype.getTextRendition=sF.prototype.Ga;sF.prototype.getAudioRendition=sF.prototype.Fa;sF.prototype.getVideoRendition=sF.prototype.ga;sF.prototype.getTextTracks=sF.prototype.ha;sF.prototype.getAudioTracks=sF.prototype.getAudioTracks;sF.prototype.getVideoTracks=sF.prototype.getVideoTracks;_.v(LF,_.Kj);_.t=LF.prototype;_.t.Fh=function(){this.w=!0;this.g||this.trigger(new _.J(XF))};_.t.Eh=function(a){this.w=!0;this.trigger(new _.J(iG,{percent:a}))};_.t.Dh=function(){this.w=!1;this.trigger(new _.J(jG))};_.t.Ih=function(){this.trigger(new _.J(kG))};_.t.Hh=function(a,b){this.trigger(new _.J(pG,{eventid:a,data:b}))};_.t.Jh=function(a,b,c,d,e){this.trigger(new _.J(qG,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
+ _.t.Gh=function(a,b){this.trigger(new _.J(rG,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Qc&&"Challenge"===b.name)cF(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(sG,{eventType:a}))};
51
+ _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(NF,f,b);g=setTimeout(function(){b.off(NF,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===mG)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){PF(b);d(webapis.avplay.play())},function(f){b.trigger(new _.J(sG));e(f)})})).then(function(){return a()});if(c===hF||c===lG)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===gF?
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()===hF?Promise.resolve():Promise.reject()};
53
+ _.t.setPlaybackRate=function(a){var b=this.getState();if(b===lG||b===gF||b===hF){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||""),_.yf(e,2),_.x(e,WF(c),4);case 4:return _.x(e,bG(c,a,b),5);case 5:_.zf(e,0);break;case 2:throw d=_.Af(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(_.Me));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.J(_.Le));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 TE:this.a.debug("The application does not have the privilege to get the volume.",UE);break;default:this.a.debug(QE,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 TE:this.a.warn("The application does not have the privilege to set the volume.",UE);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 mG="IDLE",lG="READY",gF="PLAYING",hF="PAUSED",EF="VIDEO",xF="AUDIO",yF="TEXT",oG="PLAYER_MSG_RESOLUTION_CHANGED",nG="PLAYER_MSG_BITRATE_CHANGE",aF={PLAYREADY:"PLAYREADY",Yj:"EME_PLAYREADY",fk:"VERIMATRIX",sd:"WIDEVINE_CDM",Zj:"EME_WIDEVINE_CDM",gk:"WIDEVINE_CLASSIC"};_.v(eG,_.Kj);_.t=eG.prototype;_.t.wf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.J(_.fd));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(_.Ee,{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=_.Ch(d))&&this.o.append([new _.yg(b,c,d)],[])};_.t.vf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.$f=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
+ _.t.U=function(a){this.h.debug("Error: TYPE: "+a.eventType);fF(this.f,_.$m);a=new _.L(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.J(_.gd,{detail:a}))};
62
+ _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(kG,this.wf,this);this.a.on(NF,this.uf,this);this.a.on(qG,this.xf,this);this.a.on(rG,this.vf,this);this.a.on(sG,this.U,this);this.a.on(jG,this.$f,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=tG;tG+=1;this.j=_.zn(_.Jd,{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=[_.ef,_.jd,"position",_.pd,"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];_.Bn(c,f);fG(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(kG,a.wf);a.a.off(NF,a.uf);a.a.off(qG,a.xf);a.a.off(rG,a.vf);a.a.off(sG,a.U);a.a.off(jG,a.$f);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 uG};_.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()===_.Wm?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 _.Jj};_.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:_.Tj(a)&&(b.configuration=_.Sj(b.B,a));c=_.ym(b.configuration,["html","native"]);b.o=c.create(b);d=_.gn(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.H(2);break}b.g=new jF;b.g.initialize(b);_.yf(h,3);return _.x(h,b.g.load(d),5);case 5:b.g.start();_.zf(h,2);break;case 3:f=_.Af(h),b.h.error(f);case 2:return _.yf(h,6),_.x(h,b.a.load(b.configuration),8);case 8:_.zf(h,7);break;
69
+ case 6:throw g=_.Af(h),b.onError(g),g;case 7:b.m.load(),_.z(h)}})};_.t.play=function(){var a=this;this.trigger(new _.J(_.Xd));fG(this);return this.a.play().then(function(){iF(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){iF(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.J(_.gd,{detail:a});a.severity===_.M&&(fF(this.f,_.$m),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()===_.Wm};_.t.isPaused=function(){return this.a.getState()===hF};_.t.isMuted=function(){return SF(this.a)};_.t.setMuted=function(a){aG(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 gG).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};eG.prototype.getTextDisplayer=eG.prototype.getTextDisplayer;eG.prototype.setNetworkEngine=eG.prototype.setNetworkEngine;eG.prototype.getNetworkEngine=eG.prototype.getNetworkEngine;var uG="clpp.tizen",tG=0;gG.prototype.a=function(){return uG};
72
+ gG.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.bc||a===_.uj||a===_.gc)&&b){if(_.Uh(2))return 2;if(_.Uh(3)||_.Uh(4)||_.Uh(5)||_.Uh(6))return _.G("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};gG.prototype.create=function(){return new eG};_.v(hG,_.Bo);hG.prototype.Ja=function(){this.a=new gG;_.$f(this.a)};hG.prototype.Ca=function(){if(this.a){var a=this.a.a();a&&_.Wf[a]&&(delete _.Wf[a],_.Xf.info("Removed Player factory: '"+a+"'"));this.a=null}};hG.prototype.id=function(){return"tizen"};_.C("clpp.tizen.TizenComponent",hG);var XF="onbufferingstart",iG="onbufferingprogress",jG="onbufferingcomplete",kG="onstreamcompleted",NF="oncurrentplaytime",pG="onevent",qG="onsubtitlechange",rG="ondrmevent",sG="onerror",YF="preparingstart",$F="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 os='application/mp4; codecs\x3d"stpp.ttml"',ps='application/mp4; codecs\x3d"stpp.ttml.im1i"',qs='application/mp4; codecs\x3d"stpp.ttml.im1t"',rs="backgroundColor",ss="direction",ts="displayAlign",us="region",vs="sans-serif",ws="textAlign",xs="textDecoration",ys="writingMode",zs=function(a,b,c){this.g=a;this.f=b;this.a=c},As=function(a,b,c){zs.call(this,a,[],c);this.h=b||""},Bs=function(a,b,c){zs.call(this,a,b,c)},Cs=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},Ks=function(a,b){var c=null;if(Ds.test(a)){c=Ds.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 Es.test(a)?c=Fs(Es,a):Gs.test(a)?c=Fs(Gs,a):Hs.test(a)?(c=Hs.exec(a),c=Number(c[1])/b.frameRate):Is.test(a)?(c=Is.exec(a),c=Number(c[1])/b.a):Js.test(a)&&(c=Fs(Js,a));return c},Fs=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)},Ls=function(a){return a.split(":").pop()},Ms=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},Os=function(a,b){for(;Ns.test(a);){var c=Ns.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},Ps=function(a,b,c,d,e,f,g){zs.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},Qs=function(a,b,c){a=Cs(a,b,ws);if(!a&&c&&(a=Cs(c,b,ws),!a&&"rltb"===Cs(c,b,ys)))return _.he;switch(a){case _.Ac:return _.sg;case _.he:case _.dd:return _.he;default:return _.od}},
5
- Rs=function(a,b,c){if(_.xh(a.o))return document.createTextNode(_.Bh(a.o||""));if(a.w)return _.xn("br");for(var d=_.xn("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.yn(d,f.value);a=_.u(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(Rs(c.get(e.value),b,c));return d},Ss=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]))},Ts=function(a,
6
- b,c){zs.call(this,a,b,c)},Ws=function(a,b,c,d){var e=Us.exec(a);a=Vs.exec(a);return typeof b===_.k&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},Xs=function(a,b){return typeof b===_.k&&0<b?_.yg:Vs.test(a)?0:_.yg},Ys=function(a,b){zs.call(this,"root-container",[],b);this.h=a},Zs=function(a,b,c){return typeof a===_.k?a:typeof b===_.k?b:c},$s=function(a,b){var c=a.getAttribute("extent");return(c=Vs.exec(c))?Number(c[b]):null},bt=function(a){a=a.getAttribute("cellResolution");return(a=at.exec(a))?
7
- Number(a[2]):null},ct=function(a,b,c){zs.call(this,a,b,c)},dt=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=[]},ft=function(a){return et.some(function(b){return b in a.attributes})},gt=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,_.kf(gt(a,a.a.get(e).f)).concat([e]));return c},it=function(){return"inline-"+ht++},jt=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})},kt=function(a){this.a=a.firstChild;this.f=new Set},lt=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},mt=function(a){return Ls(a.g.nodeName)},nt=function(){this.a=new Map},pt=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=_.kf(l.j).concat();-1===["#text","span","br"].indexOf(b.nodeName)&&(c=l.a,d=l.h,f=_.kf(l.f).concat(),
9
- g={},ot.forEach(function(n){n in l.attributes&&(g[n]=l.attributes[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(us)&&(c=b.getAttribute(us));b.hasAttribute(_.ve)&&f.push.apply(f,_.kf(b.getAttribute(_.ve).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=Ls(h);g[m]=b.getAttribute(h)}d=g.backgroundImage}c=new lt(b,c,d,e,f,g);a.a.set(b,c);return c},qt=function(a){this.a=a;this.f=new DOMParser},rt=function(a){this.f=
10
- a},st=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")},tt=function(){},ut=function(a){this.f=new qt(a);this.a=new _.H("clpp.ttml.Mp4TtmlParser")},vt=function(){this.a=new tt};zs.prototype.getId=function(){return this.g};zs.prototype.getAttribute=function(a){return this.a[a]};_.v(As,zs);_.v(Bs,zs);var Ds=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Es=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Gs=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Hs=/^(\d*(?:\.\d*)?)f$/,Is=/^(\d*(?:\.\d*)?)t$/,Js=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Us=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Vs=/^(\d+)px (\d+)px$/,at=/^(\d+) (\d+)$/,Ns=/(\d+)px/,wt=/^(\d+px|\d+em|\d*\.?\d+c)$/,et=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
- "color",rs,"opacity","padding","zIndex",ws,ts,ys,ss,xs,"textOutline"],ot=["begin",_.dd];_.v(Ps,Bs);
12
- Ps.prototype.build=function(a,b,c,d,e,f,g){var h=Ks(this.a.begin,b);b=Ks(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.xn(_.Vc);for(var l=_.u(this.h),m=l.next();!m.done;m=l.next())c.appendChild(Rs(g.get(m.value),e,g));g=new _.xg(h,b,c.innerHTML.trim(),_.Fe);g.cssClassList=_.kf(this.f).concat();g.textAlign=Qs(this,e,null);g.writingMode=_.tg;g.line=-1;g.lineInterpretation=_.ug;g.lineAlign=_.vg;g.containerRows=Zs(null,bt(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
- Qs(this,e,f);a:switch(Cs(f,e,ys)){case "tb":case "tblr":a=_.Ne;break a;case "tbrl":a=_.Oe;break a;default:a=_.tg}g.writingMode=a;a:switch(Cs(f,e,ts)){case _.Ac:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Cs(f,e,ts)){case _.Ac:a=1;break a;default:a=_.ug}g.lineInterpretation=a;a:switch(Cs(f,e,ts)){case _.Ac:e=_.Ac;break a;default:e=_.vg}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(Ts,Bs);
15
- Ts.prototype.build=function(a,b){var c=new _.Ag;c.id=this.getId();var d=Zs(a.h.containerWidth,$s(a,1),720),e=Zs(a.h.containerHeight,$s(a,2),480);a:switch(Cs(this,b,ts)){case "after":var f="flex-start";break a;case _.Ac:f=_.Ac;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Cs(this,b,ys)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Lc}c.writingMode=f;f=this.getAttribute("extent")||Cs(this,b,"extent");c.width=Ws(f,d,1,100);c.widthUnits=Xs(f,d);c.height=
16
- Ws(f,e,2,100);c.heightUnits=Xs(f,e);f=this.getAttribute("origin")||Cs(this,b,"origin");c.viewportAnchorX=Ws(f,d,1,0);c.viewportAnchorY=Ws(f,e,2,0);c.viewportAnchorUnits=Xs(f,d);c.cssClassList=_.kf(this.f).concat();return c};_.v(Ys,zs);_.v(ct,zs);
17
- ct.prototype.build=function(a){var b=null;var c=bt(a);c&&(b=Zs(a.h.containerHeight,$s(a,2),480)/c);b=Zs(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.u(xt.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+":"+Ms(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&&!wt.test(g)&&wt.test(h)&&wt.test(l)?(e=g,f=h):2===d.length&&!wt.test(g)&&wt.test(h)?(e=g,f=h):2===d.length&&wt.test(g)&&wt.test(h)&&(f=g);if(""!==f){f=Ms(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",vs).replace("proportionalSerif",vs).replace("sansSerif",vs).replace("default",vs)+";":"");a:{if(xs 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
- Ms(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=Ms(e),e=Os(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=Ms(d);d=Os(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 xt=new Map([["color","color"],[rs,"background-color"],[ss,ss],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var ht=0;kt.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!yt.has(Ls(a.nodeName))||zt.has(Ls(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&&!yt.has(Ls(a.nodeName))));var b=this.a;this.a=a;return b};var yt=new Set(["tt","head","layout",_.zd,_.kd,us,"styling",_.ve,"body",_.Vc,"p","span","br"]),zt=new Set([_.ve,_.kd]);lt.prototype.getId=function(){return this.attributes.id};qt.prototype.parseInit=function(){};
22
- qt.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.J.Ma(this.a.ttml||{}),e=_.N(a,0,c[0]);e=_.oh(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Ce)}catch(n){throw new _.L(_.M,2,2005,"Failed to parse TTML.");}d=new dt(d);e=new nt;f=new kt(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=_.ak(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new As(m,l,{imageType:"PNG",encoding:"Base64"}));
23
- b+=h}for(;f.a;)a=f.next(),a=pt(e,a),"tt"===mt(a)&&(d.j=new Ys(d.A,Object.assign({},a.attributes))),"tt"===mt(a)&&(d.o=new Ss(a.attributes.frameRate,a.attributes.subFrameRate,a.attributes.frameRateMultiplier,a.attributes.tickRate)),mt(a)!==_.kd||a.attributes.begin||a.attributes.end||(c="#"+a.getId(),d.g.set(c,new As(c,a.g.textContent,a.attributes))),mt(a)===_.kd&&a.attributes.begin&&a.attributes.end?(c="#"+it(),b=new As(c,a.g.textContent,a.attributes),d.g.set(c,b),c=b):c=null,c&&(a.h=c.getId()),mt(a)===
24
- _.ve&&(c=a.getId()||it(),b=new ct(c,a.f,Object.assign({},a.attributes)),d.a.set(c,b),a.a&&d.h.get(a.a).f.push(c)),mt(a)!==_.ve&&ft(a)?(c=it(),b=new ct(c,[],Object.assign({},a.attributes)),d.a.set(c,b),c=b):c=null,c&&a.f.push(c.getId()),mt(a)!==_.Vc||!a.attributes.extent&&!a.attributes.origin?c=null:(c=it(),b=new Ts(c,gt(d,a.f),Object.assign({},a.attributes)),d.h.set(c,b),c=b),c&&(a.a=c.getId()),mt(a)!==us?c=null:(c=a.getId(),b=new Ts(c,gt(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(mt(a))||0===c.length?c=null:(g=c[c.length-1],d.f.has(g)?(c=it(),b=new Ps(c,"#text"===a.g.nodeName?a.g.textContent:null,"br"===mt(a),a.a,a.h,gt(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"===mt(a)||a.h?(c=it(),b=new Ps(c,null,!1,a.a,a.h,gt(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=jt(d);f=[];a=_.u(d.a.values());for(c=a.next();!c.done;c=a.next())f.push.apply(f,
26
- _.kf(c.value.build(d.j)));return{cues:e,styles:f}};rt.prototype.a=function(a){a=(new qt(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=st(c.startTime)+" --\x3e "+st(c.endTime),e=[];switch(c.textAlign){case _.od:e.push("align:left");break;case _.he:e.push("align:right");break;case _.sg:e.push("align:middle");break;case _.od:e.push("align:start");break;case _.he:e.push("align:end")}switch(c.writingMode){case _.Ne:e.push("vertical:lr");break;
27
- case _.Oe:e.push("vertical:rl")}b+=d+(e.length?" "+e.join(" "):"")+"\n";b+=c.payload+"\n\n"}return _.sh(b)};tt.prototype.probe=function(a,b){return a===_.fc&&b===_.Be};tt.prototype.create=function(a){return new rt(a)};ut.prototype.parseInit=function(a){var b=!1;(new _.Fk).M(_.Cd,_.Gk).M(_.Ee,_.Gk).M(_.xd,_.Gk).M(_.Bd,_.Gk).M(_.se,_.Gk).V(_.ue,_.Hk).M("stpp",function(c){b=!0;c.Wa.stop()}).parse(a);if(!b)throw new _.L(_.M,2,2007);};
28
- ut.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Fk).M("moof",_.Gk).M("traf",_.Gk).V("subs",function(h){for(var l=_.U(h.F),m=0;m<l;++m){h.F.skip(4);for(var n=_.Ak(h.F),p=0;p<n;++p){var q=1===h.version?_.U(h.F):_.Ak(h.F);g.push(q);h.F.skip(6)}}}).M(_.wd,_.Ik(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(vt,_.zo);vt.prototype.Ja=function(){_.Rp[_.fc]=qt;_.Rp[_.dc]=ut;_.Rp[os]=ut;_.Rp[qs]=ut;_.Rp[ps]=ut;_.Ci.push(this.a)};vt.prototype.Ca=function(){_.Sp(_.fc);_.Sp(_.dc);_.Sp(os);_.Sp(qs);_.Sp(ps);_.Ei(this.a)};vt.prototype.id=function(){return _.ye};_.B("clpp.ttml.TtmlComponent",vt);};
2
+ var f=function(window){var ss='application/mp4; codecs\x3d"stpp.ttml"',ts='application/mp4; codecs\x3d"stpp.ttml.im1i"',us='application/mp4; codecs\x3d"stpp.ttml.im1t"',vs="backgroundColor",ws="direction",xs="displayAlign",ys="region",zs="sans-serif",As="textAlign",Bs="textDecoration",Cs="writingMode",Ds=function(a,b,c){this.g=a;this.f=b;this.a=c},Es=function(a,b,c){Ds.call(this,a,[],c);this.h=b||""},Fs=function(a,b,c){Ds.call(this,a,b,c)},Gs=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},Os=function(a,b){var c=null;if(Hs.test(a)){c=Hs.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 Is.test(a)?c=Js(Is,a):Ks.test(a)?c=Js(Ks,a):Ls.test(a)?(c=Ls.exec(a),c=Number(c[1])/b.frameRate):Ms.test(a)?(c=Ms.exec(a),c=Number(c[1])/b.a):Ns.test(a)&&(c=Js(Ns,a));return c},Js=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)},Ps=function(a){return a.split(":").pop()},Qs=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},Ss=function(a,b){for(;Rs.test(a);){var c=Rs.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},Ts=function(a,b,c,d,e,f,g){Ds.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},Us=function(a,b,c){a=Gs(a,b,As);if(!a&&c&&(a=Gs(c,b,As),!a&&"rltb"===Gs(c,b,Cs)))return _.ie;switch(a){case _.Ac:return _.tg;case _.ie:case _.ed:return _.ie;default:return _.pd}},
5
+ Vs=function(a,b,c){if(_.yh(a.o))return document.createTextNode(_.Ch(a.o||""));if(a.w)return _.zn("br");for(var d=_.zn("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.An(d,f.value);a=_.u(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(Vs(c.get(e.value),b,c));return d},Ws=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]))},Xs=function(a,
6
+ b,c){Ds.call(this,a,b,c)},$s=function(a,b,c,d){var e=Ys.exec(a);a=Zs.exec(a);return typeof b===_.k&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},at=function(a,b){return typeof b===_.k&&0<b?_.zg:Zs.test(a)?0:_.zg},bt=function(a,b){Ds.call(this,"root-container",[],b);this.h=a},ct=function(a,b,c){return typeof a===_.k?a:typeof b===_.k?b:c},dt=function(a,b){var c=a.getAttribute("extent");return(c=Zs.exec(c))?Number(c[b]):null},ft=function(a){a=a.getAttribute("cellResolution");return(a=et.exec(a))?
7
+ Number(a[2]):null},gt=function(a,b,c){Ds.call(this,a,b,c)},ht=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=[]},jt=function(a){return it.some(function(b){return b in a.attributes})},kt=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,_.lf(kt(a,a.a.get(e).f)).concat([e]));return c},mt=function(){return"inline-"+lt++},nt=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})},ot=function(a){this.a=a.firstChild;this.f=new Set},pt=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},qt=function(a){return Ps(a.g.nodeName)},rt=function(){this.a=new Map},tt=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=_.lf(l.j).concat();-1===["#text","span","br"].indexOf(b.nodeName)&&(c=l.a,d=l.h,f=_.lf(l.f).concat(),
9
+ g={},st.forEach(function(n){n in l.attributes&&(g[n]=l.attributes[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(ys)&&(c=b.getAttribute(ys));b.hasAttribute(_.we)&&f.push.apply(f,_.lf(b.getAttribute(_.we).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=Ps(h);g[m]=b.getAttribute(h)}d=g.backgroundImage}c=new pt(b,c,d,e,f,g);a.a.set(b,c);return c},ut=function(a){this.a=a;this.f=new DOMParser},vt=function(a){this.f=
10
+ a},wt=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")},xt=function(){},yt=function(a){this.f=new ut(a);this.a=new _.H("clpp.ttml.Mp4TtmlParser")},zt=function(){this.a=new xt};Ds.prototype.getId=function(){return this.g};Ds.prototype.getAttribute=function(a){return this.a[a]};_.v(Es,Ds);_.v(Fs,Ds);var Hs=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Is=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Ks=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Ls=/^(\d*(?:\.\d*)?)f$/,Ms=/^(\d*(?:\.\d*)?)t$/,Ns=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Ys=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Zs=/^(\d+)px (\d+)px$/,et=/^(\d+) (\d+)$/,Rs=/(\d+)px/,At=/^(\d+px|\d+em|\d*\.?\d+c)$/,it=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
+ "color",vs,"opacity","padding","zIndex",As,xs,Cs,ws,Bs,"textOutline"],st=["begin",_.ed];_.v(Ts,Fs);
12
+ Ts.prototype.build=function(a,b,c,d,e,f,g){var h=Os(this.a.begin,b);b=Os(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.zn(_.Wc);for(var l=_.u(this.h),m=l.next();!m.done;m=l.next())c.appendChild(Vs(g.get(m.value),e,g));g=new _.yg(h,b,c.innerHTML.trim(),_.Ge);g.cssClassList=_.lf(this.f).concat();g.textAlign=Us(this,e,null);g.writingMode=_.ug;g.line=-1;g.lineInterpretation=_.vg;g.lineAlign=_.wg;g.containerRows=ct(null,ft(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
+ Us(this,e,f);a:switch(Gs(f,e,Cs)){case "tb":case "tblr":a=_.Oe;break a;case "tbrl":a=_.Pe;break a;default:a=_.ug}g.writingMode=a;a:switch(Gs(f,e,xs)){case _.Ac:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Gs(f,e,xs)){case _.Ac:a=1;break a;default:a=_.vg}g.lineInterpretation=a;a:switch(Gs(f,e,xs)){case _.Ac:e=_.Ac;break a;default:e=_.wg}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(Xs,Fs);
15
+ Xs.prototype.build=function(a,b){var c=new _.Bg;c.id=this.getId();var d=ct(a.h.containerWidth,dt(a,1),720),e=ct(a.h.containerHeight,dt(a,2),480);a:switch(Gs(this,b,xs)){case "after":var f="flex-start";break a;case _.Ac:f=_.Ac;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Gs(this,b,Cs)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Mc}c.writingMode=f;f=this.getAttribute("extent")||Gs(this,b,"extent");c.width=$s(f,d,1,100);c.widthUnits=at(f,d);c.height=
16
+ $s(f,e,2,100);c.heightUnits=at(f,e);f=this.getAttribute("origin")||Gs(this,b,"origin");c.viewportAnchorX=$s(f,d,1,0);c.viewportAnchorY=$s(f,e,2,0);c.viewportAnchorUnits=at(f,d);c.cssClassList=_.lf(this.f).concat();return c};_.v(bt,Ds);_.v(gt,Ds);
17
+ gt.prototype.build=function(a){var b=null;var c=ft(a);c&&(b=ct(a.h.containerHeight,dt(a,2),480)/c);b=ct(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.u(Bt.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+":"+Qs(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&&!At.test(g)&&At.test(h)&&At.test(l)?(e=g,f=h):2===d.length&&!At.test(g)&&At.test(h)?(e=g,f=h):2===d.length&&At.test(g)&&At.test(h)&&(f=g);if(""!==f){f=Qs(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",zs).replace("proportionalSerif",zs).replace("sansSerif",zs).replace("default",zs)+";":"");a:{if(Bs 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
+ Qs(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=Qs(e),e=Ss(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=Qs(d);d=Ss(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 Bt=new Map([["color","color"],[vs,"background-color"],[ws,ws],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var lt=0;ot.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Ct.has(Ps(a.nodeName))||Dt.has(Ps(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&&!Ct.has(Ps(a.nodeName))));var b=this.a;this.a=a;return b};var Ct=new Set(["tt","head","layout",_.Ad,_.ld,ys,"styling",_.we,"body",_.Wc,"p","span","br"]),Dt=new Set([_.we,_.ld]);pt.prototype.getId=function(){return this.attributes.id};ut.prototype.parseInit=function(){};
22
+ ut.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=_.ph(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.De)}catch(n){throw new _.L(_.M,2,2005,"Failed to parse TTML.");}d=new ht(d);e=new rt;f=new ot(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=_.bk(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Es(m,l,{imageType:"PNG",encoding:"Base64"}));
23
+ b+=h}for(;f.a;)a=f.next(),a=tt(e,a),"tt"===qt(a)&&(d.j=new bt(d.A,Object.assign({},a.attributes))),"tt"===qt(a)&&(d.o=new Ws(a.attributes.frameRate,a.attributes.subFrameRate,a.attributes.frameRateMultiplier,a.attributes.tickRate)),qt(a)!==_.ld||a.attributes.begin||a.attributes.end||(c="#"+a.getId(),d.g.set(c,new Es(c,a.g.textContent,a.attributes))),qt(a)===_.ld&&a.attributes.begin&&a.attributes.end?(c="#"+mt(),b=new Es(c,a.g.textContent,a.attributes),d.g.set(c,b),c=b):c=null,c&&(a.h=c.getId()),qt(a)===
24
+ _.we&&(c=a.getId()||mt(),b=new gt(c,a.f,Object.assign({},a.attributes)),d.a.set(c,b),a.a&&d.h.get(a.a).f.push(c)),qt(a)!==_.we&&jt(a)?(c=mt(),b=new gt(c,[],Object.assign({},a.attributes)),d.a.set(c,b),c=b):c=null,c&&a.f.push(c.getId()),qt(a)!==_.Wc||!a.attributes.extent&&!a.attributes.origin?c=null:(c=mt(),b=new Xs(c,kt(d,a.f),Object.assign({},a.attributes)),d.h.set(c,b),c=b),c&&(a.a=c.getId()),qt(a)!==ys?c=null:(c=a.getId(),b=new Xs(c,kt(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(qt(a))||0===c.length?c=null:(g=c[c.length-1],d.f.has(g)?(c=mt(),b=new Ts(c,"#text"===a.g.nodeName?a.g.textContent:null,"br"===qt(a),a.a,a.h,kt(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"===qt(a)||a.h?(c=mt(),b=new Ts(c,null,!1,a.a,a.h,kt(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=nt(d);f=[];a=_.u(d.a.values());for(c=a.next();!c.done;c=a.next())f.push.apply(f,
26
+ _.lf(c.value.build(d.j)));return{cues:e,styles:f}};vt.prototype.a=function(a){a=(new ut(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=wt(c.startTime)+" --\x3e "+wt(c.endTime),e=[];switch(c.textAlign){case _.pd:e.push("align:left");break;case _.ie:e.push("align:right");break;case _.tg:e.push("align:middle");break;case _.pd:e.push("align:start");break;case _.ie:e.push("align:end")}switch(c.writingMode){case _.Oe:e.push("vertical:lr");break;
27
+ case _.Pe:e.push("vertical:rl")}b+=d+(e.length?" "+e.join(" "):"")+"\n";b+=c.payload+"\n\n"}return _.th(b)};xt.prototype.probe=function(a,b){return a===_.fc&&b===_.Ce};xt.prototype.create=function(a){return new vt(a)};yt.prototype.parseInit=function(a){var b=!1;(new _.Gk).M(_.Dd,_.Hk).M(_.Fe,_.Hk).M(_.yd,_.Hk).M(_.Cd,_.Hk).M(_.te,_.Hk).W(_.ve,_.Ik).M("stpp",function(c){b=!0;c.Xa.stop()}).parse(a);if(!b)throw new _.L(_.M,2,2007);};
28
+ yt.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Gk).M("moof",_.Hk).M("traf",_.Hk).W("subs",function(h){for(var l=_.U(h.G),m=0;m<l;++m){h.G.skip(4);for(var n=_.Bk(h.G),p=0;p<n;++p){var q=1===h.version?_.U(h.G):_.Bk(h.G);g.push(q);h.G.skip(6)}}}).M(_.xd,_.Jk(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(zt,_.Bo);zt.prototype.Ja=function(){_.Tp[_.fc]=ut;_.Tp[_.dc]=yt;_.Tp[ss]=yt;_.Tp[us]=yt;_.Tp[ts]=yt;_.Di.push(this.a)};zt.prototype.Ca=function(){_.Up(_.fc);_.Up(_.dc);_.Up(ss);_.Up(us);_.Up(ts);_.Fi(this.a)};zt.prototype.id=function(){return _.ze};_.C("clpp.ttml.TtmlComponent",zt);};
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));}