IWMPPlaylist::attributeCount 属性
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
attributeCount 属性获取与播放列表关联的属性数。
语法
public System.Int32 attributeCount {get; set;}
Public ReadOnly Property attributeCount As System.Int32
属性值
System.Int32,表示与播放列表关联的属性数。
备注
由于播放列表可能来自许多不同的源,因此它们可以具有多个不同的属性集。 此属性获取与特定播放列表关联的属性总数,以便 IWMPPlaylist 接口的其他成员可以访问它们。
在使用此属性之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
有关Windows 媒体播放器支持的属性的详细信息,请参阅属性参考。
示例
下面的示例演示了如何使用 IWMPPlaylist 和 IWMPMedia 接口的各种属性和方法,方法是使用当前播放列表的节点、播放列表属性、播放列表中的媒体项和媒体项属性填充树视图控件。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
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);
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)
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈