Partager via


IWMPMedia::isMemberOf 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 isMemberOf method returns a value indicating whether the specified media item is a member of the specified playlist.

Syntax

public System.Boolean isMemberOf(
  IWMPPlaylist pPlaylist
);

Public Function isMemberOf( _
  ByVal pPlaylist As IWMPPlaylist _
) As System.Boolean
Implements IWMPMedia.isMemberOf

Parameters

pPlaylist [in]

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.

Examples

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.

// 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);
}

' 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

Requirements

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

See also

AxWindowsMediaPlayer.playlistCollection (VB and C#)

IWMPMedia Interface (VB and C#)

IWMPPlaylist Interface (VB and C#)

IWMPPlaylistCollection.getByName (VB and C#)