AxWindowsMediaPlayer.currentMedia 属性
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
currentMedia 属性获取或设置与当前媒体项对应的 IWMPMedia 接口。
语法
public IWMPMedia currentMedia {get; set;}
Public Property currentMedia As IWMPMedia
属性值
WMPLib.IWMPMedia 接口,提供对当前媒体项的访问权限。
注解
如果为 AxWindowsMediaPlayer.settings。autoStart 属性为 true,每当设置 currentMedia 时,播放都会自动开始。
可以通过 IWMPPlaylist.Item 属性 (C#) 中的 IWMPPlaylist.get_Item 方法检索给定媒体项的 IWMPMedia 接口。 若要使用文件名加载媒体项,请设置 URL 属性或使用 newMedia。
示例
以下示例检索库中的第一个媒体项,并使用 currentMedia 属性将检索到的媒体项设置为当前媒体项并显示其名称。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Get an interface to the first media item in the library.
WMPLib.IWMPMedia3 firstMedia = (WMPLib.IWMPMedia3)player.mediaCollection.getAll().get_Item(0);
// Make the retrieved media item the current media item.
player.currentMedia = firstMedia;
// Display the name of the current media item.
currentMediaLabel.Text = ("Found first media item. Name = " + player.currentMedia.name);
' Get an interface to the first media item in the library.
Dim firstMedia As WMPLib.IWMPMedia3 = player.mediaCollection.getAll().Item(0)
' Make the retrieved media item the current media item.
player.currentMedia = firstMedia
' Display the name of the current media item.
currentMediaLabel.Text = ("Found first media item. Name = " + player.currentMedia.name)
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
AxWMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈