getByName method returns an IWMPPlaylist interface that provides access to media items with the specified name.
- bstrName [in]
The System.String that is the specified name.
A WMPLib.IWMPPlaylist interface for the retrieved media items.
Before calling this method, you must have read access to the library. For more information, see Library Access.
There are two ways you ways you can retrieve an IWMPMediaCollection interface, and the behavior of the
getByName method depends on which of those two ways you use. If you retrieve the interface by calling AxWindowsMediaPlayer.mediaCollection, then the
getByName method returns all the media items in the library. However, if you retrieve the interface by calling IWMPLibrary.mediaCollection, then the
getByName method returns only the audio items in the library that have the specified attribute and value.
The following example uses
getByName to retrieve three items from the library. Each item is then appended to the current playlist. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
// In each case, use the name exactly as it appears in the library. // Windows Media Player does not include file name extensions or file paths // in the name. Internet URLs include the entire path, but not the // file name extension. // Get an interface to a playlist that contains an Internet URL. WMPLib.IWMPPlaylist one = player.mediaCollection.getByName("http://www.proseware.com/Media/Laure"); // Get an interface to a playlist that contains a file on a network server. WMPLib.IWMPPlaylist two = player.mediaCollection.getByName("Jeanne"); // Get an interface to a playlist that contains a file on a local drive. WMPLib.IWMPPlaylist three = player.mediaCollection.getByName("house"); // Append each item to the current playlist. Since each playlist retrieved // using getByName contains one digital media item, use the get_Item // method with an index of zero to reference that item. player.currentPlaylist.appendItem(one.get_Item(0)); player.currentPlaylist.appendItem(two.get_Item(0)); player.currentPlaylist.appendItem(three.get_Item(0));
|Windows Media Player 9 Series or later|
Build date: 11/16/2013