AxWindowsMediaPlayer オブジェクトの CurrentPlaylistChange イベント
[このページWindows メディア プレーヤー SDK に関連付けられている機能は、レガシ機能です。 MediaPlayer に置き換わりました。 MediaPlayer は、Windows 10とWindows 11用に最適化されています。 新しいコードでは、可能な場合は SDK ではなく MediaPlayerWindows メディア プレーヤー使用することを強くお勧めします。 Microsoft は、従来の API を使用する既存のコードを、可能であれば新しい API を使用するように書き直すよう提案しています。]
CurrentPlaylistChange イベントは、現在のプレイリスト内で何かが変更されたときに発生します。
[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
イベント データ
このイベントに関連付けられているハンドラーは 、AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEventHandler型です。 このハンドラーは、このイベントに関連する次のプロパティを含む 、AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEvent型の引数を受け取ります。
プロパティ | Description |
---|---|
change (変更) | プレイリストに対して発生した変更の種類を示す WMPLib.WMPPlaylistChangeEventTypeAn 列挙値。 |
解説
このイベントは、別のプレイリストが現在のプレイリストになったときには発生しません。 これは、現在のプレイリスト内で変更が発生した場合 (プレイリストに追加されるメディアアイテムなど) にのみ発生します。
例
次の例では、CurrentPlaylistChange イベントに応答して、現在のプレイリスト内のすべてのメディア項目の名前を表示します。 AxWMPLib.AxWindowsMediaPlayer オブジェクトは、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
必要条件
要件 | 値 |
---|---|
Version |
Windows メディア プレーヤー 9 シリーズ以降 |
名前空間 |
AxWMPLib |
アセンブリ |
|
関連項目
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示