MediaCollection.getByAlbum 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 GetByAlbum method retrieves a playlist containing the media items from the specified album.

Syntax

retVal = MediaCollection.getByAlbum(
  album
)

Parameters

album [in]

String containing the name of the album.

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 example uses MediaCollection.getByAlbum to retrieve a playlist of media items. The playlist contains items with the album specified by the user in an HTML TEXT input element named GetAlbum. The Player object was created with ID = "Player".

<!-- Use an HTML BUTTON element to create the playlist and 
then play the digital media items. -->
<INPUT TYPE = "BUTTON"
       NAME = "PlayAlbum" 
       ID = "PlayAlbum"  
       VALUE = "Play Album"

onClick = "
    /* Retrieve the album title text from the user. */
    var album = GetAlbum.value;

    /* Create the playlist using getByAlbum. */
    var pl = Player.mediaCollection.getByAlbum(album);

    /* Make the new playlist the current playlist. */
    Player.currentPlaylist = pl;

    /* Play the media in the new playlist. */
    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