Media.durationString

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

durationString 属性检索一个 String 值,该值指示当前媒体项的持续时间(HH:MM:SS 格式)。

语法

玩家currentMediadurationString

可能的值

此属性是只读 的 String

备注

如果此属性用于 除 Player 中指定的媒体项以外的媒体项。currentMedia,它可能不包含有效值。 如果媒体项的长度小于一小时,则省略返回值的 HH: 部分。

若要检索此属性的值,需要对库具有读取访问权限。 有关详细信息,请参阅 库访问

示例

以下 JScript 示例使用 MediadurationString 将当前媒体项的持续时间显示为格式化文本。 名为 MediaInfo 的 HTML DIV 元素显示持续时间信息。 创建 ID 为“Player”的 Player 对象。

<!-- Create an event handler to update the display when
 the current media item changes. -->
<SCRIPT LANGUAGE = "JScript"  FOR = Player  EVENT = OpenStateChange(NewState)>

// Test whether the new media item is open.
if (NewState == 13){

   // Write the formatted duration string to the DIV region.
   MediaInfo.innerHTML = "Duration: " + Player.currentMedia.durationString;
}
</SCRIPT>

要求

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

另请参阅

Media 对象

Media.duration

Player.currentMedia

Settings.mediaAccessRights

Settings.requestMediaAccessRights