Uncaught ReferenceError: ytcfg is not defined (also __ytRIL is not defined)

Uncaught ReferenceError: ytcfg is not defined (also __ytRIL is not defined)

几个月来我一直在毫无问题地使用 YouTube IFrame 播放器 API,最近开始在加载播放器时看到此异常: Uncaught ReferenceError: ytcfg is not defined 检查 iframe,我看到对 yt.setConfig 的成功调用,但 ytcfg.set 稍后失败。 API 最近更改了吗?任何播放器参数都可能导致此问题?

<script src="//s.ytimg.com/yts/jsbin/www-embed-player-vflnzmqns/www-embed-player.js" type="text/javascript" name="www-embed-player/www-embed-player"></script>
<script src="//s.ytimg.com/yts/jsbin/player-en_US-vflr--npw/base.js" name="player/base"></script>
<script>
    yt.setConfig({
        ...
    });
    writeEmbed();
</script>
<script>
    ytcsi.info('st', 35);
    ytcfg.set({
        "TIMING_ACTION": "",
        "CSI_VIEWPORT": true,
        "TIMING_INFO": {
            "c": "WEB",
            "yt_li": 1,
            "cver": "1.20161112",
            "yt_lt": "cold"
        },
        "CSI_SERVICE_NAME": "youtube"
    });
    ;</script>

此问题有多种变体:

https://issuetracker.google.com/issues/35178202 "ytcfg is not defined" https://issuetracker.google.com/issues/35177930 “__ytRIL 未定义”

看来 bug 出在 youtube 方面。您可以在此处看到相同的 JS 错误:https://www.youtube.com/embed/U-xetxYwyak

当您单击任何视频下方的 "Share" 按钮,然后单击 "Embed" 选项卡复制粘贴嵌入 html 代码时,这种情况甚至在 youtube.com 上就开始发生了。绝对是他们的错。

我遇到了同样的问题。临时修复是使用对象而不是 iframe。它对我有用。

这是一个 Google 错误。它也发生在 Youtube 的开发者页面上。 https://developers.google.com/youtube/youtube_subscribe_button

以下错误跟踪此问题。

https://code.google.com/p/gdata-issues/issues/detail?id=8569(截至 2017 年 1 月 5 日仍然有效)

请使用下面的链接对此错误进行投票,以便引起他们的注意。他们自 2016 年 9 月 9 日以来一直在解决这个问题!!