开发者

Silverlight media player position problem

I'm facing a strange issue. My application plays movies from spe开发者_Go百科cific positions, so even a position mentioned in milliseconds matters for me. I'm assigning a position to a media element but it's showing the wrong frame. I don't know why media player is not playing from the position that I'm giving.

Here is some 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 assigning:

Silverlight media player position problem

Silverlight media player position problem

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


While you maybe concerned about the fractional milliseconds difference in this case, you have to remember that video is only going to have a frame every ~33 milliseconds or so (using standard NTSC 29.97 FPS). So unless you are doing forensics level analysis(in which case MediaPlayer is not the right tool), that is more accuracy than you should need.

Since a TimeSpan uses Int64 internally and therefore should not have any rounding issues, my guess is that MediaPlayer is snapping to the closest video frame available.


Although timespan exposes it's properties as ints I suspect that it's using a floating point value internally. Such issues are due to the way floating point values are stored.

Have you tried checking what you get from TimeSpan.Equals(MediaPlayer.Position, oTimeSpan)? I suspect this would indicate that they are equal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜