To reproduce, click on the 1st blue play button, next, click on the exit button.
In console.log("removePlayer");
It says it is removed.
Do the same thing for the next video player.
Click on the blue play button, then click on the exit, nothing occurs.
code https://jsfiddle.net/u2a9cxfh/
How come only 1 player is removed, and how would that be fixed or adjusted in the code so that, the others will get removed also?
I am not sure what needs to be adjusted so that it is working properly.
function addExitHandlers(callback) {
const resetVideo = document.querySelectorAll(".exit");
resetVideo.forEach(function resetVideoHandler(video) {
video.addEventListener("click", callback);
});
}
function removePlayer(wrapper) {
wrapper.player.destroy();
delete wrapper.player;
console.log("removePlayer");
}
function removePlayerHandler(/*evt*/) {
// const el = evt.target;
// const container = el.closest(".container");
const wrapper = document.querySelector(".wrap");
if (wrapper.player) {
return removePlayer(wrapper);
}
}