macOS High Sierra Media Key Enabler for iTunes/Spotify
It only works with physical buttons, won't work with the TouchBar. This small app detects if Spotify is installed and offers to switch between controlling iTunes and Spotify.
I don't have a developer certificate so trust the app when macOS asks. Feel free to compile the project yourself.