Κοινή χρήση μέσω


Media.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 media item is a member of the specified playlist.

Syntax

bRetVal = Media.isMemberOf(
  playlist
)

Parameters

playlist [in]

Playlist object that might contain the media item.

Return value

This method returns a Boolean.

Remarks

This method is cannot check playlists retrieved through the MediaCollection object. To test whether a media item is a member of a particular named playlist, retrieve the playlist with player.playlistCollection.getByName(name).item(0). This method can also be used with CD playlists and metafile playlists.

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

Examples

The following JScript example uses Media.isMemberOf to test whether the current media item is a member of the playlist named Sample Playlist. If it is not, the current media item is appended to the sample playlist. The Player object was created with ID = "Player".

// Store the playlist object named Sample Playlist.
var sPlaylist = Player.playlistcollection.getbyname("Sample Playlist").item(0);

// Test whether the current media item is a member of Sample Playlist.
 var answer = ((Player.currentMedia.isMemberOf(sPlaylist))?"Yes":"No");

// If the current media item is not a member of Sample Playlist,
// append the current media item to the playlist.
if (answer == "No"){
   sPlaylist.appendItem(Player.currentMedia);
}

Requirements

Requirement Value
Version
Windows Media Player version 7.0 or later.
DLL
Wmp.dll

See also

Media Object

Playlist Object

PlaylistCollection Object

Settings.mediaAccessRights

Settings.requestMediaAccessRights