2011-04-09 100 views
2

我想在我的iPhone應用程序中錄製音頻,並且一旦錄製了音頻,我想要打開一個對話框來詢問文件名。如何通過iPhone應用程序錄制音頻?

然後我想用該文件名將音頻保存到我的應用程序中。我該怎麼做?

+0

我已經在這裏添加完整的答案http://stackoverflow.com/qu estions/1010343 /怎麼辦,我記錄音頻-ON-iphone與 - avaudiorecorder – swiftBoy 2015-02-02 11:46:45

回答

2

看看蘋果公司的SpeakHere示例應用程序,可以在他們的iOS開發者網站上找到。

4

嘗試使用AVAudioPlayer和AVAudioRecorder類音頻錄音和playback.Initially你必須建立一個音頻會話使用AVAudio會話類

AVAudioSession *audioS =[AVAudioSession sharedInstance]; 
[audioS setCategory:AVAudioSessionCategoryPlayAndRecord error:&error]; 
[audioS setActive:YES error:&error]; 

NSURL *url = [NSURL fileURLWithPath:@"/dev/null"]; 

NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat: 44100.0],AVSampleRateKey, 
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, 
[NSNumber numberWithInt: 2],AVNumberOfChannelsKey,[NSNumber numberWithInt: AVAudioQualityMax],   AVEncoderAudioQualityKey, 
          nil]; 

然後初始化錄像機和播放機類......希望這有助於

相關問題