{ let targetingString = "" if (targeting) { Object.keys(targeting).forEach((k) => { targetingString += `${k}=${targeting[k]}` }) } targetingString = encodeURIComponent(targetingString) let finalTag = 'https://pubads.g.doubleclick.net/gampad/live/ads?' finalTag += 'iu=' + adUnit + '&' finalTag += 'description_url=' + encodeURIComponent(window.location.href) + '&' finalTag += 'tfcd=0&' finalTag += 'npa=0&' finalTag += 'sz=640x480&' // all ad unit sizes must be 640x480 regardless of actual video size finalTag += 'cust_params=' + targetingString + '&' finalTag += 'max_ad_duration=30000&' // 30s. also has min_ad_duration probably finalTag += 'gdfp_req=1&' finalTag += 'output=vast&' finalTag += 'unviewed_position_start=1&' finalTag += 'env=vp&' finalTag += 'vpos=preroll&' // preroll|midroll|postroll finalTag += 'vpmute=0&' // don't mute finalTag += 'vpa=click&' finalTag += 'type=js&' finalTag += 'vad_type=linear&' // linear|nonlinear finalTag += 'correlator=' + Math.floor(Math.random() * 99999999) return finalTag } const setupAdsCallbacks = (player) => { player.ima.addEventListener(google.ima.AdEvent.Type.STARTED, function() { logFirebaseEvent('ad_begin_playing_preroll'); }); player.ima.addEventListener(google.ima.AdEvent.Type.FIRST_QUARTILE, function() { logFirebaseEvent('ad_complete_1st_quart_preroll'); }); player.ima.addEventListener(google.ima.AdEvent.Type.MIDPOINT, function() { logFirebaseEvent('ad_complete_2nd_quart_preroll'); }); player.ima.addEventListener(google.ima.AdEvent.Type.THIRD_QUARTILE, function() { logFirebaseEvent('ad_complete_3rd_quart_preroll'); }); player.ima.addEventListener(google.ima.AdEvent.Type.COMPLETE, function() { logFirebaseEvent('ad_complete_preroll'); }); player.ima.addEventListener(google.ima.AdEvent.Type.ALL_ADS_COMPLETED, function() { logFirebaseEvent('ad_complete_all_preroll'); }); }; // Start by defining/accessing the video player element, set up the IMA options, and player events if necessary const getVideoPlayer = (playerID, options = {}) => videojs(playerID, options); const setIMAOpt = ({ adUnitID, targeting, player }) => { const imaOptions = { adTagUrl: generatePrerollTag(adUnitID, targeting) } player.ima(imaOptions) } const setupPlayerEvents = (player) => { player.on('play', () => { logFirebaseEvent('player_played'); }) player.on('click', () => { logFirebaseEvent('player_clicked'); }) player.on('adsready', () => { logFirebaseEvent('ad_attempt_succeeded_preroll'); setupAdsCallbacks(player) }); // player.onplayerready = () => { // videojs.log('Your player is ready!'); // }; }; ]]>
Please click the “Report” button below if the video on this page is not working properly.
Thanks! Your cooperation in making Worldstar a better site is always appreciated.
Our team will now look into fixing this error.