VLC.DotNet Control Hosted in WPF

孤街醉人 提交于 2020-01-07 06:26:09

问题


I have hosted the VLC.DotNet windows Control in a WindowsFormsHost element, inside a WPF window. 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.

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; 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.

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.

  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. Instead, it has the same size as the video itself.

Anyone has any particular ideas on why WPF is showing this strange behavior?

Any suggestions would be appreciated.

Thanks a lot folks.


回答1:


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! 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.

That was it!



来源:https://stackoverflow.com/questions/23322270/vlc-dotnet-control-hosted-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!