MediaCollection.getByAttribute 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 getByAttribute method retrieves a playlist of media items that contain a specified value for a specified attribute.
Syntax
retVal = MediaCollection.getByAttribute(
attribute,
value
)
Parameters
-
attribute [in]
-
String indicating the name of the attribute to search. For information about the attributes supported by Windows Media Player, see the Windows Media Player Attribute Reference.
-
value [in]
-
String indicating the value that the attribute should have.
Return value
This method returns a Playlist object.
Remarks
This method can be used to create a generic query for media items that match a value for an attribute in the database. This is useful in the case of user-defined attributes. If the attribute does not exist, an error will result.
You can use this method to retrieve all of the media items of a specific type. Use the attribute name "MediaType" and one of the following values:
Value | Description |
---|---|
audio | Music and other audio-only items. |
playlist | Playlists represented as Media objects. |
radio | Radio station items. Not used by Windows Media Player 10. |
video | Video items. |
photo | Photo items. Requires Windows Media Player 10. |
other | Other items, such as ASF files or URLs to streaming media. |
To use this method, read access to the library is required. For more information, see Library Access.
Examples
The following JScript example uses MediaCollection.getByAttribute to play all content from the library by the artist named Triode 48. The Player object was created with ID = "Player".
// Get a playlist object filled with media items by a
// particular artist.
var pl = Player.mediaCollection.getByAttribute("Artist", "Triode 48");
// Make the new playlist the current one.
Player.currentPlaylist = pl;
// Start Windows Media Player.
Player.controls.play();
Requirements
Requirement | Value |
---|---|
Version |
Windows Media Player version 7.0 or later. |
DLL |
|