@castlabs/prestoplay 6.2.8 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +6 -6
  5. package/cjs/cl.cast.js +110 -106
  6. package/cjs/cl.conviva.js +32 -31
  7. package/cjs/cl.core.js +371 -360
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +69 -69
  10. package/cjs/cl.externs.js +68 -17
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +44 -44
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +32 -30
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +250 -255
  17. package/cjs/cl.muxdata.js +12 -11
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -5
  21. package/cjs/cl.smooth.js +70 -70
  22. package/cjs/cl.thumbnails.js +22 -22
  23. package/cjs/cl.tizen.js +71 -71
  24. package/cjs/cl.ttml.js +26 -26
  25. package/cjs/cl.verimatrix.js +5 -5
  26. package/cjs/cl.vimond.js +13 -13
  27. package/cjs/cl.vr.js +18 -18
  28. package/cjs/cl.vtt.js +14 -14
  29. package/cjs/cl.youbora.js +19 -18
  30. package/cl.adobe.js +3 -3
  31. package/cl.airplay.js +3 -3
  32. package/cl.broadpeak.js +5 -5
  33. package/cl.cast.js +85 -81
  34. package/cl.conviva.js +27 -27
  35. package/cl.core.js +346 -337
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +62 -63
  38. package/cl.externs.js +68 -17
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +37 -37
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -24
  43. package/cl.ima.js +16 -16
  44. package/cl.mse.js +220 -224
  45. package/cl.muxdata.js +8 -9
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +9 -9
  48. package/cl.playlist.js +5 -4
  49. package/cl.smooth.js +57 -57
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +21 -21
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +14 -14
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +15 -15
  58. package/package.json +1 -1
@@ -1,27 +1,27 @@
1
1
  (function(){var g={}; var _ = _ || {}
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/
2
+ var f=function(window){var Qs="No thumbnail duration or URL specified",Rs="No thumbnail found for position ",Ss="Position is out of range: ",Ts="Thumbnail URL is mandatory",Us="Wrong gridSize format",Vs="clpp.thumbnails",Ws=function(){this.log=new _.G(Vs);this.g=null;this.a=[];this.w=!1},Ys=function(a,b){b.reduce(function(c,d){var e=d,f=!1;typeof d===_.Bd&&(e=d.step,f=d.preloadWhileBuffering);return c.then(function(){return Xs(a,0,e,!!f)})},Promise.resolve())},Xs=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();
3
+ var e=b+c;return Zs(a,d).then(function(){return a.a[b].load()}).then(function(){return Xs(a,e,c,d)})},Zs=function(a,b){return new Promise(function(c){if(b||a.g.getState()!==_.bm)c();else a.g.one(_.kc,function(){c()})})},$s=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},at=function(a,b){return b>=a.time&&b<a.time+a.duration},bt=function(){Ws.call(this);this.f=null;this.o=this.h=1;this.j=0},ct=function(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.a=new _.Qh},dt=function(){this.g=new _.G(Vs);this.f=new ArrayBuffer(0);this.a=[];this.h=new _.Qh},et=function(a){var b=a.f.byteLength;a.a.forEach(function(c){c.offset+c.length<b&&c.a.resolve()})},gt=function(a,b){return ft(a,b).then(function(c){return new $s(c,
5
+ b.time,b.duration)})},ft=function(a,b){return b.load().then(function(){var c=_.R(a.f,b.offset,b.length);return"data:image/jpeg;base64,"+_.jj(c)})},ht=function(){Ws.call(this);this.f=null},it=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},jt=function(){Ws.apply(this,arguments)},kt=function(a,b){for(var c=null,d=_.u(a),e=d.next();!e.done;e=d.next())e=e.value,e.startTime<=b&&(c=e);return c},lt=function(a,b){var c=a.horizontalTiles||
6
+ b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Vc:c,We:d,Cf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},mt=function(){this.f=new _.G(Vs);this.a=this.l=null},nt=function(a){return a.some(function(b){return 0<b.thumbStreams.length})},ot=function(a){if(!a)return null;a=new _.Wj(a);return a.path.match(/.*\.vtt$/i)?"WEBVTT":a.path.match(/.*\.bif$/i)?"BIF":a.path.match(/.*\.(png|jpg|jpeg)$/i)?"SINGLE":null},pt=function(){};Ws.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&&Ys(c,b.preload)})};$s.prototype.raw=function(){return this.a.cloneNode(!1)};
7
+ $s.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(_.Oc);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
- 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);};
9
+ $s.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(_.Zc,e);b(a)};e=function(){a.a.removeEventListener("load",f);a.a.removeEventListener(_.Zc,e);c()};a.a.addEventListener("load",
10
+ f);a.a.addEventListener(_.Zc,e);a.a.src=a.src}}));return this.f};_.B("clpp.thumbnails.Thumbnail",$s);$s.prototype.load=$s.prototype.load;$s.prototype.element=$s.prototype.element;$s.prototype.raw=$s.prototype.raw;_.v(bt,Ws);
11
+ bt.prototype.init=function(a,b){if(!b||!b.url)throw new _.K(_.M,7,7100,Ts);if("GRID"===b.mode&&!b.gridSize)throw new _.K(_.M,7,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.K(_.M,7,7100,"Duration is mandatory");this.f=b;var c=this.f.duration,d=this.f.url;if(!c||!d)throw this.log.error(Qs,c,d),new _.K(_.M,7,7100,Qs);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 _.K(_.M,7,7100,Us);}catch(f){throw this.log.error("Error during parsing gridSize",f),new _.K(_.M,7,7100,Us);}Ws.prototype.init.call(this,a,b)};bt.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(Ss+a);var d=this.a[c];return d?d.load().then(function(){return d}):Promise.reject(Rs+a+" at index "+c)};
13
+ bt.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 $s(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()};ct.prototype.load=function(){return this.a};
14
+ dt.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.K(_.M,7,7100,Ts);var d=_.ih(b.url);d.type=_.hh;a.getNetworkEngine().fetch(d).O.then(function(e){e=e.data;var f=_.R(c.f);e=_.R(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=_.R(e),g=
15
+ String.fromCharCode.apply(null,qt),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 ct(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(){et(c)})["catch"](function(e){c.g.error("Error while loading thumbnail index",e)})};dt.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ss+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 gt(b,d).then(function(e){return e.load().then(function(){return e})})}return Promise.reject(Rs+a)})};var qt=[137,66,73,70,13,10,26,10];_.v(ht,Ws);
17
+ ht.prototype.init=function(a,b){var c=this;if(!b||!b.url)throw new _.K(_.M,7,7100,Ts);var d=b.url,e=_.ih(d);e.type=_.hh;this.f=a.getNetworkEngine().fetch(e).O.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=it(l[0]);l=it(l[1])-r;c.a.push(new $s(k,r,l,m,p,q,n,0,0))}}}})["catch"](function(f){c.log.error("[VTT] Error while loading thumbnail",f)});Ws.prototype.init.call(this,a,b)};ht.prototype.get=function(a){var b=this;return 0>a?Promise.reject(Ss+a):this.f.then(function(){for(var c={},d=0;d<b.a.length;c={Kc:c.Kc},d++)if(c.Kc=b.a[d],at(c.Kc,a))return c.Kc.load().then(function(e){return function(){return e.Kc}}(c));return Promise.reject(Rs+a)})};ht.prototype.m=function(){return this.f};_.v(jt,Ws);
19
+ jt.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=kt(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=lt(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.Sa())&&0<c.length){var g=0,k=0;d=d.startTime;1<e.Cf&&(g=a%e.Vc,k=Math.floor(a/e.Vc),d+=a*e.durationPerTile);f=new $s(c[0],d,e.durationPerTile,void 0,void 0,void 0,void 0,e.Vc,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()};jt.prototype.f=function(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0};
22
+ jt.prototype.m=function(){if(0<this.a.length)return Promise.resolve();var a=this.g.getPeriods();a=_.u(a);for(var b=a.next();!b.done;b=a.next())if(b=b.value.thumbStreams.sort(this.f)[0])for(var c=b.findSegmentPosition(0),d=void 0;null!==c&&!_.J.R(d=b.getSegmentReference(c++));)for(var e=lt(d,b),f=d.Sa()[0],g=new Image,k=d.startTime,l=0;l<e.We;++l)for(var m=0;m<e.Vc;++m)this.a.push(new $s(f,k,e.durationPerTile,void 0,void 0,void 0,void 0,e.Vc,e.We,m,l,g)),k+=e.durationPerTile;return Promise.resolve()};_.t=mt.prototype;_.t.onPlayerCreated=function(a){this.l=a};_.t.onPlayerWillDestroy=function(){this.l=null};_.t.onPlayerWillRelease=function(){this.a=null};
23
+ _.t.onContentWillLoad=function(a){var b=this,c=a.getConfiguration();if(c.thumbnails){var d=c.thumbnails;d&&(void 0===d.enabled||d.enabled)&&((c=d.mode)||(c=ot(d.url||null)),c&&("SINGLE"===c||"GRID"===c?this.a=new bt:"WEBVTT"===c?this.a=new ht:"BIF"===c&&(this.a=new dt)),this.a&&(this.f.info("Loading thumbs configuration",d),this.l.one(_.md,function(){b.f.info("Initialize thumbnails provider");b.a.init(a,d)})))}else this.a=null};
24
+ _.t.onContentLoaded=function(a,b){for(var c=1;c<arguments.length;++c);if(!this.a&&(c=(c=a.getConfiguration())&&c.thumbnails,!c||void 0===c.enabled||c.enabled)){var d=a.getPeriods();nt(d)&&(this.a=new jt,this.a.init(a,c))}};_.t.get=function(a){return this.a?this.a.get(a):Promise.reject()};_.t.id=function(){return"thumbnails"};_.B("clpp.thumbnails.ThumbnailsPlugin",mt);mt.prototype.get=mt.prototype.get;mt.Id="thumbnails";pt.prototype.create=function(){return new mt};_.Fn(new pt);};
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 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
- _.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.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
- _.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 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";};
2
+ var f=function(window){var zD="An unknown error occurred while trying to get volume",AD="Cannot get loading rendition due to platform limitations",BD="PARAM_START_POSITION",CD="SecurityError",DD="The require privilege is: http://tizen.org/privilege/tv.audio",ED="|STARTBITRATE\x3d",FD=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},GD=function(a,b){this.h=a;this.w=null;this.a=_.Ad;this.o=null;this.j=!1;this.f=new Map;this.m=b;this.g=new _.G("clpp.tizen.DrmEngine")},JD=function(a){var b,
3
+ c,d;return _.A(function(e){if(1==e.a){b=a.a===_.Ic||a.a===_.Hc;if(!b)throw new _.K(_.M,6,6001,"The key system "+a.a+" is not supported by the player or the platform");c=a.f.get(a.a);if(!c.Yc)throw new _.K(_.M,6,6012,"No license server given for "+a.a);_.rf(e,2);return a.a===_.Ic?_.w(e,HD(a),5):_.w(e,ID(a,c),5)}if(2!=e.a)return a.w={keySystem:a.a,licenseServerUri:c.Yc,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Ge,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 _.K(_.M,6,6005,{message:JSON.stringify(d)});})},ID=function(a,b){var c,d,e,f;return _.A(function(g){c=KD;d=LD;e={};e[d.ng]=!b.Ge;e[d.og]=b.Yc;""!==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;}_.z(g)})},HD=function(a){var b;return _.A(function(c){b=KD;try{webapis.avplay.setDrm(b.jd,
5
+ "Initialize",""),webapis.avplay.setDrm(b.jd,"widevine_app_session",a.o.id),webapis.avplay.setDrm(b.jd,"widevine_data_type",a.o.type)}catch(d){throw d;}_.z(c)})},MD=function(a,b){var c,d,e,f,g,k,l,m,n,p,q,r,x,y,C,H,F;_.A(function(E){if(1==E.a){c=KD;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.Yc;l=_.ih([k],_.fh());l.type=3;l.body=f.buffer;l.method=
6
+ "POST";_.rf(E,2);return _.w(E,a.m.xb.fetch(l).O,4)}if(2!=E.a){m=E.f;if(a.j){n=_.R(m.data);p=n.byteLength;q="";for(r=0;r<p;r++)q+=String.fromCharCode(n[r]);x=btoa(q);y=b.session_id+BD+(x+BD);a.g.debug("Widevine license params",y);try{webapis.avplay.setDrm(c.jd,"widevine_license_data",y)}catch(L){a.g.error("License response rejected by CDM"),C=new _.K(_.M,6,6008,{browserError:JSON.stringify(L)}),a.m.onError(C)}}return _.sf(E,0)}H=_.tf(E);a.g.error("License request failed.",JSON.stringify(H));F=new _.K(_.M,
7
+ 6,6007,{message:_.Ba,url:H.data.url,status:H.data.status||NaN,response:H.data.response||"",headers:H.data.headers||{}},H);a.m.onError(F);_.z(E)})},ND=function(a){this.l=a;this.a=this.l.a;this.f=_.Xl;this.j=_.Yl;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.G("clpp.tizen.StateManager")},PD=function(a,b){if(a.f!==b)if(a.f===_.hm&&b!==_.Xl)a.g.debug(_.eu+OD(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.bm?(a.o=(new Date).getTime(),a.l.trigger(new _.I(_.lc,{detail:{bufferedTimeMS:-1,
8
+ reason:a.h}}))):a.j===_.bm&&a.l.trigger(new _.I(_.kc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));var d={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.l.trigger(new _.I(_.ie,{detail:d}));a.g.debug("State changed:",OD(a.j),"-\x3e",OD(a.f))}},OD=function(a){return Object.keys(_.fm)[a]},SD=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case QD:c=_.km;break;case RD:c=_.jm;break;default:a.l.isEnded()?c=_.dm:a.g.debug("Inconsistent AVPlay playback state:",b)}PD(a,
9
+ c)}},TD=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 _.G("clpp.tizen.TextStreamer")},UD=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},VD=function(a){var b,c;return _.A(function(d){if(1==d.a)return b=a.l.getConfiguration(),c=null,_.w(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)})},WD=function(a){var b=
10
+ document.createElement(_.Ie),c=new _.Bv,d=new _.Qu(function(){return null}),e=a.l.getTextDisplayer();return new _.Hv(b,c,e,d,a.l.getConfiguration())},XD=function(a){var b={sb:function(){return a.l.getPosition()},X:a.h,xb:a.l.getNetworkEngine(),ze:a.yh.bind(a),ye:a.xh.bind(a),onError:a.S.bind(a),Of:function(){},onEvent:function(){},Tf:a.zh.bind(a),Fd:function(){},ee:function(){return new _.Kw}};return new _.Ex(a.f,b)},YD=function(a){var b=a.l.getPosition(),c=null;a=_.u(a.f.periods);for(var d=a.next();!d.done;d=
11
+ a.next())d=d.value,d.startTime<=b&&(c=d);return c},ZD=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++),_.N);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.ru;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},$D=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){var b=_.Fx(a.g,_.te),c=null;if(b){a=ZD(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},aE=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=YD(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):(_.Nx(a.g,c,!0,0),a.l.trigger(new _.I(_.Kh))),a.o=c.language):a.a.error(_.du,d.id)}},bE=function(){this.h=this.f=this.l=null;this.g={};this.a=new _.G("clpp.tizen.TrackManager");this.w=this.m=this.j=null;this.A=!1;this.o=1},cE=function(a,b){a.l.trigger(new _.I(_.Me,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},dE=function(a){var b=a.fa();b&&a.l.trigger(new _.I(_.ic,{detail:{width:b.width,
14
+ height:b.height,bandwidth:b.bandwidth,rendition:b}}))},eE=function(a){var b=a.l.getConfiguration(),c=_.yh(b.preferredAudioLanguage||[]),d=a.g[_.P]||[];if(d.length){var e=null;c.some(function(g){e=_.Eu(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")},iE=function(a,b){if(b){var c=b.track.type.toUpperCase();fE(a.f,c,Number(b.id)).then(function(){c===gE&&(a.j=b,a.l.trigger(new _.I(_.Jh)));c===hE&&(a.m=b,a.l.trigger(new _.I(_.Kh)))})["catch"](function(){a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},jE=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=_.ec;a=new _.Gg(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},kE=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},lE=function(a,b,c){b=_.uh(b.track_lang||_.ze);c.mimeType="text/ttml";c.language=_.Ag(b);c.kind=_.ru;return new _.Gg(String(a),c)},mE=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},pE=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===nE}),f=b.filter(function(n){return n.type===gE}),g=[],k=0;k<f.length;k++){var l=mE(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++),_.P),g.push(m));m.renditions.push(jE(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=mE(a,e[k].extra_info))?f.renditions.push(kE(e[k].index,l,f)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?ZD(a.h):oE(a,b);d[_.Bg]=[f];d[_.P]=g;d[_.N]=e;return d},oE=function(a,b){for(var c=b.filter(function(k){return k.type===hE}),d=[],e=0;e<c.length;e++){var f=mE(a,c[e].extra_info);if(f){var g=new _.zg(String(a.o++),_.N);g.renditions.push(lE(c[e].index,f,g));
19
+ d.push(g)}else a.a.warn("Skipping text stream with no extra info")}return d},qE=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++)_.J.Ja(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},rE=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},tE=function(a,b){if(b===_.N&&a.h)return $D(a.h);
20
+ var c=sE(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=mE(a,c.extra_info),d=qE(a,{width:d.Width,height:d.Height}));b===_.P&&(c?(d=rE(a,c,_.P),a.j=d):d=a.j);b===_.N&&(c?(d=rE(a,c,_.N),a.m=d):d=a.m);return d},uE=function(a){_.Ph.call(this);this.l=a;this.h=null;this.a=new _.G("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={}},vE=function(a){return _.A(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;});_.z(b)})},xE=function(a){try{webapis.avplay.setListener({onbufferingstart:a.sh.bind(a),onbufferingprogress:a.rh.bind(a),onbufferingcomplete:a.qh.bind(a),onstreamcompleted:a.vh.bind(a),oncurrentplaytime:function(b){a.trigger(new _.I(wE,{currentTime:b}))},onevent:a.uh.bind(a),onsubtitlechange:a.wh.bind(a),ondrmevent:a.th.bind(a),onerror:a.S.bind(a)})}catch(b){a.a.error(b)}},
22
+ yE=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)}},zE=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,Qj:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",ED+d)}catch(e){a.a.debug(e)}},AE=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+ED+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",
23
+ c),c;}},DE=function(a){return{position:a.getPosition(),state:a.l.getState(),bf:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:BE(a),volume:a.getVolume(),tj:CE(a),Ih:sE(a)}},FE=function(a){var b,c;return _.A(function(d){if(1==d.a)return _.w(d,EE(),2);if(3!=d.a)return b=new Promise(function(e){(new _.qh(e)).$(5)}),_.w(d,Promise.race([vE(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"));_.z(d)})},LE=function(a,b,c){var d,e,f,g,k,l,m,n;return _.A(function(p){switch(p.a){case 1:a.m=_.tm(b);d=a.D;e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.a.debug("Loading manifest URL: "+a.m[d].url);f=b.startTime||void 0;a.g&&(a.trigger(new _.I(GE)),f=c.currentPosition);_.rf(p,2);g=a.m[d].url;k=a.m[d].type;k!==_.Tb||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);
25
+ e.nextBandwidth?(AE(a,e.nextBandwidth),a.o=!1):(a.o||zE(a,e),a.o=!0);xE(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)},xb:a.l.getNetworkEngine()};a.h=new GD(b.drm,m);return _.w(p,a.h.init(),4);case 4:return a.g||a.trigger(new _.I(HE)),_.w(p,IE(a),6);case 6:a.g||a.trigger(new _.I(JE));f&&typeof f===_.h&&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&&KE(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;}})},IE=function(a){return _.A(function(b){a.a.debug("avplay.prepare()");return b["return"](new Promise(function(c,d){try{webapis.avplay.prepareAsync(function(){a.a.debug("AVPlay is ready!");yE(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)}}))})},ME=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=DE(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===RD?a.pause():a.play()})}catch(e){return Promise.reject(e)}},CE=function(a){return a.g&&a.f?a.f.tj:webapis.avplay.getTotalTrackInfo()},
28
+ sE=function(a){return a.g&&a.f?a.f.Ih:webapis.avplay.getCurrentStreamInfo()},fE=function(a,b,c){b=b.toUpperCase();b===hE&&NE(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)})},NE=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)}},KE=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case CD:a.a.warn("The application does not have the privilege to set mute.",
30
+ DD);break;default:a.a.warn(zD,c)}}},BE=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case CD:a.a.warn("The application doesn't have the privilege to get the mute state.",DD);break;default:a.a.warn(zD,c)}}return!!b},EE=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");FD(c,"load",function(d){return a(d)});FD(c,_.Zc,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},
31
+ OE=function(){_.Ph.call(this);this.a=new uE(this);this.f=new ND(this);this.configuration=this.B=_.Xi();this.w=null;this.h=new _.G("clpp.tizen.Player");this.j=null;this.m=new bE;this.C=new _.mi;this.o=this.g=null;this.A=!1},PE=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())},QE=function(){},RE=function(){this.a=null};
33
+ GD.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.A(function(k){if(1==k.a){b=_.uj[a.h.env]||null;if(!b)throw a.g.debug(_.ta,_.ab+a.h.env+_.aa),new _.K(_.M,6,6015,_.ua+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[_.Hc])&&a.f.set(_.Hc,{Yc:e.licenseUrl||"",customData:c,Ge:!1});(f=d[_.Ic])&&a.f.set(_.Ic,{Yc:f.licenseUrl||"",customData:c,
34
+ Ge:!1});if(0===a.f.size)throw new _.K(_.M,6,6E3);if((g=a.h.preferredDrmSystem)&&a.f.get(g))a.a=g;else if(a.f.get(_.Hc))a.a=_.Hc;else if(a.f.get(_.Ic))a.a=_.Ic;else throw new _.K(_.M,6,6001,"Configuration for the target system is missing.");return _.w(k,JD(a),2)}a.j=!0;_.z(k)})};GD.prototype.release=function(){var a=this;return _.A(function(b){a.j=!1;a.w=null;a.a=_.Ad;a.o=null;a.f=new Map;_.z(b)})};GD.prototype.getDrmInfo=function(){return this.w};
35
+ var LD={ng:"DeleteLicenseAfterUse",og:"LicenseServer",Ej:"GetChallenge",Fj:"HttpHeader",Ij:"UserAgent",Aj:"Cookie",mg:"CustomData"};_.t=ND.prototype;_.t.initialize=function(){this.a.on(GE,this.pf,this);this.a.on(SE,this.nf,this);this.a.on(TE,this.mf,this);this.a.on(HE,this.Vf,this);this.a.on(JE,this.Uf,this);this.a.on(UE,this.qf,this)};_.t.release=function(){PD(this,_.Xl);this.m=!1;this.o=-1;this.h=2};_.t.destroy=function(){this.release();this.a.off(GE,this.pf);this.a.off(SE,this.nf);this.a.off(TE,this.mf);this.a.off(HE,this.Vf);this.a.off(JE,this.Uf);this.a.off(UE,this.qf);this.l=this.a=null};
36
+ _.t.pf=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;PD(this,_.bm)};_.t.nf=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",OD(this.f))};_.t.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()===VE;if(!a&&b){PD(this,_.jm);return}}if(a=this.f!==_.im)a=this.a.getState(),a=a===QD||a===RD;a&&SD(this)};
37
+ _.t.Vf=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===WE?PD(this,_.im):this.g.error("AVPlay prepares while state is not IDLE")};_.t.Uf=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.t.qf=function(){PD(this,_.dm)};_.t.getState=function(){return this.f};_.t=TD.prototype;_.t.initialize=function(a){this.l=a};
38
+ _.t.load=function(a){var b=this,c,d,e,f,g,k,l;return _.A(function(m){switch(m.a){case 1:if(!b.l)return b.a.debug("Text streamer is not initialized. Will not load()"),m["return"]();b.B=a;c=b;return _.w(m,VD(b),2);case 2:c.j=m.f;if(!b.j)return b.a.debug("Could not find manifest parser for source. Make sure parsers are registered."),m["return"]();d={networkingEngine:b.l.getNetworkEngine(),filterNewPeriod:function(){},filterAllPeriods:function(){},onTimelineCueAdded:function(){},onEvent:function(){},
39
+ onError:function(){}};_.rf(m,3);e=b;return _.w(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,_.w(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||!UD(b.f)){m.H(0);break}b.h=WD(b);_.rf(m,10);return _.w(m,b.h.G,12);case 12:b.g=XD(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),
40
+ b.a.debug("Could not setup media source..."),b.h=null,b.g=null,b.j=null,b.f=null,_.z(m)}})};_.t.yh=function(a){this.a.debug(_.nu,a);this.w=!0;var b=_.lw(a.textStreams,this.o||"",this.A||"")[0]||null;this.m&&(a.textStreams.includes(this.m)&&(b=this.m),this.m=null);return{variant:null,text:b}};_.t.xh=function(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.Nx(this.g,this.m,!0,0),this.m=null)};_.t.S=function(){this.a.debug("onError_")};_.t.zh=function(){this.j&&this.j.update&&this.j.update()};
41
+ _.t.start=function(){var a=this;return _.A(function(b){if(!a.g)return b["return"]();try{a.g.start()}catch(c){a.a.error("Error while starting streaming engine",c)}_.z(b)})};_.t.setTextVisibility=function(a){this.a.debug("Set text visibility",a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)};_.t.release=function(){var a=this;return _.A(function(b){a.l=null;a.f=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.m=null;_.z(b)})};
42
+ _.t.destroy=function(){var a=this;return _.A(function(b){switch(b.a){case 1:if(!a.j){b.H(2);break}return _.w(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.g){b.H(4);break}return _.w(b,a.g.destroy(),5);case 5:a.g=null,a.w=!0;case 4:if(!a.h){b.H(0);break}return _.w(b,a.h.destroy(),7);case 7:a.h=null,_.z(b)}})};_.v(bE,_.Q);_.t=bE.prototype;_.t.Lf=function(a){var b=a.eventid;a=a.data;switch(b){case XE:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+mE(this,b[0].extra_info).Bit_rate,b=qE(this,{bandwidth:b}))&&(this.w=b,cE(this,b));break;case YE:dE(this);break;default:this.a.debug("Event type: "+b+" data: "+a)}};_.t.Ce=function(a){a.detail.currentState===_.km&&this.l.off(_.ie,this.Ce)};
43
+ _.t.initialize=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===_.km&&(b.a.debug("Current state",c.currentState),b.A=!0,eE(b)))});this.f.on(ZE,this.Lf,this)};_.t.release=function(){this.g={};this.h=this.w=this.m=this.j=null;this.A=!1;this.o=1};
44
+ _.t.load=function(){if(this.f&&!(0<Object.keys(this.g).length)){this.h=this.l.g;this.l.off(_.ie,this.Ce);this.l.on(_.ie,this.Ce,this);try{var a=CE(this.f);this.g=pE(this,a);var b=this.g[_.P]||[];b.length&&(this.j=b[0].renditions[0]||null);dE(this)}catch(c){this.a.debug("Could not load track manager")}}};_.t.destroy=function(){this.f.off(ZE,this.Lf);this.f=this.l=null};_.t.getVideoTracks=function(){return this.g[_.Bg]||[]};_.t.getAudioTracks=function(){return this.g[_.P]||[]};
45
+ _.t.ea=function(){return this.g[_.N]||[]};_.t.fa=function(){return tE(this,_.Bg)};_.t.za=function(){return tE(this,_.P)};_.t.Ba=function(){return tE(this,_.N)};_.t.Qa=function(){return this.w};_.t.$a=function(){this.a.info(AD);return null};_.t.ab=function(){this.a.info(AD);return null};_.t.Ca=function(){var a=this.fa();return a?a.track:null};_.t.ia=function(){var a=this.za();return a?a.track:null};_.t.ja=function(){var a=this.Ba();return a?a.track:null};
46
+ _.t.Xa=function(a){var b=this;null===a?(a=this.fa(),ME(this.f,a.bandwidth,null).then(function(){dE(b)})):0<a.renditions.length&&this.Wa(a.renditions[0])};_.t.na=function(a){a?iE(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.t.ua=function(a){a?(a=a.renditions[0],this.h?aE(this.h,a.track):iE(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,NE(this.f,!1),this.l.trigger(new _.I(_.Kh)))};
47
+ _.t.Wa=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,cE(this,a),ME(this.f,c.bandwidth,a.bandwidth).then(function(){dE(b)})["catch"](function(d){var e=new _.K(_.M,7,7200,{tizenerror:d});b.a.debug("Error while switching video track",d);b.l.onError(e)})):this.a.debug("Trying to switch to already active rendition. Doing nothing...")};_.t.ib=function(a){iE(this,a)};_.t.jb=function(a){this.h?aE(this.h,a.track):iE(this,a)};
48
+ _.t.addTextTrack=function(){};_.t.ka=function(){return this.f.o};bE.prototype.isAbrEnabled=bE.prototype.ka;bE.prototype.addTextTrack=bE.prototype.addTextTrack;bE.prototype.setTextRendition=bE.prototype.jb;bE.prototype.setAudioRendition=bE.prototype.ib;bE.prototype.setVideoRendition=bE.prototype.Wa;bE.prototype.setTextTrack=bE.prototype.ua;bE.prototype.setAudioTrack=bE.prototype.na;bE.prototype.setVideoTrack=bE.prototype.Xa;bE.prototype.getTextTrack=bE.prototype.ja;bE.prototype.getAudioTrack=bE.prototype.ia;
49
+ bE.prototype.getVideoTrack=bE.prototype.Ca;bE.prototype.getLoadingTextRendition=bE.prototype.ab;bE.prototype.getLoadingAudioRendition=bE.prototype.$a;bE.prototype.getLoadingVideoRendition=bE.prototype.Qa;bE.prototype.getTextRendition=bE.prototype.Ba;bE.prototype.getAudioRendition=bE.prototype.za;bE.prototype.getVideoRendition=bE.prototype.fa;bE.prototype.getTextTracks=bE.prototype.ea;bE.prototype.getAudioTracks=bE.prototype.getAudioTracks;bE.prototype.getVideoTracks=bE.prototype.getVideoTracks;_.v(uE,_.Ph);_.t=uE.prototype;_.t.sh=function(){this.w=!0;this.g||this.trigger(new _.I(GE))};_.t.rh=function(a){this.w=!0;this.trigger(new _.I(SE,{percent:a}))};_.t.qh=function(){this.w=!1;this.trigger(new _.I(TE))};_.t.vh=function(){this.trigger(new _.I(UE))};_.t.uh=function(a,b){this.trigger(new _.I(ZE,{eventid:a,data:b}))};_.t.wh=function(a,b,c,d,e){this.trigger(new _.I($E,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
50
+ _.t.th=function(a,b){this.trigger(new _.I(aF,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Ic&&"Challenge"===b.name)MD(c,b);else if("DrmError"===b.name){c.g.debug("DrmError event",b);var d=new _.K(_.M,6,6005,{message:JSON.stringify(b)});c.m.onError(d)}}};_.t.S=function(a){this.trigger(new _.I(bF,{eventType:a}))};
51
+ _.t.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(wE,f,b);g=setTimeout(function(){b.off(wE,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===WE)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){yE(b);d(webapis.avplay.play())},function(f){b.trigger(new _.I(bF));e(f)})})).then(function(){return a()});if(c===RD||c===VE)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===QD?
52
+ Promise.resolve():Promise.reject("Player is in invalid state")};_.t.pause=function(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===RD?Promise.resolve():Promise.reject()};
53
+ _.t.setPlaybackRate=function(a){var b=this.getState();if(b===VE||b===QD||b===RD){try{webapis.avplay.setSpeed(a),this.C=a}catch(c){return this.a.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.a.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1};_.t.getPlaybackRate=function(){return this.C};
54
+ _.t.load=function(a,b){var c=this,d;return _.A(function(e){switch(e.a){case 1:return c.a.debug("configure()",b||""),_.rf(e,2),_.w(e,FE(c),4);case 4:return _.w(e,LE(c,a,b),5);case 5:_.sf(e,0);break;case 2:throw d=_.tf(e),new _.K(_.M,7,7003,null,d);}})};_.t.getState=function(){if(this.g&&this.f)return this.f.bf;try{return webapis.avplay.getState()}catch(a){this.S(JSON.stringify(a))}};
55
+ _.t.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.l.trigger(new _.I(_.Ee));webapis.avplay.seekTo(c,function(){b.B=!1;b.l.trigger(new _.I(_.De));d()},function(){b.B=!1;e()})})};_.t.getPosition=function(){if(this.g&&this.f)return this.f.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.S(JSON.stringify(a))}};_.t.getDuration=function(){if(this.g&&this.f)return this.f.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.S(JSON.stringify(a))}};
56
+ _.t.release=function(){var a=this;return new Promise(function(b,c){try{a.h&&(a.h.release(),a.h=null);webapis.avplay.stop();webapis.avplay.close();for(var d in a.j){var e=a.j[d];e&&e.Hd.stop()}a.j={};a.C=1;a.B=!1;a.m=null;a.f=null;return b()}catch(f){return c(f)}})};_.t.getVolume=function(){var a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case CD:this.a.debug("The application does not have the privilege to get the volume.",DD);break;default:this.a.debug(zD,b)}}return a};
57
+ _.t.setVolume=function(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.a.warn("Invalid value passed for setVolume.","The passed value value should be in the range of 0 to 1.");break;case CD:this.a.warn("The application does not have the privilege to set the volume.",DD);break;default:this.a.warn("An unknown error occurred while trying to set volume",b)}}};
58
+ _.t.isLive=function(){if(this.g&&this.f)return this.f.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.S(JSON.stringify(a))}};_.t.stop=function(){try{webapis.avplay.stop()}catch(a){this.a.debug(a)}};_.t.getDrmInfo=function(){this.h&&this.h.getDrmInfo();return null};_.t.setSourceIndex=function(a){this.D=a};_.t.getSourceIndex=function(){return this.D};_.t.getLoadedSource=function(){return this.m&&this.m[this.getSourceIndex()]};
59
+ var WE="IDLE",VE="READY",QD="PLAYING",RD="PAUSED",nE="VIDEO",gE="AUDIO",hE="TEXT",YE="PLAYER_MSG_RESOLUTION_CHANGED",XE="PLAYER_MSG_BITRATE_CHANGE",KD={PLAYREADY:"PLAYREADY",Bj:"EME_PLAYREADY",Jj:"VERIMATRIX",jd:"WIDEVINE_CDM",Cj:"EME_WIDEVINE_CDM",Kj:"WIDEVINE_CLASSIC"};_.v(OE,_.Ph);_.t=OE.prototype;_.t.kf=function(){var a=this;this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.I(_.Yc));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.h.debug("Could not loop playback")}):this.a.stop()};_.t.hf=function(a){this.trigger(new _.I(_.we,{currentTime:a.currentTime/1E3}))};
60
+ _.t.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)],[])};_.t.jf=function(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.t.Nf=function(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)};
61
+ _.t.S=function(a){this.h.debug("Error: TYPE: "+a.eventType);PD(this.f,_.hm);a=new _.K(_.M,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.I(_.Zc,{detail:a}))};
62
+ _.t.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(UE,this.kf,this);this.a.on(wE,this.hf,this);this.a.on($E,this.lf,this);this.a.on(aF,this.jf,this);this.a.on(bF,this.S,this);this.a.on(TE,this.Nf,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();var c=cF;cF+=1;this.j=_.Km(_.Bd,{id:"__clpp_tizen_player_"+c,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var d=this.w.getMedia();if(d){c=this.j;
63
+ var e=[_.Xe,_.bd,"position",_.gd,"top"],f={};d=null!==d.parentElement?window.getComputedStyle(d,null):d.style;if(!e||0===e.length){e||(e=[]);for(var g in d)e.push(g)}g=_.u(e);for(e=g.next();!e.done;e=g.next())e=e.value,f[e]=d[e];_.Mm(c,f);PE(this)}};_.t.getSurface=function(){return this.w};_.t.getConfiguration=function(){return this.configuration};
64
+ _.t.destroy=function(){var a=this;return _.A(function(b){switch(b.a){case 1:return _.w(b,a.release(),2);case 2:a.a.off(UE,a.kf);a.a.off(wE,a.hf);a.a.off($E,a.lf);a.a.off(aF,a.jf);a.a.off(bF,a.S);a.a.off(TE,a.Nf);if(!a.g){b.H(3);break}return _.w(b,a.g.destroy(),4);case 4:a.g=null;case 3:a.j&&(a.j.parentElement.removeChild(a.j),a.j=null),a.m.destroy(),a.f.destroy(),a.m=null,a.f=null,_.z(b)}})};_.t.namespace=function(){return dF};_.t.getPlaybackRate=function(){return this.a.getPlaybackRate()};
65
+ _.t.setDrmCustomDataModifier=function(){};_.t.setCdnErrorCallback=function(){};_.t.setPlaybackRate=function(a){this.a.setPlaybackRate(a)};_.t.getPosition=function(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.dm?this.getDuration():this.a.getPosition()||0};_.t.seek=function(a){return typeof a===_.h&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()};_.t.getPresentationStartTime=function(){return null};
66
+ _.t.getSeekRange=function(){return{start:0,end:0}};_.t.getVolume=function(){var a=this.a.getVolume();return typeof a===_.h?a/100:null};_.t.setVolume=function(a){this.a.setVolume(a)};_.t.getDuration=function(){return this.a.getDuration()};_.t.getBufferInfo=function(){this.h.warn(_.na);return new _.Oh};_.t.getTrackManager=function(){return this.m};_.t.unload=function(){var a=this;return this.a.release().then(function(){a.m.release()})};
67
+ _.t.release=function(){var a=this;return _.A(function(b){switch(b.a){case 1:if(!a.g){b.H(2);break}return _.w(b,a.g.release(),2);case 2:if(!a.o){b.H(4);break}return _.w(b,a.o.destroy(),5);case 5:a.o=null;case 4:return _.w(b,a.a.release(),6);case 6:a.m.release(),a.f.release(),a.A=!1,_.z(b)}})};
68
+ _.t.load=function(a){var b=this,c,d,e,f,g;return _.A(function(k){switch(k.a){case 1:_.$i(a)&&(b.configuration=_.Zi(b.B,a));c=_.Kl(b.configuration,["html",_.zd]);b.o=c.create(b);d=_.tm(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){k.H(2);break}b.g=new TD;b.g.initialize(b);_.rf(k,3);return _.w(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),_.w(k,b.a.load(b.configuration),8);case 8:_.sf(k,7);break;
69
+ case 6:throw g=_.tf(k),b.onError(g),g;case 7:b.m.load(),_.z(k)}})};_.t.play=function(){var a=this;this.trigger(new _.I(_.Pd));PE(this);return this.a.play().then(function(){SD(a.f)})};_.t.pause=function(){var a=this;return this.a.pause().then(function(){SD(a.f)})};_.t.getState=function(){return this.f.getState()};_.t.getPeriods=function(){return[]};_.t.onError=function(a){var b=new _.I(_.Zc,{detail:a});a.severity===_.M&&(PD(this.f,_.hm),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)};
70
+ _.t.getDrmInfo=function(){return this.a.getDrmInfo()};_.t.isEnded=function(){return this.f.getState()===_.dm};_.t.isPaused=function(){return this.a.getState()===RD};_.t.isMuted=function(){return BE(this.a)};_.t.setMuted=function(a){KE(this.a,a)};_.t.getNetworkEngine=function(){return this.C};_.t.setNetworkEngine=function(a){this.C=a};_.t.isLive=function(){return this.a.isLive()};_.t.getStats=function(){return null};_.t.setSourceIndex=function(a){this.a.setSourceIndex(a)};_.t.getSourceIndex=function(){return this.a.getSourceIndex()};
71
+ _.t.getLoadedSource=function(){return this.a.getLoadedSource()};_.t.canPlay=function(a,b){return(new QE).canPlay(a,b)};_.t.getTimelineCues=function(){return[]};_.t.getTextDisplayer=function(){return this.o};_.t.resetAbr=function(){};OE.prototype.getTextDisplayer=OE.prototype.getTextDisplayer;OE.prototype.setNetworkEngine=OE.prototype.setNetworkEngine;OE.prototype.getNetworkEngine=OE.prototype.getNetworkEngine;var dF="clpp.tizen",cF=0;QE.prototype.a=function(){return dF};
72
+ QE.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.Tb||a===_.Zb||a===_.Yb)&&b){if(_.hi(2))return 2;if(_.hi(3)||_.hi(4)||_.hi(5)||_.hi(6))return _.D("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};QE.prototype.create=function(){return new OE};_.v(RE,_.Kn);RE.prototype.Da=function(){this.a=new QE;_.Qf(this.a)};RE.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}};RE.prototype.id=function(){return"tizen"};_.B("clpp.tizen.TizenComponent",RE);var GE="onbufferingstart",SE="onbufferingprogress",TE="onbufferingcomplete",UE="onstreamcompleted",wE="oncurrentplaytime",ZE="onevent",$E="onsubtitlechange",aF="ondrmevent",bF="onerror",HE="preparingstart",JE="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 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);};
2
+ var f=function(window){var qr='application/mp4; codecs\x3d"stpp.ttml"',rr='application/mp4; codecs\x3d"stpp.ttml.im1i"',sr='application/mp4; codecs\x3d"stpp.ttml.im1t"',tr="backgroundColor",ur="direction",vr="displayAlign",wr="region",xr="sans-serif",yr="textAlign",zr="textDecoration",Ar="writingMode",Br=function(a,b,c){this.g=a;this.f=b;this.a=c},Cr=function(a,b,c){Br.call(this,a,[],c);this.h=b||""},Dr=function(a,b,c){Br.call(this,a,b,c)},Er=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},$r=function(a,b){var c=null;if(Fr.test(a)){c=Fr.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 Gr.test(a)?c=Hr(Gr,a):Ir.test(a)?c=Hr(Ir,a):Qr.test(a)?(c=Qr.exec(a),c=Number(c[1])/b.frameRate):Yr.test(a)?(c=Yr.exec(a),c=Number(c[1])/b.a):Zr.test(a)&&(c=Hr(Zr,a));return c},Hr=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)},as=function(a){return a.split(":").pop()},bs=function(a){return a.replace(/(\d*\.?\d+)c/g,"$1em")},ds=function(a,b){for(;cs.test(a);){var c=cs.exec(a)[0];a=a.replace(c,parseInt(c,10)/b+"em")}return a},es=function(a,b,c,d,e,f,g){Br.call(this,a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]},fs=function(a,b,c){a=Er(a,b,yr);if(!a&&c&&(a=Er(c,b,yr),!a&&"rltb"===Er(c,b,Ar)))return _.ae;switch(a){case _.sc:return _.ng;case _.ae:case _.Xc:return _.ae;default:return _.gd}},
5
+ gs=function(a,b,c){if(_.bh(a.o))return document.createTextNode(_.eh(a.o||""));if(a.w)return _.Km("br");for(var d=_.Km("span"),e=_.u(a.f),f=e.next();!f.done;f=e.next())_.Lm(d,f.value);a=_.u(a.h);for(e=a.next();!e.done;e=a.next())d.appendChild(gs(c.get(e.value),b,c));return d},hs=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]))},is=function(a,
6
+ b,c){Br.call(this,a,b,c)},ls=function(a,b,c,d){var e=js.exec(a);a=ks.exec(a);return typeof b===_.h&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},ms=function(a,b){return typeof b===_.h&&0<b?_.tg:ks.test(a)?0:_.tg},ns=function(a,b){Br.call(this,"root-container",[],b);this.h=a},os=function(a,b,c){return typeof a===_.h?a:typeof b===_.h?b:c},ps=function(a,b){var c=a.getAttribute("extent");return(c=ks.exec(c))?Number(c[b]):null},rs=function(a){a=a.getAttribute("cellResolution");return(a=qs.exec(a))?
7
+ Number(a[2]):null},ss=function(a,b,c){Br.call(this,a,b,c)},ts=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=[]},vs=function(a){return us.some(function(b){return b in a.a})},ws=function(a,b){if(0===b.length)return[];for(var c=[],d=_.u(b),e=d.next();!e.done;e=d.next())e=e.value,a.a.has(e)&&c.push.apply(c,_.df(ws(a,a.a.get(e).f)).concat([e]));return c},ys=function(){return"inline-"+xs++},zs=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})},As=function(a){this.a=a.firstChild;this.f=new Set},Bs=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},Cs=function(a){return as(a.h.nodeName)},Ds=function(){this.a=new Map},Fs=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(),g=
9
+ {},Es.forEach(function(n){n in l.a&&(g[n]=l.a[n])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(wr)&&(c=b.getAttribute(wr));b.hasAttribute(_.oe)&&f.push.apply(f,_.df(b.getAttribute(_.oe).split(" ")));d=Array.from(b.attributes).map(function(n){return n.name});d=_.u(d);for(k=d.next();!k.done;k=d.next()){k=k.value;var m=as(k);g[m]=b.getAttribute(k)}d=g.backgroundImage}c=new Bs(b,c,d,e,f,g);a.a.set(b,c);return c},Gs=function(a){this.a=a;this.f=new DOMParser},Hs=function(a){this.f=a},Is=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")},Js=function(){},Ks=function(a){this.f=new Gs(a);this.a=new _.G("clpp.ttml.Mp4TtmlParser")},Ls=function(){this.a=new Js};Br.prototype.ba=function(){return this.g};Br.prototype.getAttribute=function(a){return this.a[a]};_.v(Cr,Br);_.v(Dr,Br);var Fr=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Gr=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Ir=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Qr=/^(\d*(?:\.\d*)?)f$/,Yr=/^(\d*(?:\.\d*)?)t$/,Zr=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,js=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,ks=/^(\d+)px (\d+)px$/,qs=/^(\d+) (\d+)$/,cs=/(\d+)px/,Ms=/^(\d+px|\d+em|\d*\.?\d+c)$/,us=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
11
+ "color",tr,"opacity","padding","zIndex",yr,vr,Ar,ur,zr,"textOutline"],Es=["begin",_.Xc];_.v(es,Dr);
12
+ es.prototype.build=function(a,b,c,d,e,f,g){var k=$r(this.a.begin,b);b=$r(this.a.end,b);if(null===k||null===b)return null;k+=c;b+=c;c=_.Km(_.Oc);for(var l=_.u(this.h),m=l.next();!m.done;m=l.next())c.appendChild(gs(g.get(m.value),e,g));g=new _.sg(k,b,c.innerHTML,_.ye);g.cssClassList=_.df(this.f).concat();g.textAlign=fs(this,e,null);g.writingMode=_.og;g.line=-1;g.lineInterpretation=_.pg;g.lineAlign=_.qg;g.containerRows=os(null,rs(a),15);if(this.m&&(f=f.get(this.m))){g.region=f.build(a,e);g.textAlign=
13
+ fs(this,e,f);a:switch(Er(f,e,Ar)){case "tb":case "tblr":a=_.Ge;break a;case "tbrl":a=_.He;break a;default:a=_.og}g.writingMode=a;a:switch(Er(f,e,vr)){case _.sc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Er(f,e,vr)){case _.sc:a=1;break a;default:a=_.pg}g.lineInterpretation=a;a:switch(Er(f,e,vr)){case _.sc:e=_.sc;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};_.v(is,Dr);
15
+ is.prototype.build=function(a,b){var c=new _.vg;c.id=this.ba();var d=os(a.h.containerWidth,ps(a,1),720),e=os(a.h.containerHeight,ps(a,2),480);a:switch(Er(this,b,vr)){case "after":var f="flex-start";break a;case _.sc:f=_.sc;break a;default:f="flex-end"}c.displayAlign=f;a:switch(Er(this,b,Ar)){case "tb":case "tblr":f="row-reverse";break a;case "tbrl":f="row";break a;default:f=_.Ec}c.writingMode=f;f=this.getAttribute("extent")||Er(this,b,"extent");c.width=ls(f,d,1,100);c.widthUnits=ms(f,d);c.height=
16
+ ls(f,e,2,100);c.heightUnits=ms(f,e);f=this.getAttribute("origin")||Er(this,b,"origin");c.viewportAnchorX=ls(f,d,1,0);c.viewportAnchorY=ls(f,e,2,0);c.viewportAnchorUnits=ms(f,d);c.cssClassList=_.df(this.f).concat();return c};_.v(ns,Br);_.v(ss,Br);
17
+ ss.prototype.build=function(a){var b=null;var c=rs(a);c&&(b=os(a.h.containerHeight,ps(a,2),480)/c);b=os(a.h.fontSizeRadix,b,16);a=[];c="::ttml ."+this.g+", ::ttml ."+this.g+" * {";for(var d=_.u(Ns.entries()),e=d.next();!e.done;e=d.next()){var f=_.u(e.value);e=f.next().value;f=f.next().value;e in this.a&&(c+=f+":"+bs(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&&!Ms.test(g)&&Ms.test(k)&&Ms.test(l)?(e=g,f=k):2===d.length&&!Ms.test(g)&&Ms.test(k)?(e=g,f=k):2===d.length&&Ms.test(g)&&Ms.test(k)&&(f=g);if(""!==f){f=bs(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",xr).replace("proportionalSerif",xr).replace("sansSerif",xr).replace("default",xr)+";":"");a:{if(zr in this.a){d=[];e=_.u(this.a.textDecoration.split(" "));for(f=e.next();!f.done;f=e.next())switch(f=f.value,f){case "underline":case "overline":d.push(f);break;case "lineThrough":d.push("line-through")}if(0<d.length){d="text-decoration:"+d.join(" ")+";";break a}}d=""}e="padding"in this.a?"border: solid transparent;border-width:"+
20
+ bs(this.a.padding)+";":"";c=c+d+e;"lineHeight"in this.a?(d="",e=this.a.lineHeight,e=bs(e),e=ds(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=bs(d);d=ds(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 Ns=new Map([["color","color"],[tr,"background-color"],[ur,ur],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var xs=0;As.prototype.next=function(){if(!this.a)return null;var a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Os.has(as(a.nodeName))||Ps.has(as(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&&!Os.has(as(a.nodeName))));var b=this.a;this.a=a;return b};var Os=new Set(["tt","head","layout",_.rd,_.dd,wr,"styling",_.oe,"body",_.Oc,"p","span","br"]),Ps=new Set([_.oe,_.dd]);Bs.prototype.ba=function(){return this.a.id};Gs.prototype.parseInit=function(){};
22
+ Gs.prototype.parseMedia=function(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.J.Ha(this.a.ttml||{}),e=_.R(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 _.K(_.M,2,2005,"Failed to parse TTML.");}d=new ts(d);e=new Ds;f=new As(f);b=b.periodStart;typeof b===_.h&&(d.w=b);b=c[0];for(var g=1;g<c.length;++g){var k=c[g],l=_.R(a,b,k);l=_.jj(l);var m="urn:mpeg:14496-30:subs:"+g;d.g.set(m,new Cr(m,l,{imageType:"PNG",encoding:"Base64"}));
23
+ b+=k}for(;f.a;)a=f.next(),a=Fs(e,a),"tt"===Cs(a)&&(d.j=new ns(d.A,Object.assign({},a.a))),"tt"===Cs(a)&&(d.o=new hs(a.a.frameRate,a.a.subFrameRate,a.a.frameRateMultiplier,a.a.tickRate)),Cs(a)!==_.dd||a.a.begin||a.a.end||(c="#"+a.ba(),d.g.set(c,new Cr(c,a.h.textContent,a.a))),Cs(a)===_.dd&&a.a.begin&&a.a.end?(c="#"+ys(),b=new Cr(c,a.h.textContent,a.a),d.g.set(c,b),c=b):c=null,c&&(a.j=c.ba()),Cs(a)===_.oe&&(c=a.ba()||ys(),b=new ss(c,a.g,Object.assign({},a.a)),d.a.set(c,b),a.f&&d.h.get(a.f).f.push(c)),
24
+ Cs(a)!==_.oe&&vs(a)?(c=ys(),b=new ss(c,[],Object.assign({},a.a)),d.a.set(c,b),c=b):c=null,c&&a.g.push(c.ba()),Cs(a)!==_.Oc||!a.a.extent&&!a.a.origin?c=null:(c=ys(),b=new is(c,ws(d,a.g),Object.assign({},a.a)),d.h.set(c,b),c=b),c&&(a.f=c.ba()),Cs(a)!==wr?c=null:(c=a.ba(),b=new is(c,ws(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(Cs(a))||0===c.length?c=null:(c=c[c.length-1],d.f.has(c)?(b=ys(),g=new es(b,"#text"===a.h.nodeName?a.h.textContent:
25
+ null,"br"===Cs(a),a.f,a.j,ws(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"===Cs(a)||a.j?(c=ys(),b=new es(c,null,!1,a.f,a.j,ws(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=zs(d);f=[];a=_.u(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}};Hs.prototype.a=function(a){a=(new Gs(this.f)).parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}).cues;var b="WEBVTT\n\n";a=_.u(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=Is(c.startTime)+" --\x3e "+Is(c.endTime),e=[];switch(c.textAlign){case _.gd:e.push("align:left");break;case _.ae:e.push("align:right");break;case _.ng:e.push("align:middle");break;case _.gd: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)};Js.prototype.probe=function(a,b){return a===_.Xb&&b===_.ue};Js.prototype.create=function(a){return new Hs(a)};Ks.prototype.parseInit=function(a){var b=!1;(new _.Pj).M(_.vd,_.Qj).M(_.xe,_.Qj).M(_.pd,_.Qj).M(_.td,_.Qj).M(_.le,_.Qj).V(_.ne,_.Rj).M("stpp",function(c){b=!0;c.Ua.stop()}).parse(a);if(!b)throw new _.K(_.M,2,2007);};
27
+ Ks.prototype.parseMedia=function(a,b){var c=this,d=!1,e=[],f=[],g=[];(new _.Pj).M("moof",_.Qj).M("traf",_.Qj).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)}}}).M(_.od,_.Sj(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}};_.v(Ls,_.Kn);Ls.prototype.Da=function(){_.ep[_.Xb]=Gs;_.ep[_.Vb]=Ks;_.ep[qr]=Ks;_.ep[sr]=Ks;_.ep[rr]=Ks;_.rh.push(this.a)};Ls.prototype.va=function(){_.fp(_.Xb);_.fp(_.Vb);_.fp(qr);_.fp(sr);_.fp(rr);_.th(this.a)};Ls.prototype.id=function(){return _.re};_.B("clpp.ttml.TtmlComponent",Ls);};
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));}