Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding to media keys, block iTunes OS X

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.

like image 217
Daniel Westendorf Avatar asked Jul 11 '12 16:07

Daniel Westendorf


People also ask

Why are my media keys not working Mac?

Open System Preferences. Choose keyboard. Ensure Use F1, F2, etc, keys… is unchecked. If already unchecked, check this option for a moment, then uncheck again.

Why are my media keys not working?

Update the Keyboard Driver An outdated keyboard driver could stop the media keys from working. While Windows automatically installs any available updates, you can also install them manually. Right-click Start and select Device Manager. Extend the Keyboards menu.

How do you change key bindings on a Mac?

Customise keyboard shortcuts On your Mac, choose Apple menu > System Preferences, click Keyboard , then click Shortcuts. In the list on the left, select a category, such as Mission Control or Spotlight. In the list on the right, select the tickbox next to the shortcut you want to change.

What are media keys Mac?

The Mac Media Key Forwarder utility makes the media keys actually useful instead of an erratic mess. It allows you to prioritise Spotify or Apple Music, despite whatever else is going on in the OS. This means the media keys are predictable, which is all I want in my buttons!


1 Answers

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!

like image 84
Daniel Westendorf Avatar answered Nov 07 '22 14:11

Daniel Westendorf