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

157
Visualizações
How to destroy video

I have never used player.destroy(); before in code so I am unsure of how to add it.

How should it be written into the code?

I am using it to destroy the iframe for the video, when the X button is clicked.

After a svg play button is clicked, there is an X button that you press which when pressed, destroys the video.

Are either of these the right way?

Click Run, not update to test code:

Like this: https://jsitor.com/RTH542DH1o

function createResetHandler(player) {
    const resetVideos = document.querySelectorAll('.exit');
    resetVideos.forEach(function resetVideoHandler(video) {
      video.addEventListener('click', function resetVideoHandler() {
        if (!player) {
        } else {
          player.stopVideo();
          player.destroy();
          player = null; 
        }
      });
    });
  }

or like this: https://jsitor.com/xaLXppyXJ5

 function createResetHandler(player) {
    const resetVideos = document.querySelectorAll('.exit');
    resetVideos.forEach(function resetVideoHandler(video) {
      video.addEventListener('click', function resetVideoHandler() {

        player.destroy();

      });
    });
  }

or would it be written a different way?

https://developers.google.com/youtube/iframe_api_reference

Removes the <iframe> containing the player.

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