Skip to content

Instantly share code, notes, and snippets.

@brandonaaskov
Created March 2, 2013 15:18
Show Gist options
  • Save brandonaaskov/5071497 to your computer and use it in GitHub Desktop.
Save brandonaaskov/5071497 to your computer and use it in GitHub Desktop.
Shows a basic example of working with Doubleclick and Brightcove's iOS javascript APIs.
var _adPolicyCreated = false;
var setupVideoAdPolicy = function () {
var advertising = bc.plugins.videoPlayer.advertising,
adServerURL = 'http://ad.doubleclick.net/pfadx/site/zone', //the URL for your ad server (likely will contain dymanic key-value pairs)
adPolicy = {
preRolls: [adServerURL]
},
options = {
adPolicy: adPolicy,
adProvider: advertising.providers.GOOGLE
},
successCallback = function (event) {},
errorCallback = function (error) {
alert('createAdController() error callback: ' + error.errorCode + ' || ' + error.errorMessage);
};
if (_adPolicyCreated) //we don't want to create another ad controller if we already have one
{
options.adPolicy.preRolls = [adServerURL];
advertising.updateAdPolicy(function () {
//bc.device.alert('ad policy updated');
}, function () {
//bc.device.alert('error updating ad policy');
}, options);
} else {
//bc.device.alert('createAdController()');
advertising.createAdController(successCallback, errorCallback, options);
_adPolicyCreated = true;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment