如何向嵌入SWFObject 2.2的播放器发送搜索事件?

时间:2012-08-15 12:00:57

标签: javascript flash swfobject

我已经从1.5更新了我的SWFObject到2.2,现在需要复制一些以前在1.5中工作的旧功能,即事件跳转到视频中的某个点。

以下是我的脚本标记的内容:

var flashvars = {
    file: '79834.flv',
    autostart: 'true',
    displayclick: 'mute',
    repeat: 'single',
    start: 0
};
var params = {
    allowfullscreen: "true",
    allownetworking: "all",
    allowscriptaccess: "always"
};
swfobject.embedSWF("player.swf","main","500","400","9.0.0", "false", flashvars, params);

var player;
function playerReady(obj) {
    player = document.getElementById(obj.id);
    alert(player);
    setTimeout("seek()", 1000);
}
function seek() {
    player.sendEvent("SEEK", 100);
}

上半部分是我用。替换旧的V1.5代码。

下半部分(来自“var player”)不再适用。 playerReady仍在发生,但显然obj.id现在是“null”。有没有新的正确方法来找到玩家元素?或者以不同的方式实现搜索事件?

1 个答案:

答案 0 :(得分:0)

您错过了id属性:

var attributes = {
    id: "playerID"
}
// and later
swfobject.embedSWF("player.swf","main","500","400","9.0.0", "false", flashvars, params, attributes);