Share via


Windows Media Player 11 SDK IWMPNetwork.bufferingProgress (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPNetwork.bufferingProgress (VB and C#)

The bufferingProgress property gets the percentage of buffering completed.

  

Property Value

A System.Int32 that is the buffering progress expressed as a percentage.

Remarks

Each time playback is stopped and restarted, this property is reset to zero. It is not reset if playback is paused.

Buffering applies only to streaming content. This property gets valid information only during run time when the URL for playback is set using the AxWindowsMediaPlayer.URL property.

Use the AxWindowsMediaPlayer._WMPOCXEvents_BufferingEvent to determine when buffering starts or stops.

Example Code

The following example uses bufferingProgress to display the percentage of buffering completed in a label, in response to the Buffering Event. The example uses a timer with a 1-second interval to update the display. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

  
' Create an event handler for the Buffering event.
Public Sub player_Buffering(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_BufferingEvent) Handles player.Buffering

    ' Test whether packets may be arriving.
    Select Case e.newState

    ' If WMPPlayState is Stopped, Paused, ScanForward, ScanReverse, Waiting, MediaEnded
    ' or Transitioning then stop the timer. 
        Case 1
        Case 2
        Case 4
        Case 5
        Case 7
        Case 8
        Case 9
            timer.Stop()

        ' If WMPPlayState is Playing or Buffering then set the timer interval and start the timer.
        Case Else
            timer.Interval = 1000
            timer.Start()

    End Select

End Sub

' Update the buffering progress in a timer event handler.
Public Sub UpdateBufferingProgress(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick

    bufferingProgressLabel.Text = ("Buffering progress: " + player.network.bufferingProgress + " percent complete")

End Sub

FakePre-60af78ca775d4c749abf2c1026b52417-6cb28c3f047942a6aa04d4c59be20920

// Add a delegate for the Buffering event.
player.Buffering += new AxWMPLib._WMPOCXEvents_BufferingEventHandler(player_Buffering);

// Create an event handler for the Buffering event.
private void player_Buffering(object sender, AxWMPLib._WMPOCXEvents_BufferingEvent e)
{
    // Determine whether buffering has started or stopped.
    if (e.start == true)
    {
        // Set the timer interval at one second (1000 miliseconds).
        timer.Interval = 1000;
        
        // Start the timer.
        timer.Start();
    }
    else
    {
        // Buffering is complete. Stop the timer.
        timer.Stop();
    }
}

// Update the buffering progress in a timer event handler.
private void UpdateBufferingProgress(object sender, EventArgs e)
{
    bufferingProgressLabel.Text = ("Buffering progress: " + player.network.bufferingProgress + " percent complete");
}

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)

See Also

Previous Next