Tiago Almeida
Tiago Almeida

Reputation: 14237

Capturing media keys (play/pause) in OSX

The research, the problems, the mid-age crisis

There are some questions here and there about capturing the play/pause events. The solution usually relies on extending NSApplication and capturing the sendEvent. However, there are two problems with that: The iTunes opens OR some apps capture it before (Spotify I am looking at you).

Damn you spotify

More people were bored with iTunes opening using the play/pause, and posted in the stackoverflow. However, the solution still gets beaten by spotify (and it relies on a strange whitelist). If I open the example and press one of the mediakeys spotify catches the event and that solution doesn't.

How can I defeat Spotify and capture media events?

Upvotes: 4

Views: 1865

Answers (1)

Tiago Almeida
Tiago Almeida

Reputation: 14237

Actually the SPMediaKeyTap works as expected but with a small caveat:

You have to run it in release mode!!!

I have discovered that checking the VLC source code.

I hope this can save some time to other people.

PS: If you find a better solution than SPMediaKeyTap please post it here. So far this is the best solution I have found.

Upvotes: 6

Related Questions