AVAudioRecorder Record method returns NO at random times

后端 未结 2 1943
一整个雨季
一整个雨季 2021-01-04 06:30

I’m currently developing an app which supports in-app audio recording. The user can get a standard tableview of locally saved audio files he/she have already recorded throug

相关标签:
2条回答
  • 2021-01-04 06:58

    Is contentURL always the same or do you generate a new one each time?

    Also could you try explicitly calling prepareToRecord before record and checking whether it succeeds or not?

    0 讨论(0)
  • 2021-01-04 07:09

    Before the recording is started an audio session should be initialized:

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    NSError *err = nil;
    [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];
    if(err){
       NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
       return;
    }
    err = nil;
    [audioSession setActive:YES error:&err];
    if(err){
       NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
       return;
    }
    

    See the accepted answer for reference.

    0 讨论(0)
提交回复
热议问题