Hi everyone, i have some question regarding my project.. I am currently work on a MP3 player project.. And i came out with a problem..

Here is my code

private void mediaPlayer_PlayStateChange_1(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    if (e.newState == 3)
    {

        double dur = mediaPlayer.currentMedia.duration;

        currentSongProgress.Maximum = (int)dur;

    }
    if (e.newState == (int)WMPPlayState.wmppsPlaying)
    {
        StatusText.Text = "[Playing]";
        timer2.Start();
        btnPlay1.Enabled = false;
        currentSong.Text = mediaPlayer.currentMedia.name;
    }

    else if (e.newState == (int)WMPPlayState.wmppsPaused)
    {
        if (!finished)
        {
            StatusText.Text = "[Paused]";
            timer2.Stop();
            btnPlay1.Enabled = true;
            currentSong.Text = mediaPlayer.currentMedia.name;
        }
    }

    else if (e.newState == (int)WMPPlayState.wmppsStopped)
    {
        StatusText.Text = "[Ended]";
        timer2.Stop();
        btnPlay1.Enabled = true;
        currentSong.Text = mediaPlayer.currentMedia.name;
    }

    else if (e.newState == (int)WMPPlayState.wmppsMediaEnded)
    {
        StatusText.Text = "[Ended]";
        finished = true;
        timer2.Stop();
        btnPlay1.Enabled = true;
        currentSong.Text = mediaPlayer.currentMedia.name;
        playlist2.SelectedNode = playlist2.SelectedNode.NextNode;
        mediaPlayer.Ctlcontrols.play();
        timer2.Start();
    }

}

this code should change my treeview node and play the next song when the current song ended..

else if (e.newState == (int)WMPPlayState.wmppsMediaEnded)
{
    StatusText.Text = "[Ended]";
    finished = true;
    timer2.Stop();
    btnPlay1.Enabled = true;
    currentSong.Text = mediaPlayer.currentMedia.name;
    playlist2.SelectedNode = playlist2.SelectedNode.NextNode;
    mediaPlayer.Ctlcontrols.play();
    timer2.Start();
}

But somehow, that code doesn't help me in automatically change song at all.. Anyone can help? Oh.. Anyway, i am using treeview toolbars as my playlist.. :) :Cheer

I never use windows media player active x controls, so im not 100% certain.

course if you are starting the next song, why do you enable the play button?

What is the PlayList2 ? does changing its node set the mediaplayer currentmedia?
if not, then you need to set the current media of the mediaplayer to the nodes's value.

For any further assistance we need more code. I can't see the whole picture here.

Have you tried inserting break points? Does the code get run at all? As with DiamondDrake, we need more information about what your playlist and playlist2 are and how they interact and why.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.