首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将音频输入添加到AVCaptureSession停止AVPlayer

将音频输入添加到AVCaptureSession停止AVPlayer
EN

Stack Overflow用户
提问于 2011-05-30 21:05:53
回答 3查看 1.4K关注 0票数 5

我正在开发一个音乐应用程序,其中乐谱通过使用AVPLayer播放的m4v视频文件显示,AVCaptureSession用于预览和记录表演者随着乐谱演奏的视频和音频。

不幸的是,虽然AVCaptureVideoPreviewLayer在显示音乐符号的同时还会显示实时视频,但当我尝试向AVCaptureSession添加音频输入时,AVPlayer会暂停。

我已经尝试使用单独的AVCaptureSession用于预览层和音频记录,但似乎没有什么不同。

我是在尝试做不可能的事情,还是有一种方法可以同时播放视频/音频和录制视频/音频。

据我所知,Skype和Facetime做的是类似的事情(尽管不完全一样)。

EN

回答 3

Stack Overflow用户

发布于 2012-11-02 00:08:32

将音频会话类别设置为正确的属性PlayandRecord。同时将allowmixwithothers设置为yes。

票数 0
EN

Stack Overflow用户

发布于 2013-02-27 03:44:01

尝尝这个。我只是为另一个项目这么做了,而且很管用。

代码语言:javascript
运行
复制
-(IBAction)beepingSound2
{
    //do this so that we can hear the scream and record the movie too
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
    UInt32 doSetProperty = 1;

    AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);

    [[AVAudioSession sharedInstance] setActive: YES error: nil];

    [myAudioPlayer1 stop];
    NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"long_beep" ofType: @"mp3"];
    NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];    
    myAudioPlayer1 = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
    [myAudioPlayer1 play];
}
票数 0
EN

Stack Overflow用户

发布于 2013-12-06 03:33:18

我也有同样的问题,但在iOS 7中似乎已经解决了。在iOS 7之前,我可以让AVAudioRecorder与AVPlayer同时工作,但不能让AVCaptureSession与音频一起工作。

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

https://stackoverflow.com/questions/6176654

复制
相关文章

相似问题

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