一旦松动记录,则必须重新启动声音再次录制,你必须在前台做到这一点。您可以捕获音频中断事件,以便中断和中断结束。但目前存在缺陷,而且很多人没有收到结束事件。
AVCaptureSession *captureSession;
.......
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioInterruptionEnded) name:AVCaptureSessionInterruptionEndedNotification object:captureSession];
[captureSession addObserver: self forKeyPath:@"running" options:0x3 context:nil];
[captureSession addObserver: self forKeyPath:@"interrupted" options:0x3 context:nil];
有两种捕捉音频的方法。使用更高级别的AVCapture会议,或下一级AudioQueue,但都被第一款的限制。
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"interrupted"])
{
// try restart here if in foreground
// post local notification if in background to bring to foreground and then restart
}
}
能否请你解释如何做到这一点? 'AudioSessionSetActive(真);'没有帮助! – saiy2k 2013-08-09 13:03:23