IWMPMediaCollection::getByAttribute method (wmp.h)
[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 pointer to an IWMPPlaylist interface. This interface corresponds to the specified attribute having the specified value.
Syntax
HRESULT getByAttribute(
[in] BSTR bstrAttribute,
[in] BSTR bstrValue,
[out] IWMPPlaylist **ppMediaItems
);
Parameters
[in] bstrAttribute
String containing the specified attribute.
[in] bstrValue
String containing the specified value.
[out] ppMediaItems
Pointer to a pointer to an IWMPPlaylist interface for the retrieved media items.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
Return code | Description |
---|---|
|
The method succeeded. |
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 |
other | Other items, such as an .asf file or the URL of a stream. |
photo | Photo items. Requires Windows Media Player 10. |
playlist | Playlists represented as media items. |
radio | Radio station items. Not used by Windows Media Player 10. |
video | Video items. |
Before calling this method, you must have read access to the library. For more information, see Library Access.
There are two ways you ways you can retrieve an IWMPMediaCollection interface, and the behavior of the getByAttribute method depends on which of those two ways you use. If you retrieve the interface by calling IWMPCore::get_mediaCollection, then the getByAttribute method returns all the media items in the library that have the specified attribute and value. If you retrieve the interface by calling IWMPLibrary::get_mediaCollection, then the getByAttribute method returns only the audio items in the library that have the specified attribute and value.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Media Player 9 Series or later. |
Target Platform | Windows |
Header | wmp.h |
DLL | Wmp.dll |