Controls.playItem 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
playItem 方法播放指定的媒体项。
语法
Controls.playItem(
theMediaItem
)
parameters
-
theMediaItem [in]
-
要播放的媒体对象。
返回值
此方法不返回值。
备注
无论 “设置”的值如何,都会自动加载和播放媒体项。autoStart 属性。 若要在不自动播放项的情况下加载项目,请设置 “设置”。autoStart 为 false 并将值分配给 Player。URL,之后可以调用 播放 以开始播放项目。
注意
playItem 仅适用于 currentPlaylist 中的项目。 不支持使用对已保存媒体项的引用调用 playItem 。
示例
以下 JScript 示例使用 playItem 播放当前播放列表中的媒体项。 要播放的项是根据其在播放列表中的位置选择的。 创建的 Player 对象 ID 为“Player”。
// Declare a variable to hold the position of the media item
// in the current playlist. An arbitrary value is supplied here.
var index = 3
// Retrieve the media item at the fourth position in the current playlist.
var media = Player.currentPlaylist.item(index);
// Play the media item.
Player.controls.playItem(media);
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器版本 7.0 或更高版本。 |
DLL |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈