Méthode IWMPMedia::getAttributeName

[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 méthode getAttributeName retourne le nom de l’attribut correspondant à l’index spécifié.

Syntaxe

public System.String getAttributeName(
  System.Int32 lIndex
);

Public Function getAttributeName( _
  ByVal lIndex As System.Int32 _
) As System.String
Implements IWMPMedia.getAttributeName

Paramètres

lIndex [in]

System.Int32 qui est l’index.

Valeur retournée

System.String qui est le nom de l’attribut.

Notes

Le nom d’attribut retourné peut être utilisé conjointement avec getItemInfo pour récupérer la valeur d’un attribut nommé spécifique.

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 multimédia Windows, consultez référence des attributs.

Exemples

L’exemple suivant utilise getAttributeName pour remplir une zone de texte multiligne avec l’index et le nom de chaque attribut pour l’élément multimédia actif. L’objet AxWMPLib.AxWindowsMediaPlayer est représenté par la variable nommée player.

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

// Get the number of attributes for the current media item. 
int attCount = cm.attributeCount;

// Create an array of strings to hold the index and name for each attribute.
string[] attInfo = new string[attCount];

// Loop through the attribute list.
for (int i = 0; i < attCount; i++)
{
    // Store the attribute index and name in the array.
    attInfo[i] = ("Attribute " + i + ": " + cm.getAttributeName(i));
}

// Display the attribute information in the text box.
attributeNames.Lines = attInfo;

' Store an IWMPMedia3 interface for the current media item. 
Dim cm As WMPLib.IWMPMedia3 = player.currentMedia

&#39; Get the number of attributes for the current media. 
Dim attCount As Integer = cm.attributeCount

&#39; Create an array of strings to hold the index and name for each attribute.
Dim attInfo(attCount) As String

&#39; Loop through the attribute list.
For i As Integer = 0 To (attCount - 1)

    &#39; Store the attribute index and name in the array.
    attInfo(i) = (&quot;Attribute &quot; + i.ToString() + &quot;: &quot; + cm.getAttributeName(i))

Next i

&#39; Display the attribute information in the text box.
attributeNames.Lines = attInfo

Configuration requise

Condition requise Valeur
Version
Lecteur multimédia Windows série 9 ou ultérieure
Espace de noms
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

Voir aussi

Interface IWMPMedia (VB et C#)

IWMPMedia.getItemInfo (VB et C#)