(function(){var g={}; var _ = _ || {}
var f=function(window){var IN="An unknown error occurred while trying to get volume",JN="Cannot get loading rendition due to platform limitations",KN="PARAM_START_POSITION",LN="SecurityError",MN="The require privilege is: http://tizen.org/privilege/tv.audio",NN="|STARTBITRATE\x3d",ON=function(a,b,c){function d(e){c.call(a,e);a.removeEventListener(b,d)}a.addEventListener(b,d)},PN=function(a,b){this.h=a;this.o=null;this.a=_.Qe;this.l=null;this.j=!1;this.f=new Map;this.F=b;this.g=new _.J("clpp.tizen.DrmEngine")},SN=function(a){var b,
c,d;return _.H(function(e){if(1==e.a){b=a.a===_.Gd||a.a===_.Ed;if(!b)throw new _.N(_.O,6,6001,"The key system "+a.a+" is not supported by the player or the platform");c=a.f.get(a.a);if(!c.ue)throw new _.N(_.O,6,6012,"No license server given for "+a.a);_.C(e,2);return a.a===_.Gd?_.x(e,QN(a),5):_.x(e,RN(a,c),5)}if(2!=e.a)return a.o={keySystem:a.a,licenseServerUri:c.ue,distinctiveIdentifierRequired:!1,persistentStateRequired:c.Cg,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],
keyIds:[],periodId:null},_.uh(e,0);d=_.E(e);a.g.error("Error while configuring CDM for "+a.a,d);throw new _.N(_.O,6,6005,{message:JSON.stringify(d)});})},RN=function(a,b){var c,d,e,f;return _.H(function(g){c=TN;d=UN;e={};e[d.uj]=!b.Cg;e[d.yj]=b.ue;""!==b.customData&&(e[d.tj]=b.customData);f=JSON.stringify(e);a.g.debug("PlayReady properties: ",f);try{webapis.avplay.setDrm(c.PLAYREADY,"SetProperties",f)}catch(h){throw h;}_.y(g)})},QN=function(a){var b;return _.H(function(c){b=TN;try{webapis.avplay.setDrm(b.Pe,
"Initialize",""),webapis.avplay.setDrm(b.Pe,"widevine_app_session",a.l.id),webapis.avplay.setDrm(b.Pe,"widevine_data_type",a.l.type)}catch(d){throw d;}_.y(c)})},VN=function(a,b){var c,d,e,f,g,h,l,m,n,p,q,t,v,z,A,D,G;_.H(function(B){if(1==B.a){c=TN;d=a.f.get(a.a);a.g.debug("DRM Challenge data: ",b.challenge);e=atob(b.challenge);f=new Uint8Array(e.length);for(g=0;g<e.length;++g)f[g]=e.charCodeAt(g);h=b.serverurl&&""!==b.serverurl?b.serverurl:d.ue;l=_.ck([h],_.Yj());l.type=3;l.body=f.buffer;l.method=
_.sb;_.C(B,2);return _.x(B,a.F.Db.fetch(l).S,4)}if(2!=B.a){m=B.f;if(a.j){n=_.Oj(m.data);p=n.byteLength;q="";for(t=0;t<p;t++)q+=String.fromCharCode(n[t]);v=btoa(q);z=b.session_id+KN+(v+KN);a.g.debug("Widevine license params",z);try{webapis.avplay.setDrm(c.Pe,"widevine_license_data",z)}catch(F){a.g.error("License response rejected by CDM"),A=new _.N(_.O,6,6008,{browserError:JSON.stringify(F)}),a.F.onError(A)}}return _.uh(B,0)}D=_.E(B);a.g.error("License request failed.",JSON.stringify(D));G=new _.N(_.O,
6,6007,{message:"Error while fetching license!",url:D.data.url,status:D.data.status||NaN,response:D.data.response||"",headers:D.data.headers||{}},D);a.F.onError(G);_.y(B)})},WN=function(a){this.m=a;this.a=this.m.a;this.f=_.tq;this.j=_.uq;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.J("clpp.tizen.StateManager")},YN=function(a,b){if(a.f!==b)if(a.f===_.Eq&&b!==_.tq)a.g.debug(_.UC+XN(b));else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.yq?(a.o=(new Date).getTime(),a.m.trigger(new _.K(_.ad,
{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.yq&&a.m.trigger(new _.K(_.$c,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));var d={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.K(_.bg,{detail:d}));a.g.debug("State changed:",XN(a.j),"-\x3e",XN(a.f))}},XN=function(a){return Object.keys(_.Cq)[a]},aO=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case ZN:c=_.Hq;break;case $N:c=_.Gq;break;default:a.m.isEnded()?c=_.Aq:a.g.debug("Inconsistent AVPlay playback state:",
b)}YN(a,c)}},bO=function(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.J("clpp.tizen.TextStreamer")},cO=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},dO=function(a){var b,c;return _.H(function(d){if(1==d.a)return b=a.m.getConfiguration(),c=null,_.x(d,_.av(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null),2);(c=d.f)&&c.configure(b.manifest);return d["return"](c)})},
eO=function(a){var b=document.createElement(_.Jg),c=new _.AG,d=new _.cE,e=a.m.getTextDisplayer();return new _.CG(b,c,e,d,a.m.getConfiguration())},fO=function(a){var b={configuration:{},Pb:function(){return a.m.getPosition()},X:a.h,Db:a.m.getNetworkEngine(),od:null,ug:a.gl.bind(a),tg:a.fl.bind(a),onError:a.hl.bind(a),Ii:function(){},onEvent:function(){},Ni:a.il.bind(a),uf:function(){},fe:function(){return new _.pH},Wf:function(){return!1},$d:null};return new _.WH(a.a,b)},gO=function(a){var b=a.m.getPosition(),
c=null;a=_.u(a.a.periods);for(var d=a.next();!d.done;d=a.next())d=d.value,d.startTime<=b&&(c=d);return c},hO=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];for(d=c=0;d<a.length;d++){var e=new _.Dk(String(c++),_.S);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=
a[d].kind||_.rD;var f=new _.Lk(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},iO=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){var b=_.ZH(a.f,_.pj),c=null;if(b){a=hO(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},jO=function(a,b){a.g.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.ke,a.a&&a.f)){a.setTextVisibility(!0);
var c=gO(a),d=b.renditions[0];(c=c.textStreams.find(function(e){return String(e.id)===d.id}))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=c):(_.kI(a.f,c,!0,0),a.m.trigger(new _.K(_.mg))),a.o=c.language):a.g.error("No stream with id",d.id)}},kO=function(){this.j=this.a=this.m=null;this.f={};this.g=new _.J("clpp.tizen.TrackManager");this.w=this.o=this.l=null;this.A=!1;this.h=1},lO=function(a,b){a.m.trigger(new _.K(_.Ng,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,
abrSelection:a.a.o}}))},mO=function(a){var b=a.ma();b&&a.m.trigger(new _.K(_.Yc,{detail:{width:b.width,height:b.height,bandwidth:b.bandwidth,rendition:b}}))},nO=function(a){var b=a.m.getConfiguration(),c=_.Gi(b.preferredAudioLanguage||[]),d=a.f[_.T]||[];if(d.length){var e=null;c.some(function(g){e=_.OD(g,d.map(function(h){return h.language}));return!!e});if(e){var f=d.filter(function(g){return g.language===e});c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(function(g){return 0<=g.roles.indexOf(b.preferredAudioRole)}),
0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",e);a.Ia(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},rO=function(a,b){if(b){var c=b.track.type.toUpperCase();oO(a.a,c,Number(b.id)).then(function(){c===pO&&(a.l=b,a.m.trigger(new _.K(_.Wc)));c===qO&&(a.o=b,a.m.trigger(new _.K(_.mg)))})["catch"](function(){a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},sO=
function(a,b,c){var d=_.Cj(b.language||_.wg);c.language=_.Ek(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Tc;a=new _.Lk(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;return a},tO=function(a,b,c){c.mimeType=_.Lg;a=new _.Lk(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},uO=function(a,b,c){b=_.Cj(b.track_lang||_.wg);c.mimeType="text/ttml";
c.language=_.Ek(b);c.originalLanguage=b;c.kind=_.rD;return new _.Lk(String(a),c)},vO=function(a,b){var c=null;try{c=JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},yO=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===wO}),f=b.filter(function(n){return n.type===pO}),g=[],h=0;h<f.length;h++){var l=vO(a,f[h].extra_info);if(l){var m=
_.Cj(l.language||_.wg);m=_.Ek(m);m=c(g,m);m||(m=new _.Dk(String(a.h++),_.T),g.push(m));m.renditions.push(sO(f[h].index,l,m))}else a.g.warn("Skipping audio stream with no extra info")}f=new _.Dk(String(a.h++),_.Fk);for(h=0;h<e.length;h++)(l=vO(a,e[h].extra_info))?f.renditions.push(tO(e[h].index,l,f)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.j?hO(a.j):xO(a,b);d[_.Fk]=[f];d[_.T]=g;d[_.S]=e;return d},xO=function(a,b){for(var c=b.filter(function(h){return h.type===qO}),d=[],e=0;e<
c.length;e++){var f=vO(a,c[e].extra_info);if(f){var g=new _.Dk(String(a.h++),_.S);g.renditions.push(uO(c[e].index,f,g));d.push(g)}else a.g.warn("Skipping text stream with no extra info")}return d},zO=function(a,b){for(var c=a.f[_.Fk]||[],d=[],e=0;e<c.length;e++)for(var f=0;f<c[e].renditions.length;f++)_.L.pa(c[e].renditions[f],b,Object.keys(b))&&d.push(c[e].renditions[f]);return d[0]||null},AO=function(a,b,c){a=a.f[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},CO=function(a,b){if(b===_.S&&a.j)return iO(a.j);var c=BO(a.a)||[];if(0===c.length)return null;c=c.filter(function(e){return e.type===b.toUpperCase()})[0];var d=null;b===_.Fk&&(d=vO(a,c.extra_info),d=zO(a,{width:d.Width,height:d.Height}));b===_.T&&(c?(d=AO(a,c,_.T),a.l=d):d=a.l);b===_.S&&(c?(d=AO(a,c,_.S),a.o=d):d=a.o);return d},DO=function(a){_.mm.call(this);this.m=a;this.h=null;this.g=new _.J("clpp.tizen.Middleware");this.C=1;this.B=!1;this.l=null;this.G=0;
this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}},EO=function(a){return _.H(function(b){tizen.systeminfo.getPropertyValue("DISPLAY",function(c){a.A=c.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",a.A)},function(c){a.g.debug("Could not load DISPLAY property");throw c;});_.y(b)})},GO=function(a){try{webapis.avplay.setListener({onbufferingstart:a.Zk.bind(a),onbufferingprogress:a.Yk.bind(a),onbufferingcomplete:a.Xk.bind(a),onstreamcompleted:a.cl.bind(a),oncurrentplaytime:function(b){a.trigger(new _.K(FO,
{currentTime:b}))},onevent:a.al.bind(a),onsubtitlechange:a.el.bind(a),ondrmevent:a.$k.bind(a),onerror:a.Wd.bind(a)})}catch(b){a.g.error(b)}},HO=function(a){var b=!!a.m.getTrackManager().Wa();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},IO=function(a,b){try{var c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,jp:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",NN+d)}catch(e){a.g.debug(e)}},
JO=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+NN+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},MO=function(a){return{position:a.getPosition(),state:a.m.getState(),ph:a.getState(),playbackRate:a.getPlaybackRate(),isLive:a.isLive(),duration:a.getDuration(),isMuted:KO(a),volume:a.getVolume(),Eo:LO(a),ul:BO(a)}},OO=function(a){var b,c;return _.H(function(d){if(1==d.a)return _.x(d,NO(),2);if(3!=d.a)return b=new Promise(function(e){(new _.Xh(e)).ga(5)}),
_.x(d,Promise.race([EO(a).then(function(){return!0}),b.then(function(){return!1})]),3);c=d.f;if(!c)return a.g.debug("Took to long for the SDK to be ready"),d["return"](Promise.reject("SDK Timeout"));_.y(d)})},UO=function(a,b,c){var d,e,f,g,h,l,m,n;return _.H(function(p){switch(p.a){case 1:a.l=_.Lq(b);d=a.G;e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug("Loading manifest URL: "+a.l[d].url);f=b.startTime||void 0;a.f&&(a.trigger(new _.K(PO)),f=c.currentPosition);
_.C(p,2);g=a.l[d].url;h=a.l[d].type;h!==_.Ic||g.includes(".mpd")||(l=new URL(g),l.searchParams.append("cl-ext",".mpd"),g=l.toString());webapis.avplay.open(g);e.nextBandwidth?(JO(a,e.nextBandwidth),a.o=!1):(a.o||IO(a,e),a.o=!0);GO(a);if(!b.drm||!b.drm.env){a.g.debug("No DRM configuration was provided. Assuming clear content");p.D(4);break}m={onError:function(q){return a.m.onError(q)},Db:a.m.getNetworkEngine()};a.h=new PN(b.drm,m);return _.x(p,a.h.init(),4);case 4:return a.f||a.trigger(new _.K(QO)),
_.x(p,RO(a),6);case 6:a.f||a.trigger(new _.K(SO));f&&typeof f===_.k&&0<f&&a.seek(f)["catch"](function(q){a.g.debug("Couldn't set start position",q)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&TO(a,b.muted),b.autoplay&&a.m.play()["catch"](function(q){a.g.debug("Autoplay failed",q)}));_.uh(p,0);break;case 2:throw n=_.E(p),a.g.debug("Error while attempting to load source."),n;}})},RO=function(a){return _.H(function(b){a.g.debug("avplay.prepare()");return b["return"](new Promise(function(c,d){try{webapis.avplay.prepareAsync(function(){a.g.debug("AVPlay is ready!");
HO(a);c()},function(e){a.g.debug("prepareAsync failed",e);d(e)})}catch(e){a.g.debug("Failed to prepare media player for playback"),d(e)}}))})},VO=function(a,b,c){a.g.debug("switchVideoTrack()");try{var d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=MO(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(function(){var e=a.a.ph;a.f=!1;a.a=
null;return e===$N?a.pause():a.play()})}catch(e){return Promise.reject(e)}},LO=function(a){return a.f&&a.a?a.a.Eo:webapis.avplay.getTotalTrackInfo()},BO=function(a){return a.f&&a.a?a.a.ul:webapis.avplay.getCurrentStreamInfo()},oO=function(a,b,c){b=b.toUpperCase();b===qO&&WO(a,!0);var d=a.j[b];d&&(d.Ff.stop(),a.j[b]=null,a.g.debug("Cancelled pending track switch for "+b));return new Promise(function(e,f){function g(h,l,m){m=void 0===m?!1:m;try{webapis.avplay.setSelectTrack(h,l),a.j[h]=null,e()}catch(n){a.g.debug("Could not set "+
h+" track. Trying again...AVPlay state: "+(a.getState()+", buffering: ")+a.w,n),!1===m&&(a.j[h]={type:h,index:l,lh:0,Ff:new _.Xh(function(){return g(h,c,!0)})}),(l=a.j[h])&&3>l.lh?(!a.w&&++l.lh,l.Ff.ga(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),l&&l.Ff.stop(),a.j[h]=null,f())}}g(b,c)})},WO=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);c=a.m.h;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.g.debug("Could not set text track visibility",
d)}},TO=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case LN:a.g.warn("The application does not have the privilege to set mute.",MN);break;default:a.g.warn(IN,c)}}},KO=function(a){var b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case LN:a.g.warn("The application doesn't have the privilege to get the mute state.",MN);break;default:a.g.warn(IN,c)}}return!!b},NO=function(){return new Promise(function(a,b){if(window.webapis)a();else{var c=document.createElement("script");
ON(c,_.Be,function(d){return a(d)});ON(c,_.ie,function(d){return b(d)});c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},XO=function(){_.mm.call(this);this.a=new DO(this);this.f=new WN(this);this.configuration=this.B=_.tm();this.w=null;this.g=new _.J("clpp.tizen.Player");this.j=null;this.l=new kO;this.C=new _.vk;this.o=this.h=null;this.A=!1},YO=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.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},ZO=function(){},$O=function(){};
PN.prototype.init=function(){var a=this,b,c,d,e,f,g;return _.H(function(h){if(1==h.a){b=_.Vm[a.h.env]||null;if(!b)throw a.g.debug(_.Ea,_.xb+a.h.env+_.aa),new _.N(_.O,6,6015,_.Fa+a.h.env+"' is missing.");a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";d=_.Xm(b,a.h.customData);(e=d[_.Ed])&&a.f.set(_.Ed,{ue:e.licenseUrl||"",customData:c,Cg:!1});(f=d[_.Gd])&&a.f.set(_.Gd,{ue:f.licenseUrl||"",customData:c,
Cg:!1});if(0===a.f.size)throw new _.N(_.O,6,6E3);if((g=a.h.preferredDrmSystem)&&a.f.get(g))a.a=g;else if(a.f.get(_.Ed))a.a=_.Ed;else if(a.f.get(_.Gd))a.a=_.Gd;else throw new _.N(_.O,6,6001,"Configuration for the target system is missing.");return _.x(h,SN(a),2)}a.j=!0;_.y(h)})};PN.prototype.release=function(){var a=this;return _.H(function(b){a.j=!1;a.o=null;a.a=_.Qe;a.l=null;a.f=new Map;_.y(b)})};PN.prototype.getDrmInfo=function(){return this.o};
var UN={uj:"DeleteLicenseAfterUse",yj:"LicenseServer",Uo:"GetChallenge",Vo:"HttpHeader",Xo:"UserAgent",Ro:"Cookie",tj:"CustomData"};_.r=WN.prototype;_.r.initialize=function(){this.a.on(PO,this.Gh,this);this.a.on(aP,this.Fh,this);this.a.on(bP,this.Eh,this);this.a.on(QO,this.Pi,this);this.a.on(SO,this.Oi,this);this.a.on(cP,this.Hh,this)};_.r.release=function(){YN(this,_.tq);this.l=!1;this.o=-1;this.h=2};_.r.destroy=function(){this.release();this.a.off(PO,this.Gh);this.a.off(aP,this.Fh);this.a.off(bP,this.Eh);this.a.off(QO,this.Pi);this.a.off(SO,this.Oi);this.a.off(cP,this.Hh);this.m=this.a=null};
_.r.Gh=function(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;YN(this,_.yq)};_.r.Fh=function(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",XN(this.f))};_.r.Eh=function(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.l){this.l=!0;var a=this.m.getConfiguration().autoplay,b=this.a.getState()===dP;if(!a&&b){YN(this,_.Gq);return}}if(a=this.f!==_.Fq)a=this.a.getState(),a=a===ZN||a===$N;a&&aO(this)};
_.r.Pi=function(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===eP?YN(this,_.Fq):this.g.error("AVPlay prepares while state is not IDLE")};_.r.Oi=function(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())};_.r.Hh=function(){YN(this,_.Aq)};_.r.getState=function(){return this.f};_.r=bO.prototype;_.r.initialize=function(a){this.m=a};
_.r.load=function(a){var b=this,c,d,e,f,g,h,l;return _.H(function(m){switch(m.a){case 1:if(!b.m)return b.g.debug("Text streamer is not initialized. Will not load()"),m["return"]();b.B=a;c=b;return _.x(m,dO(b),2);case 2:c.j=m.f;if(!b.j)return b.g.debug("Could not find manifest parser for source. Make sure parsers are registered."),m["return"]();d={configurationId:"",networkingEngine:b.m.getNetworkEngine(),onContentSteeringInfoFound:function(){return null},filterNewPeriod:function(){},filterAllPeriods:function(){},
onEvent:function(){},onError:function(){}};_.C(m,3);e=b;return _.x(m,b.j.start(a.url,d),5);case 5:e.a=m.f;_.uh(m,4);break;case 3:return f=_.E(m),b.g.warn(f),_.C(m,6),g=b,_.x(m,b.j.start(a.url.replace("https://","http://"),d),8);case 8:g.a=m.f;_.uh(m,4);break;case 6:h=_.E(m),b.g.error(h),b.a=null;case 4:if(!b.a||!cO(b.a)){m.D(0);break}b.h=eO(b);_.C(m,10);return _.x(m,b.h.open(),12);case 12:b.f=fO(b);l=b.m.getConfiguration();b.f.h=l.streaming;b.o=l.preferredTextLanguage;b.A=l.preferredTextRole;b.C=
l.preferForcedSubtitles;_.uh(m,0);break;case 10:_.E(m),b.g.debug("Could not setup media source..."),b.h=null,b.f=null,b.j=null,b.a=null,_.y(m)}})};_.r.gl=function(a){this.g.debug(_.lD,a);this.w=!0;var b=_.oH(a.textStreams,this.o||"",this.A||"",this.C)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{video:null,audio:null,text:b,eb:null}};_.r.fl=function(){this.g.debug("canSwitch_");this.w=!1;this.l&&(_.kI(this.f,this.l,!0,0),this.l=null)};_.r.hl=function(){this.g.debug("onError_")};
_.r.il=function(){this.j&&this.j.update&&this.j.update()};_.r.start=function(){var a=this;return _.H(function(b){if(!a.f)return b["return"]();try{a.f.start()}catch(c){a.g.error("Error while starting streaming engine",c)}_.y(b)})};_.r.setTextVisibility=function(a){this.g.debug("Set text visibility",a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)};_.r.release=function(){var a=this;return _.H(function(b){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null;_.y(b)})};
_.r.destroy=function(){var a=this;return _.H(function(b){switch(b.a){case 1:if(!a.j){b.D(2);break}return _.x(b,a.j.stop(),3);case 3:a.j=null;case 2:if(!a.f){b.D(4);break}return _.x(b,a.f.destroy(),5);case 5:a.f=null,a.w=!0;case 4:if(!a.h){b.D(0);break}return _.x(b,a.h.destroy(),7);case 7:a.h=null,_.y(b)}})};_.w(kO,_.gl);_.r=kO.prototype;_.r.Gi=function(a){var b=a.eventid;a=a.data;switch(b){case fP:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+vO(this,b[0].extra_info).Bit_rate,b=zO(this,{bandwidth:b}))&&(this.w=b,lO(this,b));break;case gP:mO(this);break;default:this.g.debug("Event type: "+b+" data: "+a)}};_.r.yg=function(a){a.detail.currentState===_.Hq&&this.m.off(_.bg,this.yg)};
_.r.initialize=function(a){var b=this;this.m=a;this.a=this.m.a;this.m.on(_.bg,function(c){b.A||(c=c.detail,c.currentState===_.Hq&&(b.g.debug("Current state",c.currentState),b.A=!0,nO(b)))});this.a.on(hP,this.Gi,this)};_.r.release=function(){this.f={};this.j=this.w=this.o=this.l=null;this.A=!1;this.h=1};
_.r.load=function(){if(this.a&&!(0<Object.keys(this.f).length)){this.j=this.m.h;this.m.off(_.bg,this.yg);this.m.on(_.bg,this.yg,this);try{var a=LO(this.a);this.f=yO(this,a);var b=this.f[_.T]||[];b.length&&(this.l=b[0].renditions[0]||null);mO(this)}catch(c){this.g.debug("Could not load track manager")}}};_.r.destroy=function(){this.a.off(hP,this.Gi);this.a=this.m=null};_.r.getVideoTracks=function(){return this.f[_.Fk]||[]};_.r.getAudioTracks=function(){return this.f[_.T]||[]};
_.r.la=function(){return this.f[_.S]||[]};_.r.ma=function(){return CO(this,_.Fk)};_.r.Sa=function(){return CO(this,_.T)};_.r.Wa=function(){return CO(this,_.S)};_.r.Ab=function(){return this.w};_.r.Mb=function(){this.g.info(JN);return null};_.r.Nb=function(){this.g.info(JN);return null};_.r.La=function(){var a=this.ma();return a?a.track:null};_.r.qa=function(){var a=this.Sa();return a?a.track:null};_.r.Ba=function(){var a=this.Wa();return a?a.track:null};
_.r.Ib=function(a){var b=this;null===a?(a=this.ma(),VO(this.a,a.bandwidth,null).then(function(){mO(b)})):0<a.renditions.length&&this.sb(a.renditions[0])};_.r.Ia=function(a){a?rO(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")};_.r.Xa=function(a){a?(a=a.renditions[0],this.j?jO(this.j,a.track):rO(this,a)):(this.g.debug("Disabling text tracks"),this.o=null,WO(this.a,!1),this.m.trigger(new _.K(_.mg)))};
_.r.sb=function(a){var b=this,c=this.ma();this.a.o||a.width!==c.width||a.height!==c.height||a.bandwidth!==c.bandwidth?(this.w=a,lO(this,a),VO(this.a,c.bandwidth,a.bandwidth).then(function(){mO(b)})["catch"](function(d){var e=new _.N(_.O,7,7200,{tizenerror:d});b.g.debug("Error while switching video track",d);b.m.onError(e)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")};_.r.Gb=function(a){rO(this,a)};_.r.Hb=function(a){this.j?jO(this.j,a.track):rO(this,a)};
_.r.addTextTrack=function(){};_.r.va=function(){return this.a.o};kO.prototype.isAbrEnabled=kO.prototype.va;kO.prototype.addTextTrack=kO.prototype.addTextTrack;kO.prototype.setTextRendition=kO.prototype.Hb;kO.prototype.setAudioRendition=kO.prototype.Gb;kO.prototype.setVideoRendition=kO.prototype.sb;kO.prototype.setTextTrack=kO.prototype.Xa;kO.prototype.setAudioTrack=kO.prototype.Ia;kO.prototype.setVideoTrack=kO.prototype.Ib;kO.prototype.getTextTrack=kO.prototype.Ba;kO.prototype.getAudioTrack=kO.prototype.qa;
kO.prototype.getVideoTrack=kO.prototype.La;kO.prototype.getLoadingTextRendition=kO.prototype.Nb;kO.prototype.getLoadingAudioRendition=kO.prototype.Mb;kO.prototype.getLoadingVideoRendition=kO.prototype.Ab;kO.prototype.getTextRendition=kO.prototype.Wa;kO.prototype.getAudioRendition=kO.prototype.Sa;kO.prototype.getVideoRendition=kO.prototype.ma;kO.prototype.getTextTracks=kO.prototype.la;kO.prototype.getAudioTracks=kO.prototype.getAudioTracks;kO.prototype.getVideoTracks=kO.prototype.getVideoTracks;_.w(DO,_.mm);_.r=DO.prototype;_.r.Zk=function(){this.w=!0;this.f||this.trigger(new _.K(PO))};_.r.Yk=function(a){this.w=!0;this.trigger(new _.K(aP,{percent:a}))};_.r.Xk=function(){this.w=!1;this.trigger(new _.K(bP))};_.r.cl=function(){this.trigger(new _.K(cP))};_.r.al=function(a,b){this.trigger(new _.K(hP,{eventid:a,data:b}))};_.r.el=function(a,b,c,d,e){this.trigger(new _.K(iP,{duration:a,text:b,subtitleType:c,attriCount:d,attributes:e}))};
_.r.$k=function(a,b){this.trigger(new _.K(jP,{drmType:a,drmData:b}));if(this.h){var c=this.h;if(c.j)if(c.a===_.Gd&&"Challenge"===b.name)VN(c,b);else if("DrmError"===b.name){c.g.debug("DrmError event",b);var d=new _.N(_.O,6,6005,{message:JSON.stringify(b)});c.F.onError(d)}}};_.r.Wd=function(a){this.trigger(new _.K(kP,{eventType:a}))};
_.r.play=function(){function a(){return new Promise(function(d,e){function f(){d();clearTimeout(g)}var g=null;b.one(FO,f,b);g=setTimeout(function(){b.off(FO,f);e("Timeout")},3E4)})}var b=this,c=this.getState();if(c===eP)return(new Promise(function(d,e){webapis.avplay.prepareAsync(function(){HO(b);d(webapis.avplay.play())},function(f){b.trigger(new _.K(kP));e(f)})})).then(function(){return a()});if(c===$N||c===dP)try{return webapis.avplay.play(),a()}catch(d){return Promise.reject(d)}return c===ZN?
Promise.resolve():Promise.reject("Player is in invalid state")};_.r.pause=function(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===$N?Promise.resolve():Promise.reject()};
_.r.setPlaybackRate=function(a){var b=this.getState();if(b===dP||b===ZN||b===$N){try{webapis.avplay.setSpeed(a),this.C=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1};_.r.getPlaybackRate=function(){return this.C};
_.r.load=function(a,b){var c=this,d;return _.H(function(e){switch(e.a){case 1:return c.g.debug("configure()",b||""),_.C(e,2),_.x(e,OO(c),4);case 4:return _.x(e,UO(c,a,b),5);case 5:_.uh(e,0);break;case 2:throw d=_.E(e),new _.N(_.O,7,7003,null,d);}})};_.r.getState=function(){if(this.f&&this.a)return this.a.ph;try{return webapis.avplay.getState()}catch(a){this.Wd(JSON.stringify(a))}};
_.r.seek=function(a){var b=this,c=1E3*a;return new Promise(function(d,e){b.B=!0;b.m.trigger(new _.K(_.Cg));webapis.avplay.seekTo(c,function(){b.B=!1;b.m.trigger(new _.K(_.Bg));d()},function(){b.B=!1;e()})})};_.r.getPosition=function(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.Wd(JSON.stringify(a))}};_.r.getDuration=function(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.Wd(JSON.stringify(a))}};
_.r.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.Ff.stop()}a.j={};a.C=1;a.B=!1;a.l=null;a.a=null;return b()}catch(f){return c(f)}})};_.r.getVolume=function(){var a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case LN:this.g.debug("The application does not have the privilege to get the volume.",MN);break;default:this.g.debug(IN,b)}}return a};
_.r.setVolume=function(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.g.warn("Invalid value passed for setVolume.","The passed value value should be in the range of 0 to 1.");break;case LN:this.g.warn("The application does not have the privilege to set the volume.",MN);break;default:this.g.warn("An unknown error occurred while trying to set volume",b)}}};
_.r.isLive=function(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.Wd(JSON.stringify(a))}};_.r.stop=function(){try{webapis.avplay.stop()}catch(a){this.g.debug(a)}};_.r.getDrmInfo=function(){this.h&&this.h.getDrmInfo();return null};_.r.setSourceIndex=function(a){this.G=a};_.r.getSourceIndex=function(){return this.G};_.r.getLoadedSource=function(){return this.l&&this.l[this.getSourceIndex()]};
var eP="IDLE",dP="READY",ZN="PLAYING",$N="PAUSED",wO=_.Vb,pO=_.ja,qO="TEXT",gP="PLAYER_MSG_RESOLUTION_CHANGED",fP="PLAYER_MSG_BITRATE_CHANGE",TN={PLAYREADY:"PLAYREADY",So:"EME_PLAYREADY",Yo:"VERIMATRIX",Pe:"WIDEVINE_CDM",To:"EME_WIDEVINE_CDM",$o:"WIDEVINE_CLASSIC"};_.w(XO,_.mm);_.r=XO.prototype;_.r.Ch=function(){var a=this;this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.K(_.he));this.configuration.loop?this.seek(this.configuration.startTime||0)["catch"](function(){a.g.debug("Could not loop playback")}):this.a.stop()};_.r.zh=function(a){this.trigger(new _.K(_.rg,{currentTime:a.currentTime/1E3}))};
_.r.Dh=function(a){var b=this.a.getPosition(),c=b+a.duration/1E3,d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.Q.Pg(d))&&this.o.append([new _.Si(b,c,d)],[])};_.r.Ah=function(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)};_.r.Hi=function(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)};
_.r.Bh=function(a){this.g.debug("Error: TYPE: "+a.eventType);YN(this.f,_.Eq);a=new _.N(_.O,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.K(_.ie,{detail:a}))};
_.r.init=function(a,b){this.configuration=this.B=b;this.w=a;this.a.on(cP,this.Ch,this);this.a.on(FO,this.zh,this);this.a.on(iP,this.Dh,this);this.a.on(jP,this.Ah,this);this.a.on(kP,this.Bh,this);this.a.on(bP,this.Hi,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();var c=lP;lP+=1;this.j=_.er(_.Re,{id:"__clpp_tizen_player_"+c,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var d=this.w.getMedia();if(d){c=this.j;
var e=[_.Yg,_.pe,"position",_.ve,"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];_.gr(c,f);YO(this)}};_.r.getSurface=function(){return this.w};_.r.getConfiguration=function(){return this.configuration};_.r.getTimeline=function(){return null};_.r.setupPlaylist=function(){return Promise.reject(_.ob)};_.r.appendLoad=function(){return Promise.reject(_.ob)};
_.r.seekWith=function(){return Promise.reject(_.ob)};_.r.setSeekInterceptor=function(){};_.r.setPlaybackSessionId=function(){};_.r.getBandwidthEstimate=function(){return null};
_.r.destroy=function(){var a=this;return _.H(function(b){switch(b.a){case 1:return _.x(b,a.release(),2);case 2:a.a.off(cP,a.Ch);a.a.off(FO,a.zh);a.a.off(iP,a.Dh);a.a.off(jP,a.Ah);a.a.off(kP,a.Bh);a.a.off(bP,a.Hi);if(!a.h){b.D(3);break}return _.x(b,a.h.destroy(),4);case 4:a.h=null;case 3:a.j&&(a.j.parentElement.removeChild(a.j),a.j=null),a.l.destroy(),a.f.destroy(),a.l=null,a.f=null,_.y(b)}})};_.r.namespace=function(){return mP};_.r.getPlaybackRate=function(){return this.a.getPlaybackRate()};
_.r.setDrmCustomDataModifier=function(){};_.r.setCdnErrorCallback=function(){};_.r.detach=function(){};_.r.setPlaybackRate=function(a){this.a.setPlaybackRate(a)};_.r.getPosition=function(){return this.getMediaPosition()};_.r.getMediaPosition=function(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.Aq?this.getDuration():this.a.getPosition()||0};_.r.seek=function(a){return typeof a===_.k&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()};
_.r.getPresentationStartTime=function(){return null};_.r.getSeekRange=function(){return{start:0,end:0}};_.r.getVolume=function(){var a=this.a.getVolume();return typeof a===_.k?a/100:null};_.r.setVolume=function(a){this.a.setVolume(a)};_.r.getDuration=function(){return this.getMediaDuration()};_.r.getMediaDuration=function(){return this.a.getDuration()};_.r.getBufferInfo=function(){this.g.warn(_.wa);return new _.lm};_.r.getTrackManager=function(){return this.l};_.r.unload=function(){var a=this;return this.a.release().then(function(){a.l.release()})};
_.r.release=function(){var a=this;return _.H(function(b){switch(b.a){case 1:if(!a.h){b.D(2);break}return _.x(b,a.h.release(),2);case 2:if(!a.o){b.D(4);break}return _.x(b,a.o.destroy(),5);case 5:a.o=null;case 4:return _.x(b,a.a.release(),6);case 6:a.l.release(),a.f.release(),a.A=!1,_.y(b)}})};
_.r.load=function(a){var b=this,c,d,e,f,g;return _.H(function(h){switch(h.a){case 1:b.configuration=_.vm(b.B,a);c=_.kq(b.configuration,[_.re,"native"]);b.o=c.create(b);d=_.Lq(b.configuration)[0];e=!!b.configuration.tizen&&b.configuration.tizen.sideStreamText;if(!e){h.D(2);break}b.h=new bO;b.h.initialize(b);_.C(h,3);return _.x(h,b.h.load(d),5);case 5:b.h.start();_.uh(h,2);break;case 3:f=_.E(h),b.g.error(f);case 2:return _.C(h,6),_.x(h,b.a.load(b.configuration),8);case 8:_.uh(h,7);break;case 6:throw g=
_.E(h),b.onError(g),g;case 7:b.l.load(),_.y(h)}})};_.r.play=function(){var a=this;this.trigger(new _.K(_.ff));YO(this);return this.a.play().then(function(){aO(a.f)})};_.r.pause=function(){var a=this;return this.a.pause().then(function(){aO(a.f)})};_.r.getState=function(){return this.f.getState()};_.r.getPeriods=function(){return[]};_.r.onError=function(a){var b=new _.K(_.ie,{detail:a});a.severity===_.O&&(YN(this.f,_.Eq),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)};
_.r.getDrmInfo=function(){return this.a.getDrmInfo()};_.r.isEnded=function(){return this.f.getState()===_.Aq};_.r.isPaused=function(){return this.a.getState()===$N};_.r.isMuted=function(){return KO(this.a)};_.r.setMuted=function(a){TO(this.a,a)};_.r.getNetworkEngine=function(){return this.C};_.r.setNetworkEngine=function(a){this.C=a};_.r.setCmsdManager=function(){};_.r.isLive=function(){return this.a.isLive()};_.r.getStats=function(){return null};_.r.setSourceIndex=function(a){this.a.setSourceIndex(a)};
_.r.getSourceIndex=function(){return this.a.getSourceIndex()};_.r.getLoadedSource=function(){return this.a.getLoadedSource()};_.r.canPlay=function(a,b){return(new ZO).canPlay(a,b)};_.r.getTimelineCues=function(){return[]};_.r.getCueTimeline=function(){return null};_.r.getTextDisplayer=function(){return this.o};_.r.resetAbr=function(){};var mP="clpp.tizen",lP=0;ZO.prototype.a=function(){return mP};
ZO.prototype.canPlay=function(a){a=a.type;var b=!!window.webapis;if((a===_.Ic||a===_.Zl||a===_.Nc)&&b){if(_.qk(2))return 2;if(_.qk(3)||_.qk(4)||_.qk(5)||_.qk(6))return _.Jh("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0};ZO.prototype.f=function(a){return a===_.ra};ZO.prototype.create=function(){return new XO};_.w($O,_.Bu);$O.prototype.f=function(){_.Th(new ZO)};$O.prototype.a=function(){var a=mP;a&&_.Rh[a]&&(delete _.Rh[a],_.Sh.info("Removed Player factory: '"+a+"'"))};$O.prototype.id=function(){return"tizen"};_.I("clpp.tizen.TizenComponent",$O);var PO="onbufferingstart",aP="onbufferingprogress",bP="onbufferingcomplete",cP="onstreamcompleted",FO="oncurrentplaytime",hP="onevent",iP="onsubtitlechange",jP="ondrmevent",kP="onerror",QO="preparingstart",SO="preparingend";};
if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
else{_=this.clpp._;(f.call(g,this));}
})();