首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MPRemoteCommandCenter 4中的错误

MPRemoteCommandCenter 4中的错误
EN

Stack Overflow用户
提问于 2018-04-10 17:44:55
回答 1查看 2.2K关注 0票数 9

我正在尝试设置我的应用程序使用MPRemoteCommandCenter。我从文档编程指南中获得了这个示例。我导入了AVFoundation,甚至尝试导入AVKIT,我得到了未解析标识符'MPRemoteCommandCenter'的错误用法。当我创建MPRemoteCommandCenter.shared()的实例时。任何帮助都将不胜感激。

代码语言:javascript
复制
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
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-10 17:48:21

你需要import MediaPlayer

票数 32
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49759973

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档