Compress and reduce MediaSession updates

Authored by broulik on May 22 2020, 3:07 PM.


Compress and reduce MediaSession updates

Websites typically set all their callbacks (play, pause, nexttrack, previoustrack, etc) in one go,
which would have us send them over from the content script to the extension and to the host, signalling
individual MPRIS property changes. Optimize this by batching subsequent calls.

Furthermore, check if playbackState and metadata actually changed before sending them over.
There's no point in sending the data over to the host which will then find they haven't changed.

The object behind the "mediaSessionsClassName" is turned into a "class" (not ES6 Class for Firefox ESR
compat) and an instance is created. This allows using "this" from within its handlers, cleaning
up the code somewhat.