I am using the following code of answer 2 to mute external players like vlc or windows media player.
Controlling Application's Volume: By Process-ID
The VLC player is muted properly. But windows media player does not.
Visually it is mutated correctly as shown in the following image. But I still hear the sound through the speakers. When I remove the mute (mute of the application) and I put it manually using the mouse it is muted correctly.
public static void mute()
{
for(int i = 0;i<playerList.Length;i++)
{
var hWnd = FindWindow(null, playerList[i]);
if (hWnd == IntPtr.Zero)
{
Console.WriteLine("Mute " + playerList[i] + " Error_1");
continue;
}
uint pID;
GetWindowThreadProcessId(hWnd, out pID);
if (pID == 0)
{
Console.WriteLine("Mute " + playerList[i] + " Error_2");
continue;
}
VolumeMixer.SetApplicationMute((int)pID, true);
Console.WriteLine("Mute " + playerList[i] + " Ok PID: " + pID);
}
}