IWMPMedia::attributeCount 属性
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
attributeCount 属性获取可为媒体项查询和/或设置的属性数。
此属性为只读。
语法
public System.Int32 attributeCount {get;}
Public ReadOnly Property attributeCount As System.Int32
属性值
作为计数的 System.Int32 。
备注
在使用此属性之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
有关Windows 媒体播放器支持的属性的信息,请参阅属性参考。
示例
以下示例使用 attributeCount 来确定当前媒体项中可用的属性数。 代码使用该值在文本框中显示属性名称和值的列表。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Store an IWMPMedia3 interface to the current media item.
WMPLib.IWMPMedia3 cm = (WMPLib.IWMPMedia3)player.currentMedia;
// Store the number of attributes in the current media item using attributeCount.
int numAttributes = cm.attributeCount;
// Create strings to hold each attribute name and value.
string atName;
string atValue;
// Create an array to hold the attribute list.
string [] atList = new string[numAttributes];
// Loop through the attribute list.
for (int i = 0; i < numAttributes; i++)
{
// Fill the strings with the attribute information.
atName = cm.getAttributeName(i);
atValue = cm.getItemInfo(atName);
// Store the attribute information in an array.
atList[i] = (atName + ": " + atValue);
}
// Display the attribute information in the text box.
attributeList.Lines = atList;
' Store an IWMPMedia3 interface to the current media item.
Dim cm As WMPLib.IWMPMedia3 = player.currentMedia
' Store the number of attributes in the current media item using attributeCount.
Dim numAttributes As Integer = cm.attributeCount
' Create strings to hold each attribute name and value.
Dim atName As String
Dim atValue As String
' Create an array to hold the attribute list.
Dim atList(numAttributes) As String
' Loop through the attribute list.
For i As Integer = 0 To (numAttributes - 1)
' Fill the strings with the attribute information.
atName = cm.getAttributeName(i)
atValue = cm.getItemInfo(atName)
' Store the attribute information in an array.
atList(i) = (atName + ": " + atValue)
Next i
' Display the attribute information in the text box.
attributeList.Lines = atList
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈