次の方法で共有


CurrentItemChange Event of the AxWindowsMediaPlayer Object

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The CurrentItemChange event occurs when the value of IWMPControls.currentItem changes.

[C#]
private void player_CurrentItemChange(
  object sender,
  _WMPOCXEvents_CurrentItemChangeEvent e
)

[Visual Basic]
Private Sub player_CurrentItemChange(  
  sender As Object,
  e As _WMPOCXEvents_CurrentItemChangeEvent
) Handles player.CurrentItemChange

Event Data

The handler associated with this event is of type AxWMPLib._WMPOCXEvents_CurrentItemChangeEventHandler. This handler receives an argument of type AxWMPLib._WMPOCXEvents_CurrentItemChangeEvent, which contains the following property related to this event.

Property Description
pdispMedia System.ObjectThe new current media item. You can cast this to an IWMPMedia interface to access it.

Examples

The following example demonstrates an event handler for the CurrentItemChange event. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

// Add a delegate for the CurrentItemChange event
player.CurrentItemChange += new AxWMPLib._WMPOCXEvents_CurrentItemChangeEventHandler(player_CurrentItemChange);

private void player_CurrentItemChange(object sender, AxWMPLib._WMPOCXEvents_CurrentItemChangeEvent e)
{
    // Display the name of the new media item.
    mediaText.Text = player.currentMedia.name;
}

Public Sub player_CurrentItemChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_CurrentItemChangeEvent) Handles player.CurrentItemChange

    ' Display the name of the new media item.
    mediaText.Text = player.currentMedia.name

End Sub

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
AxWMPLib
Assembly
AxInterop.WMPLib.dll (AxInterop.WMPLib.dll.dll)

See also

AxWindowsMediaPlayer Object (VB and C#)

IWMPControls.currentItem (VB and C#)

IWMPMedia Interface (VB and C#)