我嵌入了一个名为的swf 三次,名为video.swf。
主权财富基金的名字是video1、video2和video3。
如果我玩swf,我想得到当前玩swf的名字?
有可能吗?
我在用javascript来沟通。
发布于 2011-08-10 16:22:11
我必须为工作在Swatch/MTV项目中做一些非常类似的事情(在一个页面上有多个嵌入式播放器,每次只播放一个剪辑(播放不同的剪辑,暂停其他片段等等)。例如:
var vids = ['video/file/72066f40bfcaea46e10460585b4e4bcb.mp4','video/file/3d5db6b87f9cdacb016c9c55afed1e08.mp4','video/file/c18b04a1a548cbf20609de70a106d7cc.mp4','video/file/4568a11f3f6a7ff467a85fefe2ac08e6.mp4','video/file/b91081d37a81692194c0e34580958c51.mp4']; for(var i = 0 ; i < vids.length; i++){
var flashvars = {};
flashvars.video_url = 'http://www.swatchmtvplayground.com/'+vids[i];
flashvars.video_id = i;
flashvars.locale = "gb";
flashvars.skin = 'upperBackground:0xf8c3c4,lowerBackground:0xe2e2e2,generalControls:0x000000,slider:0xb58f8f,progress:0xe2e2e2';
var params = {};
var attributes = {};
attributes.id = "mediaplayer"+i;
so = swfobject.embedSWF("http://www.swatchmtvplayground.com/flash/mediaplayer/mediaplayer.swf", "mediaplayer"+i, "578", "345", "10.0.0", false, flashvars, params, attributes);
}
function pauseAllPlayers(exceptThisOne){
for(var i = 0 ; i < vids.length ; i++) if(exceptThisOne != "mediaplayer"+i) document.getElementById("mediaplayer"+i).pause();
}为了获得id,我使用了一个以前不知道的小技巧(执行用actionscript创建的JS ),使用Zeh Fernando的优秀指南:从Flash电影本身获取SWF的HTML对象/嵌入id
HTH
发布于 2011-08-10 13:16:22
如果您使用同一个swf文件三次,则必须传入一个闪存变量,以便让swf知道它是哪个实例(video1、video2或video3)。然后,当一个video.swf实例开始播放时,使用AS3的ExternalInterface调用JavaScript并将该swf实例标记为当前正在播放的实例。
使用SWFObject将主权财富基金嵌入到页面中,您可以在JavaScript中设置闪光灯,如下所示:
var flashvars1 = {
name: "video1",
};
swfobject.embedSWF("video1.swf", "flashContent1", "640", "480", "10.0.0", false, flashvars1, {}, {});
var flashvars2 = {
name: "video2",
};
swfobject.embedSWF("video2.swf", "flashContent2", "640", "480", "10.0.0", false, flashvars2, {}, {});
var flashvars3 = {
name: "video3",
};
swfobject.embedSWF("video3.swf", "flashContent3", "640", "480", "10.0.0", false, flashvars3, {}, {});在每个swf中,现在可以通过LoaderInfo访问“name”var:
var name:String = LoaderInfo(this.root.loaderInfo).parameters.name;您可以从Flash调用ExternalInterface,如下所示:
ExternalInterface.call( "videoPlaying", name );这将调用一个名为'videoPlaying‘的videoPlaying函数,该函数的名称为参数:
function videoPlaying(name) {
// do something with the name arg
}https://stackoverflow.com/questions/7011043
复制相似问题