This is how I observe changes from command center:
commandCenter.playCommand.addTarget(self, action: #selector(play))
commandCenter.pauseCommand.addTarget(self, action: #selector(pause))
commandCenter.changePlaybackPositionCommand.addTarget { event in
let seconds = (event as? MPChangePlaybackPositionCommandEvent)?.positionTime ?? 0
let time = CMTime(seconds: seconds, preferredTimescale: 1)
self.player.seek(to: time)
return .success
}
When I change position of slider, my app receives callback and position of audio is updated, but... position of slider in control center brings back to the previous state. Why?
The question is:
Why it doesn't stay where I left the finger, instead of getting back to the previous position?