@castlabs/prestoplay 6.2.6 → 6.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +1 -1
  3. package/cjs/cl.adobe.js +3 -3
  4. package/cjs/cl.airplay.js +3 -3
  5. package/cjs/cl.broadpeak.js +6 -6
  6. package/cjs/cl.cast.js +103 -103
  7. package/cjs/cl.conviva.js +32 -32
  8. package/cjs/cl.core.js +377 -376
  9. package/cjs/cl.crypto.js +9 -9
  10. package/cjs/cl.dash.js +69 -68
  11. package/cjs/cl.externs.js +64 -33
  12. package/cjs/cl.freewheel.js +23 -23
  13. package/cjs/cl.hls.js +44 -43
  14. package/cjs/cl.hlssmpte.js +6 -6
  15. package/cjs/cl.htmlcue.js +30 -30
  16. package/cjs/cl.ima.js +21 -21
  17. package/cjs/cl.mse.js +251 -248
  18. package/cjs/cl.muxdata.js +11 -11
  19. package/cjs/cl.onboard.js +3 -3
  20. package/cjs/cl.persistent.js +13 -13
  21. package/cjs/cl.playlist.js +5 -5
  22. package/cjs/cl.smooth.js +69 -69
  23. package/cjs/cl.thumbnails.js +22 -22
  24. package/cjs/cl.tizen.js +69 -69
  25. package/cjs/cl.ttml.js +26 -26
  26. package/cjs/cl.verimatrix.js +5 -5
  27. package/cjs/cl.vimond.js +13 -13
  28. package/cjs/cl.vr.js +24 -0
  29. package/cjs/cl.vtt.js +14 -14
  30. package/cjs/cl.youbora.js +16 -16
  31. package/cl.adobe.js +3 -3
  32. package/cl.airplay.js +3 -3
  33. package/cl.broadpeak.js +5 -5
  34. package/cl.cast.js +82 -82
  35. package/cl.conviva.js +27 -27
  36. package/cl.core.js +333 -329
  37. package/cl.crypto.js +8 -8
  38. package/cl.dash.js +64 -62
  39. package/cl.externs.js +60 -33
  40. package/cl.freewheel.js +19 -19
  41. package/cl.hls.js +37 -36
  42. package/cl.hlssmpte.js +5 -5
  43. package/cl.htmlcue.js +24 -24
  44. package/cl.ima.js +16 -16
  45. package/cl.mse.js +223 -220
  46. package/cl.muxdata.js +9 -9
  47. package/cl.onboard.js +4 -4
  48. package/cl.persistent.js +9 -9
  49. package/cl.playlist.js +4 -4
  50. package/cl.smooth.js +57 -57
  51. package/cl.thumbnails.js +17 -17
  52. package/cl.tizen.js +57 -57
  53. package/cl.ttml.js +21 -21
  54. package/cl.verimatrix.js +4 -4
  55. package/cl.vimond.js +8 -8
  56. package/cl.vr.js +14 -0
  57. package/cl.vtt.js +12 -12
  58. package/cl.youbora.js +14 -14
  59. package/package.json +1 -1
@@ -1,27 +1,27 @@
1
1
  (function(){var g={}; var _ = _ || {}
2
- var f=function(window){var Yr="No thumbnail duration or URL specified",Zr="No thumbnail found for position ",$r="Position is out of range: ",as="Thumbnail URL is mandatory",bs="Wrong gridSize format",cs="clpp.thumbnails",ds=function(a,b,c,d,e,f,g,k,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;k=void 0===k?1:k;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.a=p;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.g=k;this.m=
3
- l;this.h=m;this.j=n;this.f=null},es=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.a=new _.Nh},fs=function(){this.g=new _.C(cs);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Nh},gs=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.a.resolve()})},is=function(a,b){return hs(a,b).then(function(c){return new ds(c,b.time,b.duration)})},hs=function(a,b){return b.load().then(function(){var c=_.Q(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+
4
- _.dj(c)})},js=function(){this.log=new _.C(cs);this.g=null;this.a=[];this.w=!1},ls=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Ad&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return ks(a,0,e,!!f)})},Promise.resolve())},ks=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();var e=b+c;return ms(a,d).then(function(){return a.a[b].load()}).then(function(){return ks(a,e,c,d)})},ms=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.Dl)c();
5
- else a.g.one(_.ic,function(){c()})})},ns=function(){js.call(this);this.f=null},os=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},ps=function(){js.call(this);this.f=null;this.o=this.h=1;this.j=0},qs=function(){js.apply(this,arguments)},rs=function(a,b){for(var c=null,d=_.t(a),e=d.next();!e.done;e=d.next())e=e.value,e.startTime<=b&&(c=e);return c},ss=function(a,b){var c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||
6
- b.verticalTiles||1,e=c*d;return{Tc:c,Ue:d,Af:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},ts=function(){this.f=new _.C(cs);this.a=this.l=null},us=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},vs=function(a){if(!a)return null;a=new _.Hj(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},ws=function(){};ds.prototype.raw=function(){return this.a.cloneNode(!1)};
7
- ds.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(_.Lc);e.style.width=c+_.Ud;e.style.height=d+_.Ud;e.style.backgroundColor="#000";e.style.backgroundRepeat="no-repeat";e.style.backgroundImage="url("+this.src+")";e.style.backgroundSize=Math.ceil(c/this.width*(this.a.naturalWidth||this.a.width))+"px "+Math.ceil(d/
2
+ var f=function(window){var Bs="No thumbnail duration or URL specified",Cs="No thumbnail found for position ",Ds="Position is out of range: ",Es="Thumbnail URL is mandatory",Fs="Wrong gridSize format",Gs="clpp.thumbnails",Hs=function(){this.log=new _.D(Gs);this.g=null;this.a=[];this.w=!1},Js=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Ad&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return Is(a,0,e,!!f)})},Promise.resolve())},Is=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();
3
+ var e=b+c;return Ks(a,d).then(function(){return a.a[b].load()}).then(function(){return Is(a,e,c,d)})},Ks=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.Ml)c();else a.g.one(_.jc,function(){c()})})},Ls=function(a,b,c,d,e,f,g,k,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;k=void 0===k?1:k;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=c;this.x=d;this.y=e;this.width=f;this.height=g;
4
+ this.a=p;this.g=k;this.m=l;this.h=m;this.j=n;this.f=null},Ms=function(a,b){return b>=a.time&&b<a.time+a.duration},Ns=function(){Hs.call(this);this.f=null;this.o=this.h=1;this.j=0},Os=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.a=new _.Qh},Ps=function(){this.g=new _.D(Gs);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Qh},Qs=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.a.resolve()})},Ss=function(a,b){return Rs(a,b).then(function(c){return new Ls(c,
5
+ b.time,b.duration)})},Rs=function(a,b){return b.load().then(function(){var c=_.Q(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.jj(c)})},Ts=function(){Hs.call(this);this.f=null},Us=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},Vs=function(){Hs.apply(this,arguments)},Ws=function(a,b){for(var c=null,d=_.t(a),e=d.next();!e.done;e=d.next())e=e.value,e.startTime<=b&&(c=e);return c},Xs=function(a,b){var c=a.horizontalTiles||
6
+ b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Uc:c,We:d,Cf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Ys=function(){this.f=new _.D(Gs);this.a=this.l=null},Zs=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},$s=function(a){if(!a)return null;a=new _.Vj(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},at=function(){};Hs.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.Xd,function(){c.w=!0});a.isLive()||this.m().then(function(){b&&b.preload&&Js(c,b.preload)})};Ls.prototype.raw=function(){return this.a.cloneNode(!1)};
7
+ Ls.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(_.Mc);e.style.width=c+_.Ud;e.style.height=d+_.Ud;e.style.backgroundColor="#000";e.style.backgroundRepeat="no-repeat";e.style.backgroundImage='url("'+this.src+'")';e.style.backgroundSize=Math.ceil(c/this.width*(this.a.naturalWidth||this.a.width))+"px "+Math.ceil(d/
8
8
  this.height*(this.a.naturalHeight||this.a.height))+_.Ud;var f=this.y/this.height;e.style.backgroundPositionX="-"+this.x/this.width*c+_.Ud;e.style.backgroundPositionY="-"+f*d+_.Ud;return e};
9
- ds.prototype.load=function(){var a=this;this.f||(this.f=new Promise(function(b,c){function d(){a.width||(a.width=(a.a.naturalWidth||a.a.width)/a.g);a.height||(a.height=(a.a.naturalHeight||a.a.height)/a.m);a.x||(a.x=a.width*a.h);a.y||(a.y=a.height*a.j)}if(a.a.src&&a.a.complete)d(),b(a);else{var e=null,f=function(){d();a.a.removeEventListener("load",f);a.a.removeEventListener(_.Wc,e);b(a)};e=function(){a.a.removeEventListener("load",f);a.a.removeEventListener(_.Wc,e);c()};a.a.addEventListener("load",
10
- f);a.a.addEventListener(_.Wc,e);a.a.src=a.src}}));return this.f};_.A("clpp.thumbnails.Thumbnail",ds);ds.prototype.load=ds.prototype.load;ds.prototype.element=ds.prototype.element;ds.prototype.raw=ds.prototype.raw;es.prototype.load=function(){return this.a};
11
- fs.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.J(_.K,7,7100,as);var d=_.fh(b.url);d.type=_.eh;a.getNetworkEngine().fetch(d).N.then(function(e){e=e.data;var f=_.Q(c.f);e=_.Q(e);for(var g=f.byteLength+e.byteLength,k=new ArrayBuffer(g),l=new DataView(k),m=0,n=0,p=f.byteLength;n<p;n++)l.setUint8(m,f[n]),m+=1;f=0;for(n=e.byteLength;f<n;f++)l.setUint8(m,e[f]),m+=1;c.f=k;c.g.info("Appended "+e.byteLength+" bytes.Total data now "+(g+" bytes."))}).then(function(){var e=c.f,f=_.Q(e),g=
12
- String.fromCharCode.apply(null,xs),k=Array.prototype.slice.call(f,0,8);f=64;var l=0;var m=!1;if(g===String.fromCharCode.apply(null,k))for(e=new DataView(e,16,20),e=e.getUint32(0,!0),0===e&&(e=1E3);!m;){l+=1;k=e;g=new DataView(c.f,f);m=g.getUint32(0,!0);k=m*k/1E3;g=g.getUint32(4,!0);g=new es(k,g);if(k=c.a.length)k=c.a[k-1],k.length=g.offset-k.offset,k.duration=g.time-k.time;c.a.push(g);f+=8;(m=4294967295===m)&&c.h.resolve();if(1E5<l)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");
13
- }).then(function(){gs(c)})["catch"](function(e){c.g.error("Error while loading thumbnail index",e)})};fs.prototype.get=function(a){var b=this;return 0>a?Promise.reject($r+a):this.h.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(d.time>=a&&a<d.time+d.duration)return is(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Zr+a)})};var xs=[137,66,73,70,13,10,26,10];js.prototype.init=function(a,b){var c=this;this.g=a;a.one(_.Xd,function(){c.w=!0});a.isLive()||this.m().then(function(){b&&b.preload&&ls(c,b.preload)})};_.u(ns,js);
14
- ns.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.J(_.K,7,7100,as);var d=b.url,e=_.fh(d);e.type=_.eh;this.f=a.getNetworkEngine().fetch(e).N.then(function(f){if(f=f.data){f=_.Qg(f).split(/\n/);for(var g=0;g<f.length;g++){var k=f[g],l=k.split(" --\x3e ");if(2===l.length){k=f[++g];var m=k.indexOf("\x3d"),n=0>m?[]:k.substr(m+1).split(/,/).map(parseFloat);m=n[0];var p=n[1],q=n[2];n=n[3];var r=k.indexOf("#");k=0>r?k:k.substr(0,r);k.match(/^http|^\/\//)||(k=d.substr(0,d.lastIndexOf("/"))+"/"+
15
- k);r=os(l[0]);l=os(l[1])-r;c.a.push(new ds(k,r,l,m,p,q,n,0,0))}}}})["catch"](function(f){c.log.error("[VTT] Error while loading thumbnail",f)});js.prototype.init.call(this,a,b)};ns.prototype.get=function(a){var b=this;return 0>a?Promise.reject($r+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Rb:c.Rb},d++)if(c.Rb=b.a[d],c.Rb.time>=a&&a<c.Rb.time+c.Rb.duration)return c.Rb.load().then(function(e){return function(){return e.Rb}}(c));return Promise.reject(Zr+a)})};ns.prototype.m=function(){return this.f};_.u(ps,js);
16
- ps.prototype.init=function(a,b){if(!b||!b.url)throw new _.J(_.K,7,7100,as);if("GRID"===b.mode&&!b.gridSize)throw new _.J(_.K,7,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.J(_.K,7,7100,"Duration is mandatory");this.f=b;var c=this.f.duration,d=this.f.url;if(!c||!d)throw this.log.error(Yr,c,d),new _.J(_.K,7,7100,Yr);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],
17
- this.o=e[1];else throw new _.J(_.K,7,7100,bs);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.J(_.K,7,7100,bs);}js.prototype.init.call(this,a,b)};ps.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($r+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Zr+a+" at index "+c)};
18
- ps.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 ds(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()};_.u(qs,js);
19
- qs.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=rs(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),
20
- Promise.reject();var d=c.getSegmentReference(b);if(d){var e=ss(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.Af+a]);else if((c=d.Ra())&&0<c.length){var g=0,k=0;d=d.startTime;1<e.Af&&(g=a%e.Tc,k=Math.floor(a/e.Tc),d+=a*e.durationPerTile);f=new ds(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.Tc,e.Ue,g,k)}if(f)return f.load().then(function(){return f})}this.log.error("segment reference for specified segment index does not exist",
21
- b);return Promise.reject()};qs.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
22
- qs.prototype.m=function(){if(0<this.a.length)return Promise.resolve();var a=this.g.getPeriods();a=_.t(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&&!_.H.R(d=b.getSegmentReference(c++));)for(var e=ss(d,b),f=d.Ra()[0],g=new Image,k=d.startTime,l=0;l<e.Ue;++l)for(var m=0;m<e.Tc;++m)this.a.push(new ds(f,k,e.durationPerTile,void 0,void 0,void 0,void 0,e.Tc,e.Ue,m,l,g)),k+=e.durationPerTile;return Promise.resolve()};_.h=ts.prototype;_.h.onPlayerCreated=function(a){this.l=a};_.h.onPlayerWillDestroy=function(){this.l=null};_.h.onPlayerWillRelease=function(){this.a=null};
23
- _.h.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=vs(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new ps:"WEBVTT"===c?this.a=new ns:"BIF"===c&&(this.a=new fs)),this.a&&(this.f.info("Loading thumbs configuraiton",d),this.l.one(_.jd,function(){b.f.info("Initialize thumbnails provider");b.a.init(a,d)})))}else this.a=null};
24
- _.h.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();this.f.info(_.Cd,d);us(d)&&(this.a=new qs,this.a.init(a,c))}};_.h.get=function(a){return this.a?this.a.get(a):Promise.reject()};_.h.id=function(){return"thumbnails"};_.A("clpp.thumbnails.ThumbnailsPlugin",ts);ts.prototype.get=ts.prototype.get;ts.Id="thumbnails";ws.prototype.create=function(){return new ts};_.fn(new ws);};
9
+ Ls.prototype.load=function(){var a=this;this.f||(this.f=new Promise(function(b,c){function d(){a.width||(a.width=(a.a.naturalWidth||a.a.width)/a.g);a.height||(a.height=(a.a.naturalHeight||a.a.height)/a.m);a.x||(a.x=a.width*a.h);a.y||(a.y=a.height*a.j)}if(a.a.src&&a.a.complete)d(),b(a);else{var e=null,f=function(){d();a.a.removeEventListener("load",f);a.a.removeEventListener(_.Xc,e);b(a)};e=function(){a.a.removeEventListener("load",f);a.a.removeEventListener(_.Xc,e);c()};a.a.addEventListener("load",
10
+ f);a.a.addEventListener(_.Xc,e);a.a.src=a.src}}));return this.f};_.A("clpp.thumbnails.Thumbnail",Ls);Ls.prototype.load=Ls.prototype.load;Ls.prototype.element=Ls.prototype.element;Ls.prototype.raw=Ls.prototype.raw;_.u(Ns,Hs);
11
+ Ns.prototype.init=function(a,b){if(!b||!b.url)throw new _.J(_.K,7,7100,Es);if("GRID"===b.mode&&!b.gridSize)throw new _.J(_.K,7,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.J(_.K,7,7100,"Duration is mandatory");this.f=b;var c=this.f.duration,d=this.f.url;if(!c||!d)throw this.log.error(Bs,c,d),new _.J(_.K,7,7100,Bs);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 _.J(_.K,7,7100,Fs);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.J(_.K,7,7100,Fs);}Hs.prototype.init.call(this,a,b)};Ns.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(Ds+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Cs+a+" at index "+c)};
13
+ Ns.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 Ls(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()};Os.prototype.load=function(){return this.a};
14
+ Ps.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.J(_.K,7,7100,Es);var d=_.ih(b.url);d.type=_.hh;a.getNetworkEngine().fetch(d).N.then(function(e){e=e.data;var f=_.Q(c.f);e=_.Q(e);for(var g=f.byteLength+e.byteLength,k=new ArrayBuffer(g),l=new DataView(k),m=0,n=0,p=f.byteLength;n<p;n++)l.setUint8(m,f[n]),m+=1;f=0;for(n=e.byteLength;f<n;f++)l.setUint8(m,e[f]),m+=1;c.f=k;c.g.info("Appended "+e.byteLength+" bytes.Total data now "+(g+" bytes."))}).then(function(){var e=c.f,f=_.Q(e),g=
15
+ String.fromCharCode.apply(null,bt),k=Array.prototype.slice.call(f,0,8);f=64;var l=0;var m=!1;if(g===String.fromCharCode.apply(null,k))for(e=new DataView(e,16,20),e=e.getUint32(0,!0),0===e&&(e=1E3);!m;){l+=1;k=e;g=new DataView(c.f,f);m=g.getUint32(0,!0);k=m*k/1E3;g=g.getUint32(4,!0);g=new Os(k,g);if(k=c.a.length)k=c.a[k-1],k.length=g.offset-k.offset,k.duration=g.time-k.time;c.a.push(g);f+=8;(m=4294967295===m)&&c.h.resolve();if(1E5<l)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");
16
+ }).then(function(){Qs(c)})["catch"](function(e){c.g.error("Error while loading thumbnail index",e)})};Ps.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ds+a):this.h.then(function(){for(var c=0;c<b.a.length;c++){var d=b.a[c];if(a>=d.time&&a<d.time+d.duration)return Ss(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Cs+a)})};var bt=[137,66,73,70,13,10,26,10];_.u(Ts,Hs);
17
+ Ts.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.J(_.K,7,7100,Es);var d=b.url,e=_.ih(d);e.type=_.hh;this.f=a.getNetworkEngine().fetch(e).N.then(function(f){if(f=f.data){f=_.Tg(f).split(/\n/);for(var g=0;g<f.length;g++){var k=f[g],l=k.split(" --\x3e ");if(2===l.length){k=f[++g];var m=k.indexOf("\x3d"),n=0>m?[]:k.substr(m+1).split(/,/).map(parseFloat);m=n[0];var p=n[1],q=n[2];n=n[3];var r=k.indexOf("#");k=0>r?k:k.substr(0,r);k.match(/^http|^\/\//)||(k=d.substr(0,d.lastIndexOf("/"))+"/"+
18
+ k);r=Us(l[0]);l=Us(l[1])-r;c.a.push(new Ls(k,r,l,m,p,q,n,0,0))}}}})["catch"](function(f){c.log.error("[VTT] Error while loading thumbnail",f)});Hs.prototype.init.call(this,a,b)};Ts.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ds+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Jc:c.Jc},d++)if(c.Jc=b.a[d],Ms(c.Jc,a))return c.Jc.load().then(function(e){return function(){return e.Jc}}(c));return Promise.reject(Cs+a)})};Ts.prototype.m=function(){return this.f};_.u(Vs,Hs);
19
+ Vs.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=Ws(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),
20
+ Promise.reject();var d=c.getSegmentReference(b);if(d){var e=Xs(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.Cf+a]);else if((c=d.Ra())&&0<c.length){var g=0,k=0;d=d.startTime;1<e.Cf&&(g=a%e.Uc,k=Math.floor(a/e.Uc),d+=a*e.durationPerTile);f=new Ls(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.Uc,e.We,g,k)}if(f)return f.load().then(function(){return f})}this.log.error("segment reference for specified segment index does not exist",
21
+ b);return Promise.reject()};Vs.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
22
+ Vs.prototype.m=function(){if(0<this.a.length)return Promise.resolve();var a=this.g.getPeriods();a=_.t(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&&!_.H.R(d=b.getSegmentReference(c++));)for(var e=Xs(d,b),f=d.Ra()[0],g=new Image,k=d.startTime,l=0;l<e.We;++l)for(var m=0;m<e.Uc;++m)this.a.push(new Ls(f,k,e.durationPerTile,void 0,void 0,void 0,void 0,e.Uc,e.We,m,l,g)),k+=e.durationPerTile;return Promise.resolve()};_.h=Ys.prototype;_.h.onPlayerCreated=function(a){this.l=a};_.h.onPlayerWillDestroy=function(){this.l=null};_.h.onPlayerWillRelease=function(){this.a=null};
23
+ _.h.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=$s(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new Ns:"WEBVTT"===c?this.a=new Ts:"BIF"===c&&(this.a=new Ps)),this.a&&(this.f.info("Loading thumbs configuration",d),this.l.one(_.kd,function(){b.f.info("Initialize thumbnails provider");b.a.init(a,d)})))}else this.a=null};
24
+ _.h.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();this.f.info(_.Cd,d);Zs(d)&&(this.a=new Vs,this.a.init(a,c))}};_.h.get=function(a){return this.a?this.a.get(a):Promise.reject()};_.h.id=function(){return"thumbnails"};_.A("clpp.thumbnails.ThumbnailsPlugin",Ys);Ys.prototype.get=Ys.prototype.get;Ys.Id="thumbnails";at.prototype.create=function(){return new Ys};_.pn(new at);};
25
25
  if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
26
26
  else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
27
27
  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 NC="An unknown error occured while trying to get volume",OC="Cannot get loading rendition due to platform limitations",PC="PARAM_START_POSITION",QC="SecurityError",RC="The require privilege is: http://tizen.org/privilege/tv.audio",SC="|STARTBITRATE\x3d",TC=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},UC=function(a,b){this.h=a;this.w=null;this.a=_.yd;this.o=null;this.j=!1;this.f=new Map;this.m=b;this.g=new _.C("clpp.tizen.DrmEngine")},XC=function(a){var b,
3
- c,d;return _.z(function(e){if(1==e.a){b=a.a===_.Fc||a.a===_.Ec;if(!b)throw new _.J(_.K,6,6001,"The key system "+a.a+" is not supported by the player or the platform");c=a.f.get(a.a);if(!c.Wc)throw new _.J(_.K,6,6012,"No license server given for "+a.a);_.pf(e,2);return a.a===_.Fc?_.v(e,VC(a),5):_.v(e,WC(a,c),5)}if(2!=e.a)return a.w={keySystem:a.a,licenseServerUri:c.Wc,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Fe,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
4
- keyIds:[],periodId:null},_.qf(e,0);d=_.rf(e);a.g.error("Error while configuring CDM for "+a.a,d);throw new _.J(_.K,6,6005,{message:JSON.stringify(d)});})},WC=function(a,b){var c,d,e,f;return _.z(function(g){c=YC;d=ZC;e={};e[d.kg]=!b.Fe;e[d.lg]=b.Wc;""!==b.customData&&(e[d.jg]=b.customData);f=JSON.stringify(e);a.g.debug("PlayReady properties: ",f);try{webapis.avplay.setDrm(c.PLAYREADY,"SetProperties",f)}catch(k){throw k;}_.w(g)})},VC=function(a){var b;return _.z(function(c){b=YC;try{webapis.avplay.setDrm(b.gd,
5
- "Initialize",""),webapis.avplay.setDrm(b.gd,"widevine_app_session",a.o.id),webapis.avplay.setDrm(b.gd,"widevine_data_type",a.o.type)}catch(d){throw d;}_.w(c)})},$C=function(a,b){var c,d,e,f,g,k,l,m,n,p,q,r,x,y,E,I,F;_.z(function(G){if(1==G.a){c=YC;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);k=b.serverurl&&""!==b.serverurl?b.serverurl:d.Wc;l=_.fh([k],_.ch());l.type=3;l.body=f.buffer;l.method=
6
- "POST";_.pf(G,2);return _.v(G,a.m.wb.fetch(l).N,4)}if(2!=G.a){m=G.f;if(a.j){n=_.Q(m.data);p=n.byteLength;q="";for(r=0;r<p;r++)q+=String.fromCharCode(n[r]);x=btoa(q);y=b.session_id+PC+(x+PC);a.g.debug("Widevine license params",y);try{webapis.avplay.setDrm(c.gd,"widevine_license_data",y)}catch(M){a.g.error("License response rejected by CDM"),E=new _.J(_.K,6,6008,{browserError:JSON.stringify(M)}),a.m.onError(E)}}return _.qf(G,0)}I=_.rf(G);a.g.error("License request failed.",JSON.stringify(I));F=new _.J(_.K,
7
- 6,6007,{message:_.Ba,url:I.data.url,status:I.data.status||NaN,response:I.data.response||"",headers:I.data.headers||{}},I);a.m.onError(F);_.w(G)})},aD=function(a){this.l=a;this.a=this.l.a;this.f=_.yl;this.j=_.zl;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.C("clpp.tizen.StateManager")},cD=function(a,b){if(a.f!==b)if(a.f===_.Jl&&b!==_.yl)a.g.debug(_.lt+bD(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.Dl?(a.o=(new Date).getTime(),a.l.trigger(new _.D(_.jc,{detail:{bufferedTimeMS:-1,
8
- reason:a.h}}))):a.j===_.Dl&&a.l.trigger(new _.D(_.ic,{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 _.D(_.he,{detail:d}));a.g.debug("State changed:",bD(a.j),"-\x3e",bD(a.f))}},bD=function(a){return Object.keys(_.Hl)[a]},fD=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case dD:c=_.Ml;break;case eD:c=_.Ll;break;default:a.l.isEnded()?c=_.Fl:a.g.debug("Inconsistent AVPlay plackback state:",b)}cD(a,
9
- c)}},gD=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 _.C("clpp.tizen.TextStreamer")},hD=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},iD=function(a){var b,c;return _.z(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.v(d,_.ho(a.B.url,a.l.getNetworkEngine(),b.manifest.attemptParameters,a.B.type),2);(c=d.f)&&c.configure(b.manifest);return d["return"](c)})},jD=function(a){var b=
10
- document.createElement(_.Ge),c=new _.Wu,d=new _.Wt(function(){return null}),e=a.l.getTextDisplayer();return new _.bv(b,c,e,d,a.l.getConfiguration())},kD=function(a){var b={qb:function(){return a.l.getPosition()},W:a.h,wb:a.l.getNetworkEngine(),ye:a.Hh.bind(a),xe:a.Gh.bind(a),onError:a.S.bind(a),Of:function(){},onEvent:function(){},Tf:a.Ih.bind(a),Cd:function(){},de:function(){return new _.fw}};return new _.$w(a.f,b)},lD=function(a){var b=a.l.getPosition(),c=null;a=_.t(a.f.periods);for(var d=a.next();!d.done;d=
11
- a.next())d=d.value,d.startTime<=b&&(c=d);return c},mD=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 _.wg(String(c++),_.L);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.zt;var f=new _.Dg(String(a[d].id),e);
12
- f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},nD=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.ax(a.g,_.re),c=null;if(b){a=mD(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},oD=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=lD(a),d=b.renditions[0];(c=c.textStreams.find(function(e){return String(e.id)==
13
- d.id}))?(a.w?(a.a.debug("Switching period defer text selection"),a.m=c):(_.ix(a.g,c,!0,0),a.l.trigger(new _.D(_.Hh))),a.o=c.language):a.a.error(_.kt,d.id)}},pD=function(){this.h=this.f=this.l=null;this.g={};this.a=new _.C("clpp.tizen.TrackManager");this.w=this.m=this.j=null;this.A=!1;this.o=1},qD=function(a,b){a.l.trigger(new _.D(_.Ke,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},rD=function(a){var b=a.fa();b&&a.l.trigger(new _.D(_.gc,{detail:{width:b.width,
14
- height:b.height,bandwidth:b.bandwidth,rendition:b}}))},sD=function(a){var b=a.l.getConfiguration(),c=_.vh(b.preferredAudioLanguage||[]),d=a.g[_.N]||[];if(d.length){var e=null;c.some(function(g){e=_.Kt(g,d.map(function(k){return k.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]));a.a.debug("Setting audio track with preferred language:",
15
- e);a.ma(c)}else a.a.debug("Preferred language(s) not available")}else a.a.debug("Could not set preferred audio language")},wD=function(a,b){if(b){var c=b.track.type.toUpperCase();tD(a.f,c,Number(b.id)).then(function(){c===uD&&(a.j=b,a.l.trigger(new _.D(_.Gh)));c===vD&&(a.m=b,a.l.trigger(new _.D(_.Hh)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},xD=function(a,b,c){var d=_.rh(b.language||_.xe);c.language=_.xg(d);c.channelsCount=
16
- b.channels?Number(b.channels):null;c.mimeType=_.cc;a=new _.Dg(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},yD=function(a,b,c){c.mimeType=_.Ie;a=new _.Dg(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},zD=function(a,b,c){b=_.rh(b.track_lang||_.xe);c.mimeType="text/ttml";c.language=_.xg(b);c.kind=_.zt;return new _.Dg(String(a),c)},AD=function(a,b){var c=null;try{c=
17
- JSON.parse(b)}catch(d){a.a.warn("Couldn't retrieve extra infos from stream."),c=null}return c},DD=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===BD}),f=b.filter(function(n){return n.type===uD}),g=[],k=0;k<f.length;k++){var l=AD(a,f[k].extra_info);if(l){var m=_.rh(l.language||_.xe);m=_.xg(m);m=c(g,m);m||(m=new _.wg(String(a.o++),_.N),g.push(m));m.renditions.push(xD(f[k].index,
18
- l,m))}else a.a.warn("Skipping audio stream with no extra info")}f=new _.wg(String(a.o++),_.yg);for(k=0;k<e.length;k++)(l=AD(a,e[k].extra_info))?f.renditions.push(yD(e[k].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?mD(a.h):CD(a,b);d[_.yg]=[f];d[_.N]=g;d[_.L]=e;return d},CD=function(a,b){for(var c=b.filter(function(k){return k.type===vD}),d=[],e=0;e<c.length;e++){var f=AD(a,c[e].extra_info);if(f){var g=new _.wg(String(a.o++),_.L);g.renditions.push(zD(c[e].index,f,g));
19
- d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},ED=function(a,b){for(var c=a.g[_.yg]||[],d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].renditions.length;f++)_.H.Oa(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},FD=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},HD=function(a,b){if(b===_.L&&a.h)return nD(a.h);
20
- var c=GD(a.f)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.yg&&(d=AD(a,c.extra_info),d=ED(a,{width:d.Width,height:d.Height}));b===_.N&&(c?(d=FD(a,c,_.N),a.j=d):d=a.j);b===_.L&&(c?(d=FD(a,c,_.L),a.m=d):d=a.m);return d},ID=function(a){_.Mh.call(this);this.l=a;this.h=null;this.a=new _.C("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=1;this.w=!1;this.j={}},JD=function(a){return _.z(function(b){tizen.systeminfo.getPropertyValue("DISPLAY",
21
- 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;});_.w(b)})},LD=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 _.D(KD,{currentTime:b}))},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)}},
22
- MD=function(a){var b=!!a.l.getTrackManager().Ba();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.a.debug("Could not set AVPlay subtitle config",c)}},ND=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,Yj:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",SC+d)}catch(e){a.a.debug(e)}},OD=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+SC+b)}catch(c){throw a.a.debug("Could not set fixed bandwdth",
23
- c),c;}},RD=function(a){return{position:a.getPosition(),state:a.l.getState(),$e:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:PD(a),volume:a.getVolume(),Cj:QD(a),Rh:GD(a)}},TD=function(a){var b,c;return _.z(function(d){if(1==d.a)return _.v(d,SD(),2);if(3!=d.a)return b=new Promise(function(e){(new _.nh(e)).Z(5)}),_.v(d,Promise.race([JD(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"),
24
- d["return"](Promise.reject("SDK Timeout"));_.w(d)})},ZD=function(a,b,c){var d,e,f,g,k,l,m,n;return _.z(function(p){switch(p.a){case 1:a.m=_.Ql(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 _.D(UD)),f=c.currentPosition);_.pf(p,2);g=a.m[d].url;k=a.m[d].type;k!==_.Rb||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);
25
- e.nextBandwidth?(OD(a,e.nextBandwidth),a.o=!1):(a.o||ND(a,e),a.o=!0);LD(a);if(!b.drm||!b.drm.env){a.a.debug("No DRM configuration was provided. Assuming clear content");p.G(4);break}m={onError:function(q){return a.l.onError(q)},wb:a.l.getNetworkEngine()};a.h=new UC(b.drm,m);return _.v(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.D(VD)),_.v(p,WD(a),6);case 6:a.g||a.trigger(new _.D(XD));f&&typeof f===_.zd&&0<f&&a.seek(f)["catch"](function(q){a.a.debug("Couldn't set start position",q)});a.g||(b.volume&&
26
- a.setVolume(b.volume),b.muted&&YD(a,b.muted),b.autoplay&&a.l.play()["catch"](function(q){a.a.debug("Autoplay failed",q)}));_.qf(p,0);break;case 2:throw n=_.rf(p),a.a.debug("Error while attempting to load source."),n;}})},WD=function(a){return _.z(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!");MD(a);c()},function(e){a.a.debug("prepareAsync failed",e);d(e)})}catch(e){a.a.debug("Failed to prepare media player for playback"),
27
- d(e)}}))})},$D=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=RD(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.f.$e;a.g=!1;a.f=null;return e===eD?a.pause():a.play()})}catch(e){return Promise.reject(e)}},QD=function(a){return a.g&&a.f?a.f.Cj:webapis.avplay.getTotalTrackInfo()},
28
- GD=function(a){return a.g&&a.f?a.f.Rh:webapis.avplay.getCurrentStreamInfo()},tD=function(a,b,c){b=b.toUpperCase();b===vD&&aE(a,!0);var d=a.j[b];d&&(d.Fd.stop(),a.j[b]=null,a.a.debug("Cancelled pending track switch for "+b));return new Promise(function(e,f){function g(k,l,m){m=void 0===m?!1:m;try{webapis.avplay.setSelectTrack(k,l),a.j[k]=null,e()}catch(n){a.a.debug("Could not set "+k+" track. Trying again...AVPlay state: "+(a.getState()+", buffering: ")+a.w,n),!1===m&&(a.j[k]={type:k,index:l,Ye:0,
29
- Fd:new _.nh(function(){return g(k,c,!0)})}),(l=a.j[k])&&3>l.Ye?(!a.w&&++l.Ye,l.Fd.Z(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Fd.stop(),a.j[k]=null,f())}}g(b,c)})},aE=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",d)}},YD=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case QC:a.a.warn("The application does not have the privilege to set mute.",
30
- RC);break;default:a.a.warn(NC,c)}}},PD=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case QC:a.a.warn("The application doesn't have the privilege to get the mute state.",RC);break;default:a.a.warn(NC,c)}}return!!b},SD=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");TC(c,"load",function(d){return a(d)});TC(c,_.Wc,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},
31
- bE=function(){_.Mh.call(this);this.a=new ID(this);this.f=new aD(this);this.configuration=this.B=_.Ri();this.w=null;this.h=new _.C("clpp.tizen.Player");this.j=null;this.m=new pD;this.C=new _.ji;this.o=this.g=null;this.A=!1},cE=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*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,
32
- 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())},dE=function(){},eE=function(){this.a=null};
33
- UC.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.z(function(k){if(1==k.a){b=_.oj[a.h.env]||null;if(!b)throw a.g.debug(_.ra,_.$a+a.h.env+_.aa),new _.J(_.K,6,6015,_.sa+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=_.qj(b,a.h.customData);(e=d[_.Ec])&&a.f.set(_.Ec,{Wc:e.licenseUrl||"",customData:c,Fe:!1});(f=d[_.Fc])&&a.f.set(_.Fc,{Wc:f.licenseUrl||"",customData:c,
34
- Fe:!1});if(0===a.f.size)throw new _.J(_.K,6,6E3);if((g=a.h.preferredDrmSystem)&&a.f.get(g))a.a=g;else if(a.f.get(_.Ec))a.a=_.Ec;else if(a.f.get(_.Fc))a.a=_.Fc;else throw new _.J(_.K,6,6001,"Configuration for the target system is missing.");return _.v(k,XC(a),2)}a.j=!0;_.w(k)})};UC.prototype.release=function(){var a=this;return _.z(function(b){a.j=!1;a.w=null;a.a=_.yd;a.o=null;a.f=new Map;_.w(b)})};UC.prototype.getDrmInfo=function(){return this.w};
35
- var ZC={kg:"DeleteLicenseAfterUse",lg:"LicenseServer",Mj:"GetChallenge",Nj:"HttpHeader",Rj:"UserAgent",Ij:"Cookie",jg:"CustomData"};_.h=aD.prototype;_.h.release=function(){cD(this,_.yl);this.m=!1;this.o=-1;this.h=2};_.h.destroy=function(){this.release();this.a.off(UD,this.mf);this.a.off(fE,this.lf);this.a.off(gE,this.kf);this.a.off(VD,this.Vf);this.a.off(XD,this.Uf);this.a.off(hE,this.nf);this.l=this.a=null};_.h.mf=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;cD(this,_.Dl)};_.h.lf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",bD(this.f))};
36
- _.h.kf=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()===iE;if(!a&&b){cD(this,_.Ll);return}}if(a=this.f!==_.Kl)a=this.a.getState(),a=a===dD||a===eD;a&&fD(this)};_.h.Vf=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===jE?cD(this,_.Kl):this.g.error("AVPlay prepares while state is not IDLE")};
37
- _.h.Uf=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.h.nf=function(){cD(this,_.Fl)};_.h.getState=function(){return this.f};_.h=gD.prototype;
38
- _.h.load=function(a){var b=this,c,d,e,f,g,k,l;return _.z(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 _.v(m,iD(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(){},onError:function(){}};
39
- _.pf(m,3);e=b;return _.v(m,b.j.start(a.url,d),5);case 5:e.f=m.f;_.qf(m,4);break;case 3:return f=_.rf(m),b.a.warn(f),_.pf(m,6),g=b,_.v(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.f=m.f;_.qf(m,4);break;case 6:k=_.rf(m),b.a.error(k),b.f=null;case 4:if(!b.f||!hD(b.f)){m.G(0);break}b.h=jD(b);_.pf(m,10);return _.v(m,b.h.H,12);case 12:b.g=kD(b);l=b.l.getConfiguration();b.g.m=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;_.qf(m,0);break;case 10:_.rf(m),b.a.debug("Could not setup media source..."),
40
- b.h=null,b.g=null,b.j=null,b.f=null,_.w(m)}})};_.h.Hh=function(a){this.a.debug(_.ut,a);this.w=!0;var b=_.Hv(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}};_.h.Gh=function(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.ix(this.g,this.m,!0,0),this.m=null)};_.h.S=function(){this.a.debug("onError_")};_.h.Ih=function(){this.j&&this.j.update&&this.j.update()};
2
+ var f=function(window){var xD="An unknown error occurred while trying to get volume",yD="Cannot get loading rendition due to platform limitations",zD="PARAM_START_POSITION",AD="SecurityError",BD="The require privilege is: http://tizen.org/privilege/tv.audio",CD="|STARTBITRATE\x3d",DD=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},ED=function(a,b){this.h=a;this.w=null;this.a=_.yd;this.o=null;this.j=!1;this.f=new Map;this.m=b;this.g=new _.D("clpp.tizen.DrmEngine")},HD=function(a){var b,
3
+ c,d;return _.z(function(e){if(1==e.a){b=a.a===_.Gc||a.a===_.Fc;if(!b)throw new _.J(_.K,6,6001,"The key system "+a.a+" is not supported by the player or the platform");c=a.f.get(a.a);if(!c.Xc)throw new _.J(_.K,6,6012,"No license server given for "+a.a);_.rf(e,2);return a.a===_.Gc?_.v(e,FD(a),5):_.v(e,GD(a,c),5)}if(2!=e.a)return a.w={keySystem:a.a,licenseServerUri:c.Xc,distinctiveIdentifierRequired:!1,persistentStateRequired:c.He,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
4
+ keyIds:[],periodId:null},_.sf(e,0);d=_.tf(e);a.g.error("Error while configuring CDM for "+a.a,d);throw new _.J(_.K,6,6005,{message:JSON.stringify(d)});})},GD=function(a,b){var c,d,e,f;return _.z(function(g){c=ID;d=JD;e={};e[d.ng]=!b.He;e[d.og]=b.Xc;""!==b.customData&&(e[d.mg]=b.customData);f=JSON.stringify(e);a.g.debug("PlayReady properties: ",f);try{webapis.avplay.setDrm(c.PLAYREADY,"SetProperties",f)}catch(k){throw k;}_.w(g)})},FD=function(a){var b;return _.z(function(c){b=ID;try{webapis.avplay.setDrm(b.hd,
5
+ "Initialize",""),webapis.avplay.setDrm(b.hd,"widevine_app_session",a.o.id),webapis.avplay.setDrm(b.hd,"widevine_data_type",a.o.type)}catch(d){throw d;}_.w(c)})},KD=function(a,b){var c,d,e,f,g,k,l,m,n,p,q,r,x,y,C,I,F;_.z(function(G){if(1==G.a){c=ID;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);k=b.serverurl&&""!==b.serverurl?b.serverurl:d.Xc;l=_.ih([k],_.fh());l.type=3;l.body=f.buffer;l.method=
6
+ "POST";_.rf(G,2);return _.v(G,a.m.wb.fetch(l).N,4)}if(2!=G.a){m=G.f;if(a.j){n=_.Q(m.data);p=n.byteLength;q="";for(r=0;r<p;r++)q+=String.fromCharCode(n[r]);x=btoa(q);y=b.session_id+zD+(x+zD);a.g.debug("Widevine license params",y);try{webapis.avplay.setDrm(c.hd,"widevine_license_data",y)}catch(M){a.g.error("License response rejected by CDM"),C=new _.J(_.K,6,6008,{browserError:JSON.stringify(M)}),a.m.onError(C)}}return _.sf(G,0)}I=_.tf(G);a.g.error("License request failed.",JSON.stringify(I));F=new _.J(_.K,
7
+ 6,6007,{message:_.Ca,url:I.data.url,status:I.data.status||NaN,response:I.data.response||"",headers:I.data.headers||{}},I);a.m.onError(F);_.w(G)})},LD=function(a){this.l=a;this.a=this.l.a;this.f=_.Hl;this.j=_.Il;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.D("clpp.tizen.StateManager")},ND=function(a,b){if(a.f!==b)if(a.f===_.Sl&&b!==_.Hl)a.g.debug(_.Qt+MD(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.Ml?(a.o=(new Date).getTime(),a.l.trigger(new _.E(_.kc,{detail:{bufferedTimeMS:-1,
8
+ reason:a.h}}))):a.j===_.Ml&&a.l.trigger(new _.E(_.jc,{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 _.E(_.ie,{detail:d}));a.g.debug("State changed:",MD(a.j),"-\x3e",MD(a.f))}},MD=function(a){return Object.keys(_.Ql)[a]},QD=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case OD:c=_.Vl;break;case PD:c=_.Ul;break;default:a.l.isEnded()?c=_.Ol:a.g.debug("Inconsistent AVPlay playback state:",b)}ND(a,
9
+ c)}},RD=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 _.D("clpp.tizen.TextStreamer")},SD=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},TD=function(a){var b,c;return _.z(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.v(d,_.qo(a.B.url,a.l.getNetworkEngine(),b.manifest.attemptParameters,a.B.type),2);(c=d.f)&&c.configure(b.manifest);return d["return"](c)})},UD=function(a){var b=
10
+ document.createElement(_.Ie),c=new _.zv,d=new _.yu(function(){return null}),e=a.l.getTextDisplayer();return new _.Fv(b,c,e,d,a.l.getConfiguration())},VD=function(a){var b={qb:function(){return a.l.getPosition()},X:a.h,wb:a.l.getNetworkEngine(),Ae:a.Kh.bind(a),ze:a.Jh.bind(a),onError:a.S.bind(a),Of:function(){},onEvent:function(){},Tf:a.Lh.bind(a),Ed:function(){},fe:function(){return new _.Iw}};return new _.Cx(a.f,b)},WD=function(a){var b=a.l.getPosition(),c=null;a=_.t(a.f.periods);for(var d=a.next();!d.done;d=
11
+ a.next())d=d.value,d.startTime<=b&&(c=d);return c},XD=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 _.zg(String(c++),_.L);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.cu;var f=new _.Gg(String(a[d].id),e);
12
+ f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},YD=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.Dx(a.g,_.te),c=null;if(b){a=XD(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},ZD=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=WD(a),d=b.renditions[0];(c=c.textStreams.find(function(e){return String(e.id)==
13
+ d.id}))?(a.w?(a.a.debug("Switching period defer text selection"),a.m=c):(_.Lx(a.g,c,!0,0),a.l.trigger(new _.E(_.Kh))),a.o=c.language):a.a.error(_.Pt,d.id)}},$D=function(){this.h=this.f=this.l=null;this.g={};this.a=new _.D("clpp.tizen.TrackManager");this.w=this.m=this.j=null;this.A=!1;this.o=1},aE=function(a,b){a.l.trigger(new _.E(_.Me,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},bE=function(a){var b=a.fa();b&&a.l.trigger(new _.E(_.hc,{detail:{width:b.width,
14
+ height:b.height,bandwidth:b.bandwidth,rendition:b}}))},cE=function(a){var b=a.l.getConfiguration(),c=_.yh(b.preferredAudioLanguage||[]),d=a.g[_.N]||[];if(d.length){var e=null;c.some(function(g){e=_.mu(g,d.map(function(k){return k.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]));a.a.debug("Setting audio track with preferred language:",
15
+ e);a.na(c)}else a.a.debug("Preferred language(s) not available")}else a.a.debug("Could not set preferred audio language")},gE=function(a,b){if(b){var c=b.track.type.toUpperCase();dE(a.f,c,Number(b.id)).then(function(){c===eE&&(a.j=b,a.l.trigger(new _.E(_.Jh)));c===fE&&(a.m=b,a.l.trigger(new _.E(_.Kh)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},hE=function(a,b,c){var d=_.uh(b.language||_.ze);c.language=_.Ag(d);c.channelsCount=
16
+ b.channels?Number(b.channels):null;c.mimeType=_.dc;a=new _.Gg(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},iE=function(a,b,c){c.mimeType=_.Ke;a=new _.Gg(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},jE=function(a,b,c){b=_.uh(b.track_lang||_.ze);c.mimeType="text/ttml";c.language=_.Ag(b);c.kind=_.cu;return new _.Gg(String(a),c)},kE=function(a,b){var c=null;try{c=
17
+ JSON.parse(b)}catch(d){a.a.warn("Couldn't retrieve extra infos from stream."),c=null}return c},nE=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===lE}),f=b.filter(function(n){return n.type===eE}),g=[],k=0;k<f.length;k++){var l=kE(a,f[k].extra_info);if(l){var m=_.uh(l.language||_.ze);m=_.Ag(m);m=c(g,m);m||(m=new _.zg(String(a.o++),_.N),g.push(m));m.renditions.push(hE(f[k].index,
18
+ l,m))}else a.a.warn("Skipping audio stream with no extra info")}f=new _.zg(String(a.o++),_.Bg);for(k=0;k<e.length;k++)(l=kE(a,e[k].extra_info))?f.renditions.push(iE(e[k].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?XD(a.h):mE(a,b);d[_.Bg]=[f];d[_.N]=g;d[_.L]=e;return d},mE=function(a,b){for(var c=b.filter(function(k){return k.type===fE}),d=[],e=0;e<c.length;e++){var f=kE(a,c[e].extra_info);if(f){var g=new _.zg(String(a.o++),_.L);g.renditions.push(jE(c[e].index,f,g));
19
+ d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},oE=function(a,b){for(var c=a.g[_.Bg]||[],d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].renditions.length;f++)_.H.Ja(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},pE=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},rE=function(a,b){if(b===_.L&&a.h)return YD(a.h);
20
+ var c=qE(a.f)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.Bg&&(d=kE(a,c.extra_info),d=oE(a,{width:d.Width,height:d.Height}));b===_.N&&(c?(d=pE(a,c,_.N),a.j=d):d=a.j);b===_.L&&(c?(d=pE(a,c,_.L),a.m=d):d=a.m);return d},sE=function(a){_.Ph.call(this);this.l=a;this.h=null;this.a=new _.D("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=1;this.w=!1;this.j={}},tE=function(a){return _.z(function(b){tizen.systeminfo.getPropertyValue("DISPLAY",
21
+ 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;});_.w(b)})},vE=function(a){try{webapis.avplay.setListener({onbufferingstart:a.Eh.bind(a),onbufferingprogress:a.Dh.bind(a),onbufferingcomplete:a.Ch.bind(a),onstreamcompleted:a.Hh.bind(a),oncurrentplaytime:function(b){a.trigger(new _.E(uE,{currentTime:b}))},onevent:a.Gh.bind(a),onsubtitlechange:a.Ih.bind(a),ondrmevent:a.Fh.bind(a),onerror:a.S.bind(a)})}catch(b){a.a.error(b)}},
22
+ wE=function(a){var b=!!a.l.getTrackManager().Ca();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.a.debug("Could not set AVPlay subtitle config",c)}},xE=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,ik:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",CD+d)}catch(e){a.a.debug(e)}},yE=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+CD+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",
23
+ c),c;}},BE=function(a){return{position:a.getPosition(),state:a.l.getState(),bf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:zE(a),volume:a.getVolume(),Kj:AE(a),Uh:qE(a)}},DE=function(a){var b,c;return _.z(function(d){if(1==d.a)return _.v(d,CE(),2);if(3!=d.a)return b=new Promise(function(e){(new _.qh(e)).$(5)}),_.v(d,Promise.race([tE(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"),
24
+ d["return"](Promise.reject("SDK Timeout"));_.w(d)})},JE=function(a,b,c){var d,e,f,g,k,l,m,n;return _.z(function(p){switch(p.a){case 1:a.m=_.Zl(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 _.E(EE)),f=c.currentPosition);_.rf(p,2);g=a.m[d].url;k=a.m[d].type;k!==_.Sb||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);
25
+ e.nextBandwidth?(yE(a,e.nextBandwidth),a.o=!1):(a.o||xE(a,e),a.o=!0);vE(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)},wb:a.l.getNetworkEngine()};a.h=new ED(b.drm,m);return _.v(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.E(FE)),_.v(p,GE(a),6);case 6:a.g||a.trigger(new _.E(HE));f&&typeof f===_.zd&&0<f&&a.seek(f)["catch"](function(q){a.a.debug("Couldn't set start position",q)});a.g||(b.volume&&
26
+ a.setVolume(b.volume),b.muted&&IE(a,b.muted),b.autoplay&&a.l.play()["catch"](function(q){a.a.debug("Autoplay failed",q)}));_.sf(p,0);break;case 2:throw n=_.tf(p),a.a.debug("Error while attempting to load source."),n;}})},GE=function(a){return _.z(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!");wE(a);c()},function(e){a.a.debug("prepareAsync failed",e);d(e)})}catch(e){a.a.debug("Failed to prepare media player for playback"),
27
+ d(e)}}))})},KE=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=BE(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(function(){var e=a.f.bf;a.g=!1;a.f=null;return e===PD?a.pause():a.play()})}catch(e){return Promise.reject(e)}},AE=function(a){return a.g&&a.f?a.f.Kj:webapis.avplay.getTotalTrackInfo()},
28
+ qE=function(a){return a.g&&a.f?a.f.Uh:webapis.avplay.getCurrentStreamInfo()},dE=function(a,b,c){b=b.toUpperCase();b===fE&&LE(a,!0);var d=a.j[b];d&&(d.Hd.stop(),a.j[b]=null,a.a.debug("Cancelled pending track switch for "+b));return new Promise(function(e,f){function g(k,l,m){m=void 0===m?!1:m;try{webapis.avplay.setSelectTrack(k,l),a.j[k]=null,e()}catch(n){a.a.debug("Could not set "+k+" track. Trying again...AVPlay state: "+(a.getState()+", buffering: ")+a.w,n),!1===m&&(a.j[k]={type:k,index:l,$e:0,
29
+ Hd:new _.qh(function(){return g(k,c,!0)})}),(l=a.j[k])&&3>l.$e?(!a.w&&++l.$e,l.Hd.$(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Hd.stop(),a.j[k]=null,f())}}g(b,c)})},LE=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",d)}},IE=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case AD:a.a.warn("The application does not have the privilege to set mute.",
30
+ BD);break;default:a.a.warn(xD,c)}}},zE=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case AD:a.a.warn("The application doesn't have the privilege to get the mute state.",BD);break;default:a.a.warn(xD,c)}}return!!b},CE=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");DD(c,"load",function(d){return a(d)});DD(c,_.Xc,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},
31
+ ME=function(){_.Ph.call(this);this.a=new sE(this);this.f=new LD(this);this.configuration=this.B=_.Xi();this.w=null;this.h=new _.D("clpp.tizen.Player");this.j=null;this.m=new $D;this.C=new _.mi;this.o=this.g=null;this.A=!1},NE=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*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,
32
+ 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())},OE=function(){},PE=function(){this.a=null};
33
+ ED.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.z(function(k){if(1==k.a){b=_.uj[a.h.env]||null;if(!b)throw a.g.debug(_.qa,_.cb+a.h.env+_.aa),new _.J(_.K,6,6015,_.sa+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=_.wj(b,a.h.customData);(e=d[_.Fc])&&a.f.set(_.Fc,{Xc:e.licenseUrl||"",customData:c,He:!1});(f=d[_.Gc])&&a.f.set(_.Gc,{Xc:f.licenseUrl||"",customData:c,
34
+ He:!1});if(0===a.f.size)throw new _.J(_.K,6,6E3);if((g=a.h.preferredDrmSystem)&&a.f.get(g))a.a=g;else if(a.f.get(_.Fc))a.a=_.Fc;else if(a.f.get(_.Gc))a.a=_.Gc;else throw new _.J(_.K,6,6001,"Configuration for the target system is missing.");return _.v(k,HD(a),2)}a.j=!0;_.w(k)})};ED.prototype.release=function(){var a=this;return _.z(function(b){a.j=!1;a.w=null;a.a=_.yd;a.o=null;a.f=new Map;_.w(b)})};ED.prototype.getDrmInfo=function(){return this.w};
35
+ var JD={ng:"DeleteLicenseAfterUse",og:"LicenseServer",Vj:"GetChallenge",Wj:"HttpHeader",ak:"UserAgent",Rj:"Cookie",mg:"CustomData"};_.h=LD.prototype;_.h.release=function(){ND(this,_.Hl);this.m=!1;this.o=-1;this.h=2};_.h.destroy=function(){this.release();this.a.off(EE,this.pf);this.a.off(QE,this.nf);this.a.off(RE,this.mf);this.a.off(FE,this.Vf);this.a.off(HE,this.Uf);this.a.off(SE,this.qf);this.l=this.a=null};_.h.pf=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;ND(this,_.Ml)};_.h.nf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",MD(this.f))};
36
+ _.h.mf=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()===TE;if(!a&&b){ND(this,_.Ul);return}}if(a=this.f!==_.Tl)a=this.a.getState(),a=a===OD||a===PD;a&&QD(this)};_.h.Vf=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===UE?ND(this,_.Tl):this.g.error("AVPlay prepares while state is not IDLE")};
37
+ _.h.Uf=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.h.qf=function(){ND(this,_.Ol)};_.h.getState=function(){return this.f};_.h=RD.prototype;
38
+ _.h.load=function(a){var b=this,c,d,e,f,g,k,l;return _.z(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 _.v(m,TD(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(){},onError:function(){}};
39
+ _.rf(m,3);e=b;return _.v(m,b.j.start(a.url,d),5);case 5:e.f=m.f;_.sf(m,4);break;case 3:return f=_.tf(m),b.a.warn(f),_.rf(m,6),g=b,_.v(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.f=m.f;_.sf(m,4);break;case 6:k=_.tf(m),b.a.error(k),b.f=null;case 4:if(!b.f||!SD(b.f)){m.H(0);break}b.h=UD(b);_.rf(m,10);return _.v(m,b.h.G,12);case 12:b.g=VD(b);l=b.l.getConfiguration();b.g.m=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;_.sf(m,0);break;case 10:_.tf(m),b.a.debug("Could not setup media source..."),
40
+ b.h=null,b.g=null,b.j=null,b.f=null,_.w(m)}})};_.h.Kh=function(a){this.a.debug(_.Zt,a);this.w=!0;var b=_.jw(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}};_.h.Jh=function(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.Lx(this.g,this.m,!0,0),this.m=null)};_.h.S=function(){this.a.debug("onError_")};_.h.Lh=function(){this.j&&this.j.update&&this.j.update()};
41
41
  _.h.start=function(){var a=this;return _.z(function(b){if(!a.g)return b["return"]();try{a.g.start()}catch(c){a.a.error("Error while starting streaming engine",c)}_.w(b)})};_.h.setTextVisibility=function(a){this.a.debug("Set text visibility",a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)};_.h.release=function(){var a=this;return _.z(function(b){a.l=null;a.f=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.m=null;_.w(b)})};
42
- _.h.destroy=function(){var a=this;return _.z(function(b){switch(b.a){case 1:if(!a.j){b.G(2);break}return _.v(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.g){b.G(4);break}return _.v(b,a.g.destroy(),5);case 5:a.g=null,a.w=!0;case 4:if(!a.h){b.G(0);break}return _.v(b,a.h.destroy(),7);case 7:a.h=null,_.w(b)}})};_.u(pD,_.P);_.h=pD.prototype;_.h.Lf=function(a){var b=a.eventid;a=a.data;switch(b){case kE:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+AD(this,b[0].extra_info).Bit_rate,b=ED(this,{bandwidth:b}))&&(this.w=b,qD(this,b));break;case lE:rD(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.h.Be=function(a){a.detail.currentState===_.Ml&&this.l.off(_.he,this.Be)};
43
- _.h.Fb=function(a){var b=this;this.l=a;this.f=this.l.a;this.l.on(_.he,function(c){b.A||(c=c.detail,c.currentState===_.Ml&&(b.a.debug("Current state",c.currentState),b.A=!0,sD(b)))});this.f.on(mE,this.Lf,this)};_.h.release=function(){this.g={};this.h=this.w=this.m=this.j=null;this.A=!1;this.o=1};
44
- _.h.load=function(){if(this.f&&!(0<Object.keys(this.g).length)){this.h=this.l.g;this.l.off(_.he,this.Be);this.l.on(_.he,this.Be,this);try{var a=QD(this.f);this.g=DD(this,a);var b=this.g[_.N]||[];b.length&&(this.j=b[0].renditions[0]||null);rD(this)}catch(c){this.a.debug("Could not load track manager")}}};_.h.destroy=function(){this.f.off(mE,this.Lf);this.f=this.l=null};_.h.getVideoTracks=function(){return this.g[_.yg]||[]};_.h.getAudioTracks=function(){return this.g[_.N]||[]};
45
- _.h.ea=function(){return this.g[_.L]||[]};_.h.fa=function(){return HD(this,_.yg)};_.h.za=function(){return HD(this,_.N)};_.h.Ba=function(){return HD(this,_.L)};_.h.Pa=function(){return this.w};_.h.Ya=function(){this.a.info(OC);return null};_.h.Za=function(){this.a.info(OC);return null};_.h.Ca=function(){var a=this.fa();return a?a.track:null};_.h.ha=function(){var a=this.za();return a?a.track:null};_.h.ia=function(){var a=this.Ba();return a?a.track:null};
46
- _.h.Va=function(a){var b=this;null===a?(a=this.fa(),$D(this.f,a.bandwidth,null).then(function(){rD(b)})):0<a.renditions.length&&this.Ua(a.renditions[0])};_.h.ma=function(a){a?wD(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.h.ua=function(a){a?(a=a.renditions[0],this.h?oD(this.h,a.track):wD(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,aE(this.f,!1),this.l.trigger(new _.D(_.Hh)))};
47
- _.h.Ua=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,qD(this,a),$D(this.f,c.bandwidth,a.bandwidth).then(function(){rD(b)})["catch"](function(d){var e=new _.J(_.K,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...")};_.h.gb=function(a){wD(this,a)};_.h.hb=function(a){this.h?oD(this.h,a.track):wD(this,a)};
48
- _.h.addTextTrack=function(){};_.h.ja=function(){return this.f.o};pD.prototype.isAbrEnabled=pD.prototype.ja;pD.prototype.addTextTrack=pD.prototype.addTextTrack;pD.prototype.setTextRendition=pD.prototype.hb;pD.prototype.setAudioRendition=pD.prototype.gb;pD.prototype.setVideoRendition=pD.prototype.Ua;pD.prototype.setTextTrack=pD.prototype.ua;pD.prototype.setAudioTrack=pD.prototype.ma;pD.prototype.setVideoTrack=pD.prototype.Va;pD.prototype.getTextTrack=pD.prototype.ia;pD.prototype.getAudioTrack=pD.prototype.ha;
49
- pD.prototype.getVideoTrack=pD.prototype.Ca;pD.prototype.getLoadingTextRendition=pD.prototype.Za;pD.prototype.getLoadingAudioRendition=pD.prototype.Ya;pD.prototype.getLoadingVideoRendition=pD.prototype.Pa;pD.prototype.getTextRendition=pD.prototype.Ba;pD.prototype.getAudioRendition=pD.prototype.za;pD.prototype.getVideoRendition=pD.prototype.fa;pD.prototype.getTextTracks=pD.prototype.ea;pD.prototype.getAudioTracks=pD.prototype.getAudioTracks;pD.prototype.getVideoTracks=pD.prototype.getVideoTracks;_.u(ID,_.Mh);_.h=ID.prototype;_.h.Bh=function(){this.w=!0;this.g||this.trigger(new _.D(UD))};_.h.Ah=function(a){this.w=!0;this.trigger(new _.D(fE,{percent:a}))};_.h.zh=function(){this.w=!1;this.trigger(new _.D(gE))};_.h.Eh=function(){this.trigger(new _.D(hE))};_.h.Dh=function(a,b){this.trigger(new _.D(mE,{eventid:a,data:b}))};_.h.Fh=function(a,b,c,d,e){this.trigger(new _.D(nE,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
- _.h.Ch=function(a,b){this.trigger(new _.D(oE,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Fc&&"Challenge"===b.name)$C(c,b);else if("DrmError"===b.name){c.g.debug("DrmError event",b);var d=new _.J(_.K,6,6005,{message:JSON.stringify(b)});c.m.onError(d)}}};_.h.S=function(a){this.trigger(new _.D(pE,{eventType:a}))};
51
- _.h.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(KD,f,b);g=setTimeout(function(){b.off(KD,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===jE)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){MD(b);d(webapis.avplay.play())},function(f){b.trigger(new _.D(pE));e(f)})})).then(function(){return a()});if(c===eD||c===iE)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===dD?
52
- Promise.resolve():Promise.reject("Player is in invalid state")};_.h.pause=function(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===eD?Promise.resolve():Promise.reject()};
53
- _.h.setPlaybackRate=function(a){var b=this.getState();if(b===iE||b===dD||b===eD){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};_.h.getPlaybackRate=function(){return this.C};
54
- _.h.load=function(a,b){var c=this,d;return _.z(function(e){switch(e.a){case 1:return c.a.debug("configure()",b||""),_.pf(e,2),_.v(e,TD(c),4);case 4:return _.v(e,ZD(c,a,b),5);case 5:_.qf(e,0);break;case 2:throw d=_.rf(e),new _.J(_.K,7,7003,null,d);}})};_.h.getState=function(){if(this.g&&this.f)return this.f.$e;try{return webapis.avplay.getState()}catch(a){this.S(JSON.stringify(a))}};
55
- _.h.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.l.trigger(new _.D(_.Ce));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.D(_.Be));d()},function(){b.B=!1;e()})})};_.h.getPosition=function(){if(this.g&&this.f)return this.f.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.S(JSON.stringify(a))}};_.h.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
- _.h.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.Fd.stop()}a.j={};a.C=1;a.B=!1;a.m=null;a.f=null;return b()}catch(f){return c(f)}})};_.h.getVolume=function(){var a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case QC:this.a.debug("The application does not have the privilege to get the volume.",RC);break;default:this.a.debug(NC,b)}}return a};
57
- _.h.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 QC:this.a.warn("The application does not have the privilege to set the volume.",RC);break;default:this.a.warn("An unknown error occured while trying to set volume",b)}}};
42
+ _.h.destroy=function(){var a=this;return _.z(function(b){switch(b.a){case 1:if(!a.j){b.H(2);break}return _.v(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.g){b.H(4);break}return _.v(b,a.g.destroy(),5);case 5:a.g=null,a.w=!0;case 4:if(!a.h){b.H(0);break}return _.v(b,a.h.destroy(),7);case 7:a.h=null,_.w(b)}})};_.u($D,_.P);_.h=$D.prototype;_.h.Lf=function(a){var b=a.eventid;a=a.data;switch(b){case VE:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+kE(this,b[0].extra_info).Bit_rate,b=oE(this,{bandwidth:b}))&&(this.w=b,aE(this,b));break;case WE:bE(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.h.De=function(a){a.detail.currentState===_.Vl&&this.l.off(_.ie,this.De)};
43
+ _.h.Fb=function(a){var b=this;this.l=a;this.f=this.l.a;this.l.on(_.ie,function(c){b.A||(c=c.detail,c.currentState===_.Vl&&(b.a.debug("Current state",c.currentState),b.A=!0,cE(b)))});this.f.on(XE,this.Lf,this)};_.h.release=function(){this.g={};this.h=this.w=this.m=this.j=null;this.A=!1;this.o=1};
44
+ _.h.load=function(){if(this.f&&!(0<Object.keys(this.g).length)){this.h=this.l.g;this.l.off(_.ie,this.De);this.l.on(_.ie,this.De,this);try{var a=AE(this.f);this.g=nE(this,a);var b=this.g[_.N]||[];b.length&&(this.j=b[0].renditions[0]||null);bE(this)}catch(c){this.a.debug("Could not load track manager")}}};_.h.destroy=function(){this.f.off(XE,this.Lf);this.f=this.l=null};_.h.getVideoTracks=function(){return this.g[_.Bg]||[]};_.h.getAudioTracks=function(){return this.g[_.N]||[]};
45
+ _.h.ea=function(){return this.g[_.L]||[]};_.h.fa=function(){return rE(this,_.Bg)};_.h.Aa=function(){return rE(this,_.N)};_.h.Ca=function(){return rE(this,_.L)};_.h.Pa=function(){return this.w};_.h.Za=function(){this.a.info(yD);return null};_.h.$a=function(){this.a.info(yD);return null};_.h.Da=function(){var a=this.fa();return a?a.track:null};_.h.ia=function(){var a=this.Aa();return a?a.track:null};_.h.ja=function(){var a=this.Ca();return a?a.track:null};
46
+ _.h.Wa=function(a){var b=this;null===a?(a=this.fa(),KE(this.f,a.bandwidth,null).then(function(){bE(b)})):0<a.renditions.length&&this.Va(a.renditions[0])};_.h.na=function(a){a?gE(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.h.ua=function(a){a?(a=a.renditions[0],this.h?ZD(this.h,a.track):gE(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,LE(this.f,!1),this.l.trigger(new _.E(_.Kh)))};
47
+ _.h.Va=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,aE(this,a),KE(this.f,c.bandwidth,a.bandwidth).then(function(){bE(b)})["catch"](function(d){var e=new _.J(_.K,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...")};_.h.gb=function(a){gE(this,a)};_.h.hb=function(a){this.h?ZD(this.h,a.track):gE(this,a)};
48
+ _.h.addTextTrack=function(){};_.h.ka=function(){return this.f.o};$D.prototype.isAbrEnabled=$D.prototype.ka;$D.prototype.addTextTrack=$D.prototype.addTextTrack;$D.prototype.setTextRendition=$D.prototype.hb;$D.prototype.setAudioRendition=$D.prototype.gb;$D.prototype.setVideoRendition=$D.prototype.Va;$D.prototype.setTextTrack=$D.prototype.ua;$D.prototype.setAudioTrack=$D.prototype.na;$D.prototype.setVideoTrack=$D.prototype.Wa;$D.prototype.getTextTrack=$D.prototype.ja;$D.prototype.getAudioTrack=$D.prototype.ia;
49
+ $D.prototype.getVideoTrack=$D.prototype.Da;$D.prototype.getLoadingTextRendition=$D.prototype.$a;$D.prototype.getLoadingAudioRendition=$D.prototype.Za;$D.prototype.getLoadingVideoRendition=$D.prototype.Pa;$D.prototype.getTextRendition=$D.prototype.Ca;$D.prototype.getAudioRendition=$D.prototype.Aa;$D.prototype.getVideoRendition=$D.prototype.fa;$D.prototype.getTextTracks=$D.prototype.ea;$D.prototype.getAudioTracks=$D.prototype.getAudioTracks;$D.prototype.getVideoTracks=$D.prototype.getVideoTracks;_.u(sE,_.Ph);_.h=sE.prototype;_.h.Eh=function(){this.w=!0;this.g||this.trigger(new _.E(EE))};_.h.Dh=function(a){this.w=!0;this.trigger(new _.E(QE,{percent:a}))};_.h.Ch=function(){this.w=!1;this.trigger(new _.E(RE))};_.h.Hh=function(){this.trigger(new _.E(SE))};_.h.Gh=function(a,b){this.trigger(new _.E(XE,{eventid:a,data:b}))};_.h.Ih=function(a,b,c,d,e){this.trigger(new _.E(YE,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
+ _.h.Fh=function(a,b){this.trigger(new _.E(ZE,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Gc&&"Challenge"===b.name)KD(c,b);else if("DrmError"===b.name){c.g.debug("DrmError event",b);var d=new _.J(_.K,6,6005,{message:JSON.stringify(b)});c.m.onError(d)}}};_.h.S=function(a){this.trigger(new _.E($E,{eventType:a}))};
51
+ _.h.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(uE,f,b);g=setTimeout(function(){b.off(uE,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===UE)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){wE(b);d(webapis.avplay.play())},function(f){b.trigger(new _.E($E));e(f)})})).then(function(){return a()});if(c===PD||c===TE)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===OD?
52
+ Promise.resolve():Promise.reject("Player is in invalid state")};_.h.pause=function(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===PD?Promise.resolve():Promise.reject()};
53
+ _.h.setPlaybackRate=function(a){var b=this.getState();if(b===TE||b===OD||b===PD){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};_.h.getPlaybackRate=function(){return this.C};
54
+ _.h.load=function(a,b){var c=this,d;return _.z(function(e){switch(e.a){case 1:return c.a.debug("configure()",b||""),_.rf(e,2),_.v(e,DE(c),4);case 4:return _.v(e,JE(c,a,b),5);case 5:_.sf(e,0);break;case 2:throw d=_.tf(e),new _.J(_.K,7,7003,null,d);}})};_.h.getState=function(){if(this.g&&this.f)return this.f.bf;try{return webapis.avplay.getState()}catch(a){this.S(JSON.stringify(a))}};
55
+ _.h.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.l.trigger(new _.E(_.Ee));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.E(_.De));d()},function(){b.B=!1;e()})})};_.h.getPosition=function(){if(this.g&&this.f)return this.f.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.S(JSON.stringify(a))}};_.h.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
+ _.h.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.Hd.stop()}a.j={};a.C=1;a.B=!1;a.m=null;a.f=null;return b()}catch(f){return c(f)}})};_.h.getVolume=function(){var a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case AD:this.a.debug("The application does not have the privilege to get the volume.",BD);break;default:this.a.debug(xD,b)}}return a};
57
+ _.h.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 AD:this.a.warn("The application does not have the privilege to set the volume.",BD);break;default:this.a.warn("An unknown error occurred while trying to set volume",b)}}};
58
58
  _.h.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))}};_.h.stop=function(){try{webapis.avplay.stop()}catch(a){this.a.debug(a)}};_.h.getDrmInfo=function(){this.h&&this.h.getDrmInfo();return null};_.h.setSourceIndex=function(a){this.D=a};_.h.getSourceIndex=function(){return this.D};_.h.getLoadedSource=function(){return this.m&&this.m[this.getSourceIndex()]};
59
- var jE="IDLE",iE="READY",dD="PLAYING",eD="PAUSED",BD="VIDEO",uD="AUDIO",vD="TEXT",lE="PLAYER_MSG_RESOLUTION_CHANGED",kE="PLAYER_MSG_BITRATE_CHANGE",YC={PLAYREADY:"PLAYREADY",Jj:"EME_PLAYREADY",Sj:"VERIMATRIX",gd:"WIDEVINE_CDM",Kj:"EME_WIDEVINE_CDM",Tj:"WIDEVINE_CLASSIC"};_.u(bE,_.Mh);_.h=bE.prototype;_.h.hf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.D(_.Uc));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.h.ff=function(a){this.trigger(new _.D(_.ue,{currentTime:a.currentTime/1E3}))};
60
- _.h.jf=function(a){var b=this.a.getPosition(),c=b+a.duration/1E3,d=a.text||"";this.h.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.bh(d))&&this.o.append([new _.pg(b,c,d)],[])};_.h.gf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.h.Nf=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
- _.h.S=function(a){this.h.debug("Error: TYPE: "+a.eventType);cD(this.f,_.Jl);a=new _.J(_.K,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.D(_.Wc,{detail:a}))};
62
- _.h.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(hE,this.hf,this);this.a.on(KD,this.ff,this);this.a.on(nE,this.jf,this);this.a.on(oE,this.gf,this);this.a.on(pE,this.S,this);this.a.on(gE,this.Nf,this);var c=this.f;c.a.on(UD,c.mf,c);c.a.on(fE,c.lf,c);c.a.on(gE,c.kf,c);c.a.on(VD,c.Vf,c);c.a.on(XD,c.Uf,c);c.a.on(hE,c.nf,c);this.m.Fb(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();c=qE;qE+=1;this.j=_.gm(_.Ad,{id:"__clpp_tizen_player_"+c,type:"application/avplayer"});
63
- this.w.addElementToContainer(this.j,!0);var d=this.w.getMedia();if(d){c=this.j;var e=[_.Ve,_.Zc,"position",_.dd,"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=_.t(e);for(e=g.next();!e.done;e=g.next())e=e.value,f[e]=d[e];_.nm(c,f);cE(this)}};_.h.getSurface=function(){return this.w};_.h.getConfiguration=function(){return this.configuration};
64
- _.h.destroy=function(){var a=this;return _.z(function(b){switch(b.a){case 1:return _.v(b,a.release(),2);case 2:a.a.off(hE,a.hf);a.a.off(KD,a.ff);a.a.off(nE,a.jf);a.a.off(oE,a.gf);a.a.off(pE,a.S);a.a.off(gE,a.Nf);if(!a.g){b.G(3);break}return _.v(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,_.w(b)}})};_.h.namespace=function(){return rE};_.h.getPlaybackRate=function(){return this.a.getPlaybackRate()};
65
- _.h.setDrmCustomDataModifier=function(){};_.h.setCdnErrorCallback=function(){};_.h.setPlaybackRate=function(a){this.a.setPlaybackRate(a)};_.h.getPosition=function(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.Fl?this.getDuration():this.a.getPosition()||0};_.h.seek=function(a){return typeof a===_.zd&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()};_.h.getPresentationStartTime=function(){return 0};
66
- _.h.getSeekRange=function(){return{start:0,end:0}};_.h.getVolume=function(){var a=this.a.getVolume();return typeof a===_.zd?a/100:null};_.h.setVolume=function(a){this.a.setVolume(a)};_.h.getDuration=function(){return this.a.getDuration()};_.h.getBufferInfo=function(){this.h.warn(_.ma);return new _.Lh};_.h.getTrackManager=function(){return this.m};_.h.unload=function(){var a=this;return this.a.release().then(function(){a.m.release()})};
67
- _.h.release=function(){var a=this;return _.z(function(b){switch(b.a){case 1:if(!a.g){b.G(2);break}return _.v(b,a.g.release(),2);case 2:if(!a.o){b.G(4);break}return _.v(b,a.o.destroy(),5);case 5:a.o=null;case 4:return _.v(b,a.a.release(),6);case 6:a.m.release(),a.f.release(),a.A=!1,_.w(b)}})};
68
- _.h.load=function(a){var b=this,c,d,e,f,g;return _.z(function(k){switch(k.a){case 1:_.Wi(a)&&(b.configuration=_.Vi(b.B,a));c=_.ll(b.configuration,["html",_.xd]);b.o=c.create(b);d=_.Ql(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){k.G(2);break}b.g=new gD;b.g.l=b;_.pf(k,3);return _.v(k,b.g.load(d),5);case 5:b.g.start();_.qf(k,2);break;case 3:f=_.rf(k),b.h.error(f);case 2:return _.pf(k,6),_.v(k,b.a.load(b.configuration),8);case 8:_.qf(k,7);break;case 6:throw g=
69
- _.rf(k),b.onError(g),g;case 7:b.m.load(),_.w(k)}})};_.h.play=function(){var a=this;this.trigger(new _.D(_.Pd));cE(this);return this.a.play().then(function(){fD(a.f)})};_.h.pause=function(){var a=this;return this.a.pause().then(function(){fD(a.f)})};_.h.getState=function(){return this.f.getState()};_.h.getPeriods=function(){return[]};_.h.onError=function(a){var b=new _.D(_.Wc,{detail:a});a.severity===_.K&&(cD(this.f,_.Jl),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)};
70
- _.h.getDrmInfo=function(){return this.a.getDrmInfo()};_.h.isEnded=function(){return this.f.getState()===_.Fl};_.h.isPaused=function(){return this.a.getState()===eD};_.h.isMuted=function(){return PD(this.a)};_.h.setMuted=function(a){YD(this.a,a)};_.h.getNetworkEngine=function(){return this.C};_.h.setNetworkEngine=function(a){this.C=a};_.h.isLive=function(){return this.a.isLive()};_.h.getStats=function(){return null};_.h.setSourceIndex=function(a){this.a.setSourceIndex(a)};_.h.getSourceIndex=function(){return this.a.getSourceIndex()};
71
- _.h.getLoadedSource=function(){return this.a.getLoadedSource()};_.h.canPlay=function(a,b){return(new dE).canPlay(a,b)};_.h.getTimelineCues=function(){return[]};_.h.getTextDisplayer=function(){return this.o};_.h.resetAbr=function(){};bE.prototype.getTextDisplayer=bE.prototype.getTextDisplayer;bE.prototype.setNetworkEngine=bE.prototype.setNetworkEngine;bE.prototype.getNetworkEngine=bE.prototype.getNetworkEngine;var rE="clpp.tizen",qE=0;dE.prototype.a=function(){return rE};
72
- dE.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.Rb||a===_.Xb||a===_.Wb)&&b){if(_.ei(2))return 2;if(_.ei(3)||_.ei(4)||_.ei(5)||_.ei(6))return _.B("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};dE.prototype.create=function(){return new bE};_.u(eE,_.ln);eE.prototype.Da=function(){this.a=new dE;_.Of(this.a)};eE.prototype.va=function(){if(this.a){var a=this.a.a();a&&_.Mf[a]&&(delete _.Mf[a],_.Nf.info("Removed Player factory: '"+a+"'"));this.a=null}};eE.prototype.id=function(){return"tizen"};_.A("clpp.tizen.TizenComponent",eE);var UD="onbufferingstart",fE="onbufferingprogress",gE="onbufferingcomplete",hE="onstreamcompleted",KD="oncurrentplaytime",mE="onevent",nE="onsubtitlechange",oE="ondrmevent",pE="onerror",VD="preparingstart",XD="preparingend";};
59
+ var UE="IDLE",TE="READY",OD="PLAYING",PD="PAUSED",lE="VIDEO",eE="AUDIO",fE="TEXT",WE="PLAYER_MSG_RESOLUTION_CHANGED",VE="PLAYER_MSG_BITRATE_CHANGE",ID={PLAYREADY:"PLAYREADY",Sj:"EME_PLAYREADY",bk:"VERIMATRIX",hd:"WIDEVINE_CDM",Tj:"EME_WIDEVINE_CDM",ck:"WIDEVINE_CLASSIC"};_.u(ME,_.Ph);_.h=ME.prototype;_.h.kf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.E(_.Wc));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.h.hf=function(a){this.trigger(new _.E(_.we,{currentTime:a.currentTime/1E3}))};
60
+ _.h.lf=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=_.eh(d))&&this.o.append([new _.sg(b,c,d)],[])};_.h.jf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.h.Nf=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
+ _.h.S=function(a){this.h.debug("Error: TYPE: "+a.eventType);ND(this.f,_.Sl);a=new _.J(_.K,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.E(_.Xc,{detail:a}))};
62
+ _.h.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(SE,this.kf,this);this.a.on(uE,this.hf,this);this.a.on(YE,this.lf,this);this.a.on(ZE,this.jf,this);this.a.on($E,this.S,this);this.a.on(RE,this.Nf,this);var c=this.f;c.a.on(EE,c.pf,c);c.a.on(QE,c.nf,c);c.a.on(RE,c.mf,c);c.a.on(FE,c.Vf,c);c.a.on(HE,c.Uf,c);c.a.on(SE,c.qf,c);this.m.Fb(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();c=aF;aF+=1;this.j=_.um(_.Ad,{id:"__clpp_tizen_player_"+c,type:"application/avplayer"});
63
+ this.w.addElementToContainer(this.j,!0);var d=this.w.getMedia();if(d){c=this.j;var e=[_.Xe,_.$c,"position",_.ed,"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=_.t(e);for(e=g.next();!e.done;e=g.next())e=e.value,f[e]=d[e];_.wm(c,f);NE(this)}};_.h.getSurface=function(){return this.w};_.h.getConfiguration=function(){return this.configuration};
64
+ _.h.destroy=function(){var a=this;return _.z(function(b){switch(b.a){case 1:return _.v(b,a.release(),2);case 2:a.a.off(SE,a.kf);a.a.off(uE,a.hf);a.a.off(YE,a.lf);a.a.off(ZE,a.jf);a.a.off($E,a.S);a.a.off(RE,a.Nf);if(!a.g){b.H(3);break}return _.v(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,_.w(b)}})};_.h.namespace=function(){return bF};_.h.getPlaybackRate=function(){return this.a.getPlaybackRate()};
65
+ _.h.setDrmCustomDataModifier=function(){};_.h.setCdnErrorCallback=function(){};_.h.setPlaybackRate=function(a){this.a.setPlaybackRate(a)};_.h.getPosition=function(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.Ol?this.getDuration():this.a.getPosition()||0};_.h.seek=function(a){return typeof a===_.zd&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()};_.h.getPresentationStartTime=function(){return 0};
66
+ _.h.getSeekRange=function(){return{start:0,end:0}};_.h.getVolume=function(){var a=this.a.getVolume();return typeof a===_.zd?a/100:null};_.h.setVolume=function(a){this.a.setVolume(a)};_.h.getDuration=function(){return this.a.getDuration()};_.h.getBufferInfo=function(){this.h.warn(_.ma);return new _.Oh};_.h.getTrackManager=function(){return this.m};_.h.unload=function(){var a=this;return this.a.release().then(function(){a.m.release()})};
67
+ _.h.release=function(){var a=this;return _.z(function(b){switch(b.a){case 1:if(!a.g){b.H(2);break}return _.v(b,a.g.release(),2);case 2:if(!a.o){b.H(4);break}return _.v(b,a.o.destroy(),5);case 5:a.o=null;case 4:return _.v(b,a.a.release(),6);case 6:a.m.release(),a.f.release(),a.A=!1,_.w(b)}})};
68
+ _.h.load=function(a){var b=this,c,d,e,f,g;return _.z(function(k){switch(k.a){case 1:_.bj(a)&&(b.configuration=_.aj(b.B,a));c=_.ul(b.configuration,["html",_.xd]);b.o=c.create(b);d=_.Zl(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){k.H(2);break}b.g=new RD;b.g.l=b;_.rf(k,3);return _.v(k,b.g.load(d),5);case 5:b.g.start();_.sf(k,2);break;case 3:f=_.tf(k),b.h.error(f);case 2:return _.rf(k,6),_.v(k,b.a.load(b.configuration),8);case 8:_.sf(k,7);break;case 6:throw g=
69
+ _.tf(k),b.onError(g),g;case 7:b.m.load(),_.w(k)}})};_.h.play=function(){var a=this;this.trigger(new _.E(_.Pd));NE(this);return this.a.play().then(function(){QD(a.f)})};_.h.pause=function(){var a=this;return this.a.pause().then(function(){QD(a.f)})};_.h.getState=function(){return this.f.getState()};_.h.getPeriods=function(){return[]};_.h.onError=function(a){var b=new _.E(_.Xc,{detail:a});a.severity===_.K&&(ND(this.f,_.Sl),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)};
70
+ _.h.getDrmInfo=function(){return this.a.getDrmInfo()};_.h.isEnded=function(){return this.f.getState()===_.Ol};_.h.isPaused=function(){return this.a.getState()===PD};_.h.isMuted=function(){return zE(this.a)};_.h.setMuted=function(a){IE(this.a,a)};_.h.getNetworkEngine=function(){return this.C};_.h.setNetworkEngine=function(a){this.C=a};_.h.isLive=function(){return this.a.isLive()};_.h.getStats=function(){return null};_.h.setSourceIndex=function(a){this.a.setSourceIndex(a)};_.h.getSourceIndex=function(){return this.a.getSourceIndex()};
71
+ _.h.getLoadedSource=function(){return this.a.getLoadedSource()};_.h.canPlay=function(a,b){return(new OE).canPlay(a,b)};_.h.getTimelineCues=function(){return[]};_.h.getTextDisplayer=function(){return this.o};_.h.resetAbr=function(){};ME.prototype.getTextDisplayer=ME.prototype.getTextDisplayer;ME.prototype.setNetworkEngine=ME.prototype.setNetworkEngine;ME.prototype.getNetworkEngine=ME.prototype.getNetworkEngine;var bF="clpp.tizen",aF=0;OE.prototype.a=function(){return bF};
72
+ OE.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.Sb||a===_.Yb||a===_.Xb)&&b){if(_.hi(2))return 2;if(_.hi(3)||_.hi(4)||_.hi(5)||_.hi(6))return _.B("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};OE.prototype.create=function(){return new ME};_.u(PE,_.un);PE.prototype.Ea=function(){this.a=new OE;_.Qf(this.a)};PE.prototype.va=function(){if(this.a){var a=this.a.a();a&&_.Of[a]&&(delete _.Of[a],_.Pf.info("Removed Player factory: '"+a+"'"));this.a=null}};PE.prototype.id=function(){return"tizen"};_.A("clpp.tizen.TizenComponent",PE);var EE="onbufferingstart",QE="onbufferingprogress",RE="onbufferingcomplete",SE="onstreamcompleted",uE="oncurrentplaytime",XE="onevent",YE="onsubtitlechange",ZE="ondrmevent",$E="onerror",FE="preparingstart",HE="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,30 +1,30 @@
1
1
  (function(){var g={}; var _ = _ || {}
2
- var f=function(window){var yq='application/mp4; codecs\x3d"stpp.ttml"',zq='application/mp4; codecs\x3d"stpp.ttml.im1i"',Aq='application/mp4; codecs\x3d"stpp.ttml.im1t"',Bq="backgroundColor",Cq="direction",Dq="displayAlign",Eq="region",Fq="sans-serif",Gq="textAlign",Hq="textDecoration",Iq="writingMode",Jq=function(a,b,c){this.g=a;this.f=b;this.a=c},Kq=function(a,b,c){Jq.call(this,a,[],c);this.h=b||""},Lq=function(a,b,c){Jq.call(this,a,b,c)},Mq=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},Uq=function(a,b){var c=null;if(Nq.test(a)){c=Nq.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 Oq.test(a)?c=Pq(Oq,a):Qq.test(a)?c=Pq(Qq,a):Rq.test(a)?(c=Rq.exec(a),c=Number(c[1])/b.frameRate):Sq.test(a)?(c=Sq.exec(a),c=Number(c[1])/b.a):Tq.test(a)&&(c=Pq(Tq,a));return c},Pq=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)},Vq=function(a){return a.split(":").pop()},Wq=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},Yq=function(a,b){for(;Xq.test(a);){var c=Xq.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},Zq=function(a,b,c,d,e,f,g){Jq.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},$q=function(a,b,c){a=Mq(a,b,Gq);if(!a&&c&&(a=Mq(c,b,Gq),!a&&"rltb"===Mq(c,b,Iq)))return _.ae;switch(a){case _.qc:return _.kg;case _.ae:case _.Tc:return _.ae;default:return _.dd}},
5
- ar=function(a,b,c){if(_.Zg(a.o))return document.createTextNode(_.bh(a.o||""));if(a.w)return _.gm("br");for(var d=_.gm("span"),e=_.t(a.f),f=e.next();!f.done;f=e.next())_.mm(d,f.value);a=_.t(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(ar(c.get(e.value),b,c));return d},br=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]))},cr=function(a,
6
- b,c){Jq.call(this,a,b,c)},fr=function(a,b,c,d){var e=dr.exec(a);a=er.exec(a);return typeof b===_.zd&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},gr=function(a,b){return typeof b===_.zd&&0<b?_.qg:er.test(a)?0:_.qg},hr=function(a,b){Jq.call(this,"root-container",[],b);this.h=a},ir=function(a,b,c){return typeof a===_.zd?a:typeof b===_.zd?b:c},jr=function(a,b){var c=a.getAttribute("extent");return(c=er.exec(c))?Number(c[b]):null},lr=function(a){a=a.getAttribute("cellResolution");return(a=
7
- kr.exec(a))?Number(a[2]):null},mr=function(a,b,c){Jq.call(this,a,b,c)},nr=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=[]},pr=function(a){return or.some(function(b){return b in a.a})},qr=function(a,b){if(0===b.length)return[];for(var c=[],d=_.t(b),e=d.next();!e.done;e=d.next())e=e.value,a.a.has(e)&&c.push.apply(c,_.bf(qr(a,a.a.get(e).f)).concat([e]));return c},sr=function(){return"inline-"+rr++},tr=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})},ur=function(a){this.a=a.firstChild;this.f=new Set},vr=function(a,b,c,d,e,f){this.h=a;this.f=b;this.j=c;this.m=d;this.g=e;this.a=f},wr=function(a){return Vq(a.h.nodeName)},xr=function(){this.a=new Map},Gr=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null,e=[],f=[],g={},k=b.parentNode;if(k&&a.a.has(k)){var l=a.a.get(k);e=_.bf(l.m).concat();-1===["#text","span","br"].indexOf(b.nodeName)&&(c=l.f,d=l.j,f=_.bf(l.g).concat(),
9
- g={},yr.forEach(function(n){n in l.a&&(g[n]=l.a[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Eq)&&(c=b.getAttribute(Eq));b.hasAttribute(_.ne)&&f.push.apply(f,_.bf(b.getAttribute(_.ne).split(" ")));d=Array.from(b.attributes).map(function(n){return n.name});d=_.t(d);for(k=d.next();!k.done;k=d.next()){k=k.value;var m=Vq(k);g[m]=b.getAttribute(k)}d=g.backgroundImage}c=new vr(b,c,d,e,f,g);a.a.set(b,c);return c},Or=function(a){this.a=a;this.f=new DOMParser},Pr=function(a){this.f=a},Qr=function(a){return String(Math.floor(a/
10
- 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")},Rr=function(){},Sr=function(a){this.f=new Or(a);this.a=new _.C("clpp.ttml.Mp4TtmlParser")},Tr=function(){this.a=new Rr};Jq.prototype.aa=function(){return this.g};Jq.prototype.getAttribute=function(a){return this.a[a]};_.u(Kq,Jq);_.u(Lq,Jq);var Nq=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Oq=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Qq=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Rq=/^(\d*(?:\.\d*)?)f$/,Sq=/^(\d*(?:\.\d*)?)t$/,Tq=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,dr=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,er=/^(\d+)px (\d+)px$/,kr=/^(\d+) (\d+)$/,Xq=/(\d+)px/,Ur=/^(\d+px|\d+em|\d*\.?\d+c)$/,or=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
- "color",Bq,"opacity","padding","zIndex",Gq,Dq,Iq,Cq,Hq,"textOutline"],yr=["begin",_.Tc];_.u(Zq,Lq);
12
- Zq.prototype.build=function(a,b,c,d,e,f,g){var k=Uq(this.a.begin,b);b=Uq(this.a.end,b);if(null===k||null===b)return null;k+=c;b+=c;c=_.gm(_.Lc);for(var l=_.t(this.h),m=l.next();!m.done;m=l.next())c.appendChild(ar(g.get(m.value),e,g));g=new _.pg(k,b,c.innerHTML,_.we);g.cssClassList=_.bf(this.f).concat();g.textAlign=$q(this,e,null);g.writingMode=_.lg;g.line=-1;g.lineInterpretation=_.mg;g.lineAlign=_.ng;g.containerRows=ir(null,lr(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
- $q(this,e,f);a:switch(Mq(f,e,Iq)){case "tb":case "tblr":a=_.Ee;break a;case "tbrl":a=_.Fe;break a;default:a=_.lg}g.writingMode=a;a:switch(Mq(f,e,Dq)){case _.qc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Mq(f,e,Dq)){case _.qc:a=1;break a;default:a=_.mg}g.lineInterpretation=a;a:switch(Mq(f,e,Dq)){case _.qc:e=_.qc;break a;default:e=_.ng}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};_.u(cr,Lq);
15
- cr.prototype.build=function(a,b){var c=new _.sg;c.id=this.aa();var d=ir(a.h.containerWidth,jr(a,1),720),e=ir(a.h.containerHeight,jr(a,2),480);a:switch(Mq(this,b,Dq)){case "after":var f="flex-start";break a;case _.qc:f=_.qc;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Mq(this,b,Iq)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Bc}c.writingMode=f;f=this.getAttribute("extent")||Mq(this,b,"extent");c.width=fr(f,d,1,100);c.widthUnits=gr(f,d);c.height=
16
- fr(f,e,2,100);c.heightUnits=gr(f,e);f=this.getAttribute("origin")||Mq(this,b,"origin");c.viewportAnchorX=fr(f,d,1,0);c.viewportAnchorY=fr(f,e,2,0);c.viewportAnchorUnits=gr(f,d);c.cssClassList=_.bf(this.f).concat();return c};_.u(hr,Jq);_.u(mr,Jq);
17
- mr.prototype.build=function(a){var b=null;var c=lr(a);c&&(b=ir(a.h.containerHeight,jr(a,2),480)/c);b=ir(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.t(Vr.entries()),e=d.next();!e.done;e=d.next()){var f=_.t(e.value);e=f.next().value;f=f.next().value;e in this.a&&(c+=f+":"+Wq(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(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!Ur.test(g)&&Ur.test(k)&&Ur.test(l)?(e=g,f=k):2===d.length&&!Ur.test(g)&&Ur.test(k)?(e=g,f=k):2===d.length&&Ur.test(g)&&Ur.test(k)&&(f=g);if(""!==f){f=Wq(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",Fq).replace("proportionalSerif",Fq).replace("sansSerif",Fq).replace("default",Fq)+";":"");a:{if(Hq in this.a){d=[];e=_.t(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
- Wq(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=Wq(e),e=Yq(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=Wq(d);d=Yq(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 Vr=new Map([["color","color"],[Bq,"background-color"],[Cq,Cq],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var rr=0;ur.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Wr.has(Vq(a.nodeName))||Xr.has(Vq(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&&!Wr.has(Vq(a.nodeName))));var b=this.a;this.a=a;return b};var Wr=new Set(["tt","head","layout",_.od,_.ad,Eq,"styling",_.ne,"body",_.Lc,"p","span","br"]),Xr=new Set([_.ne,_.ad]);vr.prototype.aa=function(){return this.a.id};Or.prototype.parseInit=function(){};
22
- Or.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.H.xa(this.a.ttml||{}),e=_.Q(a,0,c[0]);e=_.Qg(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.te)}catch(n){throw new _.J(_.K,2,2005,"Failed to parse TTML.");}d=new nr(d);e=new xr;f=new ur(f);b=b.periodStart;typeof b===_.zd&&(d.w=b);b=c[0];for(var g=1;g<c.length;++g){var k=c[g],l=_.Q(a,b,k);l=_.dj(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Kq(m,l,{imageType:"PNG",encoding:"Base64"}));
23
- b+=k}for(;f.a;)a=f.next(),a=Gr(e,a),"tt"===wr(a)&&(d.j=new hr(d.A,Object.assign({},a.a))),"tt"===wr(a)&&(d.o=new br(a.a.frameRate,a.a.subFrameRate,a.a.frameRateMultiplier,a.a.tickRate)),wr(a)!==_.ad||a.a.begin||a.a.end||(c="#"+a.aa(),d.g.set(c,new Kq(c,a.h.textContent,a.a))),wr(a)===_.ad&&a.a.begin&&a.a.end?(c="#"+sr(),b=new Kq(c,a.h.textContent,a.a),d.g.set(c,b),c=b):c=null,c&&(a.j=c.aa()),wr(a)===_.ne&&(c=a.aa()||sr(),b=new mr(c,a.g,Object.assign({},a.a)),d.a.set(c,b),a.f&&d.h.get(a.f).f.push(c)),
24
- wr(a)!==_.ne&&pr(a)?(c=sr(),b=new mr(c,[],Object.assign({},a.a)),d.a.set(c,b),c=b):c=null,c&&a.g.push(c.aa()),wr(a)!==_.Lc||!a.a.extent&&!a.a.origin?c=null:(c=sr(),b=new cr(c,qr(d,a.g),Object.assign({},a.a)),d.h.set(c,b),c=b),c&&(a.f=c.aa()),wr(a)!==Eq?c=null:(c=a.aa(),b=new cr(c,qr(d,a.g),Object.assign({},a.a)),d.h.set(c,b),c=b),c&&(a.f=c.aa()),c=a.m,-1===["#text","span","br"].indexOf(wr(a))||0===c.length?c=null:(c=c[c.length-1],d.f.has(c)?(b=sr(),g=new Zq(b,"#text"===a.h.nodeName?a.h.textContent:
25
- null,"br"===wr(a),a.f,a.j,qr(d,a.g),a.a),d.f.set(b,g),d.f.get(c).h.push(b),c=g):c=null),c&&a.m.push(c.aa()),"p"===wr(a)||a.j?(c=sr(),b=new Zq(c,null,!1,a.f,a.j,qr(d,a.g),a.a),d.f.set(c,b),d.m.push(b),c=b):c=null,c&&a.m.push(c.aa());e=tr(d);f=[];a=_.t(d.a.values());for(c=a.next();!c.done;c=a.next())f.push.apply(f,_.bf(c.value.build(d.j)));return{cues:e,styles:f}};Pr.prototype.a=function(a){a=(new Or(this.f)).parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}).cues;var b="WEBVTT\n\n";a=_.t(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=Qr(c.startTime)+" --\x3e "+Qr(c.endTime),e=[];switch(c.textAlign){case _.dd:e.push("align:left");break;case _.ae:e.push("align:right");break;case _.kg:e.push("align:middle");break;case _.dd:e.push("align:start");break;case _.ae:e.push("align:end")}switch(c.writingMode){case _.Ee:e.push("vertical:lr");break;
26
- case _.Fe:e.push("vertical:rl")}b+=d+(e.length?" "+e.join(" "):"")+"\n";b+=c.payload+"\n\n"}return _.Ug(b)};Rr.prototype.probe=function(a,b){return a===_.Vb&&b===_.se};Rr.prototype.create=function(a){return new Pr(a)};Sr.prototype.parseInit=function(a){var b=!1;(new _.pk).L(_.rd,_.qk).L(_.ve,_.qk).L(_.md,_.qk).L(_.qd,_.qk).L(_.ke,_.qk).U(_.me,_.rk).L("stpp",function(c){b=!0;c.cb.stop()}).parse(a);if(!b)throw new _.J(_.K,2,2007);};
27
- Sr.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.pk).L("moof",_.qk).L("traf",_.qk).U("subs",function(k){for(var l=_.Dj(k.F),m=0;m<l;++m){k.F.skip(4);for(var n=_.Cj(k.F),p=0;p<n;++p){var q=1===k.version?_.Dj(k.F):_.Cj(k.F);g.push(q);k.F.skip(6)}}}).L(_.ld,_.sk(function(k){d=!0;k=c.f.parseMedia(k,b,g);e=e.concat(k.cues);f=f.concat(k.styles)})).parse(a);d||this.a.warn("Couldn't find the mdat box");return{cues:e,styles:f}};_.u(Tr,_.ln);Tr.prototype.Da=function(){_.Fo[_.Vb]=Or;_.Fo[_.Tb]=Sr;_.Fo[yq]=Sr;_.Fo[Aq]=Sr;_.Fo[zq]=Sr;_.oh.push(this.a)};Tr.prototype.va=function(){_.Go(_.Vb);_.Go(_.Tb);_.Go(yq);_.Go(Aq);_.Go(zq);_.qh(this.a)};Tr.prototype.id=function(){return _.pe};_.A("clpp.ttml.TtmlComponent",Tr);};
2
+ var f=function(window){var br='application/mp4; codecs\x3d"stpp.ttml"',cr='application/mp4; codecs\x3d"stpp.ttml.im1i"',dr='application/mp4; codecs\x3d"stpp.ttml.im1t"',er="backgroundColor",fr="direction",gr="displayAlign",hr="region",ir="sans-serif",jr="textAlign",kr="textDecoration",lr="writingMode",mr=function(a,b,c){this.g=a;this.f=b;this.a=c},nr=function(a,b,c){mr.call(this,a,[],c);this.h=b||""},or=function(a,b,c){mr.call(this,a,b,c)},pr=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},xr=function(a,b){var c=null;if(qr.test(a)){c=qr.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 rr.test(a)?c=sr(rr,a):tr.test(a)?c=sr(tr,a):ur.test(a)?(c=ur.exec(a),c=Number(c[1])/b.frameRate):vr.test(a)?(c=vr.exec(a),c=Number(c[1])/b.a):wr.test(a)&&(c=sr(wr,a));return c},sr=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)},yr=function(a){return a.split(":").pop()},zr=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},Br=function(a,b){for(;Ar.test(a);){var c=Ar.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},Cr=function(a,b,c,d,e,f,g){mr.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},Dr=function(a,b,c){a=pr(a,b,jr);if(!a&&c&&(a=pr(c,b,jr),!a&&"rltb"===pr(c,b,lr)))return _.ae;switch(a){case _.rc:return _.ng;case _.ae:case _.Vc:return _.ae;default:return _.ed}},
5
+ Er=function(a,b,c){if(_.bh(a.o))return document.createTextNode(_.eh(a.o||""));if(a.w)return _.um("br");for(var d=_.um("span"),e=_.t(a.f),f=e.next();!f.done;f=e.next())_.vm(d,f.value);a=_.t(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(Er(c.get(e.value),b,c));return d},Fr=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]))},Gr=function(a,
6
+ b,c){mr.call(this,a,b,c)},Xr=function(a,b,c,d){var e=Or.exec(a);a=Wr.exec(a);return typeof b===_.zd&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},Yr=function(a,b){return typeof b===_.zd&&0<b?_.tg:Wr.test(a)?0:_.tg},Zr=function(a,b){mr.call(this,"root-container",[],b);this.h=a},$r=function(a,b,c){return typeof a===_.zd?a:typeof b===_.zd?b:c},as=function(a,b){var c=a.getAttribute("extent");return(c=Wr.exec(c))?Number(c[b]):null},cs=function(a){a=a.getAttribute("cellResolution");return(a=
7
+ bs.exec(a))?Number(a[2]):null},ds=function(a,b,c){mr.call(this,a,b,c)},es=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=[]},gs=function(a){return fs.some(function(b){return b in a.a})},hs=function(a,b){if(0===b.length)return[];for(var c=[],d=_.t(b),e=d.next();!e.done;e=d.next())e=e.value,a.a.has(e)&&c.push.apply(c,_.df(hs(a,a.a.get(e).f)).concat([e]));return c},js=function(){return"inline-"+is++},ks=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})},ls=function(a){this.a=a.firstChild;this.f=new Set},ms=function(a,b,c,d,e,f){this.h=a;this.f=b;this.j=c;this.m=d;this.g=e;this.a=f},ns=function(a){return yr(a.h.nodeName)},os=function(){this.a=new Map},qs=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null,e=[],f=[],g={},k=b.parentNode;if(k&&a.a.has(k)){var l=a.a.get(k);e=_.df(l.m).concat();-1===["#text","span","br"].indexOf(b.nodeName)&&(c=l.f,d=l.j,f=_.df(l.g).concat(),
9
+ g={},ps.forEach(function(n){n in l.a&&(g[n]=l.a[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(hr)&&(c=b.getAttribute(hr));b.hasAttribute(_.oe)&&f.push.apply(f,_.df(b.getAttribute(_.oe).split(" ")));d=Array.from(b.attributes).map(function(n){return n.name});d=_.t(d);for(k=d.next();!k.done;k=d.next()){k=k.value;var m=yr(k);g[m]=b.getAttribute(k)}d=g.backgroundImage}c=new ms(b,c,d,e,f,g);a.a.set(b,c);return c},rs=function(a){this.a=a;this.f=new DOMParser},ss=function(a){this.f=a},ts=function(a){return String(Math.floor(a/
10
+ 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")},us=function(){},vs=function(a){this.f=new rs(a);this.a=new _.D("clpp.ttml.Mp4TtmlParser")},ws=function(){this.a=new us};mr.prototype.ba=function(){return this.g};mr.prototype.getAttribute=function(a){return this.a[a]};_.u(nr,mr);_.u(or,mr);var qr=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,rr=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,tr=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,ur=/^(\d*(?:\.\d*)?)f$/,vr=/^(\d*(?:\.\d*)?)t$/,wr=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Or=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Wr=/^(\d+)px (\d+)px$/,bs=/^(\d+) (\d+)$/,Ar=/(\d+)px/,xs=/^(\d+px|\d+em|\d*\.?\d+c)$/,fs=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
+ "color",er,"opacity","padding","zIndex",jr,gr,lr,fr,kr,"textOutline"],ps=["begin",_.Vc];_.u(Cr,or);
12
+ Cr.prototype.build=function(a,b,c,d,e,f,g){var k=xr(this.a.begin,b);b=xr(this.a.end,b);if(null===k||null===b)return null;k+=c;b+=c;c=_.um(_.Mc);for(var l=_.t(this.h),m=l.next();!m.done;m=l.next())c.appendChild(Er(g.get(m.value),e,g));g=new _.sg(k,b,c.innerHTML,_.ye);g.cssClassList=_.df(this.f).concat();g.textAlign=Dr(this,e,null);g.writingMode=_.og;g.line=-1;g.lineInterpretation=_.pg;g.lineAlign=_.qg;g.containerRows=$r(null,cs(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
+ Dr(this,e,f);a:switch(pr(f,e,lr)){case "tb":case "tblr":a=_.Ge;break a;case "tbrl":a=_.He;break a;default:a=_.og}g.writingMode=a;a:switch(pr(f,e,gr)){case _.rc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(pr(f,e,gr)){case _.rc:a=1;break a;default:a=_.pg}g.lineInterpretation=a;a:switch(pr(f,e,gr)){case _.rc:e=_.rc;break a;default:e=_.qg}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};_.u(Gr,or);
15
+ Gr.prototype.build=function(a,b){var c=new _.vg;c.id=this.ba();var d=$r(a.h.containerWidth,as(a,1),720),e=$r(a.h.containerHeight,as(a,2),480);a:switch(pr(this,b,gr)){case "after":var f="flex-start";break a;case _.rc:f=_.rc;break a;default:f="flex-end"}c.displayAlign=f;a:switch(pr(this,b,lr)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Cc}c.writingMode=f;f=this.getAttribute("extent")||pr(this,b,"extent");c.width=Xr(f,d,1,100);c.widthUnits=Yr(f,d);c.height=
16
+ Xr(f,e,2,100);c.heightUnits=Yr(f,e);f=this.getAttribute("origin")||pr(this,b,"origin");c.viewportAnchorX=Xr(f,d,1,0);c.viewportAnchorY=Xr(f,e,2,0);c.viewportAnchorUnits=Yr(f,d);c.cssClassList=_.df(this.f).concat();return c};_.u(Zr,mr);_.u(ds,mr);
17
+ ds.prototype.build=function(a){var b=null;var c=cs(a);c&&(b=$r(a.h.containerHeight,as(a,2),480)/c);b=$r(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.t(ys.entries()),e=d.next();!e.done;e=d.next()){var f=_.t(e.value);e=f.next().value;f=f.next().value;e in this.a&&(c+=f+":"+zr(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(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!xs.test(g)&&xs.test(k)&&xs.test(l)?(e=g,f=k):2===d.length&&!xs.test(g)&&xs.test(k)?(e=g,f=k):2===d.length&&xs.test(g)&&xs.test(k)&&(f=g);if(""!==f){f=zr(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",ir).replace("proportionalSerif",ir).replace("sansSerif",ir).replace("default",ir)+";":"");a:{if(kr in this.a){d=[];e=_.t(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
+ zr(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=zr(e),e=Br(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=zr(d);d=Br(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 ys=new Map([["color","color"],[er,"background-color"],[fr,fr],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var is=0;ls.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!zs.has(yr(a.nodeName))||As.has(yr(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&&!zs.has(yr(a.nodeName))));var b=this.a;this.a=a;return b};var zs=new Set(["tt","head","layout",_.pd,_.bd,hr,"styling",_.oe,"body",_.Mc,"p","span","br"]),As=new Set([_.oe,_.bd]);ms.prototype.ba=function(){return this.a.id};rs.prototype.parseInit=function(){};
22
+ rs.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.H.ya(this.a.ttml||{}),e=_.Q(a,0,c[0]);e=_.Tg(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.ve)}catch(n){throw new _.J(_.K,2,2005,"Failed to parse TTML.");}d=new es(d);e=new os;f=new ls(f);b=b.periodStart;typeof b===_.zd&&(d.w=b);b=c[0];for(var g=1;g<c.length;++g){var k=c[g],l=_.Q(a,b,k);l=_.jj(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new nr(m,l,{imageType:"PNG",encoding:"Base64"}));
23
+ b+=k}for(;f.a;)a=f.next(),a=qs(e,a),"tt"===ns(a)&&(d.j=new Zr(d.A,Object.assign({},a.a))),"tt"===ns(a)&&(d.o=new Fr(a.a.frameRate,a.a.subFrameRate,a.a.frameRateMultiplier,a.a.tickRate)),ns(a)!==_.bd||a.a.begin||a.a.end||(c="#"+a.ba(),d.g.set(c,new nr(c,a.h.textContent,a.a))),ns(a)===_.bd&&a.a.begin&&a.a.end?(c="#"+js(),b=new nr(c,a.h.textContent,a.a),d.g.set(c,b),c=b):c=null,c&&(a.j=c.ba()),ns(a)===_.oe&&(c=a.ba()||js(),b=new ds(c,a.g,Object.assign({},a.a)),d.a.set(c,b),a.f&&d.h.get(a.f).f.push(c)),
24
+ ns(a)!==_.oe&&gs(a)?(c=js(),b=new ds(c,[],Object.assign({},a.a)),d.a.set(c,b),c=b):c=null,c&&a.g.push(c.ba()),ns(a)!==_.Mc||!a.a.extent&&!a.a.origin?c=null:(c=js(),b=new Gr(c,hs(d,a.g),Object.assign({},a.a)),d.h.set(c,b),c=b),c&&(a.f=c.ba()),ns(a)!==hr?c=null:(c=a.ba(),b=new Gr(c,hs(d,a.g),Object.assign({},a.a)),d.h.set(c,b),c=b),c&&(a.f=c.ba()),c=a.m,-1===["#text","span","br"].indexOf(ns(a))||0===c.length?c=null:(c=c[c.length-1],d.f.has(c)?(b=js(),g=new Cr(b,"#text"===a.h.nodeName?a.h.textContent:
25
+ null,"br"===ns(a),a.f,a.j,hs(d,a.g),a.a),d.f.set(b,g),d.f.get(c).h.push(b),c=g):c=null),c&&a.m.push(c.ba()),"p"===ns(a)||a.j?(c=js(),b=new Cr(c,null,!1,a.f,a.j,hs(d,a.g),a.a),d.f.set(c,b),d.m.push(b),c=b):c=null,c&&a.m.push(c.ba());e=ks(d);f=[];a=_.t(d.a.values());for(c=a.next();!c.done;c=a.next())f.push.apply(f,_.df(c.value.build(d.j)));return{cues:e,styles:f}};ss.prototype.a=function(a){a=(new rs(this.f)).parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}).cues;var b="WEBVTT\n\n";a=_.t(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=ts(c.startTime)+" --\x3e "+ts(c.endTime),e=[];switch(c.textAlign){case _.ed:e.push("align:left");break;case _.ae:e.push("align:right");break;case _.ng:e.push("align:middle");break;case _.ed:e.push("align:start");break;case _.ae:e.push("align:end")}switch(c.writingMode){case _.Ge:e.push("vertical:lr");break;
26
+ case _.He:e.push("vertical:rl")}b+=d+(e.length?" "+e.join(" "):"")+"\n";b+=c.payload+"\n\n"}return _.Xg(b)};us.prototype.probe=function(a,b){return a===_.Wb&&b===_.ue};us.prototype.create=function(a){return new ss(a)};vs.prototype.parseInit=function(a){var b=!1;(new _.Oj).L(_.sd,_.Pj).L(_.xe,_.Pj).L(_.nd,_.Pj).L(_.rd,_.Pj).L(_.le,_.Pj).V(_.ne,_.Qj).L("stpp",function(c){b=!0;c.Ta.stop()}).parse(a);if(!b)throw new _.J(_.K,2,2007);};
27
+ vs.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Oj).L("moof",_.Pj).L("traf",_.Pj).V("subs",function(k){for(var l=_.Kj(k.F),m=0;m<l;++m){k.F.skip(4);for(var n=_.Jj(k.F),p=0;p<n;++p){var q=1===k.version?_.Kj(k.F):_.Jj(k.F);g.push(q);k.F.skip(6)}}}).L(_.md,_.Rj(function(k){d=!0;k=c.f.parseMedia(k,b,g);e=e.concat(k.cues);f=f.concat(k.styles)})).parse(a);d||this.a.warn("Couldn't find the mdat box");return{cues:e,styles:f}};_.u(ws,_.un);ws.prototype.Ea=function(){_.Oo[_.Wb]=rs;_.Oo[_.Ub]=vs;_.Oo[br]=vs;_.Oo[dr]=vs;_.Oo[cr]=vs;_.rh.push(this.a)};ws.prototype.va=function(){_.Po(_.Wb);_.Po(_.Ub);_.Po(br);_.Po(dr);_.Po(cr);_.th(this.a)};ws.prototype.id=function(){return _.re};_.A("clpp.ttml.TtmlComponent",ws);};
28
28
  if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
29
29
  else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
30
30
  else{_=this.clpp._;(f.call(g,this));}