This code is "ok", I should really make the code into a wrapper library, but this is just a bit of a proof of concept really.
Firstly, you need to add the WMP.dll to the form using the Toolbox, which should appear as the Windows Media Player Control, it will then add two references
AxWMPLib
WMPLib
Then the main code for getting the Meta Data is
private string GetTitle(string filePath)
{
var mediaPlayer = new WindowsMediaPlayerClass();
IWMPMedia mediaItem = mediaPlayer.add(filePath);
return mediaItem.getItemInfo("Title");
}
I got all the attribute names running code like this
for (int i=0; i<mediaitem.attributeCount; i++) {
Console.WriteLine(mediaitem.getAttributeName(i) + " = " + mediaitem.getItemInfo(mediaitem.getAttributeName(i)) );
}
The code for setting it also very simple
private void SetTitle(string filePath, string title)
{
var mediaPlayer = new WindowsMediaPlayerClass();
IWMPMedia mediaItem = mediaPlayer.add(filePath);
mediaItem.setItemInfo("Title", title);
}
Here is the source code:
http://sarkie.webhop.org/Files/WindowsMediaEditor.zip
0 comments:
Post a Comment