11

I've been using the methods described here: http://weblog.rogueamoeba.com/2007/09/29/

and read this thread: Binding to Media keys on Apple keyboards under OSX 10.5

I've overridden the sendEvent class, and can detect media key input. The problem is that iTunes launches when the Play button is pressed. The above mentioned thread states that iTunes hooks into the event somewhere else (unknown), so there isn't a way to block it from getting the Play/Pause(F8) event.

As a workaround, I've been leaving Quicktime Player open with no file. However, on Mountain Lion, Quicktime closes itself after a certain period of inactivity apparently, thus rendering this workaround unviable.

I know applications such as Spotify and MPlayerX have been able to achieve this somehow. They appear to block the event completely, not just for iTunes.

More googling, I found this discussions.apple.com/thread/2122639?start=210&tstart=0 which tracks it down to the Remote Control Daemon making the calls via Applescript. There are some work arounds which removes the execution permission on the rcd daemon (requires sudo, has to be re-run anytime OSX is updated). nomitsu.com/contents/MMFix_src.tgz

Does anyone have any insight as to how they (MPlayerX, Spotify) have been able to do this is a less hacky way?

Thanks for any advice.

Community
  • 1
  • 1
Daniel Westendorf
  • 3,375
  • 18
  • 23

1 Answers1

16

I found a pre-existing class that will do this: http://overooped.com/post/2593597587/mediakeys

Wow, that took some looking to find! Hope it helps someone else!

Daniel Westendorf
  • 3,375
  • 18
  • 23
  • 8
    +1 GitHub page: [SPMediaKeyTap](https://github.com/nevyn/SPMediaKeyTap). Thanks for sharing :) – Anne Jul 13 '12 at 09:54