我正在尝试设置我的应用程序使用MPRemoteCommandCenter。我从文档编程指南中获得了这个示例。我导入了AVFoundation,甚至尝试导入AVKIT,我得到了未解析标识符'MPRemoteCommandCenter'的错误用法。当我创建MPRemoteCommandCenter.shared()的实例时。任何帮助都将不胜感激。
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
}
}发布于 2018-04-10 17:48:21
你需要import MediaPlayer
https://stackoverflow.com/questions/49759973
复制相似问题