MediaCollection.getByGenre 方法

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

getByGenre 方法检索具有指定流派的媒体项的播放列表。

语法

retVal = MediaCollection.getByGenre(
  genre
)

参数

genre [in]

包含流派名称的字符串

返回值

此方法返回 一个 Playlist 对象。

备注

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

示例

以下 JScript 示例使用 MediaCollectiongetByGenre 检索媒体项的播放列表。 播放列表包含在名为 GetGenre 的 HTML TEXT 输入元素中具有用户指定的流派的项目。 创建的 Player 对象 ID 为“Player”。

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

onClick = "
    /* Retrieve the genre text from the user. */
    var genre = GetGenre.value;

    /* Create the playlist using getByGenre. */
    var pl = Player.mediaCollection.getByGenre(genre);

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

    /* Play the digital media item in the new playlist. */
    Player.controls.play();
">

要求

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

另请参阅

MediaCollection 对象

Playlist 对象

Settings.mediaAccessRights

Settings.requestMediaAccessRights