Jquery 如何从swfobject检测闪存事件
我一直在读关于使用ExternalInterface让Flash与JavaScript通信的文章。当用户开始播放视频和视频结束时,我需要检测并调用JavaScript中的一些代码。swfobject非常适合在页面上嵌入播放器,但我不知道如何向其添加这些事件处理程序。这是我的密码:Jquery 如何从swfobject检测闪存事件,jquery,flash,Jquery,Flash,我一直在读关于使用ExternalInterface让Flash与JavaScript通信的文章。当用户开始播放视频和视频结束时,我需要检测并调用JavaScript中的一些代码。swfobject非常适合在页面上嵌入播放器,但我不知道如何向其添加这些事件处理程序。这是我的密码: function flashFallback(){ jQuery('#dialog').dialog({ modal:true, autoOpen:false, height: 119 }); jQuery
function flashFallback(){
jQuery('#dialog').dialog({
modal:true,
autoOpen:false,
height: 119
});
jQuery("#dialog").dialog("open");
setTimeout(function(){
var el = "";
var vidFileName = "";
var posterPath = "";
var videoTag = "";
var boxId = "";
var so = "";
var flashId = "";
var flashVars = "";
var params = "";
var attributes = "";
var anchorId = "";
var dotPosition = "";
var count = jQuery("video").length;
//alert(count);
jQuery("video").each(function(){
el = "";
vidFileName = "";
posterPath = "";
videoTag = "";
flashId = "";
flashVars = "";
params = "";
attributes = "";
anchorId = "";
el = jQuery(this);
boxId = this.id + "_flashBox";
flashId = this.id + "_flashPlayer";
anchorId = this.id + "_anchor";
el.parent().parent().find("div:first").attr("id",boxId);
el.parent().find("source").each(function(){
if (jQuery(this).attr("src").indexOf("m4v") != -1 ||
jQuery(this).attr("src").indexOf("mp4") != -1){
vidFileName = jQuery(this).attr("src").substring(jQuery(this).attr("src").lastIndexOf("/")+1);
}
});
/*
IE uses the Flash player, which overlays a 'Play' button
on the poster image by default; so we use a poster image
that doesn't have a play button. Otherwise we'd end up
with a play button on top of a play button.
*/
dotPosition = el.parent().find("img").attr("src").lastIndexOf(".");
posterPath = el.parent().find("img").attr("src").substring(0,dotPosition) + "-ie" + el.parent().find("img").attr("src").substring(dotPosition);
el = jQuery("[id="+boxId+"]");
el.empty();
el.append("<a id='" + anchorId +"'></a>");
flashvars =
{
file: vidFileName,
autostart: 'false',
image: posterPath
};
params =
{
allowfullscreen: 'true',
allowscriptaccess: 'always',
wmode: 'opaque'
};
attributes =
{
id: flashId,
name: flashId
};
swfobject.embedSWF('global/vid/player.swf', anchorId, '372', '233', '9.0.124', 'global/js/swfobject/expressInstall.swf', flashvars, params, attributes);
});
jQuery('#dialog').dialog("close");
}, 200);
}
函数flashFallback(){
jQuery(“#dialog”).dialog({
莫代尔:是的,
自动打开:错误,
身高:119
});
jQuery(“对话框”).dialog(“打开”);
setTimeout(函数(){
var el=“”;
var vidFileName=“”;
var posterPath=“”;
var videoTag=“”;
var-boxId=“”;
var so=“”;
var flashId=“”;
var flashVars=“”;
var params=“”;
var属性=”;
var anchorId=“”;
var dotPosition=“”;
var count=jQuery(“视频”).length;
//警报(计数);
jQuery(“视频”)。每个(函数(){
el=”“;
vidFileName=“”;
posterPath=“”;
videoTag=“”;
flashId=“”;
flashVars=“”;
params=“”;
属性=”;
anchorId=“”;
el=jQuery(this);
boxId=this.id+“\u flashBox”;
flashId=this.id+“\u flashPlayer”;
anchorId=this.id+“_anchor”;
el.parent().parent().find(“div:first”).attr(“id”,boxId);
el.parent().find(“源”).each(函数()){
if(jQuery(this).attr(“src”).indexOf(“m4v”)!=-1 |
jQuery(this.attr(“src”).indexOf(“mp4”)!=-1){
vidFileName=jQuery(this.attr(“src”).substring(jQuery(this.attr(“src”).lastIndexOf(“/”)+1);
}
});
/*
IE使用Flash播放器,它覆盖一个“播放”按钮
默认情况下,在海报图像上;因此我们使用海报图像
那没有播放按钮,否则我们就完蛋了
在播放按钮的顶部有一个播放按钮。
*/
dotPosition=el.parent().find(“img”).attr(“src”).lastIndexOf(“.”);
posterPath=el.parent().find(“img”).attr(“src”).substring(0,点位置)+“--ie“+el.parent().find(“img”).attr(“src”).substring(点位置);
el=jQuery(“[id=“+boxId+”]”);
el.empty();
el.附加(“”);
闪光灯=
{
文件名:vidFileName,
自动启动:“false”,
图片:posterPath
};
params=
{
allowfullscreen:'真',
allowscriptaccess:“始终”,
wmode:“不透明”
};
属性=
{
id:flashId,
姓名:flashId
};
swfobject.embeddeswf('global/vid/player.swf',anchorId,'372','233','9.0.124','global/js/swfobject/expressInstall.swf',flashvars,params,attributes);
});
jQuery(“#dialog”).dialog(“close”);
}, 200);
}
你不必为此烦恼。只需检测flash中的事件,然后在flash事件处理程序中调用所需的javascript函数:
import flash.external.ExternalInterface;
...
ExternalInterface.call("your_javascript_function()");
这可能会有所帮助:我正在使用他们的player.swf,因此它将提供这些活动。