question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Has anyone successfully get VPAID to work?

See original GitHub issue

I am working on making my video player to support VPAID. This is the VPAID tag XML I’m working on https://ads.stickyadstv.com/vast/vpaid-adapter/5590338

This is what I got so far. I have no idea how do it initiates the ad by calling initAd() as mentioned in IAB VPAID document thus nothing is happening to my video player.

url is the javascript link i extracted from the XML

// Initialise the vastTracker with selected ad & creative
var vastTracker = new DMVAST.tracker(ad, creative)

// Loading the vpaid script
iframe = document.createElement('iframe');
iframe.id = "adloaderframe";
document.body.appendChild(iframe);
// ‘url’ points to the ad js file
iframe.contentWindow.document.write('<script src="' + url + '"></scr' + 'ipt>');
var fn = iframe.contentWindow['getVPAIDAd'];
if (fn && typeof fn == 'function') {
    VPAIDCreative = fn();
    VPAIDCreative.initAd(); // this gives javascript error
}

Any clue? What should I do next?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ghostcommented, Dec 29, 2018

Ok it was actually pretty simple, I’m just going to leave it here too in case anyone else needs it! You need to make sure that the script tag inside the iframe is fully loaded, before you can access the “getVPAIDAd” function!

so something like this:

iframe.contentWindow.document.write('<script id="adloaderscript" src="' + url + '"></scr' + 'ipt>');

const script = iframe.contentWindow.document.querySelector('#adloaderscript')

script.onload = function() {
     // iframe.contentWindow['getVPAIDAd'] will be available here
}
0reactions
ghostcommented, Dec 29, 2018

following the same flow

iframe = document.createElement('iframe');
iframe.id = "adloaderframe";
document.body.appendChild(iframe);
// ‘url’ points to the ad js file
iframe.contentWindow.document.write('<script src="' + url + '"></scr' + 'ipt>');
var fn = iframe.contentWindow['getVPAIDAd'];

the “getVPAIDAd” function does exist inside the iframe, but iframe.contentWindow['getVPAIDAd'] returns “undefined” for me!

@briganti or anyone else have any idea why?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How this 24-year-old makes $8600 per month in passive ...
This 24-year-old lost her waitressing job. Now she makes $8,600 per month in passive income: 'I work just 2 hours a day' ·...
Read more >
Stop Expecting to Get Paid for Your Time
Being successful doesn't just mean getting lucky; it means that you made an active decision to not let your time be wasted and...
Read more >
9 Out of 10 People Are Willing to Earn Less Money to Do ...
New research on the meaning of work shows that more than 9 out of 10 employees are willing to trade a percentage of...
Read more >
25 Ways to Make Money Online and Offline - NerdWallet
Making money online is the sweet spot people look for in the gig economy ... How fast you'll get paid: You get paid...
Read more >
Ways To Ensure You Get Paid by Customers and Clients
A credit report will help you see whether this customer or client is someone who has paid back money on time and in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found