IWMPMedia::markerCount 属性

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

markerCount 属性获取媒体项中的标记数。

此属性为只读。

语法

public System.Int32 markerCount {get;}

Public ReadOnly Property markerCount As System.Int32

属性值

作为标记计数的 System.Int32

备注

如果文件没有标记,或者媒体项与 AxWindowsMediaPlayer.currentMedia 中指定的媒体项不同,则此属性返回零。

标记编号从 1 开始。

在使用此属性之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问

示例

以下示例使用 markerCount 检索当前媒体项中的标记数。 然后,该值用作循环结构的上限,循环访问标记列表以检索每个标记名称并将其显示在多行文本框中。 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 markers.
string[] markerNames = new string[mcount];

// Verify that at least one marker exists in the current media item.
if (mcount > 0)
{
    // Loop through the marker list.
    for (int i = 1; i < mcount + 1; i++)
    {
        // Store the marker name in the array.
        markerNames[i]= player.currentMedia.getMarkerName(i);
    }

    // Display the marker names in the text box.
    markerList.Lines = markerNames;            
}

' Get the number of markers in the current media item.
Dim mcount As Integer = player.currentMedia.markerCount

&#39; Create an array to store the list of markers.
Dim markerNames(mcount) As String

&#39; Verify that at least one marker exists in the current media item.
If (mcount > 0) Then

    &#39; Loop through the marker list.
    For i As Integer = 1 To mcount

        &#39; Store the marker name in the array.
        markerNames(i) = player.currentMedia.getMarkerName(i)

    Next i

    &#39; Display the marker names in the text box.
    markerList.Lines = markerNames

End If

要求

要求
版本
Windows 媒体播放器 9 系列或更高版本
命名空间
WMPLib
程序集
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

另请参阅

AxWindowsMediaPlayer.currentMedia (VB 和 C#)

IWMPMedia 接口 (VB 和 C#)