如何获得扬声器音量级别?
How to get Speaker Volume Level?
如何在 C# 中获取扬声器音量?
speaker volume image
并在我的应用程序中显示它?
App image
使用 NAudio,您可以执行以下操作:
using NAudio.CoreAudioApi;
.....
// download NAudio.dll from https://github.com/naudio/NAudio/releases
// and add it as Reference to the project
var devEnum = new MMDeviceEnumerator();
var defaultDevice = devEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
var volume = defaultDevice.AudioEndpointVolume;
float leftVolumePercent = volume.Channels[0].VolumeLevelScalar * 100;
float rightVolumePercent = volume.Channels[1].VolumeLevelScalar * 100;
float masterVolumePercent = volume.MasterVolumeLevelScalar * 100;
这个 article 演示了如何在没有外部框架的情况下实现这些事情。
如何在 C# 中获取扬声器音量?
speaker volume image
并在我的应用程序中显示它?
App image
使用 NAudio,您可以执行以下操作:
using NAudio.CoreAudioApi;
.....
// download NAudio.dll from https://github.com/naudio/NAudio/releases
// and add it as Reference to the project
var devEnum = new MMDeviceEnumerator();
var defaultDevice = devEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
var volume = defaultDevice.AudioEndpointVolume;
float leftVolumePercent = volume.Channels[0].VolumeLevelScalar * 100;
float rightVolumePercent = volume.Channels[1].VolumeLevelScalar * 100;
float masterVolumePercent = volume.MasterVolumeLevelScalar * 100;
这个 article 演示了如何在没有外部框架的情况下实现这些事情。