var standalonePlayerWrapper={};standalonePlayerWrapper.arrayObjectIndexOf=function(n,t,i){for(var r=0,u=n.length;r<u;r++)if(n[r][i]===t)return r;return-1};standalonePlayerWrapper.liveDelay=0;standalonePlayerWrapper.syncDiffAsSeconds=0;standalonePlayerWrapper.livePositionChange=3e3;standalonePlayerWrapper.livePositionChangeInterval;standalonePlayerWrapper.lastStatusChangeDate="";standalonePlayerWrapper.setupWaitingStateChange=!1;standalonePlayerWrapper.startDateUtc="";standalonePlayerWrapper.usingMetadata=!1;standalonePlayerWrapper.instance="";standalonePlayerWrapper.title="Player";standalonePlayerWrapper.isLive=!1;standalonePlayerWrapper.liveDataHash="";standalonePlayerWrapper.liveSessionStatus="";standalonePlayerWrapper.startTime=null;standalonePlayerWrapper.endTime=null;standalonePlayerWrapper.liveMarkersObj={};standalonePlayerWrapper.liveSpeakersObj={};standalonePlayerWrapper.vodSpeakersObj={};standalonePlayerWrapper.vodMarkersObj={};standalonePlayerWrapper.basePath="";standalonePlayerWrapper.sessionId=null;standalonePlayerWrapper.thumbFilePath="";standalonePlayerWrapper.defaultThumbFilePath="";standalonePlayerWrapper.pollingTimeout=0;standalonePlayerWrapper.autoScroll=!1;standalonePlayerWrapper.scrollPos=0;standalonePlayerWrapper.scrollPlaybackPos=0;standalonePlayerWrapper.currentMarkerId=null;standalonePlayerWrapper.currentMarkerIndex=null;standalonePlayerWrapper.sources=[];standalonePlayerWrapper.playerOptions={};standalonePlayerWrapper.initialize=function(n,t,i,r){standalonePlayerWrapper.pollingTimeout=n;standalonePlayerWrapper.liveSessionStatus=t;logger.debug("received date: "+i);standalonePlayerWrapper.startDateUtc=moment(i).utc();logger.debug("transformed date: "+moment(i).utc());this.setOptions(r)};standalonePlayerWrapper.setOptions=function(n){for(var t in n)standalonePlayerWrapper.hasOwnProperty(t)&&(standalonePlayerWrapper[t]=n[t])};standalonePlayerWrapper.setupPlayer=function(n){function u(){var t=standalonePlayerWrapper.thumbFilePath;$("#"+n).html("<img class='img-responsive' style='width:100%;' src='"+t+"' />")}var t,f,i,r;logger.info("standalonePlayerWrapper.setupPlayer called...");t=this.thumbFilePath;(t==""||t==null)&&(t=this.defaultThumbFilePath);playerWrapper.setupPlayer(n,t,this.sources,this.playerOptions);playerWrapper.onError(u);playerWrapper.onSetupError(u);playerWrapper.onPlay(standalonePlayerWrapper.onPlayClick);playerWrapper.onPositionChange(standalonePlayerWrapper.onPositionChanged);playerWrapper.onStop(standalonePlayerWrapper.onStop);!0==standalonePlayerWrapper.isLive&&standalonePlayerWrapper.liveSessionStatus=="STARTED"?setTimeout(function(){var o,n,r,u,f,i,s,e;if(logger.warn("statusDate: "+standalonePlayerWrapper.lastStatusChangeDate.utc()),o=standalonePlayerWrapper.lastStatusChangeDate.utc().seconds(),n=standalonePlayerWrapper.lastStatusChangeDate.utc().seconds(o+standalonePlayerWrapper.liveDelay),logger.warn("statusDate with delay = "+n.utc()),r=moment.duration(moment.utc().diff(n.utc())),logger.warn("duration from status changed = "+r),r>=0){standalonePlayerWrapper.usingMetadata==!0&&(standalonePlayerWrapper.liveMarkersObj=markers_clientHandler);logger.debug("now: "+moment.utc());logger.debug("startDate:"+standalonePlayerWrapper.startDateUtc.utc());u=moment.duration(moment.utc().diff(standalonePlayerWrapper.startDateUtc.utc()));logger.debug("live duration: "+u);f=u.asSeconds();logger.debug("duration as seconds: "+f);i=Math.round(f);logger.debug("position: "+i);logger.debug("reseting player to position: "+i);standalonePlayerWrapper.onPositionChanged(i)}else $("#current_marker").empty(),playerWrapper.disablePlayer(),$("#video_player").html('<h3 style="font-weight: normal; color: #999; font-style:italic">'+$("#pauseMessage").html()+"<\/h3>"),$.each(markers_clientHandler,function(n,t){$("#"+t.id+" .marker_timestamp").css("display","none")}),s=moment.duration(n.utc().diff(moment.utc())),e=Math.round(s.asSeconds()),logger.warn("waiting seconds: "+e),standalonePlayerWrapper.setupWaitingStateChange=!0,setTimeout(function(){function u(){var n=standalonePlayerWrapper.thumbFilePath;$("#video_player").html("<img class='img-responsive' style='width:100%;' src='"+n+"' />")}var i,r,n;playerWrapper.setupPlayer("video_player",t,standalonePlayerWrapper.sources);playerWrapper.onError(u);playerWrapper.onSetupError(u);playerWrapper.onPositionChange(standalonePlayerWrapper.onPositionChanged);playerWrapper.onPlay(standalonePlayerWrapper.onPlayClick);playerWrapper.onStop(standalonePlayerWrapper.onStop);i=moment.duration(moment.utc().diff(standalonePlayerWrapper.startDateUtc.utc()));logger.debug("live duration: "+i);r=i.asSeconds();logger.debug("duration as seconds: "+r);n=Math.round(r);logger.debug("position: "+n);logger.debug("reseting player to position: "+n);playerWrapper.play();standalonePlayerWrapper.onPositionChanged(n);standalonePlayerWrapper.setupWaitingStateChange=!1},e*1e3)},300):!0==standalonePlayerWrapper.isLive&&standalonePlayerWrapper.liveSessionStatus!="STARTED"&&(logger.warn("Live and not started!!"),standalonePlayerWrapper.usingMetadata==!0&&(standalonePlayerWrapper.liveMarkersObj=markers_clientHandler),logger.warn("statusDate: "+standalonePlayerWrapper.lastStatusChangeDate.utc()),f=standalonePlayerWrapper.lastStatusChangeDate.utc().seconds(),i=standalonePlayerWrapper.lastStatusChangeDate.utc().seconds(f+standalonePlayerWrapper.liveDelay),logger.warn("statusDate with delay = "+i.utc()),r=moment.duration(moment.utc().diff(i.utc())),logger.warn("duration from status changed = "+r),r>=0?(playerWrapper.disablePlayer(),$("#video_player").html('<h3 style="font-weight: normal; color: #999; font-style:italic">'+$("#pauseMessage").html()+"<\/h3>"),$("#current_marker").empty()):setTimeout(function(){function e(){var n=standalonePlayerWrapper.thumbFilePath;$("#video_player").html("<img class='img-responsive' style='width:100%;' src='"+n+"' />")}var r,u,n,o,f;playerWrapper.setupPlayer("video_player",t,standalonePlayerWrapper.sources);playerWrapper.onError(e);playerWrapper.onSetupError(e);playerWrapper.onPositionChange(standalonePlayerWrapper.onPositionChanged);playerWrapper.onPlay(standalonePlayerWrapper.onPlayClick);playerWrapper.onStop(standalonePlayerWrapper.onStop);r=moment.duration(moment.utc().diff(standalonePlayerWrapper.startDateUtc.utc()));logger.debug("live duration: "+r);u=r.asSeconds();logger.debug("duration as seconds: "+u);n=Math.round(u);logger.debug("position: "+n);logger.debug("reseting player to position: "+n);standalonePlayerWrapper.setupWaitingStateChange=!0;playerWrapper.play();standalonePlayerWrapper.currentMarkerId=-1;standalonePlayerWrapper.onPositionChanged(n);o=moment.duration(i.utc().diff(moment.utc()));f=Math.round(o.asSeconds());logger.warn("waiting seconds: "+f);setTimeout(function(){playerWrapper.disablePlayer();$("#current_marker").empty();$("#video_player").html('<h3 style="font-weight: normal; color: #999; font-style:italic">'+$("#pauseMessage").html()+"<\/h3>");standalonePlayerWrapper.setupWaitingStateChange=!1},f*1e3)},300));!1==standalonePlayerWrapper.isLive&&standalonePlayerWrapper.usingMetadata==!0&&(standalonePlayerWrapper.vodMarkersObj=markers_clientHandler)};standalonePlayerWrapper.seek=function(n){playerWrapper.seek(n)};standalonePlayerWrapper.onPlayClick=function(){if(!playerWrapper.isPlayRegistered&&standalonePlayerWrapper.sessionId!=null){var n=standalonePlayerWrapper.basePath+"SitePlayer/RegisterPlayClick/"+standalonePlayerWrapper.instance;$.ajax({type:"post",dataType:"html",url:n,data:AddAntiForgeryToken({sessionId:standalonePlayerWrapper.sessionId},"registerPlayclickForm"),success:function(){logger.log("playclickRegistered");n=null},error:function(t){logger.error("error occured on playclick event. playclick not registered. Exception details bellow:");logger.error(t);n=null;t=null}})}standalonePlayerWrapper.usingMetadata==!0&&standalonePlayerWrapper.isLive==!0&&typeof standalonePlayerWrapper.livePositionChangeInterval=="undefined"&&(logger.debug("seting interval"),standalonePlayerWrapper.livePositionChangeInterval=setInterval(standalonePlayerWrapper.onPositionChangedLive,standalonePlayerWrapper.livePositionChange))};standalonePlayerWrapper.onStop=function(){standalonePlayerWrapper.isLive==!0&&(logger.debug("clearing interval"),clearInterval(standalonePlayerWrapper.livePositionChangeInterval),delete standalonePlayerWrapper.livePositionChangeInterval)};standalonePlayerWrapper.onPositionChangedLive=function(){var n=moment.duration(moment.utc().diff(standalonePlayerWrapper.startDateUtc.utc())),t=n.asSeconds();currentPos=Math.round(t);standalonePlayerWrapper.onPositionChanged(currentPos)};standalonePlayerWrapper.onPositionChanged=function(n){var t,e,u,o,i,s,h,c,r,f;if(standalonePlayerWrapper.startTime!=null&&n<standalonePlayerWrapper.startTime?playerWrapper.seek(standalonePlayerWrapper.startTime):standalonePlayerWrapper.endTime!=null&&n>standalonePlayerWrapper.endTime&&(standalonePlayerWrapper.startTime!=null?(playerWrapper.seek(standalonePlayerWrapper.startTime),playerWrapper.pause()):playerWrapper.stop(),playerWrapper.showControls(!0)),standalonePlayerWrapper.usingMetadata){if(logger.debug("using metadata, position changed."),n&&typeof n!="undefined"&&n!=null||(n=0),logger.debug(playerWrapper.getState()),logger.info("player playing. executing position changed."),standalonePlayerWrapper.isLive!=!0?(logger.warn("VOD meeting"),t=parseInt(n),logger.info("onpositionchanged"),logger.debug("position: "+t),standalonePlayerWrapper.vodMarkersObj.length>0&&(logger.debug("updating markers obj."),markers_clientHandler=standalonePlayerWrapper.vodMarkersObj)):(logger.warn("LIVE meeting"),logger.debug("now utc: "+moment.utc()),logger.debug("startDate utc:"+standalonePlayerWrapper.startDateUtc.utc()),e=moment.duration(moment.utc().diff(standalonePlayerWrapper.startDateUtc.utc())),logger.debug("live duration: "+e),u=e.asSeconds(),logger.debug("duration as seconds: "+u),standalonePlayerWrapper.liveDelay&&(logger.debug("delay defined as "+standalonePlayerWrapper.liveDelay+" seconds"),u=u-standalonePlayerWrapper.liveDelay),t=Math.round(u),logger.debug("position: "+t),n=t,playerWrapper.setCurrentPosition(n),markers_clientHandler=standalonePlayerWrapper.liveMarkersObj,logger.debug("markers updated. length: "+markers_clientHandler.length)),o=[],i=markers_clientHandler&&markers_clientHandler.length>0?markers_clientHandler[0].id:"",standalonePlayerWrapper.currentMarkerIndex=0,delete s,delete h,delete c,logger.debug("total markers: "+markers_clientHandler.length),standalonePlayerWrapper.isLive!=!0?$.each(markers_clientHandler,function(n,r){if(logger.debug("marker timestamp: "+r.timestamp),r.timestamp>t)return n>0?(i=markers_clientHandler[n-1].id,standalonePlayerWrapper.currentMarkerIndex=n-1):(i=r.id,standalonePlayerWrapper.currentMarkerIndex=n),!1;if(n>0){logger.debug("inserting obj "+markers_clientHandler[n-1].id);o.push(markers_clientHandler[n-1]);var u=markers_clientHandler[n-1].type}else logger.warn("marker ignored")}):(standalonePlayerWrapper.currentMarkerId="",$.each(markers_clientHandler,function(n,r){if(logger.debug("marker timestamp: "+r.timestamp),r.timestamp==""||!r.timestamp||r.timestamp>t)return n>0?(i=markers_clientHandler[n-1].id,standalonePlayerWrapper.currentMarkerIndex=n-1):(i=r.id,standalonePlayerWrapper.currentMarkerIndex=n),!1;n>0?(logger.debug("inserting obj "+markers_clientHandler[n-1].id),o.push(markers_clientHandler[n-1]),standalonePlayerWrapper.currentMarkerPos=markers_clientHandler[n-1].timestamp):logger.warn("marker ignored")})),markers_clientHandler.length==0)return;if(i==standalonePlayerWrapper.currentMarkerId)return;standalonePlayerWrapper.currentMarkerId=i;playerWrapper.getState()!="IDLE"&&(n>=markers_clientHandler[markers_clientHandler.length-1].timestamp&&(standalonePlayerWrapper.currentMarkerIndex=markers_clientHandler.length-1),$("#current_marker").empty(),r="",f=markers_clientHandler[standalonePlayerWrapper.currentMarkerIndex].type,"mark"==f?r+="<i class='fa fa-dot-circle-o'><\/i>&nbsp;":"closedCaption"==f?r+="<i class='fa fa-cc'><\/i>&nbsp;":"subject"==f?r+="<i class='fa fa-thumb-tack'><\/i>&nbsp;":"person"==f&&(r+="<i class='fa fa-user'><\/i>&nbsp;"),r+=markers_clientHandler[standalonePlayerWrapper.currentMarkerIndex].text,$("#current_marker").html(r))}};standalonePlayerWrapper.hhmmss=function(n){return new Date(n*1e3).toUTCString().match(/(\d\d:\d\d:\d\d)/)[0]};standalonePlayerWrapper.firstRefreshMarkers=!0;standalonePlayerWrapper.liveSessionPolling=function(){var n,t;logger.info("polling server");n=standalonePlayerWrapper.basePath+"Player/ServerPolling/"+standalonePlayerWrapper.instance+"?session="+standalonePlayerWrapper.sessionId+"&hash="+standalonePlayerWrapper.liveDataHash;$.get(n,function(response){var previousSessionStatus,liveStatus,duration,playedSeconds,position,delayMilis;if(logger.debug(response.hash),standalonePlayerWrapper.liveDataHash=response.hash,response.body&&response.body!=""){if(standalonePlayerWrapper.currentMarkerId=-1,previousSessionStatus=standalonePlayerWrapper.liveSessionStatus,liveStatus=response.body.status,standalonePlayerWrapper.liveSessionStatus=liveStatus,"STARTED"!=liveStatus&&liveStatus!=previousSessionStatus&&(delayMilis=(standalonePlayerWrapper.liveDelay-standalonePlayerWrapper.syncDiffAsSeconds)*1e3,setTimeout(function(){$("#current_marker").empty();playerWrapper.disablePlayer();liveStatus=="PAUSED"?$("#video_player").html('<h3 style="font-weight: normal; color: #999; font-style:italic">'+$("#pauseMessage").html()+"<\/h3>"):$("#video_player").html('<h3 style="font-weight: normal; color: #999; font-style:italic">'+$("#noVideoMessage").html()+"<\/h3>")},delayMilis)),"STARTED"==liveStatus&&liveStatus!=previousSessionStatus&&(delayMilis=(standalonePlayerWrapper.liveDelay-standalonePlayerWrapper.syncDiffAsSeconds)*1e3,setTimeout(function(){standalonePlayerWrapper.setupPlayer("video_player")},delayMilis)),liveStatus=="STARTED"||liveStatus!="STARTED"&&standalonePlayerWrapper.setupWaitingStateChange){standalonePlayerWrapper.liveMarkersObj=eval(response.body.markers);logger.debug("now: "+moment.utc());logger.debug("startDate:"+standalonePlayerWrapper.startDateUtc.utc());duration=moment.duration(moment.utc().diff(standalonePlayerWrapper.startDateUtc.utc()));logger.debug("live duration: "+duration);playedSeconds=duration.asSeconds();logger.debug("duration as seconds: "+playedSeconds);position=playedSeconds;logger.debug("position: "+position);logger.debug("reseting player to position: "+position);standalonePlayerWrapper.onPositionChanged(position)}else liveStatus=="PAUSED"?(delayMilis=(standalonePlayerWrapper.liveDelay-standalonePlayerWrapper.syncDiffAsSeconds)*1e3,setTimeout(function(){$("#current_marker").empty();$("#video_player").html('<h3 style="font-weight: normal; color: #999; font-style:italic">'+$("#pauseMessage").html()+"<\/h3>")},delayMilis)):(delayMilis=(standalonePlayerWrapper.liveDelay-standalonePlayerWrapper.syncDiffAsSeconds)*1e3,setTimeout(function(){$("#current_marker").empty();$("#video_player").html('<h3 style="font-weight: normal; color: #999; font-style:italic">'+$("#noVideoMessage").html()+"<\/h3>")},delayMilis));standalonePlayerWrapper.firstRefreshMarkers=!1}else logger.debug("no data changes")});t=standalonePlayerWrapper.pollingTimeout;setTimeout(standalonePlayerWrapper.liveSessionPolling,t)}