Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

264
Views
i have tried to pause video in html when user switch browser tab and when come back on that tab video play again automatically from where it stopped

this is script of simple video tag that I use in my html document

var video = document.getElementById('video'); var documentTitle = document.title; var updateTitleForVideo = function(state) { if(state === 'visible') { document.title=documentTitle; return; } document.title = documentTitle + ' ['+ state +']'; }; video.onpause = function() { updateTitleForVideo('Paused'); }; video.onplay = function() { updateTitleForVideo('Played'); }; document.addEventListener('visibilitychange' , function(){ var state = document.visibilityState; if(!video.paused){ if(state === 'hidden'){ video.pause(); updateTitleForVideo('Paused'); } } if(!video.played){ if(state === 'visible'){ video.play(); updateTitleForVideo('Played'); } } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const video  = document.getElementById("video")
//The rest of your code
// video.onpause etc...

window.addEventListener("blur", function() {
video.pause();
})

window.addEventListener("focus", function(){
video.play();
})

more information

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!