1

I found WindowsMediaPlayer in WMPLib but not the TimeCode!

Anyone known how to do that?

MERose
  • 4,048
  • 7
  • 53
  • 79
user1545810
  • 217
  • 1
  • 2
  • 8

2 Answers2

1

I believe that the answer to your question is that you will need to call IWMReaderTimecode::GetTimecodeRangeCount for each stream in your file. Then call IWMReaderTimecode::GetTimecodeRangeBounds for each range in each stream to get the startTimecode and endTimecode of each range.

topcat3
  • 2,561
  • 6
  • 33
  • 57
  • Thanks, can you add a sample. How do you implement this class ? – user1545810 Dec 06 '12 at 09:37
  • I'm afraid I'm mainly a Java programmer. Your probably better asking the question over on the msdn forums http://social.msdn.microsoft.com/Forums/en-US/categories . I have the idea on how to do it as above but it will take some figuring out to code – topcat3 Dec 06 '12 at 09:49
0

Looking at these two articles Get WMA/WMV meta information in C# and Getting Current Time Code Using Windows Media Player Class in C#, you could try the following:

using WMPLib; // this file is called Interop.WMPLib.dll 

WindowsMediaPlayerClass wmp = new WindowsMediaPlayerClass(); 
IWMPMedia mediaInfo = wmp.newMedia("myfile.wmv"); 

Console.WriteLine("Duration = " + mediaInfo.duration); 

for (int i=0; i<mediaInfo.attributeCount; i++) { 
    Console.WriteLine(mediaInfo.getAttributeName(i) + " = " + 
    mediaInfo.getItemInfo(mediaInfo.getAttributeName(i)) ); 
} 

or use the Controls.CurrentPositionString property to get the current time.

Console.WriteLine(wmp.controls.currentPositionString);
chridam
  • 100,957
  • 23
  • 236
  • 235