IWMPMedia::getMarkerTime 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
getMarkerTime 方法返回指定索引处标记的时间。
语法
public System.Double getMarkerTime(
System.Int32 MarkerNum
);
Public Function getMarkerTime( _
ByVal MarkerNum As System.Int32 _
) As System.Double
Implements IWMPMedia.getMarkerTime
参数
-
MarkerNum [in]
-
作为标记索引的 System.Int32 。
返回值
作为标记时间的 System.Double 。
备注
如果指定的标记不存在,则此方法返回 NULL 。
某些媒体项不包含标记。 使用 markerCount 可找出当前媒体项中的标记数。
标记索引号从 1 开始。
在调用此方法之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
示例
下面的代码示例使用 getMarkerTime 使用每个标记的位置填充多行文本框。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Get the number of markers in the current media item.
int mcount = player.currentMedia.markerCount;
// Create an array to store the list of marker times.
string[] markers = new string[mcount];
// Verify that at least one marker exists in the current media.
if (mcount > 0)
{
// Loop through the marker list.
for (int i = 1; i < mcount + 1; i++)
{
// Store the marker information in the array.
markers[i] = "Marker number " + i + " occurs at ";
markers[i] += player.currentMedia.getMarkerTime(i).ToString();
markers[i] += " second(s).";
}
// Display the marker times in the text box.
markerTimes.Lines = markers;
}
' Get the number of markers in the current media item.
Dim mcount As Integer = player.currentMedia.markerCount
' Create an array to store the list of marker times.
Dim markers(mcount) As String
' Verify that at least one marker exists in the current media.
If (mcount > 0) Then
' Loop through the marker list.
For i As Integer = 1 To mcount
' Store the marker information in the array.
markers(i) = ("Marker number " + i + " occurs at ")
markers(i) += player.currentMedia.getMarkerTime(i).ToString()
markers(i) += " second(s)."
Next i
' Display the marker times in the text box.
markerTimes.Lines = markers
End If
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈