IWMPPlaylistCollection::getByName, méthode

[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 getByName renvoie une interface IWMPPlaylistArray qui fournit l’accès aux playlists portant le nom spécifié, le cas échéant.

Syntaxe

public IWMPPlaylistArray getByName(
  System.String bstrName
);

Public Function getByName( _
  ByVal bstrName As System.String _
) As IWMPPlaylistArray
Implements IWMPPlaylistCollection.getByName

Paramètres

bstrName [in]

System.String qui est le nom de la playlist.

Valeur retournée

Interface WMPLib.IWMPPlaylistArray pour le tableau de playlists récupéré.

Notes

Utilisez IWMPPlaylistArray.count pour déterminer s’il existe une playlist. Si count est égal à zéro, le tableau est vide.

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.

Exemples

L’exemple suivant utilise getByName pour case activée la collection de playlists d’une playlist nommée « Favoris - 4 et 5 star notés ». Si une playlist de ce nom existe, getByName la définit comme playlist actuelle. L’objet AxWMPLib.AxWindowsMediaPlayer est représenté par la variable nommée player.

// Get the count of the playlists named "Favorites -- 4 and 5 star rated".
int checkit = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").count;

// Since duplicate playlist names are allowed, the count returned
// will be either zero (no playlist) or greater than zero (playlist exists).
if (checkit > 0)
{
    // Retrieve a playlist array containing "Favorites -- 4 and 5 star rated".
    // Assume that there is only one playlist with that name, and assign it to the 
    // current playlist.
    player.currentPlaylist = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").Item(0);
}

'  Get the count of the playlists named "Favorites -- 4 and 5 star rated".
Dim checkit As Integer = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").count

'  Since duplicate playlist names are allowed, the count returned
'  will be either zero (no playlist) or greater than zero (playlist exists).
If (checkit > 0) Then

    '  Retrieve a playlist array object containing "Favorites -- 4 and 5 star rated".
    '  Assume that there is only one playlist with that name, and assign it to the 
    '  current playlist.
    player.currentPlaylist = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").Item(0)

End If

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

IWMPPlaylistArray, interface (VB et C#)

IWMPPlaylistArray.count (VB et C#)

IWMPPlaylistCollection, interface (VB et C#)