AFSoundRecord.m 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // AFSoundRecord.m
  3. // AFSoundManager-Demo
  4. //
  5. // Created by Alvaro Franco on 10/02/15.
  6. // Copyright (c) 2015 AlvaroFranco. All rights reserved.
  7. //
  8. #import "AFSoundRecord.h"
  9. #import <AVFoundation/AVFoundation.h>
  10. @interface AFSoundRecord ()
  11. @property (nonatomic, strong) AVAudioRecorder *recorder;
  12. @end
  13. @implementation AFSoundRecord
  14. -(id)initWithFilePath:(NSString *)filePath {
  15. if (self == [super init]) {
  16. _recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:filePath] settings:0 error:nil];
  17. [_recorder prepareToRecord];
  18. }
  19. return self;
  20. }
  21. -(void)startRecording {
  22. [_recorder record];
  23. }
  24. -(void)saveRecording {
  25. [_recorder stop];
  26. }
  27. -(void)cancelCurrentRecording {
  28. [_recorder stop];
  29. [_recorder deleteRecording];
  30. }
  31. @end