IWMPMedia::isReadOnlyItem 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
isReadOnlyItem 方法返回一个值,该值指示是否可以编辑指定媒体项的属性。
语法
public System.Boolean isReadOnlyItem(
System.String bstrItemName
);
Public Function isReadOnlyItem( _
ByVal bstrItemName As System.String _
) As System.Boolean
Implements IWMPMedia.isReadOnlyItem
parameters
-
bstrItemName [in]
-
作为媒体项的名称的 System.String 。
返回值
一个 System.Boolean 值,指示属性是否为只读。
备注
如果属性是只读的,则不能使用 setItemInfo 方法对其进行设置。 请注意,当与不同版本的 Windows 媒体播放器 一起使用时,此方法可能会为特定属性返回不同的值。
在调用此方法之前,必须具有对库的读取访问权限。 有关详细信息,请参阅 库访问。
示例
以下示例使用 isReadOnlyItem 在多行文本框中填充有关当前媒体项的信息。 该代码显示当前媒体项的每个属性,以及指示该属性是只读还是读/写的文本。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Store a WMPLib.IWMPMedia3 interface to the current media item.
WMPLib.IWMPMedia3 cm = (WMPLib.IWMPMedia3)player.currentMedia;
// Get the number of attributes in the current media item.
int attCount = player.currentMedia.attributeCount;
// Create an array to store the list of attribute information.
string[] atInfo = new string[attCount];
// Create a variable to hold each attribute name.
string atName;
// Loop through the attribute list.
for (int i = 0; i < cm.attributeCount; i++)
{
// Get the attribute name.
atName = cm.getAttributeName(i);
// Test whether the attribute is read-only.
string test = ((cm.isReadOnlyItem(atName)) ? "Read-Only" : "Read/Write");
// Store the attribute information in the array.
atInfo[i] = (atName + " is " + test);
}
// Display the attribute information in the text box.
rwText.Lines = atInfo;
' Store a WMPLib.IWMPMedia3 interface to the current media item.
Dim cm As WMPLib.IWMPMedia3 = player.currentMedia
' Get the number of attributes in the current media item.
Dim attCount As Integer = player.currentMedia.attributeCount
' Create an array to store the list of attribute information.
Dim atInfo(attCount) As String
' Create a variable to hold each attribute name.
Dim atName As String
' Loop through the attribute list.
For i As Integer = 0 To (cm.attributeCount - 1)
' Get the attribute name.
atName = cm.getAttributeName(i)
' Test whether the attribute is read-only.
If (cm.isReadOnlyItem(atName)) Then
atInfo(i) = (atName + " is Read-Only")
Else
atInfo(i) = (atName + " is Read/Write")
End If
Next i
' Display the attribute information in the text box.
rwText.Lines = atInfo
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈