Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda