If you're interested in a better version of that I have a project that works with all players that support the MPRIS DBus interface: https://github.com/mariusor/mpris-ctl. I'm using it for keybindings to play/pause and show song information with a tiling windows manager.