Ios AVCaptureSession DidFinishRedingToOutputFileATURL:发生中断(如控制中心)时不调用
我花了很多时间在这上面,所以我想我应该重新发布 我正在使用带有AVCaptureMovieFileOutput的AVCaptureSession,允许用户在提供暂停录制按钮的同时录制视频 在应用程序后台启动、控制中心解除或出现报警/呼叫等中断之前,此功能非常有效。根据设备硬件的不同,我们会看到不同类型的错误Ios AVCaptureSession DidFinishRedingToOutputFileATURL:发生中断(如控制中心)时不调用,ios,objective-c,avcapturesession,Ios,Objective C,Avcapturesession,我花了很多时间在这上面,所以我想我应该重新发布 我正在使用带有AVCaptureMovieFileOutput的AVCaptureSession,允许用户在提供暂停录制按钮的同时录制视频 在应用程序后台启动、控制中心解除或出现报警/呼叫等中断之前,此功能非常有效。根据设备硬件的不同,我们会看到不同类型的错误 在较旧的设备上,即使我们重新初始化captureSession,捕获会话也将无法在此类事件之后开始录制 在较新的设备上,现有的视频(如果存在的话)是可以的,但是任何后续恢复录制的尝试都将彻
- 在较旧的设备上,即使我们重新初始化captureSession,捕获会话也将无法在此类事件之后开始录制
- 在较新的设备上,现有的视频(如果存在的话)是可以的,但是任何后续恢复录制的尝试都将彻底失败,或者无法录制音频
- (void)viewDidLoad {
[self initializeCaptureSessionAndOutputData]; //based on your requirements
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.captureSession startRunning];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interruptionDidOccur)
name:UIApplicationWillResignActiveNotification
object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.captureSession stopRunning];
[[NSNotificationCenter] defaultCenter] removeObserver:self];
}
- (void)interruptionDidOccur {
[self.movieFileOutput stopRecording]; //expect didFinishRecordingToOutputFileAtURL to be called
}
这个问题没有记录在案,但可以解决。除了打电话
[self.captureSession停止运行]
在ViewWillEnglish中:每当UIApplicationWillResignActiveNotification通知也被激发时,必须调用它。以下是示例代码:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self handleAppReturn];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(becameActive)
name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resignActive)
name:UIApplicationWillResignActiveNotification
object:nil];
}
- (void)resignActive {
[self.videoCameraManager.captureSession stopRunning];
if (!self.isPaused) {
[self pauseVideo];
}
}
- (void)becameActive {
[self.videoCameraManager.captureSession startRunning];
}