问题描述
使用WASAPI,我可以控制系统音量。
我不知道,我可以通过编程方式控制特定应用程序的音量。 (当然,这是在windows7之后)是可能吗?
Using WASAPI, I could control system volume.I wonder, I can control the specific application's volume level programmatically. (of course, this is after windows7 only) is it possible?
推荐答案
标准音量混音器。在,其解释相当详细:
You can control application (session) volume, just like standard Volume Mixer does it. Read up on this in Session Volume Controls where it is explained pretty detailed:
为了支持这种行为,WASAPI实现了ISimpleAudioVolume
接口。当用户移动应用程序滑块时,应用程序
调用ISimpleAudioVolume :: SetMasterVolume方法来相应地调整
会话音量级别。 Sndvol监视器通过此方法进行的音量变化为
,并反映其显示的音量滑块
的变化。
To support this behavior, WASAPI implements the ISimpleAudioVolume interface. When the user moves the application slider, the application calls the ISimpleAudioVolume::SetMasterVolume method to adjust the session volume level accordingly. Sndvol monitors volume changes made through this method and reflects the changes in the volume sliders that it displays.
要发现正在运行的会话,可以使用 IAudioSessionEnumerator
接口。看看这个实现发现的代码片段/应用程序:。
To discover running sessions, you can use IAudioSessionEnumerator
interface. Have a look at this code snippet/application implementing the discovery: AudioSessionVolumeNotification.
这篇关于处理特定应用程序卷级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!