-
Notifications
You must be signed in to change notification settings - Fork 524
Background Audio
Josh Habdas edited this page Jun 22, 2015
·
5 revisions
Follow the steps below to get background audio working on iOS. Note that background audio only works on devices and not the simulator.
- Update your App-Info.plist file to include the audio in the UIBackgroundModes array. This is easy to do in Xcode 5:
- Select your project
- Select your project target
- Goto the Capabilities tab
- Expand the Background Modes pane
- Turn Background Modes on and select Audio and Airplay
- Initialize your AudioSession somewhere near the beginning of your app. The ExampleApp does this in AppDelegate::application:didFinishLaunchingWithOptions.
NSError* error;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
In order to successfully resume audio when the app is backgrounded, add the following while initializing your app's AudioSession:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];