Question

i want to play automatically next song in my player. I have use windows media player object.
this is my code.

 private void timer2_Tick(object sender, EventArgs e)
    {
        if (songList.SelectedIndex < files.Length - 1)
        {
            songList.SelectedIndex++;
            timer2.Enabled = false;
        }
        else
        {
            songList.SelectedIndex = 0;
            timer2.Enabled = false;
        }            

    }

    private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
    {
        if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
        {
            timer2.Interval = 100;
            timer2.Enabled = true;
        }

    }

but it's not working i have chacked timer code it is working but i think axWindowsMediaPlayer1_PlayStateChange event not working and in the designer code when i wrote this line for axWindowsMediaPlayer

 this.axWindowsMediaPlayer1.PlayStateChange += new System.EventHandler(this.axWindowsMediaPlayer1_PlayStateChange);  

it shows this error:

No overload for axWindowsMediaPlayer1_PlayStateChange matches delegate System.EventHandler

is there any solution?

Was it helpful?

Solution

Take a look at the documentation for PlayStateChange. It gives you a clear example.

Rather than using what you have, simply use this event assignment instead:

axWindowsMediaPlayer1.PlayStateChange +=
      new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(axWindowsMediaPlayer1_PlayStateChange);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top