Hi,
I'm writing a simple wav player (like winamp) and using the
SoundPlayer class in c# 2005.
Using winform buttons, I can begin playing the sound and stop half-way
through the sound using:
myPlayer.Play() and myPlayer.Stop() methods which works great, but i
want to know when the sound actually stops playing (so I can change my
button's picture). If I raise a custom event after the myPlayer.Play()
command, the event is raised immediately after the sound starts, NOT
when the sound finishes playing. This makes sense to me because it is
playing the sound 'asynchronously'. This method does work if I raise a
custom event after the myPlayer.PlaySync() instead of myPlayer.Sync(),
but the .PlaySync method waits until the entire sound finishes
playing, thus disables everything on the form and the user cannot
click the 'Stop' button to call the myPlayer.Stop() method.
I've had a go at putting this into a thread, but the main problem is
that the thread doesn't abort immediately; unlike the myPlayer.Stop()
which does. (I'm pretty sure the reason for this is that the thread
management is handled by the CLR (obviously!) and that it wil abort
the thread when it's ready i.e. NOT immediately)
How on earth can one do this?
Any ideas greatly appreciated.
Jack.