我使用 AVFoundation 进行摄像头 View ,如果电话或 Skype 通话处于事件状态,则我们无法使用摄像头。
我如何检查 AVFoundation 是否无法打开,然后我需要在不使用相机的情况下打开其他 View 。
如果我会检查这个 -
BOOL isPlayingWithOthers = [[AVAudioSession sharedInstance] isOtherAudioPlaying];
那么当任何其他应用程序播放音频时,它就不会打开。
有什么建议吗?
最佳答案
CTCallCenter
对象有一个 currentCalls
属性是 NSSet
当前通话的数量。如果有调用,则 currentCalls 属性应为 != nil。
如果您想知道是否有任何调用实际上已连接,那么您必须遍历当前调用并检查 callState
判断是否为CTCallStateConnected
或不。
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCall.h>
-(bool)isOnPhoneCall {
/*
Returns YES if the user is currently on a phone call
*/
CTCallCenter *callCenter = [[[CTCallCenter alloc] init] autorelease];
for (CTCall *call in callCenter.currentCalls) {
if (call.callState == CTCallStateConnected) {
return YES;
}
}
return NO;
}
关于ios - 检查电话调用或 Skype 调用是否处于事件状态 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33950797/