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


MediaCollection.getAll 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 getAll method retrieves a playlist containing all media items in the library.

Syntax

retVal = MediaCollection.getAll()

Parameters

This method has no parameters.

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.getAll to play media items randomly from the media collection. The Player object was created with ID = "Player".

// Store the count of all media items in the media collection.
var count = Player.mediaCollection.getAll().count;

// Generate a random number using the media count.
var rand = Math.random() * count;

// Round down the random number to the nearest integer.
rand = Math.floor(rand);

// Make the random media item the current media item.
Player.currentMedia = Player.mediaCollection.getAll().item(rand);

// Play the media item.
// Player.controls.play();

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