Skip to content

Instantly share code, notes, and snippets.

@yllus
Last active July 5, 2019 15:59
Show Gist options
  • Save yllus/3a84c3172d7e0662e4c2b9d8a7bc6c87 to your computer and use it in GitHub Desktop.
Save yllus/3a84c3172d7e0662e4c2b9d8a7bc6c87 to your computer and use it in GitHub Desktop.
// Took this JavaScript code from:
// https://ticats.ca/video/thomas-erlington-goes-75-yards-to-the-house
// Added some comments (look for COMMENT:) on what may need to be modified for the preroll ads to show successfully.
<script type="text/javascript">
function vastFromTags( tags, channels ) {
if ( tags ) {
var keywords = '&Tags=' + tags;
}
channels = channels.replace(/-/g, " ")
channels = channels.replace(/_/g, " ")
var ad_timecode = Date.now();
var ad_sitecode = '/103711331/Ticats_BigBox'; // COMMENT: Should be: /103711331/Ticats_Video
keywords += '&lang=eng'; // COMMENT: Probably remove this
if ( channels ) keywords += '&Channel=' + channels; // COMMENT: Probably remove this
// COMMENT: Should be more like: https://pubads.g.doubleclick.net/gampad/ads?iu=/103711331/Ticats_Video&description_url=[placeholder]&env=vp&impl=s&correlator=&tfcd=0&npa=0&gdfp_req=1&output=vast&sz=1280x720&unviewed_position_start=1
var ad_vasttag = 'http://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=' + ad_sitecode +
'&impl=s&gdfp_req=1&vpos=preroll&env=vp&output=xml_vast2&unviewed_position_start=1&ciu_szs=728x90,300x250' +
'&cust_params=' + encodeURIComponent(keywords) +
'&url=' + encodeURIComponent( window.location ) + '&correlator=' + ad_timecode ;
try {
console.log("VAST: " + ad_vasttag);
} catch (error) {
// ie
}
return ad_vasttag;
}
jQuery(document).ready( function() {
jwplayer("video_d709991b65fe").setup({
width : "100%",
height : "100%",
loadAtInit : true,
autostart : true,
mute : false,
aspectratio : "16:9",
primary : "html5",
stretching : "uniform",
advertising: {
client: "vast",
tag: vastFromTags('', ''),
},
image : "https:\/\/s3.amazonaws.com\/assets-ticats\/app\/uploads\/ticats\/2019\/07\/04093229\/SeanThomasErlington_01-1.jpg",
sources : [{"label":"mp4_360p","file":"http:\/\/assets-ticats.s3.amazonaws.com\/videos\/2019\/07\/02\/SeanThomasErlington_mp4_360p.mp4","width":"360"},{"label":"mp4_720p","file":"http:\/\/assets-ticats.s3.amazonaws.com\/videos\/2019\/07\/02\/SeanThomasErlington_mp4_720p.mp4","width":"720","default":"true"}],
related: {
file: "/app/themes/base/templates/video-related.php?id=100971&video_channel=0",
onclick: "link",
oncomplete: "show",
autoplaytimer: 10 },
ga: {}
});
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment