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

YouTube screen should turn black when 2nd exit is clicked

$
0
0

I am using the Protection Flag method of only allowing 1 click on the exit button, I think I am missing removed = false; in there somewhere.

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/z3w8h4mL/

or in console log: console.log("removePlayer");

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?

Before I added in the Protection Flag method the player was removed after clicking the 2nd exit button.

5 Ways to Allow "Only One Click" in Javascript https://morioh.com/p/4c24b6c911cd

Am I missing another removed = false; somewhere in here?

If yes, where would it be placed?

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>