luizcrf Posted August 4, 2019 Share Posted August 4, 2019 Hello, I've been trying to solve a problem for about 3 days and can't. I added the "adsense" preroll html5 to my online gaming site. It works correctly, and after clicking the "skip ad" button, the game appears correctly. You can check in this video: https://youtu.be/Az2TdBNL6bM The problem is that the "skip ad" button doesn't seem to work with non-countdown ads. You can check in this video: https://youtu.be/u2MwlhW8QaA I don't know why, but when this type of ad appears, preroll can't remove the ad, leaving a black screen in place of the game. What can I be doing wrong? <html> <head> <meta content='text/html; charset=utf-8' http-equiv='Content-Type' /> <meta content='IE=9' http-equiv='X-UA-Compatible' /> <title>Pizza Party</title> <link rel="stylesheet" type="text/css" media="all" href="/style.css" /> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script> </head> <body> <div id="flashok"> <h1 id="volta01h1" itemprop="name">Pizza Party</h1> </div> <div class="game-content"><div id="area"> <div id="filme"><div id="my_container"> <div id="game"> <iframe frameborder="0" id="game_src" scrolling="no" src="https://m.playdora.com/gamesource/pizza/index.html" width="800" height="600"></iframe> </div> </div> <!-- FIM: Jogo Swf --></div><div id="preload"></div> </div> </div> <div class="footer"> <script type="text/javascript"> function showcontent() { document.getElementById("preload").style.display = "none"; document.getElementById("game").style.display = "block"; } function removeAdSwf() { document.getElementById("preload").style.visibility = "hidden"; showcontent(); } function noAdsReturned() { showcontent(); } </script> <script type="text/javascript" src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script> <script> function init(){preLoad=document.getElementById("area"),requestAds()}function createAdDisplayContainer(){google.ima.settings.setVpaidAllowed(!0), adDisplayContainer=new google.ima.AdDisplayContainer(document.getElementById("preload"))}function requestAds(){createAdDisplayContainer(),adDisplayContainer.initialize(),adsLoader=new google.ima.AdsLoader(adDisplayContainer),adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,onAdsManagerLoaded,!1),adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,Finalizar,!0);{var e=new google.ima.AdsRequest;window.location.href}e.adTagUrl="https://googleads.g.doubleclick.net/pagead/ads?ad_type=video_image&client=ca-games-pub-6347577570466218&description_url=https%3A%2F%2Fmysite.com&videoad_start_delay=0&hl=pt&max_ad_duration=30000",e.linearAdSlotWidth=640,e.linearAdSlotHeight=480,e.nonLinearAdSlotWidth=400,e.nonLinearAdSlotHeight=300,adsLoader.requestAds(e)}function onAdsManagerLoaded(e){adsManager=e.getAdsManager(preLoad),adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,onAdError),adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,onContentPauseRequested),adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,onContentResumeRequested),adsManager.addEventListener(google.ima.AdEvent.Type.ALL_ADS_COMPLETED,onAdEvent),adsManager.addEventListener(google.ima.AdEvent.Type.LOADED,onAdEvent),adsManager.addEventListener(google.ima.AdEvent.Type.STARTED,onAdEvent),adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE,Finalizar),adsManager.addEventListener(google.ima.AdEvent.Type.USER_CLOSE,Finalizar),adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED,Finalizar);try{adsManager.init(640,480,google.ima.ViewMode.NORMAL),adsManager.start()}catch(a){Finalizar()}}function onAdEvent(e){var a=e.getAd();switch(e.type){case google.ima.AdEvent.Type.LOADED:a.isLinear()||(sec=15,i=setInterval(function(){--sec,0===sec&&(clearInterval(i),Finalizar())},1e3));break;case google.ima.AdEvent.Type.STARTED:a.isLinear()&&(intervalTimer=setInterval(function(){adsManager.getRemainingTime()},300));break;case google.ima.AdEvent.Type.COMPLETE:a.isLinear()&&clearInterval(intervalTimer)}}function onAdError(e){console.log(e.getError()),adsManager.destroy(),Finalizar()}function onContentPauseRequested(){}function onContentResumeRequested(){}function Finalizar(){removeAdSwf()}function adsenseAdComplete(){removeAdSwf()}function noAdsReturned(){removeAdSwf()}var adsManager,adsLoader,adDisplayContainer,intervalTimer,playButton,preLoad;countdownTimer=setInterval(function(){adsManager.getRemainingTime()},1e3),init(); </script> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
inyourpc Posted August 6, 2019 Share Posted August 6, 2019 Can I get working code for working pre-roll ad? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.