Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
YouTube screen should turn black when 2nd exit is clicked

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?

or, maybe I am not doing this the right way.

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");
        }
      });
    })
  }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda