Hi,
I have an application that uses AVCaptureSession to record the video (from front camera) and write it to file.
When i put an application on background mode i start recieve exception:
AVFoundationErrorDomain Code = -11847 "Opetation Interrupted".
When getting back on foreground, still recieving this exception.
The questions is - can i continue record video when user put application on background mode? If yes, how should i implement it?
If no, is there way to at least pause the recording and continue it to the same file.
Thanks,
Nikita.
No, incorrect. You _never_ need to stop your capture session. The capture session automatically stops itself when your app goes to the background and resumes itself when you come back to the foreground.
Regarding NikitaCh's original questions:
iOS camera privacy policy dictates that no app is allowed to use the camera in the background. When your app goes to the background, your session will be interrupted. When it comes back, the interruption ends and the session preview resumes.
AVCaptureMovieFileOutput recordings that are in progress when you go to the background are stopped. AVCaptureMovieFileOutput does not support pause/resume. I suppose you should ask yourself if you want a single movie file that has a large time hole in it reflecting the time your app was in the background.
If you decide you absolutely do want this behavior, you can use AVCaptureVideoDataOutput and AVCaptureAudioDataOutput + AVAssetWriter to do your own recording.