NAudio - seeking and navigation to play from the specified position
audio, c#, naudio
Solution
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.
`audioFile.Position += audioFile.WaveFormat.AverageBytesPerSecond * 15;`
Problem
I'm using NAudio library in a C# application. I'm trying to seek an audio (*.mp3 file) to the position I want. However I didn't figure out how to do it. ``` //Play the file starting from 16th second waveStream.Seek(16, SeekOrigin.Begin); ``` And ... It played starting almost from the beginning, but not from the 16th second. I also found a solution I thought true: ``` waveStream.Seek(waveStream.WaveFormat.AverageBytesPerSecond * 16, SeekOrigin.Begin); ``` It seems it's closer the truth. Is my resolving true or not? If not what should I do?