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

102
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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