IWMPMediaCollection :: getByAlbum, méthode

La méthode getByAlbum retourne une interface IWMPPlaylist qui fournit l’accès aux éléments multimédias à partir de l’album spécifié.

Syntaxe

public IWMPPlaylist getByAlbum(
  System.String bstrAlbum
);

Public Function getByAlbum( _
  ByVal bstrAlbum As System.String _
) As IWMPPlaylist
Implements IWMPMediaCollection.getByAlbum

Paramètres

bstrAlbum [ dans]

System. String qui est le titre de l’album.

Valeur de retour

Interface wmplib. IWMPPlaylist pour les éléments multimédias récupérés.

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.

Il existe deux façons de récupérer une interface IWMPMediaCollection , et le comportement de la méthode getByAlbum dépend de ceux de ces deux méthodes. Si vous récupérez l’interface en appelant AxWindowsMediaPlayer. mediaCollection, la méthode getByAlbum retourne tous les éléments multimédias de la bibliothèque. Toutefois, si vous récupérez l’interface en appelant IWMPLibrary. mediaCollection, la méthode getByAlbum retourne uniquement les éléments audio de la bibliothèque qui appartiennent à l’album spécifié.

Exemples

L’exemple suivant utilise getByAlbum pour créer une sélection d’éléments multimédias lorsque l’utilisateur clique sur un bouton. La sélection contient des éléments avec l’album spécifié par l’utilisateur dans une zone de texte. L’objet AxWMPLib. AxWindowsMediaPlayer est représenté par la variable Player.

private void playAlbum_Click(object sender, System.EventArgs e)
{ 
    // ...Add code to ensure that the text box contains a valid value.
 
    // Retrieve the album title text that the user entered in the text box. 
    string album = getAlbum.Text;

    // Create the playlist using getByAlbum. 
    WMPLib.IWMPPlaylist pl = player.mediaCollection.getByAlbum(album);

    // Make the new playlist the current playlist. 
    player.currentPlaylist = pl;

    // Play the media in the current playlist. 
    player.Ctlcontrols.play();
}

Public Sub playAlbum_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playAlbum.Click

    ' ...Add code to ensure that the text box contains a valid value.

    ' Retrieve the album title text that the user entered in the text box. 
    Dim album As String = getAlbum.Text

    ' Create the playlist using getByAlbum. 
    Dim pl As WMPLib.IWMPPlaylist = player.mediaCollection.getByAlbum(album)

    ' Make the new playlist the current playlist. 
    player.currentPlaylist = pl

    ' Play the media in the current playlist. 
    player.Ctlcontrols.play()

End Sub

Spécifications

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

Voir aussi

Interface IWMPMediaCollection (VB et C#)

Interface IWMPPlaylist (VB et C#)