Provide browser media playback state

Hi. I’m working on an extension to provide the media playback state of the browser. For instance if any media is played or paused on any tab then provide the state when it changes to a console.log. I don’t seem to be finding the right code to use. If anyone could perhaps steer me in the right direction that would grreat.

Well, this is not my area of expertise so I can’t tell if there is some multimedia API available (are there similar addons with such capabilities?), BUT you could query audable tabs (those that makes sound), see this:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query

From there you could inject content script to look for the media element making the sound:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement