180

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.

3

19 Answers 19

69

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
16
39

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
13
  • 12
    Instead of killing it every time, you could disable it in your login items, thanks though, was driving me nuts
    – geermc4
    May 20, 2015 at 4:13
  • 30
    Didn't work for me. Jul 23, 2015 at 15:34
  • 9
    This didn't work for me in macOS 10.13.2 (17C205) Mar 15, 2018 at 16:54
  • 4
    Doesn't work in 10.14 either.
    – KMSTR
    Oct 1, 2018 at 11:03
  • 4
    "Not 10.15 either "in october 9th 2018? Mojave is version 10.14. There is no OSX 10.15 yet. Are you from the future? Oct 16, 2018 at 12:38
22
+25

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.

2
  • 5
    "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." No. That's now how it works. Tested it on 10.13.2 and it doesn't work like that. It keeps on opening iTunes. Jan 23, 2018 at 16:39
  • The link to the download of that mmix.app by NoMitsu is broken and there doesn't seem to be any non-suspicious looking source for it. Also The link you provide goes to an older lifehacker article, that references the article your are quoting from.
    – tilltnet
    Apr 7, 2020 at 15:48
16

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.)
4
  • 1
    Give this guy a medal. Sep 8, 2016 at 12:24
  • Then you might as well use the spotify native shortcuts. Media keys are special keycodes... they are not function keys. That they occupy the same space on your keyboard is incidental, and does not solve my problem. The question here is well-asked and only a answer that addresses the question asked will solve my issue. For instance, my Bluetooth headset sends through the media keys as part of their controls, and this hack does not help me. Nor will it help me if I had some non-standard keyboard.
    – Marius
    Oct 27, 2016 at 14:10
  • How do you mean? The native shortcuts only work when you're using Spotify (and when you've switched to another application that does not claim the media keys for itself), right? Switching to keynote for example breaks Spotifys "bind" on media keys and prevents you from controlling Spotify. I read your question again, and in my understanding I had the exact same problem as you. This solution solved it for me, so maybe try it again? Nov 9, 2016 at 13:01
  • 1
    Worked for me, but I was encountering a bit of lag. I'm not sure if the bottleneck is the service or Fastscripts. I noticed that executing other scripts have a bit of lag as well, so that's where I'm leaning towards.
    – juil
    Sep 6, 2017 at 3:11
8

After looking around for a while I finally found https://github.com/zsszatmari/MagicKeys

It is not specific to Spotify but will let you select any application to launch when a media key is pressed.

There are only 2 small issues I see with it (and one is also an issue with the default iTunes behavior).

  1. It opens the application with any of the 3 media buttons. While this is what the original question requested, it is not the default behavior for iTunes. iTunes only opens when you press the play/pause button (not the back/forward buttons). Ideally this would be an option that the user could select.
  2. It does not start the media playing after the application is launched. The same thing is also true with iTunes by default but it would be nice if you just had to press play once to open Spotify and start playing music rather than to press the key, wait for the app to start and then press the key again.
3
7

Settings>User & Groups>Login Items

  • remove Itunes helper
  • Add Spotify (check hide)

Restart your computer. It will always play Spotify since it's open in the background and not itunes.

enter image description here

1
  • Wasn't able to make this solution work on the newer M1 Macs.
    – Ro Yo Mi
    Jun 4 at 18:40
5

Adding on to what @sjg said, you could have Spotify opened at startup (presuming that you don't care for iTunes to open at startup) so that you can have the media keys work with Spotify right from login. Again, this is only a workaround and not really a full solution, but if you want it to be opened at startup, go to Spotify>Preferences and scroll down to "Open Spotify automatically after you login to the computer" and select Open automatically.

5

As suggested in the comment by Beau Smith, the app BeardedSpice do an amazing job! Not only for Spotify but also for a lot of other services (Netflix, Youtube, SoundCloud, etc.)


BeardedSpice is a menubar application for Mac OSX that allows you to control web based media players and some native apps with the media keys found on Mac keyboards. It is an extensible application that works with Chrome (Canary, Yandex, Chromium) and Safari, and can control any tab with an applicable media player.

4

Is better going to User (Settings ->Users and Groups) and then click on "Startup items" and disable ituneshelper. By this way you don't need to kill the process every time you switch on the device.

enter image description here

4

a solution that worked for me for Mojave was to remove the execution bit from iTunes:

sudo chmod -x /Applications/iTunes.app/Contents/MacOS/iTunes

and optionally add the media player in question under

Preferences -> Security & privacy -> Accessibility

5
  • 3
    I was unable to do this until I had disabled System Integrity Protection (CIP) - csrutil disable during recovery mode. Jan 4, 2019 at 16:54
  • 1
    Correct, i have that disabled a long time ago. As a result, I can't tell what works with/without it :}
    – minusf
    Jan 5, 2019 at 16:20
  • This worked for me, I didn't even needed the terminal part. Just enabled Deezer to control my computer... Thanks!
    – taiar
    Oct 1, 2019 at 11:43
  • Ha, they very specifically made a change that breaks this. On Catalina, you now have the Music app which, strangely, lives in System, but Unable to change file mode on /System/Applications/Music.app/Contents/MacOS/Music: Operation not permitted even with sudo. /sigh
    – ruffin
    Apr 17, 2020 at 14:38
  • YMMV, on catalina Music.app is way less aggresive in stealing the media keys (when it's not running) to the point that i am not looking for ways to disable it. If i have a media player running, the media keys just work. If nothing is running, only then Music.app starts.
    – minusf
    Apr 20, 2020 at 9:12
3

Here's how this should work:

  1. Pressing a media key on your keyboard should send a message to the currently-active application, if it's one that supports media keys
  2. If not, the most recently-active media-key-supporting application should be sent the message
  3. If no application is available, open the default media-key-supporting application (e.g. iTunes, but configurable)
  4. Each media-key-supporting application should have an opt-out in its preferences

It doesn't seem that difficult to me, yet this is one of those small usability flaws of OSX that sits on a pile of things that just serves to make the overall experience sub-par.

3

You can go to your Applications library and manually delete iTunes.app in the terminal using:

sudo rm -rf /Applications/iTunes.app

Won't automatically make Spotify your default media player but iTunes will no longer exist on your computer.

4
  • 3
    The question is not how to remove iTunes, but how to change keyboard behavior. Removing an app provided with the OS is a dangerous way to solve the play button sporadically opening iTunes.
    – samh
    Apr 8, 2016 at 18:31
  • 13
    Still, there's something nice about this brutal answer. Dec 17, 2016 at 22:25
  • I can confirm that this works in Mojave and to be iTunes-free is amazing. Oct 30, 2018 at 23:20
  • bit heavy handed, but sure. another alternative is to remove the execution bit: sudo chmod -x /Applications/iTunes.app/Contents/MacOS/iTunes
    – minusf
    Nov 13, 2018 at 12:50
2

I've created an easier implementation of Per's answer with BetterTouchTool.

  1. Download BetterTouchTool (it has a 45 day free trial, afterwards its a one time purchase of $9).
  2. Create a keyboard shortcut, bound to the Play/Pause key.
  3. Optional: if you wish to open Spotify when its closed, add the following action (Apple Script (blocking)):

Open Spotify

tell application "Spotify"
    if it is not running then launch
    set frontmost to true
    activate
end tell
  1. Add an Apple Script (async in background) action: Pause/Play Spotify
using terms from application "Spotify"
    if player state of application "Spotify" is paused then
        tell application "Spotify" to play
    else
        tell application "Spotify" to pause
    end if
end using terms from
1
  • 1
    This is handy, I already use BTT for my trackpad and window snapping, so it tacks on well. I also notice that this makes my next/previous keys to work with spotify as well.
    – Siddhartha
    Nov 20, 2021 at 18:26
0

Here is a bundle that works as a good solution:

https://github.com/rpendleton/spotify-rcd

3
  • 1
    Why do you feel it's a good solution? What are the advantages (/disadvantages) compared with the other solutions already provided?
    – John N
    Feb 10, 2017 at 7:45
  • Honestly, you caught me there.. I thought it worked for me but I haven't been able to follow their instructions due to my poor developing skills. I've been scouring the coder's web and these two developers (rpendleton and kikobeats) are the only ones that seem to grasp the situation and have created a bundle that solves the issue according to peer review on kikobeats website. (I invite anyone with better skills to verify if their work is good)
    – JesusO
    Feb 10, 2017 at 16:57
  • 1
    I couldn't get this to work
    – chrowe
    Mar 18, 2017 at 3:06
0

No need to change libraries or programs or download tools. Everything you need is on hand and easy to use. The tip from 2007 still works: set with "Automator" what you want to do and asign it to a keyboard-shortcut.

https://forums.macrumors.com/threads/can-i-assign-f8-the-play-pause-key-to-launch-spotify-instead-of-itunes.1626645/#post-17779801

2
  • Welcome to Ask Different! We're trying to find the best answers and those answers will provide info as to why they're the best. Explain why you think the link you provided will answer the question. Answers should be self-contained so others can find them by using the search feature. Links can change and become outdated so we prefer the answers to not just be a link. See How to Answer on how to provide a quality answer. - From Review
    – fsb
    Mar 2, 2017 at 16:03
  • 1
    Thanks, this works, but it's worth mentioning that this is just adding a new shortcut, and that shortcut can't be the Play/Pause key, so it doesn't quite answer the question.
    – Jethro
    Jun 30, 2018 at 14:02
0

The keyboard buttons do not control iTunes (installed with Retroactive) in Catalina. They control the Music app instead.

-1

there is an option on the keyboard to either use the traditional F1, F2, etc keys, or the special features. Maybe you have selected the traditional mode.

-1

Something that works most of the time for me is simply rebooting the program in question.

Say for instance Spotify is not playing nice with the media keys (i.e. they don't do anything when you have Spotify open). I usually quit Spotify and restart it and when it reopens the media keys automatically work again.

Obviously, this is less than ideal and definitely doesn't do anything to make Spotify the 'default' media key program, but it does act as a soft reset for the keys which can help until a better answer is created by Apple / Spotify.

-1

Posting this April 3rd, 2020. Working perfectly well for me.


I am using shpotify with skhd. To install shpotify (command line interface for Spotify):

brew install shpotify

No need to worry about Spotify API if prompted - that is optional if you want to be able to choose tracks from the command line; play/pause, and volume settings work out of the box. Then installing skhd (amazing shortcut manager for OSX):

brew install koekeishiya/formulae/skhd
brew services start skhd

Then head over to the file ~/.skhdrc which is the configuration file for skhd and add the following:

# Spotify
fn - f8 : spotify pause
fn - f11 : spotify vol down
fn - f12 : spotify vol up

This will map your FN+Play/Pause, FN+Volume Up, and FN+Volume Down to Spotify specifically. Pressing any of those keys while Spotify is closed will automatically open it.

The added benefit of using this method is that you can control Spotify when it's playing both on your computer or an external device (i.e. Google Home), and allows more flexibility when pausing Spotify (i.e. when you open a video on the browser and OSX automatically maps the Play/Pause to the video as opposed to music playing in the background by Spotify).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .