I'm looking to use Naudio for a game I'm making.
I've coded a simple initialisation routine, which currently has:
IWavePlayer wavePlayer1; AudioFileReader file1; string filename1 = "D:\\Programming\\SFX\\MUSIC\\IN_GAME_1.wav"; wavePlayer1 = new WaveOut(); file1 = new AudioFileReader(filename1); wavePlayer1.Init(file1); Thread thread1 = new Thread(new ThreadStart(wavePlayer1.Play)); thread1.Start();
When I run the game, the wav file plays for maybe half a second, then it stops, and a second later it resumes.
If I place System.Threading.Thread.Sleep(5000) immediately after starting the thread, the delay has an additional 5 seconds. This seems to prove that 'thread1.Start();' isn't actually starting the sound in it's own thread at all.
Being a bit of a threading and Naudio noob can anyone tell me what I'm doing wrong here? My requirement for the game is to simply have the ability to play several sounds at once. Nothing major.
Thanks in advance!