Airplay、Apple TV 和远程事件 - 是否仅适用于流式音频/视频?
我的 iPad 应用程序使用此处讨论的技术向 Apple TV 呈现第二个 UI,即检测并绘制代表 Apple TV 的 UIScreen:
该文档还讨论了接收远程控制事件:
使用 AirPlay 时,您的媒体可能会通过您的主机设备在另一个房间中播放。 AirPlay 输出设备可能有自己的控件或响应 Apple 遥控器。为了获得最佳的用户体验,您的应用程序应该侦听并响应远程事件,例如播放、暂停和快进请求。启用远程事件还允许您的应用程序响应物理插入主机设备的耳机或耳塞上的控件。
我已经实现了他们描述的方法来开始接收远程控制事件,无论是在我的应用程序中还是在简单的测试项目,但我无法检测到任何事件。当我使用直接插入 iPad 的耳机时,我没有收到事件;当我向 Apple TV 发送视图时,我也没有收到事件。
我得出的结论是,事实上,拦截远程控制事件的唯一方法是将媒体流传输到 Apple TV,而不是简单地呈现应用程序 UI 或镜像。
使用 MixerHost 示例应用程序 (http://developer.apple.com/library/ios/#samplecode/MixerHost/Introduction/Intro.html):
- 在 iPad 上启动应用程序,并打开镜像到 Apple TV 的功能。
- 按遥控器上的“播放”按钮 - 没有任何反应。
- 按应用程序 UI 上的“播放”按钮,音乐开始通过 Apple TV 播放。
- 按遥控器上的“播放”按钮停止音乐,但音乐并未停止。
- 更改 iPad 上的 Airplay 路由,使其不再镜像而仅将音频发送到 Apple TV。如果您在“remoteControlReceivedWithEvent”上设置断点,然后按遥控器上的“播放/暂停”按钮,您可能会捕获该事件。它是不一致的——收到一两个事件后,它就停止工作。
还有其他人在 Airplay 和远程控制事件方面有更好的运气吗?建议?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还通过 AirPlay 镜像尝试了第二个屏幕 UI,我可以确认在镜像期间 Apple 远程事件不会从 Apple TV 转发到 iOS 设备。
在我自己的测试应用程序中,我可以一致地接收耳机远程控制事件以及来自“正在播放控件”的远程控制事件——双击主页按钮后底部工具栏中可用的媒体控件。
但 Apple TV 遥控器上从未显示任何事件。
只是另一个要添加到 Apple / AirPlay 愿望清单中的项目...
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...