views:

594

answers:

2

Hi All,

I'm trying to get the duration for an audio file in c#. I got the following code to work on my local machine but when I deploy it to a windows server 2008 box it always returns a duration of 0 for .avi and .wav files.

WindowsMediaPlayerClass wmp = new WindowsMediaPlayerClass();
    IWMPMedia mediaInfo = wmp.newMedia(filePath);
    return mediaInfo.durationString

I have windows media player 11 installed on the server.

Any help would be most appreciated

+2  A: 

I don't have experience with "WindowsMediaPlayerClass", but I have used TagLibSharp extensively, which is what I try to use for such things - it supports a pretty broad set of formats and that makes it's API much more usable that the built-in support in .NET

http://developer.novell.com/wiki/index.php/TagLib%5FSharp

Quite possibly simply using TagLibSharp will solve your problems.

(Note that taglibsharp is maintained by the banshee project, but is hosted @ novell for apparently historical reasons. I don't know about the details, but that can make contacting the devs a little confusing)

Eamon Nerbonne
A: 

My guess is that the media player isn't installed (it's not by default on server SKUs).

Did you try installing the desktop experience package?

Larry Osterman
This is completely unrelated to your answer here, but I was hoping to draw your attention to this question I asked a couple of days ago: http://stackoverflow.com/questions/1303811/what-is-the-latency-or-delay-time-for-callbacks-from-the-waveoutwrite-api-metho
MusiGenesis