使用适用于 IE7 和 IE8 的 jQuery 在 Facebox 中加载 FLV
不用说,这在 Chrome、Firefox 和 Safari 中完美运行。 IE(任何版本)都是问题所在。
目标: 我正在尝试加载 JWplayer,它会在 Facebox 弹出窗口中从 S3 加载 FLV。
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
})
HTML (haml):
%li#videoGirl
= link_to 'What is HQchannel?', '#player', :rel => 'facebox'
.grid_8.omega.alpha#player{:style => 'display: none;'}
:javascript
var so = new SWFObject('/flash/playerTrans.swf','mpl','640px','360px','0');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('wmode','transparent');
so.addVariable('file', 'http://hometownquarterlyvideos.s3.amazonaws.com/whatishqchannel.flv&autostart=true&controlbar=none&repeat=always&image=/flash/video_girl/whatishqchannel.jpg&icons=false&screencolor=none&backcolor=FFFFFF&screenalpha=0&overstretch');
so.addVariable('overstretch', 'true')
so.write('player');
问题:
- 尽管视频设置为显示:无;。无论如何它都会开始播放。
- 单击激活 div 时,IE7 会弹出一个尺寸错误的带有导航的空白 div(参数设置为不显示导航和滑块),并且导航和滑块上没有任何按钮工作。 IE8 显示正确的尺寸,但行为相同,导航和滑块不起作用,并且屏幕空白。
我的猜测:
我认为问题在于 javascript 没有在正确的时间被调用。看起来它正在加载 Facebox,而没有 jwplayer。至少我认为。这就是导航存在的原因。我认为它没有为此读取 javascript。
It goes almost without saying, this works perfectly in Chrome, Firefox, and Safari. IE (any version) being the problem.
Objective: I am trying to load JWplayer which loads an FLV from S3 in a Facebox popup.
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
})
HTML (haml):
%li#videoGirl
= link_to 'What is HQchannel?', '#player', :rel => 'facebox'
.grid_8.omega.alpha#player{:style => 'display: none;'}
:javascript
var so = new SWFObject('/flash/playerTrans.swf','mpl','640px','360px','0');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('wmode','transparent');
so.addVariable('file', 'http://hometownquarterlyvideos.s3.amazonaws.com/whatishqchannel.flv&autostart=true&controlbar=none&repeat=always&image=/flash/video_girl/whatishqchannel.jpg&icons=false&screencolor=none&backcolor=FFFFFF&screenalpha=0&overstretch');
so.addVariable('overstretch', 'true')
so.write('player');
Problem:
- Despite the video being set to display: none;. It begins playing anyway.
- When clicking on the activation div, IE7 pops up a wrong sized blank div with a nav (params are set to not show nav and scrubber), and no buttons on the nav and srubber work. IE8 shows the right size but same behavior with nav and scrubber not working, and blank screen.
My guess:
I'm thinking that the problem is with the javascript not being called at the right times. It seems it's loading the facebox without the jwplayer. At least I assume. Hence the reason why the nav is there. I thinking that it did not read the javascript for that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有几个问题。
第一个问题:SWFOBJECT
我认为您看到了不良/不可预测的行为,因为您的 SWFObject 语法有点不对劲。使用 SWFObject,您可以:
1.) 使用 addParam('flashvars', FLASHVARS),其中 FLASHVARS 是由 & 分隔的配置选项的串联字符串,即
OR
2.) 使用一堆 addVariable 语句,即
If如果您需要任何其他信息,这里有一个关于嵌入 Flash JW Player 网站上的 设置向导 将提供现成的- 使用SWFObject代码。
第二个问题:自动启动时显示:无
这是 IE 快捷方式。在大多数浏览器中,当您设置 display: none 时,Flash 将被终止。 IE 中并非如此。为了防止这种情况,你需要设置
如果你使用一些JS来设置显示CSS属性并且你希望播放器在播放器出现时开始播放,我建议你修改你的JS以开始并通过它的API停止播放器。诚然,这有点复杂,但这都是让事情跨浏览器无缝运行的一部分。
最佳,
扎克
开发者,长尾视频
There are a couple of issues here.
FIRST ISSUE: SWFOBJECT
I think you're seeing undesirable / unpredictable behavior because your SWFObject syntax is a bit off. With SWFObject, you can either:
1.) Use the addParam('flashvars', FLASHVARS), where FLASHVARS is a concatenated string of configuration options separated by &, ie
OR
2.) Use a bunch of addVariable statements, ie
If you need any additional information, there's an excellent tutorial on Embedding Flash on the JW Player site and a setup wizard that will provide ready-to-use SWFObject code.
SECOND ISSUE: AUTOSTART WHILE display: none
This is an IE quick. In most browsers, Flash is killed when you set display: none. This isn't the case in IE. To prevent this, you'll need to set
If you're using a bit of JS to set the display CSS property and you'd like the player to start playing when the player appears, I'd suggest you modify your JS to start and stop the player via it's API. Admittedly this is a bit more complicated, but it's all part of making things work seamlessly cross-browser.
Best,
Zach
Developer, LongTail Video
实例化 Facebox javascript 后,此代码将成功加载 JWplayer。视频在 IE7 或 IE8 中无法显示仍然存在一些问题,但 JWplayer 可以正常加载。
HTML:
JavaScript:
This code will successfully load JWplayer after the facebox javascript is instantiated. There is still something screwy going on with video not displaying in IE7 or IE8, but JWplayer loads appropriately.
HTML:
Javascript: