Windows Media Player 11 SDK AxWindowsMediaPlayer.CurrentPlaylistChange Event (VB and C#)
Previous | Next |
AxWindowsMediaPlayer.CurrentPlaylistChange Event (VB and C#)
The CurrentPlaylistChange event occurs when something changes within the current playlist.
[Visual Basic] Private Sub player_CurrentPlaylistChange( sender As Object, e As _WMPOCXEvents_CurrentPlaylistChangeEvent ) Handles player.CurrentPlaylistChange [C#]
Event Data
The handler associated with this event is of type AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEventHandler. This handler receives an argument of type AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEvent, which contains the following property related to this event.
Property | Description |
change | WMPLib.WMPPlaylistChangeEventType
An enumeration value indicating the type of change that occurred to the playlist. |
Remarks
This event does not occur when a different playlist becomes the current playlist. It occurs only when a change happens within the current playlist, such as a media item being appended to the playlist.
Example Code
The following example displays the names of all the media items in the current playlist in response to the CurrentPlaylistChange Event. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
[Visual Basic]
Public Sub player_CurrentPlaylistChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEvent) Handles player.CurrentPlaylistChange Select Case e.change ' Only update the list for the move, delete, insert, and append event types. Case WMPLib.WMPPlaylistChangeEventType.wmplcMove ' Value = 3 Case WMPLib.WMPPlaylistChangeEventType.wmplcDelete ' Value = 4 Case WMPLib.WMPPlaylistChangeEventType.wmplcInsert ' Value = 5 Case WMPLib.WMPPlaylistChangeEventType.wmplcAppend ' Value = 6 ' Create a string array large enough to hold all of the media item names. Dim count As Integer = player.currentPlaylist.count Dim mediaItems(count) As String ' Clear any previous contents of the text box. playlistItems.Clear() ' Loop through the playlist and store each media item name. For i As Integer = 0 To (count - 1) mediaItems(i) = player.currentPlaylist.Item(i).name Next i ' Display the media item names. playlistItems.Lines = mediaItems End Select End Sub
FakePre-77e24e1dc80e4b87b2c408b4a110a662-a4be8c464aa940d7891b60451b97d9e8
// Add a delegate for the CurrentPlaylistChange event. player.CurrentPlaylistChange += new AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEventHandler(player_CurrentPlaylistChange); private void player_CurrentPlaylistChange(object sender, AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEvent e) { switch(e.change) { // Only update the list for the move, delete, insert, and append event types. case WMPLib.WMPPlaylistChangeEventType.wmplcMove: // Value = 3 case WMPLib.WMPPlaylistChangeEventType.wmplcDelete: // Value = 4 case WMPLib.WMPPlaylistChangeEventType.wmplcInsert: // Value = 5 case WMPLib.WMPPlaylistChangeEventType.wmplcAppend: // Value = 6 // Create a string array large enough to hold all of the media item names. int count = player.currentPlaylist.count; string[] mediaItems = new string[count]; // Clear any previous contents of the text box. playlistItems.Clear(); // Loop through the playlist and store each media item name. for (int i = 0; i < count; i++) { mediaItems[i] = player.currentPlaylist.get_Item(i).name; } // Display the media item names. playlistItems.Lines = mediaItems; break; default: break; } }
Requirements
Version: Windows Media Player 9 Series or later
Namespace: AxWMPLib
Assembly: AxInterop.WMPLib.dll (automatically generated by Visual Studio)
See Also
- AxWindowsMediaPlayer Object (VB and C#)
- AxWindowsMediaPlayer.currentPlaylist (VB and C#)
- AxWindowsMediaPlayer.PlaylistChange Event (VB and C#)
- WMPPlaylistChangeEventType
Previous | Next |