Background Processes

An application can play audio even when it’s not the active application. Let’s modify the MediaPlayer application so that it continues playing audio even when its been put in the background state.

By default, when the user presses the Home button, an application is put into the background state and then transitioned to the suspended state shortly thereafter. Audio playback cannot continue in the suspended state because no code can be executed when an application is suspended. If your application needs to continue executing code once it is no longer active, it can request to stay in the background state instead of transitioning to the suspended state.

To delay being transitioned to the suspended state, you add a key-value ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.