Doing this is how it was fixed in the other code:
Shouldn’t it be set up similar to how this one was?
This other code.
https://www.sitepoint.com/community/t/im-receiving-a-script-error/371086/36
player = new YT.Player(video, {
events: {
"onReady": onPlayerReady,
"onStateChange": onPlayerStateChange
},
height: 360,
host: "https://www.youtube-nocookie.com",
playerVars: {
autoplay: 0,
controls: 1,
loop: 1,
rel: 0,
iv_load_policy: 3,
cc_load_policy: 0,
fs: 0,
disablekb: 1,
playlist
},
width: 640
});
That doesn’t work for us though because width and height are separated a long way from each other.
Because I want to maintain some logical order to the properties, we can define them separately in the config object.
const playlist = "M7lc1UVf-VE";
const config = {
height: 360,
host: "https://www.youtube-nocookie.com",
width: 640
};
config.playerVars = {
autoplay: 0,
cc_load_policy: 0,
controls: 1,
disablekb: 1,
fs: 0,
iv_load_policy: 3,
loop: 1,
playlist,
rel: 0
};
config.events = {
"onReady": onPlayerReady,
"onStateChange": onPlayerStateChange
};
player = new YT.Player(video, config);