如何得到默认的音频设备? [英] How to get the default audio device?
本文介绍了如何得到默认的音频设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用3第三方DLL可以列举音频设备(提供名称和GUID-ID),并设置一个音频设备的默认的(用ID)。
I'm using a 3-rd party DLL which can enumerate the audio devices (providing name and guid-id) and set an audio device to the default one (by the id).
我怎样才能在电流音频设备(用于通过OS)?我需要的名称或设备ID。
How can I get the current audio device (which is used by OS)? I need either name or device id.
这问题似乎没有任何有用的答案。
This question seems to have no useful answers.
这其中也。
推荐答案
您可以使用DirectShow的这一点。
You can use DirectShow for this.
private IBaseFilter CreateFilter(Guid category, string name)
{
object source = null;
Guid guid = typeof(IBaseFilter).GUID;
foreach (DsDevice device in DsDevice.GetDevicesOfCat(category))
{
if ( device.Name == name )
{
device.Mon.BindToObject(null, null, ref guid, out source);
break;
}
}
return (IBaseFilter)source;
}
// Get device like this:
IBaseFilter defaultSoundDevice = CreateFilter( FilterCategory.AudioInputDevice, "Default DirectSound Device" );
更新#2:
DsDevice[] audioRenderers;
audioRenderers = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice);
foreach (DsDevice device in audioRenderers)
{
MessageBox.Show(device.Name);
}
这篇关于如何得到默认的音频设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文