3

I'm working on karaoke app. It should record video with sound of a user singing a song. Lyrics and melody are are provided by app.

With video recording everything was fine until I've added audio input to AVCaptureSession. Problem is with AVAudioPlayer that plays melody - it just stops when AVCaptureSession starts. I did not find any restrictions on that in Apple docs.

Did anyone have experience with recording sound in AVCaptureSession simultaneously with playing sound via AVAudioPlayer?

halfer
  • 19,824
  • 17
  • 99
  • 186
HARDWARRIOR
  • 841
  • 1
  • 8
  • 22
  • http://stackoverflow.com/questions/21869802/avcapturesession-and-background-audio-ios-7 – Cbas Feb 19 '16 at 02:43

2 Answers2

0

Sounds like you need to set the audio to mix with other:

- (void)setupAudio {
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
    UInt32 doSetProperty = 1;
    AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);
    [[AVAudioSession sharedInstance] setActive: YES error: nil];
}

from here

Community
  • 1
  • 1
David Karlsson
  • 9,396
  • 9
  • 58
  • 103
0

I believe that your problem is due to having more than one audio sessions at the same time. I am not sure whether this will be supported.Anyway it will be better if you try it with different session categories.

Siddharth
  • 555
  • 4
  • 19