Share via


Windows Media Player 11 SDK IWMPMedia.isMemberOf (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPMedia.isMemberOf (VB and C#)

The isMemberOf method returns a value indicating whether the specified media item is a member of the specified playlist.

[Visual Basic]
Function isMemberOf(
  pPlaylist As IWMPPlaylist
) As Boolean

[C#]
bool isMemberOf (
  IWMPPlaylist pPlaylist
);

Parameters

pPlaylist

A WMPLib.IWMPPlaylist interface.

Return Value

A System.Boolean value that indicates whether the media item is a member of the playlist.

Remarks

This method cannot check playlists retrieved through the IWMPMediaCollection interface. To test whether a media item is a member of a particular named playlist, retrieve the playlist collection with the AxWindowsMediaPlayer.playlistCollection property. Once you retrieve the collection, retrieve the individual playlist by calling the IWMPPlaylistCollection.getByName method.

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

Example Code

The following example uses isMemberOf to test whether the current media item is a member of the playlist named All Music. If it is not, the current media item is appended to the playlist. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

[Visual Basic]
' Get an interface to the playlist named All Music.
Dim sPlaylist As WMPLib.IWMPPlaylist = player.playlistCollection.getByName("All Music").Item(0)

' Test whether the current media item is a member of the All Music playlist.
' If it is not a member, then append the current media item to the playlist.
If (player.currentMedia.isMemberOf(sPlaylist) = False) Then

    sPlaylist.appendItem(player.currentMedia)

End If

FakePre-0b4854d7133d4eeba61f6e3c34c86adc-62e0aa1572ef49cd9ab04fe0268ff0bb

// Get an interface to the playlist named All Music.
WMPLib.IWMPPlaylist sPlaylist = player.playlistCollection.getByName("All Music").Item(0);

// Test whether the current media item is a member of the All Music playlist.
// If it is not a member, append the current media item to the playlist.
if (player.currentMedia.isMemberOf(sPlaylist) == false)
{
    sPlaylist.appendItem(player.currentMedia);
}

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

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

See Also

Previous Next