关于 Playlist、PlaylistCollection 和 PlaylistArray 对象

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

PlaylistPlaylistCollectionPlaylistArray 对象控制Windows 媒体播放器可用于指定内容播放顺序的播放列表。 可从 Player 对象的 playlistCollection 属性获取 PlaylistCollection 对象。 playlistCollection 属性返回 PlaylistCollection 对象。 创建 PlaylistCollection 对象后,只能访问该对象的属性。 例如,若要创建新的播放列表,必须首先获取 PlaylistCollection 对象,然后在该对象上使用 方法。

player.playlistcollection.newplaylist('myplaylist');

可以使用 currentPlaylist 属性获取当前播放列表。 例如,若要获取当前播放列表的名称,请使用以下代码:

myname = player.currentplaylist.name;

PlaylistArray 对象由 PlaylistCollection 对象的 getAllgetByName 方法返回。 例如,若要获取播放列表的数量,请使用以下代码:

howmany = player.playlistcollection.getAll().count;

若要按名称检索已知播放列表,请使用以下代码:

if (player.playlistcollection.getbyname('myplaylist').count == 1) {
    pl = player.playlistcollection.getbyname('myplaylist').item(0);
}

脚本语言的播放器对象模型

Playlist 对象

PlaylistArray 对象

PlaylistCollection 对象