The Media Player Remote Interfacing Specification is a D-Bus interface for controlling media players in a standardized way. This for example is what Gnome uses when pressing the media keys or the play/pause buttons in the notification tray. This means that any media player which implements this interface can be controlled in the same manner!
An easy way to make use of MPRIS is through the
playerctl command which give very easy access to this interface from the command line and most importantly, scripts. When switching from Gnome to Sway I was able to have my headset’s buttons work to play and pause music by configuring some bindings which call
# Sway configuration for media keys
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
Looking at the specification I find that this is quite a capable protocol, allowing you to get short lists of songs, for example the current album. It can also call up the music player’s UI, query various attributes, start playlists… I am very glad this protocol exists and is so simple to use and I’m sure I’m only scraping the surface of what this allows. To my (very relative) deception the protocol does not seem to allow for creating completely “headless” music players that would be controlled only through the interface, as it doesn’t seem to allow browsing libraries.