Change volume of a currently running program
See original GitHub issueIs it possible to change the audio volume of a specific session/program (like Firefox)?
My current code allows me to change the volume of a device, but I can’t figure out how to change the volume of a program…
class Program
{
static void Main(string[] args)
{
try
{
MMDeviceEnumerator MMDE = new MMDeviceEnumerator();
MMDeviceCollection DevCol = MMDE.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active);
foreach (MMDevice dev in DevCol)
{
try
{
var newVolume = (float)Math.Max(Math.Min(10, 100), 0) / (float)100;
dev.AudioEndpointVolume.MasterVolumeLevelScalar = newVolume;
Debug.WriteLine("Volume of " + dev.DeviceFriendlyName + " is " + dev.AudioEndpointVolume.MasterVolumeLevelScalar.ToString());
}
catch (Exception ex)
{
Debug.WriteLine(dev.DeviceFriendlyName + " could not be muted " + ex);
}
}
}
catch (Exception ex)
{
Debug.WriteLine("Error: " + ex.Message);
}
Console.ReadKey();
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Windows 11: How to Change Sound Volume for Individual ...
If you left click the Sound icon in the notification area, it is possible to change only the master volume. Here is how...
Read more >How to Adjust Sound Volume for Individual Apps in ...
You can only change the volume for individual apps which are currently open and active. The volume setting changed will be reset if...
Read more >How to change the volume of different programs with your ...
In terms of a generic application to adjust audio volumes individually, your best bet would be NirSoft Volumouse.
Read more >How do I change default volume level for programs in ...
1. Open Internet Explorer. · 2. Open Volume Mixer. · 3. Drag the slider below Internet Explorer down to reduce its volume.
Read more >How to adjust app sound individually on Windows 10
To adjust the sound level for a particular app on Windows 10, open Settings > Sound > App volume and device preferences and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you, turns out I was using an older version for the library. Upgrading to 2.1 allow the SimpleAudioVolume property to be set.
You can set the Volume property on SimpleAudioVolume. The VolumePanel in NAudioDemo does this.