Skip to content

Compress and reduce MediaSession updates

Kai Uwe Broulik requested to merge work/optimized-media-session into master

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.

  • Verified that title, artist, album isn't sent over when mediaMetadata was merely assigned an object with same data again
  • Verified that changes are still signalled out correctly when they actually changed, e.g. changing videos
  • Verified that setting and unsetting media session action handlers still works
  • Verified that setting multiple handlers in one go will send them only once

Merge request reports