Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[c#] How to get all video and audio devices;
#1
Well today im going to show you how to get all audio & video devices on a machine, these will be loaded on form load and displayed in a listbox.
  • Step 1
    • Download this .rar with the necessary .DLLs. Link below
    • Microsoft.Expression.Encoder.Utilities.dll, Microsoft.Expression.Encoder.Types.dll, Microsoft.Expression.Encoder.dll, Microsoft.Expression.Encoder.Api2.dll.
      • 'Link'
      • Extract the.DLLs to a your desktop or a folder.

  • Step 2
    • Now in visual studio create a new project named GetDevices.
    • Next right click GetDevices in your Solution Explorer and click Add Reference.
    • Now select a .Dll and press Add.
    • Next do this for all the other .DLLs in which I supplied you.


  • Step 3
    • Now double click on form1.
    • Look for namespace GetDevices, above it Replace all the text with this.
      • Quote:using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Data;
        using System.Drawing;
        using System.Linq;
        using System.Text;
        using System.Windows.Forms;
        using Microsoft.Expression.Encoder.Devices;
        using Microsoft.Expression.Encoder.Live;
        using System.Runtime.InteropServices;


  • Step 4
    • Go back to to Form1.cs[Design]
    • Add 2 listboxes, name one LstAudio, and the other LstVideo.
    • Navigate back to form1.cs[Code]
    • In private void Form1_Load(object sender, EventArgs e) add this code.
      • Quote:foreach (EncoderDevice edv in EncoderDevices.FindDevices(EncoderDeviceType.Video))
        {
        lstVideo.Items.Add(edv.Name);
        }
        foreach (EncoderDevice eda in EncoderDevices.FindDevices(EncoderDeviceType.Audio))
        {
        LstAudio.Items.Add(eda.Name);
        }
Try it out.
So this is my first c# application. This tutorial was made by me, but the inspiration came from another site.
Reply


Messages In This Thread
[c#] How to get all video and audio devices; - by RDCA - 05-29-2011, 02:00 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)