208

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.

5
  • 4
    A similar question at Super User: What can I do to stop the Play / Pause button from opening iTunes?
    – Lri
    Commented Sep 5, 2012 at 9:53
  • 2
    I think the key feature that is being looked for here is for Spotify to be opened when one of the media keys is presses.
    – chrowe
    Commented Mar 18, 2017 at 3:37
  • 5
    Allow the media keys to work for multiple apps and websites with Beardedspice: beardedspice.github.io
    – Beau Smith
    Commented May 23, 2018 at 17:51
  • 1
    Two things with BeardedSpice (AKA, BS) 1) After you go in an uncheck all other apps, except Spotify, you have to close and reopen it 2) Spotify must be already running for the Play/Pause button to work (sadpepe) BS will not work if the Spotify app is not already running (i.e. it will not launch it, like MacOS did natively for Apple Music/iTunes). BS definitely doesn't give the same functionality, but it is "good enough" as long as I always leave Spotify open (yes, BS has Accessibility permissions) FYI - on Ventura 13.4 here you need BS, as Mac Media Key Forwarder is incompatible.
    – crobs808
    Commented Jun 22, 2023 at 20:00
  • There is also NoTunes (notunes in homebrew) - this can be configured to start Spotify even when no media app is running. It definitely runs on Ventura, and it claims to support other macOS versions (I have not tested). It's very, very simple and some configuration is via CLI but examples are given in the README.
    – sanmiguel
    Commented Aug 16 at 11:29

21 Answers 21

88

The software Mac Media Key Forwarder 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.

Mac Media Key Forwarder menu options

Download and installation

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

brew install macmediakeyforwarder

Notes

  • It is compatible with macOS Ventura.
  • Ensure the application is given sufficient privileges in Security & Privacy in the System Preferences.
  • I am not affiliated with the developer(s), I am just a satisfied user.

Update 2023-08-28 - Use Mac Media Key Forwarder as the alternative app Beardedspice is no longer being updated

As there are reports of Beardedspice not working for some users, and the developer no longer updating the app, it is recommended to use Mac Media Key Forwarder. Mac Media Key Forwarder is a fork of the original and it is receiving updates. The fork is recommended by the original author.

Nevertheless, Beardedspice will still work fine for most people running on e.g. MacOS High Sierra, Mojave, Catalina, Big Sur, Monterey or Ventura so it remains an alternative.

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 beardedspice

Notes

  • Beardedspice supports controlling a vast amount of media players. Simply disable any unwanted players, while keeping Spotify enabled.
22
  • 3
    I couldn't get macmediakeyforwarder to work, but found a similar project called beardedspice which seems to have more support: github.com/beardedspice/beardedspice
    – Alan
    Commented Feb 6, 2020 at 9:00
  • 1
    Tried the latest version and still couldn't get it working for me. Seems like the milgra is aware of the issue but doesn't know how to resolve it: github.com/milgra/macmediakeyforwarder/issues/… -- tried beardedspice and worked like a charm
    – Toland H
    Commented Mar 31, 2020 at 0:37
  • 3
    Neither BeardedSpice or Beardie are opening Spotify when I press play. I'm on Monterey 12.0.1
    – Chucky
    Commented Feb 13, 2022 at 14:07
  • 3
    BeardedSpice with the config in this post, didn't make Spotify pop up from pressing play, for me, but it did stop iTunes from popping up. However, it made play/pause consistently take a full second to register which was really annoying. Had to uninstall it then restart the computer to get back to prior state. This was on BigSur Commented Apr 1, 2022 at 13:12
  • 2
    I've just tested both and Mac Media Key was the only one that truly allowed me to prioritize Spotify above all other apps. This release works with macOS Monterey github.com/quentinlesceller/macmediakeyforwarder/releases
    – CIRCLE
    Commented Apr 30, 2022 at 22:23
41

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
  • 14
    Instead of killing it every time, you could disable it in your login items, thanks though, was driving me nuts
    – geermc4
    Commented May 20, 2015 at 4:13
  • 33
    Didn't work for me. Commented Jul 23, 2015 at 15:34
  • 11
    This didn't work for me in macOS 10.13.2 (17C205) Commented Mar 15, 2018 at 16:54
  • 5
    Doesn't work in 10.14 either.
    – KMSTR
    Commented Oct 1, 2018 at 11:03
  • 5
    "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? Commented Oct 16, 2018 at 12:38
24
+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
  • 6
    "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. Commented Jan 23, 2018 at 16:39
  • 1
    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
    Commented Apr 7, 2020 at 15:48
19

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. Commented 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
    Commented 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? Commented 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
    Commented 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
    Commented Jun 4, 2022 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

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.

5
  • 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
    Commented Apr 8, 2016 at 18:31
  • 17
    Still, there's something nice about this brutal answer. Commented Dec 17, 2016 at 22:25
  • I can confirm that this works in Mojave and to be iTunes-free is amazing. Commented 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
    Commented Nov 13, 2018 at 12:50
  • You can also smash your computer, it won't run iTunes then either :)
    – Sam
    Commented Jul 12 at 18:13
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

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. Commented 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
    Commented 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
    Commented 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
    Commented 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
    Commented Apr 20, 2020 at 9:12
4

A quick update from March 2023, for anyone else who stumbled upon this post:

At time of typing, it looks like there hasn't been a new release of Beardedspice since June 2017.

Meanwhile, Milgra, the original author of MacMediaKeyForwarder, now recommends using the Quentinlesceller fork of his project (latest release April 2022): MacMediaKeyForwarded (fork).

I can confirm that MacMediaKeyForwarder fork (3.1.1) works flawlessly with Spotify in Monterey 12.6.3.

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

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

3

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
    Commented Nov 20, 2021 at 18:26
1

As of October 7, 2023, this is the easiest and working solution I have seen:

  1. Install noTunes

  2. Open the noTunes application and add it to Login Items

  3. That's it! 🎉

  4. (Optional) Open any application you want in replacement of iTunes/Music when you press the Play button

1
  • Works great. App is small and lean. Thanks! Commented Jan 18 at 23:39
0

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.

0

Here is a bundle that works as a good solution:

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

3
  • 2
    Why do you feel it's a good solution? What are the advantages (/disadvantages) compared with the other solutions already provided?
    – John N
    Commented 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
    Commented Feb 10, 2017 at 16:57
  • 1
    I couldn't get this to work
    – chrowe
    Commented 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
    Commented 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
    Commented 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

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 .