PlaylistCollection.getByName 方法

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

getByName 方法检索包含具有指定名称的播放列表的 PlaylistArray 对象(如果存在)。

语法

retVal = PlaylistCollection.getByName(
  name
)

参数

name [in]

包含要检索的播放列表名称的字符串

返回值

此方法返回 PlaylistArray 对象。

备注

使用 PlaylistArray。用于确定播放列表是否存在的计数 。 如果 count 为零,则播放列表不存在。

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

示例

以下 JScript 示例使用 playlistCollectiongetByName 用于检查名为“ThreeList”的播放列表的 playlistCollection 对象。 如果存在“Threelist”播放列表, getByName 会将“ThreeList”设置为当前播放列表。 创建的 Player 对象 ID 为“Player”。

//Retrieve the count of the playlists named "ThreeList".
var Checkit = Player.playlistCollection.getByName("ThreeList").count;

//Since duplicate playlist names are allowed, the count returned
//will be either zero (no playlist) or greater than zero 
//(playlist exists).
if (Checkit > 0){ 
    
   //Retrieve a playlistArray object containing "ThreeList". Assume that
   //there is only one playlist with that name, and assign it to the 
   //current playlist.
   Player.currentPlaylist = Player.playlistCollection.getByName("ThreeList").item(0);
}

要求

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

另请参阅

PlaylistArray 对象

PlaylistArray.count

PlaylistCollection 对象

Settings.mediaAccessRights

Settings.requestMediaAccessRights