gpt4 book ai didi

swift - swift 4 中的 MPRemoteCommandCenter 错误

转载 作者:搜寻专家 更新时间:2023-10-30 22:23:54 24 4
gpt4 key购买 nike

我正在尝试设置我的应用程序以使用 MPRemoteCommandCenter。我从文档编程指南中得到了这个例子。我导入了 AVFoundation,甚至尝试导入 AVKIT,我收到错误消息Use of unresolved identifier '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
}
}

最佳答案

您需要导入MediaPlayer

关于swift - swift 4 中的 MPRemoteCommandCenter 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49759973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com