在我的 OSX 应用程序中,我使用下面的代码来显示来自相机的预览。
[[self session] beginConfiguration];
NSError *error = nil;
AVCaptureDeviceInput *newVideoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
if (captureDevice != nil) {
[[self session] removeInput: [self videoDeviceInput]];
if([[self session] canAddInput: newVideoDeviceInput]) {
[[self session] addInput:newVideoDeviceInput];
[self setVideoDeviceInput:newVideoDeviceInput];
} else {
DLog(@"WTF?");
}
}
[[self session] commitConfiguration];
Run Code Online (Sandbox Code Playgroud)
但是,我需要检测来自相机的预览可用的确切时间。
换句话说,我试图检测与 OSX 下的 Facetime 相同的时刻,一旦相机提供预览,动画就会开始。
实现这一目标的最佳方法是什么?