Get Master Sound Volume in c#

后端 未结 7 1494
误落风尘
误落风尘 2020-11-28 09:57

I need to get the current volume of the output to the sound card.

Any ideas how?

7条回答
  •  误落风尘
    2020-11-28 10:36

    I solved this when I was working on a (still yet to be released...) application that initiates some kind of "elevator music" when no other sound is present.

    Followed the brilliant tips given by Mark Heath, I got what I wanted :

     using NAudio.CoreAudioApi; 
     MMDeviceEnumerator devEnum = new MMDeviceEnumerator();
     MMDevice defaultDevice = devEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
     string currVolume = "MasterPeakVolume : " + defaultDevice.AudioMeterInformation.MasterPeakValue.ToString();
    

提交回复
热议问题