I'm open to using DirectX calls to do it, if required. Would beat what I'm
doing now...
Thanks...Warrick
With DirectShow, you can use IGraphBuilder::RenderFile() to create a graph
and then use IMediaSeeking::GetDuration(). See
http://msdn.microsoft.com/library/en-us/directx9_c/directX/htm/howtoplayafile.asp
on how to render a file (you don't need to actually play it, that is call
IMediaControl::Run()).
Otherwise, you can use the IMediaDet interface (which does the above
internally).
"Warrick Wilson" <warr...@mercuryonline.com> wrote:
--
Alessandro Angeli
MVP::DigitalMedia
a dot angeli at biosys dot net
Look in the Windows Media <b>Format</b> SDK. I do this in managed C#
so it's probably a bit different and MSFT provides a C# wrapper class
to the COM IWMHeaderInfo3 class which has functions like
GetAttributeCount and GetAttributeByName plus a bunch of others.
After looking at it last night I realized I was mistaken; the APIs to
do this are in the Player SDK and not the Format SDK. Sorry about
that.
Player.newMedia() is the key interface for this purpose. Here is a
code sample:
-----------------------------------------------
Microsoft.MediaPlayer.Interop.IWMPMedia m = Player.newMedia(fileName);
string currentArtist = m.getItemInfo("Author").Trim();
string currentAlbum = m.getItemInfo("Album").Trim();
string currentTitle = m.getItemInfo("Title").Trim();
double duration = m.duration;
Console.WriteLine(fileName);
Console.WriteLine("\tArtist : {0}", currentArtist);
Console.WriteLine("\tAlbum : {0}", currentAlbum);
Console.WriteLine("\tTitle : {0}", currentTitle);
Console.WriteLine("\tDuration: {0}", duration);
m.setItemInfo("Author", "bla");
m.setItemInfo("Album", "de");
m.setItemInfo("Title", "bla");