locked
help with windows media player object model in .Net RRS feed

  • Question

  • Ok everyone im trying to develop an application using c# & windows media player. Until last night everything was good. I am using windows media player 11. I don't know if it matters much but im using Vista x64. Pretty much i put a windows media player control on my form and have a list of music files that i want to be played to the user of my application. Eventhough the control is on the form, it is invisible to the user. Everything goes great for first song. It plays perfect and everything works but then when it goes to the second song everything falls apart.

    I am using the PlayStateChange even to know when to switch a song. At first i was using the following code:
                /*switch (e.newState)
                {
                    case 8:*/
                /* player is at the end of the mp3 file (media at end state) */
                //int i = 0;
                /*   currRow++;
                   PlayFile(currRow);
                   break;
           }

    This didn't work so i tried some other states to get things working. I also tried to substitue 1 (stopped) and 10 (ready) with no luck. It does get to the following code:
    //Code in PlayFile()
    wmp.URL = MyMP3FileLocation;
    wmp.Ctlcontrols.play();

    I even tried the following before the last code to see if it would help
    wmp.close()
    wmp.Ctlcontrols.stop()

    and it did nto help.

    Ive made the control visible on my form and it looks like its loading the file just fine into the control but it will not play it. I can manually click the play button on the control after it stops functioning and the 2nd file will play.

    Does anyone know what is going on? What do i need to do to get this to work. It seems like what im trying to do should be simple. I was up to 3am last night trying to figure this out.

    Any help would be GREATLY appreciated.

    thanks,
    Brent
    Tuesday, August 14, 2007 1:46 PM

Answers

All replies