I am new in studying and learning javascript, can you add a bit of changes to the code for the onstatechange, I checked and tried to modify the code, trying to add it but I fail. The code I tried to make with getPlayerState() only triggers the chosen video id to play but not to get the values stated in:
https://developers.google.com/youtube/iframe_api_reference#getPlayerState async function getPlayerState(number, id) { let num = document.querySelector(lite-youtube[id='${id}']`);
let player = await num.getYTPlayer();
player?.getPlayerState(number, true);
}
playlist.addEventListener('click', () => {
this.getPlayerState(1, '1') // the string inside works and plays the specific video id but it does not get the PlayerState value
if (this.getPlayerState(0, '1')) {
this.getPlayerState(1, '2') //<=this always trigger the specific video id but it plays no matter what is changed on the ifcondition
}
});
`
I am new in studying and learning javascript, can you add a bit of changes to the code for the onstatechange, I checked and tried to modify the code, trying to add it but I fail. The code I tried to make with getPlayerState() only triggers the chosen video id to play but not to get the values stated in: https://developers.google.com/youtube/iframe_api_reference#getPlayerState
async function getPlayerState(number, id) { let num = document.querySelector(
lite-youtube[id='${id}']`); let player = await num.getYTPlayer(); player?.getPlayerState(number, true); }playlist.addEventListener('click', () => { this.getPlayerState(1, '1') // the string inside works and plays the specific video id but it does not get the PlayerState value if (this.getPlayerState(0, '1')) {
this.getPlayerState(1, '2') //<=this always trigger the specific video id but it plays no matter what is changed on the ifcondition } }); `