var div_1_sizes = [ [400, 225] ]; var PREBID_TIMEOUT = 1000; var FAILSAFE_TIMEOUT = 3000; var video; var adsManager; var intervalTimer; var code = 'div-vidoomy-ad'; var adUnits = [{ code: code, bids: [{ bidder: '33across', params: { siteId: 'bQRTd2kMCr65i2aKkGJozW', productId: 'outstream' } }], mediaTypes: { video: { playerSize: div_1_sizes, context: 'outstream', mimes: ["video/mp4"], maxduration: 30, api: [1, 2], protocols: [2, 3, 4, 5, 6, 8] } }, renderer: { url: '//imasdk.googleapis.com/js/sdkloader/ima3.js', render: function(bid) { setTimeout(() => { render(bid); }, 100); function render(bid) { if (typeof(window['google']) !== 'undefined') { var div = document.createElement("div"); div.id = bid.adUnitCode; div.style.position = "absolute"; div.style.zIndex = "500000"; div.style.top = "0"; div.style.left = "0"; div.style.right = "0"; div.style.bottom = "0"; video = document.createElement("video"); video.style.position = "absolute"; video.style.zIndex = "500000"; video.style.top = "0"; video.style.left = "0"; video.style.right = "0"; video.style.bottom = "0"; video.muted = true; video.volume = 0; div.appendChild(video); window.vidoSlot.appendChild(div); var adDisplayContainer = new google.ima.AdDisplayContainer(div, video); var adsLoader = new google.ima.AdsLoader(adDisplayContainer); adsLoader .getSettings() .setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.INSECURE); adsLoader.addEventListener( google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, function(adsManagerLoadedEvent) { adDisplayContainer.initialize(); var adsRenderingSettings = new google.ima.AdsRenderingSettings(); adsManager = adsManagerLoadedEvent.getAdsManager(video, adsRenderingSettings); adsManager.addEventListener(google.ima.AdEvent.Type.LOADED, onAdEvent); adsManager.addEventListener(google.ima.AdEvent.Type.STARTED, onAdEvent); adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE, onAdEvent); adsManager.init(window.vidoSlot.clientWidth, window.vidoSlot.clientHeight, google.ima.ViewMode.NORMAL); adsManager.start(); }, false); adsLoader.addEventListener( google.ima.AdErrorEvent.Type.AD_ERROR, function() { console.log(arguments); }, false); // An event listener to tell the SDK that our content video // is completed so the SDK can play any post-roll ads. var contentEndedListener = function() { adsLoader.contentComplete(); }; video.onended = contentEndedListener; var adsRequest = new google.ima.AdsRequest(); adsRequest.setAdWillAutoPlay(true); adsRequest.setAdWillPlayMuted(true); adsRequest.adsResponse = bid.ad; // Specify the linear and nonlinear slot sizes. This helps the SDK to // select the correct creative if multiple are returned. adsRequest.linearAdSlotWidth = window.vidoSlot.clientWidth; adsRequest.linearAdSlotHeight = window.vidoSlot.clientHeight; adsLoader.requestAds(adsRequest); } else { setTimeout(() => { render(bid); }, 100); } } } }, consentManagement: { cmpApi: 'static', allowAuctionWithoutConsent: true, consentData: { getConsentData: { 'gdprApplies': true, 'hasGlobalScope': false, 'consentData': window.vidoGdprConsentData }, getVendorConsents: { 'metadata': window.vidoVendorConsents, } } } }, ] function searchForLkqdObject(objWindow, objtopWindow) { if (objWindow['lkqdSettings'] || objWindow == objtopWindow) { return objWindow['lkqdSettings']; } else { return searchForLkqdObject(objWindow.parent, objtopWindow); } } function getSchainObject() { // 1.0,1!vidoomy.com,60277,1, var lkqdSettings = searchForLkqdObject(window, top); var objReturned = { "validation": 'relaxed', } // primero buscamos en el custom3, donde está la cadena completa if (lkqdSettings["custom3"]) { var schainStr = lkqdSettings["custom3"]; var schainArr = schainStr.split("!"); var supplyChainObject = schainArr[0] var version = supplyChainObject.split(",")[0]; var complete = parseInt(supplyChainObject.split(",")[1]); objReturned["config"] = { "ver": version, "complete": complete, "nodes": [] } for (var i = 1; i < schainArr.length; i++) { var supplyChainNode = schainArr[i]; var supplyChainNodeArr = supplyChainNode.split(","); var node = { "asi": supplyChainNodeArr[0], "sid": supplyChainNodeArr[1], "hp": parseInt(supplyChainNodeArr[2]) } objReturned.config.nodes.push(node); } } else if (lkqdSettings["custom6"]) { // y si no en el custom6, que es el que tiene el sid únicamente objReturned["config"] = { "ver": "1.0", "complete": 1, "nodes": [{ "asi": "vidoomy.com", "sid": lkqdSettings["custom6"], "hp": 1 }] } } return objReturned; // custom6 } var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; pbjs.que.push(function() { pbjs.setConfig({ debug: true, schain: getSchainObject(), userSync: { iframeEnabled: true } }); pbjs.addAdUnits(adUnits); pbjs.requestBids({ bidsBackHandler: function(bids) { var highestCpmBids = pbjs.getHighestCpmBids(code); if (highestCpmBids && highestCpmBids[0] && highestCpmBids[0].adId) { pbjs.renderAd(document, highestCpmBids[0].adId); } else { window.vidoCallEvent("AdError"); } }, timeout: PREBID_TIMEOUT }); }); function onAdEvent(adEvent) { // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED) // don't have ad object associated. var ad = adEvent.getAd(); switch (adEvent.type) { case google.ima.AdEvent.Type.LOADED: // This is the first event sent for an ad - it is possible to // determine whether the ad is a video ad or an overlay. video.play(); break; case google.ima.AdEvent.Type.STARTED: // This event indicates the ad has started - the video player // can adjust the UI, for example display a pause button and // remaining time. if (ad.isLinear()) { // For a linear ad, a timer can be started to poll for // the remaining time. intervalTimer = setInterval( function() { var remainingTime = adsManager.getRemainingTime(); }, 300); // every 300ms } break; case google.ima.AdEvent.Type.COMPLETE: // This event indicates the ad has finished - the video player // can perform appropriate UI actions, such as removing the timer for // remaining time detection. if (ad.isLinear()) { clearInterval(intervalTimer); } break; } }