Share via


Windows Media Player 11 SDK IWMPMediaCollection.add (VB and C#) 

Windows Media Player SDK banner art

Previous Next

IWMPMediaCollection.add (VB and C#)

The add method adds a new media item or playlist to the library.

  

Parameters

bstrURL

A System.String that is the URL that specifies the location of the media item or playlist.

Return Value

The WMPLib.IWMPMedia interface for the added item or playlist.

Remarks

This method loads an existing media item or playlist into the library, given a path. This method does not move or change the file. This method fails if given an invalid local path, but media items themselves are not checked for validity before they are added to the library.

This method accepts both static and auto playlist files. The IWMPPlaylistCollection.importPlaylist method can also be used to add a static playlist to the library.

Before calling this method, you must have full access to the library. For more information, see Library Access.

Example Code

The following example adds three media objects to the Windows Media Player media collection. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.

  
' Adding a media object using a Web site.
player.mediaCollection.add("https:'www.proseware.com/Media/Laure.wma")

' Adding a media object from a local network.
player.mediaCollection.add("\\yourservername\Public\Jeanne.wma")

' Adding a media object from a file on a local drive.
player.mediaCollection.add("C:\WMSDK\WMPSDK\samples\media\house.wma")

FakePre-0f2d9ada38bf4e44bedfa4d328a616a5-5d83fe6fc9e549db8775bc673a3f983e

// Adding a media object using a Web site.
player.mediaCollection.add("https://www.proseware.com/Media/Laure.wma");

// Adding a media object from a local network.
// Either use the @ symbol to denote a quoted string literal or add additional
// backlashes as an escape for every original backslash.
player.mediaCollection.add(@"\\yourservername\Public\Jeanne.wma");

// Adding a media object from a file on a local drive.
// Either use the @ symbol to denote a quoted string literal or add additional
// backlashes as an escape for every original backslash.
player.mediaCollection.add(@"C:\WMSDK\WMPSDK\samples\media\house.wma");

Requirements

Version: Windows Media Player 9 Series or later

Namespace: WMPLib

Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)

See Also

Previous Next