The most requested feature for NewsHawker is support for the Apple Remote. Unfortunately, Apple doesn’t provide a public API for this. I considered only supporting the Apple Remote through third-party applications such as Sofa Control and Remote Buddy. However, once I found Martin Kahr’s Apple Remote Controller Wrapper Class, I decided to integrate support directly in NewsHawker.
I tried to map the behavior of the buttons on the Apple Remote such that they would be intuitive. The play/pause button starts and pauses speaking of news items. The left button reads the previous news item; the right, the next news item. The up button opens the page for the news item currently being read in the default web browser. The down button reads the body of the news item if only headlines are being read. Finally, holding the play/pause button for a bit quits NewsHawker. To play nice with other applications that support the Apple Remote, NewsHawker only intercepts button presses when it is the active application.
I wanted to support “scrolling” through multiple news items with the left and right buttons. The Apple Remote Control Wrapper Class sends a notification when these buttons are pressed and a second notification when they are released. In the interim, it is up to the application to implement the behavior for a button being held. This was surprisingly easy to implement:
remoteButtonRepeatTimer = [ NSTimer scheduledTimerWithTimeInterval: 0.5 /* seconds */ target: self selector: @selector( readNext: ) userInfo: self repeats: YES ];
When the button is released, I simply invalidate the timer.
It was trivial to integrate the Apple Remote Control Wrapper Class into NewsHawker. The only source change that I made to it was to have it notify its delegate on the main thread. This ensures that the timers all run in the main run loop.
I want to add a preference that specifies if NewsHawker should listen to the Apple Remote. Once I do that, I’ll release a new beta with this feature and a variety of other changes.
This entry was posted Tuesday, 13th February, 2007 at 1:50 pm and is filed under apple, cocoa, programming. You can leave a response, or trackback from your own site.
I ended up using Martin Kahr’s AppleRemote class too in Ishmael. So far it works really well, and my users haven’t reported any issues with it.
Name (required)
Mail (will not be published) (required)
Website
uDecide! ... because the important decisions are hard enough.
NewsHawker: Your own personal news anchor.
February 14th, 2007 at 12:49 pm
I ended up using Martin Kahr’s AppleRemote class too in Ishmael. So far it works really well, and my users haven’t reported any issues with it.