VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#获取设备(Audio和Video)名称 简单整理(3)

三、使用AForge的API来获取。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// <summary>
/// 获取麦克风列表
/// </summary>
/// <returns></returns>
public static List<string> GetAudioInDevicesList()
{
    List<string> devicesList = new List<string>();
    try
    {
        var videoDevices = new FilterInfoCollection(FilterCategory.AudioInputDevice);
        foreach (FilterInfo device in videoDevices)
        {
            devicesList.Add(device.Name);
        }
    }
    catch (ApplicationException)
    {
        Console.WriteLine("No local capture devices");
    }
    return devicesList;
}
/// <summary>
/// 获取摄像头列表
/// </summary>
/// <returns></returns>
public static List<string> GetVideoInDevicesList()
{
    List<string> devicesList = new List<string>();
    try
    {
        var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo device in videoDevices)
        {
            devicesList.Add(device.Name);
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
    return devicesList;
}

相关教程