This example illustrates the javascript callback API for Ad related events. Events are fired by the Open Ad Streamer when a linear ad starts, reaches the first quartile, midpoint, 3rd quartile and on completion. Events are also fired when non-linear ads are shown, hidden, companions shown and hidden, and the ad notice shown and hidden. Finally events are fired when an ad is clicked.
To start receiving these events, the "canFireAPICalls" config property must be set to "true". It is "true" by default.
In this example, a series of DIVs are displayed around the player. As each event fires, the corresponding DIV is turned green. If you have Firebug installed, bring up the console. Debug output is shown as each event fires so you can see the javascript callback event occur.
The configuration for this example is:
// An example ad event Javascript callback
function onLinearAdStart(ad) {
console.log("OVA CALLBACK EVENT: linear ad begin");
console.log(ad);
document.getElementById('linear-ad-start').style.backgroundColor = "#00CC00";
}
//... the other callback functions go in here
"" is defined as:
<config>
<ova.title>
Example 01 - Process Ad Events with Javascript
</ova.title>
<ova.json>
{
"canFireAPICalls": true,
"ads": {
"controls": {
"skipAd": {
"enabled": true
}
},
"servers": [
{
"type": "OpenX",
"apiAddress": "OVA_OPENX_API"
}
],
"schedule": [
{
"zone": "5",
"position": "pre-roll"
},
{
"zone": "33",
"width": 450,
"height": 50,
"startTime": "00:00:05",
"duration": "15"
}
]
},
"debug": {
"debugger": "firebug",
"levels": "OVA_DEBUG"
}
}
</ova.json>
</config>