AVAudioRecorder Won't Record On Device

后端 未结 5 1615
失恋的感觉
失恋的感觉 2021-01-02 22:28

This is my method:

-(void) playOrRecord:(UIButton *)sender {
    if (playBool == YES) {
        NSError *error = nil;
        NSString *filePath = [[NSBundle         


        
5条回答
  •  有刺的猬
    2021-01-02 22:56

    If anywhere in your code you have this setup:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
    

    Change it to:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
    

    Setting the wrong AVAudioSession category will cause record/play to fail.

提交回复
热议问题