[英]Silverlight media player position problem
I'm facing a strange issue. 我面临一个奇怪的问题。 My application plays movies from specific 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: 这是分配前后的屏幕截图:
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). 虽然您可能会担心在这种情况下的小数毫秒差异,但您必须记住,视频每隔约33毫秒才会有一帧(使用标准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.
因此,除非您正在进行取证级别分析(在这种情况下MediaPlayer不是正确的工具),否则这比您应该需要的更准确。
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. 由于TimeSpan在内部使用Int64,因此不应该有任何舍入问题,我的猜测是MediaPlayer正在捕捉到最近的可用视频帧。
Although timespan exposes it's properties as ints I suspect that it's using a floating point value internally. 虽然timespan将它的属性暴露为int,但我怀疑它在内部使用浮点值。 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)
? 您是否尝试过检查从
TimeSpan.Equals(MediaPlayer.Position, oTimeSpan)
? I suspect this would indicate that they are equal. 我怀疑这表明他们是平等的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.