Video Duration

Mar 19, 2012 at 10:19 AM

WPF Media Kit indeed is great for video playback. However, I'm curious if there's any way I can retrieve the total duration of the video?

Sorry I'm new to this.

Mar 19, 2012 at 1:29 PM

MediaDuration?

- Stephen

Mar 20, 2012 at 2:54 AM

It returns 0 value tho..

I wonder how I should make it to work.

dvdPlayer.Source = new Uri(url);
long duration = 0;

dvdPlayer.Play();
duration = dvdPlayer.MediaDuration;

Mar 20, 2012 at 1:31 PM

The source probably hasn't finished loading yet -- it is asynchronous.  You'll need to delay before reading it.