自iOS6以来,Fancybox不显示YouTube视频 [英] Fancybox not displaying YouTube video since iOS6
问题描述
这是我去年使用的代码。它很棒!
This is the code I have been using for the last year. It works great!
$("#videos a").click(function() {
if ($(this).hasClass('youtube')) {
$.fancybox({
'padding' : 0,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'title' : this.title,
'width' : $(this).attr('data-width'),
'height' : $(this).attr('data-height'),
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'allowfullscreen' : 'true'
}
});
return false;
}
});
当在iPad上使用此代码时,视频会显示。如果在iPad上无法观看视频,您会看到一个带有划掉播放按钮的YouTube图标。
When this code was used on the iPad the video would display. If the video wasn't viewable on the iPad you would see a YouTube icon with a crossed out play button.
由于iOS6已经停止工作。代码中没有任何内容发生变化。相反,你现在看到一个白色的弹出窗口。有人遇到过这个吗?有谁知道原因?
Since iOS6 this has stopped working. Nothing in the code has changed. Instead you now see a white pop up. Has anyone come across this? Does anyone know the cause?
我正在使用Fancybox 1.3.4
I am using Fancybox 1.3.4
推荐答案
要在不同平台上更方便地访问YouTube视频,您应该停止使用格式 http://www.youtube.com/watch?v=3l8MwU0IjMI
(使用一个 swf 播放器)但是使用 embed
方法(你可以从youtube中选择正确的代码来选择分享
tab)
To make your youtube videos more accessible across different platforms you should stop using the format http://www.youtube.com/watch?v=3l8MwU0IjMI
(which uses a swf player) but use the embed
method instead (you can get the right code from youtube selecting the share
tab)
所以,而不是:
<a class="fancybox" href="http://www.youtube.com/watch?v=3l8MwU0IjMI">open youtube video in fancybox</a>
...执行此操作:
<a class="fancybox" href="http://www.youtube.com/embed/3l8MwU0IjMI?autoplay=1">open youtube video in fancybox</a>
然后修改您的fancybox(v1.3.4)脚本以打开内容类型
到 iframe
喜欢
Then modify your fancybox (v1.3.4) script to open the content type
to iframe
like
$(".fancybox").fancybox({
"width": 620, // or whatever
"height": 420,
"type": "iframe"
});
这篇关于自iOS6以来,Fancybox不显示YouTube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!