我想检测任何伙伴的声音(注意:我不会按任何按钮,只是感觉到声音并开始录音)用户可以说话,我的应用程序自动检测声音,当用户停止说话时,声音自动为我做这件事,我已经通过按下按钮Record,stop play..How Play..But完成了录制如何为我sense..Its a problem ...这是代码。
#import "recordViewController.h"
@implementation recordViewController
@synthesize playButton, stopButton, recordButton;
-(void) recordAudio
{
if (!audioRecorder.recording)
{
playButton.enabled = NO;
stopButton.enabled = YES;
[audioRecorder record];
}
}
-(void)stop
{
stopButton.enabled = NO;
playButton.enabled = YES;
recordButton.enabled = YES;
if (audioRecorder.recording)
{
[audioRecorder stop];
} else if (audioPlayer.playing) {
[audioPlayer stop];
}
}
-(void) playAudio
{
if (!audioRecorder.recording)
{
stopButton.enabled = YES;
recordButton.enabled = NO;
if (audioPlayer)
[audioPlayer release];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:audioRecorder.url
error:&error];
audioPlayer.delegate = self;
if (error)
NSLog(@"Error: %@",
[error localizedDescription]);
else
[audioPlayer play];
}
}
.
.
.
@end发布于 2012-01-23 06:58:55
尝尝这个
http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/
https://stackoverflow.com/questions/6386434
复制相似问题