So I'm trying to use a soundplayer to load a wav file, and then fire an event after it's done loading it. Reason being is that I don't want my program to continue on until the WAV is fully loaded and ready to go (if there's another way to do this, let me know).
But unfortunately the LoadCompleted event is never firing!
Here's the last of what I tried. What am I doing wrong?
this.audio = new SoundPlayer();
audio.SoundLocation = "songs\\" + songname + ".wav";
audio.LoadAsync();
that belongs to the songdata object. Then I have this is the main class main method:
this.songdata.audio.LoadCompleted += new AsyncCompletedEventHandler(audio_LoadCompleted);
this.songdata.audio.Play();
lastly inside the main class:
void audio_LoadCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("aaa");
}
The file starts playing, but the message box never appears. BTW I'm using Visual Studio 2010 and .NET 4.0.