A simple Audio Recorder controller in Swift (for iPhone)
iOS provides a number of useful modal views within it’s system frameworks with everything from sending email to taking photos or video. However, there is still not a standard way to perform what is a fairly basic task; recording a voice memo.
I had a need for such a feature on a project recently and so I put together AudioRecorderViewController. It’s a basic modal view controller that allows you to record, playback, re-record, and save audio locally in mp4 format.
Usage is insanely simple and modelled on such classes as UIImagePickerController
:
@IBAction func presentAudioRecorder(sender: AnyObject) {
let controller = AudioRecorderViewController()
controller.audioRecorderDelegate = self
presentViewController(controller, animated: true, completion: nil)
}
func audioRecorderViewControllerDismissed(withFileURL fileURL: NSURL?) {
// do something with fileURL
dismissViewControllerAnimated(true, completion: nil)
}
Check out AudioRecorderViewController-Swift on GitHub.