Método IWMPMediaCollection::getByAuthor

[La característica asociada a esta página, Reproductor multimedia de Windows SDK, es una característica heredada. Se ha reemplazado por MediaPlayer. MediaPlayer se ha optimizado para Windows 10 y Windows 11. Microsoft recomienda encarecidamente que el nuevo código use MediaPlayer en lugar de Reproductor multimedia de Windows SDK, siempre que sea posible. Microsoft sugiere que el código existente que usa las API heredadas se reescriba para usar las nuevas API si es posible.

El getByAuthor método devuelve una interfaz IWMPPlaylist que proporciona acceso a los elementos multimedia del autor especificado.

Sintaxis

public IWMPPlaylist getByAuthor(
  System.String bstrAuthor
);

Public Function getByAuthor( _
  ByVal bstrAuthor As System.String _
) As IWMPPlaylist
Implements IWMPMediaCollection.getByAuthor

Parámetros

bstrAuthor [in]

System.String que es el nombre del autor.

Valor devuelto

Interfaz WMPLib.IWMPPlaylist para los elementos multimedia recuperados.

Observaciones

Antes de llamar a este método, debe tener acceso de lectura a la biblioteca. Para obtener más información, consulte Acceso a la biblioteca.

Hay dos maneras de recuperar una interfaz IWMPMediaCollection y el comportamiento del getByAuthor método depende de cuál de esas dos formas de usar. Si recuperas la interfaz llamando a AxWindowsMediaPlayer.mediaCollection, el getByAuthor método devuelve todos los elementos multimedia de la biblioteca. Sin embargo, si recupera la interfaz llamando a IWMPLibrary.mediaCollection, el getByAuthor método devuelve solo los elementos de audio de la biblioteca que tienen el atributo y el valor especificados.

Ejemplos

En el ejemplo siguiente se usa getByAuthor para crear una lista de reproducción de elementos multimedia cuando el usuario hace clic en un botón. La lista de reproducción contiene elementos que coinciden con el nombre del autor especificado por el usuario en un cuadro de texto. El objeto AxWMPLib.AxWindowsMediaPlayer se representa mediante la variable denominada player.

private void playAuthor_Click(object sender, System.EventArgs e)
{ 
    // ...Add code to ensure that the text box contains a valid value.
 
    // Retrieve the author's name from the text box. 
    string author = getAuthor.Text;

    // Create the playlist using getByAuthor. 
    WMPLib.IWMPPlaylist pl = player.mediaCollection.getByAuthor(author);

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

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

Public Sub playAuthor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playAuthor.Click

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

    ' Retrieve the author's name from the text box. 
    Dim author As String = getAuthor.Text

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

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

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

End Sub

Requisitos

Requisito Value
Versión
Reproductor multimedia de Windows serie 9 o posterior
Espacio de nombres
WMPLib
Ensamblado
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

Consulte también

Interfaz IWMPMediaCollection (VB y C#)

Interfaz IWMPPlaylist (VB y C#)