使用 UISlider 同步音量摇杆

发布于 2024-08-16 23:29:25 字数 466 浏览 10 评论 0原文

我正在尝试让 UISlider 与音量摇杆同步。我已成功使用滑块更改系统/铃声音量,但我需要滑块在摇杆移动时也移动。关于如何获取当前音量值有什么建议吗?我使用下面的代码来监视音量变化:

- (void)volumeChanged:(NSNotification *)notification{

       AVSystemController* avc = SharedAVSystemController;
       //   my sliders name is customVolume, and this is how I 
       //   am trying to get the volume:
       customVolume.value = [avc getVolume:(float *) forCategory:(id)];

}

另外,除了“铃声”之外,AVSystemController 类别还有哪些?

I am trying to get a UISlider to sync with the volume rocker. I have successfully used the slider to change the system/ringer volume, but I need the slider to move when the rocker moves. any suggestions on how to get the current volume value? I am using the code below to monnitor the volume change:

- (void)volumeChanged:(NSNotification *)notification{

       AVSystemController* avc = SharedAVSystemController;
       //   my sliders name is customVolume, and this is how I 
       //   am trying to get the volume:
       customVolume.value = [avc getVolume:(float *) forCategory:(id)];

}

Also, what are the AVSystemController categories other than "Ringtone"?

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

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

发布评论

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

评论(2

森林散布 2024-08-23 23:29:25

SDK 中有一个类可以自行处理系统音量,MPVolumeView。它不是 UISlider 的子类,因此您无法更改它的外观(好吧,您自己很难将其全部组合在一起),但这可能不是问题。 (编辑:查看类转储,视图包含一个普通的 UISlider 视图,所以它可能比我预期的更容易)

我不确定它是否可以处理您需要的所有内容以及它是否适合您的上下文,但您也可以看一下它并尝试一下。

There is a class available in the SDK which handles the system volume all by itself, MPVolumeView. It's not a subclass of UISlider therefore you can't change it's appearance (Well, it would be hard hacking it together all by yourself) but that's probably not an issue. (edit: looking at class dumps, the view contains a normal UISlider view so it may be easier than I expected)

I'm not sure whether it handles everything you need and if it will fit in your context, but you can also take a look at it and try it.

空城仅有旧梦在 2024-08-23 23:29:25

这将使用音量摇杆更新UISlider

- (void)volumeChanged:(NSNotification *)notification
{
    AVSystemController *avs = [ notification object ];
    NSString *audioDeviceName;
    [ avs getActiveCategoryVolume:&_volume andName:&audioDeviceName ];
}

This will update theUISliderwith the volume rocker:

- (void)volumeChanged:(NSNotification *)notification
{
    AVSystemController *avs = [ notification object ];
    NSString *audioDeviceName;
    [ avs getActiveCategoryVolume:&_volume andName:&audioDeviceName ];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文