1

Im new to swift and Im having issues while using MPRemoteCommandCenter. When I try to control the audio settings, previously accessed songs also start playing along with the current song. Im trying to access using the following code:

UIApplication.shared.beginReceivingRemoteControlEvents()

    let commandCenter = MPRemoteCommandCenter.shared()

    commandCenter.pauseCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
        //Update your button here for the pause command
         self.player!.pause()
        return .success
    }

    commandCenter.playCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
        //Update your button here for the play command
        self.player!.play()
        return .success
    }

I have also used the following while ending the view:

UIApplication.shared.endReceivingRemoteControlEvents()

0 Answers0