Using the AVCam demo, I'm trying to add a delay of 5 seconds before the picture is actually taken by making the following changes in AVCamViewController.m:
- (IBAction)captureStillImage:(id)sender
{
// Capture a still image
[[self stillButton] setEnabled:NO];
// delay picture capture by 5 seconds
myTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0
target: self
selector: @selector(pictureTimer:)
userInfo: nil
repeats: NO];
}
- (void) pictureTimer: (NSTimer *) timer {
[[self captureManager] captureStillImage];
}
However, the completion handler in AVCamCaptureManager::captureStillImage never seems to get called (I never see the "captureStillImage completion handler" log message):
- (void) captureStillImage
{
AVCaptureConnection *stillImageConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
if ([stillImageConnection isVideoOrientationSupported])
[stillImageConnection setVideoOrientation:orientation];
NSLog(@"captureStillImage");
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:stillImageConnection
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
NSLog(@"captureStillImage completion handler");
Will this just not work using an NSTimer?