I am working in a small audio player. You know, with the simplest stuff and functions.
I am having an issue when changing the trackbar's value (scrolling), this trackbar displays the current audio position.
When I drag the trackbar's slider, audio position should change. I am using the CSCore Audio Library. This is the code I use to update the current position of the audio playing:
private void ProgressTimerTick(object sender, EventArgs e)
{
SongProgressTrackbar.MaxValue = (int)audioPlayer.Length.TotalMilliseconds;
SongProgress.Value = (int)audioPlayer.Position.TotalMilliseconds;
}
This works perfectly with no issues.
But this...
private void SongProgressTrackbar_Scroll(object sender, ScrollEventArgs e)
{
Timespan newPos = new Timespan(SongProgressTrackbar.Value);
audioPlayer.Position = newPos;
}
What happens here, is that the audio goes to the start again when the event is fired, insteqd of changing the position to where I click in the trackbar, it begins again.
So, what did I write wrong? I tried using the ValueChanged Event, but that just gets the audio stay in 0:00 position. As I said, the TimerTick does work. But whenever I scroll the trackbar, the audio starts again from the beginning.
Hope someone can help me solve this issue. Thanks in Advance - CCB