Propriété IWMPPlaylist::attributeCount
[La fonctionnalité associée à cette page, Lecteur multimédia Windows SDK, est une fonctionnalité héritée. Il a été remplacé par MediaPlayer. MediaPlayer a été optimisé pour Windows 10 et Windows 11. Microsoft recommande vivement que le nouveau code utilise MediaPlayer au lieu de Lecteur multimédia Windows SDK, lorsque cela est possible. Microsoft suggère que le code existant qui utilise les API héritées soit réécrit pour utiliser les nouvelles API si possible.]
La propriété attributeCount obtient le nombre d’attributs associés à une playlist.
Syntaxe
public System.Int32 attributeCount {get; set;}
Public ReadOnly Property attributeCount As System.Int32
Valeur de la propriété
System.Int32 qui correspond au nombre d’attributs associés à la playlist.
Notes
Étant donné que les playlists peuvent provenir de nombreuses sources différentes, elles peuvent avoir plusieurs ensembles d’attributs différents. Cette propriété obtient le nombre total d’attributs associés à une playlist particulière afin que d’autres membres de l’interface IWMPPlaylist puissent y accéder.
Avant d’utiliser cette propriété, vous devez disposer d’un accès en lecture à la bibliothèque. Pour plus d’informations, consultez Accès à la bibliothèque.
Pour plus d’informations sur les attributs pris en charge par Lecteur multimédia Windows, consultez référence d’attribut.
Exemples
L’exemple suivant montre comment différentes propriétés et méthodes des interfaces IWMPPlaylist et IWMPMedia sont utilisées en remplissant un contrôle treeview avec des nœuds pour la playlist actuelle, les attributs de playlist, les éléments multimédias dans la playlist et les attributs d’élément multimédia. L’objet AxWMPLib.AxWindowsMediaPlayer est représenté par la variable nommée 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)
Configuration requise
Condition requise | Valeur |
---|---|
Version |
Lecteur multimédia Windows série 9 ou ultérieure |
Espace de noms |
WMPLib |
Assembly |
|
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour