IWMPMediaCollection::getByAuthor 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
方法 getByAuthor
返回一个 IWMPPlaylist 接口,该接口提供指定作者对媒体项的访问权限。
语法
public IWMPPlaylist getByAuthor(
System.String bstrAuthor
);
Public Function getByAuthor( _
ByVal bstrAuthor As System.String _
) As IWMPPlaylist
Implements IWMPMediaCollection.getByAuthor
parameters
-
bstrAuthor [in]
-
作为作者名称的 System.String 。
返回值
检索到的媒体项的 WMPLib.IWMPPlaylist 接口。
备注
在调用此方法之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
可通过两种方式检索 IWMPMediaCollection 接口,方法的行为 getByAuthor
取决于你使用这两种方法中的哪一种。 如果通过调用 AxWindowsMediaPlayer.mediaCollection 检索接口,则 getByAuthor
该方法将返回库中的所有媒体项。 但是,如果通过调用 IWMPLibrary.mediaCollection 检索接口,则 getByAuthor
该方法仅返回库中具有指定属性和值的音频项。
示例
以下示例使用 getByAuthor
在用户单击按钮时创建媒体项的播放列表。 播放列表包含与用户在文本框中指定的作者姓名匹配的项目。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
private void playAuthor_Click(object sender, System.EventArgs e)
{
// ...Add code to ensure that the text box contains a valid value.
// Retrieve the author's name from the text box.
string author = getAuthor.Text;
// Create the playlist using getByAuthor.
WMPLib.IWMPPlaylist pl = player.mediaCollection.getByAuthor(author);
// Make the new playlist the current playlist.
player.currentPlaylist = pl;
// Play the media in the current playlist.
player.Ctlcontrols.play();
}
Public Sub playAuthor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playAuthor.Click
' ...Add code to ensure that the text box contains a valid value.
' Retrieve the author's name from the text box.
Dim author As String = getAuthor.Text
' Create the playlist using getByAuthor.
Dim pl As WMPLib.IWMPPlaylist = player.mediaCollection.getByAuthor(author)
' Make the new playlist the current playlist.
player.currentPlaylist = pl
' Play the media in the current playlist.
player.Ctlcontrols.play()
End Sub
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈