Created
August 22, 2012 16:08
-
-
Save brandonaaskov/3427079 to your computer and use it in GitHub Desktop.
Override DFP Click Through in HTML5 Players in App Cloud Application
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
/* | |
* 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 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
/* | |
* 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