For several months, I had smooth sailing with the YouTube IFrame Player API until recently when an unexpected exception popped up upon loading the player:
Uncaught ReferenceError: ytcfg is not defined
Upon inspecting the iframe, I noticed that yt.setConfig
was called successfully, but ytcfg.set
encountered a failure later on. Could there have been recent changes to the API? Or perhaps a player parameter causing this issue?
<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>
This issue comes in different forms:
https://issuetracker.google.com/issues/35178202 "ytcfg is not defined" https://issuetracker.google.com/issues/35177930 "__ytRIL is not defined"