Compartilhar via


IWMPPlaylist.Item (VB e C#)

[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.]

A propriedade Item (o método get_Item em C#) obtém uma interface para o item de mídia no índice especificado.

[Visual Basic]
ReadOnly Property Item(
  lIndex As System.Int32
) As IWMPMedia
[C#]
IWMPMedia get_Item (
  System.Int32 lIndex 
);

Parâmetros

lIndex

Um System.Int32 que é o índice do item de mídia na playlist.

Valor da propriedade

Uma interface WMPLib.IWMPMedia que fornece acesso ao item de mídia no índice especificado.

Comentários

IWMPPlaylist.Item é uma propriedade somente leitura no Visual Basic que usa um parâmetro, enquanto no C# ele é conhecido como o método IWMPPlaylist.get_Item .

Exemplos

O exemplo a seguir usa a propriedade Item (o método get_Item em C#) para recuperar um item de mídia de uma playlist com base em uma seleção de usuário. Uma caixa de listagem foi criada com o nome weblist e preenchida com os títulos da playlist chamada audioPlaylist. O objeto AxWMPLib.AxWindowsMediaPlayer é representado pela variável chamada player.

private void weblist_SelectedIndexChanged(object sender, System.EventArgs e)
{
    // Store the index of the selected item in the list box.
    int index = ((System.Windows.Forms.ListBox)sender).SelectedIndex;

    // Store the corresponding media item from the playlist.
    WMPLib.IWMPMedia listItem = audioPlaylist.get_Item(index);

    // Set the player URL to the URL of the selected media item.
    player.URL = listItem.sourceURL;
}

Public Sub weblist_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles weblist.SelectedIndexChanged

    ' Store the index of the selected item in the list box.
    Dim lb As System.Windows.Forms.ListBox = sender
    Dim index As Integer = lb.SelectedIndex

    ' Store the corresponding media item from the playlist.
    Dim listItem As WMPLib.IWMPMedia = audioPlaylist.Item(index)

    ' Set the player URL to the URL of the selected media item.
    player.URL = listItem.sourceURL

End Sub

Requisitos

Requisito Valor
Versão
série Reprodutor Multimídia do Windows 9 ou posterior
Namespace
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

Confira também

Interface IWMPMedia (VB e C#)

Interface IWMPPlaylist (VB e C#)

IWMPPlaylist.insertItem (VB e C#)

IWMPPlaylist.removeItem (VB e C#)

IWMPSettings2.mediaAccessRights (VB e C#)

IWMPSettings2.requestMediaAccessRights (VB e C#)