wpfslider

Make Media Player time line using Slider


I'm using a Slider for showing media time line. While media is playing I update sidebar value with these lines of code:

void SoundTime_Tick(object sender, EventArgs e)
{
    SliderBar.Value = GetCurrentTimePosation();
}

But with this SliderBar.ValueChanged event every time called and I can't change time line position with mouse: (when I change it it return to GetCurrentTimePosation() time)

void SeekToMediaPosition(object sender, RoutedPropertyChangedEventArgs<double> e)
{
    media.setpos((uint)e.NewValue);
}

Any idea?


Solution

  • I got the answer: according seek-bar-for-media-element-in-wpf, I must add two events to Slider:

    Thumb.DragStarted="sliderTime_DragStarted"
    Thumb.DragCompleted="sliderTime_DragCompleted"
    

    and while dragging disable my timer.

    Complete answer: seek-bar-for-media-element-in-wpf