Your app can request the system to let it run in the background. Once you have doen this you can check the UIApplication's property called "backgroundTimeRemaining". This is usually 11 minutes (but may change in the future).  

Apple Guide "App States and Multitasking"

Lock Button

Pressing the Sleep/Wake button causes the system to disable touch events, moves the app to the background but sets the value of the app’s applicationState property to UIApplicationStateInactive (as opposed to UIApplicationStateBackground), and finally locks the screen. 

How Does Audio Continue To Play In The Background

Pandora, Spotify, and other apps can play indefinitely in the background because the are streaming applications. They do not download, they buffer and play. Streaming works a different way to downloading. See the streaming programming guide.

Example Apps

https://github.com/mattgallagher/AudioStreamer