Compartir a través de


MediaCollection.getAttributeStringCollection 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 getAttributeStringCollection method retrieves a StringCollection object representing the set of all values for a specified attribute within a specified media type.

Syntax

retVal = MediaCollection.getAttributeStringCollection(
  attribute,
  mediaType
)

Parameters

attribute [in]

String specifying the attribute.

mediaType [in]

String representing the media type. Contains one of the following values: "Audio", "Video", "Playlist", or "Other".

Return value

This method returns a StringCollection object.

Remarks

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

For information about the attributes supported by Windows Media Player, see the Attribute Reference section.

Examples

The following JScript example uses MediaCollection.getAttributeStringCollection to display a list of values that correspond to a particular attribute for audio items in the media collection. An HTML SELECT element, created with ID = "Attribute", allows the user to select an attribute, such as Artist, Genre, or Album. An HTML TEXTAREA element, created with ID = "AttributeVals", displays the result. The Player object was created with ID = "Player".

// Clear the text in the display area.
AttributeVals.value = "";

// Store the mediaCollection object.
var library = Player.mediaCollection;

// Get the string collection for the attribute type the user selects.
var all = library.getAttributeStringCollection(Attribute.value, "Audio");

// Loop through the string collection.
for (i = 0; i < all.count; i++){

    // Display the items one line at a time.
    AttributeVals.value += all.item(i);
    AttributeVals.value += "\n";
}

Requirements

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

See also

MediaCollection Object

Settings.mediaAccessRights

Settings.requestMediaAccessRights

StringCollection Object