Capturing media keys (play/pause) in OSX

99封情书 提交于 2019-12-12 12:13:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20398882/capturing-media-keys-play-pause-in-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!