如何知道 Objective-C 中音量硬件控制是向上还是向下

发布于 2024-12-14 22:40:50 字数 315 浏览 2 评论 0原文

是否可以检测音量硬件控制是向下还是向上?我需要在应用程序中的按钮触摸上播放声音,并且我想向用户发送一条消息,告知音量已降低,并且要使用此应用程序,他需要更改硬件

编辑:

我需要执行以下操作:

BOOL VolumeHardwareControl = getHardwareInfo();
if(VolumeHardwareControl==NO){
    message: "Attention! To play sound you need to turn hardware on!"
}else
   playSound();

Is possible to detect if volume hardware control is down or up? i need to play sound on button touch in my application, and i want to send a message to user that volume is down and to use this app he need to change hardware

EDIT:

I need to do something like this:

BOOL VolumeHardwareControl = getHardwareInfo();
if(VolumeHardwareControl==NO){
    message: "Attention! To play sound you need to turn hardware on!"
}else
   playSound();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇俏 2024-12-21 22:40:50
UInt32 routeSize = sizeof (CFStringRef);
CFStringRef route;

AudioSessionGetProperty (
                 kAudioSessionProperty_AudioRoute,
                 &routeSize,
                 &route
                );

if (route == NULL) {
    NSLog(@"Silent switch is on");
}
UInt32 routeSize = sizeof (CFStringRef);
CFStringRef route;

AudioSessionGetProperty (
                 kAudioSessionProperty_AudioRoute,
                 &routeSize,
                 &route
                );

if (route == NULL) {
    NSLog(@"Silent switch is on");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文