IWMPCdromCollection::Item method

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The Item method returns an IWMPCdrom interface at the given index.

Syntax

public IWMPCdrom Item(
  System.Int32 lIndex
);

Public Function Item( _
  ByVal lIndex As System.Int32 _
) As IWMPCdrom
Implements IWMPCdromCollection.Item

Parameters

lIndex [in]

A System.Int32 that is the index.

Return value

A WMPLib.IWMPCdrom interface.

Remarks

To use this method, read access to the library is required. For more information, see Library Access.

Examples

The following example uses Item to display the drive specifier and playlist name from each CD available on the computer in a list box. If the drive actually contains DVD content, Windows XP or later is required. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

// Store the number of available drives.
int numDrives = player.cdromCollection.count;

// Loop through the available drives.
for (int i = 0; i < numDrives; i++)
{
    // Store the drive specifier and playlist name for this drive in a string.
    string pl = player.cdromCollection.Item(i).driveSpecifier + " ";
    pl += player.cdromCollection.Item(i).Playlist.name;

    // Add the string to a list box.
    myPlaylists.Items.Add(pl);
}

' Store the number of available drives.
Dim numDrives As Integer = player.cdromCollection.count

&#39; Loop through the available drives.
For i As Integer = 0 To (numDrives - 1)

    &#39; Store the drive specifier and playlist name for this drive in a string.
    Dim pl As String = player.cdromCollection.Item(i).driveSpecifier + &quot; &quot;
    pl += player.cdromCollection.Item(i).Playlist.name

    &#39; Add the string to a list box.
    myPlaylists.Items.Add(pl)

Next i

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
WMPLib
Assembly
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

See also

IWMPCdrom Interface (VB and C#)

IWMPCdromCollection Interface (VB and C#)

IWMPCdromCollection.count (VB and C#)

IWMPCdromCollection.getByDriveSpecifier (VB and C#)

IWMPPlaylist.name (VB and C#)

IWMPSettings2.mediaAccessRights (VB and C#)

IWMPSettings2.requestMediaAccessRights (VB and C#)