I am developing a recording application and I want to play sound when recording starts.
Unfortunately, it seems that with iOS 5 it is not possible to play system sound when AVCaptureSession with an audio device is active.
Here is the relevant piece of code that I use
- (void)viewDidLoad { [super viewDidLoad]; NSURL * soundURL = [[NSBundle mainBundle] URLForResource:@"recording-starts" withExtension:@"aif"]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundURL, &_recStartSound); //... if ([self.captureManager setupSession]) { // ... dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self.captureManager.session startRunning]; }); // ... } }
Later I just call AudioServicesPlaySystemSound(_recStartSound) and nothing happens. However, if I make the same call before setting up the session, the sound plays as expected.
I found this report an error report that exactly matches my problem, as well as this and this question, but I could not find any workaround in any of them.
How can I play a short sound before starting an AV recording?
source share