Skip to content

Instantly share code, notes, and snippets.

@brandonaaskov
Created August 22, 2012 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonaaskov/3427079 to your computer and use it in GitHub Desktop.
Save brandonaaskov/3427079 to your computer and use it in GitHub Desktop.
Override DFP Click Through in HTML5 Players in App Cloud Application
/*
* This would live somewhere within the App Cloud application, wherever needed.
*/
//listen for post message from click-through override function
window.addEventListener('message', function (event){
var message = event.data;
if(message.name == 'adClick')
{
var success = function(event){
//fill this out as needed
};
var error = function(event){
//fill this out as needed
};
bc.device.openURI(message.clickThroughURL, success, error, {modalWebBrowser: true});
}
});
/*
* This should be saved as a standalone js file and needs to be hosted on public-facing URL.
* Then that URL can be added to the player as a plugin.
*/
(function(){
var _experience
, _videoPlayer;
player = brightcove.api.getExperience();
_experience = player.getModule(brightcove.api.modules.APIModules.EXPERIENCE);
_videoPlayer = player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
if(_experience.getReady())
{
initialize();
}
else
{
_experience.addEventListener(brightcove.api.events.ExperienceEvent.TEMPLATE_READY, initialize);
}
function initialize()
{
window.open = function (pClickThrough){
parent.postMessage({
name: 'adClick',
clickThroughURL: pClickThrough
}, '*');
};
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment