Share via


IWMEncSourceGroupCollection.Add

Windows Media Encoder SDK banner art

The Add method appends a new source group to the collection.

Syntax

IWMEncSourceGroup IWMEncSourceGroupCollection.Add(
  string  bstrName
);

Parameters

bstrName

[in]  String containing the name of the source group to be added to the collection.

Return Values

This method returns an IWMEncSourceGroup object.

If this method fails, it returns an error number.

Number Description
0x80070057 The string containing the name of the source group cannot be empty.
0x8007000E Memory cannot be allocated.

Remarks

The source group being added must be identified by a valid name assigned with the IWMEncSourceGroup.Name property. The Add method creates a source group object for the input name, adds the source group to the collection and returns the object to the caller. The IWMEncSourceGroupCollection.Item method can be used to retrieve a source group from the collection.

Example Code

using WMEncoderLib;

try
{
// Create a WMEncoder object.
WMEncoder Encoder;
Encoder = new WMEncoder();

// Declare objects and variables.
IWMEncSourceGroupCollection SrcGrpColl;
IWMEncSourceGroup SrcGrp;
IWMEncSourceGroup SrcGrp1;
IWMEncSourceGroup SrcGrp2;
IWMEncSourceGroup SrcGrp3;
int i;

// Create an IWMEncSourceGroupCollection object.
SrcGrpColl = Encoder.SourceGroupCollection;

// Add new source groups to the collection.
SrcGrp1 = SrcGrpColl.Add("SG_1");
SrcGrp2 = SrcGrpColl.Add("SG_2");
SrcGrp3 = SrcGrpColl.Add("SG_3");

// Loop through the collection to find a specific
// source group.
for (i = 0; i < SrcGrpColl.Count; i++)
{
    SrcGrp = SrcGrpColl.Item(i);
    if (SrcGrp.Name == "SG_3")
    {
        // Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move(SrcGrp3, SrcGrp1);
        // Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3;
    }
}

// Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove(2);
}

catch (Exception e)
{
     // TODO: Handle exceptions.
}

Requirements

Reference: Windows Media Encoder

Namespace: WMEncoderLib

Assembly: Interop.WMEncoderLib.dll

Library: WMEncoderLib.dll

See Also