Método IWMPMediaCollection::getByGenre
[O recurso associado a esta página, Reprodutor Multimídia do Windows SDK, é um recurso herdado. Foi substituído pelo MediaPlayer. O MediaPlayer foi otimizado para Windows 10 e Windows 11. A Microsoft recomenda fortemente que o novo código use o MediaPlayer em vez de Reprodutor Multimídia do Windows SDK, quando possível. A Microsoft sugere que o código existente que usa as APIs herdadas seja reescrito para usar as novas APIs, se possível.]
O getByGenre
método retorna uma interface IWMPPlaylist que fornece acesso a itens de mídia do gênero especificado.
Sintaxe
public IWMPPlaylist getByGenre(
System.String bstrGenre
);
Public Function getByGenre( _
ByVal bstrGenre As System.String _
) As IWMPPlaylist
Implements IWMPMediaCollection.getByGenre
Parâmetros
-
bstrGenre [in]
-
O System.String que é o nome do gênero.
Retornar valor
Uma interface WMPLib.IWMPPlaylist para os itens de mídia recuperados.
Comentários
Antes de chamar esse método, você deve ter acesso de leitura à biblioteca. Para obter mais informações, consulte Acesso à biblioteca.
Há duas maneiras de recuperar uma interface IWMPMediaCollection e o comportamento do método depende de getByGenre
qual dessas duas maneiras você usa. Se você recuperar a interface chamando AxWindowsMediaPlayer.mediaCollection, o getByGenre
método retornará todos os itens de mídia na biblioteca. No entanto, se você recuperar a interface chamando IWMPLibrary.mediaCollection, o getByGenre
método retornará apenas os itens de áudio na biblioteca que têm o atributo e o valor especificados.
Exemplos
O exemplo a seguir usa getByGenre
para recuperar uma playlist de itens de mídia quando o usuário clica em um botão. A playlist contém itens com o gênero especificado pelo usuário em uma caixa de texto. O objeto AxWMPLib.AxWindowsMediaPlayer é representado pela variável chamada player.
private void playGenre_Click(object sender, System.EventArgs e)
{
// ...Add code to ensure that the text box contains a valid value.
// Retrieve the genre that the user entered in the text box.
string genre = getGenre.Text;
// Create the playlist using getByGenre.
WMPLib.IWMPPlaylist pl = player.mediaCollection.getByGenre(genre);
// Make the new playlist the current playlist.
player.currentPlaylist = pl;
// Play the media in the current playlist.
player.Ctlcontrols.play();
}
Public Sub playGenre_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playGenre.Click
' ...Add code to ensure that the text box contains a valid value.
' Retrieve the genre that the user entered in the text box.
Dim genre As String = getGenre.Text
' Create the playlist using getByGenre.
Dim pl As WMPLib.IWMPPlaylist = player.mediaCollection.getByGenre(genre)
' Make the new playlist the current playlist.
player.currentPlaylist = pl
' Play the media in the current playlist.
player.Ctlcontrols.play()
End Sub
Requisitos
Requisito | Valor |
---|---|
Versão |
série Reprodutor Multimídia do Windows 9 ou posterior |
Namespace |
WMPLib |
Assembly |
|
Confira também
Comentários
https://aka.ms/ContentUserFeedback.
Em breve: Ao longo de 2024, eliminaremos os problemas do GitHub como o mecanismo de comentários para conteúdo e o substituiremos por um novo sistema de comentários. Para obter mais informações, consulteEnviar e exibir comentários de