Share via


PlaylistCollection.getByName 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 getByName method retrieves a PlaylistArray object containing playlists with the specified name, if any exist.

Syntax

retVal = PlaylistCollection.getByName(
  name
)

Parameters

name [in]

String containing the name of the playlists to be retrieved.

Return value

This method returns a PlaylistArray object.

Remarks

Use PlaylistArray.count to determine whether a playlist exists. If count is zero, a playlist does not exist.

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

Examples

The following JScript example uses playlistCollection.getByName to check the playlistCollection object for a playlist named "ThreeList". If the "Threelist" playlist exists, getByName sets "ThreeList" as the current playlist. The Player object was created with the ID = "Player".

//Retrieve the count of the playlists named "ThreeList".
var Checkit = Player.playlistCollection.getByName("ThreeList").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 playlistArray object containing "ThreeList". Assume that
   //there is only one playlist with that name, and assign it to the 
   //current playlist.
   Player.currentPlaylist = Player.playlistCollection.getByName("ThreeList").item(0);
}

Requirements

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

See also

PlaylistArray Object

PlaylistArray.count

PlaylistCollection Object

Settings.mediaAccessRights

Settings.requestMediaAccessRights