Media.setItemInfo 方法

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

setItemInfo 方法设置当前媒体项的指定属性的值。

语法

Media.setItemInfo(
  attribute,
  value
)

parameters

attribute [in]

包含属性名称的字符串。 有关 Windows 媒体播放器 支持的属性的信息,请参阅 Windows 媒体播放器 属性参考

value [in]

包含新值的字符串

返回值

此方法不返回值。

备注

attributeCount 属性包含可用于给定 Media 对象的属性数。 然后,索引号可与 getAttributeName 方法一起使用,以确定可与此方法一起使用的内置属性的名称。

在使用此方法之前,请使用 isReadOnlyItem 方法确定是否可以设置特定属性。

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

注意

如果在应用程序中嵌入Windows 媒体播放器控件,则在用户运行Windows 媒体播放器之前,不会将更改的文件属性写入数字媒体文件。 如果在用 C++ 编写的远程应用程序中使用 控件,更改的文件属性将在进行更改后不久写入数字媒体文件。 在任一情况下,这些更改都可以通过库立即提供给代码。

Windows 媒体播放器 10 移动版:此方法未实现。

示例

以下 JScript 示例使用 MediasetItemInfo :更改当前媒体项的 Genre 属性的值。 名为 genText 的 HTML TEXT 输入元素允许用户输入文本字符串,然后使用该字符串更改属性信息。 创建 ID 为“Player”的 Player 对象。

<!-- Create the button element. -->
<INPUT type = "BUTTON"  id = "NEWGEN"  name = "NEWGEN"  value = "Change Genre" 
onClick = "
    /* Store the current media item. */
    var cm = Player.currentMedia;

    /* Get the user input from the text box. */
    var atValue = genText.value;

    /* Test for read-only status of the attribute. */
    if(cm.isReadOnlyItem('Genre') == false){

        /* Change the attribute value. */
        cm.setItemInfo('Genre' ,atValue);
    } 
">

要求

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

另请参阅

Media 对象

Media.getItemInfo

Media.isReadOnlyItem

Settings.mediaAccessRights

Settings.requestMediaAccessRights