Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

How to apply the Protection Flag method of only allowing 1 click

$
0
0

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");        }      });    })  }

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>