IWMPPlaylistCollection::getByName 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
getByName 方法返回 IWMPPlaylistArray 接口,该接口提供对具有指定名称的播放列表的访问权限(如果有)。
语法
public IWMPPlaylistArray getByName(
System.String bstrName
);
Public Function getByName( _
ByVal bstrName As System.String _
) As IWMPPlaylistArray
Implements IWMPPlaylistCollection.getByName
参数
-
bstrName [in]
-
作为播放列表名称的 System.String 。
返回值
检索到的播放列表数组的 WMPLib.IWMPPlaylistArray 接口。
备注
使用 IWMPPlaylistArray.count 确定是否存在播放列表。 如果 count 为零,则数组为空。
在调用此方法之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
示例
以下示例使用 getByName 为名为“收藏夹 -- 4 和 5 star分级”的播放列表集合检查播放列表集合。 如果存在按该名称显示的播放列表, getByName 会将其设置为当前播放列表。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Get the count of the playlists named "Favorites -- 4 and 5 star rated".
int checkit = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").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 playlist array containing "Favorites -- 4 and 5 star rated".
// Assume that there is only one playlist with that name, and assign it to the
// current playlist.
player.currentPlaylist = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").Item(0);
}
' Get the count of the playlists named "Favorites -- 4 and 5 star rated".
Dim checkit As Integer = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").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) Then
' Retrieve a playlist array object containing "Favorites -- 4 and 5 star rated".
' Assume that there is only one playlist with that name, and assign it to the
' current playlist.
player.currentPlaylist = player.playlistCollection.getByName("Favorites -- 4 and 5 star rated").Item(0)
End If
要求
要求 | 值 |
---|---|
版本 |
Windows Media Player 9 系列或更高版本。 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈