如何在 WPF 中同步两个 MediaPlayer 或 MediaElement?
我正在尝试在 WPF 中实现一个系统,在两个屏幕上播放两个同步视频。我认为,如果我将两个相应的 MediaTimelines 捆绑到一个 ParallelTimeline 中,并从 ParallelTimeline 的时钟控制器控制时间线,则媒体时间线的时钟将从同一时钟驱动,从而同步播放。但事实并非如此,两者之间存在着巨大的延迟。有什么方法可以做到这一点吗?
谢谢
I am trying to implement a system in WPF that plays two synchronized videos on two screens. I thought that if I bundled the two corresponding MediaTimelines into a single ParallelTimeline and control the timelines from the clock controller of the ParallelTimeline the clocks of the media timelines would be driven from the same clock and thus play in sync. Only that is not the case, there is a huge delay between both. Is there some way of doing this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的两个 MediaTimelines 位于同一个情节提要中(听起来确实如此),您应该能够通过将 ParallelTimeline.SlipBehavior 更改为 SlipBehavior.Slip 来保持元素同步。如果故事板中的媒体元素遇到缓冲或加载延迟,此行为将“阻止”时间线的进展。
您可以在此处获取有关此行为的更多详细信息:
http://msdn.microsoft.com/en-us/library/cc304465。 ASPX
If your two MediaTimelines are in the same storyboard (and it sounds like they are), you should be able to keep the elements in sync by changing the ParallelTimeline.SlipBehavior to SlipBehavior.Slip. This behavior will "hold back" the progression of the timelines if a media element in the storyboard runs into buffering or loading delays.
You can get more details about this behavior here:
http://msdn.microsoft.com/en-us/library/cc304465.aspx