录音应用程序的 iOS 多任务处理

发布于 2024-09-25 12:57:45 字数 171 浏览 0 评论 0原文

我正在编写一个录制音频的应用程序。我正在研究在录音时支持多任务处理(在后台)的可行性。

从我到目前为止所读到的内容来看,答案似乎是否定的,特别是因为该程序旨在在关闭时释放正在使用的任何系统资源。

所以我想知道,是否可以让用户切换到 iOS 中的另一个应用程序,同时我的应用程序继续在后台捕获音频?

I am writing an application that records audio. I am looking into the feasibility of supporting multitasking while doing audio recordings (in the background).

The answer seems to be a no from what I've read so far, especially since the program is meant to release any system resources being used when switched out.

So I am wondering, is it possible to let the user switch to another application in iOS while my application continues to capture audio in the background?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

太阳公公是暖光 2024-10-02 12:57:45

你可以。 Skype 就是这么做的。

您可能需要在 Info.plist 中设置 UIBackgroundModesaudio,并且您需要确保在切换应用程序之前,音频会话处于活动状态/正在运行/无论什么(假设是当您的应用程序在后台时,您不会突然开始录制/播放音乐/无论什么)。

文档说“音频” 允许您在后台播放音频,但这可能也适用于录制音频。如果它不起作用,您可以尝试以下几种方法:

  • 设置“voip”和“audio”。
  • 播放静音(这可能是使用音频队列 API 最简单的方法)。

You can. Skype does this.

You presumably need to set <key>UIBackgroundModes</key><array><string>audio</string></array> in Info.plist, and you need to make sure that the audio session is active/running/whatever before you switch apps (the assumption is that you won't suddenly start recording/playing music/whatever when your app is in the background).

The docs say that "audio" lets you play audio in the background, but presumably this also applies to recording audio. If it doesn't work, there are a few things you could try:

  • Set both "voip" and "audio".
  • Play silence (this might be easiest to do with the Audio Queue API).
和影子一齐双人舞 2024-10-02 12:57:45

Apple 似乎已经接受 iOS4 的应用程序,这些应用程序在置于后台时会继续录制音频,因此这可能是存在的证据。应用程序必须声明自己具有后台音频功能,预先分配所有音频资源并在应用程序进入后台之前开始录音,并且如果前台应用程序需要其内存或音频资源,则还需要被杀死。因此,对系统资源的任何使用都应该是绝对最低的。

Apple appears to have been accepting apps for iOS4 which continue to record audio when put in the background, so this may be an existence proof. The app has to declare itself as background audio capable, pre-allocate all audio resources and start the audio recording before the app gets backgrounded, and also expect to get killed if its memory or audio resources are required by the foreground app. So any use of system resources should be the absolute minimum.

嗫嚅 2024-10-02 12:57:45

是的!

您的应用程序将在发送到后台时继续录制/播放音频。

不要尝试使用 VOIP,除非您不想将您的应用程序发布到苹果商店(假设您将使用安装配置文件的第三方商店广播您的应用程序)。

Yes!

Your app will continue recording/playing an audio while it is sent to background.

Do not try to use VOIP unless you don't wish to publish your app to apple store (say you will broadcast your app using third party stores who install provisioning profile).

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