Override iTunes "media" keys (play, pause, etc) for Spotify?

Solution 1:

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.

Beardedspice running in the background to handle media keys.

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 Monterey.
  • Ensure the application is given sufficient privileges in Security & 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, Big Sur or Monterey so it remains an alternative.

enter image description here

Download and installation

It can be downloaded and installed directly from GitHub, or by using e.g. Homebrew:

brew install --cask macmediakeyforwarder

Solution 2:

I find this problem happens for me inconsistently, so I use this fairly destructive approach when it happens:

  1. Open up "Activity Monitor", which can be found easily using Spotlight
  2. Select either "CPU" or "Memory" from the pills at the top of the dialog
  3. In the search box, top right, type: itunes
  4. "ituneshelper" is what you're looking for. Find it, click on it, then select "Force kill"
  5. Accept the confirmation

Spotify also has a helper running. My guess is that it depends which one loads first.


Permanent solution

Per comment below – you can simply remove it from your login items:

  1. Search for 'Login Items' in System Preferences
  2. Select itunes helper
  3. Click [-] button
  4. Restart your mac

Solution 3:

Lifehacker ran an article about this very problem a while back for Snow Leopard. http://lifehacker.com/5531707/free-your-macs-media-keys-from-itunes-grasp

The tricks we used before were far less than ideal, requiring you to start up QuickTime in the background, or do some serious hacking to system files within iTunes.app. NoMitsu has created a one-click installer that patches the remote control daemon, the app responsible for managing the media keys. Just download the patch and double-click on it. After entering your password, your media keys will be free from iTunes' grasp.

I presume you have already tried this. As I recall the media keys will control the last program that was active so if Spotify was the last media app you had open (and is currently open) then the media keys will control that. Hope this helps you out.

Solution 4:

I'v had this problem for years and in my case it goes beyond iTunes. When working in Keynote or another application that "claims" the media keys, controlling Spotify (or other music players) won't work.

But now I've finally solved it!

Quite a long process but here goes.

Binding Media keys to one Media player, and that player only:

  • Go to system preferences > Keyboard > and select "Use all F1, F2, etc keys as standard function keys". (this will disable all quick controls like brightness, and volume) (To enable those again:)
  • Download "Karabiner"
  • Choose "Change F1..F19 Key & Function key..." > "Change F1..F19 Key" > "F1..F12 to Functional Key"
  • Enable all but "F7, F8, F9 to music Controls" (unless you'd like to map any other keys to features of your choice) (now the brightness etc. should be working again)
  • Download and install FastScripts
  • Open Automator and create a new Service
  • Change "service receives selected:" [text] to [no input]
  • Add the "run apple script" action to the main screen
  • Enter and save the following three apple scripts (for Spotify, but I'm sure this works with some other media players to) to the folder [your user]/Library/Scripts:

try
tell application "Spotify"
    playpause
end tell
end try
return

try
tell application "Spotify"
    previous track
end tell
end try
return

try
tell application "Spotify"
    next track
end tell
end try
return
  • And finally in In FastScripts, go to "Script Shortcuts" and set F7, F8, and F9 as shortcuts for your scripts!

Easy as that! =)

EDIT: Karabiner does not yet work with Sierra, but a pre-release called "Karabiner Elements" does the trick. In that case, skip the first 4 steps in the above list and instead:

  • Install Karabiner Elements
  • Select Function keys and map f7>f7, f8>f8, f9>f9 (then continue from the list above by installing Fastscripts.)