BufferingProgress - Buffer Status

Mar 29, 2011 at 6:22 PM

Hi all,

I'm  trying to implement a "Buffer Status" ( 10%, 15%,17%...) and I'm using a BufferingProgressChanged.

namespace PlayerProject
    public class MyPlayer : SMFPlayer

    Double bufferPercent;

    public Double BufferPercent
        get { return bufferPercent; }
        set { bufferPercent = value; }

    public override void OnApplyTemplate()
            this.BufferingProgressChanged += new EventHandler<CustomEventArgs<double>>(MyPlayer_BufferingProgressChanged);

    void MyPlayer_BufferingProgressChanged(object sender, CustomEventArgs<double> e)

        this.BufferPercent = BufferingProgress * 100;
And I'm bindind the bufferPercent to an TextBox...
<TextBox HorizontalAlignment="Right" Height="36" Margin="0,0,8,49" TextWrapping="Wrap" Text="{Binding BufferPercent, ElementName=smfPlayer, Mode=TwoWay}" VerticalAlignment="Bottom" Width="105" IsReadOnly="True"/>

But the TextBox element don't show the progress...

Anyone can help me?


Mar 29, 2011 at 7:44 PM

marciogmunhoz, you need to create a dependency property in order for the TextBox to know about the change to the value.

An alternative would be to bind directly to the BufferingProgress property and create an IValueConverter to multiply the value by 100 before displaying it.

And one last thing: You should set Mode=OneWay on your binding since you want data to only flow from SMFPlayer to the textbox.

Hope that helps,

Tim Greenfield

Mar 30, 2011 at 11:17 AM

Thanks timgreenfield!...
I decided to use the BufferingProgress, and set the Text of the BufferingElement SMFPLAYER, but it does not update the element. I am binding the BufferingProgress.

<TextBlock x:Name="BufferingElement" Foreground="White" HorizontalAlignment="Center" Grid.Row="0" VerticalAlignment="Center" Visibility="Collapsed" Text="{Binding BufferingProgress}" IsHitTestVisible="False">

I forgot something?


Mar 30, 2011 at 4:10 PM

marciogmunhoz, you still need to tell it the source of the binding... {Binding BufferingProgress, ElementName=smfPlayer}. Also I'm sure you know this but for the sake of thoroughness: make sure Visibility is not collapsed and your foreground color stands out against the background so you can see it.

Mar 30, 2011 at 4:23 PM

Ohh!!! Thank you so much timgreenfield... it works.. {Binding BufferingProgress, ElementName=smfPlayer}