jasonzissman / TimeMe.js

A JavaScript library to accurately time how long a user views a web page, disregarding idle time and time when the tab or window is minimized.
MIT License
592 stars 124 forks source link

How to deal with embedded videos playing? #63

Open UNIQUENESSINC opened 4 years ago

UNIQUENESSINC commented 4 years ago

I have a page with embedded videos (not iframes). Short of writing a function to monitor the video embed pause/start times, can TimeMe be adjusted to factor in these elements?

Thanks

mag-hub commented 4 years ago

Even I was also working on the same concept, but the counter stops, when we perform any iFrame click, Please let me know if you found any feasible solution!

QomariSanjaya commented 2 years ago

Still no fix, if idle then the timer stop, but when we click or move mouse inside an iframe or YouTube video embed, the timer won't continue until we click or move mouse inside the parent element

bettysteger commented 2 years ago

in case someone needs it, i have a code in my interval function (that sends the tracked time to the server)

      if(document.activeElement.tagName === 'VIDEO' && !document.activeElement.paused) {
        TimeMe.resetIdleCountdown();
      }

      if(document.activeElement.tagName === 'IFRAME') {
        TimeMe.resetIdleCountdown();
        window.focus();
      }
ShardaGupta22 commented 2 years ago

Thank you so much for the code