Hi all!
I've been following this thread for a while. You guys seems to have figured it out, but I can't seem to get this approach to work.. I'm trying to capture a photo on an iPhone 2G on firmware 3.0.
My readyStateChanged delegate gets called if I do a [cameraController _setIsReady]; and my modeDidChange gets called if I do a [cameraController _setCameraMode:0 force:TRUE]; - so my delegates doesn't seem to be the problem.
I just can't get isReady to return YES and my tookPicture delegate never gets called.
I don't need a preview on the screen or anything else, I just need it to capture a photo and call the tookPicture delegate.
(NSLog indicates that my call to capturePhoto takes about 2 seconds, so I know it does
something, I just wish it would let me know what

)
Code:
@interface Scratch: UIApplication
{
id cameraController;
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
@end /* @interface Scratch */
@implementation Scratch
- (void)cameraControllerReadyStateChanged:(NSNotification *)aNotification {
NSLog(@"cameraControllerReadyStateChanged");
}
- (void)cameraController:(id)sender tookPicture:(UIImage*)picture withPreview:(UIImage*)preview jpegData:(NSData*)rawData imageProperties:(struct __CFDictionary *)imageProperties {
NSLog(@"tookPicture");
}
- (void)cameraController:(id)sender addedVideoAtPath:(NSString *)path withPreviewSurface:(id)surface metadata:(id)meta wasInterrupted:(BOOL)interrupt {
NSLog(@"addedVideoAtPath");
}
- (void)cameraController:(id)sender modeDidChange:(int)mode {
NSLog(@"modeDidChange");
}
- (void)cameraControllerVideoCaptureDidStart:(id)sender {
NSLog(@"cameraControllerVideoCaptureDidStart");
}
- (void)cameraControllerVideoCaptureDidStop:(id)sender {
NSLog(@"cameraControllerVideoCaptureDidStop");
}
- (void)cameraControllerFocusFinished:(id)sender {
NSLog(@"cameraControllerFocusFinished");
}
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
freopen([@"/tmp/scratchlog.txt" fileSystemRepresentation], "w", stderr);
NSLog(@"applicationDidFinishLaunching");
cameraController = [(id)objc_getClass("PLCameraController") performSelector:@selector(sharedInstance)];
[cameraController setDelegate:self];
// [cameraController setCameraMode: 0];
// [cameraController _setCameraMode:0 force:TRUE]; // Will trigger modeDidChange delegate
[cameraController setFocusDisabled:YES];
[cameraController setDontShowFocus:YES];
[cameraController setCaptureAtFullResolution:YES];
// [cameraController _setIsReady]; // Will trigger readyStateChanged delegate
NSLog(@"CameraMode: %d", [cameraController cameraMode]);
NSLog(@"isReady: %d", [cameraController isReady]);
NSLog(@"Starting preview");
[cameraController startPreview];
NSLog(@"isReady: %d", [cameraController isReady]);
NSLog(@"Sleeping");
sleep(2);
NSLog(@"isReady: %d", [cameraController isReady]);
NSLog(@"Capturing photo");
[cameraController capturePhoto:NO];
NSLog(@"Stopping preview");
[cameraController stopPreview];
}
int main (int argc, char **argv) {
int ret;
NSAutoreleasePool *pool;
pool = [ [ NSAutoreleasePool alloc ] init ];
ret = UIApplicationMain (argc, argv, @"Scratch", @"Scratch");
[pool release];
return ret;
}
@end /* @implementation Scratch */
What is it that I am missing? Any help would be appreciated!