我正在尝试将我的应用程序设置为使用MPRemoteCommandCenter。我从文档编程指南中得到了这个示例。我导入了AVFoundation,甚至尝试导入AVKIT,我发现了错误
使用未解析的标识符“MPRemoteCommandCenter”
。创建MPRemoteCommandCenter实例时。共享()。任何帮助都将不胜感激。
func setupRemoteTransportControls() {
// Get the shared MPRemoteCommandCenter
let commandCenter = MPRemoteCommandCenter.shared() Error //**Use of unresolved identifier 'MPRemoteCommandCenter'**
// Add handler for Play Command
commandCenter.playCommand.addTarget { [unowned self] event in
if self.audioPlayer.rate == 0.0 {
self.audioPlayer.play()
return .success
}
return .commandFailed
}
// Add handler for Pause Command
commandCenter.pauseCommand.addTarget { [unowned self] event in
if self.audioPlayer.rate == 1.0 {
self.audioPlayer.pause()
return .success
}
return .commandFailed
}
}