System wide play/pause sound

Hello !
I'm listenning to music using several sources (Invideous/Youtube, let's say Firefox, also Audacious) and I need to pause it very fast. I'd need to bind keys to a system-wide play/pause but I can't find any command. Within Windows, I don't remember how I did but it's pretty easy to do - i also linked in this OS it to Microsip so when I get a call, it (for instance) automatically pause a Youtube stream on call and resume it once hung up.
I'd like to bind a key to a command, so I can press a key to pause/resume any video or audio running.
Thank you !
 
playerctl work with players that support mpris

for mpv you also need to install mpv-mpris

Code:
mpv-0.38.0_1,1                 Free and open-source general-purpose video player
mpv-mpris-1.1                  MPRIS plugin for mpv

Code:
sudo pkg install mpv mpv-mpris
 
Make a sysctl that makes all sound devices hang.

More seriously, I use `kill -STOP` for that. But that is annoying when your web browser is the target.
 
Chromium has much better support for mpris than Firefox

Firefox implementation of mpris has been broken for the last 20 releases,
since about Firefox 100

mpris on Firefox doesnt show you whats currently playing or the duration from memory
 
On sway, I have swaync that support mpris with firefox without any issue. I think you could even automate the music stop when you have a call notification with it.
 
Well, so far I tested and... That's perfect !
This is exactly what I was looking for - I don't need to show what's playing or anything else, I only need to fast toggle the sound (ie. answering a call). Tested with Firefox (no way I ever use Groomium), Audacious, VLC, it works fine and I bind a key to play-pause - perfect. I'll see if I bind this to Baresip, so it pause the music when I get a call, and resume when I end the call, just like in Windows.
Regarding MPV, I don't use it so it's not very important (indeed, it does not work). Is it a fork of MPlayer ? Would be a *good* thing that's not well supported, since I run a webcam stream I don't want to stop (and it does not, yippie).
Thanks again very much !
 
Back
Top