简体   繁体   English

Silverlight媒体播放器位置问题

[英]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.

相关问题 Silverlight Media Player的问题 - Problem with Silverlight Media Player Silverlight媒体播放器 - Silverlight media player 自动隐藏媒体控件SilverLight Player - Autohide Media Controls SilverLight Player Windows Media Player控件 - 获取/设置视频位置? - Windows Media Player control - get/set video position? 使用Windows Media Player SDK在特定位置停止视频 - Stop video at specific position using windows media player SDK 如何在C#silverlight Windows Mobile 7应用程序中快进快退我的媒体播放器? - How to fast forward rewind my media player in C# silverlight windows mobile 7 app? Microsoft Media Platform是否存在任何已知的兼容性问题:Player Framework(以前称为SMF)和Silverlight 5? - Are there any known compatibility issues with Microsoft Media Platform: Player Framework (formerly SMF) and Silverlight 5? Silverlight媒体格式兼容性 - Silverlight media format compatibility 如何通过Windows Media Player当前位置实时更新标签,而无需使用计时器 - How to update a label by windows media player current position live, without using timer 如何以帧而不是秒显示当前媒体播放器 position - UWP MediaPlayerElement - How to display current media player position in frames rather then seconds - UWP MediaPlayerElement
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM