Método IWMPMediaCollection::getByName
[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 getByName
método retorna uma interface IWMPPlaylist que fornece acesso a itens de mídia com o nome especificado.
Sintaxe
public IWMPPlaylist getByName(
System.String bstrName
);
Public Function getByName( _
ByVal bstrName As System.String _
) As IWMPPlaylist
Implements IWMPMediaCollection.getByName
Parâmetros
-
bstrName [in]
-
O System.String que é o nome especificado.
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 getByName
quais dessas duas maneiras você usa. Se você recuperar a interface chamando AxWindowsMediaPlayer.mediaCollection, o getByName
método retornará todos os itens de mídia na biblioteca. No entanto, se você recuperar a interface chamando IWMPLibrary.mediaCollection, o getByName
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 getByName
para recuperar três itens da biblioteca. Cada item é acrescentado à playlist atual. O objeto AxWMPLib.AxWindowsMediaPlayer é representado pela variável chamada player.
// In each case, use the name exactly as it appears in the library.
// Windows Media Player does not include file name extensions or file paths
// in the name. Internet URLs include the entire path, but not the
// file name extension.
// Get an interface to a playlist that contains an Internet URL.
WMPLib.IWMPPlaylist one = player.mediaCollection.getByName("https://www.proseware.com/Media/Laure");
// Get an interface to a playlist that contains a file on a network server.
WMPLib.IWMPPlaylist two = player.mediaCollection.getByName("Jeanne");
// Get an interface to a playlist that contains a file on a local drive.
WMPLib.IWMPPlaylist three = player.mediaCollection.getByName("house");
// Append each item to the current playlist. Since each playlist retrieved
// using getByName contains one digital media item, use the get_Item
// method with an index of zero to reference that item.
player.currentPlaylist.appendItem(one.get_Item(0));
player.currentPlaylist.appendItem(two.get_Item(0));
player.currentPlaylist.appendItem(three.get_Item(0));
' In each case, use the name exactly as it appears in the library.
' Windows Media Player does not include file name extensions or file paths
' in the name. Internet URLs include the entire path, but not the
' file name extension.
' Get an interface to a playlist that contains an Internet URL.
Dim one As WMPLib.IWMPPlaylist = player.mediaCollection.getByName("https://www.proseware.com/Media/Laure")
' Get an interface to a playlist that contains a file on a network server.
Dim two As WMPLib.IWMPPlaylist = player.mediaCollection.getByName("Jeanne")
' Get an interface to a playlist that contains a file on a local drive.
Dim three As WMPLib.IWMPPlaylist = player.mediaCollection.getByName("house")
' Append each item to the current playlist. Since each playlist retrieved
' using getByName contains one digital media item, use the Item
' property with an index of zero to reference that item.
player.currentPlaylist.appendItem(one.Item(0))
player.currentPlaylist.appendItem(two.Item(0))
player.currentPlaylist.appendItem(three.Item(0))
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