My iPad app presents a second UI to an Apple TV using the techniques discussed here - that is, be detecting and drawing to a UIScreen that represents the Apple TV:
That document also discusses receiving Remote Control Events:
When AirPlay is in use, your media may be playing in another room from your host device. The AirPlay output device may have its own controls or respond to an Apple remote control. For the best user experience, your app should listen for and respond to remote events, such as play, pause, and fast-forward requests. Enabling remote events also allows your app to respond to the controls on headphones or earbuds that are plugged into the host device physically.
I have implemented the approach they describe to begin receiving remote control events, both in my app and in a simple test project, but I'm unable to detect any events. I do not receive events when I use a headphone plugged directly into an iPad and I do not receive events when I am sending a view to the Apple TV.
I am coming to the conclusion that, in fact, the only way you can intercept remote control events is if you are streaming media to the Apple TV, rather than simply present an app UI or mirroring.
This hypothesis seems to be supported by testing with the following steps using the MixerHost sample app (http://developer.apple.com/library/ios/#samplecode/MixerHost/Introduction/Intro.html):
- Launch app on iPad with mirroring to Apple TV turned on.
- Press "Play" button on remote - nothing happens.
- Press "Play" button on the app UI and music starts playing through Apple TV.
- Press "Play" button on remote to stop music, but the music does not stop.
- Change the Airplay routing on the iPad so that it is no longer mirroring and just sending audio to the Apple TV. If you set a break point on "remoteControlReceivedWithEvent", and press the Play/Pause button the remote, you may catch the event. It is inconsistent - after receiving one or two events, it stops working.
Has anyone else had better luck with Airplay and Remote Control Events? Suggestions?