在 Javascript 中检测 Flash 文件何时完成播放

发布于 2024-08-30 13:36:16 字数 390 浏览 1 评论 0原文

我正在使用 Javascript 将 Flash 文件嵌入到网站中,然后需要在播放完成后将其删除。

有没有办法用普通的 Javascript 来做到这一点?或者是否需要将回调类型的函数添加到 Flash 文件本身?

我该如何编码? ._.

JavaScript:

jQuery('body').append('<embed id="flashIntro" width="100%" height="100%" type="application/x-shockwave-flash" src="' + flashIntro + '" pluginspage="http://www.adobe.com/go/getflashplayer" /\>');

I'm using Javascript to embed a flash file into a website which I then need to remove once it's completed playing.

Is there a way to do this in plain Javascript? Or will it require a callback type function to be added into the Flash file itself?

How do I code this? ._.

Javascript:

jQuery('body').append('<embed id="flashIntro" width="100%" height="100%" type="application/x-shockwave-flash" src="' + flashIntro + '" pluginspage="http://www.adobe.com/go/getflashplayer" /\>');

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

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

发布评论

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

评论(1

莫相离 2024-09-06 13:36:16

JavaScript 没有本地方法可以知道 Flash 何时播放完毕。您可以在 javascript 中设置一个计时器,以便在 swf 始终播放设定时间时将其删除,或者在 flash 中添加一个外部接口,以便在播放完毕时向 JS 发送调用。

将其添加到 swf 的最后一帧或销毁函数中:
<代码>
导入 flash.external.ExternalInterface;
if (外部接口.可用)
ExternalInterface.call("JavaScriptFunctionNameToCallWhenDone", true);

Javascript has no native way to know when Flash is done playing. You can set a timer in javascript to remove it if the swf will always play for a set time or add an External Interface in flash to send a call to JS when its finished playing.

Add this in the last frame of the swf or in your destroy function:

import flash.external.ExternalInterface;
if (ExternalInterface.available)
ExternalInterface.call("JavaScriptFunctionNameToCallWhenDone", true);

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