raingart / Nova-YouTube-extension

Apache License 2.0
199 stars 9 forks source link

Autopause on tab focus loose #24

Closed PF4Public closed 1 year ago

PF4Public commented 1 year ago

Would it be possible to pause on tab focus loose?

raingart commented 1 year ago

"Autopause all background tabs except the active one" - there is a similar plugin.

Yes, I will do what you want. I will notify you when this functionality becomes available.

PF4Public commented 1 year ago

It is indeed similar, but it does not cover the situation where one switches to non-youtube tab. I also wonder if focus loose triggers upon mouse leave from the browser window to another window. By any chance do you know if that's the case?

Thanks!

raingart commented 1 year ago

You can see for yourself. Replace:

// window.addEventListener('blur', pause);

with:

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

and turn on "Autoplay on tab focus"

PF4Public commented 1 year ago
window.addEventListener('blur', function () {
  video.pause();
});

and turn on "Autoplay on tab focus"

It works! Video got paused both by leaving the tab as well as by leaving the browser window. There is also a side effect that interacting with browser window (opening extensions menu, window menu etc.) pauses the video, therefore it would be useful to have an option for pausing specifically as some people might find this behavior disturbing.

raingart commented 1 year ago

Enable new option "Autopause video if tab loses focus" in new ver 0.32.11