handling specific applications volume-level

夙愿已清 提交于 2019-12-25 07:20:11

问题


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?


回答1:


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 clients can individually control the volume level of each audio session. [...]

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.

To discover running sessions, you can use IAudioSessionEnumerator interface. Have a look at this code snippet/application implementing the discovery: AudioSessionVolumeNotification.



来源:https://stackoverflow.com/questions/17226557/handling-specific-applications-volume-level

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!