Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
421 views
in Technique[技术] by (71.8m points)

objective c - How to record audio through an iPhone app?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...