I am writing a simple windows media player program with Visual Studio C# windows form. In the form I add a wmp component and a listbox. The listbox shows a list of songs. When user double clicks on a song in the listbox, the wmp plays the song without any problem. But when a song ends, the listbox selected item moves to the next song and the listbox double click function is called as well, but the wmp doesn't play the next song. How to fix the problem?
private void ListBoxDblClick(object sender, EventArgs e)
{
Player.URL = ListBoxDblClick.SelectedItem.ToString();
Player.Ctlcontrols.play();
}
private void Player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (e.newState == 8)
{
if (ListBoxDblClick.SelectedIndex < ListBoxDblClick.Items.Count - 1)
{
ListBoxDblClick.SelectedIndex = ListBoxDblClick.SelectedIndex + 1;
}
else
if (ListBoxDblClick.SelectedIndex == ListBoxDblClick.Items.Count - 1)
{
ListBoxDblClick.SelectedIndex = 0;
}
ListBoxDblClick(sender, new EventArgs());
}
}