iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK
by Kyle Richter, Joe Keeley
Playing Music in the Background
To play music in the background, the first step is to adjust the audio session settings for the app. By default, an app uses the AVAudioSessionCategorySoloAmbient audio session category. This ensures that other audio is turned off when the app is started, and that the app audio is silenced when the screen is locked or the ring/silent switch on the device is set to silent. This session will not work, since audio will be silenced when the screen is locked or when another app is brought to the foreground. The viewDidLoad method in ICFViewController adjusts the audio session category to AVAudioSessionCategoryPlayback, which will ensure that the audio will continue playing when the app is in the background or the ring/silent ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access