我正在尝试使用coreaudio.dll从Volume Mixer中静音Spotify卷。 这是我的代码:
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);
}
这是输出:
'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.
这段代码在我使用它的几周前曾经完美地运行。最近我从W8.1 64位转到W8.1 32位。从那以后就出现了这个问题。
有什么想法吗?
答案 0 :(得分:1)
这是一个副作用,但最好的办法是避免操纵调音台,而是使用Spotify API。它为您提供了所需的一切控制,并且对用户来说不那么容易混淆 - 我认识的大多数非专家都没有想到那里有一个体积混音器而且Spotify没有检查混音器或者,你最终得到一个静音的Spotify,它看起来没有静音,也无法修复它。