Override iTunes "media" keys (play, pause, etc) for Spotify? Is it possible to set Spotify as the default program when the "media" keys (play, pause, previous, next, etc) are pressed on the Mac keyboard? 

For the most part when Spotify is open, the "media" keys work fine. But every once and a while iTunes will pop up when you hit them. It'd be a lot nicer if you could just specify that Spotify is the default program when these keys are triggered, as oppose to iTunes.

If it matters, I'm using Mountain Lion.
The software Beardedspice provides a user-friendly approach to prioritizing Spotify for your media keys. It runs in the background and gives you a few simple settings in the Mac menu bar. It just works.

Download and installation
It can be downloaded and installed directly from the Beardedspice homepage, or by using e.g. Homebrew:
brew install --cask beardedspice

Notes

It is compatible with macOS Big Sur.
Ensure the application is given sufficient privileges in Security &amp; Privacy in the System Preferences.
Beardedspice supports controlling a vast amount of media players. Simply disable any unwanted players, while keeping Spotify enabled.
I am not affiliated with the developer(s), I am just a satisfied user.


Update 2021-01-16 - Use Beardedspice as the alternative app Mac Media Key Forwarder is no longer being updated
As there are reports of Mac Media Key Forwarder not working for some users, and the developer no longer updating the app, it is recommended to use Beardedspice.
Nevertheless, Mac Media Key Forwarder will still work fine for most people running on e.g. MacOS High Sierra, Mojave, Catalina, or Big Sur so it remains an alternative.

Download and installation
It can be downloaded and installed directly from GitHub, or by using e.g. Homebrew:
brew install --cask macmediakeyforwarder