Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
.gif)
| Previous | Next |
IWMPMediaCollection.getByAuthor (VB and C#)
The getByAuthor method returns an IWMPPlaylist interface that provides access to the media items by the specified author.
Parameters
bstrAuthor
The System.String that is the name of the author.
Return Value
A WMPLib.IWMPPlaylist interface for the retrieved media items.
Remarks
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 getByAuthor method depends on which of those two ways you use. If you retrieve the interface by calling AxWindowsMediaPlayer.mediaCollection, then the getByAuthor method returns all the media items in the library. However, if you retrieve the interface by calling IWMPLibrary.mediaCollection, then the getByAuthor method returns only the audio items in the library that have the specified attribute and value.
Example Code
The following example uses getByAuthor to create a playlist of media items when the user clicks a button. The playlist contains items matching the author's name specified by the user in a text box. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.
Public Sub playAuthor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles playAuthor.Click
' ...Add code to ensure that the text box contains a valid value.
' Retrieve the author's name from the text box.
Dim author As String = getAuthor.Text
' Create the playlist using getByAuthor.
Dim pl As WMPLib.IWMPPlaylist = player.mediaCollection.getByAuthor(author)
' Make the new playlist the current playlist.
player.currentPlaylist = pl
' Play the media in the current playlist.
player.Ctlcontrols.play()
End Sub
FakePre-bbf3d95e7dc84e9b8d922e97f4fae210-6d1d8198f8944f0eab43c9a963dd28dd
private void playAuthor_Click(object sender, System.EventArgs e)
{
// ...Add code to ensure that the text box contains a valid value.
// Retrieve the author's name from the text box.
string author = getAuthor.Text;
// Create the playlist using getByAuthor.
WMPLib.IWMPPlaylist pl = player.mediaCollection.getByAuthor(author);
// Make the new playlist the current playlist.
player.currentPlaylist = pl;
// Play the media in the current playlist.
player.Ctlcontrols.play();
}
Requirements
Version: Windows Media Player 9 Series or later
Namespace: WMPLib
Assembly: Interop.WMPLib.dll (automatically generated by Visual Studio)
See Also
| Previous | Next |