Giter Club home page Giter Club logo

spmediakeytap's Introduction

SPMediaKeyTap

SPMediaKeyTap abstracts a CGEventHook and other nastiness in order to give you a relatively simple API to receive media key events (prev/next/playpause, on F7 to F9 on modern MacBook Pros) exclusively, without them reaching other applications like iTunes. SPMediaKeyTap is clever enough to resign its exclusive lock on media keys by looking for which application was active most recently: if that application is in SPMediaKeyTap's whitelist, it will resign the keys. This is similar to the behavior of Apple's applications collaborating on media key handling exclusivity, but unfortunately, Apple are not exposing any APIs allowing third-parties to join in on this collaboration.

For now, the whitelist is just a hardcoded array in +[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers]. If your app starts using SPMediaKeyTap, please mail me your bundle ID, and I'll include it in the canonical repository. This is a bad solution; a better solution would be to use distributed notifications to collaborate in creating this whitelist at runtime. Hopefully someone'll have the time and energy to write this soon.

In Example/SPMediaKeyTapExampleAppDelegate.m is an example of both how you use SPMediaKeyTap, and how you handle the semi-private NSEvent subtypes involved in media keys, including on how to fall back to non-event tap handling of these events.

SPMediaKeyTap and other CGEventHooks on the event type NSSystemDefined is known to interfere with each other and applications doing weird stuff with mouse input, because mouse clicks are also part of the NSSystemDefined category. The single issue we have had reported here at Spotify is Adobe Fireworks, in which item selection stops working with SPMediaKeyTap is active.

SPMediaKeyTap requires 10.5 to work, and disables itself on 10.4.

spmediakeytap's People

Contributors

nevyn avatar fkuehne avatar robby avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.