I have an application which takes some pictures. My whole application is based on the AVCam sample code from WWDC 2010. I've messed with it a lot and yet, up until now I can't figure out how to release the camera view properly which releases the camera session...
All i'm trying to do is the following:
The second time I push the viewController the session is lost, preview is not available and capturing is not available as well. I've published full example code on github.
My workaround for the issue was not to release the camera at all so the Camera View Controller acts as a Singleton, which I think is not the right way. moreover, with this behavior I couldn't figure out a way to support camera when application went to the background (phone call for example).
Please advice. How do I destruct the camera session? and is it important to do so?
I've added the following message to AVCamCaptureManager
- (void) destroySession {
if ([delegate respondsToSelector:@selector(captureManagerSessionWillEnd:)]) {
[delegate captureManagerSessionWillEnd:self];
}
// remove the device inputs
[session removeInput:[self videoInput]];
[session removeInput:[self audioInput]];
// release
[session release];
// remove AVCamRecorder
[recorder release];
if ([delegate respondsToSelector:@selector(captureManagerSessionEnded:)]) {
[delegate captureManagerSessionEnded:self];
}
}
I'm calling destroySession
when the viewController holding the camera get close (on my example it's -closeCamera:
of AVCamViewController
).
For the full working example, you're welcome to download AVCam-CameraReleaseTest on github.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With