IWMPMediaCollection :: getAttributeStringCollection, méthode
La méthode getAttributeStringCollection retourne une interface IWMPStringCollection qui représente l’ensemble de toutes les valeurs d’un attribut spécifié dans un type de média.
Syntaxe
public IWMPStringCollection getAttributeStringCollection(
System.String bstrAttribute,
System.String bstrMediaType
);
Public Function getAttributeStringCollection( _
ByVal bstrAttribute As System.String, _
ByVal bstrMediaType As System.String _
) As IWMPStringCollection
Implements IWMPMediaCollection.getAttributeStringCollection
Paramètres
-
bstrAttribute [ dans]
-
System. String qui est l’attribut pour lequel les valeurs sont récupérées.
-
bstrMediaType [ dans]
-
System. String qui est le type de média pour lequel les valeurs sont récupérées.
Valeur de retour
Interface wmplib. IWMPStringCollection pour les valeurs récupérées.
Notes
Avant d’appeler cette méthode, 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 Windows Media, consultez la référence d’attribut.
Exemples
L’exemple suivant utilise getAttributeStringCollection pour afficher une liste de valeurs qui correspondent à un attribut particulier pour les éléments audio de la collection de supports. Une zone de liste permet à l’utilisateur de sélectionner un attribut, tel qu’un artiste, un genre ou un album, et une zone de texte multiligne affiche le résultat. L’objet AxWMPLib. AxWindowsMediaPlayer est représenté par la variable Player.
private void audioAttributes_OnSelectedIndexChanged(object sender, System.EventArgs e)
{
// Retrieve the attribute type from the ListBox
string attributeType = (string)((System.Windows.Forms.ListBox)sender).SelectedItem;
// Get an interface to the mediaCollection.
WMPLib.IWMPMediaCollection2 library = (WMPLib.IWMPMediaCollection2)player.mediaCollection;
// Get an interface to the string collection for the attribute type the user selects.
WMPLib.IWMPStringCollection2 all = (WMPLib.IWMPStringCollection2)library.getAttributeStringCollection(attributeType, "Audio");
// Clear the text box of previous results.
attributeValues.Clear();
// Create an array to hold the attribute values.
string[] attributeArray = new string[all.count];
// Loop through the string collection.
for (int i = 0; i < all.count; i++)
{
// Store the items in the array.
attributeArray[i] = all.Item(i);
}
// Display the items in the text box.
attributeValues.Lines = attributeArray;
}
Public Sub audioAttributes_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles audioAttributes.SelectedIndexChanged
' Retrieve the attribute type from the ListBox
Dim lb As System.Windows.Forms.ListBox = sender
Dim attributeType As String = lb.SelectedItem
' Get an interface to the mediaCollection.
Dim library As WMPLib.IWMPMediaCollection2 = player.mediaCollection
' Get an interface to the string collection for the attribute type the user selects.
Dim all As WMPLib.IWMPStringCollection2 = library.getAttributeStringCollection(attributeType, "Audio")
' Clear the text box of previous results.
attributeValues.Clear()
' Create an array to hold the attribute values.
Dim attributeArray(all.count) As String
' Loop through the string collection.
For i As Integer = 0 To (all.count - 1)
' Store the items in the array.
attributeArray(i) = all.Item(i)
Next i
' Display the items in the text box.
attributeValues.Lines = attributeArray
End Sub
Spécifications
| Condition requise | Valeur |
|---|---|
| Version |
Lecteur Windows Media série 9 ou version ultérieure |
| Espace de noms |
WMPLib |
| Assembly |
|