When you receive an incoming call, the recorded video is damaged, and AVFoundation methods give errors

I have a video recording application. Everything is working fine. Except when receiving a phone call during recording.

When I receive a phone call, I try to end the recording, but any of my recording calls to AVAssetWriter are rejected. audioWriterInput appendSampleBufferreturns no, appendPixelBuffererror. I try to call avAssetWriter finishWritingbut returns AVAssetWriterStatusFailed.

Nothing works, my video is damaged, because it seems that my usual methods for ending a recording session are not allowed after receiving a call.

What can I listen to correctly end the recording session when I receive a phone call? The only thing I can do now is listen applicationWillResignActiveand stop everything, but this will prevent recording when the user receives a text message, etc., which will make my application work differently than the native camera application.

+3
source share
1 answer

Take a look at basic telephony and, in particular, the class CTCallCenter. You can register callEventHandlerwhich is the block that receives the object CTCall. This object describes the status of the call. Try to end recording when the call object points to an incoming call.

+2
source

All Articles