iOS 应用正在使用AVPlayer,可以在Apple TV 上播放视频,但应用无法接收Apple TV 远程控制通知。例如,当用户按下 Remote 上的暂停按钮时,本地应用程序应该获取此信息并将按钮更改为暂停状态。我已将播放器 Controller 设置为第一响应者。
最佳答案
在您的 MainViewController 中覆盖“pressesEnded”:
override func pressesEnded(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
for press in presses {
if(press.type == UIPressType.PlayPause) {
// do what you want
} else {
super.pressesEnded(presses, withEvent: event)
}
}
}
关于ios - 如何从 Apple TV Remote 接收控制通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31826204/