In PlayerAndLyricsViewController i have added
class PlayerAndLyricsViewController: UIViewController{
let commandCenter = MPRemoteCommandCenter.shared()
override func viewDidLoad() {
commandCenter.nextTrackCommand.addTarget(self,
action:#selector(nextPressed))
commandCenter.nextTrackCommand.isEnabled = true
}
@IBAction func nextPressed(_ sender: Any) {
// Some code
}
}
I am using commandCenter to enable and disable for next, back and pause button.
When I initialise PlayerAndLyricsViewController first time Control Center working fine (Next, Pervious, Pause button), then I pop the controller from navigation stack and again initialising this controller from other view controller . Now i am putting application in background and clicking on next button (Control center) or previous button throwing error(Crash)
[_MPWeakInvocationTarget pause]: unrecognized selector sent to instance
or
[_MPWeakInvocationTarget nextPressed]: unrecognized selector sent to instance
I am not getting whats going wrong. Please help me to solve this issue.