Update MPRemoteCommandCenter play button

I have an iOS 9 app that plays MIDI-like songs using an AudioGraph. I've set up remote control commands with

MPRemoteCommandCenter
and info with
MPNowPlayingInfoCenter
such that the currently playing song shows up in Control Center and responds to control center button presses or headphone button presses. Tapping the pause button in Control Center pauses my song, but the playhead in Control Center keeps moving and the button remains as a pause icon. Tapping it again just keeps calling pause.


Is there a way to update the

MPNowPlayingInfoCenter
or
MPRemoteCommandCenter
state such that Control Center knows the song is paused?


Solutions I have tried:


  • Setting
    enabled
    on
    playCommand
    and
    pauseCommand

    has no effect
  • Setting
    MPNowPlayingInfoPropertyPlaybackRate
    to
    0
    in
    MPNowPlayingInfoCenter

    stops the playhead from advancing (and resets the elapsed time if I don't explicitly set it as well), but the button is still a pause button
  • Stopping my audio engine and calling
    AVAudioSession.setActive(false)

    this does seem to work, but it is slow, causes audio glitches, and other parts of my app rely on the audio engine running even if a song is paused
Hey! I have same problem are you have solution after 4 year? :)
The same issue here, any update?

You can try with following and set MPNowPlayingInfoPropertyPlaybackRate to 1.

commandCenter.pauseCommand.addTarget { [weak self] (event) -> MPRemoteCommandHandlerStatus in if self?.state == .playing { self?.pause() /// This is to keep the player slider position at the same of audio time paused. MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPNowPlayingInfoPropertyElapsedPlaybackTime] = CMTimeGetSeconds(self?.currentTime ?? CMTime(seconds: 0, preferredTimescale: 0)) } return .success }

Update MPRemoteCommandCenter play button
 
 
Q