problem using MediaElement for audio/video

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manontheedge
    New Member
    • Oct 2006
    • 175

    problem using MediaElement for audio/video

    I've scoured the Internet and can find many people with the same problem, but not a single solution. So, anyway ...

    The problem is that when using MediaElement ( .NET, VS2008 ), when I get to the point where I want to check the length of ( in my case ) an audio file, I do something like this ...

    Code:
    MediaElement me = new MediaElement();
    
    ...
    ...
    ...
    
    double milliseconds = 0;
    bool gotTime = me.NaturalDuration.HasTimeSpan;
    
    if( gotTime )
    {
        milliseconds = me.NaturalDuration.Timespan.TotalMilliseconds;
    }

    ... and an exception gets thrown SOME TIMES ( other times it runs through just fine ), saying that there is no time span. BUT, when the exception gets thrown, while stepping through the code, 'me.NaturalDura tion.Timespan.T otalMillisecond s' has a value, and not just a value, but the correct value. Why won't the value return when it's right there!?

    If anyone can help I would greatly appreciate it, as this issue is driving me crazy.
Working...