Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

jwplayer.js onComplete not fired when no ad delivered. workaround?

2 replies [Last post]
Reply

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

Reply

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

Reply

Thank you Paul. I never knew those callbacks existed. Very helpful! I have it working

function onAdSchedulingComplete(ads) {
if( ads.length <= 0 ) {
$('.overlay').fadeOut();
jwplayer('player').play();
}
}

Then I call those 2 lines again for the onComplete:

events: {
onComplete: function(event) {               
$('.overlay').hide();
jwplayer('player').play();
}
},

This way, the ad overlay is hidden if no ads exist, and if they do exist the overlay is hidden once playback is complete.

Cheers

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • You may post code using <code>...</code> .
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options