在 Javascript 中检测 Flash 文件何时完成播放
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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);