Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Audio and Video > 9.4. Handling Interruptions While Recording Audio

9.4. Handling Interruptions While Recording Audio

Problem

You want your AVAudioRecorder instance to be able to resume recording after an interruption, such as an incoming phone call.

Solution

Implement the audioRecorderBeginInterruption: and audioRecorderEndInterruption:withFlags: methods of the AVAudioRecorderDelegate protocol in the delegate object of your audio recorder, and resume the recording process by invoking the record instance method of your AVAudioRecorder when the interruption has ended:

- (void)audioRecorderBeginInterruption:(AVAudioRecorder *)recorder{
  
  NSLog(@"Recording process is interrupted");
  
}

- (void)audioRecorderEndInterruption:(AVAudioRecorder *)recorder 
                           withFlags:(NSUInteger)flags{
  
  if (flags == AVAudioSessionInterruptionFlags_ShouldResume){
    NSLog(@"Resuming the recording...");
    [recorder record];
  }
  
}

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint