Share via


Get a Collection of Media Devices

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The IUccMediaDeviceManager interface provides a method to return a collection of audio and video devices on a local machine capable of capturing and rendering media content. The returned IUccCollection object provides the interface necessary to iterate over the collection of IUccMediaDevice interface objects that represent the media hardware attached to the local machine.

The attributes of each individual media device is encapsulated by the property members of the IUccMediaDevice.

Building a List of Media Devices

The example method in the C# snippet uses a collection of audio media device objects to fill a list control (mediaDeviceList) on a form. The Id and MediaType properties will be read from each IUccMediaDevice. The dm object implements the IUccMediaDeviceManager interface.

private void loadAudioMediaDevices()
{
    mediaDeviceList.Items.Clear();
    try
    {
        IUccCollection mds = dm.GetDevices(
                UCC_MEDIA_TYPES.UCCMT_AUDIO,
                UCC_MEDIA_DIRECTIONS.UCCMD_RECEIVE);

        if (mds != null && mds.Count > 0)
        {
            foreach (IUccMediaDevice md in mds)
            {
                int addedItem = 0;
                StringBuilder s_dp = new StringBuilder();
                s_dp.Append(
                     "ID: ");

                s_dp.Append(
                     md.Id.ToString());

                s_dp.Append(
                     " Device Type: ");

                s_dp.Append(
                     md.MediaType.ToString());
               if (s_dp != null)
                    addedItem = mediaDeviceList.Items.Add(s_dp.ToString());
            }
        }
    }
    catch (COMException CE_1)
    {
        Console.WriteLine(CE_1.ErrorCode.ToString());
    }
    catch (Exception lMD)
    {
        Console.WriteLine(lMD.Message);
    }
}

See Also

Concepts

Get and Set the Selected Device for a Media Type
Invoke a Tuning Wizard