Share via


Windows Media Player 11 SDK IWMPError.Item (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPError.Item (VB and C#)

The Item property (the get_Item method in C#) gets an IWMPErrorItem interface at the specified index in the error queue.

[Visual Basic]
ReadOnly Property Item(
  dwIndex As Integer
) As IWMPErrorItem

[C#]
IWMPErrorItem get_Item (
  int dwIndex
);

Parameters

dwIndex

A System.Int32 that is the zero-based index of an IWMPErrorItem interface in the error queue.

Property Value

A WMPLib.IWMPErrorItem interface.

Remarks

Windows Media Player can generate a number of errors in response to an error condition. This property gets a specific error in the queue by using an index number. The index numbers for the error queue begin with zero.

You should set IWMPSettings.enableErrorDialogs to false if you choose to display custom error messages.

Example Code

The following example uses the Item property (the get_Item method in C#) in an Error event handler to retrieve and display information about the most recent error in the error queue. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

[Visual Basic]
Public Sub player_ErrorEvent_get_Item(ByVal sender As Object, ByVal e As System.EventArgs) Handles player.ErrorEvent

    ' Store the index of the most recent error.
    Dim max As Integer = (player.Error.errorCount - 1)

    ' Get an interface for the most recent error item. 
    Dim errItem As WMPLib.IWMPErrorItem2 = player.Error.Item(max)

    ' Use the interface to access and store the error info.
    Dim errNum As Integer = errItem.errorCode
    Dim errDesc As String = errItem.errorDescription

    ' Display the error info.
    System.Windows.Forms.MessageBox.Show(errNum.ToString() + ":  " + errDesc)

End Sub

FakePre-162ec62c85df4019bd36abdeeaa988e2-eb5dfb63f57e4058aca87bde6898d4d4

private void player_ErrorEvent_get_Item(object sender, System.EventArgs e)
{
    // Store the index of the most recent error.
    int max = (player.Error.errorCount - 1);

    // Get an interface for the most recent error item. Cast it to
    // a WMPLib.IWMPErrorItem2 interface to get all of the available functionality.
    WMPLib.IWMPErrorItem2 errItem = (WMPLib.IWMPErrorItem2)player.Error.get_Item(max);

    // Use the interface to access and store the error info.
    int errNum = errItem.errorCode;
    string errDesc = errItem.errorDescription;

    // Display the error info.
    System.Windows.Forms.MessageBox.Show(errNum.ToString() + ":  " + errDesc);
}

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

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

See Also

Previous Next