iOS中的后台录音 [英] background audio recording in iOS

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

问题描述

我已经广泛搜索了有关如何在后台录制音频的文档,并得出结论,在 plist 文件中指定音频"可能有效.但是,因为 iOS 4 会在内存不足时终止后台应用程序,所以我们还必须采取一些措施来减少过渡到后台时的内存使用量.我们如何减少内存使用量?

I have searched far and wide for documentation on how to record audio in the background and have come to the conclusion that specifying 'audio' in the plist file might work. But, because iOS 4 will terminate background apps when it runs low on memory, we must also take some steps to reduce our memory usage when we transition to the background. How do we reduce our memory usage?

另外,有谁知道在 iOS 后台录制音频的可靠方法吗??

Also, does anybody know a sure shot way of recording audio in the background on iOS??

我取消选中 Info.plist 文件中显示应用程序不在后台运行"的框,并添加了

I unchecked the box in the Info.plist file that says "Application does not run in background" and also added the

<key> UIBackgroundModes </ key> < array> < string> audio</ string></ array>

Info.plist 中.但是,只要我按下HOME"按钮,录音就会停止.

in Info.plist. But, the recording stops as soon as I press the "HOME" button.

我们实现了什么回调来知道应用程序已经进入后台?请指教.

What callbacks do we implement to know that application has gone to background? Please advise.

推荐答案

除了在 plist 文件中指定后台录制外,我们还可以实现 applicationDidEnterBackground ,它会告诉我们应用程序何时进入后台.在这里,我们应该停止对 UI 的任何更新,因为这会消耗内存,例如更新计时器和均衡器.

Apart from specifying background recording in the plist file, we can implement applicationDidEnterBackground wihch will tell us when the application enters background. Here, we should stop any updates to the UI because that consumes memory for eg, updating a timer and an equalizer.

调用 applicationWillEnterForeground 将在应用程序返回前台之前被调用,因此我们可以继续我们停止的任何内容.

The call applicationWillEnterForeground will be called just before the app returns to foreground so we can resume whatever we stopped.

然后录制会在后台进行.实现一个中断监听器也有帮助(这也可以在后台工作),这样你就不会丢失你的录音.

The recording then takes place in the background. It would also help to implement an interruption listener(this would work in the backgroud as well) so that you don't lose your recordings.

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

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