我一直在尋找的答案2天的時候保存文件,但我似乎無法得到它的權利......停止攝像機記錄並輸入背景
我有一個示例應用程序,它記錄的音頻和視頻從設備使用AVCaptureSession和AVCaptureMovieFileOutput。
當我開始記錄我打電話:
[self.movieFileOutput startRecordingToOutputFileURL:outputURL recordingDelegate:self];
並開始記錄到文件中。如果我再次按下按鈕,停止記錄
[self.movieFileOutput stopRecording];
一切運作良好,但是當我進入後臺(來電或首頁新聞)我得到的委託方法的錯誤:didFinishRecordingToOutputFileAtURL
我想要的動作應在進入後臺時保存/完成文件。如果我調用stopDcording on「applicationDidEnterBackground」它將在調用applicationDidEnterBackground之前進入後臺。進入活動狀態時,它被稱爲....並生成一個錯誤,並保留一個損壞的電影文件...
它似乎沒有足夠的時間來保存該文件。
我在這裏錯過了什麼?
這是我的錯誤
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}
AVErrorSessionWasInterrupted = -11818
我也試過蘋果AVDemo應用程序,它也給出了相同的錯誤。似乎無論如何都會拋出錯誤。不同的是,在蘋果的代碼中,他們有時間使用UIBackgroundTaskIdentifier – Michiel