var cssId = 'HDPlayerCSS'; // you could encode the css path itself to generate id.. if (!document.getElementById(cssId)) { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.id = cssId; link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'https://www.xfreehd.com/media/fluid/master/fluidplayer.min.css'; link.media = 'all'; head.appendChild(link); } var xhdPlayer = document.getElementById('hdPlayer'); var hdPlayerImg = xhdPlayer.getAttribute('data-img'); var hdPlayerVtt = xhdPlayer.getAttribute('data-vtt'); var hdPlayerThumbs = xhdPlayer.getAttribute('data-thumbs'); var hdPlayerLogo = xhdPlayer.getAttribute('data-logo'); var hdPlayerTarget = xhdPlayer.getAttribute('data-target'); hdPlayer(hdPlayerImg,hdPlayerVtt,hdPlayerThumbs,hdPlayerLogo,hdPlayerTarget); function hdPlayer($mainImg,$vtt,$thumbs,$ads){ fluidPlayer('hdPlayer',{ layoutControls: { persistentSettings: { volume: true, quality: true, speed: true, theatre: true }, posterImage: $mainImg, logo: { imageUrl: hdPlayerLogo, position: 'top right', clickUrl: hdPlayerTarget, opacity: 1 }, primaryColor: "#28B8ED", playButtonShowing: true, playPauseAnimation: true, fillToContainer: true, autoPlay: false, mute: false, keyboardControl: true, layout: 'default', allowDownload: false, playbackRateEnabled: true, allowTheatre: false, controlBar: { autoHide: true, autoHideTimeout: 4, animated: true }, timelinePreview: { file: $vtt, sprite: $thumbs, type: 'VTT' }, htmlOnPauseBlock: { html: null, height: null, width: null }, }, vastOptions: { skipButtonCaption: 'Skip ad in [seconds]', skipButtonClickCaption: 'Skip ad ', adText: null, adTextPosition: 'top left', adCTAText: null, adCTATextPosition: 'bottom right', vastTimeout: 5000, maxAllowedVastTagRedirects: 1, showProgressbarMarkers: true, adClickable: true, "adList": [ { "vAlign" : "middle", "roll" : "onPauseRoll", "vastTag" : "//s.magsrv.com/splash.php?idzone=3353508", "timer" : "10" }, { "vAlign" : "top", "roll" : "midRoll", "vastTag" : "//s.magsrv.com/splash.php?idzone=4500026&tags=brunette,outdoor,amateur,oral,sex,car,cumshot,fingering", "timer" : "600" }, { "vAlign" : "top", "roll" : "preRoll", "vastTag" : "//s.magsrv.com/splash.php?idzone=3349088&tags=brunette,outdoor,amateur,oral,sex,car,cumshot,fingering", "timer" : "0" }, ] } } ).on('pause', function(){ adsFix(); }); } window.addEventListener('resize', function(event){ adsFix(); }); function adsFix(){ var mainH = document.getElementById('fluid_video_wrapper_hdPlayer').clientHeight; var mainW = document.getElementById('fluid_video_wrapper_hdPlayer').clientWidth; var adsH = mainH*0.7; var adsW = adsH*0.83; if(adsW*1.2>mainW){ adsH = mainW*0.7; adsW = adsH*0.83; } if(mainH>600 & mainW>600) { adsH = 300; adsW = 250; } var eXoImg = document.getElementById('fluid_nonLinear_ID0'); if(eXoImg!=null) { eXoImg.style.width = adsH+"px"; eXoImg.style.height = adsW+"px"; eXoImg.childNodes[0].style.width = '100%'; eXoImg.childNodes[0].style.height = '100%'; } var eXoImg = document.getElementById('fluid_nonLinear_ID1'); if(eXoImg!=null) { eXoImg.style.width = adsH+"px"; eXoImg.style.height = adsW+"px"; eXoImg.childNodes[0].style.width = '100%'; eXoImg.childNodes[0].style.height = '100%'; } }