AVCaptureSession and background audio iOS 7

In your AppDelegate: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Stop app pausing other sound. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDuckOthers | AVAudioSessionCategoryOptionDefaultToSpeaker error:nil]; } Where you are allocating AVCaptureSession: AVCaptureSession *session = [[AVCaptureSession alloc] init]; session.automaticallyConfiguresApplicationAudioSession = NO; This code will allow you to play background music and run AVCaptureSession with the microphone. SWIFT UPDATE: AppDelegate: func … Read more

How Do I Route Audio to Speaker without using AudioSessionSetProperty?

On each release of iOS, more of the audioSession properties are migrated to AVFoundation, so you should use those in preference whenever available. Since iOS 6 kAudioSessionProperty_OverrideAudioRoute is represented in AVAudioSession by the method – (BOOL)overrideOutputAudioPort:error: Available values are AVAudioSessionPortOverrideNone and AVAudioSessionPortOverrideSpeaker Here is an example audio session configured entirely via AVFoundation: – (void)configureAVAudioSession { … Read more

Detecting the iPhone’s Ring / Silent / Mute switch using AVAudioPlayer not working?

Well I found the answer thanks to someone from the Developer Forums, and you guys aren’t gonna like it! I’ve had a response from Apple on this. They’ve said they don’t and never have provided a method for detecting hardware mute switch and don’t intend to do so. 🙁 IMO there is definitely value in … Read more

How to programmatically sense the iPhone mute switch?

Thanks, JPM. Indeed, the link you provide leads to the correct answer (eventually. 😉 For completeness (because S.O. should be a source of QUICK answers! )… // “Ambient” makes it respect the mute switch // Must call this once to init session if (!gAudioSessionInited) { AudioSessionInterruptionListener inInterruptionListener = NULL; OSStatus error; if ((error = AudioSessionInitialize … Read more