既然iPhone 3.0 sdk是公开的,我想我可以向那些已经玩过3.0 sdk的人提出这个问题.我想在我的应用程序中录制音频,但我想使用AVAudioRecorder而不是像SpeakHere演示的示例那样的旧录音方式.没有任何关于如何在iPhone开发人员中心做到最好的例子,只引用这些类.我是iPhone开发的新手,所以我正在寻找一个简单的示例来帮助我入门.提前致谢.
我目前正在开发一款支持应用内录音的应用.用户可以获得他/她已经通过应用程序记录的本地保存的音频文件的标准表格视图,或者按下按钮转到新的录制视图,从那里可以录制新的音频会话,这将自动获得保存到应用程序沙箱.现在这个功能在大多数情况下运行良好.我可以录制新文件并从应用程序播放它们,但随机时间录音机将无法以此方法开始录制:
-(void) startRecording
{
if (!isRecording)
{
isRecording = YES;
BOOL recordingSucess = [audioRecorder record];
if (recordingSucess)
NSLog(@"WE STARTED THE RECORDING!");
else
NSLog(@"WE DID NOT START THE RECORDING!");
// Start the timer
recordTiming = [NSDate date];
timeCheck = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timeCheck) userInfo:nil repeats:YES]
}
Run Code Online (Sandbox Code Playgroud)
也就是说,NSLog将打印出"我们没有开始录制",表示它无法开始录制.这导致仍然将空音频文件保存到应用程序,文件大小通常为4096字节.这是录音机对象的初始化方式:
-(id) initWithContentURL:(NSURL *)contentURL
{
self = [super init];
if (self)
{
NSLog(@"Initializing audio recorder!");
// Specific settings for the audio recording
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:8],
AVEncoderBitRateKey,
[NSNumber numberWithInt: …Run Code Online (Sandbox Code Playgroud)