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

244
Visualizações
Pause video on Tab switch in browser but should continue Playing when minimized the browser window

I am trying to pause the video when the user switches the tab in the browser and simultaneously if the user minimizes the browser window it should not get paused. I tried it implementing by using PageVisibility Api but using it the video gets paused in both cases. I only need to pause if the tab is switched on, not in case the window is minimized.

var videoElement = document.getElementById("videoElement");
document.addEventListener("visibilitychange", function() {
        if(document.visibilityState==="hidden")
        {
            videoElement.pause();
        }
        else if(document.visibilityState==="visible")
        {
            videoElement.play();
        }      
})
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

document.addEventListener("visibilitychange", function() {
    if (document.hidden){
        console.log("Browser tab is hidden")
    } else {
        console.log("Browser tab is visible")
   }
});
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