简体   繁体   English

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

[英]iOS multitasking for an Audio Recording application

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? 所以我想知道,当我的应用程序继续在后台捕获音频时,是否可以让用户切换到iOS中的另一个应用程序?

You can. 您可以。 Skype does this. Skype做到了这一点。

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). 您可能需要在Info.plist中设置<key>UIBackgroundModes</key><array><string>audio</string></array> ,并且您需要确保音频会话处于活动/正在运行/之前的任何内容你切换应用程序(假设当你的应用程序在后台时你不会突然开始录制/播放音乐/什么)。

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". 设置“voip”和“audio”。
  • Play silence (this might be easiest to do with the Audio Queue API). 播放静音(这可能是最容易使用音频队列API)。

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. Apple似乎已经接受iOS4的应用程序,这些应用程序在后台播放时会继续录制音频,因此这可能是一种存在证据。 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. 因此,任何系统资源的使用都应该是绝对最小的。

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). 除非您不希望将应用程序发布到Apple商店,否则请勿尝试使用VOIP(假设您将使用安装配置文件的第三方商店广播您的应用程序)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM