开发者

Changing volume for current app exclusively

开发者 https://www.devze.com 2023-02-01 06:03 出处:网络
from Windows Vista on, the waveOutSetVolume function (winmm.dll) no more operates on the OS master volume but for each app individually. As a default it is set to 100% which means that the app plays s

from Windows Vista on, the waveOutSetVolume function (winmm.dll) no more operates on the OS master volume but for each app individually. As a default it is set to 100% which means that the app plays sound with the same volume like the OS.

Now I want to make use of exactly this effect: Only changing the volume for my current app without changing the OS volume.

I tried the app provided at http://www.geekpedia.com/tutorial176_Get-and-set-the-wave-sound-volume.html. I added a WindowsMediaPlayer control and loaded an Webradio stream into it using the URL property (autost开发者_开发技巧art set to true). At first glance the code does not what it should: When I scroll the slider the radio keeps on playing at the same volume, even if I set to to 0 which would equal muting it. I debugged and figured that everything is ok, waveOutSetVolume returns 0. That should be ok, or am I mistaken?

I opened the mixer console provided by Windows 7. There I saw the following: The slider of the respective app in the mixer view changes (as it should) when I scroll the slider in the sample. Yet the volume doesn't change. But if I reduce the app's volume in the mixer console (manually with my mouse), the webradio plays in a lower voice (as it should). It seem's that in my code there is missing some "Submit" call to actually make the OS adjust the app's volume accordingly.

Any ideas? Thanks, David


You can use the Audio session APIs IAudioVolume and IAudioSessionNotification to modify the current apps volume and to track your volume with the volume slider in the app.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号