获取音频会话的音量 [英] Get an audio session's volume level

查看:64
本文介绍了获取音频会话的音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在Vista或7中获得当前音频会话*的音量吗?

Does anyone know how to get the current volume level of an audio session* in Vista or 7?

我有IAudioSessionControl2和IAudioSessionManager2实例,您需要侦听音量更改,但事实证明,获得当前音量是难以捉摸的.

I've got the IAudioSessionControl2 and IAudioSessionManager2 instances you need to listen for volume changes, but actually getting the current volume is proving elusive.

*通过音频会话,我的意思是(大致)针对每个应用程序的音频控件,而不是主"控件

请注意(据我所知)IAudioSessionManager2-> GetSimpleVolume()在这里不是正确的答案.在IAudioSessionControl2中发布GUID的唯一内容是分组参数,并在GetSimpleVolume中使用它来创建新会话,而不是让您控制现有会话.

Note that (so far as I can tell) IAudioSessionManager2->GetSimpleVolume() isn't the right answer here. The only thing that publishes a GUID in IAudioSessionControl2 is the Grouping parameter, and using it in GetSimpleVolume creates new sessions rather than giving you the control for an existing one.

GetSimpleVolume()是我的意思想要,但是此设置中的参数来自哪里?

GetSimpleVolume() is what I want, but where are the params coming from in this setup?

推荐答案

实际上IAudioSessionManager :: GetSimpleAudioVolume就是您想要的.

Actually IAudioSessionManager::GetSimpleAudioVolume IS what you're looking for.

音频会话由两个(或三个)事物标识:会话guid,进程ID和跨进程标志(如果在创建流时指定了跨进程标志,则将忽略进程ID).

An audio session is identified by two (or three) things: The session guid, the process ID and the cross process flag (if the cross process flag is specified when the stream is created, the process ID is ignored).

简单的音频音量控制该音频会话中所有流的音量.这非常简单(大多数渲染框架为会话GUID指定NULL).如果您的应用程序使用特定的会话GUID,则只需指定应用程序正在使用的会话GUID.

The simple audio volume controls the volume of all the streams within that audio session. It's fairly straightforward (most rendering frameworks specify NULL for the session GUID). If your application uses a specific session GUID, you should just specify the session GUID your application is using.

但是还有另一种转折.音量控件(sndvol.exe)在UI中将所有具有相同分组参数"的会话组合在一起-这不是音量控件的一部分,它是UI便利功能,仅适用于IE等网络浏览器-它存在允许第三方音频框架(指定GUID_NULL会话GUID)和WMP OCX(指定具有特定会话GUID的跨进程会话)在卷UI中共享单个滑块.

There's one other twist though. The volume control (sndvol.exe) combines all sessions with the same "grouping param" together in the UI - this isn't a part of the volume control, it's a UI convenience feature that exists only for web browsers like IE - it exists to allow 3rd party audio frameworks (which specify a GUID_NULL session GUID) and the WMP OCX (which specifies a cross process session with a specific session GUID) to share a single slider in the volume UI.

这篇关于获取音频会话的音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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