MPRemoteCommandCenter on Apple Watch

In order to pause/play the live stream on my app I am using MediaPlayer framework and MPRemoteCommandCenter to control it. However, when AirPods button is pressed once while the stream is been played it pauses that stream and when pressed again it does not resume playing. It seems player.rate is not being set to 0.0 when pressed after being paused. Any ideas as to why this behaviour? Here is my code:

func setupRemoteControls() {
// Get the shared MPRemoteCommandCenter
let commandCenter = MPRemoteCommandCenter.shared()

     // Add handler for play Command
    commandCenter.playCommand.addTarget { [unowned self] (event) -> MPRemoteCommandHandlerStatus in
        if self.player.rate == 0.0 {
         self.player.play()
         return MPRemoteCommandHandlerStatus.success
     }
        return MPRemoteCommandHandlerStatus.commandFailed
    }

     // Add handler for Pause Command
     commandCenter.pauseCommand.addTarget { [unowned self] (event) -> MPRemoteCommandHandlerStatus in
         if self.player.rate == 1.0 {
         self.player.pause()
         return MPRemoteCommandHandlerStatus.success
     }
         return MPRemoteCommandHandlerStatus.commandFailed
    }
 }