I’ve managed to incorporate the HTML5 version of Google IMA ads and am trying to hook in with MediaElement’s fla project file.
IMA uses a Flash Component which can be easily added to stage and configured. Is there any way to use this with MediaElements.JS without resorting to using the Google IMA Flash SDK?
UPDATE:
Currently I’ve been following directions from Google’s IMA site on incorporating their swc component into media players.
Ideally I would like to simply pass a few variables from a JavaScript function to set, trigger, stop and remove video ads.
Well since no one knows or is willing to answer,..
According to MediaElement.JS‘s website, there will soon be a tutorial on postrolls. Whenever that hits (or if I get to working on this ActionScript before then) I will post a preroll version here.
UPDATE:
Eventually we just figured it out. There are a few things which need to be added to Media Element, especially in the
FlashMediaElement.asfile.First step is to download and install the Google IMA ActionScript 3 component.
Next open
FlashMediaElement.flaandFlashMediaElement.asin MediaElement’s \src\flash\ folder.In the .FLA file, you need to add the Google IMA component to the stage, then configure the preroll tag to any url. This simply makes that field available in the .as scope.
Finally begin to integrate Google IMA by adding the following properties to the FlashMediaElement class in the .AS file:
Next up go to the constructor,
public function FlashMediaElement() {and set the values for episodeData. There are a number of ways you may want to fill these dynamically. This example is using simple flashvars added on where you see mediaelement.swf in your HTML or JS use mediaelement.swf?title=YourTitle and so on.At the end of the constructor all you have to do is call
addEventListener(Event.ADDED_TO_STAGE, initialize);Finally the last step is to place the following functions from the Google IMA Example into the end of your FlashMediaElement class.
textAreaLogger refers to a dynamic text field in the Google example. To vary slightly from Google’s code, you can change
textAreaLoggerto_output(and set debug=true in the constructor sometimes) if you want to use MediaElement’s built in debug text window.There you go; Google IMA prerolls and postrolls.