Why do the Lock Screen audio controls disappear when I pause AVAudioPlayer?
You're on the right track ...
You seem to be missing setting;
MPNowPlayingInfoCenter nowPlayingInfo
Without it, you will get the results described, IE after pressing pause, the lock screen no longer shows the pause, or indeed that it is playing a song. Here's a guide on how to set it (i've taken this from working code I did some time back, but I'm sure you can figure out what's what).
MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc]initWithImage:albumImage]; [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = [NSDictionary dictionaryWithObjectsAndKeys:aSong.songTitle, MPMediaItemPropertyTitle, aSong.artistName, MPMediaItemPropertyArtist, artwork, MPMediaItemPropertyArtwork, 1.0f, MPNowPlayingInfoPropertyPlaybackRate, nil];
Add this Code in ViewDidLoad() For background play. It work for me. You should try it
UIApplication.sharedApplication().beginReceivingRemoteControlEvents() let session:AVAudioSession = AVAudioSession.sharedInstance() do { try session.setCategory(AVAudioSessionCategoryPlayback) } catch { print("Background Play Error") }