forked from fluid-player/fluid-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfluidplayer.min.js
1 lines (1 loc) · 86.4 KB
/
fluidplayer.min.js
1
var fluidPlayerScriptLocation=function(){var e,t,i="";return document.currentScript?i=document.currentScript.src:(e=document.getElementsByTagName("script"),i=void 0!==(t=e[e.length-1]).getAttribute.length?t.src:t.getAttribute("src",-1)),i?i.substring(0,i.lastIndexOf("/")+1):""}();"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){"use strict";if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n<arguments.length;n++){var o=arguments[n];if(null!=o)for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(i[a]=o[a])}return i},writable:!0,configurable:!0}),function(){if("function"==typeof window.CustomEvent)return;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i}e.prototype=window.Event.prototype,window.CustomEvent=e}(),fluidPlayer=function(e,t){var i=function(e,t){for(var i=t.length,n=0;n<i;n++)if(t[n]==e)return!0;return!1},n=fluidPlayerClass.constructor();for(var o in fluidPlayerClass)fluidPlayerClass.hasOwnProperty(o)&&!i(o,fluidPlayerClass.notCloned)&&(n[o]=fluidPlayerClass[o]);return fluidPlayerClass.instances.push(n),n.init(e,t),n};var fluidPlayerClass={vttParserScript:"/scripts/webvtt.min.js",instances:[],notCloned:["notCloned","vttParserScript","instances","getInstanceById","requestStylesheet","reqiestScript","isTouchDevice","vastOptions","displayOptions","getEventOffsetX","getEventOffsetY","getTranslateX","toggleElementText","getMobileOs","findClosestParent","activeVideoPlayerId","getInstanceIdByWrapperId","timer","timerPool","adList","adPool","isUserActive","isCurrentlyPlayingAd","initialAnimationSet"],version:"2.4.4",homepage:"https://www.fluidplayer.com/",activeVideoPlayerId:null,getInstanceById:function(e){for(var t=0;t<this.instances.length;t++)if(this.instances[t].videoPlayerId===e)return this.instances[t];return null},getInstanceIdByWrapperId:function(e){return void 0!==e?e.replace("fluid_video_wrapper_",""):null},requestStylesheet:function(e,t){if(!document.getElementById(e)){var i=document.getElementsByTagName("head")[0],n=document.createElement("link");n.id=e,n.rel="stylesheet",n.type="text/css",n.href=t,n.media="all",i.appendChild(n)}},requestScript:function(e,t){var i=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e,n.onreadystatechange=t,n.onload=t,i.appendChild(n)},isTouchDevice:function(){return!!("ontouchstart"in window||navigator.maxTouchPoints)},getMobileOs:function(){var e,t=navigator.userAgent,i={device:!1,userOs:!1,userOsVer:!1,userOsMajor:!1};if(t.match(/iPad/i)?(i.device="iPad",i.userOs="iOS",e=t.indexOf("OS ")):t.match(/iPhone/i)?(i.device="iPhone",i.userOs="iOS",e=t.indexOf("OS ")):t.match(/Android/i)?(i.userOs="Android",e=t.indexOf("Android ")):i.userOs=!1,"iOS"===i.userOs&&-1<e){var n=t.substr(e+3);-1!==n.indexOf(" ")&&(i.userOsVer=n.substring(0,n.indexOf(" ")).replace(/_/g,"."),i.userOsMajor=parseInt(i.userOsVer))}else"Android"===i.userOs&&-1<e?i.userOsVer=t.substr(e+8,3):i.userOsVer=!1;return i},getBrowserVersion:function(){var e,t,i=navigator.userAgent,n={browserName:!1,fullVersion:!1,majorVersion:!1,userOsMajor:!1};try{n.browserName=navigator.appName,-1!=(e=i.indexOf("OPR/"))?(n.browserName="Opera",n.fullVersion=i.substring(e+4)):-1!=(e=i.indexOf("Opera"))?(n.browserName="Opera",n.fullVersion=i.substring(e+6),-1!=(e=i.indexOf("Version"))&&(n.fullVersion=i.substring(e+8))):-1!=(e=i.indexOf("MSIE"))?(n.browserName="Microsoft Internet Explorer",n.fullVersion=i.substring(e+5)):-1!=(e=i.indexOf("Chrome"))?(n.browserName="Google Chrome",n.fullVersion=i.substring(e+7)):-1!=(e=i.indexOf("Safari"))?(n.browserName="Safari",n.fullVersion=i.substring(e+7),-1!=(e=i.indexOf("Version"))&&(n.fullVersion=i.substring(e+8))):-1!=(e=i.indexOf("Firefox"))?(n.browserName="Mozilla Firefox",n.fullVersion=i.substring(e+8)):(t=i.lastIndexOf(" ")+1)<(e=i.lastIndexOf("/"))&&(n.browserName=i.substring(t,e),n.fullVersion=i.substring(e+1),n.browserName.toLowerCase()==n.browserName.toUpperCase()&&(n.browserName=navigator.appName)),-1!=(t=n.fullVersion.indexOf(";"))&&(n.fullVersion=n.fullVersion.substring(0,t)),-1!=(t=n.fullVersion.indexOf(" "))&&(n.fullVersion=n.fullVersion.substring(0,t)),n.majorVersion=parseInt(""+n.fullVersion,10),isNaN(n.majorVersion)&&(n.fullVersion=""+parseFloat(navigator.appVersion),n.majorVersion=parseInt(navigator.appVersion,10))}catch(e){}return n},getCurrentVideoDuration:function(){var e=document.getElementById(this.videoPlayerId);return e?e.duration:0},getClickThroughUrlFromLinear:function(e){var t=e.getElementsByTagName("VideoClicks");if(t.length){var i=t[0].getElementsByTagName("ClickThrough");if(i.length)return this.extractNodeData(i[0])}return!1},getVastAdTagUriFromWrapper:function(e){var t=e.getElementsByTagName("Wrapper");if(void 0!==t&&t.length){var i=t[0].getElementsByTagName("VASTAdTagURI");if(i.length)return this.extractNodeData(i[0])}return!1},hasInLine:function(e){var t=e.getElementsByTagName("InLine");return void 0!==t&&t.length},hasVastAdTagUri:function(e){var t=e.getElementsByTagName("VASTAdTagURI");return void 0!==t&&t.length},hasVastAdTagUriFromWrapper:function(e){if(void 0!==e&&e.length){var t=e[0].getElementsByTagName("Linear");if(null!=t&&t.length)return this.getMediaFileFromLinear(t[0])}return!1},getClickThroughUrlFromNonLinear:function(e){var t="";if(e.getElementsByTagName("NonLinear").length){var i=e.getElementsByTagName("NonLinearClickThrough");i.length&&(t=this.extractNodeData(i[0]))}return t},getTrackingFromLinear:function(e){var t=e.getElementsByTagName("TrackingEvents");return t.length?t[0].getElementsByTagName("Tracking"):[]},getDurationFromLinear:function(e){var t=e.getElementsByTagName("Duration");if(t.length&&void 0!==t[0].childNodes[0]){var i=this.extractNodeData(t[0]);return this.convertTimeStringToSeconds(i)}return!1},getDurationFromNonLinear:function(e){var t=0,i=e.getElementsByTagName("NonLinear");return i.length&&void 0!==i[0].getAttribute("minSuggestedDuration")&&(t=this.convertTimeStringToSeconds(i[0].getAttribute("minSuggestedDuration"))),t},getDimensionFromNonLinear:function(e){var t={width:null,height:null},i=e.getElementsByTagName("NonLinear");return i.length&&(void 0!==i[0].getAttribute("width")&&(t.width=i[0].getAttribute("width")),void 0!==i[0].getAttribute("height")&&(t.height=i[0].getAttribute("height"))),t},getCreativeTypeFromStaticResources:function(e){var t="",i=e.getElementsByTagName("NonLinear");return i.length&&void 0!==i[0].childNodes[0]&&(t=i[0].getElementsByTagName("StaticResource")[0].getAttribute("creativeType")),t.toLowerCase()},getMediaFilesFromLinear:function(e){var t=e.getElementsByTagName("MediaFiles");return t.length?t[0].getElementsByTagName("MediaFile"):[]},getStaticResourcesFromNonLinear:function(e){var t=[],i=e.getElementsByTagName("NonLinear");return i.length&&(t=i[0].getElementsByTagName("StaticResource")),t},extractNodeData:function(e){for(var t="",i=0;i<e.childNodes.length;i++){var n=e.childNodes[i];8===n.nodeType||3===n.nodeType&&/^\s*$/.test(n.nodeValue)||(t+=n.nodeValue)}return t.replace(/(^\s+|\s+$)/g,"")},getMediaFileFromLinear:function(e){var t,i=this.getMediaFilesFromLinear(e);return i.length&&(t=this.extractNodeData(i[0])),t},getIconClickThroughFromLinear:function(e){var t=e.getElementsByTagName("IconClickThrough");return t.length?this.extractNodeData(t[0]):(this.displayOptions.vastOptions.adCTAText=!1,"")},getStaticResourceFromNonLinear:function(e){for(var t,i=this.getStaticResourcesFromNonLinear(e),n=0;n<i.length;n++)if(i[n].getAttribute("type")||(t=this.extractNodeData(i[n])),i[n].getAttribute("type")===this.displayOptions.staticResource)return this.extractNodeData(i[n]);return t},registerTrackingEvents:function(e,t){for(var i=this.getTrackingFromLinear(e),n="",o=0,a=0;a<i.length;a++)switch(n=i[a].getAttribute("event")){case"start":case"firstQuartile":case"midpoint":case"thirdQuartile":case"complete":void 0===t.tracking[n]&&(t.tracking[n]=[]),void 0===t.stopTracking[n]&&(t.stopTracking[n]=[]),t.tracking[n].push(i[a].childNodes[0].nodeValue),t.stopTracking[n]=!1;break;case"progress":void 0===t.tracking[n]&&(t.tracking[n]=[]),o=this.convertTimeStringToSeconds(i[a].getAttribute("offset")),void 0===t.tracking[n][o]&&(t.tracking[n][o]={elements:[],stopTracking:!1}),t.tracking[n][o].elements.push(i[a].childNodes[0].nodeValue)}},registerClickTracking:function(e,t){if(e.length)for(var i=0;i<e.length;i++)""!=e[i]&&t.clicktracking.push(e[i])},registerImpressionEvents:function(e,t){if(e.length)for(var i=0;i<e.length;i++){var n=this.extractNodeData(e[i]);t.impression.push(n)}},registerErrorEvents:function(e,t){null!=e&&1===e.length&&1===e[0].childNodes.length&&(t.errorUrl=e[0].childNodes[0].nodeValue)},announceError:function(e){if(void 0!==this.vastOptions.errorUrl&&this.vastOptions.errorUrl){e=void 0!==e?parseInt(e):900;var t=this.vastOptions.errorUrl.replace("[ERRORCODE]",e);this.callUris([t])}},announceLocalError:function(e,t){e=void 0!==e?parseInt(e):900,message="[Error] ("+e+"): ",message+=t||"Failed to load Vast",console.log(message)},getClickTrackingEvents:function(e){var t=[],i=e.getElementsByTagName("VideoClicks");if(i.length){var n=i[0].getElementsByTagName("ClickTracking");if(n.length)for(var o=0;o<n.length;o++){var a=this.extractNodeData(n[o]);t.push(a)}}return t},getNonLinearClickTrackingEvents:function(e){var t=[];if(e.getElementsByTagName("NonLinear").length){var i=e.getElementsByTagName("NonLinearClickTracking");if(i.length)for(var n=0;n<i.length;n++){var o=this.extractNodeData(i[n]);t.push(o)}}return t},callUris:function(e){for(var t=0;t<e.length;t++)(new Image).src=e[t]},recalculateAdDimensions:function(e){if(!e&&void 0!==this.videoPlayerId)e=this.videoPlayerId;var t=document.getElementById(e),i=document.getElementById("vast_clickthrough_layer_"+e);i&&(i.style.width=t.offsetWidth+"px",i.style.height=t.offsetHeight+"px");var n=this.checkFullscreenSupport("fluid_video_wrapper_"+e),o=document.getElementById(e+"_fluid_control_fullscreen"),a=document.getElementById(e+"context_option_fullscreen");n?null===document[n.isFullscreen]?this.fullscreenOff(o,a):this.fullscreenOn(o,a):-1!==fullscreenTag.className.search(/\bpseudo_fullscreen\b/g)?(fullscreenTag.className+=" pseudo_fullscreen",this.fullscreenOn(o,a)):(fullscreenTag.className=fullscreenTag.className.replace(/\bpseudo_fullscreen\b/g,""),this.fullscreenOff(o,a))},prepareVast:function(e){var t=this,i=document.getElementById(this.videoPlayerId),n=[];n.length=0,n=t.findRoll(e);for(var o=0;o<n.length;o++){var a=n[o];!0!==t.adList[a].vastLoaded&&!0!==t.adList[a].error&&(t.processUrl(t.adList[a].vastTag,a),i.addEventListener("adId_"+a,t[e]))}},toggleLoader:function(e){if(this.isLoading=!!e,"browser"!==this.displayOptions.layoutControls.layout){var t=document.getElementById("vast_video_loading_"+this.videoPlayerId);t.style.display=e?"table":"none"}},sendRequest:function(e,t,i,n){var o=new XMLHttpRequest;o.onreadystatechange=n,o.open("GET",e,!0),o.withCredentials=t,o.timeout=i,o.send()},playMainVideoWhenVastFails:function(e){var t=this,i=document.getElementById(t.videoPlayerId);i.removeEventListener("loadedmetadata",t.switchPlayerToVastMode),i.pause(),t.toggleLoader(!1),t.displayOptions.vastOptions.vastAdvanced.noVastVideoCallback(),t.vastOptions&&void 0!==this.vastOptions.errorUrl?t.announceError(e):t.announceLocalError(e),t.switchToMainVideo()},switchPlayerToVastMode:function(){},processVastXml:function(e,t,i){var n=this;if(e){var o=e.getElementsByTagName("Impression");null!==o&&n.registerImpressionEvents(o,i);var a=e.getElementsByTagName("Error");null!==a&&n.registerErrorEvents(a,i);var l=e.getElementsByTagName("Creative");if(void 0!==l&&l.length){var r=l[0].getElementsByTagName("Linear");if(null!=r&&r.length){var s=r[0];n.registerTrackingEvents(s,i);var d=n.getClickTrackingEvents(s);n.registerClickTracking(d,i),!n.hasVastAdTagUri(e)&&n.hasInLine(e)&&(i.adFinished=!1,i.adType="linear",i.skipoffset=n.convertTimeStringToSeconds(s.getAttribute("skipoffset")),i.clickthroughUrl=n.getClickThroughUrlFromLinear(s),i.duration=n.getDurationFromLinear(s),i.mediaFile=n.getMediaFileFromLinear(s),i.iconClick=n.getIconClickThroughFromLinear(s))}void 0!==i.iconClick&&null!==i.iconClick&&i.iconClick.length&&(n.adList[t].landingPage=i.iconClick);var u=l[0].getElementsByTagName("NonLinearAds");if(null!=u&&u.length){var c=u[0];n.registerTrackingEvents(c,i);d=n.getNonLinearClickTrackingEvents(c);n.registerClickTracking(d,i),!n.hasVastAdTagUri(e)&&n.hasInLine(e)&&(i.adType="nonLinear",i.clickthroughUrl=n.getClickThroughUrlFromNonLinear(c),i.duration=n.getDurationFromNonLinear(c),i.dimension=n.getDimensionFromNonLinear(c),i.staticResource=n.getStaticResourceFromNonLinear(c),i.creativeType=n.getCreativeTypeFromStaticResources(c))}if(!n.hasVastAdTagUri(e)&&n.hasInLine(e))if(n.adList[t].adType=i.adType?i.adType:"unknown",void 0!==i.mediaFile||void 0!==i.staticResource){n.adList[t].vastLoaded=!0,n.adPool[t]=Object.assign({},i);var y=document.createEvent("Event");y.initEvent("adId_"+t,!1,!0),document.getElementById(n.videoPlayerId).dispatchEvent(y),n.displayOptions.vastOptions.vastAdvanced.vastLoadedCallback()}else n.stopProcessAndReportError(t)}else n.stopProcessAndReportError(t)}else n.stopProcessAndReportError(t)},processUrl:function(e,t){this.resolveVastTag(e,0,t,{tracking:[],stopTracking:[],impression:[],clicktracking:[],vastLoaded:!1})},resolveVastTag:function(e,n,o,a){var l=this;if(e&&""!=e){n<=l.displayOptions.vastOptions.maxAllowedVastTagRedirects&&l.sendRequest(e,!0,l.displayOptions.vastOptions.vastTimeout,function(){var e=this;if(4!==e.readyState||404!==e.status)if(4!==e.readyState||0!==e.status){if(4===e.readyState&&200===e.status)if(4!==e.readyState||200===e.status){try{var t=e.responseXML}catch(e){return void l.stopProcessAndReportError(o)}if(t){if(l.inLineFound=l.hasInLine(t),!l.inLineFound&&l.hasVastAdTagUri(t)){var i=l.getVastAdTagUriFromWrapper(t);if(!i)return void l.stopProcessAndReportError(o);l.resolveVastTag(i,n,o,a)}n>l.displayOptions.vastOptions.maxAllowedVastTagRedirects&&!l.inLineFound?l.stopProcessAndReportError(o):l.processVastXml(t,o,a)}else l.stopProcessAndReportError(o)}else l.stopProcessAndReportError(o)}else l.stopProcessAndReportError(o);else l.stopProcessAndReportError(o)}),n++}else l.stopProcessAndReportError(o)},stopProcessAndReportError:function(e){this.adList[e].error=!0,void 0!==e&&"preRoll"==this.adList[e].roll?this.playMainVideoWhenVastFails(900):this.announceLocalError(101)},playRoll:function(e){var t=this,i=document.getElementById(t.videoPlayerId);if(t.adPool.hasOwnProperty(e)){var n=t.adList[e].roll;switch(t.vastOptions=t.adPool[e],n){case"midRoll":i.mainVideoCurrentTime=i.currentTime-1;break;case"postRoll":i.mainVideoCurrentTime=0,t.autoplayAfterAd=!1,i.currentTime=t.mainVideoDuration}var o,a=function(){if(t.adFinished)i.removeEventListener("timeupdate",a);else{var e=Math.floor(i.currentTime);0!=t.vastOptions.duration&&t.scheduleTrackingEvent(e,t.vastOptions.duration),e>=t.vastOptions.duration-1&&0!=t.vastOptions.duration&&(i.removeEventListener("timeupdate",a),t.adFinished=!0)}};o=e,t.switchPlayerToVastMode=function(){if(t.vastOptions.duration||(t.vastOptions.duration=i.duration),(void 0!==t.adList[o].adClickable?t.adList[o].adClickable:t.displayOptions.vastOptions.adClickable)&&t.addClickthroughLayer(t.videoPlayerId),!1!==t.vastOptions.skipoffset&&t.addSkipButton(),i.loop=!1,t.addCTAButton(t.adList[o].landingPage),t.addAdCountdown(),i.removeAttribute("controls"),t.vastLogoBehaviour(!0),"browser"!==t.displayOptions.layoutControls.layout&&null!==document.getElementById(t.videoPlayerId+"_fluid_controls_progress_container")&&(document.getElementById(t.videoPlayerId+"_vast_control_currentprogress").style.backgroundColor=t.displayOptions.layoutControls.adProgressColor),t.displayOptions.vastOptions.adText||t.adList[o].adText){var e=null!==t.adList[o].adText?t.adList[o].adText:t.displayOptions.vastOptions.adText;t.addAdPlayingText(e)}t.positionTextElements(t.adList[o]),t.toggleLoader(!1),t.adList[o].played=!0,t.adFinished=!1,i.play(),t.trackSingleEvent("impression"),i.removeEventListener("loadedmetadata",t.switchPlayerToVastMode)},i.pause(),i.addEventListener("loadedmetadata",t.switchPlayerToVastMode),t.mainVideoCurrentTime=i.currentTime,t.detachStreamers(),i.src=t.vastOptions.mediaFile,t.isCurrentlyPlayingAd=!0,t.displayOptions.vastOptions.showProgressbarMarkers&&t.hideAdMarkers(),i.load(),i.addEventListener("ended",t.onVastAdEnded),i.addEventListener("timeupdate",a)}else t.announceLocalError(101)},scheduleTrackingEvent:function(e,t){var i=this;0==e&&i.trackSingleEvent("start"),void 0!==i.vastOptions.tracking.progress&&i.vastOptions.tracking.progress.length&&void 0!==i.vastOptions.tracking.progress[e]&&i.trackSingleEvent("progress",e),e==Math.floor(t/4)&&i.trackSingleEvent("firstQuartile"),e==Math.floor(t/2)&&i.trackSingleEvent("midpoint"),e==Math.floor(3*t/4)&&i.trackSingleEvent("thirdQuartile"),t-1<=e&&i.trackSingleEvent("complete")},trackSingleEvent:function(e,i){var n=this;if(void 0!==n.vastOptions&&null!==n.vastOptions){var o=[];switch(o.length=0,e){case"start":case"firstQuartile":case"midpoint":case"thirdQuartile":case"complete":!1===n.vastOptions.stopTracking[e]&&(null!==n.vastOptions.tracking[e]&&(o=n.vastOptions.tracking[e]),n.vastOptions.stopTracking[e]=!0);break;case"progress":n.vastOptions.tracking.progress[i].elements.forEach(function(e,t){!1===n.vastOptions.tracking.progress[i].stopTracking&&n.vastOptions.tracking.progress[i].elements.length&&(o=n.vastOptions.tracking.progress[i].elements),n.vastOptions.tracking.progress[i].stopTracking=!0});break;case"impression":void 0!==n.vastOptions.impression&&null!==n.vastOptions.impression&&"unknown"!=typeof n.vastOptions.impression.length&&(o=n.vastOptions.impression)}n.callUris(o)}},completeNonLinearStatic:function(e){var t=this;t.closeNonLinear(e),0==t.adFinished&&(t.adFinished=!0,t.trackSingleEvent("complete")),clearInterval(t.nonLinearTracking)},createNonLinearStatic:function(e){var t=this,i=document.getElementById(t.videoPlayerId);if(t.adPool.hasOwnProperty(e)&&!0!==t.adPool[e].error){t.vastOptions=t.adPool[e],t.createBoard(e),t.adFinished=!1,t.trackSingleEvent("start");var n=t.adList[e].nonLinearDuration?t.adList[e].nonLinearDuration:t.vastOptions.duration;t.nonLinearTracking=setInterval(function(){if(!0!==t.adFinished){var e=Math.floor(i.currentTime);t.scheduleTrackingEvent(e,n),n-1<=e&&(t.adFinished=!0)}},400),time=parseInt(t.getCurrentTime())+parseInt(n),t.scheduleTask({time:time,closeStaticAd:e})}else t.announceLocalError(101)},createBoard:function(e){var t=this,i=t.adPool[e];if(void 0!==i.staticResource&&-1!==t.supportedStaticTypes.indexOf(i.creativeType)){t.adList[e].played=!0;var n=document.getElementById(t.videoPlayerId),o=n.clientWidth,a=(n.clientHeight,document.createElement("div")),l=t.adList[e].vAlign?t.adList[e].vAlign:t.nonLinearVerticalAlign,r=new Image;r.src=i.staticResource,r.id="fluid_nonLinear_imgCreative_"+e+"_"+t.videoPlayerId,r.onload=function(){void 0!==t.adList[e].size?(origWidth=t.adList[e].size.split("x")[0],origHeight=t.adList[e].size.split("x")[1]):i.dimension.width&&i.dimension.height?(origWidth=i.dimension.width,origHeight=i.dimension.height):(origWidth=r.width,origHeight=r.height),origWidth>o?(newBannerWidth=o-5,newBannerHeight=origHeight*newBannerWidth/origWidth):(newBannerWidth=origWidth,newBannerHeight=origHeight),img=document.getElementById(r.id),img.width=newBannerWidth,img.height=newBannerHeight,t.trackSingleEvent("impression")},a.id="fluid_nonLinear_"+e,a.className="fluid_nonLinear_"+l,a.innerHTML=r.outerHTML,a.onclick=function(){void 0!==i.clickthroughUrl&&window.open(i.clickthroughUrl),void 0!==i.clicktracking&&t.callUris([i.clicktracking])},void 0!==i.clickthroughUrl&&(a.style.cursor="pointer");var s=document.createElement("div");s.id="close_button_"+t.videoPlayerId,s.className="close_button",s.innerHTML="",s.title=t.displayOptions.layoutControls.closeButtonCaption,s.onclick=function(e){return this.parentElement.remove(t),void 0!==e.stopImmediatePropagation&&e.stopImmediatePropagation(),t.adFinished=!0,clearInterval(t.nonLinearTracking),!1},a.appendChild(s),n.parentNode.insertBefore(a,n.nextSibling)}else t.adList[e].error=!0},closeNonLinear:function(e){var t=document.getElementById("fluid_nonLinear_"+e);t&&t.remove()},preRoll:function(e){var t=fluidPlayerClass.getInstanceById(this.id);document.getElementById(this.getAttribute("id")).removeEventListener(e.type,t.preRoll),t.firstPlayLaunched=!0;var i=e.type.replace("adId_","");!0!==t.adList[i].played&&("linear"==t.adList[i].adType&&(t.toggleLoader(!0),t.playRoll(i)),"nonLinear"==t.adList[i].adType&&(t.switchToMainVideo(),t.createNonLinearStatic(i)))},createAdMarker:function(e,t){var i=document.getElementById(this.videoPlayerId+"_ad_markers_holder"),n=document.createElement("div");n.id="ad_marker_"+this.videoPlayerId+"_"+e,n.className="fluid_controls_ad_marker",n.style.left=t/this.mainVideoDuration*100+"%",this.isCurrentlyPlayingAd&&(n.style.display="none"),i.appendChild(n)},hideAdMarker:function(e){var t=document.getElementById("ad_marker_"+this.videoPlayerId+"_"+e);t&&(t.style.display="none")},showAdMarkers:function(){for(var e=document.getElementById(this.videoPlayerId+"_ad_markers_holder").getElementsByClassName("fluid_controls_ad_marker"),t="ad_marker_"+this.videoPlayerId+"_",i=0;i<e.length;++i){var n=e[i],o=n.id.replace(t,"");!1===this.adList[o].played&&(n.style.display="")}},hideAdMarkers:function(){for(var e=document.getElementById(this.videoPlayerId+"_ad_markers_holder").getElementsByClassName("fluid_controls_ad_marker"),t=0;t<e.length;++t){e[t].style.display="none"}},midRoll:function(e){var t=fluidPlayerClass.getInstanceById(this.id);document.getElementById(this.getAttribute("id")).removeEventListener(e.type,t.midRoll);var i=e.type.replace("adId_","");if(!0!==t.adList[i].played){var n=t.adList[i].timer;"string"==typeof n&&-1!==n.indexOf("%")&&(n=n.replace("%",""),n=Math.floor(t.mainVideoDuration/100*n)),t.displayOptions.vastOptions.showProgressbarMarkers&&"nonLinear"===t.adList[i].adType&&t.createAdMarker(i,n),t.scheduleTask({time:n,playRoll:"midRoll",adListId:i})}},postRoll:function(e){var t=fluidPlayerClass.getInstanceById(this.id);document.getElementById(this.getAttribute("id")).removeEventListener(e.type,t.postRoll);var i=e.type.replace("adId_","");t.scheduleTask({time:Math.floor(t.mainVideoDuration),playRoll:"postRoll",adListId:i})},onPauseRoll:function(e){var t=fluidPlayerClass.getInstanceById(this.id);document.getElementById(this.getAttribute("id")).removeEventListener(e.type,t.onPauseRoll);var i=e.type.replace("adId_","");if("nonLinear"==t.adList[i].adType){if(!t.adPool.hasOwnProperty(i)||!0===t.adPool[i].error)return void t.announceLocalError(101);t.createBoard(i),onPauseAd=document.getElementById("fluid_nonLinear_"+i),onPauseAd.style.display="none"}},hasValidOnPauseAd:function(){var e=this.findRoll("onPauseRoll");return 0!=e.length&&this.adList[e[0]]&&!1===this.adList[e[0]].error},toggleOnPauseAd:function(){var e=this,t=document.getElementById(this.videoPlayerId);e.hasValidOnPauseAd()&&!e.isCurrentlyPlayingAd&&(onPauseRoll=e.findRoll("onPauseRoll"),adListId=onPauseRoll[0],e.vastOptions=e.adPool[adListId],onPauseAd=document.getElementById("fluid_nonLinear_"+adListId),onPauseAd&&t.paused?(onPauseAd.style.display="flex",e.adList[adListId].played=!1,e.trackingOnPauseNonLinearAd(adListId,"start")):onPauseAd&&!t.paused&&(onPauseAd.style.display="none",e.adFinished=!0,e.trackingOnPauseNonLinearAd(adListId,"complete")))},trackingOnPauseNonLinearAd:function(e,t){var i=this;i.adPool.hasOwnProperty(e)&&!0!==i.adPool[e].error?(i.vastOptions=i.adPool[e],i.trackSingleEvent(t)):i.announceLocalError(101)},adTimer:function(){var n=this;1!=n.isTimer&&(n.isTimer=!n.isTimer,n.timer=setInterval(function(){for(var e in n.timerPool)if(time=Math.floor(n.getCurrentTime()),time==e&&!n.isCurrentlyPlayingAd){if(n.timerPool[e]&&n.timerPool[e].hasOwnProperty("playRoll")){var t=n.timerPool[e].adListId;n.timerPool[e].playRoll;0==n.adList[t].played&&(n.vastOptions=n.adPool[t],"linear"==n.vastOptions.adType&&(n.toggleLoader(!0),n.playRoll(t)),"nonLinear"==n.vastOptions.adType&&(n.createNonLinearStatic(t),n.displayOptions.vastOptions.showProgressbarMarkers&&n.hideAdMarker(t)),delete n.timerPool[e])}if(n.timerPool[e]&&n.timerPool[e].hasOwnProperty("closeStaticAd")){var i=n.timerPool[e].closeStaticAd;1==n.adList[i].played&&(n.completeNonLinearStatic(i),delete n.timerPool[e])}}},800))},scheduleTask:function(e){this.timerPool[e.time]=e},switchToMainVideo:function(){var e=this,t=document.getElementById(e.videoPlayerId);t.src=e.originalSrc,e.initialiseStreamers();var i=void 0!==t.mainVideoCurrentTime?t.mainVideoCurrentTime:0;(t.hasOwnProperty("currentTime")&&(t.currentTime=i),e.displayOptions.layoutControls.loop&&(t.loop=!0),e.setCurrentTimeAndPlay(i,e.autoplayAfterAd),e.isCurrentlyPlayingAd=!1,e.removeClickthrough(),e.removeSkipButton(),e.removeAdCountdown(),e.removeAdPlayingText(),e.removeCTAButton(),e.vastLogoBehaviour(!1),e.adFinished=!0,e.displayOptions.vastOptions.vastAdvanced.vastVideoEndedCallback(),e.vastOptions=null,"browser"!==e.displayOptions.layoutControls.layout)&&(e.setBuffering(),null!==document.getElementById(e.videoPlayerId+"_fluid_controls_progress_container")&&(backgroundColor=e.displayOptions.layoutControls.primaryColor?e.displayOptions.layoutControls.primaryColor:"white",document.getElementById(e.videoPlayerId+"_vast_control_currentprogress").style.backgroundColor=backgroundColor));t.removeEventListener("ended",e.onVastAdEnded),"browser"===e.displayOptions.layoutControls.layout&&t.setAttribute("controls","controls"),e.displayOptions.vastOptions.showProgressbarMarkers&&e.showAdMarkers()},vastLogoBehaviour:function(e){if(!this.displayOptions.layoutControls.logo.showOverAds){var t=document.getElementById(this.videoPlayerId+"_logo"),i=document.getElementById(this.videoPlayerId+"_logo_image");if(!t||!i)return;var n=e?"none":"inline";t.style.display=n}},onVastAdEnded:function(){var e=fluidPlayerClass.getInstanceById(this.id);e.switchToMainVideo(),e.vastOptions=null,e.adFinished=!0},onMainVideoEnded:function(){var e=fluidPlayerClass.getInstanceById(this.id);if(!(e.isCurrentlyPlayingAd&&e.autoplayAfterAd||(Math.floor(e.getCurrentTime())>=Math.floor(e.mainVideoDuration)&&clearInterval(e.timer),!0!==e.displayOptions.layoutControls.loop))){var t=fluidPlayerClass.getInstanceIdByWrapperId(this.getAttribute("id"));fluidPlayerClass.getInstanceById(t);e.switchToMainVideo(),e.playPauseToggle(this)}},getCurrentTime:function(){return this.isCurrentlyPlayingAd?this.mainVideoCurrentTime:document.getElementById(this.videoPlayerId).currentTime},addSkipButton:function(){var e=document.getElementById(this.videoPlayerId),t=document.createElement("div");t.id="skip_button_"+this.videoPlayerId,t.className="skip_button skip_button_disabled",t.innerHTML=this.displayOptions.vastOptions.skipButtonCaption.replace("[seconds]",this.vastOptions.skipoffset),document.getElementById("fluid_video_wrapper_"+this.videoPlayerId).appendChild(t),e.addEventListener("timeupdate",this.decreaseSkipOffset,!1)},addAdCountdown:function(){var e=document.getElementById(this.videoPlayerId),t=document.getElementById("fluid_video_wrapper_"+this.videoPlayerId),i=document.createElement("div"),n=this.pad(parseInt(this.currentVideoDuration/60))+":"+this.pad(parseInt(this.currentVideoDuration%60)),o=parseInt(n);i.id="ad_countdown"+this.videoPlayerId,i.className="ad_countdown",i.innerHTML="Ad - "+o,t.appendChild(i),e.addEventListener("timeupdate",this.decreaseAdCountdown,!1),t.addEventListener("mouseover",function(){i.style.display="none"},!1)},decreaseAdCountdown:function(){var e=fluidPlayerClass.getInstanceById(this.id),t=parseInt(e.currentVideoDuration)-parseInt(this.currentTime),i=document.getElementById("ad_countdown"+e.videoPlayerId);i?i.innerHTML="Ad - "+e.pad(parseInt(t/60))+":"+e.pad(parseInt(t%60)):this.removeEventListener("timeupdate",e.decreaseAdCountdown)},removeAdCountdown:function(){var e=document.getElementById("ad_countdown"+this.videoPlayerId);e&&e.parentElement.removeChild(e)},toggleAdCountdown:function(e){var t=document.getElementById("ad_countdown"+this.videoPlayerId);t&&(t.style.display=e?"inline-block":"none")},addAdPlayingText:function(e){var t=document.createElement("div");t.id=this.videoPlayerId+"_fluid_ad_playing",this.displayOptions.layoutControls.primaryColor&&(t.style.backgroundColor=this.displayOptions.layoutControls.primaryColor,t.style.opacity=1),t.className="fluid_ad_playing",t.innerText=e,document.getElementById("fluid_video_wrapper_"+this.videoPlayerId).appendChild(t)},positionTextElements:function(e){var t=this,i=["top left","top right","bottom left","bottom right"],n=document.getElementById("skip_button_"+t.videoPlayerId),o=document.getElementById(t.videoPlayerId+"_fluid_ad_playing"),a=document.getElementById(t.videoPlayerId+"_fluid_cta"),l=0,r=0,s=!1,d=0,u=[],c={top:{left:{h:34,v:34},right:{h:0,v:34}},bottom:{left:{h:34,v:50},right:{h:0,v:50}}};null!==n&&(d=n.offsetHeight+8,document.getElementById("fluid_video_wrapper_"+t.videoPlayerId).classList.contains("mobile")&&(c.bottom.left.v=75,c.bottom.right.v=75));if(null!==a){var y=t.displayOptions.vastOptions.adCTATextPosition.toLowerCase();-1==i.indexOf(y)&&(console.log('[FP Error] Invalid position for CTAText. Reverting to "bottom right"'),y="bottom right"),s="bottom"==(u=y.split(" "))[0],a.style[u[0]]=c[u[0]][u[1]].v+"px",a.style[u[1]]=c[u[0]][u[1]].h+"px",s&&"right"==u[1]&&(a.style[u[0]]=c[u[0]][u[1]].v+d+"px"),l=a.offsetHeight+8+"px"}if(null!==o){var p=null!==e.adTextPosition?e.adTextPosition.toLowerCase():this.displayOptions.vastOptions.adTextPosition.toLowerCase();-1==i.indexOf(p)&&(console.log('[FP Error] Invalid position for adText. Reverting to "top left"'),p="top left");var m=p.split(" ");o.style[m[0]]=c[m[0]][m[1]].v+"px",o.style[m[1]]=c[m[0]][m[1]].h+"px",r=o.offsetHeight+8+"px"}0<l&&0<r&&y==p&&(s?"right"==u[1]?o.style.bottom=c[m[0]][m[1]].v+d+l+"px":o.style.bottom=c[m[0]][m[1]].v+l+"px":a.style.top=c[u[0]][u[1]].v+r+"px")},removeAdPlayingText:function(){var e=document.getElementById(this.videoPlayerId+"_fluid_ad_playing");e&&e.parentElement.removeChild(e)},addCTAButton:function(e){if(this.displayOptions.vastOptions.adCTAText){var t=this,i=document.getElementById(this.videoPlayerId),n=document.createElement("div");n.id=this.videoPlayerId+"_fluid_cta",n.className="fluid_ad_cta";var o=document.createElement("span");o.innerHTML=this.displayOptions.vastOptions.adCTAText+'<br/><span class="add_icon_clickthrough">'+e+"</span>",n.addEventListener("click",function(){return i.paused||i.pause(),window.open(t.vastOptions.clickthroughUrl,"_blank").focus(),!0},!1),n.appendChild(o),document.getElementById("fluid_video_wrapper_"+this.videoPlayerId).appendChild(n)}},removeCTAButton:function(){var e=document.getElementById(this.videoPlayerId+"_fluid_cta");e&&e.parentElement.removeChild(e)},decreaseSkipOffset:function(){var e=this,t=fluidPlayerClass.getInstanceById(e.id),i=t.vastOptions.skipoffset-Math.floor(e.currentTime),n=document.getElementById("skip_button_"+t.videoPlayerId);n?1<=i?n.innerHTML=t.displayOptions.vastOptions.skipButtonCaption.replace("[seconds]",i):(n.innerHTML='<a href="javascript:;" id="skipHref_'+t.videoPlayerId+'" onclick="fluidPlayerClass.getInstanceById(\''+t.videoPlayerId+"').pressSkipButton();\">"+t.displayOptions.vastOptions.skipButtonClickCaption+"</a>",n.className=n.className.replace(/\bskip_button_disabled\b/,""),e.removeEventListener("timeupdate",t.decreaseSkipOffset)):(i=0,e.removeEventListener("timeupdate",e.decreaseSkipOffset))},pressSkipButton:function(){this.removeSkipButton(),this.removeAdPlayingText(),this.removeCTAButton(),this.displayOptions.vastOptions.vastAdvanced.vastVideoSkippedCallback();var e=document.createEvent("Event");e.initEvent("ended",!1,!0),document.getElementById(this.videoPlayerId).dispatchEvent(e)},removeSkipButton:function(){btn=document.getElementById("skip_button_"+this.videoPlayerId),btn&&btn.parentElement.removeChild(btn)},addClickthroughLayer:function(){var e=this,t=document.getElementById(e.videoPlayerId),i=document.getElementById("fluid_video_wrapper_"+e.videoPlayerId),n=document.createElement("div");n.className="vast_clickthrough_layer",n.id="vast_clickthrough_layer_"+e.videoPlayerId,n.setAttribute("style","position: absolute; cursor: pointer; top: 0; left: 0; width: "+t.offsetWidth+"px; height: "+t.offsetHeight+"px;"),i.appendChild(n);var o=function(){window.open(e.vastOptions.clickthroughUrl),void 0!==e.vastOptions.clicktracking&&e.callUris(e.vastOptions.clicktracking)},a=document.getElementById("vast_clickthrough_layer_"+e.videoPlayerId),l="iPhone"===e.mobileInfo.device&&!1!==e.mobileInfo.userOsMajor&&e.mobileInfo.userOsMajor<=9;a.onclick=function(){t.paused?l&&!e.suppressClickthrough?(o(),e.suppressClickthrough=!0):t.play():(o(),t.pause())}},removeClickthrough:function(){var e=document.getElementById("vast_clickthrough_layer_"+this.videoPlayerId);e&&e.parentNode.removeChild(e)},getCurrentSrc:function(){var e=document.getElementById(this.videoPlayerId).getElementsByTagName("source");return e.length?e[0].getAttribute("src"):null},getCurrentSrcType:function(){var e=document.getElementById(this.videoPlayerId).getElementsByTagName("source");if(e.length)for(var t=0;t<e.length;t++)if(e[t].getAttribute("src")==this.originalSrc)return e[t].getAttribute("type");return null},convertTimeStringToSeconds:function(e){if(e&&e.match(/^(\d){2}(:[0-5][0-9]){2}(.(\d){1,3})?$/)){var t=e.split(":");return 3600*parseInt(t[0],10)+60*parseInt(t[1],10)+parseInt(t[2],10)}return!1},onRecentWaiting:function(){var e=fluidPlayerClass.getInstanceById(this.id);e.recentWaiting=!0,setTimeout(function(){e.recentWaiting=!1},1e3)},onFluidPlayerPause:function(){var t=this;setTimeout(function(){if(!fluidPlayerClass.getInstanceById(t.id).recentWaiting){var e=document.createEvent("CustomEvent");e.initEvent("fluidplayerpause",!1,!0),t.dispatchEvent(e)}},100)},checkShouldDisplayVolumeBar:function(){return"iOS"!==fluidPlayerClass.getMobileOs().userOs},generateCustomControlTags:function(){return'<div class="fluid_controls_left"> <div id="'+this.videoPlayerId+'_fluid_control_playpause" class="fluid_button fluid_button_play"></div></div><div id="'+this.videoPlayerId+'_fluid_controls_progress_container" class="fluid_controls_progress_container fluid_slider"> <div class="fluid_controls_progress"> <div id="'+this.videoPlayerId+'_vast_control_currentprogress" class="fluid_controls_currentprogress"> <div id="'+this.videoPlayerId+'_vast_control_currentpos" class="fluid_controls_currentpos"></div> </div> </div> <div id="'+this.videoPlayerId+'_buffered_amount" class="fluid_controls_buffered"></div> <div id="'+this.videoPlayerId+'_ad_markers_holder" class="fluid_controls_ad_markers_holder"></div></div><div class="fluid_controls_right"> <div id="'+this.videoPlayerId+'_fluid_control_fullscreen" class="fluid_button fluid_button_fullscreen"></div> <div id="'+this.videoPlayerId+'_fluid_control_theatre" class="fluid_button fluid_button_theatre"></div> <div id="'+this.videoPlayerId+'_fluid_control_video_source" class="fluid_button fluid_button_video_source"></div> <div id="'+this.videoPlayerId+'_fluid_control_playback_rate" class="fluid_button fluid_button_playback_rate"></div> <div id="'+this.videoPlayerId+'_fluid_control_download" class="fluid_button fluid_button_download"></div> <div id="'+this.videoPlayerId+'_fluid_control_volume_container" class="fluid_control_volume_container fluid_slider"> <div id="'+this.videoPlayerId+'_fluid_control_volume" class="fluid_control_volume"> <div id="'+this.videoPlayerId+'_fluid_control_currentvolume" class="fluid_control_currentvolume"> <div id="'+this.videoPlayerId+'_fluid_control_volume_currentpos" class="fluid_control_volume_currentpos"></div> </div> </div> </div> <div id="'+this.videoPlayerId+'_fluid_control_mute" class="fluid_button fluid_button_volume"></div> <div id="'+this.videoPlayerId+'_fluid_control_duration" class="fluid_fluid_control_duration">00:00 / 00:00</div></div>'},controlPlayPauseToggle:function(e){var t=document.getElementById(e+"_fluid_control_playpause"),i=document.getElementById(e+"context_option_play"),n=fluidPlayerClass.getInstanceById(e),o=document.getElementById(n.videoPlayerId+"_fluid_controls_container"),a=document.getElementById(n.videoPlayerId+"_logo"),l=document.getElementById(n.videoPlayerId);document.getElementById(e+"_fluid_initial_play")&&(document.getElementById(e+"_fluid_initial_play").style.display="none",document.getElementById(e+"_fluid_initial_play_button").style.opacity="1"),l.paused?(t.className=t.className.replace(/\bfluid_button_pause\b/g,"fluid_button_play"),o.classList.add("initial_controls_show"),a&&a.classList.add("initial_controls_show"),null!==i&&(i.innerHTML="Play")):(t.className=t.className.replace(/\bfluid_button_play\b/g,"fluid_button_pause"),o.classList.remove("initial_controls_show"),a&&a.classList.remove("initial_controls_show"),null!==i&&(i.innerHTML="Pause"))},playPauseAnimationToggle:function(e){this.isCurrentlyPlayingAd||!this.displayOptions.layoutControls.playPauseAnimation||this.isSwitchingSource||(videoPlayerId=this.videoPlayerId,e?(document.getElementById(videoPlayerId+"_fluid_state_button").classList.remove("fluid_initial_pause_button"),document.getElementById(videoPlayerId+"_fluid_state_button").classList.add("fluid_initial_play_button")):(document.getElementById(videoPlayerId+"_fluid_state_button").classList.remove("fluid_initial_play_button"),document.getElementById(videoPlayerId+"_fluid_state_button").classList.add("fluid_initial_pause_button")),document.getElementById(videoPlayerId+"_fluid_initial_play").classList.add("transform-active"),setTimeout(function(){document.getElementById(videoPlayerId+"_fluid_initial_play").classList.remove("transform-active")},800))},contolProgressbarUpdate:function(e){var t=fluidPlayerClass.getInstanceById(e),i=document.getElementById(e);document.getElementById(e+"_vast_control_currentprogress").style.width=i.currentTime/t.currentVideoDuration*100+"%"},contolDurationUpdate:function(e){var t=fluidPlayerClass.getInstanceById(e),i=document.getElementById(e),n=t.pad(parseInt(i.currentTime/60))+":"+t.pad(parseInt(i.currentTime%60))+" / "+t.pad(parseInt(t.currentVideoDuration/60))+":"+t.pad(parseInt(t.currentVideoDuration%60));document.getElementById(e+"_fluid_control_duration").innerHTML=n},pad:function(e){return e<10?"0"+e:e},contolVolumebarUpdate:function(e){var t=fluidPlayerClass.getInstanceById(e);if("browser"!==t.displayOptions.layoutControls.layout){var i=document.getElementById(e),n=document.getElementById(e+"_fluid_control_currentvolume"),o=document.getElementById(e+"_fluid_control_volume_currentpos"),a=document.getElementById(e+"_fluid_control_volume").clientWidth,l=o.clientWidth,r=document.getElementById(e+"_fluid_control_mute"),s=document.getElementById(e+"context_option_mute");i.volume&&(t.latestVolume=i.volume,t.fluidStorage.fluidMute=!1),i.volume&&!i.muted?(r.className=r.className.replace(/\bfluid_button_mute\b/g,"fluid_button_volume"),null!==s&&(s.innerHTML="Mute")):(r.className=r.className.replace(/\bfluid_button_volume\b/g,"fluid_button_mute"),null!==s&&(s.innerHTML="Unmute")),n.style.width=i.volume*a+"px",o.style.left=i.volume*a-l/2+"px"}},muteToggle:function(e){var t=fluidPlayerClass.getInstanceById(e),i=document.getElementById(e);i.volume&&!i.muted?(i.volume=0,i.muted=!0):(i.volume=t.latestVolume,i.muted=!1),this.fluidStorage.fluidVolume=t.latestVolume,this.fluidStorage.fluidMute=i.muted},checkFullscreenSupport:function(e){var t=document.getElementById(e),i=document.getElementById(this.videoPlayerId);return t.mozRequestFullScreen?{goFullscreen:"mozRequestFullScreen",exitFullscreen:"mozCancelFullScreen",isFullscreen:"mozFullScreenElement"}:t.webkitRequestFullscreen?{goFullscreen:"webkitRequestFullscreen",exitFullscreen:"webkitExitFullscreen",isFullscreen:"webkitFullscreenElement"}:t.msRequestFullscreen?{goFullscreen:"msRequestFullscreen",exitFullscreen:"msExitFullscreen",isFullscreen:"msFullscreenElement"}:t.requestFullscreen?{goFullscreen:"requestFullscreen",exitFullscreen:"exitFullscreen",isFullscreen:"fullscreenElement"}:!!i.webkitSupportsFullscreen&&{goFullscreen:"webkitEnterFullscreen",exitFullscreen:"webkitExitFullscreen",isFullscreen:"webkitDisplayingFullscreen"}},fullscreenOff:function(e,t){e.className=e.className.replace(/\bfluid_button_fullscreen_exit\b/g,"fluid_button_fullscreen"),null!==t&&(t.innerHTML="Fullscreen"),this.fullscreenMode=!1},fullscreenOn:function(e,t){e.className=e.className.replace(/\bfluid_button_fullscreen\b/g,"fluid_button_fullscreen_exit"),null!==t&&(t.innerHTML="Exit Fullscreen"),this.fullscreenMode=!0},fullscreenToggle:function(){fluidPlayerClass.activeVideoPlayerId=this.videoPlayerId;var e=document.getElementById("fluid_video_wrapper_"+this.videoPlayerId),t=this.checkFullscreenSupport("fluid_video_wrapper_"+this.videoPlayerId),i=document.getElementById(this.videoPlayerId+"_fluid_control_fullscreen"),n=document.getElementById(this.videoPlayerId+"context_option_fullscreen"),o=document.getElementById(this.videoPlayerId);if(this.theatreMode&&this.theatreToggle(),t)switch(t.goFullscreen){case"webkitEnterFullscreen":o[t.isFullscreen]||(functionNameToExecute="videoPlayerTag."+t.goFullscreen+"();",this.fullscreenOn(i,n),new Function("videoPlayerTag",functionNameToExecute)(o));break;default:null===document[t.isFullscreen]?(functionNameToExecute="videoPlayerTag."+t.goFullscreen+"();",this.fullscreenOn(i,n)):(functionNameToExecute="document."+t.exitFullscreen+"();",this.fullscreenOff(i,n)),new Function("videoPlayerTag",functionNameToExecute)(e)}else-1!==e.className.search(/\bpseudo_fullscreen\b/g)?(e.className=e.className.replace(/\bpseudo_fullscreen\b/g,""),this.fullscreenOff(i,n)):(e.className+=" pseudo_fullscreen",this.fullscreenOn(i,n))},findClosestParent:function(e,t){var i,n;if(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"].some(function(e){return"function"==typeof document.body[e]&&(i=e,!0)}),e[i](t))return e;for(;e;){if((n=e.parentElement)&&n[i](t))return n;e=n}return null},getTranslateX:function(e){var t=null;try{var i=e.style.transform.match(/translate3d\((-?\d+px,\s?){2}-?\d+px\)/);i&&i.length&&(t=i[0].replace("translate3d(","").replace(")","").replace(/\s/g,"").replace(/px/g,"").split(","))}catch(e){t=null}return t&&3===t.length?parseInt(t[0]):0},getEventOffsetX:function(e,t){for(var i=0,n=0;t&&!isNaN(t.offsetLeft);)n=fluidPlayerClass.getTranslateX(t),"BODY"===t.tagName?i+=t.offsetLeft+t.clientLeft+n-(t.scrollLeft||document.documentElement.scrollLeft):i+=t.offsetLeft+t.clientLeft+n-t.scrollLeft,t=t.offsetParent;return(void 0!==e.touches&&void 0!==e.touches[0]?e.touches[0].clientX:e.clientX)-i},getEventOffsetY:function(e,t){var i=1,n=fluidPlayerClass.findClosestParent(t,'div[id^="fluid_video_wrapper_"]');if(n){var o=n.id.replace("fluid_video_wrapper_",""),a=fluidPlayerClass.checkFullscreenSupport("fluid_video_wrapper_"+o);a&&document[a.isFullscreen]&&(i=0)}for(var l=0;t&&!isNaN(t.offsetTop);)"BODY"===t.tagName?l+=t.offsetTop-(t.scrollTop||document.documentElement.scrollTop)*i:l+=t.offsetTop-t.scrollTop*i,t=t.offsetParent;return e.clientY-l},onProgressbarMouseDown:function(i,e){var n=fluidPlayerClass.getInstanceById(i);n.displayOptions.layoutControls.playPauseAnimation=!1;var o=fluidPlayerClass.getEventOffsetX(e,document.getElementById(i+"_fluid_controls_progress_container"));if(!n.isCurrentlyPlayingAd){n.fluidPseudoPause=!0;var a=document.getElementById(i),l=a.paused;l||a.pause(),document.addEventListener("mouseup",d),document.addEventListener("touchend",d),document.addEventListener("mousemove",s),document.addEventListener("touchmove",s)}function r(e,t){var i=document.getElementById(e+"_fluid_controls_progress_container").clientWidth;i&&(a.currentTime=n.currentVideoDuration*t/i)}function s(e){var t=fluidPlayerClass.getEventOffsetX(e,document.getElementById(i+"_fluid_controls_progress_container"));o=NaN,r(i,t),n.contolProgressbarUpdate(n.videoPlayerId),n.contolDurationUpdate(n.videoPlayerId)}function d(e){document.removeEventListener("mousemove",s),document.removeEventListener("touchmove",s),document.removeEventListener("mouseup",d),document.removeEventListener("touchend",d);var t=fluidPlayerClass.getEventOffsetX(e,document.getElementById(i+"_fluid_controls_progress_container"));isNaN(t)&&!isNaN(o)&&(t=o),isNaN(t)||r(i,t),l||n.play(),n.initialAnimationSet&&setTimeout(function(){n.displayOptions.layoutControls.playPauseAnimation=n.initialAnimationSet},200),n.fluidPseudoPause=!1}},onVolumebarMouseDown:function(i){function n(e,t){var i=document.getElementById(e),n=document.getElementById(e+"_fluid_control_volume_container").clientWidth,o=fluidPlayerClass.getInstanceById(e);if(n){var a=t/n;a<.05?(a=0,i.muted=!0):.95<a&&(a=1),i.muted&&0<a&&(i.muted=!1),o.setVolume(a)}}function o(e){var t=fluidPlayerClass.getEventOffsetX(e,document.getElementById(i+"_fluid_control_volume_container"));n(i,t)}function a(e){document.removeEventListener("mousemove",o),document.removeEventListener("touchmove",o),document.removeEventListener("mouseup",a),document.removeEventListener("touchend",a);var t=fluidPlayerClass.getEventOffsetX(e,document.getElementById(i+"_fluid_control_volume_container"));isNaN(t)||n(i,t)}document.addEventListener("mouseup",a),document.addEventListener("touchend",a),document.addEventListener("mousemove",o),document.addEventListener("touchmove",o)},setVastList:function(){var e,t,i=this,n={},o={id:null,roll:null,played:!1,vastLoaded:!1,error:!1,adText:null,adTextPosition:null},a=0,l=function(e){var t=!1;switch(e.roll){case"midRoll":void 0===e.timer&&(t=!0)}return t};if(i.displayOptions.vastOptions.hasOwnProperty("adList"))for(var r in i.displayOptions.vastOptions.adList)adItem=i.displayOptions.vastOptions.adList[r],e=adItem,t=void 0,t=!1,e.vastTag||(i.announceLocalError(102,'"vastTag" property is missing from adList.'),t=!0),e.roll||(i.announceLocalError(102,'"roll" is missing from adList.'),t=!0),-1===i.availableRolls.indexOf(e.roll)&&(i.announceLocalError(102,"Only "+i.availableRolls.join(",")+" rolls are supported."),t=!0),e.size&&-1===i.supportedNonLinearAd.indexOf(e.size)&&(i.announceLocalError(102,"Only "+i.supportedNonLinearAd.join(",")+" size are supported."),t=!0),t?i.announceLocalError(102,"Wrong adList parameters."):(id="ID"+a,n[id]=Object.assign({},o),n[id]=Object.assign(n[id],i.displayOptions.vastOptions.adList[r]),"midRoll"==adItem.roll&&(n[id].error=l("midRoll",adItem)),n[id].id=id,a++);i.adList=n},findRoll:function(e){var t=[];if(t.length=0,e&&this.hasOwnProperty("adList")){for(var i in this.adList)this.adList[i].roll==e&&t.push(i);return t}},volumeChange:function(e,t){var i=document.getElementById(e).volume;"asc"==t?i+=.05:"desc"==t&&(i-=.05),i<.05?i=0:.95<i&&(i=1),this.setVolume(i)},currentTimeChange:function(e,t){var i=fluidPlayerClass.getInstanceById(e);if(!i.isCurrentlyPlayingAd){var n=document.getElementById(e);n.currentTime=i.getNewCurrentTimeValueByKeyCode(t,n.currentTime,n.duration)}},getNewCurrentTimeValueByKeyCode:function(e,t,i){var n=t;switch(e){case 37:n=(n-=5)<5?0:n;break;case 39:n=i-5<(n+=5)?i:n;break;case 35:n=i;break;case 36:n=0;break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:if(e<58&&47<e)n=i*(10*(e-48))/100}return n},handleMouseleave:function(e){var t=fluidPlayerClass.getInstanceIdByWrapperId(this.getAttribute("id")),i=fluidPlayerClass.getInstanceById(t);void 0!==e.clientX&&document.getElementById("fluid_video_wrapper_"+t).contains(document.elementFromPoint(e.clientX,e.clientY))||i.hideControlBar.call(this)},handleMouseenterForKeyboard:function(){var i=fluidPlayerClass.getInstanceIdByWrapperId(this.getAttribute("id")),n=fluidPlayerClass.getInstanceById(i),o=document.getElementById(i);n.captureKey||(n.captureKey=function(e){e.stopPropagation();var t=e.keyCode;switch(t){case 70:n.fullscreenToggle(),e.preventDefault();break;case 13:case 32:n.playPauseToggle(o),e.preventDefault();break;case 77:n.muteToggle(i),e.preventDefault();break;case 38:n.volumeChange(i,"asc"),e.preventDefault();break;case 40:n.volumeChange(i,"desc"),e.preventDefault();break;case 37:case 39:case 35:case 36:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:n.currentTimeChange(i,t),e.preventDefault()}return!1},document.addEventListener("keydown",n.captureKey,!0))},keyboardControl:function(){var n=this;document.getElementById("fluid_video_wrapper_"+n.videoPlayerId).addEventListener("click",n.handleMouseenterForKeyboard,!1),window.addEventListener("click",function(e){var t=n.videoPlayerId,i=fluidPlayerClass.getInstanceById(t);document.getElementById("fluid_video_wrapper_"+t).contains(e.target)||e.target.id=="skipHref_"+t||(document.removeEventListener("keydown",i.captureKey,!0),delete i.captureKey,i.theatreMode&&!i.theatreModeAdvanced&&i.theatreToggle())})},initialPlay:function(){var e=this,t=fluidPlayerClass.getInstanceById(e.id);if(e.addEventListener("playing",function(){t.toggleLoader(!1)}),e.addEventListener("waiting",function(){t.toggleLoader(!0)}),!t.displayOptions.layoutControls.playButtonShowing){document.getElementById(t.videoPlayerId+"_fluid_controls_container").classList.remove("initial_controls_show");var i=document.getElementById(t.videoPlayerId+"_logo");i&&i.classList.remove("initial_controls_show")}t.firstPlayLaunched||(t.playPauseToggle(e),e.removeEventListener("play",t.initialPlay))},playPauseToggle:function(e){var t=fluidPlayerClass.getInstanceById(e.id),i=!t.firstPlayLaunched,n=t.findRoll("preRoll");if(i&&0!=n.length){var o=fluidPlayerClass.getBrowserVersion();t.isCurrentlyPlayingAd=!0,("Safari"==o.browserName||!1!==t.mobileInfo.userOs&&"Android"==t.mobileInfo.userOs&&"Google Chrome"==o.browserName)&&(e.src=fluidPlayerScriptLocation+"blank.mp4",e.play(),this.playPauseAnimationToggle(!0)),t.firstPlayLaunched=!0,t.prepareVast("preRoll")}else i&&0==n.length&&(t.firstPlayLaunched=!0,t.displayOptions.vastOptions.vastAdvanced.noVastVideoCallback()),"browser"!==t.displayOptions.layoutControls.layout&&(e.paused?(t.dashPlayer?t.dashPlayer.play():e.play(),this.playPauseAnimationToggle(!0)):i||(e.pause(),this.playPauseAnimationToggle(!1))),t.toggleOnPauseAd();var a=function(){t.prepareVast("onPauseRoll"),t.prepareVast("postRoll"),t.prepareVast("midRoll")};if(i){var l=document.getElementById(t.videoPlayerId+"_fluid_pseudo_poster");l&&l.parentNode.removeChild(l),0<t.mainVideoDuration?a():e.addEventListener("mainVideoDurationSet",a)}t.adTimer();var r=document.getElementById(t.videoPlayerId+"_fluid_html_on_pause");r&&!t.isCurrentlyPlayingAd&&(e.paused?r.style.display="flex":r.style.display="none")},setCustomControls:function(){var t=this,e=document.getElementById(this.videoPlayerId);document.getElementById(this.videoPlayerId+"_fluid_control_playpause").addEventListener("click",function(){t.firstPlayLaunched||e.removeEventListener("play",t.initialPlay),t.playPauseToggle(e)},!1),document.getElementById(t.videoPlayerId).addEventListener("play",function(){t.controlPlayPauseToggle(t.videoPlayerId),t.contolVolumebarUpdate(t.videoPlayerId)},!1),document.getElementById(t.videoPlayerId).addEventListener("fluidplayerpause",function(){t.controlPlayPauseToggle(t.videoPlayerId)},!1),e.addEventListener("timeupdate",function(){t.contolProgressbarUpdate(t.videoPlayerId),t.contolDurationUpdate(t.videoPlayerId)});var i=fluidPlayerClass.getMobileOs().userOs?"touchstart":"mousedown";document.getElementById(t.videoPlayerId+"_fluid_controls_progress_container").addEventListener(i,function(e){t.onProgressbarMouseDown(t.videoPlayerId,e)},!1),document.getElementById(t.videoPlayerId+"_fluid_control_volume_container").addEventListener(i,function(e){t.onVolumebarMouseDown(t.videoPlayerId)},!1),e.addEventListener("volumechange",function(){t.contolVolumebarUpdate(t.videoPlayerId)}),document.getElementById(t.videoPlayerId+"_fluid_control_mute").addEventListener("click",function(){t.muteToggle(t.videoPlayerId)}),t.setBuffering(),document.getElementById(t.videoPlayerId+"_fluid_control_fullscreen").addEventListener("click",function(){t.fullscreenToggle()}),t.displayOptions.layoutControls.allowTheatre&&!t.isInIframe?document.getElementById(t.videoPlayerId+"_fluid_control_theatre").addEventListener("click",function(){t.theatreToggle(t.videoPlayerId)}):document.getElementById(t.videoPlayerId+"_fluid_control_theatre").style.display="none",e.addEventListener("ratechange",function(){t.isCurrentlyPlayingAd&&(this.playbackRate=1)})},createTimePositionPreview:function(){var a=this,l=document.getElementById(a.videoPlayerId);if(a.showTimeOnHover){var e=document.getElementById(a.videoPlayerId+"_fluid_controls_progress_container"),t=document.createElement("div");t.id=a.videoPlayerId+"_fluid_timeline_preview",t.className="fluid_timeline_preview",t.style.display="none",t.style.position="absolute",e.appendChild(t),document.getElementById(a.videoPlayerId+"_fluid_controls_progress_container").addEventListener("mousemove",function(e){var t=document.getElementById(a.videoPlayerId+"_fluid_controls_progress_container"),i=t.clientWidth,n=document.getElementById(a.videoPlayerId+"_fluid_timeline_preview"),o=fluidPlayerClass.getEventOffsetX(e,t);hoverSecondQ=a.currentVideoDuration*o/i,showad=a.pad(parseInt(hoverSecondQ/60))+":"+a.pad(parseInt(hoverSecondQ%60)),n.innerText=showad,n.style.display="block",n.style.left=hoverSecondQ/l.duration*100+"%"},!1),document.getElementById(a.videoPlayerId+"_fluid_controls_progress_container").addEventListener("mouseout",function(){document.getElementById(a.videoPlayerId+"_fluid_timeline_preview").style.display="none"},!1)}},setCustomContextMenu:function(){var e=this,t=document.getElementById(e.videoPlayerId),i=document.getElementById("fluid_video_wrapper_"+e.videoPlayerId),n=document.createElement("div");n.id=e.videoPlayerId+"_fluid_context_menu",n.className="fluid_context_menu",n.style.display="none",n.style.position="absolute",n.innerHTML='<ul> <li id="'+e.videoPlayerId+'context_option_play">Play</li> <li id="'+e.videoPlayerId+'context_option_mute">Mute</li> <li id="'+e.videoPlayerId+'context_option_fullscreen">Fullscreen</li> <li id="'+e.videoPlayerId+'context_option_homepage">Fluid Player '+e.version+"</li></ul>",t.parentNode.insertBefore(n,t.nextSibling),i.addEventListener("contextmenu",function(e){e.preventDefault(),n.style.left=fluidPlayerClass.getEventOffsetX(e,t)+"px",n.style.top=fluidPlayerClass.getEventOffsetY(e,t)+"px",n.style.display="block"},!1),document.addEventListener("click",function(e){e.target===t&&2===e.button||(n.style.display="none")},!1);var o=document.getElementById(e.videoPlayerId+"context_option_play"),a=document.getElementById(e.videoPlayerId+"context_option_mute"),l=document.getElementById(e.videoPlayerId+"context_option_fullscreen"),r=document.getElementById(e.videoPlayerId+"context_option_homepage");o.addEventListener("click",function(){e.playPauseToggle(t)},!1),a.addEventListener("click",function(){e.muteToggle(e.videoPlayerId)},!1),l.addEventListener("click",function(){e.fullscreenToggle()},!1),r.addEventListener("click",function(){window.open(e.homepage,"_blank").focus()},!1)},setDefaultLayout:function(){var e=this,t=document.getElementById(e.videoPlayerId);document.getElementById("fluid_video_wrapper_"+e.videoPlayerId).className+=" fluid_player_layout_"+e.displayOptions.layoutControls.layout,t.removeAttribute("controls"),e.setCustomContextMenu();var i="";e.checkShouldDisplayVolumeBar()||(i=" no_volume_bar");var n=document.createElement("div");n.id=e.videoPlayerId+"_fluid_controls_container",n.className="fluid_controls_container"+i,n.innerHTML=e.generateCustomControlTags(),t.parentNode.insertBefore(n,t.nextSibling);var o=document.createElement("div");o.className="vast_video_loading",o.id="vast_video_loading_"+e.videoPlayerId,o.style.display="none",backgroundColor=e.displayOptions.layoutControls.primaryColor?e.displayOptions.layoutControls.primaryColor:"white",document.getElementById(e.videoPlayerId+"_vast_control_currentprogress").style.backgroundColor=backgroundColor,t.parentNode.insertBefore(o,t.nextSibling);var a=100,l=setInterval(function(){a?e.checkIfVolumebarIsRendered()?(clearInterval(l),e.contolVolumebarUpdate(e.videoPlayerId)):a--:clearInterval(l)},100);e.initHtmlOnPauseBlock(),e.setCustomControls(),e.setupThumbnailPreview(),e.createTimePositionPreview(),e.posterImage(),e.initPlayButton(),e.createPlaybackList(),e.createDownload()},checkIfVolumebarIsRendered:function(){var e=document.getElementById(this.videoPlayerId+"_fluid_control_volume_currentpos"),t=document.getElementById(this.videoPlayerId+"_fluid_control_volume").clientWidth;return e.clientWidth!==t},setLayout:function(){var e=this,t=document.getElementById(e.videoPlayerId),i=fluidPlayerClass.isTouchDevice()?"touchend":"click";switch(document.getElementById(this.videoPlayerId).addEventListener(i,function(){e.playPauseToggle(t)},!1),this.displayOptions.layoutControls.layout){case"browser":break;default:t.addEventListener("play",e.initialPlay,!1),this.setDefaultLayout()}},handleFullscreen:function(){var t=this;void 0===document.vastFullsreenChangeEventListenersAdded&&(["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","msfullscreenchange"].forEach(function(e){"object"==typeof document["on"+e]&&document.addEventListener(e,function(e){t.recalculateAdDimensions(fluidPlayerClass.activeVideoPlayerId)},!1)}),document.vastFullsreenChangeEventListenersAdded=!0)},setupThumbnailPreviewVtt:function(){var d=this;d.sendRequest(d.displayOptions.layoutControls.timelinePreview.file,!0,d.displayOptions.vastOptions.vastTimeout,function(){var e=this;if((4!==e.readyState||200===e.status)&&4===e.readyState&&200===e.status){var t=e.responseText,i=(new WebVTTParser).parse(t);d.timelinePreviewData=function(e){if(void 0===e.cues||!e.cues.length)return[];for(var t=[],i=null,n=null,o=0;o<e.cues.length;o++){var a=0,l=0,r=122.5,s=69;2===(i=e.cues[o].text.split("#")).length&&0===i[1].indexOf("xywh=")&&4===(n=(n=i[1].substring(5)).split(",")).length&&(d.displayOptions.layoutControls.timelinePreview.spriteImage=!0,a=parseInt(n[0]),l=parseInt(n[1]),r=parseInt(n[2]),s=parseInt(n[3])),!d.displayOptions.layoutControls.timelinePreview.spriteRelativePath||-1===d.displayOptions.layoutControls.timelinePreview.file.indexOf("/")||void 0!==d.displayOptions.layoutControls.timelinePreview.sprite&&""!=d.displayOptions.layoutControls.timelinePreview.sprite?imageUrl=d.displayOptions.layoutControls.timelinePreview.sprite?d.displayOptions.layoutControls.timelinePreview.sprite:i[0]:(imageUrl=d.displayOptions.layoutControls.timelinePreview.file.substring(0,d.displayOptions.layoutControls.timelinePreview.file.lastIndexOf("/")),imageUrl+="/"+i[0]),t.push({startTime:e.cues[o].startTime,endTime:e.cues[o].endTime,image:imageUrl,x:a,y:l,w:r,h:s})}return t}(i)}})},generateTimelinePreviewTags:function(){var e=document.getElementById(this.videoPlayerId+"_fluid_controls_progress_container"),t=document.createElement("div");t.id=this.videoPlayerId+"_fluid_timeline_preview_container",t.className="fluid_timeline_preview_container",t.style.display="none",t.style.position="absolute",e.appendChild(t);var i=document.createElement("div");i.id=this.videoPlayerId+"_fluid_timeline_preview_container_shadow",i.className="fluid_timeline_preview_container_shadow",i.style.position="absolute",i.style.display="none",i.style.opacity=1,e.appendChild(i)},getThumbnailCoordinates:function(e){var t=this;if(t.timelinePreviewData.length)for(var i=0;i<t.timelinePreviewData.length;i++)if(e>=t.timelinePreviewData[i].startTime&&e<=t.timelinePreviewData[i].endTime)return t.timelinePreviewData[i];return!1},drawTimelinePreview:function(e){var t=this,i=document.getElementById(t.videoPlayerId+"_fluid_timeline_preview_container"),n=document.getElementById(t.videoPlayerId+"_fluid_timeline_preview_container_shadow"),o=document.getElementById(t.videoPlayerId+"_fluid_controls_progress_container"),a=o.clientWidth;if(t.isCurrentlyPlayingAd)"none"!==i.style.display&&(i.style.display="none");else{var l=fluidPlayerClass.getEventOffsetX(e,o),r=null;if(a){r=t.currentVideoDuration*l/a;var s=t.getThumbnailCoordinates(r);n.style.width=a+"px",!(n.style.display="block")!==s?(i.style.width=s.w+"px",i.style.height=s.h+"px",n.style.height=s.h+"px",i.style.background="url("+s.image+") no-repeat scroll -"+s.x+"px -"+s.y+"px",i.style.left=l-s.w/2+"px",i.style.display="block",t.displayOptions.layoutControls.timelinePreview.spriteImage||(i.style.backgroundSize="contain")):i.style.display="none"}}},setupThumbnailPreview:function(){var i=this;if(i.displayOptions.layoutControls.timelinePreview&&"string"==typeof i.displayOptions.layoutControls.timelinePreview.file&&"string"==typeof i.displayOptions.layoutControls.timelinePreview.type){switch(i.displayOptions.layoutControls.timelinePreview.type){case"VTT":fluidPlayerClass.requestScript(fluidPlayerScriptLocation+fluidPlayerClass.vttParserScript,i.setupThumbnailPreviewVtt.bind(this));var e="mousemove",t="mouseleave";i.mobileInfo.userOs&&(e="touchmove",t="touchend"),document.getElementById(i.videoPlayerId+"_fluid_controls_progress_container").addEventListener(e,i.drawTimelinePreview.bind(i),!1),document.getElementById(i.videoPlayerId+"_fluid_controls_progress_container").addEventListener(t,function(e){var t=document.getElementById(i.videoPlayerId+"_fluid_controls_progress_container");void 0!==e.clientX&&t.contains(document.elementFromPoint(e.clientX,e.clientY))||(document.getElementById(i.videoPlayerId+"_fluid_timeline_preview_container").style.display="none",document.getElementById(i.videoPlayerId+"_fluid_timeline_preview_container_shadow").style.display="none")},!1),i.generateTimelinePreviewTags()}i.showTimeOnHover=!1}},setupPlayerWrapper:function(){var e=document.getElementById(this.videoPlayerId),t=document.createElement("div");t.className=fluidPlayerClass.isTouchDevice()?"fluid_video_wrapper mobile":"fluid_video_wrapper",t.id="fluid_video_wrapper_"+this.videoPlayerId,this.displayOptions.layoutControls.fillToContainer?(t.style.width="100%",t.style.height="100%"):(t.style.height=e.clientHeight+"px",t.style.width=e.clientWidth+"px"),e.style.height="100%",e.style.width="100%",e.parentNode.insertBefore(t,e),t.appendChild(e)},onErrorDetection:function(){var e=fluidPlayerClass.getInstanceById(this.id);this.networkState===this.NETWORK_NO_SOURCE&&e.isCurrentlyPlayingAd&&e.playMainVideoWhenVastFails(401)},createVideoSourceSwitch:function(){var a=this,l=document.getElementById(a.videoPlayerId);if("browser"!==a.displayOptions.layoutControls.layout){var t=[],e=l.querySelectorAll("source");if([].forEach.call(e,function(e){e.title&&e.src&&t.push({title:e.title,url:e.src,isHD:null!=e.getAttribute("data-fluid-hd")})}),a.videoSources=t,1<a.videoSources.length){var i=document.getElementById(a.videoPlayerId+"_fluid_control_video_source"),r=!1,s=document.createElement("div");s.id=a.videoPlayerId+"_fluid_control_video_source_list",s.className="fluid_video_sources_list",s.style.display="none";var d=!0;a.videoSources.forEach(function(e){var t=e.url.split(".").pop();if("iOS"!=a.mobileInfo.userOs||"mkv"!=t){var i=d?"source_selected":"",n=e.isHD?'<sup style="color:'+a.displayOptions.layoutControls.primaryColor+'" class="fp_hd_source"></sup>':"";d=!1;var o=document.createElement("div");o.id="source_"+a.videoPlayerId+"_"+e.title,o.className="fluid_video_source_list_item",o.innerHTML='<span class="source_button_icon '+i+'"></span>'+e.title+n,o.addEventListener("click",function(e){l.style.width=l.clientWidth+"px",l.style.height=l.clientHeight+"px",e.stopPropagation();for(var t=this,i=document.getElementsByClassName("source_button_icon"),n=0;n<i.length;n++)i[n].className=i[n].className.replace("source_selected","");t.firstChild.className+=" source_selected",a.videoSources.forEach(function(e){e.title==t.innerText.replace(/(\r\n\t|\n|\r\t)/gm,"")&&(a.setBuffering(),a.setVideoSource(e.url),a.fluidStorage.fluidQuality=e.title)}),a.openCloseVideoSourceSwitch()}),s.appendChild(o),r=!0}}),r?(i.appendChild(s),i.addEventListener("click",function(){a.openCloseVideoSourceSwitch()})):document.getElementById(a.videoPlayerId+"_fluid_control_video_source").style.display="none"}else document.getElementById(a.videoPlayerId+"_fluid_control_video_source").style.display="none"}},openCloseVideoSourceSwitch:function(){var t=document.getElementById(this.videoPlayerId+"_fluid_control_video_source_list"),i=document.getElementById(this.videoPlayerId+"_fluid_control_video_source");if(this.isCurrentlyPlayingAd)t.style.display="none";else if("none"==t.style.display){t.style.display="block";var n=function(e){i.removeEventListener("mouseleave",n),t.style.display="none"};i.addEventListener("mouseleave",n)}else t.style.display="none"},setVideoSource:function(e){var t=this,i=document.getElementById(t.videoPlayerId);if("iOS"==t.mobileInfo.userOs&&0<e.indexOf(".mkv"))return console.log("[FP_ERROR] .mkv files not supported by iOS devices."),!1;if(t.isCurrentlyPlayingAd)t.originalSrc=e;else{var n=!(t.isSwitchingSource=!0);i.paused||(i.pause(),n=!0);var o=i.currentTime;t.setCurrentTimeAndPlay(o,n),i.src=e,t.originalSrc=e,t.displayOptions.layoutControls.mediaType=t.getCurrentSrcType(),t.initialiseStreamers()}},setCurrentTimeAndPlay:function(e,t){var i=document.getElementById(this.videoPlayerId),n=this,o=function(){i.currentTime=e,i.removeEventListener("loadedmetadata",o),"iOS"==n.mobileInfo.userOs&&i.addEventListener("playing",a),t&&i.play(),n.isSwitchingSource=!1,i.style.width="100%",i.style.height="100%"},a=function(){this.currentTime=e,i.removeEventListener("playing",a)};i.addEventListener("loadedmetadata",o,!1),i.load()},initLogo:function(){var e=this,t=document.getElementById(e.videoPlayerId);if(e.displayOptions.layoutControls.logo.imageUrl){var i=document.createElement("div");i.id=e.videoPlayerId+"_logo";var n="logo_maintain_display";e.displayOptions.layoutControls.logo.hideWithControls&&(n="initial_controls_show"),i.classList.add(n,"fp_logo");var o=document.createElement("img");o.id=e.videoPlayerId+"_logo_image",e.displayOptions.layoutControls.logo.imageUrl&&(o.src=e.displayOptions.layoutControls.logo.imageUrl),o.style.position="absolute",o.style.margin=e.displayOptions.layoutControls.logo.imageMargin;var a=e.displayOptions.layoutControls.logo.position.toLowerCase();-1!==a.indexOf("bottom")?o.style.bottom=0:o.style.top=0,-1!==a.indexOf("right")?o.style.right=0:o.style.left=0,e.displayOptions.layoutControls.logo.opacity&&(o.style.opacity=e.displayOptions.layoutControls.logo.opacity),null!==e.displayOptions.layoutControls.logo.clickUrl&&(o.style.cursor="pointer",o.addEventListener("click",function(){window.open(e.displayOptions.layoutControls.logo.clickUrl,"_blank").focus()})),e.displayOptions.layoutControls.logo.mouseOverImageUrl&&(o.addEventListener("mouseover",function(){o.src=e.displayOptions.layoutControls.logo.mouseOverImageUrl},!1),o.addEventListener("mouseout",function(){o.src=e.displayOptions.layoutControls.logo.imageUrl},!1)),t.parentNode.insertBefore(i,null),i.appendChild(o,null)}},initHtmlOnPauseBlock:function(){var t=this;if(!t.hasValidOnPauseAd()&&t.displayOptions.layoutControls.htmlOnPauseBlock.html){var i=document.getElementById(t.videoPlayerId),e=document.createElement("div");e.id=t.videoPlayerId+"_fluid_html_on_pause",e.className="fluid_html_on_pause",e.style.display="none",e.innerHTML=t.displayOptions.layoutControls.htmlOnPauseBlock.html,e.onclick=function(e){t.playPauseToggle(i)},t.displayOptions.layoutControls.htmlOnPauseBlock.width&&(e.style.width=t.displayOptions.layoutControls.htmlOnPauseBlock.width+"px"),t.displayOptions.layoutControls.htmlOnPauseBlock.height&&(e.style.height=t.displayOptions.layoutControls.htmlOnPauseBlock.height+"px"),i.parentNode.insertBefore(e,null)}},initPlayButton:function(){var e=this,t=document.getElementById(e.videoPlayerId),i=document.createElement("div");i.id=e.videoPlayerId+"_fluid_initial_play_button",i.className="fluid_html_on_pause",backgroundColor=e.displayOptions.layoutControls.primaryColor?e.displayOptions.layoutControls.primaryColor:"#333333",i.innerHTML='<div id="'+e.videoPlayerId+'_fluid_initial_play" class="fluid_initial_play" style="background-color:'+backgroundColor+'"><div id="'+e.videoPlayerId+'_fluid_state_button" class="fluid_initial_play_button"></div></div>';var n=function(){e.playPauseToggle(t),i.removeEventListener("click",n)};(i.addEventListener("click",n),e.displayOptions.layoutControls.playButtonShowing)||(document.getElementById(e.videoPlayerId+"_fluid_controls_container").classList.add("initial_controls_show"),i.style.opacity="0");t.parentNode.insertBefore(i,null)},mainVideoReady:function(){var e=fluidPlayerClass.getInstanceById(this.id);if(0==e.mainVideoDuration&&!e.isCurrentlyPlayingAd&&!1===e.mainVideoReadyState){e.mainVideoDuration=this.duration,e.mainVideoReadyState=!0;var t=new CustomEvent("mainVideoDurationSet");this.dispatchEvent(t),this.removeEventListener("loadedmetadata",e.mainVideoReady)}},userActivityChecker:function(){var t=this,e=document.getElementById("fluid_video_wrapper_"+t.videoPlayerId),i=document.getElementById(t.videoPlayerId);t.newActivity=null;var n=!1,o=function(e){"touchstart"!==e.type&&"mousedown"!==e.type||(n=!0),"touchend"!==e.type&&"mouseup"!==e.type||(n=!1),t.newActivity=!0};activityCheck=setInterval(function(){if(!0===t.newActivity){if(n||t.isLoading||(t.newActivity=!1),!1===t.isUserActive||!t.isControlBarVisible()){var e=new CustomEvent("userActive");i.dispatchEvent(e),t.isUserActive=!0}clearTimeout(t.inactivityTimeout),t.inactivityTimeout=setTimeout(function(){!0!==t.newActivity?(t.isUserActive=!1,e=new CustomEvent("userInactive"),i.dispatchEvent(e)):clearTimeout(t.inactivityTimeout)},1e3*t.displayOptions.layoutControls.controlBar.autoHideTimeout)}},300);for(var a=fluidPlayerClass.isTouchDevice()?["touchstart","touchmove","touchend"]:["mousemove","mousedown","mouseup"],l=0;l<a.length;l++)e.addEventListener(a[l],o)},hasControlBar:function(){return!(!document.getElementById(this.videoPlayerId+"_fluid_controls_container")||"browser"==this.displayOptions.layoutControls.layout)},isControlBarVisible:function(){if(!1===this.hasControlBar())return!1;var e=document.getElementById(this.videoPlayerId+"_fluid_controls_container"),t=window.getComputedStyle(e,null);return!(0==t.opacity||"hidden"==t.visibility)},hideControlBar:function(){var e=fluidPlayerClass.getInstanceIdByWrapperId(this.getAttribute("id")),t=fluidPlayerClass.getInstanceById(e),i=document.getElementById(e);if(t.isCurrentlyPlayingAd&&!i.paused&&"browser"!==t.displayOptions.layoutControls.layout&&t.toggleAdCountdown(!0),t.hasControlBar()){var n=document.getElementById(t.videoPlayerId+"_fluid_controls_container"),o=document.getElementById(t.videoPlayerId+"_logo");t.displayOptions.layoutControls.controlBar.animated?(n.classList.remove("fade_in"),n.classList.add("fade_out"),o&&(o.classList.remove("fade_in"),o.classList.add("fade_out"))):(n.style.display="none",o&&(o.style.display="none"))}i.style.cursor="none"},showControlBar:function(){var e=fluidPlayerClass.getInstanceIdByWrapperId(this.getAttribute("id")),t=fluidPlayerClass.getInstanceById(e),i=document.getElementById(e);if(t.isCurrentlyPlayingAd&&!i.paused&&"browser"!==t.displayOptions.layoutControls.layout&&t.toggleAdCountdown(!1),t.hasControlBar()){var n=document.getElementById(t.videoPlayerId+"_fluid_controls_container"),o=document.getElementById(t.videoPlayerId+"_logo");t.displayOptions.layoutControls.controlBar.animated?(n.classList.remove("fade_out"),n.classList.add("fade_in"),o&&(o.classList.remove("fade_out"),o.classList.add("fade_in"))):(n.style.display="block",o&&(o.style.display="block"))}fluidPlayerClass.isTouchDevice()||(i.style.cursor="default")},linkControlBarUserActivity:function(){var e=document.getElementById(this.videoPlayerId);e.addEventListener("userInactive",this.hideControlBar),e.addEventListener("userActive",this.showControlBar)},initMute:function(){!0===this.displayOptions.layoutControls.mute&&(document.getElementById(this.videoPlayerId).volume=0)},initLoop:function(){var e=document.getElementById(this.videoPlayerId);null!==this.displayOptions.layoutControls.loop?e.loop=this.displayOptions.layoutControls.loop:e.loop&&(this.displayOptions.layoutControls.loop=!0)},setBuffering:function(){var i=document.getElementById(this.videoPlayerId),n=document.getElementById(this.videoPlayerId+"_buffered_amount");n.style.width=0,logProgress=function(){var e=i.duration;if(0<e)for(var t=0;t<i.buffered.length;t++)if(i.buffered.start(i.buffered.length-1-t)<i.currentTime){n.style.width=i.buffered.end(i.buffered.length-1-t)/e*100+"%",i.buffered.end(i.buffered.length-1-t)/e=="1"&&clearInterval(o);break}};var o=setInterval(logProgress,500)},createPlaybackList:function(){var i=this;if(i.displayOptions.layoutControls.playbackRateEnabled){var e=document.getElementById(i.videoPlayerId+"_fluid_control_playback_rate"),n=document.createElement("div");n.id=i.videoPlayerId+"_fluid_control_video_playback_rate",n.className="fluid_video_playback_rates",n.style.display="none",["x2","x1.5","x1","x0.5"].forEach(function(e){var t=document.createElement("div");t.className="fluid_video_playback_rates_item",t.innerText=e,t.addEventListener("click",function(e){e.stopPropagation(),playbackRate=this.innerText.replace("x",""),i.setPlaybackSpeed(playbackRate),i.openCloseVideoPlaybackRate()}),n.appendChild(t)}),e.appendChild(n),e.addEventListener("click",function(){i.openCloseVideoPlaybackRate()})}else document.getElementById(i.videoPlayerId+"_fluid_control_playback_rate").style.display="none"},openCloseVideoPlaybackRate:function(){var e=document.getElementById(this.videoPlayerId+"_fluid_control_video_playback_rate"),t=document.getElementById(this.videoPlayerId+"_fluid_control_playback_rate");if(this.isCurrentlyPlayingAd)e.style.display="none";else if("none"==e.style.display){e.style.display="block";var i=function(){t.removeEventListener("mouseleave",i),e.style.display="none"};t.addEventListener("mouseleave",i)}else e.style.display="none"},createDownload:function(){var t=this,e=document.getElementById(this.videoPlayerId+"_fluid_control_download");t.displayOptions.layoutControls.allowDownload?(downloadClick=document.createElement("a"),downloadClick.id=this.videoPlayerId+"_download",downloadClick.onclick=function(e){var t=this;void 0!==e.stopImmediatePropagation&&e.stopImmediatePropagation(),setInterval(function(){t.download="",t.href=""},100)},e.appendChild(downloadClick),e.addEventListener("click",function(){var e=document.getElementById(t.videoPlayerId+"_download");e.download=t.originalSrc,e.href=t.originalSrc,downloadClick.click()})):e.style.display="none"},theatreToggle:function(){if(!this.isInIframe){if(this.fullscreenMode&&this.fullscreenToggle(),this.displayOptions.layoutControls.theatreAdvanced){var e=document.getElementById(this.displayOptions.layoutControls.theatreAdvanced.theatreElement),t=this.displayOptions.layoutControls.theatreAdvanced.classToApply;null!=e&&null!=t?(this.theatreMode?e.classList.remove(t):e.classList.add(t),this.theatreModeAdvanced=!this.theatreModeAdvanced):(console.log("[FP_ERROR] Theatre mode elements could not be found, defaulting behaviour."),this.defaultTheatre())}else this.defaultTheatre();this.theatreMode=!this.theatreMode,this.fluidStorage.fluidTheatre=this.theatreMode;var i=document.getElementById(this.videoPlayerId),n=this.theatreMode?"theatreModeOn":"theatreModeOff",o=document.createEvent("CustomEvent");o.initEvent(n,!1,!0),i.dispatchEvent(o)}},defaultTheatre:function(){var e=document.getElementById("fluid_video_wrapper_"+this.videoPlayerId);if(this.theatreMode)e.classList.remove("fluid_theatre_mode"),e.style.maxHeight="",e.style.marginTop="",e.style.left="",e.style.right="",e.style.position="",this.displayOptions.layoutControls.fillToContainer?(e.style.width="100%",e.style.height="100%"):(e.style.width=this.originalWidth+"px",e.style.height=this.originalHeight+"px");else{e.classList.add("fluid_theatre_mode");var t=this.displayOptions.layoutControls.theatreSettings.width,i="10px";switch(e.style.width=t,e.style.height=this.displayOptions.layoutControls.theatreSettings.height,e.style.maxHeight=screen.height+"px",e.style.marginTop=this.displayOptions.layoutControls.theatreSettings.marginTop+"px",this.displayOptions.layoutControls.theatreSettings.horizontalAlign){case"center":"string"==typeof t&&"%"==t.substr(t.length-1)?i=(100-parseInt(t.substring(0,t.length-1)))/2+"%":"string"==typeof t&&"px"==t.substr(t.length-2)?i=(screen.width-parseInt(t.substring(0,t.length-2)))/screen.width*100/2+"%":console.log("[FP_ERROR] Theatre width specified invalid."),e.style.left=i;break;case"right":e.style.right=i;break;case"left":default:e.style.left=i}}},posterImage:function(){if(this.displayOptions.layoutControls.posterImage){var e=document.createElement("div");e.id=this.videoPlayerId+"_fluid_pseudo_poster",e.className="fluid_pseudo_poster",e.style.background="url('"+this.displayOptions.layoutControls.posterImage+"') center center / contain no-repeat black",document.getElementById(this.videoPlayerId).parentNode.insertBefore(e,null)}},initialiseStreamers:function(){switch(this.detachStreamers(),this.displayOptions.layoutControls.mediaType){case"application/dash+xml":this.dashScriptLoaded?this.initialiseDash():(this.dashScriptLoaded=!0,fluidPlayerClass.requestScript("https://cdn.dashjs.org/latest/dash.mediaplayer.min.js",this.initialiseDash.bind(this)));break;case"application/x-mpegURL":this.hlsScriptLoaded||window.Hls?this.initialiseHls():(this.hlsScriptLoaded=!0,fluidPlayerClass.requestScript("https://cdn.jsdelivr.net/npm/hls.js@latest",this.initialiseHls.bind(this)))}},initialiseDash:function(){if("function"==typeof(window.MediaSource||window.WebKitMediaSource)){var e=this.autoplayAfterAd?this.displayOptions.layoutControls.autoPlay:this.autoplayAfterAd,t=dashjs.MediaPlayer().create();t.getDebug().setLogToBrowserConsole(!1),t.initialize(document.getElementById(this.videoPlayerId),this.originalSrc,e),this.dashPlayer=t}else this.nextSource(),console.log("[FP_ERROR] Media type not supported by this browser. (application/dash+xml)")},initialiseHls:function(){if(Hls.isSupported()){var e=new Hls(this.displayOptions.hlsjsConfig);e.attachMedia(document.getElementById(this.videoPlayerId)),e.loadSource(this.originalSrc),this.hlsPlayer=e,!this.firstPlayLaunched&&this.displayOptions.layoutControls.autoPlay&&document.getElementById(this.videoPlayerId).play()}else this.nextSource(),console.log("[FP_ERROR] Media type not supported by this browser. (application/x-mpegURL)")},detachStreamers:function(){this.dashPlayer?(this.dashPlayer.reset(),this.dashPlayer=!1):this.hlsPlayer&&(this.hlsPlayer.detachMedia(),this.hlsPlayer=!1)},nextSource:function(){var e=document.getElementById(this.videoPlayerId).getElementsByTagName("source");if(e.length)for(var t=0;t<e.length-1;t++)if(e[t].getAttribute("src")==this.originalSrc&&e[t+1].getAttribute("src"))return void this.setVideoSource(e[t+1].getAttribute("src"));return null},inIframe:function(){try{return window.self!==window.top}catch(e){return!0}},setPersistentSettings:function(){if("undefined"!=typeof Storage&&"undefined"!=typeof localStorage){if(this.fluidStorage=localStorage,void 0!==this.fluidStorage.fluidVolume&&this.displayOptions.layoutControls.persistentSettings.volume&&(this.setVolume(this.fluidStorage.fluidVolume),void 0!==this.fluidStorage.fluidMute&&"true"==this.fluidStorage.fluidMute&&this.muteToggle(this.videoPlayerId)),void 0!==this.fluidStorage.fluidQuality&&this.displayOptions.layoutControls.persistentSettings.quality){var e=document.getElementById("source_"+this.videoPlayerId+"_"+this.fluidStorage.fluidQuality),t=document.getElementById(this.videoPlayerId+"_fluid_control_video_source");e&&(e.click(),t.click())}void 0!==this.fluidStorage.fluidSpeed&&this.displayOptions.layoutControls.persistentSettings.speed&&this.setPlaybackSpeed(this.fluidStorage.fluidSpeed),void 0!==this.fluidStorage.fluidTheatre&&"true"==this.fluidStorage.fluidTheatre&&this.displayOptions.layoutControls.persistentSettings.theatre&&this.theatreToggle()}},init:function(e,t){var i=this,n=document.getElementById(e);for(var o in n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline",""),i.vastOptions={tracking:[],stopTracking:[]},i.videoPlayerId=e,i.originalSrc=i.getCurrentSrc(),i.isCurrentlyPlayingAd=!1,i.recentWaiting=!1,i.latestVolume=1,i.currentVideoDuration=0,i.firstPlayLaunched=!1,i.suppressClickthrough=!1,i.timelinePreviewData=[],i.mainVideoCurrentTime=0,i.mainVideoDuration=0,i.isTimer=!1,i.timer=null,i.timerPool={},i.adList={},i.adPool={},i.availableRolls=["preRoll","midRoll","postRoll","onPauseRoll"],i.supportedNonLinearAd=["300x250","468x60","728x90"],i.autoplayAfterAd=!0,i.nonLinearDuration=15,i.supportedStaticTypes=["image/gif","image/jpeg","image/png"],i.inactivityTimeout=null,i.isUserActive=null,i.nonLinearVerticalAlign="bottom",i.showTimeOnHover=!0,i.initialAnimationSet=!0,i.theatreMode=!1,i.theatreModeAdvanced=!1,i.fullscreenMode=!1,i.originalWidth=n.offsetWidth,i.originalHeight=n.offsetHeight,i.dashPlayer=!1,i.hlsPlayer=!1,i.dashScriptLoaded=!1,i.hlsScriptLoaded=!1,i.isPlayingMedia=!1,i.isSwitchingSource=!1,i.isLoading=!1,i.isInIframe=i.inIframe(),i.mainVideoReadyState=!1,i.xmlCollection=[],i.inLineFound=null,i.fluidStorage={},i.fluidPseudoPause=!1,i.mobileInfo=fluidPlayerClass.getMobileOs(),i.displayOptions={layoutControls:{mediaType:i.getCurrentSrcType(),primaryColor:!1,posterImage:!1,adProgressColor:"#f9d300",playButtonShowing:!0,playPauseAnimation:!0,closeButtonCaption:"Close",fillToContainer:!1,autoPlay:!1,mute:!1,loop:null,keyboardControl:!0,allowDownload:!1,playbackRateEnabled:!1,allowTheatre:!0,theatreSettings:{width:"100%",height:"60%",marginTop:0,horizontalAlign:"center",keepPosition:!1},theatreAdvanced:!1,logo:{imageUrl:null,position:"top left",clickUrl:null,opacity:1,mouseOverImageUrl:null,imageMargin:"2px",hideWithControls:!1,showOverAds:!1},controlBar:{autoHide:!1,autoHideTimeout:3,animated:!0},timelinePreview:{spriteImage:!1,spriteRelativePath:!1},htmlOnPauseBlock:{html:null,height:null,width:null},layout:"default",playerInitCallback:function(){},persistentSettings:{volume:!0,quality:!0,speed:!0,theatre:!0}},vastOptions:{adList:{},skipButtonCaption:"Skip ad in [seconds]",skipButtonClickCaption:'Skip Ad <span class="skip_button_icon"></span>',adText:null,adTextPosition:"top left",adCTAText:"Visit now!",adCTATextPosition:"bottom right",adClickable:!0,vastTimeout:5e3,showProgressbarMarkers:!1,maxAllowedVastTagRedirects:3,vastAdvanced:{vastLoadedCallback:function(){},noVastVideoCallback:function(){},vastVideoSkippedCallback:function(){},vastVideoEndedCallback:function(){}}},hlsjsConfig:{p2pConfig:{logLevel:!1}}},t)if("object"==typeof t[o])for(var a in t[o])i.displayOptions[o][a]=t[o][a];else i.displayOptions[o]=t[o];i.setupPlayerWrapper(),i.initialiseStreamers(),n.addEventListener("webkitfullscreenchange",i.recalculateAdDimensions,!1),n.addEventListener("fullscreenchange",i.recalculateAdDimensions,!1),n.addEventListener("waiting",i.onRecentWaiting,!1),n.addEventListener("pause",i.onFluidPlayerPause,!1),n.addEventListener("loadedmetadata",i.mainVideoReady,!1),n.addEventListener("durationchange",function(){i.currentVideoDuration=i.getCurrentVideoDuration()},!1),n.addEventListener("error",i.onErrorDetection,!1),n.addEventListener("ended",i.onMainVideoEnded,!1),i.currentVideoDuration=i.getCurrentVideoDuration(),isNaN(i.currentVideoDuration)&&(i.currentVideoDuration=0),i.setLayout(),i.latestVolume=n.volume,i.initialAnimationSet=i.displayOptions.layoutControls.playPauseAnimation,i.handleFullscreen(),i.initLogo(),i.initMute(),i.initLoop(),i.displayOptions.layoutControls.playerInitCallback(),i.createVideoSourceSwitch(),i.userActivityChecker(),i.setVastList(),i.setPersistentSettings();var l=n.play;n.play=function(){var e=null,t=fluidPlayerClass.getInstanceById(this.id);try{null!=(e=l.apply(this,arguments))&&(e.then(function(){t.isPlayingMedia=!0,clearTimeout(t.promiseTimeout)}).catch(function(e){void 0!==e.name&&"AbortError"===e.name||t.announceLocalError(202,"Failed to play video."),clearTimeout(t.promiseTimeout)}),t.promiseTimeout=setTimeout(function(){!1===t.isPlayingMedia&&t.announceLocalError(204,"Timeout error. Failed to play video.")},5e3))}catch(e){t.announceLocalError(201,"Failed to play video.")}};var r=n.pause;if(n.pause=function(){var t=fluidPlayerClass.getInstanceById(this.id);if(!0===t.isPlayingMedia)return t.isPlayingMedia=!1,r.apply(this,arguments);if(t.isCurrentlyPlayingVideo(this))try{return t.isPlayingMedia=!1,r.apply(this,arguments)}catch(e){t.announceLocalError(203,"Failed to play video.")}},i.displayOptions.layoutControls.autoPlay&&!i.dashScriptLoaded&&!i.hlsScriptLoaded){var s=fluidPlayerClass.getBrowserVersion();if("Safari"==s.browserName&&11<=s.majorVersion)return;n.play()}var d=document.getElementById("fluid_video_wrapper_"+n.id);i.mobileInfo.userOs?(i.hideControlBar.call(d),d.addEventListener("touchstart",i.showControlBar,!1)):(d.addEventListener("mouseleave",i.handleMouseleave,!1),d.addEventListener("mouseenter",i.showControlBar,!1)),i.displayOptions.layoutControls.keyboardControl&&i.keyboardControl(),i.displayOptions.layoutControls.controlBar.autoHide&&i.linkControlBarUserActivity()},play:function(){var e=document.getElementById(this.videoPlayerId);return e.paused&&this.playPauseToggle(e),!0},pause:function(){var e=document.getElementById(this.videoPlayerId);return e.paused||this.playPauseToggle(e),!0},skipTo:function(e){document.getElementById(this.videoPlayerId).currentTime=e},setPlaybackSpeed:function(e){this.isCurrentlyPlayingAd||(document.getElementById(this.videoPlayerId).playbackRate=e,this.fluidStorage.fluidSpeed=e)},setVolume:function(e){document.getElementById(this.videoPlayerId).volume=e,this.latestVolume=e,this.fluidStorage.fluidVolume=e},isCurrentlyPlayingVideo:function(e){return e&&0<e.currentTime&&!e.paused&&!e.ended&&2<e.readyState},setHtmlOnPauseBlock:function(e){if("object"!=typeof e||void 0===e.html)return!1;var t=document.getElementById(this.videoPlayerId+"_fluid_html_on_pause");if(t)t.innerHTML=e.html,e.width&&(t.style.width=e.width+"px"),e.height&&(t.style.height=e.height+"px");else{var i=document.getElementById(player.videoPlayerId),n=document.createElement("div");n.id=player.videoPlayerId+"_fluid_html_on_pause",n.className="fluid_html_on_pause",n.style.display="none",n.innerHTML=e.html,n.onclick=function(){player.playPauseToggle(i)},e.width&&(n.style.width=e.width+"px"),e.height&&(n.style.height=e.height+"px"),i.parentNode.insertBefore(n,null)}},toggleControlBar:function(e){var t=document.getElementById(this.videoPlayerId+"_fluid_controls_container");e?t.className+=" initial_controls_show":t.className=t.className.replace(" initial_controls_show","")},toggleFullscreen:function(e){this.fullscreenMode!=e&&(e&&this.theatreMode&&this.theatreToggle(),this.fullscreenToggle())},on:function(e,t){var i=document.getElementById(this.videoPlayerId),n=this;switch(e){case"play":i.onplay=t;break;case"pause":i.addEventListener("pause",function(){n.fluidPseudoPause||t()});break;case"theatreModeOn":i.addEventListener("theatreModeOn",function(){t()});break;case"theatreModeOff":i.addEventListener("theatreModeOff",function(){t()});break;default:console.log("[FP_ERROR] Event not recognised")}},toggleLogo:function(e){if("object"!=typeof e||!e.imageUrl)return!1;var t=document.getElementById(this.videoPlayerId+"_logo");this.displayOptions.layoutControls.logo.imageUrl=e.imageUrl?e.imageUrl:null,this.displayOptions.layoutControls.logo.position=e.position?e.position:"top left",this.displayOptions.layoutControls.logo.clickUrl=e.clickUrl?e.clickUrl:null,this.displayOptions.layoutControls.logo.opacity=e.opacity?e.opacity:1,this.displayOptions.layoutControls.logo.mouseOverImageUrl=e.mouseOverImageUrl?e.mouseOverImageUrl:null,this.displayOptions.layoutControls.logo.imageMargin=e.imageMargin?e.imageMargin:"2px",this.displayOptions.layoutControls.logo.hideWithControls=!!e.hideWithControls&&e.hideWithControls,this.displayOptions.layoutControls.logo.showOverAds=!!e.showOverAds&&e.showOverAds,t&&t.remove(),this.initLogo()}};