使用jQuery设置flash播放器

时间:2012-05-14 21:39:09

标签: javascript jquery internet-explorer internet-explorer-8

我有一个flash播放器(仅用于不支持html5视频的浏览器)设置如下:

<object id="mpl" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="300">
    <param name="id" value="mpl" />
    <param name="movie" value="/r/player.swf" />
    <param name="quality" value="high" />
    <param name="allowfullscreen" value="true" />
    <param name="allowscriptaccess" value="always" />
</object>

对于我需要flash的情况,这就是我试图动态设置url的方式。它适用于Chrome,但不适用于IE8(IE8模式下的IE9),这是我实际需要它工作的地方。

我得到的错误是jquery中的“无效参数”,在与append方法对应的行上。

IE8是否要我以不同的方式做到这一点?

data.videoPlayerContainer.find("object").append($('<param name="flashvars" value="width=400&height=300&displayheight=300&file=' + encodeURIComponent(flashUrl) + ' &autostart=true&type=flv&bufferlength=10&javascriptid=mpl&enablejs=true" />'));
data.videoPlayerContainer.find("object").append($('<embed src="/r/player.swf" name="mpl" width="400" height="300" bgcolor="#ccc3ad" allowfullscreen="true" allowscriptaccess="always" flashvars="width=400&height=300&displayheight=300&file=' + encodeURIComponent(flashUrl) + '&type=flv&bufferlength=10&showicons=false&shownavigation=false&autostart=true&javascriptid=mpl&enablejs=true" />'));

1 个答案:

答案 0 :(得分:2)

看看http://code.google.com/p/swfobject/这可以帮助您找到合适的解决方案。