Music info showing in Command Center but not Lock Screen

Using Swift 4+, iOS 11.4+, Xcode 10+


I've built a music player using MPMediaPlayer and I can interact with it from the Command Center, however I would like to be able to also use it on the Lock Screen.


(To be honest, I'm a bit confused as to why it's showing/working in the Command Center as I have not written any code to do this.

Nevertheless, I would also like it to show in the Lock Screen.)


This is what I have done so far:


1) I'm using the applicationMusicPlayer and made certain something is playing during my tests:

let myMP:MPMusicPlayerController = MPMusicPlayerController.applicationMusicPlayer


Plus I've also tried these variations with the same failed results:

let myMP:MPMusicPlayerController = MPMusicPlayerController.applicationQueuePlayer

and

let myMP:MPMusicPlayerApplicationController = MPMusicPlayerApplicationController.applicationQueuePlayer


2) Set the BackgroundModes to include Audio, Fetch, and Remote Notifications

under Capabilities > Background Modes (info.plist)


3) Added AVAudioSession code (which doesn't seem to do anything as I have tried it and tried commenting it out and seen no difference):

      let session = AVAudioSession.sharedInstance()
        do {
            // Configure the audio session for playback
            try session.setCategory(AVAudioSessionCategoryPlayback,
                                    mode: AVAudioSessionModeDefault,
                                    options: [])
            try session.setActive(true)
        } catch let error as NSError {
            print("Failed to set the audio session category and mode: \(error.localizedDescription)")
        }


4) Used this basic code to see if I can get it to show on the lock screen with just some basic hard-coded content:

        let image = UIImage(named: "testimage")!
        let mediaArtwork = MPMediaItemArtwork(boundsSize: image.size) { (size: CGSize) -> UIImage in
            return image
        }
        let nowPlayingInfo: [String: Any] = [
            MPMediaItemPropertyArtist: "Pink Floyd",
            MPMediaItemPropertyTitle: "Wish You Were Here",
            MPMediaItemPropertyAlbumTitle: "Wish You Were Here",
            MPMediaItemPropertyArtwork: mediaArtwork
        ]
        nowPlayingInfoCenter.nowPlayingInfo = nowPlayingInfo


5) I know I have not implemented anything to actively update the info or respond to any commands as I'm just trying to get something to show on the lock screen at this point.


Primary Question:

What do I need to do to get the info to show on the Lock Screen like it does in the Command Center?


Secondary Question:

Why is the now playing info showing in the Command Center if I have done nothing to put it there?


INFO:

Link to simple project that has same issue on GitLab: https://gitlab.com/whoit/lockscreentest

Link to my question on StackOverflow: https://stackoverflow.com/questions/54171258/music-info-showing-in-command-center-but-not-lock-screen