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

Windows Media Player SDK banner art

Previous Next

IWMPPlaylist.attributeCount (VB and C#)

The attributeCount property gets the number of attributes associated with a playlist.

  

Property Value

A System.Int32 that is the number of attributes associated with the playlist.

Remarks

Because playlists can come from many different sources, they can have several different sets of attributes. This property gets the total number of attributes associated with a particular playlist so that other members of the IWMPPlaylist interface can access them.

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

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

Example Code

The following example illustrates how various properties and methods of the IWMPPlaylist and IWMPMedia interfaces are used by filling a treeview control with nodes for the current playlist, playlist attributes, media items in the playlist, and media item attributes. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

  
Dim playlist As WMPLib.IWMPPlaylist = player.currentPlaylist
Dim Media As WMPLib.IWMPMedia
Dim name As String

' Demonstrates setItemInfo()
playlist.setItemInfo("custom playlist attribute", "changed")
playlist.Item(0).setItemInfo("new custom attribute", "5")

' Create a tree node for each playlist attribute and a subnode for the item info of that attribute.
Dim playlistRootNode As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Playlist Attributes")

For i As Integer = 0 To (playlist.attributeCount - 1) Step 1

    ' Add a tree node for each playlist attribute.
    Dim attribute As String = playlist.attributeName(i)
    playlistRootNode.Nodes.Add(New System.Windows.Forms.TreeNode(attribute))

    ' Add a subnode for the item info for that attribute.
    Dim info As String = playlist.getItemInfo(attribute)
    playlistRootNode.Nodes(i).Nodes.Add(New System.Windows.Forms.TreeNode(info))

Next i

' Add the playlist root node to the tree
displayAttributes.Nodes.Add(playlistRootNode)

' Add nodes for each media item and subnodes for each attribute of that item.
Dim mediaRootNode As System.Windows.Forms.TreeNode = New System.Windows.Forms.TreeNode("Media Items in the Playlist")

For i As Integer = 0 To (playlist.count - 1) Step 1

    ' Get the media item
    Media = playlist.Item(i)

    ' Add a tree node for each media item in the playlist.
    mediaRootNode.Nodes.Add(New System.Windows.Forms.TreeNode(Media.name))

    ' Add a child node for each attribute of the media item
    For j As Integer = 0 To (Media.attributeCount - 1) Step 1

        name = Media.getAttributeName(j)
        mediaRootNode.Nodes(i).Nodes.Add(New System.Windows.Forms.TreeNode(name + ": " + Media.getItemInfo(name)))

    Next j

Next i

' Add the media root node to the tree
displayAttributes.Nodes.Add(mediaRootNode)

FakePre-65d1d275bbbf49818dfc8dec05a5a805-5bca0bf966d647b8811085c5f69d8835

WMPLib.IWMPPlaylist playlist = player.currentPlaylist;
WMPLib.IWMPMedia media;
string name;

// Demonstrates setItemInfo()
playlist.setItemInfo("custom playlist attribute", "changed");
playlist.get_Item(0).setItemInfo("new custom attribute", "5");

// Create a tree node for each playlist attribute and a subnode for the item info of that attribute.
System.Windows.Forms.TreeNode playlistRootNode = new System.Windows.Forms.TreeNode("Playlist Attributes");

for (int i = 0; i < playlist.attributeCount; ++i)
{
    // Add a tree node for each playlist attribute.
    string attribute = playlist.get_attributeName(i);
    playlistRootNode.Nodes.Add(new System.Windows.Forms.TreeNode(attribute));

    // Add a subnode for the item info for that attribute.
    string info = playlist.getItemInfo(attribute);
    playlistRootNode.Nodes[i].Nodes.Add(new System.Windows.Forms.TreeNode(info));
}

// Add the playlist root node to the tree
displayAttributes.Nodes.Add(playlistRootNode);

// Add nodes for each media item and subnodes for each attribute of that item.
System.Windows.Forms.TreeNode mediaRootNode = new System.Windows.Forms.TreeNode("Media Items in the Playlist");
for(int i = 0; i < playlist.count; i++)
{
    // Get the media item
    media = playlist.get_Item(i);

    // Add a tree node for each media item in the playlist.
    mediaRootNode.Nodes.Add(new System.Windows.Forms.TreeNode(media.name));

    // Add a child node for each attribute of the media item
    for(int j = 0; j < media.attributeCount; j++)
    {
        name = media.getAttributeName(j);
        mediaRootNode.Nodes[i].Nodes.Add(new System.Windows.Forms.TreeNode(name + ": " + media.getItemInfo(name)));
    }
}

// Add the media root node to the tree
displayAttributes.Nodes.Add(mediaRootNode);

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

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

See Also

Previous Next