码迷,mamicode.com
首页 > 其他好文 > 详细

语音(LCVoiceHudDemo)

时间:2014-12-08 15:25:48      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   sp   for   on   div   

代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    voice = [[LCVoice alloc] init];
   
    UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(self.view.frame.size.width/2-50, self.view.frame.size.height-100, 100, 100);
    [button setTitle:@"录制" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(recordStart) forControlEvents:UIControlEventTouchDown];
    [button addTarget:self action:@selector(recordEnd) forControlEvents:UIControlEventTouchUpInside];
    [button addTarget:self action:@selector(recordCancel) forControlEvents:UIControlEventTouchUpOutside];
    [self.view addSubview:button];
}
-(void) recordStart
{
    [voice startRecordWithPath:[NSString stringWithFormat:@"%@/Documents/MySound.caf", NSHomeDirectory()]];
}

-(void) recordEnd
{
    [voice stopRecordWithCompletionBlock:^{
        
        if (voice.recordTime > 0.0f) {
            UIAlertView * alert = [[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithFormat:@"\nrecord finish ! \npath:%@ \nduration:%f",voice.recordPath,voice.recordTime] delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
            [alert show];
         }
        
    }];
}

-(void) recordCancel
{
    [voice cancelled];
    
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:nil message:@"取消了" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
    [alert show];
}

 

语音(LCVoiceHudDemo)

标签:style   blog   io   ar   color   sp   for   on   div   

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4151018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!