Play/Pause with Earbud Remote

Related code:

http://stackoverflow.com/questions/15398237/detect-hardware-headphone-presses-in-mac

 

Because pressing the remote button and having iTunes open makes me sad.

I am not sure if this is a recent development because I could have swore that it worked before but I've found the same thing happening in the iOS app as well, where when I click the button to paus that it starts playing music.

2021 clean-up: duplicate