I would like to show play/pause controls on the ios lockscren. It's an audio app using libPd. What I did so far :
In the Info.plist : Set the value of the key "Required background modes" to "App plays audio or streams audio/video using AirPlay"
In the capabilities : Enable Background Modes ("Audio, Airplay, and Picture in Picture")
In the source code :
Configure the AVAudioSession :
try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: [])
try! AVAudioSession.sharedInstance().setActive(true)
add infos to the MPNowPlayingInfoCenter :
let nowPlayingInfo = [
MPMediaItemPropertyArtist: "test",
MPNowPlayingInfoPropertyPlaybackRate: NSNumber(value: 1.0 as Float)] as [String : Any]
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
Nothing appear on the lockscreen/control center. I don't understand what triggers the control display. When I use a AVAudioPlayer and play it, it works. But I guess those controls are not limited to AVAudioPlayer.