无法获取 params.play='false'在 SWFObject 2.2 中按预期、如文档或“应该”那样工作
我正在尝试使用 swfobject 和一些 cookie 代码来创建一个非常简约的无边界视频示例,以检查网站访问者之前是否去过那里。后一个 cookie 代码可以工作,但基本的 SWFObject 2.2 代码却不能。
我的问题是 code.google 中的 SWFObject 2.2 库未按预期工作;具体来说,它不遵守 params.play='false' 并且每次都会自动播放 SWF,无论我如何设置此属性(它不遵守)。我从给定域读取了一个 cookie,如果设置为“autostart_video=false”,我会将字符串“false”传递给该 SWFObject 播放参数,目的是使其在刷新时不会自动启动视频。 cookie 检查代码,但 @#$%#$@$ swf 代码则不然。在下面最简单的示例中,我完全排除了 cookie 代码,仅测试 SWFobject 代码本身。
下面的代码示例中的属性使用静态发布,但动态发布方法也不起作用(尝试了两种方法)。我开始认为示例 SWF 文件本身有问题,但用其他 swf 对其进行了测试,它们都有这种行为。
下面的代码是使用 google 发布的“SWFObject 2 HTML 和 JavaScript 生成器 v1.2”生成的。
我试图反转 swfobject 库,坦率地说,代码被混淆了或者远远超出了我的范围,所以无法找到它在哪里设置参数和/或自动加载更多库,否则我不会寻求帮助。
无论如何,请帮忙!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="swfobject/swfobject.js"></script> <!--path is correct-->
<script type="text/javascript">
swfobject.registerObject("myFlashContent", "9.0.0");
</script>
</head>
<body>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="600" id="myFlashContent" align="middle">
<param name="movie" value="swfObject2.2-is-retarded.swf" />
<param name="play" value="false" />
<param name="loop" value="false" />
<param name="menu" value="false" />
<param name="quality" value="autohigh" />
<param name="scale" value="noscale" />
<param name="wmode" value="transparent" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="dwfObject2.2-is-retarded.swf" width="400" height="600" align="middle">
<param name="play" value="false" />
<param name="loop" value="false" />
<param name="menu" value="false" />
<param name="quality" value="autohigh" />
<param name="scale" value="noscale" />
<param name="wmode" value="transparent" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>
I am trying to do a very minimalistic sample of borderless video using swfobject and some cookie code that checks if a site visitor has been there before. The latter cookie code works, but basic SWFObject 2.2 code doesn't.
My problem is that the SWFObject 2.2 library from code.google is not working as expected; specifically it is NOT obeying the params.play='false' and it is autoplaying the SWF each time, regardless of how i set this attribute (it disobeys). I read a cookie from the given domain, and should it be set with 'autostart_video=false' I then pass the string "false" to that SWFObject play parameter, with the purpose of making it NOT autostart the video upon refresh. The cookie checking code, but the @#$%#$@$ swf code doesn't. In the simplest example below, I've excluded the cookie code altogether to test just the SWFobject code by itself.
The attribute in the code sample below is using static publishing but dynamic publishing method doesn't work either (tried both methods). I was beginning to think there was something wrong with the sample SWF file itself, but tested it with other swfs and they all have this behavior.
The code below was generated using the "SWFObject 2 HTML and JavaScript generator v1.2" that google published.
I tried to reverse the swfobject library, and frankly the code is obfuscated or just well beyond me, so cannot find where it's setting the params and/or autoloading more libraries otherwise i'd not ask for help.
At any rate, please help!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="swfobject/swfobject.js"></script> <!--path is correct-->
<script type="text/javascript">
swfobject.registerObject("myFlashContent", "9.0.0");
</script>
</head>
<body>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="600" id="myFlashContent" align="middle">
<param name="movie" value="swfObject2.2-is-retarded.swf" />
<param name="play" value="false" />
<param name="loop" value="false" />
<param name="menu" value="false" />
<param name="quality" value="autohigh" />
<param name="scale" value="noscale" />
<param name="wmode" value="transparent" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="dwfObject2.2-is-retarded.swf" width="400" height="600" align="middle">
<param name="play" value="false" />
<param name="loop" value="false" />
<param name="menu" value="false" />
<param name="quality" value="autohigh" />
<param name="scale" value="noscale" />
<param name="wmode" value="transparent" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
的设计目的不是阻止视频播放,而是阻止 SWF 播放。
大多数视频播放器 SWF 不是基于时间轴的,而是基于 ActionScript 的。这意味着它们几乎是 100% AS,这通常意味着它们仅包含一两个帧。如果项目中只有一帧,并且该项目依赖 ActionScript 来执行操作,则在第一帧上停止 SWF 将产生零效果...第一帧上的 ActionScript 仍将执行。反过来,链接的视频仍将被加载并播放。
因此,您需要做的是确定您的播放器 SWF 是否具有可设置以防止自动播放的内部变量。然后需要使用 FlashVars 参数(而不是“自动播放”参数)将其传达给 SWF - 该参数只是告诉 Flash Player 不要让 SWF 越过帧加载时为一个。它不会阻止 ActionScript 执行,并且完全独立于视频控制器。
例如,如果您的视频播放器 SWF 使用名为“autostart”的内部变量,并且它接受布尔值作为参数,则您可以将其编写为:
检查视频播放器 SWF 的文档以了解您可以使用哪些 flashvar。
<param name="play" value="false" />
isn't designed to stop a video from playing, only the SWF.Most video player SWFs are not timeline-based and are ActionScript-based instead. This means they are almost 100% AS, which usually means they only consist of one or two frames. If there is only one frame in the project, and the project relies on ActionScript to do stuff, stopping the SWF on the first frame will have zero effect... the ActionScript on frame one will still execute. In turn, the linked video will still be loaded and will play.
So what you'll need to do is determine if your player SWF has an internal variable you can set to prevent auto-play. This then needs to be communicated to the SWF using the FlashVars param, not the "autoplay" param -- that param simply tells Flash Player not to let the SWF go past frame one when loaded. It doesn't prevent ActionScript from executing, and is completely independent from the video controller.
For example, if your video player SWF uses an internal variable named "autostart", and it accepts a boolean as an argument, you'd write it as:
Check the documentation for your video player SWF to see what flashvars are available to you.