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

105
Vistas
Switch video source on click

For example: Section 1 HOME: has a video loop background, "video source 1" I want to change the video source by clicking on the video in section 1 to "video source 2",

but video2 has only to be played one time and has to switch back again to video1

How do I fix that

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can try something like this:

  • Create a Boolean for true/false as your "If played once" variable. Set it to = false;...

  • Give the (background) <video> tag an ID in the tag setup.

  • Add a "click" listener to the <video> tag.

  • The click handling function should get video object by ID...

  • Have an if statement to check If (played_Once == false)

  • Inside the if, you can set myVideoID.src = "other_video.mp4 and then do also:
    myVideoID.load();
    myVideoID.play();
    played_Once = true;

  • You also need to add an "on ended" listener to the video object, where the handling function will change src in the same way as the steps above, back to the original video, remove the listener for "ended" at this point

about 4 years ago · Juan Pablo Isaza Denunciar
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