Okay, we first of all we should get consistent about things, playerOptions is the better tern to use there.
The following code has several issues that need to be dealt with.
function addPlayer(video, settings, videoIds = video.dataset.id) {
const videoId = !Array.isArray(videoIds) && videoIds;
const playlist = Array.isArray(videoIds) && videoIds.join();
const config = {
host: "https://www.youtube-nocookie.com",
videoId
};
config.playerVars = {
playlist: playlist || undefined
};
config.events = {
"onReady": onPlayerReady
};
const defaultOptions = config;
const playerOptions = Object.assign({}, defaultOptions, settings);
players.push(new YT.Player(video, config));
}
On the players.push line, config should be replaced with playerOptions.
Everything else called config in that function should be renamed to defaultOptions instead.
The const defaultOptions
line should be removed.