Reputation: 61774
This is what I do in my code:
commandCenter.pauseCommand.addTarget(self, action: #selector(pause))
@objc private func pause() {
player?.pause()
playButton.setImage(UIImage(named: "icon-play")?.alwaysTemplate, for: .normal)
delegate?.playerViewDidPause()
}
And this is error I get when I run the app:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported action method signature. Must return MPRemoteCommandHandlerStatus or take a completion handler as the second argument.'
Upvotes: 8
Views: 2077
Reputation: 61774
You should change your method like this:
@objc private func pause() -> MPRemoteCommandHandlerStatus {
player?.pause()
playButton.setImage(UIImage(named: "icon-play")?.alwaysTemplate, for: .normal)
delegate?.playerViewDidPause()
return .success
}
and everything will work like a charm😀
Upvotes: 9