Created
March 2, 2013 15:18
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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