Windows Media Player 11 SDK AxWindowsMediaPlayer.MediaChange Event (VB and C#)
Previous | Next |
AxWindowsMediaPlayer.MediaChange Event (VB and C#)
The MediaChange event occurs when a media item changes.
[Visual Basic] Private Sub player_MediaChange( sender As Object, e As _WMPOCXEvents_MediaChangeEvent ) Handles player.MediaChange [C#] private void player_MediaChange( object sender, _WMPOCXEvents_MediaChangeEvent e )
Event Data
The handler associated with this event is of type AxWMPLib._WMPOCXEvents_MediaChangeEventHandler. This handler receives an argument of type AxWMPLib._WMPOCXEvents_MediaChangeEvent, which contains the following property related to this event.
Property | Description |
Item | System.Object
The media item that changed. You can cast this to an IWMPMedia interface to access it. |
Example Code
The following example uses a label to display the name of the current media item. The code updates the text in the label with each occurrence of the MediaChange Event. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
[Visual Basic]
Public Sub player_MediaChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_MediaChangeEvent) Handles player.MediaChange ' Get an interface to the changed media item that is returned in the event data. Dim changedItem As WMPLib.IWMPMedia3 = e.item ' Display the name of the changed media item. mediaName.Text = changedItem.name End Sub
FakePre-d53470566ddd4819b1e607339312c631-c2671eb657ea468995e174d71cc74527
// Add a delegate for the MediaChange event. player.MediaChange += new AxWMPLib._WMPOCXEvents_MediaChangeEventHandler(player_MediaChange); private void player_MediaChange(object sender, AxWMPLib._WMPOCXEvents_MediaChangeEvent e) { // Get an interface to the changed media item that is returned in the event data. WMPLib.IWMPMedia3 changedItem = (WMPLib.IWMPMedia3)e.item; // Display the name of the changed media item. mediaName.Text = changedItem.name; }
Requirements
Version: Windows Media Player 9 Series or later
Namespace: AxWMPLib
Assembly: AxInterop.WMPLib.dll (automatically generated by Visual Studio)
See Also
Previous | Next |