iOS - Playback of recorded audio fails with OSStatus error -43 (file not found)

前端 未结 4 1411
-上瘾入骨i
-上瘾入骨i 2021-01-03 03:54

I set up an AVAudioRecorder instance the following way when my view loads:

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
audioSession.deleg         


        
4条回答
  •  醉梦人生
    2021-01-03 04:49

    Okay try this:

    Make NSURL *soundFileURL global for your class so you can access it anywhere in your class and set in the same way as you are now (except it would be soundFileURL = [NSURL fileURLWithPath:soundFilePath]; instead of NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];.

    Then change this

    self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:self.recorder.url error:&error];
    

    to this

    self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:&error];
    

提交回复
热议问题