IWMPControls::currentItem-Eigenschaft
Die currentItem-Eigenschaft ruft das aktuelle Medienelement in einer Wiedergabeliste ab oder legt es fest.
Syntax
public IWMPMedia currentItem {get; set;}
Public Property currentItem As IWMPMedia
Eigenschaftswert
Eine WMPLib.IWMPMedia-Schnittstelle, die das Medienelement darstellt.
Bemerkungen
Diese Eigenschaft funktioniert nur mit Elementen in der aktuellen Wiedergabeliste. Das Festlegen von currentItem auf die Schnittstelle eines gespeicherten Medienelements wird nicht unterstützt.
Beispiele
Im folgenden Beispiel wird currentItem verwendet, um das aktuelle Medienelement des Players auf ein Element zu setzen, das aus einem Listenfeld ausgewählt wurde. Das Listenfeld wurde mit allen Elementen in der aktuellen Wiedergabeliste gefüllt. Das AxWMPLib.AxWindowsMediaPlayer-Objekt wird durch die Variable player dargestellt.
private void playItem_OnSelectedIndexChanged(object sender, System.EventArgs e)
{
int selectedItem = ((System.Windows.Forms.ListBox)sender).SelectedIndex;
// Ensure that the previous media item is stopped.
player.Ctlcontrols.stop();
// Set the current item to the item selected from the list box.
player.Ctlcontrols.currentItem = player.currentPlaylist.get_Item(selectedItem);
// Play the current item.
player.Ctlcontrols.play();
}
Public Sub playItem_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles playItem.SelectedIndexChanged
Dim lb As System.Windows.Forms.ListBox = sender
Dim selectedItem As Integer = lb.SelectedIndex
' Ensure that the previous media item is stopped.
player.Ctlcontrols.stop()
' Set the current item to the item selected from the list box.
player.Ctlcontrols.currentItem = player.currentPlaylist.Item(selectedItem)
' Play the current item.
player.Ctlcontrols.play()
End Sub
Requirements (Anforderungen)
| Anforderung | Wert |
|---|---|
| Version |
Windows Media Player 9-Serie oder höher |
| Namespace |
WMPLib |
| Assembly |
|