我正在开发一个应用程序,喜欢说话Tom.Some狗动画与声音是产生时,我们触摸苹果手机屏幕.For,我实现了一切,但苹果手机屏幕的视频录制。我实现了基于here..It录制狗动画没有sound.What的苹果手机屏幕的视频录制我必须做,以包括音频的视频文件?有任何样本代码可用?
如果你使用cocos2D开发你的应用程序,示例代码here会很有用!
发布于 2012-04-11 23:09:08
在AVFoundation框架中使用AVAudioRecorder。导入AVFoundation框架并遵循AVAudioRecorderDelegate创建AVAudioRecorder实例和NSURL实例**示例代码
录制:
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil]; // assign it to recording session
[audioSession setActive:YES error:nil]; // activate it!
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue: [NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey]; // assign this special hardware component as the function to record
[recordSetting setValue:[NSNumber numberWithFloat:44100.0]
forKey:AVSampleRateKey]; //44100 is the sample rate
[recordSetting setValue:[NSNumber numberWithInt: 2]
forKey:AVNumberOfChannelsKey]; // same thing
tmpFile = [NSURL fileURLWithPath:
[NSTemporaryDirectory() stringByAppendingPathComponent:
[NSString stringWithFormat: @"%.0f.%@",
[NSDate timeIntervalSinceReferenceDate] * 1000.0,
@"caf"]]]; // how we identify the audio written to the file to play later
recorder = [[AVAudioRecorder alloc] initWithURL:tmpFile settings:recordSetting
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];播放:
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
[audioSession setActive:YES error:nil];
AVAudioPlayer * player =
[[AVAudioPlayer alloc] initWithContentsOfURL:tmpFile error:nil]; // takes recording data from tmpFile where we wrote the recording in
[player prepareToPlay];
[player play];这只是一些示例代码……为了帮助您,但除此之外,请阅读文档。我不确定如何使嘴巴动起来,也不确定您是否想要改变音高,但这是开始录制
https://stackoverflow.com/questions/10108365
复制相似问题