问题描述
我正在编写一个记录音频的应用程序。我正在研究在录音时支持多任务的可行性(在后台)。
I am writing an application that records audio. I am looking into the feasibility of supporting multitasking while doing audio recordings (in the background).
答案似乎是 no 我到目前为止已阅读过,特别是因为该程序旨在释放切换时使用的所有系统资源。
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.
所以我想知道,是否有可能让当我的应用程序继续在后台捕获音频时,用户切换到iOS中的另一个应用程序?
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?
推荐答案
你可以。 Skype会这样做。
You can. Skype does this.
你可能需要设置< key> UIBackgroundModes< / key>< array>< string> audio< / Info.plist中的字符串>< / array>
,您需要确保音频会话处于活动状态/正在运行/切换应用之前的任何内容(假设您不会突然启动录制/播放音乐/当你的应用在后台播放时。)
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).
说audio允许你在后台播放音频,但这可能也适用于录制音频。如果它不起作用,你可以尝试一些事情:
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:
- 设置voip和audio。
- 播放静音(这可能是最容易使用音频队列API)。
这篇关于用于音频录制应用程序的iOS多任务处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!