Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robwalch/171729c7204bdd606f85f6937e915413 to your computer and use it in GitHub Desktop.
Save robwalch/171729c7204bdd606f85f6937e915413 to your computer and use it in GitHub Desktop.
JW Player Google IMA (bad) waterfall setup, with player that is hidden/removed unless ad break begins
const correlator = Math.floor(Date.now() / 1000 / 60); // changes every 60s
jwplayer('jwplayer_1').setup({
file: 'https://cdn.jwplayer.com/manifests/LQQpmqYT.m3u8',
autostart: true,
advertising: {
preloadAds: true,
autoplayadsmuted: true,
client: 'googima',
tag: [
// This is not a valid URL. Expect an error.
'https://pubads.g.doubleclick.net' + correlator,
// Expect first ad tag to ________ (fill in the blank)
'https://pubads.g.doubleclick.net/gampad/live/ads?iu=/220249732/IT_PUBLY_RON/IT_PUBLY_RON_VAST&description_url=%5Bplaceholder%5D&tfcd=0&npa=0&sz=640x360&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=',
// Expect first ad tag to ________ (fill in the blank)
'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dredirecterror&correlator=',
// Expect first ad tag to ________ (fill in the blank)
'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator='
]
},
events: {
ready: function() {
this.getContainer().style.display = 'none';
},
adBreakStart: function() {
this.getContainer().style.display = 'block';
},
adError: function() {
this.remove();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment