NAudio - seeking and navigation to play from the specified position

You can set Position directly on a WaveStream, which must be converted into a byte offset - so yes, multiplying the average bytes per second by the number of seconds will get you to the right place (at least with regular PCM WAV files). WaveStream also has a helper property called CurrentTime allowing you to use a TimeSpan and it does the same calculation for you.


If someone still has this problem and can not figure it out. Then here is an example:

myWaveStream.CurrentTime = myWaveStream.CurrentTime.Add(new TimeSpan(0, hours, minutes, seconds, milliseconds));

myWaveStream.CurrentTime = myWaveStream.CurrentTime.Subtract(new TimeSpan(0, hours, minutes, seconds, milliseconds));

Tags:

C#

Audio

Naudio