谷歌 IMA + MediaElementJS
我已成功合并 HTML5 版本的 Google IMA 广告,并尝试与 MediaElement 的 fla 项目文件挂钩。
IMA 使用 Flash 组件,可以轻松添加到舞台并进行配置。有没有办法将其与 MediaElements.JS 一起使用,而无需使用 Google IMA Flash SDK?
更新:
目前,我一直按照 Google 的 IMA 网站 将其 SWC 组件合并到媒体播放器中。
理想情况下,我想简单地从 JavaScript 函数传递一些变量来设置、触发、停止和删除视频广告。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,既然没有人知道或愿意回答,..
根据 MediaElement.JS 的网站,将会有很快就会有关于后贴片的教程。每当出现这种情况时(或者如果我在此之前开始处理此 ActionScript),我都会在此处发布预卷版本。
更新:
最终我们找到了答案。有一些内容需要添加到媒体元素中,特别是在
FlashMediaElement.as
文件中。第一步是下载并安装 Google IMA ActionScript 3 组件。
接下来打开 MediaElement 的 \src\flash\ 文件夹中的
FlashMediaElement.fla
和FlashMediaElement.as
。在 .FLA 文件中,您需要将 Google IMA 组件添加到舞台,然后将 preroll 标签配置到任意 url。这只是使该字段在 .as 范围内可用。
最后,通过将以下属性添加到 .AS 文件中的 FlashMediaElement 类,开始集成 Google IMA:
接下来转到构造函数
public function FlashMediaElement() {
并设置 EpisodeData 的值。您可能希望通过多种方式动态填充这些内容。此示例使用简单的 flashvars 添加到您在 HTML 或 JS 中看到 mediaelement.swf 的位置,使用 mediaelement.swf?title=YourTitle 等。在构造函数的末尾,您所要做的就是调用
addEventListener(Event.ADDED_TO_STAGE,initialize);
最后一步是将 Google IMA 示例中的以下函数放入 FlashMediaElement 的末尾班级。
textAreaLogger 指的是 Google 示例中的动态文本字段。为了与 Google 的代码稍有不同,如果您想使用 MediaElement 的内置调试文本窗口,可以将
textAreaLogger
更改为_output
(有时在构造函数中设置 debug=true)。就这样吧; Google IMA 预贴片和后贴片。
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.as
file.First step is to download and install the Google IMA ActionScript 3 component.
Next open
FlashMediaElement.fla
andFlashMediaElement.as
in 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
textAreaLogger
to_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.