如何使用 swfobject 监听事件(如“onVideoEnded”)

发布于 2024-12-13 05:56:01 字数 1704 浏览 2 评论 0原文

我使用 swfobject 的静态发布方法将 swf 电影嵌入到我的 html 中:

<object id="swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300">
    <param name="movie" value="some.swf" />
    <param name="play" value="false" />
    <param name="menu" value="true" />
    <param name="allowFullScreen" value="true" />
    <param name="loop" value="false" />
    <param name="FlashVars" value="javascriptCallbackFunction=onJavaScriptBridgeCreated" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="some.swf" width="400" height="300">
    <!--<![endif]-->
      <p><a href="http://www.adobe.com/go/getflash">
        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    </a></p>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>

我想在视频完成后触发 Javascript 函数,并尝试在 flashvars 参数中使用上述回调函数。我的 Javascript 函数如下所示:

function onJavaScriptBridgeCreated(playerId) {
var player = document.getElementById(playerId);
player.addEventListener("complete", "completeFunc");}

function completeFunc() {
alert('video ended');}

http://forums.adobe.com/thread 找到了这种方法/791624 并将其修改为静态发布方法(http://code.google.com/p/swfobject/wiki/documentation)。

但问题是,函数 completeFunc 从未被调用,我不明白为什么。

如果你能帮助我,我会很高兴。

I am embedding a swf movie into my html with the static publishing method of swfobject:

<object id="swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300">
    <param name="movie" value="some.swf" />
    <param name="play" value="false" />
    <param name="menu" value="true" />
    <param name="allowFullScreen" value="true" />
    <param name="loop" value="false" />
    <param name="FlashVars" value="javascriptCallbackFunction=onJavaScriptBridgeCreated" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="some.swf" width="400" height="300">
    <!--<![endif]-->
      <p><a href="http://www.adobe.com/go/getflash">
        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    </a></p>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>

I want to trigger a Javascript function after the video had finished and tried with the above callback function in the flashvars parameter. My Javascript function looks like this:

function onJavaScriptBridgeCreated(playerId) {
var player = document.getElementById(playerId);
player.addEventListener("complete", "completeFunc");}

and

function completeFunc() {
alert('video ended');}

I found this approach at http://forums.adobe.com/thread/791624 and modified it for the static publishing method (http://code.google.com/p/swfobject/wiki/documentation).

But the problem is, the function completeFunc is never called and I can't figure out why.

I would be very glad if you could help me out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸠书 2024-12-20 05:56:01

我无法与 onJavaScriptBridgeCreated 代码对话,但您的 SWFObject 代码不正确,您需要在 节点中包含 节点。 节点,如下所示:

<object id="swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300">
    <param name="movie" value="some.swf" />
    <param name="play" value="false" />
    <param name="menu" value="true" />
    <param name="allowFullScreen" value="true" />
    <param name="loop" value="false" />
    <param name="FlashVars" value="javascriptCallbackFunction=onJavaScriptBridgeCreated" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="some.swf" width="400" height="300">
        <param name="play" value="false" />
        <param name="menu" value="true" />
        <param name="allowFullScreen" value="true" />
        <param name="loop" value="false" />
        <param name="FlashVars" value="javascriptCallbackFunction=onJavaScriptBridgeCreated" />
    <!--<![endif]-->
      <p><a href="http://www.adobe.com/go/getflash">
        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    </a></p>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>

唯一的例外是 'movie' 参数,该参数仅由 IE 在第一个 中使用

I can't speak to the onJavaScriptBridgeCreated code, but your SWFObject code is incorrect, you need to include the <param> node in BOTH <object> nodes, like so:

<object id="swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300">
    <param name="movie" value="some.swf" />
    <param name="play" value="false" />
    <param name="menu" value="true" />
    <param name="allowFullScreen" value="true" />
    <param name="loop" value="false" />
    <param name="FlashVars" value="javascriptCallbackFunction=onJavaScriptBridgeCreated" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="some.swf" width="400" height="300">
        <param name="play" value="false" />
        <param name="menu" value="true" />
        <param name="allowFullScreen" value="true" />
        <param name="loop" value="false" />
        <param name="FlashVars" value="javascriptCallbackFunction=onJavaScriptBridgeCreated" />
    <!--<![endif]-->
      <p><a href="http://www.adobe.com/go/getflash">
        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    </a></p>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>

The only exception is the 'movie' param, which is only used by IE in the first <object>

鸵鸟症 2024-12-20 05:56:01

我已经通过使用 flowplayer 解决了这个问题。它非常易于使用并提供足够的配置可能性。不管怎样,谢谢你的帮助。

i have solved this by using flowplayer. its very easy to use and offers sufficient configuration possibilities. thanks for your help anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文