Skip to content
  • Kai Uwe Broulik's avatar
    Compress and reduce MediaSession updates · bd66295a
    Kai Uwe Broulik authored
    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.
    bd66295a