Question

I have a video recording app. Everything works fine. Except when a phone call is received while recording.

When a phone call is received, I try to end the recording, however, any of my calls to write to an AVAssetWriter are denied. audioWriterInput appendSampleBuffer returns no, appendPixelBuffer errors out. I try to call avAssetWriter finishWriting but that returns AVAssetWriterStatusFailed.

Nothing works, my video is corrupted because it seems that my usual methods to finish up a recording session are not being allowed once a call is received.

What could I listen for to properly end a recording session when a phone call is received? The only thing I can currently do is listen for applicationWillResignActive and stop everything, but that prevents recording while a user receives a text message, etc. which would make my app work differently than the native Camera app.

Was it helpful?

Solution

Take a look at the Core Telephony framework, and specifically the CTCallCenter class. You can register an callEventHandler which is a block that accepts a CTCall object. This object describes the call state. Try to end recording when the call object indicates it's an incoming call.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top