Richard Romanchik
Richard Romanchik

Reputation: 49

c# Detecting when a music file has stopped playing in the WMPLib

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.

Upvotes: 1

Views: 878

Answers (1)

Maximilian Gerhardt
Maximilian Gerhardt

Reputation: 5353

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?

Upvotes: 1

Related Questions