I think what I would be doing here is:
Adding a click event to the iframe
I was just told to try:
mousedown event
But how exactly would this be done?
How would you add a ‘click’ or ‘mousedown’ event to the youtube, without using their api?
added: onPlayerStateChange: The borders and lines change colors after it’s clicked.
https://jsfiddle.net/byw5szgt/127/
/* function onPlayerStateChange(evt) {
// possible states values are:
// -1 (unstarted), 0 (ended), 1 (playing),
// 2 (paused), 3 (buffering), 5 (video cued).
const state = evt.data;
if (state > 0) {
changeColor();
}
}
"onStateChange": onPlayerStateChange */
With ‘onPlayerStateChange’ removed, how would I get it to work the same way, but without using their api?
removed: onPlayerStateChange
https://jsfiddle.net/byw5szgt/129/
When the video is clicked, the border and lines should change colors.
Javascript color code
const wrapper = document.querySelector(".wrapg");
function changeColor() {
wrapper.classList.add("playerStatus");
}
function colorClickHandler() {
changeColor();
player.playVideo();
}
wrapper.addEventListener("click", colorClickHandler);