User hits the play/pause multimedia key, while he has two apps opened: Chromium with a YouTube Video, and Goodvibes Radio Player. What happens is that both start / stop playing at the same time.
It seems that XFCE forwards the keystroke to both applications. Tested with chromium+goodvibes, and also chromium+vlc.
Indeed. What's worse is that it toggles the pause state, so if you have a paused video in a browser and a running music player, the play/pause will pause the music player but resume the video and vice-versa :D Probably not as intended.
That's a problem with how X11 handles keyboard input. All clients can listen to any (e.g. multimedia) keys, so if two X11 clients decide to listen to the multimedia keys, the will both react.
@ochosi But in this case, it is solely the plugin doing the listening.
Repro:
Open two MPRIS-capable music players. Have one playing, one paused
pkill -f -SIGSTOP pulseaudio-plugin, press multimedia keys -> Nothing should happen, confirming the media players do not on their own react to multimedia keys
pkill -f -SIGCONT pulseaudio-plugin
Press multimedia key -> The running player pauses, the paused player resumes
I don't see how to fix this, the plugin receives keystrokes of XF86AudioPlay and treats it as PlayPause, there is no dedicated key for pausing (at least in the vast majority of keyboards out there). It's up to players to toggle play or pause depending on their internal state.
Hmm, but the MPRIS protocol does have dedicated play and pause commands. Maybe the plugin could toggle an internal state with XF86AudioPlay and distribute the same command to all clients?
Ugh, having its own internal state is asking for trouble, for example, suppose the plugin starts with state=Paused, now a player is opened and starts playing, XF86AudioPlay is pressed, pulseaudio toggles its state to Play and send Play to all players... you need to press XF86AudioPlay again to pause the player.
I checked how macOS behaves, play/pause is toggled only for the last player that the user toggle play/pause, for me this isn't exactly more sensible.
True, it's not perfect. I don't see a way to solve the multiple-active-players use case well.
Imho, Toggling only the most recently launcher player like MacOS does is most sensible. At the very least, it's better than cross-toggling all available players at once.
it's better than cross-toggling all available players at once.
Call me weird, but that's the expected behavior for me, I find it sometimes useful: Spotify is paused and a video is playing, I wanna pause the video and start listing to music again. Now I need to go back to that video an indian dude is patiently teaching something and of course I need to silence the screaming guitar solo I was listening to while coding. Everytime I switch I just need one key press.
Bottom line, I don't think there's an one size fits all solution, introducing preferences to select different behaviors is not good either (maintainability, discoverablity, etc).