111

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.

16 Answers 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
  • 11
    Instead of killing it every time, you could disable it in your login items, thanks though, was driving me nuts – geermc4 May 20 '15 at 4:13
  • 21
    Didn't work for me. – Steve Moser Jul 23 '15 at 15:34
  • 2
    @geermc4's answer is the correct long-term solution. It'll stop iTunes from launching whenever your computer restarts. If you never restart your computer, follow jakeisonline's answer. – ArtSabintsev Jul 7 '16 at 2:12
  • 6
    This didn't work for me in macOS 10.13.2 (17C205) – Cypress Frankenfeld Mar 15 '18 at 16:54
  • 3
    Doesn't work in 10.14 either. – KMSTR Oct 1 '18 at 11:03
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.

  • 3
    "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. – Lucio Mollinedo Jan 23 '18 at 16:39
12

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.)
  • 1
    Give this guy a medal. – Jonas Borggren Sep 8 '16 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 '16 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? – Per Rundblom Nov 9 '16 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 '17 at 3:11
7

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.

enter image description here

Download and installation

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

brew cask install macmediakeyforwarder

Notes

  • It is compatible with OS X Mojave.
  • The software was previously known as High Sierra Media Key Enabler.
  • 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.
6

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.
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.

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

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

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

  • 2
    I was unable to do this until I had disabled System Integrity Protection (CIP) - csrutil disable during recovery mode. – geedoubleya Jan 4 at 16:54
  • Correct, i have that disabled a long time ago. As a result, I can't tell what works with/without it :} – minusf Jan 5 at 16:20
2

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.

  • 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 '16 at 18:31
  • 7
    Still, there's something nice about this brutal answer. – Mirek Rusin Dec 17 '16 at 22:25
  • I can confirm that this works in Mojave and to be iTunes-free is amazing. – Michael DiStefano Oct 30 '18 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 '18 at 12:50
2

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.)

2

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

0

Here is a bundle that works as a good solution:

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

  • 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 '17 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 '17 at 16:57
  • I couldn't get this to work – chrowe Mar 18 '17 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

  • 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 '17 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 '18 at 14:02
-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.

You must log in to answer this question.

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