接到来电时,录制的视频已损坏,并且 AVFoundation 方法出现错误
我有一个视频录制应用程序。一切正常。录音时接到电话的情况除外。
当接到电话时,我尝试结束录音,但是,任何写入 AVAssetWriter 的调用都被拒绝。 audioWriterInput appendSampleBuffer
返回 no,appendPixelBuffer
出错。我尝试调用 avAssetWriter finishWriting
但返回 AVAssetWriterStatusFailed
。
什么都不起作用,我的视频已损坏,因为一旦接到电话,我完成录制会话的常用方法似乎就不允许了。
当接到电话时,我可以听什么才能正确结束录音会话?我目前唯一能做的就是监听 applicationWillResignActive
并停止一切,但这会阻止在用户收到短信等时进行录制,这将使我的应用程序的工作方式与本机相机应用程序不同。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看核心电话框架,特别是
CTCallCenter
类。您可以注册一个callEventHandler
,它是一个接受CTCall
对象的块。该对象描述了呼叫状态。当呼叫对象指示有来电时尝试结束录音。Take a look at the Core Telephony framework, and specifically the
CTCallCenter
class. You can register ancallEventHandler
which is a block that accepts aCTCall
object. This object describes the call state. Try to end recording when the call object indicates it's an incoming call.