iOS背景录音 [英] iOS Background audio recording

查看:98
本文介绍了iOS背景录音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,如果我在前台启动音频录制会话,并且在功能->背景模式"中激活了音频",播放"和画中画"功能;即使在后台也可以继续录制,但前提是必须先在前台开始录制会话,然后再进入后台.

我的问题是我想从后台开始语音录制会话,这似乎有点陈腐,而不是Apple想要的,但是用例是这样的:

我有一个带按钮的Bluetooth LE设备和一个iOS应用程序.这两个配对(蓝牙LE设备和运行iOS应用程序的iPhone)配对,并且iOS应用程序正在侦听蓝牙LE设备上的事件,如按一下按钮之类的事件.

现在,当用户单击Bluetooth LE设备上的按钮时,iOS应用程序将捕获事件,即使该应用程序处于后台,我也可以运行代码,但是我无法开始语音记录. /p>

我的问题是:那有可能吗?要从后台开始录音?即使我们在此处(不是在iOS应用程序上)而是在Bluetooth LE上进行了用户交互,所以这也不像是在后台开始录音并且用户不知道它,他还是按下了Bluetooth LE设备上的按钮,他知道他在做什么.

任何帮助,文档,Apple工程师的鸣叫,都将不胜感激.谢谢.

更新:不需要MFI. https://mfi.apple.com/MFiWeb/getFAQ.action#1- 2 .

如果您查看以下部分:

哪些类型的附件和技术不属于MFi计划的一部分?"

您将看到:

仅使用低功耗蓝牙(BTLE)的附件(注意:启用BTLE的HomeKit配件和启用BTLE的MFi助听器是MFi计划的一部分)"

提到

,这意味着 MFI 在这种情况下不需要 .

解决方案

来自Apple文档

一个连续播放或录制音频的应用程序(即使该应用程序处于 在后台运行)可以注册以在后台执行这些任务 背景.您可以从背景模式"部分启用音频支持 Xcode项目中功能"选项卡上的按钮. (您也可以启用 通过在音频中包含UIBackgroundModes键来实现这种支持 应用的Info.plist文件中的值.)在以下位置播放音频内容的应用 背景必须播放可听的内容,而不是保持沉默.

典型的背景音频应用示例包括:

音乐播放器应用程序录音应用程序支持音频或音频的应用程序 通过AirPlay VoIP应用播放视频

对于需要更多执行时间才能实现的任务,您必须 请求特定权限以在后台运行它们而无需 他们被停职了.在iOS中,仅允许特定的应用类型 在后台运行:

  • 在后台录制音频内容的应用

关于您的蓝牙设备":

查看 ExternalAccessory 的文档.

请注意,您需要依次申请特殊开发人员计划并获得批准以便能够创建外部附件.

I know that if I start an audio recording session in foreground, with Audio, Airplay, and Picture in Picture activated in Capabilities -> Background Modes; I am able to continue to record even in background, but only if I start the recording session in foreground and then I go in background.

My problem is that I want to start the voice recording session from background, which might seem shaddy and not what Apple wants, but the use case is like this:

I have a Bluetooth LE device with buttons and an iOS app. Those two are paired (Bluetooth LE device and the iPhone which runs the iOS app) and the iOS app is listening for events on the Bluetooth LE device, events like a hit of a button.

Now, when the user hits a button on the Bluetooth LE device, the iOS app captures the event and I am able to run code even if the app is in background, but I am not able to start a voice recording.

My question is: is that even possible? To start a voice recording from background? Even if we have user interaction here, not on the iOS app but on the Bluetooth LE, so it's not like the voice recording starts in background and the user is not aware of it, he pressed the button on the Bluetooth LE device, he knows what he's doing.

Any help, documentation, tweet of an Apple engineer, anything would be much appreciated. Thanks.

UPDATE: MFI is not required. https://mfi.apple.com/MFiWeb/getFAQ.action#1-2.

If you look into the section:

"What types of accessories and technologies are NOT part of the MFi Program?"

You will see that:

"Accessories that use only Bluetooth Low Energy (BTLE) (note: BTLE-enabled HomeKit accessories and BTLE-enabled MFi Hearing Aids are part of the MFi Program)"

Is mentioned, which means MFI in this case is not required.

解决方案

From Apple Documentation

An app that plays or records audio continuously (even while the app is running in the background) can register to perform those tasks in the background. You enable audio support from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the audio value in your app’s Info.plist file.) Apps that play audio content in the background must play audible content and not silence.

Typical examples of background audio apps include:

Music player apps Audio recording apps Apps that support audio or video playback over AirPlay VoIP apps

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:

  • Apps that record audio content while in the background

EDIT:

Also regarding your "Bluetooth device":

Check out the documentation for ExternalAccessory .

Be aware that you need to apply and get approved for a special developer program in order to be able to create external accessories.

这篇关于iOS背景录音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆