IWMPNetwork::receptionQuality 属性

[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]

receptionQuality 属性获取过去 30 秒内未丢失的数据包百分比。

语法

public System.Int32 receptionQuality {get; set;}

Public ReadOnly Property receptionQuality As System.Int32

属性值

接收质量的 System.Int32

备注

每秒监视一次流式处理期间接收、丢失和恢复的数据包数。 receptionQuality 属性获取过去 30 秒内未丢失的数据包百分比。

每次停止并重启播放时,此属性将重置为零。 如果播放暂停,则不会重置值。

仅当使用 AxWindowsMediaPlayer.URL 属性设置播放 URL 时,此属性才会在运行时获取有效信息。

示例

以下示例使用 receiveQuality 显示标签中收到的数据包的百分比,以响应 PlayStateChange 事件。 该示例使用间隔为 1 秒的计时器来更新显示。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

// 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)
{
    // Test whether content is playing. 
    if (e.newState == 3)
    {
        // Start the timer. Update the display every 10 seconds.
        timer.Interval = 10000;
        timer.Start();
    }
    else
    {
        // Not playing; stop the timer.
        timer.Stop();
    }
}

private void UpdateReceptionQuality(object sender, EventArgs e)
{
    receptionQualityLabel.Text = ("Packets recovered: " + player.network.receptionQuality.ToString() + "%");
}

' 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

    ' 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

Public Sub UpdateReceptionQuality(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick

    receptionQualityLabel.Text = ("Packets recovered: " + player.network.receptionQuality.ToString() + "%")

End Sub

要求

要求
版本
Windows 媒体播放器 9 系列或更高版本
命名空间
WMPLib
程序集
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

另请参阅

AxWindowsMediaPlayer.URL (VB 和 C#)

IWMPNetwork 接口 (VB 和 C#)