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:
http://developer.apple.com/library/IOs/#documentation/AudioVideo/Conceptual/AirPlayGuide/EnrichYourAppforAirPlay/EnrichYourAppforAirPlay.html
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):
Has anyone else had better luck with Airplay and Remote Control Events? Suggestions?
The original Apple AirPlay is a proprietary system for streaming audio or video from one Apple source -- typically an iPhone, iPad or a Mac computer -- to another device over a home network.
AirPlay allows you to wirelessly cast audio or video from your iPhone, iPad, or Mac to an Apple TV or an AirPlay 2-compatible smart TV, as long as your device is connected to the same Wi-Fi as the TV. You can stream videos from any iPhone, iPad, iPod touch, or Mac.
AirPlay lets you do it all. AirPlay lets you share videos, photos, music, and more from Apple devices to your Apple TV, favorite speakers, and popular smart TVs.
Apple AirPlay lets you stream, control, and share content from your iPhone, iPad, or Mac to your compatible Roku streaming device. You can watch movies, TV shows, and family videos, listen to popular music, or browse vacation photos.
I've also been experimenting with a second screen UI via AirPlay Mirroring, and I can confirm that Apple remote events are not forwarded from the Apple TV to the iOS device during Mirroring.
In my own test application, I can receive headphone remote control events consistently and remote control events from the "Now Playing Controls" -- the media controls available in the bottom toolbar after a double-tap on the home button.
But no events ever show up from the Apple TV remote.
Just another item to add to the Apple / AirPlay wishlist...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With