如何使用 swfobject 监听事件(如“onVideoEnded”)
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我无法与
onJavaScriptBridgeCreated
代码对话,但您的 SWFObject 代码不正确,您需要在唯一的例外是 '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:The only exception is the 'movie' param, which is only used by IE in the first
<object>
我已经通过使用 flowplayer 解决了这个问题。它非常易于使用并提供足够的配置可能性。不管怎样,谢谢你的帮助。
i have solved this by using flowplayer. its very easy to use and offers sufficient configuration possibilities. thanks for your help anyway.