Share via


Windows Media Player 11 SDK IWMPMedia.attributeCount (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPMedia.attributeCount (VB and C#)

The attributeCount property gets the number of attributes that can be queried and/or set for the media item.

[Visual Basic]
ReadOnly Property attributeCount As Integer

[C#]
int attributeCount {get;}

Property Value

A System.Int32 that is the count.

Remarks

Before using this property, you must have read access to the library. For more information, see Library Access.

For information about the attributes supported by Windows Media Player, see the Attribute Reference.

Example Code

The following example uses attributeCount to determine the number of attributes available in the current media item. The code uses that value to display a list of attribute names and values in a text box. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

[Visual Basic]
' Store an IWMPMedia3 interface to the current media item. 
Dim cm As WMPLib.IWMPMedia3 = player.currentMedia

' Store the number of attributes in the current media item using attributeCount.
Dim numAttributes As Integer = cm.attributeCount

' Create strings to hold each attribute name and value.
Dim atName As String
Dim atValue As String

' Create an array to hold the attribute list.
Dim atList(numAttributes) As String

' Loop through the attribute list.   
For i As Integer = 0 To (numAttributes - 1)

    ' Fill the strings with the attribute information.
    atName = cm.getAttributeName(i)
    atValue = cm.getItemInfo(atName)

    ' Store the attribute information in an array.
    atList(i) = (atName + ": " + atValue)

Next i

' Display the attribute information in the text box.
attributeList.Lines = atList

FakePre-5122d36cbd364b89be9470f7df63c1cf-91c08be8482345c8ac3420ec54e24b1a

// Store an IWMPMedia3 interface to the current media item. 
WMPLib.IWMPMedia3 cm = (WMPLib.IWMPMedia3)player.currentMedia;

// Store the number of attributes in the current media item using attributeCount.
int numAttributes = cm.attributeCount;

// Create strings to hold each attribute name and value.
string atName;
string atValue;

// Create an array to hold the attribute list.
string [] atList = new string[numAttributes];

// Loop through the attribute list.   
for (int i = 0; i < numAttributes; i++)
{
    // Fill the strings with the attribute information.
    atName = cm.getAttributeName(i);
    atValue = cm.getItemInfo(atName);

    // Store the attribute information in an array.
    atList[i] = (atName + ": " + atValue);
}

// Display the attribute information in the text box.
attributeList.Lines = atList;

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)

See Also

Previous Next