Media.isReadOnlyItem 方法

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

isReadOnlyItem 方法返回一个值,该值指示是否可以编辑媒体项的指定属性。

语法

bRetVal = Media.isReadOnlyItem(
  attribute
)

参数

attribute [in]

指示要测试的属性的名称的字符串。 有关 Windows 媒体播放器 支持的属性的信息,请参阅Windows 媒体播放器属性参考

返回值

此方法返回 布尔值

备注

如果属性是只读的,则不能使用 setItemInfo 方法对其进行设置。 请注意,当与不同版本的 Windows 媒体播放器 一起使用时,此方法可能会为特定属性返回不同的值。

若要使用此方法,需要对库的读取访问权限。 有关详细信息,请参阅 库访问

Windows 媒体播放器 10 Mobile:此属性始终返回 true

示例

以下 JScript 示例使用 媒体isReadOnlyItem 以使用有关当前媒体项的信息填充名为 rwText 的 HTML TEXTAREA 元素。 代码输出当前媒体项的每个属性,以及指示该属性是只读还是读/写的文本。 创建的 Player 对象 ID 为“Player”。

// Store the current media item object.
var cm = Player.currentMedia;

// Create a variable to hold each attribute name.
var atName;

// Loop through the attribute list.
for(var i = 0; i < cm.attributeCount; i++){

   // Get the attribute name.
   atName = cm.getAttributeName(i);

   // Test whether the attribute is read-only.
   var test = ((cm.isReadOnlyItem(atName))?"Read-Only":"Read/Write");

// Print the attribute information to the text area.
   rwText.value += atName + " is " + test;
   rwText.value += "\n";
}

要求

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

另请参阅

媒体对象

Media.setItemInfo

Settings.mediaAccessRights

Settings.requestMediaAccessRights