AVAudioSession AVAudioSessionCategoryPlayAndRecord glitch

前端 未结 2 1067
北恋
北恋 2021-02-02 18:07

I would like to record videos with audio using AVCaptureSession. For this I need the AudioSessionCategory AVAudioSessionCategoryPlayAndRecord, since my

2条回答
  •  一整个雨季
    2021-02-02 18:55

    [self.captureSession startRunning];
    [[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
    [[AVAudioSession sharedInstance] setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
    

    When capureSession startRunning, deactive current audioSession and resume other interrupted music app on the background use this option AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation.

    Reset the category AVAudioSessionCategoryPlayAndRecord with current audioSession,and avtive again.

    I hope it works for you.

提交回复
热议问题