I did the following using this guide: http://www.mabishu.com/blog/2010/11/15/playing-with-d-bus-interface-of-spotify-for-linux/
You will need to install mdbus2:
sudo apt-get install mdbus2
Now you can try out to play/pause:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
To bind this to a key you need for example AutoKey.
sudo apt-get install autokey-gtk
Create a new script and use this code:
system.exec_command("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause", getOutput=False)
and bind it to whatever key you want to use.
Of course you can use the same method to create hotkeys for next and previous :)
This command will show you which methods that is available:
mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2
Though, I don't know what will happen if you use both banshee and spotify with the same hotkey!
Xfce/Xubuntu actually already includes the functionality to map multimedia keys to custom commands, so this can be done without having to install any extra packages or create any files:
Bind the keys
(This can also be done manually through Settings → Keyboard → Application Shortcuts)
xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/XF86AudioPlay -s "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" -n -t string
xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/XF86AudioNext -s "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" -n -t string
xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/XF86AudioPrev -s "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" -n -t string
Log out and log back in (alternatively you can close any apps that may be intercepting multimedia keys, in my instance this meant Google Chrome)
It worked for me on two different computers: A Dell Optiplex running Xubuntu 14.04 and a Thinkpad running Xubuntu 16.04.
I also added a few additional notes with more detailed troubleshooting, etc. here: https://gist.github.com/bmaupin/acc566ff44a8ebf20c2aa2707789e6ea
Best Answer
Ok, found the answer. Not sure why is stopped working, but here's how to get it working again. Go into keyboard shortcuts and re-create custom shortcuts:
Play/Pause toggle:
Previous:
Next: