接到来电时,录制的视频已损坏,并且 AVFoundation 方法出现错误

发布于 2024-11-07 07:21:57 字数 464 浏览 0 评论 0原文

我有一个视频录制应用程序。一切正常。录音时接到电话的情况除外。

当接到电话时,我尝试结束录音,但是,任何写入 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪推晚风 2024-11-14 07:21:57

查看核心电话框架,特别是 CTCallCenter 类。您可以注册一个 callEventHandler,它是一个接受 CTCall 对象的块。该对象描述了呼叫状态。当呼叫对象指示有来电时尝试结束录音。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文