YouTube Fancybox未加载视频

YouTube Fancybox not loading the video

本文关键字:视频 加载 Fancybox YouTube      更新时间:2023-09-26

我在网站上设置了一个PHP视频浏览器(检查视频吊舱),当点击视频缩略图时,视频应该弹出并使用FancyBox脚本播放,但视频就是不加载。为什么会这样?

您使用的是带有fancybox v1.3.x选项的fancybox v2.x(它们彼此不兼容)

你最好的选择是摆脱这个脚本:

<script type="text/javascript">
    $(".videobox").click(function () {
        $.fancybox({
            'padding': 0,
            'autoScale': false,
            'transitionIn': 'none',
            'transitionOut': 'none',
            'title': this.title,
            'width': 680,
            'height': 495,
            'href': this.href.replace(new RegExp("watch''?v=", "i"), 'v/'),
            'type': 'swf',
            'swf': {
                'wmode': 'transparent',
                'allowfullscreen': 'true'
            }
        });
        return false;
    });
</script>

然后试试这个:

<script type="text/javascript">
    $(document).ready(function () {
        $(".videobox").fancybox({
            width: 680,
            height: 495,
            type: "iframe"
        }); // fancybox
    }); // ready
</script>

注意,我们使用type : "iframe"是因为您使用的是youtube embed模式

旁注:当您实际上需要一个实例(最好是最新版本)来避免意外错误时,您正在加载两个版本的jQuery(1.7.1和1.7.2)。