首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >视频录制就像会说话的应用程序

视频录制就像会说话的应用程序
EN

Stack Overflow用户
提问于 2012-04-11 22:47:02
回答 1查看 1.2K关注 0票数 0

我正在开发一个应用程序,喜欢说话Tom.Some狗动画与声音是产生时,我们触摸苹果手机屏幕.For,我实现了一切,但苹果手机屏幕的视频录制。我实现了基于here..It录制狗动画没有sound.What的苹果手机屏幕的视频录制我必须做,以包括音频的视频文件?有任何样本代码可用?

如果你使用cocos2D开发你的应用程序,示例代码here会很有用!

EN

回答 1

Stack Overflow用户

发布于 2012-04-11 23:09:08

在AVFoundation框架中使用AVAudioRecorder。导入AVFoundation框架并遵循AVAudioRecorderDelegate创建AVAudioRecorder实例和NSURL实例**示例代码

录制:

代码语言:javascript
运行
复制
    [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];

播放:

代码语言:javascript
运行
复制
    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];

这只是一些示例代码……为了帮助您,但除此之外,请阅读文档。我不确定如何使嘴巴动起来,也不确定您是否想要改变音高,但这是开始录制

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10108365

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档