Note that there are some explanatory texts on larger screens.

plurals
  1. POStop Camera recording and save file when entering background
    primarykey
    data
    text
    <p>I've been looking for the answer for 2 days, but I can't seem to get it right...</p> <p>I have an example app that records audio and video from the device using a AVCaptureSession and a AVCaptureMovieFileOutput.</p> <p>When I start recording I call:</p> <pre><code>[self.movieFileOutput startRecordingToOutputFileURL:outputURL recordingDelegate:self]; </code></pre> <p>And it starts recording to the file. If I press the button again it stops recording</p> <pre><code>[self.movieFileOutput stopRecording]; </code></pre> <p>Everything works well, but when I enter background (incoming call or HOME press) I get an error in the delegate method: didFinishRecordingToOutputFileAtURL</p> <p>My desired action should be saving / completing the file on entering the background. If I call stopRecording on "applicationDidEnterBackground" it will enter background before the applicationDidEnterBackground is called. On entering the active state it is called.... and generates an error and leaves a corrupted movie file...</p> <p>It seems that it hasn't got enough time to save the file.</p> <p>What am I missing here?</p> <p>This is my Error</p> <p><code>Error Domain=AVFoundationErrorDomain Code=-11818 "Recording Stopped" UserInfo=0x17594e20 {NSLocalizedRecoverySuggestion=Stop any other actions using the recording device and try again., NSUnderlyingError=0x175d3500 "The operation couldn’t be completed. (OSStatus error -16133.)", NSLocalizedDescription=Recording Stopped}</code></p> <pre><code>AVErrorSessionWasInterrupted = -11818 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload