Compartilhar via


MediaCollection.remove method

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The remove method removes an item from the media collection.

Syntax

MediaCollection.remove(
  item,
  delete
)

Parameters

item [in]

Media object to be removed.

delete [in]

Boolean indicating whether to remove the item.

Return value

This method does not return a value.

Remarks

This method deletes an item from the library. This method does not delete files from the user's computer.

To use this method, full access to the library is required. For more information, see Library Access.

Examples

The following JScript example, after prompting the user, permanently deletes the first media item in the media collection by using MediaCollection.remove. The Player object was created with ID = "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);
}

Requirements

Requirement Value
Version
Windows Media Player version 7.0 or later.
DLL
Wmp.dll

See also

Media Object

MediaCollection Object

MediaCollection.add

Settings.mediaAccessRights

Settings.requestMediaAccessRights