如何通过 iPhone 应用程序录制音频? [英] How to record audio through an iPhone app?
本文介绍了如何通过 iPhone 应用程序录制音频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的 iPhone 应用程序中录制音频,一旦录制了音频,我想打开一个对话框,要求输入文件名.
I want to record audio in my iPhone app and once the audio is recorded I want a dialog box to open which asks for the filename.
然后我想将带有该文件名的音频保存到我的应用程序中.我该怎么做?
And then I want to save the audio with that filename into my app. How can I do so?
推荐答案
尝试使用 AVAudioPlayer 和 AVAudioRecorder 类进行音频录制和播放.首先您必须使用 AVAudio 会话类建立音频会话
try using AVAudioPlayer and AVAudioRecorder classes for audio recording and playback.Initially you have to establish an audio session using AVAudio session class
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];
然后初始化记录器和播放器类...希望这有帮助
and then initialize the recorder and player classes...Hope this helps
这篇关于如何通过 iPhone 应用程序录制音频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文