Q:

Stop video recording by pressing Home button

How do I safely stop video recording on AVFramework, when home button is pressed?
I want my app to work like the native camera app: when you press the home button during recording it stops the recording process and then goes to the background mode.
On my app delegate, I call [[videoController captureManager] stopRecording]; but in recordingDidFinishToOutputFileURL I get an error which says:

Stop any other actions using the recording device and try again.

A:

I would suggest putting the call to stop your video recording in your app delegate's applicationWillResignActive: method. This method is triggered when your app moves from being active to being inactive, which, according to the UIApplicationDelegate docs, occurs:

... for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

The code would look something like this:
- (void)applicationWillResignActive:(UIApplication *)application
{
    [[videoController captureManager] stopRecording];

    // Do anything else before app becomes inactive
}

