AVAudioPlayer stops when audio input is added to AVCaptureSession

I am working on a karaoke application. He should record a video with the sound of the user singing the song. Text and melody are provided by the application.

Everything was fine with video recording until I added an audio input to AVCaptureSession. The problem is with AVAudioPlayer, which plays the tune - it just stops when starting AVCaptureSession. I did not find any restrictions on this in Apple docs.

Has anyone had experience recording audio in AVCaptureSession while playing audio through AVAudioPlayer?

+3
source share
2 answers

, . , . , .

0

, :

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

0

Source: https://habr.com/ru/post/1772123/


All Articles