Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!