Problem with Silverlight Media Player Position

I got a strange problem. My application plays movies from certain positions, so even the position mentioned in milliseconds is important to me. I am assigning a position to a multimedia element, but it is showing the wrong frame. I do not know why the media player does not play from the position that I give.

Here is a sample code:

TimeSpan oTimeSpan = TimeSpan.FromMilliseconds(16800200); // This shows 04:40:00.2000000 MediaPlayer.Position = oTimeSpan; // But after assigning, value is 04:40:00.1990000 

Here is a screenshot before and after the appointment: alt text

alt text

Can someone tell me what I'm doing wrong here?

+6
c # wpf silverlight timespan
source share
2 answers

Although you may be worried about the difference in fractional milliseconds in this case, you should remember that the video will only have a frame every ~ 33 milliseconds or so (using the standard NTSC 29.97 FPS). Therefore, if you do not analyze the level of forensics (in which case MediaPlayer is not the right tool), this is more accuracy than you need.

Since TimeSpan uses Int64 internally and therefore should not have problems with rounding, I assume that MediaPlayer is snapped to the nearest available frame.

+3
source share

Although the timepan exposes its properties as ints, I suspect that it uses a floating point value inside. Such issues are related to how floating point values ​​are stored.

Have you tried to check what you get from TimeSpan.Equals(MediaPlayer.Position, oTimeSpan) ? I suspect that this will mean that they are equal.

+1
source share

All Articles