Macos – change the default app that opens when I hit play

macos

On macOS, if I hit the play button on the keyboard after closing all apps, iTunes starts. (If Spotify is open then it will play music instead.)

I don't use iTunes. Is it possible to make Spotify open when I hit the play button?

I have found this answer, but the top answer there refers to an old version of Karabiner and no longer works. The other answers don't achieve what I'm looking for: I'd like Spotify to open if I press play and Spotify is closed, and otherwise I'd like the play button to behave as normal, where it can play/pause any supported media application e.g., YouTube and VLC.

Best Answer

Finally got to try this on a Mac with that kind of keyboard (iMac). For me, the Play/Pause key plays whatever app (iTunes or Spotify) was last playing. If neither are opened, neither will launch, so the key doesn't default to iTunes for me.

I installed Karabiner, as linked in the question. I couldn't see how to create the steps shown in that link, but if you want to get into customizing that app, I'm sure it would work. Looks pretty powerful.

But, this gets you pretty close?.. I followed the top-rated answer at https://apple.stackexchange.com/questions/175215/how-do-i-assign-a-keyboard-shortcut-to-an-applescript-i-wrote and created an Automator app running a simple Applescript:

tell application "Spotify"
    activate
    playpause
end tell

I couldn't get my Mac to run the Automator service through a keyboard shortcut. So, instead, I fell back to my favorite free third-party keyboard/shortcut tool, QUicksilver. There's a ton more like that, though, so take your pick.

It was pretty easy to bind a shortcut key to the AppleScript itself (didn't need the Automator Service for this), except it wouldn't let me pick the "real" Play/Pause key, only F8 (press Fn key and press F8/PlayPause key).

But, with this AppleScript, pressing F8 does launch and play/pause Spotify! If Spotify was closed, it will launch, but it will "miss" the play command. So just press F8 again.

Feel free to tweak the AppleScript to be more aware of it Spotify is running or not. Shouldn't be too hard to do, but then again, it's not too hard to press F8 twice if it wasn't running either...

Related Question