0

I'm programming a game and using NAudio with WaveOut. The sound is played when a collision occurs. The problem is the sound plays some times and after a few seconds if the collision happens again, the sound isn't played. I'm using this code.

WaveOut device = new WaveOut();
WaveStream source = new Mp3FileReader("hit.mp3");

device.Init(source);

And to play it,

source.Position = 0;
source.CurrentTime = TimeSpan.Zero;
device.Play();

Am I forgetting anything?

Thanks.

Sri Harsha Chilakapati
  • 11,744
  • 6
  • 50
  • 91

1 Answers1

0

Try take a look at this instruction, by Mark Heath, on how to use NAudio for "fire and forget" audio playback:

http://mark-dot-net.blogspot.co.uk/2014/02/fire-and-forget-audio-playback-with.html

rdongart
  • 390
  • 3
  • 10