GuOrg / Gu.Wpf.Media

Wrapper for System.Windows.Controls.MediaElement.
MIT License
33 stars 11 forks source link

Unable to return a TimeSpan property value #3

Open julesx opened 7 years ago

julesx commented 7 years ago

Unable to return a TimeSpan property value for a Duration value of 'Automatic'. Check the HasTimeSpan property before requesting the TimeSpan property value from a Duration

I can't seem to replicate it reliably. I have a window where I am loading and unloading media players fairly rapidly and it seems to randomly occur.

Stack Trace:

" at System.Windows.Duration.get_TimeSpan()\r\n at Gu.Wpf.Media.MediaElementWrapper.<.ctor>b__3_4(Object o, RoutedEventArgs e)\r\n at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n at System.Windows.Controls.AVElementHelper.OnMediaOpened(Object sender, EventArgs args)\r\n at System.Windows.Media.UniqueEventHelper.InvokeEvents(Object sender, EventArgs args)\r\n at System.Windows.Media.UniqueEventHelper.InvokeEvents(Object sender, EventArgs args)\r\n at System.Windows.Media.MediaEventsHelper.OnMediaPrerolled(Object o)\r\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)"

JohanLarsson commented 7 years ago

Thanks for reporting, looks like I dumbed something.

julesx commented 7 years ago

happened again

StackTrace = " at System.Windows.Duration.get_TimeSpan()\r\n at Gu.Wpf.Media.MediaElementWrapper.<.ctor>b__3_4(Object o, RoutedEventArgs e)\r\n at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n at System.W...

JohanLarsson commented 7 years ago

@julesx if you have time you can try cloning and reference a debug build to find out where the dumb is, I'm a bit lost about writing a testcase/fix for this issue.

ghost commented 7 years ago

This error occurs whenever MediaElement hasn't buffered/loaded the media; MediaElement doesn't exactly work well: the issue is probably MediaElement's fault, especially as you said that you were unloading media players rapidly - the media probably hadn't loaded depending on the operation.