CurrentPlaylistChange 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 CurrentPlaylistChange event occurs when something changes within the current playlist.
[C#]
private void player_CurrentPlaylistChange(
object sender,
_WMPOCXEvents_CurrentPlaylistChangeEvent e
)
[Visual Basic]
Private Sub player_CurrentPlaylistChange(
sender As Object,
e As _WMPOCXEvents_CurrentPlaylistChangeEvent
) Handles player.CurrentPlaylistChange
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.WMPPlaylistChangeEventTypeAn 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.
Examples
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.
// 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;
}
}
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
Requirements
Requirement | Value |
---|---|
Version |
Windows Media Player 9 Series or later |
Namespace |
AxWMPLib |
Assembly |
|