开发者

iOS multitasking for an Audio Recording application

开发者 https://www.devze.com 2023-01-19 00:03 出处:网络
I am writing an application that records audio. I am looking into the feasibility of supporting multitasking while doing audio recordings (in the background).

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 m开发者_运维问答y application continues to capture audio in the background?


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).


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消