Player.currentMedia

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

currentMedia 属性指定或检索当前 Media 对象。

语法

playercurrentMedia

可能的值

此属性是可读/写媒体对象。

备注

如果为“设置”。autoStart 属性为 true,每当设置 currentMedia 时,播放都会自动开始。

此属性采用 Media 对象,可使用 Playlist 获取该 对象项目。 若要使用文件名加载 媒体 项,请设置 URL 属性或使用 newMedia

示例

以下 JScript 示例检索库中的第一个媒体项。 然后,它使用 currentMedia 将检索到的媒体项设置为当前媒体项,然后显示当前媒体项的名称。 创建的 Player 对象 ID 为“Player”。

// Retrieve the first media item from the library.
var firstMedia = 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.
document.write("Found first media item. Name = " + Player.currentMedia.name);

要求

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

另请参阅

媒体对象

Player 对象

Player.newMedia

Playlist.item

Settings.autoStart