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.'
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😀
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With