简体   繁体   English

WPF中托管的VLC.DotNet控件

[英]VLC.DotNet Control Hosted in WPF

I have hosted the VLC.DotNet windows Control in a WindowsFormsHost element, inside a WPF window. 我已经在WPF窗口内的WindowsFormsHost元素中托管了VLC.DotNet窗口控件。 The reason behind doing this, instead of using Vlc.DotNet WPF control is because the performance of the WinForms version is twice better than the WPF version. 之所以这样做,而不是使用Vlc.DotNet WPF控件,是因为WinForms版本的性能是WPF版本的两倍。

Anyway, everything works fine, except for one annoying detail; 无论如何,除了一个烦人的细节,一切都很好。 When using the WinForms version inside a WinForms App , the rendered video will exactly fit the control ; WinForms应用程序中使用WinForms版本时,渲染的视频将完全适合控件 However, using the same control inside a WindowsFormsHost element, causes the video to be rendered as it's original size and not fitted to the control. 但是,在WindowsFormsHost元素内使用相同的控件会导致视频以其原始大小呈现,而不适合该控件。

There are 2 things to notice here : 这里有两件事要注意:

  1. The WinForms control is exactly the same, so in my opinion, this behavior could not be related to it. WinForms控件是完全相同的,因此在我看来,此行为与之无关。

  2. Using Spy++ I've managed to see when the control is used inside a WinForms App, the rectangle of the rendered video is exactly the same size as the rectangle of the Control itself, But when used in WPF App, the recatngle of the video (which is rendered by VLC and I have no control on it) is not the same size as the control. 使用Spy ++,我设法查看了何时在WinForms App中使用控件,渲染视频的矩形大小与Control本身的矩形大小完全相同,但是当在WPF App中使用时,视频的重响(由VLC渲染,但我没有控件)与控件的大小不同。 Instead, it has the same size as the video itself. 相反,它具有与视频本身相同的大小。

Anyone has any particular ideas on why WPF is showing this strange behavior? 关于WPF为什么显示这种奇怪行为,有人有什么特别的想法吗?

Any suggestions would be appreciated. 任何建议,将不胜感激。

Thanks a lot folks. 非常感谢大家。

Finally, I managed to find out what was causing the problem and resolved it! 最后,我设法找出导致问题的原因并解决了!

I should confess that the problem was not even remotely related to the first 2000 things that comes to mind in these situations! 我应该承认,在这些情况下,这个问题甚至与想到的头2000件事没有太大关系! Instead, it was related to the most ridiculous thing that never happened to catch my eye! 取而代之的是,这与从未发生过的最荒谬的事情有关! Well, as they say, it's always in the last place you look! 就像他们说的那样,它始终在您寻找的最后一个位置!

As weird as it may sound, the problem was related to video scaling! 听起来可能很奇怪,但问题与视频缩放有关! I needed to scale the video and apparently, when you set scaling in vlc, the video wont get fitted to container anymore. 我需要缩放视频,显然,当您在vlc中设置缩放比例时,视频将不再适合容器。

That was it! 就是这样!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM