MediaCollection.getAll 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
getAll 方法检索包含库中所有媒体项的播放列表。
语法
retVal = MediaCollection.getAll()
参数
此方法没有任何参数。
返回值
此方法返回 一个 Playlist 对象。
备注
若要使用此方法,需要对库的读取访问权限。 有关详细信息,请参阅 库访问。
示例
以下 JScript 示例使用 MediaCollection。getAll 可从媒体集合中随机播放媒体项。 创建 ID 为“Player”的 Player 对象。
// Store the count of all media items in the media collection.
var count = Player.mediaCollection.getAll().count;
// Generate a random number using the media count.
var rand = Math.random() * count;
// Round down the random number to the nearest integer.
rand = Math.floor(rand);
// Make the random media item the current media item.
Player.currentMedia = Player.mediaCollection.getAll().item(rand);
// Play the media item.
// Player.controls.play();
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器版本 7.0 或更高版本。 |
DLL |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈