Share via


Windows Media Player 11 SDK IWMPPlaylistCollection.getByName (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPPlaylistCollection.getByName (VB and C#)

The getByName method returns a IWMPPlaylistArray interface that provides access to playlists with the specified name, if any exist.

  

Parameters

bstrName

A System.String that is the name of the playlist.

Return Value

A WMPLib.IWMPPlaylistArray interface for the retrieved array of playlists.

Remarks

Use IWMPPlaylistArray.count to determine whether a playlist exists. If count is zero, the array is empty.

Remarks

Before calling this method, you must have read access to the library. For more information, see Library Access.

Example Code

The following example uses getByName to check the playlist collection for a playlist named "Favorites -- 4 and 5 star rated". If a playlist by that name exists, getByName sets it as the current playlist. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

  
'  Get the count of the playlists named "Favorites -- 4 and 5 star rated".
Dim checkit As Integer = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").count

'  Since duplicate playlist names are allowed, the count returned
'  will be either zero (no playlist) or greater than zero (playlist exists).
If (checkit > 0) Then

    '  Retrieve a playlist array object containing "Favorites -- 4 and 5 star rated".
    '  Assume that there is only one playlist with that name, and assign it to the 
    '  current playlist.
    player.currentPlaylist = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").Item(0)

End If

FakePre-e5b87dbb507247da97b7aa488e252a6b-07c49db4c5f947eea599d4c6b08e4551

// Get the count of the playlists named "Favorites -- 4 and 5 star rated".
int checkit = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").count;

// Since duplicate playlist names are allowed, the count returned
// will be either zero (no playlist) or greater than zero (playlist exists).
if (checkit > 0)
{
    // Retrieve a playlist array containing "Favorites -- 4 and 5 star rated".
    // Assume that there is only one playlist with that name, and assign it to the 
    // current playlist.
    player.currentPlaylist = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").Item(0);
}

Requirements

Version: Windows Media Player 9 Series or later.

Namespace: WMPLib

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

See Also

Previous Next