다음을 통해 공유


IWMPMediaCollection::add method (wmp.h)

[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 add method adds a new media item or playlist to the library.

Syntax

HRESULT add(
  [in]  BSTR      bstrURL,
  [out] IWMPMedia **ppItem
);

Parameters

[in] bstrURL

String containing the URL that specifies the location of the media item or playlist.

[out] ppItem

Pointer to a pointer to the IWMPMedia interface for the added item or playlist.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK
The method succeeded.

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.

Requirements

Requirement Value
Minimum supported client Windows Media Player 9 Series or later.
Target Platform Windows
Header wmp.h
DLL Wmp.dll

See also

IWMPMediaCollection Interface

IWMPMediaCollection::remove

IWMPPlaylistCollection::importPlaylist