Using Media Keys for Active Player State

I was surprised i didn't find something like this on here already but I found a useful Applescript for using F8 (Media Key) to pause whatever app is currently in a playing State.

Currently, I swap between iTunes and Spotify for playing music so I wanted a way to use the F8 key to just play or pause what was currently playing. For me i always have iTunes running

If I have Spotify open it because I am using it as a media player ATM. So the first step in the macro is the Applescript to determine what is playing. After that based on the variable, it will send either

The space bar to Spotify to pause the current track or the play/pause to iTunes to pause the current track.

What made me create an additional step in the macro was. If nothing is currently playing than the script comes back empty and nothing happens.

So I added an If/Then. So for Me is Spotify if open but is not currently playing that means I want to play the track that was paused.

If Spotify is not open then i want to play the currently paused iTunes track.

This has worked flawlessly for me the past few weeks and i also have one for F7 and F9 for Previous and next.

if you use Catalina you can just update the script to say "Music" instead of iTunes.

Just wanted to share!

Play : Pause Media Keys.kmmacros (24.1 KB)

1 Like