Search code examples
c#naudio

Trackview or timeline in Naudio


How can I use trackview or timeline in Naudio in C#?

Here is my code and it's not working.

I want to see my line going as track is playing.

 NAudio.Wave.WaveStream pcm = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(new NAudio.Wave.Mp3FileReader(open.FileName));
                customWaveViewer2.WaveStream = pcm;
                stream = new NAudio.Wave.BlockAlignReductionStream(pcm);
                trackView1.NowTime = stream.CurrentTime;

Solution

  • Unfortunately, TrackView and TimeLine are not completed controls, and you would be better off writing your own custom control to place a vertical line at a position that represents the now playing time.

    You would probably be best using a timer to invalidate your custom wave viewer, and in the Paint method, drawing a vertical line that represents the current play time.