This is a message.

Scheduling Ads

Placing an ad is easy with the DFP plugin: set the adTagUrl and you are done. Good scheduling of ads is key to maximize your revenue while keeping an excellent user experience. You can create your own ad logic using our low-level events and advanced Javascript APIs.

In this section:

Predefined ad logic

The predefined ad logic will not make ad requests for you. However it will only allow a request to be made a specific times. Just define what kind of ads you want on your content and the plugin will select which request should be actually sent to the AdSense system.

Scheduling ads with clip config

The simplest way to schedule an ad is to add an ads array to your clip config:

clip: {
url: "http://pseudo01.hdddn.com/vod/demo.flowplayervod/flowplayer-700.flv",
scaling: "fit",
// .. as many parameter as you want here
ads: [{
// the "ads" array containing the ads for that clip
// we have only one ad here
time: 10, // make the ad appear after 10 secs
request: {
adTagUrl: "http://ad.doubleclick.net/pfadx/AngelaSite;"
+ "foo=prodtest;sz=728x90;dcmt=text/html"
}
}]
}

JavaScript

You can add as many ads as you want in the ads array. It's a good idea to respect the following guidelines:

  • Keep an aspect ratio of 4:3 or 16:9
  • Overlay ads shouldn't be smaller than 300x100 px
  • The player shouldn't be less than 200x200 px when playing an ad
  • The main clip's length must be longer than 30 seconds to show an overlay ad
  • The main clip's length must be longer than 1 minute to show a video ad

Scheduling ads with Javascript

When you need to dynamically allocate ads while your clip is playing, you can use the javascript APIs to schedule, unschedule, load or unload an ad. You can also use the low-level events to add your own tracking system or decide when to show an ad.

MethodReturnsDescription

loadAd(adRequest)

-

Load an ad immediately, without preloading. You must pass an ad object.

unloadAd()

-

Unload the current ad. This has no effect if no ad is currently shown. Please note it doesn't unschedule the ad.

scheduleAd(adRequest, time)

-

Schedule an ad at the specific play time. The adRequest is an ad object. The time parameter is an integer. Possible values are:

  • 0: preroll. This has no effect if the clip is alread playing.
  • 1: post roll.
  • any other value: mid roll. Will play exactly at that time. The ad is automatically preloaded.

unscheduleAd(time)

-

Unschedules the ad scheduled for the given time. It has no effect if no ad is scheduled at that time. Note that if the ad being unscheduled is currently playing, it will be unloaded as well.

getScheduledAds()

array

Returns an array of scheduled ads. For each scheduled ad the following 3 fields are returned:

  • time: The time when the ad is scheduled.
  • isActive: Tells if he ad is currently playing.
  • request: The Adsense ad request

clearScheduledAds*()

-

Clears all scheduled ads of the current clip.

Here's an example of Javascript ad scheduling. In this example, we schedule an overlay after 10 seconds when the clip starts. If the user seeks, we unschedule all the scheduled ads and we schedule another ad 10 seconds after the seek point.

flowplayer("javascript_schedule", "http://releases.flowplayer.org/swf/flowplayer-3.2.11.swf", {
clip: {
url: "http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv",
},
 
plugins: {
controls: {
url: "flowplayer.controls-3.2.11.swf",
autoHide: "never" // we don't want the controlbar to hide
},
 
dfp: {
url: "/media/swf/flowplayer.dfp-flowplayer.org-1.6.5-dev.swf"
}
},
onStart: function() {
// when the clip start, schedule an overlay at 10 seconds
$f().getPlugin('dfp').scheduleAd({
adTagUrl:
"http://ad.doubleclick.net/pfadx/AngelaSite;" +
"foo=prodtest;sz=728x90;dcmt=text/html"
}, 10);
},
 
onSeek: function() {
var dfp = $f().getPlugin('dfp');
dfp.clearScheduledAds();
 
dfp.scheduleAd({
adTagUrl:
"http://ad.doubleclick.net/pfadx/AngelaSite;" +
"foo=prodtest;sz=728x90;dcmt=text/html"
},
// on each seek, reschedule an ad in 10 secs
$f().getStatus().time + 10);
}
});

JavaScript


Creating your own ad logic

Thanks to the low-level events and the Javascript, you can define the ads on your clip and leave the ad logic to the Javascript.

var i = 0;
function shouldDisplayAd() {
// only allow an ad every 2 play. Change this to your implementation
return ++i%2;
}
flowplayer("events", "http://releases.flowplayer.org/swf/flowplayer-3.2.11.swf", {
clip: {
url: "http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv",
ads: [{ // our ad is always scheduled
time: 0,
request: {
adTagUrl:
"http://ad.doubleclick.net/pfadx/AngelaSite;" +
"foo=prodtest;sz=728x90;dcmt=text/html"
}
}]
},
 
plugins: {
controls: {
url: "flowplayer.controls-3.2.11.swf",
autoHide: "never" // we don't want the controlbar to hide
},
 
dfp: {
url: "/media/swf/flowplayer.dfp-flowplayer.org-1.6.5-dev.swf",
onBeforeAdLoad: function(event) {
// this is your custom function
if ( ! shouldDisplayAd() )
// cancel the schedule of the ad
return false;
},
onAdStarted: function(event) {
document.getElementById("alert").innerHTML = "The advert just started!";
}
}
}
});

JavaScript
Search engine friendly content
This area will be updated once the advert starts