我已经使用 YouTube IFrame Player API 几个月了,没有出现任何问题,最近当播放器加载时,我开始看到这个异常:
Uncaught ReferenceError: ytcfg is not defined
检查 iframe 时,我看到一个对 yt.setConfig
的成功调用,但是 ytcfg.set
后来失败了。空气污染指数最近有变化吗?任何球员参数都可能导致这个问题?
<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 没有定义” Https://issuetracker.google.com/issues/35177930 “ _ _ ytRIL 未定义”