1

I need to know when a music file has stopped playing to play the next song in a playlist string array I made.

I use the WMPLib and here is my code to get the song playing:

https://gyazo.com/993d8ea2dff20316f6c98ff88ab57394 + under a button event I usePlayFile(@playlist[0]);`

Also I realised I have a memory leak so if someone just happened to also know the code for fixing that for every song that would be cool.

1 Answers1

1

One solution would be to give Windows Media Player the whole playlist at once, so you don't have to worry about that. Refer to How to add multiple files to a playlist. On the other hand, you already subscribed to the PlayStateChange event. https://msdn.microsoft.com/en-us/library/windows/desktop/dd562460%28v=vs.85%29.aspx describes all the possible states, and I'm sure on of these PlayStateChanges is the right one for you. Maybe MediaEnded?

Maximilian Gerhardt
  • 5,188
  • 3
  • 28
  • 61
  • Thanks for the help, What I did was under the `Player_PlayStateChange` I tryed if the instance was 8 (the MediaEnded) it would do its work, thanks again! and please rate my post up so im not at -1 :) – Richard Romanchik Sep 08 '15 at 00:46