I am displaying a video ad in an overlay with no other content. When ad completes, I hide the overlay by way of some jquery in the onComplete() callback in jwplayer.js API. This seems to works splendidly:
onComplete: function(event) {
console.log('complete');
$('.overlay').fadeOut();
}My problem: Using OpenX, I have scheduled the ad to display no more than 3 times per session (30 minutes). Now, when the page loads, the overlay stays forever because evidently, when the VAST xml is empty, the onComplete() callback never fires, and no error fires either.
Am I going about this all wrong?
I've tried onIdle, loading an empty playlist. Is there a setting in the ad config file to make jwplayer.js advance when it does not encounter an ad?
Cheers
Ah...
There is a different set of Javascript callbacks that will help.
See section 17 of the RC5 release note:
http://developer.longtailvideo.com/ova/wiki/OvaReleaseNote-0.5.0-RC5
The ones that will help are the ad scheduling callbacks:
onAdSchedulingStarted()onLinearAdScheduled(ad:Object)
onNonLinearAdScheduled(ad:Object)
onCompanionAdScheduled(divSpecification:Object, companionAd:Object, parentAd:Object)
onAdSchedulingComplete(ads:Array)
Basically you can use the onAdSchedulingComplete(ads) callback and check the length of the ads array. If it's 0, then there haven't been any ads scheduled.
Equally, the individual scheduling methods can be used to count the ads.
Here's an example that may help you...
http://static.openvideoads.org/qa/latest/ova.jwplayer.5x/examples/pages/javascript/example1.01.00.ht...
Look at the Javascript Console to see the callbacks in action in that example...
Paul