Currently, the player does not get removed when clicking on a 2nd exit button.
To know if a player is removed, the screen turns black. https://jsfiddle.net/jt2o3mny/
While implementing the Protection Flag method, did I forget to do something?
To reproduce issue, click on 1 exit button, then click on a 2nd exit button.
You will notice that the player does not get removed after clicking the 2nd exit button.
How would that be fixed?
const videoPlayer = (function makeVideoPlayer() { let removed = false; function createResetHandler(player) { const resetVideo = document.querySelectorAll(".exit"); resetVideo.forEach(function resetVideoHandler(video) { video.addEventListener("click", function resetVideoHandler() { if (!removed) { removed = true; player.destroy(); console.log("removePlayer"); } }); }) }