@castlabs/prestoplay 6.4.0 → 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 +57 -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 +421 -402
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +72 -72
  10. package/cjs/cl.externs.js +54 -133
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +47 -49
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -32
  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 +363 -351
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +67 -67
  38. package/cl.externs.js +49 -132
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +40 -40
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +16 -16
  44. package/cl.mse.js +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 +8 -2
@@ -1,28 +1,28 @@
1
1
  (function(){var g={}; var _ = _ || {}
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===_.Gd&&(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()!==_.om)c();else a.g.one(_.qc,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.ga=p;this.Ph=h;this.Dj=l;this.ji=m;this.ki=n;this.Nb=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.Of=new _.ai},st=function(){this.g=new _.H(jt);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.ai},tt=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.Of.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=_.R(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.uj(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},At=function(a,b){var c=a.horizontalTiles||
6
- b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Zc:c,cf:d,If:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Bt=function(){this.f=new _.H(jt);this.a=this.l=null},Ct=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},Dt=function(a){if(!a)return null;a=new _.gk(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},Et=function(){};kt.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.be,function(){c.w=!0});a.isLive()||this.m().then(function(){b&&b.preload&&mt(c,b.preload)})};pt.prototype.raw=function(){return this.ga.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(_.Tc);e.style.width=c+_.Zd;e.style.height=d+_.Zd;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))+_.Zd;var f=this.y/this.height;e.style.backgroundPositionX="-"+this.x/this.width*c+_.Zd;e.style.backgroundPositionY="-"+f*d+_.Zd;return e};
9
- pt.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.Ph);a.height||(a.height=(a.ga.naturalHeight||a.ga.height)/a.Dj);a.x||(a.x=a.width*a.ji);a.y||(a.y=a.height*a.ki)}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(_.dd,e);b(a)};e=function(){a.ga.removeEventListener("load",f);a.ga.removeEventListener(_.dd,e);c()};a.ga.addEventListener("load",
10
- f);a.ga.addEventListener(_.dd,e);a.ga.src=a.src}}));return this.Nb};_.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.Of};
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=_.vh(d);e.type=_.uh;a.getNetworkEngine().fetch(e).P.then(function(f){f=f.data;var g=_.R(c.f);f=_.R(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=_.R(f),
15
- h=String.fromCharCode.apply(null,Ft),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 Ft=[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=_.vh(d);e.type=_.uh;this.f=a.getNetworkEngine().fetch(e).P.then(function(f){if(f=f.data){f=_.ah(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={Nc:c.Nc},d++)if(c.Nc=b.a[d],ot(c.Nc,a))return c.Nc.load().then(function(e){return function(){return e.Nc}}(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=At(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.If+a]);else if((c=d.Ha())&&0<c.length){var g=0,h=0;d=d.startTime;1<e.If&&(g=a%e.Zc,h=Math.floor(a/e.Zc),d+=a*e.durationPerTile);f=new pt(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.Zc,e.cf,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.R(d=b.getSegmentReference(c++));)for(var e=At(d,b),f=d.Ha()[0],g=new Image,h=d.startTime,l=0;l<e.cf;++l)for(var m=0;m<e.Zc;++m)this.a.push(new pt(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.Zc,e.cf,m,l,g)),h+=e.durationPerTile;return Promise.resolve()};_.t=Bt.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=Dt(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(_.rd,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();Ct(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",Bt);Bt.prototype.get=Bt.prototype.get;Bt.Id="thumbnails";Et.prototype.create=function(){return new Bt};_.Un(new Et);};
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 uE="An unknown error occurred while trying to get volume",vE="Cannot get loading rendition due to platform limitations",wE="PARAM_START_POSITION",xE="SecurityError",yE="The require privilege is: http://tizen.org/privilege/tv.audio",zE="|STARTBITRATE\x3d",AE=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},BE=function(a,b){this.h=a;this.w=null;this.a=_.Fd;this.o=null;this.j=!1;this.f=new Map;this.m=b;this.g=new _.H("clpp.tizen.DrmEngine")},EE=function(a){var b,
3
- c,d;return _.A(function(e){if(1==e.a){b=a.a===_.Nc||a.a===_.Mc;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.dd)throw new _.L(_.M,6,6012,"No license server given for "+a.a);_.wf(e,2);return a.a===_.Nc?_.y(e,CE(a),5):_.y(e,DE(a,c),5)}if(2!=e.a)return a.w={keySystem:a.a,licenseServerUri:c.dd,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Me,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
4
- keyIds:[],periodId:null},_.xf(e,0);d=_.yf(e);a.g.error("Error while configuring CDM for "+a.a,d);throw new _.L(_.M,6,6005,{message:JSON.stringify(d)});})},DE=function(a,b){var c,d,e,f;return _.A(function(g){c=FE;d=GE;e={};e[d.ug]=!b.Me;e[d.vg]=b.dd;""!==b.customData&&(e[d.tg]=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)})},CE=function(a){var b;return _.A(function(c){b=FE;try{webapis.avplay.setDrm(b.od,
5
- "Initialize",""),webapis.avplay.setDrm(b.od,"widevine_app_session",a.o.id),webapis.avplay.setDrm(b.od,"widevine_data_type",a.o.type)}catch(d){throw d;}_.z(c)})},HE=function(a,b){var c,d,e,f,g,h,l,m,n,p,q,r,w,x,B,D,E;_.A(function(G){if(1==G.a){c=FE;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.dd;l=_.vh([h],_.sh());l.type=3;l.body=f.buffer;l.method=
6
- "POST";_.wf(G,2);return _.y(G,a.m.Ab.fetch(l).P,4)}if(2!=G.a){m=G.f;if(a.j){n=_.R(m.data);p=n.byteLength;q="";for(r=0;r<p;r++)q+=String.fromCharCode(n[r]);w=btoa(q);x=b.session_id+wE+(w+wE);a.g.debug("Widevine license params",x);try{webapis.avplay.setDrm(c.od,"widevine_license_data",x)}catch(I){a.g.error("License response rejected by CDM"),B=new _.L(_.M,6,6008,{browserError:JSON.stringify(I)}),a.m.onError(B)}}return _.xf(G,0)}D=_.yf(G);a.g.error("License request failed.",JSON.stringify(D));E=new _.L(_.M,
7
- 6,6007,{message:_.Ga,url:D.data.url,status:D.data.status||NaN,response:D.data.response||"",headers:D.data.headers||{}},D);a.m.onError(E);_.z(G)})},IE=function(a){this.l=a;this.a=this.l.a;this.f=_.jm;this.j=_.km;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.H("clpp.tizen.StateManager")},KE=function(a,b){if(a.f!==b)if(a.f===_.um&&b!==_.jm)a.g.debug(_.vu+JE(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.om?(a.o=(new Date).getTime(),a.l.trigger(new _.J(_.rc,{detail:{bufferedTimeMS:-1,
8
- reason:a.h}}))):a.j===_.om&&a.l.trigger(new _.J(_.qc,{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(_.oe,{detail:d}));a.g.debug("State changed:",JE(a.j),"-\x3e",JE(a.f))}},JE=function(a){return Object.keys(_.sm)[a]},NE=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case LE:c=_.xm;break;case ME:c=_.wm;break;default:a.l.isEnded()?c=_.qm:a.g.debug("Inconsistent AVPlay playback state:",b)}KE(a,
9
- c)}},OE=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")},PE=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},QE=function(a){var b,c;return _.A(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.y(d,_.Wo(a.B.url,a.l.getNetworkEngine(),b.manifest.attemptParameters,a.B.type),2);(c=d.f)&&c.configure(b.manifest);return d["return"](c)})},RE=function(a){var b=
10
- document.createElement(_.Oe),c=new _.cw,d=new _.mv(function(){return null}),e=a.l.getTextDisplayer();return new _.iw(b,c,e,d,a.l.getConfiguration())},SE=function(a){var b={wb:function(){return a.l.getPosition()},X:a.h,Ab:a.l.getNetworkEngine(),Fe:a.Hh.bind(a),Ee:a.Gh.bind(a),onError:a.S.bind(a),Wf:function(){},onEvent:function(){},ag:a.Ih.bind(a),Md:function(){},ne:function(){return new _.lx},ce:function(){return!1},Xc:null};return new _.fy(a.f,b)},TE=function(a){var b=a.l.getPosition(),c=null;a=
11
- _.u(a.f.periods);for(var d=a.next();!d.done;d=a.next())d=d.value,d.startTime<=b&&(c=d);return c},UE=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 _.Gg(String(c++),_.N);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||
12
- _.Nu;var f=new _.Og(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},VE=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.hy(a.g,_.ze),c=null;if(b){a=UE(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},WE=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=TE(a),d=b.renditions[0];
13
- (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):(_.py(a.g,c,!0,0),a.l.trigger(new _.J(_.Vh))),a.o=c.language):a.a.error(_.uu,d.id)}},XE=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},YE=function(a,b){a.l.trigger(new _.J(_.Se,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},ZE=function(a){var b=
14
- a.fa();b&&a.l.trigger(new _.J(_.oc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},$E=function(a){var b=a.l.getConfiguration(),c=_.Dg(b.preferredAudioLanguage||[]),d=a.g[_.P]||[];if(d.length){var e=null;c.some(function(g){e=_.bv(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)}),0<f.length&&(c=f[0]));
15
- 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")},dF=function(a,b){if(b){var c=b.track.type.toUpperCase();aF(a.f,c,Number(b.id)).then(function(){c===bF&&(a.j=b,a.l.trigger(new _.J(_.Uh)));c===cF&&(a.m=b,a.l.trigger(new _.J(_.Vh)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},eF=function(a,b,c){var d=
16
- _.Gh(b.language||_.Fe);c.language=_.Hg(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.kc;a=new _.Og(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},fF=function(a,b,c){c.mimeType=_.Qe;a=new _.Og(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},gF=function(a,b,c){b=_.Gh(b.track_lang||_.Fe);c.mimeType="text/ttml";c.language=_.Hg(b);c.kind=_.Nu;return new _.Og(String(a),
17
- c)},hF=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},kF=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===iF}),f=b.filter(function(n){return n.type===bF}),g=[],h=0;h<f.length;h++){var l=hF(a,f[h].extra_info);if(l){var m=_.Gh(l.language||_.Fe);m=_.Hg(m);m=c(g,m);m||(m=new _.Gg(String(a.o++),
18
- _.P),g.push(m));m.renditions.push(eF(f[h].index,l,m))}else a.a.warn("Skipping audio stream with no extra info")}f=new _.Gg(String(a.o++),_.Ig);for(h=0;h<e.length;h++)(l=hF(a,e[h].extra_info))?f.renditions.push(fF(e[h].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?UE(a.h):jF(a,b);d[_.Ig]=[f];d[_.P]=g;d[_.N]=e;return d},jF=function(a,b){for(var c=b.filter(function(h){return h.type===cF}),d=[],e=0;e<c.length;e++){var f=hF(a,c[e].extra_info);if(f){var g=new _.Gg(String(a.o++),
19
- _.N);g.renditions.push(gF(c[e].index,f,g));d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},lF=function(a,b){for(var c=a.g[_.Ig]||[],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},mF=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===b){c=a[d].renditions[e];break}return c},
20
- oF=function(a,b){if(b===_.N&&a.h)return VE(a.h);var c=nF(a.f)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.Ig&&(d=hF(a,c.extra_info),d=lF(a,{width:d.Width,height:d.Height}));b===_.P&&(c?(d=mF(a,c,_.P),a.j=d):d=a.j);b===_.N&&(c?(d=mF(a,c,_.N),a.m=d):d=a.m);return d},pF=function(a){_.$h.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;this.o=!0;this.g=!1;this.f=null;this.A=
21
- 1;this.w=!1;this.j={}},qF=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)})},sF=function(a){try{webapis.avplay.setListener({onbufferingstart:a.Bh.bind(a),onbufferingprogress:a.Ah.bind(a),onbufferingcomplete:a.zh.bind(a),onstreamcompleted:a.Eh.bind(a),oncurrentplaytime:function(b){a.trigger(new _.J(rF,{currentTime:b}))},
22
- onevent:a.Dh.bind(a),onsubtitlechange:a.Fh.bind(a),ondrmevent:a.Ch.bind(a),onerror:a.S.bind(a)})}catch(b){a.a.error(b)}},tF=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)}},uF=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,hk:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",zE+d)}catch(e){a.a.debug(e)}},vF=function(a,
23
- b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+zE+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},yF=function(a){return{position:a.getPosition(),state:a.l.getState(),jf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:wF(a),volume:a.getVolume(),Lj:xF(a),Sh:nF(a)}},AF=function(a){var b,c;return _.A(function(d){if(1==d.a)return _.y(d,zF(),2);if(3!=d.a)return b=new Promise(function(e){(new _.Ch(e)).$(5)}),
24
- _.y(d,Promise.race([qF(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)})},GF=function(a,b,c){var d,e,f,g,h,l,m,n;return _.A(function(p){switch(p.a){case 1:a.m=_.Gm(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 _.J(BF)),f=c.currentPosition);
25
- _.wf(p,2);g=a.m[d].url;h=a.m[d].type;h!==_.Zb||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);e.nextBandwidth?(vF(a,e.nextBandwidth),a.o=!1):(a.o||uF(a,e),a.o=!0);sF(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 BE(b.drm,m);return _.y(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.J(CF)),
26
- _.y(p,DF(a),6);case 6:a.g||a.trigger(new _.J(EF));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&&FF(a,b.muted),b.autoplay&&a.l.play()["catch"](function(q){a.a.debug("Autoplay failed",q)}));_.xf(p,0);break;case 2:throw n=_.yf(p),a.a.debug("Error while attempting to load source."),n;}})},DF=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
- tF(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)}}))})},HF=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=yF(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.f.jf;a.g=!1;a.f=
28
- null;return e===ME?a.pause():a.play()})}catch(e){return Promise.reject(e)}},xF=function(a){return a.g&&a.f?a.f.Lj:webapis.avplay.getTotalTrackInfo()},nF=function(a){return a.g&&a.f?a.f.Sh:webapis.avplay.getCurrentStreamInfo()},aF=function(a,b,c){b=b.toUpperCase();b===cF&&IF(a,!0);var d=a.j[b];d&&(d.Od.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,gf:0,Od:new _.Ch(function(){return g(h,c,!0)})}),(l=a.j[h])&&3>l.gf?(!a.w&&++l.gf,l.Od.$(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Od.stop(),a.j[h]=null,f())}}g(b,c)})},IF=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)}},FF=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case xE:a.a.warn("The application does not have the privilege to set mute.",yE);break;default:a.a.warn(uE,c)}}},wF=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case xE:a.a.warn("The application doesn't have the privilege to get the mute state.",yE);break;default:a.a.warn(uE,c)}}return!!b},zF=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
31
- AE(c,"load",function(d){return a(d)});AE(c,_.dd,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},JF=function(){_.$h.call(this);this.a=new pF(this);this.f=new IE(this);this.configuration=this.B=_.jj();this.w=null;this.h=new _.H("clpp.tizen.Player");this.j=null;this.m=new XE;this.C=new _.yi;this.o=this.g=null;this.A=!1},KF=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())},LF=function(){},MF=function(){this.a=null};
33
- BE.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.A(function(h){if(1==h.a){b=_.Fj[a.h.env]||null;if(!b)throw a.g.debug(_.va,_.fb+a.h.env+_.aa),new _.L(_.M,6,6015,_.wa+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=_.Hj(b,a.h.customData);(e=d[_.Mc])&&a.f.set(_.Mc,{dd:e.licenseUrl||"",customData:c,Me:!1});(f=d[_.Nc])&&a.f.set(_.Nc,{dd:f.licenseUrl||"",customData:c,
34
- Me:!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(_.Mc))a.a=_.Mc;else if(a.f.get(_.Nc))a.a=_.Nc;else throw new _.L(_.M,6,6001,"Configuration for the target system is missing.");return _.y(h,EE(a),2)}a.j=!0;_.z(h)})};BE.prototype.release=function(){var a=this;return _.A(function(b){a.j=!1;a.w=null;a.a=_.Fd;a.o=null;a.f=new Map;_.z(b)})};BE.prototype.getDrmInfo=function(){return this.w};
35
- var GE={ug:"DeleteLicenseAfterUse",vg:"LicenseServer",Wj:"GetChallenge",Xj:"HttpHeader",$j:"UserAgent",Sj:"Cookie",tg:"CustomData"};_.t=IE.prototype;_.t.initialize=function(){this.a.on(BF,this.wf,this);this.a.on(NF,this.vf,this);this.a.on(OF,this.uf,this);this.a.on(CF,this.cg,this);this.a.on(EF,this.bg,this);this.a.on(PF,this.xf,this)};_.t.release=function(){KE(this,_.jm);this.m=!1;this.o=-1;this.h=2};_.t.destroy=function(){this.release();this.a.off(BF,this.wf);this.a.off(NF,this.vf);this.a.off(OF,this.uf);this.a.off(CF,this.cg);this.a.off(EF,this.bg);this.a.off(PF,this.xf);this.l=this.a=null};
36
- _.t.wf=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;KE(this,_.om)};_.t.vf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",JE(this.f))};_.t.uf=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()===QF;if(!a&&b){KE(this,_.wm);return}}if(a=this.f!==_.vm)a=this.a.getState(),a=a===LE||a===ME;a&&NE(this)};
37
- _.t.cg=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===RF?KE(this,_.vm):this.g.error("AVPlay prepares while state is not IDLE")};_.t.bg=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.xf=function(){KE(this,_.qm)};_.t.getState=function(){return this.f};_.t=OE.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,QE(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(){}};_.wf(m,3);e=b;return _.y(m,b.j.start(a.url,d),5);case 5:e.f=m.f;_.xf(m,4);break;case 3:return f=_.yf(m),b.a.warn(f),_.wf(m,6),g=b,_.y(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.f=m.f;_.xf(m,4);break;case 6:h=_.yf(m),b.a.error(h),b.f=null;case 4:if(!b.f||!PE(b.f)){m.H(0);break}b.h=RE(b);_.wf(m,10);return _.y(m,b.h.G,12);case 12:b.g=SE(b);l=b.l.getConfiguration();b.g.m=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;_.xf(m,0);break;case 10:_.yf(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.Hh=function(a){this.a.debug(_.Hu,a);this.w=!0;var b=_.Ow(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.Gh=function(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.py(this.g,this.m,!0,0),this.m=null)};_.t.S=function(){this.a.debug("onError_")};_.t.Ih=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(XE,_.Q);_.t=XE.prototype;_.t.Tf=function(a){var b=a.eventid;a=a.data;switch(b){case SF:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+hF(this,b[0].extra_info).Bit_rate,b=lF(this,{bandwidth:b}))&&(this.w=b,YE(this,b));break;case TF:ZE(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.t.Ie=function(a){a.detail.currentState===_.xm&&this.l.off(_.oe,this.Ie)};
43
- _.t.initialize=function(a){var b=this;this.l=a;this.f=this.l.a;this.l.on(_.oe,function(c){b.A||(c=c.detail,c.currentState===_.xm&&(b.a.debug("Current state",c.currentState),b.A=!0,$E(b)))});this.f.on(UF,this.Tf,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(_.oe,this.Ie);this.l.on(_.oe,this.Ie,this);try{var a=xF(this.f);this.g=kF(this,a);var b=this.g[_.P]||[];b.length&&(this.j=b[0].renditions[0]||null);ZE(this)}catch(c){this.a.debug("Could not load track manager")}}};_.t.destroy=function(){this.f.off(UF,this.Tf);this.f=this.l=null};_.t.getVideoTracks=function(){return this.g[_.Ig]||[]};_.t.getAudioTracks=function(){return this.g[_.P]||[]};
45
- _.t.ea=function(){return this.g[_.N]||[]};_.t.fa=function(){return oF(this,_.Ig)};_.t.Fa=function(){return oF(this,_.P)};_.t.Ga=function(){return oF(this,_.N)};_.t.Ta=function(){return this.w};_.t.eb=function(){this.a.info(vE);return null};_.t.fb=function(){this.a.info(vE);return null};_.t.Ia=function(){var a=this.fa();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.fa(),HF(this.f,a.bandwidth,null).then(function(){ZE(b)})):0<a.renditions.length&&this.Za(a.renditions[0])};_.t.ra=function(a){a?dF(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?WE(this.h,a.track):dF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,IF(this.f,!1),this.l.trigger(new _.J(_.Vh)))};
47
- _.t.Za=function(a){var b=this,c=this.fa();this.f.o||a.width!==c.width||a.height!==c.height||a.bandwidth!==c.bandwidth?(this.w=a,YE(this,a),HF(this.f,c.bandwidth,a.bandwidth).then(function(){ZE(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){dF(this,a)};_.t.mb=function(a){this.h?WE(this.h,a.track):dF(this,a)};
48
- _.t.addTextTrack=function(){};_.t.ha=function(){return this.f.o};XE.prototype.isAbrEnabled=XE.prototype.ha;XE.prototype.addTextTrack=XE.prototype.addTextTrack;XE.prototype.setTextRendition=XE.prototype.mb;XE.prototype.setAudioRendition=XE.prototype.lb;XE.prototype.setVideoRendition=XE.prototype.Za;XE.prototype.setTextTrack=XE.prototype.Ba;XE.prototype.setAudioTrack=XE.prototype.ra;XE.prototype.setVideoTrack=XE.prototype.$a;XE.prototype.getTextTrack=XE.prototype.la;XE.prototype.getAudioTrack=XE.prototype.ka;
49
- XE.prototype.getVideoTrack=XE.prototype.Ia;XE.prototype.getLoadingTextRendition=XE.prototype.fb;XE.prototype.getLoadingAudioRendition=XE.prototype.eb;XE.prototype.getLoadingVideoRendition=XE.prototype.Ta;XE.prototype.getTextRendition=XE.prototype.Ga;XE.prototype.getAudioRendition=XE.prototype.Fa;XE.prototype.getVideoRendition=XE.prototype.fa;XE.prototype.getTextTracks=XE.prototype.ea;XE.prototype.getAudioTracks=XE.prototype.getAudioTracks;XE.prototype.getVideoTracks=XE.prototype.getVideoTracks;_.v(pF,_.$h);_.t=pF.prototype;_.t.Bh=function(){this.w=!0;this.g||this.trigger(new _.J(BF))};_.t.Ah=function(a){this.w=!0;this.trigger(new _.J(NF,{percent:a}))};_.t.zh=function(){this.w=!1;this.trigger(new _.J(OF))};_.t.Eh=function(){this.trigger(new _.J(PF))};_.t.Dh=function(a,b){this.trigger(new _.J(UF,{eventid:a,data:b}))};_.t.Fh=function(a,b,c,d,e){this.trigger(new _.J(VF,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
- _.t.Ch=function(a,b){this.trigger(new _.J(WF,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Nc&&"Challenge"===b.name)HE(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.S=function(a){this.trigger(new _.J(XF,{eventType:a}))};
51
- _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(rF,f,b);g=setTimeout(function(){b.off(rF,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===RF)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){tF(b);d(webapis.avplay.play())},function(f){b.trigger(new _.J(XF));e(f)})})).then(function(){return a()});if(c===ME||c===QF)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===LE?
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()===ME?Promise.resolve():Promise.reject()};
53
- _.t.setPlaybackRate=function(a){var b=this.getState();if(b===QF||b===LE||b===ME){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||""),_.wf(e,2),_.y(e,AF(c),4);case 4:return _.y(e,GF(c,a,b),5);case 5:_.xf(e,0);break;case 2:throw d=_.yf(e),new _.L(_.M,7,7003,null,d);}})};_.t.getState=function(){if(this.g&&this.f)return this.f.jf;try{return webapis.avplay.getState()}catch(a){this.S(JSON.stringify(a))}};
55
- _.t.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.l.trigger(new _.J(_.Ke));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.J(_.Je));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.S(JSON.stringify(a))}};_.t.getDuration=function(){if(this.g&&this.f)return this.f.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.S(JSON.stringify(a))}};
56
- _.t.release=function(){var a=this;return new Promise(function(b,c){try{a.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.Od.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 xE:this.a.debug("The application does not have the privilege to get the volume.",yE);break;default:this.a.debug(uE,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 xE:this.a.warn("The application does not have the privilege to set the volume.",yE);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.S(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 RF="IDLE",QF="READY",LE="PLAYING",ME="PAUSED",iF="VIDEO",bF="AUDIO",cF="TEXT",TF="PLAYER_MSG_RESOLUTION_CHANGED",SF="PLAYER_MSG_BITRATE_CHANGE",FE={PLAYREADY:"PLAYREADY",Tj:"EME_PLAYREADY",ak:"VERIMATRIX",od:"WIDEVINE_CDM",Uj:"EME_WIDEVINE_CDM",bk:"WIDEVINE_CLASSIC"};_.v(JF,_.$h);_.t=JF.prototype;_.t.sf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.J(_.cd));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.t.qf=function(a){this.trigger(new _.J(_.Ce,{currentTime:a.currentTime/1E3}))};
60
- _.t.tf=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=_.qh(d))&&this.o.append([new _.wg(b,c,d)],[])};_.t.rf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.Vf=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
- _.t.S=function(a){this.h.debug("Error: TYPE: "+a.eventType);KE(this.f,_.um);a=new _.L(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.J(_.dd,{detail:a}))};
62
- _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(PF,this.sf,this);this.a.on(rF,this.qf,this);this.a.on(VF,this.tf,this);this.a.on(WF,this.rf,this);this.a.on(XF,this.S,this);this.a.on(OF,this.Vf,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=YF;YF+=1;this.j=_.Xm(_.Gd,{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=[_.cf,_.gd,"position",_.ld,"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];_.Zm(c,f);KF(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(PF,a.sf);a.a.off(rF,a.qf);a.a.off(VF,a.tf);a.a.off(WF,a.rf);a.a.off(XF,a.S);a.a.off(OF,a.Vf);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 ZF};_.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()===_.qm?this.getDuration():this.a.getPosition()||0};_.t.seek=function(a){return typeof a===_.k&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()};_.t.getPresentationStartTime=function(){return null};
66
- _.t.getSeekRange=function(){return{start:0,end:0}};_.t.getVolume=function(){var a=this.a.getVolume();return typeof a===_.k?a/100:null};_.t.setVolume=function(a){this.a.setVolume(a)};_.t.getDuration=function(){return this.a.getDuration()};_.t.getBufferInfo=function(){this.h.warn(_.ra);return new _.Zh};_.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:_.mj(a)&&(b.configuration=_.lj(b.B,a));c=_.Xl(b.configuration,["html",_.Ed]);b.o=c.create(b);d=_.Gm(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.H(2);break}b.g=new OE;b.g.initialize(b);_.wf(h,3);return _.y(h,b.g.load(d),5);case 5:b.g.start();_.xf(h,2);break;case 3:f=_.yf(h),b.h.error(f);case 2:return _.wf(h,6),_.y(h,b.a.load(b.configuration),8);case 8:_.xf(h,7);break;
69
- case 6:throw g=_.yf(h),b.onError(g),g;case 7:b.m.load(),_.z(h)}})};_.t.play=function(){var a=this;this.trigger(new _.J(_.Ud));KF(this);return this.a.play().then(function(){NE(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){NE(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.J(_.dd,{detail:a});a.severity===_.M&&(KE(this.f,_.um),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()===_.qm};_.t.isPaused=function(){return this.a.getState()===ME};_.t.isMuted=function(){return wF(this.a)};_.t.setMuted=function(a){FF(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 LF).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};JF.prototype.getTextDisplayer=JF.prototype.getTextDisplayer;JF.prototype.setNetworkEngine=JF.prototype.setNetworkEngine;JF.prototype.getNetworkEngine=JF.prototype.getNetworkEngine;var ZF="clpp.tizen",YF=0;LF.prototype.a=function(){return ZF};
72
- LF.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.Zb||a===_.ec||a===_.dc)&&b){if(_.ti(2))return 2;if(_.ti(3)||_.ti(4)||_.ti(5)||_.ti(6))return _.F("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};LF.prototype.create=function(){return new JF};_.v(MF,_.Zn);MF.prototype.Ja=function(){this.a=new LF;_.Vf(this.a)};MF.prototype.Ca=function(){if(this.a){var a=this.a.a();a&&_.Tf[a]&&(delete _.Tf[a],_.Uf.info("Removed Player factory: '"+a+"'"));this.a=null}};MF.prototype.id=function(){return"tizen"};_.C("clpp.tizen.TizenComponent",MF);var BF="onbufferingstart",NF="onbufferingprogress",OF="onbufferingcomplete",PF="onstreamcompleted",rF="oncurrentplaytime",UF="onevent",VF="onsubtitlechange",WF="ondrmevent",XF="onerror",CF="preparingstart",EF="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 Gr='application/mp4; codecs\x3d"stpp.ttml"',Hr='application/mp4; codecs\x3d"stpp.ttml.im1i"',Ir='application/mp4; codecs\x3d"stpp.ttml.im1t"',Jr="backgroundColor",Kr="direction",Lr="displayAlign",Mr="region",Nr="sans-serif",Or="textAlign",Pr="textDecoration",Qr="writingMode",Rr=function(a,b,c){this.g=a;this.f=b;this.a=c},Sr=function(a,b,c){Rr.call(this,a,[],c);this.h=b||""},Tr=function(a,b,c){Rr.call(this,a,b,c)},Ur=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(Vr.test(a)){c=Vr.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 Wr.test(a)?c=Xr(Wr,a):Yr.test(a)?c=Xr(Yr,a):Zr.test(a)?(c=Zr.exec(a),c=Number(c[1])/b.frameRate):$r.test(a)?(c=$r.exec(a),c=Number(c[1])/b.a):gs.test(a)&&(c=Xr(gs,a));return c},Xr=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){Rr.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=Ur(a,b,Or);if(!a&&c&&(a=Ur(c,b,Or),!a&&"rltb"===Ur(c,b,Qr)))return _.fe;switch(a){case _.yc:return _.rg;case _.fe:case _.bd:return _.fe;default:return _.ld}},
5
- vs=function(a,b,c){if(_.jh(a.o))return document.createTextNode(_.qh(a.o||""));if(a.w)return _.Xm("br");for(var d=_.Xm("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.Ym(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){Rr.call(this,a,b,c)},As=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},Bs=function(a,b){return typeof b===_.k&&0<b?_.xg:zs.test(a)?0:_.xg},Cs=function(a,b){Rr.call(this,"root-container",[],b);this.h=a},Ds=function(a,b,c){return typeof a===_.k?a:typeof b===_.k?b:c},Es=function(a,b){var c=a.getAttribute("extent");return(c=zs.exec(c))?Number(c[b]):null},Gs=function(a){a=a.getAttribute("cellResolution");return(a=Fs.exec(a))?
7
- Number(a[2]):null},Hs=function(a,b,c){Rr.call(this,a,b,c)},Is=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=[]},Ks=function(a){return Js.some(function(b){return b in a.attributes})},Ls=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,_.jf(Ls(a,a.a.get(e).f)).concat([e]));return c},Ns=function(){return"inline-"+Ms++},Os=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})},Ps=function(a){this.a=a.firstChild;this.f=new Set},Qs=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},Rs=function(a){return ps(a.g.nodeName)},Ss=function(){this.a=new Map},Us=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=_.jf(l.j).concat();-1===["#text","span","br"].indexOf(b.nodeName)&&(c=l.a,d=l.h,f=_.jf(l.f).concat(),
9
- g={},Ts.forEach(function(n){n in l.attributes&&(g[n]=l.attributes[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Mr)&&(c=b.getAttribute(Mr));b.hasAttribute(_.ue)&&f.push.apply(f,_.jf(b.getAttribute(_.ue).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 Qs(b,c,d,e,f,g);a.a.set(b,c);return c},Vs=function(a){this.a=a;this.f=new DOMParser},Ws=function(a){this.f=
10
- a},Xs=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")},Ys=function(){},Zs=function(a){this.f=new Vs(a);this.a=new _.H("clpp.ttml.Mp4TtmlParser")},$s=function(){this.a=new Ys};Rr.prototype.getId=function(){return this.g};Rr.prototype.getAttribute=function(a){return this.a[a]};_.v(Sr,Rr);_.v(Tr,Rr);var Vr=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Wr=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Yr=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Zr=/^(\d*(?:\.\d*)?)f$/,$r=/^(\d*(?:\.\d*)?)t$/,gs=/^(?:(\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$/,Fs=/^(\d+) (\d+)$/,rs=/(\d+)px/,at=/^(\d+px|\d+em|\d*\.?\d+c)$/,Js=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
- "color",Jr,"opacity","padding","zIndex",Or,Lr,Qr,Kr,Pr,"textOutline"],Ts=["begin",_.bd];_.v(ts,Tr);
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=_.Xm(_.Tc);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 _.wg(h,b,c.innerHTML,_.Ee);g.cssClassList=_.jf(this.f).concat();g.textAlign=us(this,e,null);g.writingMode=_.sg;g.line=-1;g.lineInterpretation=_.tg;g.lineAlign=_.ug;g.containerRows=Ds(null,Gs(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(Ur(f,e,Qr)){case "tb":case "tblr":a=_.Me;break a;case "tbrl":a=_.Ne;break a;default:a=_.sg}g.writingMode=a;a:switch(Ur(f,e,Lr)){case _.yc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Ur(f,e,Lr)){case _.yc:a=1;break a;default:a=_.tg}g.lineInterpretation=a;a:switch(Ur(f,e,Lr)){case _.yc:e=_.yc;break a;default:e=_.ug}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,Tr);
15
- xs.prototype.build=function(a,b){var c=new _.zg;c.id=this.getId();var d=Ds(a.h.containerWidth,Es(a,1),720),e=Ds(a.h.containerHeight,Es(a,2),480);a:switch(Ur(this,b,Lr)){case "after":var f="flex-start";break a;case _.yc:f=_.yc;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Ur(this,b,Qr)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Jc}c.writingMode=f;f=this.getAttribute("extent")||Ur(this,b,"extent");c.width=As(f,d,1,100);c.widthUnits=Bs(f,d);c.height=
16
- As(f,e,2,100);c.heightUnits=Bs(f,e);f=this.getAttribute("origin")||Ur(this,b,"origin");c.viewportAnchorX=As(f,d,1,0);c.viewportAnchorY=As(f,e,2,0);c.viewportAnchorUnits=Bs(f,d);c.cssClassList=_.jf(this.f).concat();return c};_.v(Cs,Rr);_.v(Hs,Rr);
17
- Hs.prototype.build=function(a){var b=null;var c=Gs(a);c&&(b=Ds(a.h.containerHeight,Es(a,2),480)/c);b=Ds(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",Nr).replace("proportionalSerif",Nr).replace("sansSerif",Nr).replace("default",Nr)+";":"");a:{if(Pr 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"],[Jr,"background-color"],[Kr,Kr],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Ms=0;Ps.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",_.wd,_.id,Mr,"styling",_.ue,"body",_.Tc,"p","span","br"]),dt=new Set([_.ue,_.id]);Qs.prototype.getId=function(){return this.attributes.id};Vs.prototype.parseInit=function(){};
22
- Vs.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.K.Ma(this.a.ttml||{}),e=_.R(a,0,c[0]);e=_.ah(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Be)}catch(n){throw new _.L(_.M,2,2005,"Failed to parse TTML.");}d=new Is(d);e=new Ss;f=new Ps(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=_.R(a,b,h);l=_.uj(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Sr(m,l,{imageType:"PNG",encoding:"Base64"}));
23
- b+=h}for(;f.a;)a=f.next(),a=Us(e,a),"tt"===Rs(a)&&(d.j=new Cs(d.A,Object.assign({},a.attributes))),"tt"===Rs(a)&&(d.o=new ws(a.attributes.frameRate,a.attributes.subFrameRate,a.attributes.frameRateMultiplier,a.attributes.tickRate)),Rs(a)!==_.id||a.attributes.begin||a.attributes.end||(c="#"+a.getId(),d.g.set(c,new Sr(c,a.g.textContent,a.attributes))),Rs(a)===_.id&&a.attributes.begin&&a.attributes.end?(c="#"+Ns(),b=new Sr(c,a.g.textContent,a.attributes),d.g.set(c,b),c=b):c=null,c&&(a.h=c.getId()),Rs(a)===
24
- _.ue&&(c=a.getId()||Ns(),b=new Hs(c,a.f,Object.assign({},a.attributes)),d.a.set(c,b),a.a&&d.h.get(a.a).f.push(c)),Rs(a)!==_.ue&&Ks(a)?(c=Ns(),b=new Hs(c,[],Object.assign({},a.attributes)),d.a.set(c,b),c=b):c=null,c&&a.f.push(c.getId()),Rs(a)!==_.Tc||!a.attributes.extent&&!a.attributes.origin?c=null:(c=Ns(),b=new xs(c,Ls(d,a.f),Object.assign({},a.attributes)),d.h.set(c,b),c=b),c&&(a.a=c.getId()),Rs(a)!==Mr?c=null:(c=a.getId(),b=new xs(c,Ls(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(Rs(a))||0===c.length?c=null:(c=c[c.length-1],d.f.has(c)?(b=Ns(),g=new ts(b,"#text"===a.g.nodeName?a.g.textContent:null,"br"===Rs(a),a.a,a.h,Ls(d,a.f),a.attributes),d.f.set(b,g),d.f.get(c).h.push(b),c=g):c=null),c&&a.j.push(c.getId()),"p"===Rs(a)||a.h?(c=Ns(),b=new ts(c,null,!1,a.a,a.h,Ls(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=Os(d);f=[];a=_.u(d.a.values());for(c=a.next();!c.done;c=a.next())f.push.apply(f,
26
- _.jf(c.value.build(d.j)));return{cues:e,styles:f}};Ws.prototype.a=function(a){a=(new Vs(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=Xs(c.startTime)+" --\x3e "+Xs(c.endTime),e=[];switch(c.textAlign){case _.ld:e.push("align:left");break;case _.fe:e.push("align:right");break;case _.rg:e.push("align:middle");break;case _.ld:e.push("align:start");break;case _.fe:e.push("align:end")}switch(c.writingMode){case _.Me:e.push("vertical:lr");break;
27
- case _.Ne:e.push("vertical:rl")}b+=d+(e.length?" "+e.join(" "):"")+"\n";b+=c.payload+"\n\n"}return _.eh(b)};Ys.prototype.probe=function(a,b){return a===_.cc&&b===_.Ae};Ys.prototype.create=function(a){return new Ws(a)};Zs.prototype.parseInit=function(a){var b=!1;(new _.Zj).M(_.zd,_.ak).M(_.De,_.ak).M(_.ud,_.ak).M(_.yd,_.ak).M(_.re,_.ak).V(_.te,_.bk).M("stpp",function(c){b=!0;c.Wa.stop()}).parse(a);if(!b)throw new _.L(_.M,2,2007);};
28
- Zs.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Zj).M("moof",_.ak).M("traf",_.ak).V("subs",function(h){for(var l=_.U(h.F),m=0;m<l;++m){h.F.skip(4);for(var n=_.Uj(h.F),p=0;p<n;++p){var q=1===h.version?_.U(h.F):_.Uj(h.F);g.push(q);h.F.skip(6)}}}).M(_.td,_.ck(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($s,_.Zn);$s.prototype.Ja=function(){_.tp[_.cc]=Vs;_.tp[_.ac]=Zs;_.tp[Gr]=Zs;_.tp[Ir]=Zs;_.tp[Hr]=Zs;_.Dh.push(this.a)};$s.prototype.Ca=function(){_.up(_.cc);_.up(_.ac);_.up(Gr);_.up(Ir);_.up(Hr);_.Fh(this.a)};$s.prototype.id=function(){return _.xe};_.C("clpp.ttml.TtmlComponent",$s);};
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));}