Hi Wayne,
In your post you asked how to get the name of each track in a playlist and
asked for some sample code.
First of all,I assume you have installed the WM Player SDK9 properly, and
registered the PIA followed the documentation described, because the
following method in my reply as well as code snippet is based on the method
name in PIA ,which has a bit different with the WMPSDK Docuementation.
You may get the track name as well as other attribute of an media item by
getItemInfo method,
this method has a string argument which should pass in a name of the
attribute. For example,
string titleName = axWMP1.currentPlayList.get_Item(0).getItemInfo("Title");
will return the title of the first media item in the current playlist. You
can find more attribute name list in WMP SDK9,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay/mmp_
sdk/availableattributes.asp
Here is a code snippet which retrieve all attribute of every media item in
the current playlist.
<code>
///using Microsoft.MediaPlayer.Interop;
private void button1_Click(object sender, System.EventArgs e)
{
IWMPMedia media =
axWindowsMediaPlayer1.newMedia("C:\\WMSDK\\WMPSDK9\\samples\\media\\laure.wm
a");
axWindowsMediaPlayer1.currentPlaylist.appendItem(media);
media =
axWindowsMediaPlayer1.newMedia(@"C:\WMSDK\WMPSDK9\samples\media\house.wma");
axWindowsMediaPlayer1.currentPlaylist.appendItem(media);
media = axWindowsMediaPlayer1.newMedia
(@"C:\Documents and Settings\All Users\Documents\My Music\Sample
Music\Beethoven's Symphony No. 9 (Scherzo).wma");
axWindowsMediaPlayer1.currentPlaylist.appendItem(media);
}
private void button2_Click(object sender, System.EventArgs e)
{
IWMPPlaylist pl = axWindowsMediaPlayer1.currentPlaylist;
for(int i = 0; i < pl.count; ++i)
{
for (int j = 0; j < pl.get_Item(i).attributeCount; ++j)
{
IWMPMedia it = pl.get_Item(i);
string attrName = it.getAttributeName(j);
listBox1.Items.Add(attrName + " : " + it.getItemInfo(attrName));
}
}
}
<code>
Does this answer your question?
Please be free to post on our group, if you still have questions on it.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
--------------------