Search code examples
c#wpflibvlclibvlcsharp

LibVLCSharp.WPF VideoView.Content (overlay) scrolling


I am trying to include VideoView with some overlay in a changing view (scrolling, resizing, etc.). The problem is, that the overlay stays in the same position. I've tried to fix it, I've searched for a solution, but I wasn't able to find or come up with anything. Is it possible to do this somehow?

In ordere to provide a demo, I have edited Example1.xaml and Example1.xaml.cs from the LibVLCSharp.WPF.Sample app in the following way:

Example1.xaml
...
<ScrollViewer>
    <StackPanel>
        <StackPanel Background="Blue" Height="300" Width="200"/>
        <uc:VideoView x:Name="VideoView" Width="200" Height="200"/>
        <StackPanel Background="Red" Height="300" Width="200"/>
    </StackPanel>
</ScrollViewer>
...

Example1.xaml.cs
...
public Example1()
{
    InitializeComponent();

    _controls = new Controls(this);
    VideoView.Content = _controls;
    VideoView.Height = 200;
}
...

This makes the window scrollable and should demonstrate the issue. The problem is, that the Start and Stop buttons don't scroll with the VideoView.

Unscrolled: Unscrolled Scrolled: Scrolled

Thanks in advance.


Solution

  • If you have followed the long history of "writing controls over a vlc view" in LibVLCSharp and Vlc.DotNet, and more broadly the question about "writing WPF control over a WinFormsHost", you know that it's all about hacks and tradeoffs.

    In short:

    • WPF has no performant way of displaying a video, so we need to create a WinFormsHost
    • Users wants to easily be able to put controls over the video. WPF can't do that easily (it's named the "airspace issue") and we tried to provide an out of the box solution, which is actually a hack and draws a window floating above.

    I think the issue lies in how we handle that floating window, and you should post an issue on code.videolan.org . Otherwise, you will need to reimplement the VideoView with your own fix