I'm writing a Windows Forms application which is supposed to play three sound files and at the end of each sound file, it's to change the source of an image.
I can get it to play the sounds using System.Media.SoundPlayer
. However, it seems to play the sound in a different thread, continuing on.
The net effect of this is that only the last sound is played and all the images are changed.
I've tried Thread.Sleep
, but it sleeps the whole GUI and after the sleep period everything happens at once and the last sound it played.
UPDATE
I thought PlaySynch was working, but it seems to freeze my GUI which is less than ideal. What else can I do?
Did you try SoundPlayer.PlaySync Method? From the help:
The PlaySync method uses the current thread to play a .wav file, preventing the thread from handling other messages until the load is complete.
Instead of using the Play method, use the PlaySync method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With