Windows Media Player 11 SDK IWMPMediaCollection.remove (VB and C#)
Previous | Next |
IWMPMediaCollection.remove (VB and C#)
The remove method removes a specified item from the media collection.
Parameters
pItem
A WMPLib.IWMPMedia interface that identifies the item to remove.
varfDeleteFile
A System.Boolean value that specifies whether the method should remove the specified item from the library.
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.
Before calling this method, you must have read access to the library. For more information, see Library Access.
Example Code
The following example, after prompting the user, permanently deletes the first media item in the media collection by using remove. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
' Get an interface to the first item from the media collection. Dim media As WMPLib.IWMPMedia3 = player.mediaCollection.getAll().Item(0) ' Store the name of the retrieved media item. Dim mediaName As String = media.name ' Prepare a message, a caption and buttons for the user prompt. Dim message As String = ("OK to permanently delete " + mediaName + "?") Dim caption As String = "Confirm deletion" Dim buttons As System.Windows.Forms.MessageBoxButtons = System.Windows.Forms.MessageBoxButtons.OKCancel ' Prompt the user for permission to delete the object. Dim result As System.Windows.Forms.DialogResult = System.Windows.Forms.MessageBox.Show(message, caption, buttons) ' Check the user response. If (result = System.Windows.Forms.DialogResult.OK) Then ' Permanently delete the item. player.mediaCollection.remove(media, True) ' Report that the item was deleted. System.Windows.Forms.MessageBox.Show("Deleted item " + mediaName) End If
FakePre-5eb65a55d54f44dba5527740d2066147-87fd04cb15a940d99e624928e69c4ae3
// Get an interface to the first item from the media collection. WMPLib.IWMPMedia3 media = (WMPLib.IWMPMedia3)player.mediaCollection.getAll().get_Item(0); // Store the name of the retrieved media item. string mediaName = media.name; // Prepare a message, a caption and buttons for the user prompt. string message = ("OK to permanently delete " + mediaName + "?"); string caption = "Confirm deletion"; System.Windows.Forms.MessageBoxButtons buttons = System.Windows.Forms.MessageBoxButtons.OKCancel; // Prompt the user for permission to delete the object. System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(message, caption, buttons); // Check the user response. if (result == System.Windows.Forms.DialogResult.OK) { // Permanently delete the item. player.mediaCollection.remove(media, true); // Report that the item was deleted. System.Windows.Forms.MessageBox.Show("Deleted item " + mediaName); }
Requirements
Version: Windows Media Player 9 Series or later
Namespace: WMPLib
Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)
See Also
- IWMPMedia Interface (VB and C#)
- IWMPMediaCollection Interface (VB and C#)
- IWMPMediaCollection.add (VB and C#)
Previous | Next |