views:

54

answers:

0

Hello,

I have a MediaElement that displays a simple progress bar when buffering. It gets displayed or hidden on the BufferingProgressChanged event. For the code, see below.

The problem is that quite often the MediaElement decides to buffer twice, causing the progress bar to show up twice. Why is this and is there a way to fix this?

Thanks!

private void MediaElement_BufferingProgressChanged(object sender, RoutedEventArgs e)
{
    if (MediaElement.CurrentState == MediaElementState.Buffering)
    {
        BufferProgressBar.Value = MediaElement.BufferingProgress;
        BufferGrid.Visibility = System.Windows.Visibility.Visible;
    }
    else
    {
        BufferGrid.Visibility = System.Windows.Visibility.Collapsed;
    }
}