MediaCollection.getAll method

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

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

See also

MediaCollection Object

Playlist Object

Settings.mediaAccessRights

Settings.requestMediaAccessRights