Search code examples
xcodeios4core-audioavaudiorecorder

Setting a time limit when recording an audio clip?


I looked for search terms along the lines of the post title, but alas..

I am building an iPhone app using AVFoundation.

Is there a correct procedure to limit the amount of audio that will be recorded? I would like a maximum of 10 seconds.

Thanks for any help/advice/tips/pointers..


Solution

  • AVAudioRecorder has the following method:

    - (BOOL)recordForDuration:(NSTimeInterval)duration
    

    I think that will do the trick!

    http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioRecorder_ClassReference/Reference/Reference.html#//apple_ref/doc/uid/TP40008238