This project has moved. For the latest updates, please go here.

Working with elapsed time

Feb 23, 2011 at 6:48 PM

Hi,

I'm trying to incorporate NAudio into an existing app and I have a couple of questions:

  1. If I've opened an audio file, begun playing it, then paused, is there a way I can get the current playback "position" in terms of milliseconds from the beginning of the file?  I've looked at something named "position" in the samples, but that seems to be something like a stream position expressed in bytes.
  2. If I've paused playback, is there a way for me to "seek" to a certain time in the audio (again specified in milliseconds) so that subsequent playback will start from that point?

Thanks very much!

 

 

Feb 28, 2011 at 11:16 AM

Hi!

1. I believe that there is a function called .CurrentTime which returns a TimeSpan variable. I think you can use it to get the current time.

2. Im not too sure but maybe you can make calculations based on the time you want to seek and convert it into Position? I think there is an example in NAudioDemo where you can seek where to play the file.

Goodluck! Also, may I ask how you are playing the file? Do you know of any other way to play a file rather than using the IWavePlayer? Im having trouble because I need to play a file while controlling the # of bytes that are read each time.

Thanks!