Can you help me?
I am still trying to understand how to assign listType to a button.
There are 8 buttons.
Each of these would be assigned to a specific button.
I am stuck on how to do this.
https://jsfiddle.net/82gv4nhm/
Doing this only assigns playlist: "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g" to a specific button.
This means i - 0 playlist is being assigned as the first button.
How would I then assign listType to a specific button?
let playerVarsList = [{
playlist: "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g"
},
{
listType: "playlist",
list: "PLYeOyMz9C9kYmnPHfw5-ItOxYBiMG4amq"
},
{}
];
for (let i = 0; i <= 7; i++) {
players.add(".playSingle" + i, {
playerVars: playerVarsList[i - 0]
});
}
This i - 0 inside here: playerVars: playerVarsList[i - 0] tells the playlist what number button it is:
playlist: "0dgNc5S8cLI,mnfmQe8Mv1g,-Xgi_way56U,CHahce95B1g
players.add(".playSingle" + i, {
playerVars: playerVarsList[i - 1]
});
For this one, what tells it what button number it should be?
listType: "playlist",
list: "PLYeOyMz9C9kYmnPHfw5-ItOxYBiMG4amq"
}
How the code works is, after clicking on a button a video appears.
<button class="playSingle0 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
<button class="playSingle1 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
<button class="playSingle2 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
<button class="playSingle3 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
<button class="playSingle4 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
<button class="playSingle5 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
<button class="playSingle6 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
<button class="playSingle7 cover" type="button" data-container="play1" data-id="M7lc1UVf-VE"></button>
I am having trouble understanding how to do it.
To do this more than one of these would be needed: i - 0
playerVars: playerVarsList[i - 0],
playerVars: playerVarsList[i - 3]
or
playerVars: playerVarsList[i - 0, i - 3] ?