Send media play/pause shortcuts to music player rather than video player

If I have my music player (Spotify, in case it matters) but not my video player (the default Videos), then the media player keyboard shortcuts go to Spotify, and everything works fine.

If, however, I have both Spotify and Videos open, the media player keyboard shortcuts go to Videos, and start/stop/etc Videos instead of Spotify. Which is not what I want - is there any way to change this so these shortcuts affect the music player rather than the video player when both are open?


Solution 1:

I found an answer myself!

Go to Settings -> Keyboard -> Shortcuts, and create a new Custom Shortcut. Give it an appropriate name, and for the command put:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

Assign it to an appropriate key, and now that key will only send to Spotify.

For Next and Previous the commands are, respectively:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous