Share via


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

Windows Media Player SDK banner art

Previous Next

IWMPNetwork.bandWidth (VB and C#)

The bandWidth property gets the current bandwidth of the media item.

  

Property Value

A System.Int32 that is the bandwidth.

Remarks

The value retrieved through AxWindowsMediaPlayer.URL will be zero if the URL is not set. This property is valid only for streaming media.

Example Code

The following example uses bandWidth to display the current media bandwidth. The information is displayed in a label in response to the PlayStateChange Event.  The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

  
' Create an event handler for the PlayStateChange event.
Public Sub player_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles player.PlayStateChange

    ' Display the bandWidth when the player is playing. 
    Select Case e.newState

        Case 3 ' Play State = WMPLib.WMPPlayState.wmppsPlaying = 3

            If (player.network.bandWidth <> 0) Then

                bandWidthLabel.Text = "Current Bandwidth: " + player.network.bandWidth + " K bits/second"

            Else

                bandWidthLabel.Text = "Bandwidth is only available for streaming media."

            End If

    End Select

End Sub

FakePre-adb268e8c4db4b7ba84464fddfbf48e0-249f75877bc249d8954557aea91654ab

// Add a delegate for the PlayStateChange event.
player.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(player_PlayStateChange);

// Create an event handler for the PlayStateChange event.
private void player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    // Display the bandwidth when the player is playing. 
    switch (e.newState)
    {
        case 3:  // Play State = WMPLib.WMPPlayState.wmppsPlaying = 3
            if (player.network.bandWidth != 0)
            {
                bandWidthLabel.Text = "Current Bandwidth: " + player.network.bandWidth + " K bits/second";
            }
            else
            {
                bandWidthLabel.Text = "Bandwidth is only available for streaming media.";
            }
            break;

        default:
            break;
    }
}

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

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

See Also

Previous Next