gpt4 book ai didi

ios - AudioSessionGetProperty已过时,如何知道设备已静音

转载 作者:行者123 更新时间:2023-12-01 16:42:26 25 4
gpt4 key购买 nike

我正在尝试检测用户的设备是否静音(电话侧面的按钮)。
我找到了检测此问题的方法,但iOS7中不推荐使用AudioSessionGetProperty。

- (BOOL)deviceIsSilenced {    
CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
OSStatus audioStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if (audioStatus == kAudioSessionNoError) {
NSLog(@"audio route: %@", state) // "Speaker" regardless of silent switch setting, but "Headphone" when my headphones are plugged in
return (CFStringGetLength(state) <= 0);
}
return NO;
}

有人对此有解决方案吗?

最佳答案

根据Sound Switch的介绍,尚无 public API来检测静默交换机的状态,但它们提供了一种破解方法(使用 public API,因此可以通过Ap Store批准,但仍应谨慎对待):

http://sharkfood.com/content/Developers/content/Sound%20Switch/

关于ios - AudioSessionGetProperty已过时,如何知道设备已静音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23059485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com