Is there an API that would allow me to pause all playing videos?

I have an extension that opens a popup every X minutes telling the user to do something. A major complaint from users is that it’s annoying if they are watching a video because they can’t pause it.

Is there an Webextension API that I can use to pause all videos/audio that may be playing in Firefox?

The API is called “content scripts”… Really, the only control you have is to look for and objects and pause them.

If you are only concerned about the noise, you could of course just mute the tabs temporarily.

1 Like

Thanks. I was kind of hoping that there was a better API for that, but I guess not.

This may be much easier than you think:

document.querySelectorAll('video').forEach(video => video.pause());

I’ve tested it on YouTube and it works :slight_smile:.
Just inject it to the tab as content script and it should pause all videos there.

1 Like