MediaCollection.getByAlbum 方法

[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]

GetByAlbum 方法检索包含指定专辑中的媒体项的播放列表。

语法

retVal = MediaCollection.getByAlbum(
  album
)

参数

专辑 [in]

包含相册名称的字符串

返回值

此方法返回 一个 Playlist 对象。

备注

若要使用此方法,需要对库的读取访问权限。 有关详细信息,请参阅 库访问

示例

以下示例使用 MediaCollectiongetByAlbum 用于检索媒体项的播放列表。 播放列表包含由用户在名为 GetAlbum 的 HTML 文本输入元素中指定的专辑的项目。 创建 ID 为“Player”的 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();
">

要求

要求
版本
Windows 媒体播放器版本 7.0 或更高版本。
DLL
Wmp.dll

另请参阅

MediaCollection 对象

Playlist 对象

Settings.mediaAccessRights

Settings.requestMediaAccessRights