Airplay, Apple TV and Remote Events - is it only for streaming audio/video?
Asked Answered
D

1

13

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):

  1. Launch app on iPad with mirroring to Apple TV turned on.
  2. Press "Play" button on remote - nothing happens.
  3. Press "Play" button on the app UI and music starts playing through Apple TV.
  4. Press "Play" button on remote to stop music, but the music does not stop.
  5. 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?

Donata answered 10/12, 2011 at 22:26 Comment(2)
Great question. My workplace submitted a tech support incident with Apple w.r.t. this precise question not too long ago. I'll see if we've had a response yet.Hamper
Have you guys heard back from Apple on this one?Donata
S
3

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...

Schleswig answered 12/12, 2011 at 23:18 Comment(4)
I was not able to get headphone remote control events working. They work with MixerHost, but that's when sending audio. Do you have a sample app that you could share so I can check out your implementation? Thanks Mark.Donata
The app I was using has some proprietary code, so I can't share it... But here are some things to check: - make sure to receive events in your root ViewController - make sure your responder chain is in order / your ViewController is the first responder - you may need your app to be using an AVAudioSession: NSError *setCategoryError = nil; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];Schleswig
Yup, did all those things, including the AVAudioSession trick, but no go with headphone events. Fact is, that wouldn't help me much if did work because what I'm really after is the remote control functionality, and it sounds like that is broken. I guess I'll submit a bug to Apple.Donata
This is similar to my exploration of this as well.Poulterer

© 2022 - 2024 — McMap. All rights reserved.