O'Reilly logo

iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK by Joe Keeley, Kyle Richter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required