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


MediaCollection.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 playlist of the media items with the specified name.

Syntax

retVal = MediaCollection.getByName(
  name
)

Parameters

name [in]

String containing the name.

Return value

This method returns a Playlist object.

Remarks

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

Examples

The following JScript example uses MediaCollection.getByName to retrieve three items from the library. Each item is then appended to the current playlist. The Player object was created with ID="Player".

// In each case, use the name exactly as it appears in the library.
// Windows Media Player does not include file name extensions or file paths
// in the name. Internet URLs include the entire path, but not the 
// file name extension.

// Get a playlist object that contains an Internet URL.
var One = Player.mediaCollection.getByName("https://www.proseware.com/Media/Laure");
 
// Get a playlist object that contains a file on a network server.
var Two = Player.mediaCollection.getByName("Jeanne");

// Get a playlist object that contains a file on a local drive.
var Three = Player.mediaCollection.getByName("house");

// Append each item to the current playlist. Since each playlist retrieved
// using getByName contains one digital media item, use Playlist.item with
// an index of zero to reference that item.
Player.currentPlaylist.appendItem(One.item(0));
Player.currentPlaylist.appendItem(Two.item(0));
Player.currentPlaylist.appendItem(Three.item(0));

Requirements

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

See also

MediaCollection Object

Playlist Object

Settings.mediaAccessRights

Settings.requestMediaAccessRights