My current Code is:
public static MMDevice GetDefaultRenderDevice()
{
using (var enumerator = new MMDeviceEnumerator())
{
return enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
}
}
public static bool IsAudioPlaying(MMDevice device)
{
using (var meter = AudioMeterInformation.FromDevice(device))
{
return meter.PeakValue > 0;
}
}
When I say Console.WriteLine(IsAudioPlaying(GetDefaultRenderDevice())); it only tells if any sound is played. What can I do if I only want it to check if for example chrome plays a sound?
You can use the AudioSession api. Take a look at the AudioSessionTests of cscore. https://github.com/filoe/cscore/blob/master/CSCore.Test/CoreAudioAPI/AudioSessionTests.cs
It might work using something like this: