iOS 后台录音 [英] iOS Background audio recording

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

问题描述

我知道如果我在前台开始录音会话,并在功能 -> 背景模式中激活音频、Airplay 和画中画;即使在后台,我也可以继续录制,但前提是我在前台开始录制会话,然后进入后台.

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.

我的问题是我想从后台开始录音会话,这可能看起来很黑,而不是 Apple 想要的,但用例是这样的:

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:

我有一个带按钮的蓝牙 LE 设备和一个 iOS 应用程序.这两个是配对的(蓝牙 LE 设备和运行 iOS 应用的 iPhone),iOS 应用正在监听蓝牙 LE 设备上的事件,比如点击按钮之类的事件.

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.

现在,当用户点击蓝牙 LE 设备上的按钮时,iOS 应用程序会捕获事件,即使应用程序在后台,我也可以运行代码,但我无法开始录音.

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.

我的问题是:这可能吗?从后台开始录音?即使我们在这里有用户交互,不是在 iOS 应用程序上而是在蓝牙 LE 上,所以这不像录音在后台开始而用户不知道,他按下了蓝牙 LE 设备上的按钮,他知道他在做什么.

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.

Apple 工程师的任何帮助、文档、推文,任何内容都将不胜感激.谢谢.

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

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

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

如果您查看该部分:

哪些类型的配件和技术不属于 MFi 计划?"

你会看到:

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

被提及,这意味着在这种情况下MFI不是必需的.

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

推荐答案

来自 Apple 文档

连续播放或录制音频的应用程序(即使应用程序处于在后台运行)可以注册以在后台执行这些任务背景.您可以从后台模式部分启用音频支持Xcode 项目中的 Capabilities 选项卡.(您也可以启用这种支持通过在音频中包含 UIBackgroundModes 键值在您的应用程序的 Info.plist 文件中.)播放音频内容的应用程序背景必须播放可听内容,而不是静音.

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:

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

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

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

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:

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

还有关于您的蓝牙设备":

Also regarding your "Bluetooth device":

查看 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天全站免登陆