隐藏红色录音状态栏在iOS应用中不录制时 [英] Hide Red Recording Status Bar In iOS App When Not Recording

查看:7649
本文介绍了隐藏红色录音状态栏在iOS应用中不录制时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当应用程序在后台,而不是记录我不能让红色的录制状态栏在我的应用程序隐藏。

I can't get the red "Recording" status bar to hide in my app when the app is in the background and not recording.

我碰巧使用惊人的音频引擎的,但我认为这个问题可以解决该库的知识。它得到的设置是这样的:

I happen to be using The Amazing Audio Engine, but I think this question could be tackled knowledge of that library. It gets setup like this:

audioController = [[AEAudioController alloc] initWithAudioDescription:desc inputEnabled:YES];
audioController.audioSessionCategory = kAudioSessionCategory_MediaPlayback;

当用户想记录下来,我打开这样的麦克风:

When the user wants to record, I turn on the mic like this:

[audioController addInputReceiver:mic];
audioController.audioSessionCategory = kAudioSessionCategory_PlayAndRecord;

当用户想停止录​​制,我将其关闭:

When the user wants to stop recording, I turn it off:

[audioController removeInputReceiver:mic];
audioController.audioSessionCategory = kAudioSessionCategory_MediaPlayback;

问题是,当应用程序没有记录&功放;在用户离开应用程序,红色的录制状态栏仍显示。我不能停止/处置audioController,因为应用程序仍然可能的播放的声音。

我不想红色记录状态栏上显示如果我不记录。任何想法如何做到这一点?

我设置code以下块在我的应用程序每2秒运行。

I setup the following block of code to run every 2 seconds in my app.

audioController.audioSessionCategory = kAudioSessionCategory_MediaPlayback;

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError* error = nil;
[audioSession setActive:NO error: &error];
NSLog(@"error: %@", error);
[audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];

此日志:

TAAE: Setting audio session category to MediaPlayback
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryEnableBluetoothInput)    result 2003329396 77686174 what
Error Domain=NSOSStatusErrorDomain Code=560030580 "The operation couldn’t be completed. (OSStatus error 560030580.)"

显然它不能禁止因事TAAE持有到话筒。我还没有添加任何投入到控制器,所以我不知道它可能是什么。

Obviously it fails to disable the mic because of something TAAE is holding on to. I have not added any inputs to the controller, so I don't know what it could be.

推荐答案

解决,请参阅编辑2

酒吧永远不会只要话筒在使用中,记录或不会消失。这是一个安全措施以允许用户知道应用程式是听麦克风,而不是表明该电话被记录

The bar will never disappear as long as the mic is in use, recording or not. it's a security measure to allow the user to know that an app is listening to the microphone, not to show that the phone is recording.

要得到它走的唯一方法是从输入接收器取下麦克风

The only way to get it gone is to remove the mic from the input receivers

我看到你的麦克风没有被删除,必须有一些bug。

I see that your mic isn't being removed, there has to be some bug.

的一点是,你不能隐藏的红酒吧,只要麦克风被打开。

Point is, you cannot hide the Red bar as long as the microphone is opened..

如果你想暂时禁用它,你也许可以试试这个?

if you want to temporarily disable it, you can try this maybe ?

[audioController setInputEnabled:NO]

什么是你想无论如何要完成什么?有可能是一个更好的方式来处理事情

What are you trying to accomplish anyway? there might be a better way to handle things

修改1:添加其他解决方法

我不知道setInputEnabled是只读的,对不起。

I didn't know that setInputEnabled was readonly, sorry.

好了,另一件事是尝试完全停止控制器,试试这个:

Well, another thing to try is to stop the controller completely, try this:

[audioController stop]

如果没有,尝试,如果你不使用ARC将其释放,或者干脆

if not, try to release it if you're not using ARC, or simply

audioController = Nil;

。希望修复该问题。但我宁愿尝试找出它为什么不删除 MIC 从输入接收器..也许 MIC 是零,当你叫 [audioController removeInputReceiver:MIC] ??

Hope that fixes the issue. but I rather try to find out why it's not removing mic from the input receivers.. perhaps mic is Nil when you call [audioController removeInputReceiver:mic] ??

编辑2:加入溶液

当您使用 INPUT启用初始化出现问题设置为,因为它是 readOnly的,你无法禁用输入,唯一的办法就是实际释放 audioController
如果你使用ARC,只需将其设置为,如果没有,只是 [audioController发布]

The problem arises when you initialize with inputEnabled set to YES, since it's readOnly, you can't disable the input, the only way is to actually release audioController. if you're using ARC, just set it to Nil, if not, just [audioController release]

这篇关于隐藏红色录音状态栏在iOS应用中不录制时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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