I am trying to mute the Spotify volume from the Volume Mixer with coreaudio.dll. This is my code:
private float volume = 0.9f;
MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
MMDevice device = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
AudioSessionManager2 asm = device.AudioSessionManager2;
SessionCollection sessions = asm.Sessions;
try
{
for (int sid = 0; sid < sessions.Count; sid++)
{
string id = sessions[sid].GetSessionIdentifier;
Console.WriteLine(id);
if (id.ToLower().IndexOf("spotify.exe") > -1)
{
if (muted)
{
volume = sessions[sid].SimpleAudioVolume.MasterVolume;
sessions[sid].SimpleAudioVolume.MasterVolume = 0;
}
else
{
sessions[sid].SimpleAudioVolume.MasterVolume = volume;
}
//sessions[sid].SimpleAudioVolume.Mute = muted;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
This is the output:
'VMTit.vshost.exe' (CLR v4.0.30319: VMTit.vshost.exe): Loaded 'C:\Users\Maria\Desktop\Spotify-Ad-Blocker-1.6.3.0\VMTit\VMTit2\bin\Debug\VMTit.exe'. Symbols loaded.
'VMTit.vshost.exe' (CLR v4.0.30319: VMTit.vshost.exe): Loaded 'C:\Users\Maria\Desktop\Spotify-Ad-Blocker-1.6.3.0\VMTit\VMTit2\bin\Debug\CoreAudio.dll'. Cannot find or open the PDB file.
{0.0.0.00000000}.{612a18a0-426d-44a5-bfe5-655ee61c2700}|#%b{A9EF3FD9-4240-455E-A4D5-F2B3301887B2}
{0.0.0.00000000}.{612a18a0-426d-44a5-bfe5-655ee61c2700}|\Device\HarddiskVolume2\Program Files\Steam\Steam.exe%b{00000000-0000-0000-0000-000000000000}
{0.0.0.00000000}.{612a18a0-426d-44a5-bfe5-655ee61c2700}|\Device\HarddiskVolume2\Users\Maria\AppData\Roaming\Spotify\Spotify.exe%b{00000000-0000-0000-0000-000000000000}
The program '[7908] VMTit.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation.
This code used to work perfectly some weeks ago when I was using it. Recently I moved from W8.1 64bit to W8.1 32bits. It's since then that this problem occurs.
Any ideas?