//
// ViewController.m
// RecorderVoice
//
// Created by hq on 16/5/12.
// Copyright © 2016年 hanqing. All rights reserved.
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()
@property(nonatomic,strong) AVAudioRecorder *recoder;
- (IBAction)startRecord:(UIButton *)sender;
- (IBAction)stopRecord:(UIButton *)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *documentPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
//保存的路径名
NSString *urlString=[documentPath stringByAppendingString:@"hq.wav"];
self.recoder=[[AVAudioRecorder alloc]initWithURL:[NSURL URLWithString:urlString] settings:nil error:nil];
[self.recoder prepareToRecord];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
//开始录音
- (IBAction)startRecord:(UIButton *)sender {
[self.recoder record];
}
//结束录音
- (IBAction)stopRecord:(UIButton *)sender {
[self.recoder stop];
}
@end
ios最简单的录音程序
最新推荐文章于 2021-05-25 23:05:06 发布
6081

被折叠的 条评论
为什么被折叠?



