MediaCollection.remove 方法

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

remove 方法从媒体集合中删除项。

语法

MediaCollection.remove(
  item,
  delete
)

参数

item [in]

要删除的媒体对象。

delete [in]

指示是否删除项的布尔值

返回值

此方法不返回值。

备注

此方法从库中删除项。 此方法不会从用户的计算机中删除文件。

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

示例

下面的 JScript 示例在提示用户后,使用 MediaCollection 永久删除媒体集合中的第一个媒体项。remove创建 ID 为“Player”的 Player 对象。

// Retrieve the first item from the media collection.
var mediaObject = Player.mediaCollection.getAll().item(0);

// Store the name of the retrieved object.
var mediaName = mediaObject.name;

// Prompt the user for permission to delete the object.
var answer = confirm("OK to permanently delete " + mediaName + "?");

// Check the user response.
if (answer){

    // Permanently delete the item.
    Player.mediaCollection.remove(mediaObject, true);

    // Report that the item was deleted.
    alert("Deleted item " + mediaName);
}

要求

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

另请参阅

Media 对象

MediaCollection 对象

MediaCollection.add

Settings.mediaAccessRights

Settings.requestMediaAccessRights