What’s on your Lock Screen? Implementing MPNowPlayingInfoCenter

I am in the midst of creating an iOS mobile app for a client that will play a variety of audio tracks.
 
One of the features that I wanted to implement was to display information about a currently-playing audio track on the lock screen. This is one of those simple convenience to a mobile user and a must-have if your app has background audio playing. Personally, I use this feature all the time!
 
This is quite simple to implement in any of your current projects.
 
What is needed is the MPNowPlayingInfoCenter Class. You can review the documentation by visiting the Apple Developer Reference.
 
Go ahead and open your project. You will have to make one change in your application’s info.plist file. This change will let the iOS know that you want to play background audio.
 
Right Click and select ‘Add Row‘. Type in ‘Require Background Modes’. This will create an array called ‘Item 0’. Change it’s value to ‘App plays audio or streams audio/video using AirPlay’.
 
Once finished, it should look like this:
 
01_Plist
 
Now you will add the MediaPlayer.framework to your project:
 
02_Framework
Next, you want to import the following two class into the top of your implementation file:
 

Finally, you want to add the following to your audio button in your implementation file. Of course, you will have to modify the below to fit with your project. However, this should get you started!