Skip to content

Properly handle redundant MediaSession play/pause requests

Tony Wasserka requested to merge neobrain/funkwhale:fix_resume_on_sleep into develop

MediaSession pause requests may happen even when Funkwhale is already in a paused state. Previously FW would flip between play/pause without consideration for the current state instead of doing nothing when the playback state matches the requested one.

Notably, this made Funkwhale resume audio playback when entering sleep mode on my system.

NOTE: My first attempt at fixing this used the navigator.mediaSession.playbackState property to read the requested from within togglePlay. That doesn't seem to work though, since at least on my browser (Firefox), that property is always None (perhaps for fingerprinting protection).

Manual testing:

  • Pause/Play button in the UI works as expected
    • Large mode
    • Tablet mode
  • Going to sleep pauses a playing track
  • Going to sleep does not resume a paused track
  • Pressing "p" toggles pause/play
Edited by Tony Wasserka

Merge request reports